model-writtenrun 2124 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Dean Rasheed proposed OLD/NEW support for RETURNING in #1, using a Var flag and parser aliases to preserve existing table-name meanings while allowing explicit old and new values for INSERT, UPDATE, and DELETE.
- The initial design in #1 allowed otherwise absent rows to return NULL because ON CONFLICT and rewrite rules make OLD useful for INSERT and NEW useful for DELETE, and introduced RETURNING WITH aliases to avoid conflicts with trigger variables.
- After jian he tested the prototype in #2, Dean revised whole-row handling for dropped columns and avoided constructing unused OLD/NEW tuples in #3.
- Tomas Vondra supported the alias syntax and questioned foreign-table restrictions in #4; Dean explained the advantages over an older RTE-based design and added documentation in #5.
- Jian found SubPlan crashes and inconsistent foreign-partition behavior in #6, leading Dean to propagate expression flags and support foreign tables with direct modification disabled in #7.
- Dean corrected OLD/NEW parameter deduplication and EXPLAIN alias handling in #8, then extended the feature to MERGE once MERGE RETURNING became available in #9.
- Testing auto-updatable views exposed expressions that incorrectly remained non-NULL when the underlying OLD/NEW row was absent, so Dean introduced ReturningExpr wrappers and their planner, executor, and LLVM support in #11.
- Jian's review in #10 led to comment and deparser refinements in #12, followed by executor integration adjustments in #13.
- Jeff Davis endorsed the syntax but asked about overlooked interactions in #14; Dean analyzed rule pseudorelations and decided to defer the feature to PostgreSQL 18 because the recent view-related expansion needed more review in #558088.
- After updating MERGE coverage in #17, Dean returned three months later with #18, adapting to an unrelated executor revert, moving system-attribute null handling into the executor, consolidating rewrite helpers, and documenting rule behavior.
- Jian's July and August reviews prompted stronger checks, cached OLD/NEW detection, clearer documentation, and executor cleanup across #21 and #25, while an upstream SubPlan change removed the need for explicit flag propagation in #23.
- Dean changed absent whole-row OLD/NEW results from all-NULL records to SQL NULL in #27, applying the same semantics to regular tables and rewritten views.
- Jian proposed planner checks and parser optimizations in #28; Dean added defensive checks and improved error messages in #29, but rejected grammar-level OLD/NEW detection because arbitrary expressions and subqueries made it complex and error-prone.
- The October round resumed with a rebase and parameter-metadata cleanup in #32, then addressed Jian's coverage and ParseLoc observations in #34 and replaced the boolean option discriminator with an enum in #35.
- Dean removed speculative executor fast paths, excluded alias names from query jumbling, and simplified ReturningExpr EXPLAIN output in #40, judging the fast paths unlikely to justify their overhead.
- Jian requested additional error-path tests in #43, and Dean incorporated them while fixing quoted alias deparsing in #44; suspected pre-existing deparser problems were left for separate investigation.
- Dean committed the feature as 80feb727c8 from #44, adding duplicate-alias and ReturningExpr flag fixes with regression tests before announcing completion in #45.
- Richard Guo then demonstrated that schema-qualified RETURNING references became ambiguous in #46, and Dean fixed namespace lookup and added a regression test directly in 43830ecb8a, announcing the fix in #47.
- In June, Dean found two outdated documentation paragraphs and posted #48; Robert Treat identified two typos in #49, which Dean corrected before committing 3ba9639e39.
- The thread ends with Dean confirming the documentation fix was pushed in #50, leaving the feature and both follow-up corrections committed with no attached patch still pending.