Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tveOt-006kpw-6w for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Mar 2025 15:35:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tveOr-009pKr-SZ for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Mar 2025 15:35:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tveOr-009pKj-K7 for pgsql-bugs@lists.postgresql.org; Fri, 21 Mar 2025 15:35:09 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tveOp-000LHD-1R for pgsql-bugs@lists.postgresql.org; Fri, 21 Mar 2025 15:35:09 +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 52LFZ3eE1563712; Fri, 21 Mar 2025 11:35:03 -0400 From: Tom Lane To: Andrei Lepikhov cc: splarv@ya.ru, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18859: ERROR: unexpected plan node type: 356 In-reply-to: References: <18859-0d5f28ac99a37059@postgresql.org> <72c3c1f4-9ed1-4d1c-ae67-eb04b8e50cd1@gmail.com> <1243263.1742562053@sss.pgh.pa.us> Comments: In-reply-to Andrei Lepikhov message dated "Fri, 21 Mar 2025 15:49:40 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1563710.1742571303.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 21 Mar 2025 11:35:03 -0400 Message-ID: <1563711.1742571303@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrei Lepikhov writes: > On 21/3/2025 14:00, Tom Lane wrote: >> Yeah, I'd just come to the same conclusion. I guess we can make >> this code look through a Material node as well as Gather. > Yes, as I see there are no additional corner cases. See the code in = > attachment. I think actually we want to use the same processing as for Gather, in particular the check for a Const. That's all about what setrefs.c will do to the plan tree, and it'll do the same things to Material as it would to Gather. Since that stanza doesn't actually do anything that's specific to Gather, the code change can be as simple as @@ -8323,7 +8325,7 @@ exec_save_simple_expr(PLpgSQL_expr *expr, CachedPlan= *cplan) ((Result *) plan)->resconstantqual =3D=3D NULL); break; } - else if (IsA(plan, Gather)) + else if (IsA(plan, Gather) || IsA(plan, Material)) { Assert(plan->lefttree !=3D NULL && plan->righttree =3D=3D NULL && I fixed that, did some cosmetic fooling with the comment and test case, and pushed it. Thanks for the report, and for the patch! regards, tom lane