mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	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: <871sznz69m.fsf@metapensiero.it>
This commit is contained in:
		@@ -87,13 +87,13 @@ CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] [ RECURSIVE ] VIEW <replaceable class
 | 
				
			|||||||
     <para>
 | 
					     <para>
 | 
				
			||||||
      Creates a recursive view.  The syntax
 | 
					      Creates a recursive view.  The syntax
 | 
				
			||||||
<synopsis>
 | 
					<synopsis>
 | 
				
			||||||
CREATE RECURSIVE VIEW <replaceable>name</> (<replaceable>columns</>) AS SELECT <replaceable>...</>;
 | 
					CREATE RECURSIVE VIEW [ <replaceable>schema</> . ] <replaceable>view_name</> (<replaceable>column_names</>) AS SELECT <replaceable>...</>;
 | 
				
			||||||
</synopsis>
 | 
					</synopsis>
 | 
				
			||||||
      is equivalent to
 | 
					      is equivalent to
 | 
				
			||||||
<synopsis>
 | 
					<synopsis>
 | 
				
			||||||
CREATE VIEW <replaceable>name</> AS WITH RECURSIVE <replaceable>name</> (<replaceable>columns</>) AS (SELECT <replaceable>...</>) SELECT <replaceable>columns</> FROM <replaceable>name</>;
 | 
					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</>;
 | 
				
			||||||
</synopsis>
 | 
					</synopsis>
 | 
				
			||||||
      A view column list must be specified for a recursive view.
 | 
					      A view column name list must be specified for a recursive view.
 | 
				
			||||||
     </para>
 | 
					     </para>
 | 
				
			||||||
    </listitem>
 | 
					    </listitem>
 | 
				
			||||||
   </varlistentry>
 | 
					   </varlistentry>
 | 
				
			||||||
@@ -462,11 +462,16 @@ CREATE VIEW comedies AS
 | 
				
			|||||||
  <para>
 | 
					  <para>
 | 
				
			||||||
   Create a recursive view consisting of the numbers from 1 to 100:
 | 
					   Create a recursive view consisting of the numbers from 1 to 100:
 | 
				
			||||||
<programlisting>
 | 
					<programlisting>
 | 
				
			||||||
CREATE RECURSIVE VIEW nums_1_100 (n) AS
 | 
					CREATE RECURSIVE VIEW public.nums_1_100 (n) AS
 | 
				
			||||||
    VALUES (1)
 | 
					    VALUES (1)
 | 
				
			||||||
UNION ALL
 | 
					UNION ALL
 | 
				
			||||||
    SELECT n+1 FROM nums_1_100 WHERE n < 100;
 | 
					    SELECT n+1 FROM nums_1_100 WHERE n < 100;
 | 
				
			||||||
</programlisting></para>
 | 
					</programlisting>
 | 
				
			||||||
 | 
					   Notice that although the recursive view's name is schema-qualified in this
 | 
				
			||||||
 | 
					   <command>CREATE</>, its internal self-reference is not schema-qualified.
 | 
				
			||||||
 | 
					   This is because the implicitly-created CTE's name cannot be
 | 
				
			||||||
 | 
					   schema-qualified.
 | 
				
			||||||
 | 
					  </para>
 | 
				
			||||||
 </refsect1>
 | 
					 </refsect1>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 <refsect1>
 | 
					 <refsect1>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user