Index: doc/src/sgml/runtime.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/runtime.sgml,v
retrieving revision 1.183
diff -c -c -r1.183 runtime.sgml
*** doc/src/sgml/runtime.sgml	11 Jun 2003 18:01:13 -0000	1.183
--- doc/src/sgml/runtime.sgml	11 Jun 2003 20:54:40 -0000
***************
*** 1300,1305 ****
--- 1300,1321 ----
  
      <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: src/backend/parser/parse_relation.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/parser/parse_relation.c,v
retrieving revision 1.81
diff -c -c -r1.81 parse_relation.c
*** src/backend/parser/parse_relation.c	29 Apr 2003 22:13:10 -0000	1.81
--- src/backend/parser/parse_relation.c	11 Jun 2003 20:54:42 -0000
***************
*** 32,37 ****
--- 32,39 ----
  #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,1867 ****
  		}
  	}
  	if (foundInFromCl)
! 		elog(NOTICE, "Adding missing FROM-clause entry%s for table \"%s\"",
! 			 pstate->parentParseState != NULL ? " in subquery" : "",
! 			 relation->relname);
  }
--- 1863,1876 ----
  		}
  	}
  	if (foundInFromCl)
! 	{
! 		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: src/backend/utils/misc/guc.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/misc/guc.c,v
retrieving revision 1.130
diff -c -c -r1.130 guc.c
*** src/backend/utils/misc/guc.c	11 Jun 2003 18:49:00 -0000	1.130
--- src/backend/utils/misc/guc.c	11 Jun 2003 20:54:49 -0000
***************
*** 43,48 ****
--- 43,49 ----
  #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,559 ****
  		{"transaction_read_only", PGC_USERSET, GUC_NO_RESET_ALL}, &XactReadOnly,
  		false, NULL, NULL
  	},
  
  	{
  		{NULL, 0}, NULL, false, NULL, NULL
! 	}
  };
  
  
--- 551,565 ----
  		{"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,747 ****
--- 748,754 ----
  		0, 0, INT_MAX / 1000, NULL, NULL
  	},
  
+ 	/* End-of-list marker */
  	{
  		{NULL, 0}, NULL, 0, 0, 0, NULL, NULL
  	}
***************
*** 784,789 ****
--- 791,797 ----
  		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,951 ****
--- 954,960 ----
  		XLOG_sync_method_default, assign_xlog_sync_method, NULL
  	},
  
+ 	/* End-of-list marker */
  	{
  		{NULL, 0}, NULL, NULL, NULL, NULL
  	}
Index: src/backend/utils/misc/postgresql.conf.sample
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/misc/postgresql.conf.sample,v
retrieving revision 1.80
diff -c -c -r1.80 postgresql.conf.sample
*** src/backend/utils/misc/postgresql.conf.sample	11 Jun 2003 18:01:14 -0000	1.80
--- src/backend/utils/misc/postgresql.conf.sample	11 Jun 2003 20:54:49 -0000
***************
*** 208,210 ****
--- 208,211 ----
  #statement_timeout = 0		# 0 is disabled, in milliseconds
  #db_user_namespace = false
  #preload_libraries = ''
+ #add_missing_from = true
Index: src/bin/psql/tab-complete.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/psql/tab-complete.c,v
retrieving revision 1.78
diff -c -c -r1.78 tab-complete.c
*** src/bin/psql/tab-complete.c	11 Jun 2003 18:01:14 -0000	1.78
--- src/bin/psql/tab-complete.c	11 Jun 2003 20:54:52 -0000
***************
*** 492,497 ****
--- 492,498 ----
  		 * 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: src/include/parser/parse_relation.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/parser/parse_relation.h,v
retrieving revision 1.39
diff -c -c -r1.39 parse_relation.h
*** src/include/parser/parse_relation.h	4 Sep 2002 20:31:45 -0000	1.39
--- src/include/parser/parse_relation.h	11 Jun 2003 20:54:52 -0000
***************
*** 16,21 ****
--- 16,23 ----
  
  #include "parser/parse_node.h"
  
+ extern bool add_missing_from;
+ 
  extern RangeTblEntry *refnameRangeTblEntry(ParseState *pstate,
  					 const char *schemaname,
  					 const char *refname,
