Preliminary refactoring of plpgsql expression construction.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 11 Feb 2025 17:20:05 +0000 (12:20 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 11 Feb 2025 17:20:05 +0000 (12:20 -0500)
commita654af21ae522cc8e867e052defd16f76ffaef2e
tree0fea7fa4a574fbcc72d3d26398fa405544ccfd1c
parent6a7283dd2f1c573f2cf3daaf14e8a246577da57d
Preliminary refactoring of plpgsql expression construction.

This short and boring patch simply moves the responsibility for
initializing PLpgSQL_expr.target_param into plpgsql parsing,
rather than doing it at first execution of the expr as before.
This doesn't save anything in terms of runtime, since the work was
trivial and done only once per expr anyway.  But it makes the info
available during parsing, which will be useful for the next step.

Likewise set PLpgSQL_expr.func during parsing.  According to the
comments, this was once impossible; but it's certainly possible
since we invented the plpgsql_curr_compile variable.  Again, this
saves little runtime, but it seems far cleaner conceptually.

While at it, I reordered stuff in struct PLpgSQL_expr to make it
clearer which fields are filled when, and merged some duplicative
code in pl_gram.y.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Pavel Borisov <pashkin.elfe@gmail.com>
Discussion: https://postgr.es/m/CACxu=vJaKFNsYxooSnW1wEgsAO5u_v1XYBacfVJ14wgJV_PYeg@mail.gmail.com
src/pl/plpgsql/src/pl_exec.c
src/pl/plpgsql/src/pl_gram.y
src/pl/plpgsql/src/plpgsql.h