From: Stephen Frost <sfrost@snowman.net>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [COMMITTERS] pgsql: Add pg_sequence system catalog
Date: Thu, 19 Jan 2017 11:03:05 -0500
Message-ID: <20170119160305.GS18360@tamriel.snowman.net> (raw)
In-Reply-To: <E1cJKgv-0004eC-KE@gemulon.postgresql.org>
References: <E1cJKgv-0004eC-KE@gemulon.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Peter,
* Peter Eisentraut (peter_e@gmx.net) wrote:
> Add pg_sequence system catalog
The query this added to dumpSequence() seems to think that sequence
names are unique across databases:
appendPQExpBuffer(query,
"SELECT seqstart, seqincrement, "
"CASE WHEN seqincrement > 0 AND seqmax = %s THEN NULL "
" WHEN seqincrement < 0 AND seqmax = -1 THEN NULL "
" ELSE seqmax "
"END AS seqmax, "
"CASE WHEN seqincrement > 0 AND seqmin = 1 THEN NULL "
" WHEN seqincrement < 0 AND seqmin = %s THEN NULL "
" ELSE seqmin "
"END AS seqmin, "
"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);
Note that tbinfo->dobj.name contains just the name, and trying to match
based on just 'relname' isn't going to work since sequences with the
same name can exist in difference schemas.
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. As is, this
query will also fail if a user has created a 'pg_class' or
'pg_sequence' table in their schema.
Thanks!
Stephen
Attachments:
signature.asc (application/pgp-signature, 818B) 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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: sfrost@snowman.net, peter_e@gmx.net
Subject: Re: [COMMITTERS] pgsql: Add pg_sequence system catalog
In-Reply-To: <20170119160305.GS18360@tamriel.snowman.net>
* 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