summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2017-05-08 18:01:00 +0000
committerPeter Eisentraut2017-05-08 18:01:00 +0000
commitfe974cc5a69903e9f53b36d6e2709fd3de0a1ac7 (patch)
treeba6ed5745ed39bd63affbc1af498a2d5eb652a4b
parentc89d2d0204f25e556e94dabd0fd5174cf6963b1d (diff)
Check connection info string in ALTER SUBSCRIPTION
Previously it would allow an invalid connection string to be set. Author: Petr Jelinek <[email protected]> Reported-by: tushar <[email protected]>
-rw-r--r--src/backend/commands/subscriptioncmds.c5
-rw-r--r--src/test/regress/expected/subscription.out4
-rw-r--r--src/test/regress/sql/subscription.sql3
3 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index ee0983fd87..fde9e6e20c 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -653,6 +653,11 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
}
case ALTER_SUBSCRIPTION_CONNECTION:
+ /* Load the library providing us libpq calls. */
+ load_file("libpqwalreceiver", false);
+ /* Check the connection info string. */
+ walrcv_check_conninfo(stmt->conninfo);
+
values[Anum_pg_subscription_subconninfo - 1] =
CStringGetTextDatum(stmt->conninfo);
replaces[Anum_pg_subscription_subconninfo - 1] = true;
diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out
index b1686db12e..fd09f54548 100644
--- a/src/test/regress/expected/subscription.out
+++ b/src/test/regress/expected/subscription.out
@@ -45,6 +45,10 @@ SET SESSION AUTHORIZATION 'regress_subscription_user2';
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT);
ERROR: must be superuser to create subscriptions
SET SESSION AUTHORIZATION 'regress_subscription_user';
+-- fail - invalid connection string
+ALTER SUBSCRIPTION testsub CONNECTION 'foobar';
+ERROR: invalid connection string syntax: missing "=" after "foobar" in connection info string
+
\dRs+
List of subscriptions
Name | Owner | Enabled | Publication | Synchronous commit | Conninfo
diff --git a/src/test/regress/sql/subscription.sql b/src/test/regress/sql/subscription.sql
index 1b30d150ce..db05f523a2 100644
--- a/src/test/regress/sql/subscription.sql
+++ b/src/test/regress/sql/subscription.sql
@@ -38,6 +38,9 @@ SET SESSION AUTHORIZATION 'regress_subscription_user2';
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT);
SET SESSION AUTHORIZATION 'regress_subscription_user';
+-- fail - invalid connection string
+ALTER SUBSCRIPTION testsub CONNECTION 'foobar';
+
\dRs+
ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 NOREFRESH;