From: Craig Ringer Date: Sun, 27 Apr 2014 04:47:24 +0000 (+0800) Subject: bdr: Don't create TRUNCATE triggers for DDL replication during pg_restore X-Git-Url: http://git.postgresql.org/gitweb/static/developers.postgresql.org?a=commitdiff_plain;h=118fccd2e3014f53bc00ddecda7013d41210ab0c;p=users%2Fandresfreund%2Fpostgres.git bdr: Don't create TRUNCATE triggers for DDL replication during pg_restore --- diff --git a/contrib/bdr/bdr--0.5.sql b/contrib/bdr/bdr--0.5.sql index 9e56d262ce..4df82521e2 100644 --- a/contrib/bdr/bdr--0.5.sql +++ b/contrib/bdr/bdr--0.5.sql @@ -189,6 +189,12 @@ BEGIN IF pg_replication_identifier_is_replaying() THEN RETURN; END IF; + IF current_setting('bdr.skip_ddl_replication')::boolean THEN + -- If we're doing a pg_restore from a remote BDR node's + -- state, we must not create truncate triggers etc because + -- they'll get copied over in the dump. + RETURN; + END IF; FOR r IN SELECT * FROM pg_event_trigger_get_creation_commands() LOOP diff --git a/contrib/bdr/bdr.c b/contrib/bdr/bdr.c index 36b109514e..e45f554d33 100644 --- a/contrib/bdr/bdr.c +++ b/contrib/bdr/bdr.c @@ -70,6 +70,7 @@ static char *connections = NULL; static char *bdr_synchronous_commit = NULL; int bdr_default_apply_delay; int bdr_max_workers; +static bool bdr_skip_ddl_replication; /* TODO: Remove when bdr_apply_main moved into bdr_apply.c */ extern BdrApplyWorker *bdr_apply_worker; @@ -1444,6 +1445,15 @@ _PG_init(void) 0, NULL, NULL, NULL); + DefineCustomBoolVariable("bdr.skip_ddl_replication", + "Internal. Set during local restore during init_replica only", + NULL, + &bdr_skip_ddl_replication, + false, + PGC_BACKEND, + 0, + NULL, NULL, NULL); + /* if nothing is configured, we're done */ if (connections == NULL) { diff --git a/contrib/bdr/scripts/bdr_initial_load b/contrib/bdr/scripts/bdr_initial_load index b2b05d2610..ac4c5856ad 100644 --- a/contrib/bdr/scripts/bdr_initial_load +++ b/contrib/bdr/scripts/bdr_initial_load @@ -65,7 +65,7 @@ if ! pg_dump -j $JOBS $SNAP -F d -f $TMPDIR "$SOURCE"; then fi echo "Restoring dump to local DB \"$TARGET\" with $JOBS concurrent workers from \"$TMPDIR\"" -if ! PGOPTIONS="-c bdr.permit_unsafe_ddl_commands=true" pg_restore --exit-on-error --single-transaction -j $JOBS -F d -d "$TARGET" $TMPDIR; then +if ! PGOPTIONS="-c bdr.permit_unsafe_ddl_commands=true -c bdr.skip_ddl_replication=true" pg_restore --exit-on-error --single-transaction -j $JOBS -F d -d "$TARGET" $TMPDIR; then echo "pg_restore to "$TARGET" failed, aborting" exit 2 fi