From d3d2eb82d22dc2def330c864a5640a85667d411c Mon Sep 17 00:00:00 2001 From: Shigeru Hanada Date: Thu, 25 Nov 2010 11:30:55 +0900 Subject: [PATCH] Remove oid support on foreign tables. --- doc/src/sgml/ref/alter_foreign_table.sgml | 36 +++----------------- doc/src/sgml/ref/alter_table.sgml | 6 ++++ doc/src/sgml/ref/create_foreign_table.sgml | 38 +--------------------- src/backend/commands/tablecmds.c | 4 +-- src/backend/parser/gram.y | 20 ++---------- src/bin/pg_dump/pg_dump.c | 2 +- src/test/regress/expected/foreign_data.out | 14 +++++--- src/test/regress/sql/foreign_data.sql | 6 ++-- 8 files changed, 29 insertions(+), 97 deletions(-) diff --git a/doc/src/sgml/ref/alter_foreign_table.sgml b/doc/src/sgml/ref/alter_foreign_table.sgml index 0ea555d2f9..ebb3d402c1 100644 --- a/doc/src/sgml/ref/alter_foreign_table.sgml +++ b/doc/src/sgml/ref/alter_foreign_table.sgml @@ -45,8 +45,6 @@ ALTER FOREIGN TABLE name ENABLE RULE rewrite_rule_name ENABLE REPLICA RULE rewrite_rule_name ENABLE ALWAYS RULE rewrite_rule_name - SET WITH OIDS - SET WITHOUT OIDS INHERIT parent_table NO INHERIT parent_table OWNER TO new_owner @@ -151,36 +149,6 @@ ALTER FOREIGN TABLE name - - SET WITH OIDS - - - This form adds an oid system column to the - table (see ). - It does nothing if the table already has OIDs. - - - - Note that this is not equivalent to ADD COLUMN oid oid; - that would add a normal column that happened to be named - oid, not a system column. - - - - - - SET WITHOUT OIDS - - - This form removes the oid system column from the - table. This is exactly equivalent to - DROP COLUMN oid RESTRICT, - except that it will not complain if there is already no - oid column. - - - - INHERIT parent_table @@ -199,6 +167,10 @@ ALTER FOREIGN TABLE name There must also be matching child-table constraints for all CHECK constraints of the parent. + + + The parent must not have OIDs because foreign table can't have OIDs. + diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 784feaef54..7a1da1dbd6 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -319,6 +319,12 @@ ALTER TABLE name that would add a normal column that happened to be named oid, not a system column. + + + If the target table has been inherited by any foreign table, you can't + add oid system column because foreign table can't have + oid. + diff --git a/doc/src/sgml/ref/create_foreign_table.sgml b/doc/src/sgml/ref/create_foreign_table.sgml index d56087c7c9..572f70f89c 100644 --- a/doc/src/sgml/ref/create_foreign_table.sgml +++ b/doc/src/sgml/ref/create_foreign_table.sgml @@ -29,7 +29,6 @@ CREATE FOREIGN TABLE table_name ( [ ] ) [ INHERITS ( parent_table [, ... ] ) ] SERVER server_name -[ WITH OIDS | WITHOUT OIDS ] [ OPTIONS ( option 'value' [, ... ] ) ] where column_constraint is: @@ -193,7 +192,7 @@ CHECK ( expression ) - Column STORAGE settings are also copied from parent tables. + The parent must not have OIDs because foreign table can't have OIDs. @@ -309,32 +308,6 @@ CHECK ( expression ) - - WITH OIDS | WITHOUT OIDS - - - This clause specifies whether rows of the foreign table should have - OIDs (object identifiers) assigned to them, or not. - If WITH OIDS is not specified, the default setting depends - upon the configuration parameter. - (If the new foreign table inherits from any tables that have OIDs, then - WITH OIDS is forced even if the command says - WITHOUT OIDS.) - - - - If WITH OIDS is specified or implied, the first - column of the rows which was retrieved from the foreign table - must be the oid column. - - - - To remove OIDs from a foreign table after it has been created, use . - - - - @@ -445,15 +418,6 @@ SERVER distributor_server; - - <literal>WITH</> clause - - - The WITH clause is a PostgreSQL - extension; neither storage parameters nor OIDs are in the standard. - - - diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 0880e2328b..fb0f45b582 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -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) { diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 666a189cf7..7f459b7abe 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -1785,7 +1785,6 @@ alter_table_cmd: n->subtype = AT_DropOids; $$ = (Node *)n; } - /* ALTER TABLE CLUSTER ON */ | 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 SET WITH OIDS */ - | SET WITH OIDS - { - AlterTableCmd *n = makeNode(AlterTableCmd); - n->subtype = AT_AddOids; - $$ = (Node *)n; - } - /* ALTER FOREIGN TABLE SET WITHOUT OIDS */ - | SET WITHOUT OIDS - { - AlterTableCmd *n = makeNode(AlterTableCmd); - n->subtype = AT_DropOids; - $$ = (Node *)n; - } /* ALTER FOREIGN TABLE ENABLE RULE */ | ENABLE_P RULE name { diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 4045930e14..cf13b02665 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -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, diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out index 028afdbea3..95c35aa259 100644 --- a/src/test/regress/expected/foreign_data.out +++ b/src/test/regress/expected/foreign_data.out @@ -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; diff --git a/src/test/regress/sql/foreign_data.sql b/src/test/regress/sql/foreign_data.sql index 6d9385ea5b..f71139fc8d 100644 --- a/src/test/regress/sql/foreign_data.sql +++ b/src/test/regress/sql/foreign_data.sql @@ -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; -- 2.39.5