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 1uP60l-000BT7-EP for pgsql-general@arkaria.postgresql.org; Tue, 10 Jun 2025 20:55:59 +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 1uP60j-009dxM-5f for pgsql-general@arkaria.postgresql.org; Tue, 10 Jun 2025 20:55:57 +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 1uOThy-005GZU-Ee for pgsql-general@lists.postgresql.org; Mon, 09 Jun 2025 04:02:03 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uOThx-000zOY-15 for pgsql-general@lists.postgresql.org; Mon, 09 Jun 2025 04:02:02 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-32ac42bb4e4so32911951fa.0 for ; Sun, 08 Jun 2025 21:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749441719; x=1750046519; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=2kahBI71m1G4rOOpEXsl/v1yj8q9rvyKd7QFvU1ySeU=; b=h7RcFqTBc49MYMan/rWfDcCx8IZhgxwH1LJCj0HhT91SC4jeuSAB+yZIWexkr7ayQY NegkcfVoVKFtV2mxMWR7egIkJgy9XnUbId3tFJUliTMQp37EqjVl3vpQ33vojpzlApX0 ec9Xb59IcfYmUmjxi+GOb5qUtpFcsN7cpuJtoCbaLz2kV72KL6Hubmcq3N9rMJluNu+k ZRSUp5F72IePDJz6ajfcZK4WDQLAdPs9j0kZQaQUheuvgCSnTYIXR8scE6jHihzYR+nW IP3Tmt7XAPdVtaENoOFYFleFMhFDu5j/kUvBOGOioJXeacDFFE1KO5VeHv8IYriQL8VK hO1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749441719; x=1750046519; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=2kahBI71m1G4rOOpEXsl/v1yj8q9rvyKd7QFvU1ySeU=; b=XqA8nIuQFvWza4Htfrol9MBAwakWcq/GQj94fusUCP0O5F+7GZCg2EJfdQLrlQ/gSS gN/ahND0oKiy4N5pnxBJIA88pruBbRntC/EE+PuTvYpSs8ri8oUPI8Tz07e9XdheczuA rrkECnoeII8v0WccbVvA2JlPOQJxo8oKVGKJdUASCxTsU7IAD1p/IKM0IUAqgIIHblP0 ndpfzK0xgZP9UWPHnEF99s40DW2w0X428iNEwg1zvIUV7AtREXMO//tagxgE6YgClgvu sWk7xux8VPi28hNEwRZp0PzoUutqf5R++x0lcuMSZ2RnltOJryWlp5UoKhMRpAxVav/F uVPg== X-Gm-Message-State: AOJu0YyGUx0Jrm2CbNtzhjYZ612K6+7ZoVSl9ze7MKIc7CI3YORqMLEo QUTcLpOEtfnqvHAsy0sob98izPB0yfVWB1Nn3dhItC4OxrGVirJpQtXl1IFVziKQEnfaVKjq07y dN4YH68YU3mobYVnD7f5GodvZYRXOnXccGpsx X-Gm-Gg: ASbGnct2DI9mBlaKHNqErz80eX2F550mpzDUGkR6hKcuvL2nCl/BbGUFH4mfbLeEgZd kLqZTDU8cR6hmOm1acG4CI5K5J1KC18mbtPZBaYuuj0YCqpae9DzzobwfwhvdkFhvjgx/TJu3EE Klm9MCQNSrHWGYBHTV4BU8Oxqn9aE4o5AMK4wKwiLsCANuLfKoshCoOo4g X-Google-Smtp-Source: AGHT+IFBYW8w5CRgS2uxWO2yUl1cR0wxImwaznL6/4+huRjCZRPyHGpSzR/GDCX8CC1RP4JLAy+QCKs8yW1/w2JsUq8= X-Received: by 2002:a2e:8183:0:b0:32a:6312:bfc1 with SMTP id 38308e7fff4ca-32adfb894camr18685131fa.24.1749441718290; Sun, 08 Jun 2025 21:01:58 -0700 (PDT) MIME-Version: 1.0 From: Logan Grosz Date: Sun, 8 Jun 2025 22:01:47 -0600 X-Gm-Features: AX0GCFtPUZo5mg06drsuLOxs0fZMDlfZOuFDSl2Hk6tnlR9cIhPAub6DDU8d6Ns Message-ID: Subject: Is it correct to raise an exception in a domain check To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000002c8d7b06371ba478" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000002c8d7b06371ba478 Content-Type: text/plain; charset="UTF-8" Hi, I have a `DOMAIN` on `JSONB`. I need to verify the shape of the JSON, so I have a check expression written in PL/pgSQL. The docs say > Each constraint must be an expression producing a Boolean result Would it be correct to raise an exception to indicate a failed check? I perform type-casts (that throw already) and other checks that would benefit from attaching a description to the client error. Thank you, Logan --0000000000002c8d7b06371ba478 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I have a `DOMAIN` on `JSONB`. I nee= d to verify the shape of the JSON, so I have a check expression written in = PL/pgSQL. The docs say

>=C2=A0Each constraint m= ust be an expression producing a Boolean result

Would it be c= orrect to raise an exception to indicate a failed check? I perform type-cas= ts (that throw already) and other checks that would benefit from attaching = a description=C2=A0to the client error.

Thank you,
= Logan
--0000000000002c8d7b06371ba478--