ALTER TABLE ... ALTER COLUMN TYPE ... USING stores wrong values (or errors) in children whose attnos differ from the parent, when USING has IS [NOT] NULL, IS [NOT] TRUE/FALSE/UNKNOWN, or named function arguments =================================================================================================================================================================================================================== AI-generated bug report from the AI Annex Report ID: 01a2347b-ecce-7597-bf6d-8a9f65619227 Filed: 2026-12-02 02:01:06 UTC Severity: 55/100 Blamed commit: 1281a5c907b41e992a66deb13c3aa61888a62268 ## Summary ALTER TABLE ... ALTER COLUMN ... TYPE ... USING stores wrong values (or fails with an internal error) in child tables or partitions whose column numbers differ from the parent's, when the USING expression contains IS [NOT] NULL, IS [NOT] TRUE/FALSE/UNKNOWN, or named function arguments. Reported on pgsql-bugs on 2026-10-13 (BUG #19756). ## Reproduction ```sql CREATE TABLE pu (x int, k int, a int, b int, c int) PARTITION BY LIST (k); ALTER TABLE pu DROP COLUMN x; CREATE TABLE pu1 PARTITION OF pu FOR VALUES IN (1); INSERT INTO pu VALUES (1, 5, NULL, 9); ALTER TABLE pu ALTER COLUMN a TYPE bigint USING CASE WHEN b IS NULL THEN -1 ELSE a END; SELECT k, a, b, c FROM pu; -- a = 5, expected -1 ``` With plain inheritance: ```sql CREATE TABLE r (a int); CREATE TABLE r1 () INHERITS (r); ALTER TABLE r ALTER COLUMN a TYPE int USING (1 IS NULL)::int; -- ERROR: unrecognized node type: 7 (SQLSTATE XX000) ``` ## Analysis ATPrepAlterColumnType() maps the transformed USING expression to each child's column numbers. ATPrepCmd() then runs ATParseTransformCmd() again for each child, which re-parses the raw USING expression and replaces the already-mapped expression. Some node types (NullTest, BooleanTest, NamedArgExpr) then reference the wrong child column, or fail with "unrecognized node type" when parsed a second time. A reply on the list identifies 1281a5c907b4 ("Restructure ALTER TABLE execution to fix assorted bugs") as the origin; 12.x is unaffected. ## Branches 1281a5c907b4 is in REL_13_STABLE through master; the list report says it reproduces on 13 through 18 and master. No fix commit found on master as of dc168a83874f.