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 1w6EHp-00459o-1h for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 21:00:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w6EHl-00C3MZ-2m for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 21:00:06 +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 1w6EHl-00C3MR-1k for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 21:00:05 +0000 Received: from mail-dl1-x122a.google.com ([2607:f8b0:4864:20::122a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w6EHj-00000001Y2g-1886 for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 21:00:05 +0000 Received: by mail-dl1-x122a.google.com with SMTP id a92af1059eb24-1271257ae53so2875356c88.1 for ; Fri, 27 Mar 2026 14:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774645201; cv=none; d=google.com; s=arc-20240605; b=XNR6m6GXsXfUJ4PqHBIDorCtHtXdT5+eL3A5PqPjER7YEKxyVD/4ejyqvCJnMP7Kvy ZKZhBFmlRjld2JmIHyOyA1ImnuggEX5vLyd6kM0TQixTHof0i88Gk+DnZsXo9KQ2LQAU HT4VWnsCUJ8B9gQBVgyJzqN836VTenp5xAZxKJgbjFu6e61FjPHcEYopIkH5snei2ix2 wmtvaKzrTQ3+LnB/aJu+Ye/oc+YfFdD0ppuj1UPfu3jbSej6dxLqOEmsJbRJpLzBeQ1p deOc1tTduCvaTnWrd1IELCsSV4HbQqA2EZzGnek8Z3ihKlUmneJlSGT/Ma0DDl+xch5q wsPQ== 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=j2IH+EBf1uIykHignDnCBAXY3uGg7jtQESVgBjfZqnM=; fh=7xgOZakqFn7lHWXtAzsp+v1SCzx1U+VVunbgNeKgotM=; b=Tc1dH+/A1m4vAFrqJY55SsXxU4xzo/BVptrzUnjsym0lPeWcnVU4vrhuN/BOs6L603 xxnRgzPizr3iqpowOpWsICjqMmUZYVXZfF+Po/FGUX2xskfUSW1QBfyr0F5B70K6T0dH TPw+U+VKg0SL7UWR/b8kiZDQZDqLgM5a/SSiBDd+qHGYU46xI64VKCgRwBJgjh+V86ta XXFox0Odwhj5vhREycxfnhP4OH26GT2/wf+9sgd60Kl+m4fujilrwFem/V0eOLzjVBU7 mDQ6CrmYoVbEP10bdBLmz646y5dN9juDh9bnQqUbizBLEZU4QvRXw8JTRZmLNLuUprSX heaA==; 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=20251104; t=1774645201; x=1775250001; 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=j2IH+EBf1uIykHignDnCBAXY3uGg7jtQESVgBjfZqnM=; b=W4doMlGgMp7PzTdBXwy24fjXs4NkrtVKmpfwRiMBnpuFHX+YVU+LSWkYKK8DILm6mB 267j8x66TqkFqwEcBT82lRs2KvpvY6vhvcDowDDCaXlYtKK3d5wZcvAlglSAtD6pAtY3 /2cbVs8iaGzuoDVHVIhBdnSQK/Ul6HfHVyYHnaf8sRx/TnyWuz3XA+5WxJtddV5wfOxX rbNp4SV+voWYZhX+4XOns4YL2HgWeqOyniN82L5BpW2dzlB/XjFU5pyd/rqlllECPSbL VWSM7L8QyatWJc18nyvmm6ieD7Da3pPRdK617qVLLAazpCZHHnwrlVb1F2kwwOQwWWi5 XVqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774645201; x=1775250001; 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=j2IH+EBf1uIykHignDnCBAXY3uGg7jtQESVgBjfZqnM=; b=HlYGza9n6Q9/JBlgQpa06iKHKwzxNprijg5bau4Ff0vXYgpgbSpg40K8bb89xnsges MrRrmV7WgY9SpDnpMTgdYuAGcCcqfodXKzTOzHfQbeiw1+x/XxZckLaQHRdr8cUkdcNT 9qEJOLiMzOU+T5GIkufgMIYzKfPK+0SrLspKYMInZ4ZxQwNbHa41zUWzw7TgZgPUGuFl fGQ/R5t7k3c5708r8B4evuQM9Q0kIf39/jhEUjdRLZWWwvYsnPJkkSLdYspz8+OdrUSZ bs+l7S3aU5MygXDQxVGInu/aENNpvFNmAJhOhg+BUK3+hWrxYtWAz3RAnKzbkzEiF34h 040g== X-Forwarded-Encrypted: i=1; AJvYcCVqgzMfZ2Vd7Hs3byGD3h36OaEk8lDYZ38LL7EM/JeRq5WULlOgfm5hZoU+2g4SZ7lHqJXtW+Kz+0omwQ/d@lists.postgresql.org X-Gm-Message-State: AOJu0Ywl+nUwnETvYHXguuZItb25pQsw0AS84yBQJD7L1hLPVTbpZ6K/ hF9gzGPr3GprJEetjLsoeVXuOP/qDTkTZVXeh/s/MRcCiPcvlrswH4sZTAXFkNK06qMAGKRs7Ky Hc3kmAMKf0ShfEHggtBbm0QY9CSVvVSg= X-Gm-Gg: ATEYQzy1feUNv3U0mAehp/7ZoczsFmRxEoz1yoYosKHLyErYuxCbTNlQwe2tVrLbRME aBlBFz1IeKTLFYn3EDfTP3XIXssHznY7KaC9rdCgQ8W98/hLBjAbMoqdaWUUzPOoz80boeHEHMo yNUbO1tJhzmfNHDnSJVetFz3OgOHV4Pv223Wo3LXzwSapVFKAXV+Xlwaga1PH5gqRZV915e4b+9 2zxIWHGrs5VE5wIGBui+aB/Oo5VlyY8aq/jMtJ7htezl7wvXalF3RFN/vP3axWOKGZP1bnEktV8 poJktnxgY5B78W5apsZUSqhH8OCXugQ7Ce1w5T61PlTTYZXMPj/0mbfwHseoxq1bGnMosgDumNW nJxwhsrb1JAusJcMq0aZ7hTK4WPqDd/ZungQ= X-Received: by 2002:a05:7022:b98:b0:128:d39a:b13e with SMTP id a92af1059eb24-12ab28dc2d3mr2093945c88.27.1774645201156; Fri, 27 Mar 2026 14:00:01 -0700 (PDT) MIME-Version: 1.0 References: <5ae9578e-f25e-49c5-97ab-ad27bc2050b5@eisentraut.org> In-Reply-To: From: Corey Huinker Date: Fri, 27 Mar 2026 16:59:49 -0400 X-Gm-Features: AQROBzBsfe7bjKdeOFEOw9tq5D3owwZCOOR-zMNDv6rNANyRkYjTHDopgj4SHV4 Message-ID: Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions To: jian he Cc: Peter Eisentraut , Amul Sul , Kirill Reshke , Vik Fearing , Isaac Morland , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000d13de1064e07c8d8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000d13de1064e07c8d8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Mar 25, 2026 at 9:14=E2=80=AFAM jian he wrote: > On Tue, Mar 24, 2026 at 9:13=E2=80=AFPM Peter Eisentraut > wrote: > > > > In patch 0012, I did not apply the changes involving > > float_*flow_error() in dtof(). These should be considered together > > with the error handling changes in patch 0018 (about which below). > > > > Patch 0004 is probably ok, I just need to study a bit more, since it's > > a bit different from the other ones. > > > > In the comment for patch 0008 you write that supporting soft errors in > > int4_cash() is not easy. I suppose this is because of the external > > function call to int8mul()? Maybe that was necessary in ancient > > times, but int8mul() is nowadays just a fmgr wrapper around > > pg_mul_s64_overflow(), which you can call directly in int4_cash(), and > > then it should be easy. > > > > cash_numeric is not easy to refactor safely, > To do this, we have to refactor (numeric_round, numeric_div), which > will require refactoring more functions. > So CoercionErrorSafe_Internal still checks whether the source > element/base type is MONEYOID. > What if we just...didn't? The MONEY has been deprecated since 7.4. If we simply didn't implement this, and someone attempted to use this cast with default, what bad would happen? --000000000000d13de1064e07c8d8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Mar 25, 2026 at 9:14=E2=80=AFAM jian = he <jian.universality@gma= il.com> wrote:
On Tue, Mar 24, 2026 at 9:13=E2=80=AFPM Peter Eisentraut <peter@eisentraut.org= > wrote:
>
> In patch 0012, I did not apply the changes involving
> float_*flow_error() in dtof().=C2=A0 These should be considered togeth= er
> with the error handling changes in patch 0018 (about which below).
>
> Patch 0004 is probably ok, I just need to study a bit more, since it&#= 39;s
> a bit different from the other ones.
>
> In the comment for patch 0008 you write that supporting soft errors in=
> int4_cash() is not easy.=C2=A0 I suppose this is because of the extern= al
> function call to int8mul()?=C2=A0 Maybe that was necessary in ancient<= br> > times, but int8mul() is nowadays just a fmgr wrapper around
> pg_mul_s64_overflow(), which you can call directly in int4_cash(), and=
> then it should be easy.
>

cash_numeric is not easy to refactor safely,
To do this, we have to refactor (numeric_round, numeric_div), which
will require refactoring more functions.
So CoercionErrorSafe_Internal still checks whether the source
element/base type is MONEYOID.

What if = we just...didn't? The MONEY has been deprecated since 7.4. If we simply= didn't implement this, and someone attempted to use this cast with def= ault, what bad would happen?

--000000000000d13de1064e07c8d8--