Michael Paquier <michael.paquier@gmail.com> writes:
> I found the following error when playing with jsonb and json_build_object:
> =# with jsonb_data as (select * from jsonb_each('{"aa" :
> "po"}'::jsonb)) select json_build_object(key,value) from jsonb_data;
> ERROR: XX000: cache lookup failed for type 2147483650
> LOCATION: lookup_type_cache, typcache.c:193
The immediate problem seems to be that add_json() did not get taught
that jsonb is of TYPCATEGORY_JSON; somebody missed updating that copy
of logic that's been copied and pasted several times too many, IMNSHO.
However, now that I look at this code, it seems like it's got more
problems than that:
* it will be fooled utterly by domains over types it's interested in.
* there is nothing stopping somebody from making user-defined types
with category 'j' or 'c', which will confuse it even more.
regards, tom lane