Re: [PATCH] Allow multiple recursive self-references

From: Denis Hirn <denis(dot)hirn(at)uni-tuebingen(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pantelis Theodosiou <ypercube(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Allow multiple recursive self-references
Date: 2021-03-31 13:31:29
Message-ID: B8715F3D-81D1-4033-A195-413EE5CC5F05@uni-tuebingen.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Based on Toms feedback, and due to the fact that SQL:2021 forbids
non-linear recursion, version 2 of the patch allows only linear
recursion. Therefore, later SQL committee decisions on non-linear
recursion should not be problematic.

> [LIN] PostgreSQL does not allow multiple references to the recursive
> common table, even if the recursion is LINEAR. Plenty of examples
> of such queries are found in the documentation of established RDBMSs,
> among these IBM Db2 and MS SQL Server:
>
> - https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/sqlp/rbafyrecursivequeries.htm#d60691e2455 <https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/sqlp/rbafyrecursivequeries.htm#d60691e2455>
> (example "Two tables used for recursion using recursive common
> table expressions")

See the gist at [1] below for SQL code that features multiple (yet linear)
recursive references. A patched PostgreSQL runs this query as expected.

Best wishes,
--Denis and Torsten

[1] https://gist.github.com/kryonix/73d77d3eaa5a15b3a4bdb7d590fa1253 <https://gist.github.com/kryonix/73d77d3eaa5a15b3a4bdb7d590fa1253>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Steele 2021-03-31 13:33:25 Re: invalid data in file backup_label problem on windows
Previous Message Sait Talha Nisanci 2021-03-31 13:26:34 Re: Crash in record_type_typmod_compare