Change the default setting of "add_missing_from" to false. This has been
authorNeil Conway
Fri, 8 Apr 2005 00:59:59 +0000 (00:59 +0000)
committerNeil Conway
Fri, 8 Apr 2005 00:59:59 +0000 (00:59 +0000)
the long-term plan for this behavior for quite some time, but it is only
possible now that DELETE has a USING clause so that the user can join
other tables in a DELETE statement without relying on this behavior.

doc/src/sgml/ref/delete.sgml
doc/src/sgml/ref/select.sgml
doc/src/sgml/ref/show.sgml
doc/src/sgml/runtime.sgml
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample

index 954391a228b0647fd300f18c2f4a6953bb581ef9..598936cd5acd07d3a2148b7713d434e767e3a216 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -148,12 +148,6 @@ DELETE FROM films
    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.
-  
  
 
  
index 93218e16c2eac512cac1d12f9b053bedc1a104d6..9044adfa8c89f4f39aa2c95718d52c22b0290471 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -1011,42 +1011,21 @@ SELECT 2+2;
    
 
    
-    A less obvious use is to abbreviate a normal
-    SELECT from tables:
+    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';
-
- 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.
+    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 
+    linkend="guc-add-missing-from"> configuration variable can be
+    enabled.
    
   
 
index 8fb07bc9e46b19f081f6d0ae073383fa207b6c3a..5fdfa2b4b06d6e8ccd3e7f43c419bf1eb67ff00c 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -166,7 +166,7 @@ SHOW geqo;
 SHOW ALL;
               name              |                     setting
 --------------------------------+----------------------------------------------
- add_missing_from               | on
+ add_missing_from               | off
  archive_command                | unset
  australian_timezones           | off
     .
index f019dbb4ae640297d83a6d17b194597046ad327a..e5567abf27927cfbe420fbb47fdfc2510861e190 100644 (file)
@@ -1,5 +1,5 @@
 
 
 
@@ -3553,15 +3553,25 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
       
       
        
-        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.
+        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 1db12c23135f920e3b86b9010b354f848d636ee4..4658991e7341fa3d602e578bc21db6dbbfffa95e 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut .
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.257 2005/03/25 16:17:27 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.258 2005/04/08 00:59:59 neilc Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -791,7 +791,7 @@ static struct config_bool ConfigureNamesBool[] =
            NULL
        },
        &add_missing_from,
-       true, NULL, NULL
+       false, NULL, NULL
    },
    {
        {"check_function_bodies", PGC_USERSET, CLIENT_CONN_STATEMENT,
index 113021fd79f175b87cf154b18d9f286e11923e37..6b06afcb7fdb17187586c9a7fe9d61a6060a50ba 100644 (file)
 
 # - Previous Postgres Versions -
 
-#add_missing_from = true
+#add_missing_from = false
 #regex_flavor = advanced   # advanced, extended, or basic
 #sql_inheritance = true
 #default_with_oids = false