model-writtenrun 7526 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Amit Langote reported that cross-partition UPDATE could misinterpret joined-table columns in RETURNING when partitions had different row layouts, and proposed converting the inserted tuple back to the source layout and evaluating its RETURNING projection in ExecUpdate #1.
- Takamichi Osumi tested the initial patch successfully, while Amit Kapila questioned both the placement of RETURNING evaluation and the trigger test; Amit Langote explained why destination-compatible plan tuples were difficult to construct and clarified that the trigger test protects changes made to the inserted row #4 #6 #7.
- Etsuro Fujita supplied revisions that suppressed RETURNING when an INSERT trigger canceled insertion, used the actual slot returned by an FDW, and corrected tableoid to identify the destination partition #8 #9.
- Amit Langote then found that tuple conversion lost system-column information, supplied a separate heap-slot workaround, and sketched copying transaction metadata; Etsuro Fujita rejected the sketch as incorrect for foreign tables, leaving the main fix entangled with the broader system-column problem #10 #11 #13.
- Alvaro Herrera urged fixing the RETURNING bug independently of the larger table-access-method problem, while Amit Langote and Etsuro Fujita agreed on retaining the source projection but continued debating how system attributes could be transferred safely #15 #16 #17 #18.
- Etsuro Fujita corrected his earlier revision, added CTID copying and a PostgreSQL 11 variant, and Amit Langote requested clearer comments and system-column tests; discussion then considered restricting RETURNING access to certain system columns on partitioned tables #19 #20 #21 #24.
- Amit Langote rebased the main patch after executor refactoring in October, explicitly recording that the system-column question remained unresolved, and returned in March with versions for all affected branches and a request to proceed independently #28 #30.
- Tom Lane reported that intervening development had eliminated the bug on HEAD, so only PostgreSQL 11–13 needed this fix; he reworked the patch to keep RETURNING evaluation inside ExecInsert and pass the source projection and destination table OID separately #31.
- Amit Langote ported Tom Lane's revision to PostgreSQL 11 and 12 and proposed skipping conversion-map checks when the source and destination slots were identical, leaving that optimization for the committer #32.
- Tom Lane added the slot-identity optimization and pushed the branch fixes, represented by 27835b5476, from the final ports in #32, crediting Amit Langote and Etsuro Fujita for the patch #33.
- The thread ended with acknowledgments from Amit Langote and Etsuro Fujita after the main fix landed for PostgreSQL 11–13; the separate heap-slot workaround was not included in this commit #34 #35 #10.