mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Enhanced cycle mark values
Per SQL:202x draft, in the CYCLE clause of a recursive query, the cycle mark values can be of type boolean and can be omitted, in which case they default to TRUE and FALSE. Reviewed-by: Vik Fearing <vik@postgresfriends.org> Discussion: https://www.postgresql.org/message-id/flat/db80ceee-6f97-9b4a-8ee8-3ba0c58e5be2@2ndquadrant.com
This commit is contained in:
@@ -2349,14 +2349,13 @@ WITH RECURSIVE search_graph(id, link, data, depth) AS (
|
||||
SELECT g.id, g.link, g.data, sg.depth + 1
|
||||
FROM graph g, search_graph sg
|
||||
WHERE g.id = sg.link
|
||||
) <emphasis>CYCLE id SET is_cycle TO true DEFAULT false USING path</emphasis>
|
||||
) <emphasis>CYCLE id SET is_cycle USING path</emphasis>
|
||||
SELECT * FROM search_graph;
|
||||
</programlisting>
|
||||
and it will be internally rewritten to the above form. The
|
||||
<literal>CYCLE</literal> clause specifies first the list of columns to
|
||||
track for cycle detection, then a column name that will show whether a
|
||||
cycle has been detected, then two values to use in that column for the yes
|
||||
and no cases, and finally the name of another column that will track the
|
||||
cycle has been detected, and finally the name of another column that will track the
|
||||
path. The cycle and path columns will implicitly be added to the output
|
||||
rows of the CTE.
|
||||
</para>
|
||||
|
Reference in New Issue
Block a user