From 082921f1633aa55d68d6a0b084882f4a6869cef4 Mon Sep 17 00:00:00 2001 From: Mark Dilger Date: Wed, 4 Aug 2021 14:52:49 -0700 Subject: [PATCH v5 11/12] BUGFIX This applies the unrelated patch: "Fix cache lookup error in ownership check" which has been posted to the -hackers list but has not yet been committed. Without this patch, the tests we're about to write have cache lookup failures in them, which are annoying, but also make the results nondeterministic because the error text contains variable Oid values. If this patch fails to apply, great! That probably means the bugfix has been committed and this patch is no longer needed. Discussion: https://www.postgresql.org/message-id/1F238937-7CC2-4703-A1B1-6DC225B8978A%40enterprisedb.com --- src/backend/catalog/objectaddress.c | 3 ++- src/test/regress/expected/stats_ext.out | 11 +++++++++++ src/test/regress/sql/stats_ext.sql | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c index 9882e549c4..deaabaeae9 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -2571,7 +2571,8 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address, break; case OBJECT_STATISTIC_EXT: if (!pg_statistics_object_ownercheck(address.objectId, roleid)) - aclcheck_error_type(ACLCHECK_NOT_OWNER, address.objectId); + aclcheck_error(ACLCHECK_NOT_OWNER, objtype, + NameListToString(castNode(List, object))); break; default: elog(ERROR, "unrecognized object type: %d", diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out index 7fb54de53d..90684a1454 100644 --- a/src/test/regress/expected/stats_ext.out +++ b/src/test/regress/expected/stats_ext.out @@ -67,6 +67,17 @@ DROP TABLE ext_stats_test; -- Ensure stats are dropped sanely, and test IF NOT EXISTS while at it CREATE TABLE ab1 (a INTEGER, b INTEGER, c INTEGER); CREATE STATISTICS IF NOT EXISTS ab1_a_b_stats ON a, b FROM ab1; +COMMENT ON STATISTICS ab1_a_b_stats IS 'new comment'; +CREATE ROLE temp_role; +SET SESSION AUTHORIZATION temp_role; +COMMENT ON STATISTICS ab1_a_b_stats IS 'changed comment'; +ERROR: must be owner of statistics object ab1_a_b_stats +DROP STATISTICS ab1_a_b_stats; +ERROR: must be owner of statistics object ab1_a_b_stats +ALTER STATISTICS ab1_a_b_stats RENAME TO ab1_a_b_stats_new; +ERROR: must be owner of statistics object ab1_a_b_stats +RESET SESSION AUTHORIZATION; +DROP ROLE temp_role; CREATE STATISTICS IF NOT EXISTS ab1_a_b_stats ON a, b FROM ab1; NOTICE: statistics object "ab1_a_b_stats" already exists, skipping DROP STATISTICS ab1_a_b_stats; diff --git a/src/test/regress/sql/stats_ext.sql b/src/test/regress/sql/stats_ext.sql index d563c4654c..57396184c1 100644 --- a/src/test/regress/sql/stats_ext.sql +++ b/src/test/regress/sql/stats_ext.sql @@ -48,6 +48,15 @@ DROP TABLE ext_stats_test; -- Ensure stats are dropped sanely, and test IF NOT EXISTS while at it CREATE TABLE ab1 (a INTEGER, b INTEGER, c INTEGER); CREATE STATISTICS IF NOT EXISTS ab1_a_b_stats ON a, b FROM ab1; +COMMENT ON STATISTICS ab1_a_b_stats IS 'new comment'; +CREATE ROLE temp_role; +SET SESSION AUTHORIZATION temp_role; +COMMENT ON STATISTICS ab1_a_b_stats IS 'changed comment'; +DROP STATISTICS ab1_a_b_stats; +ALTER STATISTICS ab1_a_b_stats RENAME TO ab1_a_b_stats_new; +RESET SESSION AUTHORIZATION; +DROP ROLE temp_role; + CREATE STATISTICS IF NOT EXISTS ab1_a_b_stats ON a, b FROM ab1; DROP STATISTICS ab1_a_b_stats; -- 2.21.1 (Apple Git-122.3)