duckdb 0.4.1-dev36.0 → 0.4.1-dev47.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.4.1-dev36.0",
4
+ "version": "0.4.1-dev47.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -25536,6 +25536,11 @@ duckdb::string_t StringCast::Operation(hugeint_t input, Vector &vector) {
25536
25536
 
25537
25537
  template <>
25538
25538
  duckdb::string_t StringCast::Operation(date_t input, Vector &vector) {
25539
+ if (input == date_t::infinity()) {
25540
+ return "infinity";
25541
+ } else if (input == date_t::ninfinity()) {
25542
+ return "-infinity";
25543
+ }
25539
25544
  int32_t date[3];
25540
25545
  Date::Convert(input, date[0], date[1], date[2]);
25541
25546
 
@@ -25571,6 +25576,11 @@ duckdb::string_t StringCast::Operation(dtime_t input, Vector &vector) {
25571
25576
 
25572
25577
  template <>
25573
25578
  duckdb::string_t StringCast::Operation(timestamp_t input, Vector &vector) {
25579
+ if (input == timestamp_t::infinity()) {
25580
+ return string_t("infinity");
25581
+ } else if (input == timestamp_t::ninfinity()) {
25582
+ return string_t("-infinity");
25583
+ }
25574
25584
  date_t date_entry;
25575
25585
  dtime_t time_entry;
25576
25586
  Timestamp::Convert(input, date_entry, time_entry);
@@ -42133,6 +42143,126 @@ dtime_t AddTimeOperator::Operation(interval_t left, dtime_t right);
42133
42143
  } // namespace duckdb
42134
42144
 
42135
42145
 
42146
+ //===----------------------------------------------------------------------===//
42147
+ // DuckDB
42148
+ //
42149
+ // duckdb/common/operator/subtract.hpp
42150
+ //
42151
+ //
42152
+ //===----------------------------------------------------------------------===//
42153
+
42154
+
42155
+
42156
+
42157
+
42158
+
42159
+ namespace duckdb {
42160
+
42161
+ struct SubtractOperator {
42162
+ template <class TA, class TB, class TR>
42163
+ static inline TR Operation(TA left, TB right) {
42164
+ return left - right;
42165
+ }
42166
+ };
42167
+
42168
+ template <>
42169
+ float SubtractOperator::Operation(float left, float right);
42170
+ template <>
42171
+ double SubtractOperator::Operation(double left, double right);
42172
+ template <>
42173
+ interval_t SubtractOperator::Operation(interval_t left, interval_t right);
42174
+ template <>
42175
+ int64_t SubtractOperator::Operation(date_t left, date_t right);
42176
+ template <>
42177
+ date_t SubtractOperator::Operation(date_t left, int32_t right);
42178
+ template <>
42179
+ date_t SubtractOperator::Operation(date_t left, interval_t right);
42180
+ template <>
42181
+ timestamp_t SubtractOperator::Operation(timestamp_t left, interval_t right);
42182
+ template <>
42183
+ interval_t SubtractOperator::Operation(timestamp_t left, timestamp_t right);
42184
+
42185
+ struct TrySubtractOperator {
42186
+ template <class TA, class TB, class TR>
42187
+ static inline bool Operation(TA left, TB right, TR &result) {
42188
+ throw InternalException("Unimplemented type for TrySubtractOperator");
42189
+ }
42190
+ };
42191
+
42192
+ template <>
42193
+ bool TrySubtractOperator::Operation(uint8_t left, uint8_t right, uint8_t &result);
42194
+ template <>
42195
+ bool TrySubtractOperator::Operation(uint16_t left, uint16_t right, uint16_t &result);
42196
+ template <>
42197
+ bool TrySubtractOperator::Operation(uint32_t left, uint32_t right, uint32_t &result);
42198
+ template <>
42199
+ bool TrySubtractOperator::Operation(uint64_t left, uint64_t right, uint64_t &result);
42200
+
42201
+ template <>
42202
+ bool TrySubtractOperator::Operation(int8_t left, int8_t right, int8_t &result);
42203
+ template <>
42204
+ bool TrySubtractOperator::Operation(int16_t left, int16_t right, int16_t &result);
42205
+ template <>
42206
+ bool TrySubtractOperator::Operation(int32_t left, int32_t right, int32_t &result);
42207
+ template <>
42208
+ bool TrySubtractOperator::Operation(int64_t left, int64_t right, int64_t &result);
42209
+ template <>
42210
+ bool TrySubtractOperator::Operation(hugeint_t left, hugeint_t right, hugeint_t &result);
42211
+
42212
+ struct SubtractOperatorOverflowCheck {
42213
+ template <class TA, class TB, class TR>
42214
+ static inline TR Operation(TA left, TB right) {
42215
+ TR result;
42216
+ if (!TrySubtractOperator::Operation(left, right, result)) {
42217
+ throw OutOfRangeException("Overflow in subtraction of %s (%d - %d)!", TypeIdToString(GetTypeId<TA>()), left,
42218
+ right);
42219
+ }
42220
+ return result;
42221
+ }
42222
+ };
42223
+
42224
+ struct TryDecimalSubtract {
42225
+ template <class TA, class TB, class TR>
42226
+ static inline bool Operation(TA left, TB right, TR &result) {
42227
+ throw InternalException("Unimplemented type for TryDecimalSubtract");
42228
+ }
42229
+ };
42230
+
42231
+ template <>
42232
+ bool TryDecimalSubtract::Operation(int16_t left, int16_t right, int16_t &result);
42233
+ template <>
42234
+ bool TryDecimalSubtract::Operation(int32_t left, int32_t right, int32_t &result);
42235
+ template <>
42236
+ bool TryDecimalSubtract::Operation(int64_t left, int64_t right, int64_t &result);
42237
+ template <>
42238
+ bool TryDecimalSubtract::Operation(hugeint_t left, hugeint_t right, hugeint_t &result);
42239
+
42240
+ struct DecimalSubtractOverflowCheck {
42241
+ template <class TA, class TB, class TR>
42242
+ static inline TR Operation(TA left, TB right) {
42243
+ TR result;
42244
+ if (!TryDecimalSubtract::Operation<TA, TB, TR>(left, right, result)) {
42245
+ throw OutOfRangeException("Overflow in subtract of DECIMAL(18) (%d - %d). You might want to add an "
42246
+ "explicit cast to a bigger decimal.",
42247
+ left, right);
42248
+ }
42249
+ return result;
42250
+ }
42251
+ };
42252
+
42253
+ template <>
42254
+ hugeint_t DecimalSubtractOverflowCheck::Operation(hugeint_t left, hugeint_t right);
42255
+
42256
+ struct SubtractTimeOperator {
42257
+ template <class TA, class TB, class TR>
42258
+ static TR Operation(TA left, TB right);
42259
+ };
42260
+
42261
+ template <>
42262
+ dtime_t SubtractTimeOperator::Operation(dtime_t left, interval_t right);
42263
+
42264
+ } // namespace duckdb
42265
+
42136
42266
 
42137
42267
 
42138
42268
  namespace duckdb {
@@ -42410,6 +42540,7 @@ int64_t Interval::GetNanoseconds(const interval_t &val) {
42410
42540
  }
42411
42541
 
42412
42542
  interval_t Interval::GetAge(timestamp_t timestamp_1, timestamp_t timestamp_2) {
42543
+ D_ASSERT(Timestamp::IsFinite(timestamp_1) && Timestamp::IsFinite(timestamp_2));
42413
42544
  date_t date1, date2;
42414
42545
  dtime_t time1, time2;
42415
42546
 
@@ -42499,9 +42630,15 @@ interval_t Interval::GetAge(timestamp_t timestamp_1, timestamp_t timestamp_2) {
42499
42630
  }
42500
42631
 
42501
42632
  interval_t Interval::GetDifference(timestamp_t timestamp_1, timestamp_t timestamp_2) {
42633
+ if (!Timestamp::IsFinite(timestamp_1) || !Timestamp::IsFinite(timestamp_2)) {
42634
+ throw InvalidInputException("Cannot subtract infinite timestamps");
42635
+ }
42502
42636
  const auto us_1 = Timestamp::GetEpochMicroSeconds(timestamp_1);
42503
42637
  const auto us_2 = Timestamp::GetEpochMicroSeconds(timestamp_2);
42504
- const auto delta_us = us_1 - us_2;
42638
+ int64_t delta_us;
42639
+ if (!TrySubtractOperator::Operation(us_1, us_2, delta_us)) {
42640
+ throw ConversionException("Timestamp difference is out of bounds");
42641
+ }
42505
42642
  return FromMicro(delta_us);
42506
42643
  }
42507
42644
 
@@ -46769,7 +46906,7 @@ void Vector::Verify(Vector &vector_p, const SelectionVector &sel_p, idx_t count)
46769
46906
  D_ASSERT(child_types.size() == children.size());
46770
46907
  for (idx_t child_idx = 0; child_idx < children.size(); child_idx++) {
46771
46908
  D_ASSERT(children[child_idx]->GetType() == child_types[child_idx].second);
46772
- children[child_idx]->Verify(count);
46909
+ Vector::Verify(*children[child_idx], sel_p, count);
46773
46910
  if (vtype == VectorType::CONSTANT_VECTOR) {
46774
46911
  D_ASSERT(children[child_idx]->GetVectorType() == VectorType::CONSTANT_VECTOR);
46775
46912
  if (ConstantVector::IsNull(*vector)) {
@@ -74924,125 +75061,6 @@ void PhysicalOperator::Verify() {
74924
75061
 
74925
75062
  } // namespace duckdb
74926
75063
 
74927
- //===----------------------------------------------------------------------===//
74928
- // DuckDB
74929
- //
74930
- // duckdb/common/operator/subtract.hpp
74931
- //
74932
- //
74933
- //===----------------------------------------------------------------------===//
74934
-
74935
-
74936
-
74937
-
74938
-
74939
-
74940
- namespace duckdb {
74941
-
74942
- struct SubtractOperator {
74943
- template <class TA, class TB, class TR>
74944
- static inline TR Operation(TA left, TB right) {
74945
- return left - right;
74946
- }
74947
- };
74948
-
74949
- template <>
74950
- float SubtractOperator::Operation(float left, float right);
74951
- template <>
74952
- double SubtractOperator::Operation(double left, double right);
74953
- template <>
74954
- interval_t SubtractOperator::Operation(interval_t left, interval_t right);
74955
- template <>
74956
- int64_t SubtractOperator::Operation(date_t left, date_t right);
74957
- template <>
74958
- date_t SubtractOperator::Operation(date_t left, int32_t right);
74959
- template <>
74960
- date_t SubtractOperator::Operation(date_t left, interval_t right);
74961
- template <>
74962
- timestamp_t SubtractOperator::Operation(timestamp_t left, interval_t right);
74963
- template <>
74964
- interval_t SubtractOperator::Operation(timestamp_t left, timestamp_t right);
74965
-
74966
- struct TrySubtractOperator {
74967
- template <class TA, class TB, class TR>
74968
- static inline bool Operation(TA left, TB right, TR &result) {
74969
- throw InternalException("Unimplemented type for TrySubtractOperator");
74970
- }
74971
- };
74972
-
74973
- template <>
74974
- bool TrySubtractOperator::Operation(uint8_t left, uint8_t right, uint8_t &result);
74975
- template <>
74976
- bool TrySubtractOperator::Operation(uint16_t left, uint16_t right, uint16_t &result);
74977
- template <>
74978
- bool TrySubtractOperator::Operation(uint32_t left, uint32_t right, uint32_t &result);
74979
- template <>
74980
- bool TrySubtractOperator::Operation(uint64_t left, uint64_t right, uint64_t &result);
74981
-
74982
- template <>
74983
- bool TrySubtractOperator::Operation(int8_t left, int8_t right, int8_t &result);
74984
- template <>
74985
- bool TrySubtractOperator::Operation(int16_t left, int16_t right, int16_t &result);
74986
- template <>
74987
- bool TrySubtractOperator::Operation(int32_t left, int32_t right, int32_t &result);
74988
- template <>
74989
- bool TrySubtractOperator::Operation(int64_t left, int64_t right, int64_t &result);
74990
- template <>
74991
- bool TrySubtractOperator::Operation(hugeint_t left, hugeint_t right, hugeint_t &result);
74992
-
74993
- struct SubtractOperatorOverflowCheck {
74994
- template <class TA, class TB, class TR>
74995
- static inline TR Operation(TA left, TB right) {
74996
- TR result;
74997
- if (!TrySubtractOperator::Operation(left, right, result)) {
74998
- throw OutOfRangeException("Overflow in subtraction of %s (%d - %d)!", TypeIdToString(GetTypeId<TA>()), left,
74999
- right);
75000
- }
75001
- return result;
75002
- }
75003
- };
75004
-
75005
- struct TryDecimalSubtract {
75006
- template <class TA, class TB, class TR>
75007
- static inline bool Operation(TA left, TB right, TR &result) {
75008
- throw InternalException("Unimplemented type for TryDecimalSubtract");
75009
- }
75010
- };
75011
-
75012
- template <>
75013
- bool TryDecimalSubtract::Operation(int16_t left, int16_t right, int16_t &result);
75014
- template <>
75015
- bool TryDecimalSubtract::Operation(int32_t left, int32_t right, int32_t &result);
75016
- template <>
75017
- bool TryDecimalSubtract::Operation(int64_t left, int64_t right, int64_t &result);
75018
- template <>
75019
- bool TryDecimalSubtract::Operation(hugeint_t left, hugeint_t right, hugeint_t &result);
75020
-
75021
- struct DecimalSubtractOverflowCheck {
75022
- template <class TA, class TB, class TR>
75023
- static inline TR Operation(TA left, TB right) {
75024
- TR result;
75025
- if (!TryDecimalSubtract::Operation<TA, TB, TR>(left, right, result)) {
75026
- throw OutOfRangeException("Overflow in subtract of DECIMAL(18) (%d - %d). You might want to add an "
75027
- "explicit cast to a bigger decimal.",
75028
- left, right);
75029
- }
75030
- return result;
75031
- }
75032
- };
75033
-
75034
- template <>
75035
- hugeint_t DecimalSubtractOverflowCheck::Operation(hugeint_t left, hugeint_t right);
75036
-
75037
- struct SubtractTimeOperator {
75038
- template <class TA, class TB, class TR>
75039
- static TR Operation(TA left, TB right);
75040
- };
75041
-
75042
- template <>
75043
- dtime_t SubtractTimeOperator::Operation(dtime_t left, interval_t right);
75044
-
75045
- } // namespace duckdb
75046
75064
 
75047
75065
 
75048
75066
 
@@ -93018,6 +93036,9 @@ string StrfTimeFormat::Format(timestamp_t timestamp, const string &format_str) {
93018
93036
  }
93019
93037
 
93020
93038
  string StrTimeFormat::ParseFormatSpecifier(const string &format_string, StrTimeFormat &format) {
93039
+ if (format_string.empty()) {
93040
+ return "Empty format string";
93041
+ }
93021
93042
  format.specifiers.clear();
93022
93043
  format.literals.clear();
93023
93044
  format.numeric_width.clear();
@@ -93396,6 +93417,7 @@ bool StrpTimeFormat::Parse(string_t str, ParseResult &result) {
93396
93417
  uint64_t yearday = 0;
93397
93418
 
93398
93419
  for (idx_t i = 0;; i++) {
93420
+ D_ASSERT(i < literals.size());
93399
93421
  // first compare the literal
93400
93422
  const auto &literal = literals[i];
93401
93423
  for (size_t l = 0; l < literal.size();) {
@@ -93786,7 +93808,10 @@ static unique_ptr<FunctionData> StrpTimeBindFunction(ClientContext &context, Sca
93786
93808
  Value options_str = ExpressionExecutor::EvaluateScalar(*arguments[1]);
93787
93809
  string format_string = options_str.ToString();
93788
93810
  StrpTimeFormat format;
93789
- if (!options_str.IsNull() && options_str.type().id() == LogicalTypeId::VARCHAR) {
93811
+ if (!options_str.IsNull()) {
93812
+ if (options_str.type().id() != LogicalTypeId::VARCHAR) {
93813
+ throw InvalidInputException("strptime format must be a string");
93814
+ }
93790
93815
  format.format_specifier = format_string;
93791
93816
  string error = StrTimeFormat::ParseFormatSpecifier(format_string, format);
93792
93817
  if (!error.empty()) {
package/src/duckdb.hpp CHANGED
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
13
  #define DUCKDB_AMALGAMATION_EXTENDED 1
14
- #define DUCKDB_SOURCE_ID "530a5f55c"
15
- #define DUCKDB_VERSION "v0.4.1-dev36"
14
+ #define DUCKDB_SOURCE_ID "82e13a4bb"
15
+ #define DUCKDB_VERSION "v0.4.1-dev47"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -22466,7 +22466,7 @@ protected:
22466
22466
  //! Format is literals[0], specifiers[0], literals[1], ..., specifiers[n - 1], literals[n]
22467
22467
  vector<string> literals;
22468
22468
  //! The constant size that appears in the format string
22469
- idx_t constant_size;
22469
+ idx_t constant_size = 0;
22470
22470
  //! The max numeric width of the specifier (if it is parsed as a number), or -1 if it is not a number
22471
22471
  vector<int> numeric_width;
22472
22472