pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15343: Segmentation fault using pg_dump with --exclude-table if table contains identity column
9+ messages / 5 participants
[nested] [flat]
* BUG #15343: Segmentation fault using pg_dump with --exclude-table if table contains identity column
@ 2018-08-20 19:38 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 9+ messages in thread
From: PG Bug reporting form @ 2018-08-20 19:38 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: abelisto@gmail.com
The following bug has been logged on the website:
Bug reference: 15343
Logged by: Andy Abelisto
Email address: abelisto@gmail.com
PostgreSQL version: 10.5
Operating system: Linux Mint 19 Tara
Description:
To reproduce:
$ createdb foo
$ psql foo -c "create table bar(i int generated by default as identity
primary key);"
$ pg_dump foo --exclude-table=bar
Segmentation fault (core dumped)
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #15343: Segmentation fault using pg_dump with --exclude-table if table contains identity column
@ 2018-08-21 00:37 David Rowley <david.rowley@2ndquadrant.com>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 9+ messages in thread
From: David Rowley @ 2018-08-21 00:37 UTC (permalink / raw)
To: abelisto@gmail.com; pgsql-bugs@lists.postgresql.org
> To reproduce:
> $ createdb foo
> $ psql foo -c "create table bar(i int generated by default as identity
> primary key);"
> $ pg_dump foo --exclude-table=bar
> Segmentation fault (core dumped)
This crashes during dumpSequence() when the owning_tab's attnames are
accessed. This array is NULL since we didn't populate it in
getTableAttrs due to the table being !interesting.
I think the fix depends exactly on what we want the behaviour to be
here. Should dumpSequence() still dump out a CREATE SEQUENCE
statement for this, or should we just ignore the sequence? I imagine
we should just ignore identity sequences when we're not going to dump
the table that owns them. It looks like that would require a small
modification in getOwnedSeqs(). Otherwise we'd need something like
the attached to still dump out the CREATE SEQUENCE.
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachments:
[application/octet-stream] pg_dump_seq_fix.patch (1.3K, ../../CAKJS1f_RzF8s5Osi2ae3fMMnBOv=zZSw51OJ1iPur=07d0Sw-w@mail.gmail.com/2-pg_dump_seq_fix.patch)
download | inline diff:
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d5f1269f93..fbf4e1356b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -16738,6 +16738,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
PQExpBuffer query = createPQExpBuffer();
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
+ TableInfo *owning_tab;
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
@@ -16849,10 +16850,13 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
tbinfo->dobj.catId.oid);
}
- if (tbinfo->is_identity_sequence)
+ /*
+ * Only dump the ALTER TABLE portion if the table is not to be excluded
+ * from the dump.
+ */
+ if (tbinfo->is_identity_sequence &&
+ (owning_tab = findTableByOid(tbinfo->owning_tab))->interesting)
{
- TableInfo *owning_tab = findTableByOid(tbinfo->owning_tab);
-
appendPQExpBuffer(query,
"ALTER TABLE %s ",
fmtQualifiedDumpable(owning_tab));
@@ -16895,7 +16899,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
" CACHE %s%s",
cache, (cycled ? "\n CYCLE" : ""));
- if (tbinfo->is_identity_sequence)
+ if (tbinfo->is_identity_sequence && owning_tab->interesting)
appendPQExpBufferStr(query, "\n);\n");
else
appendPQExpBufferStr(query, ";\n");
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #15343: Segmentation fault using pg_dump with --exclude-table if table contains identity column
@ 2018-08-21 01:19 Alvaro Herrera <alvherre@2ndquadrant.com>
parent: David Rowley <david.rowley@2ndquadrant.com>
0 siblings, 1 reply; 9+ messages in thread
From: Alvaro Herrera @ 2018-08-21 01:19 UTC (permalink / raw)
To: David Rowley <david.rowley@2ndquadrant.com>; +Cc: abelisto@gmail.com; pgsql-bugs@lists.postgresql.org
On 2018-Aug-21, David Rowley wrote:
> > To reproduce:
> > $ createdb foo
> > $ psql foo -c "create table bar(i int generated by default as identity
> > primary key);"
> > $ pg_dump foo --exclude-table=bar
> > Segmentation fault (core dumped)
> I think the fix depends exactly on what we want the behaviour to be
> here. Should dumpSequence() still dump out a CREATE SEQUENCE
> statement for this, or should we just ignore the sequence? I imagine
> we should just ignore identity sequences when we're not going to dump
> the table that owns them. It looks like that would require a small
> modification in getOwnedSeqs().
Yeah, we should omit the sequence too. I don't see any principled
reason to think that the sequence is interesting on its own.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #15343: Segmentation fault using pg_dump with --exclude-table if table contains identity column
@ 2018-08-21 01:49 Michael Paquier <michael@paquier.xyz>
parent: Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 9+ messages in thread
From: Michael Paquier @ 2018-08-21 01:49 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: David Rowley <david.rowley@2ndquadrant.com>; abelisto@gmail.com; pgsql-bugs@lists.postgresql.org
On Mon, Aug 20, 2018 at 10:19:49PM -0300, Alvaro Herrera wrote:
> Yeah, we should omit the sequence too. I don't see any principled
> reason to think that the sequence is interesting on its own.
I was just looking at this issue, or both of you are already on it?
--
Michael
Attachments:
[application/pgp-signature] signature.asc (832B, ../../20180821014944.GC2897@paquier.xyz/2-signature.asc)
download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #15343: Segmentation fault using pg_dump with --exclude-table if table contains identity column
@ 2018-08-21 05:46 David Rowley <david.rowley@2ndquadrant.com>
parent: Michael Paquier <michael@paquier.xyz>
0 siblings, 2 replies; 9+ messages in thread
From: David Rowley @ 2018-08-21 05:46 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; abelisto@gmail.com; pgsql-bugs@lists.postgresql.org
On 21 August 2018 at 13:49, Michael Paquier <michael@paquier.xyz> wrote:
> On Mon, Aug 20, 2018 at 10:19:49PM -0300, Alvaro Herrera wrote:
>> Yeah, we should omit the sequence too. I don't see any principled
>> reason to think that the sequence is interesting on its own.
>
> I was just looking at this issue, or both of you are already on it?
It's already in my head what it should look like, so I can write it,
although it might not appear until tomorrow, as I've reached the end
of my day now.
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #15343: Segmentation fault using pg_dump with --exclude-table if table contains identity column
@ 2018-08-21 06:24 Michael Paquier <michael@paquier.xyz>
parent: David Rowley <david.rowley@2ndquadrant.com>
1 sibling, 0 replies; 9+ messages in thread
From: Michael Paquier @ 2018-08-21 06:24 UTC (permalink / raw)
To: David Rowley <david.rowley@2ndquadrant.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; abelisto@gmail.com; pgsql-bugs@lists.postgresql.org
On Tue, Aug 21, 2018 at 05:46:56PM +1200, David Rowley wrote:
> It's already in my head what it should look like, so I can write it,
> although it might not appear until tomorrow, as I've reached the end
> of my day now.
Nice to hear. Please feel free to post at your convenient time if you
have something.
--
Michael
Attachments:
[application/pgp-signature] signature.asc (832B, ../../20180821062407.GI2897@paquier.xyz/2-signature.asc)
download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #15343: Segmentation fault using pg_dump with --exclude-table if table contains identity column
@ 2018-08-21 11:12 David Rowley <david.rowley@2ndquadrant.com>
parent: David Rowley <david.rowley@2ndquadrant.com>
1 sibling, 1 reply; 9+ messages in thread
From: David Rowley @ 2018-08-21 11:12 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; ND Abelisto <abelisto@gmail.com>; pgsql-bugs@lists.postgresql.org
On 21 August 2018 at 17:46, David Rowley <david.rowley@2ndquadrant.com> wrote:
> On 21 August 2018 at 13:49, Michael Paquier <michael@paquier.xyz> wrote:
>> I was just looking at this issue, or both of you are already on it?
>
> It's already in my head what it should look like, so I can write it,
> although it might not appear until tomorrow, as I've reached the end
> of my day now.
I've attached what I had in mind. The header comment for
getOwnedSeqs() gives me the impression this is the best place to
locate this code.
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachments:
[application/octet-stream] pg_dump_identity_seq_fix.patch (1.0K, ../../CAKJS1f-5m+RXkRQbGh7AKng5mcW_68aP9uytHKCP5bFyRmBJDQ@mail.gmail.com/2-pg_dump_identity_seq_fix.patch)
download | inline diff:
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d5f1269f93..89056207b9 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -6636,8 +6636,20 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
seqinfo->owning_tab, seqinfo->dobj.catId.oid);
/*
- * We need to dump the components that are being dumped for the table
- * and any components which the sequence is explicitly marked with.
+ * Only dump identity sequences if we're going to dump the table that
+ * it belongs to.
+ */
+ if (owning_tab->dobj.dump == DUMP_COMPONENT_NONE &&
+ seqinfo->is_identity_sequence)
+ {
+ seqinfo->dobj.dump = DUMP_COMPONENT_NONE;
+ continue;
+ }
+
+ /*
+ * Otherwise we need to dump the components that are being dumped for
+ * the table and any components which the sequence is explicitly
+ * marked with.
*
* We can't simply use the set of components which are being dumped
* for the table as the table might be in an extension (and only the
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #15343: Segmentation fault using pg_dump with --exclude-table if table contains identity column
@ 2018-08-21 13:01 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
parent: David Rowley <david.rowley@2ndquadrant.com>
0 siblings, 1 reply; 9+ messages in thread
From: Peter Eisentraut @ 2018-08-21 13:01 UTC (permalink / raw)
To: David Rowley <david.rowley@2ndquadrant.com>; Michael Paquier <michael@paquier.xyz>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; ND Abelisto <abelisto@gmail.com>; pgsql-bugs@lists.postgresql.org
On 21/08/2018 13:12, David Rowley wrote:
> On 21 August 2018 at 17:46, David Rowley <david.rowley@2ndquadrant.com> wrote:
>> On 21 August 2018 at 13:49, Michael Paquier <michael@paquier.xyz> wrote:
>>> I was just looking at this issue, or both of you are already on it?
>>
>> It's already in my head what it should look like, so I can write it,
>> although it might not appear until tomorrow, as I've reached the end
>> of my day now.
>
> I've attached what I had in mind. The header comment for
> getOwnedSeqs() gives me the impression this is the best place to
> locate this code.
Yes, that looks good to me.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #15343: Segmentation fault using pg_dump with --exclude-table if table contains identity column
@ 2018-08-22 05:24 Michael Paquier <michael@paquier.xyz>
parent: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
0 siblings, 0 replies; 9+ messages in thread
From: Michael Paquier @ 2018-08-22 05:24 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: David Rowley <david.rowley@2ndquadrant.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; ND Abelisto <abelisto@gmail.com>; pgsql-bugs@lists.postgresql.org
On Tue, Aug 21, 2018 at 03:01:49PM +0200, Peter Eisentraut wrote:
> On 21/08/2018 13:12, David Rowley wrote:
>> I've attached what I had in mind. The header comment for
>> getOwnedSeqs() gives me the impression this is the best place to
>> locate this code.
>
> Yes, that looks good to me.
This got through the TAP tests because exclude_test_table only considers
dump_test.test_table as the table to exclude when processing the dumps.
I have tried to plug in a new column into this relation but that's
proving to be a hassle with a lot of test dependencies in need to be
changed. Trying to add a new field in full_runs is also a PITA, as that
means adding a bunch of individual markers for each test. The nicest
way I could think of would be to be able to pass down parameters to a
given run flag, but that would require more infrastructure. I have
checked as well if an identity column within a table's extension, and
that's working as expected.
So committed the proposed fix and back-patched down to 10.
--
Michael
Attachments:
[application/pgp-signature] signature.asc (832B, ../../20180822052431.GB4333@paquier.xyz/2-signature.asc)
download
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2018-08-22 05:24 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-20 19:38 BUG #15343: Segmentation fault using pg_dump with --exclude-table if table contains identity column PG Bug reporting form <noreply@postgresql.org>
2018-08-21 00:37 ` David Rowley <david.rowley@2ndquadrant.com>
2018-08-21 01:19 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2018-08-21 01:49 ` Michael Paquier <michael@paquier.xyz>
2018-08-21 05:46 ` David Rowley <david.rowley@2ndquadrant.com>
2018-08-21 06:24 ` Michael Paquier <michael@paquier.xyz>
2018-08-21 11:12 ` David Rowley <david.rowley@2ndquadrant.com>
2018-08-21 13:01 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2018-08-22 05:24 ` Michael Paquier <michael@paquier.xyz>
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