Restructure plpgsql's caching of 'simple' expression evaluation trees
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Sep 2003 23:37:45 +0000 (23:37 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Sep 2003 23:37:45 +0000 (23:37 +0000)
commitae4ba0e16181dde454a423b98b6dc963159c0afe
treef3cbfb24817ec532e79f0de8d7d0bbcfb4142795
parent8c2b3e50d97812a43447c1e222de63c1fa067087
Restructure plpgsql's caching of 'simple' expression evaluation trees
to be less dangerous, and often faster as well.  ExprState trees are
not kept across transaction boundaries; this eliminates problems with
resource leakage in failed transactions.  But by keeping them in a
per-transaction EState, we can safely arrange for a single ExprState
to be shared by all the expression evaluations done in a given plpgsql
function call.  (Formerly it seemed necessary to create and destroy an
ExprState for each exec_eval_simple_expr() call.)  This saves time in
any scenario where a plpgsql function executes more than one expression.
Seems to be about as fast as 7.3 for simple cases, and significantly
faster for functions that do a lot of calculations.
src/pl/plpgsql/src/pl_exec.c
src/pl/plpgsql/src/pl_handler.c
src/pl/plpgsql/src/plpgsql.h