Re: Rethinking plpgsql's assignment implementation

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Chapman Flack <chap(at)anastigmatix(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
Subject: Re: Rethinking plpgsql's assignment implementation
Date: 2021-01-19 18:21:04
Message-ID: CAFj8pRC6T3kfv=ewa4DomW7dpqt31daUxAvmafk0Nk6sn=WHZw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

Now, I am testing subscribing on the jsonb feature, and I found one issue,
that is not supported by parser.

When the target is scalar, then all is ok. But we can have a plpgsql array
of jsonb values.

postgres=# do $$
declare j jsonb[];
begin
j[1] = '{"b":"Ahoj"}';
raise notice '%', j;
raise notice '%', (j[1])['b'];
end
$$;
NOTICE: {"{\"b\": \"Ahoj\"}"}
NOTICE: "Ahoj"
DO

Parenthesis work well in expressions, but are not supported on the left
side of assignment.

postgres=# do $$
declare j jsonb[];
begin
(j[1])['b'] = '"Ahoj"';
raise notice '%', j;
raise notice '%', j[1]['b'];
end
$$;
ERROR: syntax error at or near "("
LINE 4: (j[1])['b'] = '"Ahoj"';
^

Regards

Pavel

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2021-01-19 18:42:25 Re: [HACKERS] [PATCH] Generic type subscripting
Previous Message James Hilliard 2021-01-19 17:55:46 Re: [PATCH v2 1/1] Fix detection of pwritev support for OSX.