Fix potential catalog corruption with temporary identity columns
authorPeter Eisentraut
Mon, 29 Apr 2019 06:44:51 +0000 (08:44 +0200)
committerPeter Eisentraut
Mon, 29 Apr 2019 06:49:22 +0000 (08:49 +0200)
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.

Several locations for placing the new CommandCounterIncrement() call
were discussed.  This patch places it at the end of
standard_ProcessUtility().  That would also help if other commands
were to create catalog entries that some on-commit action would like
to see.

Bug: #15631
Reported-by: Serge Latyntsev
Author: Peter Eisentraut 
Reviewed-by: Michael Paquier
src/backend/tcop/utility.c

index 75faf37a71493857796571420d2462fbe27c7fcb..9e195891ce9688aaad67717304aba9108e4d8a90 100644 (file)
@@ -935,6 +935,13 @@ standard_ProcessUtility(PlannedStmt *pstmt,
    }
 
    free_parsestate(pstate);
+
+   /*
+    * Make effects of commands visible, for instance so that
+    * PreCommit_on_commit_actions() can see them (see for example bug
+    * #15631).
+    */
+   CommandCounterIncrement();
 }
 
 /*