add_missing_from = false
add_missing_from = false
От:
Neil Conway <neilc@samurai.com>
Дата:
Now that DELETE has a USING clause, we should be able to make
add_missing_from=false the default in 8.1; the attached patch implements
this and updates the documentation.
Barring any objections, I'll apply this tomorrow.
-Neil
Index: doc/src/sgml/runtime.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql/doc/src/sgml/runtime.sgml,v
retrieving revision 1.312
diff -c -r1.312 runtime.sgml
*** doc/src/sgml/runtime.sgml 29 Mar 2005 03:01:29 -0000 1.312
--- doc/src/sgml/runtime.sgml 7 Apr 2005 07:02:30 -0000
***************
*** 3553,3567 ****
! When true</>, tables that are referenced by a query will be
! automatically added to the FROM</> clause if not already
! present. The default is true</> for compatibility with
! previous releases of PostgreSQL</>. However, this
! behavior is not SQL-standard, and many people dislike it because it
! can mask mistakes (such as referencing a table where you should have
! referenced its alias). Set to false</> for the SQL-standard
! behavior of rejecting references to tables that are not listed in
! FROM</>.
--- 3553,3577 ----
! When true</>, tables that are referenced by a query
! will be automatically added to the FROM</> clause if
! not already present. This behavior does not comply with the
! SQL standard and many people dislike it because it can mask
! mistakes (such as referencing a table where you should have
! referenced its alias). The default is false</>. This
! variable can be enabled for compatibility with releases of
! PostgreSQL</> prior to 8.1, where this behavior
! was allowed by default.
!
!
!
! Note that even when this variable is enabled, a warning
! message will be emitted for each implicit FROM</>
! entry referenced by a query. Users are encouraged to update
! their applications to not rely on this behavior, by adding all
! tables referenced by a query to the query's FROM</>
! clause (or its USING</> clause in the case of
! DELETE</>).
Index: doc/src/sgml/ref/delete.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql/doc/src/sgml/ref/delete.sgml,v
retrieving revision 1.23
diff -c -r1.23 delete.sgml
*** doc/src/sgml/ref/delete.sgml 7 Apr 2005 01:51:37 -0000 1.23
--- doc/src/sgml/ref/delete.sgml 7 Apr 2005 06:30:31 -0000
***************
*** 148,159 ****
In some cases the join style is easier to write or faster to
execute than the sub-select style.
-
-
- If add_missing_from is enabled, any relations
- mentioned in the WHERE condition will be
- implicitly added to the USING clause.
-
--- 148,153 ----
Index: doc/src/sgml/ref/select.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql/doc/src/sgml/ref/select.sgml,v
retrieving revision 1.82
diff -c -r1.82 select.sgml
*** doc/src/sgml/ref/select.sgml 10 Mar 2005 23:21:20 -0000 1.82
--- doc/src/sgml/ref/select.sgml 7 Apr 2005 06:12:25 -0000
***************
*** 1011,1052 ****
! A less obvious use is to abbreviate a normal
! SELECT from tables:
SELECT distributors.* WHERE distributors.name = 'Westward';
-
- did | name
- -----+----------
- 108 | Westward
-
- This works because an implicit FROM item is
- added for each table that is referenced in other parts of the
- SELECT statement but not mentioned in
- FROM.
-
-
-
- While this is a convenient shorthand, it's easy to misuse. For
- example, the command
-
- SELECT distributors.* FROM distributors d;
-
- is probably a mistake; most likely the user meant
-
- SELECT d.* FROM distributors d;
-
- rather than the unconstrained join
-
- SELECT distributors.* FROM distributors d, distributors distributors;
! that he will actually get. To help detect this sort of mistake,
! PostgreSQL will warn if the
! implicit-FROM feature is used in a
! SELECT statement that also contains an explicit
! FROM clause. Also, it is possible to disable
! the implicit-FROM feature by setting the
! parameter to false.
--- 1011,1031 ----
! Note that if a FROM clause is not specified,
! the query cannot reference any database tables. For example, the
! following query is invalid:
SELECT distributors.* WHERE distributors.name = 'Westward';
! PostgreSQL releases prior to
! 8.1 would accept queries of this form, and add an implicit entry
! to the query's FROM clause for each table
! referenced by the query. This is no longer the default behavior,
! because it does not comply with the SQL standard, and is
! considered by many to be error-prone. For compatibility with
! applications that rely on this behavior the configuration variable can be
! enabled.
Index: doc/src/sgml/ref/show.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql/doc/src/sgml/ref/show.sgml,v
retrieving revision 1.37
diff -c -r1.37 show.sgml
*** doc/src/sgml/ref/show.sgml 4 Jan 2005 03:58:16 -0000 1.37
--- doc/src/sgml/ref/show.sgml 7 Apr 2005 05:37:12 -0000
***************
*** 166,172 ****
SHOW ALL;
name | setting
--------------------------------+----------------------------------------------
! add_missing_from | on
archive_command | unset
australian_timezones | off
.
--- 166,172 ----
SHOW ALL;
name | setting
--------------------------------+----------------------------------------------
! add_missing_from | off
archive_command | unset
australian_timezones | off
.
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /var/lib/cvs/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.257
diff -c -r1.257 guc.c
*** src/backend/utils/misc/guc.c 25 Mar 2005 16:17:27 -0000 1.257
--- src/backend/utils/misc/guc.c 7 Apr 2005 05:34:40 -0000
***************
*** 791,797 ****
NULL
},
&add_missing_from,
! true, NULL, NULL
},
{
{"check_function_bodies", PGC_USERSET, CLIENT_CONN_STATEMENT,
--- 791,797 ----
NULL
},
&add_missing_from,
! false, NULL, NULL
},
{
{"check_function_bodies", PGC_USERSET, CLIENT_CONN_STATEMENT,
Index: src/backend/utils/misc/postgresql.conf.sample
===================================================================
RCS file: /var/lib/cvs/pgsql/src/backend/utils/misc/postgresql.conf.sample,v
retrieving revision 1.138
diff -c -r1.138 postgresql.conf.sample
*** src/backend/utils/misc/postgresql.conf.sample 24 Mar 2005 04:36:18 -0000 1.138
--- src/backend/utils/misc/postgresql.conf.sample 7 Apr 2005 05:35:04 -0000
***************
*** 313,319 ****
# - Previous Postgres Versions -
! #add_missing_from = true
#regex_flavor = advanced # advanced, extended, or basic
#sql_inheritance = true
#default_with_oids = false
--- 313,319 ----
# - Previous Postgres Versions -
! #add_missing_from = false
#regex_flavor = advanced # advanced, extended, or basic
#sql_inheritance = true
#default_with_oids = false