> > > 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).