From 4690c421219fef298cc5864d2229caafc0cede9a Mon Sep 17 00:00:00 2001 From: Halil Ozan Akgul Date: Tue, 22 Mar 2022 17:06:04 +0300 Subject: [PATCH] Fixes ALTER COLLATION encoding does not exist bug --- .../deparser/qualify_collation_stmt.c | 1 - .../expected/distributed_collations.out | 33 +++++++++++++++++++ .../regress/sql/distributed_collations.sql | 18 ++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/backend/distributed/deparser/qualify_collation_stmt.c b/src/backend/distributed/deparser/qualify_collation_stmt.c index e1fcc2b50..dad3b7a0e 100644 --- a/src/backend/distributed/deparser/qualify_collation_stmt.c +++ b/src/backend/distributed/deparser/qualify_collation_stmt.c @@ -124,7 +124,6 @@ QualifyCollationName(List *name) (Form_pg_collation) GETSTRUCT(colltup); schemaName = get_namespace_name(collationForm->collnamespace); - collationName = NameStr(collationForm->collname); name = list_make2(makeString(schemaName), makeString(collationName)); ReleaseSysCache(colltup); } diff --git a/src/test/regress/expected/distributed_collations.out b/src/test/regress/expected/distributed_collations.out index 448f7f037..21b3f7f8e 100644 --- a/src/test/regress/expected/distributed_collations.out +++ b/src/test/regress/expected/distributed_collations.out @@ -184,3 +184,36 @@ SET citus.enable_ddl_propagation TO on; CREATE COLLATION pg_temp.temp_collation (provider = icu, locale = 'de-u-co-phonebk'); WARNING: "collation pg_temp_xxx.temp_collation" has dependency on unsupported object "schema pg_temp_xxx" DETAIL: "collation pg_temp_xxx.temp_collation" will be created only locally +SET client_min_messages TO ERROR; +CREATE USER alter_collation_user; +SELECT 1 FROM run_command_on_workers('CREATE USER alter_collation_user'); + ?column? +--------------------------------------------------------------------- + 1 + 1 +(2 rows) + +RESET client_min_messages; +CREATE COLLATION alter_collation FROM "C"; +ALTER COLLATION alter_collation OWNER TO alter_collation_user; +SELECT result FROM run_command_on_all_nodes(' + SELECT collowner::regrole FROM pg_collation WHERE collname = ''alter_collation''; +'); + result +--------------------------------------------------------------------- + alter_collation_user + alter_collation_user + alter_collation_user +(3 rows) + +DROP COLLATION alter_collation; +SET client_min_messages TO ERROR; +DROP USER alter_collation_user; +SELECT 1 FROM run_command_on_workers('DROP USER alter_collation_user'); + ?column? +--------------------------------------------------------------------- + 1 + 1 +(2 rows) + +RESET client_min_messages; diff --git a/src/test/regress/sql/distributed_collations.sql b/src/test/regress/sql/distributed_collations.sql index e875de00e..6e6e35263 100644 --- a/src/test/regress/sql/distributed_collations.sql +++ b/src/test/regress/sql/distributed_collations.sql @@ -114,3 +114,21 @@ SET citus.enable_ddl_propagation TO on; -- will skip trying to propagate the collation due to temp schema CREATE COLLATION pg_temp.temp_collation (provider = icu, locale = 'de-u-co-phonebk'); + +SET client_min_messages TO ERROR; +CREATE USER alter_collation_user; +SELECT 1 FROM run_command_on_workers('CREATE USER alter_collation_user'); +RESET client_min_messages; + +CREATE COLLATION alter_collation FROM "C"; +ALTER COLLATION alter_collation OWNER TO alter_collation_user; + +SELECT result FROM run_command_on_all_nodes(' + SELECT collowner::regrole FROM pg_collation WHERE collname = ''alter_collation''; +'); + +DROP COLLATION alter_collation; +SET client_min_messages TO ERROR; +DROP USER alter_collation_user; +SELECT 1 FROM run_command_on_workers('DROP USER alter_collation_user'); +RESET client_min_messages;