duckdb 0.7.1-dev100.0 → 0.7.1-dev103.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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.7.1-dev100.0",
5
+ "version": "0.7.1-dev103.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -65,9 +65,12 @@ void ColumnBindingResolver::VisitOperator(LogicalOperator &op) {
65
65
  // ON CONFLICT DO UPDATE clause
66
66
  auto &insert_op = (LogicalInsert &)op;
67
67
  if (insert_op.action_type != OnConflictAction::THROW) {
68
+ // Get the bindings from the children
68
69
  VisitOperatorChildren(op);
69
- auto dummy_bindings = LogicalOperator::GenerateColumnBindings(
70
- insert_op.excluded_table_index, insert_op.table->GetColumns().PhysicalColumnCount());
70
+ auto column_count = insert_op.table->GetColumns().PhysicalColumnCount();
71
+ auto dummy_bindings = LogicalOperator::GenerateColumnBindings(insert_op.excluded_table_index, column_count);
72
+ // Now insert our dummy bindings at the start of the bindings,
73
+ // so the first 'column_count' indices of the chunk are reserved for our 'excluded' columns
71
74
  bindings.insert(bindings.begin(), dummy_bindings.begin(), dummy_bindings.end());
72
75
  if (insert_op.on_conflict_condition) {
73
76
  VisitExpression(&insert_op.on_conflict_condition);
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.7.1-dev100"
2
+ #define DUCKDB_VERSION "0.7.1-dev103"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "1955e8bf10"
5
+ #define DUCKDB_SOURCE_ID "cfea2a2db7"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -32,11 +32,7 @@ protected:
32
32
  // already resolved
33
33
  }
34
34
  vector<ColumnBinding> GetColumnBindings() override {
35
- vector<ColumnBinding> bindings;
36
- for (idx_t i = 0; i < types.size(); i++) {
37
- bindings.push_back(ColumnBinding(0, i));
38
- }
39
- return bindings;
35
+ return GenerateColumnBindings(0, types.size());
40
36
  }
41
37
  };
42
38
  } // namespace duckdb
@@ -33,8 +33,7 @@ protected:
33
33
  LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR};
34
34
  }
35
35
  vector<ColumnBinding> GetColumnBindings() override {
36
- return {ColumnBinding(0, 0), ColumnBinding(0, 1), ColumnBinding(0, 2),
37
- ColumnBinding(0, 3), ColumnBinding(0, 4), ColumnBinding(0, 5)};
36
+ return GenerateColumnBindings(0, types.size());
38
37
  }
39
38
  };
40
39
  } // namespace duckdb
@@ -28,6 +28,9 @@ InsertStatement::InsertStatement(const InsertStatement &other)
28
28
  select_statement(unique_ptr_cast<SQLStatement, SelectStatement>(other.select_statement->Copy())),
29
29
  columns(other.columns), table(other.table), schema(other.schema), catalog(other.catalog) {
30
30
  cte_map = other.cte_map.Copy();
31
+ if (other.table_ref) {
32
+ table_ref = other.table_ref->Copy();
33
+ }
31
34
  if (other.on_conflict_info) {
32
35
  on_conflict_info = other.on_conflict_info->Copy();
33
36
  }
@@ -301,7 +301,28 @@ void Binder::BindOnConflictClause(LogicalInsert &insert, TableCatalogEntry &tabl
301
301
  insert.on_conflict_condition = std::move(condition);
302
302
  }
303
303
 
304
- auto projection_index = insert.children[0]->GetTableIndex()[0];
304
+ auto bindings = insert.children[0]->GetColumnBindings();
305
+ idx_t projection_index = DConstants::INVALID_INDEX;
306
+ std::vector<unique_ptr<LogicalOperator>> *insert_child_operators;
307
+ insert_child_operators = &insert.children;
308
+ while (projection_index == DConstants::INVALID_INDEX) {
309
+ if (insert_child_operators->empty()) {
310
+ // No further children to visit
311
+ break;
312
+ }
313
+ D_ASSERT(insert_child_operators->size() >= 1);
314
+ auto &current_child = (*insert_child_operators)[0];
315
+ auto table_indices = current_child->GetTableIndex();
316
+ if (table_indices.empty()) {
317
+ // This operator does not have a table index to refer to, we have to visit its children
318
+ insert_child_operators = &current_child->children;
319
+ continue;
320
+ }
321
+ projection_index = table_indices[0];
322
+ }
323
+ if (projection_index == DConstants::INVALID_INDEX) {
324
+ throw InternalException("Could not locate a table_index from the children of the insert");
325
+ }
305
326
 
306
327
  string unused;
307
328
  auto original_binding = bind_context.GetBinding(table_alias, unused);
@@ -57,6 +57,7 @@ void LogicalOperator::ResolveOperatorTypes() {
57
57
 
58
58
  vector<ColumnBinding> LogicalOperator::GenerateColumnBindings(idx_t table_idx, idx_t column_count) {
59
59
  vector<ColumnBinding> result;
60
+ result.reserve(column_count);
60
61
  for (idx_t i = 0; i < column_count; i++) {
61
62
  result.emplace_back(table_idx, i);
62
63
  }
@@ -84,6 +85,7 @@ vector<ColumnBinding> LogicalOperator::MapBindings(const vector<ColumnBinding> &
84
85
  vector<ColumnBinding> result_bindings;
85
86
  result_bindings.reserve(projection_map.size());
86
87
  for (auto index : projection_map) {
88
+ D_ASSERT(index < bindings.size());
87
89
  result_bindings.push_back(bindings[index]);
88
90
  }
89
91
  return result_bindings;