pgsql: Fix jsonpath existense checking of missing variables

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix jsonpath existense checking of missing variables
Date: 2023-01-12 15:23:10
Message-ID: E1pFzQ6-003Iyt-5v@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix jsonpath existense checking of missing variables

The current jsonpath code assumes that the referenced variable always exists.
It could only throw an error at the value valuation time. At the same time
existence checking assumes variable is present without valuation, and error
suppression doesn't work for missing variables.

This commit makes existense checking trigger an error for missing variables.
This makes the overall behavior consistent.

Backpatch to 12 where jsonpath was introduced.

Reported-by: David G. Johnston
Discussion: https://postgr.es/m/CAKFQuwbeytffJkVnEqDyLZ%3DrQsznoTh1OgDoOF3VmOMkxcTMjA%40mail.gmail.com
Author: Alexander Korotkov, David G. Johnston
Backpatch-through: 12

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9e24e4781750ca92a0a5ff0aaa8e2091785c3bed

Modified Files
--------------
src/backend/utils/adt/jsonpath_exec.c | 8 +++++--
src/test/regress/expected/jsonb_jsonpath.out | 32 ++++++++++++++++++++++++++++
src/test/regress/sql/jsonb_jsonpath.sql | 8 +++++++
3 files changed, 46 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2023-01-12 15:26:32 pgsql: Fix jsonpath existense checking of missing variables
Previous Message Robert Haas 2023-01-12 15:11:46 Re: pgsql: Add new GUC createrole_self_grant.