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.98.2) (envelope-from ) id 1xOXmx-00000000CWJ-2xrh for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Nov 2026 10:00:17 +0000 Received: from localhost ([127.0.0.1]:40294 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xOXmy-00000005YVx-0fee for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Nov 2026 10:00:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:53072) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xNuYu-00000004Sni-3jvQ for pgsql-bugs@lists.postgresql.org; Mon, 02 Nov 2026 16:07:09 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xNuYs-00000002Fx8-1dSC for pgsql-bugs@lists.postgresql.org; Mon, 02 Nov 2026 16:07:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=oYAi6zzObvsx5xTvbNNAXS/pXAoSM3dk9k5J3NiowIo=; b=Om/5VY7jCCOVF4PSf6TZlYNsl0 8/G0zxabeH0b3+yhfFPGiX9XSWuMRZVm07N/fi+2hn9ZQ2y9zueU8E0DYgQL+T6EaJv6msx7BZOdH o8mIHoubak76ddCgrO4/+m+6MlT70MKuisTh3ukgAs61x7Kbal2Oc+fWFlm8RiPDjBNSWwDsCFoK8 eWgEzIFxU925KVPB16XYa2HeUnzzoyUqqNwtLUPTsKUemRm6ebJ2l5+kIRizrVe8dB/GRFghQbk5A 8tNpRnULbM8w9cOZdJwJxx+qCcio+P0JjhXdn88K/IW6sQbw76j9nHd2j1eVdy+xYdHAMarytGFpX SeQuFVbg==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xNuYr-00000006Rn4-0y13 for pgsql-bugs@lists.postgresql.org; Mon, 02 Nov 2026 16:07:05 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xNuYp-0000000C4DY-09Ct for pgsql-bugs@lists.postgresql.org; Mon, 02 Nov 2026 16:07:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19828: "plan should not reference subplan's variable" with Memoize since f8da64e6 To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: venu2805k@gmail.com Reply-To: venu2805k@gmail.com, pgsql-bugs@lists.postgresql.org Date: Mon, 02 Nov 2026 16:06:24 +0000 Message-ID: <19828-7bbadfc4fcb8077a@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19828 Logged by: Venu Kummari Email address: venu2805k@gmail.com PostgreSQL version: 19rc1 Operating system: Ubuntu 24.04, x86_64 Description: =20 PostgreSQL version: master (20devel) 633dee1b, built from source with assertions. Operating system: Ubuntu 24.04, x86_64. Since commit f8da64e6 ("Make cache keys of other Params a Memoize subplan depends on"), a correlated ALL/ANY sublink in the quals of a memoized relation makes planning fail, with default settings: CREATE TABLE d_a (x int NOT NULL); CREATE TABLE d_b (x int, pad text); INSERT INTO d_a SELECT g % 10 FROM generate_series(1, 1000) g; INSERT INTO d_b SELECT g, repeat('x', 100) FROM generate_series(1, 100000) g; CREATE INDEX ON d_b (x); VACUUM ANALYZE d_a, d_b; SELECT count(*) FROM d_a a JOIN d_b b ON a.x =3D b.x WHERE 5 > ALL (SELECT b.x); ERROR: plan should not reference subplan's variable Expected: 400 (the result with enable_memoize =3D off, on 126976a8, and with f8da64e6 reverted). Cause: paraminfo_get_equal_hashops() now collects every PARAM_EXEC Param in the inner relation's base quals and targetlist with pull_exec_params_walker() and makes it a cache key. The walker descends into SubPlans, so the Param in the SubPlan's testexpr (5 > $n), which stands for the subplan's own output and is set by the subplan itself, also becomes a cache key. The Memoize node then references a Param that only its child sets, and finalize_plan() raises the error. I will reply with a patch that, for a SubPlan, walks only its args (which are evaluated in the memoized relation's context), with a regression test in memoize.sql; make check passes. Found with a grammar-based fuzzer for PostgreSQL.