Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc7f3c41

Browse files
committed
Fix possible crash in pg_dump with identity sequences.
If an owned sequence is considered interesting, force its owningtable to be marked interesting too. This ensures, in particular,that we'll fetch the owning table's column names so we have thedata needed for ALTER TABLE ... ADD GENERATED. Previously there wereedge cases where pg_dump could get SIGSEGV due to not having filled inthe column names. (The known case is where the owning table has beenmade part of an extension while its identity sequence is not a member;but there may be others.)Also, if it's an identity sequence, force its dumped-components maskto exactly match the owning table: dump definition only if we'redumping the table's definition, dump data only if we're dumping thetable's data, etc. This generalizes the code introduced in commitb965f26 that set the sequence's dump mask to NONE if the owningtable's mask is NONE. That's insufficient to prevent failures,because for example the table's mask might only request dumping ACLs,which would lead us to still emit ALTER TABLE ADD GENERATED eventhough we didn't create the table. It seems better to treat anidentity sequence as though it were an inseparable aspect of thetable, matching the treatment used in the backend's dependency logic.Perhaps this policy needs additional refinement, but let's wait tosee some field use-cases before changing it further.While here, add a comment in pg_dump.h warning against writing testslike "if (dobj->dump == DUMP_COMPONENT_NONE)", which was a bug in thiscase. There is one other example in getPublicationNamespaces, whichif it's not a bug is at least remarkably unclear and under-documented.Changing that requires a separate discussion, however.Per report from Artur Zakirov. Back-patch to all supported branches.Discussion:https://postgr.es/m/CAKNkYnwXFBf136=u9UqUxFUVagevLQJ=zGd5BsLhCsatDvQsKQ@mail.gmail.com
1 parent4abf615 commitc7f3c41

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7227,20 +7227,15 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
72277227
seqinfo->owning_tab, seqinfo->dobj.catId.oid);
72287228

72297229
/*
7230-
* Only dump identity sequences if we're going to dump the table that
7231-
* it belongs to.
7232-
*/
7233-
if (owning_tab->dobj.dump == DUMP_COMPONENT_NONE &&
7234-
seqinfo->is_identity_sequence)
7235-
{
7236-
seqinfo->dobj.dump = DUMP_COMPONENT_NONE;
7237-
continue;
7238-
}
7239-
7240-
/*
7241-
* Otherwise we need to dump the components that are being dumped for
7242-
* the table and any components which the sequence is explicitly
7243-
* marked with.
7230+
* For an identity sequence, dump exactly the same components for the
7231+
* sequence as for the owning table. This is important because we
7232+
* treat the identity sequence as an integral part of the table. For
7233+
* example, there is not any DDL command that allows creation of such
7234+
* a sequence independently of the table.
7235+
*
7236+
* For other owned sequences such as serial sequences, we need to dump
7237+
* the components that are being dumped for the table and any
7238+
* components that the sequence is explicitly marked with.
72447239
*
72457240
* We can't simply use the set of components which are being dumped
72467241
* for the table as the table might be in an extension (and only the
@@ -7253,10 +7248,17 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
72537248
* marked by checkExtensionMembership() and this will be a no-op as
72547249
* the table will be equivalently marked.
72557250
*/
7256-
seqinfo->dobj.dump = seqinfo->dobj.dump | owning_tab->dobj.dump;
7251+
if (seqinfo->is_identity_sequence)
7252+
seqinfo->dobj.dump = owning_tab->dobj.dump;
7253+
else
7254+
seqinfo->dobj.dump |= owning_tab->dobj.dump;
72577255

7256+
/* Make sure that necessary data is available if we're dumping it */
72587257
if (seqinfo->dobj.dump != DUMP_COMPONENT_NONE)
7258+
{
72597259
seqinfo->interesting = true;
7260+
owning_tab->interesting = true;
7261+
}
72607262
}
72617263
}
72627264

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp