mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
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 commitc7b849a89
. I had forgotten about that while writing commit0fc94a5ba
, 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 commit0fc94a5ba
. Per bug #13571 from Feike Steenbergen. Preliminary analysis by Oleksandr Shulgin.
This commit is contained in:
@ -4764,6 +4764,13 @@ commit;
|
||||
drop function cast_invoker(integer);
|
||||
drop function sql_to_date(integer) cascade;
|
||||
NOTICE: drop cascades to cast from integer to date
|
||||
-- Test handling of cast cache inside DO blocks
|
||||
-- (to check the original crash case, this must be a cast not previously
|
||||
-- used in this session)
|
||||
begin;
|
||||
do $$ declare x text[]; begin x := '{1.23, 4.56}'::numeric[]; end $$;
|
||||
do $$ declare x text[]; begin x := '{1.23, 4.56}'::numeric[]; end $$;
|
||||
end;
|
||||
-- Test for consistent reporting of error context
|
||||
create function fail() returns int language plpgsql as $$
|
||||
begin
|
||||
|
@ -3836,6 +3836,15 @@ commit;
|
||||
drop function cast_invoker(integer);
|
||||
drop function sql_to_date(integer) cascade;
|
||||
|
||||
-- Test handling of cast cache inside DO blocks
|
||||
-- (to check the original crash case, this must be a cast not previously
|
||||
-- used in this session)
|
||||
|
||||
begin;
|
||||
do $$ declare x text[]; begin x := '{1.23, 4.56}'::numeric[]; end $$;
|
||||
do $$ declare x text[]; begin x := '{1.23, 4.56}'::numeric[]; end $$;
|
||||
end;
|
||||
|
||||
-- Test for consistent reporting of error context
|
||||
|
||||
create function fail() returns int language plpgsql as $$
|
||||
|
Reference in New Issue
Block a user