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 - Using record fields #38

Closed
rafaelthca opened this issue Sep 22, 2017 · 2 comments
Closed

PLPGSQL - Using record fields #38

rafaelthca opened this issue Sep 22, 2017 · 2 comments

Comments

@rafaelthca
Copy link

Hi,

Can't attribute values to record fields:

CREATE FUNCTION test(str character varying) RETURNS integer
LANGUAGE plpgsql
AS $$
DECLARE
  v3 RECORD;
  v4 integer;
BEGIN
  select 1 as c1, 2 as c2 into v3;
  v3.c1 := 4;
END;$$;

Error:

ERROR: "v3.c1" is not a known variable
CONTEXT: compilation of PL/pgSQL function "test" near line 7
LOCATION: cword_is_not_variable, pl_gram.y:2534

But postgresql accepts this syntax.

Great library by the way, keep up the good work.

Rafael.

@lfittl
Copy link
Member

lfittl commented Sep 23, 2017

Hi @rafaelthca - thanks for reaching out about this!

You are indeed correct that this doesn't work - the PL/pgSQL parser is a bit of work in progress, since it doesn't setup variables and return values correctly (yet).

See https://github.com/lfittl/libpg_query/blob/10-latest/src/pg_query_parse_plpgsql.c#L80 which is inspired by https://github.com/postgres/postgres/blob/REL_10_STABLE/src/pl/plpgsql/src/pl_comp.c#L794

If you have time to work on this help would be very welcome :)

@lfittl
Copy link
Member

lfittl commented Oct 9, 2021

Fixed in e9e4ba9

@lfittl lfittl closed this as completed Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants