postgresql/src/backend
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
..
access Simplify some ERROR paths clearing wait events and transient files 2019-04-17 09:51:45 +09:00
bootstrap tableam: relation creation, VACUUM FULL/CLUSTER, SET TABLESPACE. 2019-03-28 20:01:43 -07:00
catalog Return NULL for checksum failures if checksums are not enabled 2019-04-17 13:51:48 +02:00
commands Fix potential use-after-free for BEFORE UPDATE row triggers on non-core AMs. 2019-04-18 17:53:54 -07:00
executor Fix problems with auto-held portals. 2019-04-19 11:20:37 -04:00
foreign Update copyright for 2019 2019-01-02 12:44:25 -05:00
jit Fix collection of typos and grammar mistakes in docs and comments 2019-04-19 16:57:40 +09:00
lib Fix example in comment. 2019-04-09 08:33:42 +03:00
libpq Fix assorted minor bogosity in GSSAPI transport error messages. 2019-04-17 17:06:50 -04:00
main Replace @postgresql.org with @lists.postgresql.org for mailinglists 2019-01-19 19:06:35 +01:00
nodes Use Append rather than MergeAppend for scanning ordered partitions. 2019-04-05 19:20:43 -04:00
optimizer Fix collection of typos and grammar mistakes in docs and comments 2019-04-19 16:57:40 +09:00
parser Fix backwards test in operator_precedence_warning logic. 2019-04-10 19:02:21 -04:00
partitioning Fix failure with textual partition hash keys. 2019-04-15 16:47:09 -04:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Consistently test for in-use shared memory. 2019-04-12 22:36:38 -07:00
postmaster Consistently test for in-use shared memory. 2019-04-12 22:36:38 -07:00
regex Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
replication Fix thinko introduced by 82a5649 in slot.c 2019-04-17 10:01:22 +09:00
rewrite Perform RLS subquery checks as the right user when going via a view. 2019-04-02 08:13:59 +01:00
snowball Update copyright for 2019 2019-01-02 12:44:25 -05:00
statistics Fix pg_mcv_list deserialization 2019-04-16 00:01:39 +02:00
storage Simplify some ERROR paths clearing wait events and transient files 2019-04-17 09:51:45 +09:00
tcop Define WIN32_STACK_RLIMIT throughout win32 and cygwin builds. 2019-04-09 08:25:39 -07:00
tsearch Fix more strcmp() calls using boolean-like comparisons for result checks 2019-04-12 10:16:49 +09:00
utils Fix problems with auto-held portals. 2019-04-19 11:20:37 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00