pgsql: Improve PL/Tcl's method for choosing Tcl names of procedures.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve PL/Tcl's method for choosing Tcl names of procedures.
Date: 2024-07-05 18:14:58
Message-ID: E1sPnST-000Rei-HZ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve PL/Tcl's method for choosing Tcl names of procedures.

Previously, the internal name of a PL/Tcl function was just
"__PLTcl_proc_NNNN", where NNNN is the function OID. That's pretty
unhelpful when reading an error report. Plus it prevents us from
testing the CONTEXT output for PL/Tcl errors, since the OIDs shown
in the regression tests wouldn't be stable.

Instead, base the internal name on the result of format_procedure(),
which will be unique in most cases. For the edge cases where it's
not, we can append the function OID to make it unique.

Sadly, the pltcl_trigger.sql test script still has to suppress the
context reports, because they'd include trigger arguments which
contain relation OIDs per PL/Tcl's longstanding API for triggers.

I had to modify one existing test case to throw a different error
than before, because I found that Tcl 8.5 and Tcl 8.6 spell the
context message for the original error slightly differently.
We might have to make more adjustments in that vein once this
gets wider testing.

Patch by me; thanks to Pavel Stehule for the idea to use
format_procedure() rather than just the proname.

Discussion: https://postgr.es/m/890581.1717609350@sss.pgh.pa.us

Branch
------
master

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

Modified Files
--------------
doc/src/sgml/pltcl.sgml | 17 +-
src/pl/tcl/expected/pltcl_queries.out | 320 +++++++++++++++++++++++++++++-
src/pl/tcl/expected/pltcl_transaction.out | 47 ++++-
src/pl/tcl/expected/pltcl_trigger.out | 2 +-
src/pl/tcl/pltcl.c | 137 ++++++++++---
src/pl/tcl/sql/pltcl_queries.sql | 38 +++-
src/pl/tcl/sql/pltcl_transaction.sql | 3 -
src/pl/tcl/sql/pltcl_trigger.sql | 2 +-
8 files changed, 520 insertions(+), 46 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2024-07-05 19:45:35 pgsql: Remove check hooks for GUCs that contribute to MaxBackends.
Previous Message Tom Lane 2024-07-05 17:12:42 pgsql: Doc: minor improvements for our "Brief History" chapter.