bdr: Make sure tables can't be created WITH OIDs
authorAndres Freund <andres@anarazel.de>
Wed, 26 Nov 2014 16:39:16 +0000 (17:39 +0100)
committerAndres Freund <andres@anarazel.de>
Wed, 26 Nov 2014 16:39:16 +0000 (17:39 +0100)
bdr_commandfilter.c
expected/ddl/create.out
sql/ddl/create.sql

index 43a61769086b15535c402f69ef1069c0b3e5f95f..7a9b669c5ab454a43734c5aa0267cdaabafb5a84 100644 (file)
@@ -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);
index acf80ffa5c7092fcd40228a18e867732762adce9..0001fa94cb650a4a089ef54910b6025a8745d957 100644 (file)
@@ -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 (
index 49792a25779c3be16a531207a83aeec9dcfadf51..2cca95845c432c1b1cf6ed4516ff9b9543dc2300 100644 (file)
@@ -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