On Wed, Dec 26, 2018 at 07:02:04AM +0100, Pavel Stehule wrote: > is called two times, what is not expected, if you don't know some about > this inconsistency. > > So it is reason, why I don't think so current behave is correct. On second > hand, the impact is very small - only few extensions uses plpgsql plugin > API, and workaround is not hard. So I can live with current state if nobody > see this issue (sure - it is minor issue).
Hm. Using the following functions based on the code of above, I can see the following numbers if I place some trackers (elog(WARNING) entries) at the beginning of each callback part of plpgsql_check.c to measure how many times a callback is done: CREATE OR REPLACE FUNCTION public.f2() RETURNS void LANGUAGE plpgsql AS $$ DECLARE x int; BEGIN x := 2; RETURN; END; $$; CREATE OR REPLACE FUNCTION public.f3() RETURNS void LANGUAGE plpgsql AS $$ DECLARE x int; BEGIN BEGIN x := 3; RETURN; END; END $$; On HEAD, for plpgsql_check_function_tb('f2()'): - stmt_beg is called 4 times. - stmt_end is called 3 times. - func_setup is called 2 times. - func_beg is called 2 times. - func_end is called 2 times. For plpgsql_check_function_tb('f3()'): - stmt_beg is called 3 times. - stmt_end is called 3 times. - func_setup is called 1 time. - func_beg is called 1 time. - func_end is called 2 times. So based on the previous example f2 gets over f3 one extra stmt_beg, one extra func_beg and one extra func_setup. With patched HEAD, I got for f2: - stmt_beg is called 6 times. - stmt_end is called 5 times. - func_setup is called 2 times. - func_beg is called 2 times. - func_end is called 2 times. And for f3: - stmt_beg is called 6 times. - stmt_end is called 5 times. - func_setup is called 2 times. - func_beg is called 2 times. - func_end is called 2 times. -- Michael
signature.asc
Description: PGP signature