forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0ffc0ac

Richard Guo
Fix right-anti-joins when the inner relation is proven unique
For an inner_unique join, we always assume that the executor will stopscanning for matches after the first match. Therefore, for a mergejointhat is inner_unique and whose mergeclauses are sufficient to identify amatch, we set the skip_mark_restore flag to true, indicating that theexecutor need not do mark/restore calls. However, merge-right-anti-joindid not get this memo and continues scanning the inner side for matchesafter the first match. If there are duplicates in the outer scan, wemay incorrectly skip matching some inner tuples, which can lead to wrongresults.Here we fix this issue by ensuring that merge-right-anti-join alsoadvances to next outer tuple after the first match in inner_uniquecases. This also saves cycles by avoiding unnecessary scanning of innertuples after the first match.Although hash-right-anti-join does not suffer from this wrong resultsissue, we apply the same change to it as well, to help save cycles forthe same reason.Per bug #18522 from Antti Lampinen, and bug #18526 from Feliphe Pozzer.Back-patch to v16 where right-anti-join was introduced.Author: Richard GuoDiscussion:https://postgr.es/m/18522-c7a8956126afdfd0@postgresql.org1 parent74b8e6a commit0ffc0ac
File tree
4 files changed
+100
-20
lines changed- src
- backend/executor
- test/regress
- expected
- sql
4 files changed
+100
-20
lines changedLines changed: 11 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
573 | 573 |
| |
574 | 574 |
| |
575 | 575 |
| |
576 |
| - | |
577 |
| - | |
578 |
| - | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
579 | 579 |
| |
580 |
| - | |
581 |
| - | |
| 580 | + | |
| 581 | + | |
582 | 582 |
| |
583 | 583 |
| |
584 |
| - | |
585 |
| - | |
586 |
| - | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
587 | 588 |
| |
588 |
| - | |
589 |
| - | |
| 589 | + | |
| 590 | + | |
590 | 591 |
| |
591 | 592 |
| |
592 | 593 |
| |
|
Lines changed: 11 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
805 | 805 |
| |
806 | 806 |
| |
807 | 807 |
| |
808 |
| - | |
809 |
| - | |
810 |
| - | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
811 | 811 |
| |
812 |
| - | |
813 |
| - | |
| 812 | + | |
| 813 | + | |
814 | 814 |
| |
815 | 815 |
| |
816 |
| - | |
817 |
| - | |
818 |
| - | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
819 | 820 |
| |
820 |
| - | |
821 |
| - | |
| 821 | + | |
| 822 | + | |
822 | 823 |
| |
823 | 824 |
| |
824 | 825 |
| |
|
Lines changed: 54 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2924 | 2924 |
| |
2925 | 2925 |
| |
2926 | 2926 |
| |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
2927 | 2981 |
| |
2928 | 2982 |
| |
2929 | 2983 |
| |
|
Lines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
693 | 693 |
| |
694 | 694 |
| |
695 | 695 |
| |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
696 | 720 |
| |
697 | 721 |
| |
698 | 722 |
| |
|
0 commit comments
Comments
(0)