pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Stephen Frost <sfrost@snowman.net>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [COMMITTERS] pgsql: Add pg_sequence system catalog
Date: Tue, 24 Jan 2017 10:08:21 -0500
Message-ID: <1b722fdc-7f69-9033-2bed-34e318d61a74@2ndquadrant.com> (raw)
In-Reply-To: <20170119160305.GS18360@tamriel.snowman.net>
References: <E1cJKgv-0004eC-KE@gemulon.postgresql.org>
	<20170119160305.GS18360@tamriel.snowman.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On 1/19/17 11:03 AM, Stephen Frost wrote:
> I'd suggest using our usual approach in pg_dump, which is matching based
> on the OID, like so:
> 
> WHERE c.oid = '%u'::oid
> 
> The OID is in: tbinfo->dobj.catId.oid
> 
> Also, you should move the selectSourceSchema() into the per-version
> branches and set it to 'pg_catalog' for PG10 and up, which would allow
> you to avoid having to qualify the table names, et al.

Does the attached patch look correct to you?

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

0001-pg_dump-Fix-some-schema-issues-when-dumping-sequence.patch (text/x-patch, 2.4K) download From 96820dd460e9fe842a608d99e7a1da2f8b9ce67d Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <peter_e@gmx.net> Date: Tue, 24 Jan 2017 10:03:25 -0500 Subject: [PATCH] pg_dump: Fix some schema issues when dumping sequences In the new code for selecting sequence data from pg_sequence, set the schema to pg_catalog instead of the sequences own schema, and refer to the sequence by OID instead of name, which was missing a schema qualification. Reported-by: Stephen Frost <sfrost@snowman.net> --- src/bin/pg_dump/pg_dump.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index e3cca62bf7..b28b7e42d4 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -15873,14 +15873,14 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) PQExpBuffer delqry = createPQExpBuffer(); PQExpBuffer labelq = createPQExpBuffer(); - /* Make sure we are in proper schema */ - selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name); - snprintf(bufm, sizeof(bufm), INT64_FORMAT, PG_INT64_MIN); snprintf(bufx, sizeof(bufx), INT64_FORMAT, PG_INT64_MAX); if (fout->remoteVersion >= 100000) { + /* Make sure we are in proper schema */ + selectSourceSchema(fout, "pg_catalog"); + appendPQExpBuffer(query, "SELECT seqstart, seqincrement, " "CASE WHEN seqincrement > 0 AND seqmax = %s THEN NULL " @@ -15894,12 +15894,15 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) "seqcache, seqcycle " "FROM pg_class c " "JOIN pg_sequence s ON (s.seqrelid = c.oid) " - "WHERE relname = ", - bufx, bufm); - appendStringLiteralAH(query, tbinfo->dobj.name, fout); + "WHERE c.oid = '%u'::oid", + bufx, bufm, + tbinfo->dobj.catId.oid); } else if (fout->remoteVersion >= 80400) { + /* Make sure we are in proper schema */ + selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name); + appendPQExpBuffer(query, "SELECT start_value, increment_by, " "CASE WHEN increment_by > 0 AND max_value = %s THEN NULL " @@ -15916,6 +15919,9 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) } else { + /* Make sure we are in proper schema */ + selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name); + appendPQExpBuffer(query, "SELECT 0 AS start_value, increment_by, " "CASE WHEN increment_by > 0 AND max_value = %s THEN NULL " -- 2.11.0

view thread (11+ messages)  latest in thread

Message-ID: <1b722fdc-7f69-9033-2bed-34e318d61a74@2ndquadrant.com>
Permalink:  ../1b722fdc-7f69-9033-2bed-34e318d61a74@2ndquadrant.com/
Also on:    postgresql.org/message-id/1b722fdc-7f69-9033-2bed-34e318d61a74@2ndquadrant.com

 ·  · 

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-hackers@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com, sfrost@snowman.net
  Subject: Re: [COMMITTERS] pgsql: Add pg_sequence system catalog
  In-Reply-To: <1b722fdc-7f69-9033-2bed-34e318d61a74@2ndquadrant.com>
  References: <E1cJKgv-0004eC-KE@gemulon.postgresql.org> <20170119160305.GS18360@tamriel.snowman.net> <1b722fdc-7f69-9033-2bed-34e318d61a74@2ndquadrant.com>

* 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