Revert "Don't check for presence of a PRIMARY KEY if not replicating rows"
authorCraig Ringer <craig@2ndquadrant.com>
Fri, 3 Jul 2015 11:30:27 +0000 (19:30 +0800)
committerCraig Ringer <craig@2ndquadrant.com>
Fri, 3 Jul 2015 13:44:54 +0000 (21:44 +0800)
This reverts commit 15abe5e5946c1542ecf43b42c69ba03c984d199f as the
initial change was too naïve.

The check shouldn't be within the loop.

It should run after the DDL lock check, since it could change data
in the table in ways that means the incoming DDL might not apply
anymore, e.g. inserting a NULL value into an otherwise NULL-free
table at the same time an
  ALTER TABLE ... ALTER COLUMN ... SET NOT NULL
comes in.

It's also necessary for it to be skipped if the node is read-only
so a check like  && !node_read_only is needed.

bdr_executor.c

index c5e196b5b975f196e6faf3a697f55132bee271bc..963ff74226c2c18e9914e82c39aaff232088ce1d 100644 (file)
@@ -950,13 +950,6 @@ BdrExecutorStart(QueryDesc *queryDesc, int eflags)
            continue;
        }
 
-       /* If replication is suppressed then no key is required */
-       if (bdr_do_not_replicate)
-       {
-           RelationClose(rel);
-           continue;
-       }
-
        /*
         * Since changes to pg_catalog aren't replicated directly there's
         * no strong need to suppress direct UPDATEs on them. The usual