libpg_query
libpg_query copied to clipboard
Error when parsing PL/pgSQL function with RETURN NEXT;
Trying to parse the following example gives the error missing expression at or near ";"
CREATE OR REPLACE FUNCTION public.test_pl(s integer, e integer)
RETURNS TABLE(id INTEGER) AS $$
BEGIN
id := s;
LOOP
EXIT WHEN id>e;
RETURN NEXT;
id := id + 1;
END LOOP;
END
$$
LANGUAGE plpgsql;
after debugging i discovered that plpgsql_curr_compile->out_param_varno
is -1 in function make_return_next_stmt for this example , so the function continues execution in the block else with comment "Note that a well-formed expression is required here; anything else is a compile-time error"