forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit501b018
committed
Check equality semantics for unique indexes on partitioned tables.
We require the partition key to be a subset of the set of columnsbeing made unique, so that physically-separate indexes on the differentpartitions are sufficient to enforce the uniqueness constraint.The existing code checked that the listed columns appear, but did notinquire into the index semantics, which is a serious oversight giventhat different index opclasses might enforce completely differentnotions of uniqueness.Ideally, perhaps, we'd just match the partition key opfamily to theindex opfamily. But hash partitioning uses hash opfamilies which wecan't directly match to btree opfamilies. Hence, look up the equalityoperator in each family, and accept if it's the same operator. Thisshould be okay in a fairly general sense, since the equality operatorought to precisely represent the opfamily's notion of uniqueness.A remaining weak spot is that we don't have a cross-index-AM notion ofwhich opfamily member is "equality". But we know which one to use forhash and btree AMs, and those are the only two that are relevant hereat present. (Any non-core AMs that know how to enforce equality areout of luck, for now.)Back-patch to v11 where this feature was introduced.Guancheng Luo, revised a bit by meDiscussion:https://postgr.es/m/D9C3CEF7-04E8-47A1-8300-CA1DCD5ED40D@gmail.com1 parenta808186 commit501b018
1 file changed
+77
-25
lines changedLines changed: 77 additions & 25 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
871 | 871 |
| |
872 | 872 |
| |
873 | 873 |
| |
874 |
| - | |
875 |
| - | |
876 |
| - | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
877 | 877 |
| |
878 | 878 |
| |
879 | 879 |
| |
880 | 880 |
| |
881 | 881 |
| |
882 | 882 |
| |
883 | 883 |
| |
| 884 | + | |
884 | 885 |
| |
885 | 886 |
| |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
886 | 899 |
| |
887 |
| - | |
888 |
| - | |
889 |
| - | |
890 |
| - | |
891 |
| - | |
892 |
| - | |
893 |
| - | |
| 900 | + | |
| 901 | + | |
894 | 902 |
| |
895 | 903 |
| |
896 | 904 |
| |
897 | 905 |
| |
| 906 | + | |
| 907 | + | |
898 | 908 |
| |
899 |
| - | |
900 |
| - | |
901 |
| - | |
902 |
| - | |
903 |
| - | |
904 |
| - | |
905 |
| - | |
906 |
| - | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
907 | 918 |
| |
908 |
| - | |
909 |
| - | |
910 |
| - | |
911 |
| - | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
912 | 943 |
| |
913 | 944 |
| |
914 | 945 |
| |
| |||
922 | 953 |
| |
923 | 954 |
| |
924 | 955 |
| |
| 956 | + | |
925 | 957 |
| |
926 | 958 |
| |
927 | 959 |
| |
928 | 960 |
| |
929 |
| - | |
930 |
| - | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
931 | 981 |
| |
932 | 982 |
| |
| 983 | + | |
933 | 984 |
| |
934 | 985 |
| |
935 | 986 |
| |
936 | 987 |
| |
937 |
| - | |
| 988 | + | |
| 989 | + | |
938 | 990 |
| |
939 | 991 |
| |
940 | 992 |
| |
|
0 commit comments
Comments
(0)