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.98.2) (envelope-from ) id 1xRBNT-00000000lAi-2Adx for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Nov 2026 16:40:51 +0000 Received: from localhost ([127.0.0.1]:60902 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xRBNS-0000000C7iI-0hPR for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Nov 2026 16:40:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:35938) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xRBNR-0000000C7i8-3mMe for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 16:40:50 +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 1xRBNP-00000000UxJ-4BK3 for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 16:40:49 +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 6ABGegml3245517; Wed, 11 Nov 2026 11:40:42 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 sss.pgh.pa.us 6ABGegml3245517 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sss.pgh.pa.us; s=default; t=1794415243; bh=xmT06zZ+9/veGUnRyMXPsH/zkte6WYjJ9xzmomtSzh0=; h=From:To:cc:Subject:In-reply-to:References:Date:From; b=oPdlc7KysTwzrz2R/R7APgvrSV9r/kvpOhTjXk/1YHeRCocuML1+Ij7t97Ziy2581 eSFO1OMw9fImYSN1F/OqS/Pi3lzmTg3NMYxvaK2mkiBukhDsI3DovgJTbrN4xpXUKs 1pIem64OgW3+Gk7q7rVmDOwb/jnf10AMpNtRWZcQ= From: Tom Lane To: shihao zhong cc: Marcos Castedo , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19816: PL/Python SD dictionary is split by input collation in 19rc1 In-reply-to: References: <19816-921b5cbc3ee63146@postgresql.org> <2491842.1794252108@sss.pgh.pa.us> Comments: In-reply-to shihao zhong message dated "Mon, 09 Nov 2026 17:59:43 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3245515.1794415242.1@sss.pgh.pa.us> Date: Wed, 11 Nov 2026 11:40:42 -0500 Message-ID: <3245516.1794415242@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk shihao zhong writes: > I have a proposal. SD stays with the cache entry, and plpython leaves > the input collation out of its cache key. Yeah, I had been wondering if we should go in that direction. However ... It occurred to me to consult the fine manual, and I read this: The global dictionary SD is available to store private data between repeated calls to the same function. Full stop. So that's already a lie, and we need to fix it. However, this would certainly not leave a reader with the impression that different argument types or collations would give you different SDs. In fact, it leaves the impression that different uses of the same trigger function should share SD. But that's never been true, and I'm sure there are users out there who depend on the per-trigger-relation behavior. So I'm now coming around to the conclusion that bug compatibility with the old behavior is the way to go. Maybe we will rethink that when/if we get around to supporting polymorphic arguments, but we don't have to make a decision about that today. If we split off a separate hashtable as Shihao's v1 patch does, then we've successfully decoupled the SD behavior from funccache.c's rules, and we will be free to go either way when the time comes. So I think Shihao's patch is the right thing (at least approximately, I haven't read it in detail), and I'll move forward with that. The manual's text needs to be updated to something like The global dictionary SD is available to store private data between repeated calls to the same function within a session. Each PL/Python function has its own instance of SD, except that for trigger functions, there is one instance of SD per function per triggered-on relation. As a separate matter that is an optimization not a bug fix, it might be interesting to suppress collation from plpython's funccache keys, just so we don't get useless redundant cache entries. But we can leave that for another day. regards, tom lane