From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix two edge cases in numeric log(base, val).
Date: Thu, 15 Oct 2026 15:25:29 +0000
Message-ID: <E1xHNKj-00000001kYj-46EO@gemulon.postgresql.org> (raw)
Fix two edge cases in numeric log(base, val).
For log(base, +Infinity) where 0 < base < 1, the correct output
is -Infinity, not +Infinity as we had been giving.
log(1, x) is erroneous regardless of x. Formerly we returned
+Infinity when x is +Infinity, and threw a rather confusing
"division by zero" error for finite-positive x. Change both
cases to report "cannot take logarithm using base one".
While the cases with infinite inputs are clearly wrong, it's
not clear that people would appreciate such a behavior change
in stable branches, so fix master only.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/08270B8B-634F-4381-9D6F-9BDB18DA82A0@gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/94e1385ed28509bee486aa0be40dea78b9e083c3
Modified Files
--------------
src/backend/utils/adt/numeric.c | 24 ++++++++++++++++++++++--
src/test/regress/expected/numeric.out | 10 +++++++++-
src/test/regress/sql/numeric.sql | 2 ++
3 files changed, 33 insertions(+), 3 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Fix two edge cases in numeric log(base, val).
In-Reply-To: <E1xHNKj-00000001kYj-46EO@gemulon.postgresql.org>
References: <E1xHNKj-00000001kYj-46EO@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox