diff options
author | Tom Lane | 2024-07-05 18:14:42 +0000 |
---|---|---|
committer | Tom Lane | 2024-07-05 18:14:42 +0000 |
commit | ba8f00eef6d6199b1d01f4b1eb6ed955dc4bd17e (patch) | |
tree | 593cb541bdd30d93c30a84c9841a25e20e203d4b /src/pl/tcl/expected/pltcl_transaction.out | |
parent | aaab3ee9c64129b5afb2c35e743fba322a052bff (diff) |
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/[email protected]
Diffstat (limited to 'src/pl/tcl/expected/pltcl_transaction.out')
-rw-r--r-- | src/pl/tcl/expected/pltcl_transaction.out | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/pl/tcl/expected/pltcl_transaction.out b/src/pl/tcl/expected/pltcl_transaction.out index f557b791386..cf71b58d483 100644 --- a/src/pl/tcl/expected/pltcl_transaction.out +++ b/src/pl/tcl/expected/pltcl_transaction.out @@ -1,5 +1,3 @@ --- suppress CONTEXT so that function OIDs aren't in output -\set VERBOSITY terse CREATE TABLE test1 (a int, b text); CREATE PROCEDURE transaction_test1() LANGUAGE pltcl @@ -41,6 +39,12 @@ return 1 $$; SELECT transaction_test2(); ERROR: invalid transaction termination +CONTEXT: while executing +"commit" + (procedure "__PLTcl_proc_transaction_test2" line 6) + invoked from within +"__PLTcl_proc_transaction_test2" +in PL/Tcl function transaction_test2() SELECT * FROM test1; a | b ---+--- @@ -55,6 +59,17 @@ return 1 $$; SELECT transaction_test3(); ERROR: invalid transaction termination +CONTEXT: while executing +"commit" + (procedure "__PLTcl_proc_transaction_test1" line 6) + invoked from within +"__PLTcl_proc_transaction_test1" + invoked from within +"spi_exec "CALL transaction_test1()"" + (procedure "__PLTcl_proc_transaction_test3" line 3) + invoked from within +"__PLTcl_proc_transaction_test3" +in PL/Tcl function transaction_test3() SELECT * FROM test1; a | b ---+--- @@ -74,6 +89,17 @@ spi_exec -array row "SELECT * FROM test2 ORDER BY x" { $$; CALL transaction_test4a(); ERROR: cannot commit while a subtransaction is active +CONTEXT: while executing +"commit" + invoked from within +"spi_exec -array row "SELECT * FROM test2 ORDER BY x" { + spi_exec "INSERT INTO test1 (a) VALUES ($row(x))" + commit +}" + (procedure "__PLTcl_proc_transaction_test4a" line 3) + invoked from within +"__PLTcl_proc_transaction_test4a" +in PL/Tcl function transaction_test4a() SELECT * FROM test1; a | b ---+--- @@ -91,6 +117,17 @@ spi_exec -array row "SELECT * FROM test2 ORDER BY x" { $$; CALL transaction_test4b(); ERROR: cannot roll back while a subtransaction is active +CONTEXT: while executing +"rollback" + invoked from within +"spi_exec -array row "SELECT * FROM test2 ORDER BY x" { + spi_exec "INSERT INTO test1 (a) VALUES ($row(x))" + rollback +}" + (procedure "__PLTcl_proc_transaction_test4b" line 3) + invoked from within +"__PLTcl_proc_transaction_test4b" +in PL/Tcl function transaction_test4b() SELECT * FROM test1; a | b ---+--- @@ -109,6 +146,12 @@ elog WARNING "should not get here" $$; CALL transaction_testfk(); ERROR: insert or update on table "testfk" violates foreign key constraint "testfk_f1_fkey" +CONTEXT: while executing +"commit" + (procedure "__PLTcl_proc_transaction_testfk" line 5) + invoked from within +"__PLTcl_proc_transaction_testfk" +in PL/Tcl function transaction_testfk() SELECT * FROM testpk; id ---- |