]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Repair unsafe use of shared typecast-lookup table in plpgsql DO blocks.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 15 Aug 2015 16:00:36 +0000 (12:00 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 15 Aug 2015 16:00:49 +0000 (12:00 -0400)
commit1f6a7eba466d0cb31cd2f374603799935fcb9df8
treea279ac3046a804d594883dc0bb5c171f6922981f
parent6942663d1bde1e6d6e6da38710d3e6aade900e63
Repair unsafe use of shared typecast-lookup table in plpgsql DO blocks.

DO blocks use private simple_eval_estates to avoid intra-transaction memory
leakage, cf commit c7b849a89.  I had forgotten about that while writing
commit 0fc94a5ba, but it means that expression execution trees created
within a DO block disappear immediately on exiting the DO block, and hence
can't safely be linked into plpgsql's session-wide cast hash table.
To fix, give a DO block a private cast hash table to go with its private
simple_eval_estate.  This is less efficient than one could wish, since
DO blocks can no longer share any cast lookup work with other plpgsql
execution, but it shouldn't be too bad; in any case it's no worse than
what happened in DO blocks before commit 0fc94a5ba.

Per bug #13571 from Feike Steenbergen.  Preliminary analysis by
Oleksandr Shulgin.
src/pl/plpgsql/src/pl_exec.c
src/pl/plpgsql/src/plpgsql.h
src/test/regress/expected/plpgsql.out
src/test/regress/sql/plpgsql.sql