Re: BUG #16828: duplicate results when using ** recursive expression in JSON path

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #16828: duplicate results when using ** recursive expression in JSON path
Дата
Msg-id 231763.1610912521@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #16828: duplicate results when using ** recursive expression in JSON path  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #16828: duplicate results when using ** recursive expression in JSON path  (Alexander Korotkov <aekorotkov@gmail.com>)
Список pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> The following query 

>   select jsonb_path_query_array(col, '$.**.itemName')
>   from (
>     values ('{"items": [{"itemName": "a", "items": [{"itemName":
> "b"}]}]}'::jsonb)
>   ) as t(col) 

> returns ["a", "a", "b", "b"] but should return only ["a", "b"] as each value
> only appears once in the JSON value. 

jsonpath_exec.c is a muddle of undocumented code, but I think
I found where the duplication is occurring: in executeAnyItem(),
the first occurrence comes out while recursing down from the
executeItemOptUnwrapTarget call at line 1419 (as of HEAD), and then
the duplicate comes out while recursing down from the executeAnyItem
call at line 1439.  So I'd say that that logic for
"ignoreStructuralErrors" needs a rethink.  (BTW, why is half of this
code relying on cxt->ignoreStructuralErrors while the other half
receives a passed-down flag?  That seems like a recipe for bugs,
especially with the lack of commentary about the reason for it.)

Alexander, git blame says all this code is your fault ...

            regards, tom lane



В списке pgsql-bugs по дате отправления:

Предыдущее
От:
Дата:
Сообщение: RE: BUG #16825: When building on Windows, cl /? retrun 'x64' not AMD64 and the build does not create x64 environment
Следующее
От: Alexander Korotkov
Дата:
Сообщение: Re: BUG #16828: duplicate results when using ** recursive expression in JSON path