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 1xASOc-00000002ell-336d for pgsql-bugs@arkaria.postgresql.org; Sat, 26 Sep 2026 13:24:55 +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 1xASOb-00000004Nby-44x3 for pgsql-bugs@arkaria.postgresql.org; Sat, 26 Sep 2026 13:24:53 +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.98.2) (envelope-from ) id 1xAOCa-00000003sEm-3sMD for pgsql-bugs@lists.postgresql.org; Sat, 26 Sep 2026 08:56:12 +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 1xAOCW-00000001NCG-3qd1 for pgsql-bugs@lists.postgresql.org; Sat, 26 Sep 2026 08:56: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=oscCosb7e/4XsuPKWVDaR5a5KFDaRzyYhcW5rfPaiDA=; b=NsguX51Gdo++pxjllJsRjupHPd GTUazXKE29e6lsvcC19Dxjc3NprmVjgnDXZqszzsw83e1umOL2tdxddmT7M2W2za5sKSFQitgwHPY J9vDF9BJuGMU3g9Kq4B+1iG4xpoTdtz08rW2SVGuUKKhnLb8LcX+UwVYSRvwTDKTqSz3ZLFCwIf7a tyHnpgx/kCtydwHf2TTR1QbkWrwv/RgBhUNtEAiTclKh6w10cl0F62nQ4LjAAOo2XXxsXi7NBOTiM o6zYJVdEQnvxmHRs/cgBEwQUPeiOq4x82RpGEYio4gNhch8f7Fdz6Rt3xAheE3P5dPcNjtmaTbalI ii3ptd7g==; 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 1xAOCT-003whF-2m for pgsql-bugs@lists.postgresql.org; Sat, 26 Sep 2026 08:56:07 +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 1xAOCR-0000000BRWF-2sVT for pgsql-bugs@lists.postgresql.org; Sat, 26 Sep 2026 08:56:04 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19722: Window PARTITION BY numeric treats equal values with different scales as separate partitions 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: Sat, 26 Sep 2026 08:55:20 +0000 Message-ID: <19722-1b775eae8675c158@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: 19722 Logged by: N J Email address: 1482694023@qq.com PostgreSQL version: 18.6 Operating system: Windows 11 64-bit Description: =20 Environment: PostgreSQL: 18.6 OS: Windows 11 64-bit Reproduction SQL: CREATE TEMP TABLE decimal_source (raw_value text NOT NULL); INSERT INTO decimal_source VALUES ('1.0'), ('1.00'), ('1.000'); SELECT amount, partition_size FROM ( SELECT raw_value::numeric AS amount, COUNT(*) OVER (PARTITION BY raw_value::numeric) AS partition_size FROM decimal_source ) AS windowed WHERE scale(amount) =3D 1; Observed result: amount | partition_size --------+---------------- 1.0 | 1 Expected result: amount | partition_size --------+---------------- 1.0 | 3 Bug analysis: All three text values convert to numerically equal numeric values (1.0, 1.00, 1.000 all represent the same number). According to standard SQL semantics, PARTITION BY groups rows by value equality, so all three rows should belong to the same window partition and COUNT(*) OVER should return 3 for every row. The actual result shows partition_size =3D 1, which means values with different decimal scales are incorrectly treated as distinct partition keys. The window partition logic appears to use the internal representation (including scale metadata) instead of logical numeric equality to determine partition membership. This is a correctness bug: numerically equal values must be grouped into the same window partition regardless of their precision/scale.