- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit9481d16
committed
Fix conversion of SIMILAR TO regexes for character classes
The code that translates SIMILAR TO pattern matching expressions toPOSIX-style regular expressions did not consider that square bracketscan be nested. For example, in an expression like [[:alpha:]%_], thelogic replaced the placeholders '_' and '%' but it should not.This commit fixes the conversion logic by tracking the nesting level ofsquare brackets marking character class areas, while considering thatin expressions like []] or [^]] the first closing square bracket is aregular character. Multiple tests are added to show how the conversionsshould or should not apply applied while in a character class area, withspecific cases added for all the characters converted outside characterclasses like an opening parenthesis '(', dollar sign '$', etc.Author: Laurenz Albe <laurenz.albe@cybertec.at>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/16ab039d1af455652bdf4173402ddda145f2c73b.camel@cybertec.atBackpatch-through: 131 parent4f49456 commit9481d16
File tree
3 files changed
+114
-6
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+114
-6
lines changedLines changed: 32 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
673 | 673 |
| |
674 | 674 |
| |
675 | 675 |
| |
676 |
| - | |
677 | 676 |
| |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
678 | 681 |
| |
679 | 682 |
| |
680 | 683 |
| |
| |||
804 | 807 |
| |
805 | 808 |
| |
806 | 809 |
| |
807 |
| - | |
| 810 | + | |
808 | 811 |
| |
809 | 812 |
| |
810 | 813 |
| |
| |||
853 | 856 |
| |
854 | 857 |
| |
855 | 858 |
| |
856 |
| - | |
| 859 | + | |
857 | 860 |
| |
858 | 861 |
| |
859 | 862 |
| |
860 | 863 |
| |
861 |
| - | |
862 |
| - | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
863 | 887 |
| |
864 | 888 |
| |
865 | 889 |
| |
| 890 | + | |
866 | 891 |
| |
867 |
| - | |
| 892 | + | |
| 893 | + | |
868 | 894 |
| |
869 | 895 |
| |
870 | 896 |
| |
|
Lines changed: 62 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
557 | 557 |
| |
558 | 558 |
| |
559 | 559 |
| |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
560 | 622 |
| |
561 | 623 |
| |
562 | 624 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
183 | 183 |
| |
184 | 184 |
| |
185 | 185 |
| |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
186 | 206 |
| |
187 | 207 |
| |
188 | 208 |
| |
|
0 commit comments
Comments
(0)