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 1t9LFu-009Msq-PM for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Nov 2024 09:26:14 +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 1t9LFs-007cDL-6K for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Nov 2024 09:26:12 +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 1t9LFr-007cDC-AX for pgsql-hackers@lists.postgresql.org; Fri, 08 Nov 2024 09:26:12 +0000 Received: from fout-b8-smtp.messagingengine.com ([202.12.124.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 1t9LFj-000pIa-LO for pgsql-hackers@lists.postgresql.org; Fri, 08 Nov 2024 09:26:11 +0000 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfout.stl.internal (Postfix) with ESMTP id C286B1140196; Fri, 8 Nov 2024 04:26:01 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Fri, 08 Nov 2024 04:26:01 -0500 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-sender :x-me-sender:x-sasl-enc; s=fm3; t=1731057961; x=1731144361; bh=p 0wH7Mw4QvMvBbdkf7EWHQ5Q4QrLpzD4lgQ/Y/dVdHA=; b=MPHbAG6p9iUOeWaRd KkHsHYhHmz8Ydpiy88vQwkP4jAa/1VrOpDzt/T38ciq1MxgsfAySb4/rgRtKczps pbPbfwQM0Qc+mSF3l4/j6gdyP1wTkJsF6DSuQgxWqrXGntKrahYv2eQ8E/oiimS5 7G5xwnDWe4wQtIG9fdIU8u4f91OJTuq2NwA68XPKfZUj+oF74+aEjk8Pr47KVxx0 85Ukq8L74IC0zSvgRvT4nnfC1vruY5Jhrw3hDzy4McLPkoPW1gPlvas62SpjO67R wR3/ZZc3T1UXePouO/a/6W+Hr6sxZaFQHI4y+vVlILdhtXVOGixDMabcZJSWadpx w/fDg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrtdeiucetufdoteggodetrfdotffvucfrrh hofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfurfetoffk rfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculd dquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhho mheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqd hiphdrohhrgheqnecuggftrfgrthhtvghrnhepkeefieehkeekffdtffeggedtffelkeei gfduvdekgfdugfeluedtiefhkeetudfgnecuffhomhgrihhnpehgihhthhhusgdrtghomh dpvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdroh hrghdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohep jhhirghnrdhunhhivhgvrhhsrghlihhthiesghhmrghilhdrtghomhdprhgtphhtthhope htnhgurhifrghnghesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggt khgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 8 Nov 2024 04:26:01 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1731057957; bh=xMH+4Z2pu11rb9rN/3E4yBRUm0YVONd8lmKxwFXT/os=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=isFyhVM3xzklyHBDOouYxUb9J/iZoqVrASfReGKpgW4cIPixj5CHetUFymfBxWTe5 y8pmOlAJ4D/COBZOVXK2cSK92w0yOfT9//YkgeNOwCsipb1o6IbxpR8LVgb/rhKDd4 ReCchqDwt4fYDiyKDDjf+mkpjT0z0Qr9Yl7yYXiLxbKx37KbBCCP6Xt2hUA84kuyg6 4VkQyXXELhgnQ3War68PGGAy8GNqQlX47kQyc40fgMRk5E1kFn+fPvAe2OHxFv9Tc8 WLYST6qOh2KYaPZjb9lgkak3B6FuGgUgv3vJQZcb84KQu4dG2LhEiouLHhnpjAD/GN b25UiBfF5FiEw== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id CDA3F9B; Fri, 8 Nov 2024 10:25:57 +0100 (CET) Date: Fri, 8 Nov 2024 10:25:57 +0100 From: Alvaro Herrera To: jian he Cc: Pg Hackers , Tender Wang Subject: Re: not null constraints, again Message-ID: <202411080925.z3appqymaoaw@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-Nov-08, jian he wrote: > > Here's v11, which I intended to commit today, but didn't get around to. > > CI is happy with it, so I'll probably do it tomorrow first thing. > > > > CREATE TABLE notnull_tbl2 (a INTEGER CONSTRAINT blah NOT NULL, b > INTEGER CONSTRAINT blah NOT NULL); > > RelationGetNotNullConstraints, StoreRelNotNull > will first create the constraint "blah", then iterate through the > second "blah" error out, > which is not great for error out cleaning, i believe. I applaud your enthusiasm, but I don't like this change. We have plenty of cases where we abort a command partway through after having created a bunch of catalog rows (we even have comments about such behavior being acceptable); if we wanted to get rid of them all, the code would become far too complicated because it'd have to save state until the last minute, just in case something else threw errors. Your proposed coding seems complicated enough, in fact, given how fringe an error condition it's protecting against. It's not like the user will try to run the command thousands of times "to see if it works next time". One dead catalog row every now and then won't hurt anything. > while debugging, in RelationGetNotNullConstraints > if (cooked) > { > CookedConstraint *cooked; > cooked = (CookedConstraint *) palloc(sizeof(CookedConstraint)); > cooked->contype = CONSTR_NOTNULL; > cooked->name = pstrdup(NameStr(conForm->conname)); > cooked->attnum = colnum; > ..... > } > We missed the assignment of cooked->conoid? Eh, I can't see the OID would ever be useful for anything, but let's put it there just in case some future caller wants it for some reason. > MergeConstraintsIntoExisting > /* > * If the CHECK child constraint is "no inherit" then cannot > * merge. > */ > if (child_con->connoinherit) > ereport(ERROR, > (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), > errmsg("constraint \"%s\" conflicts with > non-inherited constraint on child table \"%s\"", > NameStr(child_con->conname), > RelationGetRelationName(child_rel)))); > > the above comment can also be hit by not-null constraint, so the > comment is wrong? Strange ... my copy is fixed already, and in fact I don't see the patch touching this function at all. [ pokes around ] Ah, I changed it two weeks ago: https://github.com/alvherre/postgres/commit/efeed9416b8c7397d61446958d6835e23ec3f0b6 Thanks for looking once more! -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "La grandeza es una experiencia transitoria. Nunca es consistente. Depende en gran parte de la imaginación humana creadora de mitos" (Irulan)