From 69ffdbf0e3fdc2ad06bda96eb9f90aeb63d4b30f Mon Sep 17 00:00:00 2001 From: Naisila Puka <37271756+naisila@users.noreply.github.com> Date: Thu, 18 Aug 2022 11:05:17 +0300 Subject: [PATCH] Uses object name in cannot distribute object error (#6186) Object type ids have changed in PG15 because of at least two added objects in the list: OBJECT_PARAMETER_ACL, OBJECT_PUBLICATION_NAMESPACE To avoid different output between pg versions, let's use the object name in the error, and put the object id in the error detail. Relevant PG commits: a0ffa885e478f5eeacc4e250e35ce25a4740c487 5a2832465fd8984d089e8c44c094e6900d987fcd --- .../metadata/pg_get_object_address_13_14_15.c | 13 ++++++++----- src/test/regress/expected/metadata_sync_helpers.out | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/backend/distributed/metadata/pg_get_object_address_13_14_15.c b/src/backend/distributed/metadata/pg_get_object_address_13_14_15.c index 03a3f0ae8..00c2da620 100644 --- a/src/backend/distributed/metadata/pg_get_object_address_13_14_15.c +++ b/src/backend/distributed/metadata/pg_get_object_address_13_14_15.c @@ -34,7 +34,8 @@ #include "mb/pg_wchar.h" #include "parser/parse_type.h" -static void ErrorIfCurrentUserCanNotDistributeObject(ObjectType type, +static void ErrorIfCurrentUserCanNotDistributeObject(char *textType, + ObjectType type, ObjectAddress *addr, Node *node, Relation *relation); @@ -372,7 +373,7 @@ PgGetObjectAddress(char *ttype, ArrayType *namearr, ArrayType *argsarr) &relation, AccessShareLock, false); /* CITUS CODE BEGIN */ - ErrorIfCurrentUserCanNotDistributeObject(type, &addr, objnode, &relation); + ErrorIfCurrentUserCanNotDistributeObject(ttype, type, &addr, objnode, &relation); /* CITUS CODE END */ @@ -394,14 +395,16 @@ PgGetObjectAddress(char *ttype, ArrayType *namearr, ArrayType *argsarr) * distribute object, if not errors out. */ static void -ErrorIfCurrentUserCanNotDistributeObject(ObjectType type, ObjectAddress *addr, - Node *node, Relation *relation) +ErrorIfCurrentUserCanNotDistributeObject(char *textType, ObjectType type, + ObjectAddress *addr, Node *node, + Relation *relation) { Oid userId = GetUserId(); if (!SupportedDependencyByCitus(addr)) { - ereport(ERROR, (errmsg("Object type %d can not be distributed by Citus", type))); + ereport(ERROR, (errmsg("%s object can not be distributed by Citus", textType), + errdetail("Object type id is %d", type))); } switch (type) diff --git a/src/test/regress/expected/metadata_sync_helpers.out b/src/test/regress/expected/metadata_sync_helpers.out index c8f518807..9800f5031 100644 --- a/src/test/regress/expected/metadata_sync_helpers.out +++ b/src/test/regress/expected/metadata_sync_helpers.out @@ -675,7 +675,7 @@ BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('publication', ARRAY['publication_test']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) FROM distributed_object_data; -ERROR: Object type 29 can not be distributed by Citus +ERROR: publication object can not be distributed by Citus ROLLBACK; -- Show that citus_internal_add_object_metadata checks the priviliges BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;