forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit70dc4c5
committed
Fix lquery's NOT handling, and add ability to quantify non-'*' items.
The existing implementation of the ltree ~ lquery match operator issufficiently complex and undocumented that it's hard to tell exactlywhat it does. But one thing it clearly gets wrong is the combinationof NOT symbols (!) and '*' symbols. A pattern such as '*.!foo.*'should, by any ordinary understanding of regular expression behavior,match any ltree that has at least one label that's not "foo". As bestwe can tell by experimentation, what it's actually matching is anyltree in which *no* label is "foo". That's surprising, and not at allwhat the documentation says.Now, that's arguably a useful behavior, so if we rewrite to fix thebug we should provide some other way to get it. To do so, add theability to attach lquery quantifiers to non-'*' items as well as '*'s.Then the pattern '!foo{,}' expresses "any ltree in which no label isfoo". For backwards compatibility, the default quantifier for non-'*'items has to be "{1}", although the default for '*' items is '{,}'.I wouldn't have done it like that in a green field, but it's nottotally horrible.Armed with that, rewrite checkCond() from scratch. Treating '*' andnon-'*' items alike makes it simpler, not more complicated, so thatthe function actually gets a lot shorter than it was.Filip Rembiałkowski, Tom Lane, Nikita Glukhov, per a veryancient bug report from M. PalmDiscussion:https://postgr.es/m/CAP_rww=waX2Oo6q+MbMSiZ9ktdj6eaJj0cQzNu=Ry2cCDij5fw@mail.gmail.com1 parente07e2a4 commit70dc4c5
File tree
6 files changed
+262
-260
lines changed- contrib/ltree
- expected
- sql
- doc/src/sgml
6 files changed
+262
-260
lines changedLines changed: 94 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
445 | 445 |
| |
446 | 446 |
| |
447 | 447 |
| |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
448 | 454 |
| |
449 | 455 |
| |
450 | 456 |
| |
| |||
727 | 733 |
| |
728 | 734 |
| |
729 | 735 |
| |
730 |
| - | |
| 736 | + | |
731 | 737 |
| |
732 | 738 |
| |
733 | 739 |
| |
| |||
757 | 763 |
| |
758 | 764 |
| |
759 | 765 |
| |
760 |
| - | |
| 766 | + | |
761 | 767 |
| |
762 | 768 |
| |
763 | 769 |
| |
| |||
775 | 781 |
| |
776 | 782 |
| |
777 | 783 |
| |
778 |
| - | |
| 784 | + | |
779 | 785 |
| |
780 | 786 |
| |
781 | 787 |
| |
| |||
793 | 799 |
| |
794 | 800 |
| |
795 | 801 |
| |
796 |
| - | |
| 802 | + | |
797 | 803 |
| |
798 | 804 |
| |
799 | 805 |
| |
| |||
817 | 823 |
| |
818 | 824 |
| |
819 | 825 |
| |
820 |
| - | |
| 826 | + | |
821 | 827 |
| |
822 | 828 |
| |
823 | 829 |
| |
824 | 830 |
| |
825 | 831 |
| |
826 |
| - | |
| 832 | + | |
827 | 833 |
| |
828 | 834 |
| |
829 | 835 |
| |
| |||
835 | 841 |
| |
836 | 842 |
| |
837 | 843 |
| |
838 |
| - | |
| 844 | + | |
839 | 845 |
| |
840 | 846 |
| |
841 | 847 |
| |
| |||
883 | 889 |
| |
884 | 890 |
| |
885 | 891 |
| |
886 |
| - | |
| 892 | + | |
887 | 893 |
| |
888 | 894 |
| |
889 | 895 |
| |
890 | 896 |
| |
891 | 897 |
| |
892 |
| - | |
| 898 | + | |
893 | 899 |
| |
894 | 900 |
| |
895 | 901 |
| |
896 | 902 |
| |
897 | 903 |
| |
898 |
| - | |
| 904 | + | |
899 | 905 |
| |
900 | 906 |
| |
901 | 907 |
| |
902 | 908 |
| |
903 | 909 |
| |
904 |
| - | |
| 910 | + | |
905 | 911 |
| |
906 | 912 |
| |
907 | 913 |
| |
908 | 914 |
| |
909 | 915 |
| |
910 |
| - | |
| 916 | + | |
911 | 917 |
| |
912 | 918 |
| |
913 | 919 |
| |
| |||
937 | 943 |
| |
938 | 944 |
| |
939 | 945 |
| |
940 |
| - | |
| 946 | + | |
941 | 947 |
| |
942 | 948 |
| |
943 | 949 |
| |
944 | 950 |
| |
945 | 951 |
| |
946 |
| - | |
| 952 | + | |
947 | 953 |
| |
948 | 954 |
| |
949 | 955 |
| |
950 | 956 |
| |
951 | 957 |
| |
952 |
| - | |
| 958 | + | |
953 | 959 |
| |
954 | 960 |
| |
955 | 961 |
| |
| |||
961 | 967 |
| |
962 | 968 |
| |
963 | 969 |
| |
964 |
| - | |
| 970 | + | |
965 | 971 |
| |
966 | 972 |
| |
967 | 973 |
| |
| |||
988 | 994 |
| |
989 | 995 |
| |
990 | 996 |
| |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
991 | 1069 |
| |
992 | 1070 |
| |
993 | 1071 |
| |
|
0 commit comments
Comments
(0)