duckdb 0.3.5-dev368.0 → 0.3.5-dev378.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 +110 -117
- package/src/duckdb.hpp +43 -24
- package/src/parquet-amalgamation.cpp +36832 -36832
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -3273,6 +3273,9 @@ unique_ptr<CatalogEntry> TableCatalogEntry::AddColumn(ClientContext &context, Ad
|
|
|
3273
3273
|
for (idx_t i = 0; i < columns.size(); i++) {
|
|
3274
3274
|
create_info->columns.push_back(columns[i].Copy());
|
|
3275
3275
|
}
|
|
3276
|
+
for (auto &constraint : constraints) {
|
|
3277
|
+
create_info->constraints.push_back(constraint->Copy());
|
|
3278
|
+
}
|
|
3276
3279
|
Binder::BindLogicalType(context, info.new_column.type, schema->name);
|
|
3277
3280
|
info.new_column.oid = columns.size();
|
|
3278
3281
|
create_info->columns.push_back(info.new_column.Copy());
|
|
@@ -6923,17 +6926,6 @@ string StatementTypeToString(StatementType type) {
|
|
|
6923
6926
|
}
|
|
6924
6927
|
// LCOV_EXCL_STOP
|
|
6925
6928
|
|
|
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
6929
|
} // namespace duckdb
|
|
6938
6930
|
|
|
6939
6931
|
|
|
@@ -39593,10 +39585,10 @@ int32_t Date::ExtractISODayOfTheWeek(date_t date) {
|
|
|
39593
39585
|
// 7 = 4
|
|
39594
39586
|
if (date.days < 0) {
|
|
39595
39587
|
// negative date: start off at 4 and cycle downwards
|
|
39596
|
-
return (7 - ((-date.days + 3) % 7));
|
|
39588
|
+
return (7 - ((-int64_t(date.days) + 3) % 7));
|
|
39597
39589
|
} else {
|
|
39598
39590
|
// positive date: start off at 4 and cycle upwards
|
|
39599
|
-
return ((date.days + 3) % 7) + 1;
|
|
39591
|
+
return ((int64_t(date.days) + 3) % 7) + 1;
|
|
39600
39592
|
}
|
|
39601
39593
|
}
|
|
39602
39594
|
|
|
@@ -53956,9 +53948,8 @@ void ExpressionExecutor::Execute(const BoundOperatorExpression &expr, Expression
|
|
|
53956
53948
|
}
|
|
53957
53949
|
}
|
|
53958
53950
|
if (remaining_count > 0) {
|
|
53959
|
-
auto &result_mask = FlatVector::Validity(result);
|
|
53960
53951
|
for (idx_t i = 0; i < remaining_count; i++) {
|
|
53961
|
-
|
|
53952
|
+
FlatVector::SetNull(result, current_sel->get_index(i), true);
|
|
53962
53953
|
}
|
|
53963
53954
|
}
|
|
53964
53955
|
if (sel) {
|
|
@@ -60088,15 +60079,8 @@ public:
|
|
|
60088
60079
|
//! The result types of the transaction
|
|
60089
60080
|
vector<LogicalType> types;
|
|
60090
60081
|
|
|
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;
|
|
60082
|
+
//! The statement properties
|
|
60083
|
+
StatementProperties properties;
|
|
60100
60084
|
|
|
60101
60085
|
//! The catalog version of when the prepared statement was bound
|
|
60102
60086
|
//! If this version is lower than the current catalog version, we have to rebind the prepared statement
|
|
@@ -109137,7 +109121,7 @@ idx_t duckdb_arrow_rows_changed(duckdb_arrow result) {
|
|
|
109137
109121
|
auto wrapper = (ArrowResultWrapper *)result;
|
|
109138
109122
|
idx_t rows_changed = 0;
|
|
109139
109123
|
idx_t row_count = wrapper->result->collection.Count();
|
|
109140
|
-
if (row_count > 0 &&
|
|
109124
|
+
if (row_count > 0 && wrapper->result->properties.return_type == duckdb::StatementReturnType::CHANGED_ROWS) {
|
|
109141
109125
|
auto row_changes = wrapper->result->GetValue(0, 0);
|
|
109142
109126
|
if (!row_changes.IsNull() && row_changes.TryCastAs(LogicalType::BIGINT)) {
|
|
109143
109127
|
rows_changed = row_changes.GetValue<int64_t>();
|
|
@@ -110595,7 +110579,8 @@ bool deprecated_materialize_result(duckdb_result *result) {
|
|
|
110595
110579
|
result->__deprecated_columns[i].__deprecated_name = (char *)result_data->result->names[i].c_str();
|
|
110596
110580
|
}
|
|
110597
110581
|
result->__deprecated_row_count = materialized.collection.Count();
|
|
110598
|
-
if (result->__deprecated_row_count > 0 &&
|
|
110582
|
+
if (result->__deprecated_row_count > 0 &&
|
|
110583
|
+
materialized.properties.return_type == StatementReturnType::CHANGED_ROWS) {
|
|
110599
110584
|
// update total changes
|
|
110600
110585
|
auto row_changes = materialized.GetValue(0, 0);
|
|
110601
110586
|
if (!row_changes.IsNull() && row_changes.TryCastAs(LogicalType::BIGINT)) {
|
|
@@ -111809,10 +111794,7 @@ public:
|
|
|
111809
111794
|
shared_ptr<Binder> binder;
|
|
111810
111795
|
ClientContext &context;
|
|
111811
111796
|
|
|
111812
|
-
|
|
111813
|
-
bool requires_valid_transaction;
|
|
111814
|
-
bool allow_stream_result;
|
|
111815
|
-
bool bound_all_parameters;
|
|
111797
|
+
StatementProperties properties;
|
|
111816
111798
|
|
|
111817
111799
|
private:
|
|
111818
111800
|
void CreatePlan(SQLStatement &statement);
|
|
@@ -112101,20 +112083,22 @@ unique_ptr<QueryResult> ClientContext::FetchResultInternal(ClientContextLock &lo
|
|
|
112101
112083
|
D_ASSERT(active_query->open_result == &pending);
|
|
112102
112084
|
D_ASSERT(active_query->prepared);
|
|
112103
112085
|
auto &prepared = *active_query->prepared;
|
|
112104
|
-
bool create_stream_result = prepared.allow_stream_result && allow_stream_result;
|
|
112086
|
+
bool create_stream_result = prepared.properties.allow_stream_result && allow_stream_result;
|
|
112105
112087
|
if (create_stream_result) {
|
|
112106
112088
|
active_query->progress_bar.reset();
|
|
112107
112089
|
query_progress = -1;
|
|
112108
112090
|
|
|
112109
112091
|
// successfully compiled SELECT clause and it is the last statement
|
|
112110
112092
|
// return a StreamQueryResult so the client can call Fetch() on it and stream the result
|
|
112111
|
-
auto stream_result =
|
|
112112
|
-
|
|
112093
|
+
auto stream_result = make_unique<StreamQueryResult>(pending.statement_type, pending.properties,
|
|
112094
|
+
shared_from_this(), pending.types, pending.names);
|
|
112113
112095
|
active_query->open_result = stream_result.get();
|
|
112114
112096
|
return move(stream_result);
|
|
112115
112097
|
}
|
|
112116
112098
|
// create a materialized result by continuously fetching
|
|
112117
|
-
auto result =
|
|
112099
|
+
auto result =
|
|
112100
|
+
make_unique<MaterializedQueryResult>(pending.statement_type, pending.properties, pending.types, pending.names);
|
|
112101
|
+
result->properties = pending.properties;
|
|
112118
112102
|
while (true) {
|
|
112119
112103
|
auto chunk = FetchInternal(lock, GetExecutor(), *result);
|
|
112120
112104
|
if (!chunk || chunk->size() == 0) {
|
|
@@ -112155,14 +112139,11 @@ shared_ptr<PreparedStatementData> ClientContext::CreatePreparedStatement(ClientC
|
|
|
112155
112139
|
plan->Verify();
|
|
112156
112140
|
#endif
|
|
112157
112141
|
// 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;
|
|
112142
|
+
result->properties = planner.properties;
|
|
112161
112143
|
result->names = planner.names;
|
|
112162
112144
|
result->types = planner.types;
|
|
112163
112145
|
result->value_map = move(planner.value_map);
|
|
112164
112146
|
result->catalog_version = Transaction::GetTransaction(*this).catalog_version;
|
|
112165
|
-
result->bound_all_parameters = planner.bound_all_parameters;
|
|
112166
112147
|
|
|
112167
112148
|
if (config.enable_optimizer) {
|
|
112168
112149
|
profiler.StartPhase("optimizer");
|
|
@@ -112198,11 +112179,11 @@ unique_ptr<PendingQueryResult> ClientContext::PendingPreparedStatement(ClientCon
|
|
|
112198
112179
|
vector<Value> bound_values) {
|
|
112199
112180
|
D_ASSERT(active_query);
|
|
112200
112181
|
auto &statement = *statement_p;
|
|
112201
|
-
if (ActiveTransaction().IsInvalidated() && statement.requires_valid_transaction) {
|
|
112182
|
+
if (ActiveTransaction().IsInvalidated() && statement.properties.requires_valid_transaction) {
|
|
112202
112183
|
throw Exception("Current transaction is aborted (please ROLLBACK)");
|
|
112203
112184
|
}
|
|
112204
112185
|
auto &db_config = DBConfig::GetConfig(*this);
|
|
112205
|
-
if (db_config.access_mode == AccessMode::READ_ONLY && !statement.read_only) {
|
|
112186
|
+
if (db_config.access_mode == AccessMode::READ_ONLY && !statement.properties.read_only) {
|
|
112206
112187
|
throw Exception(StringUtil::Format("Cannot execute statement of type \"%s\" in read-only mode!",
|
|
112207
112188
|
StatementTypeToString(statement.statement_type)));
|
|
112208
112189
|
}
|
|
@@ -112471,17 +112452,17 @@ ClientContext::PendingStatementOrPreparedStatement(ClientContextLock &lock, cons
|
|
|
112471
112452
|
result = PendingStatementInternal(lock, query, move(statement));
|
|
112472
112453
|
} else {
|
|
112473
112454
|
auto &catalog = Catalog::GetCatalog(*this);
|
|
112474
|
-
if (prepared->unbound_statement &&
|
|
112475
|
-
|
|
112455
|
+
if (prepared->unbound_statement && (catalog.GetCatalogVersion() != prepared->catalog_version ||
|
|
112456
|
+
!prepared->properties.bound_all_parameters)) {
|
|
112476
112457
|
// catalog was modified: rebind the statement before execution
|
|
112477
112458
|
auto new_prepared = CreatePreparedStatement(lock, query, prepared->unbound_statement->Copy(), values);
|
|
112478
|
-
if (prepared->types != new_prepared->types && prepared->bound_all_parameters) {
|
|
112459
|
+
if (prepared->types != new_prepared->types && prepared->properties.bound_all_parameters) {
|
|
112479
112460
|
throw BinderException("Rebinding statement after catalog change resulted in change of types");
|
|
112480
112461
|
}
|
|
112481
|
-
D_ASSERT(new_prepared->bound_all_parameters);
|
|
112462
|
+
D_ASSERT(new_prepared->properties.bound_all_parameters);
|
|
112482
112463
|
new_prepared->unbound_statement = move(prepared->unbound_statement);
|
|
112483
112464
|
prepared = move(new_prepared);
|
|
112484
|
-
prepared->bound_all_parameters = false;
|
|
112465
|
+
prepared->properties.bound_all_parameters = false;
|
|
112485
112466
|
}
|
|
112486
112467
|
result = PendingPreparedStatement(lock, prepared, *values);
|
|
112487
112468
|
}
|
|
@@ -112539,7 +112520,11 @@ unique_ptr<QueryResult> ClientContext::Query(const string &query, bool allow_str
|
|
|
112539
112520
|
}
|
|
112540
112521
|
if (statements.empty()) {
|
|
112541
112522
|
// no statements, return empty successful result
|
|
112542
|
-
|
|
112523
|
+
StatementProperties properties;
|
|
112524
|
+
vector<LogicalType> types;
|
|
112525
|
+
vector<string> names;
|
|
112526
|
+
return make_unique<MaterializedQueryResult>(StatementType::INVALID_STATEMENT, properties, move(types),
|
|
112527
|
+
move(names));
|
|
112543
112528
|
}
|
|
112544
112529
|
|
|
112545
112530
|
unique_ptr<QueryResult> result;
|
|
@@ -122905,13 +122890,9 @@ Extension::~Extension() {
|
|
|
122905
122890
|
|
|
122906
122891
|
namespace duckdb {
|
|
122907
122892
|
|
|
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)) {
|
|
122893
|
+
MaterializedQueryResult::MaterializedQueryResult(StatementType statement_type, StatementProperties properties,
|
|
122894
|
+
vector<LogicalType> types, vector<string> names)
|
|
122895
|
+
: QueryResult(QueryResultType::MATERIALIZED_RESULT, statement_type, properties, move(types), move(names)) {
|
|
122915
122896
|
}
|
|
122916
122897
|
|
|
122917
122898
|
MaterializedQueryResult::MaterializedQueryResult(string error)
|
|
@@ -122964,7 +122945,8 @@ namespace duckdb {
|
|
|
122964
122945
|
|
|
122965
122946
|
PendingQueryResult::PendingQueryResult(shared_ptr<ClientContext> context_p, PreparedStatementData &statement,
|
|
122966
122947
|
vector<LogicalType> types_p)
|
|
122967
|
-
: BaseQueryResult(QueryResultType::PENDING_RESULT, statement.statement_type, move(types_p),
|
|
122948
|
+
: BaseQueryResult(QueryResultType::PENDING_RESULT, statement.statement_type, statement.properties, move(types_p),
|
|
122949
|
+
statement.names),
|
|
122968
122950
|
context(move(context_p)) {
|
|
122969
122951
|
}
|
|
122970
122952
|
|
|
@@ -123054,6 +123036,11 @@ StatementType PreparedStatement::GetStatementType() {
|
|
|
123054
123036
|
return data->statement_type;
|
|
123055
123037
|
}
|
|
123056
123038
|
|
|
123039
|
+
StatementProperties PreparedStatement::GetStatementProperties() {
|
|
123040
|
+
D_ASSERT(data);
|
|
123041
|
+
return data->properties;
|
|
123042
|
+
}
|
|
123043
|
+
|
|
123057
123044
|
const vector<LogicalType> &PreparedStatement::GetTypes() {
|
|
123058
123045
|
D_ASSERT(data);
|
|
123059
123046
|
return data->types;
|
|
@@ -123069,7 +123056,7 @@ unique_ptr<QueryResult> PreparedStatement::Execute(vector<Value> &values, bool a
|
|
|
123069
123056
|
if (!pending->success) {
|
|
123070
123057
|
return make_unique<MaterializedQueryResult>(pending->error);
|
|
123071
123058
|
}
|
|
123072
|
-
return pending->Execute(allow_stream_result && data->allow_stream_result);
|
|
123059
|
+
return pending->Execute(allow_stream_result && data->properties.allow_stream_result);
|
|
123073
123060
|
}
|
|
123074
123061
|
|
|
123075
123062
|
unique_ptr<PendingQueryResult> PreparedStatement::PendingQuery(vector<Value> &values) {
|
|
@@ -123088,9 +123075,7 @@ unique_ptr<PendingQueryResult> PreparedStatement::PendingQuery(vector<Value> &va
|
|
|
123088
123075
|
|
|
123089
123076
|
namespace duckdb {
|
|
123090
123077
|
|
|
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) {
|
|
123078
|
+
PreparedStatementData::PreparedStatementData(StatementType type) : statement_type(type) {
|
|
123094
123079
|
}
|
|
123095
123080
|
|
|
123096
123081
|
PreparedStatementData::~PreparedStatementData() {
|
|
@@ -123835,13 +123820,10 @@ ExpressionRootInfo::ExpressionRootInfo(ExpressionExecutorState &state, string na
|
|
|
123835
123820
|
|
|
123836
123821
|
namespace duckdb {
|
|
123837
123822
|
|
|
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) {
|
|
123823
|
+
BaseQueryResult::BaseQueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
|
|
123824
|
+
vector<LogicalType> types_p, vector<string> names_p)
|
|
123825
|
+
: type(type), statement_type(statement_type), properties(properties), types(move(types_p)), names(move(names_p)),
|
|
123826
|
+
success(true) {
|
|
123845
123827
|
D_ASSERT(types.size() == names.size());
|
|
123846
123828
|
}
|
|
123847
123829
|
|
|
@@ -123861,12 +123843,9 @@ idx_t BaseQueryResult::ColumnCount() {
|
|
|
123861
123843
|
return types.size();
|
|
123862
123844
|
}
|
|
123863
123845
|
|
|
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)) {
|
|
123846
|
+
QueryResult::QueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
|
|
123847
|
+
vector<LogicalType> types_p, vector<string> names_p)
|
|
123848
|
+
: BaseQueryResult(type, statement_type, properties, move(types_p), move(names_p)) {
|
|
123870
123849
|
}
|
|
123871
123850
|
|
|
123872
123851
|
QueryResult::QueryResult(QueryResultType type, string error) : BaseQueryResult(type, move(error)) {
|
|
@@ -127147,9 +127126,10 @@ Value ThreadsSetting::GetSetting(ClientContext &context) {
|
|
|
127147
127126
|
|
|
127148
127127
|
namespace duckdb {
|
|
127149
127128
|
|
|
127150
|
-
StreamQueryResult::StreamQueryResult(StatementType statement_type,
|
|
127151
|
-
vector<LogicalType> types, vector<string> names)
|
|
127152
|
-
: QueryResult(QueryResultType::STREAM_RESULT, statement_type, move(types), move(names)),
|
|
127129
|
+
StreamQueryResult::StreamQueryResult(StatementType statement_type, StatementProperties properties,
|
|
127130
|
+
shared_ptr<ClientContext> context, vector<LogicalType> types, vector<string> names)
|
|
127131
|
+
: QueryResult(QueryResultType::STREAM_RESULT, statement_type, properties, move(types), move(names)),
|
|
127132
|
+
context(move(context)) {
|
|
127153
127133
|
}
|
|
127154
127134
|
|
|
127155
127135
|
StreamQueryResult::~StreamQueryResult() {
|
|
@@ -127199,7 +127179,7 @@ unique_ptr<MaterializedQueryResult> StreamQueryResult::Materialize() {
|
|
|
127199
127179
|
if (!success) {
|
|
127200
127180
|
return make_unique<MaterializedQueryResult>(error);
|
|
127201
127181
|
}
|
|
127202
|
-
auto result = make_unique<MaterializedQueryResult>(statement_type, types, names);
|
|
127182
|
+
auto result = make_unique<MaterializedQueryResult>(statement_type, properties, types, names);
|
|
127203
127183
|
while (true) {
|
|
127204
127184
|
auto chunk = Fetch();
|
|
127205
127185
|
if (!chunk || chunk->size() == 0) {
|
|
@@ -142111,7 +142091,7 @@ ThreadContext::ThreadContext(ClientContext &context) : profiler(QueryProfiler::G
|
|
|
142111
142091
|
|
|
142112
142092
|
namespace duckdb {
|
|
142113
142093
|
|
|
142114
|
-
void BaseExpression::Print() {
|
|
142094
|
+
void BaseExpression::Print() const {
|
|
142115
142095
|
Printer::Print(ToString());
|
|
142116
142096
|
}
|
|
142117
142097
|
|
|
@@ -161132,6 +161112,7 @@ BoundStatement Binder::Bind(CallStatement &stmt) {
|
|
|
161132
161112
|
result.types = get.returned_types;
|
|
161133
161113
|
result.names = get.names;
|
|
161134
161114
|
result.plan = CreatePlan(*bound_func);
|
|
161115
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
161135
161116
|
return result;
|
|
161136
161117
|
}
|
|
161137
161118
|
|
|
@@ -161278,7 +161259,8 @@ BoundStatement Binder::Bind(CopyStatement &stmt) {
|
|
|
161278
161259
|
}
|
|
161279
161260
|
stmt.select_statement = move(statement);
|
|
161280
161261
|
}
|
|
161281
|
-
|
|
161262
|
+
properties.allow_stream_result = false;
|
|
161263
|
+
properties.return_type = StatementReturnType::CHANGED_ROWS;
|
|
161282
161264
|
if (stmt.info->is_from) {
|
|
161283
161265
|
return BindCopyFrom(stmt);
|
|
161284
161266
|
} else {
|
|
@@ -161417,7 +161399,7 @@ SchemaCatalogEntry *Binder::BindSchema(CreateInfo &info) {
|
|
|
161417
161399
|
if (info.schema == TEMP_SCHEMA) {
|
|
161418
161400
|
throw ParserException("Only TEMPORARY table names can use the \"temp\" schema");
|
|
161419
161401
|
}
|
|
161420
|
-
|
|
161402
|
+
properties.read_only = false;
|
|
161421
161403
|
} else {
|
|
161422
161404
|
if (info.schema != TEMP_SCHEMA) {
|
|
161423
161405
|
throw ParserException("TEMPORARY table names can *only* use the \"%s\" schema", TEMP_SCHEMA);
|
|
@@ -161562,6 +161544,7 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
161562
161544
|
BoundStatement result;
|
|
161563
161545
|
result.names = {"Count"};
|
|
161564
161546
|
result.types = {LogicalType::BIGINT};
|
|
161547
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
161565
161548
|
|
|
161566
161549
|
auto catalog_type = stmt.info->type;
|
|
161567
161550
|
switch (catalog_type) {
|
|
@@ -161672,6 +161655,8 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
161672
161655
|
auto &schema = bound_info->schema;
|
|
161673
161656
|
auto create_table = make_unique<LogicalCreateTable>(schema, move(bound_info));
|
|
161674
161657
|
if (root) {
|
|
161658
|
+
// CREATE TABLE AS
|
|
161659
|
+
properties.return_type = StatementReturnType::CHANGED_ROWS;
|
|
161675
161660
|
create_table->children.push_back(move(root));
|
|
161676
161661
|
}
|
|
161677
161662
|
result.plan = move(create_table);
|
|
@@ -161685,7 +161670,7 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
161685
161670
|
default:
|
|
161686
161671
|
throw Exception("Unrecognized type!");
|
|
161687
161672
|
}
|
|
161688
|
-
|
|
161673
|
+
properties.allow_stream_result = false;
|
|
161689
161674
|
return result;
|
|
161690
161675
|
}
|
|
161691
161676
|
|
|
@@ -161939,7 +161924,7 @@ unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateIn
|
|
|
161939
161924
|
}
|
|
161940
161925
|
}
|
|
161941
161926
|
}
|
|
161942
|
-
|
|
161927
|
+
properties.allow_stream_result = false;
|
|
161943
161928
|
return result;
|
|
161944
161929
|
}
|
|
161945
161930
|
|
|
@@ -161999,7 +161984,7 @@ BoundStatement Binder::Bind(DeleteStatement &stmt) {
|
|
|
161999
161984
|
|
|
162000
161985
|
if (!table->temporary) {
|
|
162001
161986
|
// delete from persistent table: not read only!
|
|
162002
|
-
|
|
161987
|
+
properties.read_only = false;
|
|
162003
161988
|
}
|
|
162004
161989
|
|
|
162005
161990
|
// plan any tables from the various using clauses
|
|
@@ -162060,7 +162045,8 @@ BoundStatement Binder::Bind(DeleteStatement &stmt) {
|
|
|
162060
162045
|
result.plan = move(del);
|
|
162061
162046
|
result.names = {"Count"};
|
|
162062
162047
|
result.types = {LogicalType::BIGINT};
|
|
162063
|
-
|
|
162048
|
+
properties.allow_stream_result = false;
|
|
162049
|
+
properties.return_type = StatementReturnType::CHANGED_ROWS;
|
|
162064
162050
|
}
|
|
162065
162051
|
return result;
|
|
162066
162052
|
}
|
|
@@ -162082,11 +162068,11 @@ BoundStatement Binder::Bind(DropStatement &stmt) {
|
|
|
162082
162068
|
case CatalogType::PREPARED_STATEMENT:
|
|
162083
162069
|
// dropping prepared statements is always possible
|
|
162084
162070
|
// it also does not require a valid transaction
|
|
162085
|
-
|
|
162071
|
+
properties.requires_valid_transaction = false;
|
|
162086
162072
|
break;
|
|
162087
162073
|
case CatalogType::SCHEMA_ENTRY:
|
|
162088
162074
|
// dropping a schema is never read-only because there are no temporary schemas
|
|
162089
|
-
|
|
162075
|
+
properties.read_only = false;
|
|
162090
162076
|
break;
|
|
162091
162077
|
case CatalogType::VIEW_ENTRY:
|
|
162092
162078
|
case CatalogType::SEQUENCE_ENTRY:
|
|
@@ -162102,7 +162088,7 @@ BoundStatement Binder::Bind(DropStatement &stmt) {
|
|
|
162102
162088
|
}
|
|
162103
162089
|
if (!entry->temporary) {
|
|
162104
162090
|
// we can only drop temporary tables in read-only mode
|
|
162105
|
-
|
|
162091
|
+
properties.read_only = false;
|
|
162106
162092
|
}
|
|
162107
162093
|
stmt.info->schema = entry->schema->name;
|
|
162108
162094
|
break;
|
|
@@ -162113,7 +162099,8 @@ BoundStatement Binder::Bind(DropStatement &stmt) {
|
|
|
162113
162099
|
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::LOGICAL_DROP, move(stmt.info));
|
|
162114
162100
|
result.names = {"Success"};
|
|
162115
162101
|
result.types = {LogicalType::BOOLEAN};
|
|
162116
|
-
|
|
162102
|
+
properties.allow_stream_result = false;
|
|
162103
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162117
162104
|
return result;
|
|
162118
162105
|
}
|
|
162119
162106
|
|
|
@@ -162137,6 +162124,7 @@ BoundStatement Binder::Bind(ExplainStatement &stmt) {
|
|
|
162137
162124
|
result.plan = move(explain);
|
|
162138
162125
|
result.names = {"explain_key", "explain_value"};
|
|
162139
162126
|
result.types = {LogicalType::VARCHAR, LogicalType::VARCHAR};
|
|
162127
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
162140
162128
|
return result;
|
|
162141
162129
|
}
|
|
162142
162130
|
|
|
@@ -162340,7 +162328,8 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {
|
|
|
162340
162328
|
}
|
|
162341
162329
|
|
|
162342
162330
|
result.plan = move(export_node);
|
|
162343
|
-
|
|
162331
|
+
properties.allow_stream_result = false;
|
|
162332
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162344
162333
|
return result;
|
|
162345
162334
|
}
|
|
162346
162335
|
|
|
@@ -162408,7 +162397,7 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
|
162408
162397
|
D_ASSERT(table);
|
|
162409
162398
|
if (!table->temporary) {
|
|
162410
162399
|
// inserting into a non-temporary table: alters underlying database
|
|
162411
|
-
|
|
162400
|
+
properties.read_only = false;
|
|
162412
162401
|
}
|
|
162413
162402
|
|
|
162414
162403
|
auto insert = make_unique<LogicalInsert>(table);
|
|
@@ -162514,7 +162503,8 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
|
162514
162503
|
} else {
|
|
162515
162504
|
D_ASSERT(result.types.size() == result.names.size());
|
|
162516
162505
|
result.plan = move(insert);
|
|
162517
|
-
|
|
162506
|
+
properties.allow_stream_result = false;
|
|
162507
|
+
properties.return_type = StatementReturnType::CHANGED_ROWS;
|
|
162518
162508
|
return result;
|
|
162519
162509
|
}
|
|
162520
162510
|
}
|
|
@@ -162533,7 +162523,8 @@ BoundStatement Binder::Bind(LoadStatement &stmt) {
|
|
|
162533
162523
|
result.names = {"Success"};
|
|
162534
162524
|
|
|
162535
162525
|
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::LOGICAL_LOAD, move(stmt.info));
|
|
162536
|
-
|
|
162526
|
+
properties.allow_stream_result = false;
|
|
162527
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162537
162528
|
return result;
|
|
162538
162529
|
}
|
|
162539
162530
|
|
|
@@ -162569,6 +162560,7 @@ BoundStatement Binder::Bind(PragmaStatement &stmt) {
|
|
|
162569
162560
|
result.names = {"Success"};
|
|
162570
162561
|
result.types = {LogicalType::BOOLEAN};
|
|
162571
162562
|
result.plan = make_unique<LogicalPragma>(bound_function, *stmt.info);
|
|
162563
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
162572
162564
|
return result;
|
|
162573
162565
|
}
|
|
162574
162566
|
|
|
@@ -162594,7 +162586,8 @@ BoundStatement Binder::Bind(RelationStatement &stmt) {
|
|
|
162594
162586
|
namespace duckdb {
|
|
162595
162587
|
|
|
162596
162588
|
BoundStatement Binder::Bind(SelectStatement &stmt) {
|
|
162597
|
-
|
|
162589
|
+
properties.allow_stream_result = true;
|
|
162590
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
162598
162591
|
return Bind(*stmt.node);
|
|
162599
162592
|
}
|
|
162600
162593
|
|
|
@@ -162612,6 +162605,7 @@ BoundStatement Binder::Bind(SetStatement &stmt) {
|
|
|
162612
162605
|
result.names = {"Success"};
|
|
162613
162606
|
|
|
162614
162607
|
result.plan = make_unique<LogicalSet>(stmt.name, stmt.value, stmt.scope);
|
|
162608
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162615
162609
|
return result;
|
|
162616
162610
|
}
|
|
162617
162611
|
|
|
@@ -162641,6 +162635,7 @@ BoundStatement Binder::Bind(ShowStatement &stmt) {
|
|
|
162641
162635
|
result.names = {"column_name", "column_type", "null", "key", "default", "extra"};
|
|
162642
162636
|
result.types = {LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR,
|
|
162643
162637
|
LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR};
|
|
162638
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
162644
162639
|
return result;
|
|
162645
162640
|
}
|
|
162646
162641
|
|
|
@@ -162666,20 +162661,22 @@ BoundStatement Binder::Bind(AlterStatement &stmt) {
|
|
|
162666
162661
|
auto entry = catalog.GetEntry(context, stmt.info->GetCatalogType(), stmt.info->schema, stmt.info->name, true);
|
|
162667
162662
|
if (entry && !entry->temporary) {
|
|
162668
162663
|
// we can only alter temporary tables/views in read-only mode
|
|
162669
|
-
|
|
162664
|
+
properties.read_only = false;
|
|
162670
162665
|
}
|
|
162671
162666
|
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::LOGICAL_ALTER, move(stmt.info));
|
|
162667
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162672
162668
|
return result;
|
|
162673
162669
|
}
|
|
162674
162670
|
|
|
162675
162671
|
BoundStatement Binder::Bind(TransactionStatement &stmt) {
|
|
162676
162672
|
// transaction statements do not require a valid transaction
|
|
162677
|
-
|
|
162673
|
+
properties.requires_valid_transaction = false;
|
|
162678
162674
|
|
|
162679
162675
|
BoundStatement result;
|
|
162680
162676
|
result.names = {"Success"};
|
|
162681
162677
|
result.types = {LogicalType::BOOLEAN};
|
|
162682
162678
|
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::LOGICAL_TRANSACTION, move(stmt.info));
|
|
162679
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
162683
162680
|
return result;
|
|
162684
162681
|
}
|
|
162685
162682
|
|
|
@@ -162814,6 +162811,7 @@ BoundStatement Binder::BindSummarize(ShowStatement &stmt) {
|
|
|
162814
162811
|
select_node->select_list.push_back(SummarizeWrapUnnest(null_percentage_children, "null_percentage"));
|
|
162815
162812
|
select_node->from_table = move(subquery_ref);
|
|
162816
162813
|
|
|
162814
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
162817
162815
|
return Bind(*select_node);
|
|
162818
162816
|
}
|
|
162819
162817
|
|
|
@@ -163022,7 +163020,7 @@ BoundStatement Binder::Bind(UpdateStatement &stmt) {
|
|
|
163022
163020
|
|
|
163023
163021
|
if (!table->temporary) {
|
|
163024
163022
|
// update of persistent table: not read only!
|
|
163025
|
-
|
|
163023
|
+
properties.read_only = false;
|
|
163026
163024
|
}
|
|
163027
163025
|
auto update = make_unique<LogicalUpdate>(table);
|
|
163028
163026
|
|
|
@@ -163103,7 +163101,8 @@ BoundStatement Binder::Bind(UpdateStatement &stmt) {
|
|
|
163103
163101
|
result.names = {"Count"};
|
|
163104
163102
|
result.types = {LogicalType::BIGINT};
|
|
163105
163103
|
result.plan = move(update);
|
|
163106
|
-
|
|
163104
|
+
properties.allow_stream_result = false;
|
|
163105
|
+
properties.return_type = StatementReturnType::CHANGED_ROWS;
|
|
163107
163106
|
}
|
|
163108
163107
|
return result;
|
|
163109
163108
|
}
|
|
@@ -163120,6 +163119,7 @@ BoundStatement Binder::Bind(VacuumStatement &stmt) {
|
|
|
163120
163119
|
result.names = {"Success"};
|
|
163121
163120
|
result.types = {LogicalType::BOOLEAN};
|
|
163122
163121
|
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::LOGICAL_VACUUM, move(stmt.info));
|
|
163122
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
163123
163123
|
return result;
|
|
163124
163124
|
}
|
|
163125
163125
|
|
|
@@ -164413,8 +164413,7 @@ shared_ptr<Binder> Binder::CreateBinder(ClientContext &context, Binder *parent,
|
|
|
164413
164413
|
}
|
|
164414
164414
|
|
|
164415
164415
|
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) {
|
|
164416
|
+
: context(context), parent(move(parent_p)), bound_tables(0), inherit_ctes(inherit_ctes_p) {
|
|
164418
164417
|
parameters = nullptr;
|
|
164419
164418
|
parameter_types = nullptr;
|
|
164420
164419
|
if (parent) {
|
|
@@ -164815,7 +164814,8 @@ BoundStatement Binder::BindReturning(vector<unique_ptr<ParsedExpression>> return
|
|
|
164815
164814
|
projection->AddChild(move(child_operator));
|
|
164816
164815
|
D_ASSERT(result.types.size() == result.names.size());
|
|
164817
164816
|
result.plan = move(projection);
|
|
164818
|
-
|
|
164817
|
+
properties.allow_stream_result = true;
|
|
164818
|
+
properties.return_type = StatementReturnType::QUERY_RESULT;
|
|
164819
164819
|
return result;
|
|
164820
164820
|
}
|
|
164821
164821
|
|
|
@@ -168234,19 +168234,17 @@ void Planner::CreatePlan(SQLStatement &statement) {
|
|
|
168234
168234
|
auto bound_statement = binder->Bind(statement);
|
|
168235
168235
|
profiler.EndPhase();
|
|
168236
168236
|
|
|
168237
|
-
this->
|
|
168238
|
-
this->requires_valid_transaction = binder->requires_valid_transaction;
|
|
168239
|
-
this->allow_stream_result = binder->allow_stream_result;
|
|
168237
|
+
this->properties = binder->properties;
|
|
168240
168238
|
this->names = bound_statement.names;
|
|
168241
168239
|
this->types = bound_statement.types;
|
|
168242
168240
|
this->plan = move(bound_statement.plan);
|
|
168243
|
-
|
|
168241
|
+
properties.bound_all_parameters = true;
|
|
168244
168242
|
|
|
168245
168243
|
// set up a map of parameter number -> value entries
|
|
168246
168244
|
for (auto &expr : bound_parameters) {
|
|
168247
168245
|
// check if the type of the parameter could be resolved
|
|
168248
168246
|
if (expr->return_type.id() == LogicalTypeId::INVALID || expr->return_type.id() == LogicalTypeId::UNKNOWN) {
|
|
168249
|
-
|
|
168247
|
+
properties.bound_all_parameters = false;
|
|
168250
168248
|
continue;
|
|
168251
168249
|
}
|
|
168252
168250
|
auto value = make_unique<Value>(expr->return_type);
|
|
@@ -168274,11 +168272,8 @@ shared_ptr<PreparedStatementData> Planner::PrepareSQLStatement(unique_ptr<SQLSta
|
|
|
168274
168272
|
prepared_data->names = names;
|
|
168275
168273
|
prepared_data->types = types;
|
|
168276
168274
|
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;
|
|
168275
|
+
prepared_data->properties = properties;
|
|
168280
168276
|
prepared_data->catalog_version = Transaction::GetTransaction(context).catalog_version;
|
|
168281
|
-
prepared_data->bound_all_parameters = this->bound_all_parameters;
|
|
168282
168277
|
return prepared_data;
|
|
168283
168278
|
}
|
|
168284
168279
|
|
|
@@ -168308,7 +168303,7 @@ void Planner::PlanExecute(unique_ptr<SQLStatement> statement) {
|
|
|
168308
168303
|
Value value = ExpressionExecutor::EvaluateScalar(*bound_expr);
|
|
168309
168304
|
bind_values.push_back(move(value));
|
|
168310
168305
|
}
|
|
168311
|
-
bool all_bound = prepared->bound_all_parameters;
|
|
168306
|
+
bool all_bound = prepared->properties.bound_all_parameters;
|
|
168312
168307
|
if (catalog.GetCatalogVersion() != entry->second->catalog_version || !all_bound) {
|
|
168313
168308
|
// catalog was modified or statement does not have clear types: rebind the statement before running the execute
|
|
168314
168309
|
for (auto &value : bind_values) {
|
|
@@ -168319,7 +168314,7 @@ void Planner::PlanExecute(unique_ptr<SQLStatement> statement) {
|
|
|
168319
168314
|
throw BinderException("Rebinding statement \"%s\" after catalog change resulted in change of types",
|
|
168320
168315
|
stmt.name);
|
|
168321
168316
|
}
|
|
168322
|
-
D_ASSERT(prepared->bound_all_parameters);
|
|
168317
|
+
D_ASSERT(prepared->properties.bound_all_parameters);
|
|
168323
168318
|
rebound = true;
|
|
168324
168319
|
}
|
|
168325
168320
|
// add casts to the prepared statement parameters as required
|
|
@@ -168339,12 +168334,9 @@ void Planner::PlanExecute(unique_ptr<SQLStatement> statement) {
|
|
|
168339
168334
|
}
|
|
168340
168335
|
|
|
168341
168336
|
// 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;
|
|
168337
|
+
this->properties = prepared->properties;
|
|
168345
168338
|
this->names = prepared->names;
|
|
168346
168339
|
this->types = prepared->types;
|
|
168347
|
-
this->bound_all_parameters = prepared->bound_all_parameters;
|
|
168348
168340
|
this->plan = make_unique<LogicalExecute>(move(prepared));
|
|
168349
168341
|
}
|
|
168350
168342
|
|
|
@@ -168354,12 +168346,13 @@ void Planner::PlanPrepare(unique_ptr<SQLStatement> statement) {
|
|
|
168354
168346
|
|
|
168355
168347
|
auto prepare = make_unique<LogicalPrepare>(stmt.name, move(prepared_data), move(plan));
|
|
168356
168348
|
// we can prepare in read-only mode: prepared statements are not written to the catalog
|
|
168357
|
-
|
|
168349
|
+
properties.read_only = true;
|
|
168358
168350
|
// we can always prepare, even if the transaction has been invalidated
|
|
168359
168351
|
// this is required because most clients ALWAYS invoke prepared statements
|
|
168360
|
-
|
|
168361
|
-
|
|
168362
|
-
|
|
168352
|
+
properties.requires_valid_transaction = false;
|
|
168353
|
+
properties.allow_stream_result = false;
|
|
168354
|
+
properties.bound_all_parameters = true;
|
|
168355
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
168363
168356
|
this->names = {"Success"};
|
|
168364
168357
|
this->types = {LogicalType::BOOLEAN};
|
|
168365
168358
|
this->plan = move(prepare);
|