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 1x8FtB-000000013zJ-1R1z for pgsql-bugs@arkaria.postgresql.org; Sun, 20 Sep 2026 11:39:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x8FtA-00000006PVu-0RNE for pgsql-bugs@arkaria.postgresql.org; Sun, 20 Sep 2026 11:39:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x8FnF-00000006PPB-0LIx for pgsql-bugs@lists.postgresql.org; Sun, 20 Sep 2026 11:33:13 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x8FnC-00000000K6A-2mYy for pgsql-bugs@lists.postgresql.org; Sun, 20 Sep 2026 11:33:12 +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=2I9T0pFYHsdLurkvY0DONJ/wnF8ofshWh9LmMjRkRGA=; b=inaBwg3shcai4WXx26gRij2/r6 KxuXl4V7ilHbY8V6Kce3N6R0mSEnbt3W4HGliwyDImz2HJSmJR5qcTmj/3lUe9UqIPBtzU4ICROSP etQxykjphyMjrbujO1cri19H2NPITbSN1MYSPCKCJAMii8+uvsXfGpMvFstzqwrnV2CEiL7N8ZTM+ YC9FdkERMORp/OmOiZYkYhmfVmAq4pxNeRCSKYyQX8Pvj2U/sKW12rUYs1sbKcm2bqv8wf+eeKCaI WNcawgA2lWjYZnJCdfsdf9cPW2G6LwH33wg9Okrn2PVJs+Jj2TOm83OCKkdKNcSEePlLlAsNoLiY/ khcu0HOA==; 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.96) (envelope-from ) id 1x8Fn6-000z0N-2c for pgsql-bugs@lists.postgresql.org; Sun, 20 Sep 2026 11:33:06 +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 1x8Fn5-00000002mZp-0SoC for pgsql-bugs@lists.postgresql.org; Sun, 20 Sep 2026 11:33:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19707: Reproduction of BUG #19553 on PostgreSQL 18.4: nested LEFT JOIN returns a constant instead of NULL To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: 1482694023@qq.com Reply-To: 1482694023@qq.com, pgsql-bugs@lists.postgresql.org Date: Sun, 20 Sep 2026 11:33:00 +0000 Message-ID: <19707-da66e5a04b617fd4@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: 19707 Logged by: N J Email address: 1482694023@qq.com PostgreSQL version: 18.4 Operating system: Windows 11 64-bit Description: =20 Environment: PostgreSQL: 18.4 Client: pgAdmin 4 Operating system: Windows 11 64-bit The following query returns a constant from the nullable side of a LEFT JOIN, although the corresponding subquery is guaranteed to be empty. Reproduction query: SELECT input_rows.sample_id, nullable_side.payload FROM (VALUES (11), (22)) AS input_rows(sample_id) LEFT JOIN ( SELECT payload FROM ( SELECT 37 AS payload FROM (SELECT WHERE FALSE) AS guaranteed_empty ) AS projected_empty LEFT JOIN ( SELECT 99 AS auxiliary_value ) AS one_row_helper ON TRUE ) AS nullable_side ON TRUE; Observed result on PostgreSQL 18.4: sample_id | payload -----------+--------- 11 | 37 22 | 37 Expected result: sample_id | payload -----------+--------- 11 | NULL 22 | NULL The guaranteed_empty subquery cannot produce any rows. Therefore, the right-hand side of the outer LEFT JOIN is empty and payload should be NULL-extended for both input rows. Instead, the constant value 37 is emitted for both rows. EXPLAIN (VERBOSE) may show that the right-hand side has been optimized away while the constant is retained in the output expression.