OSDN Git Service

Add add_missing_from GUC variable.
authorBruce Momjian <bruce@momjian.us>
Wed, 11 Jun 2003 22:13:22 +0000 (22:13 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 11 Jun 2003 22:13:22 +0000 (22:13 +0000)
Nigel J. Andrews

doc/TODO
doc/src/sgml/runtime.sgml
src/backend/parser/parse_relation.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample
src/bin/psql/tab-complete.c
src/include/parser/parse_relation.h

index f45e79a..063d803 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -1,6 +1,6 @@
 TODO list for PostgreSQL
 ========================
-Last updated:          Wed Jun 11 17:38:50 EDT 2003
+Last updated:          Wed Jun 11 18:09:42 EDT 2003
 
 Current maintainer:    Bruce Momjian (pgman@candle.pha.pa.us)
 
index f90800a..27feffd 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.183 2003/06/11 18:01:13 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.184 2003/06/11 22:13:21 momjian Exp $
 -->
 
 <Chapter Id="runtime">
@@ -1300,6 +1300,22 @@ SET ENABLE_SEQSCAN TO OFF;
 
     <variablelist>
      <varlistentry>
+      <term><varname>ADD_MISSING_FROM</varname> (<type>boolean</type>)</term>
+      <listitem>
+       <para>
+        This parameter controls whether a relation referenced in a query but
+        missing from the FROM clause should be automatically added to
+        the FROM clause. If enabled (the default), the notice
+        <literal>Adding missing FROM-clause entry for table "tablename"</literal>
+        is generated if a relation is automatically added. If not enabled,
+        an error is raised when an additional extra relation is required.
+        For SQL standards compliance, this value should be set to 
+        <literal>false</>.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term><varname>AUSTRALIAN_TIMEZONES</varname> (<type>boolean</type>)</term>
       <indexterm><primary>Australian time zones</></>
       <listitem>
index 41fd98f..59a3627 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.81 2003/04/29 22:13:10 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.82 2003/06/11 22:13:22 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -32,6 +32,8 @@
 #include "utils/lsyscache.h"
 #include "utils/syscache.h"
 
+/* GUC parameter */
+bool add_missing_from;
 
 static Node *scanNameSpaceForRefname(ParseState *pstate, Node *nsnode,
                                                const char *refname);
@@ -1861,7 +1863,14 @@ warnAutoRange(ParseState *pstate, RangeVar *relation)
                }
        }
        if (foundInFromCl)
-               elog(NOTICE, "Adding missing FROM-clause entry%s for table \"%s\"",
-                        pstate->parentParseState != NULL ? " in subquery" : "",
-                        relation->relname);
+       {
+               if (add_missing_from)
+                       elog(NOTICE, "Adding missing FROM-clause entry%s for table \"%s\"",
+                                pstate->parentParseState != NULL ? " in subquery" : "",
+                                relation->relname);
+               else
+                       elog(ERROR, "Missing FROM-clause entry%s for table \"%s\"",
+                                pstate->parentParseState != NULL ? " in subquery" : "",
+                                relation->relname);
+       }
 }
index 33f8cf4..f1582b8 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.130 2003/06/11 18:49:00 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.131 2003/06/11 22:13:22 momjian Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -43,6 +43,7 @@
 #include "optimizer/paths.h"
 #include "optimizer/prep.h"
 #include "parser/parse_expr.h"
+#include "parser/parse_relation.h"
 #include "storage/fd.h"
 #include "storage/freespace.h"
 #include "storage/lock.h"
@@ -550,10 +551,15 @@ static struct config_bool
                {"transaction_read_only", PGC_USERSET, GUC_NO_RESET_ALL}, &XactReadOnly,
                false, NULL, NULL
        },
+       {
+               {"add_missing_from", PGC_USERSET}, &add_missing_from,
+               true, NULL, NULL
+       },
 
+       /* End-of-list marker */
        {
                {NULL, 0}, NULL, false, NULL, NULL
-       }
+       },
 };
 
 
@@ -742,6 +748,7 @@ static struct config_int
                0, 0, INT_MAX / 1000, NULL, NULL
        },
 
+       /* End-of-list marker */
        {
                {NULL, 0}, NULL, 0, 0, 0, NULL, NULL
        }
@@ -784,6 +791,7 @@ static struct config_real
                0.5, 0.0, 1.0, assign_random_seed, show_random_seed
        },
 
+       /* End-of-list marker */
        {
                {NULL, 0}, NULL, 0.0, 0.0, 0.0, NULL, NULL
        }
@@ -946,6 +954,7 @@ static struct config_string
                XLOG_sync_method_default, assign_xlog_sync_method, NULL
        },
 
+       /* End-of-list marker */
        {
                {NULL, 0}, NULL, NULL, NULL, NULL
        }
index 7785838..594c230 100644 (file)
 #statement_timeout = 0         # 0 is disabled, in milliseconds
 #db_user_namespace = false
 #preload_libraries = ''
+#add_missing_from = true
index 0946bab..d1e1272 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000-2002 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.78 2003/06/11 18:01:14 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.79 2003/06/11 22:13:22 momjian Exp $
  */
 
 /*----------------------------------------------------------------------
@@ -492,6 +492,7 @@ psql_completion(char *text, int start, int end)
                 * the rest should match USERSET and possibly SUSET entries in
                 * backend/utils/misc/guc.c.
                 */
+               "add_missing_from",
                "australian_timezones",
                "client_encoding",
                "client_min_messages",
index 2259851..9fba185 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parse_relation.h,v 1.39 2002/09/04 20:31:45 momjian Exp $
+ * $Id: parse_relation.h,v 1.40 2003/06/11 22:13:22 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -16,6 +16,8 @@
 
 #include "parser/parse_node.h"
 
+extern bool add_missing_from;
+
 extern RangeTblEntry *refnameRangeTblEntry(ParseState *pstate,
                                         const char *schemaname,
                                         const char *refname,