Restructure plpgsql's caching of 'simple' expression evaluation trees

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

Commit: 8b510838f6213f69aeca8f237f7718ea1b14a5d1
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2003-09-28T23:37:45Z
Releases: 7.4.1
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.

Files

PathChange+/−
src/pl/plpgsql/src/pl_exec.c modified +145 −71
src/pl/plpgsql/src/pl_handler.c modified +3 −2
src/pl/plpgsql/src/plpgsql.h modified +12 −7