Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b987294

Browse files
committed
Improve documentation for CREATE RECURSIVE VIEW.
It was perhaps not entirely clear that internal self-references shouldn't be schema-qualified even if the view name is written with a schema. Spell it out. Discussion: <[email protected]>
1 parent 4f87f76 commit b987294

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

doc/src/sgml/ref/create_view.sgml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] [ RECURSIVE ] VIEW <replaceable class
8787
<para>
8888
Creates a recursive view. The syntax
8989
<synopsis>
90-
CREATE RECURSIVE VIEW <replaceable>name</> (<replaceable>columns</>) AS SELECT <replaceable>...</>;
90+
CREATE RECURSIVE VIEW [ <replaceable>schema</> . ] <replaceable>view_name</> (<replaceable>column_names</>) AS SELECT <replaceable>...</>;
9191
</synopsis>
9292
is equivalent to
9393
<synopsis>
94-
CREATE VIEW <replaceable>name</> AS WITH RECURSIVE <replaceable>name</> (<replaceable>columns</>) AS (SELECT <replaceable>...</>) SELECT <replaceable>columns</> FROM <replaceable>name</>;
94+
CREATE VIEW [ <replaceable>schema</> . ] <replaceable>view_name</> AS WITH RECURSIVE <replaceable>view_name</> (<replaceable>column_names</>) AS (SELECT <replaceable>...</>) SELECT <replaceable>column_names</> FROM <replaceable>view_name</>;
9595
</synopsis>
96-
A view column list must be specified for a recursive view.
96+
A view column name list must be specified for a recursive view.
9797
</para>
9898
</listitem>
9999
</varlistentry>
@@ -461,11 +461,16 @@ CREATE VIEW comedies AS
461461
<para>
462462
Create a recursive view consisting of the numbers from 1 to 100:
463463
<programlisting>
464-
CREATE RECURSIVE VIEW nums_1_100 (n) AS
464+
CREATE RECURSIVE VIEW public.nums_1_100 (n) AS
465465
VALUES (1)
466466
UNION ALL
467467
SELECT n+1 FROM nums_1_100 WHERE n < 100;
468-
</programlisting></para>
468+
</programlisting>
469+
Notice that although the recursive view's name is schema-qualified in this
470+
<command>CREATE</>, its internal self-reference is not schema-qualified.
471+
This is because the implicitly-created CTE's name cannot be
472+
schema-qualified.
473+
</para>
469474
</refsect1>
470475

471476
<refsect1>

0 commit comments

Comments
 (0)