duckdb 0.3.5-dev365.0 → 0.3.5-dev375.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.cpp +107 -117
- package/src/duckdb.hpp +43 -24
- package/src/parquet-amalgamation.cpp +36523 -36523
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -6923,17 +6923,6 @@ string StatementTypeToString(StatementType type) {
|
|
|
6923
6923
|
}
|
|
6924
6924
|
// LCOV_EXCL_STOP
|
|
6925
6925
|
|
|
6926
|
-
bool StatementTypeReturnChanges(StatementType type) {
|
|
6927
|
-
switch (type) {
|
|
6928
|
-
case StatementType::INSERT_STATEMENT:
|
|
6929
|
-
case StatementType::UPDATE_STATEMENT:
|
|
6930
|
-
case StatementType::DELETE_STATEMENT:
|
|
6931
|
-
return true;
|
|
6932
|
-
default:
|
|
6933
|
-
return false;
|
|
6934
|
-
}
|
|
6935
|
-
}
|
|
6936
|
-
|
|
6937
6926
|
} // namespace duckdb
|
|
6938
6927
|
|
|
6939
6928
|
|
|
@@ -39593,10 +39582,10 @@ int32_t Date::ExtractISODayOfTheWeek(date_t date) {
|
|
|
39593
39582
|
// 7 = 4
|
|
39594
39583
|
if (date.days < 0) {
|
|
39595
39584
|
// negative date: start off at 4 and cycle downwards
|
|
39596
|
-
return (7 - ((-date.days + 3) % 7));
|
|
39585
|
+
return (7 - ((-int64_t(date.days) + 3) % 7));
|
|
39597
39586
|
} else {
|
|
39598
39587
|
// positive date: start off at 4 and cycle upwards
|
|
39599
|
-
return ((date.days + 3) % 7) + 1;
|
|
39588
|
+
return ((int64_t(date.days) + 3) % 7) + 1;
|
|
39600
39589
|
}
|
|
39601
39590
|
}
|
|
39602
39591
|
|
|
@@ -53956,9 +53945,8 @@ void ExpressionExecutor::Execute(const BoundOperatorExpression &expr, Expression
|
|
|
53956
53945
|
}
|
|
53957
53946
|
}
|
|
53958
53947
|
if (remaining_count > 0) {
|
|
53959
|
-
auto &result_mask = FlatVector::Validity(result);
|
|
53960
53948
|
for (idx_t i = 0; i < remaining_count; i++) {
|
|
53961
|
-
|
|
53949
|
+
FlatVector::SetNull(result, current_sel->get_index(i), true);
|
|
53962
53950
|
}
|
|
53963
53951
|
}
|
|
53964
53952
|
if (sel) {
|
|
@@ -60088,15 +60076,8 @@ public:
|
|
|
60088
60076
|
//! The result types of the transaction
|
|
60089
60077
|
vector<LogicalType> types;
|
|
60090
60078
|
|
|
60091
|
-
//!
|
|
60092
|
-
|
|
60093
|
-
//! Whether or not the statement requires a valid transaction. Almost all statements require this, with the
|
|
60094
|
-
//! exception of
|
|
60095
|
-
bool requires_valid_transaction;
|
|
60096
|
-
//! Whether or not the result can be streamed to the client
|
|
60097
|
-
bool allow_stream_result;
|
|
60098
|
-
//! Whether or not all parameters have successfully had their types determined
|
|
60099
|
-
bool bound_all_parameters;
|
|
60079
|
+
//! The statement properties
|
|
60080
|
+
StatementProperties properties;
|
|
60100
60081
|
|
|
60101
60082
|
//! The catalog version of when the prepared statement was bound
|
|
60102
60083
|
//! If this version is lower than the current catalog version, we have to rebind the prepared statement
|
|
@@ -109137,7 +109118,7 @@ idx_t duckdb_arrow_rows_changed(duckdb_arrow result) {
|
|
|
109137
109118
|
auto wrapper = (ArrowResultWrapper *)result;
|
|
109138
109119
|
idx_t rows_changed = 0;
|
|
109139
109120
|
idx_t row_count = wrapper->result->collection.Count();
|
|
109140
|
-
if (row_count > 0 &&
|
|
109121
|
+
if (row_count > 0 && wrapper->result->properties.return_type == duckdb::StatementReturnType::CHANGED_ROWS) {
|
|
109141
109122
|
auto row_changes = wrapper->result->GetValue(0, 0);
|
|
109142
109123
|
if (!row_changes.IsNull() && row_changes.TryCastAs(LogicalType::BIGINT)) {
|
|
109143
109124
|
rows_changed = row_changes.GetValue<int64_t>();
|
|
@@ -110595,7 +110576,8 @@ bool deprecated_materialize_result(duckdb_result *result) {
|
|
|
110595
110576
|
result->__deprecated_columns[i].__deprecated_name = (char *)result_data->result->names[i].c_str();
|
|
110596
110577
|
}
|
|
110597
110578
|
result->__deprecated_row_count = materialized.collection.Count();
|
|
110598
|
-
if (result->__deprecated_row_count > 0 &&
|
|
110579
|
+
if (result->__deprecated_row_count > 0 &&
|
|
110580
|
+
materialized.properties.return_type == StatementReturnType::CHANGED_ROWS) {
|
|
110599
110581
|
// update total changes
|
|
110600
110582
|
auto row_changes = materialized.GetValue(0, 0);
|
|
110601
110583
|
if (!row_changes.IsNull() && row_changes.TryCastAs(LogicalType::BIGINT)) {
|
|
@@ -111809,10 +111791,7 @@ public:
|
|
|
111809
111791
|
shared_ptr<Binder> binder;
|
|
111810
111792
|
ClientContext &context;
|
|
111811
111793
|
|
|
111812
|
-
|
|
111813
|
-
bool requires_valid_transaction;
|
|
111814
|
-
bool allow_stream_result;
|
|
111815
|
-
bool bound_all_parameters;
|
|
111794
|
+
StatementProperties properties;
|
|
111816
111795
|
|
|
111817
111796
|
private:
|
|
111818
111797
|
void CreatePlan(SQLStatement &statement);
|
|
@@ -112101,20 +112080,22 @@ unique_ptr<QueryResult> ClientContext::FetchResultInternal(ClientContextLock &lo
|
|
|
112101
112080
|
D_ASSERT(active_query->open_result == &pending);
|
|
112102
112081
|
D_ASSERT(active_query->prepared);
|
|
112103
112082
|
auto &prepared = *active_query->prepared;
|
|
112104
|
-
bool create_stream_result = prepared.allow_stream_result && allow_stream_result;
|
|
112083
|
+
bool create_stream_result = prepared.properties.allow_stream_result && allow_stream_result;
|
|
112105
112084
|
if (create_stream_result) {
|
|
112106
112085
|
active_query->progress_bar.reset();
|
|
112107
112086
|
query_progress = -1;
|
|
112108
112087
|
|
|
112109
112088
|
// successfully compiled SELECT clause and it is the last statement
|
|
112110
112089
|
// return a StreamQueryResult so the client can call Fetch() on it and stream the result
|
|
112111
|
-
auto stream_result =
|
|
112112
|
-
|
|
112090
|
+
auto stream_result = make_unique<StreamQueryResult>(pending.statement_type, pending.properties,
|
|
112091
|
+
shared_from_this(), pending.types, pending.names);
|
|
112113
112092
|
active_query->open_result = stream_result.get();
|
|
112114
112093
|
return move(stream_result);
|
|
112115
112094
|
}
|
|
112116
112095
|
// create a materialized result by continuously fetching
|
|
112117
|
-
auto result =
|
|
112096
|
+
auto result =
|
|
112097
|
+
make_unique<MaterializedQueryResult>(pending.statement_type, pending.properties, pending.types, pending.names);
|
|
112098
|
+
result->properties = pending.properties;
|
|
112118
112099
|
while (true) {
|
|
112119
112100
|
auto chunk = FetchInternal(lock, GetExecutor(), *result);
|
|
112120
112101
|
if (!chunk || chunk->size() == 0) {
|
|
@@ -112155,14 +112136,11 @@ shared_ptr<PreparedStatementData> ClientContext::CreatePreparedStatement(ClientC
|
|
|
112155
112136
|
plan->Verify();
|
|
112156
112137
|
#endif
|
|
112157
112138
|
// extract the result column names from the plan
|
|
112158
|
-
result->
|
|
112159
|
-
result->requires_valid_transaction = planner.requires_valid_transaction;
|
|
112160
|
-
result->allow_stream_result = planner.allow_stream_result;
|
|
112139
|
+
result->properties = planner.properties;
|
|
112161
112140
|
result->names = planner.names;
|
|
112162
112141
|
result->types = planner.types;
|
|
112163
112142
|
result->value_map = move(planner.value_map);
|
|
112164
112143
|
result->catalog_version = Transaction::GetTransaction(*this).catalog_version;
|
|
112165
|
-
result->bound_all_parameters = planner.bound_all_parameters;
|
|
112166
112144
|
|
|
112167
112145
|
if (config.enable_optimizer) {
|
|
112168
112146
|
profiler.StartPhase("optimizer");
|
|
@@ -112198,11 +112176,11 @@ unique_ptr<PendingQueryResult> ClientContext::PendingPreparedStatement(ClientCon
|
|
|
112198
112176
|
vector<Value> bound_values) {
|
|
112199
112177
|
D_ASSERT(active_query);
|
|
112200
112178
|
auto &statement = *statement_p;
|
|
112201
|
-
if (ActiveTransaction().IsInvalidated() && statement.requires_valid_transaction) {
|
|
112179
|
+
if (ActiveTransaction().IsInvalidated() && statement.properties.requires_valid_transaction) {
|
|
112202
112180
|
throw Exception("Current transaction is aborted (please ROLLBACK)");
|
|
112203
112181
|
}
|
|
112204
112182
|
auto &db_config = DBConfig::GetConfig(*this);
|
|
112205
|
-
if (db_config.access_mode == AccessMode::READ_ONLY && !statement.read_only) {
|
|
112183
|
+
if (db_config.access_mode == AccessMode::READ_ONLY && !statement.properties.read_only) {
|
|
112206
112184
|
throw Exception(StringUtil::Format("Cannot execute statement of type \"%s\" in read-only mode!",
|
|
112207
112185
|
StatementTypeToString(statement.statement_type)));
|
|
112208
112186
|
}
|
|
@@ -112471,17 +112449,17 @@ ClientContext::PendingStatementOrPreparedStatement(ClientContextLock &lock, cons
|
|
|
112471
112449
|
result = PendingStatementInternal(lock, query, move(statement));
|
|
112472
112450
|
} else {
|
|
112473
112451
|
auto &catalog = Catalog::GetCatalog(*this);
|
|
112474
|
-
if (prepared->unbound_statement &&
|
|
112475
|
-
|
|
112452
|
+
if (prepared->unbound_statement && (catalog.GetCatalogVersion() != prepared->catalog_version ||
|
|
112453
|
+
!prepared->properties.bound_all_parameters)) {
|
|
112476
112454
|
// catalog was modified: rebind the statement before execution
|
|
112477
112455
|
auto new_prepared = CreatePreparedStatement(lock, query, prepared->unbound_statement->Copy(), values);
|
|
112478
|
-
if (prepared->types != new_prepared->types && prepared->bound_all_parameters) {
|
|
112456
|
+
if (prepared->types != new_prepared->types && prepared->properties.bound_all_parameters) {
|
|
112479
112457
|
throw BinderException("Rebinding statement after catalog change resulted in change of types");
|
|
112480
112458
|
}
|
|
112481
|
-
D_ASSERT(new_prepared->bound_all_parameters);
|
|
112459
|
+
D_ASSERT(new_prepared->properties.bound_all_parameters);
|
|
112482
112460
|
new_prepared->unbound_statement = move(prepared->unbound_statement);
|
|
112483
112461
|
prepared = move(new_prepared);
|
|
112484
|
-
prepared->bound_all_parameters = false;
|
|
112462
|
+
prepared->properties.bound_all_parameters = false;
|
|
112485
112463
|
}
|
|
112486
112464
|
result = PendingPreparedStatement(lock, prepared, *values);
|
|
112487
112465
|
}
|
|
@@ -112539,7 +112517,11 @@ unique_ptr<QueryResult> ClientContext::Query(const string &query, bool allow_str
|
|
|
112539
112517
|
}
|
|
112540
112518
|
if (statements.empty()) {
|
|
112541
112519
|
// no statements, return empty successful result
|
|
112542
|
-
|
|
112520
|
+
StatementProperties properties;
|
|
112521
|
+
vector<LogicalType> types;
|
|
112522
|
+
vector<string> names;
|
|
112523
|
+
return make_unique<MaterializedQueryResult>(StatementType::INVALID_STATEMENT, properties, move(types),
|
|
112524
|
+
move(names));
|
|
112543
112525
|
}
|
|
112544
112526
|
|
|
112545
112527
|
unique_ptr<QueryResult> result;
|
|
@@ -122905,13 +122887,9 @@ Extension::~Extension() {
|
|
|
122905
122887
|
|
|
122906
122888
|
namespace duckdb {
|
|
122907
122889
|
|
|
122908
|
-
MaterializedQueryResult::MaterializedQueryResult(StatementType statement_type
|
|
122909
|
-
|
|
122910
|
-
|
|
122911
|
-
|
|
122912
|
-
MaterializedQueryResult::MaterializedQueryResult(StatementType statement_type, vector<LogicalType> types,
|
|
122913
|
-
vector<string> names)
|
|
122914
|
-
: QueryResult(QueryResultType::MATERIALIZED_RESULT, statement_type, move(types), move(names)) {
|
|
122890
|
+
MaterializedQueryResult::MaterializedQueryResult(StatementType statement_type, StatementProperties properties,
|
|
122891
|
+
vector<LogicalType> types, vector<string> names)
|
|
122892
|
+
: QueryResult(QueryResultType::MATERIALIZED_RESULT, statement_type, properties, move(types), move(names)) {
|
|
122915
122893
|
}
|
|
122916
122894
|
|
|
122917
122895
|
MaterializedQueryResult::MaterializedQueryResult(string error)
|
|
@@ -122964,7 +122942,8 @@ namespace duckdb {
|
|
|
122964
122942
|
|
|
122965
122943
|
PendingQueryResult::PendingQueryResult(shared_ptr<ClientContext> context_p, PreparedStatementData &statement,
|
|
122966
122944
|
vector<LogicalType> types_p)
|
|
122967
|
-
: BaseQueryResult(QueryResultType::PENDING_RESULT, statement.statement_type, move(types_p),
|
|
122945
|
+
: BaseQueryResult(QueryResultType::PENDING_RESULT, statement.statement_type, statement.properties, move(types_p),
|
|
122946
|
+
statement.names),
|
|
122968
122947
|
context(move(context_p)) {
|
|
122969
122948
|
}
|
|
122970
122949
|
|
|
@@ -123054,6 +123033,11 @@ StatementType PreparedStatement::GetStatementType() {
|
|
|
123054
123033
|
return data->statement_type;
|
|
123055
123034
|
}
|
|
123056
123035
|
|
|
123036
|
+
StatementProperties PreparedStatement::GetStatementProperties() {
|
|
123037
|
+
D_ASSERT(data);
|
|
123038
|
+
return data->properties;
|
|
123039
|
+
}
|
|
123040
|
+
|
|
123057
123041
|
const vector<LogicalType> &PreparedStatement::GetTypes() {
|
|
123058
123042
|
D_ASSERT(data);
|
|
123059
123043
|
return data->types;
|
|
@@ -123069,7 +123053,7 @@ unique_ptr<QueryResult> PreparedStatement::Execute(vector<Value> &values, bool a
|
|
|
123069
123053
|
if (!pending->success) {
|
|
123070
123054
|
return make_unique<MaterializedQueryResult>(pending->error);
|
|
123071
123055
|
}
|
|
123072
|
-
return pending->Execute(allow_stream_result && data->allow_stream_result);
|
|
123056
|
+
return pending->Execute(allow_stream_result && data->properties.allow_stream_result);
|
|
123073
123057
|
}
|
|
123074
123058
|
|
|
123075
123059
|
unique_ptr<PendingQueryResult> PreparedStatement::PendingQuery(vector<Value> &values) {
|
|
@@ -123088,9 +123072,7 @@ unique_ptr<PendingQueryResult> PreparedStatement::PendingQuery(vector<Value> &va
|
|
|
123088
123072
|
|
|
123089
123073
|
namespace duckdb {
|
|
123090
123074
|
|
|
123091
|
-
PreparedStatementData::PreparedStatementData(StatementType type)
|
|
123092
|
-
: statement_type(type), read_only(true), requires_valid_transaction(true), allow_stream_result(false),
|
|
123093
|
-
bound_all_parameters(true) {
|
|
123075
|
+
PreparedStatementData::PreparedStatementData(StatementType type) : statement_type(type) {
|
|
123094
123076
|
}
|
|
123095
123077
|
|
|
123096
123078
|
PreparedStatementData::~PreparedStatementData() {
|
|
@@ -123835,13 +123817,10 @@ ExpressionRootInfo::ExpressionRootInfo(ExpressionExecutorState &state, string na
|
|
|
123835
123817
|
|
|
123836
123818
|
namespace duckdb {
|
|
123837
123819
|
|
|
123838
|
-
BaseQueryResult::BaseQueryResult(QueryResultType type, StatementType statement_type
|
|
123839
|
-
|
|
123840
|
-
|
|
123841
|
-
|
|
123842
|
-
BaseQueryResult::BaseQueryResult(QueryResultType type, StatementType statement_type, vector<LogicalType> types_p,
|
|
123843
|
-
vector<string> names_p)
|
|
123844
|
-
: type(type), statement_type(statement_type), types(move(types_p)), names(move(names_p)), success(true) {
|
|
123820
|
+
BaseQueryResult::BaseQueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
|
|
123821
|
+
vector<LogicalType> types_p, vector<string> names_p)
|
|
123822
|
+
: type(type), statement_type(statement_type), properties(properties), types(move(types_p)), names(move(names_p)),
|
|
123823
|
+
success(true) {
|
|
123845
123824
|
D_ASSERT(types.size() == names.size());
|
|
123846
123825
|
}
|
|
123847
123826
|
|
|
@@ -123861,12 +123840,9 @@ idx_t BaseQueryResult::ColumnCount() {
|
|
|
123861
123840
|
return types.size();
|
|
123862
123841
|
}
|
|
123863
123842
|
|
|
123864
|
-
QueryResult::QueryResult(QueryResultType type, StatementType statement_type
|
|
123865
|
-
|
|
123866
|
-
|
|
123867
|
-
QueryResult::QueryResult(QueryResultType type, StatementType statement_type, vector<LogicalType> types_p,
|
|
123868
|
-
vector<string> names_p)
|
|
123869
|
-
: BaseQueryResult(type, statement_type, move(types_p), move(names_p)) {
|
|
123843
|
+
QueryResult::QueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
|
|
123844
|
+
vector<LogicalType> types_p, vector<string> names_p)
|
|
123845
|
+
: BaseQueryResult(type, statement_type, properties, move(types_p), move(names_p)) {
|
|
123870
123846
|
}
|
|
123871
123847
|
|
|
123872
123848
|
QueryResult::QueryResult(QueryResultType type, string error) : BaseQueryResult(type, move(error)) {
|
|
@@ -127147,9 +127123,10 @@ Value ThreadsSetting::GetSetting(ClientContext &context) {
|
|
|
127147
127123
|
|
|
127148
127124
|
namespace duckdb {
|
|
127149
127125
|
|
|
127150
|
-
StreamQueryResult::StreamQueryResult(StatementType statement_type,
|
|
127151
|
-
vector<LogicalType> types, vector<string> names)
|
|
127152
|
-
: QueryResult(QueryResultType::STREAM_RESULT, statement_type, move(types), move(names)),
|
|
127126
|
+
StreamQueryResult::StreamQueryResult(StatementType statement_type, StatementProperties properties,
|
|
127127
|
+
shared_ptr<ClientContext> context, vector<LogicalType> types, vector<string> names)
|
|
127128
|
+
: QueryResult(QueryResultType::STREAM_RESULT, statement_type, properties, move(types), move(names)),
|
|
127129
|
+
context(move(context)) {
|
|
127153
127130
|
}
|
|
127154
127131
|
|
|
127155
127132
|
StreamQueryResult::~StreamQueryResult() {
|
|
@@ -127199,7 +127176,7 @@ unique_ptr<MaterializedQueryResult> StreamQueryResult::Materialize() {
|
|
|
127199
127176
|
if (!success) {
|
|
127200
127177
|
return make_unique<MaterializedQueryResult>(error);
|
|
127201
127178
|
}
|
|
127202
|
-
auto result = make_unique<MaterializedQueryResult>(statement_type, types, names);
|
|
127179
|
+
auto result = make_unique<MaterializedQueryResult>(statement_type, properties, types, names);
|
|
127203
127180
|
while (true) {
|
|
127204
127181
|
auto chunk = Fetch();
|
|
127205
127182
|
if (!chunk || chunk->size() == 0) {
|
|
@@ -142111,7 +142088,7 @@ ThreadContext::ThreadContext(ClientContext &context) : profiler(QueryProfiler::G
|
|
|
142111
142088
|
|
|
142112
142089
|
namespace duckdb {
|
|
142113
142090
|
|
|
142114
|
-
void BaseExpression::Print() {
|
|
142091
|
+
void BaseExpression::Print() const {
|
|
142115
142092
|
Printer::Print(ToString());
|
|
142116
142093
|
}
|
|
142117
142094
|
|
|
@@ -161132,6 +161109,7 @@ BoundStatement Binder::Bind(CallStatement &stmt) {
|
|
|
161132
161109
|
result.types = get.returned_types;
|
|
161133
161110
|
result.names = get.names;
|
|
161134
161111
|
result.plan = CreatePlan(*bound_func);
|
|
161112
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
161135
161113
|
return result;
|
|
161136
161114
|
}
|
|
161137
161115
|
|
|
@@ -161278,7 +161256,8 @@ BoundStatement Binder::Bind(CopyStatement &stmt) {
|
|
|
161278
161256
|
}
|
|
161279
161257
|
stmt.select_statement = move(statement);
|
|
161280
161258
|
}
|
|
161281
|
-
|
|
161259
|
+
properties.allow_stream_result = false;
|
|
161260
|
+
properties.return_type = StatementReturnType::CHANGED_ROWS;
|
|
161282
161261
|
if (stmt.info->is_from) {
|
|
161283
161262
|
return BindCopyFrom(stmt);
|
|
161284
161263
|
} else {
|
|
@@ -161417,7 +161396,7 @@ SchemaCatalogEntry *Binder::BindSchema(CreateInfo &info) {
|
|
|
161417
161396
|
if (info.schema == TEMP_SCHEMA) {
|
|
161418
161397
|
throw ParserException("Only TEMPORARY table names can use the \"temp\" schema");
|
|
161419
161398
|
}
|
|
161420
|
-
|
|
161399
|
+
properties.read_only = false;
|
|
161421
161400
|
} else {
|
|
161422
161401
|
if (info.schema != TEMP_SCHEMA) {
|
|
161423
161402
|
throw ParserException("TEMPORARY table names can *only* use the \"%s\" schema", TEMP_SCHEMA);
|
|
@@ -161562,6 +161541,7 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
161562
161541
|
BoundStatement result;
|
|
161563
161542
|
result.names = {"Count"};
|
|
161564
161543
|
result.types = {LogicalType::BIGINT};
|
|
161544
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
161565
161545
|
|
|
161566
161546
|
auto catalog_type = stmt.info->type;
|
|
161567
161547
|
switch (catalog_type) {
|
|
@@ -161672,6 +161652,8 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
161672
161652
|
auto &schema = bound_info->schema;
|
|
161673
161653
|
auto create_table = make_unique<LogicalCreateTable>(schema, move(bound_info));
|
|
161674
161654
|
if (root) {
|
|
161655
|
+
// CREATE TABLE AS
|
|
161656
|
+
properties.return_type = StatementReturnType::CHANGED_ROWS;
|
|
161675
161657
|
create_table->children.push_back(move(root));
|
|
161676
161658
|
}
|
|
161677
161659
|
result.plan = move(create_table);
|
|
@@ -161685,7 +161667,7 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
161685
161667
|
default:
|
|
161686
161668
|
throw Exception("Unrecognized type!");
|
|
161687
161669
|
}
|
|
161688
|
-
|
|
161670
|
+
properties.allow_stream_result = false;
|
|
161689
161671
|
return result;
|
|
161690
161672
|
}
|
|
161691
161673
|
|
|
@@ -161939,7 +161921,7 @@ unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateIn
|
|
|
161939
161921
|
}
|
|
161940
161922
|
}
|
|
161941
161923
|
}
|
|
161942
|
-
|
|
161924
|
+
properties.allow_stream_result = false;
|
|
161943
161925
|
return result;
|
|
161944
161926
|
}
|
|
161945
161927
|
|
|
@@ -161999,7 +161981,7 @@ BoundStatement Binder::Bind(DeleteStatement &stmt) {
|
|
|
161999
161981
|
|
|
162000
161982
|
if (!table->temporary) {
|
|
162001
161983
|
// delete from persistent table: not read only!
|
|
162002
|
-
|
|
161984
|
+
properties.read_only = false;
|
|
162003
161985
|
}
|
|
162004
161986
|
|
|
162005
161987
|
// plan any tables from the various using clauses
|
|
@@ -162060,7 +162042,8 @@ BoundStatement Binder::Bind(DeleteStatement &stmt) {
|
|
|
162060
162042
|
result.plan = move(del);
|
|
162061
162043
|
result.names = {"Count"};
|
|
162062
162044
|
result.types = {LogicalType::BIGINT};
|
|
162063
|
-
|
|
162045
|
+
properties.allow_stream_result = false;
|
|
162046
|
+
properties.return_type = StatementReturnType::CHANGED_ROWS;
|
|
162064
162047
|
}
|
|
162065
162048
|
return result;
|
|
162066
162049
|
}
|
|
@@ -162082,11 +162065,11 @@ BoundStatement Binder::Bind(DropStatement &stmt) {
|
|
|
162082
162065
|
case CatalogType::PREPARED_STATEMENT:
|
|
162083
162066
|
// dropping prepared statements is always possible
|
|
162084
162067
|
// it also does not require a valid transaction
|
|
162085
|
-
|
|
162068
|
+
properties.requires_valid_transaction = false;
|
|
162086
162069
|
break;
|
|
162087
162070
|
case CatalogType::SCHEMA_ENTRY:
|
|
162088
162071
|
// dropping a schema is never read-only because there are no temporary schemas
|
|
162089
|
-
|
|
162072
|
+
properties.read_only = false;
|
|
162090
162073
|
break;
|
|
162091
162074
|
case CatalogType::VIEW_ENTRY:
|
|
162092
162075
|
case CatalogType::SEQUENCE_ENTRY:
|
|
@@ -162102,7 +162085,7 @@ BoundStatement Binder::Bind(DropStatement &stmt) {
|
|
|
162102
162085
|
}
|
|
162103
162086
|
if (!entry->temporary) {
|
|
162104
162087
|
// we can only drop temporary tables in read-only mode
|
|
162105
|
-
|
|
162088
|
+
properties.read_only = false;
|
|
162106
162089
|
}
|
|
162107
162090
|
stmt.info->schema = entry->schema->name;
|
|
162108
162091
|
break;
|
|
@@ -162113,7 +162096,8 @@ BoundStatement Binder::Bind(DropStatement &stmt) {
|
|
|
162113
162096
|
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::LOGICAL_DROP, move(stmt.info));
|
|
162114
162097
|
result.names = {"Success"};
|
|
162115
162098
|
result.types = {LogicalType::BOOLEAN};
|
|
162116
|
-
|
|
162099
|
+
properties.allow_stream_result = false;
|
|
162100
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162117
162101
|
return result;
|
|
162118
162102
|
}
|
|
162119
162103
|
|
|
@@ -162137,6 +162121,7 @@ BoundStatement Binder::Bind(ExplainStatement &stmt) {
|
|
|
162137
162121
|
result.plan = move(explain);
|
|
162138
162122
|
result.names = {"explain_key", "explain_value"};
|
|
162139
162123
|
result.types = {LogicalType::VARCHAR, LogicalType::VARCHAR};
|
|
162124
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
162140
162125
|
return result;
|
|
162141
162126
|
}
|
|
162142
162127
|
|
|
@@ -162340,7 +162325,8 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {
|
|
|
162340
162325
|
}
|
|
162341
162326
|
|
|
162342
162327
|
result.plan = move(export_node);
|
|
162343
|
-
|
|
162328
|
+
properties.allow_stream_result = false;
|
|
162329
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162344
162330
|
return result;
|
|
162345
162331
|
}
|
|
162346
162332
|
|
|
@@ -162408,7 +162394,7 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
|
162408
162394
|
D_ASSERT(table);
|
|
162409
162395
|
if (!table->temporary) {
|
|
162410
162396
|
// inserting into a non-temporary table: alters underlying database
|
|
162411
|
-
|
|
162397
|
+
properties.read_only = false;
|
|
162412
162398
|
}
|
|
162413
162399
|
|
|
162414
162400
|
auto insert = make_unique<LogicalInsert>(table);
|
|
@@ -162514,7 +162500,8 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
|
162514
162500
|
} else {
|
|
162515
162501
|
D_ASSERT(result.types.size() == result.names.size());
|
|
162516
162502
|
result.plan = move(insert);
|
|
162517
|
-
|
|
162503
|
+
properties.allow_stream_result = false;
|
|
162504
|
+
properties.return_type = StatementReturnType::CHANGED_ROWS;
|
|
162518
162505
|
return result;
|
|
162519
162506
|
}
|
|
162520
162507
|
}
|
|
@@ -162533,7 +162520,8 @@ BoundStatement Binder::Bind(LoadStatement &stmt) {
|
|
|
162533
162520
|
result.names = {"Success"};
|
|
162534
162521
|
|
|
162535
162522
|
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::LOGICAL_LOAD, move(stmt.info));
|
|
162536
|
-
|
|
162523
|
+
properties.allow_stream_result = false;
|
|
162524
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162537
162525
|
return result;
|
|
162538
162526
|
}
|
|
162539
162527
|
|
|
@@ -162569,6 +162557,7 @@ BoundStatement Binder::Bind(PragmaStatement &stmt) {
|
|
|
162569
162557
|
result.names = {"Success"};
|
|
162570
162558
|
result.types = {LogicalType::BOOLEAN};
|
|
162571
162559
|
result.plan = make_unique<LogicalPragma>(bound_function, *stmt.info);
|
|
162560
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
162572
162561
|
return result;
|
|
162573
162562
|
}
|
|
162574
162563
|
|
|
@@ -162594,7 +162583,8 @@ BoundStatement Binder::Bind(RelationStatement &stmt) {
|
|
|
162594
162583
|
namespace duckdb {
|
|
162595
162584
|
|
|
162596
162585
|
BoundStatement Binder::Bind(SelectStatement &stmt) {
|
|
162597
|
-
|
|
162586
|
+
properties.allow_stream_result = true;
|
|
162587
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
162598
162588
|
return Bind(*stmt.node);
|
|
162599
162589
|
}
|
|
162600
162590
|
|
|
@@ -162612,6 +162602,7 @@ BoundStatement Binder::Bind(SetStatement &stmt) {
|
|
|
162612
162602
|
result.names = {"Success"};
|
|
162613
162603
|
|
|
162614
162604
|
result.plan = make_unique<LogicalSet>(stmt.name, stmt.value, stmt.scope);
|
|
162605
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162615
162606
|
return result;
|
|
162616
162607
|
}
|
|
162617
162608
|
|
|
@@ -162641,6 +162632,7 @@ BoundStatement Binder::Bind(ShowStatement &stmt) {
|
|
|
162641
162632
|
result.names = {"column_name", "column_type", "null", "key", "default", "extra"};
|
|
162642
162633
|
result.types = {LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR,
|
|
162643
162634
|
LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR};
|
|
162635
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
162644
162636
|
return result;
|
|
162645
162637
|
}
|
|
162646
162638
|
|
|
@@ -162666,20 +162658,22 @@ BoundStatement Binder::Bind(AlterStatement &stmt) {
|
|
|
162666
162658
|
auto entry = catalog.GetEntry(context, stmt.info->GetCatalogType(), stmt.info->schema, stmt.info->name, true);
|
|
162667
162659
|
if (entry && !entry->temporary) {
|
|
162668
162660
|
// we can only alter temporary tables/views in read-only mode
|
|
162669
|
-
|
|
162661
|
+
properties.read_only = false;
|
|
162670
162662
|
}
|
|
162671
162663
|
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::LOGICAL_ALTER, move(stmt.info));
|
|
162664
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162672
162665
|
return result;
|
|
162673
162666
|
}
|
|
162674
162667
|
|
|
162675
162668
|
BoundStatement Binder::Bind(TransactionStatement &stmt) {
|
|
162676
162669
|
// transaction statements do not require a valid transaction
|
|
162677
|
-
|
|
162670
|
+
properties.requires_valid_transaction = false;
|
|
162678
162671
|
|
|
162679
162672
|
BoundStatement result;
|
|
162680
162673
|
result.names = {"Success"};
|
|
162681
162674
|
result.types = {LogicalType::BOOLEAN};
|
|
162682
162675
|
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::LOGICAL_TRANSACTION, move(stmt.info));
|
|
162676
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162683
162677
|
return result;
|
|
162684
162678
|
}
|
|
162685
162679
|
|
|
@@ -162814,6 +162808,7 @@ BoundStatement Binder::BindSummarize(ShowStatement &stmt) {
|
|
|
162814
162808
|
select_node->select_list.push_back(SummarizeWrapUnnest(null_percentage_children, "null_percentage"));
|
|
162815
162809
|
select_node->from_table = move(subquery_ref);
|
|
162816
162810
|
|
|
162811
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
162817
162812
|
return Bind(*select_node);
|
|
162818
162813
|
}
|
|
162819
162814
|
|
|
@@ -163022,7 +163017,7 @@ BoundStatement Binder::Bind(UpdateStatement &stmt) {
|
|
|
163022
163017
|
|
|
163023
163018
|
if (!table->temporary) {
|
|
163024
163019
|
// update of persistent table: not read only!
|
|
163025
|
-
|
|
163020
|
+
properties.read_only = false;
|
|
163026
163021
|
}
|
|
163027
163022
|
auto update = make_unique<LogicalUpdate>(table);
|
|
163028
163023
|
|
|
@@ -163103,7 +163098,8 @@ BoundStatement Binder::Bind(UpdateStatement &stmt) {
|
|
|
163103
163098
|
result.names = {"Count"};
|
|
163104
163099
|
result.types = {LogicalType::BIGINT};
|
|
163105
163100
|
result.plan = move(update);
|
|
163106
|
-
|
|
163101
|
+
properties.allow_stream_result = false;
|
|
163102
|
+
properties.return_type = StatementReturnType::CHANGED_ROWS;
|
|
163107
163103
|
}
|
|
163108
163104
|
return result;
|
|
163109
163105
|
}
|
|
@@ -163120,6 +163116,7 @@ BoundStatement Binder::Bind(VacuumStatement &stmt) {
|
|
|
163120
163116
|
result.names = {"Success"};
|
|
163121
163117
|
result.types = {LogicalType::BOOLEAN};
|
|
163122
163118
|
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::LOGICAL_VACUUM, move(stmt.info));
|
|
163119
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
163123
163120
|
return result;
|
|
163124
163121
|
}
|
|
163125
163122
|
|
|
@@ -164413,8 +164410,7 @@ shared_ptr<Binder> Binder::CreateBinder(ClientContext &context, Binder *parent,
|
|
|
164413
164410
|
}
|
|
164414
164411
|
|
|
164415
164412
|
Binder::Binder(bool, ClientContext &context, shared_ptr<Binder> parent_p, bool inherit_ctes_p)
|
|
164416
|
-
: context(context),
|
|
164417
|
-
parent(move(parent_p)), bound_tables(0), inherit_ctes(inherit_ctes_p) {
|
|
164413
|
+
: context(context), parent(move(parent_p)), bound_tables(0), inherit_ctes(inherit_ctes_p) {
|
|
164418
164414
|
parameters = nullptr;
|
|
164419
164415
|
parameter_types = nullptr;
|
|
164420
164416
|
if (parent) {
|
|
@@ -164815,7 +164811,8 @@ BoundStatement Binder::BindReturning(vector<unique_ptr<ParsedExpression>> return
|
|
|
164815
164811
|
projection->AddChild(move(child_operator));
|
|
164816
164812
|
D_ASSERT(result.types.size() == result.names.size());
|
|
164817
164813
|
result.plan = move(projection);
|
|
164818
|
-
|
|
164814
|
+
properties.allow_stream_result = true;
|
|
164815
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
164819
164816
|
return result;
|
|
164820
164817
|
}
|
|
164821
164818
|
|
|
@@ -168234,19 +168231,17 @@ void Planner::CreatePlan(SQLStatement &statement) {
|
|
|
168234
168231
|
auto bound_statement = binder->Bind(statement);
|
|
168235
168232
|
profiler.EndPhase();
|
|
168236
168233
|
|
|
168237
|
-
this->
|
|
168238
|
-
this->requires_valid_transaction = binder->requires_valid_transaction;
|
|
168239
|
-
this->allow_stream_result = binder->allow_stream_result;
|
|
168234
|
+
this->properties = binder->properties;
|
|
168240
168235
|
this->names = bound_statement.names;
|
|
168241
168236
|
this->types = bound_statement.types;
|
|
168242
168237
|
this->plan = move(bound_statement.plan);
|
|
168243
|
-
|
|
168238
|
+
properties.bound_all_parameters = true;
|
|
168244
168239
|
|
|
168245
168240
|
// set up a map of parameter number -> value entries
|
|
168246
168241
|
for (auto &expr : bound_parameters) {
|
|
168247
168242
|
// check if the type of the parameter could be resolved
|
|
168248
168243
|
if (expr->return_type.id() == LogicalTypeId::INVALID || expr->return_type.id() == LogicalTypeId::UNKNOWN) {
|
|
168249
|
-
|
|
168244
|
+
properties.bound_all_parameters = false;
|
|
168250
168245
|
continue;
|
|
168251
168246
|
}
|
|
168252
168247
|
auto value = make_unique<Value>(expr->return_type);
|
|
@@ -168274,11 +168269,8 @@ shared_ptr<PreparedStatementData> Planner::PrepareSQLStatement(unique_ptr<SQLSta
|
|
|
168274
168269
|
prepared_data->names = names;
|
|
168275
168270
|
prepared_data->types = types;
|
|
168276
168271
|
prepared_data->value_map = move(value_map);
|
|
168277
|
-
prepared_data->
|
|
168278
|
-
prepared_data->requires_valid_transaction = this->requires_valid_transaction;
|
|
168279
|
-
prepared_data->allow_stream_result = this->allow_stream_result;
|
|
168272
|
+
prepared_data->properties = properties;
|
|
168280
168273
|
prepared_data->catalog_version = Transaction::GetTransaction(context).catalog_version;
|
|
168281
|
-
prepared_data->bound_all_parameters = this->bound_all_parameters;
|
|
168282
168274
|
return prepared_data;
|
|
168283
168275
|
}
|
|
168284
168276
|
|
|
@@ -168308,7 +168300,7 @@ void Planner::PlanExecute(unique_ptr<SQLStatement> statement) {
|
|
|
168308
168300
|
Value value = ExpressionExecutor::EvaluateScalar(*bound_expr);
|
|
168309
168301
|
bind_values.push_back(move(value));
|
|
168310
168302
|
}
|
|
168311
|
-
bool all_bound = prepared->bound_all_parameters;
|
|
168303
|
+
bool all_bound = prepared->properties.bound_all_parameters;
|
|
168312
168304
|
if (catalog.GetCatalogVersion() != entry->second->catalog_version || !all_bound) {
|
|
168313
168305
|
// catalog was modified or statement does not have clear types: rebind the statement before running the execute
|
|
168314
168306
|
for (auto &value : bind_values) {
|
|
@@ -168319,7 +168311,7 @@ void Planner::PlanExecute(unique_ptr<SQLStatement> statement) {
|
|
|
168319
168311
|
throw BinderException("Rebinding statement \"%s\" after catalog change resulted in change of types",
|
|
168320
168312
|
stmt.name);
|
|
168321
168313
|
}
|
|
168322
|
-
D_ASSERT(prepared->bound_all_parameters);
|
|
168314
|
+
D_ASSERT(prepared->properties.bound_all_parameters);
|
|
168323
168315
|
rebound = true;
|
|
168324
168316
|
}
|
|
168325
168317
|
// add casts to the prepared statement parameters as required
|
|
@@ -168339,12 +168331,9 @@ void Planner::PlanExecute(unique_ptr<SQLStatement> statement) {
|
|
|
168339
168331
|
}
|
|
168340
168332
|
|
|
168341
168333
|
// copy the properties of the prepared statement into the planner
|
|
168342
|
-
this->
|
|
168343
|
-
this->requires_valid_transaction = prepared->requires_valid_transaction;
|
|
168344
|
-
this->allow_stream_result = prepared->allow_stream_result;
|
|
168334
|
+
this->properties = prepared->properties;
|
|
168345
168335
|
this->names = prepared->names;
|
|
168346
168336
|
this->types = prepared->types;
|
|
168347
|
-
this->bound_all_parameters = prepared->bound_all_parameters;
|
|
168348
168337
|
this->plan = make_unique<LogicalExecute>(move(prepared));
|
|
168349
168338
|
}
|
|
168350
168339
|
|
|
@@ -168354,12 +168343,13 @@ void Planner::PlanPrepare(unique_ptr<SQLStatement> statement) {
|
|
|
168354
168343
|
|
|
168355
168344
|
auto prepare = make_unique<LogicalPrepare>(stmt.name, move(prepared_data), move(plan));
|
|
168356
168345
|
// we can prepare in read-only mode: prepared statements are not written to the catalog
|
|
168357
|
-
|
|
168346
|
+
properties.read_only = true;
|
|
168358
168347
|
// we can always prepare, even if the transaction has been invalidated
|
|
168359
168348
|
// this is required because most clients ALWAYS invoke prepared statements
|
|
168360
|
-
|
|
168361
|
-
|
|
168362
|
-
|
|
168349
|
+
properties.requires_valid_transaction = false;
|
|
168350
|
+
properties.allow_stream_result = false;
|
|
168351
|
+
properties.bound_all_parameters = true;
|
|
168352
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
168363
168353
|
this->names = {"Success"};
|
|
168364
168354
|
this->types = {LogicalType::BOOLEAN};
|
|
168365
168355
|
this->plan = move(prepare);
|