title: Postgres ltree module, update id of a node with all the children related paths
body: <p>I have the following simple table:</p>
  
  <pre><code>create table nodes(
      id text primary key,
      path ltree
  );
  </code></pre>
  
  <p>lets say I put some data to the table:</p>
  
  <pre><code>insert into nodes (id, path) values ('A', 'A');
  insert into nodes (id, path) values ('B', 'A.B');
  insert into nodes (id, path) values ('C', 'A.C');
  </code></pre>
  
  <p>so that the tree looks like:</p>
  
  <pre><code>       A
  
    /          \
  
  B             C
  </code></pre>
  
  <p>Now I want to rename id of <code>A</code> to, lets say, <code>X</code> so that the tree </p>
  
  <pre><code>       X
  
    /          \
  
  B             C
  </code></pre>
  
  <p>and the table would look like </p>
  
  <pre><code>insert into nodes (id, path) values ('X', 'X');
  insert into nodes (id, path) values ('B', 'X.B');
  insert into nodes (id, path) values ('C', 'X.C');
  </code></pre>
  
  <p>Could someone please give a hint - is that possible to do with a single query? </p>
  
  <p>Would appreciate any help, thanks</p>