1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Support 'q' flag in jsonpath 'like_regex' predicate

SQL/JSON standard defines that jsonpath 'like_regex' predicate should support
the same set of flags as XQuery/XPath.  It appears that implementation of 'q'
flag was missed.  This commit fixes that.

Discussion: https://postgr.es/m/CAPpHfdtyfPsxLYiTjp5Ov8T5xGsB5t3CwE5%2B3PS%3DLLwA%2BxTJog%40mail.gmail.com
Author: Nikita Glukhov, Alexander Korotkov
This commit is contained in:
Alexander Korotkov
2019-06-19 22:40:58 +03:00
parent d8594d123c
commit 261a5c1928
8 changed files with 85 additions and 0 deletions

View File

@ -1664,6 +1664,17 @@ executeLikeRegex(JsonPathItem *jsp, JsonbValue *str, JsonbValue *rarg,
cxt->cflags &= ~REG_NEWLINE;
if (flags & JSP_REGEX_WSPACE)
cxt->cflags |= REG_EXPANDED;
/*
* 'q' flag can work together only with 'i'. When other is specified,
* then 'q' has no effect.
*/
if ((flags & JSP_REGEX_QUOTE) &&
!(flags & (JSP_REGEX_MLINE | JSP_REGEX_SLINE | JSP_REGEX_WSPACE)))
{
cxt->cflags &= ~REG_ADVANCED;
cxt->cflags |= REG_QUOTE;
}
}
if (RE_compile_and_execute(cxt->regex, str->val.string.val,