postgresql/src/backend/utils
Tom Lane 4d5840cea9 Fix problems with auto-held portals.
HoldPinnedPortals() did things in the wrong order: it must not mark
a portal autoHeld until it's been successfully held.  Otherwise,
a failure while persisting the portal results in a server crash
because we think the portal is in a good state when it's not.

Also add a check that portal->status is READY before attempting to
hold a pinned portal.  We have such a check before the only other
use of HoldPortal(), so it seems unwise not to check it here.

Lastly, rethink the responsibility for where to call HoldPinnedPortals.
The comment for it imagined that it was optional for any individual PL
to call it or not, but that cannot be the case: if some outer level of
procedure has a pinned portal, failing to persist it when an inner
procedure commits is going to be trouble.  Let's have SPI do it instead
of the individual PLs.  That's not a complete solution, since in theory
a PL might not be using SPI to perform commit/rollback, but such a PL
is going to have to be aware of lots of related requirements anyway.
(This change doesn't cause an API break for any external PLs that might
be calling HoldPinnedPortals per the old regime, because calling it
twice during a commit or rollback sequence won't hurt.)

Per bug #15703 from Julian Schauder.  Back-patch to v11 where this code
came in.

Discussion: https://postgr.es/m/15703-c12c5bc0ea34ba26@postgresql.org
2019-04-19 11:20:37 -04:00
..
adt Minor jsonpath fixes. 2019-04-17 13:37:00 -04:00
cache Fix handling of temp and unlogged tables in FOR ALL TABLES publications 2019-04-18 08:55:55 +02:00
error Update copyright for 2019 2019-01-02 12:44:25 -05:00
fmgr Change function call information to be variable length. 2019-01-26 14:17:52 -08:00
hash Fix collection of typos and grammar mistakes in docs and comments 2019-04-19 16:57:40 +09:00
init Consistently test for in-use shared memory. 2019-04-12 22:36:38 -07:00
mb More unconstify use 2019-02-13 11:50:16 +01:00
misc postgresql.conf.sample: add proper defaults for include actions 2019-04-17 18:12:10 -04:00
mmgr Fix problems with auto-held portals. 2019-04-19 11:20:37 -04:00
resowner Enable parallel query with SERIALIZABLE isolation. 2019-03-15 17:47:04 +13:00
sort Make heap TID a tiebreaker nbtree index column. 2019-03-20 10:04:01 -07:00
time Mark correctly initial slot snapshots with MVCC type when built 2019-02-20 12:31:07 +09:00
.gitignore Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
errcodes.txt Partial implementation of SQL/JSON path language 2019-03-16 12:16:48 +03:00
Gen_dummy_probes.pl Update copyright for 2019 2019-01-02 12:44:25 -05:00
Gen_dummy_probes.sed Update copyright for 2019 2019-01-02 12:44:25 -05:00
Gen_fmgrtab.pl Use Getopt::Long for catalog scripts 2019-02-12 12:22:08 -03:00
generate-errcodes.pl Update copyright for 2019 2019-01-02 12:44:25 -05:00
Makefile Use Getopt::Long for catalog scripts 2019-02-12 12:22:08 -03:00
probes.d Update copyright for 2019 2019-01-02 12:44:25 -05:00