Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0wD2-0002rH-2o for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Dec 2022 02:55:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p0wD1-00032T-00 for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Dec 2022 02:55:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0wD0-00032B-NB for pgsql-hackers@lists.postgresql.org; Fri, 02 Dec 2022 02:55:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0wCy-0002Cf-6q for pgsql-hackers@lists.postgresql.org; Fri, 02 Dec 2022 02:55:25 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2B22tNC91854241 for ; Thu, 1 Dec 2022 21:55:23 -0500 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: Missing MaterialPath support in reparameterize_path_by_child MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <1853519.1669949457.0@sss.pgh.pa.us> Date: Thu, 01 Dec 2022 21:55:23 -0500 Message-ID: <1854233.1669949723@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1853519.1669949457.1@sss.pgh.pa.us> Whilst fooling with my outer-join-aware-Vars patch, I tripped across a multi-way join query that failed with ERROR: could not devise a query plan for the given query when enable_partitionwise_join is on. I traced that to the fact that reparameterize_path_by_child() omits support for MaterialPath, so that if the only surviving path(s) for a child join include materialization steps, we'll fail outright to produce a plan for the parent join. Unfortunately, I don't have an example that produces such a failure against HEAD. It seems certain to me that such cases exist, though, so I'd like to apply and back-patch the attached. I'm suspicious now that reparameterize_path() should be extended likewise, but I don't really have any hard evidence for that. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="fix-reparameterize_path_by_child.patch"; charset="us-ascii" Content-ID: <1853519.1669949457.2@sss.pgh.pa.us> Content-Description: fix-reparameterize_path_by_child.patch Content-Transfer-Encoding: quoted-printable commit f74ca5d8611af3306eb96719d5d1910c9b6a8db5 Author: Tom Lane Date: Thu Dec 1 21:04:49 2022 -0500 Add missing MaterialPath case in reparameterize_path_by_child. = Surprised we hadn't noticed this already. diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer= /util/pathnode.c index c77399ca92..224ba84107 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -4209,6 +4209,16 @@ do { \ } break; = + case T_MaterialPath: + { + MaterialPath *mpath; + + FLAT_COPY_PATH(mpath, path, MaterialPath); + REPARAMETERIZE_CHILD_PATH(mpath->subpath); + new_path =3D (Path *) mpath; + } + break; + case T_MemoizePath: { MemoizePath *mpath; ------- =_aaaaaaaaaa0--