Skip to content

Commit 955c3a0

Browse files
Update vendored DuckDB sources to 0086304
1 parent 0086304 commit 955c3a0

File tree

64 files changed

+621
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+621
-405
lines changed

Diff for: src/duckdb/extension/core_functions/include/core_functions/aggregate/quantile_sort_tree.hpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@
88

99
#pragma once
1010

11-
#include "duckdb/common/sort/sort.hpp"
1211
#include "duckdb/common/types/column/column_data_collection.hpp"
13-
#include "duckdb/common/types/row/row_layout.hpp"
1412
#include "core_functions/aggregate/quantile_helpers.hpp"
15-
#include "duckdb/execution/merge_sort_tree.hpp"
1613
#include "duckdb/common/operator/cast_operators.hpp"
1714
#include "duckdb/common/operator/multiply.hpp"
1815
#include "duckdb/planner/expression/bound_constant_expression.hpp"
1916
#include "duckdb/function/window/window_index_tree.hpp"
2017
#include <algorithm>
21-
#include <numeric>
2218
#include <stdlib.h>
2319
#include <utility>
2420

@@ -89,7 +85,7 @@ struct QuantileDirect {
8985
using RESULT_TYPE = T;
9086

9187
inline const INPUT_TYPE &operator()(const INPUT_TYPE &x) const {
92-
return x;
88+
return x; // NOLINT
9389
}
9490
};
9591

@@ -365,7 +361,7 @@ struct QuantileSortTree {
365361
}
366362

367363
inline idx_t SelectNth(const SubFrames &frames, size_t n) const {
368-
return index_tree->SelectNth(frames, n);
364+
return index_tree->SelectNth(frames, n).first;
369365
}
370366

371367
template <typename INPUT_TYPE, typename RESULT_TYPE, bool DISCRETE>

Diff for: src/duckdb/extension/core_functions/include/core_functions/aggregate/quantile_state.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ struct WindowQuantileState {
207207
dest[0] = skips[0].second;
208208
if (skips.size() > 1) {
209209
dest[1] = skips[1].second;
210+
} else {
211+
// Avoid UMA
212+
dest[1] = skips[0].second;
210213
}
211214
return interp.template Extract<INPUT_TYPE, RESULT_TYPE>(dest.data(), result);
212215
} catch (const duckdb_skiplistlib::skip_list::IndexError &idx_err) {

Diff for: src/duckdb/extension/parquet/geo_parquet.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,9 @@ GeoParquetColumnMetadataWriter::GeoParquetColumnMetadataWriter(ClientContext &co
6060
auto &catalog = Catalog::GetSystemCatalog(context);
6161

6262
// These functions are required to extract the geometry type, ZM flag and bounding box from a WKB blob
63-
auto &type_func_set =
64-
catalog.GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, DEFAULT_SCHEMA, "st_geometrytype")
65-
.Cast<ScalarFunctionCatalogEntry>();
66-
auto &flag_func_set = catalog.GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, DEFAULT_SCHEMA, "st_zmflag")
67-
.Cast<ScalarFunctionCatalogEntry>();
68-
auto &bbox_func_set = catalog.GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, DEFAULT_SCHEMA, "st_extent")
69-
.Cast<ScalarFunctionCatalogEntry>();
63+
auto &type_func_set = catalog.GetEntry<ScalarFunctionCatalogEntry>(context, DEFAULT_SCHEMA, "st_geometrytype");
64+
auto &flag_func_set = catalog.GetEntry<ScalarFunctionCatalogEntry>(context, DEFAULT_SCHEMA, "st_zmflag");
65+
auto &bbox_func_set = catalog.GetEntry<ScalarFunctionCatalogEntry>(context, DEFAULT_SCHEMA, "st_extent");
7066

7167
auto wkb_type = LogicalType(LogicalTypeId::BLOB);
7268
wkb_type.SetAlias("WKB_BLOB");
@@ -404,8 +400,7 @@ unique_ptr<ColumnReader> GeoParquetFileMetadata::CreateColumnReader(ParquetReade
404400
column.geometry_encoding == GeoParquetColumnEncoding::WKB) {
405401
// Look for a conversion function in the catalog
406402
auto &conversion_func_set =
407-
catalog.GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, DEFAULT_SCHEMA, "st_geomfromwkb")
408-
.Cast<ScalarFunctionCatalogEntry>();
403+
catalog.GetEntry<ScalarFunctionCatalogEntry>(context, DEFAULT_SCHEMA, "st_geomfromwkb");
409404
auto conversion_func = conversion_func_set.functions.GetFunctionByArguments(context, {LogicalType::BLOB});
410405

