model-writtenrun 8656 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Justin Pryzby reported that ALTER TABLE type changes lose the index designation used by subsequent CLUSTER commands and supplied an initial fix that saves an extra SQL command alongside index definitions #1.
- Amit Langote replaced that bookkeeping approach with a PreserveClusterOn() helper that directly queues AT_ClusterOn commands and added tests for ordinary and primary-key indexes; his follow-up corrected comments and brought the patch onto the mailing list #2 #4.
- Justin proposed storing the clustered index's OID in pg_class, and Alvaro Herrera encouraged an experiment while warning about index deletion; Justin then posted an incomplete catalog redesign alongside an obsolete-comment correction and bootstrap consistency checks #5 #6 #8.
- Justin withdrew the catalog redesign because it adds overhead to every pg_class row and still requires the original ALTER TABLE fix; the bootstrap checks were not carried into the final fixes, and Tom Lane later noted that the separate comment correction had been superseded #10 #11.
- Justin discovered that REINDEX CONCURRENTLY independently loses the clustering designation, identified it as a PostgreSQL 12 bug, and submitted its fix alongside a rebase of Amit's older ALTER TABLE fix #12 #13.
- Michael Paquier found that the REINDEX regression test needed to inspect indisclustered, then committed that component with test and comment adjustments as d79fb88ac7 and backpatched it to PostgreSQL 12 #14 #15.
- Justin resent the remaining ALTER TABLE patch, and Ibrar Ahmed reported that its feature checks and installcheck-world tests passed #17 #18.
- Tom Lane objected that consulting old index objects inside ATPostAlterTypeParse() violates its reconstruction contract and urged capturing clustering metadata earlier; Amit consequently reworked the patch to remember the index before rebuilding and restore its designation during cleanup, following the recently introduced replica-identity preservation approach #19 #20.
- Justin added a companion cleanup using the new get_index_isclustered() helper in three cluster.c locations; Alvaro Herrera and Michael Paquier favored retaining that helper name for consistency with existing cache routines, and Michael proposed keeping the cleanup on the development branch #21 #22 #23.
- Michael requested tests that retain both clustered and unclustered indexes, and later supplied revised comments and tests checking ordinary and constraint indexes together without changing the fix's logic #23 #26.
- Michael also raised a separate question about whether ALTER TABLE rewrites should rebuild invalid non-toast indexes, which can cause a rewrite to fail; the thread did not resolve or implement that behavior change #23.
- Michael initially questioned whether replacing the lookup in cluster_rel() could turn a harmless missing-index case into an error, prompting discussion of an optional missing-index flag; Alvaro explained that the preceding existence check and exclusive table lock already exclude that case, so Michael retained Justin's original cleanup #26 #27 #30 #29 #31.
- Michael committed the final ALTER TABLE patch from #26 with formatting and comment reflow as a40caf5f86, then committed the unchanged cluster.c companion from #21 as 8ef9451f58; his closing message confirmed that the bug fix was backpatched through PostgreSQL 9.5 and the cleanup applied only to the development branch #32.