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.94.2) (envelope-from ) id 1ruViP-005qZf-Dy for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Apr 2024 11:02:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ruViO-0011z5-9U for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Apr 2024 11:02:04 +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.94.2) (envelope-from ) id 1ruViN-0011yx-TZ for pgsql-hackers@lists.postgresql.org; Wed, 10 Apr 2024 11:02:04 +0000 Received: from wfout8-smtp.messagingengine.com ([64.147.123.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ruViH-000BTr-1Q for pgsql-hackers@lists.postgresql.org; Wed, 10 Apr 2024 11:02:03 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.west.internal (Postfix) with ESMTP id BC3E71C00074; Wed, 10 Apr 2024 07:01:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Wed, 10 Apr 2024 07:01:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712746914; x= 1712833314; bh=4YZT38c9P3WaZGMDzHz8WeuJ58GNjm/9Bm1kqIhAYcw=; b=m WqpQ9LuFNAGGYYNwcd12KKNKjzpk0F/POmqA4bJHKICUm2zruPMUYBHlaHRBgavb JQMmP3o92f+QTlzgMuhriH0nSdiTom8Huk0U0goHyxxclu/VhCetyjgs8yzGaJ5R 6Hi6uec5NmpBDTIutF8FqM4UboWiP4NlcMVmwhNMRlqOqYfkPCBVwxIMsu79cTxc Su18QVzqHRq09ZSuJN8XEekZ6LcY/XqoGlp2xl+yRWaun4Zn4M5Ra0a+9bn0SeP9 6eFciKUZ4MRW8dOfoYI67+6JXYcW8d9sMl/cUWe9OiG5jAye4kzT1Cx1xcNbVQbf cvZ5qQeoydaxztgehSWGQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehiedgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 10 Apr 2024 07:01:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1712746912; bh=h7y8m8i+g6xOqb8JE4DeDliggehXRAKfrHlZodVzaWM=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=TqrE/2J4tUjEn/uFvKr9BRK+EwnZWOAkKQiEJkudFHHC1X5KObqoOS5n2/SVn7rVd N7DmwtszuL4Ir8vdJsejVXaT2gdmXT22aFjqV3pIx/64Ld4s2GOKUwhjZBrES3/syG PBN+nccQCCX5vA75xE62TvqsuUuAC9/Olbs3meakyA2iqovkh+MX9cfWw3ff9ZGyts veUkHccuN2cN+T+6xDWv9qmBH9ZR0m0YbZFRuQQKf2+UYSIW2eRPOnPK8nckg4yKSj 6Tym/6f6C5aprfYva59DL6lMcizFKD1lQN9/zuV/iMoawsa6seWA6m+q0aFbVBlMs6 ih3IwSIzaXYXQ== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 2A9FB385; Wed, 10 Apr 2024 13:01:52 +0200 (CEST) Date: Wed, 10 Apr 2024 13:01:52 +0200 From: Alvaro Herrera To: jian he Cc: Tender Wang , PostgreSQL Hackers Subject: Re: Can't find not null constraint, but \d+ shows that Message-ID: <202404101101.c7brh2evkssj@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Apr-10, jian he wrote: > another related bug, in master. > > drop table if exists notnull_tbl1; > CREATE TABLE notnull_tbl1 (c0 int not null, c1 int); > ALTER TABLE notnull_tbl1 ADD CONSTRAINT Q PRIMARY KEY(c0, c1); > \d+ notnull_tbl1 > ALTER TABLE notnull_tbl1 ALTER c0 DROP NOT NULL; > ALTER TABLE notnull_tbl1 ALTER c1 DROP NOT NULL; > > "ALTER TABLE notnull_tbl1 ALTER c0 DROP NOT NULL;" > should fail? No, this should not fail, and it is working correctly in master. You can drop the not-null constraint, but the column will still be non-nullable, because the primary key still exists. If you drop the primary key later, then the column becomes nullable. This is by design. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "El miedo atento y previsor es la madre de la seguridad" (E. Burke)