Redesign query-snapshot timing so that volatile functions in READ COMMITTED

Tom Lane <tgl@sss.pgh.pa.us>

Commit: b2c4071299e02ed96d48d3c8e776de2fab36f88c
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2004-09-13T20:10:13Z
Releases: 8.0.0
Redesign query-snapshot timing so that volatile functions in READ COMMITTED
mode see a fresh snapshot for each command in the function, rather than
using the latest interactive command's snapshot.  Also, suppress fresh
snapshots as well as CommandCounterIncrement inside STABLE and IMMUTABLE
functions, instead using the snapshot taken for the most closely nested
regular query.  (This behavior is only sane for read-only functions, so
the patch also enforces that such functions contain only SELECT commands.)
As per my proposal of 6-Sep-2004; I note that I floated essentially the
same proposal on 19-Jun-2002, but that discussion tailed off without any
action.  Since 8.0 seems like the right place to be taking possibly
nontrivial backwards compatibility hits, let's get it done now.

Files

PathChange+/−
contrib/tablefunc/tablefunc.c modified +4 −4
contrib/tsearch2/ts_stat.c modified +1 −1
doc/src/sgml/plpython.sgml modified +2 −2
doc/src/sgml/ref/create_function.sgml modified +6 −2
doc/src/sgml/release.sgml modified +41 −1
doc/src/sgml/spi.sgml modified +338 −78
doc/src/sgml/xfunc.sgml modified +136 −10
src/backend/access/transam/xact.c modified +7 −5
src/backend/commands/cluster.c modified +3 −3
src/backend/commands/copy.c modified +2 −5
src/backend/commands/explain.c modified +8 −4
src/backend/commands/indexcmds.c modified +3 −3
src/backend/commands/portalcmds.c modified +2 −2
src/backend/commands/prepare.c modified +5 −3
src/backend/commands/vacuum.c modified +5 −5
src/backend/executor/execMain.c modified +16 −31
src/backend/executor/functions.c modified +175 −102
src/backend/executor/spi.c modified +266 −212
src/backend/tcop/fastpath.c modified +1 −6
src/backend/tcop/postgres.c modified +7 −4
src/backend/tcop/pquery.c modified +72 −21
src/backend/tcop/utility.c modified +90 −3
src/backend/utils/adt/ri_triggers.c modified +35 −23
src/backend/utils/adt/ruleutils.c modified +3 −3
src/backend/utils/time/tqual.c modified +69 −69
src/include/executor/execdesc.h modified +5 −1
src/include/executor/executor.h modified +2 −3
src/include/executor/spi.h modified +12 −6
src/include/tcop/pquery.h modified +3 −8
src/include/tcop/utility.h modified +5 −1
src/include/utils/tqual.h modified +11 −6
src/pl/plperl/plperl.c modified +129 −24
src/pl/plperl/spi_internal.c modified +2 −83
src/pl/plperl/spi_internal.h modified +1 −0
src/pl/plpgsql/src/pl_comp.c modified +4 −1
src/pl/plpgsql/src/pl_exec.c modified +34 −18
src/pl/plpgsql/src/plpgsql.h modified +4 −1
src/pl/plpython/plpython.c modified +33 −17
src/pl/tcl/pltcl.c modified +74 −36
src/test/regress/expected/transactions.out modified +78 −0
src/test/regress/sql/transactions.sql modified +43 −0