duckdb 0.8.1-dev287.0 → 0.8.1-dev327.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.
Files changed (45) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb/extension/parquet/parquet-extension.cpp +24 -0
  3. package/src/duckdb/src/common/types/timestamp.cpp +37 -1
  4. package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +18 -12
  5. package/src/duckdb/src/execution/index/art/art.cpp +80 -7
  6. package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +20 -1
  7. package/src/duckdb/src/execution/index/art/leaf.cpp +10 -11
  8. package/src/duckdb/src/execution/index/art/leaf_segment.cpp +10 -0
  9. package/src/duckdb/src/execution/index/art/node.cpp +47 -35
  10. package/src/duckdb/src/execution/index/art/node16.cpp +3 -0
  11. package/src/duckdb/src/execution/index/art/node256.cpp +1 -0
  12. package/src/duckdb/src/execution/index/art/node4.cpp +3 -0
  13. package/src/duckdb/src/execution/index/art/node48.cpp +2 -0
  14. package/src/duckdb/src/execution/index/art/prefix.cpp +2 -0
  15. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +29 -3
  16. package/src/duckdb/src/function/table/read_csv.cpp +2 -0
  17. package/src/duckdb/src/function/table/repeat.cpp +3 -0
  18. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  19. package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +4 -14
  20. package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +10 -4
  21. package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +3 -0
  22. package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +1 -1
  23. package/src/duckdb/src/include/duckdb/execution/index/art/leaf_segment.hpp +2 -0
  24. package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +13 -3
  25. package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +1 -0
  26. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +0 -2
  27. package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/byte_reader.hpp +4 -0
  28. package/src/duckdb/src/include/duckdb/storage/in_memory_block_manager.hpp +13 -13
  29. package/src/duckdb/src/include/duckdb/storage/index.hpp +4 -2
  30. package/src/duckdb/src/include/duckdb/storage/storage_extension.hpp +0 -6
  31. package/src/duckdb/src/parser/parsed_data/create_info.cpp +0 -3
  32. package/src/duckdb/src/parser/transform/helpers/nodetype_to_string.cpp +0 -2
  33. package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +0 -3
  34. package/src/duckdb/src/parser/transformer.cpp +0 -2
  35. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +0 -27
  36. package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +0 -25
  37. package/src/duckdb/src/planner/operator/logical_pivot.cpp +14 -2
  38. package/src/duckdb/src/storage/index.cpp +13 -0
  39. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +0 -14
  40. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +12828 -12956
  41. package/src/duckdb/third_party/zstd/compress/zstd_compress.cpp +3 -0
  42. package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_cwksp.h +4 -0
  43. package/src/duckdb/ub_src_parser_transform_statement.cpp +0 -2
  44. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_database_info.hpp +0 -46
  45. package/src/duckdb/src/parser/transform/statement/transform_create_database.cpp +0 -27
@@ -7,6 +7,8 @@
7
7
  #include "duckdb/storage/storage_manager.hpp"
8
8
  #include "duckdb/main/database_manager.hpp"
9
9
  #include "duckdb/execution/index/art/art_key.hpp"
10
+ #include "duckdb/execution/index/art/node.hpp"
11
+ #include "duckdb/execution/index/art/leaf.hpp"
10
12
 
11
13
  namespace duckdb {
12
14
 
@@ -106,6 +108,28 @@ SinkResultType PhysicalCreateIndex::Sink(ExecutionContext &context, DataChunk &c
106
108
  if (!lstate.local_index->MergeIndexes(*art)) {
107
109
  throw ConstraintException("Data contains duplicates on indexed column(s)");
108
110
  }
111
+
112
+ #ifdef DEBUG
113
+ // ensure that all row IDs of this chunk exist in the ART
114
+ auto row_ids = FlatVector::GetData<row_t>(row_identifiers);
115
+ for (idx_t i = 0; i < lstate.key_chunk.size(); i++) {
116
+ auto leaf_node =
117
+ lstate.local_index->Cast<ART>().Lookup(*lstate.local_index->Cast<ART>().tree, lstate.keys[i], 0);
118
+ D_ASSERT(leaf_node.IsSet());
119
+ auto &leaf = Leaf::Get(lstate.local_index->Cast<ART>(), leaf_node);
120
+
121
+ if (leaf.IsInlined()) {
122
+ D_ASSERT(row_ids[i] == leaf.row_ids.inlined);
123
+ continue;
124
+ }
125
+
126
+ D_ASSERT(leaf.row_ids.ptr.IsSet());
127
+ Node leaf_segment = leaf.row_ids.ptr;
128
+ auto position = leaf.FindRowId(lstate.local_index->Cast<ART>(), leaf_segment, row_ids[i]);
129
+ D_ASSERT(position != (uint32_t)DConstants::INVALID_INDEX);
130
+ }
131
+ #endif
132
+
109
133
  return SinkResultType::NEED_MORE_INPUT;
110
134
  }
111
135
 
@@ -119,6 +143,9 @@ void PhysicalCreateIndex::Combine(ExecutionContext &context, GlobalSinkState &gs
119
143
  if (!gstate.global_index->MergeIndexes(*lstate.local_index)) {
120
144
  throw ConstraintException("Data contains duplicates on indexed column(s)");
121
145
  }
146
+
147
+ // vacuum excess memory
148
+ gstate.global_index->Vacuum();
122
149
  }
123
150
 
124
151
  SinkFinalizeType PhysicalCreateIndex::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
@@ -127,6 +154,8 @@ SinkFinalizeType PhysicalCreateIndex::Finalize(Pipeline &pipeline, Event &event,
127
154
  // here, we just set the resulting global index as the newly created index of the table
128
155
 
129
156
  auto &state = gstate_p.Cast<CreateIndexGlobalSinkState>();
157
+ D_ASSERT(!state.global_index->VerifyAndToString(true).empty());
158
+
130
159
  auto &storage = table.GetStorage();
131
160
  if (!storage.IsRoot()) {
132
161
  throw TransactionException("Transaction conflict: cannot add an index to a table that has been altered!");
@@ -147,9 +176,6 @@ SinkFinalizeType PhysicalCreateIndex::Finalize(Pipeline &pipeline, Event &event,
147
176
  index.parsed_expressions.push_back(parsed_expr->Copy());
148
177
  }
149
178
 
150
- // vacuum excess memory
151
- state.global_index->Vacuum();
152
-
153
179
  // add index to storage
154
180
  storage.info->indexes.AddIndex(std::move(state.global_index));
155
181
  return SinkFinalizeType::READY;
@@ -1112,6 +1112,7 @@ void BufferedCSVReaderOptions::Deserialize(FieldReader &reader) {
1112
1112
 
1113
1113
  static void CSVReaderSerialize(FieldWriter &writer, const FunctionData *bind_data_p, const TableFunction &function) {
1114
1114
  auto &bind_data = bind_data_p->Cast<ReadCSVData>();
1115
+ writer.WriteString(function.extra_info);
1115
1116
  writer.WriteList<string>(bind_data.files);
1116
1117
  writer.WriteRegularSerializableList<LogicalType>(bind_data.csv_types);
1117
1118
  writer.WriteList<string>(bind_data.csv_names);
@@ -1130,6 +1131,7 @@ static void CSVReaderSerialize(FieldWriter &writer, const FunctionData *bind_dat
1130
1131
 
1131
1132
  static unique_ptr<FunctionData> CSVReaderDeserialize(ClientContext &context, FieldReader &reader,
1132
1133
  TableFunction &function) {
1134
+ function.extra_info = reader.ReadRequired<string>();
1133
1135
  auto result_data = make_uniq<ReadCSVData>();
1134
1136
  result_data->files = reader.ReadRequiredList<string>();
1135
1137
  result_data->csv_types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
@@ -23,6 +23,9 @@ static unique_ptr<FunctionData> RepeatBind(ClientContext &context, TableFunction
23
23
  auto &inputs = input.inputs;
24
24
  return_types.push_back(inputs[0].type());
25
25
  names.push_back(inputs[0].ToString());
26
+ if (inputs[1].IsNull()) {
27
+ throw BinderException("Repeat second parameter cannot be NULL");
28
+ }
26
29
  return make_uniq<RepeatFunctionData>(inputs[0], inputs[1].GetValue<int64_t>());
27
30
  }
28
31
 
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.8.1-dev287"
2
+ #define DUCKDB_VERSION "0.8.1-dev327"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "8c32403411"
5
+ #define DUCKDB_SOURCE_ID "57912b60a6"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -59,22 +59,12 @@ struct timestamp_t { // NOLINT
59
59
  };
60
60
 
61
61
  // arithmetic operators
62
- inline timestamp_t operator+(const double &value) const {
63
- return timestamp_t(this->value + int64_t(value));
64
- };
65
- inline int64_t operator-(const timestamp_t &other) const {
66
- return this->value - other.value;
67
- };
62
+ timestamp_t operator+(const double &value) const;
63
+ int64_t operator-(const timestamp_t &other) const;
68
64
 
69
65
  // in-place operators
70
- inline timestamp_t &operator+=(const int64_t &value) {
71
- this->value += value;
72
- return *this;
73
- };
74
- inline timestamp_t &operator-=(const int64_t &value) {
75
- this->value -= value;
76
- return *this;
77
- };
66
+ timestamp_t &operator+=(const int64_t &delta);
67
+ timestamp_t &operator-=(const int64_t &delta);
78
68
 
79
69
  // special values
80
70
  static timestamp_t infinity() { // NOLINT
@@ -97,8 +97,11 @@ public:
97
97
  //! Performs constraint checking for a chunk of input data
98
98
  void CheckConstraintsForChunk(DataChunk &input, ConflictManager &conflict_manager) override;
99
99
 
100
- //! Returns the string representation of the ART
101
- string ToString() override;
100
+ //! Returns the string representation of the ART, or only traverses and verifies the index
101
+ string VerifyAndToString(IndexLock &state, const bool only_verify) override;
102
+
103
+ //! Find the node with a matching key, or return nullptr if not found
104
+ Node Lookup(Node node, const ARTKey &key, idx_t depth);
102
105
 
103
106
  private:
104
107
  //! Insert a row ID into a leaf
@@ -107,8 +110,7 @@ private:
107
110
  bool Insert(Node &node, const ARTKey &key, idx_t depth, const row_t &row_id);
108
111
  //! Erase a key from the tree (if a leaf has more than one value) or erase the leaf itself
109
112
  void Erase(Node &node, const ARTKey &key, idx_t depth, const row_t &row_id);
110
- //! Find the node with a matching key, or return nullptr if not found
111
- Node Lookup(Node node, const ARTKey &key, idx_t depth);
113
+
112
114
  //! Returns all row IDs belonging to a key greater (or equal) than the search key
113
115
  bool SearchGreater(ARTIndexScanState &state, ARTKey &key, bool inclusive, idx_t max_count,
114
116
  vector<row_t> &result_ids);
@@ -129,6 +131,10 @@ private:
129
131
  //! Finalizes a vacuum operation by calling the finalize operation of all qualifying
130
132
  //! fixed size allocators
131
133
  void FinalizeVacuum(const ARTFlags &flags);
134
+
135
+ //! Internal function to return the string representation of the ART,
136
+ //! or only traverses and verifies the index
137
+ string VerifyAndToStringInternal(const bool only_verify);
132
138
  };
133
139
 
134
140
  } // namespace duckdb
@@ -100,6 +100,9 @@ public:
100
100
  //! Vacuums a pointer
101
101
  SwizzleablePointer VacuumPointer(const SwizzleablePointer ptr);
102
102
 
103
+ //! Verify that the allocation counts match the existing positions on the buffers
104
+ void Verify() const;
105
+
103
106
  private:
104
107
  //! Returns the data_ptr_t of a pointer
105
108
  inline data_ptr_t Get(const SwizzleablePointer ptr) const {
@@ -73,7 +73,7 @@ public:
73
73
  uint32_t FindRowId(const ART &art, Node &ptr, const row_t row_id) const;
74
74
 
75
75
  //! Returns the string representation of a leaf
76
- string ToString(const ART &art) const;
76
+ string VerifyAndToString(const ART &art, const bool only_verify) const;
77
77
 
78
78
  //! Serialize this leaf
79
79
  BlockPointer Serialize(const ART &art, MetaBlockWriter &writer) const;
@@ -26,6 +26,8 @@ public:
26
26
  static inline LeafSegment &Get(const ART &art, const Node ptr) {
27
27
  return *Node::GetAllocator(art, NType::LEAF_SEGMENT).Get<LeafSegment>(ptr);
28
28
  }
29
+ //! Free the leaf segment and any subsequent ones
30
+ static void Free(ART &art, Node &node);
29
31
 
30
32
  //! Append a row ID to the current segment, or create a new segment containing that row ID
31
33
  LeafSegment &Append(ART &art, uint32_t &count, const row_t row_id);
@@ -65,13 +65,23 @@ public:
65
65
  //! Free the node (and its subtree)
66
66
  static void Free(ART &art, Node &node);
67
67
 
68
+ inline bool operator==(const Node &node) const {
69
+ return swizzle_flag == node.swizzle_flag && type == node.type && offset == node.offset &&
70
+ buffer_id == node.buffer_id;
71
+ }
72
+
68
73
  //! Retrieve the node type from the leftmost byte
69
74
  inline NType DecodeARTNodeType() const {
75
+ D_ASSERT(!IsSwizzled());
76
+ D_ASSERT(type >= (uint8_t)NType::PREFIX_SEGMENT);
77
+ D_ASSERT(type <= (uint8_t)NType::NODE_256);
70
78
  return NType(type);
71
79
  }
72
80
 
73
81
  //! Set the pointer
74
82
  inline void SetPtr(const SwizzleablePointer ptr) {
83
+ swizzle_flag = ptr.swizzle_flag;
84
+ type = ptr.type;
75
85
  offset = ptr.offset;
76
86
  buffer_id = ptr.buffer_id;
77
87
  }
@@ -86,15 +96,15 @@ public:
86
96
  //! Get the child for the respective byte in the node
87
97
  optional_ptr<Node> GetChild(ART &art, const uint8_t byte) const;
88
98
  //! Get the first child that is greater or equal to the specific byte
89
- optional_ptr<Node> GetNextChild(ART &art, uint8_t &byte) const;
99
+ optional_ptr<Node> GetNextChild(ART &art, uint8_t &byte, const bool deserialize = true) const;
90
100
 
91
101
  //! Serialize the node
92
102
  BlockPointer Serialize(ART &art, MetaBlockWriter &writer);
93
103
  //! Deserialize the node
94
104
  void Deserialize(ART &art);
95
105
 
96
- //! Returns the string representation of the node
97
- string ToString(ART &art) const;
106
+ //! Returns the string representation of the node, or only traverses and verifies the node and its subtree
107
+ string VerifyAndToString(ART &art, const bool only_verify);
98
108
  //! Returns the capacity of the node
99
109
  idx_t GetCapacity() const;
100
110
  //! Returns a pointer to the prefix of the node
@@ -59,6 +59,7 @@ public:
59
59
  //! Get the child for the respective byte in the node
60
60
  inline optional_ptr<Node> GetChild(const uint8_t byte) {
61
61
  if (child_index[byte] != Node::EMPTY_MARKER) {
62
+ D_ASSERT(children[child_index[byte]].IsSet());
62
63
  return &children[child_index[byte]];
63
64
  }
64
65
  return nullptr;
@@ -127,8 +127,6 @@ private:
127
127
  unique_ptr<CreateStatement> TransformCreateFunction(duckdb_libpgquery::PGCreateFunctionStmt &stmt);
128
128
  //! Transform a Postgres duckdb_libpgquery::T_PGCreateTypeStmt node into CreateStatement
129
129
  unique_ptr<CreateStatement> TransformCreateType(duckdb_libpgquery::PGCreateTypeStmt &stmt);
130
- //! Transform a Postgres duckdb_libpgquery::T_PGCreateDatabaseStmt node into a CreateStatement
131
- unique_ptr<CreateStatement> TransformCreateDatabase(duckdb_libpgquery::PGCreateDatabaseStmt &stmt);
132
130
  //! Transform a Postgres duckdb_libpgquery::T_PGAlterSeqStmt node into CreateStatement
133
131
  unique_ptr<AlterStatement> TransformAlterSequence(duckdb_libpgquery::PGAlterSeqStmt &stmt);
134
132
  //! Transform a Postgres duckdb_libpgquery::T_PGDropStmt node into a Drop[Table,Schema]Statement
@@ -45,6 +45,7 @@ public:
45
45
  inline T ReadValue(uint8_t bytes, uint8_t trailing_zero) {
46
46
  T result = 0;
47
47
  switch (bytes) {
48
+ // LCOV_EXCL_START
48
49
  case 1:
49
50
  result = Load<uint8_t>(buffer + index);
50
51
  index++;
@@ -73,6 +74,7 @@ public:
73
74
  memcpy(&result, (void *)(buffer + index), 7);
74
75
  index += 7;
75
76
  return result;
77
+ // LCOV_EXCL_STOP
76
78
  default:
77
79
  if (trailing_zero < 8) {
78
80
  result = Load<T>(buffer + index);
@@ -93,6 +95,7 @@ inline uint32_t ByteReader::ReadValue(uint8_t bytes, uint8_t trailing_zero) {
93
95
  uint32_t result = 0;
94
96
  switch (bytes) {
95
97
  case 0:
98
+ // LCOV_EXCL_START
96
99
  if (trailing_zero < 8) {
97
100
  result = Load<uint32_t>(buffer + index);
98
101
  index += sizeof(uint32_t);
@@ -115,6 +118,7 @@ inline uint32_t ByteReader::ReadValue(uint8_t bytes, uint8_t trailing_zero) {
115
118
  result = Load<uint32_t>(buffer + index);
116
119
  index += 4;
117
120
  return result;
121
+ // LCOV_EXCL_STOP
118
122
  default:
119
123
  throw InternalException("Write of %llu bytes attempted into address pointing to 4 byte value", bytes);
120
124
  }
@@ -21,43 +21,43 @@ public:
21
21
 
22
22
  // LCOV_EXCL_START
23
23
  unique_ptr<Block> ConvertBlock(block_id_t block_id, FileBuffer &source_buffer) override {
24
- throw InternalException("Cannot perform IO in in-memory database!");
24
+ throw InternalException("Cannot perform IO in in-memory database - ConvertBlock!");
25
25
  }
26
26
  unique_ptr<Block> CreateBlock(block_id_t block_id, FileBuffer *source_buffer) override {
27
- throw InternalException("Cannot perform IO in in-memory database!");
27
+ throw InternalException("Cannot perform IO in in-memory database - CreateBlock!");
28
28
  }
29
29
  block_id_t GetFreeBlockId() override {
30
- throw InternalException("Cannot perform IO in in-memory database!");
30
+ throw InternalException("Cannot perform IO in in-memory database - GetFreeBlockId!");
31
31
  }
32
32
  bool IsRootBlock(block_id_t root) override {
33
- throw InternalException("Cannot perform IO in in-memory database!");
33
+ throw InternalException("Cannot perform IO in in-memory database - IsRootBlock!");
34
34
  }
35
35
  void MarkBlockAsFree(block_id_t block_id) override {
36
- throw InternalException("Cannot perform IO in in-memory database!");
36
+ throw InternalException("Cannot perform IO in in-memory database - MarkBlockAsFree!");
37
37
  }
38
38
  void MarkBlockAsModified(block_id_t block_id) override {
39
- throw InternalException("Cannot perform IO in in-memory database!");
39
+ throw InternalException("Cannot perform IO in in-memory database - MarkBlockAsModified!");
40
40
  }
41
41
  void IncreaseBlockReferenceCount(block_id_t block_id) override {
42
- throw InternalException("Cannot perform IO in in-memory database!");
42
+ throw InternalException("Cannot perform IO in in-memory database - IncreaseBlockReferenceCount!");
43
43
  }
44
44
  block_id_t GetMetaBlock() override {
45
- throw InternalException("Cannot perform IO in in-memory database!");
45
+ throw InternalException("Cannot perform IO in in-memory database - GetMetaBlock!");
46
46
  }
47
47
  void Read(Block &block) override {
48
- throw InternalException("Cannot perform IO in in-memory database!");
48
+ throw InternalException("Cannot perform IO in in-memory database - Read!");
49
49
  }
50
50
  void Write(FileBuffer &block, block_id_t block_id) override {
51
- throw InternalException("Cannot perform IO in in-memory database!");
51
+ throw InternalException("Cannot perform IO in in-memory database - Write!");
52
52
  }
53
53
  void WriteHeader(DatabaseHeader header) override {
54
- throw InternalException("Cannot perform IO in in-memory database!");
54
+ throw InternalException("Cannot perform IO in in-memory database - WriteHeader!");
55
55
  }
56
56
  idx_t TotalBlocks() override {
57
- throw InternalException("Cannot perform IO in in-memory database!");
57
+ throw InternalException("Cannot perform IO in in-memory database - TotalBlocks!");
58
58
  }
59
59
  idx_t FreeBlocks() override {
60
- throw InternalException("Cannot perform IO in in-memory database!");
60
+ throw InternalException("Cannot perform IO in in-memory database - FreeBlocks!");
61
61
  }
62
62
  // LCOV_EXCL_STOP
63
63
  };
@@ -104,8 +104,10 @@ public:
104
104
  //! Obtains a lock and calls Vacuum while holding that lock
105
105
  void Vacuum();
106
106
 
107
- //! Returns the string representation of an index
108
- virtual string ToString() = 0;
107
+ //! Returns the string representation of an index, or only traverses and verifies the index
108
+ virtual string VerifyAndToString(IndexLock &state, const bool only_verify) = 0;
109
+ //! Obtains a lock and calls VerifyAndToString while holding that lock
110
+ string VerifyAndToString(const bool only_verify);
109
111
 
110
112
  //! Returns true if the index is affected by updates on the specified column IDs, and false otherwise
111
113
  bool IndexIsUpdated(const vector<PhysicalIndex> &column_ids) const;
@@ -28,17 +28,11 @@ typedef unique_ptr<Catalog> (*attach_function_t)(StorageExtensionInfo *storage_i
28
28
  const string &name, AttachInfo &info, AccessMode access_mode);
29
29
  typedef unique_ptr<TransactionManager> (*create_transaction_manager_t)(StorageExtensionInfo *storage_info,
30
30
  AttachedDatabase &db, Catalog &catalog);
31
- typedef unique_ptr<TableFunctionRef> (*create_database_t)(StorageExtensionInfo *info, ClientContext &context,
32
- const string &database_name, const string &source_path);
33
- typedef unique_ptr<TableFunctionRef> (*drop_database_t)(StorageExtensionInfo *storage_info, ClientContext &context,
34
- const string &database_name);
35
31
 
36
32
  class StorageExtension {
37
33
  public:
38
34
  attach_function_t attach;
39
35
  create_transaction_manager_t create_transaction_manager;
40
- create_database_t create_database;
41
- drop_database_t drop_database;
42
36
 
43
37
  //! Additional info passed to the various storage functions
44
38
  shared_ptr<StorageExtensionInfo> storage_info;
@@ -5,7 +5,6 @@
5
5
  #include "duckdb/parser/parsed_data/create_table_info.hpp"
6
6
  #include "duckdb/parser/parsed_data/create_view_info.hpp"
7
7
  #include "duckdb/parser/parsed_data/create_sequence_info.hpp"
8
- #include "duckdb/parser/parsed_data/create_database_info.hpp"
9
8
  #include "duckdb/parser/parsed_data/create_type_info.hpp"
10
9
  #include "duckdb/parser/parsed_data/alter_info.hpp"
11
10
  #include "duckdb/parser/parsed_data/create_macro_info.hpp"
@@ -43,8 +42,6 @@ unique_ptr<CreateInfo> CreateInfo::Deserialize(Deserializer &deserializer) {
43
42
  return CreateSchemaInfo::Deserialize(deserializer);
44
43
  case CatalogType::VIEW_ENTRY:
45
44
  return CreateViewInfo::Deserialize(deserializer);
46
- case CatalogType::DATABASE_ENTRY:
47
- return CreateDatabaseInfo::Deserialize(deserializer);
48
45
  case CatalogType::TYPE_ENTRY:
49
46
  return CreateTypeInfo::Deserialize(deserializer);
50
47
  case CatalogType::MACRO_ENTRY:
@@ -816,8 +816,6 @@ std::string Transformer::NodetypeToString(duckdb_libpgquery::PGNodeTag type) { /
816
816
  return "T_PGAttachStmt";
817
817
  case duckdb_libpgquery::T_PGUseStmt:
818
818
  return "T_PGUseStmt";
819
- case duckdb_libpgquery::T_PGCreateDatabaseStmt:
820
- return "T_PGCreateDatabaseStmt";
821
819
  default:
822
820
  return "(UNKNOWN)";
823
821
  }
@@ -34,9 +34,6 @@ unique_ptr<SQLStatement> Transformer::TransformDrop(duckdb_libpgquery::PGDropStm
34
34
  case duckdb_libpgquery::PG_OBJECT_TYPE:
35
35
  info.type = CatalogType::TYPE_ENTRY;
36
36
  break;
37
- case duckdb_libpgquery::PG_OBJECT_DATABASE:
38
- info.type = CatalogType::DATABASE_ENTRY;
39
- break;
40
37
  default:
41
38
  throw NotImplementedException("Cannot drop this type yet");
42
39
  }
@@ -204,8 +204,6 @@ unique_ptr<SQLStatement> Transformer::TransformStatementInternal(duckdb_libpgque
204
204
  return TransformDetach(PGCast<duckdb_libpgquery::PGDetachStmt>(stmt));
205
205
  case duckdb_libpgquery::T_PGUseStmt:
206
206
  return TransformUse(PGCast<duckdb_libpgquery::PGUseStmt>(stmt));
207
- case duckdb_libpgquery::T_PGCreateDatabaseStmt:
208
- return TransformCreateDatabase(PGCast<duckdb_libpgquery::PGCreateDatabaseStmt>(stmt));
209
207
  default:
210
208
  throw NotImplementedException(NodetypeToString(stmt.type));
211
209
  }
@@ -13,7 +13,6 @@
13
13
  #include "duckdb/parser/parsed_data/create_index_info.hpp"
14
14
  #include "duckdb/parser/parsed_data/create_macro_info.hpp"
15
15
  #include "duckdb/parser/parsed_data/create_view_info.hpp"
16
- #include "duckdb/parser/parsed_data/create_database_info.hpp"
17
16
  #include "duckdb/parser/tableref/table_function_ref.hpp"
18
17
  #include "duckdb/parser/parsed_expression_iterator.hpp"
19
18
  #include "duckdb/parser/statement/create_statement.hpp"
@@ -656,32 +655,6 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
656
655
  }
657
656
  break;
658
657
  }
659
- case CatalogType::DATABASE_ENTRY: {
660
- // not supported in DuckDB yet but allow extensions to intercept and implement this functionality
661
- auto &base = stmt.info->Cast<CreateDatabaseInfo>();
662
- string database_name = base.name;
663
- string source_path = base.path;
664
-
665
- auto &config = DBConfig::GetConfig(context);
666
-
667
- if (config.storage_extensions.empty()) {
668
- throw NotImplementedException("CREATE DATABASE not supported in DuckDB yet");
669
- }
670
- // for now assume only one storage extension provides the custom create_database impl
671
- for (auto &extension_entry : config.storage_extensions) {
672
- if (extension_entry.second->create_database != nullptr) {
673
- auto &storage_extension = extension_entry.second;
674
- auto create_database_function_ref = storage_extension->create_database(
675
- storage_extension->storage_info.get(), context, database_name, source_path);
676
- if (create_database_function_ref) {
677
- auto bound_create_database_func = Bind(*create_database_function_ref);
678
- result.plan = CreatePlan(*bound_create_database_func);
679
- break;
680
- }
681
- }
682
- }
683
- break;
684
- }
685
658
  default:
686
659
  throw Exception("Unrecognized type!");
687
660
  }
@@ -47,31 +47,6 @@ BoundStatement Binder::Bind(DropStatement &stmt) {
47
47
  stmt.info->schema = entry->ParentSchema().name;
48
48
  break;
49
49
  }
50
- case CatalogType::DATABASE_ENTRY: {
51
- auto &base = (DropInfo &)*stmt.info;
52
- string database_name = base.name;
53
-
54
- auto &config = DBConfig::GetConfig(context);
55
- // for now assume only one storage extension provides the custom drop_database impl
56
- for (auto &extension_entry : config.storage_extensions) {
57
- if (extension_entry.second->drop_database == nullptr) {
58
- continue;
59
- }
60
- auto &storage_extension = extension_entry.second;
61
- auto drop_database_function_ref =
62
- storage_extension->drop_database(storage_extension->storage_info.get(), context, database_name);
63
- if (drop_database_function_ref) {
64
- auto bound_drop_database_func = Bind(*drop_database_function_ref);
65
- result.plan = CreatePlan(*bound_drop_database_func);
66
- result.names = {"Success"};
67
- result.types = {LogicalType::BIGINT};
68
- properties.allow_stream_result = false;
69
- properties.return_type = StatementReturnType::NOTHING;
70
- return result;
71
- }
72
- }
73
- throw BinderException("Drop is not supported for this database!");
74
- }
75
50
  default:
76
51
  throw BinderException("Unknown catalog type for drop statement!");
77
52
  }
@@ -19,11 +19,23 @@ vector<ColumnBinding> LogicalPivot::GetColumnBindings() {
19
19
  }
20
20
 
21
21
  void LogicalPivot::Serialize(FieldWriter &writer) const {
22
- throw NotImplementedException("Serializing pivot is not supported yet");
22
+ writer.WriteField(pivot_index);
23
+ writer.WriteOptional<LogicalOperator>(children.back());
24
+ writer.WriteField(bound_pivot.group_count);
25
+ writer.WriteRegularSerializableList<LogicalType>(bound_pivot.types);
26
+ writer.WriteList<string>(bound_pivot.pivot_values);
27
+ writer.WriteSerializableList<Expression>(bound_pivot.aggregates);
23
28
  }
24
29
 
25
30
  unique_ptr<LogicalOperator> LogicalPivot::Deserialize(LogicalDeserializationState &state, FieldReader &reader) {
26
- throw NotImplementedException("Deserializing pivot is not supported yet");
31
+ auto pivot_index = reader.ReadRequired<idx_t>();
32
+ auto plan = reader.ReadOptional<LogicalOperator>(nullptr, state.gstate);
33
+ BoundPivotInfo info;
34
+ info.group_count = reader.ReadRequired<idx_t>();
35
+ info.types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
36
+ info.pivot_values = reader.ReadRequiredList<string>();
37
+ info.aggregates = reader.ReadRequiredSerializableList<Expression>(state.gstate);
38
+ return make_uniq<LogicalPivot>(pivot_index, std::move(plan), std::move(info));
27
39
  }
28
40
 
29
41
  vector<idx_t> LogicalPivot::GetTableIndex() const {
@@ -59,6 +59,19 @@ bool Index::MergeIndexes(Index &other_index) {
59
59
  }
60
60
  }
61
61
 
62
+ string Index::VerifyAndToString(const bool only_verify) {
63
+
64
+ IndexLock state;
65
+ InitializeLock(state);
66
+
67
+ switch (this->type) {
68
+ case IndexType::ART:
69
+ return Cast<ART>().VerifyAndToString(state, only_verify);
70
+ default:
71
+ throw InternalException("Unimplemented index type for VerifyAndToString");
72
+ }
73
+ }
74
+
62
75
  void Index::Vacuum() {
63
76
 
64
77
  IndexLock state;
@@ -2119,20 +2119,6 @@ typedef struct PGDetachStmt
2119
2119
  bool missing_ok;
2120
2120
  } PGDetachStmt;
2121
2121
 
2122
-
2123
-
2124
- /* ----------------------
2125
- * CREATE DATABASE Statement
2126
- * ----------------------
2127
- */
2128
- typedef struct PGCreateDatabaseStmt
2129
- {
2130
- PGNodeTag type;
2131
- PGRangeVar *name; /* The name of the created database */
2132
- char *extension; /* The name of the extension which will create the database */
2133
- char *path; /* The file path of the to-be-created database */
2134
- } PGCreateDatabaseStmt;
2135
-
2136
2122
  /* ----------------------
2137
2123
  * Use Statement
2138
2124
  * ----------------------