Skip to content

Commit 0569392

Browse files
craig[bot]yuzefovich
andcommitted
Merge #148544
148544: builtins: fix decimal logarithm computation when base is infinite r=yuzefovich a=yuzefovich Previously, we would end up using `apd.Context.Quo` method with the infinity in the denominator, and it would result in a zero decimal that had `Clamped` flag set (with exponent being 2019). The result should just be regular zero, so we add a short-circuiting behavior (which matches PG). Fixes: #148255. Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
2 parents c821431 + 9735eaf commit 0569392

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pkg/sql/sem/builtins/math_builtins.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ var mathBuiltins = map[string]builtinDefinition{
307307
case 0:
308308
return nil, errLogOfZero
309309
}
310+
if isInf(b) {
311+
return &tree.DDecimal{Decimal: *decimalZero}, nil
312+
}
310313

311314
top := new(apd.Decimal)
312315
if _, err := tree.IntermediateCtx.Ln(top, x); err != nil {

pkg/sql/sem/eval/testdata/eval/infinity

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,8 @@ eval
239239
'Inf'::float::decimal
240240
----
241241
Infinity
242+
243+
eval
244+
log('Inf'::decimal, 1)
245+
----
246+
0

0 commit comments

Comments
 (0)