Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xBFZc-000000036Fd-3SGO for pgsql-bugs@arkaria.postgresql.org; Mon, 28 Sep 2026 17:55:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xBFZa-0000000AqBg-3vVL for pgsql-bugs@arkaria.postgresql.org; Mon, 28 Sep 2026 17:55:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xBFZa-0000000AqBY-2vfE for pgsql-bugs@lists.postgresql.org; Mon, 28 Sep 2026 17:55:30 +0000 Received: from mail-vs2-x0d.google.com ([2a00:1450:4864:3a::d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xBFZY-00000001mOe-25LL for pgsql-bugs@lists.postgresql.org; Mon, 28 Sep 2026 17:55:30 +0000 Received: by mail-vs2-x0d.google.com with SMTP id ada2fe7eead31-781d728173cso130055137.3 for ; Mon, 28 Sep 2026 10:55:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790618127; x=1791222927; darn=lists.postgresql.org; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=0L+KaiXiTVlTobrDv9iJwI2rsL+YOhM0yWFNbFce+8k=; b=VFvA/OQz8NzoOm/RQXBx/DeHffA+rA7sC8lBfVeurUnOr2BbDPegpGwkP6IyZxQZvw RHmXixNMmy4uyl70TElzOQ+wFeSj53L7kVzr1HpLo+FVGGjRGyTPJh15na8LWnMtK5pI cxm6yzCGLxyZRDCAA5AVykcOKkchQPnoFwQsGalHzbhF1dzehKuQReUTSM8r0X1RUX9X f+mOcoJ/YsQPDjqBQ05eOZE15u70eBuPKyvG6wtxeBQSahZVps/8e3jeTvXlTb3T0wzq zE/2dxyXY1m39GhtzU4HbSAQie3u75A4TQAnNivW2GbOTJ3mdkQkXRg+vjdIkSNZWOr0 uVfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790618127; x=1791222927; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=0L+KaiXiTVlTobrDv9iJwI2rsL+YOhM0yWFNbFce+8k=; b=fF5Vu8L9Ohv4GsF3oVYHjClcYgfiP3zuENb2Z/kHt7HO3FZY1SVdWXawKdLGFy3Qod oY3a/m0/Lr2/h6o4dtPgRAA7upoaS2f86S+v6X/89YGZ9WK4K/+/Dz9h+fMxdVRQciNT hD2lGDyCXEl7d5Rzih4nxy4vO6BBA7+sGtQVgzKCAiCQPYsU553NK1a6gkalxWEn7/+w JL8GDB5WveSrUIxtIPx8minIcEvGCFnmqx+uyNBv5cb55Eq5T/pWXerZUIQOyLhoqtPx d5sVd9Br1OC0DA1GmpIWxXOcdfVpm5Scz+8Zw8+PoAXI/xP8/oe576X+NbceJfcmaq9s TFXg== X-Forwarded-Encrypted: i=1; AKwUvBxJbseyPDlYuf4UcAXUsDhvuzFacE7lEOa+oHG91b5rDpZ5r7gR/7HIYbdtfl0mQrMeRyqvn9eY1llW@lists.postgresql.org X-Gm-Message-State: AFq9FYKONTIS5CDdyLIjo2f9RWjgWHHo4LMmsSJ6KqxJ8hj6DyeA2YDP r5wxT/yfYkaeHHOszTFMg48W7FiV+ZGcDc4dpX9ZhdjPsULH0Jrq2xXK X-Gm-Gg: AYBFou36vwnSrXPETbuGndl4dtV8/qN4xqnLMAxSRhM2TvjhdT2g0LUrdlA1ab39dCP QapDbl7rdqJ53tLvOsOmR0ihYrRt0g/1cAnMlnlUuFSVfIuCJgI2ETR1r9/+E6MUayGxNNjTKPs EppGisqYgdbQng/nbVvD3KxN4mEc7oYBXhN/CnyVHjACfhhzFnhPcSzJ3TFYUO7PE8T3Tl1WNEB rZ8Wk450t/b9RWP+kbhC1x0boU2ZjjBFIYdObii3POpB6w8a9Zb9bgMEBXiCklvKhGCpRv6J8Oe LkRx21LgF+AERB1l6rFRSSu1JY812/0ARUNOvQ+wK4XznSmyuz696E+EEKHXIshXfRWgvTp66CT nu8tvN2IIOXt4VlhC5co7WM8bfrjdJYXNdR2kp/iUZM+QvBuW9D1o5SgSyn1ViEw5wE873YASLU ygNpWUx/ZCCjXHHsxHDoPOrOO3+jn5881CmpqpOhGyd2oxYasS7KcwSNHwnLEIJnFQJ9MJckzf0 AgNsqvr5F7ezB5obr0gZb7CGAiKK+bfdmiI8nh6kW8K9LxrTMtFXSSxuSzKL53aTDyWUHuKiEQI V2niu2LG+KNp968mb/jAA+H0btSlkLtTml6I X-Received: by 2002:a05:6102:5801:b0:7a7:c789:88e with SMTP id ada2fe7eead31-7af1c8a2515mr3508592137.1.1790618126773; Mon, 28 Sep 2026 10:55:26 -0700 (PDT) Received: from [192.168.1.4] ([2803:3c90:cee:ea00:5c3c:7e70:29e3:7a55]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-9889b1f453bsm7779896241.11.2026.09.28.10.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 10:55:24 -0700 (PDT) From: Manu To: Fujii Masao Cc: Ludvig Janiuk , pgsql-bugs@lists.postgresql.org Subject: Re: 42P16 error when dropping and adding column Date: Mon, 28 Sep 2026 14:55:21 -0300 Message-ID: <179061812106.376834.11309923193808938178@gmail.com> In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Fujii-san, > Thanks! Attached is v2 patch, which includes your tests. > While working with the v1 patch, I found that the following DDL failed > [...] v2 fixes this regression introduced by v1. I ran v2 through a differential of 32 ALTER TABLE cases on master (a5447a2deac) and REL_18_STABLE, cassert builds, comparing each build against unpatched master and REL_18: the 24 from the v1 review plus 8 around a separate named NOT NULL combined with ADD PRIMARY KEY. v2 fixes the reported case and the seven other 42P16 forms in the set, each with the expected catalog state (the primary key and an auto-created NOT NULL). The regression you caught, ALTER TABLE t ALTER COLUMN id DROP NOT NULL, ADD PRIMARY KEY (id), ADD CONSTRAINT hoge NOT NULL id; fails on v1 with "cannot create not-null constraint" and succeeds on v2, as do the drop-column and partitioned variants of it. No case in the set errors on v2 while succeeding on unpatched master or REL_18. The scenarios where a primary key still cannot be added (ONLY on an inheritance parent, a column that already holds a null row, a redundant named NOT NULL on a column that already has one) error identically on all three. master and REL_18 give the same result on every case, and make check passes on both. Thanks for folding in the tests. Regards, Manu