mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Free SQLSTATE and SQLERRM no earlier than other PL/pgSQL variables.
"RETURN SQLERRM" prompted plpgsql_exec_function() to read from freed memory. Back-patch to 9.0 (all supported versions). Little code ran between the premature free and the read, so non-assert builds are unlikely to witness user-visible consequences.
This commit is contained in:
@ -2655,9 +2655,21 @@ NOTICE: P0001 user exception
|
||||
|
||||
(1 row)
|
||||
|
||||
create function excpt_test4() returns text as $$
|
||||
begin
|
||||
begin perform 1/0;
|
||||
exception when others then return sqlerrm; end;
|
||||
end; $$ language plpgsql;
|
||||
select excpt_test4();
|
||||
excpt_test4
|
||||
------------------
|
||||
division by zero
|
||||
(1 row)
|
||||
|
||||
drop function excpt_test1();
|
||||
drop function excpt_test2();
|
||||
drop function excpt_test3();
|
||||
drop function excpt_test4();
|
||||
-- parameters of raise stmt can be expressions
|
||||
create function raise_exprs() returns void as $$
|
||||
declare
|
||||
|
@ -2246,11 +2246,19 @@ begin
|
||||
raise notice '% %', sqlstate, sqlerrm;
|
||||
end;
|
||||
end; $$ language plpgsql;
|
||||
|
||||
select excpt_test3();
|
||||
|
||||
create function excpt_test4() returns text as $$
|
||||
begin
|
||||
begin perform 1/0;
|
||||
exception when others then return sqlerrm; end;
|
||||
end; $$ language plpgsql;
|
||||
select excpt_test4();
|
||||
|
||||
drop function excpt_test1();
|
||||
drop function excpt_test2();
|
||||
drop function excpt_test3();
|
||||
drop function excpt_test4();
|
||||
|
||||
-- parameters of raise stmt can be expressions
|
||||
create function raise_exprs() returns void as $$
|
||||
|
Reference in New Issue
Block a user