Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d063a07

Browse files
author
Nikita Glukhov
committed
Don't generate all possible lax paths for jsonb_value_path_ops
1 parent 60c0c71 commit d063a07

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

jsonb_gin_ops.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ gin_extract_jsonb_query_value_path(PG_FUNCTION_ARGS)
815815
if (strategy != JsQueryMatchStrategyNumber)
816816
root = extractJsonPath(PG_GETARG_JSONPATH_P(0),
817817
strategy == JsonpathExistsStrategyNumber,
818+
false,
818819
make_value_path_entry_handler,
819820
check_value_path_entry_handler,
820821
(Pointer)&e);
@@ -1287,6 +1288,7 @@ gin_extract_jsonb_query_path_value_internal(FunctionCallInfo fcinfo, bool lax)
12871288
if (strategy != JsQueryMatchStrategyNumber)
12881289
root = extractJsonPath(PG_GETARG_JSONPATH_P(0),
12891290
strategy == JsonpathExistsStrategyNumber,
1291+
!lax,
12901292
make_path_value_entry_handler,
12911293
check_path_value_entry_handler,
12921294
(Pointer) &extra);

jsquery.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ bool isLogicalNodeType(ExtractedNodeType type);
245245
ExtractedNode *extractJsQuery(JsQuery *jq, MakeEntryHandler makeHandler,
246246
CheckEntryHandler checkHandler, Pointer extra);
247247
#ifndef NO_JSONPATH
248-
ExtractedNode *extractJsonPath(JsonPath *jp, bool exists,
248+
ExtractedNode *extractJsonPath(JsonPath *jp, bool exists, bool arrayPathItems,
249249
MakeEntryHandler makeHandler,
250250
CheckEntryHandler checkHandler, Pointer extra);
251251
#endif

jsquery_extract.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,12 +1346,13 @@ extractJsQuery(JsQuery *jq, MakeEntryHandler makeHandler,
13461346
* Turn jsonpath into tree of entries using user-provided handler.
13471347
*/
13481348
ExtractedNode *
1349-
extractJsonPath(JsonPath *jp, bool exists, MakeEntryHandler makeHandler,
1349+
extractJsonPath(JsonPath *jp, bool exists, bool arrayPathItems,
1350+
MakeEntryHandler makeHandler,
13501351
CheckEntryHandler checkHandler, Pointer extra)
13511352
{
13521353
ExtractedNode *root;
13531354
JsonPathItem jsp;
1354-
bool lax = (jp->header & JSONPATH_LAX) != 0;
1355+
bool lax = (jp->header & JSONPATH_LAX) != 0 && arrayPathItems;
13551356

13561357
jspInit(&jsp, jp);
13571358
root = exists

0 commit comments

Comments
 (0)