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.96) (envelope-from ) id 1wdSc8-00477n-0D for pgsql-bugs@arkaria.postgresql.org; Sat, 27 Jun 2026 12:58:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wdSc7-00FLwI-06 for pgsql-bugs@arkaria.postgresql.org; Sat, 27 Jun 2026 12:58:27 +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.96) (envelope-from ) id 1wcOsc-001IZW-1G for pgsql-bugs@lists.postgresql.org; Wed, 24 Jun 2026 14:47:06 +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 1wcOsa-000000002Jb-1DGt for pgsql-bugs@lists.postgresql.org; Wed, 24 Jun 2026 14:47:05 +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=VXhr1V3yRDpbuLDLu7gKULeZ19b0jONrIbON6nnJkR8=; b=Ef7FNkO5sFzdlVKRRedwx2kty/ XeMrD2/SDsIy5CnPofOIB628nP0TYFz4p3vM56n8vHqMypxxXl5C45Y2QUFpGL7gZPTsUZ5RAiwZ0 rxG8eYmCn4HBGext4GpityBKAMU3LUVNioKPaxtxkWpQkcF5C723hHeOiZJHypNVlX5iVLHIayNFa 4saLjshqNMISfGpeBr4fVHcPYoipPQNboxCnVon+8SE0VCQhU7C9DCxauWWZU6sx8tdjpatHQndbn mktUxgR2WWl+KzQG9e9aVc5JWs5GSC96gpg/YUs0nH1+/PjRNOg5NE/bDeFXZUvpKTZXupSA4x5AW YLXQ8FDw==; 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 1wcOsZ-005uEO-0y for pgsql-bugs@lists.postgresql.org; Wed, 24 Jun 2026 14:47:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wcOsX-000Oyb-2W for pgsql-bugs@lists.postgresql.org; Wed, 24 Jun 2026 14:47:02 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19535: Splitting window input targets can break same-level SRF lockstep semantics To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: imchifan@163.com Reply-To: imchifan@163.com, pgsql-bugs@lists.postgresql.org Date: Wed, 24 Jun 2026 14:46:21 +0000 Message-ID: <19535-376081d7cc07c86d@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: 19535 Logged by: Qifan Liu Email address: imchifan@163.com PostgreSQL version: 18.4 Operating system: Ubuntu 20.04 x86-64, docker image postgres:18.4 Description: =20 ## PoC ```sql WITH source AS ( SELECT row_number() OVER ( PARTITION BY generate_series(1, 2) ORDER BY generate_series(1, 2) ) AS rn, generate_series(1, 2) AS g1, generate_series(11, 12) AS g2 ) SELECT * FROM source ORDER BY rn, g1, g2; WITH s AS ( SELECT generate_series(1, 2) AS g1, generate_series(11, 12) AS g2 ) SELECT 1::bigint AS rn, g1, g2 FROM s ORDER BY rn, g1, g2; EXPLAIN (COSTS OFF) WITH source AS ( SELECT row_number() OVER ( PARTITION BY generate_series(1, 2) ORDER BY generate_series(1, 2) ) AS rn, generate_series(1, 2) AS g1, generate_series(11, 12) AS g2 ) SELECT * FROM source ORDER BY rn, g1, g2; ``` ## Expected Behavior The two same-level SRFs should run in lockstep, yielding: ```text 1 | 1 | 11 1 | 2 | 12 ``` ## Actual Behavior The query returns four rows instead of two: ```text 1 | 1 | 11 1 | 1 | 12 1 | 2 | 11 1 | 2 | 12 ``` The plan shows one `ProjectSet` below `WindowAgg` and another above it, which breaks same-level SRF lockstep semantics.