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 1uj90o-003TLN-7k for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Aug 2025 04:10:54 +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 1uj90m-006xUV-Qn for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Aug 2025 04:10:52 +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 1uj90m-006xUN-HI for pgsql-hackers@lists.postgresql.org; Tue, 05 Aug 2025 04:10:52 +0000 Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uj90j-000oMe-07 for pgsql-hackers@lists.postgresql.org; Tue, 05 Aug 2025 04:10:50 +0000 Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-8818a5ba63fso44982139f.2 for ; Mon, 04 Aug 2025 21:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754367047; x=1754971847; 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=tSir1TCpNjn5SwdmBOPQFbtsOXsXvc+/2SR7EDniWok=; b=EMG1/lmXxjO6RY6KRiQsH+FozJQfYOgobnE1YCm2Oy/eUaWWxtIcfnxndt7kt+LOoE ZgsZG7l57Z2VOI0bkEcR26G+z28InEqjmeZ486jALnHpjC9XkLM/heg6O+qfuBU/aeWb gB4MudkMYuvss48K2IXin3o6QZBXYHCPN3LcTh3xNd0Cw5XJK1GEFozZ1766itmNepxG 6uhXJr29GAzkkxbr6II14UrTLuXefZ3C2m+lqwOkISqN3hf7JwB/TdWyjveppa/y4H6z jrsJdyK02vCjE+sn3Z6p+zGuF+WTAjhSMkisOIbzUKx+aRi7LwIuRSn79C+Epcw1ypou 1MOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754367047; x=1754971847; 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=tSir1TCpNjn5SwdmBOPQFbtsOXsXvc+/2SR7EDniWok=; b=FSoHI+9XGQrYaZVFX0UHu5ZmjOaDAGanB46MlLXeeGwhOZKa7yGLYcB9YmGfJAKjcP MR5LDD8i5kyT26hZr4hyPc6ostsl2beQes7O0HnTJIMWt+gA851hzaSjkgM6xaRyYlOx LD6CPiFNpW0S1SW4MH4CZG+kVdPnYPNWHe9ah1PDQ5d2YnNegzfkP9Y65n/BVxW+0Dfd c4hB2wypsVnJic2KNk0dyfIBQxJKdftedADi/wgzLRWJo8AMNuwYMzsyNvIrZQw4O6o6 9jyQgKXlCjCHPo3f0qkLs8nbqlsW2J6fw+2jQx5nX5/t9bqMO5p4OwnNTlwrSQJd8WsO 4G0A== X-Forwarded-Encrypted: i=1; AJvYcCVk2lpsX7srEYjXgO7QhYO83FBwuivxbChCU2r2oqGq38zx7GRb5TsVCWxdAwphJ2gU7fOPOA5da89W/Wom@lists.postgresql.org X-Gm-Message-State: AOJu0Yw0Pb+iV+lWuMsHgjNpeILpnTfL+I64mhNEGBaFpTsFZLznscxP M8+Xm0nZCsoPyeJV5DmkJGZ9XbdbM9eeizcpTpTlChTeNl/LKDgilUvsM/4Q2MOs56pzZuOzf4K 5e752Kt0h7ePsHCMgRLDwt1HBBiMHWhI= X-Gm-Gg: ASbGncvRIKqFmSa0WbLfhPvp6QplyDKzRqMpQyqdLlkQpO++7e3Bpxzd3Eu1G0nm1RS DaP3fP8CoEv3Bnj1mzBRdaGDr82RitWdldn/ETv6TTr7uKmNJyCPoeD3mnF4L/Xnf/oP2ZlQZpC MSWeEA3k+ZWcH+GVmgmCwpnsBe1H2OvnfNPAAJTDY8sLfCTZKz8qLqJ/Z0fgS4YiQ99Mkjc09dF I+c7cc= X-Google-Smtp-Source: AGHT+IFBxNNkXkV6QdatkLzGvqLa5C2xcF3hYIaNrFL65L7F5CjBq//5XTZjsJXhhN+9MYYSHeATo1hi4HK1ndwfeNk= X-Received: by 2002:a05:6e02:190f:b0:3e2:9977:bebb with SMTP id e9e14a558f8ab-3e4163460ecmr179837065ab.13.1754367046757; Mon, 04 Aug 2025 21:10:46 -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, 5 Aug 2025 00:10:33 -0400 X-Gm-Features: Ac12FXwRDGeShRmR0IrHKnuPcsfhQuh0mD7sE8aH0KE1nK5EqoDJQLaTzWYzkfY 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="000000000000a0af20063b9668f8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a0af20063b9668f8 Content-Type: text/plain; charset="UTF-8" > > > In the end, it seems we need to make all these functions in the below > query error safe. > select castsource::regtype, casttarget::regtype, castfunc, > castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc > pp on > pp.oid = pc.castfunc and pc.castfunc > 0 > order by castsource::regtype; > It's a lot of work, but seems doable, after playing around with it. > It is do-able. But that's just the cast functions that are part of core postgres. > > > I don't think we need to change the pg_cast catalog entry, > we just need to make these function (pg_cast.castmethod) errors safe. That would break any user-defined cast functions that were not also error safe, which is to say all of them. We need a way for user-defined cast functions to indicate whether or not they are error safe, and handle both situations accordingly (i.e. fail a CAST ON DEFAULT when the user-defined cast is not error-safe). --000000000000a0af20063b9668f8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

In the end, it seems we need to make all these functions in the below
query error safe.
select castsource::regtype, casttarget::regtype, castfunc,
castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc = pp on
pp.oid =3D pc.castfunc and pc.castfunc > 0
order by castsource::regtype;
It's a lot of work, but seems doable, after playing around with it.
=

It is do-able. But that's just the cas= t functions that are part of core postgres.=C2=A0
=C2= =A0


I don't think we need to change the pg_cast catalog entry,
we just need to make these function (pg_cast.castmethod) errors safe.

That would break any user-defined cast functions= that were not also error safe, which is to say all of them.

=
We need a way for user-defined cast functions to indicate w= hether or not they are error safe, and handle both situations accordingly (= i.e. fail a CAST ON DEFAULT when the user-defined cast is not error-safe).<= /div>=C2=A0
--000000000000a0af20063b9668f8--