]> granicus.if.org Git - postgresql/commitdiff
Check connection info string in ALTER SUBSCRIPTION
authorPeter Eisentraut <peter_e@gmx.net>
Mon, 8 May 2017 18:01:00 +0000 (14:01 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Mon, 8 May 2017 18:01:00 +0000 (14:01 -0400)
Previously it would allow an invalid connection string to be set.

Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Reported-by: tushar <tushar.ahuja@enterprisedb.com>
src/backend/commands/subscriptioncmds.c
src/test/regress/expected/subscription.out
src/test/regress/sql/subscription.sql

index ee0983fd87e09e9847c12bf500a8c3305e9bd2ff..fde9e6e20cd108152b2d83c69a366008f4f9f42c 100644 (file)
@@ -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;
index b1686db12ecba1d04c6c055f4868845a527b5539..fd09f54548480afbc7307c8c7c6b2bd643bc69d9 100644 (file)
@@ -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       
index 1b30d150cea15f5d3f04975695c87de73488c26f..db05f523a2bcf0f1d222bc98c2a1aec4e50e3474 100644 (file)
@@ -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;