pgsql: Test and document the behavior of initialization cross-refs in p - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Test and document the behavior of initialization cross-refs in p
Date
Msg-id E1mgV0l-0000l4-Qf@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Test and document the behavior of initialization cross-refs in plpgsql.

We had a test showing that a variable isn't referenceable in its
own initialization expression, nor in prior ones in the same block.
It *is* referenceable in later expressions in the same block, but
AFAICS there is no test case exercising that.  Add one, and also
add some error cases.

Also, document that this is possible, since the docs failed to
cover the point.

Per question from tomás at tuxteam.  I don't feel any need to
back-patch this, but we should ensure we don't break it in future.

Discussion: https://postgr.es/m/20211029121435.GA5414@tuxteam.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a2a731d6c9db0ba650aa6f7c4fe349ccf712f74d

Modified Files
--------------
doc/src/sgml/plpgsql.sgml             | 12 ++++++++-
src/test/regress/expected/plpgsql.out | 48 +++++++++++++++++++++++++++--------
src/test/regress/sql/plpgsql.sql      | 36 ++++++++++++++++++++------
3 files changed, 76 insertions(+), 20 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Update time zone data files to tzdata release 2021e.
Next
From: Peter Geoghegan
Date:
Subject: pgsql: Demote pg_unreachable() in heapam to an assertion.