Adjust parser so that POSTQUEL-style implicit RTEs are stored with

inFromCl true, meaning that they will list out as explicit RTEs if they
are in a view or rule.  Update comments about inFromCl to reflect the way
it's now actually used.  Per recent discussion.
This commit is contained in:
Tom Lane 2005-10-26 19:21:55 +00:00
parent 7d9ff58b22
commit fc5894bf77
3 changed files with 27 additions and 13 deletions

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.393 2005/10/25 17:54:30 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.394 2005/10/26 19:21:53 tgl Exp $
Typical markup: Typical markup:
@ -268,9 +268,19 @@ pg_[A-Za-z0-9_] <application>
</para> </para>
<para> <para>
By default, we now generate an error if a table is used in a query By default, we now generate an error if a table is used in a query
without a <command>FROM</> reference. The old behavior is still without a <literal>FROM</> reference. The old behavior is still
available, but the parameter must be set to 'true' to obtain it. available, but the parameter must be set to 'true' to obtain it.
</para> </para>
<para>
It may be necessary to set <varname>add_missing_from</> to true
in order to load an existing dump file, if the dump contains any
views or rules created using the implicit-<literal>FROM</> syntax.
This should be a one-time annoyance, because
<productname>PostgreSQL</productname> 8.1 will convert
such views and rules to standard explicit-<literal>FROM</> syntax.
Subsequent dumps will therefore not have the problem.
</para>
</listitem> </listitem>
<listitem> <listitem>

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.115 2005/10/15 02:49:22 momjian Exp $ * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.116 2005/10/26 19:21:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1005,7 +1005,13 @@ addImplicitRTE(ParseState *pstate, RangeVar *relation)
{ {
RangeTblEntry *rte; RangeTblEntry *rte;
rte = addRangeTableEntry(pstate, relation, NULL, false, false); /*
* Note that we set inFromCl true, so that the RTE will be listed
* explicitly if the parsetree is ever decompiled by ruleutils.c.
* This provides a migration path for views/rules that were originally
* written with implicit-RTE syntax.
*/
rte = addRangeTableEntry(pstate, relation, NULL, false, true);
/* Add to joinlist and relnamespace, but not varnamespace */ /* Add to joinlist and relnamespace, but not varnamespace */
addRTEtoQuery(pstate, rte, true, true, false); addRTEtoQuery(pstate, rte, true, true, false);
warnAutoRange(pstate, relation); warnAutoRange(pstate, relation);

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.291 2005/10/15 02:49:45 momjian Exp $ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.292 2005/10/26 19:21:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -476,14 +476,12 @@ typedef struct LockingClause
* RTEs other than RTE_RELATION entries. * RTEs other than RTE_RELATION entries.
* *
* inFromCl marks those range variables that are listed in the FROM clause. * inFromCl marks those range variables that are listed in the FROM clause.
* In SQL, the query can only refer to range variables listed in the * It's false for RTEs that are added to a query behind the scenes, such
* FROM clause, but POSTQUEL allows you to refer to tables not listed, * as the NEW and OLD variables for a rule, or the subqueries of a UNION.
* in which case a range table entry will be generated. We still support * This flag is not used anymore during parsing, since the parser now uses
* this POSTQUEL feature, although there is some doubt whether it's * a separate "namespace" data structure to control visibility, but it is
* convenient or merely confusing. The flag is not actually needed * needed by ruleutils.c to determine whether RTEs should be shown in
* anymore during parsing, since the parser uses a separate "namespace" * decompiled queries.
* data structure to control visibility, but it is needed by ruleutils.c
* to determine whether RTEs should be included in decompiled queries.
* *
* requiredPerms and checkAsUser specify run-time access permissions * requiredPerms and checkAsUser specify run-time access permissions
* checks to be performed at query startup. The user must have *all* * checks to be performed at query startup. The user must have *all*