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

Commit148cc01

Browse files
committed
Fix pg_dump --clean with partitioned indexes.
We'd try to drop the partitions of a partitioned index separately,which is disallowed by the backend, leading to an error duringrestore. While the error is harmless, it causes problems if youtry to use --single-transaction mode.Fortunately, there seems no need to do a DROP at all, since thepartition will go away silently when we drop either the parent indexor the partition's table. So just make the DROP conditional on notbeing a partition.Reported-by: jian he <jian.universality@gmail.com>Author: jian he <jian.universality@gmail.com>Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/CACJufxF0QSdkjFKF4di-JGWN6CSdQYEAhGPmQJJCdkSZtd=oLg@mail.gmail.comBackpatch-through: 13
1 parent4604928 commit148cc01

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17075,7 +17075,17 @@ dumpIndex(Archive *fout, const IndxInfo *indxinfo)
1707517075
qindxname);
1707617076
}
1707717077

17078-
appendPQExpBuffer(delq, "DROP INDEX %s;\n", qqindxname);
17078+
/*
17079+
* If this index is a member of a partitioned index, the backend will
17080+
* not allow us to drop it separately, so don't try. It will go away
17081+
* automatically when we drop either the index's table or the
17082+
* partitioned index. (If, in a selective restore with --clean, we
17083+
* drop neither of those, then this index will not be dropped either.
17084+
* But that's fine, and even if you think it's not, the backend won't
17085+
* let us do differently.)
17086+
*/
17087+
if (indxinfo->parentidx == 0)
17088+
appendPQExpBuffer(delq, "DROP INDEX %s;\n", qqindxname);
1707917089

1708017090
if (indxinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
1708117091
ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId,
@@ -17129,11 +17139,15 @@ dumpIndexAttach(Archive *fout, const IndexAttachInfo *attachinfo)
1712917139
fmtQualifiedDumpable(attachinfo->partitionIdx));
1713017140

1713117141
/*
17132-
* There is no point in creating a drop query as the drop is done by
17133-
* index drop. (If you think to change this, see also
17134-
* _printTocEntry().) Although this object doesn't really have
17135-
* ownership as such, set the owner field anyway to ensure that the
17136-
* command is run by the correct role at restore time.
17142+
* There is no need for a dropStmt since the drop is done implicitly
17143+
* when we drop either the index's table or the partitioned index.
17144+
* Moreover, since there's no ALTER INDEX DETACH PARTITION command,
17145+
* there's no way to do it anyway. (If you think to change this,
17146+
* consider also what to do with --if-exists.)
17147+
*
17148+
* Although this object doesn't really have ownership as such, set the
17149+
* owner field anyway to ensure that the command is run by the correct
17150+
* role at restore time.
1713717151
*/
1713817152
ArchiveEntry(fout, attachinfo->dobj.catId, attachinfo->dobj.dumpId,
1713917153
ARCHIVE_OPTS(.tag = attachinfo->dobj.name,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp