jsonpath-exists-semantics-fix-wip.patch
text/x-diff
Filename: jsonpath-exists-semantics-fix-wip.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/utils/adt/jsonpath_exec.c | 8 | 1 |
| src/test/regress/expected/jsonb_jsonpath.out | 1 | 1 |
diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c
index ac16f5c85d..63c46cfab5 100644
--- a/src/backend/utils/adt/jsonpath_exec.c
+++ b/src/backend/utils/adt/jsonpath_exec.c
@@ -2065,7 +2065,14 @@ appendBoolResult(JsonPathExecContext *cxt, JsonPathItem *jsp,
JsonbValue jbv;
if (!jspGetNext(jsp, &next) && !found)
- return jperOk; /* found singleton boolean value */
+ {
+ /*
+ * We have a predicate check expression, i.e. a path ending in a bare
+ * boolean operator, and we don't need to return the exact value(s)
+ * found. Just report success or failure of the boolean.
+ */
+ return (res == jpbTrue) ? jperOk : jperNotFound;
+ }
if (res == jpbUnknown)
{
diff --git a/src/test/regress/expected/jsonb_jsonpath.out b/src/test/regress/expected/jsonb_jsonpath.out
index 6659bc9091..59e1b71051 100644
--- a/src/test/regress/expected/jsonb_jsonpath.out
+++ b/src/test/regress/expected/jsonb_jsonpath.out
@@ -1157,7 +1157,7 @@ select jsonb_path_query('2', '$ == "2"');
select jsonb '2' @? '$ == "2"';
?column?
----------
- t
+ f
(1 row)
select jsonb '2' @@ '$ > 1';