Re: PL/pgSQL: « arr[j].a := v » works fine in PG Version 14.4, fails to compile in Version 11.2. Which version brought the fix?

From: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: PL/pgSQL: « arr[j].a := v » works fine in PG Version 14.4, fails to compile in Version 11.2. Which version brought the fix?
Date: 2022-07-25 18:43:15
Message-ID: 89FDDABB-CF19-4DBF-9C43-B881CA1A5BB2@yugabyte.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> david(dot)g(dot)johnston(at)gmail(dot)com wrote:
>
>> bryn(at)yugabyte(dot)com wrote:
>>
>> I copied my testcase at the end. It runs OK and produces the output that I expect using PG Version 14.4. But using Version 11.9 (and earlier 11 sub-versions), it fails to compile with this error:
>>
>> syntax error at or near "."
>> lhs[j].a := rhs[j].a;
>> ^
>>
>> If I comment out the "Ideal approach" loop, then it runs fine in PG 11 and produces the same output as the "Ideal approach" does in PG 14,
>>
>> I looked at the Release Notes for each of Versions 14, 13, and 12:
>
>
> From the change to this page I'd say v14:
>
> https://www.postgresql.org/docs/14/plpgsql-statements.html
>
> The release note for v14 say:
>
> «
> PL/PgSQL:
> Improve PL/pgSQL's expression and assignment parsing (Tom Lane)
> This change allows assignment to array slices and nested record fields.
> »

Thanks for the quick reply, David.

I looked at "43.5.1. Assignment" (https://www.postgresql.org/docs/14/plpgsql-statements.html#PLPGSQL-STATEMENTS-ASSIGNMENT)

I searched in the page for « ]. » and found this:

complex_array[n].realpart = 12.3;

The corresponding page for Version 13 has no hits for « ]. ». So that seems to be a clear answer to my question.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2022-07-25 20:40:22 Re: Password reset link / 'less' does not exit in psql version 13.4
Previous Message Adrian Klaver 2022-07-25 17:53:35 Re: Password reset link / 'less' does not exit in psql version 13.4