diff --git a/src/backend/distributed/commands/utility_hook.c b/src/backend/distributed/commands/utility_hook.c index 9426e13c0ea..77ef231afa2 100644 --- a/src/backend/distributed/commands/utility_hook.c +++ b/src/backend/distributed/commands/utility_hook.c @@ -938,11 +938,14 @@ citus_ProcessUtilityInternal(PlannedStmt *pstmt, if (ops && ops->markDistributed) { List *addresses = GetObjectAddressListFromParseTree(parsetree, false, true); - ObjectAddress *address = NULL; - foreach_ptr(address, addresses) + if (!IsAnyObjectDistributed(addresses)) { - MarkObjectDistributed(address); - TrackPropagatedObject(address); + ObjectAddress *address = NULL; + foreach_ptr(address, addresses) + { + MarkObjectDistributed(address); + TrackPropagatedObject(address); + } } } } diff --git a/src/test/regress/expected/non_super_user_create_existing_extension.out b/src/test/regress/expected/non_super_user_create_existing_extension.out new file mode 100644 index 00000000000..c02420d8275 --- /dev/null +++ b/src/test/regress/expected/non_super_user_create_existing_extension.out @@ -0,0 +1,30 @@ +CREATE SCHEMA non_super_user_create_existing_extension; +SET search_path TO non_super_user_create_existing_extension; +SELECT CURRENT_USER; + current_user +--------------------------------------------------------------------- + postgres +(1 row) + +CREATE EXTENSION if not exists "uuid-ossp" SCHEMA public; +CREATE EXTENSION if not exists "uuid-ossp" SCHEMA public; +NOTICE: extension "uuid-ossp" already exists, skipping +CREATE USER non_super_user_ext; +SET ROLE non_super_user_ext; +SELECT CURRENT_USER; + current_user +--------------------------------------------------------------------- + non_super_user_ext +(1 row) + +CREATE EXTENSION if not exists "uuid-ossp" SCHEMA public; +NOTICE: extension "uuid-ossp" already exists, skipping +RESET ROLE; +SELECT CURRENT_USER; + current_user +--------------------------------------------------------------------- + postgres +(1 row) + +DROP USER non_super_user_ext; +DROP SCHEMA non_super_user_create_existing_extension CASCADE; diff --git a/src/test/regress/multi_schedule b/src/test/regress/multi_schedule index 7f0c7ca57f6..bca93f33fc3 100644 --- a/src/test/regress/multi_schedule +++ b/src/test/regress/multi_schedule @@ -111,6 +111,7 @@ test: background_task_queue_monitor test: other_databases grant_role_from_non_maindb role_operations_from_non_maindb seclabel_non_maindb test: citus_internal_access test: function_with_case_when +test: non_super_user_create_existing_extension # Causal clock test test: clock diff --git a/src/test/regress/sql/non_super_user_create_existing_extension.sql b/src/test/regress/sql/non_super_user_create_existing_extension.sql new file mode 100644 index 00000000000..134b9a5d628 --- /dev/null +++ b/src/test/regress/sql/non_super_user_create_existing_extension.sql @@ -0,0 +1,14 @@ +CREATE SCHEMA non_super_user_create_existing_extension; +SET search_path TO non_super_user_create_existing_extension; + +SELECT CURRENT_USER; +CREATE EXTENSION if not exists "uuid-ossp" SCHEMA public; +CREATE EXTENSION if not exists "uuid-ossp" SCHEMA public; +CREATE USER non_super_user_ext; +SET ROLE non_super_user_ext; +SELECT CURRENT_USER; +CREATE EXTENSION if not exists "uuid-ossp" SCHEMA public; +RESET ROLE; +SELECT CURRENT_USER; +DROP USER non_super_user_ext; +DROP SCHEMA non_super_user_create_existing_extension CASCADE; \ No newline at end of file