| From: | Denis Hirn <denis(dot)hirn(at)uni-tuebingen(dot)de> | 
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org | 
| Subject: | [PATCH] Allow multiple recursive self-references | 
| Date: | 2021-03-23 13:03:44 | 
| Message-ID: | F4329B6F-6D84-4AC6-B205-D2B38BF15FBB@uni-tuebingen.de | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
Hey everyone,
As you know, Postgres currently supports SQL:1999 recursive common table
expressions, using WITH RECURSIVE. However, Postgres does not allow more than
one recursive self-reference in the recursive term. This restriction seems to be
unnecessary.
In this mail, I'd like to propose a patch that removes this restriction, and 
therefore allows the use of multiple self-references in the recursive term.
After the patch:
WITH RECURSIVE t(n) AS (
    VALUES(1)
  UNION ALL
    SELECT t.n+f.n
    FROM t, t AS f
    WHERE t.n < 100
) SELECT * FROM t;
  n
-----
   1
   2
   4
   8
  16
  32
  64
 128
(8 rows)
This feature deviates only slightly from the current WITH RECURSIVE, and 
requires very little changes (~10 loc). Any thoughts on this?
--
Denis Hirn
| Attachment | Content-Type | Size | 
|---|---|---|
| 0001-Allow-multiple-recursive-self-references.patch | application/octet-stream | 4.3 KB | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | gkokolatos | 2021-03-23 13:06:17 | Re: PATCH: Attempt to make dbsize a bit more consistent | 
| Previous Message | Amit Langote | 2021-03-23 12:53:18 | Re: Wired if-statement in gen_partprune_steps_internal |