Test and document the behavior of initialization cross-refs in plpgsql.
authorTom Lane <[email protected]>
Fri, 29 Oct 2021 16:45:33 +0000 (12:45 -0400)
committerTom Lane <[email protected]>
Fri, 29 Oct 2021 16:45:33 +0000 (12:45 -0400)
commita2a731d6c9db0ba650aa6f7c4fe349ccf712f74d
treecf75177961f20fe623e555faffaa858cf8fe6284
parent937aafd6d5580b81134c7f303d04cf7561ad0309
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[email protected]
doc/src/sgml/plpgsql.sgml
src/test/regress/expected/plpgsql.out
src/test/regress/sql/plpgsql.sql