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 1uhCGi-00Bc6i-0M for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Jul 2025 19:15:16 +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 1uhCGh-00CAzU-24 for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Jul 2025 19:15:15 +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.94.2) (envelope-from ) id 1uhCGg-00CAyx-OM for pgsql-hackers@lists.postgresql.org; Wed, 30 Jul 2025 19:15:15 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uhCGe-001bbl-1m for pgsql-hackers@lists.postgresql.org; Wed, 30 Jul 2025 19:15:13 +0000 Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-3e3cecf0b53so580225ab.3 for ; Wed, 30 Jul 2025 12:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753902911; x=1754507711; 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=wCHexQgK+Kvr42x6xNE/pxjlHOZwwMihoIWlbaPUsHA=; b=ciOOE38zvCoRv9DLooiR4TDtyI15X2BqyU7krCNJRkVDv/TmAIZbmeYbnRL/bIBA/d LeenGm8RmuLhW5hVENWxKeld9QhKgQc225wiBhqyPUKHhiAQgTohA5Pb3PKgR1htwO4S hpsgo8MUrh/KT3IQAAnuCzPOqBETVffYXF09K9i5q+llnEXKvlAE7bkX01KXQWcS0vUC c2EIWymZ40q/GbEBqvESzxEk3jM1DH8ZFpLdRxaJEY4eE/syc1dA9THrn5HqvEe4fJYk HKun2oW6uPJtzzxzhiodIUCKRbN3cn/Srd3iXA7J0Yu/9NTJIFr8Kxf/KFB5MhKpmYYG SVEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753902911; x=1754507711; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wCHexQgK+Kvr42x6xNE/pxjlHOZwwMihoIWlbaPUsHA=; b=XaUMS4pBZr9p9B1vTc2UTIV5G1aZTTv4ztG0R7eGiB0/LuwXxEW+5WeixCo/Oheo/r +OSi/6oEy/RPkuLEnerT1kBso21152/7/JWEbmibHeJw63q+wStQv749vicexccPQp6H ihld8IRSpy0DMgPkRQdLJYKVLdnzWuKnMPAqTv8VI66F2BpldcpFCFr+eeVtI0qsq5Ih ehuFbvEIl1qIUTY3nPmsB0/wa3TmV2DWg0pb8uyvfqj3Ka4THEseM8DkiQINLmEVBpBu HKhkJ7+Tpo0rZ+TZrhSRM+a8PJ4BdMyMXaBbfK7rrGOMj5U6rxrmEeusd7EgNRiZJLhq Lycw== X-Forwarded-Encrypted: i=1; AJvYcCWr4QalgoMuoLnE9IOCo3vM6HEM5UZsqOhEj6fw0XhZHnxswOL3NljCoTGifvXougNh08CAwvFFW5XoQ0Ef@lists.postgresql.org X-Gm-Message-State: AOJu0YyUbeLnNBbBgiYzOhg4GUtDUhyTk67A5yqIvsAPfp9soX8JkFUr Bk8kLaTshK6J8LBo5szGbgRmtJ5RvY+n+Q+YSnEmCaJnF3pEHkt9fm6gvCDGhPmRr36FwE04SUb BYZJnUv205hBrIwSZ7WK3xk/YXwP5LQQ= X-Gm-Gg: ASbGncs3KDc9+2iiboZkeKWkFL1GD/ZRb7AK9rwRckMRHzWCpAV9bOR+w8imHU4fFqd q469Ov2MYLREbUdSBEzpuR2USZ1ZcYp4QyhwN4Rnm1j/dZyUxoj//NXLS26ebRccXNMUidS/5UX zgwg8NSEuQV1YNz1FIdrOMFRtvf5MJToqiI4guDKlZKwGf9tSEG8vhrZla7/zjY8/3RoBQNBqSq HeglY4= X-Google-Smtp-Source: AGHT+IFVMaIreSv40eNI7+RjwlS4iDyL90FrxETvVZ+U4Gga08Eqbe/tAyVVHfKbgkaBLcRI2YR9UZnxwxTt8rVRI6I= X-Received: by 2002:a05:6e02:f:b0:3e3:f914:d774 with SMTP id e9e14a558f8ab-3e3f914d892mr57194355ab.17.1753902911572; Wed, 30 Jul 2025 12:15:11 -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: Wed, 30 Jul 2025 15:14:58 -0400 X-Gm-Features: Ac12FXzg6uXvi7rvddvxzJEhmKT2LVXXcu147oHMWpMlEDIOQmiwZ5uhDIE1RQc Message-ID: Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions To: jian he Cc: Vik Fearing , Isaac Morland , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000003d101063b2a5877" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000003d101063b2a5877 Content-Type: text/plain; charset="UTF-8" > > > I didn't implement the [ FORMAT ] part for now. > please check the attached regress test and tests expected result. > Question about this: +/* + * Push steps to evaluate a SafeTypeCastExpr and its various subsidiary expressions. + * We already handle CoerceViaIO, CoerceToDomain, and ArrayCoerceExpr error + * softly. However, FuncExpr (e.g., int84) cannot be made error-safe. + * In such cases, we wrap the source expression and target type information into + * a CoerceViaIO node instead. + */ I'm not sure we _can_ just fall back to the CoerceViaIO if there is a defined cast from TypeA -> TypeB. I seem to recall there was some reason we couldn't do that, possibly to do with how it handled rounding, but I have no clear memory of it. Aside from that, I like what you've done with making SafeTypeCastExpr be its own node type and not saddling regular typecasts with the overhead. --00000000000003d101063b2a5877 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable



I didn't implement the [ FORMAT <cast template> ] part for now. please check the attached regress test and tests expected result.

Question about this:

+/= *
+ * Push steps to evaluate a SafeTypeCastExpr and its various subsidia= ry expressions.
+ * We already handle CoerceViaIO, CoerceToDomain, and A= rrayCoerceExpr error
+ * softly.=C2=A0 However, FuncExpr (e.g., int84) c= annot be made error-safe.
+ * In such cases, we wrap the source expressi= on and target type information into
+ * a CoerceViaIO node instead.
+= */

I'm not sure we _can_ just fall back to th= e CoerceViaIO if there is a defined cast from TypeA -> TypeB. I seem to = recall there was some reason we couldn't do that,=C2=A0possibly to do w= ith how it handled rounding, but I have no clear memory of it.
Aside from that, I like what you've done with making=C2=A0= SafeTypeCastExpr=C2=A0be its own node type and not saddling regular typecas= ts with the overhead.
--00000000000003d101063b2a5877--