2017-01-19 18:00:00 +01:00
|
|
|
--
|
|
|
|
-- SUBSCRIPTION
|
|
|
|
--
|
|
|
|
|
|
|
|
CREATE ROLE regress_subscription_user LOGIN SUPERUSER;
|
2017-03-25 02:48:05 +01:00
|
|
|
CREATE ROLE regress_subscription_user2;
|
2017-03-08 04:44:59 +01:00
|
|
|
CREATE ROLE regress_subscription_user_dummy LOGIN NOSUPERUSER;
|
2017-01-19 18:00:00 +01:00
|
|
|
SET SESSION AUTHORIZATION 'regress_subscription_user';
|
|
|
|
|
|
|
|
-- fail - no publications
|
|
|
|
CREATE SUBSCRIPTION testsub CONNECTION 'foo';
|
|
|
|
|
|
|
|
-- fail - no connection
|
|
|
|
CREATE SUBSCRIPTION testsub PUBLICATION foo;
|
|
|
|
|
2017-03-04 05:25:34 +01:00
|
|
|
-- fail - cannot do CREATE SUBSCRIPTION CREATE SLOT inside transaction block
|
|
|
|
BEGIN;
|
|
|
|
CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub WITH (CREATE SLOT);
|
|
|
|
COMMIT;
|
|
|
|
|
2017-03-25 02:48:05 +01:00
|
|
|
-- fail - invalid connection string
|
2017-01-19 18:00:00 +01:00
|
|
|
CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub;
|
|
|
|
|
2017-03-25 02:48:05 +01:00
|
|
|
-- fail - duplicate publications
|
|
|
|
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION foo, testpub, foo WITH (NOCONNECT);
|
|
|
|
|
|
|
|
-- ok
|
|
|
|
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (NOCONNECT);
|
|
|
|
|
2017-03-25 04:25:24 +01:00
|
|
|
COMMENT ON SUBSCRIPTION testsub IS 'test subscription';
|
|
|
|
SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
|
|
|
|
|
2017-03-25 02:48:05 +01:00
|
|
|
-- fail - name already exists
|
2017-03-23 13:36:36 +01:00
|
|
|
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (NOCONNECT);
|
2017-01-19 18:00:00 +01:00
|
|
|
|
2017-03-25 02:48:05 +01:00
|
|
|
-- fail - must be superuser
|
|
|
|
SET SESSION AUTHORIZATION 'regress_subscription_user2';
|
|
|
|
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT);
|
|
|
|
SET SESSION AUTHORIZATION 'regress_subscription_user';
|
|
|
|
|
2017-03-23 13:36:36 +01:00
|
|
|
\dRs+
|
2017-01-19 18:00:00 +01:00
|
|
|
|
2017-03-23 13:36:36 +01:00
|
|
|
ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 NOREFRESH;
|
2017-01-19 18:00:00 +01:00
|
|
|
ALTER SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist2';
|
2017-03-25 02:48:05 +01:00
|
|
|
ALTER SUBSCRIPTION testsub WITH (SLOT NAME = 'newname');
|
|
|
|
|
|
|
|
-- fail
|
|
|
|
ALTER SUBSCRIPTION doesnotexist CONNECTION 'dbname=doesnotexist2';
|
2017-01-19 18:00:00 +01:00
|
|
|
|
|
|
|
\dRs+
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
ALTER SUBSCRIPTION testsub ENABLE;
|
|
|
|
|
|
|
|
\dRs
|
|
|
|
|
|
|
|
ALTER SUBSCRIPTION testsub DISABLE;
|
|
|
|
|
|
|
|
\dRs
|
|
|
|
|
|
|
|
COMMIT;
|
|
|
|
|
2017-03-08 04:44:59 +01:00
|
|
|
-- fail - must be owner of subscription
|
|
|
|
SET ROLE regress_subscription_user_dummy;
|
|
|
|
ALTER SUBSCRIPTION testsub RENAME TO testsub_dummy;
|
|
|
|
RESET ROLE;
|
|
|
|
|
2017-03-03 16:47:04 +01:00
|
|
|
ALTER SUBSCRIPTION testsub RENAME TO testsub_foo;
|
|
|
|
|
|
|
|
\dRs
|
|
|
|
|
2017-03-15 21:52:12 +01:00
|
|
|
-- rename back to keep the rest simple
|
|
|
|
ALTER SUBSCRIPTION testsub_foo RENAME TO testsub;
|
|
|
|
|
2017-03-25 02:48:05 +01:00
|
|
|
-- fail - new owner must be superuser
|
|
|
|
ALTER SUBSCRIPTION testsub OWNER TO regress_subscription_user2;
|
|
|
|
ALTER ROLE regress_subscription_user2 SUPERUSER;
|
|
|
|
-- now it works
|
|
|
|
ALTER SUBSCRIPTION testsub OWNER TO regress_subscription_user2;
|
|
|
|
|
2017-03-04 05:25:34 +01:00
|
|
|
-- fail - cannot do DROP SUBSCRIPTION DROP SLOT inside transaction block
|
|
|
|
BEGIN;
|
|
|
|
DROP SUBSCRIPTION testsub DROP SLOT;
|
|
|
|
COMMIT;
|
|
|
|
|
|
|
|
BEGIN;
|
2017-03-15 21:52:12 +01:00
|
|
|
DROP SUBSCRIPTION testsub NODROP SLOT;
|
2017-03-04 05:25:34 +01:00
|
|
|
COMMIT;
|
2017-01-19 18:00:00 +01:00
|
|
|
|
2017-03-25 02:48:05 +01:00
|
|
|
DROP SUBSCRIPTION IF EXISTS testsub NODROP SLOT;
|
|
|
|
DROP SUBSCRIPTION testsub NODROP SLOT; -- fail
|
|
|
|
|
2017-01-19 18:00:00 +01:00
|
|
|
RESET SESSION AUTHORIZATION;
|
|
|
|
DROP ROLE regress_subscription_user;
|
2017-03-08 04:44:59 +01:00
|
|
|
DROP ROLE regress_subscription_user_dummy;
|