Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb4b7a0

Browse files
author
Neil Conway
committed
Change the default setting of "add_missing_from" to false. This has been
the long-term plan for this behavior for quite some time, but it is onlypossible now that DELETE has a USING clause so that the user can joinother tables in a DELETE statement without relying on this behavior.
1 parentf53cd94 commiteb4b7a0

File tree

6 files changed

+39
-56
lines changed

6 files changed

+39
-56
lines changed

‎doc/src/sgml/ref/delete.sgml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/delete.sgml,v 1.23 2005/04/07 01:51:37 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/delete.sgml,v 1.24 2005/04/08 00:59:58 neilc Exp $
33
PostgreSQL documentation
44
-->
55

@@ -148,12 +148,6 @@ DELETE FROM films
148148
In some cases the join style is easier to write or faster to
149149
execute than the sub-select style.
150150
</para>
151-
152-
<para>
153-
If <varname>add_missing_from</varname> is enabled, any relations
154-
mentioned in the <literal>WHERE</literal> condition will be
155-
implicitly added to the <literal>USING</literal> clause.
156-
</para>
157151
</refsect1>
158152

159153
<refsect1>

‎doc/src/sgml/ref/select.sgml

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.82 2005/03/10 23:21:20 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.83 2005/04/08 00:59:58 neilc Exp $
33
PostgreSQL documentation
44
-->
55

@@ -1011,42 +1011,21 @@ SELECT 2+2;
10111011
</para>
10121012

10131013
<para>
1014-
A less obvious use is to abbreviate a normal
1015-
<command>SELECT</command> from tables:
1014+
Note that if a <literal>FROM</literal> clause is not specified,
1015+
the query cannot reference any database tables. For example, the
1016+
following query is invalid:
10161017
<programlisting>
10171018
SELECT distributors.* WHERE distributors.name = 'Westward';
1018-
1019-
did | name
1020-
-----+----------
1021-
108 | Westward
1022-
</programlisting>
1023-
This works because an implicit <literal>FROM</literal> item is
1024-
added for each table that is referenced in other parts of the
1025-
<command>SELECT</command> statement but not mentioned in
1026-
<literal>FROM</literal>.
1027-
</para>
1028-
1029-
<para>
1030-
While this is a convenient shorthand, it's easy to misuse. For
1031-
example, the command
1032-
<programlisting>
1033-
SELECT distributors.* FROM distributors d;
1034-
</programlisting>
1035-
is probably a mistake; most likely the user meant
1036-
<programlisting>
1037-
SELECT d.* FROM distributors d;
1038-
</programlisting>
1039-
rather than the unconstrained join
1040-
<programlisting>
1041-
SELECT distributors.* FROM distributors d, distributors distributors;
10421019
</programlisting>
1043-
that he will actually get. To help detect this sort of mistake,
1044-
<productname>PostgreSQL</productname> will warn if the
1045-
implicit-<literal>FROM</literal> feature is used in a
1046-
<command>SELECT</command> statement that also contains an explicit
1047-
<literal>FROM</literal> clause. Also, it is possible to disable
1048-
the implicit-<literal>FROM</literal> feature by setting the
1049-
<xref linkend="guc-add-missing-from"> parameter to false.
1020+
<productname>PostgreSQL</productname> releases prior to
1021+
8.1 would accept queries of this form, and add an implicit entry
1022+
to the query's <literal>FROM</literal> clause for each table
1023+
referenced by the query. This is no longer the default behavior,
1024+
because it does not comply with the SQL standard, and is
1025+
considered by many to be error-prone. For compatibility with
1026+
applications that rely on this behavior the <xref
1027+
linkend="guc-add-missing-from"> configuration variable can be
1028+
enabled.
10501029
</para>
10511030
</refsect2>
10521031

‎doc/src/sgml/ref/show.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/show.sgml,v 1.37 2005/01/04 03:58:16 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/show.sgml,v 1.38 2005/04/08 00:59:58 neilc Exp $
33
PostgreSQL documentation
44
-->
55

@@ -166,7 +166,7 @@ SHOW geqo;
166166
SHOW ALL;
167167
name | setting
168168
--------------------------------+----------------------------------------------
169-
add_missing_from |on
169+
add_missing_from |off
170170
archive_command | unset
171171
australian_timezones | off
172172
.

‎doc/src/sgml/runtime.sgml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.312 2005/03/29 03:01:29 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.313 2005/04/08 00:59:57 neilc Exp $
33
-->
44

55
<chapter Id="runtime">
@@ -3553,15 +3553,25 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
35533553
</indexterm>
35543554
<listitem>
35553555
<para>
3556-
When <literal>true</>, tables that are referenced by a query will be
3557-
automatically added to the <literal>FROM</> clause if not already
3558-
present. The default is <literal>true</> for compatibility with
3559-
previous releases of <productname>PostgreSQL</>. However, this
3560-
behavior is not SQL-standard, and many people dislike it because it
3561-
can mask mistakes (such as referencing a table where you should have
3562-
referenced its alias). Set to <literal>false</> for the SQL-standard
3563-
behavior of rejecting references to tables that are not listed in
3564-
<literal>FROM</>.
3556+
When <literal>true</>, tables that are referenced by a query
3557+
will be automatically added to the <literal>FROM</> clause if
3558+
not already present. This behavior does not comply with the
3559+
SQL standard and many people dislike it because it can mask
3560+
mistakes (such as referencing a table where you should have
3561+
referenced its alias). The default is <literal>false</>. This
3562+
variable can be enabled for compatibility with releases of
3563+
<productname>PostgreSQL</> prior to 8.1, where this behavior
3564+
was allowed by default.
3565+
</para>
3566+
3567+
<para>
3568+
Note that even when this variable is enabled, a warning
3569+
message will be emitted for each implicit <literal>FROM</>
3570+
entry referenced by a query. Users are encouraged to update
3571+
their applications to not rely on this behavior, by adding all
3572+
tables referenced by a query to the query's <literal>FROM</>
3573+
clause (or its <literal>USING</> clause in the case of
3574+
<command>DELETE</>).
35653575
</para>
35663576
</listitem>
35673577
</varlistentry>

‎src/backend/utils/misc/guc.c

Lines changed: 2 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-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.257 2005/03/25 16:17:27 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.258 2005/04/08 00:59:59 neilc Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -791,7 +791,7 @@ static struct config_bool ConfigureNamesBool[] =
791791
NULL
792792
},
793793
&add_missing_from,
794-
true,NULL,NULL
794+
false,NULL,NULL
795795
},
796796
{
797797
{"check_function_bodies",PGC_USERSET,CLIENT_CONN_STATEMENT,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@
313313

314314
# - Previous Postgres Versions -
315315

316-
#add_missing_from =true
316+
#add_missing_from =false
317317
#regex_flavor = advanced# advanced, extended, or basic
318318
#sql_inheritance = true
319319
#default_with_oids = false

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp