- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitd46911e
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 parent3e782ca commitd46911e
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 | |
---|---|---|---|
| |||
773 | 773 |
| |
774 | 774 |
| |
775 | 775 |
| |
776 |
| - | |
777 | 776 |
| |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
778 | 781 |
| |
779 | 782 |
| |
780 | 783 |
| |
| |||
904 | 907 |
| |
905 | 908 |
| |
906 | 909 |
| |
907 |
| - | |
| 910 | + | |
908 | 911 |
| |
909 | 912 |
| |
910 | 913 |
| |
| |||
953 | 956 |
| |
954 | 957 |
| |
955 | 958 |
| |
956 |
| - | |
| 959 | + | |
957 | 960 |
| |
958 | 961 |
| |
959 | 962 |
| |
960 | 963 |
| |
961 |
| - | |
962 |
| - | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
963 | 987 |
| |
964 | 988 |
| |
965 | 989 |
| |
| 990 | + | |
966 | 991 |
| |
967 |
| - | |
| 992 | + | |
| 993 | + | |
968 | 994 |
| |
969 | 995 |
| |
970 | 996 |
| |
|
Lines changed: 62 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
614 | 614 |
| |
615 | 615 |
| |
616 | 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 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
617 | 679 |
| |
618 | 680 |
| |
619 | 681 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
197 | 197 |
| |
198 | 198 |
| |
199 | 199 |
| |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
200 | 220 |
| |
201 | 221 |
| |
202 | 222 |
| |
|
0 commit comments
Comments
(0)