Remove oid support on foreign tables.
authorShigeru Hanada <[email protected]>
Thu, 25 Nov 2010 02:30:55 +0000 (11:30 +0900)
committerShigeru Hanada <[email protected]>
Thu, 25 Nov 2010 02:30:55 +0000 (11:30 +0900)
doc/src/sgml/ref/alter_foreign_table.sgml
doc/src/sgml/ref/alter_table.sgml
doc/src/sgml/ref/create_foreign_table.sgml
src/backend/commands/tablecmds.c
src/backend/parser/gram.y
src/bin/pg_dump/pg_dump.c
src/test/regress/expected/foreign_data.out
src/test/regress/sql/foreign_data.sql

index 0ea555d2f9115d6606b95dd6791cd2b2b88e5207..ebb3d402c1267a54affdaa2b99591f69feb6c6cb 100644 (file)
@@ -45,8 +45,6 @@ ALTER FOREIGN TABLE <replaceable class="PARAMETER">name</replaceable>
     ENABLE RULE <replaceable class="PARAMETER">rewrite_rule_name</replaceable>
     ENABLE REPLICA RULE <replaceable class="PARAMETER">rewrite_rule_name</replaceable>
     ENABLE ALWAYS RULE <replaceable class="PARAMETER">rewrite_rule_name</replaceable>
-    SET WITH OIDS
-    SET WITHOUT OIDS
     INHERIT <replaceable class="PARAMETER">parent_table</replaceable>
     NO INHERIT <replaceable class="PARAMETER">parent_table</replaceable>
     OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
@@ -151,36 +149,6 @@ ALTER FOREIGN TABLE <replaceable class="PARAMETER">name</replaceable>
     </listitem>
    </varlistentry>
 
-   <varlistentry>
-    <term><literal>SET WITH OIDS</literal></term>
-    <listitem>
-     <para>
-      This form adds an <literal>oid</literal> system column to the
-      table (see <xref linkend="ddl-system-columns">).
-      It does nothing if the table already has OIDs.
-     </para>
-
-     <para>
-      Note that this is not equivalent to <literal>ADD COLUMN oid oid</>;
-      that would add a normal column that happened to be named
-      <literal>oid</>, not a system column.
-     </para>
-    </listitem>
-   </varlistentry>
-
-   <varlistentry>
-    <term><literal>SET WITHOUT OIDS</literal></term>
-    <listitem>
-     <para>
-      This form removes the <literal>oid</literal> system column from the
-      table.  This is exactly equivalent to
-      <literal>DROP COLUMN oid RESTRICT</literal>,
-      except that it will not complain if there is already no
-      <literal>oid</literal> column.
-     </para>
-    </listitem>
-   </varlistentry>
-
    <varlistentry>
     <term><literal>INHERIT <replaceable class="PARAMETER">parent_table</replaceable></literal></term>
     <listitem>
@@ -199,6 +167,10 @@ ALTER FOREIGN TABLE <replaceable class="PARAMETER">name</replaceable>
       There must also be matching child-table constraints for all
       <literal>CHECK</literal> constraints of the parent.
      </para>
+
+     <para>
+      The parent must not have OIDs because foreign table can't have OIDs.
+     </para>
     </listitem>
    </varlistentry>
 
index 784feaef54887a44e7da04ad68e0e8ee1f5f7ad7..7a1da1dbd622841adc32a3c2c1ebf8228d9a9125 100644 (file)
@@ -319,6 +319,12 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
       that would add a normal column that happened to be named
       <literal>oid</>, not a system column.
      </para>
+
+     <para>
+      If the target table has been inherited by any foreign table, you can't
+      add <literal>oid</literal> system column because foreign table can't have
+      <literal>oid</literal>.
+     </para>
     </listitem>
    </varlistentry>
 
index d56087c7c937cf2687e4e1ca0f4d2f7169d10318..572f70f89c410c24709e73cc5ecd5ac419fecc13 100644 (file)
@@ -29,7 +29,6 @@ CREATE FOREIGN TABLE <replaceable class="PARAMETER">table_name</replaceable> ( [
 ] )
 [ INHERITS ( <replaceable>parent_table</replaceable> [, ... ] ) ]
   SERVER <replaceable class="parameter">server_name</replaceable>
-[ WITH OIDS | WITHOUT OIDS ]
 [ OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] ) ]
 
 <phrase>where <replaceable class="PARAMETER">column_constraint</replaceable> is:</phrase>
@@ -193,7 +192,7 @@ CHECK ( <replaceable class="PARAMETER">expression</replaceable> )
      </para>
 
      <para>
-      Column <literal>STORAGE</> settings are also copied from parent tables.
+      The parent must not have OIDs because foreign table can't have OIDs.
      </para>
 
     </listitem>
@@ -309,32 +308,6 @@ CHECK ( <replaceable class="PARAMETER">expression</replaceable> )
     </listitem>
    </varlistentry>
 
