duckdb 0.8.2-dev3079.0 → 0.8.2-dev3107.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb/src/function/scalar/operators/add.cpp +9 -0
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +6 -3
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/operator/add.hpp +5 -2
- package/src/duckdb/src/include/duckdb/common/operator/multiply.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/operator/subtract.hpp +3 -2
package/package.json
CHANGED
@@ -160,6 +160,15 @@ bool TryAddOperator::Operation(int64_t left, int64_t right, int64_t &result) {
|
|
160
160
|
return true;
|
161
161
|
}
|
162
162
|
|
163
|
+
template <>
|
164
|
+
bool TryAddOperator::Operation(hugeint_t left, hugeint_t right, hugeint_t &result) {
|
165
|
+
if (!Hugeint::AddInPlace(left, right)) {
|
166
|
+
return false;
|
167
|
+
}
|
168
|
+
result = left;
|
169
|
+
return true;
|
170
|
+
}
|
171
|
+
|
163
172
|
//===--------------------------------------------------------------------===//
|
164
173
|
// add decimal with overflow check
|
165
174
|
//===--------------------------------------------------------------------===//
|
@@ -35,6 +35,9 @@ static scalar_function_t GetScalarIntegerFunction(PhysicalType type) {
|
|
35
35
|
case PhysicalType::INT64:
|
36
36
|
function = &ScalarFunction::BinaryFunction<int64_t, int64_t, int64_t, OP>;
|
37
37
|
break;
|
38
|
+
case PhysicalType::INT128:
|
39
|
+
function = &ScalarFunction::BinaryFunction<hugeint_t, hugeint_t, hugeint_t, OP>;
|
40
|
+
break;
|
38
41
|
case PhysicalType::UINT8:
|
39
42
|
function = &ScalarFunction::BinaryFunction<uint8_t, uint8_t, uint8_t, OP>;
|
40
43
|
break;
|
@@ -302,7 +305,7 @@ ScalarFunction AddFun::GetFunction(const LogicalType &left_type, const LogicalTy
|
|
302
305
|
function.serialize = SerializeDecimalArithmetic;
|
303
306
|
function.deserialize = DeserializeDecimalArithmetic<AddOperator, DecimalAddOverflowCheck>;
|
304
307
|
return function;
|
305
|
-
} else if (left_type.IsIntegral()
|
308
|
+
} else if (left_type.IsIntegral()) {
|
306
309
|
return ScalarFunction("+", {left_type, right_type}, left_type,
|
307
310
|
GetScalarIntegerFunction<AddOperatorOverflowCheck>(left_type.InternalType()), nullptr,
|
308
311
|
nullptr, PropagateNumericStats<TryAddOperator, AddPropagateStatistics, AddOperator>);
|
@@ -564,7 +567,7 @@ ScalarFunction SubtractFun::GetFunction(const LogicalType &left_type, const Logi
|
|
564
567
|
function.serialize = SerializeDecimalArithmetic;
|
565
568
|
function.deserialize = DeserializeDecimalArithmetic<SubtractOperator, DecimalSubtractOverflowCheck>;
|
566
569
|
return function;
|
567
|
-
} else if (left_type.IsIntegral()
|
570
|
+
} else if (left_type.IsIntegral()) {
|
568
571
|
return ScalarFunction(
|
569
572
|
"-", {left_type, right_type}, left_type,
|
570
573
|
GetScalarIntegerFunction<SubtractOperatorOverflowCheck>(left_type.InternalType()), nullptr, nullptr,
|
@@ -768,7 +771,7 @@ void MultiplyFun::RegisterFunction(BuiltinFunctions &set) {
|
|
768
771
|
function.serialize = SerializeDecimalArithmetic;
|
769
772
|
function.deserialize = DeserializeDecimalArithmetic<MultiplyOperator, DecimalMultiplyOverflowCheck>;
|
770
773
|
functions.AddFunction(function);
|
771
|
-
} else if (TypeIsIntegral(type.InternalType())
|
774
|
+
} else if (TypeIsIntegral(type.InternalType())) {
|
772
775
|
functions.AddFunction(ScalarFunction(
|
773
776
|
{type, type}, type, GetScalarIntegerFunction<MultiplyOperatorOverflowCheck>(type.InternalType()),
|
774
777
|
nullptr, nullptr,
|
@@ -1,8 +1,8 @@
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
2
|
-
#define DUCKDB_VERSION "0.8.2-
|
2
|
+
#define DUCKDB_VERSION "0.8.2-dev3107"
|
3
3
|
#endif
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
5
|
+
#define DUCKDB_SOURCE_ID "4c2de0a942"
|
6
6
|
#endif
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
8
8
|
#include "duckdb/main/database.hpp"
|
@@ -11,6 +11,7 @@
|
|
11
11
|
#include "duckdb/common/types.hpp"
|
12
12
|
#include "duckdb/common/type_util.hpp"
|
13
13
|
#include "duckdb/common/exception.hpp"
|
14
|
+
#include "duckdb/common/types/cast_helpers.hpp"
|
14
15
|
|
15
16
|
namespace duckdb {
|
16
17
|
|
@@ -68,14 +69,16 @@ template <>
|
|
68
69
|
bool TryAddOperator::Operation(int32_t left, int32_t right, int32_t &result);
|
69
70
|
template <>
|
70
71
|
DUCKDB_API bool TryAddOperator::Operation(int64_t left, int64_t right, int64_t &result);
|
72
|
+
template <>
|
73
|
+
bool TryAddOperator::Operation(hugeint_t left, hugeint_t right, hugeint_t &result);
|
71
74
|
|
72
75
|
struct AddOperatorOverflowCheck {
|
73
76
|
template <class TA, class TB, class TR>
|
74
77
|
static inline TR Operation(TA left, TB right) {
|
75
78
|
TR result;
|
76
79
|
if (!TryAddOperator::Operation(left, right, result)) {
|
77
|
-
throw OutOfRangeException("Overflow in addition of %s (%
|
78
|
-
right);
|
80
|
+
throw OutOfRangeException("Overflow in addition of %s (%s + %s)!", TypeIdToString(GetTypeId<TA>()),
|
81
|
+
NumericHelper::ToString(left), NumericHelper::ToString(right));
|
79
82
|
}
|
80
83
|
return result;
|
81
84
|
}
|
@@ -11,6 +11,7 @@
|
|
11
11
|
#include "duckdb/common/types.hpp"
|
12
12
|
#include "duckdb/common/exception.hpp"
|
13
13
|
#include "duckdb/common/type_util.hpp"
|
14
|
+
#include "duckdb/common/types/cast_helpers.hpp"
|
14
15
|
|
15
16
|
namespace duckdb {
|
16
17
|
|
@@ -64,8 +65,8 @@ struct MultiplyOperatorOverflowCheck {
|
|
64
65
|
static inline TR Operation(TA left, TB right) {
|
65
66
|
TR result;
|
66
67
|
if (!TryMultiplyOperator::Operation(left, right, result)) {
|
67
|
-
throw OutOfRangeException("Overflow in multiplication of %s (%
|
68
|
-
left, right);
|
68
|
+
throw OutOfRangeException("Overflow in multiplication of %s (%s * %s)!", TypeIdToString(GetTypeId<TA>()),
|
69
|
+
NumericHelper::ToString(left), NumericHelper::ToString(right));
|
69
70
|
}
|
70
71
|
return result;
|
71
72
|
}
|
@@ -11,6 +11,7 @@
|
|
11
11
|
#include "duckdb/common/types.hpp"
|
12
12
|
#include "duckdb/common/exception.hpp"
|
13
13
|
#include "duckdb/common/type_util.hpp"
|
14
|
+
#include "duckdb/common/types/cast_helpers.hpp"
|
14
15
|
|
15
16
|
namespace duckdb {
|
16
17
|
|
@@ -75,8 +76,8 @@ struct SubtractOperatorOverflowCheck {
|
|
75
76
|
static inline TR Operation(TA left, TB right) {
|
76
77
|
TR result;
|
77
78
|
if (!TrySubtractOperator::Operation(left, right, result)) {
|
78
|
-
throw OutOfRangeException("Overflow in subtraction of %s (%
|
79
|
-
right);
|
79
|
+
throw OutOfRangeException("Overflow in subtraction of %s (%s - %s)!", TypeIdToString(GetTypeId<TA>()),
|
80
|
+
NumericHelper::ToString(left), NumericHelper::ToString(right));
|
80
81
|
}
|
81
82
|
return result;
|
82
83
|
}
|