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 1udn9l-00061f-Ca for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jul 2025 09:50:02 +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 1udn8m-000A6h-AV for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jul 2025 09:49:00 +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 1udn8l-000A6Z-Kf for pgsql-hackers@lists.postgresql.org; Mon, 21 Jul 2025 09:49:00 +0000 Received: from fhigh-b7-smtp.messagingengine.com ([202.12.124.158]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1udn8i-0001Bz-0l for pgsql-hackers@lists.postgresql.org; Mon, 21 Jul 2025 09:48:59 +0000 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 042E97A0359; Mon, 21 Jul 2025 05:48:54 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Mon, 21 Jul 2025 05:48:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm1; t=1753091334; x= 1753177734; bh=nFubO340TfArAu6iNbmdnQS8wSreW2LjLMDpVHLLf9I=; b=d OP5CAw7+XMEZ8nBK+OpRv5ldXyxrkeS6YqNA/mmHQEuc8GBpY+i69J4CeX87Y2Ho 7dxZrtEKNvW20L5j4GvFzGGaeA7eEqaul2Qne++POxA3Ohdr3ykf3jpPKnjDXoVt vgQeboMU7PDFc/XAOD/35XAZJpB3AxSUvwQKIl1r0Kgw3hvV1J1mSrixp5ZtBwey HIDOIN00+qS3FAUS3i6/M4PVQrlH4j17XrWgLcjBr+xUAOOnSEL5jpNweulz6DgU tMo0zuEW9cFlhddpveoF+j8d92Xa9MSndHcsb8fu2lh3s2HziUsyMh5ElMPLUG4y Hp8x9b4RknKt3qCYJO9gg== 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=fm2; t=1753091334; x=1753177734; bh=n FubO340TfArAu6iNbmdnQS8wSreW2LjLMDpVHLLf9I=; b=f7cQ7cKYbP9jaXFBt OuID6s21G+isOt43tVbjRdglsZ6M5Hg/07JsF9vmuw/H8ZVd7QyoGPvW9IhVOXlf +8EdkU94uzsYgI0Xh1S/V2jwGeHygSPGXynrECE2fvBUyjxD1NxWBwsZ67VtdGf0 7psnUnvd5i41X0LWZXuwfOmyHshxdsMbY5BOwU0ZvllYIIiK8049mMTTtRYp6I00 JpatibkG7jsH+zzHjJP2Kne3ELp9Jyb6JhH0BlMwMTRiTIvqJHrRQFlCD3nUXSKH Ex4Kq5qWPOaPx4wUdZwv/VL3L2MXCZxhAdDSJmMDt278EBh7tV2FBACqB4fYGOog VI2Uw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejudejiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpemllhhvrghrohcu jfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgeskhhurhhilhgvmhhurdguvgeqnecuggftrf grthhtvghrnhepteeuvdehffekvefgueehveetveekgfegtddtueefueehuddutdfhfeff hfejfeffnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvges khhurhhilhgvmhhurdguvgdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohepjhhirghnrdhunhhivhgvrhhsrghlihhthiesghhmrghilhdrtgho mhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrh gvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Jul 2025 05:48:54 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1753091332; bh=wPn8r3WO7srLjo79ymci3XXuNnOcjj8Kr2Kt3YOfzpg=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=bUnc2e3iej6HCyCg0k/XTGWmhBZw/60DVWl+P7bvZ/q7vD9KiI5okyEV8YdmIfzut lPgK0cDgThiwTkAtMKhD2yEPJ1JBkuU75woJ4vUeTBqb2FjJ10hzo6xYbLrYQzoHpF C/iN9zjtHgU90gwSm5tzFlbE9ITdcGLkoe3lU4aGFMHyqgoX7iHqSrEjLyQ4xpYt5/ M+e0pSoIsN59/42MdeSGVAEX9/XLVduocB0Pis/egcUY7c9chbSOs5TUq9c6vzEcX4 ptoQCDuYejWybY1wsaQz0QfIVxyducpjSr+BuxxeE7YsF6UPfByKBtgLJ0c0QA8nE4 oRhtCQyP5FGQQ== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id C59D790; Mon, 21 Jul 2025 11:48:52 +0200 (CEST) Date: Mon, 21 Jul 2025 11:48:52 +0200 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: jian he Cc: PostgreSQL Hackers Subject: Re: pg_dump does not dump domain not-null constraint's comments Message-ID: <202507210948.lljgqgrrnm5v@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 2025-Jul-18, jian he wrote: > one minor issue in getDomainConstraints: > > for (int i = 0, j = 0; i < ntups; i++) > { > char contype = (PQgetvalue(res, i, i_contype))[0]; > .... > constraint->contype = *(PQgetvalue(res, i, i_contype)); > } > > for the same code simplicity, > ``constraint->contype = *(PQgetvalue(res, i, i_contype));`` > can change to > `` constraint->contype = contype; `` > ? > other than that, looks good to me. Thanks, changed it that way. I noticed some other issues however. First, you had removed the contype comparisons in repairDependencyLoop; I put them back several versions of the patch ago, but I had mistakenly made them reference the wrong array item -- in all three places. Doh. Second, the name comparisons to determine whether to list the constraint name in the "CREATE DOMAIN .. NOT NULL" syntax was wrong: it was using fmtId() around the constraint name, but of course that would have never worked, because we're comparing to the original string, not a quoted name. So if you had a domain called, say CREATE DOMAIN "my domain" AS int NOT NULL; then pg_dump would have said CREATE DOMAIN "my domain" AS int CONSTRAINT "my domain_not_null" NOT NULL; even though listing the name is unnecessary. This wouldn't have made the dump fail, so it's borderline; but it would be /slightly/ ugly. Lastly, I made dumpDomain print unadorned "NOT NULL" if a pg_constraint row for the constraint is not found and yet we observe typnotnull set. This can be considered catalog corruption (the row should be there), but I think this is better than having pg_dump just crash if that row is not there. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ Voy a acabar con todos los humanos / con los humanos yo acabaré voy a acabar con todos (bis) / con todos los humanos acabaré ¡acabaré! (Bender)