Skip to content

Commit 03e5bc9

Browse files
duckdblabs-botgithub-actions[bot]
authored andcommitted
Update vendored DuckDB sources to 4d195b9091
1 parent f4a7440 commit 03e5bc9

File tree

17 files changed

+147
-119
lines changed

17 files changed

+147
-119
lines changed

src/duckdb/src/common/arrow/arrow_wrapper.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,25 @@ int ResultArrowArrayStreamWrapper::MyStreamGetNext(struct ArrowArrayStream *stre
130130
my_stream->column_types = result.types;
131131
my_stream->column_names = result.names;
132132
}
133-
idx_t result_count;
134-
ErrorData error;
135-
if (!ArrowUtil::TryFetchChunk(scan_state, result.client_properties, my_stream->batch_size, out, result_count, error,
136-
my_stream->extension_types)) {
137-
D_ASSERT(error.HasError());
138-
my_stream->last_error = error;
133+
134+
try {
135+
idx_t result_count;
136+
ErrorData error;
137+
if (!ArrowUtil::TryFetchChunk(scan_state, result.client_properties, my_stream->batch_size, out, result_count,
138+
error, my_stream->extension_types)) {
139+
D_ASSERT(error.HasError());
140+
my_stream->last_error = error;
141+
return -1;
142+
}
143+
if (result_count == 0) {
144+
// Nothing to output
145+
out->release = nullptr;
146+
}
147+
} catch (std::exception &e) {
148+
my_stream->last_error = ErrorData(e);
139149
return -1;
140150
}
141-
if (result_count == 0) {
142-
// Nothing to output
143-
out->release = nullptr;
144-
}
151+
145152
return 0;
146153
}
147154

