Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe974cc

Browse files
committed
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]>
1 parent c89d2d0 commit fe974cc

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/backend/commands/subscriptioncmds.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,11 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
653653
}
654654

655655
case ALTER_SUBSCRIPTION_CONNECTION:
656+
/* Load the library providing us libpq calls. */
657+
load_file("libpqwalreceiver", false);
658+
/* Check the connection info string. */
659+
walrcv_check_conninfo(stmt->conninfo);
660+
656661
values[Anum_pg_subscription_subconninfo - 1] =
657662
CStringGetTextDatum(stmt->conninfo);
658663
replaces[Anum_pg_subscription_subconninfo - 1] = true;

src/test/regress/expected/subscription.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ SET SESSION AUTHORIZATION 'regress_subscription_user2';
4545
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT);
4646
ERROR: must be superuser to create subscriptions
4747
SET SESSION AUTHORIZATION 'regress_subscription_user';
48+
-- fail - invalid connection string
49+
ALTER SUBSCRIPTION testsub CONNECTION 'foobar';
50+
ERROR: invalid connection string syntax: missing "=" after "foobar" in connection info string
51+
4852
\dRs+
4953
List of subscriptions
5054
Name | Owner | Enabled | Publication | Synchronous commit | Conninfo

src/test/regress/sql/subscription.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ SET SESSION AUTHORIZATION 'regress_subscription_user2';
3838
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT);
3939
SET SESSION AUTHORIZATION 'regress_subscription_user';
4040

41+
-- fail - invalid connection string
42+
ALTER SUBSCRIPTION testsub CONNECTION 'foobar';
43+
4144
\dRs+
4245

4346
ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 NOREFRESH;

0 commit comments

Comments
 (0)