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 1uLo06-00024g-MO for pgsql-hackers@arkaria.postgresql.org; Sun, 01 Jun 2025 19:05:42 +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 1uLo05-004qMM-69 for pgsql-hackers@arkaria.postgresql.org; Sun, 01 Jun 2025 19:05:41 +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 1uLo04-004qMD-T2 for pgsql-hackers@lists.postgresql.org; Sun, 01 Jun 2025 19:05:40 +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.96) (envelope-from ) id 1uLo02-001FH8-0a for pgsql-hackers@lists.postgresql.org; Sun, 01 Jun 2025 19:05:40 +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 551J5bDb3395264 for ; Sun, 1 Jun 2025 15:05:37 -0400 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: Re: Confused coding in PLy_traceback() In-reply-to: <2954090.1748723636@sss.pgh.pa.us> References: <2954090.1748723636@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 31 May 2025 16:33:56 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3395262.1748804737.1@sss.pgh.pa.us> Date: Sun, 01 Jun 2025 15:05:37 -0400 Message-ID: <3395263.1748804737@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > So I propose the attached. For ease of review, I've not re-indented > the code that needs to move inside PG_TRY blocks. Also, I dropped the > logic about pfree'ing the string buffers in PLy_elog_impl's PG_FINALLY > block: that doesn't seem necessary, and continuing to do it would > require making those things volatile which is notationally messy. Pushed. After sleeping on it I decided that removing the pfree's would be a poor tradeoff, as it's not clear how long those allocations might survive otherwise. The extra "volatile" markers for "xmsg" and "tbmsg" aren't that big a deal. Trying to mark "emsg" as volatile would be problematic because none of the StringInfo routines are set up to allow that, but it shouldn't be a problem because that struct will surely be on the stack. regards, tom lane