mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-09 08:10:09 +08:00
Add more tests for CREATE SUBSCRIPTION
Add some tests for parsing different option combinations. Fix some of the resulting error messages for recent changes in option naming. Author: Masahiko Sawada <sawada.mshk@gmail.com>
This commit is contained in:
parent
9485516ea2
commit
3db22794b7
@ -181,17 +181,17 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
|
||||
if (enabled && *enabled_given && *enabled)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("noconnect and enabled are mutually exclusive options")));
|
||||
errmsg("connect = false and enabled = true are mutually exclusive options")));
|
||||
|
||||
if (create_slot && create_slot_given && *create_slot)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("noconnect and create slot are mutually exclusive options")));
|
||||
errmsg("connect = false and create_slot = true are mutually exclusive options")));
|
||||
|
||||
if (copy_data && copy_data_given && *copy_data)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("noconnect and copy data are mutually exclusive options")));
|
||||
errmsg("connect = false and copy_data = true are mutually exclusive options")));
|
||||
|
||||
/* Change the defaults of other options. */
|
||||
*enabled = false;
|
||||
@ -208,12 +208,12 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
|
||||
if (enabled && *enabled_given && *enabled)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("slot_name = NONE and enabled are mutually exclusive options")));
|
||||
errmsg("slot_name = NONE and enabled = true are mutually exclusive options")));
|
||||
|
||||
if (create_slot && create_slot_given && *create_slot)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("slot_name = NONE and create slot are mutually exclusive options")));
|
||||
errmsg("slot_name = NONE and create_slot = true are mutually exclusive options")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,26 @@ SET SESSION AUTHORIZATION 'regress_subscription_user2';
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (connect = false);
|
||||
ERROR: must be superuser to create subscriptions
|
||||
SET SESSION AUTHORIZATION 'regress_subscription_user';
|
||||
-- fail - invalid option combinations
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false, copy_data = true);
|
||||
ERROR: connect = false and copy_data = true are mutually exclusive options
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false, enabled = true);
|
||||
ERROR: connect = false and enabled = true are mutually exclusive options
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false, create_slot = true);
|
||||
ERROR: connect = false and create_slot = true are mutually exclusive options
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, enabled = true);
|
||||
ERROR: slot_name = NONE and enabled = true are mutually exclusive options
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, create_slot = true);
|
||||
ERROR: slot_name = NONE and create_slot = true are mutually exclusive options
|
||||
-- ok - with slot_name = NONE
|
||||
CREATE SUBSCRIPTION testsub3 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, connect = false);
|
||||
WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables
|
||||
-- fail
|
||||
ALTER SUBSCRIPTION testsub3 ENABLE;
|
||||
ERROR: cannot enable subscription that does not have a slot name
|
||||
ALTER SUBSCRIPTION testsub3 REFRESH PUBLICATION;
|
||||
ERROR: ALTER SUBSCRIPTION ... REFRESH is not allowed for disabled subscriptions
|
||||
DROP SUBSCRIPTION testsub3;
|
||||
-- fail - invalid connection string
|
||||
ALTER SUBSCRIPTION testsub CONNECTION 'foobar';
|
||||
ERROR: invalid connection string syntax: missing "=" after "foobar" in connection info string
|
||||
|
@ -38,6 +38,21 @@ SET SESSION AUTHORIZATION 'regress_subscription_user2';
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (connect = false);
|
||||
SET SESSION AUTHORIZATION 'regress_subscription_user';
|
||||
|
||||
-- fail - invalid option combinations
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false, copy_data = true);
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false, enabled = true);
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false, create_slot = true);
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, enabled = true);
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, create_slot = true);
|
||||
|
||||
-- ok - with slot_name = NONE
|
||||
CREATE SUBSCRIPTION testsub3 CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, connect = false);
|
||||
-- fail
|
||||
ALTER SUBSCRIPTION testsub3 ENABLE;
|
||||
ALTER SUBSCRIPTION testsub3 REFRESH PUBLICATION;
|
||||
|
||||
DROP SUBSCRIPTION testsub3;
|
||||
|
||||
-- fail - invalid connection string
|
||||
ALTER SUBSCRIPTION testsub CONNECTION 'foobar';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user