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 1ruqS0-0080F9-Vp for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Apr 2024 09:10:33 +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 1ruqRz-00FRx7-5J for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Apr 2024 09:10:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ruqRx-00FRvE-RW for pgsql-hackers@lists.postgresql.org; Thu, 11 Apr 2024 09:10:30 +0000 Received: from fout5-smtp.messagingengine.com ([103.168.172.148]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ruqRs-002K4O-No for pgsql-hackers@lists.postgresql.org; Thu, 11 Apr 2024 09:10:28 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id A48101380130; Thu, 11 Apr 2024 05:10:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 11 Apr 2024 05:10:22 -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=1712826622; x= 1712913022; bh=NLHcPBjiAnxUtbixdRC1sXy61N0GP/lsy7Txcnk99LI=; b=N YUUVHLiaE/Daalhd1bRfTUHgLlWjSh3BxPch+14dd0cFKenT4zjfhtXIGe1Tp8GM JQUMih6I9EIAvNIE1tnVgcTiB67VhUM9cxE8lx9oanLdVwTmpVH7rpCKpcZZOBB9 FiTUZhD6sigtoD2ptgzZpWttHuabc9ZFcZakcG7OghLfaCWJk42/gVAm8+jjUeaA ySWxSfpZHsskShx5WvgAdojlC1lLOD6fucZq1XrPORN3DaYTISe64IZL0/Y+ERlH SGCbn1Rh4Dcuz/yoKGN7SDDF1PLr5dD9gLV6DhAHDTGGplUEZz8zypwNYJjVANTi tL6KnPkXJwdia5npvh7iQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehkedgudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 11 Apr 2024 05:10:22 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1712826617; bh=gyFGazxi47sRBJX17W24678v4Rbm5uCNdXcTj21dM30=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=j5fOo0DBok7Bntzrt1U6zQF+DiTvLNitnmFQDzR/h0mehG4wTS+K1Sz8MATJsWxen Chpzyq9psWrh1CV56NX5qvAMlNaUKahdkt9SFVUNuyDMhS/QVg6e2ILbm29YxPHnUN /GXubjtL3pGncMkPmPsPOazwmZgQskMdhGSHzzccVrDUkJ3oFZymsuE1Z6GDkX5vro vrI/3zshhbN+lWxyn+VM1Er2zYmv5zl8sA3qAdKisEX5k7NQWXIQ0wYPVLXG9Z6W5L YNKA1DRft/n5SnmEFXyvZl3SGNzqALKgC/x+1W+J2UG/uN0bOTRur6rhYAXBuTgssG j8temNnpiFoGA== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id E63B336E; Thu, 11 Apr 2024 11:10:17 +0200 (CEST) Date: Thu, 11 Apr 2024 11:10:17 +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: <202404110910.dbwfcz47kpth@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-11, jian he wrote: > now I figured out that > dropping a column of primary key columns will not change other key > columns' "not null" property. > dropping the primary key associated constraint will make all key > columns "not null" property disappear. Well, I think you were right that we should try to handle the situation of unmarking attnotnull as much as possible, to decrease the chances that the problematic situation occurs. That means, we can use the earlier code to handle DROP COLUMN when it causes a PK to be dropped -- even though we still need to handle the situation of an attnotnull flag set with no pg_constraint row. I mean, we still have to handle DROP DOMAIN correctly (and there might be other cases that I haven't thought about) ... but surely this is a much less common situation than the one you reported. So I'll merge everything and post an updated patch. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ Bob [Floyd] used to say that he was planning to get a Ph.D. by the "green stamp method," namely by saving envelopes addressed to him as 'Dr. Floyd'. After collecting 500 such letters, he mused, a university somewhere in Arizona would probably grant him a degree. (Don Knuth)