Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plrsU-0006jP-Pw for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Apr 2023 13:48:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1plrrU-0003Pr-JE for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Apr 2023 13:47:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plrrU-0003Ph-As for pgsql-bugs@lists.postgresql.org; Mon, 10 Apr 2023 13:47:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plrrN-0000AE-Gb for pgsql-bugs@lists.postgresql.org; Mon, 10 Apr 2023 13:47:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 33ADkxTC4031606; Mon, 10 Apr 2023 09:46:59 -0400 From: Tom Lane To: Michael Paquier cc: Richard Guo , Alvaro Herrera , PostgreSQL mailing lists Subject: Re: ERROR: no NOT NULL constraint found to drop In-reply-to: References: Comments: In-reply-to Michael Paquier message dated "Mon, 10 Apr 2023 16:55:28 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4031604.1681134419.1@sss.pgh.pa.us> Date: Mon, 10 Apr 2023 09:46:59 -0400 Message-ID: <4031605.1681134419@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > On Mon, Apr 10, 2023 at 03:16:06PM +0800, Richard Guo wrote: >> I run into error $subject with the query below: >> # create table t1 (c int primary key null unique); >> CREATE TABLE >> # create table t2 (like t1); >> CREATE TABLE >> # alter table t2 alter c drop not null; >> ERROR: no NOT NULL constraint found to drop > Thanks for the report. This is not the only issue that has been > pointed out with this patch, so it is going to be reverted if you look > around here: It's still good to know about it for next time. The issue I guess is that LIKE with no options propagates column attnotnull bits, but not constraints, so we now have an inconsistency: t2.c has attnotnull set but there is nothing in pg_constraint to justify it. It seems to me we're going to have to think about what we want to happen in this case. In a green field we'd probably not propagate NOT NULL unless told to copy constraints ... but is it okay to break functional compatibility with the old behavior? regards, tom lane