Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zero-byte disturbs further regexp matching #9160

Closed
filimonov opened this issue Feb 17, 2020 · 2 comments · Fixed by #9163
Closed

zero-byte disturbs further regexp matching #9160

filimonov opened this issue Feb 17, 2020 · 2 comments · Fixed by #9163
Labels
bug Confirmed user-visible misbehaviour in official release comp-functions Relates to some SQL function st-accepted The issue is in our backlog, ready to take

Comments

@filimonov
Copy link
Contributor

select unhex('34') || ' key="v" ' as haystack, length(haystack), extract( haystack, 'key="(.*?)"') as needle;
-- works, result = v

select unhex('00') || ' key="v" ' as haystack, length(haystack), extract( haystack, 'key="(.*?)"') as needle;
-- returns nothing (zero-byte in the begining of haystack)

select number as char_code,  extract( char(char_code) || ' key="v" ' as haystack, 'key="(.*?)"') as needle from numbers(256);
-- every other chars codes (except of zero byte) works ok
@filimonov filimonov added bug Confirmed user-visible misbehaviour in official release comp-functions Relates to some SQL function labels Feb 17, 2020
@alexey-milovidov
Copy link
Member

alexey-milovidov commented Feb 17, 2020

It looks like the deficiency of re2 library. Upd: untrue.
It also does not support zero bytes in regexp.

@alexey-milovidov
Copy link
Member

If use hyperscan instead of re2, everything is Ok:

select match('\0 key="v" ', 'key="(.*?)"')
0

select multiMatchAny('\0 key="v" ', ['key="(.*?)"'])
1

@alexey-milovidov alexey-milovidov added st-declined The feature will not be implemented. Check the comments. st-accepted The issue is in our backlog, ready to take and removed st-declined The feature will not be implemented. Check the comments. labels Feb 17, 2020
alexey-milovidov added a commit that referenced this issue Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed user-visible misbehaviour in official release comp-functions Relates to some SQL function st-accepted The issue is in our backlog, ready to take
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants