Skip to content

Commit 240dc5c

Browse files
committed
Add add_missing_from GUC variable.
Nigel J. Andrews
1 parent 9ffdd91 commit 240dc5c

File tree

7 files changed

+48
-10
lines changed

7 files changed

+48
-10
lines changed

doc/TODO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
TODO list for PostgreSQL
22
========================
3-
Last updated: Wed Jun 11 17:38:50 EDT 2003
3+
Last updated: Wed Jun 11 18:09:42 EDT 2003
44

55
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
66

doc/src/sgml/runtime.sgml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.183 2003/06/11 18:01:13 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.184 2003/06/11 22:13:21 momjian Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -1299,6 +1299,22 @@ SET ENABLE_SEQSCAN TO OFF;
12991299
<title>General Operation</title>
13001300

13011301
<variablelist>
1302+
<varlistentry>
1303+
<term><varname>ADD_MISSING_FROM</varname> (<type>boolean</type>)</term>
1304+
<listitem>
1305+
<para>
1306+
This parameter controls whether a relation referenced in a query but
1307+
missing from the FROM clause should be automatically added to
1308+
the FROM clause. If enabled (the default), the notice
1309+
<literal>Adding missing FROM-clause entry for table "tablename"</literal>
1310+
is generated if a relation is automatically added. If not enabled,
1311+
an error is raised when an additional extra relation is required.
1312+
For SQL standards compliance, this value should be set to
1313+
<literal>false</>.
1314+
</para>
1315+
</listitem>
1316+
</varlistentry>
1317+
13021318
<varlistentry>
13031319
<term><varname>AUSTRALIAN_TIMEZONES</varname> (<type>boolean</type>)</term>
13041320
<indexterm><primary>Australian time zones</></>

src/backend/parser/parse_relation.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.81 2003/04/29 22:13:10 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.82 2003/06/11 22:13:22 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -32,6 +32,8 @@
3232
#include "utils/lsyscache.h"
3333
#include "utils/syscache.h"
3434

35+
/* GUC parameter */
36+
bool add_missing_from;
3537

3638
static Node *scanNameSpaceForRefname(ParseState *pstate, Node *nsnode,
3739
const char *refname);
@@ -1861,7 +1863,14 @@ warnAutoRange(ParseState *pstate, RangeVar *relation)
18611863
}
18621864
}
18631865
if (foundInFromCl)
1864-
elog(NOTICE, "Adding missing FROM-clause entry%s for table \"%s\"",
1865-
pstate->parentParseState != NULL ? " in subquery" : "",
1866-
relation->relname);
1866+
{
1867+
if (add_missing_from)
1868+
elog(NOTICE, "Adding missing FROM-clause entry%s for table \"%s\"",
1869+
pstate->parentParseState != NULL ? " in subquery" : "",
1870+
relation->relname);
1871+
else
1872+
elog(ERROR, "Missing FROM-clause entry%s for table \"%s\"",
1873+
pstate->parentParseState != NULL ? " in subquery" : "",
1874+
relation->relname);
1875+
}
18671876
}

src/backend/utils/misc/guc.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.130 2003/06/11 18:49:00 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.131 2003/06/11 22:13:22 momjian Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -43,6 +43,7 @@
4343
#include "optimizer/paths.h"
4444
#include "optimizer/prep.h"
4545
#include "parser/parse_expr.h"
46+
#include "parser/parse_relation.h"
4647
#include "storage/fd.h"
4748
#include "storage/freespace.h"
4849
#include "storage/lock.h"
@@ -550,10 +551,15 @@ static struct config_bool
550551
{"transaction_read_only", PGC_USERSET, GUC_NO_RESET_ALL}, &XactReadOnly,
551552
false, NULL, NULL
552553
},
554+
{
555+
{"add_missing_from", PGC_USERSET}, &add_missing_from,
556+
true, NULL, NULL
557+
},
553558

559+
/* End-of-list marker */
554560
{
555561
{NULL, 0}, NULL, false, NULL, NULL
556-
}
562+
},
557563
};
558564

559565

@@ -742,6 +748,7 @@ static struct config_int
742748
0, 0, INT_MAX / 1000, NULL, NULL
743749
},
744750

751+
/* End-of-list marker */
745752
{
746753
{NULL, 0}, NULL, 0, 0, 0, NULL, NULL
747754
}
@@ -784,6 +791,7 @@ static struct config_real
784791
0.5, 0.0, 1.0, assign_random_seed, show_random_seed
785792
},
786793

794+
/* End-of-list marker */
787795
{
788796
{NULL, 0}, NULL, 0.0, 0.0, 0.0, NULL, NULL
789797
}
@@ -946,6 +954,7 @@ static struct config_string
946954
XLOG_sync_method_default, assign_xlog_sync_method, NULL
947955
},
948956

957+
/* End-of-list marker */
949958
{
950959
{NULL, 0}, NULL, NULL, NULL, NULL
951960
}

src/backend/utils/misc/postgresql.conf.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,4 @@
208208
#statement_timeout = 0 # 0 is disabled, in milliseconds
209209
#db_user_namespace = false
210210
#preload_libraries = ''
211+
#add_missing_from = true

src/bin/psql/tab-complete.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000-2002 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.78 2003/06/11 18:01:14 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.79 2003/06/11 22:13:22 momjian Exp $
77
*/
88

99
/*----------------------------------------------------------------------
@@ -492,6 +492,7 @@ psql_completion(char *text, int start, int end)
492492
* the rest should match USERSET and possibly SUSET entries in
493493
* backend/utils/misc/guc.c.
494494
*/
495+
"add_missing_from",
495496
"australian_timezones",
496497
"client_encoding",
497498
"client_min_messages",

src/include/parser/parse_relation.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: parse_relation.h,v 1.39 2002/09/04 20:31:45 momjian Exp $
10+
* $Id: parse_relation.h,v 1.40 2003/06/11 22:13:22 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -16,6 +16,8 @@
1616

1717
#include "parser/parse_node.h"
1818

19+
extern bool add_missing_from;
20+
1921
extern RangeTblEntry *refnameRangeTblEntry(ParseState *pstate,
2022
const char *schemaname,
2123
const char *refname,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy