Commit 358eaa0
committed
Make entirely-dummy appendrels get marked as such in set_append_rel_size.
The planner generally expects that the estimated rowcount of any relation
is at least one row, *unless* it has been proven empty by constraint
exclusion or similar mechanisms, which is marked by installing a dummy path
as the rel's cheapest path (cf. IS_DUMMY_REL). When I split up
allpaths.c's processing of base rels into separate set_base_rel_sizes and
set_base_rel_pathlists steps, the intention was that dummy rels would get
marked as such during the "set size" step; this is what justifies an Assert
in indxpath.c's get_loop_count that other relations should either be dummy
or have positive rowcount. Unfortunately I didn't get that quite right
for append relations: if all the child rels have been proven empty then
set_append_rel_size would come up with a rowcount of zero, which is
correct, but it didn't then do set_dummy_rel_pathlist. (We would have
ended up with the right state after set_append_rel_pathlist, but that's
too late, if we generate indexpaths for some other rel first.)
In addition to fixing the actual bug, I installed an Assert enforcing this
convention in set_rel_size; that then allows simplification of a couple
of now-redundant tests for zero rowcount in set_append_rel_size.
Also, to cover the possibility that third-party FDWs have been careless
about not returning a zero rowcount estimate, apply clamp_row_est to
whatever an FDW comes up with as the rows estimate.
Per report from Andreas Seltenreich. Back-patch to 9.2. Earlier branches
did not have the separation between set_base_rel_sizes and
set_base_rel_pathlists steps, so there was no intermediate state where an
appendrel would have had inconsistent rowcount and pathlist. It's possible
that adding the Assert to set_rel_size would be a good idea in older
branches too; but since they're not under development any more, it's likely
not worth the trouble.1 parent 159cff5 commit 358eaa0
File tree
3 files changed
+94
-42
lines changed- src
- backend/optimizer/path
- test/regress
- expected
- sql
3 files changed
+94
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
363 | 368 | | |
364 | 369 | | |
365 | 370 | | |
| |||
579 | 584 | | |
580 | 585 | | |
581 | 586 | | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
582 | 590 | | |
583 | 591 | | |
584 | 592 | | |
| |||
608 | 616 | | |
609 | 617 | | |
610 | 618 | | |
| 619 | + | |
611 | 620 | | |
612 | 621 | | |
613 | 622 | | |
| |||
628 | 637 | | |
629 | 638 | | |
630 | 639 | | |
| 640 | + | |
631 | 641 | | |
632 | 642 | | |
633 | 643 | | |
| |||
755 | 765 | | |
756 | 766 | | |
757 | 767 | | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
758 | 771 | | |
759 | 772 | | |
760 | 773 | | |
761 | | - | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
762 | 789 | | |
763 | | - | |
764 | | - | |
| 790 | + | |
| 791 | + | |
765 | 792 | | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
| 793 | + | |
776 | 794 | | |
777 | | - | |
778 | | - | |
| 795 | + | |
| 796 | + | |
779 | 797 | | |
780 | | - | |
| 798 | + | |
| 799 | + | |
781 | 800 | | |
782 | | - | |
783 | | - | |
| 801 | + | |
784 | 802 | | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
| 803 | + | |
797 | 804 | | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
798 | 810 | | |
799 | 811 | | |
800 | 812 | | |
801 | 813 | | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
| 814 | + | |
807 | 815 | | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
808 | 819 | | |
809 | 820 | | |
| 821 | + | |
| 822 | + | |
810 | 823 | | |
811 | 824 | | |
812 | 825 | | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
813 | 832 | | |
814 | 833 | | |
815 | | - | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | | - | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
822 | 842 | | |
823 | 843 | | |
824 | 844 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2164 | 2164 | | |
2165 | 2165 | | |
2166 | 2166 | | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
2167 | 2187 | | |
2168 | 2188 | | |
2169 | 2189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
356 | 367 | | |
357 | 368 | | |
358 | 369 | | |
| |||
1120 | 1131 | | |
1121 | 1132 | | |
1122 | 1133 | | |
| 1134 | + | |
1123 | 1135 | | |
1124 | 1136 | | |
1125 | 1137 | | |
| |||
0 commit comments