pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: shihao zhong <zhong950419@gmail.com>
Cc: Marcos Castedo <marcos.castedo@anachronics.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19816: PL/Python SD dictionary is split by input collation in 19rc1
Date: Wed, 11 Nov 2026 11:40:42 -0500
Message-ID: <3245516.1794415242@sss.pgh.pa.us> (raw)
In-Reply-To: <CAGRkXqTCSAQZVXHUdN-u+fELdfdVc8hy8XrNVuWBrBhkRb04mg@mail.gmail.com>
References: <19816-921b5cbc3ee63146@postgresql.org>
	<CAGRkXqSAdTj_pk3wZbjbZQU_HjB9Hj0Ybwc3J5RrFM1j7RvckA@mail.gmail.com>
	<2491842.1794252108@sss.pgh.pa.us>
	<CABH3EXo09nT501nbyoY+xqBXCP2gz-7gXH3vLsSYiSuWnEUR+Q@mail.gmail.com>
	<CAGRkXqTCSAQZVXHUdN-u+fELdfdVc8hy8XrNVuWBrBhkRb04mg@mail.gmail.com>

shihao zhong <zhong950419@gmail.com> 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






view thread (11+ messages)  latest in thread

Message-ID: <3245516.1794415242@sss.pgh.pa.us>
Permalink:  ../3245516.1794415242@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3245516.1794415242@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, zhong950419@gmail.com, marcos.castedo@anachronics.com
  Subject: Re: BUG #19816: PL/Python SD dictionary is split by input collation in 19rc1
  In-Reply-To: <3245516.1794415242@sss.pgh.pa.us>
  References: <19816-921b5cbc3ee63146@postgresql.org> <CAGRkXqSAdTj_pk3wZbjbZQU_HjB9Hj0Ybwc3J5RrFM1j7RvckA@mail.gmail.com> <2491842.1794252108@sss.pgh.pa.us> <CABH3EXo09nT501nbyoY+xqBXCP2gz-7gXH3vLsSYiSuWnEUR+Q@mail.gmail.com> <CAGRkXqTCSAQZVXHUdN-u+fELdfdVc8hy8XrNVuWBrBhkRb04mg@mail.gmail.com> <3245516.1794415242@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox