diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2021-02-27 08:11:14 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2021-02-27 08:13:24 +0100 |
commit | f4adc41c4f92cc91d507b19e397140c35bb9fd71 (patch) | |
tree | 387b6ecdd5e9b4547d887b73f01689aa954f177d /doc/src | |
parent | 4e90052c46c7751779ed83627676ed5e74ebe6d4 (diff) | |
download | postgresql-f4adc41c4f92cc91d507b19e397140c35bb9fd71.tar.gz postgresql-f4adc41c4f92cc91d507b19e397140c35bb9fd71.zip |
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
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/queries.sgml | 5 | ||||
-rw-r--r-- | doc/src/sgml/ref/select.sgml | 8 |
2 files changed, 7 insertions, 6 deletions
diff --git a/doc/src/sgml/queries.sgml b/doc/src/sgml/queries.sgml index 4741506eb56..bc0b3cc9fe1 100644 --- a/doc/src/sgml/queries.sgml +++ b/doc/src/sgml/queries.sgml @@ -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> diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml index eb8b5249518..ab911055994 100644 --- a/doc/src/sgml/ref/select.sgml +++ b/doc/src/sgml/ref/select.sgml @@ -74,7 +74,7 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="parameter">expression</replac <replaceable class="parameter">with_query_name</replaceable> [ ( <replaceable class="parameter">column_name</replaceable> [, ...] ) ] AS [ [ NOT ] MATERIALIZED ] ( <replaceable class="parameter">select</replaceable> | <replaceable class="parameter">values</replaceable> | <replaceable class="parameter">insert</replaceable> | <replaceable class="parameter">update</replaceable> | <replaceable class="parameter">delete</replaceable> ) [ SEARCH { BREADTH | DEPTH } FIRST BY <replaceable>column_name</replaceable> [, ...] SET <replaceable>search_seq_col_name</replaceable> ] - [ CYCLE <replaceable>column_name</replaceable> [, ...] SET <replaceable>cycle_mark_col_name</replaceable> TO <replaceable>cycle_mark_value</replaceable> DEFAULT <replaceable>cycle_mark_default</replaceable> USING <replaceable>cycle_path_col_name</replaceable> ] + [ CYCLE <replaceable>column_name</replaceable> [, ...] SET <replaceable>cycle_mark_col_name</replaceable> [ TO <replaceable>cycle_mark_value</replaceable> DEFAULT <replaceable>cycle_mark_default</replaceable> ] USING <replaceable>cycle_path_col_name</replaceable> ] TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ] </synopsis> @@ -302,8 +302,10 @@ TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ] been detected. <replaceable>cycle_mark_value</replaceable> and <replaceable>cycle_mark_default</replaceable> must be constants and they must be coercible to a common data type, and the data type must have an - inequality operator. (The SQL standard requires that they be character - strings, but PostgreSQL does not require that.) Furthermore, a column + inequality operator. (The SQL standard requires that they be Boolean + constants or character strings, but PostgreSQL does not require that.) By + default, <literal>TRUE</literal> and <literal>FALSE</literal> (of type + <type>boolean</type>) are used. Furthermore, a column named <replaceable>cycle_path_col_name</replaceable> will be added to the result column list of the <literal>WITH</literal> query. This column is used internally for tracking visited rows. See <xref |