aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-05-17 12:22:56 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-05-17 12:24:48 -0400
commit3db22794b76eb0548f002f02a607ebcd101fc68e (patch)
tree040e4761c570ff3aa41a2fcb8676019397c0d33c /src
parent9485516ea2bf3b3ff36020bec03cbb752d8a204c (diff)
downloadpostgresql-3db22794b76eb0548f002f02a607ebcd101fc68e.tar.gz
postgresql-3db22794b76eb0548f002f02a607ebcd101fc68e.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/subscriptioncmds.c10
-rw-r--r--src/test/regress/expected/subscription.out20
-rw-r--r--src/test/regress/sql/subscription.sql15
3 files changed, 40 insertions, 5 deletions
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 265f2efd622..1f7274bc572 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -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")));
}
}
diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out
index 10c3644e51d..1c42013b472 100644
--- a/src/test/regress/expected/subscription.out
+++ b/src/test/regress/expected/subscription.out
@@ -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
diff --git a/src/test/regress/sql/subscription.sql b/src/test/regress/sql/subscription.sql
index 798bb0dbd31..36cdd96c775 100644
--- a/src/test/regress/sql/subscription.sql
+++ b/src/test/regress/sql/subscription.sql
@@ -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';