duckdb 0.7.2-dev457.0 → 0.7.2-dev614.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/binding.gyp +9 -9
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-table-range.cpp +7 -7
- package/src/duckdb/extension/parquet/parquet-extension.cpp +1 -0
- package/src/duckdb/extension/parquet/parquet_reader.cpp +1 -1
- package/src/duckdb/src/catalog/catalog.cpp +13 -0
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +2 -21
- package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +8 -2
- package/src/duckdb/src/catalog/catalog_set.cpp +1 -0
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +48 -4
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +1 -1
- package/src/duckdb/src/common/field_writer.cpp +1 -0
- package/src/duckdb/src/common/serializer/buffered_deserializer.cpp +4 -0
- package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +15 -2
- package/src/duckdb/src/common/types/blob.cpp +1 -1
- package/src/duckdb/src/common/types/chunk_collection.cpp +2 -2
- package/src/duckdb/src/common/types/data_chunk.cpp +1 -1
- package/src/duckdb/src/common/types/value.cpp +8 -8
- package/src/duckdb/src/common/types.cpp +147 -64
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +12 -3
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +2 -2
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +6 -11
- package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +20 -40
- package/src/duckdb/src/function/aggregate/holistic/quantile.cpp +1 -1
- package/src/duckdb/src/function/aggregate/nested/list.cpp +8 -8
- package/src/duckdb/src/function/cast/struct_cast.cpp +1 -1
- package/src/duckdb/src/function/scalar/date/date_part.cpp +1 -1
- package/src/duckdb/src/function/scalar/list/list_concat.cpp +5 -4
- package/src/duckdb/src/function/scalar/list/list_lambdas.cpp +3 -3
- package/src/duckdb/src/function/scalar/list/list_value.cpp +1 -1
- package/src/duckdb/src/function/scalar/map/map_entries.cpp +1 -1
- package/src/duckdb/src/function/scalar/struct/struct_insert.cpp +1 -1
- package/src/duckdb/src/function/scalar/struct/struct_pack.cpp +1 -1
- package/src/duckdb/src/function/table/arrow.cpp +5 -2
- package/src/duckdb/src/function/table/arrow_conversion.cpp +18 -0
- package/src/duckdb/src/function/table/system/test_all_types.cpp +2 -2
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/function/table_function.cpp +11 -11
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +3 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/field_writer.hpp +12 -4
- package/src/duckdb/src/include/duckdb/common/{http_stats.hpp → http_state.hpp} +18 -4
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_deserializer.hpp +4 -2
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +8 -2
- package/src/duckdb/src/include/duckdb/common/serializer.hpp +13 -0
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +3 -3
- package/src/duckdb/src/include/duckdb/common/types.hpp +30 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +12 -1
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +8 -0
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +3 -3
- package/src/duckdb/src/include/duckdb/main/connection_manager.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +6 -0
- package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +7 -0
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +0 -1
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +1 -1
- package/src/duckdb/src/main/client_context.cpp +30 -32
- package/src/duckdb/src/main/client_data.cpp +7 -6
- package/src/duckdb/src/main/config.cpp +4 -0
- package/src/duckdb/src/main/database.cpp +9 -0
- package/src/duckdb/src/main/query_profiler.cpp +17 -15
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +3 -4
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +5 -3
- package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +9 -2
- package/src/duckdb/src/optimizer/unnest_rewriter.cpp +2 -2
- package/src/duckdb/src/parser/expression/conjunction_expression.cpp +2 -0
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +1 -1
- package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +3 -2
- package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +3 -4
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +4 -3
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +2 -1
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +2 -1
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +1 -0
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +11 -1
- package/src/duckdb/src/planner/binder/tableref/plan_cteref.cpp +1 -0
- package/src/duckdb/src/planner/expression_binder.cpp +1 -1
- package/src/duckdb/src/planner/logical_operator.cpp +4 -2
- package/src/duckdb/src/planner/planner.cpp +2 -1
- package/src/duckdb/src/storage/checkpoint_manager.cpp +8 -3
- package/src/duckdb/src/storage/meta_block_reader.cpp +22 -0
- package/src/duckdb/src/storage/statistics/list_stats.cpp +6 -2
- package/src/duckdb/src/storage/statistics/struct_stats.cpp +3 -1
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
- package/src/duckdb/src/storage/table/update_segment.cpp +11 -7
- package/src/duckdb/src/storage/wal_replay.cpp +8 -5
- package/src/duckdb/src/storage/write_ahead_log.cpp +2 -2
- package/src/duckdb/src/transaction/commit_state.cpp +11 -7
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +1152 -1152
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
@@ -128,6 +128,8 @@ void SingleFileCheckpointReader::LoadFromStorage() {
|
|
128
128
|
con.BeginTransaction();
|
129
129
|
// create the MetaBlockReader to read from the storage
|
130
130
|
MetaBlockReader reader(block_manager, meta_block);
|
131
|
+
reader.SetCatalog(&catalog.GetAttached().GetCatalog());
|
132
|
+
reader.SetContext(con.context.get());
|
131
133
|
LoadCheckpoint(*con.context, reader);
|
132
134
|
con.Commit();
|
133
135
|
}
|
@@ -395,13 +397,16 @@ void CheckpointReader::ReadIndex(ClientContext &context, MetaBlockReader &reader
|
|
395
397
|
//===--------------------------------------------------------------------===//
|
396
398
|
// Custom Types
|
397
399
|
//===--------------------------------------------------------------------===//
|
398
|
-
void CheckpointWriter::WriteType(TypeCatalogEntry &
|
399
|
-
|
400
|
+
void CheckpointWriter::WriteType(TypeCatalogEntry &type) {
|
401
|
+
type.Serialize(GetMetaBlockWriter());
|
400
402
|
}
|
401
403
|
|
402
404
|
void CheckpointReader::ReadType(ClientContext &context, MetaBlockReader &reader) {
|
403
405
|
auto info = TypeCatalogEntry::Deserialize(reader);
|
404
|
-
catalog.CreateType(context, info.get());
|
406
|
+
auto catalog_entry = (TypeCatalogEntry *)catalog.CreateType(context, info.get());
|
407
|
+
if (info->type.id() == LogicalTypeId::ENUM) {
|
408
|
+
EnumType::SetCatalog(info->type, catalog_entry);
|
409
|
+
}
|
405
410
|
}
|
406
411
|
|
407
412
|
//===--------------------------------------------------------------------===//
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#include "duckdb/storage/meta_block_reader.hpp"
|
2
2
|
#include "duckdb/storage/buffer_manager.hpp"
|
3
|
+
#include "duckdb/main/connection_manager.hpp"
|
4
|
+
#include "duckdb/main/database.hpp"
|
3
5
|
|
4
6
|
#include <cstring>
|
5
7
|
|
@@ -34,6 +36,16 @@ void MetaBlockReader::ReadData(data_ptr_t buffer, idx_t read_size) {
|
|
34
36
|
offset += read_size;
|
35
37
|
}
|
36
38
|
|
39
|
+
ClientContext &MetaBlockReader::GetContext() {
|
40
|
+
if (!context) {
|
41
|
+
throw InternalException("Meta Block Reader is missing context");
|
42
|
+
}
|
43
|
+
return *context;
|
44
|
+
}
|
45
|
+
Catalog *MetaBlockReader::GetCatalog() {
|
46
|
+
return catalog;
|
47
|
+
}
|
48
|
+
|
37
49
|
void MetaBlockReader::ReadNewBlock(block_id_t id) {
|
38
50
|
auto &buffer_manager = block_manager.buffer_manager;
|
39
51
|
|
@@ -52,4 +64,14 @@ void MetaBlockReader::ReadNewBlock(block_id_t id) {
|
|
52
64
|
offset = sizeof(block_id_t);
|
53
65
|
}
|
54
66
|
|
67
|
+
void MetaBlockReader::SetCatalog(Catalog *catalog_p) {
|
68
|
+
D_ASSERT(!catalog);
|
69
|
+
catalog = catalog_p;
|
70
|
+
}
|
71
|
+
|
72
|
+
void MetaBlockReader::SetContext(ClientContext *context_p) {
|
73
|
+
D_ASSERT(!context);
|
74
|
+
context = context_p;
|
75
|
+
}
|
76
|
+
|
55
77
|
} // namespace duckdb
|
@@ -34,12 +34,16 @@ void ListStats::Copy(BaseStatistics &stats, const BaseStatistics &other) {
|
|
34
34
|
}
|
35
35
|
|
36
36
|
const BaseStatistics &ListStats::GetChildStats(const BaseStatistics &stats) {
|
37
|
-
|
37
|
+
if (stats.GetStatsType() != StatisticsType::LIST_STATS) {
|
38
|
+
throw InternalException("ListStats::GetChildStats called on stats that is not a list");
|
39
|
+
}
|
38
40
|
D_ASSERT(stats.child_stats);
|
39
41
|
return stats.child_stats[0];
|
40
42
|
}
|
41
43
|
BaseStatistics &ListStats::GetChildStats(BaseStatistics &stats) {
|
42
|
-
|
44
|
+
if (stats.GetStatsType() != StatisticsType::LIST_STATS) {
|
45
|
+
throw InternalException("ListStats::GetChildStats called on stats that is not a list");
|
46
|
+
}
|
43
47
|
D_ASSERT(stats.child_stats);
|
44
48
|
return stats.child_stats[0];
|
45
49
|
}
|
@@ -34,7 +34,9 @@ BaseStatistics StructStats::CreateEmpty(LogicalType type) {
|
|
34
34
|
}
|
35
35
|
|
36
36
|
const BaseStatistics *StructStats::GetChildStats(const BaseStatistics &stats) {
|
37
|
-
|
37
|
+
if (stats.GetStatsType() != StatisticsType::STRUCT_STATS) {
|
38
|
+
throw InternalException("Calling StructStats::GetChildStats on stats that is not a struct");
|
39
|
+
}
|
38
40
|
return stats.child_stats.get();
|
39
41
|
}
|
40
42
|
|
@@ -38,7 +38,17 @@ UpdateSegment::UpdateSegment(UpdateSegment &other, ColumnData &owner)
|
|
38
38
|
: column_data(owner), root(std::move(other.root)), stats(std::move(other.stats)), type_size(other.type_size) {
|
39
39
|
|
40
40
|
this->heap.Move(other.heap);
|
41
|
-
|
41
|
+
// update the segment links
|
42
|
+
if (root) {
|
43
|
+
for (idx_t i = 0; i < RowGroup::ROW_GROUP_VECTOR_COUNT; i++) {
|
44
|
+
if (!root->info[i]) {
|
45
|
+
continue;
|
46
|
+
}
|
47
|
+
for (auto info = root->info[i]->info.get(); info; info = info->next) {
|
48
|
+
info->segment = this;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
42
52
|
initialize_update_function = other.initialize_update_function;
|
43
53
|
merge_update_function = other.merge_update_function;
|
44
54
|
fetch_update_function = other.fetch_update_function;
|
@@ -52,12 +62,6 @@ UpdateSegment::UpdateSegment(UpdateSegment &other, ColumnData &owner)
|
|
52
62
|
UpdateSegment::~UpdateSegment() {
|
53
63
|
}
|
54
64
|
|
55
|
-
void UpdateSegment::ClearUpdates() {
|
56
|
-
stats.statistics.Copy(BaseStatistics::CreateEmpty(stats.statistics.GetType()));
|
57
|
-
root.reset();
|
58
|
-
heap.Destroy();
|
59
|
-
}
|
60
|
-
|
61
65
|
//===--------------------------------------------------------------------===//
|
62
66
|
// Update Info Helpers
|
63
67
|
//===--------------------------------------------------------------------===//
|
@@ -24,17 +24,19 @@
|
|
24
24
|
namespace duckdb {
|
25
25
|
|
26
26
|
bool WriteAheadLog::Replay(AttachedDatabase &database, string &path) {
|
27
|
-
|
27
|
+
Connection con(database.GetDatabase());
|
28
|
+
auto initial_reader = make_unique<BufferedFileReader>(FileSystem::Get(database), path.c_str(), con.context.get());
|
28
29
|
if (initial_reader->Finished()) {
|
29
30
|
// WAL is empty
|
30
31
|
return false;
|
31
32
|
}
|
32
|
-
|
33
|
+
|
33
34
|
con.BeginTransaction();
|
34
35
|
|
35
36
|
// first deserialize the WAL to look for a checkpoint flag
|
36
37
|
// if there is a checkpoint flag, we might have already flushed the contents of the WAL to disk
|
37
38
|
ReplayState checkpoint_state(database, *con.context, *initial_reader);
|
39
|
+
initial_reader->catalog = &checkpoint_state.catalog;
|
38
40
|
checkpoint_state.deserialize_only = true;
|
39
41
|
try {
|
40
42
|
while (true) {
|
@@ -70,7 +72,8 @@ bool WriteAheadLog::Replay(AttachedDatabase &database, string &path) {
|
|
70
72
|
}
|
71
73
|
|
72
74
|
// we need to recover from the WAL: actually set up the replay state
|
73
|
-
BufferedFileReader reader(FileSystem::Get(database), path.c_str());
|
75
|
+
BufferedFileReader reader(FileSystem::Get(database), path.c_str(), con.context.get());
|
76
|
+
reader.catalog = &checkpoint_state.catalog;
|
74
77
|
ReplayState state(database, *con.context, reader);
|
75
78
|
|
76
79
|
// replay the WAL
|
@@ -192,6 +195,7 @@ void ReplayState::ReplayEntry(WALType entry_type) {
|
|
192
195
|
// Replay Table
|
193
196
|
//===--------------------------------------------------------------------===//
|
194
197
|
void ReplayState::ReplayCreateTable() {
|
198
|
+
|
195
199
|
auto info = TableCatalogEntry::Deserialize(source, context);
|
196
200
|
if (deserialize_only) {
|
197
201
|
return;
|
@@ -278,10 +282,9 @@ void ReplayState::ReplayDropSchema() {
|
|
278
282
|
//===--------------------------------------------------------------------===//
|
279
283
|
void ReplayState::ReplayCreateType() {
|
280
284
|
auto info = TypeCatalogEntry::Deserialize(source);
|
281
|
-
if (
|
285
|
+
if (Catalog::TypeExists(context, info->catalog, info->schema, info->name)) {
|
282
286
|
return;
|
283
287
|
}
|
284
|
-
|
285
288
|
catalog.CreateType(context, info.get());
|
286
289
|
}
|
287
290
|
|
@@ -281,12 +281,12 @@ void WriteAheadLog::WriteUpdate(DataChunk &chunk, const vector<column_t> &column
|
|
281
281
|
//===--------------------------------------------------------------------===//
|
282
282
|
// Write ALTER Statement
|
283
283
|
//===--------------------------------------------------------------------===//
|
284
|
-
void WriteAheadLog::WriteAlter(
|
284
|
+
void WriteAheadLog::WriteAlter(data_ptr_t ptr, idx_t data_size) {
|
285
285
|
if (skip_writing) {
|
286
286
|
return;
|
287
287
|
}
|
288
288
|
writer->Write<WALType>(WALType::ALTER_INFO);
|
289
|
-
|
289
|
+
writer->WriteData(ptr, data_size);
|
290
290
|
}
|
291
291
|
|
292
292
|
//===--------------------------------------------------------------------===//
|
@@ -46,12 +46,16 @@ void CommitState::WriteCatalogEntry(CatalogEntry *entry, data_ptr_t dataptr) {
|
|
46
46
|
// ALTER TABLE statement, read the extra data after the entry
|
47
47
|
auto extra_data_size = Load<idx_t>(dataptr);
|
48
48
|
auto extra_data = (data_ptr_t)(dataptr + sizeof(idx_t));
|
49
|
-
|
49
|
+
|
50
50
|
BufferedDeserializer source(extra_data, extra_data_size);
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
string column_name = source.Read<string>();
|
52
|
+
|
53
|
+
if (!column_name.empty()) {
|
54
|
+
// write the alter table in the log
|
55
|
+
table_entry->CommitAlter(column_name);
|
56
|
+
}
|
57
|
+
|
58
|
+
log->WriteAlter(source.ptr, source.endptr - source.ptr);
|
55
59
|
} else {
|
56
60
|
// CREATE TABLE statement
|
57
61
|
log->WriteCreateTable((TableCatalogEntry *)parent);
|
@@ -71,9 +75,9 @@ void CommitState::WriteCatalogEntry(CatalogEntry *entry, data_ptr_t dataptr) {
|
|
71
75
|
auto extra_data = (data_ptr_t)(dataptr + sizeof(idx_t));
|
72
76
|
// deserialize it
|
73
77
|
BufferedDeserializer source(extra_data, extra_data_size);
|
74
|
-
|
78
|
+
string column_name = source.Read<string>();
|
75
79
|
// write the alter table in the log
|
76
|
-
log->WriteAlter(
|
80
|
+
log->WriteAlter(source.ptr, source.endptr - source.ptr);
|
77
81
|
} else {
|
78
82
|
log->WriteCreateView((ViewCatalogEntry *)parent);
|
79
83
|
}
|