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 1vR8k8-007j1D-31 for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Dec 2025 12:47:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vR8k7-002g2g-13 for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Dec 2025 12:47:31 +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 1vR8k6-002g2X-2t for pgsql-hackers@lists.postgresql.org; Thu, 04 Dec 2025 12:47:31 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vR8k4-0036SQ-16 for pgsql-hackers@lists.postgresql.org; Thu, 04 Dec 2025 12:47:30 +0000 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-349195f1a52so1016812a91.1 for ; Thu, 04 Dec 2025 04:47:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764852448; x=1765457248; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GSEF9Z2PUj/C2tQpjCujwxBYhmdmdVOhXgd+Wtzq+NU=; b=RINYcavasAEG2Ne3tTh6FwOsirQ1RUMkaFgusYvIdGDu9Q6tdeLK53Uar+UWYxSVtD WOCPJM2CMgehzc334UckOx+MwWBMLpBca3Ng4RUEFQa2azL/0U1bZ0P1mm8HBtcXaCkr jGZ8K98JbmMad8vxv6+WjDUVqoJOKQySS9NGfCgmB5Y+GLYyz6gTXLg1S0EUAn/Udf2j f38XDRZmfSWFu7+OCPE7mDxj4wtbm1P7Nb/kkutINF57gCGMe74bnpndToTh4ciuQQTo 3VSRwjAvPrPv/lDqGMhyo4qQXF9DGK4JC/8SsY/NeZ4IdZpaGhwVCmmbyZ/wselyA1Df WCaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764852448; x=1765457248; h=content-transfer-encoding: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=GSEF9Z2PUj/C2tQpjCujwxBYhmdmdVOhXgd+Wtzq+NU=; b=aGzDlMIrY4EW0dTligb4aWIlKB2dMAh1Yg8DIYZdehlImLgGziXjV8i7tq7sZhAiWc /7X49NoKgW/Ac4aownOliI7jqFhc1zn/NYknAyqHdfbPZn1bLjOs3pHBQEVZsEc0QUgj Og4BPZCGU2l5Cp3E4/pSkQo26M6bCTwisZUSmqnPYEhJeTeRXe/JGFrSxAir4up/OMSa FdGVVuFHW6TrrPCe1Z0C+wl2VP1XRSnr4qQxXhAKoaibaVuRafn0EZTaLdm75aU15bTq oQ7gPh1nftbcFQLd6tD9Rv/DthlZJ4njgytreJV1uiLCn/TQjxQNQgTLgVpbZoI2nUSN Mz4A== X-Forwarded-Encrypted: i=1; AJvYcCWyXoym1UwrhQIjhawcniipnr5CnCaL/qyGVqVLUvQXUdvBsLAyADdra1teJsYuzOVxiktEdFX676aSiLWI@lists.postgresql.org X-Gm-Message-State: AOJu0Yx2C83bkVm91oBRq2SkLWEOjpOA1P3gR1Sd44JAlaN5pwUFX3PP l1poC0uYH7iyDjmDhkF9c3w3mEFLUF8olle+vbWv4Qg2ThDmImUdky5RdS6eJbRuaAQo+9IuyRQ 2QI3yWq3BMS7Ch8RdBkKMsB+AQgPKZzc= X-Gm-Gg: ASbGncuIQAlsNwCwSJ2mEpAfOT6Ib24/CjlavUhIslXdmk7igI2wH1sJbLmgBVoLP9a AE7OK0l4+1IDLhlhftWvlOV49amCG2NB8BZyFrsko/57AXQXpaR7FOfpJNU90IkH29bEa6jz11J GvkjL9VD2yi1TclhvY40xPrPDs/3svrav6/BJrenW2cFAeXTYc+aTfdKN1YGgb/FMdWjoCTSDOt PPk7V+DSBICwZLXs1IbJPa2p00c0NArwGxgHnWIKephamQA5eCxxOsc83FQ2AWcviqrAwBGsg== X-Google-Smtp-Source: AGHT+IF2E3Y7shQBRPP0ZbYmQUQfi9a5jTSoyZXsekpIzqwNTK8UjFx/AX4dJzCqA0d2D8TQSJssED4hsf+JgPW7bZw= X-Received: by 2002:a17:90a:d2ce:b0:32e:72bd:6d5a with SMTP id 98e67ed59e1d1-3494385beeamr3267204a91.1.1764852447898; Thu, 04 Dec 2025 04:47:27 -0800 (PST) MIME-Version: 1.0 References: <04afcd1f-ed7d-4c0a-add1-50e3719ccbf9@postgresfriends.org> <762ae707-7fdc-43d8-a77a-3a10d12ce21d@postgresfriends.org> In-Reply-To: From: Amul Sul Date: Thu, 4 Dec 2025 18:16:50 +0530 X-Gm-Features: AWmQ_bkgPFz4IvpmajO4NsopFqhphG4Z9ekxzC4m5V1k0Tf1Gx5fjZp7LJp2nrc Message-ID: Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions To: jian he Cc: Corey Huinker , Vik Fearing , Isaac Morland , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Dec 2, 2025 at 1:23=E2=80=AFPM jian he wrote: > > On Mon, Dec 1, 2025 at 8:09=E2=80=AFPM Amul Sul wrote= : > > > > Since you declared float8_div_safe() as static inline, I believe it > > wouldn't have any performance degradation since most compilers > > optimize it. Also, I suggest you pass the ErrorSafeContext to > > float_overflow_error(), float_underflow_error(), and > > float_zero_divide_error() so that you can avoid duplicating error > > messages. > > > hi. > > First I want to use ereturn, then I found out > float_overflow_error, float_underflow_error, float_zero_divide_error > used both in float4, float8. > ereturn would not be appropriate for both types. > so I choose errsave. > for these 3 functions, now it looks like: Make sense, thanks for updating the patch. Regarding v13-0019 and v13-0020 patches, I have a bunch of comments for the code, but I'd like to understand the implemented design first. I have some basic questions regarding the commit message and code comment, as follows: " We cannot simply prohibit user-defined functions in pg_cast for safe cast evaluation because CREATE CAST can also utilize built-in functions. So, to completely disallow custom casts created via CREATE CAST used in safe cast evaluation, a new field in pg_cast would unfortunately be necessary. " I might not have understood the implementation completely -- can't we use fmgr_last_builtin_oid to detect built-in functions? -- + /* + * We have to to use CoerceUnknownConstSafe rather than + * coerce_to_target_type. because coerce_to_target_type is not = error + * safe. + */ How difficult would it be to modify coerce_to_target_type() to make it error safe? Could we utilize the existing type casting infrastructure for this, perhaps= by simply considering the evolution and use of the additional default expression? If we could, the resulting implementation would be very clean, IMHO. Kindly excuse and point me if that is already discussed. -- Here are few comments for v13-0018: static inline void point_add_point(Point *result, Point *pt1, Point *pt2); +static inline bool point_add_point_safe(Point *result, Point *pt1, Point *= pt2, + Node *escontext); +static inline float8 point_dt_safe(Point *pt1, Point *pt2, Node *escontext= ); static inline float8 point_sl(Point *pt1, Point *pt2); I think we should avoid introducing the "_safe" version of static routines in the .c file. Instead, we can add the Node *escontext argument to the existing routines, similar to how single_decode() was previously modified to accept it. -- -static void poly_to_circle(CIRCLE *result, POLYGON *poly); +static bool poly_to_circle_safe(CIRCLE *result, POLYGON *poly, Node *escontext); Following the previous suggestion, please keep the existing function as it is and just add one more argument to it. -- } + static inline float4 float4_mi(const float4 val1, const float4 val2) { A spurious change. -- Regards, Amul