model-writtenrun 6355 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Andres Freund reported that logical replication's slot_store_error_callback() could access catalogs when the transaction was already unsafe, and Masahiko Sawada identified format_type_be() as another unsafe lookup and offered to fix it #1 #2.
- Masahiko Sawada's first patch precomputed local and remote type names before invoking the callback; Bharath Rupireddy reviewed it, identified the analogous postgres_fdw problem, and supplied naming and formatting refinements while reporting successful regression tests #3 #4 #5 #6.
- A parallel assertion experiment tried to prohibit unsafe catalog accesses globally: Bharath's error_context_stack check failed during initdb, and Masahiko replaced it with recursion-depth and error-level checks; subsequent discussion exposed uncertainties and deferred that work to a separate thread #6 #7 #8 #9 #10.
- Bharath introduced a postgres_fdw patch that precomputed conversion-context names, incorporated Masahiko's helper-name and fallback suggestions, combined both callback fixes into one series, and corrected description errors reported by Zhihong Yu #8 #9 #10 #11 #12.
- Amit Kapila requested evidence that the replication fix addressed a real failure and suggested debugger-assisted testing; Bharath demonstrated the original assertion failure and successful patched error reporting, while Andres supplied a critical-section reproduction and Bharath later tested the callback outside a transaction #13 #19 #20 #22 #23.
- Tom Lane objected that precomputing names imposed catalog lookups on every column of every row and leaked memory; he proposed dropping replication type names and either caching postgres_fdw names at setup time or obtaining them from the query rangetable #24.
- Bharath adopted the simpler replication design, removing type names from the context message and deleting the now-unused logicalrep_typmap_gettypname() function #26.
- For postgres_fdw, Bharath instead implemented a hash table populated once at scan startup, bundled it with the revised replication patch, and later rebased the series without changing either design #27 #28.
- Tom committed the replication half of #28 as 50371df266, additionally deleting the unused type-map cache and update machinery while retaining protocol TYPE messages; he explicitly left postgres_fdw for further review #29.
- Tom then rejected the postgres_fdw hash table's complexity and unnecessary lookup work, replacing it with direct rangetable access that reports query aliases and preserves a generic fallback for expressions #30.
- Bharath endorsed Tom's replacement and suggested a small simplification, while separately reviving the global assertion proposal; Tom explained that the assertion would reject legitimate catalog lookups during error construction and declined it #32 #482191 #33.
- Tom extended rangetable-based reporting to simple foreign-table scans and adjusted regression tests to demonstrate alias handling; Bharath approved this version with only a line-wrapping suggestion #34 #35.
- Tom applied that formatting suggestion and committed #34 as c7b7311f61, leaving both callback fixes landed by the final message and the broader assertion experiment unadopted in this thread #36.