model-writtenrun 8460 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Marcos Castedo reported that PostgreSQL 19rc1 splits PL/Python SD dictionaries by input collation, breaking state sharing even when an optional text argument is merely omitted, and suggested separating SD storage or excluding collation from the cache key #1.
- Shihao Zhong supplied a separate SD hash keyed by function OID and trigger relation, initially resetting dictionaries when functions were redefined; Python global variables remained split because sharing them would also involve call-stack state #2.
- Marcos Castedo tested the patch successfully, including trigger and record-returning cases, but found that rolling back a function redefinition could still split SD and noted gaps in the regression tests #3.
- Tom Lane questioned the rationale for distinguishing trigger relations but ignoring argument types and collations; Marcos explained that input collation is invisible to PL/Python code, and Shihao proposed instead excluding collation from the compiled-function cache key #4 #5 #6.
- After consulting the documentation, Tom Lane favored the separate SD hash to preserve established behavior while leaving future polymorphic semantics open, proposed documenting the per-trigger-relation exception, and deferred suppressing redundant collation cache entries as an optimization #7.
- The documentation correction landed as b560839108, using the wording proposed in #7 to explain session scope and the separate SD instance for each triggered-on relation; it did not include either attached implementation patch.
- Tom Lane subsequently requested that SD survive function redefinition and that both callers supply the dictionary to PLy_procedure_compile; Shihao's revised patch implemented these changes while retaining the separate hash #8 #9.
- Tom Lane committed #9 as c13c414c6e with minor include, test presentation, and commit-message edits, then confirmed the push in #10, completing the documentation correction and SD implementation fix.
- Shihao Zhong reopened the deferred optimization with a master-only follow-up that makes input collation optional in the shared function-cache key, preserves collation-sensitive caching for SQL and PL/pgSQL, and disables it for PL/Python while retaining the separate SD hash; its regression test checks Python global-variable sharing across collations, and the patch awaits review with no landing shown #11.