SEARCH and CYCLE clauses

Peter Eisentraut <peter.eisentraut@2ndquadrant.com>

From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-05-20T11:46:18Z
Lists: pgsql-hackers

Attachments

I have implemented the SEARCH and CYCLE clauses.

This is standard SQL syntax attached to a recursive CTE to compute a 
depth- or breadth-first ordering and cycle detection, respectively. 
This is just convenience syntax for what you can already do manually. 
The original discussion about recursive CTEs briefly mentioned these as 
something to do later but then it was never mentioned again.

SQL specifies these in terms of syntactic transformations, and so that's 
how I have implemented them also, mainly in the rewriter.

I have successfully tested this against examples I found online that 
were aimed at DB2.

The contained documentation and the code comment in rewriteHandler.c 
explain the details.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Commits

  1. Enhanced cycle mark values

  2. SEARCH and CYCLE clauses

  3. doc: Expand recursive query documentation

  4. Adjust cycle detection examples and tests