pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Ensure schema qualification in pg_restore DISABLE/ENABLE TRIGGER
Date: Fri, 17 Aug 2018 21:12:45 +0000
Message-ID: <E1fqm33-0007E8-6F@gemulon.postgresql.org> (raw)

Ensure schema qualification in pg_restore DISABLE/ENABLE TRIGGER commands.

Previously, this code blindly followed the common coding pattern of
passing PQserverVersion(AH->connection) as the server-version parameter
of fmtQualifiedId.  That works as long as we have a connection; but in
pg_restore with text output, we don't.  Instead we got a zero from
PQserverVersion, which fmtQualifiedId interpreted as "server is too old to
have schemas", and so the name went unqualified.  That still accidentally
managed to work in many cases, which is probably why this ancient bug went
undetected for so long.  It only became obvious in the wake of the changes
to force dump/restore to execute with restricted search_path.

In HEAD/v11, let's deal with this by ripping out fmtQualifiedId's server-
version behavioral dependency, and just making it schema-qualify all the
time.  We no longer support pg_dump from servers old enough to need the
ability to omit schema name, let alone restoring to them.  (Also, the few
callers outside pg_dump already didn't work with pre-schema servers.)

In older branches, that's not an acceptable solution, so instead just
tweak the DISABLE/ENABLE TRIGGER logic to ensure it will schema-qualify
its output regardless of server version.

Per bug #15338 from Oleg somebody.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/153452458706.1316.5328079417086507743@wrigleys.postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6771c932cf5a8bbb8219461066987ad3b11688ff

Modified Files
--------------
src/bin/pg_dump/parallel.c           |  2 +-
src/bin/pg_dump/pg_backup_archiver.c | 12 +++---------
src/bin/pg_dump/pg_dump.c            |  4 +---
src/bin/scripts/common.c             |  3 +--
src/bin/scripts/vacuumdb.c           |  3 +--
src/fe_utils/string_utils.c          |  9 ++++-----
src/include/fe_utils/string_utils.h  |  3 +--
7 files changed, 12 insertions(+), 24 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1fqm33-0007E8-6F@gemulon.postgresql.org>
Permalink:  ../E1fqm33-0007E8-6F@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fqm33-0007E8-6F@gemulon.postgresql.org

 · 

reply

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Ensure schema qualification in pg_restore DISABLE/ENABLE TRIGGER
  In-Reply-To: <E1fqm33-0007E8-6F@gemulon.postgresql.org>
  References: <E1fqm33-0007E8-6F@gemulon.postgresql.org>

* 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