pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix generate_partitionwise_join_paths() to tolerate failure.
Date: Sun, 04 Dec 2022 18:48:35 +0000
Message-ID: <E1p1u2U-001zz8-Bs@gemulon.postgresql.org> (raw)

Fix generate_partitionwise_join_paths() to tolerate failure.

We might fail to generate a partitionwise join, because
reparameterize_path_by_child() does not support all path types.
This should not be a hard failure condition: we should just fall back
to a non-partitioned join.  However, generate_partitionwise_join_paths
did not consider this possibility and would emit the (misleading)
error "could not devise a query plan for the given query" if we'd
failed to make any paths for a child join.  Fix it to give up on
partitionwise joining if so.  (The accepted technique for giving up
appears to be to set rel->nparts = 0, which I find pretty bizarre,
but there you have it.)

I have not added a test case because there'd be little point:
any omissions of this sort that we identify would soon get fixed
by extending reparameterize_path_by_child(), so the test would stop
proving anything.  However, right now there is a known test case based
on failure to cover MaterialPath, and with that I've found that this
is broken in all supported versions.  Hence, patch all the way back.

Original report and patch by me; thanks to Richard Guo for
identifying a test case that works against committed versions.

Discussion: https://postgr.es/m/1854233.1669949723@sss.pgh.pa.us

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bf8fd64ff5e65f8964d1b52c50019f0198ec5f5e

Modified Files
--------------
src/backend/optimizer/path/allpaths.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1p1u2U-001zz8-Bs@gemulon.postgresql.org>
Permalink:  ../E1p1u2U-001zz8-Bs@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1p1u2U-001zz8-Bs@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix generate_partitionwise_join_paths() to tolerate failure.
  In-Reply-To: <E1p1u2U-001zz8-Bs@gemulon.postgresql.org>
  References: <E1p1u2U-001zz8-Bs@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox