model-writtenrun 8514 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Alberto Piai proposed converting a backfilled ordinary column into a stored generated column without a long table rewrite under AccessExclusiveLock, using a trigger, a separately validated CHECK constraint and a final conversion command; his initial two-patch prototype rewrote by default but skipped rewriting when it found a structurally matching equality constraint #1.
- Alberto extended the prototype to partitioning and inheritance, requiring conversion of the whole hierarchy and explicitly retaining STORED in the syntax; subsequent preparation revisions reused cooked expressions, moved dependency checks before catalog changes and reorganized tests #2 #4.
- Laurenz Albe's first review supported the feature but identified missing documentation and completion, invalid conversions of identity and serial columns, and a NULL case where ordinary equality incorrectly allowed the rewrite to be skipped #5.
- Reporting discussions at pgconf.dev, Alberto credited Staš Kotarac Guček with another NULL warning, Tom Lane with questioning silent overwriting when no suitable constraint exists, and Álvaro Herrera with suggesting a dedicated conversion command; Alberto consequently proposed naming the constraint and failing rather than rewriting #6.
- Laurenz endorsed failure without a suitable constraint, recommended preserving the CHECK constraint and tentatively allowing ordinary equality for NOT NULL columns, and withdrew his earlier request to extend rewrite avoidance to SET EXPRESSION #8 #9.
- Alberto implemented the redesign as one patch, taking colleague Philip's suggestion to derive the generation expression directly from the named constraint, retaining that constraint and adding documentation, completion and dependency checks; he also described logical-replication migration strategies and supplied separate experimental subscription tests outside the main patch #10.
- After CI exposed the fragility of a test based on DEBUG output, Alberto added injection-point tests to verify that conversion neither scans nor rewrites the table #11.
- Laurenz's next review prompted shorter syntax, symmetric operand handling and clearer errors; Alberto and Laurenz settled on ADD GENERATED USING CONSTRAINT ... STORED, keeping GENERATED to match existing identity syntax and STORED because virtual generation is otherwise the default, and Alberto implemented these changes with improved cast diagnostics and hierarchy checks #12 #13 #14 #15.
- Further review refined documentation and hierarchy diagnostics to refer to the root table, after which Laurenz marked the patch ready for a committer #16 #17 #18 #19 #20 #21 #22.
- Alberto then demonstrated that a NOT NULL destination still does not make ordinary equality safe when the generation expression can return NULL, so he removed that form while retaining either operand order for IS NOT DISTINCT FROM; Laurenz agreed that ordinary equality should be abandoned #25 #26.
- Solai v reported successful builds, regression tests and conversions on tables containing up to one million rows with unchanged relation files and sizes; Alberto subsequently refreshed the patch and repaired completion and regression tests #27 #29.
- Alberto found that IS NOT DISTINCT FROM also permits unequal representations, such as numeric values with different scales, potentially breaking unique expression indexes during later updates or dump/restore, and removed the ready-for-committer designation pending a sounder equality test #30.
- Laurenz suggested comparing type send-function outputs, while Matthias van de Meent proposed his pg_datum_image_equal function and described restricting ordinary equality to types whose equalimage support proves representation equality; Álvaro questioned the practical significance, but Matthias and Alberto argued that observable representation differences and restore failures must be prevented #31 #32 #33 #34 #36.
- Alberto preferred a dedicated datum-image comparison because an equalimage restriction would exclude useful types such as jsonb and tsvector; Laurenz proposed the existing record-image equality operator as an alternative, and Matthias objected to its overhead and more complicated constraint syntax #37 #38 #39 #40 #41.
- Alberto resumed with a two-patch series incorporating Matthias's datum-equality implementation and requiring CHECK constraints using pg_datum_image_equal, leaving record-image comparison as a fallback if that dependency could not land; he also added foreign-key action checks and tsvector coverage, removed foreign-table support because conversion there needs no local rewrite, and cleared missing-value metadata #42.
- Xiaoxuan Li showed that clearing missing-value metadata loses values for pre-existing rows in columns added with a constant default, despite the CHECK constraint remaining validated, and moved the entry to Waiting on Author #43.
- After considering whether generated columns could safely retain missing-value metadata, Alberto chose to reject columns with atthasmissing, added a regression test and documented starting without a DEFAULT; he acknowledged that this conservative restriction could be discovered only after a user had completed backfilling #44 #45.
- Zsolt Parragi's final review reported that session settings can change expressions during deparse/reparse, BEFORE-trigger WHEN conditions can retain prohibited references to generated columns, and multiple inheritance or typed-table conversions can produce states that fail dump/restore #46.
- The thread ends with the two-patch series still under review and no linked commit: Zsolt also found that foreign-key checks incorrectly reject conversion on the referenced side, and none of his five reported issues has a subsequent fix in the supplied thread #45 #46.