diff --git a/doc/TODO b/doc/TODO index f45e79a661..063d803f31 100644 --- 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) diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index f90800ab5e..27feffde8b 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -1,5 +1,5 @@ @@ -1299,6 +1299,22 @@ SET ENABLE_SEQSCAN TO OFF; General Operation + + ADD_MISSING_FROM (boolean) + + + 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 + Adding missing FROM-clause entry for table "tablename" + 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 + false. + + + + AUSTRALIAN_TIMEZONES (boolean) Australian time zones diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index 41fd98fc07..59a362726d 100644 --- a/src/backend/parser/parse_relation.c +++ b/src/backend/parser/parse_relation.c @@ -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); + } } diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 33f8cf493f..f1582b8c5b 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut . * * 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 } diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 77858388c3..594c230a76 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -208,3 +208,4 @@ #statement_timeout = 0 # 0 is disabled, in milliseconds #db_user_namespace = false #preload_libraries = '' +#add_missing_from = true diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 0946bab9cd..d1e1272a32 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -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", diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h index 225985192b..9fba1857c9 100644 --- a/src/include/parser/parse_relation.h +++ b/src/include/parser/parse_relation.h @@ -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,