Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPQNo-004XUg-7V for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jul 2024 17:36:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sPQNl-001fxv-TT for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jul 2024 17:36:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPQNl-001fxn-KB for pgsql-hackers@lists.postgresql.org; Thu, 04 Jul 2024 17:36:34 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPQNk-000QMU-EK for pgsql-hackers@lists.postgresql.org; Thu, 04 Jul 2024 17:36:33 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 464HaQZi026373; Thu, 4 Jul 2024 13:36:26 -0400 From: Tom Lane To: Pavel Stehule cc: Heikki Linnakangas , pgsql-hackers@lists.postgresql.org Subject: Re: Improving PL/Tcl's error context reports In-reply-to: References: <890581.1717609350@sss.pgh.pa.us> <974c2531-536a-4223-a264-166872386459@iki.fi> Comments: In-reply-to Pavel Stehule message dated "Thu, 04 Jul 2024 19:15:55 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <26371.1720114586.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Thu, 04 Jul 2024 13:36:26 -0400 Message-ID: <26372.1720114586@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Pavel Stehule writes: > čt 4. 7. 2024 v 17:27 odesílatel Heikki Linnakangas > napsal: >> What happens if you rename a function? I guess the error context will >> still print the old name, but that's pretty harmless. > The rename should to generate different tid, so the function will be > recompiled Right. With patch: regression=# create function bogus() returns int language pltcl as 'return [expr 1 / 0]'; CREATE FUNCTION regression=# select bogus(); ERROR: divide by zero CONTEXT: while executing "expr 1 / 0" (procedure "__PLTcl_proc_bogus" line 2) invoked from within "__PLTcl_proc_bogus" in PL/Tcl function "bogus" regression=# alter function bogus() rename to stillbogus; ALTER FUNCTION regression=# select stillbogus(); ERROR: divide by zero CONTEXT: while executing "expr 1 / 0" (procedure "__PLTcl_proc_stillbogus" line 2) invoked from within "__PLTcl_proc_stillbogus" in PL/Tcl function "stillbogus" >> Hmm, could we do something with tcl namespaces to allow having two >> procedures with the same name? E.g. create a separate namespace, based >> on the OID, for each procedure. I wonder how the stack trace would look >> like then. If the namespace depends on the OID then we still have nonreproducible stack traces, no? We could maybe make Tcl namespaces that match the SQL schema names, but that doesn't get us out of the duplication problem when there are similarly-named functions with different argument lists. Another idea is to make the Tcl names include the SQL schema name, that is __PLTcl_proc_myschema_myfunction. That avoids needing to append OIDs when the problem is functions in different schemas, but it doesn't move the needle for overloaded functions. On the whole I feel like that'd add verbosity without buying much. regards, tom lane