From f13390a1922266906e949510b93a979bb1575b0f Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Tue, 9 Mar 2021 15:40:13 +0100 Subject: [PATCH v1] Fix sslcompression in postgres_fdw and dblink Commit f9264d1524ba deprecated sslcompression leaving the libpq option as a debug option to preserve backwards compatibility by silently eating it when passed in. postgres_fdw and dblink does however skip over debug options when validating the set of options and would thus fail with an invalid option. This teaches postgres_fdw and dblink to treat the option in the same way to avoid upgrades breaking. This reverts commit 096bbf7c934a4288c9 which was a temporary fix of the test failure in f9264d1524ba. Discussion: https://postgr.es/m/7E384D48-11C5-441B-9EC3-F7DB1F8518F6@yesql.se Discussion: https://postgr.es/m/E1lJRxU-00051U-47@gemulon.postgresql.org --- contrib/dblink/dblink.c | 13 ++++++++++--- contrib/postgres_fdw/expected/postgres_fdw.out | 3 +-- contrib/postgres_fdw/option.c | 13 ++++++++++--- contrib/postgres_fdw/sql/postgres_fdw.sql | 1 - src/interfaces/libpq/fe-connect.c | 2 +- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 3a0beaa88e..d589886aa2 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -2035,14 +2035,21 @@ dblink_fdw_validator(PG_FUNCTION_ARGS) if (!is_valid_dblink_option(options, def->defname, context)) { + StringInfoData buf; + const PQconninfoOption *opt; + + /* + * sslcompression is deprecated and should be silently ignored to + * preserve backwards compatibility. + */ + if (strcmp(def->defname, "sslcompression") == 0) + continue; + /* * Unknown option, or invalid option for the context specified, so * complain about it. Provide a hint with list of valid options * for the context. */ - StringInfoData buf; - const PQconninfoOption *opt; - initStringInfo(&buf); for (opt = options; opt->keyword; opt++) { diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out index f17f3b6c29..c2565dfc70 100644 --- a/contrib/postgres_fdw/expected/postgres_fdw.out +++ b/contrib/postgres_fdw/expected/postgres_fdw.out @@ -167,7 +167,6 @@ ALTER SERVER testserver1 OPTIONS ( sslcert 'value', sslkey 'value', sslrootcert 'value', - sslcompression 'value', sslcrl 'value', --requirepeer 'value', krbsrvname 'value', @@ -8946,7 +8945,7 @@ DO $d$ END; $d$; ERROR: invalid option "password" -HINT: Valid options in this context are: service, passfile, channel_binding, connect_timeout, dbname, host, hostaddr, port, options, application_name, keepalives, keepalives_idle, keepalives_interval, keepalives_count, tcp_user_timeout, sslmode, sslcompression, sslcert, sslkey, sslrootcert, sslcrl, sslcrldir, requirepeer, ssl_min_protocol_version, ssl_max_protocol_version, gssencmode, krbsrvname, gsslib, target_session_attrs, use_remote_estimate, fdw_startup_cost, fdw_tuple_cost, extensions, updatable, fetch_size, batch_size +HINT: Valid options in this context are: service, passfile, channel_binding, connect_timeout, dbname, host, hostaddr, port, options, application_name, keepalives, keepalives_idle, keepalives_interval, keepalives_count, tcp_user_timeout, sslmode, sslcert, sslkey, sslrootcert, sslcrl, sslcrldir, requirepeer, ssl_min_protocol_version, ssl_max_protocol_version, gssencmode, krbsrvname, gsslib, target_session_attrs, use_remote_estimate, fdw_startup_cost, fdw_tuple_cost, extensions, updatable, fetch_size, batch_size CONTEXT: SQL statement "ALTER SERVER loopback_nopw OPTIONS (ADD password 'dummypw')" PL/pgSQL function inline_code_block line 3 at EXECUTE -- If we add a password for our user mapping instead, we should get a different diff --git a/contrib/postgres_fdw/option.c b/contrib/postgres_fdw/option.c index 64698c4da3..6fb0288018 100644 --- a/contrib/postgres_fdw/option.c +++ b/contrib/postgres_fdw/option.c @@ -81,13 +81,20 @@ postgres_fdw_validator(PG_FUNCTION_ARGS) if (!is_valid_option(def->defname, catalog)) { + PgFdwOption *opt; + StringInfoData buf; + + /* + * sslcompression is deprecated and should be silently ignored to + * preserve backwards compatibility. + */ + if (strcmp(def->defname, "sslcompression") == 0) + continue; + /* * Unknown option specified, complain about it. Provide a hint * with list of valid options for the object. */ - PgFdwOption *opt; - StringInfoData buf; - initStringInfo(&buf); for (opt = postgres_fdw_options; opt->keyword; opt++) { diff --git a/contrib/postgres_fdw/sql/postgres_fdw.sql b/contrib/postgres_fdw/sql/postgres_fdw.sql index be5618f759..a143a70406 100644 --- a/contrib/postgres_fdw/sql/postgres_fdw.sql +++ b/contrib/postgres_fdw/sql/postgres_fdw.sql @@ -181,7 +181,6 @@ ALTER SERVER testserver1 OPTIONS ( sslcert 'value', sslkey 'value', sslrootcert 'value', - sslcompression 'value', sslcrl 'value', --requirepeer 'value', krbsrvname 'value', diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index aeb64c5bca..318c45ec19 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -280,7 +280,7 @@ static const internalPQconninfoOption PQconninfoOptions[] = { * compatibility. */ {"sslcompression", NULL, NULL, NULL, - "SSL-Compression", "", 1, -1}, + "SSL-Compression", "D", 1, -1}, {"sslcert", "PGSSLCERT", NULL, NULL, "SSL-Client-Cert", "", 64, -- 2.21.1 (Apple Git-122.3)