-   <varlistentry>
-    <term><literal>WITH OIDS | WITHOUT OIDS</literal></term>
-    <listitem>
-     <para>
-      This clause specifies whether rows of the foreign table should have
-      OIDs (object identifiers) assigned to them, or not.
-      If <literal>WITH OIDS</> is not specified, the default setting depends
-      upon the <xref linkend="guc-default-with-oids"> configuration parameter.
-      (If the new foreign table inherits from any tables that have OIDs, then
-      <literal>WITH OIDS</> is forced even if the command says
-      <literal>WITHOUT OIDS</>.)
-     </para>
-
-     <para>
-      If <literal>WITH OIDS</literal> is specified or implied, the first
-      column of the rows which was retrieved from the foreign table
-      must be the oid column.
-     </para>
-
-     <para>
-      To remove OIDs from a foreign table after it has been created, use <xref
-      linkend="sql-alterforeigntable">.
-     </para>
-    </listitem>
-   </varlistentry>
-
   </variablelist>
 
  </refsect1>
@@ -445,15 +418,6 @@ SERVER distributor_server;
    </para>
   </refsect2>
 
-  <refsect2>
-   <title><literal>WITH</> clause</title>
-
-   <para>
-    The <literal>WITH</> clause is a <productname>PostgreSQL</productname>
-    extension; neither storage parameters nor OIDs are in the standard.
-   </para>
-  </refsect2>
-
  </refsect1>
 
 
index 0880e2328b87bc28a5845a80ac29bc4fda85b504..fb0f45b582f69547da03dbc066c826946633c84d 100644 (file)
@@ -2773,14 +2773,14 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
            pass = AT_PASS_MISC;
            break;
        case AT_AddOids:        /* SET WITH OIDS */
-           ATSimplePermissions(rel, false, false, true);
+           ATSimplePermissions(rel, false, false, false);
            /* Performs own recursion */
            if (!rel->rd_rel->relhasoids || recursing)
                ATPrepAddOids(wqueue, rel, recurse, cmd, lockmode);
            pass = AT_PASS_ADD_COL;
            break;
        case AT_DropOids:       /* SET WITHOUT OIDS */
-           ATSimplePermissions(rel, false, false, true);
+           ATSimplePermissions(rel, false, false, false);
            /* Performs own recursion */
            if (rel->rd_rel->relhasoids)
            {
index 666a189cf7fc1c1ae6d97ac85d1dd49337bcf3f5..7f459b7abe0cde0e99c5a1d6316ce671f54c626c 100644 (file)
@@ -1785,7 +1785,6 @@ alter_table_cmd:
                    n->subtype = AT_DropOids;
                    $$ = (Node *)n;
                }
-
            /* ALTER TABLE <name> CLUSTER ON <indexname> */
            | CLUSTER ON name
                {
@@ -3473,17 +3472,16 @@ AlterForeignServerStmt: ALTER SERVER name foreign_server_version alter_generic_o
 CreateForeignTableStmt:
        CREATE FOREIGN TABLE qualified_name
            OptForeignTableElementList OptInherit
-           SERVER name OptWith create_generic_options
+           SERVER name create_generic_options
                {
                    CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
                    $4->istemp = false;
                    n->base.relation = $4;
                    n->base.tableElts = $5;
                    n->base.inhRelations = $6;
-                   n->base.options = $9;
                    /* FDW-specific data */
                    n->servername = $8;
-                   n->options = $10;
+                   n->options = $9;
                    $$ = (Node *) n;
                }
        ;
@@ -3697,20 +3695,6 @@ alter_foreign_table_cmd:
                    n->missing_ok = FALSE;
                    $$ = (Node *)n;
                }
