From 4005c1deec4c955df7facd94ce2eae23e4d349d9 Mon Sep 17 00:00:00 2001 From: Petr Jelinek Date: Wed, 8 Apr 2015 02:04:42 +0200 Subject: [PATCH] Make bdr_replicate_ddl_command() obey the command filter. 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 | 11 +---------- bdr_executor.c | 3 --- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/bdr_commandfilter.c b/bdr_commandfilter.c index 1f27bd717d..b7e2ccd69c 100644 --- a/bdr_commandfilter.c +++ b/bdr_commandfilter.c @@ -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) diff --git a/bdr_executor.c b/bdr_executor.c index 411b6722c7..ac01350987 100644 --- a/bdr_executor.c +++ b/bdr_executor.c @@ -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(); } -- 2.39.5