Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ba8f00e

Browse filesBrowse files
committed
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
1 parent aaab3ee commit ba8f00e
Copy full SHA for ba8f00e

File tree

Expand file treeCollapse file tree

8 files changed

+520
-46
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+520
-46
lines changed

‎doc/src/sgml/pltcl.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/pltcl.sgml
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,16 +1120,25 @@ CALL transaction_test1();
11201120

11211121
<para>
11221122
In <productname>PostgreSQL</productname>, the same function name can be used for
1123-
different function definitions as long as the number of arguments or their types
1123+
different function definitions if the functions are placed in different
1124+
schemas, or if the number of arguments or their types
11241125
differ. Tcl, however, requires all procedure names to be distinct.
1125-
PL/Tcl deals with this by making the internal Tcl procedure names contain
1126-
the object
1127-
ID of the function from the system table <structname>pg_proc</structname> as part of their name. Thus,
1126+
PL/Tcl deals with this by including the argument type names in the
1127+
internal Tcl procedure name, and then appending the function's object
1128+
ID (OID) to the internal Tcl procedure name if necessary to make it
1129+
different from the names of all previously-loaded functions in the
1130+
same Tcl interpreter. Thus,
11281131
<productname>PostgreSQL</productname> functions with the same name
11291132
and different argument types will be different Tcl procedures, too. This
11301133
is not normally a concern for a PL/Tcl programmer, but it might be visible
11311134
when debugging.
11321135
</para>
11331136

1137+
<para>
1138+
For this reason among others, a PL/Tcl function cannot call another one
1139+
directly (that is, within Tcl). If you need to do that, you must go
1140+
through SQL, using <function>spi_exec</function> or a related command.
1141+
</para>
1142+
11341143
</sect1>
11351144
</chapter>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.