From: Michael Paquier <michael@paquier.xyz>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: kotlarski.krzysztof@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15116: pg_recvlogical always fails
Date: Sat, 17 Mar 2018 09:32:23 +0900
Message-ID: <20180317003223.GC1532@paquier.xyz> (raw)
In-Reply-To: <20180317002026.GB1532@paquier.xyz>
References: <152121448830.1224.17250900005569274883@wrigleys.postgresql.org>
<c28a0c4f-e8e6-e618-2a6a-0915f38609b9@2ndquadrant.com>
<20180317002026.GB1532@paquier.xyz>
On Sat, Mar 17, 2018 at 09:20:26AM +0900, Michael Paquier wrote:
> At least slot creation fails. One just needs to start up an instance
> and run that for example:
> $ pg_recvlogical --create-slot -S popo -d "dbname=postgres"
> pg_recvlogical: could not clear search_path: ERROR: syntax erro
The issue is that support for plain SQL queries has been added in
PostgreSQL 10 for logical replication connections, however e170b8c8 has
missed the fact that this is not supported for older versions. Hence,
two things need to happen as pg_recvlogical needs to be kept compatible
with past server versions:
1) Make the check deciding if search_path should be enforced smarter by
checking if the server version is newer than 10. This needs to be
patched on HEAD and REL_10_STABLE. recvlogical-search-path-fix.patch
does so.
2) Simply remove the check on past branches, as I recall that we
maintain downstream compatibility, but do not for example guarantee that
a Postgres 10 server would work with a 9.6's pg_recvlogical. This is
what recvlogical-search-path-fix-96.patch attached does.
Thanks,
--
Michael
Attachments:download all (3 files, .tar.gz)recvlogical-search-path-fix.patch (text/x-diff, 685B) downloaddiff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.cindex 296b1888aa..79a1a0bdca 100644--- a/src/bin/pg_basebackup/streamutil.c+++ b/src/bin/pg_basebackup/streamutil.c@@ -209,8 +209,12 @@ GetConnection(void)
if (conn_opts)
PQconninfoFree(conn_opts);
- /* Set always-secure search path, so malicious users can't get control. */- if (dbname != NULL)+ /*+ * Set always-secure search path, so malicious users can't get control.+ * The capacity to run normal SQL queries has been added in PostgreSQL+ * 10, so this does not matter for older versions.+ */+ if (dbname != NULL && PQserverVersion(conn) >= 100000)
{
PGresult *res;
recvlogical-search-path-fix-96.patch (text/x-diff, 817B) downloaddiff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.cindex aa14dbbb75..3f3f2633ae 100644--- a/src/bin/pg_basebackup/streamutil.c+++ b/src/bin/pg_basebackup/streamutil.c@@ -209,23 +209,6 @@ GetConnection(void)
if (conn_opts)
PQconninfoFree(conn_opts);
- /* Set always-secure search path, so malicious users can't get control. */- if (dbname != NULL)- {- PGresult *res;-- res = PQexec(tmpconn, ALWAYS_SECURE_SEARCH_PATH_SQL);- if (PQresultStatus(res) != PGRES_TUPLES_OK)- {- fprintf(stderr, _("%s: could not clear search_path: %s\n"),- progname, PQerrorMessage(tmpconn));- PQclear(res);- PQfinish(tmpconn);- exit(1);- }- PQclear(res);- }-
/*
* Ensure we have the same value of integer timestamps as the server we
* are connecting to.
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: michael@paquier.xyz, peter.eisentraut@2ndquadrant.com, kotlarski.krzysztof@gmail.com
Subject: Re: BUG #15116: pg_recvlogical always fails
In-Reply-To: <20180317003223.GC1532@paquier.xyz>
References: <152121448830.1224.17250900005569274883@wrigleys.postgresql.org> <c28a0c4f-e8e6-e618-2a6a-0915f38609b9@2ndquadrant.com> <20180317002026.GB1532@paquier.xyz> <20180317003223.GC1532@paquier.xyz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox