duckdb 0.7.1-dev14.0 → 0.7.1-dev157.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/extension/json/buffered_json_reader.cpp +29 -5
- package/src/duckdb/extension/json/include/buffered_json_reader.hpp +5 -1
- package/src/duckdb/extension/json/include/json_scan.hpp +17 -2
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +19 -0
- package/src/duckdb/extension/json/json_functions/read_json.cpp +30 -28
- package/src/duckdb/extension/json/json_functions.cpp +6 -0
- package/src/duckdb/extension/json/json_scan.cpp +111 -23
- package/src/duckdb/extension/parquet/parquet-extension.cpp +3 -2
- package/src/duckdb/src/common/enums/logical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
- package/src/duckdb/src/common/file_system.cpp +14 -0
- package/src/duckdb/src/common/operator/cast_operators.cpp +14 -8
- package/src/duckdb/src/common/printer.cpp +1 -1
- package/src/duckdb/src/common/types/time.cpp +1 -1
- package/src/duckdb/src/common/types/timestamp.cpp +35 -4
- package/src/duckdb/src/common/types.cpp +36 -10
- package/src/duckdb/src/execution/column_binding_resolver.cpp +5 -2
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +7 -9
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +6 -11
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +7 -13
- package/src/duckdb/src/execution/operator/persistent/parallel_csv_reader.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +37 -0
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +0 -5
- package/src/duckdb/src/execution/physical_plan/plan_simple.cpp +4 -0
- package/src/duckdb/src/execution/physical_plan_generator.cpp +1 -0
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +36 -9
- package/src/duckdb/src/function/table/read_csv.cpp +15 -4
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/exception.hpp +10 -0
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +5 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +0 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +32 -0
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/config.hpp +0 -3
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_database_info.hpp +0 -4
- package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +32 -0
- package/src/duckdb/src/include/duckdb/parser/statement/detach_statement.hpp +29 -0
- package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +1 -0
- 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/include/duckdb/storage/storage_extension.hpp +7 -0
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -0
- package/src/duckdb/src/main/client_context.cpp +2 -0
- package/src/duckdb/src/main/extension/extension_alias.cpp +2 -1
- package/src/duckdb/src/parser/statement/copy_statement.cpp +2 -13
- package/src/duckdb/src/parser/statement/delete_statement.cpp +3 -0
- package/src/duckdb/src/parser/statement/detach_statement.cpp +15 -0
- package/src/duckdb/src/parser/statement/insert_statement.cpp +9 -0
- package/src/duckdb/src/parser/statement/update_statement.cpp +3 -0
- package/src/duckdb/src/parser/transform/expression/transform_case.cpp +3 -3
- package/src/duckdb/src/parser/transform/statement/transform_create_database.cpp +0 -1
- package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +19 -0
- package/src/duckdb/src/parser/transformer.cpp +2 -0
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +16 -14
- package/src/duckdb/src/planner/binder/statement/bind_detach.cpp +19 -0
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +29 -4
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +22 -1
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +2 -1
- package/src/duckdb/src/planner/binder.cpp +2 -0
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +21 -5
- package/src/duckdb/src/planner/logical_operator.cpp +4 -0
- package/src/duckdb/src/planner/planner.cpp +1 -0
- package/src/duckdb/src/storage/storage_info.cpp +2 -1
- package/src/duckdb/src/storage/table/column_data.cpp +4 -2
- package/src/duckdb/src/storage/table/update_segment.cpp +15 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +14 -0
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +530 -1006
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +17659 -17626
- package/src/duckdb/ub_src_execution_operator_schema.cpp +2 -0
- package/src/duckdb/ub_src_parser_statement.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_statement.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_statement.cpp +2 -0
- package/src/duckdb/src/include/duckdb/function/create_database_extension.hpp +0 -37
|
@@ -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);
|
|
@@ -128,6 +128,8 @@ unique_ptr<BoundTableRef> Binder::Bind(JoinRef &ref) {
|
|
|
128
128
|
{
|
|
129
129
|
LateralBinder binder(left_binder, context);
|
|
130
130
|
result->right = right_binder.Bind(*ref.right);
|
|
131
|
+
result->correlated_columns = binder.ExtractCorrelatedColumns(right_binder);
|
|
132
|
+
|
|
131
133
|
result->lateral = binder.HasCorrelatedColumns();
|
|
132
134
|
if (result->lateral) {
|
|
133
135
|
// lateral join: can only be an INNER or LEFT join
|
|
@@ -135,7 +137,6 @@ unique_ptr<BoundTableRef> Binder::Bind(JoinRef &ref) {
|
|
|
135
137
|
throw BinderException("The combining JOIN type must be INNER or LEFT for a LATERAL reference");
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
|
-
result->correlated_columns = binder.ExtractCorrelatedColumns(right_binder);
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
vector<unique_ptr<ParsedExpression>> extra_conditions;
|
|
@@ -90,6 +90,8 @@ BoundStatement Binder::Bind(SQLStatement &statement) {
|
|
|
90
90
|
return Bind((LogicalPlanStatement &)statement);
|
|
91
91
|
case StatementType::ATTACH_STATEMENT:
|
|
92
92
|
return Bind((AttachStatement &)statement);
|
|
93
|
+
case StatementType::DETACH_STATEMENT:
|
|
94
|
+
return Bind((DetachStatement &)statement);
|
|
93
95
|
default: // LCOV_EXCL_START
|
|
94
96
|
throw NotImplementedException("Unimplemented statement type \"%s\" for Bind",
|
|
95
97
|
StatementTypeToString(statement.type));
|
|
@@ -39,14 +39,30 @@ BindResult LateralBinder::BindColumnRef(unique_ptr<ParsedExpression> *expr_ptr,
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
vector<CorrelatedColumnInfo> LateralBinder::ExtractCorrelatedColumns(Binder &binder) {
|
|
42
|
+
|
|
43
|
+
if (correlated_columns.empty()) {
|
|
44
|
+
return binder.correlated_columns;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// clear outer
|
|
48
|
+
correlated_columns.clear();
|
|
42
49
|
auto all_correlated_columns = binder.correlated_columns;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
|
|
51
|
+
// remove outer from inner
|
|
52
|
+
for (auto &corr_column : correlated_columns) {
|
|
53
|
+
auto entry = std::find(binder.correlated_columns.begin(), binder.correlated_columns.end(), corr_column);
|
|
54
|
+
if (entry != binder.correlated_columns.end()) {
|
|
55
|
+
binder.correlated_columns.erase(entry);
|
|
47
56
|
}
|
|
48
|
-
binder.correlated_columns.erase(entry);
|
|
49
57
|
}
|
|
58
|
+
|
|
59
|
+
// add inner to outer
|
|
60
|
+
for (auto &corr_column : binder.correlated_columns) {
|
|
61
|
+
correlated_columns.push_back(corr_column);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// clear inner
|
|
65
|
+
binder.correlated_columns.clear();
|
|
50
66
|
return all_correlated_columns;
|
|
51
67
|
}
|
|
52
68
|
|
|
@@ -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;
|
|
@@ -338,6 +340,8 @@ unique_ptr<LogicalOperator> LogicalOperator::Deserialize(Deserializer &deseriali
|
|
|
338
340
|
case LogicalOperatorType::LOGICAL_DROP:
|
|
339
341
|
result = LogicalSimple::Deserialize(state, reader);
|
|
340
342
|
break;
|
|
343
|
+
case LogicalOperatorType::LOGICAL_DETACH:
|
|
344
|
+
throw SerializationException("Logical Detach does not support serialization");
|
|
341
345
|
case LogicalOperatorType::LOGICAL_EXTENSION_OPERATOR:
|
|
342
346
|
result = LogicalExtensionOperator::Deserialize(state, reader);
|
|
343
347
|
break;
|
|
@@ -133,6 +133,7 @@ void Planner::CreatePlan(unique_ptr<SQLStatement> statement) {
|
|
|
133
133
|
case StatementType::EXECUTE_STATEMENT:
|
|
134
134
|
case StatementType::LOGICAL_PLAN_STATEMENT:
|
|
135
135
|
case StatementType::ATTACH_STATEMENT:
|
|
136
|
+
case StatementType::DETACH_STATEMENT:
|
|
136
137
|
CreatePlan(*statement);
|
|
137
138
|
break;
|
|
138
139
|
default:
|
|
@@ -9,7 +9,8 @@ struct StorageVersionInfo {
|
|
|
9
9
|
idx_t storage_version;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
static StorageVersionInfo storage_version_info[] = {{"v0.
|
|
12
|
+
static StorageVersionInfo storage_version_info[] = {{"v0.7.0", 43},
|
|
13
|
+
{"v0.6.0 or v0.6.1", 39},
|
|
13
14
|
{"v0.5.0 or v0.5.1", 38},
|
|
14
15
|
{"v0.3.3, v0.3.4 or v0.4.0", 33},
|
|
15
16
|
{"v0.3.2", 31},
|
|
@@ -27,8 +27,10 @@ ColumnData::ColumnData(BlockManager &block_manager, DataTableInfo &info, idx_t c
|
|
|
27
27
|
|
|
28
28
|
ColumnData::ColumnData(ColumnData &other, idx_t start, ColumnData *parent)
|
|
29
29
|
: block_manager(other.block_manager), info(other.info), column_index(other.column_index), start(start),
|
|
30
|
-
type(std::move(other.type)), parent(parent),
|
|
31
|
-
|
|
30
|
+
type(std::move(other.type)), parent(parent), version(parent ? parent->version + 1 : 0) {
|
|
31
|
+
if (other.updates) {
|
|
32
|
+
updates = make_unique<UpdateSegment>(*other.updates, *this);
|
|
33
|
+
}
|
|
32
34
|
idx_t offset = 0;
|
|
33
35
|
for (auto segment = other.data.GetRootSegment(); segment; segment = segment->Next()) {
|
|
34
36
|
auto &other = (ColumnSegment &)*segment;
|
|
@@ -36,6 +36,21 @@ UpdateSegment::UpdateSegment(ColumnData &column_data)
|
|
|
36
36
|
this->statistics_update_function = GetStatisticsUpdateFunction(physical_type);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
UpdateSegment::UpdateSegment(UpdateSegment &other, ColumnData &owner)
|
|
40
|
+
: column_data(owner), root(std::move(other.root)), stats(std::move(other.stats)), type_size(other.type_size) {
|
|
41
|
+
|
|
42
|
+
this->heap.Move(other.heap);
|
|
43
|
+
|
|
44
|
+
initialize_update_function = other.initialize_update_function;
|
|
45
|
+
merge_update_function = other.merge_update_function;
|
|
46
|
+
fetch_update_function = other.fetch_update_function;
|
|
47
|
+
fetch_committed_function = other.fetch_committed_function;
|
|
48
|
+
fetch_committed_range = other.fetch_committed_range;
|
|
49
|
+
fetch_row_function = other.fetch_row_function;
|
|
50
|
+
rollback_update_function = other.rollback_update_function;
|
|
51
|
+
statistics_update_function = other.statistics_update_function;
|
|
52
|
+
}
|
|
53
|
+
|
|
39
54
|
UpdateSegment::~UpdateSegment() {
|
|
40
55
|
}
|
|
41
56
|
|
|
@@ -2070,6 +2070,20 @@ typedef struct PGAttachStmt
|
|
|
2070
2070
|
PGNode *query;
|
|
2071
2071
|
} PGAttachStmt;
|
|
2072
2072
|
|
|
2073
|
+
/* ----------------------
|
|
2074
|
+
* Dettach Statement
|
|
2075
|
+
* ----------------------
|
|
2076
|
+
*/
|
|
2077
|
+
|
|
2078
|
+
typedef struct PGDetachStmt
|
|
2079
|
+
{
|
|
2080
|
+
PGNodeTag type;
|
|
2081
|
+
char *db_name; /* list of names of attached databases */
|
|
2082
|
+
bool missing_ok;
|
|
2083
|
+
} PGDetachStmt;
|
|
2084
|
+
|
|
2085
|
+
|
|
2086
|
+
|
|
2073
2087
|
/* ----------------------
|
|
2074
2088
|
* CREATE DATABASE Statement
|
|
2075
2089
|
* ----------------------
|