From: | Andres Freund <andres(at)2ndquadrant(dot)com> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
Cc: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Cache lookup error when using jsonb, json_build_object and a WITH clause |
Date: | 2014-05-09 13:11:36 |
Message-ID: | 20140509131136.GD30231@awork2.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2014-05-09 21:40:07 +0900, Michael Paquier wrote:
> Hi all,
>
> 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
>
> I would have expected the result to be the same as in the case of json:
> =# with json_data as (select * from json_each('{"aa" : "po"}'::json))
> select json_build_object(key,value) from json_data;
> json_build_object
> -------------------
> {"aa" : "po"}
> (1 row)
Whoa. There's two wierd things here:
a) "jsonb" has a typcategory 'C'. Marking a composite type. "json" has
'U'.
b) datum_to_json() thinks it's a good idea to use typcategory to decide
how a type is output. Isn't that pertty fundamentally flawed? To
detect composite types it really should look at typtype, now?
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2014-05-09 13:14:25 | Re: New pg_lsn type doesn't have hash/btree opclasses |
Previous Message | Tom Lane | 2014-05-09 13:09:13 | Re: Cache lookup error when using jsonb, json_build_object and a WITH clause |