duckdb 0.4.1-dev171.0 → 0.4.1-dev188.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 +158 -38
- package/src/duckdb.hpp +110 -3
- package/src/parquet-amalgamation.cpp +36753 -36753
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -7663,6 +7663,8 @@ string StatementTypeToString(StatementType type) {
|
|
|
7663
7663
|
return "SET";
|
|
7664
7664
|
case StatementType::LOAD_STATEMENT:
|
|
7665
7665
|
return "LOAD";
|
|
7666
|
+
case StatementType::EXTENSION_STATEMENT:
|
|
7667
|
+
return "EXTENSION";
|
|
7666
7668
|
case StatementType::INVALID_STATEMENT:
|
|
7667
7669
|
break;
|
|
7668
7670
|
}
|
|
@@ -112254,7 +112256,11 @@ TableFunction::TableFunction(const vector<LogicalType> &arguments, table_functio
|
|
|
112254
112256
|
table_function_init_local_t init_local)
|
|
112255
112257
|
: TableFunction(string(), arguments, function, bind, init_global, init_local) {
|
|
112256
112258
|
}
|
|
112257
|
-
TableFunction::TableFunction()
|
|
112259
|
+
TableFunction::TableFunction()
|
|
112260
|
+
: SimpleNamedParameterFunction("", {}), bind(nullptr), init_global(nullptr), init_local(nullptr), function(nullptr),
|
|
112261
|
+
in_out_function(nullptr), statistics(nullptr), dependency(nullptr), cardinality(nullptr),
|
|
112262
|
+
pushdown_complex_filter(nullptr), to_string(nullptr), table_scan_progress(nullptr), get_batch_index(nullptr),
|
|
112263
|
+
projection_pushdown(false), filter_pushdown(false) {
|
|
112258
112264
|
}
|
|
112259
112265
|
|
|
112260
112266
|
} // namespace duckdb
|
|
@@ -116965,6 +116971,7 @@ ParserOptions ClientContext::GetParserOptions() {
|
|
|
116965
116971
|
ParserOptions options;
|
|
116966
116972
|
options.preserve_identifier_case = ClientConfig::GetConfig(*this).preserve_identifier_case;
|
|
116967
116973
|
options.max_expression_depth = ClientConfig::GetConfig(*this).max_expression_depth;
|
|
116974
|
+
options.extensions = &DBConfig::GetConfig(*this).parser_extensions;
|
|
116968
116975
|
return options;
|
|
116969
116976
|
}
|
|
116970
116977
|
|
|
@@ -118240,6 +118247,7 @@ void DatabaseInstance::Configure(DBConfig &new_config) {
|
|
|
118240
118247
|
config.replacement_scans = move(new_config.replacement_scans);
|
|
118241
118248
|
config.initialize_default_database = new_config.initialize_default_database;
|
|
118242
118249
|
config.disabled_optimizers = move(new_config.disabled_optimizers);
|
|
118250
|
+
config.parser_extensions = move(new_config.parser_extensions);
|
|
118243
118251
|
}
|
|
118244
118252
|
|
|
118245
118253
|
DBConfig &DBConfig::GetConfig(ClientContext &context) {
|
|
@@ -155261,6 +155269,36 @@ vector<string> ReadPgListToString(duckdb_libpgquery::PGList *column_list);
|
|
|
155261
155269
|
|
|
155262
155270
|
|
|
155263
155271
|
|
|
155272
|
+
//===----------------------------------------------------------------------===//
|
|
155273
|
+
// DuckDB
|
|
155274
|
+
//
|
|
155275
|
+
// duckdb/parser/statement/extension_statement.hpp
|
|
155276
|
+
//
|
|
155277
|
+
//
|
|
155278
|
+
//===----------------------------------------------------------------------===//
|
|
155279
|
+
|
|
155280
|
+
|
|
155281
|
+
|
|
155282
|
+
|
|
155283
|
+
|
|
155284
|
+
|
|
155285
|
+
namespace duckdb {
|
|
155286
|
+
|
|
155287
|
+
class ExtensionStatement : public SQLStatement {
|
|
155288
|
+
public:
|
|
155289
|
+
ExtensionStatement(ParserExtension extension, unique_ptr<ParserExtensionParseData> parse_data);
|
|
155290
|
+
|
|
155291
|
+
//! The ParserExtension this statement was generated from
|
|
155292
|
+
ParserExtension extension;
|
|
155293
|
+
//! The parse data for this specific statement
|
|
155294
|
+
unique_ptr<ParserExtensionParseData> parse_data;
|
|
155295
|
+
|
|
155296
|
+
public:
|
|
155297
|
+
unique_ptr<SQLStatement> Copy() const override;
|
|
155298
|
+
};
|
|
155299
|
+
|
|
155300
|
+
} // namespace duckdb
|
|
155301
|
+
|
|
155264
155302
|
|
|
155265
155303
|
|
|
155266
155304
|
|
|
@@ -155358,6 +155396,7 @@ public:
|
|
|
155358
155396
|
|
|
155359
155397
|
|
|
155360
155398
|
|
|
155399
|
+
|
|
155361
155400
|
// LICENSE_CHANGE_BEGIN
|
|
155362
155401
|
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #11
|
|
155363
155402
|
// See the end of this file for a list
|
|
@@ -155420,6 +155459,22 @@ void Parser::ParseQuery(const string &query) {
|
|
|
155420
155459
|
parser.Parse(query);
|
|
155421
155460
|
|
|
155422
155461
|
if (!parser.success) {
|
|
155462
|
+
if (options.extensions) {
|
|
155463
|
+
for (auto &ext : *options.extensions) {
|
|
155464
|
+
D_ASSERT(ext.parse_function);
|
|
155465
|
+
auto result = ext.parse_function(ext.parser_info.get(), query);
|
|
155466
|
+
if (result.type == ParserExtensionResultType::PARSE_SUCCESSFUL) {
|
|
155467
|
+
auto statement = make_unique<ExtensionStatement>(ext, move(result.parse_data));
|
|
155468
|
+
statement->stmt_length = query.size();
|
|
155469
|
+
statement->stmt_location = 0;
|
|
155470
|
+
statements.push_back(move(statement));
|
|
155471
|
+
return;
|
|
155472
|
+
}
|
|
155473
|
+
if (result.type == ParserExtensionResultType::DISPLAY_EXTENSION_ERROR) {
|
|
155474
|
+
throw ParserException(result.error);
|
|
155475
|
+
}
|
|
155476
|
+
}
|
|
155477
|
+
}
|
|
155423
155478
|
throw ParserException(QueryErrorContext::Format(query, parser.error_message, parser.error_location - 1));
|
|
155424
155479
|
}
|
|
155425
155480
|
|
|
@@ -156812,6 +156867,19 @@ unique_ptr<SQLStatement> ExportStatement::Copy() const {
|
|
|
156812
156867
|
} // namespace duckdb
|
|
156813
156868
|
|
|
156814
156869
|
|
|
156870
|
+
namespace duckdb {
|
|
156871
|
+
|
|
156872
|
+
ExtensionStatement::ExtensionStatement(ParserExtension extension_p, unique_ptr<ParserExtensionParseData> parse_data_p)
|
|
156873
|
+
: SQLStatement(StatementType::EXTENSION_STATEMENT), extension(move(extension_p)), parse_data(move(parse_data_p)) {
|
|
156874
|
+
}
|
|
156875
|
+
|
|
156876
|
+
unique_ptr<SQLStatement> ExtensionStatement::Copy() const {
|
|
156877
|
+
return make_unique<ExtensionStatement>(extension, parse_data->Copy());
|
|
156878
|
+
}
|
|
156879
|
+
|
|
156880
|
+
} // namespace duckdb
|
|
156881
|
+
|
|
156882
|
+
|
|
156815
156883
|
|
|
156816
156884
|
|
|
156817
156885
|
namespace duckdb {
|
|
@@ -168128,6 +168196,37 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {
|
|
|
168128
168196
|
|
|
168129
168197
|
|
|
168130
168198
|
|
|
168199
|
+
namespace duckdb {
|
|
168200
|
+
|
|
168201
|
+
BoundStatement Binder::Bind(ExtensionStatement &stmt) {
|
|
168202
|
+
BoundStatement result;
|
|
168203
|
+
|
|
168204
|
+
// perform the planning of the function
|
|
168205
|
+
D_ASSERT(stmt.extension.plan_function);
|
|
168206
|
+
auto parse_result = stmt.extension.plan_function(stmt.extension.parser_info.get(), context, move(stmt.parse_data));
|
|
168207
|
+
|
|
168208
|
+
properties.read_only = parse_result.read_only;
|
|
168209
|
+
properties.requires_valid_transaction = parse_result.requires_valid_transaction;
|
|
168210
|
+
properties.return_type = parse_result.return_type;
|
|
168211
|
+
|
|
168212
|
+
// create the plan as a scan of the given table function
|
|
168213
|
+
result.plan = BindTableFunction(parse_result.function, move(parse_result.parameters));
|
|
168214
|
+
D_ASSERT(result.plan->type == LogicalOperatorType::LOGICAL_GET);
|
|
168215
|
+
auto &get = (LogicalGet &)*result.plan;
|
|
168216
|
+
result.names = get.names;
|
|
168217
|
+
result.types = get.returned_types;
|
|
168218
|
+
get.column_ids.clear();
|
|
168219
|
+
for (idx_t i = 0; i < get.returned_types.size(); i++) {
|
|
168220
|
+
get.column_ids.push_back(i);
|
|
168221
|
+
}
|
|
168222
|
+
return result;
|
|
168223
|
+
}
|
|
168224
|
+
|
|
168225
|
+
} // namespace duckdb
|
|
168226
|
+
|
|
168227
|
+
|
|
168228
|
+
|
|
168229
|
+
|
|
168131
168230
|
|
|
168132
168231
|
|
|
168133
168232
|
//===----------------------------------------------------------------------===//
|
|
@@ -169748,9 +169847,60 @@ bool Binder::BindTableFunctionParameters(TableFunctionCatalogEntry &table_functi
|
|
|
169748
169847
|
return true;
|
|
169749
169848
|
}
|
|
169750
169849
|
|
|
169850
|
+
unique_ptr<LogicalOperator>
|
|
169851
|
+
Binder::BindTableFunctionInternal(TableFunction &table_function, const string &function_name, vector<Value> parameters,
|
|
169852
|
+
named_parameter_map_t named_parameters, vector<LogicalType> input_table_types,
|
|
169853
|
+
vector<string> input_table_names, const vector<string> &column_name_alias,
|
|
169854
|
+
unique_ptr<ExternalDependency> external_dependency) {
|
|
169855
|
+
auto bind_index = GenerateTableIndex();
|
|
169856
|
+
// perform the binding
|
|
169857
|
+
unique_ptr<FunctionData> bind_data;
|
|
169858
|
+
vector<LogicalType> return_types;
|
|
169859
|
+
vector<string> return_names;
|
|
169860
|
+
if (table_function.bind) {
|
|
169861
|
+
TableFunctionBindInput bind_input(parameters, named_parameters, input_table_types, input_table_names,
|
|
169862
|
+
table_function.function_info.get());
|
|
169863
|
+
bind_data = table_function.bind(context, bind_input, return_types, return_names);
|
|
169864
|
+
if (table_function.name == "pandas_scan" || table_function.name == "arrow_scan") {
|
|
169865
|
+
auto arrow_bind = (PyTableFunctionData *)bind_data.get();
|
|
169866
|
+
arrow_bind->external_dependency = move(external_dependency);
|
|
169867
|
+
}
|
|
169868
|
+
}
|
|
169869
|
+
if (return_types.size() != return_names.size()) {
|
|
169870
|
+
throw InternalException(
|
|
169871
|
+
"Failed to bind \"%s\": Table function return_types and return_names must be of the same size",
|
|
169872
|
+
table_function.name);
|
|
169873
|
+
}
|
|
169874
|
+
if (return_types.empty()) {
|
|
169875
|
+
throw InternalException("Failed to bind \"%s\": Table function must return at least one column",
|
|
169876
|
+
table_function.name);
|
|
169877
|
+
}
|
|
169878
|
+
// overwrite the names with any supplied aliases
|
|
169879
|
+
for (idx_t i = 0; i < column_name_alias.size() && i < return_names.size(); i++) {
|
|
169880
|
+
return_names[i] = column_name_alias[i];
|
|
169881
|
+
}
|
|
169882
|
+
for (idx_t i = 0; i < return_names.size(); i++) {
|
|
169883
|
+
if (return_names[i].empty()) {
|
|
169884
|
+
return_names[i] = "C" + to_string(i);
|
|
169885
|
+
}
|
|
169886
|
+
}
|
|
169887
|
+
auto get = make_unique<LogicalGet>(bind_index, table_function, move(bind_data), return_types, return_names);
|
|
169888
|
+
// now add the table function to the bind context so its columns can be bound
|
|
169889
|
+
bind_context.AddTableFunction(bind_index, function_name, return_names, return_types, *get);
|
|
169890
|
+
return move(get);
|
|
169891
|
+
}
|
|
169892
|
+
|
|
169893
|
+
unique_ptr<LogicalOperator> Binder::BindTableFunction(TableFunction &function, vector<Value> parameters) {
|
|
169894
|
+
named_parameter_map_t named_parameters;
|
|
169895
|
+
vector<LogicalType> input_table_types;
|
|
169896
|
+
vector<string> input_table_names;
|
|
169897
|
+
vector<string> column_name_aliases;
|
|
169898
|
+
return BindTableFunctionInternal(function, function.name, move(parameters), move(named_parameters),
|
|
169899
|
+
move(input_table_types), move(input_table_names), column_name_aliases, nullptr);
|
|
169900
|
+
}
|
|
169901
|
+
|
|
169751
169902
|
unique_ptr<BoundTableRef> Binder::Bind(TableFunctionRef &ref) {
|
|
169752
169903
|
QueryErrorContext error_context(root_statement, ref.query_location);
|
|
169753
|
-
auto bind_index = GenerateTableIndex();
|
|
169754
169904
|
|
|
169755
169905
|
D_ASSERT(ref.function->type == ExpressionType::FUNCTION);
|
|
169756
169906
|
auto fexpr = (FunctionExpression *)ref.function.get();
|
|
@@ -169824,42 +169974,9 @@ unique_ptr<BoundTableRef> Binder::Bind(TableFunctionRef &ref) {
|
|
|
169824
169974
|
input_table_types = subquery->subquery->types;
|
|
169825
169975
|
input_table_names = subquery->subquery->names;
|
|
169826
169976
|
}
|
|
169827
|
-
|
|
169828
|
-
|
|
169829
|
-
|
|
169830
|
-
vector<LogicalType> return_types;
|
|
169831
|
-
vector<string> return_names;
|
|
169832
|
-
if (table_function.bind) {
|
|
169833
|
-
TableFunctionBindInput bind_input(parameters, named_parameters, input_table_types, input_table_names,
|
|
169834
|
-
table_function.function_info.get());
|
|
169835
|
-
bind_data = table_function.bind(context, bind_input, return_types, return_names);
|
|
169836
|
-
if (table_function.name == "pandas_scan" || table_function.name == "arrow_scan") {
|
|
169837
|
-
auto arrow_bind = (PyTableFunctionData *)bind_data.get();
|
|
169838
|
-
arrow_bind->external_dependency = move(ref.external_dependency);
|
|
169839
|
-
}
|
|
169840
|
-
}
|
|
169841
|
-
if (return_types.size() != return_names.size()) {
|
|
169842
|
-
throw InternalException(
|
|
169843
|
-
"Failed to bind \"%s\": Table function return_types and return_names must be of the same size",
|
|
169844
|
-
table_function.name);
|
|
169845
|
-
}
|
|
169846
|
-
if (return_types.empty()) {
|
|
169847
|
-
throw InternalException("Failed to bind \"%s\": Table function must return at least one column",
|
|
169848
|
-
table_function.name);
|
|
169849
|
-
}
|
|
169850
|
-
// overwrite the names with any supplied aliases
|
|
169851
|
-
for (idx_t i = 0; i < ref.column_name_alias.size() && i < return_names.size(); i++) {
|
|
169852
|
-
return_names[i] = ref.column_name_alias[i];
|
|
169853
|
-
}
|
|
169854
|
-
for (idx_t i = 0; i < return_names.size(); i++) {
|
|
169855
|
-
if (return_names[i].empty()) {
|
|
169856
|
-
return_names[i] = "C" + to_string(i);
|
|
169857
|
-
}
|
|
169858
|
-
}
|
|
169859
|
-
auto get = make_unique<LogicalGet>(bind_index, table_function, move(bind_data), return_types, return_names);
|
|
169860
|
-
// now add the table function to the bind context so its columns can be bound
|
|
169861
|
-
bind_context.AddTableFunction(bind_index, ref.alias.empty() ? fexpr->function_name : ref.alias, return_names,
|
|
169862
|
-
return_types, *get);
|
|
169977
|
+
auto get = BindTableFunctionInternal(table_function, ref.alias.empty() ? fexpr->function_name : ref.alias,
|
|
169978
|
+
move(parameters), move(named_parameters), move(input_table_types),
|
|
169979
|
+
move(input_table_names), ref.column_name_alias, move(ref.external_dependency));
|
|
169863
169980
|
if (subquery) {
|
|
169864
169981
|
get->children.push_back(Binder::CreatePlan(*subquery));
|
|
169865
169982
|
}
|
|
@@ -170288,6 +170405,8 @@ BoundStatement Binder::Bind(SQLStatement &statement) {
|
|
|
170288
170405
|
return Bind((SetStatement &)statement);
|
|
170289
170406
|
case StatementType::LOAD_STATEMENT:
|
|
170290
170407
|
return Bind((LoadStatement &)statement);
|
|
170408
|
+
case StatementType::EXTENSION_STATEMENT:
|
|
170409
|
+
return Bind((ExtensionStatement &)statement);
|
|
170291
170410
|
default: // LCOV_EXCL_START
|
|
170292
170411
|
throw NotImplementedException("Unimplemented statement type \"%s\" for Bind",
|
|
170293
170412
|
StatementTypeToString(statement.type));
|
|
@@ -174225,6 +174344,7 @@ void Planner::CreatePlan(unique_ptr<SQLStatement> statement) {
|
|
|
174225
174344
|
case StatementType::SHOW_STATEMENT:
|
|
174226
174345
|
case StatementType::SET_STATEMENT:
|
|
174227
174346
|
case StatementType::LOAD_STATEMENT:
|
|
174347
|
+
case StatementType::EXTENSION_STATEMENT:
|
|
174228
174348
|
CreatePlan(*statement);
|
|
174229
174349
|
break;
|
|
174230
174350
|
case StatementType::EXECUTE_STATEMENT:
|
package/src/duckdb.hpp
CHANGED
|
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
13
|
#define DUCKDB_AMALGAMATION_EXTENDED 1
|
|
14
|
-
#define DUCKDB_SOURCE_ID "
|
|
15
|
-
#define DUCKDB_VERSION "v0.4.1-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "b5a0b2595"
|
|
15
|
+
#define DUCKDB_VERSION "v0.4.1-dev188"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -9935,7 +9935,8 @@ enum class StatementType : uint8_t {
|
|
|
9935
9935
|
CALL_STATEMENT, // CALL statement type
|
|
9936
9936
|
SET_STATEMENT, // SET statement type
|
|
9937
9937
|
LOAD_STATEMENT, // LOAD statement type
|
|
9938
|
-
RELATION_STATEMENT
|
|
9938
|
+
RELATION_STATEMENT,
|
|
9939
|
+
EXTENSION_STATEMENT
|
|
9939
9940
|
};
|
|
9940
9941
|
|
|
9941
9942
|
string StatementTypeToString(StatementType type);
|
|
@@ -13127,6 +13128,7 @@ class CopyStatement;
|
|
|
13127
13128
|
class CreateStatement;
|
|
13128
13129
|
class DeleteStatement;
|
|
13129
13130
|
class DropStatement;
|
|
13131
|
+
class ExtensionStatement;
|
|
13130
13132
|
class InsertStatement;
|
|
13131
13133
|
class SelectStatement;
|
|
13132
13134
|
class TransactionStatement;
|
|
@@ -14036,6 +14038,7 @@ private:
|
|
|
14036
14038
|
BoundStatement Bind(ShowStatement &stmt);
|
|
14037
14039
|
BoundStatement Bind(CallStatement &stmt);
|
|
14038
14040
|
BoundStatement Bind(ExportStatement &stmt);
|
|
14041
|
+
BoundStatement Bind(ExtensionStatement &stmt);
|
|
14039
14042
|
BoundStatement Bind(SetStatement &stmt);
|
|
14040
14043
|
BoundStatement Bind(LoadStatement &stmt);
|
|
14041
14044
|
BoundStatement BindReturning(vector<unique_ptr<ParsedExpression>> returning_list, TableCatalogEntry *table,
|
|
@@ -14069,6 +14072,12 @@ private:
|
|
|
14069
14072
|
unique_ptr<BoundSubqueryRef> &subquery, string &error);
|
|
14070
14073
|
bool BindTableInTableOutFunction(vector<unique_ptr<ParsedExpression>> &expressions,
|
|
14071
14074
|
unique_ptr<BoundSubqueryRef> &subquery, string &error);
|
|
14075
|
+
unique_ptr<LogicalOperator> BindTableFunction(TableFunction &function, vector<Value> parameters);
|
|
14076
|
+
unique_ptr<LogicalOperator>
|
|
14077
|
+
BindTableFunctionInternal(TableFunction &table_function, const string &function_name, vector<Value> parameters,
|
|
14078
|
+
named_parameter_map_t named_parameters, vector<LogicalType> input_table_types,
|
|
14079
|
+
vector<string> input_table_names, const vector<string> &column_name_alias,
|
|
14080
|
+
unique_ptr<ExternalDependency> external_dependency);
|
|
14072
14081
|
|
|
14073
14082
|
unique_ptr<LogicalOperator> CreatePlan(BoundBaseTableRef &ref);
|
|
14074
14083
|
unique_ptr<LogicalOperator> CreatePlan(BoundCrossProductRef &ref);
|
|
@@ -18568,6 +18577,100 @@ enum class SetScope : uint8_t {
|
|
|
18568
18577
|
|
|
18569
18578
|
} // namespace duckdb
|
|
18570
18579
|
|
|
18580
|
+
//===----------------------------------------------------------------------===//
|
|
18581
|
+
// DuckDB
|
|
18582
|
+
//
|
|
18583
|
+
// duckdb/parser/parser_extension.hpp
|
|
18584
|
+
//
|
|
18585
|
+
//
|
|
18586
|
+
//===----------------------------------------------------------------------===//
|
|
18587
|
+
|
|
18588
|
+
|
|
18589
|
+
|
|
18590
|
+
|
|
18591
|
+
|
|
18592
|
+
|
|
18593
|
+
|
|
18594
|
+
namespace duckdb {
|
|
18595
|
+
|
|
18596
|
+
//! The ParserExtensionInfo holds static information relevant to the parser extension
|
|
18597
|
+
//! It is made available in the parse_function, and will be kept alive as long as the database system is kept alive
|
|
18598
|
+
struct ParserExtensionInfo {
|
|
18599
|
+
DUCKDB_API virtual ~ParserExtensionInfo() {
|
|
18600
|
+
}
|
|
18601
|
+
};
|
|
18602
|
+
|
|
18603
|
+
//===--------------------------------------------------------------------===//
|
|
18604
|
+
// Parse
|
|
18605
|
+
//===--------------------------------------------------------------------===//
|
|
18606
|
+
enum class ParserExtensionResultType : uint8_t { PARSE_SUCCESSFUL, DISPLAY_ORIGINAL_ERROR, DISPLAY_EXTENSION_ERROR };
|
|
18607
|
+
|
|
18608
|
+
//! The ParserExtensionParseData holds the result of a successful parse step
|
|
18609
|
+
//! It will be passed along to the subsequent plan function
|
|
18610
|
+
struct ParserExtensionParseData {
|
|
18611
|
+
DUCKDB_API virtual ~ParserExtensionParseData() {
|
|
18612
|
+
}
|
|
18613
|
+
|
|
18614
|
+
virtual unique_ptr<ParserExtensionParseData> Copy() const = 0;
|
|
18615
|
+
};
|
|
18616
|
+
|
|
18617
|
+
struct ParserExtensionParseResult {
|
|
18618
|
+
ParserExtensionParseResult() : type(ParserExtensionResultType::DISPLAY_ORIGINAL_ERROR) {
|
|
18619
|
+
}
|
|
18620
|
+
ParserExtensionParseResult(string error_p)
|
|
18621
|
+
: type(ParserExtensionResultType::DISPLAY_EXTENSION_ERROR), error(move(error_p)) {
|
|
18622
|
+
}
|
|
18623
|
+
ParserExtensionParseResult(unique_ptr<ParserExtensionParseData> parse_data_p)
|
|
18624
|
+
: type(ParserExtensionResultType::PARSE_SUCCESSFUL), parse_data(move(parse_data_p)) {
|
|
18625
|
+
}
|
|
18626
|
+
|
|
18627
|
+
//! Whether or not parsing was successful
|
|
18628
|
+
ParserExtensionResultType type;
|
|
18629
|
+
//! The parse data (if successful)
|
|
18630
|
+
unique_ptr<ParserExtensionParseData> parse_data;
|
|
18631
|
+
//! The error message (if unsuccessful)
|
|
18632
|
+
string error;
|
|
18633
|
+
};
|
|
18634
|
+
|
|
18635
|
+
typedef ParserExtensionParseResult (*parse_function_t)(ParserExtensionInfo *info, const string &query);
|
|
18636
|
+
//===--------------------------------------------------------------------===//
|
|
18637
|
+
// Plan
|
|
18638
|
+
//===--------------------------------------------------------------------===//
|
|
18639
|
+
struct ParserExtensionPlanResult {
|
|
18640
|
+
//! The table function to execute
|
|
18641
|
+
TableFunction function;
|
|
18642
|
+
//! Parameters to the function
|
|
18643
|
+
vector<Value> parameters;
|
|
18644
|
+
//! Whether or not the statement is read_only (i.e. can be executed in a read_only database)
|
|
18645
|
+
bool read_only = false;
|
|
18646
|
+
//! Whether or not the statement requires a valid transaction to be executed
|
|
18647
|
+
bool requires_valid_transaction = true;
|
|
18648
|
+
//! What type of result set the statement returns
|
|
18649
|
+
StatementReturnType return_type = StatementReturnType::NOTHING;
|
|
18650
|
+
};
|
|
18651
|
+
|
|
18652
|
+
typedef ParserExtensionPlanResult (*plan_function_t)(ParserExtensionInfo *info, ClientContext &context,
|
|
18653
|
+
unique_ptr<ParserExtensionParseData> parse_data);
|
|
18654
|
+
|
|
18655
|
+
//===--------------------------------------------------------------------===//
|
|
18656
|
+
// ParserExtension
|
|
18657
|
+
//===--------------------------------------------------------------------===//
|
|
18658
|
+
class ParserExtension {
|
|
18659
|
+
public:
|
|
18660
|
+
//! The parse function of the parser extension.
|
|
18661
|
+
//! Takes a query string as input and returns ParserExtensionParseData (on success) or an error
|
|
18662
|
+
parse_function_t parse_function;
|
|
18663
|
+
|
|
18664
|
+
//! The plan function of the parser extension
|
|
18665
|
+
//! Takes as input the result of the parse_function, and outputs various properties of the resulting plan
|
|
18666
|
+
plan_function_t plan_function;
|
|
18667
|
+
|
|
18668
|
+
//! Additional parser info passed to the parse function
|
|
18669
|
+
shared_ptr<ParserExtensionInfo> parser_info;
|
|
18670
|
+
};
|
|
18671
|
+
|
|
18672
|
+
} // namespace duckdb
|
|
18673
|
+
|
|
18571
18674
|
|
|
18572
18675
|
namespace duckdb {
|
|
18573
18676
|
class ClientContext;
|
|
@@ -18673,6 +18776,8 @@ public:
|
|
|
18673
18776
|
WindowAggregationMode window_mode = WindowAggregationMode::WINDOW;
|
|
18674
18777
|
//! Whether or not preserving insertion order should be preserved
|
|
18675
18778
|
bool preserve_insertion_order = true;
|
|
18779
|
+
//! Extensions made to the parser
|
|
18780
|
+
vector<ParserExtension> parser_extensions;
|
|
18676
18781
|
|
|
18677
18782
|
//! Extra parameters that can be SET for loaded extensions
|
|
18678
18783
|
case_insensitive_map_t<ExtensionOption> extension_parameters;
|
|
@@ -21900,10 +22005,12 @@ struct PGList;
|
|
|
21900
22005
|
} // namespace duckdb_libpgquery
|
|
21901
22006
|
|
|
21902
22007
|
namespace duckdb {
|
|
22008
|
+
class ParserExtension;
|
|
21903
22009
|
|
|
21904
22010
|
struct ParserOptions {
|
|
21905
22011
|
bool preserve_identifier_case = true;
|
|
21906
22012
|
idx_t max_expression_depth = 1000;
|
|
22013
|
+
vector<ParserExtension> *extensions = nullptr;
|
|
21907
22014
|
};
|
|
21908
22015
|
|
|
21909
22016
|
//! The parser is responsible for parsing the query and converting it into a set
|