pgsql: Allow extension functions to participate in in-place updates.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow extension functions to participate in in-place updates.
Date: 2025-02-11 17:49:46
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Allow extension functions to participate in in-place updates.

Commit 1dc5ebc90 allowed PL/pgSQL to perform in-place updates
of expanded-object variables that are being updated with
assignments like "x := f(x, ...)". However this was allowed
only for a hard-wired list of functions f(), since we need to
be sure that f() will not modify the variable if it fails.
It was always envisioned that we should make that extensible,
but at the time we didn't have a good way to do so. Since
then we've invented the idea of "support functions" to allow
attaching specialized optimization knowledge to functions,
and that is a perfect mechanism for doing this.

Hence, adjust PL/pgSQL to use a support function request instead
of hard-wired logic to decide if in-place update is safe.
Preserve the previous optimizations by creating support functions
for the three functions that were previously hard-wired.

Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Reviewed-by: Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com>
Discussion: https://postgr.es/m/CACxu=vJaKFNsYxooSnW1wEgsAO5u_v1XYBacfVJ14wgJV_PYeg@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/utils/adt/array_userfuncs.c | 61 +++++++++++++++++++
src/backend/utils/adt/arraysubs.c | 34 +++++++++++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 20 +++++--
src/include/nodes/supportnodes.h | 55 +++++++++++++++--
src/pl/plpgsql/src/expected/plpgsql_array.out | 3 +-
src/pl/plpgsql/src/pl_exec.c | 86 ++++++++++++---------------
src/pl/plpgsql/src/sql/plpgsql_array.sql | 1 +
src/tools/pgindent/typedefs.list | 1 +
9 files changed, 203 insertions(+), 60 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2025-02-11 17:56:57 pgsql: config: Rename "Asynchronous Behavior" to "I/O"
Previous Message Peter Eisentraut 2025-02-11 10:18:15 pgsql: Replace AssertMacro() with Assert() when not in macro