Re: Cache lookup error when using jsonb, json_build_object and a WITH clause - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Cache lookup error when using jsonb, json_build_object and a WITH clause
Date
Msg-id 8422.1399640953@sss.pgh.pa.us
Whole thread Raw
In response to Cache lookup error when using jsonb, json_build_object and a WITH clause  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: New pg_lsn type doesn't have hash/btree opclasses
Next
From: Andres Freund
Date:
Subject: Re: Cache lookup error when using jsonb, json_build_object and a WITH clause