libpg_query
libpg_query copied to clipboard
plpgsql parsing error on assigning value to row type (e.g. row_a.column_a := null::TEXT)
When parsing a function using the plpgsql parser it'll error with Error: "row_a.column_a" is not a known variable when the function in question is assigning a value to a row type variable. (row_a.column_a := null::TEXT)
@wesselvdv Thanks for the report!
Could you provide a complete example function definition that can be used for testing?
Here's a simple one:
CREATE TABLE IF NOT EXISTS public.table_a
(
column_a TEXT NOT NULL PRIMARY KEY
);
INSERT INTO public.table_a(column_a) VALUES ('test_a');
CREATE OR REPLACE FUNCTION public.function_a(
) RETURNS public.table_a
LANGUAGE plpgsql
AS
$$
DECLARE
row_a public.table_a := (SELECT table_a FROM public.table_a WHERE column_a = 'test_a');
BEGIN
row_a.column_a := 'test_b';
RETURN row_a;
END;
$$;
SELECT
public.function_a();