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 1tE6Kq-0058yy-Lu for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Nov 2024 12:31:00 +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 1tE6Kp-00FDMJ-BW for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Nov 2024 12:30:59 +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 1tE6Ko-00FDMA-WF for pgsql-bugs@lists.postgresql.org; Thu, 21 Nov 2024 12:30:59 +0000 Received: from fhigh-a8-smtp.messagingengine.com ([103.168.172.159]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tE6Kl-0036MQ-QK for pgsql-bugs@lists.postgresql.org; Thu, 21 Nov 2024 12:30:58 +0000 Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 4E2AD114019B; Thu, 21 Nov 2024 07:30:54 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Thu, 21 Nov 2024 07:30:54 -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=fm1; t=1732192254; x=1732278654; bh=5 OPC63tyr3Nwzis80PRvzeGZErbKcX2EcTe23HLZ97w=; b=2+IhxF/xAWuMpX7tB ogoBDiqcPdMKriGNFyWKSTqzeE7TkdJNxtO/cq279IR8s2DyrouFiVt/K0Ndkrm1 csLwPf3t7vBIMklR2jhHBUssr+XbXwSEmkefTOGBU0Oaid6hCcLAWLdm+RcNuZPk H3fR9Zabz1sXrub9jsDe8W2t7F0coVomB+2gG63zLP2JM8oqO0nrJ3j5QYRsLali IQtrLoZiiOI0sr3fPb4hEUhjx7KzJr+mLZzA4sosdR1ZYmuxM6sw23ofl/Dcgn/G BzfI+rkiDKBNWtgmtYbhUNEVMHebKy2GbuTTFkPR1zRi+qlzK3i6R59yExZYzATc RpTpw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrfeeigdeflecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpeffhffvvefukfggtggugfgjsehmkeerredttdejnecu hfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrd hnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeduleekkefgtddttedtkefguddv ieffleetgeejiefhteehkeevfeettdduvdfhueenucffohhmrghinhepvghnthgvrhhprh hishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrghdpnhgspghrtg hpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepmhgrghhnuhhssehh rghgrghnuggvrhdrnhgvthdprhgtphhtthhopehpghhsqhhlqdgsuhhgsheslhhishhtsh drphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepvghrkhhirdgvvghsshgrrghr sehtrghlthgvtghhrdgvvg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Nov 2024 07:30:53 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1732192252; bh=RsmktXGCkNXdyW6CVGTkP+XqDgVe1BvPpQRjN/O6Rnw=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Q3snv+cKeLU4DV0N7MKbFbc6mbdx+AGRBr73eSDrclTtNtjSNeMnjRtNJy+5S2Yij NavhwyyY+AThZ/H3QeVlIJp7+9K+SNkHZQtDEXYyuB+QUuFxQM6rDHUfYFqow3UTh0 dMO44NU7pRp+zFl1F/iB2w/VlE7FSQlW7nTn0Hjt5QveADWQzPMj2pDsTDdqIJnzHd Ts5fz51Bh2jY6iqB+gl8BCZ91/mWmKPXDVfUOY+vpRxEI8lDPrfQcGss69utXfG/pf 7yoydZJ+PkDDsUqXCZcqv3JtW8jLoGDCOmAfmH4vftr+JRSMFmRTZLg01DT5Lf8/BD dvWCXY+tLrc7g== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id A8B4CE3; Thu, 21 Nov 2024 13:30:52 +0100 (CET) Date: Thu, 21 Nov 2024 13:30:52 +0100 From: Alvaro Herrera To: Magnus Hagander Cc: Erki Eessaar , "pgsql-bugs@lists.postgresql.org" Subject: Re: Function pg_get_constraintdef Message-ID: <202411211230.ocnd65fqmdk2@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="dlg2ozuuyadg6s27" 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 --dlg2ozuuyadg6s27 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2024-Nov-21, Magnus Hagander wrote: > On Thu, Nov 21, 2024 at 1:01 PM Erki Eessaar > wrote: > > > SELECT pg_get_constraintdef(c.oid) > > FROM pg_catalog.pg_constraint c; > > > > If I execute the query in two different servers with PostgreSQL 17.1 and > > in different databases in these servers, then I get the answer > > > > ERROR: invalid constraint type "n" > Looks like this is an omission in the catalog-not-null-constraints patch. > It happens when you've got a domain that has a not null constraint on it. > Easily reproducible with > > create domain test as int int not null; > SELECT pg_get_constraintdef(c.oid) FROM pg_catalog.pg_constraint c; Ah, yeah. The overall catalog-not-null-constraints patch was reverted in 17 (and recently reintroduced in 18). But we kept not-null constraints for domains. However, the ruleutils.c code to support domain ones wasn't kept. So we need something based on the attached patch, which just copies what the code in 18 does for the domain case. I wonder if there are other places that need to handle these constraint entries, though. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ --dlg2ozuuyadg6s27 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="getconstraintdef-domains.patch" diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index cd9c3eddd1d..c31d6fc1fb8 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2499,6 +2499,11 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, conForm->connoinherit ? " NO INHERIT" : ""); break; } + + case CONSTRAINT_NOTNULL: + appendStringInfoString(&buf, "NOT NULL"); + break; + case CONSTRAINT_TRIGGER: /* --dlg2ozuuyadg6s27--