Re: Bug in jsonb_path_exists (maybe _match) one-element scalar/variable jsonpath handling

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Bug in jsonb_path_exists (maybe _match) one-element scalar/variable jsonpath handling
Дата
Msg-id CAKFQuwZ_A_JFpBaHiNvR3Ti5X5L9Ut6csyARPygO53Chd_vcUA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Bug in jsonb_path_exists (maybe _match) one-element scalar/variable jsonpath handling  (Alexander Korotkov <aekorotkov@gmail.com>)
Ответы Re: Bug in jsonb_path_exists (maybe _match) one-element scalar/variable jsonpath handling
Список pgsql-bugs
On Mon, Dec 5, 2022 at 4:58 PM Alexander Korotkov <aekorotkov@gmail.com> wrote:
On Fri, Dec 2, 2022 at 3:18 PM Alexander Korotkov <aekorotkov@gmail.com> wrote:
> Draft patch fixing the issue is attached.  Let me know what you think
> about this.

Revised patch is attached, wrong pfree() is fixed.  I was intended to
backpatch it.  But the behavior change makes me uneasy.

select * from jsonb_path_query('{"a": 10}', '$ ? (@.a < $value)');

Currently, this query generates an error because of missing "value"
variable.  The patch suppress this error.  I'm not sure this error
should be suppressed.  Especially, I'm sure this should be
backpatched.

Should we fix only existence checking behaviour and let other cases
throw an error?  Thoughts?


I've attached some additional regression test changes to formally document what it is we are affecting here.  The "false" ones seems like it can stand-in for all of the types left behind when the variable one got moved to its own case.

The regressions.diffs file is the changes made by the 0001 patch.

Instead of making everything that today correctly produces a "could not find jsonpath variable" error behave in a non-error way we need to make _exists produce the exact same error.  Aside from seemingly being correct on its own merits, it is superior to turning what was a true outcome to a false outcome, which is much more likely to go unnoticed and cause people grief.

I feel like we are not adequately testing the "jspGetNext" true outcome of the variable path but I still haven't fully gotten my head around the code.

The behavior of the introduced constant false jsonpath expression seems internally consistent.  Fixing the documentation to make it clear how such an unusual but acceptable jsonpath expression behaves is material for a separate patch.

David J.

Вложения

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

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #17706: ALTER TYPE leads to crash
Следующее
От: Richard Guo
Дата:
Сообщение: Re: BUG #17706: ALTER TYPE leads to crash