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 1w2hJw-000W6C-2z for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 03:11:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2hJt-006vrc-0r for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 03:11:41 +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.96) (envelope-from ) id 1w2hJs-006vqx-2t for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2026 03:11:40 +0000 Received: from mail-dl1-x122b.google.com ([2607:f8b0:4864:20::122b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w2hJl-00000000piU-10EU for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2026 03:11:35 +0000 Received: by mail-dl1-x122b.google.com with SMTP id a92af1059eb24-12732e6a123so1000345c88.1 for ; Tue, 17 Mar 2026 20:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773803491; cv=none; d=google.com; s=arc-20240605; b=ODgkvkA9nW6CUHBc+qrdRXZEl9jZyt49+VKCEU7IlPqodwJ5EgWSdoYVxXOlhggCEO WXuuCo7MRxJIG8pAxzXP6HVw02brV7rzvmJxyuc1/KZ2Z+7LM3Z0Gq1QhfstcWP0HlH5 PzLPo/ezMghgszEKOKLTEtKp+FsY6898sS0e0wwFD4PlML8g3DAKONIOpb32WN0d1bIj HnuL0ac9KiyPxEImLN7UaEc7MwBRwWkTiRW70mvLL1Hd2cb/2x89Ir4zrwJOW62zkxrF /iALYvdxkWPnY38Yb0p3++kIGQtqso9/nMzrGsCAA2ZrEK4N+9GEP2U4eXk8VFRdMg1r bh9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=PcIap00gLMmt1m2yaTrVU9RtfQm7UtkZ4DOIKQKxJjQ=; fh=nYLW4ehIFE8pZI5miwrviLuGcjmUIZ46KSoaJLbRX78=; b=kz6oVUuyeQGvKER+loOUNSS/bhGKjzh6w4xrZ9wKE7kKvO1yYGhZlP7Wj3geKCvanb ktqEVAlCK0x24gzGTKiR6plmSnoLjW4VUIJf+q7HaqCn629rCn/JIfxkEmsy9SzIyV18 m246vfUzFYzMEZi3WDDTi/tTFKVAQJQg2d8B7cxjuf1xK+RA+dXam51wFAwUQqRG69gd xVub/a1HCwCjPJbhljDWxBFGx0MAOznHXZw5KrSdIDxFPYijOKXEixRpy/rshFue8tJS fTCk3+PuTzlyTehvbJ5ZaEdUSgSsA23cJgzaRItal8UAFnpSv4KotAsZnAStkJL9+xZI rW8A==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773803491; x=1774408291; darn=lists.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=PcIap00gLMmt1m2yaTrVU9RtfQm7UtkZ4DOIKQKxJjQ=; b=ArecFIRIJahM8aU+vkaaimY1did5nNLil0WOYWyFywvDXyZca9OuqL5BROly2F/Sxt +I+AsEo38QgapdT/jvYePP1bMrZvgujjv1iEvArmyFNVEgG2Wj25uXtKNSygRCjGzrPQ qKIB1muBhISP1qnSCuYwIjPYNEJUE86KeajBGDZoe5uQzhpS+E99Jl0750qU8j2qfeOa EAXjpBPWqo2Y9Atgtc5favql+v53vyCYbEv7MnjY3+oujBnT5u9KAzVwuA8YxLQGHEn4 iQzixCEbX+zD1JmxevUTJLCEUTdQUEr5Yn6ykoSmjpZ/pGzuQF3FlPwq0Wk0pymhA4Cu ofhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773803491; x=1774408291; 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=PcIap00gLMmt1m2yaTrVU9RtfQm7UtkZ4DOIKQKxJjQ=; b=Dh34ZsANOq5qsX/WuzRIdqBmzLUjtcpLy3HZK8bFDI7KdIA00TFLF4p+bl3uHo3150 VQNBiixKBGiYIEKA4NTcbMFQK5TPY4xqb56/Mwwds2TlBSC/FnD2aXIBQkNfJjty5pLQ h5CLMQ7JY0IzlTtTz1mPO1HAjdq7oyf4u2t+h3Raeq3hzYm0naisdm/9PnJdRLJjKHFp T5+wvecOHzPdYMENYZ4LWo1hB/He9qT0bqdnuteMANL23WEvtzyArRxo1xTZxK0oFBHh gdxHiIE9+s8atA3AYBInZy+34kOmAQWEO6Gesd2kGAOMGdVWe3e6Oq77ayzWXwtb6PVW UTOQ== X-Forwarded-Encrypted: i=1; AJvYcCXiItsYVLp6bDtj9yyI3dYGlOgMZtDreJgntlSoQkDDZ/F+Spr6IRNAYPehucMU1xGKv+NnRY0h7E8OYBOa@lists.postgresql.org X-Gm-Message-State: AOJu0YyErlXwQTyTMj8mgMJlX5muHjd3Y9i1sp7PNpVn0sN6owMDwiuS cAweJOAD8O/0ZfwSjhkY3JKu51coNrKKMCUniM8P+wrRLH8i1nRpfVKHB/mqXh1SDGyjdT0NZEL +OGIV8zwib2HBIhoUJFsCt/oyR4WXjjo= X-Gm-Gg: ATEYQzzbnuOrUNs9klfNSFhmPjCDXdvw0NzSc1za3f1W+YpEGxQHd8rLCkxYyoDAMit qplKeWzQcEgiXiLZ3KDZsVRh/8H4iF5XoTmMuq4PVdbXt9Fbw//WafbVHD7+Q14/8Yz4xTjCl5t fDdSeth8CfMenvmsNa64MZmbY7qnBYO79u5YhT+MikueaC/GzILvoJCvY6HWPvR1I3XtYLjdbxY hNF6QCzjBKsQiuXqtT+7iOVWREjwEaOqq8Rj5fi0KDdFycBNYCMC8ir93J0ZOCH5PO9GXqNPePp JpNREU7Xf/arqiNo3RsQvpmXV74bkhVUFsYpxk0N/98nzrxnDDwBMoEpjKx0Rdjbvu5Y7Aa4Cp9 NFeneSyv+h57fauH18DzBxANf X-Received: by 2002:a05:7022:6709:b0:123:2c98:f6af with SMTP id a92af1059eb24-129a7111dfamr1220677c88.14.1773803491006; Tue, 17 Mar 2026 20:11:31 -0700 (PDT) MIME-Version: 1.0 References: <04afcd1f-ed7d-4c0a-add1-50e3719ccbf9@postgresfriends.org> <762ae707-7fdc-43d8-a77a-3a10d12ce21d@postgresfriends.org> In-Reply-To: From: Corey Huinker Date: Tue, 17 Mar 2026 23:11:18 -0400 X-Gm-Features: AaiRm52-2NQKC8pCCaa-_reqOsR6hYcvQ11O2WHSkwvZmPi03HtRuDUAc5kesXQ Message-ID: Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions To: jian he Cc: Amul Sul , Kirill Reshke , Vik Fearing , Isaac Morland , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000fb9d09064d43ce5e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000fb9d09064d43ce5e Content-Type: text/plain; charset="UTF-8" > > + if (inputElementBaseType == MONEYOID || > + targetElementBaseType == MONEYOID || > + (inputElementBaseType == CIRCLEOID && > + targetElementBaseType == POLYGONOID)) > + { > + errorsafe_coercion = false; > + } > What if we just reject cast functions with a non-null prosqlbody? > > Given the interaction with array and domain coercion, we need to think more > about error-safe type casts for user-defined range, multirange, and > composite > types. For now, we should disallow error-safe casting for these types. > I agree. It's far better to get this working for the majority of cases, and we can chip away at more obscure types later. There will *always* be user defined types that we cannot account for. --000000000000fb9d09064d43ce5e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
+ if (inputElementBaseType =3D=3D = MONEYOID ||
+ targetElementBaseType =3D=3D MONEYOID ||
+ (inputElementBaseType =3D=3D CIRCLEOID &&
+ targetElementBaseType =3D=3D POLYGONOID))
+ {
+ errorsafe_coercion =3D false;
+ }

What if we just reject cast functions wi= th a non-null prosqlbody?
=C2=A0

Given the interaction with array and domain coercion, we need to think more=
about error-safe type casts for user-defined range, multirange, and composi= te
types.=C2=A0 For now, we should disallow error-safe casting for these types= .

I agree. It's far better to get t= his working for the majority of cases, and we can chip away at more obscure= types later. There will *always* be user defined types that we cannot acco= unt for.
--000000000000fb9d09064d43ce5e--