Test and document the behavior of initialization cross-refs in plpgsql.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: a2a731d6c9db0ba650aa6f7c4fe349ccf712f74d
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2021-10-29T16:45:33Z
Releases: 15.0
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

Files

PathChange+/−
doc/src/sgml/plpgsql.sgml modified +11 −1
src/test/regress/expected/plpgsql.out modified +37 −11
src/test/regress/sql/plpgsql.sql modified +28 −8

Documentation touched

Discussion