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 <[email protected]> Reviewed-by: Matthias van de Meent <[email protected]> Reviewed-by: Tom Lane <[email protected]> Discussion: https://postgr.es/m/[email protected] 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(-)
