From: Peter Eisentraut Date: Wed, 8 Mar 2017 03:44:59 +0000 (-0500) Subject: Fix segfault in ALTER PUBLICATION/SUBSCRIPTION RENAME X-Git-Tag: REL_10_BETA1~740 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8957927e642ae15c01f985c17fd6fe00ec68069;p=postgresql Fix segfault in ALTER PUBLICATION/SUBSCRIPTION RENAME From: Masahiko Sawada Reported-by: Fujii Masao --- diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c index f2b96015bf..3a7f049247 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -464,7 +464,7 @@ static const ObjectPropertyType ObjectProperty[] = InvalidAttrNumber, Anum_pg_publication_pubowner, InvalidAttrNumber, - -1, + ACL_KIND_PUBLICATION, true }, { @@ -476,7 +476,7 @@ static const ObjectPropertyType ObjectProperty[] = InvalidAttrNumber, Anum_pg_subscription_subowner, InvalidAttrNumber, - -1, + ACL_KIND_SUBSCRIPTION, true } }; diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out index 6416fbb914..34320267c3 100644 --- a/src/test/regress/expected/publication.out +++ b/src/test/regress/expected/publication.out @@ -2,6 +2,7 @@ -- PUBLICATION -- CREATE ROLE regress_publication_user LOGIN SUPERUSER; +CREATE ROLE regress_publication_user_dummy LOGIN NOSUPERUSER; SET SESSION AUTHORIZATION 'regress_publication_user'; CREATE PUBLICATION testpub_default; CREATE PUBLICATION testpib_ins_trunct WITH (nopublish delete, nopublish update); @@ -148,6 +149,11 @@ DROP TABLE testpub_tbl1; t | t | t (1 row) +-- faile - must be owner of publication +SET ROLE regress_publication_user_dummy; +ALTER PUBLICATION testpub_default RENAME TO testpub_dummy; +ERROR: must be owner of publication testpub_default +RESET ROLE; ALTER PUBLICATION testpub_default RENAME TO testpub_foo; \dRp testpub_foo List of publications @@ -163,3 +169,4 @@ DROP SCHEMA pub_test CASCADE; NOTICE: drop cascades to table pub_test.testpub_nopk RESET SESSION AUTHORIZATION; DROP ROLE regress_publication_user; +DROP ROLE regress_publication_user_dummy; diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out index a8a61ee8af..26f0a36ff0 100644 --- a/src/test/regress/expected/subscription.out +++ b/src/test/regress/expected/subscription.out @@ -2,6 +2,7 @@ -- SUBSCRIPTION -- CREATE ROLE regress_subscription_user LOGIN SUPERUSER; +CREATE ROLE regress_subscription_user_dummy LOGIN NOSUPERUSER; SET SESSION AUTHORIZATION 'regress_subscription_user'; -- fail - no publications CREATE SUBSCRIPTION testsub CONNECTION 'foo'; @@ -66,6 +67,11 @@ ALTER SUBSCRIPTION testsub DISABLE; (1 row) COMMIT; +-- fail - must be owner of subscription +SET ROLE regress_subscription_user_dummy; +ALTER SUBSCRIPTION testsub RENAME TO testsub_dummy; +ERROR: must be owner of subscription testsub +RESET ROLE; ALTER SUBSCRIPTION testsub RENAME TO testsub_foo; \dRs List of subscriptions @@ -84,3 +90,4 @@ DROP SUBSCRIPTION testsub_foo NODROP SLOT; COMMIT; RESET SESSION AUTHORIZATION; DROP ROLE regress_subscription_user; +DROP ROLE regress_subscription_user_dummy; diff --git a/src/test/regress/sql/publication.sql b/src/test/regress/sql/publication.sql index 9563ea1857..de68e61cb3 100644 --- a/src/test/regress/sql/publication.sql +++ b/src/test/regress/sql/publication.sql @@ -2,6 +2,7 @@ -- PUBLICATION -- CREATE ROLE regress_publication_user LOGIN SUPERUSER; +CREATE ROLE regress_publication_user_dummy LOGIN NOSUPERUSER; SET SESSION AUTHORIZATION 'regress_publication_user'; CREATE PUBLICATION testpub_default; @@ -73,6 +74,11 @@ DROP TABLE testpub_tbl1; \dRp+ testpub_default +-- faile - must be owner of publication +SET ROLE regress_publication_user_dummy; +ALTER PUBLICATION testpub_default RENAME TO testpub_dummy; +RESET ROLE; + ALTER PUBLICATION testpub_default RENAME TO testpub_foo; \dRp testpub_foo @@ -85,3 +91,4 @@ DROP SCHEMA pub_test CASCADE; RESET SESSION AUTHORIZATION; DROP ROLE regress_publication_user; +DROP ROLE regress_publication_user_dummy; diff --git a/src/test/regress/sql/subscription.sql b/src/test/regress/sql/subscription.sql index 0b6c8a3f5c..d97b4f7346 100644 --- a/src/test/regress/sql/subscription.sql +++ b/src/test/regress/sql/subscription.sql @@ -3,6 +3,7 @@ -- CREATE ROLE regress_subscription_user LOGIN SUPERUSER; +CREATE ROLE regress_subscription_user_dummy LOGIN NOSUPERUSER; SET SESSION AUTHORIZATION 'regress_subscription_user'; -- fail - no publications @@ -43,6 +44,11 @@ ALTER SUBSCRIPTION testsub DISABLE; COMMIT; +-- fail - must be owner of subscription +SET ROLE regress_subscription_user_dummy; +ALTER SUBSCRIPTION testsub RENAME TO testsub_dummy; +RESET ROLE; + ALTER SUBSCRIPTION testsub RENAME TO testsub_foo; \dRs @@ -58,3 +64,4 @@ COMMIT; RESET SESSION AUTHORIZATION; DROP ROLE regress_subscription_user; +DROP ROLE regress_subscription_user_dummy;