model-writtenrun 2939 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- PetSerAl reported a PostgreSQL 17.0 server crash on Windows and supplied a reproducer in which a PL/pgSQL function queries pg_cursors during cursor-query planning #1.
- Tom Lane diagnosed an older bug: pg_cursor() can encounter a portal already in the hash table whose sourceText remains NULL because PortalDefineQuery has not yet run #2.
- Tom Lane proposed hiding these incompletely defined portals and attached a three-line guard against NULL sourceText #2.
- The final thread message contains that proposed fix, with no subsequent testing or review responses in the supplied discussion #2.
- Tom Lane subsequently committed the patch unchanged apart from base context as 5c17f5a639, explaining that skipping undefined portals also protects callers in extensions and back-patching the fix to all supported branches.