duckdb 0.7.1-dev100.0 → 0.7.1-dev107.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/duckdb/src/execution/column_binding_resolver.cpp +5 -2
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +36 -9
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +1 -5
- package/src/duckdb/src/include/duckdb/planner/operator/logical_show.hpp +1 -2
- package/src/duckdb/src/parser/statement/insert_statement.cpp +3 -0
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +22 -1
- package/src/duckdb/src/planner/logical_operator.cpp +2 -0
package/package.json
CHANGED
|
@@ -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
|
|
70
|
-
|
|
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,10 +1,12 @@
|
|
|
1
|
-
#include "duckdb/
|
|
2
|
-
#include "duckdb/common/string_util.hpp"
|
|
1
|
+
#include "duckdb/common/constants.hpp"
|
|
3
2
|
#include "duckdb/common/file_system.hpp"
|
|
4
|
-
#include "duckdb/
|
|
5
|
-
#include "duckdb/
|
|
6
|
-
#include "duckdb/parser/parser.hpp"
|
|
3
|
+
#include "duckdb/common/string_util.hpp"
|
|
4
|
+
#include "duckdb/function/pragma/pragma_functions.hpp"
|
|
7
5
|
#include "duckdb/main/config.hpp"
|
|
6
|
+
#include "duckdb/parser/parser.hpp"
|
|
7
|
+
#include "duckdb/parser/qualified_name.hpp"
|
|
8
|
+
#include "duckdb/parser/statement/copy_statement.hpp"
|
|
9
|
+
#include "duckdb/parser/statement/export_statement.hpp"
|
|
8
10
|
|
|
9
11
|
namespace duckdb {
|
|
10
12
|
|
|
@@ -58,10 +60,35 @@ string PragmaFunctionsQuery(ClientContext &context, const FunctionParameters &pa
|
|
|
58
60
|
|
|
59
61
|
string PragmaShow(ClientContext &context, const FunctionParameters ¶meters) {
|
|
60
62
|
// PRAGMA table_info but with some aliases
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
auto table = QualifiedName::Parse(parameters.values[0].ToString());
|
|
64
|
+
|
|
65
|
+
// clang-format off
|
|
66
|
+
string sql = R"(
|
|
67
|
+
SELECT
|
|
68
|
+
name AS "column_name",
|
|
69
|
+
type as "column_type",
|
|
70
|
+
CASE WHEN "notnull" THEN 'NO' ELSE 'YES' END AS "null",
|
|
71
|
+
(SELECT
|
|
72
|
+
MIN(CASE
|
|
73
|
+
WHEN constraint_type='PRIMARY KEY' THEN 'PRI'
|
|
74
|
+
WHEN constraint_type='UNIQUE' THEN 'UNI'
|
|
75
|
+
ELSE NULL END)
|
|
76
|
+
FROM duckdb_constraints() c
|
|
77
|
+
WHERE c.table_oid=cols.table_oid
|
|
78
|
+
AND list_contains(constraint_column_names, cols.column_name)) AS "key",
|
|
79
|
+
dflt_value AS "default",
|
|
80
|
+
NULL AS "extra"
|
|
81
|
+
FROM pragma_table_info('%func_param_table%')
|
|
82
|
+
LEFT JOIN duckdb_columns cols
|
|
83
|
+
ON cols.column_name = pragma_table_info.name
|
|
84
|
+
AND cols.table_name='%table_name%'
|
|
85
|
+
AND cols.schema_name='%table_schema%';)";
|
|
86
|
+
// clang-format on
|
|
87
|
+
|
|
88
|
+
sql = StringUtil::Replace(sql, "%func_param_table%", parameters.values[0].ToString());
|
|
89
|
+
sql = StringUtil::Replace(sql, "%table_name%", table.name);
|
|
90
|
+
sql = StringUtil::Replace(sql, "%table_schema%", table.schema.empty() ? DEFAULT_SCHEMA : table.schema);
|
|
91
|
+
return sql;
|
|
65
92
|
}
|
|
66
93
|
|
|
67
94
|
string PragmaVersion(ClientContext &context, const FunctionParameters ¶meters) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
|
2
|
-
#define DUCKDB_VERSION "0.7.1-
|
|
2
|
+
#define DUCKDB_VERSION "0.7.1-dev107"
|
|
3
3
|
#endif
|
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
|
5
|
+
#define DUCKDB_SOURCE_ID "8a8581e2e3"
|
|
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
|
-
|
|
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
|
|
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
|
|
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 ¤t_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 = ¤t_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;
|