duckdb 0.2.10-dev345.0 → 0.2.10-dev362.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.cpp +30 -10
- package/src/duckdb.hpp +6 -3
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -35991,7 +35991,7 @@ int64_t Interval::GetNanoseconds(interval_t val) {
|
|
|
35991
35991
|
|
|
35992
35992
|
return nano;
|
|
35993
35993
|
}
|
|
35994
|
-
interval_t Interval::
|
|
35994
|
+
interval_t Interval::GetAge(timestamp_t timestamp_1, timestamp_t timestamp_2) {
|
|
35995
35995
|
date_t date1, date2;
|
|
35996
35996
|
dtime_t time1, time2;
|
|
35997
35997
|
|
|
@@ -36079,6 +36079,18 @@ interval_t Interval::GetDifference(timestamp_t timestamp_1, timestamp_t timestam
|
|
|
36079
36079
|
|
|
36080
36080
|
return interval;
|
|
36081
36081
|
}
|
|
36082
|
+
interval_t Interval::GetDifference(timestamp_t timestamp_1, timestamp_t timestamp_2) {
|
|
36083
|
+
const auto us_1 = Timestamp::GetEpochMicroSeconds(timestamp_1);
|
|
36084
|
+
const auto us_2 = Timestamp::GetEpochMicroSeconds(timestamp_2);
|
|
36085
|
+
const auto delta_us = us_1 - us_2;
|
|
36086
|
+
|
|
36087
|
+
interval_t result;
|
|
36088
|
+
result.months = 0;
|
|
36089
|
+
result.days = delta_us / Interval::MICROS_PER_DAY;
|
|
36090
|
+
result.micros = delta_us % Interval::MICROS_PER_DAY;
|
|
36091
|
+
|
|
36092
|
+
return result;
|
|
36093
|
+
}
|
|
36082
36094
|
|
|
36083
36095
|
static void NormalizeIntervalEntries(interval_t input, int64_t &months, int64_t &days, int64_t µs) {
|
|
36084
36096
|
int64_t extra_months_d = input.days / Interval::DAYS_PER_MONTH;
|
|
@@ -49217,7 +49229,6 @@ void Leaf::Insert(row_t row_id) {
|
|
|
49217
49229
|
row_ids[num_elements++] = row_id;
|
|
49218
49230
|
}
|
|
49219
49231
|
|
|
49220
|
-
//! TODO: Maybe shrink array dynamically?
|
|
49221
49232
|
void Leaf::Remove(row_t row_id) {
|
|
49222
49233
|
idx_t entry_offset = INVALID_INDEX;
|
|
49223
49234
|
for (idx_t i = 0; i < num_elements; i++) {
|
|
@@ -49230,8 +49241,19 @@ void Leaf::Remove(row_t row_id) {
|
|
|
49230
49241
|
return;
|
|
49231
49242
|
}
|
|
49232
49243
|
num_elements--;
|
|
49233
|
-
|
|
49234
|
-
|
|
49244
|
+
if (capacity > 2 && num_elements < capacity / 2) {
|
|
49245
|
+
// Shrink array, if less than half full
|
|
49246
|
+
auto new_row_id = unique_ptr<row_t[]>(new row_t[capacity / 2]);
|
|
49247
|
+
memcpy(new_row_id.get(), row_ids.get(), entry_offset * sizeof(row_t));
|
|
49248
|
+
memcpy(new_row_id.get() + entry_offset, row_ids.get() + entry_offset + 1,
|
|
49249
|
+
(num_elements - entry_offset) * sizeof(row_t));
|
|
49250
|
+
capacity /= 2;
|
|
49251
|
+
row_ids = move(new_row_id);
|
|
49252
|
+
} else {
|
|
49253
|
+
// Copy the rest
|
|
49254
|
+
for (idx_t j = entry_offset; j < num_elements; j++) {
|
|
49255
|
+
row_ids[j] = row_ids[j + 1];
|
|
49256
|
+
}
|
|
49235
49257
|
}
|
|
49236
49258
|
}
|
|
49237
49259
|
|
|
@@ -49327,7 +49349,6 @@ Node16::Node16(ART &art, size_t compression_length) : Node(art, NodeType::N16, c
|
|
|
49327
49349
|
memset(key, 16, sizeof(key));
|
|
49328
49350
|
}
|
|
49329
49351
|
|
|
49330
|
-
// TODO : In the future this can be performed using SIMD (#include <emmintrin.h> x86 SSE intrinsics)
|
|
49331
49352
|
idx_t Node16::GetChildPos(uint8_t k) {
|
|
49332
49353
|
for (idx_t pos = 0; pos < count; pos++) {
|
|
49333
49354
|
if (key[pos] == k) {
|
|
@@ -76572,7 +76593,7 @@ static void AgeFunctionStandard(DataChunk &input, ExpressionState &state, Vector
|
|
|
76572
76593
|
auto current_timestamp = Timestamp::GetCurrentTimestamp();
|
|
76573
76594
|
|
|
76574
76595
|
UnaryExecutor::Execute<timestamp_t, interval_t>(input.data[0], result, input.size(), [&](timestamp_t input) {
|
|
76575
|
-
return Interval::
|
|
76596
|
+
return Interval::GetAge(current_timestamp, input);
|
|
76576
76597
|
});
|
|
76577
76598
|
}
|
|
76578
76599
|
|
|
@@ -76581,7 +76602,7 @@ static void AgeFunction(DataChunk &input, ExpressionState &state, Vector &result
|
|
|
76581
76602
|
|
|
76582
76603
|
BinaryExecutor::Execute<timestamp_t, timestamp_t, interval_t>(
|
|
76583
76604
|
input.data[0], input.data[1], result, input.size(),
|
|
76584
|
-
[&](timestamp_t input1, timestamp_t input2) { return Interval::
|
|
76605
|
+
[&](timestamp_t input1, timestamp_t input2) { return Interval::GetAge(input1, input2); });
|
|
76585
76606
|
}
|
|
76586
76607
|
|
|
76587
76608
|
void AgeFun::RegisterFunction(BuiltinFunctions &set) {
|
|
@@ -77951,7 +77972,7 @@ struct DateSub {
|
|
|
77951
77972
|
// Our interval difference will now give the correct result.
|
|
77952
77973
|
// Note that PG gives different interval subtraction results,
|
|
77953
77974
|
// so if we change this we will have to reimplement.
|
|
77954
|
-
return Interval::
|
|
77975
|
+
return Interval::GetAge(end_ts, start_ts).months;
|
|
77955
77976
|
}
|
|
77956
77977
|
};
|
|
77957
77978
|
|
|
@@ -129685,8 +129706,7 @@ SetScope ToSetScope(duckdb_libpgquery::VariableSetScope pg_scope) {
|
|
|
129685
129706
|
case duckdb_libpgquery::VariableSetScope::VAR_SET_SCOPE_GLOBAL:
|
|
129686
129707
|
return SetScope::GLOBAL;
|
|
129687
129708
|
case duckdb_libpgquery::VariableSetScope::VAR_SET_SCOPE_DEFAULT:
|
|
129688
|
-
|
|
129689
|
-
return SetScope::GLOBAL;
|
|
129709
|
+
return SetScope::SESSION;
|
|
129690
129710
|
default:
|
|
129691
129711
|
throw InternalException("Unexpected pg_scope: %d", pg_scope);
|
|
129692
129712
|
}
|
package/src/duckdb.hpp
CHANGED
|
@@ -10,8 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
10
10
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
|
-
#define DUCKDB_SOURCE_ID "
|
|
14
|
-
#define DUCKDB_VERSION "0.2.10-
|
|
13
|
+
#define DUCKDB_SOURCE_ID "622ee7e43"
|
|
14
|
+
#define DUCKDB_VERSION "0.2.10-dev362"
|
|
15
15
|
//===----------------------------------------------------------------------===//
|
|
16
16
|
// DuckDB
|
|
17
17
|
//
|
|
@@ -5964,7 +5964,10 @@ public:
|
|
|
5964
5964
|
//! Get Interval in Nanoseconds
|
|
5965
5965
|
static int64_t GetNanoseconds(interval_t val);
|
|
5966
5966
|
|
|
5967
|
-
//! Returns the
|
|
5967
|
+
//! Returns the age between two timestamps (including 30 day months)
|
|
5968
|
+
static interval_t GetAge(timestamp_t timestamp_1, timestamp_t timestamp_2);
|
|
5969
|
+
|
|
5970
|
+
//! Returns the exact difference between two timestamps (days and seconds)
|
|
5968
5971
|
static interval_t GetDifference(timestamp_t timestamp_1, timestamp_t timestamp_2);
|
|
5969
5972
|
|
|
5970
5973
|
//! Comparison operators
|