Re: BUG #13996: json_to_record() returns non-NULL, malformed value for omitted key under some circumstances
От | Andrew Dunstan |
---|---|
Тема | Re: BUG #13996: json_to_record() returns non-NULL, malformed value for omitted key under some circumstances |
Дата | |
Msg-id | 56D7A8CC.2050206@dunslane.net обсуждение исходный текст |
Ответ на | Re: BUG #13996: json_to_record() returns non-NULL, malformed value for omitted key under some circumstances (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: BUG #13996: json_to_record() returns non-NULL, malformed value for omitted key under some circumstances
|
Список | pgsql-bugs |
On 03/02/2016 08:04 PM, Tom Lane wrote: > johann@visagie.za.net writes: >> SELECT t.* >> FROM json_to_record('{"a":1, "b":{"c":16, "d":2}, "x":8}'::json) >> AS t(a int, b json, c text, x int); >> However, if (as in this example) another key in the JSON object - `b` in >> this case - refers to a nested JSON object which *does* contain a key `c`, >> the function returns a malformed JSON string as (text) value for column >> `c`: >> a | b | c | x >> ---+----------------+---------+--- >> 1 | {"c":16,"d":2} | {"c":16 | 8 >> (1 row) > > AFAICT this is a simple thinko in the hash_object_field_end() callback, > as per attached patch that fixes this and doesn't break any existing > regression test cases. Andrew, do you concur that this is correct, > or is there something I'm missing about the tracking of lex_level? > > Looks like you're right. lex_level is incremented at object/array start and decremented at object/array end. So keys of the outermost object will be at lex_level 1, and we shouldn't be using anything at a higher level. I guess we should add something like this as an extra regression test. cheers andrew
В списке pgsql-bugs по дате отправления: