Commit de0dc1a
committed
Fix cost_incremental_sort for expressions with varno 0
When estimating the number of pre-sorted groups in cost_incremental_sort
we must not pass Vars with varno 0 to estimate_num_groups, which would
cause failues in find_base_rel. This may happen when sorting output of
set operations, thanks to generate_append_tlist.
Unlike recurse_set_operations we can't easily access the original target
list, so if we find any Vars with varno 0, we fall back to the default
estimate DEFAULT_NUM_DISTINCT.
Reported-by: Justin Pryzby
Discussion: https://postgr.es/m/20200411214639.GK2228%40telsasoft.com1 parent 92c12e4 commit de0dc1a
File tree
3 files changed
+75
-3
lines changed- src
- backend/optimizer/path
- test/regress
- expected
- sql
3 files changed
+75
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1804 | 1804 | | |
1805 | 1805 | | |
1806 | 1806 | | |
| 1807 | + | |
1807 | 1808 | | |
1808 | 1809 | | |
1809 | 1810 | | |
| |||
1814 | 1815 | | |
1815 | 1816 | | |
1816 | 1817 | | |
1817 | | - | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
1818 | 1843 | | |
1819 | 1844 | | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
1820 | 1848 | | |
1821 | 1849 | | |
1822 | 1850 | | |
1823 | 1851 | | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
1824 | 1870 | | |
1825 | 1871 | | |
1826 | 1872 | | |
1827 | 1873 | | |
1828 | 1874 | | |
1829 | 1875 | | |
1830 | 1876 | | |
1831 | | - | |
1832 | | - | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
1833 | 1881 | | |
1834 | 1882 | | |
1835 | 1883 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1447 | 1447 | | |
1448 | 1448 | | |
1449 | 1449 | | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
1450 | 1470 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
219 | 223 | | |
0 commit comments