Rethink the "read/write parameter" mechanism in pl/pgsql.
Tom Lane <tgl@sss.pgh.pa.us>
Rethink the "read/write parameter" mechanism in pl/pgsql. Performance issues with the preceding patch to re-implement array element assignment within pl/pgsql led me to realize that the read/write parameter mechanism is misdesigned. Instead of requiring the assignment source expression to be such that *all* its references to the target variable could be passed as R/W, we really want to identify *one* reference to the target variable to be passed as R/W, allowing any other ones to be passed read/only as they would be by default. As long as the R/W reference is a direct argument to the top-level (hence last to be executed) function in the expression, there is no harm in R/O references being passed to other lower parts of the expression. Nor is there any use-case for more than one argument of the top-level function being R/W. Hence, rewrite that logic to identify one single Param that references the target variable, and make only that Param pass a read/write reference, not any other Params referencing the target variable. Discussion: https://postgr.es/m/4165684.1607707277@sss.pgh.pa.us
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/arrayfuncs.c | modified | +5 −2 |
| src/pl/plpgsql/src/pl_exec.c | modified | +87 −90 |
| src/pl/plpgsql/src/pl_gram.y | modified | +3 −3 |
| src/pl/plpgsql/src/plpgsql.h | modified | +11 −1 |
Discussion
- Rethinking plpgsql's assignment implementation 21 messages · 2020-12-11 → 2021-01-20