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.96) (envelope-from ) id 1vdbVi-002fpw-0J for pgsql-general@arkaria.postgresql.org; Wed, 07 Jan 2026 21:56:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vdbVg-00FflW-20 for pgsql-general@arkaria.postgresql.org; Wed, 07 Jan 2026 21:56:09 +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.96) (envelope-from ) id 1vdbVg-00FflO-0A for pgsql-general@lists.postgresql.org; Wed, 07 Jan 2026 21:56:09 +0000 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vdbVa-004mOQ-1t for pgsql-general@postgresql.org; Wed, 07 Jan 2026 21:56:07 +0000 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-3fa11ba9ed5so1776068fac.0 for ; Wed, 07 Jan 2026 13:56:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ridewithvia.com; s=google; t=1767822961; x=1768427761; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=gqa8HlI1eAL3u/8ZopShN1uz9a5hUIJznciqqQSX4mw=; b=s7VI21Y0h76AFoyHAgiomxStyvohKUm/X9FMXk4KvY8uuk07SUFq+3uq9a73zUuZAO tL2mvAUgFIiPqCDynCwSKG4nuWOsK63ZQLlcP4W7fb8VXj8ey7a4PhyohdaHy9lxQzmb 7GRWZAtXWfBFLeAk3i7kCc2KAroEi7av5qw3Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767822961; x=1768427761; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gqa8HlI1eAL3u/8ZopShN1uz9a5hUIJznciqqQSX4mw=; b=t1MaJwkGslgcxd7DX+D0XvOQfhEZ3HnzQtgpV6NMAYfLp80F3+//Gixcs1kftlZrjS RBPCBiAIrtEGtSj+EnCYM2j2P/5x6eEdkxOkcfrGUKzQgddfnvBuzXsbmTDL093eyUEt jtvB63FppMsK9UQcZIwIekfDJWQbk5sdeQhtlpiiQ0w2+UGk+FUtA8tFLIvgIatCppNT MglZ0HU91aOwLPYf+7QL2xTgrClozvCG/SO+fM5RWHDIvsCXzqv0RDIyfa954G0VGtO5 IruZLaXLTbZoK7FJ6NEtdCV64gBqTjw6Ai4/qZWAQI+NWnx86rIPvQTopVj4F1qc1ucf MCsQ== X-Gm-Message-State: AOJu0YwD6/rMiueGC+K4CSknUxWygnzKDiSnT77nV1vQuR0YEmt9hU5a zXGi1M8Mu3WurPJzvsRj85/yz02jTBDohL5zkD4i+JpeGZPeHzr1UC6gt0UvMAM40ckJsEuvy7r Vbe4vGnyV5ZH1UeXUp42FX4Ftb/bfqXJPuoPZImnvdgYC66ZPGaC8NTvcjvR3lE33p52L/Fl7WM Mi4G6tcimOgdZ3M2qt8E89nsFRXxoVXL23prfbVwvVCOcpFAw= X-Gm-Gg: AY/fxX6qz3gYSdLlGwDBLjaBq3yOOCniG3dYis+op0T24mbIaySRtLVs/hOM5LbhRv1 O2C1Gm34TVMnA3FayWrjjdySVXPVotlI0YtFnXmOtBo/0rVgwLJPRkYs2+JUgMzMrdmn6lsnAUB ouXIq9CofFKGC/YJwdrlX2vxmkkqy4XRbcsCToQKzaMvfHbMjoQzzSpkrx7OzFjPrMse07Vre74 OMiW9JP3KYInb+nClDpK0ZYjwjM5dxeHoC0/Z2nbUZrFT4sE4kGvDGluzNQNHT3NRSR/Q== X-Google-Smtp-Source: AGHT+IFo7/LGy0A6+7hT+QtLjvF7xbBJ1vasj8fCaIhxb8YOYTTMhuJ7L+X6XKjiA3H8e1/BcGv4rFeq1J0fMcDPMuU= X-Received: by 2002:a05:6820:2287:b0:659:9a49:8f64 with SMTP id 006d021491bc7-65f54f5e6b3mr1461157eaf.41.1767822961383; Wed, 07 Jan 2026 13:56:01 -0800 (PST) MIME-Version: 1.0 References: <1fa24f41862f214b44bcf94556db51c9946d28bd.camel@cybertec.at> In-Reply-To: <1fa24f41862f214b44bcf94556db51c9946d28bd.camel@cybertec.at> From: Stuart Campbell Date: Thu, 8 Jan 2026 08:55:50 +1100 X-Gm-Features: AQt7F2oxgKUxZesrtF3AIANPt5sjGTbGr3NO1DHp0N2MO6unHvRv9IAECZJ3ykY Message-ID: Subject: Re: Unexpected modification of check constraint definition To: Laurenz Albe Cc: pgsql-general@postgresql.org Content-Type: multipart/alternative; boundary="000000000000a42d1e0647d35b11" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a42d1e0647d35b11 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 7, 2026 at 11:57=E2=80=AFPM Laurenz Albe wrote: > Yes, using "varchar" is definitely part of why it is so odd. > There is no equality operator for "varchar", so you need an (implicit) > cast to "text". > Got it. That seems like a possible reason to prefer text over varchar. > That implicit cast is made explicit when the parsed binary form of the > constraint expression is > reverse engineered to a string during "pg_dump". > Makes sense. > I'd say that the change you mention "just happened", but you can never > rely on these expressions > being rendered in a fixed way - this can change any time. > That seems reasonable. What mostly seemed unexpected was that the parsed expression changed the second time. i.e. original expression -> rewritten expression with explicit type casting -> rewritten expression with (even more!) explicit type casting. > But perhaps it is good enoulh if you define the constraint by casting to > "text" > early: CHECK (val::text IN ('a','b','c')) > Sounds good, I may try that. Thanks! > > This communication and any attachments may contain confidential > information and are intended to be > > viewed only by the intended recipients. > > Got it, I won't forward your mail... err... > Heh, yes... sorry about that. I can't control how that message is included from this email address. Rest assured, you and everyone else here are the intended recipients :-) Regards, Stuart --=20 This communication and any attachments may contain confidential information= =20 and are intended to be viewed only by the intended recipients. If you have= =20 received this message in error, please notify the sender immediately by=20 replying to the original message and then delete all copies of the email=20 from your systems. --000000000000a42d1e0647d35b11 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Jan 7, 2026 at 11:57=E2=80=AFPM L= aurenz Albe <laurenz.albe@cy= bertec.at> wrote:
Yes, using "varchar" is definitely part of why it is so odd.
There is no equality operator for "varchar", so you need an (impl= icit) cast to "text".

