@@ -99,6 +99,29 @@ flattenJsonPathParseItem(StringInfo buf, JsonPathParseItem *item,
9999 * (int32 * )(buf -> data + right ) = chld ;
100100 }
101101 break ;
102+ case jpiLikeRegex :
103+ {
104+ int32 offs ;
105+
106+ appendBinaryStringInfo (buf ,
107+ (char * ) & item -> value .like_regex .flags ,
108+ sizeof (item -> value .like_regex .flags ));
109+ offs = buf -> len ;
110+ appendBinaryStringInfo (buf , (char * ) & offs /* fake value */ , sizeof (offs ));
111+
112+ appendBinaryStringInfo (buf ,
113+ (char * ) & item -> value .like_regex .patternlen ,
114+ sizeof (item -> value .like_regex .patternlen ));
115+ appendBinaryStringInfo (buf , item -> value .like_regex .pattern ,
116+ item -> value .like_regex .patternlen );
117+ appendStringInfoChar (buf , '\0' );
118+
119+ chld = flattenJsonPathParseItem (buf , item -> value .like_regex .expr ,
120+ forbiddenRoot ,
121+ insideArraySubscript );
122+ * (int32 * )(buf -> data + offs ) = chld ;
123+ }
124+ break ;
102125 case jpiFilter :
103126 case jpiIsUnknown :
104127 case jpiNot :
@@ -369,6 +392,38 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey, bool printBracket
369392 if (printBracketes )
370393 appendStringInfoChar (buf , ')' );
371394 break ;
395+ case jpiLikeRegex :
396+ if (printBracketes )
397+ appendStringInfoChar (buf , '(' );
398+
399+ jspInitByBuffer (& elem , v -> base , v -> content .like_regex .expr );
400+ printJsonPathItem (buf , & elem , false,
401+ operationPriority (elem .type ) <=
402+ operationPriority (v -> type ));
403+
404+ appendBinaryStringInfo (buf , " like_regex " , 12 );
405+
406+ escape_json (buf , v -> content .like_regex .pattern );
407+
408+ if (v -> content .like_regex .flags )
409+ {
410+ appendBinaryStringInfo (buf , " flag \"" , 7 );
411+
412+ if (v -> content .like_regex .flags & JSP_REGEX_ICASE )
413+ appendStringInfoChar (buf , 'i' );
414+ if (v -> content .like_regex .flags & JSP_REGEX_SLINE )
415+ appendStringInfoChar (buf , 's' );
416+ if (v -> content .like_regex .flags & JSP_REGEX_MLINE )
417+ appendStringInfoChar (buf , 'm' );
418+ if (v -> content .like_regex .flags & JSP_REGEX_WSPACE )
419+ appendStringInfoChar (buf , 'x' );
420+
421+ appendStringInfoChar (buf , '"' );
422+ }
423+
424+ if (printBracketes )
425+ appendStringInfoChar (buf , ')' );
426+ break ;
372427 case jpiPlus :
373428 case jpiMinus :
374429 if (printBracketes )
@@ -607,6 +662,12 @@ jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
607662 read_int32 (v -> content .args .left , base , pos );
608663 read_int32 (v -> content .args .right , base , pos );
609664 break ;
665+ case jpiLikeRegex :
666+ read_int32 (v -> content .like_regex .flags , base , pos );
667+ read_int32 (v -> content .like_regex .expr , base , pos );
668+ read_int32 (v -> content .like_regex .patternlen , base , pos );
669+ v -> content .like_regex .pattern = base + pos ;
670+ break ;
610671 case jpiNot :
611672 case jpiExists :
612673 case jpiIsUnknown :
0 commit comments