1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Fix segfault in ALTER PUBLICATION/SUBSCRIPTION RENAME

From: Masahiko Sawada <sawada.mshk@gmail.com>
Reported-by: Fujii Masao <masao.fujii@gmail.com>
This commit is contained in:
Peter Eisentraut
2017-03-07 22:44:59 -05:00
parent 38305398cd
commit b8957927e6
5 changed files with 30 additions and 2 deletions

View File

@ -464,7 +464,7 @@ static const ObjectPropertyType ObjectProperty[] =
InvalidAttrNumber, InvalidAttrNumber,
Anum_pg_publication_pubowner, Anum_pg_publication_pubowner,
InvalidAttrNumber, InvalidAttrNumber,
-1, ACL_KIND_PUBLICATION,
true true
}, },
{ {
@ -476,7 +476,7 @@ static const ObjectPropertyType ObjectProperty[] =
InvalidAttrNumber, InvalidAttrNumber,
Anum_pg_subscription_subowner, Anum_pg_subscription_subowner,
InvalidAttrNumber, InvalidAttrNumber,
-1, ACL_KIND_SUBSCRIPTION,
true true
} }
}; };

View File

@ -2,6 +2,7 @@
-- PUBLICATION -- PUBLICATION
-- --
CREATE ROLE regress_publication_user LOGIN SUPERUSER; CREATE ROLE regress_publication_user LOGIN SUPERUSER;
CREATE ROLE regress_publication_user_dummy LOGIN NOSUPERUSER;
SET SESSION AUTHORIZATION 'regress_publication_user'; SET SESSION AUTHORIZATION 'regress_publication_user';
CREATE PUBLICATION testpub_default; CREATE PUBLICATION testpub_default;
CREATE PUBLICATION testpib_ins_trunct WITH (nopublish delete, nopublish update); CREATE PUBLICATION testpib_ins_trunct WITH (nopublish delete, nopublish update);
@ -148,6 +149,11 @@ DROP TABLE testpub_tbl1;
t | t | t t | t | t
(1 row) (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; ALTER PUBLICATION testpub_default RENAME TO testpub_foo;
\dRp testpub_foo \dRp testpub_foo
List of publications List of publications
@ -163,3 +169,4 @@ DROP SCHEMA pub_test CASCADE;
NOTICE: drop cascades to table pub_test.testpub_nopk NOTICE: drop cascades to table pub_test.testpub_nopk
RESET SESSION AUTHORIZATION; RESET SESSION AUTHORIZATION;
DROP ROLE regress_publication_user; DROP ROLE regress_publication_user;
DROP ROLE regress_publication_user_dummy;

View File

@ -2,6 +2,7 @@
-- SUBSCRIPTION -- SUBSCRIPTION
-- --
CREATE ROLE regress_subscription_user LOGIN SUPERUSER; CREATE ROLE regress_subscription_user LOGIN SUPERUSER;
CREATE ROLE regress_subscription_user_dummy LOGIN NOSUPERUSER;
SET SESSION AUTHORIZATION 'regress_subscription_user'; SET SESSION AUTHORIZATION 'regress_subscription_user';
-- fail - no publications -- fail - no publications
CREATE SUBSCRIPTION testsub CONNECTION 'foo'; CREATE SUBSCRIPTION testsub CONNECTION 'foo';
@ -66,6 +67,11 @@ ALTER SUBSCRIPTION testsub DISABLE;
(1 row) (1 row)
COMMIT; 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; ALTER SUBSCRIPTION testsub RENAME TO testsub_foo;
\dRs \dRs
List of subscriptions List of subscriptions
@ -84,3 +90,4 @@ DROP SUBSCRIPTION testsub_foo NODROP SLOT;
COMMIT; COMMIT;
RESET SESSION AUTHORIZATION; RESET SESSION AUTHORIZATION;
DROP ROLE regress_subscription_user; DROP ROLE regress_subscription_user;
DROP ROLE regress_subscription_user_dummy;

View File

@ -2,6 +2,7 @@
-- PUBLICATION -- PUBLICATION
-- --
CREATE ROLE regress_publication_user LOGIN SUPERUSER; CREATE ROLE regress_publication_user LOGIN SUPERUSER;
CREATE ROLE regress_publication_user_dummy LOGIN NOSUPERUSER;
SET SESSION AUTHORIZATION 'regress_publication_user'; SET SESSION AUTHORIZATION 'regress_publication_user';
CREATE PUBLICATION testpub_default; CREATE PUBLICATION testpub_default;
@ -73,6 +74,11 @@ DROP TABLE testpub_tbl1;
\dRp+ testpub_default \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; ALTER PUBLICATION testpub_default RENAME TO testpub_foo;
\dRp testpub_foo \dRp testpub_foo
@ -85,3 +91,4 @@ DROP SCHEMA pub_test CASCADE;
RESET SESSION AUTHORIZATION; RESET SESSION AUTHORIZATION;
DROP ROLE regress_publication_user; DROP ROLE regress_publication_user;
DROP ROLE regress_publication_user_dummy;

View File

@ -3,6 +3,7 @@
-- --
CREATE ROLE regress_subscription_user LOGIN SUPERUSER; CREATE ROLE regress_subscription_user LOGIN SUPERUSER;
CREATE ROLE regress_subscription_user_dummy LOGIN NOSUPERUSER;
SET SESSION AUTHORIZATION 'regress_subscription_user'; SET SESSION AUTHORIZATION 'regress_subscription_user';
-- fail - no publications -- fail - no publications
@ -43,6 +44,11 @@ ALTER SUBSCRIPTION testsub DISABLE;
COMMIT; 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; ALTER SUBSCRIPTION testsub RENAME TO testsub_foo;
\dRs \dRs
@ -58,3 +64,4 @@ COMMIT;
RESET SESSION AUTHORIZATION; RESET SESSION AUTHORIZATION;
DROP ROLE regress_subscription_user; DROP ROLE regress_subscription_user;
DROP ROLE regress_subscription_user_dummy;