411406
// Create a bound function call expression

Diff for: src/duckdb/src/catalog/catalog.cpp

+146-96
Large diffs are not rendered by default.

Diff for: src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -348,19 +348,19 @@ void DuckSchemaEntry::OnDropEntry(CatalogTransaction transaction, CatalogEntry &
348348
local_storage.DropTable(table_entry.GetStorage());
349349
}
350350

351-
optional_ptr<CatalogEntry> DuckSchemaEntry::GetEntry(CatalogTransaction transaction, CatalogType type,
352-
const string &name) {
353-
return GetCatalogSet(type).GetEntry(transaction, name);
351+
optional_ptr<CatalogEntry> DuckSchemaEntry::LookupEntry(CatalogTransaction transaction,
352+
const EntryLookupInfo &lookup_info) {
353+
return GetCatalogSet(lookup_info.GetCatalogType()).GetEntry(transaction, lookup_info.GetEntryName());
354354
}
355355

356-
CatalogSet::EntryLookup DuckSchemaEntry::GetEntryDetailed(CatalogTransaction transaction, CatalogType type,
357-
const string &name) {
358-
return GetCatalogSet(type).GetEntryDetailed(transaction, name);
356+
CatalogSet::EntryLookup DuckSchemaEntry::LookupEntryDetailed(CatalogTransaction transaction,
357+
const EntryLookupInfo &lookup_info) {
358+
return GetCatalogSet(lookup_info.GetCatalogType()).GetEntryDetailed(transaction, lookup_info.GetEntryName());
359359
}
360360

361-
SimilarCatalogEntry DuckSchemaEntry::GetSimilarEntry(CatalogTransaction transaction, CatalogType type,
362-
const string &name) {
363-
return GetCatalogSet(type).SimilarEntry(transaction, name);
361+
SimilarCatalogEntry DuckSchemaEntry::GetSimilarEntry(CatalogTransaction transaction,
362+
const EntryLookupInfo &lookup_info) {
363+
return GetCatalogSet(lookup_info.GetCatalogType()).SimilarEntry(transaction, lookup_info.GetEntryName());
364364
}
365365

366366
CatalogSet &DuckSchemaEntry::GetCatalogSet(CatalogType type) {

Diff for: src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp

+13-7
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ optional_ptr<CatalogEntry> SchemaCatalogEntry::CreateIndex(ClientContext &contex
2727
return CreateIndex(GetCatalogTransaction(context), info, table);
2828
}
2929

30-
SimilarCatalogEntry SchemaCatalogEntry::GetSimilarEntry(CatalogTransaction transaction, CatalogType type,
31-
const string &name) {
30+
SimilarCatalogEntry SchemaCatalogEntry::GetSimilarEntry(CatalogTransaction transaction,
31+
const EntryLookupInfo &lookup_info) {
3232
SimilarCatalogEntry result;
33-
Scan(transaction.GetContext(), type, [&](CatalogEntry &entry) {
34-
auto entry_score = StringUtil::SimilarityRating(entry.name, name);
33+
Scan(transaction.GetContext(), lookup_info.GetCatalogType(), [&](CatalogEntry &entry) {
34+
auto entry_score = StringUtil::SimilarityRating(entry.name, lookup_info.GetEntryName());
3535
if (entry_score > result.score) {
3636
result.score = entry_score;
3737
result.name = entry.name;
@@ -40,12 +40,18 @@ SimilarCatalogEntry SchemaCatalogEntry::GetSimilarEntry(CatalogTransaction trans
4040
return result;
4141
}
4242

43+
optional_ptr<CatalogEntry> SchemaCatalogEntry::GetEntry(CatalogTransaction transaction, CatalogType type,
44+
const string &name) {
45+
EntryLookupInfo lookup_info(type, name);
46+
return LookupEntry(transaction, lookup_info);
47+
}
48+
4349
//! This should not be used, it's only implemented to not put the burden of implementing it on every derived class of
4450
//! SchemaCatalogEntry
45-
CatalogSet::EntryLookup SchemaCatalogEntry::GetEntryDetailed(CatalogTransaction transaction, CatalogType type,
46-
const string &name) {
51+
CatalogSet::EntryLookup SchemaCatalogEntry::LookupEntryDetailed(CatalogTransaction transaction,
52+
const EntryLookupInfo &lookup_info) {
4753
CatalogSet::EntryLookup result;
48-
result.result = GetEntry(transaction, type, name);
54+
result.result = LookupEntry(transaction, lookup_info);
4955
if (!result.result) {
5056
result.reason = CatalogSet::EntryLookup::FailureReason::DELETED;
5157
} else {

Diff for: src/duckdb/src/catalog/catalog_entry_retriever.cpp

+16-17
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace duckdb {
1313

1414
LogicalType CatalogEntryRetriever::GetType(Catalog &catalog, const string &schema, const string &name,
1515
OnEntryNotFound on_entry_not_found) {
16-
QueryErrorContext error_context;
17-
auto result = GetEntry(CatalogType::TYPE_ENTRY, catalog, schema, name, on_entry_not_found, error_context);
16+
EntryLookupInfo lookup_info(CatalogType::TYPE_ENTRY, name);
17+
auto result = GetEntry(catalog, schema, lookup_info, on_entry_not_found);
1818
if (!result) {
1919
return LogicalType::INVALID;
2020
}
@@ -24,26 +24,25 @@ LogicalType CatalogEntryRetriever::GetType(Catalog &catalog, const string &schem
2424

2525
LogicalType CatalogEntryRetriever::GetType(const string &catalog, const string &schema, const string &name,
2626
OnEntryNotFound on_entry_not_found) {
27-
QueryErrorContext error_context;
28-
auto result = GetEntry(CatalogType::TYPE_ENTRY, catalog, schema, name, on_entry_not_found, error_context);
27+
EntryLookupInfo lookup_info(CatalogType::TYPE_ENTRY, name);
28+
auto result = GetEntry(catalog, schema, lookup_info, on_entry_not_found);
2929
if (!result) {
3030
return LogicalType::INVALID;
3131
}
3232
auto &type_entry = result->Cast<TypeCatalogEntry>();
3333
return type_entry.user_type;
3434
}
3535

36-
optional_ptr<CatalogEntry> CatalogEntryRetriever::GetEntry(CatalogType type, const string &catalog,
37-
const string &schema, const string &name,
38-
OnEntryNotFound on_entry_not_found,
39-
QueryErrorContext error_context) {
40-
return ReturnAndCallback(Catalog::GetEntry(*this, type, catalog, schema, name, on_entry_not_found, error_context));
36+
optional_ptr<CatalogEntry> CatalogEntryRetriever::GetEntry(const string &catalog, const string &schema,
37+
const EntryLookupInfo &lookup_info,
38+
OnEntryNotFound on_entry_not_found) {
39+
return ReturnAndCallback(Catalog::GetEntry(*this, catalog, schema, lookup_info, on_entry_not_found));
4140
}
4241

43-
optional_ptr<SchemaCatalogEntry> CatalogEntryRetriever::GetSchema(const string &catalog, const string &name,
44-
OnEntryNotFound on_entry_not_found,
45-
QueryErrorContext error_context) {
46-
auto result = Catalog::GetSchema(*this, catalog, name, on_entry_not_found, error_context);
42+
optional_ptr<SchemaCatalogEntry> CatalogEntryRetriever::GetSchema(const string &catalog,
43+
const EntryLookupInfo &schema_lookup,
44+
OnEntryNotFound on_entry_not_found) {
45+
auto result = Catalog::GetSchema(*this, catalog, schema_lookup, on_entry_not_found);
4746
if (!result) {
4847
return result;
4948
}
@@ -54,10 +53,10 @@ optional_ptr<SchemaCatalogEntry> CatalogEntryRetriever::GetSchema(const string &
5453
return result;
5554
}
5655

57-
optional_ptr<CatalogEntry> CatalogEntryRetriever::GetEntry(CatalogType type, Catalog &catalog, const string &schema,
58-
const string &name, OnEntryNotFound on_entry_not_found,
59-
QueryErrorContext error_context) {
60-
return ReturnAndCallback(catalog.GetEntry(*this, type, schema, name, on_entry_not_found, error_context));
56+
optional_ptr<CatalogEntry> CatalogEntryRetriever::GetEntry(Catalog &catalog, const string &schema,
57+
const EntryLookupInfo &lookup_info,
58+
OnEntryNotFound on_entry_not_found) {
59+
return ReturnAndCallback(catalog.GetEntry(*this, schema, lookup_info, on_entry_not_found));
6160
}
6261

6362
optional_ptr<CatalogEntry> CatalogEntryRetriever::ReturnAndCallback(optional_ptr<CatalogEntry> result) {

Diff for: src/duckdb/src/catalog/dependency_manager.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ void DependencyManager::VerifyExistence(CatalogTransaction transaction, Dependen
455455

456456
if (type != CatalogType::SCHEMA_ENTRY && lookup_result.result) {
457457
auto &schema_entry = lookup_result.result->Cast<SchemaCatalogEntry>();
458-
lookup_result = schema_entry.GetEntryDetailed(transaction, type, name);
458+
EntryLookupInfo lookup_info(type, name);
459+
lookup_result = schema_entry.LookupEntryDetailed(transaction, lookup_info);
459460
}
460461

461462
if (lookup_result.reason == CatalogSet::EntryLookup::FailureReason::DELETED) {

Diff for: src/duckdb/src/catalog/duck_catalog.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,15 @@ CatalogSet &DuckCatalog::GetSchemaCatalogSet() {
123123
return *schemas;
124124
}
125125

126-
optional_ptr<SchemaCatalogEntry> DuckCatalog::GetSchema(CatalogTransaction transaction, const string &schema_name,
127-
OnEntryNotFound if_not_found, QueryErrorContext error_context) {
126+
optional_ptr<SchemaCatalogEntry> DuckCatalog::LookupSchema(CatalogTransaction transaction,
127+
const EntryLookupInfo &schema_lookup,
128+
OnEntryNotFound if_not_found) {
129+
auto &schema_name = schema_lookup.GetEntryName();
128130
D_ASSERT(!schema_name.empty());
129131
auto entry = schemas->GetEntry(transaction, schema_name);
130132
if (!entry) {
131133
if (if_not_found == OnEntryNotFound::THROW_EXCEPTION) {
132-
throw CatalogException(error_context, "Schema with name %s does not exist!", schema_name);
134+
throw CatalogException(schema_lookup.GetErrorContext(), "Schema with name %s does not exist!", schema_name);
133135
}
134136
return nullptr;
135137
}

Diff for: src/duckdb/src/catalog/entry_lookup_info.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "duckdb/catalog/entry_lookup_info.hpp"
2+
3+
namespace duckdb {
4+
5+
EntryLookupInfo::EntryLookupInfo(CatalogType catalog_type_p, const string &name_p, QueryErrorContext error_context_p)
6+
: catalog_type(catalog_type_p), name(name_p), error_context(error_context_p) {
7+
}
8+
9+
CatalogType EntryLookupInfo::GetCatalogType() const {
10+
return catalog_type;
11+
}
12+
13+
const string &EntryLookupInfo::GetEntryName() const {
14+
return name;
15+
}
16+
17+
const QueryErrorContext &EntryLookupInfo::GetErrorContext() const {
18+
return error_context;
19+
}
20+
21+
} // namespace duckdb

Diff for: src/duckdb/src/common/types/row/tuple_data_segment.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ void TupleDataChunkPart::SetHeapEmpty() {
1515
base_heap_ptr = nullptr;
1616
}
1717

18-
void SwapTupleDataChunkPart(TupleDataChunkPart &a, TupleDataChunkPart &b) {
19-
std::swap(a.row_block_index, b.row_block_index);
20-
std::swap(a.row_block_offset, b.row_block_offset);
21-
std::swap(a.heap_block_index, b.heap_block_index);
22-
std::swap(a.heap_block_offset, b.heap_block_offset);
23-
std::swap(a.base_heap_ptr, b.base_heap_ptr);
24-
std::swap(a.total_heap_size, b.total_heap_size);
25-
std::swap(a.count, b.count);
18+
void MoveTupleDataChunkPart(TupleDataChunkPart &a, TupleDataChunkPart &b) {
19+
a.row_block_index = b.row_block_index;
20+
a.row_block_offset = b.row_block_offset;
21+
a.heap_block_index = b.heap_block_index;
22+
a.heap_block_offset = b.heap_block_offset;
23+
a.base_heap_ptr = b.base_heap_ptr;
24+
a.total_heap_size = b.total_heap_size;
25+
a.count = b.count;
2626
std::swap(a.lock, b.lock);
2727
}
2828

2929
TupleDataChunkPart::TupleDataChunkPart(TupleDataChunkPart &&other) noexcept : lock((other.lock)) {
30-
SwapTupleDataChunkPart(*this, other);
30+
MoveTupleDataChunkPart(*this, other);
3131
}
3232

3333
TupleDataChunkPart &TupleDataChunkPart::operator=(TupleDataChunkPart &&other) noexcept {
34-
SwapTupleDataChunkPart(*this, other);
34+
MoveTupleDataChunkPart(*this, other);
3535
return *this;
3636
}
3737

0 commit comments

Comments
 (0)