duckdb 0.6.2-dev1104.0 → 0.6.2-dev1114.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
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.6.2-dev1104.0",
5
+ "version": "0.6.2-dev1114.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -57,23 +57,37 @@ timestamp_t ICUCalendarAdd::Operation(timestamp_t timestamp, interval_t interval
57
57
  const auto udate = UDate(millis);
58
58
  calendar->setTime(udate, status);
59
59
 
60
- // Add interval fields from lowest to highest
61
-
62
60
  // Break units apart to avoid overflow
63
- auto remaining = interval.micros / Interval::MICROS_PER_MSEC;
64
- calendar->add(UCAL_MILLISECOND, remaining % Interval::MSECS_PER_SEC, status);
65
-
66
- remaining /= Interval::MSECS_PER_SEC;
67
- calendar->add(UCAL_SECOND, remaining % Interval::SECS_PER_MINUTE, status);
68
-
69
- remaining /= Interval::SECS_PER_MINUTE;
70
- calendar->add(UCAL_MINUTE, remaining % Interval::MINS_PER_HOUR, status);
71
-
72
- remaining /= Interval::MINS_PER_HOUR;
73
- calendar->add(UCAL_HOUR, remaining, status);
74
-
75
- calendar->add(UCAL_DATE, interval.days, status);
76
- calendar->add(UCAL_MONTH, interval.months, status);
61
+ auto interval_h = interval.micros / Interval::MICROS_PER_MSEC;
62
+
63
+ const auto interval_ms = interval_h % Interval::MSECS_PER_SEC;
64
+ interval_h /= Interval::MSECS_PER_SEC;
65
+
66
+ const auto interval_s = interval_h % Interval::SECS_PER_MINUTE;
67
+ interval_h /= Interval::SECS_PER_MINUTE;
68
+
69
+ const auto interval_m = interval_h % Interval::MINS_PER_HOUR;
70
+ interval_h /= Interval::MINS_PER_HOUR;
71
+
72
+ if (interval.months < 0 || interval.days < 0 || interval.micros < 0) {
73
+ // Add interval fields from lowest to highest (non-ragged to ragged)
74
+ calendar->add(UCAL_MILLISECOND, interval_ms, status);
75
+ calendar->add(UCAL_SECOND, interval_s, status);
76
+ calendar->add(UCAL_MINUTE, interval_m, status);
77
+ calendar->add(UCAL_HOUR, interval_h, status);
78
+
79
+ calendar->add(UCAL_DATE, interval.days, status);
80
+ calendar->add(UCAL_MONTH, interval.months, status);
81
+ } else {
82
+ // Add interval fields from highest to lowest (ragged to non-ragged)
83
+ calendar->add(UCAL_MONTH, interval.months, status);
84
+ calendar->add(UCAL_DATE, interval.days, status);
85
+
86
+ calendar->add(UCAL_HOUR, interval_h, status);
87
+ calendar->add(UCAL_MINUTE, interval_m, status);
88
+ calendar->add(UCAL_SECOND, interval_s, status);
89
+ calendar->add(UCAL_MILLISECOND, interval_ms, status);
90
+ }
77
91
 
78
92
  return ICUDateFunc::GetTime(calendar, micros);
79
93
  }
@@ -112,14 +112,6 @@ int32_t ICUDateFunc::ExtractField(icu::Calendar *calendar, UCalendarDateFields f
112
112
  }
113
113
 
114
114
  int64_t ICUDateFunc::SubtractField(icu::Calendar *calendar, UCalendarDateFields field, timestamp_t end_date) {
115
- // ICU triggers the address sanitiser because it tries to left shift a negative value
116
- // when start_date > end_date. To avoid this, we swap the values and negate the result.
117
- const auto start_date = GetTimeUnsafe(calendar);
118
- if (start_date > end_date) {
119
- SetTime(calendar, end_date);
120
- return -SubtractField(calendar, field, start_date);
121
- }
122
-
123
115
  const int64_t millis = end_date.value / Interval::MICROS_PER_MSEC;
124
116
  const auto when = UDate(millis);
125
117
  UErrorCode status = U_ZERO_ERROR;
@@ -2350,7 +2350,7 @@ int32_t Calendar::fieldDifference(UDate targetMs, UCalendarDateFields field, UEr
2350
2350
  break;
2351
2351
  } else {
2352
2352
  min = max;
2353
- max <<= 1;
2353
+ max = ((uint32_t) max) << 1;
2354
2354
  if (max == 0) {
2355
2355
  // Field difference too large to fit into int32_t
2356
2356
  #if defined (U_DEBUG_CAL)
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.6.2-dev1104"
2
+ #define DUCKDB_VERSION "0.6.2-dev1114"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "a8e2c21b84"
5
+ #define DUCKDB_SOURCE_ID "51945c68c0"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"