Re: [HACKERS] Cache lookup error when using jsonb, json_build_object and a WITH clause

2014-05-09 Thread Tom Lane
Andres Freund writes: >> Anybody see other problems to fix here? > Yea. > 5) > if (val_type > FirstNormalObjectId) > isn't fundamentally incorrect but imo shouldn't be replaced by something > like !IsCatalogType() (akin to IsCatalogRelation). At least if we decide > that hunk is safe from ot

Re: [HACKERS] Cache lookup error when using jsonb, json_build_object and a WITH clause

2014-05-09 Thread Tom Lane
Andrew Dunstan writes: > I guess this is my fault. I recall some discussions when some of this > was first being written about the best way to make the type based > decisions, not sure at this remove whether on list or off. The origin of > it is in 9.2, so if you're going to adjust it you shoul

Re: [HACKERS] Cache lookup error when using jsonb, json_build_object and a WITH clause

2014-05-09 Thread Andres Freund
On 2014-05-09 10:07:10 -0400, Tom Lane wrote: > I wrote: > > Andres Freund writes: > >> 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? > > > Indeed. I think the bit that uses TYPCATEGORY_NUMERIC as a hint

Re: [HACKERS] Cache lookup error when using jsonb, json_build_object and a WITH clause

2014-05-09 Thread Andrew Dunstan
On 05/09/2014 10:07 AM, Tom Lane wrote: After further reflection I think we should lose the TYPCATEGORY_NUMERIC business too. ruleutils.c hard-wires the set of types it will consider to be numeric, and I see no very good reason not to do likewise here. That will remove the need to look up the t

Re: [HACKERS] Cache lookup error when using jsonb, json_build_object and a WITH clause

2014-05-09 Thread Tom Lane
I wrote: > Andres Freund writes: >> 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? > Indeed. I think the bit that uses TYPCATEGORY_NUMERIC as a hint to decide > whether the value can be left unquoted (assum

Re: [HACKERS] Cache lookup error when using jsonb, json_build_object and a WITH clause

2014-05-09 Thread Tom Lane
Andres Freund writes: > Whoa. There's two wierd things here: > a) "jsonb" has a typcategory 'C'. Marking a composite type. "json" has >'U'. Yeah, that's flat out wrong. I changed it before seeing your message. > b) datum_to_json() thinks it's a good idea to use typcategory to decide >ho

Re: [HACKERS] Cache lookup error when using jsonb, json_build_object and a WITH clause

2014-05-09 Thread Andres Freund
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: cach

Re: [HACKERS] Cache lookup error when using jsonb, json_build_object and a WITH clause

2014-05-09 Thread Tom Lane
Michael Paquier 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

[HACKERS] Cache lookup error when using jsonb, json_build_object and a WITH clause

2014-05-09 Thread Michael Paquier
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, typc