Thread: pgsql-server: Redesign query-snapshot timing so that volatile functions
pgsql-server: Redesign query-snapshot timing so that volatile functions
From
tgl@svr1.postgresql.org (Tom Lane)
Date:
Log Message: ----------- 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. Modified Files: -------------- pgsql-server/contrib/tablefunc: tablefunc.c (r1.31 -> r1.32) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/contrib/tablefunc/tablefunc.c.diff?r1=1.31&r2=1.32) pgsql-server/contrib/tsearch2: ts_stat.c (r1.8 -> r1.9) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/contrib/tsearch2/ts_stat.c.diff?r1=1.8&r2=1.9) pgsql-server/doc/src/sgml: plpython.sgml (r1.23 -> r1.24) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/doc/src/sgml/plpython.sgml.diff?r1=1.23&r2=1.24) release.sgml (r1.295 -> r1.296) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/doc/src/sgml/release.sgml.diff?r1=1.295&r2=1.296) spi.sgml (r1.34 -> r1.35) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/doc/src/sgml/spi.sgml.diff?r1=1.34&r2=1.35) xfunc.sgml (r1.86 -> r1.87) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/doc/src/sgml/xfunc.sgml.diff?r1=1.86&r2=1.87) pgsql-server/doc/src/sgml/ref: create_function.sgml (r1.58 -> r1.59) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/doc/src/sgml/ref/create_function.sgml.diff?r1=1.58&r2=1.59) pgsql-server/src/backend/access/transam: xact.c (r1.187 -> r1.188) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/access/transam/xact.c.diff?r1=1.187&r2=1.188) pgsql-server/src/backend/commands: cluster.c (r1.129 -> r1.130) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/cluster.c.diff?r1=1.129&r2=1.130) copy.c (r1.231 -> r1.232) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/copy.c.diff?r1=1.231&r2=1.232) explain.c (r1.125 -> r1.126) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/explain.c.diff?r1=1.125&r2=1.126) indexcmds.c (r1.125 -> r1.126) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/indexcmds.c.diff?r1=1.125&r2=1.126) portalcmds.c (r1.34 -> r1.35) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/portalcmds.c.diff?r1=1.34&r2=1.35) prepare.c (r1.31 -> r1.32) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/prepare.c.diff?r1=1.31&r2=1.32) vacuum.c (r1.290 -> r1.291) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/vacuum.c.diff?r1=1.290&r2=1.291) pgsql-server/src/backend/executor: execMain.c (r1.237 -> r1.238) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/executor/execMain.c.diff?r1=1.237&r2=1.238) functions.c (r1.88 -> r1.89) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/executor/functions.c.diff?r1=1.88&r2=1.89) spi.c (r1.126 -> r1.127) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/executor/spi.c.diff?r1=1.126&r2=1.127) pgsql-server/src/backend/tcop: fastpath.c (r1.75 -> r1.76) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/tcop/fastpath.c.diff?r1=1.75&r2=1.76) postgres.c (r1.431 -> r1.432) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/tcop/postgres.c.diff?r1=1.431&r2=1.432) pquery.c (r1.86 -> r1.87) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/tcop/pquery.c.diff?r1=1.86&r2=1.87) utility.c (r1.229 -> r1.230) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/tcop/utility.c.diff?r1=1.229&r2=1.230) pgsql-server/src/backend/utils/adt: ri_triggers.c (r1.72 -> r1.73) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/utils/adt/ri_triggers.c.diff?r1=1.72&r2=1.73) ruleutils.c (r1.180 -> r1.181) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/utils/adt/ruleutils.c.diff?r1=1.180&r2=1.181) pgsql-server/src/backend/utils/time: tqual.c (r1.77 -> r1.78) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/utils/time/tqual.c.diff?r1=1.77&r2=1.78) pgsql-server/src/include/executor: execdesc.h (r1.28 -> r1.29) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/executor/execdesc.h.diff?r1=1.28&r2=1.29) executor.h (r1.112 -> r1.113) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/executor/executor.h.diff?r1=1.112&r2=1.113) spi.h (r1.47 -> r1.48) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/executor/spi.h.diff?r1=1.47&r2=1.48) pgsql-server/src/include/tcop: pquery.h (r1.32 -> r1.33) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/tcop/pquery.h.diff?r1=1.32&r2=1.33) utility.h (r1.24 -> r1.25) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/tcop/utility.h.diff?r1=1.24&r2=1.25) pgsql-server/src/include/utils: tqual.h (r1.51 -> r1.52) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/utils/tqual.h.diff?r1=1.51&r2=1.52) pgsql-server/src/pl/plperl: plperl.c (r1.50 -> r1.51) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/pl/plperl/plperl.c.diff?r1=1.50&r2=1.51) spi_internal.c (r1.4 -> r1.5) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/pl/plperl/spi_internal.c.diff?r1=1.4&r2=1.5) spi_internal.h (r1.3 -> r1.4) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/pl/plperl/spi_internal.h.diff?r1=1.3&r2=1.4) pgsql-server/src/pl/plpgsql/src: pl_comp.c (r1.81 -> r1.82) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/pl/plpgsql/src/pl_comp.c.diff?r1=1.81&r2=1.82) pl_exec.c (r1.118 -> r1.119) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/pl/plpgsql/src/pl_exec.c.diff?r1=1.118&r2=1.119) plpgsql.h (r1.53 -> r1.54) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/pl/plpgsql/src/plpgsql.h.diff?r1=1.53&r2=1.54) pgsql-server/src/pl/plpython: plpython.c (r1.55 -> r1.56) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/pl/plpython/plpython.c.diff?r1=1.55&r2=1.56) pgsql-server/src/pl/tcl: pltcl.c (r1.91 -> r1.92) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/pl/tcl/pltcl.c.diff?r1=1.91&r2=1.92) pgsql-server/src/test/regress/expected: transactions.out (r1.9 -> r1.10) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/test/regress/expected/transactions.out.diff?r1=1.9&r2=1.10) pgsql-server/src/test/regress/sql: transactions.sql (r1.9 -> r1.10) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/test/regress/sql/transactions.sql.diff?r1=1.9&r2=1.10)