Skip to content

Commit 356fe32

Browse files
duckdblabs-botgithub-actions[bot]
authored andcommitted
Update vendored DuckDB sources to 3a3967aa81
1 parent 3c7d074 commit 356fe32

25 files changed

Lines changed: 276 additions & 203 deletions

File tree

src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@ namespace duckdb {
1717
void ViewCatalogEntry::Initialize(CreateViewInfo &info) {
1818
query = std::move(info.query);
1919
this->aliases = info.aliases;
20-
if (!info.types.empty() && !info.names.empty()) {
20+
if (!info.types.empty()) {
2121
bind_state = ViewBindState::BOUND;
2222
view_columns = make_shared_ptr<ViewColumnInfo>();
2323
view_columns->types = info.types;
2424
view_columns->names = info.names;
25-
if (info.types.size() != info.names.size()) {
26-
throw InternalException("Error creating view %s - view types / names size mismatch (%d types, %d names)",
27-
name, info.types.size(), info.names.size());
25+
if (view_columns->names.empty()) {
26+
// DuckDB v0.9.2 and below store their names in the "aliases" field
27+
view_columns->names = info.aliases;
28+
}
29+
if (view_columns->types.size() != view_columns->names.size()) {
30+
throw InvalidInputException(
31+
"Error creating view %s - view types / names size mismatch (%d types, %d names)", name,
32+
view_columns->types.size(), view_columns->names.size());
2833
}
2934
}
3035
this->temporary = info.temporary;

src/duckdb/src/common/enum_util.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,25 +1169,6 @@ CompressedMaterializationDirection EnumUtil::FromString<CompressedMaterializatio
11691169
return static_cast<CompressedMaterializationDirection>(StringUtil::StringToEnum(GetCompressedMaterializationDirectionValues(), 3, "CompressedMaterializationDirection", value));
11701170
}
11711171

1172-
const StringUtil::EnumStringLiteral *GetCompressionFunctionSetLoadResultValues() {
1173-
static constexpr StringUtil::EnumStringLiteral values[] {
1174-
{ static_cast<uint32_t>(CompressionFunctionSetLoadResult::ALREADY_LOADED_BEFORE_LOCK), "ALREADY_LOADED_BEFORE_LOCK" },
1175-
{ static_cast<uint32_t>(CompressionFunctionSetLoadResult::ALREADY_LOADED_AFTER_LOCK), "ALREADY_LOADED_AFTER_LOCK" },
1176-
{ static_cast<uint32_t>(CompressionFunctionSetLoadResult::LAZILY_LOADED), "LAZILY_LOADED" }
1177-
};
1178-
return values;
1179-
}
1180-
1181-
template<>
1182-
const char* EnumUtil::ToChars<CompressionFunctionSetLoadResult>(CompressionFunctionSetLoadResult value) {
1183-
return StringUtil::EnumToString(GetCompressionFunctionSetLoadResultValues(), 3, "CompressionFunctionSetLoadResult", static_cast<uint32_t>(value));
1184-
}
1185-
1186-
template<>
1187-
CompressionFunctionSetLoadResult EnumUtil::FromString<CompressionFunctionSetLoadResult>(const char *value) {
1188-
return static_cast<CompressionFunctionSetLoadResult>(StringUtil::StringToEnum(GetCompressionFunctionSetLoadResultValues(), 3, "CompressionFunctionSetLoadResult", value));
1189-
}
1190-
11911172
const StringUtil::EnumStringLiteral *GetCompressionTypeValues() {
11921173
static constexpr StringUtil::EnumStringLiteral values[] {
11931174
{ static_cast<uint32_t>(CompressionType::COMPRESSION_AUTO), "AUTO" },

src/duckdb/src/common/multi_file/multi_file_column_mapper.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,8 +1035,20 @@ static unique_ptr<TableFilter> TryCastTableFilter(const TableFilter &global_filt
10351035
}
10361036

10371037
void SetIndexToZero(unique_ptr<Expression> &root_expr) {
1038+
#ifdef DEBUG
1039+
optional_idx index;
1040+
ExpressionIterator::VisitExpressionMutable<BoundReferenceExpression>(root_expr, [&](BoundReferenceExpression &ref,
1041+
unique_ptr<Expression> &expr) {
1042+
if (index.IsValid() && index.GetIndex() != ref.index) {
1043+
throw InternalException("Expected an expression that only references a single column, but found multiple!");
1044+
}
1045+
index = ref.index;
1046+
ref.index = 0;
1047+
});
1048+
#else
10381049
ExpressionIterator::VisitExpressionMutable<BoundReferenceExpression>(
10391050
root_expr, [&](BoundReferenceExpression &ref, unique_ptr<Expression> &expr) { ref.index = 0; });
1051+
#endif
10401052
}
10411053

10421054
bool CanPropagateCast(const MultiFileIndexMapping &mapping, const LogicalType &local_type,

src/duckdb/src/execution/operator/join/physical_iejoin.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,9 @@ idx_t IEJoinUnion::JoinComplexBlocks(unsafe_vector<idx_t> &lsel, unsafe_vector<i
733733
// 8. initialize join result as an empty list for tuple pairs
734734
idx_t result_count = 0;
735735

736+
lsel.resize(STANDARD_VECTOR_SIZE);
737+
rsel.resize(STANDARD_VECTOR_SIZE);
738+
736739
// 11. for(i←1 to n) do
737740
while (i < n) {
738741
// 13. for (j ← pos+eqOff to n) do
@@ -776,6 +779,9 @@ idx_t IEJoinUnion::JoinComplexBlocks(unsafe_vector<idx_t> &lsel, unsafe_vector<i
776779
}
777780
}
778781

782+
lsel.resize(result_count);
783+
rsel.resize(result_count);
784+
779785
return result_count;
780786
}
781787

src/duckdb/src/execution/physical_plan/plan_get.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,21 @@ PhysicalOperator &PhysicalPlanGenerator::CreatePlan(LogicalGet &op) {
102102
vector<unique_ptr<Expression>> select_list;
103103
unique_ptr<Expression> unsupported_filter;
104104
unordered_set<idx_t> to_remove;
105+
106+
virtual_column_map_t virtual_columns;
107+
if (op.function.get_virtual_columns) {
108+
virtual_columns = op.function.get_virtual_columns(context, op.bind_data.get());
109+
}
105110
for (auto &entry : table_filters->filters) {
106111
auto column_id = column_ids[entry.first].GetPrimaryIndex();
107-
auto &type = op.returned_types[column_id];
108112
if (!op.function.supports_pushdown_type(*op.bind_data, column_id)) {
113+
LogicalType column_type;
114+
if (IsVirtualColumn(column_id)) {
115+
auto &column = virtual_columns.at(column_id);
116+
column_type = column.type;
117+
} else {
118+
column_type = op.returned_types[column_id];
119+
}
109120
idx_t column_id_filter = entry.first;
110121
bool found_projection = false;
111122
for (idx_t i = 0; i < projection_ids.size(); i++) {
@@ -119,7 +130,7 @@ PhysicalOperator &PhysicalPlanGenerator::CreatePlan(LogicalGet &op) {
119130
projection_ids.push_back(entry.first);
120131
column_id_filter = projection_ids.size() - 1;
121132
}
122-
auto column = make_uniq<BoundReferenceExpression>(type, column_id_filter);
133+
auto column = make_uniq<BoundReferenceExpression>(column_type, column_id_filter);
123134
select_list.push_back(entry.second->ToExpression(*column));
124135
to_remove.insert(entry.first);
125136
}
@@ -132,7 +143,12 @@ PhysicalOperator &PhysicalPlanGenerator::CreatePlan(LogicalGet &op) {
132143
vector<LogicalType> filter_types;
133144
for (auto &c : projection_ids) {
134145
auto column_id = column_ids[c].GetPrimaryIndex();
135-
filter_types.push_back(op.returned_types[column_id]);
146+
if (IsVirtualColumn(column_id)) {
147+
auto &column = virtual_columns.at(column_id);
148+
filter_types.push_back(column.type);
149+
} else {
150+
filter_types.push_back(op.returned_types[column_id]);
151+
}
136152
}
137153
filter = Make<PhysicalFilter>(filter_types, std::move(select_list), op.estimated_cardinality);
138154
}

src/duckdb/src/function/compression_config.cpp

Lines changed: 33 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,31 @@ idx_t CompressionFunctionSet::GetCompressionIndex(CompressionType type) {
8484
}
8585

8686
CompressionFunctionSet::CompressionFunctionSet() {
87-
for (idx_t i = 0; i < PHYSICAL_TYPE_COUNT; i++) {
88-
is_loaded[i] = false;
89-
}
9087
ResetDisabledMethods();
9188
functions.resize(PHYSICAL_TYPE_COUNT);
89+
90+
static PhysicalType physical_types[PHYSICAL_TYPE_COUNT] = {
91+
PhysicalType::BOOL, PhysicalType::UINT8, PhysicalType::INT8, PhysicalType::UINT16, PhysicalType::INT16,
92+
PhysicalType::UINT32, PhysicalType::INT32, PhysicalType::UINT64, PhysicalType::INT64, PhysicalType::FLOAT,
93+
PhysicalType::DOUBLE, PhysicalType::INTERVAL, PhysicalType::LIST, PhysicalType::STRUCT, PhysicalType::ARRAY,
94+
PhysicalType::VARCHAR, PhysicalType::UINT128, PhysicalType::INT128, PhysicalType::BIT,
95+
};
96+
for (idx_t type_index = 0; type_index < PHYSICAL_TYPE_COUNT; type_index++) {
97+
const auto physical_type = physical_types[type_index];
98+
const auto index = GetCompressionIndex(physical_type);
99+
auto &function_list = functions[index];
100+
101+
for (idx_t method_index = 0; internal_compression_methods[method_index].get_function; method_index++) {
102+
auto &method = internal_compression_methods[method_index];
103+
if (!method.supports_type(physical_type)) {
104+
// Not supported for this type.
105+
continue;
106+
}
107+
// The type is supported.
108+
// We create the function and insert it into the set of available functions.
109+
function_list.push_back(method.get_function(physical_type));
110+
}
111+
}
92112
}
93113

94114
bool EmitCompressionFunction(CompressionType type) {
@@ -113,14 +133,12 @@ bool EmitCompressionFunction(CompressionType type) {
113133

114134
vector<reference<const CompressionFunction>>
115135
CompressionFunctionSet::GetCompressionFunctions(PhysicalType physical_type) {
116-
LoadCompressionFunctions(physical_type);
117-
auto index = GetCompressionIndex(physical_type);
136+
const auto index = GetCompressionIndex(physical_type);
118137
auto &function_list = functions[index];
119138
vector<reference<const CompressionFunction>> result;
120139
for (auto &entry : function_list) {
121-
auto compression_index = GetCompressionIndex(entry.type);
140+
const auto compression_index = GetCompressionIndex(entry.type);
122141
if (is_disabled[compression_index]) {
123-
// explicitly disabled
124142
continue;
125143
}
126144
if (!EmitCompressionFunction(entry.type)) {
@@ -131,50 +149,22 @@ CompressionFunctionSet::GetCompressionFunctions(PhysicalType physical_type) {
131149
return result;
132150
}
133151

134-
CompressionFunctionSetLoadResult CompressionFunctionSet::LoadCompressionFunctions(PhysicalType physical_type) {
135-
auto index = GetCompressionIndex(physical_type);
136-
if (is_loaded[index]) {
137-
return CompressionFunctionSetLoadResult::ALREADY_LOADED_BEFORE_LOCK;
138-
}
139-
// not loaded - try to load it
140-
lock_guard<mutex> guard(lock);
141-
// verify nobody loaded it in the mean-time
142-
if (is_loaded[index]) {
143-
return CompressionFunctionSetLoadResult::ALREADY_LOADED_AFTER_LOCK;
144-
}
145-
// actually perform the load
146-
auto &function_list = functions[index];
147-
for (idx_t i = 0; internal_compression_methods[i].get_function; i++) {
148-
auto &method = internal_compression_methods[i];
149-
if (!method.supports_type(physical_type)) {
150-
// not supported for this type
151-
continue;
152-
}
153-
// The type is supported. We create the function and insert it into the set of available functions.
154-
function_list.push_back(method.get_function(physical_type));
155-
}
156-
is_loaded[index] = true;
157-
return CompressionFunctionSetLoadResult::LAZILY_LOADED;
158-
}
159-
160-
pair<CompressionFunctionSetLoadResult, optional_ptr<const CompressionFunction>>
152+
optional_ptr<const CompressionFunction>
161153
CompressionFunctionSet::GetCompressionFunction(CompressionType type, const PhysicalType physical_type) {
162-
const auto load_result = LoadCompressionFunctions(physical_type);
163-
164154
const auto index = GetCompressionIndex(physical_type);
165155
const auto &function_list = functions[index];
166156
for (auto &function : function_list) {
167157
if (function.type == type) {
168-
return make_pair(load_result, &function);
158+
return &function;
169159
}
170160
}
171-
return make_pair(load_result, nullptr);
161+
return nullptr;
172162
}
173163

174164
void CompressionFunctionSet::SetDisabledCompressionMethods(const vector<CompressionType> &methods) {
175165
ResetDisabledMethods();
176166
for (auto &method : methods) {
177-
auto idx = GetCompressionIndex(method);
167+
const auto idx = GetCompressionIndex(method);
178168
is_disabled[idx] = true;
179169
}
180170
}
@@ -193,55 +183,6 @@ vector<CompressionType> CompressionFunctionSet::GetDisabledCompressionMethods()
193183
return result;
194184
}
195185

196-
string CompressionFunctionSet::GetDebugInfo() const {
197-
static PhysicalType physical_types[PHYSICAL_TYPE_COUNT] = {
198-
PhysicalType::BOOL, PhysicalType::UINT8, PhysicalType::INT8, PhysicalType::UINT16, PhysicalType::INT16,
199-
PhysicalType::UINT32, PhysicalType::INT32, PhysicalType::UINT64, PhysicalType::INT64, PhysicalType::FLOAT,
200-
PhysicalType::DOUBLE, PhysicalType::INTERVAL, PhysicalType::LIST, PhysicalType::STRUCT, PhysicalType::ARRAY,
201-
PhysicalType::VARCHAR, PhysicalType::UINT128, PhysicalType::INT128, PhysicalType::BIT,
202-
};
203-
204-
vector<string> compression_type_debug_infos;
205-
for (idx_t i = 0; i < COMPRESSION_TYPE_COUNT; i++) {
206-
compression_type_debug_infos.push_back(
207-
StringUtil::Format("%llu: {compression type: %s, is disabled: %llu}", i,
208-
EnumUtil::ToString(internal_compression_methods[i].type), is_disabled[i].load()));
209-
}
210-
211-
lock_guard<mutex> guard(lock);
212-
vector<string> physical_type_debug_infos;
213-
for (idx_t index = 0; index < PHYSICAL_TYPE_COUNT; index++) {
214-
const auto &physical_type = physical_types[index];
215-
D_ASSERT(GetCompressionIndex(physical_type) == index);
216-
217-
idx_t out_of = 0;
218-
for (idx_t i = 0; internal_compression_methods[i].get_function; i++) {
219-
auto &method = internal_compression_methods[i];
220-
if (method.supports_type(physical_type)) {
221-
out_of++;
222-
}
223-
}
224-
225-
const auto &function_list = functions[index];
226-
vector<string> function_list_debug_infos;
227-
for (idx_t function_index = 0; function_index < function_list.size(); function_index++) {
228-
auto &function = function_list[function_index];
229-
function_list_debug_infos.push_back(StringUtil::Format("%llu: {compression type: %s, physical type: %s}",
230-
function_index, EnumUtil::ToString(function.type),
231-
EnumUtil::ToString(function.data_type)));
232-
}
233-
234-
physical_type_debug_infos.push_back(StringUtil::Format(
235-
"%llu: {physical type: %s, loaded: %llu, loaded functions: %llu (out of: %llu)}\t\t%s", index,
236-
EnumUtil::ToString(physical_type), is_loaded[index].load(), function_list.size(), out_of,
237-
function_list_debug_infos.empty() ? "" : "\n\t\t" + StringUtil::Join(function_list_debug_infos, "\n\t\t")));
238-
}
239-
240-
return StringUtil::Format("DEBUG INFO:\n - Compression types:\n\t%s\n\n - Physical types:\n\t%s",
241-
StringUtil::Join(compression_type_debug_infos, "\n\t"),
242-
StringUtil::Join(physical_type_debug_infos, "\n\t"));
243-
}
244-
245186
vector<CompressionType> DBConfig::GetDisabledCompressionMethods() const {
246187
return compression_functions->GetDisabledCompressionMethods();
247188
}
@@ -258,18 +199,17 @@ vector<reference<const CompressionFunction>> DBConfig::GetCompressionFunctions(c
258199

259200
optional_ptr<const CompressionFunction> DBConfig::TryGetCompressionFunction(CompressionType type,
260201
const PhysicalType physical_type) const {
261-
return compression_functions->GetCompressionFunction(type, physical_type).second;
202+
return compression_functions->GetCompressionFunction(type, physical_type);
262203
}
263204

264205
reference<const CompressionFunction> DBConfig::GetCompressionFunction(CompressionType type,
265206
const PhysicalType physical_type) const {
266207
auto result = compression_functions->GetCompressionFunction(type, physical_type);
267-
if (!result.second) {
208+
if (!result) {
268209
throw InternalException(
269210
"Could not find compression function \"%s\" for physical type \"%s\". Load result: %s. %s",
270-
EnumUtil::ToString(type), EnumUtil::ToString(physical_type), EnumUtil::ToString(result.first),
271-
compression_functions->GetDebugInfo());
211+
EnumUtil::ToString(type), EnumUtil::ToString(physical_type));
272212
}
273-
return *result.second;
213+
return *result;
274214
}
275215
} // namespace duckdb

src/duckdb/src/function/table/system/duckdb_views.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ static unique_ptr<FunctionData> DuckDBViewsBind(ClientContext &context, TableFun
5656
names.emplace_back("sql");
5757
return_types.emplace_back(LogicalType::VARCHAR);
5858

59+
names.emplace_back("is_bound");
60+
return_types.emplace_back(LogicalType::BOOLEAN);
61+
5962
return nullptr;
6063
}
6164

@@ -135,15 +138,24 @@ void DuckDBViewsFunction(ClientContext &context, TableFunctionInput &data_p, Dat
135138
case 10: {
136139
// column_count, LogicalType::BIGINT
137140
// make sure the view is bound so we know the columns it emits
138-
view.BindView(context);
139141
auto columns = view.GetColumnInfo();
140-
output.SetValue(c, count, Value::BIGINT(NumericCast<int64_t>(columns->types.size())));
142+
Value column_count;
143+
if (columns) {
144+
column_count = Value::BIGINT(NumericCast<int64_t>(columns->types.size()));
145+
}
146+
output.SetValue(c, count, column_count);
141147
break;
142148
}
143149
case 11:
144150
// sql, LogicalType::VARCHAR
145151
output.SetValue(c, count, Value(view.ToSQL()));
146152
break;
153+
case 12: {
154+
// is_bound, LogicalType::BOOLEAN
155+
auto columns = view.GetColumnInfo();
156+
output.SetValue(c, count, Value::BOOLEAN(columns.get()));
157+
break;
158+
}
147159
default:
148160
throw InternalException("Unsupported column index for duckdb_views");
149161
}

src/duckdb/src/function/table/table_scan.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,15 @@ bool TryScanIndex(ART &art, IndexEntry &entry, const ColumnList &column_list, Ta
622622
vector<reference<ART>> arts_to_scan;
623623
arts_to_scan.push_back(art);
624624
if (entry.deleted_rows_in_use) {
625+
if (entry.deleted_rows_in_use->GetIndexType() != ART::TYPE_NAME) {
626+
throw InternalException("Concurrent changes made to a non-ART index");
627+
}
625628
arts_to_scan.push_back(entry.deleted_rows_in_use->Cast<ART>());
626629
}
627630
if (entry.added_data_during_checkpoint) {
631+
if (entry.added_data_during_checkpoint->GetIndexType() != ART::TYPE_NAME) {
632+
throw InternalException("Concurrent changes made to a non-ART index");
633+
}
628634
arts_to_scan.push_back(entry.added_data_during_checkpoint->Cast<ART>());
629635
}
630636

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 "0-dev7526"
2+
#define DUCKDB_PATCH_VERSION "0-dev7605"
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.0-dev7526"
11+
#define DUCKDB_VERSION "v1.5.0-dev7605"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "490e7a8f47"
14+
#define DUCKDB_SOURCE_ID "3a3967aa81"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

0 commit comments

Comments
 (0)