On 10/28/2014 09:49 AM, Andrew Dunstan wrote:
>
> On 10/27/2014 05:57 PM, Alvaro Herrera wrote:
>
>> Anyway this whole business of searching through the CASTSOURCETARGET
>> syscache seems like it could be refactored. If I'm counting correctly,
>> that block now appears four times (three in this patch, once in json.c).
>> Can't we add a new function to (say) lsyscache and remove that?
>
> Twice, not three times in this patch, unless I'm going crazier than I
> thought.
>
> I can add a function to lsyscache along the lines of
>
> Oid get_cast_func(Oid from_type, Oid to_type)
>
> if you think it's worth it.
>
>
OK, here is a new patch version that
* uses find_coercion_path() to find the cast function if any, as
discussed elsewhere
* removes calls to getTypeOutputInfo() except where required
* honors a cast to json only for rendering both json and jsonb
* adds processing for the date type that was previously missing in
datum_to_jsonb
cheers
andrew