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.96) (envelope-from ) id 1wvhRl-001S0X-0I for pgsql-hackers@arkaria.postgresql.org; Sun, 16 Aug 2026 20:27:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wvhRi-0070LB-2A for pgsql-hackers@arkaria.postgresql.org; Sun, 16 Aug 2026 20:27:07 +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.96) (envelope-from ) id 1wvhRi-0070L3-1D for pgsql-hackers@lists.postgresql.org; Sun, 16 Aug 2026 20:27:07 +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.98.2) (envelope-from ) id 1wvhRg-000000016QA-2wlH for pgsql-hackers@lists.postgresql.org; Sun, 16 Aug 2026 20:27:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 67GKQvhA579929; Sun, 16 Aug 2026 16:26:57 -0400 From: Tom Lane To: Andrey Rachitskiy cc: andrew@dunslane.net, pgsql-hackers@lists.postgresql.org Subject: Re: Residual cleanups for tied objects in PL/Perl In-reply-to: References: <569769.1786901901@sss.pgh.pa.us> Comments: In-reply-to Andrey Rachitskiy message dated "Mon, 17 Aug 2026 01:08:07 +0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <579927.1786912017.1@sss.pgh.pa.us> Date: Sun, 16 Aug 2026 16:26:57 -0400 Message-ID: <579928.1786912017@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrey Rachitskiy writes: > A tied hash does not store the value in HeVAL(). hv_iternext() leaves that > pointer unset. Tom's NULL check therefore always takes the SQL NULL path, > even when FETCH would return a real value. hv_iterval() plus SvGETMAGIC() > is what actually runs FETCH. > The same applies to a tied array. av_len() stops the infinite loop, but > av_fetch() still returns a magic SV whose SvOK() is false until GETMAGIC. > Without that, SETOF also yields NULLs. Hmm. I confirm that adding SvGETMAGIC() makes the tied-array test work (didn't try the hash case). But to my previous point, where else would we need to call it, if we're going to try to support such cases? Also, what exactly are the preconditions for that function? Looking at the perl header files here, it looks like sv being nonnull is required and sufficient ... but your patch is inconsistent about checking that. regards, tom lane