- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitb3e9911
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 parent6b0d69d commitb3e9911
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 | |
---|---|---|---|
| |||
759 | 759 |
| |
760 | 760 |
| |
761 | 761 |
| |
762 |
| - | |
763 | 762 |
| |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
764 | 767 |
| |
765 | 768 |
| |
766 | 769 |
| |
| |||
890 | 893 |
| |
891 | 894 |
| |
892 | 895 |
| |
893 |
| - | |
| 896 | + | |
894 | 897 |
| |
895 | 898 |
| |
896 | 899 |
| |
| |||
939 | 942 |
| |
940 | 943 |
| |
941 | 944 |
| |
942 |
| - | |
| 945 | + | |
943 | 946 |
| |
944 | 947 |
| |
945 | 948 |
| |
946 | 949 |
| |
947 |
| - | |
948 |
| - | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
949 | 973 |
| |
950 | 974 |
| |
951 | 975 |
| |
| 976 | + | |
952 | 977 |
| |
953 |
| - | |
| 978 | + | |
| 979 | + | |
954 | 980 |
| |
955 | 981 |
| |
956 | 982 |
| |
|
Lines changed: 62 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
571 | 571 |
| |
572 | 572 |
| |
573 | 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 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
574 | 636 |
| |
575 | 637 |
| |
576 | 638 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
187 | 187 |
| |
188 | 188 |
| |
189 | 189 |
| |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
190 | 210 |
| |
191 | 211 |
| |
192 | 212 |
| |
|
0 commit comments
Comments
(0)