Got it.= That seems like a possible reason to prefer text over varchar.
= =C2=A0
That implicit cast is made explicit when the parsed binary form of the cons= traint expression is
reverse engineered to a string during "pg_dump".
=

Makes sense.
=C2=A0
I'd say that the change you mention "just happened", but you = can never rely on these expressions
being rendered in a fixed way - this can change any time.
<= div>
That seems reasonable. What mostly seemed unexpected was= that the parsed expression changed the second=C2=A0time. i.e. original exp= ression -> rewritten expression with explicit type casting -> rewritt= en expression with (even more!) explicit type casting.
=C2=A0
But perhaps it is good enoulh if you define the constraint by casting to &q= uot;text"
early: CHECK (val::text IN ('a','b','c'))

Sounds good, I may try that. Thanks!
= =C2=A0
> This communication and any attachments may contain confidential inform= ation and are intended to be
> viewed only by the intended recipients.

Got it, I won't forward your mail... err...

Heh, yes... sorry about that. I can't control how that message= is included from this email address. Rest assured, you and everyone else h= ere are the intended recipients :-)

Regards,
Stuart

This communication and any attachments may contain confidential inform= ation and are intended to be viewed only by the intended recipients. If you= have received this message in error, please notify the sender immediately = by replying to the original message and then delete all copies of the email= from your systems.


--000000000000a42d1e0647d35b11--