From 80518d272c7abb0017176c82f418fb15ff3683c1 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 26 Apr 2019 15:02:14 +0200 Subject: [PATCH v3] 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/tcop/utility.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index edf24c438c..9a6f8b496d 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -931,6 +931,12 @@ standard_ProcessUtility(PlannedStmt *pstmt, } free_parsestate(pstate); + + /* + * Make effects of commands visible, for instance so that + * PreCommit_on_commit_actions() can see it (see for example bug #15631). + */ + CommandCounterIncrement(); } /* -- 2.21.0