postgresql/src
Tom Lane 0d18b8eb40 Fix behavior of stable functions called from a CALL's argument list.
If the CALL is within an atomic context (e.g. there's an outer
transaction block), _SPI_execute_plan should acquire a fresh snapshot
to execute any such functions with.  We failed to do that and instead
passed them the Portal snapshot, which had been acquired at the start
of the current SQL command.  This'd lead to seeing stale values of
rows modified since the start of the command.

This is arguably a bug in 84f5c2908: I failed to see that "are we in
non-atomic mode" needs to be defined the same way as it is further
down in _SPI_execute_plan, i.e. check !_SPI_current->atomic not just
options->allow_nonatomic.  Alternatively the blame could be laid on
plpgsql, which is unconditionally passing allow_nonatomic = true
for CALL/DO even when it knows it's in an atomic context.  However,
fixing it in spi.c seems like a better idea since that will also fix
the problem for any extensions that may have copied plpgsql's coding
pattern.

While here, update an obsolete comment about _SPI_execute_plan's
snapshot management.

Per report from Victor Yegorov.  Back-patch to all supported versions.

Discussion: https://postgr.es/m/CAGnEboiRe+fG2QxuBO2390F7P8e2MQ6UyBjZSL_w1Cej+E4=Vw@mail.gmail.com
2024-06-07 13:27:26 -04:00
..
backend Fix behavior of stable functions called from a CALL's argument list. 2024-06-07 13:27:26 -04:00
bin Fix query result leak during binary upgrade 2024-05-15 22:48:51 +02:00
common Fix overread in JSON parsing errors for incomplete byte sequences 2024-05-09 12:45:43 +09:00
fe_utils Fix PL/pgSQL's handling of integer ranges containing underscores. 2024-06-04 11:51:25 +01:00
include Account for optimized MinMax aggregates during SS_finalize_plan. 2024-05-18 14:31:35 -04:00
interfaces Fix PL/pgSQL's handling of integer ranges containing underscores. 2024-06-04 11:51:25 +01:00
makefiles
pl Fix behavior of stable functions called from a CALL's argument list. 2024-06-07 13:27:26 -04:00
port
template
test Fix failure with SQL-procedure polymorphic output arguments in v12. 2024-06-06 15:16:56 -04:00
timezone
tools Fix the missing table sync due to improper invalidation handling. 2024-04-25 10:52:34 +05:30
tutorial
.gitignore
DEVELOPERS
Makefile
Makefile.global.in
Makefile.shlib
meson.build
nls-global.mk