Commit fe974cc5 authored by Peter Eisentraut's avatar Peter Eisentraut

Check connection info string in ALTER SUBSCRIPTION

Previously it would allow an invalid connection string to be set.

Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Reported-by: default avatartushar <tushar.ahuja@enterprisedb.com>
parent c89d2d02
...@@ -653,6 +653,11 @@ AlterSubscription(AlterSubscriptionStmt *stmt) ...@@ -653,6 +653,11 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
} }
case ALTER_SUBSCRIPTION_CONNECTION: 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] = values[Anum_pg_subscription_subconninfo - 1] =
CStringGetTextDatum(stmt->conninfo); CStringGetTextDatum(stmt->conninfo);
replaces[Anum_pg_subscription_subconninfo - 1] = true; replaces[Anum_pg_subscription_subconninfo - 1] = true;
......
...@@ -45,6 +45,10 @@ SET SESSION AUTHORIZATION 'regress_subscription_user2'; ...@@ -45,6 +45,10 @@ SET SESSION AUTHORIZATION 'regress_subscription_user2';
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT); CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT);
ERROR: must be superuser to create subscriptions ERROR: must be superuser to create subscriptions
SET SESSION AUTHORIZATION 'regress_subscription_user'; 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+ \dRs+
List of subscriptions List of subscriptions
Name | Owner | Enabled | Publication | Synchronous commit | Conninfo Name | Owner | Enabled | Publication | Synchronous commit | Conninfo
......
...@@ -38,6 +38,9 @@ SET SESSION AUTHORIZATION 'regress_subscription_user2'; ...@@ -38,6 +38,9 @@ SET SESSION AUTHORIZATION 'regress_subscription_user2';
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT); CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT);
SET SESSION AUTHORIZATION 'regress_subscription_user'; SET SESSION AUTHORIZATION 'regress_subscription_user';
-- fail - invalid connection string
ALTER SUBSCRIPTION testsub CONNECTION 'foobar';
\dRs+ \dRs+
ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 NOREFRESH; ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 NOREFRESH;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment