model-writtenrun 6251 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Ján Pecsők reported that casting numeric(18,3) to plain numeric in a view still left a table created from that view with numeric(18,3), contrary to the requested cast #1.
- Tom Lane traced the problem to treating casts to unspecified typmod as complete no-ops and supplied a patch to expose the intended typmod, with numeric regression tests; he initially hesitated to backpatch behavior that had existed for decades #2.
- Dean Rasheed endorsed the fix and pointed out that ineffective casts also prevented users from resolving recursive-CTE type mismatches #3; this persuaded Tom Lane that backpatching could be worthwhile, after first shipping the change in PostgreSQL 14 beta3 and allowing time for complaints #4.
- David G. Johnston supplied related examples and supported the staged rollout #5; Tom Lane distinguished an incorrectly typed recursive query from a duplicate cast bug and confirmed his intention to commit #6, then landed the attached patch unchanged as 5c056b0c25.
- In December, John Naylor reported that the subsequently backpatched change broke partition pruning for explicit casts from character(16) to bpchar, providing a bisection result, reproducer, and contrasting execution plans #7.
- Tom Lane diagnosed that coercion-function lookup generated a real bpchar() call instead of a RelabelType #8; the original numeric tests had concealed the problem because numeric planner support simplified the corresponding function call.
- The follow-up 9c356f4b2d implemented the discussion's correction without another attached patch, forcing negative-typmod casts through RelabelType and adding bpchar index-use coverage; it was backpatched to supported branches, with PostgreSQL 9.6 already out of support, leaving both the original fix and its regression correction committed.