Fix cost_incremental_sort for expressions with varno 0
Tomas Vondra <tomas.vondra@postgresql.org>
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.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/path/costsize.c | modified | +51 −3 |
| src/test/regress/expected/incremental_sort.out | modified | +20 −0 |
| src/test/regress/sql/incremental_sort.sql | modified | +4 −0 |
Discussion
- Re: sqlsmith crash incremental sort 25 messages · 2020-04-11 → 2020-04-23