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 1wtnYm-000FuG-2F for pgsql-bugs@arkaria.postgresql.org; Tue, 11 Aug 2026 14:34:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wtnYk-002y1V-1u for pgsql-bugs@arkaria.postgresql.org; Tue, 11 Aug 2026 14:34:31 +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 1wtcKa-000oeI-1o for pgsql-bugs@lists.postgresql.org; Tue, 11 Aug 2026 02:35:09 +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 1wtcKY-0000000029S-2DY2 for pgsql-bugs@lists.postgresql.org; Tue, 11 Aug 2026 02:35: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=GtTclSO6io5EzVamez8wAwCxbY+aA51wwE7Fixw9TJI=; b=6SiC4McMMGWttbGQvRzZKTzJvz 8f8sBn8rjWuGlW3etUax9z8oQBEpm3u0jgqdmL+CTAfgfKXBIkgAB9WIEIfD5+QW6QFe0qeUQhX1M dZfhzk+n52a55iKWdHLLpe65SirA+xqJXTNxsdr5/y32wtyJ63TjjnN4eYa/IjGouglXKzmgUHato NyDbjBcwdO/+VMx06vM/IJeRea1YsUO91id3tBq2N+jhTBovW0iAqTZf5ew2n0Ei3Mfqd2sFV2rXZ hkMswejD+Y5fo7JJAtyTHEjWbdNHg+/iMPjXs38RiuO5lHCglm9rT4d+S6QIC5iWwlStvDwiW0qyT i1zabzNg==; 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 1wtcKX-0006qs-2f for pgsql-bugs@lists.postgresql.org; Tue, 11 Aug 2026 02:35: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 1wtcKV-00000000H5L-3YU2 for pgsql-bugs@lists.postgresql.org; Tue, 11 Aug 2026 02:35:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19615: COVAR_POP / COVAR_SAMP / REGR_SXY return 0.0 instead of NaN To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: feasiblechart@gmail.com Reply-To: feasiblechart@gmail.com, pgsql-bugs@lists.postgresql.org Date: Tue, 11 Aug 2026 02:34:38 +0000 Message-ID: <19615-c7e390593416f6b6@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: 19615 Logged by: Junwen An Email address: feasiblechart@gmail.com PostgreSQL version: 19beta2 Operating system: Linux Ubuntu Description: =20 I found `COVAR_POP`/`REGR_SXY` returns 0.0 instead of NaN when one arg is constant and the other has Inf (not first), which might be unexpected. I could reproduce it on 19beta1, 19beta2, and 20devel, but not on 18.4. Minimal repro: CREATE TABLE t (y double precision); INSERT INTO t VALUES (3), ('Infinity'), (4); SELECT COVAR_POP(0::float8, y) FROM t; -- Expected 1 row: NaN -- Actual: 0.0 SELECT COVAR_POP(y, 0::float8) FROM t; -- Expected 1 row: NaN -- Actual: 0.0 SELECT COVAR_SAMP(0::float8, y) FROM t; -- Expected 1 row: NaN -- Actual: 0.0 SELECT REGR_SXY(0::float8, y) FROM t; -- Expected 1 row: NaN -- Actual: 0.0 Did some further experiments, and it seems this behavior also depends on the position of 'Inf' WITH t(ord, y) AS ( VALUES (1, 'Infinity'::float8), (2, 3::float8), (3, 4::float8) ) SELECT covar_pop(0::float8, y ORDER BY ord) AS inf_first, covar_pop(0::float8, y ORDER BY ord DESC) AS inf_last FROM t; inf_first | inf_last -----------+---------- NaN | 0