pgsql: Check parallel safety in generate_useful_gather_paths

From: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Check parallel safety in generate_useful_gather_paths
Date: 2020-12-21 17:58:07
Message-ID: E1krPRf-0005IU-LC@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/86b7cca72d4d0a4e043fac0a2cdd56218ff2f258

Modified Files
--------------
src/backend/optimizer/path/allpaths.c | 13 +++++++--
src/backend/optimizer/path/equivclass.c | 9 +++++-
src/include/optimizer/paths.h | 5 +++-
src/test/regress/expected/incremental_sort.out | 40 ++++++++++++++++++++++++++
src/test/regress/sql/incremental_sort.sql | 11 +++++++
5 files changed, 73 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2020-12-21 18:12:22 pgsql: Remove "invalid concatenation of jsonb objects" error case.
Previous Message Tomas Vondra 2020-12-21 17:57:57 pgsql: Check parallel safety in generate_useful_gather_paths