postgresql/src
Tom Lane 77e760d5cc Avoid crash when rolling back within a prepared statement.
If a portal is used to run a prepared CALL or DO statement that
contains a ROLLBACK, PortalRunMulti fails because the portal's
statement list gets cleared by the rollback.  (Since the grammar
doesn't allow CALL/DO in PREPARE, the only easy way to get to this is
via extended query protocol, which treats all inputs as prepared
statements.)  It's difficult to avoid resetting the portal early
because of resource-management issues, so work around this by teaching
PortalRunMulti to be wary of portal->stmts having suddenly become NIL.

The crash has only been seen to occur in v13 and HEAD (as a
consequence of commit 1cff1b95a having added an extra touch of
portal->stmts).  But even before that, the code involved touching a
List that the portal no longer has any claim on.  In the test case at
hand, the List will still exist because of another refcount on the
cached plan; but I'm far from convinced that it's impossible for the
cached plan to have been dropped by the time control gets back to
PortalRunMulti.  Hence, backpatch to v11 where nested transactions
were added.

Thomas Munro and Tom Lane, per bug #16811 from James Inform

Discussion: https://postgr.es/m/16811-c1b599b2c6c2d622@postgresql.org
2021-02-03 19:38:29 -05:00
..
backend Avoid crash when rolling back within a prepared statement. 2021-02-03 19:38:29 -05:00
bin pg_dump: Fix dumping of inherited generated columns 2021-02-03 11:58:15 +01:00
common Fix command-line colorization on Windows with VT100-compatible environments 2020-03-02 15:46:24 +09:00
fe_utils Fix parallel restore of FKs to partitioned tables 2019-10-17 09:58:01 +02:00
include Fix CREATE INDEX CONCURRENTLY for simultaneous prepared transactions. 2021-01-30 00:01:56 -08:00
interfaces Make ecpg's rjulmdy() and rmdyjul() agree with their declarations. 2021-01-28 11:17:33 -05:00
makefiles Select CFLAGS_SL at configure time, not in platform-specific Makefiles. 2019-10-21 12:32:35 -04:00
pl Remove extra increment of plpgsql's statement counter for FOR loops. 2021-02-02 14:35:25 -05:00
port Stamp 12.5. 2020-11-09 17:26:33 -05:00
template Further tweaking of PG_SYSROOT heuristics for macOS. 2021-01-20 12:07:35 -05:00
test Fix CREATE INDEX CONCURRENTLY for simultaneous prepared transactions. 2021-01-30 00:01:56 -08:00
timezone Update time zone data files to tzdata release 2021a. 2021-01-24 16:29:47 -05:00
tools backpatch "jit: Add support for LLVM 12." 2020-12-07 18:39:32 -08:00
tutorial Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
.gitignore
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Select CFLAGS_SL at configure time, not in platform-specific Makefiles. 2019-10-21 12:32:35 -04:00
Makefile.shlib Ensure static libraries have correct mod time even if ranlib messes it up. 2018-11-29 15:53:44 -05:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:05:50 +02:00