Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plpgsql parsing error on assigning value to row type (e.g. row_a.column_a := null::TEXT) #159

Open
wesselvdv opened this issue Nov 10, 2022 · 2 comments
Labels

Comments

@wesselvdv
Copy link
Contributor

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)

@lfittl
Copy link
Member

lfittl commented Nov 10, 2022

@wesselvdv Thanks for the report!

Could you provide a complete example function definition that can be used for testing?

@wesselvdv
Copy link
Contributor Author

wesselvdv commented Nov 10, 2022

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();

@lfittl lfittl added the plpgsql label Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants