Repository navigation
Commit deafe5d
authored
Add MySQL-judged REGEXP test suites (#622)
## Summary
This PR adds **two extensive REGEXP test suites, judged by MySQL 8.4**.
Each case expects the result that a real MySQL server returned, so the
tests show exactly where the driver differs from MySQL.
The cases come from two sources:
- **MySQL server test suite:** 12,684 cases, built from the `REGEXP`,
`RLIKE`, and `REGEXP_*()` patterns in MySQL's own tests.
- **ICU's `regextst.txt`:** 3,965 cases from the regex tests of ICU, the
library that MySQL uses for regular expressions. ICU's copyright and
license (Unicode License V3) are kept next to the data.
Each case stores MySQL's results for `REGEXP_LIKE()`, `REGEXP_INSTR()`,
`REGEXP_SUBSTR()`, and `REGEXP_REPLACE()`. There is one test class per
function, and it lists the cases that fail today in
`get_known_failures()`. A test fails when an unlisted case fails, **and
also when a listed case starts to pass**, so the list must shrink as
REGEXP support improves. Cases that fail only with some PHP or PCRE
versions are listed under version checks that name the cause.
To measure the current state, this PR also adds **a basic
`REGEXP_LIKE()`**. It reuses the existing matching of the `REGEXP`
operator and adds match types. Like in MySQL, it returns `NULL` for a
`NULL` argument, and so does the operator now. With PHP 8.5 and PCRE2
10.49, it fails 302 of the 12,684 MySQL cases and 951 of the 3,965 ICU
cases. The tests of the other functions are skipped until the functions
exist.
To rebuild the data from a MySQL server, run
`tests/tools/generate-regexp-test-data.php`.
## Why
REGEXP support needs improvements, which will come in later PRs. These
suites give us a baseline to measure them: a fix shows up as known
failures that now pass, and a regression as a new failure.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **New Features**
* Added support for MySQL-compatible `REGEXP_LIKE` matching, including
case sensitivity, multiline and dot-all options, and `NULL` results when
inputs are `NULL`.
* The `REGEXP` and `NOT REGEXP` operators now return `NULL` when their
inputs require it.
* **Tests**
* Added broad compatibility checks for regular expression behavior.
Support for `REGEXP_INSTR`, `REGEXP_REPLACE`, and `REGEXP_SUBSTR`
remains unavailable.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent bcde35e commit deafe5d
11 files changed
Lines changed: 19097 additions & 11 deletions
File tree
- packages/mysql-on-sqlite
- src/sqlite
- tests
- regexp
- data
- tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
565 | 566 | | |
566 | 567 | | |
567 | 568 | | |
568 | | - | |
| 569 | + | |
569 | 570 | | |
570 | | - | |
571 | | - | |
| 571 | + | |
| 572 | + | |
572 | 573 | | |
573 | | - | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
574 | 578 | | |
575 | 579 | | |
576 | 580 | | |
| |||
587 | 591 | | |
588 | 592 | | |
589 | 593 | | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
596 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
597 | 646 | | |
598 | 647 | | |
599 | 648 | | |
600 | | - | |
| 649 | + | |
601 | 650 | | |
602 | 651 | | |
603 | 652 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
269 | 315 | | |
270 | 316 | | |
271 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments