From: Tom Lane <tgl@sss.pgh.pa.us>
To: Sergei Kornilov <sk@zsrv.org>
Cc: nekomata@olegk.ca <nekomata@olegk.ca>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #15338: pg_restore --disable-triggers --data-only AND schema for table is not set.
Date: Fri, 17 Aug 2018 16:12:09 -0400
Message-ID: <16244.1534536729@sss.pgh.pa.us> (raw)
In-Reply-To: <34444001534528891@myt5-f1576e7b5bad.qloud-c.yandex.net>
References: <153452458706.1316.5328079417086507743@wrigleys.postgresql.org>
<34444001534528891@myt5-f1576e7b5bad.qloud-c.yandex.net>
Sergei Kornilov <sk@zsrv.org> writes:
> Plain format looks good:
> /usr/lib/postgresql/10/bin/pg_dump bug15338 --disable-triggers --data-only # all ok!
> But custom and dir formats are wrong:
> /usr/lib/postgresql/10/bin/pg_dump bug15338 --disable-triggers --data-only -Fc --file bug15338.pgdump
> /usr/lib/postgresql/10/bin/pg_restore bug15338.pgdump --disable-triggers --data-only
> Produces wrong ALTER TABLE test DISABLE TRIGGER ALL, not testschema.test
That's weird [ digs ] ... oh, here's the problem:
ahprintf(AH, "ALTER TABLE %s DISABLE TRIGGER ALL;\n\n",
fmtQualifiedId(PQserverVersion(AH->connection),
te->namespace,
te->tag));
This code is fine as long as we're connected to a database (either
for dump or restore). But if we're not, AH->connection is NULL.
PQserverVersion doesn't crash, but silently returns 0 ... which
fmtQualifiedId interprets as "too old for schemas", so it doesn't
emit the schema part.
We could make a narrow fix right here (and in the matching ENABLE stanza);
but having seen this, it seems like a potentially generic problem.
I think we'd be smarter to try to fix this by-design.
In particular, since no current version of pg_dump even pretends either
to dump from pre-8.0 servers or to produce output that could be loaded
into a pre-7.3 server without adjustment, it doesn't seem like
fmtQualifiedId should consider server version at all. I was tempted
to remove its server-version argument in 64f3524e2, but refrained ---
now that seems like a mistake.
However, that doesn't work for pre-v10 since we still supported dumping
from pre-7.3 servers then, and some of the uses of fmtQualifiedId are
for commands to be sent to the source server rather than commands to
be emitted. In the back branches, probably the best thing is just to
assume that the output is for >= 7.3 when producing DISABLE/ENABLE
TRIGGERS commands.
regards, tom lane
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-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, sk@zsrv.org, nekomata@olegk.ca, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15338: pg_restore --disable-triggers --data-only AND schema for table is not set.
In-Reply-To: <16244.1534536729@sss.pgh.pa.us>
* 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