Make bdr_replicate_ddl_command() obey the command filter.
authorPetr Jelinek <pjmodos@pjmodos.net>
Wed, 8 Apr 2015 00:04:42 +0000 (02:04 +0200)
committerPetr Jelinek <pjmodos@pjmodos.net>
Wed, 8 Apr 2015 00:11:19 +0000 (02:11 +0200)
Previously, bdr_replicate_ddl_command() would always execute any
command, no matter if it's considered safe or not. But this behaviour is
too much of a footgun for users of this function. Plus we already have
mechanism to override command filter - the
bdr.permit_unsafe_ddl_commands GUC, so it makes sense that
bdr_replicate_ddl_command() function should behave according to this GUC
just like plain DDL in BDR.

bdr_commandfilter.c
bdr_executor.c

index 1f27bd717dddebf82f386beae66dbdb0c54dd392..b7e2ccd69cfd26ebf39b7a3ecc2de9d7435552b2 100644 (file)
@@ -52,8 +52,6 @@ static ProcessUtility_hook_type next_ProcessUtility_hook = NULL;
 /* GUCs */
 bool bdr_permit_unsafe_commands = false;
 
-bool bdr_always_allow_ddl = false;
-
 static void error_unsupported_command(const char *cmdtag) __attribute__((noreturn));
 
 /*
@@ -578,7 +576,7 @@ bdr_commandfilter(Node *parsetree,
        goto done;
 
    /* don't filter if explicitly told so */
-   if (bdr_always_allow_ddl || bdr_permit_unsafe_commands)
+   if (bdr_permit_unsafe_commands)
        goto done;
 
    /* extension contents aren't individually replicated */
@@ -901,13 +899,6 @@ done:
                                dest, completionTag);
 }
 
-void
-bdr_commandfilter_always_allow_ddl(bool always_allow)
-{
-   Assert(IsUnderPostmaster);
-   bdr_always_allow_ddl = always_allow;
-}
-
 /* Module load */
 void
 init_bdr_commandfilter(void)
index 411b6722c77750699dc74400c49572d91b3d37c4..ac013509876d5eddb359843e75224f1db9573b1a 100644 (file)
@@ -734,7 +734,6 @@ bdr_replicate_ddl_command(PG_FUNCTION_ARGS)
                             GUC_ACTION_SAVE, true, 0);
 
    /* Execute the query locally. */
-   bdr_commandfilter_always_allow_ddl(true);
    in_bdr_replicate_ddl_command = true;
 
    PG_TRY();
@@ -745,12 +744,10 @@ bdr_replicate_ddl_command(PG_FUNCTION_ARGS)
        bdr_execute_ddl_command(query, GetUserNameFromId(GetUserId()), false);
    PG_CATCH();
        in_bdr_replicate_ddl_command = false;
-       bdr_commandfilter_always_allow_ddl(false);
        PG_RE_THROW();
    PG_END_TRY();
 
    in_bdr_replicate_ddl_command = false;
-   bdr_commandfilter_always_allow_ddl(false);
 
    PG_RETURN_VOID();
 }