-           /* ALTER FOREIGN TABLE <name> SET WITH OIDS  */
-           | SET WITH OIDS
-               {
-                   AlterTableCmd *n = makeNode(AlterTableCmd);
-                   n->subtype = AT_AddOids;
-                   $$ = (Node *)n;
-               }
-           /* ALTER FOREIGN TABLE <name> SET WITHOUT OIDS  */
-           | SET WITHOUT OIDS
-               {
-                   AlterTableCmd *n = makeNode(AlterTableCmd);
-                   n->subtype = AT_DropOids;
-                   $$ = (Node *)n;
-               }
            /* ALTER FOREIGN TABLE <name> ENABLE RULE <rule> */
            | ENABLE_P RULE name
                {
index 4045930e14392f570d0c80998450a823d841862f..cf13b02665fbf0a9b2dd2910b36eca71bf9bcb71 100644 (file)
@@ -11380,7 +11380,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
    ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
                 tbinfo->dobj.name,
                 tbinfo->dobj.namespace->dobj.name,
-            (tbinfo->relkind == RELKIND_VIEW) ? NULL : tbinfo->reltablespace,
+           (tbinfo->relkind == RELKIND_VIEW) ? NULL : tbinfo->reltablespace,
                 tbinfo->rolname,
               (strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false,
                 reltypename, SECTION_PRE_DATA,
index 028afdbea318c916568b1728fae2694d5a644b9e..95c35aa2591ffa4306dcb1bedb15bc66fc79414f 100644 (file)
@@ -663,6 +663,10 @@ ERROR:  relation "no_table" does not exist
 CREATE FOREIGN TABLE ft1 (c1 serial) SERVER sc;                 -- ERROR
 NOTICE:  CREATE TABLE will create implicit sequence "ft1_c1_seq" for serial column "ft1.c1"
 ERROR:  referenced relation "ft1" is not a table
+CREATE FOREIGN TABLE ft1 () SERVER sc WITH OIDS;                -- ERROR
+ERROR:  syntax error at or near "WITH OIDS"
+LINE 1: CREATE FOREIGN TABLE ft1 () SERVER sc WITH OIDS;
+                                              ^
 CREATE FOREIGN TABLE ft1 (
    c1 integer OPTIONS (force_not_null 'true') NOT NULL,
    c2 text DEFAULT 'foo',
@@ -688,7 +692,7 @@ Rules:
 Server: sc
 Has OIDs: no
 
-CREATE FOREIGN TABLE ft2 () INHERITS (t1) SERVER sc WITH OIDS OPTIONS (delimiter ' ', quote '`');
+CREATE FOREIGN TABLE ft2 () INHERITS (t1) SERVER sc OPTIONS (delimiter ' ', quote '`');
 \d+ ft2
                         Foreign table "public.ft2"
  Column |  Type   |      Modifiers      | Storage  | Description | Options 
@@ -701,7 +705,7 @@ Check constraints:
     "t1_c3_check" CHECK (c3 > '01-01-2000'::date)
 Server: sc
 Inherits: t1
-Has OIDs: yes
+Has OIDs: no
 
 \det+
                 List of foreign tables
@@ -744,8 +748,10 @@ ERROR:  constraint "no_const" of relation "ft1" does not exist
 ALTER FOREIGN TABLE ft1 DROP CONSTRAINT IF EXISTS no_const;
 NOTICE:  constraint "no_const" of relation "ft1" does not exist, skipping
 ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c1_check;
-ALTER FOREIGN TABLE ft1 SET WITH OIDS;
-ALTER FOREIGN TABLE ft1 SET WITHOUT OIDS;
+ALTER FOREIGN TABLE ft1 SET WITH OIDS;                          -- ERROR
+ERROR:  syntax error at or near "WITH OIDS"
+LINE 1: ALTER FOREIGN TABLE ft1 SET WITH OIDS;
+                                    ^
 ALTER FOREIGN TABLE ft1 ENABLE RULE ft1_insert_rule;
 ALTER FOREIGN TABLE ft1 ENABLE ALWAYS RULE ft1_insert_rule;
 ALTER FOREIGN TABLE ft1 ENABLE REPLICA RULE ft1_insert_rule;
index 6d9385ea5b1518fa9b6b615783df6b49074668cb..f71139fc8d4a70bbcd485ac475aea24f0a24f3cb 100644 (file)
@@ -273,6 +273,7 @@ CREATE FOREIGN TABLE ft1 () SERVER no_server;                   -- ERROR
 CREATE FOREIGN TABLE ft1 () INHERITS () SERVER sc;              -- ERROR
 CREATE FOREIGN TABLE ft1 () INHERITS (no_table) SERVER sc;      -- ERROR
 CREATE FOREIGN TABLE ft1 (c1 serial) SERVER sc;                 -- ERROR
+CREATE FOREIGN TABLE ft1 () SERVER sc WITH OIDS;                -- ERROR
 CREATE FOREIGN TABLE ft1 (
    c1 integer OPTIONS (force_not_null 'true') NOT NULL,
    c2 text DEFAULT 'foo',
@@ -282,7 +283,7 @@ CREATE FOREIGN TABLE ft1 (
 CREATE RULE ft1_insert_rule AS ON INSERT TO ft1 DO INSTEAD
    INSERT INTO t1 VALUES (new.c1, new.c2, new.c3);
 \d+ ft1
-CREATE FOREIGN TABLE ft2 () INHERITS (t1) SERVER sc WITH OIDS OPTIONS (delimiter ' ', quote '`');
+CREATE FOREIGN TABLE ft2 () INHERITS (t1) SERVER sc OPTIONS (delimiter ' ', quote '`');
 \d+ ft2
 \det+
 CREATE INDEX id_ft1_c2 ON ft1 (c2);                             -- ERROR
@@ -316,8 +317,7 @@ ALTER FOREIGN TABLE ft1 ADD CONSTRAINT ft1_c9_check CHECK (c9 < 0);
 ALTER FOREIGN TABLE ft1 DROP CONSTRAINT no_const;               -- ERROR
 ALTER FOREIGN TABLE ft1 DROP CONSTRAINT IF EXISTS no_const;
 ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c1_check;
-ALTER FOREIGN TABLE ft1 SET WITH OIDS;
-ALTER FOREIGN TABLE ft1 SET WITHOUT OIDS;
+ALTER FOREIGN TABLE ft1 SET WITH OIDS;                          -- ERROR
 ALTER FOREIGN TABLE ft1 ENABLE RULE ft1_insert_rule;
 ALTER FOREIGN TABLE ft1 ENABLE ALWAYS RULE ft1_insert_rule;
 ALTER FOREIGN TABLE ft1 ENABLE REPLICA RULE ft1_insert_rule;