Remove support for creating typed foreign tables.
authorShigeru Hanada <[email protected]>
Mon, 18 Oct 2010 06:09:30 +0000 (15:09 +0900)
committerShigeru Hanada <[email protected]>
Mon, 18 Oct 2010 06:09:30 +0000 (15:09 +0900)
SQL/MED standard requires CREATE FOREIGN TABLE statement to
accept only <basic column definition> such as:
<column name> <data type> [ <column generic options> ]

Typed tables are supported on only normal tables.

doc/src/sgml/ref/create_foreign_table.sgml
src/backend/parser/gram.y

index ac6e2e868ea98ba64eec0f25432d8a6ab507a020..37418000cf0c731be9bc6f99f9affdc46c955b1f 100644 (file)
@@ -32,17 +32,6 @@ CREATE FOREIGN TABLE <replaceable class="PARAMETER">table_name</replaceable> ( [
 [ WITH OIDS | WITHOUT OIDS ]
 [ OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] ) ]
 
-CREATE FOREIGN TABLE <replaceable class="PARAMETER">table_name</replaceable>
-    OF <replaceable class="PARAMETER">type_name</replaceable> [ (
-  { <replaceable class="PARAMETER">column_name</replaceable> WITH OPTIONS [ <replaceable class="PARAMETER">column_constraint</replaceable> [ ... ] ]
-    | <replaceable>table_constraint</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>
 
 [ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
@@ -125,27 +114,6 @@ CHECK ( <replaceable class="PARAMETER">expression</replaceable> )
     </listitem>
    </varlistentry>
 
-   <varlistentry>
-    <term><literal>OF <replaceable class="PARAMETER">type_name</replaceable></literal></term>
-    <listitem>
-     <para>
-      Creates a <firstterm>typed table</firstterm>, which takes its
-      structure from the specified composite type (name optionally
-      schema-qualified).  A typed table is tied to its type; for
-      example the table will be dropped if the type is dropped
-      (with <literal>DROP TYPE ... CASCADE</literal>).
-     </para>
-
-     <para>
-      When a typed table is created, then the data types of the
-      columns are determined by the underlying composite type and are
-      not specified by the <literal>CREATE FOREIGN TABLE</literal> command.
-      But the <literal>CREATE FOREIGN TABLE</literal> command can add defaults
-      and constraints to the table.
-     </para>
-    </listitem>
-   </varlistentry>
-
    <varlistentry>
     <term><replaceable class="PARAMETER">column_name</replaceable></term>
     <listitem>
@@ -167,6 +135,18 @@ CHECK ( <replaceable class="PARAMETER">expression</replaceable> )
     </listitem>
    </varlistentry>
 
+   <varlistentry>
+    <term><literal>OPTIONS ( <replaceable class="PARAMETER">option</replaceable> = '<replaceable class="PARAMETER">value</replaceable>' [, ...] )</literal></term>
+    <listitem>
+     <para>
+      This clause specified options for the new foreign table.
+      The allowed option names and values are specific to each foreign
+      data wrapper and are validated using the foreign-data wrapper
+      library. Option names must be unique. 
+     </para>
+    </listitem>
+   </varlistentry>
+
    <varlistentry>
     <term><literal>INHERITS ( <replaceable>parent_table</replaceable> [, ... ] )</literal></term>
     <listitem>
@@ -403,17 +383,6 @@ SERVER distributor_server;
 </programlisting>
   </para>
 
-  <para>
-   Create a composite type and a typed foreign table:
-<programlisting>
-CREATE TYPE employee_type AS (name text, salary numeric);
-
-CREATE FOREIGN TABLE employees OF employee_type (
-    salary WITH OPTIONS CHECK (salary &gt; 0)
-)
-SERVER employee_server;
-</programlisting>
-  </para>
  </refsect1>
 
  <refsect1 id="SQL-CREATEFOREIGNTABLE-compatibility">
@@ -494,18 +463,6 @@ SERVER employee_server;
    </para>
   </refsect2>
 
-  <refsect2>
-   <title>Typed Tables</title>
-
-   <para>
-    Typed tables implement a subset of the SQL standard.  According to
-    the standard, a typed table has columns corresponding to the
-    underlying composite type as well as one other column that is
-    the <quote>self-referencing column</quote>.  PostgreSQL does not
-    support these self-referencing columns explicitly, but the same
-    effect can be had using the OID feature.
-   </para>
-  </refsect2>
  </refsect1>
 
 
index 87f961ea693a61e24f2d4865a9ca1ebaf2b1b6c8..11977c5f39ef7b2abc66cc40ceacf20b41c888d3 100644 (file)
@@ -282,7 +282,6 @@ static RangeVar *makeRangeVarFromAnyName(List *names, int position, core_yyscan_
                OptTableElementList TableElementList OptInherit definition
                OptTypedTableElementList TypedTableElementList
                OptForeignTableElementList ForeignTableElementList
-               OptTypedForeignTableElementList TypedForeignTableElementList
                reloptions opt_reloptions
                OptWith opt_distinct opt_definition func_args func_args_list
                func_args_with_defaults func_args_with_defaults_list
@@ -357,8 +356,7 @@ static RangeVar *makeRangeVarFromAnyName(List *names, int position, core_yyscan_
 %type <vsetstmt> set_rest SetResetClause
 
 %type <node>   TableElement TypedTableElement ConstraintElem TableFuncElement
-               ForeignTableElement TypedForeignTableElement
-               ForeignConstraintElem
+               ForeignTableElement ForeignConstraintElem
 %type <node>   CheckConstraintElem UniqueConstraintElem PrimaryKeyConstraintElem
                ExcludeConstraintElem ForeignKeyConstraintElem
 %type <node>   columnDef columnOptions
@@ -3486,22 +3484,6 @@ CreateForeignTableStmt:
                    n->options = $10;
                    $$ = (Node *) n;
                }
-       | CREATE FOREIGN TABLE qualified_name OF any_name
-           OptTypedForeignTableElementList
-           SERVER name OptWith create_generic_options
-               {
-                   CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
-                   $4->istemp = false;
-                   n->base.relation = $4;
-                   n->base.tableElts = $7;
-                   n->base.ofTypename = makeTypeNameFromNameList($6);
-                   n->base.ofTypename->location = @6;
-                   n->base.options = $10;
-                   /* FDW-specific data */
-                   n->servername = $9;
-                   n->options = $11;
-                   $$ = (Node *) n;
-               }
        ;
 
 OptForeignTableElementList:
@@ -3514,11 +3496,6 @@ OptForeignTableElementList:
                }
        ;
 
-OptTypedForeignTableElementList:
-           '(' TypedForeignTableElementList ')'    { $$ = $2; }
-           | /*EMPTY*/                             { $$ = NIL; }
-       ;
-
 ForeignTableElementList:
            ForeignTableElement
                {
@@ -3530,28 +3507,12 @@ ForeignTableElementList:
                }
        ;
 
-TypedForeignTableElementList:
-           TypedForeignTableElement
-               {
-                   $$ = list_make1($1);
-               }
-           | TypedForeignTableElementList ',' TypedForeignTableElement
-               {
-                   $$ = lappend($1, $3);
-               }
-       ;
-
 ForeignTableElement:
            foreignColumnDef                    { $$ = $1; }
            | ForeignTableLikeClause            { $$ = $1; }
            | ForeignTableConstraint            { $$ = $1; }
        ;
 
-TypedForeignTableElement:
-           columnOptions                       { $$ = $1; }
-           | ForeignTableConstraint            { $$ = $1; }
-       ;
-
 /* TODO: support GENERIC OPTIONS of foreign column */
 foreignColumnDef:  ColId Typename ForeignColQualList
                {