From: Andres Freund Date: Wed, 26 Nov 2014 16:39:16 +0000 (+0100) Subject: bdr: Make sure tables can't be created WITH OIDs X-Git-Tag: bdr-plugin/dynconf-before-global-add~66 X-Git-Url: http://git.postgresql.org/gitweb/static/connections.php?a=commitdiff_plain;h=b8f609958ed784cc2f7e7ec26a42bf4fe162d59e;p=2ndquadrant_bdr.git bdr: Make sure tables can't be created WITH OIDs --- diff --git a/bdr_commandfilter.c b/bdr_commandfilter.c index 43a6176908..7a9b669c5a 100644 --- a/bdr_commandfilter.c +++ b/bdr_commandfilter.c @@ -29,6 +29,7 @@ #include "commands/dbcommands.h" #include "commands/event_trigger.h" #include "commands/extension.h" +#include "commands/defrem.h" #include "commands/tablecmds.h" #include "parser/parse_utilcmd.h" @@ -106,12 +107,34 @@ filter_CreateStmt(Node *parsetree, { CreateStmt *stmt; ListCell *cell; + bool with_oids = default_with_oids; stmt = (CreateStmt *) parsetree; if (stmt->ofTypename != NULL) error_unsupported_command("CREATE TABLE ... OF TYPE"); + /* verify WITH options */ + foreach(cell, stmt->options) + { + DefElem *def = (DefElem *) lfirst(cell); + + /* reject WITH OIDS */ + if (def->defnamespace == NULL && + pg_strcasecmp(def->defname, "oids") == 0) + { + with_oids = defGetBoolean(def); + } + } + + if (with_oids) + { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Tables WITH OIDs are not supported with bdr"))); + } + + /* verify table elements */ foreach(cell, stmt->tableElts) { Node *element = lfirst(cell); diff --git a/expected/ddl/create.out b/expected/ddl/create.out index acf80ffa5c..0001fa94cb 100644 --- a/expected/ddl/create.out +++ b/expected/ddl/create.out @@ -753,6 +753,27 @@ SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_r \d+ test_tbl_inh_* \c regression \d+ test_tbl_inh_* +-- ensure tables WITH OIDs can't be created +SHOW default_with_oids; + default_with_oids +------------------- + off +(1 row) + +CREATE TABLE tbl_with_oids() WITH oids; +ERROR: Tables WITH OIDs are not supported with bdr +CREATE TABLE tbl_without_oids() WITHOUT oids; +DROP TABLE tbl_without_oids; +CREATE TABLE tbl_without_oids(); +DROP TABLE tbl_without_oids; +SET default_with_oids = true; +CREATE TABLE tbl_with_oids(); +ERROR: Tables WITH OIDs are not supported with bdr +CREATE TABLE tbl_with_oids() WITH OIDS; +ERROR: Tables WITH OIDs are not supported with bdr +CREATE TABLE tbl_without_oids() WITHOUT oids; +DROP TABLE tbl_without_oids; +SET default_with_oids = false; --- AGGREGATE --- \c postgres CREATE AGGREGATE test_avg ( diff --git a/sql/ddl/create.sql b/sql/ddl/create.sql index 49792a2577..2cca95845c 100644 --- a/sql/ddl/create.sql +++ b/sql/ddl/create.sql @@ -199,6 +199,19 @@ SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_r \c regression \d+ test_tbl_inh_* +-- ensure tables WITH OIDs can't be created +SHOW default_with_oids; +CREATE TABLE tbl_with_oids() WITH oids; +CREATE TABLE tbl_without_oids() WITHOUT oids; +DROP TABLE tbl_without_oids; +CREATE TABLE tbl_without_oids(); +DROP TABLE tbl_without_oids; +SET default_with_oids = true; +CREATE TABLE tbl_with_oids(); +CREATE TABLE tbl_with_oids() WITH OIDS; +CREATE TABLE tbl_without_oids() WITHOUT oids; +DROP TABLE tbl_without_oids; +SET default_with_oids = false; --- AGGREGATE --- \c postgres