- Notifications
You must be signed in to change notification settings - Fork28
Commit7f1921c
committed
Fix hash partition pruning with asymmetric partition sets.
perform_pruning_combine_step() was not taught about the number ofpartition indexes used in hash partitioning; more embarrassingly,get_matching_hash_bounds() also had it wrong. These errors are maskedin the common case where all the partitions have the same modulusand no partition is missing. However, with missing or unequal-sizepartitions, we could erroneously prune some partitions that needto be scanned, leading to silently wrong query answers.While a minimal-footprint fix for this could be to exportget_partition_bound_num_indexes and make the incorrect functions use it,I'm of the opinion that that function should never have existed in thefirst place. It's not reasonable data structure design thatPartitionBoundInfoData lacks any explicit record of the length ofits indexes[] array. Perhaps that was all right when it could alwaysbe assumed equal to ndatums, but something should have been done aboutit as soon as that stopped being true. Putting in an explicit"nindexes" field makes both partition_bounds_equal() andpartition_bounds_copy() simpler, safer, and faster than before,and removes explicit knowledge of the number-of-partition-indexesrules from some other places too.This change also makes get_hash_partition_greatest_modulus obsolete.I left that in place in case any external code uses it, but no corecode does anymore.Per bug #16840 from Michał Albrycht. Back-patch to v11 where thehash partitioning code came in. (In the back branches, add the newfield at the end of PartitionBoundInfoData to minimize ABI risks.)Discussion:https://postgr.es/m/16840-571a22976f829ad4@postgresql.org1 parent1449770 commit7f1921c
File tree
6 files changed
+124
-141
lines changed- src
- backend
- executor
- partitioning
- include/partitioning
- test/regress
- expected
- sql
6 files changed
+124
-141
lines changedLines changed: 1 addition & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1312 | 1312 |
| |
1313 | 1313 |
| |
1314 | 1314 |
| |
1315 |
| - | |
1316 | 1315 |
| |
1317 | 1316 |
| |
1318 |
| - | |
1319 | 1317 |
| |
1320 | 1318 |
| |
1321 | 1319 |
| |
1322 | 1320 |
| |
1323 | 1321 |
| |
1324 |
| - | |
| 1322 | + | |
1325 | 1323 |
| |
1326 | 1324 |
| |
1327 | 1325 |
| |
|
Lines changed: 31 additions & 84 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
224 | 224 |
| |
225 | 225 |
| |
226 | 226 |
| |
227 |
| - | |
228 | 227 |
| |
229 | 228 |
| |
230 | 229 |
| |
| |||
398 | 397 |
| |
399 | 398 |
| |
400 | 399 |
| |
| 400 | + | |
401 | 401 |
| |
402 | 402 |
| |
403 | 403 |
| |
| |||
530 | 530 |
| |
531 | 531 |
| |
532 | 532 |
| |
| 533 | + | |
533 | 534 |
| |
534 | 535 |
| |
535 | 536 |
| |
| |||
725 | 726 |
| |
726 | 727 |
| |
727 | 728 |
| |
728 |
| - | |
| 729 | + | |
729 | 730 |
| |
| 731 | + | |
730 | 732 |
| |
731 | 733 |
| |
732 | 734 |
| |
| |||
807 | 809 |
| |
808 | 810 |
| |
809 | 811 |
| |
| 812 | + | |
| 813 | + | |
| 814 | + | |
810 | 815 |
| |
811 | 816 |
| |
812 | 817 |
| |
813 | 818 |
| |
814 | 819 |
| |
815 | 820 |
| |
816 |
| - | |
| 821 | + | |
| 822 | + | |
817 | 823 |
| |
818 |
| - | |
819 |
| - | |
820 |
| - | |
821 |
| - | |
822 |
| - | |
823 |
| - | |
824 |
| - | |
| 824 | + | |
825 | 825 |
| |
| 826 | + | |
826 | 827 |
| |
| 828 | + | |
| 829 | + | |
| 830 | + | |
827 | 831 |
| |
828 | 832 |
| |
829 | 833 |
| |
830 | 834 |
| |
831 | 835 |
| |
832 | 836 |
| |
833 |
| - | |
834 |
| - | |
835 |
| - | |
836 |
| - | |
837 |
| - | |
838 |
| - | |
839 |
| - | |
840 |
| - | |
841 |
| - | |
842 |
| - | |
843 |
| - | |
844 |
| - | |
845 |
| - | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
846 | 843 |
| |
847 | 844 |
| |
848 | 845 |
| |
| 846 | + | |
849 | 847 |
| |
850 | 848 |
| |
851 | 849 |
| |
| |||
891 | 889 |
| |
892 | 890 |
| |
893 | 891 |
| |
894 |
| - | |
895 |
| - | |
896 |
| - | |
897 | 892 |
| |
898 |
| - | |
899 |
| - | |
900 |
| - | |
901 |
| - | |
902 |
| - | |
903 | 893 |
| |
904 | 894 |
| |
905 | 895 |
| |
| |||
920 | 910 |
| |
921 | 911 |
| |
922 | 912 |
| |
| 913 | + | |
923 | 914 |
| |
924 |
| - | |
925 | 915 |
| |
926 | 916 |
| |
927 | 917 |
| |
928 | 918 |
| |
929 | 919 |
| |
930 | 920 |
| |
931 | 921 |
| |
| 922 | + | |
932 | 923 |
| |
933 | 924 |
| |
934 |
| - | |
935 |
| - | |
936 | 925 |
| |
937 | 926 |
| |
938 | 927 |
| |
| |||
990 | 979 |
| |
991 | 980 |
| |
992 | 981 |
| |
993 |
| - | |
994 |
| - | |
| 982 | + | |
| 983 | + | |
995 | 984 |
| |
996 | 985 |
| |
997 | 986 |
| |
| |||
2456 | 2445 |
| |
2457 | 2446 |
| |
2458 | 2447 |
| |
| 2448 | + | |
2459 | 2449 |
| |
2460 | 2450 |
| |
2461 | 2451 |
| |
| |||
2889 | 2879 |
| |
2890 | 2880 |
| |
2891 | 2881 |
| |
2892 |
| - | |
| 2882 | + | |
2893 | 2883 |
| |
2894 | 2884 |
| |
2895 | 2885 |
| |
| |||
3254 | 3244 |
| |
3255 | 3245 |
| |
3256 | 3246 |
| |
3257 |
| - | |
3258 |
| - | |
3259 |
| - | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
3260 | 3250 |
| |
3261 | 3251 |
| |
3262 | 3252 |
| |
3263 | 3253 |
| |
3264 | 3254 |
| |
3265 |
| - | |
3266 |
| - | |
3267 |
| - | |
3268 |
| - | |
| 3255 | + | |
3269 | 3256 |
| |
3270 | 3257 |
| |
3271 | 3258 |
| |
| |||
3662 | 3649 |
| |
3663 | 3650 |
| |
3664 | 3651 |
| |
3665 |
| - | |
3666 |
| - | |
3667 |
| - | |
3668 |
| - | |
3669 |
| - | |
3670 |
| - | |
3671 |
| - | |
3672 |
| - | |
3673 |
| - | |
3674 |
| - | |
3675 |
| - | |
3676 |
| - | |
3677 |
| - | |
3678 |
| - | |
3679 |
| - | |
3680 |
| - | |
3681 |
| - | |
3682 |
| - | |
3683 |
| - | |
3684 |
| - | |
3685 |
| - | |
3686 |
| - | |
3687 |
| - | |
3688 |
| - | |
3689 |
| - | |
3690 |
| - | |
3691 |
| - | |
3692 |
| - | |
3693 |
| - | |
3694 |
| - | |
3695 |
| - | |
3696 |
| - | |
3697 |
| - | |
3698 |
| - | |
3699 |
| - | |
3700 |
| - | |
3701 |
| - | |
3702 |
| - | |
3703 |
| - | |
3704 |
| - | |
3705 | 3652 |
| |
3706 | 3653 |
| |
3707 | 3654 |
| |
|
Lines changed: 11 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
776 | 776 |
| |
777 | 777 |
| |
778 | 778 |
| |
779 |
| - | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
780 | 783 |
| |
781 | 784 |
| |
782 | 785 |
| |
| |||
2509 | 2512 |
| |
2510 | 2513 |
| |
2511 | 2514 |
| |
2512 |
| - | |
2513 | 2515 |
| |
2514 | 2516 |
| |
2515 | 2517 |
| |
| 2518 | + | |
2516 | 2519 |
| |
2517 | 2520 |
| |
2518 | 2521 |
| |
2519 | 2522 |
| |
2520 | 2523 |
| |
2521 | 2524 |
| |
2522 |
| - | |
2523 |
| - | |
| 2525 | + | |
2524 | 2526 |
| |
2525 |
| - | |
| 2527 | + | |
2526 | 2528 |
| |
2527 | 2529 |
| |
2528 | 2530 |
| |
| |||
3383 | 3385 |
| |
3384 | 3386 |
| |
3385 | 3387 |
| |
3386 |
| - | |
3387 |
| - | |
| 3388 | + | |
3388 | 3389 |
| |
| 3390 | + | |
3389 | 3391 |
| |
3390 | 3392 |
| |
3391 | 3393 |
| |
3392 | 3394 |
| |
3393 | 3395 |
| |
3394 |
| - | |
3395 |
| - | |
| 3396 | + | |
3396 | 3397 |
| |
3397 | 3398 |
| |
3398 |
| - | |
3399 |
| - | |
3400 |
| - | |
3401 |
| - | |
3402 |
| - | |
3403 |
| - | |
3404 |
| - | |
3405 |
| - | |
3406 |
| - | |
3407 | 3399 |
| |
3408 | 3400 |
| |
3409 |
| - | |
| 3401 | + | |
3410 | 3402 |
| |
3411 | 3403 |
| |
3412 | 3404 |
| |
|
Lines changed: 18 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
31 | 31 |
| |
32 | 32 |
| |
33 | 33 |
| |
34 |
| - | |
| 34 | + | |
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
| |||
47 | 47 |
| |
48 | 48 |
| |
49 | 49 |
| |
50 |
| - | |
51 |
| - | |
52 |
| - | |
53 |
| - | |
54 |
| - | |
55 |
| - | |
56 |
| - | |
57 |
| - | |
58 |
| - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
59 | 65 |
| |
60 | 66 |
| |
61 | 67 |
| |
62 | 68 |
| |
63 |
| - | |
| 69 | + | |
64 | 70 |
| |
65 | 71 |
| |
66 | 72 |
| |
| |||
70 | 76 |
| |
71 | 77 |
| |
72 | 78 |
| |
| 79 | + | |
73 | 80 |
| |
74 | 81 |
| |
75 | 82 |
| |
|
0 commit comments
Comments
(0)