Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix overly strict Assert in jsonpath code
authorDavid Rowley <drowley@postgresql.org>
Tue, 1 Aug 2023 13:44:31 +0000 (01:44 +1200)
committerDavid Rowley <drowley@postgresql.org>
Tue, 1 Aug 2023 13:44:31 +0000 (01:44 +1200)
This was failing for queries which try to get the .type() of a
jpiLikeRegex.  For example:

select jsonb_path_query('["string", "string"]',
                        '($[0] like_regex ".{7}").type()');

Reported-by: Alexander Kozhemyakin
Bug: #18035
Discussion: https://postgr.es/m/18035-64af5cdcb5adf2a9@postgresql.org
Backpatch-through: 12, where SQL/JSON path was added.

src/backend/utils/adt/jsonpath.c

index 7f322485e7b1f399bb6d4ecae5ab403b52bb65bd..bc2168cf926666c02e6a4857f74d9c64b82c05e9 100644 (file)
@@ -962,7 +962,8 @@ jspGetNext(JsonPathItem *v, JsonPathItem *a)
               v->type == jpiCeiling ||
               v->type == jpiDouble ||
               v->type == jpiKeyValue ||
-              v->type == jpiStartsWith);
+              v->type == jpiStartsWith ||
+              v->type == jpiLikeRegex);
 
        if (a)
            jspInitByBuffer(a, v->base, v->nextPos);