title: postgres recursive view returning multple rows per input row
body: <p><strong>I want a recursive view which reports all children of a given group, one per row.</strong> </p>
  
  <p>I've tried the basic examples from postgres documentation, and modified to try and return multiple rows per recursive step, but I keep ending up with infinite loops.</p>
  
  <p><strong>Sample Data</strong></p>
  
  <pre><code>create table groups (
         group_id varchar,
         parent_id varchar
         );
  
  insert into groups (group_id, parent_id) values
         ('A',NULL),
         ('B','A'),
         ('C','B'),
         ('D','C'),
         ('E','A')
         ;
  
  --      A
  --    /   \
  --   E     B
  --          \
  --           C
  --            \
  --             D
  
  select * from groups;
  
  group_id |parent_id 
  ---------|----------
  A        |[NULL]    
  B        |A         
  C        |B         
  D        |C
  E        |A
  </code></pre>
  
  <p>I want a recursive view which reports each child of a given group, one per row.</p>
  
  <p><strong>Intended Output</strong> </p>
  
  <p>The vertical white-space is just for clarity.</p>
  
  <pre><code>select * from group_recursive;
  
  group_id | parent_id | all_children_ids
  ---------|-----------|-----------------
  A        | NULL      | A        
  
  B        | A         | B
  B        | A         | A
  
  E        | A         | E
  E        | A         | A
  
  C        | B         | C
  C        | B         | B
  C        | B         | A
  
  D        | C         | D
  D        | C         | C
  D        | C         | B
  D        | C         | A
  
  select * from group_recursive where all_children_ids = 'A';
  A        | NULL      | A
  B        | A         | A
  E        | A         | A
  C        | B         | A
  D        | C         | A
  
  select * from group_recursive where all_children_ids = 'B';
  B        | A         | B
  C        | B         | B
  D        | C         | B
  
  select * from group_recursive where all_children_ids = 'D';
  D        | C         | D
  </code></pre>
  
  <p>I have to assume this is possible as a view, but if necessary I could change to defining a function or something.</p>
  
  <p>Any help is appreciated, thanks!</p>