From 655df3d600ca42e7749b5c4071dd8440d6f2b5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=BE=D1=80=D0=BE=D0=B7=D0=BE=D0=B2=20=D0=9A=D0=BE?= =?UTF-8?q?=D0=BD=D1=81=D1=82=D0=B0=D0=BD=D1=82=D0=B8=D0=BD?= Date: Tue, 2 Jul 2024 21:05:46 +0300 Subject: [PATCH 1/2] fix 7091 issue --- .../distributed/commands/utility_hook.c | 11 ++++--- ...n_super_user_create_existing_extension.out | 30 +++++++++++++++++++ src/test/regress/multi_schedule | 1 + ...n_super_user_create_existing_extension.sql | 14 +++++++++ 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 src/test/regress/expected/non_super_user_create_existing_extension.out create mode 100644 src/test/regress/sql/non_super_user_create_existing_extension.sql 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 From fb93841653ba940d9de80c3642894596527d7c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=BE=D1=80=D0=BE=D0=B7=D0=BE=D0=B2=20=D0=9A=D0=BE?= =?UTF-8?q?=D0=BD=D1=81=D1=82=D0=B0=D0=BD=D1=82=D0=B8=D0=BD?= Date: Tue, 2 Jul 2024 21:21:14 +0300 Subject: [PATCH 2/2] fix whitespace --- .../regress/sql/non_super_user_create_existing_extension.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 134b9a5d628..0d50d428aa2 100644 --- a/src/test/regress/sql/non_super_user_create_existing_extension.sql +++ b/src/test/regress/sql/non_super_user_create_existing_extension.sql @@ -11,4 +11,4 @@ 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 +DROP SCHEMA non_super_user_create_existing_extension CASCADE;