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 1xLzaE-00000001nWy-2AqZ for pgsql-bugs@arkaria.postgresql.org; Wed, 28 Oct 2026 09:04:35 +0000 Received: from localhost ([127.0.0.1]:49214 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xLzaC-0000000EtO9-3r41 for pgsql-bugs@arkaria.postgresql.org; Wed, 28 Oct 2026 09:04:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]:49666) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xLzGS-0000000EmZB-0r5A for pgsql-bugs@lists.postgresql.org; Wed, 28 Oct 2026 08:44:08 +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 1xLzGQ-00000001Kip-1MXI for pgsql-bugs@lists.postgresql.org; Wed, 28 Oct 2026 08:44:07 +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=tNlFYu1gKI/k3Yw7v3vyvyx60EOP6YsS41CTnV4Jxy0=; b=0/OotSMJD1emfoK6Dgx8WDet+i y94rxsRMYaUjATXqkx//PftA6EtKZjm9U/MmrbBkT1dDyPP7a+D+4S+u0FV+t+awUhm4l+1GLiUh1 6mKWQ1uEY7hwDAY6EDQL25gqD9LUqgDuIcMQM3ASx5of+3OtpF451V9WBb+iTi7Wm3tDZyWgSCvj/ yBbSIpSjdCONyK1r3R/dv4hn2v5GaqEfMSmU49JhMTyEVDkiNarNZoCZxb3QO0dAVW/3zPHpU2aRd ktgyS55nh07BY0GyVX6X3JZvz1P+t8jWRRB9ABDphToq/qDmrJz6iUYq4rgsU37Tw+S4jnv3C71HN JL37Wm9w==; 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 1xLzGO-00000003qlD-0o9J for pgsql-bugs@lists.postgresql.org; Wed, 28 Oct 2026 08:44: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 1xLzGM-00000003wP8-0wO4 for pgsql-bugs@lists.postgresql.org; Wed, 28 Oct 2026 08:44:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19801: atan2d underflow causes equivalent queries to return different results To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: 2320415112@qq.com Reply-To: 2320415112@qq.com, pgsql-bugs@lists.postgresql.org Date: Wed, 28 Oct 2026 08:43:45 +0000 Message-ID: <19801-980bafdd39d7e3c5@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: 19801 Logged by: cl hl Email address: 2320415112@qq.com PostgreSQL version: 18.6 Operating system: Linux LAPTOP-2SQAVLB0 6.6.87.2-microsoft-standard- Description: =20 ## Description `atan2d('5e-324'::float8, 2::float8)` returns `0`, although the correctly rounded angle is the representable positive value `1.43e-322`. The FPMT oracle uses the function's monotonicity around zero: ```text y > 0 <=3D> atan2d(y, x) > atan2d(0, x) ``` Inputs are restricted to finite positive `y` and `0 < x <=3D 32`, ensuring = the correct angle remains positive after binary64 rounding. Replacing the first predicate with the second should preserve the result set, but the reproducer produces different row counts. ## How to repeat ### 1. Complete schema and input data Run the following statements in one PostgreSQL session. No extensions or existing application tables are required. ```sql CREATE TEMPORARY TABLE fpmt_atan2d_repro ( y DOUBLE PRECISION NOT NULL, x DOUBLE PRECISION NOT NULL ); INSERT INTO fpmt_atan2d_repro (y, x) VALUES ('5e-324'::float8, 2::float8); ``` ### 2. Original query Q1 ```sql WITH t(y, x) AS ( SELECT y, x FROM pg_temp.fpmt_atan2d_repro ) SELECT y, x FROM t WHERE y > 0; ``` Result: **1 row**, containing the inserted `(y, x)` pair. ### 3. Property-mutated query Q2 Keep the same input and projection, and replace the predicate using the function property: ```sql WITH t(y, x) AS ( SELECT y, x FROM pg_temp.fpmt_atan2d_repro ) SELECT y, x FROM t WHERE atan2d(y, x) > atan2d(0::float8, x); ``` Expected result: **the same 1 row as Q1**. With the observed PostgreSQL 18.6 function results, the predicate evaluates to `0 > 0`, and Q2 returns **0 rows**. ### 4. Self-contained query pair The same oracle can also be expressed entirely with `VALUES`, without creating a table: ```sql -- Original query: returns 1 row. WITH t(y, x) AS ( VALUES ('5e-324'::float8, 2::float8) ) SELECT y, x FROM t WHERE y > 0; ``` ```sql -- Property-mutated query: returns 0 rows with the observed PG 18.6 results. WITH t(y, x) AS ( VALUES ('5e-324'::float8, 2::float8) ) SELECT y, x FROM t WHERE atan2d(y, x) > atan2d(0::float8, x); ``` ### Oracle criterion Both queries should return identical result sets under the stated input constraints. A difference in their result sets, including their row counts, triggers the oracle: ```text Expected: result(Q1) =3D result(Q2) Q1: 1 row Q2: 0 rows Result: function-property violation. ```