From b59d6c639f7fa50a0ed54586187c9a5251c3ea40 Mon Sep 17 00:00:00 2001 From: Drew Kimball Date: Sat, 8 Jul 2023 00:52:56 -0600 Subject: [PATCH] sql: fix decimal evaluation edge cases Previously, the logic for decimal and float division, floor division and mod operators was incorrect for a few edge cases involving `NaN` or `Infinity` values. For example, `'NaN'::DECIMAL / 0` would throw a division-by-zero error when it should evaluate to `NaN` and `0/'inf'::DECIMAL` returned `0E-2019` instead of just `0`. This patch updates the special-case logic to mirror that of postgres, so division-by-zero errors always check the `NaN` case and the division by infinity case returns a `0` without extra digits. Fixes #40929 Fixes #103633 Release note (bug fix): Fixed edge cases in decimal and float evaluation for division operators. `'NaN'::DECIMAL / 0` will now return `NaN` instead of a division-by-zero error, and `0 / 'inf'::DECIMAL` will return `0` instead of `0E-2019`. --- pkg/cmd/roachtest/tests/sqlsmith.go | 3 - pkg/sql/colexec/colexecagg/hash_avg_agg.eg.go | 2 + pkg/sql/colexec/colexecagg/hash_sum_agg.eg.go | 2 + .../colexec/colexecagg/ordered_avg_agg.eg.go | 4 + .../colexec/colexecagg/ordered_sum_agg.eg.go | 4 + .../colexec/colexecagg/window_avg_agg.eg.go | 4 + .../colexec/colexecagg/window_sum_agg.eg.go | 4 + .../colexecproj/proj_non_const_ops.eg.go | 360 +++++++++++++++--- .../proj_const_left_ops.eg.go | 360 +++++++++++++++--- .../proj_const_right_ops.eg.go | 360 +++++++++++++++--- .../colexecwindow/range_offset_handler.eg.go | 8 + .../execgen/cmd/execgen/overloads_bin.go | 23 +- pkg/sql/logictest/testdata/logic_test/decimal | 127 +++--- pkg/sql/sem/eval/binary_op.go | 31 +- pkg/sql/sem/tree/datum.go | 15 +- 15 files changed, 1058 insertions(+), 249 deletions(-) diff --git a/pkg/cmd/roachtest/tests/sqlsmith.go b/pkg/cmd/roachtest/tests/sqlsmith.go index 515216228ce8..b11a043214f2 100644 --- a/pkg/cmd/roachtest/tests/sqlsmith.go +++ b/pkg/cmd/roachtest/tests/sqlsmith.go @@ -247,9 +247,6 @@ WITH into_db = 'defaultdb', unsafe_restore_incompatible_version; for _, exp := range []string{ // Optimizer panic-injection surfaces as an internal error. "injected panic in optimizer", - // TODO(yuzefovich): we temporarily ignore internal errors - // that are because of #40929. - "could not parse \"0E-2019\" as type decimal", } { expectedError = expectedError || strings.Contains(es, exp) } diff --git a/pkg/sql/colexec/colexecagg/hash_avg_agg.eg.go b/pkg/sql/colexec/colexecagg/hash_avg_agg.eg.go index 4440ef4be629..d8ef9eaaf36f 100644 --- a/pkg/sql/colexec/colexecagg/hash_avg_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/hash_avg_agg.eg.go @@ -447,6 +447,7 @@ func (a *avgDecimalHashAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.curCount++ @@ -466,6 +467,7 @@ func (a *avgDecimalHashAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.curCount++ diff --git a/pkg/sql/colexec/colexecagg/hash_sum_agg.eg.go b/pkg/sql/colexec/colexecagg/hash_sum_agg.eg.go index c286bb4a8c82..0ec3374a065b 100644 --- a/pkg/sql/colexec/colexecagg/hash_sum_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/hash_sum_agg.eg.go @@ -431,6 +431,7 @@ func (a *sumDecimalHashAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.numNonNull++ @@ -450,6 +451,7 @@ func (a *sumDecimalHashAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.numNonNull++ diff --git a/pkg/sql/colexec/colexecagg/ordered_avg_agg.eg.go b/pkg/sql/colexec/colexecagg/ordered_avg_agg.eg.go index 1f601dc1eeb1..802ca6a64caf 100644 --- a/pkg/sql/colexec/colexecagg/ordered_avg_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/ordered_avg_agg.eg.go @@ -913,6 +913,7 @@ func (a *avgDecimalOrderedAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.curCount++ @@ -954,6 +955,7 @@ func (a *avgDecimalOrderedAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.curCount++ @@ -996,6 +998,7 @@ func (a *avgDecimalOrderedAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.curCount++ @@ -1035,6 +1038,7 @@ func (a *avgDecimalOrderedAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.curCount++ diff --git a/pkg/sql/colexec/colexecagg/ordered_sum_agg.eg.go b/pkg/sql/colexec/colexecagg/ordered_sum_agg.eg.go index 7a5a2d539da9..18f1b36c4c6e 100644 --- a/pkg/sql/colexec/colexecagg/ordered_sum_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/ordered_sum_agg.eg.go @@ -852,6 +852,7 @@ func (a *sumDecimalOrderedAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.numNonNull++ @@ -889,6 +890,7 @@ func (a *sumDecimalOrderedAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.numNonNull++ @@ -928,6 +930,7 @@ func (a *sumDecimalOrderedAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.numNonNull++ @@ -963,6 +966,7 @@ func (a *sumDecimalOrderedAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.numNonNull++ diff --git a/pkg/sql/colexec/colexecagg/window_avg_agg.eg.go b/pkg/sql/colexec/colexecagg/window_avg_agg.eg.go index aafffe6e85ca..26efae4ae8f9 100644 --- a/pkg/sql/colexec/colexecagg/window_avg_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/window_avg_agg.eg.go @@ -617,6 +617,7 @@ func (a *avgDecimalWindowAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.curCount++ @@ -637,6 +638,7 @@ func (a *avgDecimalWindowAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.curCount++ @@ -713,6 +715,7 @@ func (a *avgDecimalWindowAgg) Remove(vecs []coldata.Vec, inputIdxs []uint32, sta if err != nil { colexecerror.ExpectedError(err) } + } a.curCount-- @@ -733,6 +736,7 @@ func (a *avgDecimalWindowAgg) Remove(vecs []coldata.Vec, inputIdxs []uint32, sta if err != nil { colexecerror.ExpectedError(err) } + } a.curCount-- diff --git a/pkg/sql/colexec/colexecagg/window_sum_agg.eg.go b/pkg/sql/colexec/colexecagg/window_sum_agg.eg.go index 4b3a7a809965..33f584086026 100644 --- a/pkg/sql/colexec/colexecagg/window_sum_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/window_sum_agg.eg.go @@ -607,6 +607,7 @@ func (a *sumDecimalWindowAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.numNonNull++ @@ -627,6 +628,7 @@ func (a *sumDecimalWindowAgg) Compute( if err != nil { colexecerror.ExpectedError(err) } + } a.numNonNull++ @@ -701,6 +703,7 @@ func (a *sumDecimalWindowAgg) Remove( if err != nil { colexecerror.ExpectedError(err) } + } a.numNonNull-- @@ -721,6 +724,7 @@ func (a *sumDecimalWindowAgg) Remove( if err != nil { colexecerror.ExpectedError(err) } + } a.numNonNull-- diff --git a/pkg/sql/colexec/colexecproj/proj_non_const_ops.eg.go b/pkg/sql/colexec/colexecproj/proj_non_const_ops.eg.go index 54249b5d2545..cf0a92614f91 100644 --- a/pkg/sql/colexec/colexecproj/proj_non_const_ops.eg.go +++ b/pkg/sql/colexec/colexecproj/proj_non_const_ops.eg.go @@ -3008,6 +3008,7 @@ func (p projPlusDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3031,6 +3032,7 @@ func (p projPlusDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3050,6 +3052,7 @@ func (p projPlusDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3069,6 +3072,7 @@ func (p projPlusDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3434,6 +3438,7 @@ func (p projPlusInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3459,6 +3464,7 @@ func (p projPlusInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3480,6 +3486,7 @@ func (p projPlusInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3501,6 +3508,7 @@ func (p projPlusInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3993,6 +4001,7 @@ func (p projPlusInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4018,6 +4027,7 @@ func (p projPlusInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4039,6 +4049,7 @@ func (p projPlusInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4060,6 +4071,7 @@ func (p projPlusInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4552,6 +4564,7 @@ func (p projPlusInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4577,6 +4590,7 @@ func (p projPlusInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4598,6 +4612,7 @@ func (p projPlusInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4619,6 +4634,7 @@ func (p projPlusInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6112,6 +6128,7 @@ func (p projMinusDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6135,6 +6152,7 @@ func (p projMinusDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6154,6 +6172,7 @@ func (p projMinusDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6173,6 +6192,7 @@ func (p projMinusDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6538,6 +6558,7 @@ func (p projMinusInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6563,6 +6584,7 @@ func (p projMinusInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6584,6 +6606,7 @@ func (p projMinusInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6605,6 +6628,7 @@ func (p projMinusInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7097,6 +7121,7 @@ func (p projMinusInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7122,6 +7147,7 @@ func (p projMinusInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7143,6 +7169,7 @@ func (p projMinusInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7164,6 +7191,7 @@ func (p projMinusInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7656,6 +7684,7 @@ func (p projMinusInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7681,6 +7710,7 @@ func (p projMinusInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7702,6 +7732,7 @@ func (p projMinusInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7723,6 +7754,7 @@ func (p projMinusInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9838,6 +9870,7 @@ func (p projMultDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9861,6 +9894,7 @@ func (p projMultDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9880,6 +9914,7 @@ func (p projMultDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9899,6 +9934,7 @@ func (p projMultDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10454,6 +10490,7 @@ func (p projMultInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10479,6 +10516,7 @@ func (p projMultInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10500,6 +10538,7 @@ func (p projMultInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10521,6 +10560,7 @@ func (p projMultInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -11056,6 +11096,7 @@ func (p projMultInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -11081,6 +11122,7 @@ func (p projMultInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -11102,6 +11144,7 @@ func (p projMultInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -11123,6 +11166,7 @@ func (p projMultInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -11658,6 +11702,7 @@ func (p projMultInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -11683,6 +11728,7 @@ func (p projMultInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -11704,6 +11750,7 @@ func (p projMultInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -11725,6 +11772,7 @@ func (p projMultInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -12398,7 +12446,7 @@ func (p projDivDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12426,7 +12474,7 @@ func (p projDivDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12450,7 +12498,7 @@ func (p projDivDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12474,7 +12522,7 @@ func (p projDivDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12524,7 +12572,7 @@ func (p projDivDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12552,7 +12600,7 @@ func (p projDivDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12576,7 +12624,7 @@ func (p projDivDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12600,7 +12648,7 @@ func (p projDivDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12650,7 +12698,7 @@ func (p projDivDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12678,7 +12726,7 @@ func (p projDivDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12702,7 +12750,7 @@ func (p projDivDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12726,7 +12774,7 @@ func (p projDivDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12776,7 +12824,7 @@ func (p projDivDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12784,6 +12832,11 @@ func (p projDivDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite && arg1.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -12803,7 +12856,7 @@ func (p projDivDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12811,6 +12864,11 @@ func (p projDivDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite && arg1.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -12826,7 +12884,7 @@ func (p projDivDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12834,6 +12892,11 @@ func (p projDivDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite && arg1.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -12849,7 +12912,7 @@ func (p projDivDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -12857,6 +12920,11 @@ func (p projDivDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite && arg1.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -13274,6 +13342,11 @@ func (p projDivInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13303,6 +13376,11 @@ func (p projDivInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13328,6 +13406,11 @@ func (p projDivInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13353,6 +13436,11 @@ func (p projDivInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13770,6 +13858,11 @@ func (p projDivInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13799,6 +13892,11 @@ func (p projDivInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13824,6 +13922,11 @@ func (p projDivInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13849,6 +13952,11 @@ func (p projDivInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14266,6 +14374,11 @@ func (p projDivInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14295,6 +14408,11 @@ func (p projDivInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14320,6 +14438,11 @@ func (p projDivInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14345,6 +14468,11 @@ func (p projDivInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14386,7 +14514,7 @@ func (p projDivFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14410,7 +14538,7 @@ func (p projDivFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14430,7 +14558,7 @@ func (p projDivFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14450,7 +14578,7 @@ func (p projDivFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14856,7 +14984,7 @@ func (p projFloorDivDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14884,7 +15012,7 @@ func (p projFloorDivDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14908,7 +15036,7 @@ func (p projFloorDivDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14932,7 +15060,7 @@ func (p projFloorDivDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14982,7 +15110,7 @@ func (p projFloorDivDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15010,7 +15138,7 @@ func (p projFloorDivDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15034,7 +15162,7 @@ func (p projFloorDivDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15058,7 +15186,7 @@ func (p projFloorDivDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15108,7 +15236,7 @@ func (p projFloorDivDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15136,7 +15264,7 @@ func (p projFloorDivDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15160,7 +15288,7 @@ func (p projFloorDivDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15184,7 +15312,7 @@ func (p projFloorDivDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15234,7 +15362,7 @@ func (p projFloorDivDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15242,6 +15370,11 @@ func (p projFloorDivDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite && arg1.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -15261,7 +15394,7 @@ func (p projFloorDivDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15269,6 +15402,11 @@ func (p projFloorDivDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite && arg1.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -15284,7 +15422,7 @@ func (p projFloorDivDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15292,6 +15430,11 @@ func (p projFloorDivDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite && arg1.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -15307,7 +15450,7 @@ func (p projFloorDivDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15315,6 +15458,11 @@ func (p projFloorDivDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite && arg1.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -15672,6 +15820,11 @@ func (p projFloorDivInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15701,6 +15854,11 @@ func (p projFloorDivInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15726,6 +15884,11 @@ func (p projFloorDivInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15751,6 +15914,11 @@ func (p projFloorDivInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -16108,6 +16276,11 @@ func (p projFloorDivInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -16137,6 +16310,11 @@ func (p projFloorDivInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -16162,6 +16340,11 @@ func (p projFloorDivInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -16187,6 +16370,11 @@ func (p projFloorDivInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -16544,6 +16732,11 @@ func (p projFloorDivInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -16573,6 +16766,11 @@ func (p projFloorDivInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -16598,6 +16796,11 @@ func (p projFloorDivInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -16623,6 +16826,11 @@ func (p projFloorDivInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg2.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -16664,7 +16872,7 @@ func (p projFloorDivFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -16688,7 +16896,7 @@ func (p projFloorDivFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -16708,7 +16916,7 @@ func (p projFloorDivFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -16728,7 +16936,7 @@ func (p projFloorDivFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -16774,7 +16982,7 @@ func (p projModDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -16802,7 +17010,7 @@ func (p projModDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -16826,7 +17034,7 @@ func (p projModDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -16850,7 +17058,7 @@ func (p projModDecimalInt16Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -16900,7 +17108,7 @@ func (p projModDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -16928,7 +17136,7 @@ func (p projModDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -16952,7 +17160,7 @@ func (p projModDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -16976,7 +17184,7 @@ func (p projModDecimalInt32Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17026,7 +17234,7 @@ func (p projModDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17054,7 +17262,7 @@ func (p projModDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17078,7 +17286,7 @@ func (p projModDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17102,7 +17310,7 @@ func (p projModDecimalInt64Op) Next() coldata.Batch { { - if arg2 == 0 { + if arg2 == 0 && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17152,7 +17360,7 @@ func (p projModDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17160,6 +17368,7 @@ func (p projModDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17179,7 +17388,7 @@ func (p projModDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17187,6 +17396,7 @@ func (p projModDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17202,7 +17412,7 @@ func (p projModDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17210,6 +17420,7 @@ func (p projModDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17225,7 +17436,7 @@ func (p projModDecimalDecimalOp) Next() coldata.Batch { { - if arg2.IsZero() { + if arg2.IsZero() && arg1.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17233,6 +17444,7 @@ func (p projModDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17590,6 +17802,7 @@ func (p projModInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17619,6 +17832,7 @@ func (p projModInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17644,6 +17858,7 @@ func (p projModInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17669,6 +17884,7 @@ func (p projModInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18026,6 +18242,7 @@ func (p projModInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18055,6 +18272,7 @@ func (p projModInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18080,6 +18298,7 @@ func (p projModInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18105,6 +18324,7 @@ func (p projModInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18462,6 +18682,7 @@ func (p projModInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18491,6 +18712,7 @@ func (p projModInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18516,6 +18738,7 @@ func (p projModInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18541,6 +18764,7 @@ func (p projModInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18582,7 +18806,7 @@ func (p projModFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -18606,7 +18830,7 @@ func (p projModFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -18626,7 +18850,7 @@ func (p projModFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -18646,7 +18870,7 @@ func (p projModFloat64Float64Op) Next() coldata.Batch { { - if arg2 == 0.0 { + if arg2 == 0.0 && !math.IsNaN(arg1) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -19026,6 +19250,7 @@ func (p projPowDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19049,6 +19274,7 @@ func (p projPowDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19068,6 +19294,7 @@ func (p projPowDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19087,6 +19314,7 @@ func (p projPowDecimalDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19524,6 +19752,7 @@ func (p projPowInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19549,6 +19778,7 @@ func (p projPowInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19570,6 +19800,7 @@ func (p projPowInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19591,6 +19822,7 @@ func (p projPowInt16DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -20028,6 +20260,7 @@ func (p projPowInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -20053,6 +20286,7 @@ func (p projPowInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -20074,6 +20308,7 @@ func (p projPowInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -20095,6 +20330,7 @@ func (p projPowInt32DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -20532,6 +20768,7 @@ func (p projPowInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -20557,6 +20794,7 @@ func (p projPowInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -20578,6 +20816,7 @@ func (p projPowInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -20599,6 +20838,7 @@ func (p projPowInt64DecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } diff --git a/pkg/sql/colexec/colexecprojconst/proj_const_left_ops.eg.go b/pkg/sql/colexec/colexecprojconst/proj_const_left_ops.eg.go index f3e8a408d688..10f25d9c12a6 100644 --- a/pkg/sql/colexec/colexecprojconst/proj_const_left_ops.eg.go +++ b/pkg/sql/colexec/colexecprojconst/proj_const_left_ops.eg.go @@ -2721,6 +2721,7 @@ func (p projPlusDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -2740,6 +2741,7 @@ func (p projPlusDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -2758,6 +2760,7 @@ func (p projPlusDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -2774,6 +2777,7 @@ func (p projPlusDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3115,6 +3119,7 @@ func (p projPlusInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3136,6 +3141,7 @@ func (p projPlusInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3156,6 +3162,7 @@ func (p projPlusInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3174,6 +3181,7 @@ func (p projPlusInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3636,6 +3644,7 @@ func (p projPlusInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3657,6 +3666,7 @@ func (p projPlusInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3677,6 +3687,7 @@ func (p projPlusInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3695,6 +3706,7 @@ func (p projPlusInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4157,6 +4169,7 @@ func (p projPlusInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4178,6 +4191,7 @@ func (p projPlusInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4198,6 +4212,7 @@ func (p projPlusInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4216,6 +4231,7 @@ func (p projPlusInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -5609,6 +5625,7 @@ func (p projMinusDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -5628,6 +5645,7 @@ func (p projMinusDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -5646,6 +5664,7 @@ func (p projMinusDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -5662,6 +5681,7 @@ func (p projMinusDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6003,6 +6023,7 @@ func (p projMinusInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6024,6 +6045,7 @@ func (p projMinusInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6044,6 +6066,7 @@ func (p projMinusInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6062,6 +6085,7 @@ func (p projMinusInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6524,6 +6548,7 @@ func (p projMinusInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6545,6 +6570,7 @@ func (p projMinusInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6565,6 +6591,7 @@ func (p projMinusInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6583,6 +6610,7 @@ func (p projMinusInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7045,6 +7073,7 @@ func (p projMinusInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7066,6 +7095,7 @@ func (p projMinusInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7086,6 +7116,7 @@ func (p projMinusInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7104,6 +7135,7 @@ func (p projMinusInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9071,6 +9103,7 @@ func (p projMultDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9090,6 +9123,7 @@ func (p projMultDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9108,6 +9142,7 @@ func (p projMultDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9124,6 +9159,7 @@ func (p projMultDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9647,6 +9683,7 @@ func (p projMultInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9668,6 +9705,7 @@ func (p projMultInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9688,6 +9726,7 @@ func (p projMultInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9706,6 +9745,7 @@ func (p projMultInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10209,6 +10249,7 @@ func (p projMultInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10230,6 +10271,7 @@ func (p projMultInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10250,6 +10292,7 @@ func (p projMultInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10268,6 +10311,7 @@ func (p projMultInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10771,6 +10815,7 @@ func (p projMultInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10792,6 +10837,7 @@ func (p projMultInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10812,6 +10858,7 @@ func (p projMultInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10830,6 +10877,7 @@ func (p projMultInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -11439,7 +11487,7 @@ func (p projDivDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11463,7 +11511,7 @@ func (p projDivDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11486,7 +11534,7 @@ func (p projDivDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11507,7 +11555,7 @@ func (p projDivDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11557,7 +11605,7 @@ func (p projDivDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11581,7 +11629,7 @@ func (p projDivDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11604,7 +11652,7 @@ func (p projDivDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11625,7 +11673,7 @@ func (p projDivDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11675,7 +11723,7 @@ func (p projDivDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11699,7 +11747,7 @@ func (p projDivDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11722,7 +11770,7 @@ func (p projDivDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11743,7 +11791,7 @@ func (p projDivDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11793,7 +11841,7 @@ func (p projDivDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11801,6 +11849,11 @@ func (p projDivDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite && p.constArg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -11816,7 +11869,7 @@ func (p projDivDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11824,6 +11877,11 @@ func (p projDivDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite && p.constArg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -11838,7 +11896,7 @@ func (p projDivDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11846,6 +11904,11 @@ func (p projDivDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite && p.constArg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -11858,7 +11921,7 @@ func (p projDivDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11866,6 +11929,11 @@ func (p projDivDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite && p.constArg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -12259,6 +12327,11 @@ func (p projDivInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12284,6 +12357,11 @@ func (p projDivInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12308,6 +12386,11 @@ func (p projDivInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12330,6 +12413,11 @@ func (p projDivInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12723,6 +12811,11 @@ func (p projDivInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12748,6 +12841,11 @@ func (p projDivInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12772,6 +12870,11 @@ func (p projDivInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12794,6 +12897,11 @@ func (p projDivInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13187,6 +13295,11 @@ func (p projDivInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13212,6 +13325,11 @@ func (p projDivInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13236,6 +13354,11 @@ func (p projDivInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13258,6 +13381,11 @@ func (p projDivInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13299,7 +13427,7 @@ func (p projDivFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13319,7 +13447,7 @@ func (p projDivFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13338,7 +13466,7 @@ func (p projDivFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13355,7 +13483,7 @@ func (p projDivFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13729,7 +13857,7 @@ func (p projFloorDivDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13753,7 +13881,7 @@ func (p projFloorDivDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13776,7 +13904,7 @@ func (p projFloorDivDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13797,7 +13925,7 @@ func (p projFloorDivDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13847,7 +13975,7 @@ func (p projFloorDivDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13871,7 +13999,7 @@ func (p projFloorDivDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13894,7 +14022,7 @@ func (p projFloorDivDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13915,7 +14043,7 @@ func (p projFloorDivDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13965,7 +14093,7 @@ func (p projFloorDivDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13989,7 +14117,7 @@ func (p projFloorDivDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14012,7 +14140,7 @@ func (p projFloorDivDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14033,7 +14161,7 @@ func (p projFloorDivDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14083,7 +14211,7 @@ func (p projFloorDivDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14091,6 +14219,11 @@ func (p projFloorDivDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite && p.constArg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -14106,7 +14239,7 @@ func (p projFloorDivDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14114,6 +14247,11 @@ func (p projFloorDivDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite && p.constArg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -14128,7 +14266,7 @@ func (p projFloorDivDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14136,6 +14274,11 @@ func (p projFloorDivDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite && p.constArg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -14148,7 +14291,7 @@ func (p projFloorDivDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14156,6 +14299,11 @@ func (p projFloorDivDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite && p.constArg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -14489,6 +14637,11 @@ func (p projFloorDivInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14514,6 +14667,11 @@ func (p projFloorDivInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14538,6 +14696,11 @@ func (p projFloorDivInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14560,6 +14723,11 @@ func (p projFloorDivInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14893,6 +15061,11 @@ func (p projFloorDivInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14918,6 +15091,11 @@ func (p projFloorDivInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14942,6 +15120,11 @@ func (p projFloorDivInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14964,6 +15147,11 @@ func (p projFloorDivInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15297,6 +15485,11 @@ func (p projFloorDivInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15322,6 +15515,11 @@ func (p projFloorDivInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15346,6 +15544,11 @@ func (p projFloorDivInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15368,6 +15571,11 @@ func (p projFloorDivInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if arg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15409,7 +15617,7 @@ func (p projFloorDivFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15429,7 +15637,7 @@ func (p projFloorDivFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15448,7 +15656,7 @@ func (p projFloorDivFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15465,7 +15673,7 @@ func (p projFloorDivFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15511,7 +15719,7 @@ func (p projModDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15535,7 +15743,7 @@ func (p projModDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15558,7 +15766,7 @@ func (p projModDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15579,7 +15787,7 @@ func (p projModDecimalConstInt16Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15629,7 +15837,7 @@ func (p projModDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15653,7 +15861,7 @@ func (p projModDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15676,7 +15884,7 @@ func (p projModDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15697,7 +15905,7 @@ func (p projModDecimalConstInt32Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15747,7 +15955,7 @@ func (p projModDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15771,7 +15979,7 @@ func (p projModDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15794,7 +16002,7 @@ func (p projModDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15815,7 +16023,7 @@ func (p projModDecimalConstInt64Op) Next() coldata.Batch { { - if arg == 0 { + if arg == 0 && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15865,7 +16073,7 @@ func (p projModDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15873,6 +16081,7 @@ func (p projModDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -15888,7 +16097,7 @@ func (p projModDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15896,6 +16105,7 @@ func (p projModDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -15910,7 +16120,7 @@ func (p projModDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15918,6 +16128,7 @@ func (p projModDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -15930,7 +16141,7 @@ func (p projModDecimalConstDecimalOp) Next() coldata.Batch { { - if arg.IsZero() { + if arg.IsZero() && p.constArg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15938,6 +16149,7 @@ func (p projModDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16271,6 +16483,7 @@ func (p projModInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16296,6 +16509,7 @@ func (p projModInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16320,6 +16534,7 @@ func (p projModInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16342,6 +16557,7 @@ func (p projModInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16675,6 +16891,7 @@ func (p projModInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16700,6 +16917,7 @@ func (p projModInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16724,6 +16942,7 @@ func (p projModInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16746,6 +16965,7 @@ func (p projModInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17079,6 +17299,7 @@ func (p projModInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17104,6 +17325,7 @@ func (p projModInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17128,6 +17350,7 @@ func (p projModInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17150,6 +17373,7 @@ func (p projModInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17191,7 +17415,7 @@ func (p projModFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17211,7 +17435,7 @@ func (p projModFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17230,7 +17454,7 @@ func (p projModFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17247,7 +17471,7 @@ func (p projModFloat64ConstFloat64Op) Next() coldata.Batch { { - if arg == 0.0 { + if arg == 0.0 && !math.IsNaN(p.constArg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17603,6 +17827,7 @@ func (p projPowDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17622,6 +17847,7 @@ func (p projPowDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17640,6 +17866,7 @@ func (p projPowDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17656,6 +17883,7 @@ func (p projPowDecimalConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18069,6 +18297,7 @@ func (p projPowInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18090,6 +18319,7 @@ func (p projPowInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18110,6 +18340,7 @@ func (p projPowInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18128,6 +18359,7 @@ func (p projPowInt16ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18541,6 +18773,7 @@ func (p projPowInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18562,6 +18795,7 @@ func (p projPowInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18582,6 +18816,7 @@ func (p projPowInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18600,6 +18835,7 @@ func (p projPowInt32ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19013,6 +19249,7 @@ func (p projPowInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19034,6 +19271,7 @@ func (p projPowInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19054,6 +19292,7 @@ func (p projPowInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19072,6 +19311,7 @@ func (p projPowInt64ConstDecimalOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } diff --git a/pkg/sql/colexec/colexecprojconst/proj_const_right_ops.eg.go b/pkg/sql/colexec/colexecprojconst/proj_const_right_ops.eg.go index 04012e174f75..95ac73ded8c9 100644 --- a/pkg/sql/colexec/colexecprojconst/proj_const_right_ops.eg.go +++ b/pkg/sql/colexec/colexecprojconst/proj_const_right_ops.eg.go @@ -2724,6 +2724,7 @@ func (p projPlusDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -2743,6 +2744,7 @@ func (p projPlusDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -2761,6 +2763,7 @@ func (p projPlusDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -2777,6 +2780,7 @@ func (p projPlusDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3118,6 +3122,7 @@ func (p projPlusInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3139,6 +3144,7 @@ func (p projPlusInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3159,6 +3165,7 @@ func (p projPlusInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3177,6 +3184,7 @@ func (p projPlusInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3637,6 +3645,7 @@ func (p projPlusInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3658,6 +3667,7 @@ func (p projPlusInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3678,6 +3688,7 @@ func (p projPlusInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -3696,6 +3707,7 @@ func (p projPlusInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4156,6 +4168,7 @@ func (p projPlusInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4177,6 +4190,7 @@ func (p projPlusInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4197,6 +4211,7 @@ func (p projPlusInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -4215,6 +4230,7 @@ func (p projPlusInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -5612,6 +5628,7 @@ func (p projMinusDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -5631,6 +5648,7 @@ func (p projMinusDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -5649,6 +5667,7 @@ func (p projMinusDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -5665,6 +5684,7 @@ func (p projMinusDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6006,6 +6026,7 @@ func (p projMinusInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6027,6 +6048,7 @@ func (p projMinusInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6047,6 +6069,7 @@ func (p projMinusInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6065,6 +6088,7 @@ func (p projMinusInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6525,6 +6549,7 @@ func (p projMinusInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6546,6 +6571,7 @@ func (p projMinusInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6566,6 +6592,7 @@ func (p projMinusInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -6584,6 +6611,7 @@ func (p projMinusInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7044,6 +7072,7 @@ func (p projMinusInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7065,6 +7094,7 @@ func (p projMinusInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7085,6 +7115,7 @@ func (p projMinusInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -7103,6 +7134,7 @@ func (p projMinusInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9080,6 +9112,7 @@ func (p projMultDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9099,6 +9132,7 @@ func (p projMultDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9117,6 +9151,7 @@ func (p projMultDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9133,6 +9168,7 @@ func (p projMultDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9656,6 +9692,7 @@ func (p projMultInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9677,6 +9714,7 @@ func (p projMultInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9697,6 +9735,7 @@ func (p projMultInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -9715,6 +9754,7 @@ func (p projMultInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10218,6 +10258,7 @@ func (p projMultInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10239,6 +10280,7 @@ func (p projMultInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10259,6 +10301,7 @@ func (p projMultInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10277,6 +10320,7 @@ func (p projMultInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10780,6 +10824,7 @@ func (p projMultInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10801,6 +10846,7 @@ func (p projMultInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10821,6 +10867,7 @@ func (p projMultInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -10839,6 +10886,7 @@ func (p projMultInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -11448,7 +11496,7 @@ func (p projDivDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11472,7 +11520,7 @@ func (p projDivDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11495,7 +11543,7 @@ func (p projDivDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11516,7 +11564,7 @@ func (p projDivDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11566,7 +11614,7 @@ func (p projDivDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11590,7 +11638,7 @@ func (p projDivDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11613,7 +11661,7 @@ func (p projDivDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11634,7 +11682,7 @@ func (p projDivDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11684,7 +11732,7 @@ func (p projDivDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11708,7 +11756,7 @@ func (p projDivDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11731,7 +11779,7 @@ func (p projDivDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11752,7 +11800,7 @@ func (p projDivDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11802,7 +11850,7 @@ func (p projDivDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11810,6 +11858,11 @@ func (p projDivDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite && arg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -11825,7 +11878,7 @@ func (p projDivDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11833,6 +11886,11 @@ func (p projDivDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite && arg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -11847,7 +11905,7 @@ func (p projDivDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11855,6 +11913,11 @@ func (p projDivDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite && arg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -11867,7 +11930,7 @@ func (p projDivDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -11875,6 +11938,11 @@ func (p projDivDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite && arg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -12268,6 +12336,11 @@ func (p projDivInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12293,6 +12366,11 @@ func (p projDivInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12317,6 +12395,11 @@ func (p projDivInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12339,6 +12422,11 @@ func (p projDivInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12732,6 +12820,11 @@ func (p projDivInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12757,6 +12850,11 @@ func (p projDivInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12781,6 +12879,11 @@ func (p projDivInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -12803,6 +12906,11 @@ func (p projDivInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13196,6 +13304,11 @@ func (p projDivInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13221,6 +13334,11 @@ func (p projDivInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13245,6 +13363,11 @@ func (p projDivInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13267,6 +13390,11 @@ func (p projDivInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -13308,7 +13436,7 @@ func (p projDivFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13328,7 +13456,7 @@ func (p projDivFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13347,7 +13475,7 @@ func (p projDivFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13364,7 +13492,7 @@ func (p projDivFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13738,7 +13866,7 @@ func (p projFloorDivDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13762,7 +13890,7 @@ func (p projFloorDivDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13785,7 +13913,7 @@ func (p projFloorDivDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13806,7 +13934,7 @@ func (p projFloorDivDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13856,7 +13984,7 @@ func (p projFloorDivDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13880,7 +14008,7 @@ func (p projFloorDivDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13903,7 +14031,7 @@ func (p projFloorDivDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13924,7 +14052,7 @@ func (p projFloorDivDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13974,7 +14102,7 @@ func (p projFloorDivDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -13998,7 +14126,7 @@ func (p projFloorDivDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14021,7 +14149,7 @@ func (p projFloorDivDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14042,7 +14170,7 @@ func (p projFloorDivDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14092,7 +14220,7 @@ func (p projFloorDivDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14100,6 +14228,11 @@ func (p projFloorDivDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite && arg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -14115,7 +14248,7 @@ func (p projFloorDivDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14123,6 +14256,11 @@ func (p projFloorDivDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite && arg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -14137,7 +14275,7 @@ func (p projFloorDivDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14145,6 +14283,11 @@ func (p projFloorDivDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite && arg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -14157,7 +14300,7 @@ func (p projFloorDivDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -14165,6 +14308,11 @@ func (p projFloorDivDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite && arg.Form == apd.Finite { + projCol[i] = apd.Decimal{} + } + } } @@ -14498,6 +14646,11 @@ func (p projFloorDivInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14523,6 +14676,11 @@ func (p projFloorDivInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14547,6 +14705,11 @@ func (p projFloorDivInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14569,6 +14732,11 @@ func (p projFloorDivInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14902,6 +15070,11 @@ func (p projFloorDivInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14927,6 +15100,11 @@ func (p projFloorDivInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14951,6 +15129,11 @@ func (p projFloorDivInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -14973,6 +15156,11 @@ func (p projFloorDivInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15306,6 +15494,11 @@ func (p projFloorDivInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15331,6 +15524,11 @@ func (p projFloorDivInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15355,6 +15553,11 @@ func (p projFloorDivInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15377,6 +15580,11 @@ func (p projFloorDivInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + + if p.constArg.Form == apd.Infinite { + projCol[i] = apd.Decimal{} + } + } } @@ -15418,7 +15626,7 @@ func (p projFloorDivFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15438,7 +15646,7 @@ func (p projFloorDivFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15457,7 +15665,7 @@ func (p projFloorDivFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15474,7 +15682,7 @@ func (p projFloorDivFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15520,7 +15728,7 @@ func (p projModDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15544,7 +15752,7 @@ func (p projModDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15567,7 +15775,7 @@ func (p projModDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15588,7 +15796,7 @@ func (p projModDecimalInt16ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15638,7 +15846,7 @@ func (p projModDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15662,7 +15870,7 @@ func (p projModDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15685,7 +15893,7 @@ func (p projModDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15706,7 +15914,7 @@ func (p projModDecimalInt32ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15756,7 +15964,7 @@ func (p projModDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15780,7 +15988,7 @@ func (p projModDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15803,7 +16011,7 @@ func (p projModDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15824,7 +16032,7 @@ func (p projModDecimalInt64ConstOp) Next() coldata.Batch { { - if p.constArg == 0 { + if p.constArg == 0 && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15874,7 +16082,7 @@ func (p projModDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15882,6 +16090,7 @@ func (p projModDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -15897,7 +16106,7 @@ func (p projModDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15905,6 +16114,7 @@ func (p projModDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -15919,7 +16129,7 @@ func (p projModDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15927,6 +16137,7 @@ func (p projModDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -15939,7 +16150,7 @@ func (p projModDecimalDecimalConstOp) Next() coldata.Batch { { - if p.constArg.IsZero() { + if p.constArg.IsZero() && arg.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -15947,6 +16158,7 @@ func (p projModDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16280,6 +16492,7 @@ func (p projModInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16305,6 +16518,7 @@ func (p projModInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16329,6 +16543,7 @@ func (p projModInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16351,6 +16566,7 @@ func (p projModInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16684,6 +16900,7 @@ func (p projModInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16709,6 +16926,7 @@ func (p projModInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16733,6 +16951,7 @@ func (p projModInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -16755,6 +16974,7 @@ func (p projModInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17088,6 +17308,7 @@ func (p projModInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17113,6 +17334,7 @@ func (p projModInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17137,6 +17359,7 @@ func (p projModInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17159,6 +17382,7 @@ func (p projModInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17200,7 +17424,7 @@ func (p projModFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17220,7 +17444,7 @@ func (p projModFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17239,7 +17463,7 @@ func (p projModFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17256,7 +17480,7 @@ func (p projModFloat64Float64ConstOp) Next() coldata.Batch { { - if p.constArg == 0.0 { + if p.constArg == 0.0 && !math.IsNaN(arg) { colexecerror.ExpectedError(tree.ErrDivByZero) } @@ -17612,6 +17836,7 @@ func (p projPowDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17631,6 +17856,7 @@ func (p projPowDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17649,6 +17875,7 @@ func (p projPowDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -17665,6 +17892,7 @@ func (p projPowDecimalDecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18078,6 +18306,7 @@ func (p projPowInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18099,6 +18328,7 @@ func (p projPowInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18119,6 +18349,7 @@ func (p projPowInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18137,6 +18368,7 @@ func (p projPowInt16DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18550,6 +18782,7 @@ func (p projPowInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18571,6 +18804,7 @@ func (p projPowInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18591,6 +18825,7 @@ func (p projPowInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -18609,6 +18844,7 @@ func (p projPowInt32DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19022,6 +19258,7 @@ func (p projPowInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19043,6 +19280,7 @@ func (p projPowInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19063,6 +19301,7 @@ func (p projPowInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } @@ -19081,6 +19320,7 @@ func (p projPowInt64DecimalConstOp) Next() coldata.Batch { if err != nil { colexecerror.ExpectedError(err) } + } } diff --git a/pkg/sql/colexec/colexecwindow/range_offset_handler.eg.go b/pkg/sql/colexec/colexecwindow/range_offset_handler.eg.go index a1db171c3887..dbbbcebb623a 100644 --- a/pkg/sql/colexec/colexecwindow/range_offset_handler.eg.go +++ b/pkg/sql/colexec/colexecwindow/range_offset_handler.eg.go @@ -1235,6 +1235,7 @@ func (h *rangeHandlerOffsetPrecedingStartAscDecimal) getIdx(ctx context.Context, if err != nil { colexecerror.ExpectedError(err) } + } // Pick up where the last index left off, since the start and indexes of each @@ -2451,6 +2452,7 @@ func (h *rangeHandlerOffsetPrecedingStartDescDecimal) getIdx(ctx context.Context if err != nil { colexecerror.ExpectedError(err) } + } // Pick up where the last index left off, since the start and indexes of each @@ -3654,6 +3656,7 @@ func (h *rangeHandlerOffsetPrecedingEndAscDecimal) getIdx(ctx context.Context, c if err != nil { colexecerror.ExpectedError(err) } + } // Pick up where the last index left off, since the start and indexes of each @@ -5023,6 +5026,7 @@ func (h *rangeHandlerOffsetPrecedingEndDescDecimal) getIdx(ctx context.Context, if err != nil { colexecerror.ExpectedError(err) } + } // Pick up where the last index left off, since the start and indexes of each @@ -6243,6 +6247,7 @@ func (h *rangeHandlerOffsetFollowingStartAscDecimal) getIdx(ctx context.Context, if err != nil { colexecerror.ExpectedError(err) } + } // Pick up where the last index left off, since the start and indexes of each @@ -7459,6 +7464,7 @@ func (h *rangeHandlerOffsetFollowingStartDescDecimal) getIdx(ctx context.Context if err != nil { colexecerror.ExpectedError(err) } + } // Pick up where the last index left off, since the start and indexes of each @@ -8662,6 +8668,7 @@ func (h *rangeHandlerOffsetFollowingEndAscDecimal) getIdx(ctx context.Context, c if err != nil { colexecerror.ExpectedError(err) } + } // Pick up where the last index left off, since the start and indexes of each @@ -10031,6 +10038,7 @@ func (h *rangeHandlerOffsetFollowingEndDescDecimal) getIdx(ctx context.Context, if err != nil { colexecerror.ExpectedError(err) } + } // Pick up where the last index left off, since the start and indexes of each diff --git a/pkg/sql/colexec/execgen/cmd/execgen/overloads_bin.go b/pkg/sql/colexec/execgen/cmd/execgen/overloads_bin.go index 2f896143e79c..f67d53686ee3 100644 --- a/pkg/sql/colexec/execgen/cmd/execgen/overloads_bin.go +++ b/pkg/sql/colexec/execgen/cmd/execgen/overloads_bin.go @@ -312,6 +312,10 @@ func checkRightIsZero(binOp treebin.BinaryOperatorSymbol) bool { return binOp == treebin.Div || binOp == treebin.FloorDiv || binOp == treebin.Mod } +func checkRightIsInf(binOp treebin.BinaryOperatorSymbol) bool { + return binOp == treebin.Div || binOp == treebin.FloorDiv +} + func (decimalCustomizer) getBinOpAssignFunc() assignFunc { return func(op *lastArgWidthOverload, targetElem, leftElem, rightElem, targetCol, leftCol, rightCol string) string { binOp := op.overloadBase.BinOp @@ -319,6 +323,7 @@ func (decimalCustomizer) getBinOpAssignFunc() assignFunc { "Ctx": binaryOpDecCtx[binOp], "Op": binaryOpDecMethod[binOp], "CheckRightIsZero": checkRightIsZero(binOp), + "CheckRightIsInf": checkRightIsInf(binOp), "Target": targetElem, "Left": leftElem, "Right": rightElem, @@ -327,7 +332,7 @@ func (decimalCustomizer) getBinOpAssignFunc() assignFunc { t := template.Must(template.New("").Parse(` { {{if .CheckRightIsZero}} - if {{.Right}}.IsZero() { + if {{.Right}}.IsZero() && {{.Left}}.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } {{end}} @@ -335,6 +340,11 @@ func (decimalCustomizer) getBinOpAssignFunc() assignFunc { if err != nil { colexecerror.ExpectedError(err) } + {{if .CheckRightIsInf}} + if {{.Right}}.Form == apd.Infinite && {{.Left}}.Form == apd.Finite { + {{.Target}} = apd.Decimal{} + } + {{end}} } `)) if err := t.Execute(&buf, args); err != nil { @@ -359,6 +369,7 @@ func (c floatCustomizer) getBinOpAssignFunc() assignFunc { args := map[string]interface{}{ "CheckRightIsZero": checkRightIsZero(binOp), "Target": targetElem, + "Left": leftElem, "Right": rightElem, "ComputeBinOp": computeBinOp, } @@ -366,7 +377,7 @@ func (c floatCustomizer) getBinOpAssignFunc() assignFunc { t := template.Must(template.New("").Parse(` { {{if .CheckRightIsZero}} - if {{.Right}} == 0.0 { + if {{.Right}} == 0.0 && !math.IsNaN({{.Left}}) { colexecerror.ExpectedError(tree.ErrDivByZero) } {{end}} @@ -541,7 +552,7 @@ func (c decimalIntCustomizer) getBinOpAssignFunc() assignFunc { t := template.Must(template.New("").Parse(` { {{if .CheckRightIsZero}} - if {{.Right}} == 0 { + if {{.Right}} == 0 && {{.Left}}.Form != apd.NaN { colexecerror.ExpectedError(tree.ErrDivByZero) } {{end}} @@ -566,6 +577,7 @@ func (c intDecimalCustomizer) getBinOpAssignFunc() assignFunc { "Ctx": binaryOpDecCtx[binOp], "Op": binaryOpDecMethod[binOp], "CheckRightIsZero": checkRightIsZero(binOp), + "CheckRightIsInf": checkRightIsInf(binOp), "Target": targetElem, "Left": leftElem, "Right": rightElem, @@ -584,6 +596,11 @@ func (c intDecimalCustomizer) getBinOpAssignFunc() assignFunc { if err != nil { colexecerror.ExpectedError(err) } + {{if .CheckRightIsInf}} + if {{.Right}}.Form == apd.Infinite { + {{.Target}} = apd.Decimal{} + } + {{end}} } `)) if err := t.Execute(&buf, args); err != nil { diff --git a/pkg/sql/logictest/testdata/logic_test/decimal b/pkg/sql/logictest/testdata/logic_test/decimal index 7b20854e02fe..b795b0a9eeb4 100644 --- a/pkg/sql/logictest/testdata/logic_test/decimal +++ b/pkg/sql/logictest/testdata/logic_test/decimal @@ -356,7 +356,7 @@ NaN query R SELECT 1.0 / 'Infinity' + 2 FROM a; ---- -2.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +2 query R SELECT 2.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @@ -465,57 +465,61 @@ NaN Infinity NaN NaN NaN NaN -Infinity NaN NaN NaN NaN NaN NaN NaN NaN -query RRRRR rowsort -WITH v(x) AS - (VALUES('0'::numeric),('1'::numeric),('-1'::numeric),('4.2'::numeric),('inf'::numeric),('-inf'::numeric),('nan'::numeric)) +# TODO(drewk): There are a few differences vs postgres in the number of decimal +# places and negative zeros. +query RRRRR +WITH v(id, x) AS (VALUES (1, '0'::numeric), (2, '1'::numeric), (3, '-1'::numeric), + (4, '4.2'::numeric), (5, 'inf'::numeric), (6, '-inf'::numeric), (7, 'nan'::numeric) +) SELECT x1, x2, x1 / x2 AS quot, x1 % x2 AS mod, div(x1, x2) AS div -FROM v AS v1(x1), v AS v2(x2) WHERE x2 != 0 ----- -0 1 0 0 0 -0 -1 -0 0 -0 -0 4.2 0E+1 0.0 0 -0 Infinity 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0 0 -0 -Infinity -0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0 -0 -0 NaN NaN NaN NaN -1 1 1.0000000000000000000 0 1 -1 -1 -1.0000000000000000000 0 -1 -1 4.2 0.23809523809523809524 1.0 0 -1 Infinity 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 1 0 -1 -Infinity -0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 1 -0 -1 NaN NaN NaN NaN --1 1 -1.0000000000000000000 -0 -1 --1 -1 1.0000000000000000000 -0 1 --1 4.2 -0.23809523809523809524 -1.0 -0 --1 Infinity -0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -1 -0 --1 -Infinity 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -1 0 --1 NaN NaN NaN NaN -4.2 1 4.2000000000000000000 0.2 4 -4.2 -1 -4.2000000000000000000 0.2 -4 -4.2 4.2 1.0000000000000000000 0.0 1 -4.2 Infinity 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4.2 0 -4.2 -Infinity -0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4.2 -0 -4.2 NaN NaN NaN NaN -Infinity 1 Infinity NaN Infinity -Infinity -1 -Infinity NaN -Infinity -Infinity 4.2 Infinity NaN Infinity -Infinity Infinity NaN NaN NaN -Infinity -Infinity NaN NaN NaN -Infinity NaN NaN NaN NaN --Infinity 1 -Infinity NaN -Infinity --Infinity -1 Infinity NaN Infinity --Infinity 4.2 -Infinity NaN -Infinity --Infinity Infinity NaN NaN NaN --Infinity -Infinity NaN NaN NaN --Infinity NaN NaN NaN NaN -NaN 1 NaN NaN NaN -NaN -1 NaN NaN NaN -NaN 4.2 NaN NaN NaN -NaN Infinity NaN NaN NaN -NaN -Infinity NaN NaN NaN -NaN NaN NaN NaN NaN +FROM v AS v1(id1, x1), v AS v2(id2, x2) WHERE x2 != 0 +ORDER BY id1, id2 +---- +0 1 0 0 0 +0 -1 -0 0 -0 +0 4.2 0E+1 0.0 0 +0 Infinity 0 0 0 +0 -Infinity 0 0 -0 +0 NaN NaN NaN NaN +1 1 1.0000000000000000000 0 1 +1 -1 -1.0000000000000000000 0 -1 +1 4.2 0.23809523809523809524 1.0 0 +1 Infinity 0 1 0 +1 -Infinity 0 1 -0 +1 NaN NaN NaN NaN +-1 1 -1.0000000000000000000 -0 -1 +-1 -1 1.0000000000000000000 -0 1 +-1 4.2 -0.23809523809523809524 -1.0 -0 +-1 Infinity 0 -1 -0 +-1 -Infinity 0 -1 0 +-1 NaN NaN NaN NaN +4.2 1 4.2000000000000000000 0.2 4 +4.2 -1 -4.2000000000000000000 0.2 -4 +4.2 4.2 1.0000000000000000000 0.0 1 +4.2 Infinity 0 4.2 0 +4.2 -Infinity 0 4.2 -0 +4.2 NaN NaN NaN NaN +Infinity 1 Infinity NaN Infinity +Infinity -1 -Infinity NaN -Infinity +Infinity 4.2 Infinity NaN Infinity +Infinity Infinity NaN NaN NaN +Infinity -Infinity NaN NaN NaN +Infinity NaN NaN NaN NaN +-Infinity 1 -Infinity NaN -Infinity +-Infinity -1 Infinity NaN Infinity +-Infinity 4.2 -Infinity NaN -Infinity +-Infinity Infinity NaN NaN NaN +-Infinity -Infinity NaN NaN NaN +-Infinity NaN NaN NaN NaN +NaN 1 NaN NaN NaN +NaN -1 NaN NaN NaN +NaN 4.2 NaN NaN NaN +NaN Infinity NaN NaN NaN +NaN -Infinity NaN NaN NaN +NaN NaN NaN NaN NaN statement error division by zero SELECT 'inf'::numeric / '0' @@ -523,6 +527,12 @@ SELECT 'inf'::numeric / '0' statement error division by zero SELECT '-inf'::numeric / '0' +# Don't throw a division-by-zero error when the numerator is NaN. +query R +SELECT 'NaN'::DECIMAL / 0::DECIMAL; +---- +NaN + query R SELECT 'Infinity'::float8::numeric ---- @@ -614,3 +624,24 @@ SELECT (x / 1)::DECIMAL FROM t86790 statement ok RESET testing_optimizer_disable_rule_probability + +# Regression test for #103633 and #40929 - short-circuit return 0 on division by +# infinity. The results should only have one digit each. +statement ok +CREATE TABLE regression_40929 AS SELECT g FROM VALUES (1) AS v(g); + +query IRRRR +SELECT +g, +0 / '-Infinity'::DECIMAL, +0 / 'Infinity'::DECIMAL, +1 / '-Infinity'::DECIMAL, +1 / 'Infinity'::DECIMAL +FROM regression_40929 +---- +1 0 0 0 0 + +query R +SELECT 0::DECIMAL/ 'infinity'::DECIMAL; +---- +0 diff --git a/pkg/sql/sem/eval/binary_op.go b/pkg/sql/sem/eval/binary_op.go index 8956f45600d1..14a47fc4a7d7 100644 --- a/pkg/sql/sem/eval/binary_op.go +++ b/pkg/sql/sem/eval/binary_op.go @@ -328,7 +328,7 @@ func (e *evaluator) EvalDivDecimalIntOp( ) (tree.Datum, error) { l := &left.(*tree.DDecimal).Decimal r := tree.MustBeDInt(right) - if r == 0 { + if l.Form != apd.NaN && r == 0 { return nil, tree.ErrDivByZero } dd := &tree.DDecimal{} @@ -342,8 +342,10 @@ func (e *evaluator) EvalDivDecimalOp( ) (tree.Datum, error) { l := &left.(*tree.DDecimal).Decimal r := &right.(*tree.DDecimal).Decimal - if r.IsZero() { + if r.IsZero() && l.Form != apd.NaN { return nil, tree.ErrDivByZero + } else if r.Form == apd.Infinite && l.Form == apd.Finite { + return tree.DZeroDecimal, nil } dd := &tree.DDecimal{} _, err := tree.DecimalCtx.Quo(&dd.Decimal, l, r) @@ -353,11 +355,12 @@ func (e *evaluator) EvalDivDecimalOp( func (e *evaluator) EvalDivFloatOp( ctx context.Context, _ *tree.DivFloatOp, left, right tree.Datum, ) (tree.Datum, error) { - r := *right.(*tree.DFloat) - if r == 0.0 { + l := float64(*left.(*tree.DFloat)) + r := float64(*right.(*tree.DFloat)) + if r == 0.0 && !math.IsNaN(l) { return nil, tree.ErrDivByZero } - return tree.NewDFloat(*left.(*tree.DFloat) / r), nil + return tree.NewDFloat(tree.DFloat(l / r)), nil } func (e *evaluator) EvalDivIntDecimalOp( @@ -367,6 +370,8 @@ func (e *evaluator) EvalDivIntDecimalOp( r := &right.(*tree.DDecimal).Decimal if r.IsZero() { return nil, tree.ErrDivByZero + } else if r.Form == apd.Infinite { + return tree.DZeroDecimal, nil } dd := &tree.DDecimal{} dd.SetInt64(int64(l)) @@ -418,7 +423,7 @@ func (e *evaluator) EvalFloorDivDecimalIntOp( ) (tree.Datum, error) { l := &left.(*tree.DDecimal).Decimal r := tree.MustBeDInt(right) - if r == 0 { + if r == 0 && l.Form != apd.NaN { return nil, tree.ErrDivByZero } dd := &tree.DDecimal{} @@ -432,8 +437,10 @@ func (e *evaluator) EvalFloorDivDecimalOp( ) (tree.Datum, error) { l := &left.(*tree.DDecimal).Decimal r := &right.(*tree.DDecimal).Decimal - if r.IsZero() { + if r.IsZero() && l.Form != apd.NaN { return nil, tree.ErrDivByZero + } else if r.Form == apd.Infinite && l.Form == apd.Finite { + return tree.DZeroDecimal, nil } dd := &tree.DDecimal{} _, err := tree.HighPrecisionCtx.QuoInteger(&dd.Decimal, l, r) @@ -445,7 +452,7 @@ func (e *evaluator) EvalFloorDivFloatOp( ) (tree.Datum, error) { l := float64(*left.(*tree.DFloat)) r := float64(*right.(*tree.DFloat)) - if r == 0.0 { + if r == 0.0 && !math.IsNaN(l) { return nil, tree.ErrDivByZero } return tree.NewDFloat(tree.DFloat(math.Trunc(l / r))), nil @@ -458,6 +465,8 @@ func (e *evaluator) EvalFloorDivIntDecimalOp( r := &right.(*tree.DDecimal).Decimal if r.IsZero() { return nil, tree.ErrDivByZero + } else if r.Form == apd.Infinite { + return tree.DZeroDecimal, nil } dd := &tree.DDecimal{} dd.SetInt64(int64(l)) @@ -996,7 +1005,7 @@ func (e *evaluator) EvalModDecimalIntOp( ) (tree.Datum, error) { l := &left.(*tree.DDecimal).Decimal r := tree.MustBeDInt(right) - if r == 0 { + if r == 0 && l.Form != apd.NaN { return nil, tree.ErrDivByZero } dd := &tree.DDecimal{} @@ -1010,7 +1019,7 @@ func (e *evaluator) EvalModDecimalOp( ) (tree.Datum, error) { l := &left.(*tree.DDecimal).Decimal r := &right.(*tree.DDecimal).Decimal - if r.IsZero() { + if r.IsZero() && l.Form != apd.NaN { return nil, tree.ErrDivByZero } dd := &tree.DDecimal{} @@ -1023,7 +1032,7 @@ func (e *evaluator) EvalModFloatOp( ) (tree.Datum, error) { l := float64(*left.(*tree.DFloat)) r := float64(*right.(*tree.DFloat)) - if r == 0.0 { + if r == 0.0 && !math.IsNaN(l) { return nil, tree.ErrDivByZero } return tree.NewDFloat(tree.DFloat(math.Mod(l, r))), nil diff --git a/pkg/sql/sem/tree/datum.go b/pkg/sql/sem/tree/datum.go index 386671d007e9..c3937615f0cd 100644 --- a/pkg/sql/sem/tree/datum.go +++ b/pkg/sql/sem/tree/datum.go @@ -1160,9 +1160,16 @@ func (d *DDecimal) Next(ctx CompareContext) (Datum, bool) { return nil, false } -var dZeroDecimal = &DDecimal{Decimal: apd.Decimal{}} -var dPosInfDecimal = &DDecimal{Decimal: apd.Decimal{Form: apd.Infinite, Negative: false}} -var dNaNDecimal = &DDecimal{Decimal: apd.Decimal{Form: apd.NaN}} +var ( + // DZeroDecimal is the decimal constant '0'. + DZeroDecimal = &DDecimal{Decimal: apd.Decimal{}} + + // dNaNDecimal is the decimal constant 'NaN'. + dNaNDecimal = &DDecimal{Decimal: apd.Decimal{Form: apd.NaN}} + + // dPosInfDecimal is the decimal constant 'inf'. + dPosInfDecimal = &DDecimal{Decimal: apd.Decimal{Form: apd.Infinite, Negative: false}} +) // IsMax implements the Datum interface. func (d *DDecimal) IsMax(ctx CompareContext) bool { @@ -5909,7 +5916,7 @@ func NewDefaultDatum(collationEnv *CollationEnvironment, t *types.T) (d Datum, e case types.FloatFamily: return DZeroFloat, nil case types.DecimalFamily: - return dZeroDecimal, nil + return DZeroDecimal, nil case types.DateFamily: return dEpochDate, nil case types.TimestampFamily: