duckdb 0.6.1-dev86.0 → 0.6.2-dev13.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/connection.cpp +100 -99
- package/src/duckdb.cpp +1567 -811
- package/src/duckdb.hpp +100 -35
- package/src/duckdb_node.hpp +0 -1
- package/src/parquet-amalgamation.cpp +13204 -13194
- package/test/arrow.test.js +36 -45
package/src/duckdb.hpp
CHANGED
|
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
13
|
#define DUCKDB_AMALGAMATION_EXTENDED 1
|
|
14
|
-
#define DUCKDB_SOURCE_ID "
|
|
15
|
-
#define DUCKDB_VERSION "v0.6.
|
|
14
|
+
#define DUCKDB_SOURCE_ID "afeda73278"
|
|
15
|
+
#define DUCKDB_VERSION "v0.6.2-dev13"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -4351,6 +4351,7 @@ void DestroyObject(T *ptr) {
|
|
|
4351
4351
|
//! As such this class should be used primarily for larger allocations.
|
|
4352
4352
|
struct BufferAllocator {
|
|
4353
4353
|
DUCKDB_API static Allocator &Get(ClientContext &context);
|
|
4354
|
+
DUCKDB_API static Allocator &Get(DatabaseInstance &db);
|
|
4354
4355
|
};
|
|
4355
4356
|
|
|
4356
4357
|
} // namespace duckdb
|
|
@@ -4404,7 +4405,7 @@ namespace duckdb {
|
|
|
4404
4405
|
//! returned pointer will remain valid until the StringHeap is destroyed
|
|
4405
4406
|
class StringHeap {
|
|
4406
4407
|
public:
|
|
4407
|
-
StringHeap();
|
|
4408
|
+
StringHeap(Allocator &allocator = Allocator::DefaultAllocator());
|
|
4408
4409
|
|
|
4409
4410
|
void Destroy();
|
|
4410
4411
|
void Move(StringHeap &other);
|
|
@@ -9171,6 +9172,7 @@ public:
|
|
|
9171
9172
|
|
|
9172
9173
|
public:
|
|
9173
9174
|
virtual unique_ptr<CatalogEntry> AlterEntry(ClientContext &context, AlterInfo *info);
|
|
9175
|
+
virtual void UndoAlter(ClientContext &context, AlterInfo *info);
|
|
9174
9176
|
|
|
9175
9177
|
virtual unique_ptr<CatalogEntry> Copy(ClientContext &context);
|
|
9176
9178
|
|
|
@@ -11162,6 +11164,8 @@ public:
|
|
|
11162
11164
|
public:
|
|
11163
11165
|
bool HasGeneratedColumns() const;
|
|
11164
11166
|
unique_ptr<CatalogEntry> AlterEntry(ClientContext &context, AlterInfo *info) override;
|
|
11167
|
+
void UndoAlter(ClientContext &context, AlterInfo *info) override;
|
|
11168
|
+
|
|
11165
11169
|
//! Returns whether or not a column with the given name exists
|
|
11166
11170
|
DUCKDB_API bool ColumnExists(const string &name);
|
|
11167
11171
|
//! Returns a reference to the column of the specified name. Throws an
|
|
@@ -11340,6 +11344,9 @@ public:
|
|
|
11340
11344
|
return true;
|
|
11341
11345
|
}
|
|
11342
11346
|
|
|
11347
|
+
//! Returns the set of table indexes of this operator
|
|
11348
|
+
virtual vector<idx_t> GetTableIndex() const;
|
|
11349
|
+
|
|
11343
11350
|
protected:
|
|
11344
11351
|
//! Resolve types for this specific operator
|
|
11345
11352
|
virtual void ResolveTypes() = 0;
|
|
@@ -14190,6 +14197,9 @@ public:
|
|
|
14190
14197
|
void Reset();
|
|
14191
14198
|
void ResetSink();
|
|
14192
14199
|
void ResetSource(bool force);
|
|
14200
|
+
void ClearSource() {
|
|
14201
|
+
source_state.reset();
|
|
14202
|
+
}
|
|
14193
14203
|
void Schedule(shared_ptr<Event> &event);
|
|
14194
14204
|
|
|
14195
14205
|
//! Finalize this pipeline
|
|
@@ -15527,27 +15537,46 @@ namespace duckdb {
|
|
|
15527
15537
|
struct AlterInfo;
|
|
15528
15538
|
|
|
15529
15539
|
class ClientContext;
|
|
15540
|
+
struct MappingValue;
|
|
15541
|
+
struct EntryIndex;
|
|
15530
15542
|
|
|
15531
15543
|
typedef unordered_map<CatalogSet *, unique_lock<mutex>> set_lock_map_t;
|
|
15532
15544
|
|
|
15533
|
-
struct
|
|
15534
|
-
|
|
15545
|
+
struct EntryValue {
|
|
15546
|
+
EntryValue() {
|
|
15547
|
+
throw InternalException("EntryValue called without a catalog entry");
|
|
15535
15548
|
}
|
|
15536
15549
|
|
|
15537
|
-
|
|
15538
|
-
|
|
15539
|
-
|
|
15540
|
-
|
|
15541
|
-
|
|
15550
|
+
explicit EntryValue(unique_ptr<CatalogEntry> entry_p) : entry(move(entry_p)), reference_count(0) {
|
|
15551
|
+
}
|
|
15552
|
+
//! enable move constructors
|
|
15553
|
+
EntryValue(EntryValue &&other) noexcept {
|
|
15554
|
+
Swap(other);
|
|
15555
|
+
}
|
|
15556
|
+
EntryValue &operator=(EntryValue &&other) noexcept {
|
|
15557
|
+
Swap(other);
|
|
15558
|
+
return *this;
|
|
15559
|
+
}
|
|
15560
|
+
void Swap(EntryValue &other) {
|
|
15561
|
+
std::swap(entry, other.entry);
|
|
15562
|
+
idx_t count = reference_count;
|
|
15563
|
+
reference_count = other.reference_count.load();
|
|
15564
|
+
other.reference_count = count;
|
|
15565
|
+
}
|
|
15566
|
+
|
|
15567
|
+
unique_ptr<CatalogEntry> entry;
|
|
15568
|
+
atomic<idx_t> reference_count;
|
|
15542
15569
|
};
|
|
15543
15570
|
|
|
15544
15571
|
//! The Catalog Set stores (key, value) map of a set of CatalogEntries
|
|
15545
15572
|
class CatalogSet {
|
|
15546
15573
|
friend class DependencyManager;
|
|
15547
15574
|
friend class EntryDropper;
|
|
15575
|
+
friend struct EntryIndex;
|
|
15548
15576
|
|
|
15549
15577
|
public:
|
|
15550
15578
|
DUCKDB_API explicit CatalogSet(Catalog &catalog, unique_ptr<DefaultGenerator> defaults = nullptr);
|
|
15579
|
+
~CatalogSet();
|
|
15551
15580
|
|
|
15552
15581
|
//! Create an entry in the catalog set. Returns whether or not it was
|
|
15553
15582
|
//! successful.
|
|
@@ -15588,7 +15617,6 @@ public:
|
|
|
15588
15617
|
DUCKDB_API static bool HasConflict(ClientContext &context, transaction_t timestamp);
|
|
15589
15618
|
DUCKDB_API static bool UseTimestamp(ClientContext &context, transaction_t timestamp);
|
|
15590
15619
|
|
|
15591
|
-
CatalogEntry *GetEntryFromIndex(idx_t index);
|
|
15592
15620
|
void UpdateTimestamp(CatalogEntry *entry, transaction_t timestamp);
|
|
15593
15621
|
|
|
15594
15622
|
private:
|
|
@@ -15601,29 +15629,32 @@ private:
|
|
|
15601
15629
|
//! Given a root entry, gets the entry valid for this transaction
|
|
15602
15630
|
CatalogEntry *GetEntryForTransaction(ClientContext &context, CatalogEntry *current);
|
|
15603
15631
|
CatalogEntry *GetCommittedEntry(CatalogEntry *current);
|
|
15604
|
-
bool GetEntryInternal(ClientContext &context, const string &name,
|
|
15605
|
-
bool GetEntryInternal(ClientContext &context,
|
|
15632
|
+
bool GetEntryInternal(ClientContext &context, const string &name, EntryIndex *entry_index, CatalogEntry *&entry);
|
|
15633
|
+
bool GetEntryInternal(ClientContext &context, EntryIndex &entry_index, CatalogEntry *&entry);
|
|
15606
15634
|
//! Drops an entry from the catalog set; must hold the catalog_lock to safely call this
|
|
15607
|
-
void DropEntryInternal(ClientContext &context,
|
|
15635
|
+
void DropEntryInternal(ClientContext &context, EntryIndex entry_index, CatalogEntry &entry, bool cascade);
|
|
15608
15636
|
CatalogEntry *CreateEntryInternal(ClientContext &context, unique_ptr<CatalogEntry> entry);
|
|
15609
15637
|
MappingValue *GetMapping(ClientContext &context, const string &name, bool get_latest = false);
|
|
15610
|
-
void PutMapping(ClientContext &context, const string &name,
|
|
15638
|
+
void PutMapping(ClientContext &context, const string &name, EntryIndex entry_index);
|
|
15611
15639
|
void DeleteMapping(ClientContext &context, const string &name);
|
|
15612
|
-
void DropEntryDependencies(ClientContext &context,
|
|
15640
|
+
void DropEntryDependencies(ClientContext &context, EntryIndex &entry_index, CatalogEntry &entry, bool cascade);
|
|
15613
15641
|
|
|
15614
15642
|
//! Create all default entries
|
|
15615
15643
|
void CreateDefaultEntries(ClientContext &context, unique_lock<mutex> &lock);
|
|
15616
15644
|
//! Attempt to create a default entry with the specified name. Returns the entry if successful, nullptr otherwise.
|
|
15617
15645
|
CatalogEntry *CreateDefaultEntry(ClientContext &context, const string &name, unique_lock<mutex> &lock);
|
|
15618
15646
|
|
|
15647
|
+
EntryIndex PutEntry(idx_t entry_index, unique_ptr<CatalogEntry> entry);
|
|
15648
|
+
void PutEntry(EntryIndex index, unique_ptr<CatalogEntry> entry);
|
|
15649
|
+
|
|
15619
15650
|
private:
|
|
15620
15651
|
Catalog &catalog;
|
|
15621
15652
|
//! The catalog lock is used to make changes to the data
|
|
15622
15653
|
mutex catalog_lock;
|
|
15654
|
+
//! The set of catalog entries
|
|
15655
|
+
unordered_map<idx_t, EntryValue> entries;
|
|
15623
15656
|
//! Mapping of string to catalog entry
|
|
15624
15657
|
case_insensitive_map_t<unique_ptr<MappingValue>> mapping;
|
|
15625
|
-
//! The set of catalog entries
|
|
15626
|
-
unordered_map<idx_t, unique_ptr<CatalogEntry>> entries;
|
|
15627
15658
|
//! The current catalog entry index
|
|
15628
15659
|
idx_t current_entry = 0;
|
|
15629
15660
|
//! The generator used to generate default internal entries
|
|
@@ -16616,6 +16647,14 @@ public:
|
|
|
16616
16647
|
DUCKDB_API shared_ptr<Relation> RelationFromQuery(unique_ptr<SelectStatement> select_stmt,
|
|
16617
16648
|
const string &alias = "queryrelation");
|
|
16618
16649
|
|
|
16650
|
+
//! Returns a substrait BLOB from a valid query
|
|
16651
|
+
DUCKDB_API string GetSubstrait(const string &query);
|
|
16652
|
+
//! Returns a Query Result from a substrait blob
|
|
16653
|
+
DUCKDB_API unique_ptr<QueryResult> FromSubstrait(const string &proto);
|
|
16654
|
+
//! Returns a substrait BLOB from a valid query
|
|
16655
|
+
DUCKDB_API string GetSubstraitJSON(const string &query);
|
|
16656
|
+
//! Returns a Query Result from a substrait JSON
|
|
16657
|
+
DUCKDB_API unique_ptr<QueryResult> FromSubstraitJSON(const string &json);
|
|
16619
16658
|
DUCKDB_API void BeginTransaction();
|
|
16620
16659
|
DUCKDB_API void Commit();
|
|
16621
16660
|
DUCKDB_API void Rollback();
|
|
@@ -18911,6 +18950,9 @@ struct OperatorExtensionInfo {
|
|
|
18911
18950
|
typedef BoundStatement (*bind_function_t)(ClientContext &context, Binder &binder, OperatorExtensionInfo *info,
|
|
18912
18951
|
SQLStatement &statement);
|
|
18913
18952
|
|
|
18953
|
+
// forward declaration to avoid circular reference
|
|
18954
|
+
struct LogicalExtensionOperator;
|
|
18955
|
+
|
|
18914
18956
|
class OperatorExtension {
|
|
18915
18957
|
public:
|
|
18916
18958
|
bind_function_t Bind;
|
|
@@ -18918,6 +18960,10 @@ public:
|
|
|
18918
18960
|
//! Additional info passed to the CreatePlan & Bind functions
|
|
18919
18961
|
shared_ptr<OperatorExtensionInfo> operator_info;
|
|
18920
18962
|
|
|
18963
|
+
virtual std::string GetName() = 0;
|
|
18964
|
+
virtual std::unique_ptr<LogicalExtensionOperator> Deserialize(LogicalDeserializationState &state,
|
|
18965
|
+
FieldReader &reader) = 0;
|
|
18966
|
+
|
|
18921
18967
|
DUCKDB_API virtual ~OperatorExtension() {
|
|
18922
18968
|
}
|
|
18923
18969
|
};
|
|
@@ -19063,7 +19109,7 @@ public:
|
|
|
19063
19109
|
//! A reference to the (shared) default allocator (Allocator::DefaultAllocator)
|
|
19064
19110
|
shared_ptr<Allocator> default_allocator;
|
|
19065
19111
|
//! Extensions made to binder
|
|
19066
|
-
vector<OperatorExtension
|
|
19112
|
+
vector<std::unique_ptr<OperatorExtension>> operator_extensions;
|
|
19067
19113
|
|
|
19068
19114
|
public:
|
|
19069
19115
|
DUCKDB_API static DBConfig &GetConfig(ClientContext &context);
|
|
@@ -25993,6 +26039,7 @@ struct SBIterator {
|
|
|
25993
26039
|
|
|
25994
26040
|
|
|
25995
26041
|
|
|
26042
|
+
|
|
25996
26043
|
//===----------------------------------------------------------------------===//
|
|
25997
26044
|
// DuckDB
|
|
25998
26045
|
//
|
|
@@ -26164,6 +26211,10 @@ public:
|
|
|
26164
26211
|
can_destroy = can_destroy_p;
|
|
26165
26212
|
}
|
|
26166
26213
|
|
|
26214
|
+
inline const idx_t &GetMemoryUsage() const {
|
|
26215
|
+
return memory_usage;
|
|
26216
|
+
}
|
|
26217
|
+
|
|
26167
26218
|
private:
|
|
26168
26219
|
static BufferHandle Load(shared_ptr<BlockHandle> &handle, unique_ptr<FileBuffer> buffer = nullptr);
|
|
26169
26220
|
unique_ptr<FileBuffer> UnloadAndTakeBlock();
|
|
@@ -26197,7 +26248,6 @@ private:
|
|
|
26197
26248
|
|
|
26198
26249
|
|
|
26199
26250
|
|
|
26200
|
-
|
|
26201
26251
|
namespace duckdb {
|
|
26202
26252
|
class BlockManager;
|
|
26203
26253
|
class DatabaseInstance;
|
|
@@ -26218,10 +26268,6 @@ public:
|
|
|
26218
26268
|
BufferManager(DatabaseInstance &db, string temp_directory, idx_t maximum_memory);
|
|
26219
26269
|
virtual ~BufferManager();
|
|
26220
26270
|
|
|
26221
|
-
//! Register an in-memory buffer of arbitrary size, as long as it is >= BLOCK_SIZE. can_destroy signifies whether or
|
|
26222
|
-
//! not the buffer can be destroyed when unpinned, or whether or not it needs to be written to a temporary file so
|
|
26223
|
-
//! it can be reloaded. The resulting buffer will already be allocated, but needs to be pinned in order to be used.
|
|
26224
|
-
shared_ptr<BlockHandle> RegisterMemory(idx_t block_size, bool can_destroy);
|
|
26225
26271
|
//! Registers an in-memory buffer that cannot be unloaded until it is destroyed
|
|
26226
26272
|
//! This buffer can be small (smaller than BLOCK_SIZE)
|
|
26227
26273
|
//! Unpin and pin are nops on this block of memory
|
|
@@ -26229,7 +26275,8 @@ public:
|
|
|
26229
26275
|
|
|
26230
26276
|
//! Allocate an in-memory buffer with a single pin.
|
|
26231
26277
|
//! The allocated memory is released when the buffer handle is destroyed.
|
|
26232
|
-
DUCKDB_API BufferHandle Allocate(idx_t block_size
|
|
26278
|
+
DUCKDB_API BufferHandle Allocate(idx_t block_size, bool can_destroy = true,
|
|
26279
|
+
shared_ptr<BlockHandle> *block = nullptr);
|
|
26233
26280
|
|
|
26234
26281
|
//! Reallocate an in-memory buffer that is pinned.
|
|
26235
26282
|
void ReAllocate(shared_ptr<BlockHandle> &handle, idx_t block_size);
|
|
@@ -26263,6 +26310,10 @@ public:
|
|
|
26263
26310
|
return db;
|
|
26264
26311
|
}
|
|
26265
26312
|
|
|
26313
|
+
static idx_t GetAllocSize(idx_t block_size) {
|
|
26314
|
+
return AlignValue<idx_t, Storage::SECTOR_SIZE>(block_size + Storage::BLOCK_HEADER_SIZE);
|
|
26315
|
+
}
|
|
26316
|
+
|
|
26266
26317
|
//! Construct a managed buffer.
|
|
26267
26318
|
//! The block_id is just used for internal tracking. It doesn't map to any actual
|
|
26268
26319
|
//! BlockManager.
|
|
@@ -26273,6 +26324,12 @@ public:
|
|
|
26273
26324
|
DUCKDB_API void FreeReservedMemory(idx_t size);
|
|
26274
26325
|
|
|
26275
26326
|
private:
|
|
26327
|
+
//! Register an in-memory buffer of arbitrary size, as long as it is >= BLOCK_SIZE. can_destroy signifies whether or
|
|
26328
|
+
//! not the buffer can be destroyed when unpinned, or whether or not it needs to be written to a temporary file so
|
|
26329
|
+
//! it can be reloaded. The resulting buffer will already be allocated, but needs to be pinned in order to be used.
|
|
26330
|
+
//! This needs to be private to prevent creating blocks without ever pinning them:
|
|
26331
|
+
//! blocks that are never pinned are never added to the eviction queue
|
|
26332
|
+
shared_ptr<BlockHandle> RegisterMemory(idx_t block_size, bool can_destroy);
|
|
26276
26333
|
//! Evict blocks until the currently used memory + extra_memory fit, returns false if this was not possible
|
|
26277
26334
|
//! (i.e. not enough blocks could be evicted)
|
|
26278
26335
|
//! If the "buffer" argument is specified AND the system can find a buffer to re-use for the given allocation size
|
|
@@ -26354,7 +26411,8 @@ public:
|
|
|
26354
26411
|
RowDataBlock(BufferManager &buffer_manager, idx_t capacity, idx_t entry_size)
|
|
26355
26412
|
: capacity(capacity), entry_size(entry_size), count(0), byte_offset(0) {
|
|
26356
26413
|
idx_t size = MaxValue<idx_t>(Storage::BLOCK_SIZE, capacity * entry_size);
|
|
26357
|
-
|
|
26414
|
+
buffer_manager.Allocate(size, false, &block);
|
|
26415
|
+
D_ASSERT(BufferManager::GetAllocSize(size) == block->GetMemoryUsage());
|
|
26358
26416
|
}
|
|
26359
26417
|
explicit RowDataBlock(idx_t entry_size) : entry_size(entry_size) {
|
|
26360
26418
|
}
|
|
@@ -26428,17 +26486,23 @@ public:
|
|
|
26428
26486
|
count = 0;
|
|
26429
26487
|
}
|
|
26430
26488
|
|
|
26431
|
-
//! The size (in bytes) of this RowDataCollection
|
|
26489
|
+
//! The size (in bytes) of this RowDataCollection
|
|
26432
26490
|
idx_t SizeInBytes() const {
|
|
26433
|
-
|
|
26434
|
-
|
|
26435
|
-
|
|
26436
|
-
|
|
26437
|
-
}
|
|
26438
|
-
} else {
|
|
26439
|
-
bytes = count * entry_size;
|
|
26491
|
+
VerifyBlockSizes();
|
|
26492
|
+
idx_t size = 0;
|
|
26493
|
+
for (auto &block : blocks) {
|
|
26494
|
+
size += block->block->GetMemoryUsage();
|
|
26440
26495
|
}
|
|
26441
|
-
return
|
|
26496
|
+
return size;
|
|
26497
|
+
}
|
|
26498
|
+
|
|
26499
|
+
//! Verifies that the block sizes are correct (Debug only)
|
|
26500
|
+
void VerifyBlockSizes() const {
|
|
26501
|
+
#ifdef DEBUG
|
|
26502
|
+
for (auto &block : blocks) {
|
|
26503
|
+
D_ASSERT(block->block->GetMemoryUsage() == BufferManager::GetAllocSize(block->capacity * entry_size));
|
|
26504
|
+
}
|
|
26505
|
+
#endif
|
|
26442
26506
|
}
|
|
26443
26507
|
|
|
26444
26508
|
static inline idx_t EntriesPerBlock(idx_t width) {
|
|
@@ -30777,6 +30841,7 @@ public:
|
|
|
30777
30841
|
|
|
30778
30842
|
void Serialize(FieldWriter &writer) const override;
|
|
30779
30843
|
static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
|
|
30844
|
+
vector<idx_t> GetTableIndex() const override;
|
|
30780
30845
|
|
|
30781
30846
|
protected:
|
|
30782
30847
|
void ResolveTypes() override;
|
package/src/duckdb_node.hpp
CHANGED
|
@@ -133,7 +133,6 @@ public:
|
|
|
133
133
|
std::unique_ptr<duckdb::Connection> connection;
|
|
134
134
|
Database *database_ref;
|
|
135
135
|
std::unordered_map<std::string, duckdb_node_udf_function_t> udfs;
|
|
136
|
-
std::unordered_map<std::string, std::vector<std::pair<uint64_t, uint64_t>>> buffers;
|
|
137
136
|
std::unordered_map<std::string, Napi::Reference<Napi::Array>> array_references;
|
|
138
137
|
};
|
|
139
138
|
|