[MDEV-12942] REGEXP_INSTR returns 1 when using brackets Created: 2017-05-29 Updated: 2017-05-30 Resolved: 2017-05-30 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | OTHER |
| Affects Version/s: | 10.1.13, 10.2.6 |
| Fix Version/s: | 10.1.25, 10.2.7 |
| Type: | Bug | Priority: | Major |
| Reporter: | Konstantin Schmidt | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
ms windows 7 Home Premium 64 bit, Intel i5 750 |
||
| Description |
|
MariaDB Documentation says about REGEXP_INSTR: Returns the position of the first occurrence of the regular expression pattern in the string subject, or 0 if pattern was not found. My task is (simplified): finding o followed by a double consonant
It returns 1 but I would have expected 4 as the position of oll Doing the same with replace works:
It seems that the trouble starts when using brackets in REGEXP_INSTR:
Checked with latest stable version 10.2.6, default settings. |
| Comments |
| Comment by Sergei Golubchik [ 2017-05-29 ] |
|
bar, do you remember what was the reason for this m_subpatterns_needed in the first place, instead of always using array_elments(m_SubStrVec) ? |
| Comment by Alexander Barkov [ 2017-05-30 ] |
|
Sergei, I overlooked in the documentation that PCRE uses this buffer not only to return matching subpatterns, but also to store back-references, in the last one third of the buffer. Your changes looks fine. But perhaps we should just remove m_subpatterns_needed. |
| Comment by Sergei Golubchik [ 2017-05-30 ] |
|
Yes, I've removed it in a followup cleanup patch:
in the cleanup patch I've noticed another bug, where re.init was called with subpatterns_needed=10, but this value should be a multiple of 3 (man pcre_exec). |