src/duckdb/src/common/bignum.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ string_t BignumIntermediate::Add(Vector &result_vector, const BignumIntermediate
308308
auto target_data = target.GetDataWriteable();
309309
Bignum::SetHeader(target_data, 1, false);
310310
target_data[Bignum::BIGNUM_HEADER_SIZE] = 0;
311+
target.SetSizeAndFinalize(1 + Bignum::BIGNUM_HEADER_SIZE, result_size);
311312
return target;
312313

313314
} else if (is_absolute_bigger == SMALLER) {

src/duckdb/src/common/box_renderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,8 +1915,8 @@ void BoxRendererImplementation::ComputeRenderWidths(vector<RenderDataCollection>
19151915

19161916
// check if we shortened any columns that would be rendered and if we can expand them
19171917
// we only expand columns in the ".mode rows", and only if we haven't hidden any columns
1918-
if (shortened_columns && config.render_mode == RenderMode::ROWS && row_count + 5 < config.max_rows &&
1919-
pruned_columns.empty()) {
1918+
if (shortened_columns && config.render_mode == RenderMode::ROWS && row_count > 0 &&
1919+
row_count + 5 < config.max_rows && pruned_columns.empty()) {
19201920
max_rows_per_row = MaxValue<idx_t>(1, config.max_rows <= 5 ? 0 : (config.max_rows - 5) / row_count);
19211921
if (max_rows_per_row > 1) {
19221922
// we can expand rows - check if we should expand any rows

src/duckdb/src/common/enum_util.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,20 +383,19 @@ const StringUtil::EnumStringLiteral *GetAllowParserOverrideValues() {
383383
static constexpr StringUtil::EnumStringLiteral values[] {
384384
{ static_cast<uint32_t>(AllowParserOverride::DEFAULT_OVERRIDE), "DEFAULT" },
385385
{ static_cast<uint32_t>(AllowParserOverride::FALLBACK_OVERRIDE), "FALLBACK" },
386-
{ static_cast<uint32_t>(AllowParserOverride::STRICT_OVERRIDE), "STRICT" },
387-
{ static_cast<uint32_t>(AllowParserOverride::STRICT_WHEN_SUPPORTED), "STRICT_WHEN_SUPPORTED" }
386+
{ static_cast<uint32_t>(AllowParserOverride::STRICT_OVERRIDE), "STRICT" }
388387
};
389388
return values;
390389
}
391390

392391
template<>
393392
const char* EnumUtil::ToChars<AllowParserOverride>(AllowParserOverride value) {
394-
return StringUtil::EnumToString(GetAllowParserOverrideValues(), 4, "AllowParserOverride", static_cast<uint32_t>(value));
393+
return StringUtil::EnumToString(GetAllowParserOverrideValues(), 3, "AllowParserOverride", static_cast<uint32_t>(value));
395394
}
396395

397396
template<>
398397
AllowParserOverride EnumUtil::FromString<AllowParserOverride>(const char *value) {
399-
return static_cast<AllowParserOverride>(StringUtil::StringToEnum(GetAllowParserOverrideValues(), 4, "AllowParserOverride", value));
398+
return static_cast<AllowParserOverride>(StringUtil::StringToEnum(GetAllowParserOverrideValues(), 3, "AllowParserOverride", value));
400399
}
401400

402401
const StringUtil::EnumStringLiteral *GetAlterDatabaseTypeValues() {

src/duckdb/src/common/error_data.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ void ErrorData::AddErrorLocation(const string &query) {
142142
auto entry = extra_info.find("position");
143143
if (entry != extra_info.end()) {
144144
raw_message = QueryErrorContext::Format(query, raw_message, std::stoull(entry->second));
145+
extra_info.erase(entry);
145146
}
146147
}
147148
{

src/duckdb/src/function/table/version/pragma_version.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef DUCKDB_PATCH_VERSION
2-
#define DUCKDB_PATCH_VERSION "2-dev118"
2+
#define DUCKDB_PATCH_VERSION "2-dev189"
33
#endif
44
#ifndef DUCKDB_MINOR_VERSION
55
#define DUCKDB_MINOR_VERSION 5
@@ -8,10 +8,10 @@
88
#define DUCKDB_MAJOR_VERSION 1
99
#endif
1010
#ifndef DUCKDB_VERSION
11-
#define DUCKDB_VERSION "v1.5.2-dev118"
11+
#define DUCKDB_VERSION "v1.5.2-dev189"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "c23c958a93"
14+
#define DUCKDB_SOURCE_ID "4d195b9091"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

src/duckdb/src/include/duckdb/common/arrow/arrow_buffer.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,16 @@ struct ArrowBuffer {
8787

8888
private:
8989
void ReserveInternal(idx_t bytes) {
90+
data_ptr_t new_ptr;
9091
if (dataptr) {
91-
dataptr = data_ptr_cast(realloc(dataptr, bytes));
92+
new_ptr = data_ptr_cast(realloc(dataptr, bytes));
9293
} else {
93-
dataptr = data_ptr_cast(malloc(bytes));
94+
new_ptr = data_ptr_cast(malloc(bytes));
9495
}
96+
if (!new_ptr) {
97+
throw OutOfMemoryException("ArrowBuffer: failed to allocate %llu bytes", bytes);
98+
}
99+
dataptr = new_ptr;
95100
capacity = bytes;
96101
}
97102

src/duckdb/src/include/duckdb/common/enums/allow_parser_override.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212

1313
namespace duckdb {
1414

15-
enum class AllowParserOverride : uint8_t {
16-
DEFAULT_OVERRIDE,
17-
FALLBACK_OVERRIDE,
18-
STRICT_OVERRIDE,
19-
STRICT_WHEN_SUPPORTED
20-
};
15+
enum class AllowParserOverride : uint8_t { DEFAULT_OVERRIDE, FALLBACK_OVERRIDE, STRICT_OVERRIDE };
2116

2217
} // namespace duckdb

src/duckdb/src/include/duckdb/function/aggregate/minmax_n_helpers.hpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "duckdb/common/enums/order_type.hpp"
1010
#include "duckdb/function/aggregate_function.hpp"
1111
#include "duckdb/function/create_sort_key.hpp"
12+
#include <new>
1213

1314
namespace duckdb {
1415

@@ -180,9 +181,8 @@ class BinaryAggregateHeap {
180181

181182
void Initialize(ArenaAllocator &allocator, const idx_t capacity_p) {
182183
capacity = capacity_p;
183-
auto ptr = allocator.AllocateAligned(capacity * sizeof(STORAGE_TYPE));
184-
memset(ptr, 0, capacity * sizeof(STORAGE_TYPE));
185-
heap = reinterpret_cast<STORAGE_TYPE *>(ptr);
184+
allocated_capacity = 0;
185+
heap = nullptr;
186186
size = 0;
187187
}
188188

@@ -201,6 +201,9 @@ class BinaryAggregateHeap {
201201

202202
// If the heap is not full, insert the value into a new slot
203203
if (size < capacity) {
204+
if (size == allocated_capacity) {
205+
Grow(allocator);
206+
}
204207
heap[size].first.Assign(allocator, key);
205208
heap[size].second.Assign(allocator, value);
206209
size++;
@@ -233,13 +236,33 @@ class BinaryAggregateHeap {
233236
}
234237

235238
private:
239+
void Grow(ArenaAllocator &allocator) {
240+
D_ASSERT(allocated_capacity < capacity);
241+
const auto old_allocated_capacity = allocated_capacity;
242+
if (allocated_capacity == 0) {
243+
allocated_capacity = 1;
244+
} else if (allocated_capacity > capacity / 2) {
245+
allocated_capacity = capacity;
246+
} else {
247+
allocated_capacity *= 2;
248+
}
249+
250+
const auto old_size = old_allocated_capacity * sizeof(STORAGE_TYPE);
251+
const auto new_size = allocated_capacity * sizeof(STORAGE_TYPE);
252+
auto ptr = heap ? allocator.ReallocateAligned(reinterpret_cast<data_ptr_t>(heap), old_size, new_size)
253+
: allocator.AllocateAligned(new_size);
254+
memset(ptr + old_size, 0, new_size - old_size);
255+
heap = reinterpret_cast<STORAGE_TYPE *>(ptr);
256+
}
257+
236258
static bool Compare(const STORAGE_TYPE &left, const STORAGE_TYPE &right) {
237259
return K_COMPARATOR::Operation(left.first.value, right.first.value);
238260
}
239261

240-
idx_t capacity;
241-
STORAGE_TYPE *heap;
242-
idx_t size;
262+
idx_t capacity = 0;
263+
idx_t allocated_capacity = 0;
264+
STORAGE_TYPE *heap = nullptr;
265+
idx_t size = 0;
243266
};
244267

245268
enum class ArgMinMaxNullHandling { IGNORE_ANY_NULL, HANDLE_ARG_NULL, HANDLE_ANY_NULL };

src/duckdb/src/include/duckdb/optimizer/topn_window_elimination.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class TopNWindowElimination : public BaseColumnPruner {
5151

5252
vector<unique_ptr<Expression>> GenerateAggregatePayload(const vector<ColumnBinding> &bindings,
5353
const LogicalWindow &window, map<idx_t, idx_t> &group_idxs);
54-
vector<ColumnBinding> TraverseProjectionBindings(const std::vector<ColumnBinding> &old_bindings,
55-
reference<LogicalOperator> &op);
54+
bool TraverseProjectionBindings(const vector<ColumnBinding> &old_bindings, reference<LogicalOperator> &op,
55+
vector<ColumnBinding> &new_bindings);
5656
unique_ptr<Expression> CreateAggregateExpression(vector<unique_ptr<Expression>> aggregate_params, bool requires_arg,
5757
const TopNWindowEliminationParameters &params) const;
5858
unique_ptr<Expression> CreateRowNumberGenerator(unique_ptr<Expression> aggregate_column_ref) const;

0 commit comments

Comments
 (0)