diff options
author | Alexander Korotkov <akorotkov@postgresql.org> | 2019-06-19 22:40:58 +0300 |
---|---|---|
committer | Alexander Korotkov <akorotkov@postgresql.org> | 2019-06-19 22:41:57 +0300 |
commit | 261a5c1928566f938cbda0f62dc16f6a2d1e871d (patch) | |
tree | b8c8f249ab1d48bfa0bfe7b7b0d278f0ff572565 /src/backend/utils/adt/jsonpath_exec.c | |
parent | d8594d123c155aeecd47fc2450f62f5100b2fbf0 (diff) | |
download | postgresql-261a5c1928566f938cbda0f62dc16f6a2d1e871d.tar.gz postgresql-261a5c1928566f938cbda0f62dc16f6a2d1e871d.zip |
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
Diffstat (limited to 'src/backend/utils/adt/jsonpath_exec.c')
-rw-r--r-- | src/backend/utils/adt/jsonpath_exec.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c index 873d64b6304..6bf4dcaec33 100644 --- a/src/backend/utils/adt/jsonpath_exec.c +++ b/src/backend/utils/adt/jsonpath_exec.c @@ -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, |