Skip to content

Instantly share code, notes, and snippets.

@onderkalaci
Created January 12, 2021 08:33
Show Gist options
  • Select an option

  • Save onderkalaci/4c4a8267a0f7e582f3a321ee0111e1c2 to your computer and use it in GitHub Desktop.

Select an option

Save onderkalaci/4c4a8267a0f7e582f3a321ee0111e1c2 to your computer and use it in GitHub Desktop.
Overly Simplified Savepoint Bug Repro
CREATE OR REPLACE PROCEDURE public.top_function() LANGUAGE PLPGSQL AS $procedure$
begin
call second_function_that_fails();
EXCEPTION
when others then
RAISE NOTICE 'Top function exception handling';
call third_function_that_fails();
end; $procedure$;
CREATE OR REPLACE PROCEDURE public.second_function_that_fails() LANGUAGE PLPGSQL AS $procedure$
begin
PERFORM user_id/0 FROM users_table as foo_second;
end; $procedure$;
CREATE OR REPLACE PROCEDURE public.third_function_that_fails() LANGUAGE PLPGSQL AS $procedure$
begin
PERFORM user_id/0 FROM users_table as foo_third;
EXCEPTION
when others then
RAISE NOTICE 'Third function failed';
end; $procedure$;
CALL top_function();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment