From 8b14e85ce705af1509acf696afeb8ca4c8887e1d Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 8 Mar 2019 11:34:50 +0100 Subject: [PATCH v2 1/2] Fix potential catalog corruption with temporary identity columns If a temporary table with an identity column and ON COMMIT DROP is created in a single-statement transaction (not useful, but allowed), it would leave the catalog corrupted. We need to add a CommandCounterIncrement() so that PreCommit_on_commit_actions() sees the created dependency between table and sequence and can clean it up. The analogous and more useful case of doing this in a transaction block already runs some CommandCounterIncrement() before it gets to the on-commit cleanup, so it wasn't a problem in practical use. Bug: #15631 Reported-by: Serge Latyntsev Author: Michael Paquier Reviewed-by: Peter Eisentraut --- src/backend/commands/sequence.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 574b46a281..f843502de6 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -1729,6 +1729,13 @@ process_owned_by(Relation seqrel, List *owned_by, bool for_identity) depobject.objectId = RelationGetRelid(seqrel); depobject.objectSubId = 0; recordDependencyOn(&depobject, &refobject, deptype); + + /* + * Make new dependency visible, for instance so that + * PreCommit_on_commit_actions() can see it (see for example bug + * #15631). + */ + CommandCounterIncrement(); } /* Done, but hold lock until commit */ -- 2.21.0