Check parallel safety in generate_useful_gather_paths
Tomas Vondra <tomas.vondra@postgresql.org>
Check parallel safety in generate_useful_gather_paths Commit ebb7ae839d ensured we ignore pathkeys with volatile expressions when considering adding a sort below a Gather Merge. Turns out we need to care about parallel safety of the pathkeys too, otherwise we might try sorting e.g. on results of a correlated subquery (as demonstrated by a report from Luis Roberto). Initial investigation by Tom Lane, patch by James Coleman. Backpatch to 13, where the code was instroduced (as part of Incremental Sort). Reported-by: Luis Roberto Author: James Coleman Reviewed-by: Tomas Vondra Backpatch-through: 13 Discussion: https://postgr.es/m/622580997.37108180.1604080457319.JavaMail.zimbra%40siscobra.com.br Discussion: https://postgr.es/m/CAAaqYe8cK3g5CfLC4w7bs=hC0mSksZC=H5M8LSchj5e5OxpTAg@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/path/allpaths.c | modified | +10 −3 |
| src/backend/optimizer/path/equivclass.c | modified | +8 −1 |
| src/include/optimizer/paths.h | modified | +4 −1 |
| src/test/regress/expected/incremental_sort.out | modified | +40 −0 |
| src/test/regress/sql/incremental_sort.sql | modified | +11 −0 |
Discussion
- segfault with incremental sort 23 messages · 2020-10-30 → 2020-12-01
- Fix generate_useful_gather_paths for parallel unsafe pathkeys 8 messages · 2020-11-21 → 2020-12-22