Fix up plpgsql's "simple expression" evaluation mechanism so that it behaves
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Jan 2007 16:15:49 +0000 (16:15 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Jan 2007 16:15:49 +0000 (16:15 +0000)
commita8e0b660610de84550b5affb8c2b3f1b59e4c1eb
tree0ac15ad6186526b8287b6f65fa4f4818e6ed94ae
parent76c7d2afeead62b81017b67252b572925fe138d8
Fix up plpgsql's "simple expression" evaluation mechanism so that it behaves
safely in the presence of subtransactions.  To ensure that any ExprContext
shutdown callbacks are called at the right times, we have to have a separate
EState for each level of subtransaction.  Per "TupleDesc reference leak" bug
report from Stefan Kaltenbrunner.

Although I'm convinced the code is wrong as far back as 8.0, it doesn't seem
that there are any ways for the problem to really manifest before 8.2: AFAICS,
8.0 and 8.1 only use the ExprContextCallback mechanism to handle set-returning
functions, which cannot usefully be executed in a "simple expression" anyway.
Hence, no backpatch before 8.2 --- the risk of unforeseen breakage seems
to outweigh the chance of fixing something.
src/pl/plpgsql/src/pl_exec.c
src/pl/plpgsql/src/pl_handler.c
src/pl/plpgsql/src/plpgsql.h