duckdb 0.7.2-dev1803.0 → 0.7.2-dev1898.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb/src/catalog/catalog.cpp +27 -27
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_set.cpp +27 -25
- package/src/duckdb/src/catalog/default/default_functions.cpp +6 -6
- package/src/duckdb/src/catalog/default/default_types.cpp +4 -4
- package/src/duckdb/src/catalog/default/default_views.cpp +4 -4
- package/src/duckdb/src/catalog/dependency_list.cpp +7 -6
- package/src/duckdb/src/catalog/dependency_manager.cpp +44 -38
- package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +11 -6
- package/src/duckdb/src/common/sort/sorted_block.cpp +9 -4
- package/src/duckdb/src/common/types/batched_data_collection.cpp +2 -1
- package/src/duckdb/src/common/types/column_data_allocator.cpp +1 -0
- package/src/duckdb/src/common/types/vector.cpp +2 -2
- package/src/duckdb/src/common/vector_operations/vector_copy.cpp +14 -11
- package/src/duckdb/src/execution/operator/aggregate/distinct_aggregate_data.cpp +1 -1
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +51 -50
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +4 -0
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +14 -13
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +20 -20
- package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +3 -3
- package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +172 -63
- package/src/duckdb/src/function/cast/cast_function_set.cpp +2 -1
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +15 -9
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +29 -29
- package/src/duckdb/src/function/scalar/string/damerau_levenshtein.cpp +106 -0
- package/src/duckdb/src/function/scalar/string/regexp.cpp +145 -28
- package/src/duckdb/src/function/scalar/string_functions.cpp +1 -0
- package/src/duckdb/src/function/table/checkpoint.cpp +4 -4
- package/src/duckdb/src/function/table/system/duckdb_columns.cpp +24 -24
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +7 -6
- package/src/duckdb/src/function/table/system/duckdb_databases.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +11 -11
- package/src/duckdb/src/function/table/system/pragma_database_size.cpp +1 -1
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +17 -18
- package/src/duckdb/src/function/table/table_scan.cpp +8 -11
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +9 -9
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry_map.hpp +38 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_transaction.hpp +4 -3
- package/src/duckdb/src/include/duckdb/catalog/default/default_functions.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/default/default_types.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/default/default_views.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/dependency.hpp +4 -5
- package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +4 -5
- package/src/duckdb/src/include/duckdb/catalog/dependency_manager.hpp +10 -9
- package/src/duckdb/src/include/duckdb/common/allocator.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/field_writer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/helper.hpp +9 -0
- package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +29 -6
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +6 -5
- package/src/duckdb/src/include/duckdb/common/serializer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/row_data_collection.hpp +1 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +5 -5
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +3 -2
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +5 -0
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +4 -3
- package/src/duckdb/src/include/duckdb/main/query_result.hpp +3 -2
- package/src/duckdb/src/include/duckdb/main/settings.hpp +19 -0
- package/src/duckdb/src/include/duckdb/optimizer/filter_combiner.hpp +7 -7
- package/src/duckdb/src/include/duckdb/optimizer/matcher/expression_matcher.hpp +11 -11
- package/src/duckdb/src/include/duckdb/optimizer/matcher/set_matcher.hpp +8 -8
- package/src/duckdb/src/include/duckdb/optimizer/rule/arithmetic_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/case_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/comparison_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/conjunction_simplification.hpp +2 -2
- package/src/duckdb/src/include/duckdb/optimizer/rule/constant_folding.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/date_part_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/distributivity.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/empty_needle_removal.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/enum_comparison.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/equal_or_null_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/in_clause_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/like_optimizations.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/move_constants.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/ordered_aggregate_optimizer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/regex_optimizations.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/base_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression_map.hpp +19 -6
- package/src/duckdb/src/include/duckdb/parser/expression_util.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parser.hpp +1 -7
- package/src/duckdb/src/include/duckdb/parser/parser_options.hpp +23 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +5 -3
- package/src/duckdb/src/include/duckdb/planner/expression.hpp +5 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/order_binder.hpp +3 -3
- package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +10 -2
- package/src/duckdb/src/include/duckdb/storage/buffer/buffer_pool.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +49 -126
- package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +5 -5
- package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +159 -0
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +1 -0
- package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +6 -5
- package/src/duckdb/src/main/client_context.cpp +5 -3
- package/src/duckdb/src/main/config.cpp +2 -0
- package/src/duckdb/src/main/database.cpp +2 -1
- package/src/duckdb/src/main/database_manager.cpp +4 -4
- package/src/duckdb/src/main/settings/settings.cpp +36 -0
- package/src/duckdb/src/optimizer/common_aggregate_optimizer.cpp +2 -2
- package/src/duckdb/src/optimizer/cse_optimizer.cpp +4 -4
- package/src/duckdb/src/optimizer/deliminator.cpp +13 -11
- package/src/duckdb/src/optimizer/expression_rewriter.cpp +2 -2
- package/src/duckdb/src/optimizer/filter_combiner.cpp +67 -65
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +1 -0
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +26 -25
- package/src/duckdb/src/optimizer/matcher/expression_matcher.cpp +23 -21
- package/src/duckdb/src/optimizer/rule/arithmetic_simplification.cpp +7 -6
- package/src/duckdb/src/optimizer/rule/case_simplification.cpp +2 -2
- package/src/duckdb/src/optimizer/rule/comparison_simplification.cpp +6 -7
- package/src/duckdb/src/optimizer/rule/conjunction_simplification.cpp +9 -8
- package/src/duckdb/src/optimizer/rule/constant_folding.cpp +7 -7
- package/src/duckdb/src/optimizer/rule/date_part_simplification.cpp +3 -3
- package/src/duckdb/src/optimizer/rule/distributivity.cpp +5 -5
- package/src/duckdb/src/optimizer/rule/empty_needle_removal.cpp +6 -6
- package/src/duckdb/src/optimizer/rule/enum_comparison.cpp +4 -4
- package/src/duckdb/src/optimizer/rule/equal_or_null_simplification.cpp +23 -26
- package/src/duckdb/src/optimizer/rule/in_clause_simplification_rule.cpp +2 -3
- package/src/duckdb/src/optimizer/rule/like_optimizations.cpp +3 -3
- package/src/duckdb/src/optimizer/rule/move_constants.cpp +6 -6
- package/src/duckdb/src/optimizer/rule/ordered_aggregate_optimizer.cpp +2 -2
- package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +3 -3
- package/src/duckdb/src/parser/expression_util.cpp +6 -6
- package/src/duckdb/src/parser/parser.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +7 -3
- package/src/duckdb/src/parser/transform/helpers/transform_groupby.cpp +3 -3
- package/src/duckdb/src/parser/transformer.cpp +6 -5
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +3 -3
- package/src/duckdb/src/planner/binder/query_node/bind_setop_node.cpp +5 -5
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder/order_binder.cpp +3 -3
- package/src/duckdb/src/storage/buffer/block_handle.cpp +3 -2
- package/src/duckdb/src/storage/buffer/block_manager.cpp +3 -1
- package/src/duckdb/src/storage/buffer/buffer_handle.cpp +1 -0
- package/src/duckdb/src/storage/buffer/buffer_pool_reservation.cpp +3 -0
- package/src/duckdb/src/storage/buffer_manager.cpp +35 -726
- package/src/duckdb/src/storage/checkpoint_manager.cpp +2 -2
- package/src/duckdb/src/storage/meta_block_reader.cpp +6 -5
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +801 -0
- package/src/duckdb/src/storage/wal_replay.cpp +2 -2
- package/src/duckdb/src/transaction/meta_transaction.cpp +13 -13
- package/src/duckdb/src/transaction/transaction.cpp +1 -1
- package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +949 -947
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +16431 -16385
- package/src/duckdb/third_party/libpg_query/src_backend_parser_scan.cpp +503 -493
- package/src/duckdb/ub_src_function_scalar_string.cpp +2 -0
- package/src/duckdb/ub_src_storage.cpp +2 -0
@@ -97,10 +97,11 @@ public:
|
|
97
97
|
};
|
98
98
|
|
99
99
|
struct BindCastInput {
|
100
|
-
DUCKDB_API BindCastInput(CastFunctionSet &function_set, BindCastInfo
|
100
|
+
DUCKDB_API BindCastInput(CastFunctionSet &function_set, optional_ptr<BindCastInfo> info,
|
101
|
+
optional_ptr<ClientContext> context);
|
101
102
|
|
102
103
|
CastFunctionSet &function_set;
|
103
|
-
BindCastInfo
|
104
|
+
optional_ptr<BindCastInfo> info;
|
104
105
|
optional_ptr<ClientContext> context;
|
105
106
|
|
106
107
|
public:
|
@@ -205,6 +205,10 @@ struct LevenshteinFun {
|
|
205
205
|
static void RegisterFunction(BuiltinFunctions &set);
|
206
206
|
};
|
207
207
|
|
208
|
+
struct DamerauLevenshteinFun {
|
209
|
+
static void RegisterFunction(BuiltinFunctions &set);
|
210
|
+
};
|
211
|
+
|
208
212
|
struct JaccardFun {
|
209
213
|
static void RegisterFunction(BuiltinFunctions &set);
|
210
214
|
};
|
@@ -77,6 +77,8 @@ struct ClientConfig {
|
|
77
77
|
//! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
|
78
78
|
//! elements)
|
79
79
|
idx_t perfect_ht_threshold = 12;
|
80
|
+
//! The maximum number of rows to accumulate before sorting ordered aggregates.
|
81
|
+
idx_t ordered_aggregate_threshold = (idx_t(1) << 18);
|
80
82
|
|
81
83
|
//! Callback to create a progress bar display
|
82
84
|
progress_bar_display_create_func_t display_create_func = nullptr;
|
@@ -90,6 +92,9 @@ struct ClientConfig {
|
|
90
92
|
//! The maximum amount of pivot columns
|
91
93
|
idx_t pivot_limit = 100000;
|
92
94
|
|
95
|
+
//! Whether or not the "/" division operator defaults to integer division or floating point division
|
96
|
+
bool integer_division = false;
|
97
|
+
|
93
98
|
//! Generic options
|
94
99
|
case_insensitive_map_t<Value> set_variables;
|
95
100
|
|
@@ -12,6 +12,7 @@
|
|
12
12
|
#include "duckdb/common/case_insensitive_map.hpp"
|
13
13
|
#include "duckdb/common/mutex.hpp"
|
14
14
|
#include "duckdb/common/atomic.hpp"
|
15
|
+
#include "duckdb/common/optional_ptr.hpp"
|
15
16
|
|
16
17
|
namespace duckdb {
|
17
18
|
class AttachedDatabase;
|
@@ -35,7 +36,7 @@ public:
|
|
35
36
|
|
36
37
|
void InitializeSystemCatalog();
|
37
38
|
//! Get an attached database with the given name
|
38
|
-
AttachedDatabase
|
39
|
+
optional_ptr<AttachedDatabase> GetDatabase(ClientContext &context, const string &name);
|
39
40
|
//! Add a new attached database to the database manager
|
40
41
|
void AddDatabase(ClientContext &context, unique_ptr<AttachedDatabase> db);
|
41
42
|
void DetachDatabase(ClientContext &context, const string &name, bool if_exists);
|
@@ -43,8 +44,8 @@ public:
|
|
43
44
|
Catalog &GetSystemCatalog();
|
44
45
|
static const string &GetDefaultDatabase(ClientContext &context);
|
45
46
|
|
46
|
-
AttachedDatabase
|
47
|
-
vector<AttachedDatabase
|
47
|
+
optional_ptr<AttachedDatabase> GetDatabaseFromPath(ClientContext &context, const string &path);
|
48
|
+
vector<optional_ptr<AttachedDatabase>> GetDatabases(ClientContext &context);
|
48
49
|
|
49
50
|
transaction_t GetNewQueryNumber() {
|
50
51
|
return current_query_number++;
|
@@ -131,7 +131,8 @@ private:
|
|
131
131
|
//! The row-based query result iterator. Invoking the
|
132
132
|
class QueryResultIterator {
|
133
133
|
public:
|
134
|
-
explicit QueryResultIterator(QueryResult
|
134
|
+
explicit QueryResultIterator(optional_ptr<QueryResult> result_p)
|
135
|
+
: current_row(*this, 0), result(result_p), base_row(0) {
|
135
136
|
if (result) {
|
136
137
|
chunk = shared_ptr<DataChunk>(result->Fetch().release());
|
137
138
|
if (!chunk) {
|
@@ -142,7 +143,7 @@ private:
|
|
142
143
|
|
143
144
|
QueryResultRow current_row;
|
144
145
|
shared_ptr<DataChunk> chunk;
|
145
|
-
QueryResult
|
146
|
+
optional_ptr<QueryResult> result;
|
146
147
|
idx_t base_row;
|
147
148
|
|
148
149
|
public:
|
@@ -65,6 +65,15 @@ struct DebugForceNoCrossProduct {
|
|
65
65
|
static Value GetSetting(ClientContext &context);
|
66
66
|
};
|
67
67
|
|
68
|
+
struct OrderedAggregateThreshold {
|
69
|
+
static constexpr const char *Name = "ordered_aggregate_threshold";
|
70
|
+
static constexpr const char *Description = "the number of rows to accumulate before sorting, used for tuning";
|
71
|
+
static constexpr const LogicalTypeId InputType = LogicalTypeId::UBIGINT;
|
72
|
+
static void SetLocal(ClientContext &context, const Value ¶meter);
|
73
|
+
static void ResetLocal(ClientContext &context);
|
74
|
+
static Value GetSetting(ClientContext &context);
|
75
|
+
};
|
76
|
+
|
68
77
|
struct DebugWindowMode {
|
69
78
|
static constexpr const char *Name = "debug_window_mode";
|
70
79
|
static constexpr const char *Description = "DEBUG SETTING: switch window mode to use";
|
@@ -270,6 +279,16 @@ struct HomeDirectorySetting {
|
|
270
279
|
static Value GetSetting(ClientContext &context);
|
271
280
|
};
|
272
281
|
|
282
|
+
struct IntegerDivisionSetting {
|
283
|
+
static constexpr const char *Name = "integer_division";
|
284
|
+
static constexpr const char *Description =
|
285
|
+
"Whether or not the / operator defaults to integer division, or to floating point division";
|
286
|
+
static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
|
287
|
+
static void SetLocal(ClientContext &context, const Value ¶meter);
|
288
|
+
static void ResetLocal(ClientContext &context);
|
289
|
+
static Value GetSetting(ClientContext &context);
|
290
|
+
};
|
291
|
+
|
273
292
|
struct LogQueryPathSetting {
|
274
293
|
static constexpr const char *Name = "log_query_path";
|
275
294
|
static constexpr const char *Description =
|
@@ -52,14 +52,14 @@ public:
|
|
52
52
|
// &pushed_filters);
|
53
53
|
|
54
54
|
private:
|
55
|
-
FilterResult AddFilter(Expression
|
56
|
-
FilterResult AddBoundComparisonFilter(Expression
|
55
|
+
FilterResult AddFilter(Expression &expr);
|
56
|
+
FilterResult AddBoundComparisonFilter(Expression &expr);
|
57
57
|
FilterResult AddTransitiveFilters(BoundComparisonExpression &comparison);
|
58
|
-
unique_ptr<Expression> FindTransitiveFilter(Expression
|
58
|
+
unique_ptr<Expression> FindTransitiveFilter(Expression &expr);
|
59
59
|
// unordered_map<idx_t, std::pair<Value *, Value *>>
|
60
60
|
// FindZonemapChecks(vector<idx_t> &column_ids, unordered_set<idx_t> ¬_constants, Expression *filter);
|
61
|
-
Expression
|
62
|
-
idx_t GetEquivalenceSet(Expression
|
61
|
+
Expression &GetNode(Expression &expr);
|
62
|
+
idx_t GetEquivalenceSet(Expression &expr);
|
63
63
|
FilterResult AddConstantComparison(vector<ExpressionValueInformation> &info_list, ExpressionValueInformation info);
|
64
64
|
//
|
65
65
|
// //! Functions used to push and generate OR Filters
|
@@ -97,9 +97,9 @@ private:
|
|
97
97
|
vector<unique_ptr<Expression>> remaining_filters;
|
98
98
|
|
99
99
|
expression_map_t<unique_ptr<Expression>> stored_expressions;
|
100
|
-
|
100
|
+
expression_map_t<idx_t> equivalence_set_map;
|
101
101
|
unordered_map<idx_t, vector<ExpressionValueInformation>> constant_values;
|
102
|
-
unordered_map<idx_t, vector<Expression
|
102
|
+
unordered_map<idx_t, vector<reference<Expression>>> equivalence_map;
|
103
103
|
idx_t set_index = 0;
|
104
104
|
//
|
105
105
|
// //! Structures used for OR Filters
|
@@ -27,7 +27,7 @@ public:
|
|
27
27
|
|
28
28
|
//! Checks if the given expression matches this ExpressionMatcher. If it does, the expression is appended to the
|
29
29
|
//! bindings list and true is returned. Otherwise, false is returned.
|
30
|
-
virtual bool Match(Expression
|
30
|
+
virtual bool Match(Expression &expr, vector<reference<Expression>> &bindings);
|
31
31
|
|
32
32
|
//! The ExpressionClass of the to-be-matched expression. ExpressionClass::INVALID for ANY.
|
33
33
|
ExpressionClass expr_class;
|
@@ -40,14 +40,14 @@ public:
|
|
40
40
|
//! The ExpressionEqualityMatcher matches on equality with another (given) expression
|
41
41
|
class ExpressionEqualityMatcher : public ExpressionMatcher {
|
42
42
|
public:
|
43
|
-
explicit ExpressionEqualityMatcher(Expression
|
43
|
+
explicit ExpressionEqualityMatcher(Expression &expr)
|
44
44
|
: ExpressionMatcher(ExpressionClass::INVALID), expression(expr) {
|
45
45
|
}
|
46
46
|
|
47
|
-
bool Match(Expression
|
47
|
+
bool Match(Expression &expr, vector<reference<Expression>> &bindings) override;
|
48
48
|
|
49
49
|
private:
|
50
|
-
Expression
|
50
|
+
const Expression &expression;
|
51
51
|
};
|
52
52
|
|
53
53
|
class ConstantExpressionMatcher : public ExpressionMatcher {
|
@@ -61,7 +61,7 @@ public:
|
|
61
61
|
CaseExpressionMatcher() : ExpressionMatcher(ExpressionClass::BOUND_CASE) {
|
62
62
|
}
|
63
63
|
|
64
|
-
bool Match(Expression
|
64
|
+
bool Match(Expression &expr_, vector<reference<Expression>> &bindings) override;
|
65
65
|
};
|
66
66
|
|
67
67
|
class ComparisonExpressionMatcher : public ExpressionMatcher {
|
@@ -74,7 +74,7 @@ public:
|
|
74
74
|
//! The set matcher matching policy to use
|
75
75
|
SetMatcher::Policy policy;
|
76
76
|
|
77
|
-
bool Match(Expression
|
77
|
+
bool Match(Expression &expr_, vector<reference<Expression>> &bindings) override;
|
78
78
|
};
|
79
79
|
|
80
80
|
class CastExpressionMatcher : public ExpressionMatcher {
|
@@ -84,7 +84,7 @@ public:
|
|
84
84
|
//! The matcher for the child expressions
|
85
85
|
unique_ptr<ExpressionMatcher> matcher;
|
86
86
|
|
87
|
-
bool Match(Expression
|
87
|
+
bool Match(Expression &expr_, vector<reference<Expression>> &bindings) override;
|
88
88
|
};
|
89
89
|
|
90
90
|
class InClauseExpressionMatcher : public ExpressionMatcher {
|
@@ -96,7 +96,7 @@ public:
|
|
96
96
|
//! The set matcher matching policy to use
|
97
97
|
SetMatcher::Policy policy;
|
98
98
|
|
99
|
-
bool Match(Expression
|
99
|
+
bool Match(Expression &expr_, vector<reference<Expression>> &bindings) override;
|
100
100
|
};
|
101
101
|
|
102
102
|
class ConjunctionExpressionMatcher : public ExpressionMatcher {
|
@@ -109,7 +109,7 @@ public:
|
|
109
109
|
//! The set matcher matching policy to use
|
110
110
|
SetMatcher::Policy policy;
|
111
111
|
|
112
|
-
bool Match(Expression
|
112
|
+
bool Match(Expression &expr_, vector<reference<Expression>> &bindings) override;
|
113
113
|
};
|
114
114
|
|
115
115
|
class FunctionExpressionMatcher : public ExpressionMatcher {
|
@@ -123,7 +123,7 @@ public:
|
|
123
123
|
//! The function name to match
|
124
124
|
unique_ptr<FunctionMatcher> function;
|
125
125
|
|
126
|
-
bool Match(Expression
|
126
|
+
bool Match(Expression &expr_, vector<reference<Expression>> &bindings) override;
|
127
127
|
};
|
128
128
|
|
129
129
|
//! The FoldableConstant matcher matches any expression that is foldable into a constant by the ExpressionExecutor (i.e.
|
@@ -133,7 +133,7 @@ public:
|
|
133
133
|
FoldableConstantMatcher() : ExpressionMatcher(ExpressionClass::INVALID) {
|
134
134
|
}
|
135
135
|
|
136
|
-
bool Match(Expression
|
136
|
+
bool Match(Expression &expr, vector<reference<Expression>> &bindings) override;
|
137
137
|
};
|
138
138
|
|
139
139
|
} // namespace duckdb
|
@@ -29,8 +29,8 @@ public:
|
|
29
29
|
|
30
30
|
/* The double {{}} in the intializer for excluded_entries is intentional, workaround for bug in gcc-4.9 */
|
31
31
|
template <class T, class MATCHER>
|
32
|
-
static bool MatchRecursive(vector<unique_ptr<MATCHER>> &matchers, vector<T
|
33
|
-
unordered_set<idx_t> excluded_entries, idx_t m_idx = 0) {
|
32
|
+
static bool MatchRecursive(vector<unique_ptr<MATCHER>> &matchers, vector<reference<T>> &entries,
|
33
|
+
vector<reference<T>> &bindings, unordered_set<idx_t> excluded_entries, idx_t m_idx = 0) {
|
34
34
|
if (m_idx == matchers.size()) {
|
35
35
|
// matched all matchers!
|
36
36
|
return true;
|
@@ -65,8 +65,8 @@ public:
|
|
65
65
|
}
|
66
66
|
|
67
67
|
template <class T, class MATCHER>
|
68
|
-
static bool Match(vector<unique_ptr<MATCHER>> &matchers, vector<T
|
69
|
-
Policy policy) {
|
68
|
+
static bool Match(vector<unique_ptr<MATCHER>> &matchers, vector<reference<T>> &entries,
|
69
|
+
vector<reference<T>> &bindings, Policy policy) {
|
70
70
|
if (policy == Policy::ORDERED) {
|
71
71
|
// ordered policy, count has to match
|
72
72
|
if (matchers.size() != entries.size()) {
|
@@ -100,12 +100,12 @@ public:
|
|
100
100
|
}
|
101
101
|
|
102
102
|
template <class T, class MATCHER>
|
103
|
-
static bool Match(vector<unique_ptr<MATCHER>> &matchers, vector<unique_ptr<T>> &entries,
|
104
|
-
Policy policy) {
|
103
|
+
static bool Match(vector<unique_ptr<MATCHER>> &matchers, vector<unique_ptr<T>> &entries,
|
104
|
+
vector<reference<T>> &bindings, Policy policy) {
|
105
105
|
// convert vector of unique_ptr to vector of normal pointers
|
106
|
-
vector<T
|
106
|
+
vector<reference<T>> ptr_entries;
|
107
107
|
for (auto &entry : entries) {
|
108
|
-
ptr_entries.push_back(entry
|
108
|
+
ptr_entries.push_back(*entry);
|
109
109
|
}
|
110
110
|
// then just call the normal match function
|
111
111
|
return Match(matchers, ptr_entries, bindings, policy);
|
@@ -18,7 +18,7 @@ class ArithmeticSimplificationRule : public Rule {
|
|
18
18
|
public:
|
19
19
|
explicit ArithmeticSimplificationRule(ExpressionRewriter &rewriter);
|
20
20
|
|
21
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
21
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
22
22
|
bool is_root) override;
|
23
23
|
};
|
24
24
|
|
@@ -17,7 +17,7 @@ class CaseSimplificationRule : public Rule {
|
|
17
17
|
public:
|
18
18
|
explicit CaseSimplificationRule(ExpressionRewriter &rewriter);
|
19
19
|
|
20
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
20
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
21
21
|
bool is_root) override;
|
22
22
|
};
|
23
23
|
|
@@ -17,7 +17,7 @@ class ComparisonSimplificationRule : public Rule {
|
|
17
17
|
public:
|
18
18
|
explicit ComparisonSimplificationRule(ExpressionRewriter &rewriter);
|
19
19
|
|
20
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
20
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
21
21
|
bool is_root) override;
|
22
22
|
};
|
23
23
|
|
@@ -17,10 +17,10 @@ class ConjunctionSimplificationRule : public Rule {
|
|
17
17
|
public:
|
18
18
|
explicit ConjunctionSimplificationRule(ExpressionRewriter &rewriter);
|
19
19
|
|
20
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
20
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
21
21
|
bool is_root) override;
|
22
22
|
|
23
|
-
unique_ptr<Expression> RemoveExpression(BoundConjunctionExpression &conj, Expression
|
23
|
+
unique_ptr<Expression> RemoveExpression(BoundConjunctionExpression &conj, const Expression &expr);
|
24
24
|
};
|
25
25
|
|
26
26
|
} // namespace duckdb
|
@@ -17,7 +17,7 @@ class ConstantFoldingRule : public Rule {
|
|
17
17
|
public:
|
18
18
|
explicit ConstantFoldingRule(ExpressionRewriter &rewriter);
|
19
19
|
|
20
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
20
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
21
21
|
bool is_root) override;
|
22
22
|
};
|
23
23
|
|
@@ -18,7 +18,7 @@ class DatePartSimplificationRule : public Rule {
|
|
18
18
|
public:
|
19
19
|
explicit DatePartSimplificationRule(ExpressionRewriter &rewriter);
|
20
20
|
|
21
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
21
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
22
22
|
bool is_root) override;
|
23
23
|
};
|
24
24
|
|
@@ -18,7 +18,7 @@ class DistributivityRule : public Rule {
|
|
18
18
|
public:
|
19
19
|
explicit DistributivityRule(ExpressionRewriter &rewriter);
|
20
20
|
|
21
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
21
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
22
22
|
bool is_root) override;
|
23
23
|
|
24
24
|
private:
|
@@ -18,7 +18,7 @@ class EmptyNeedleRemovalRule : public Rule {
|
|
18
18
|
public:
|
19
19
|
explicit EmptyNeedleRemovalRule(ExpressionRewriter &rewriter);
|
20
20
|
|
21
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
21
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
22
22
|
bool is_root) override;
|
23
23
|
};
|
24
24
|
|
@@ -17,7 +17,7 @@ class EnumComparisonRule : public Rule {
|
|
17
17
|
public:
|
18
18
|
explicit EnumComparisonRule(ExpressionRewriter &rewriter);
|
19
19
|
|
20
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
20
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
21
21
|
bool is_root) override;
|
22
22
|
};
|
23
23
|
|
@@ -18,7 +18,7 @@ class EqualOrNullSimplification : public Rule {
|
|
18
18
|
public:
|
19
19
|
explicit EqualOrNullSimplification(ExpressionRewriter &rewriter);
|
20
20
|
|
21
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
21
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
22
22
|
bool is_root) override;
|
23
23
|
};
|
24
24
|
|
@@ -17,7 +17,7 @@ class InClauseSimplificationRule : public Rule {
|
|
17
17
|
public:
|
18
18
|
explicit InClauseSimplificationRule(ExpressionRewriter &rewriter);
|
19
19
|
|
20
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
20
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
21
21
|
bool is_root) override;
|
22
22
|
};
|
23
23
|
|
@@ -18,7 +18,7 @@ class LikeOptimizationRule : public Rule {
|
|
18
18
|
public:
|
19
19
|
explicit LikeOptimizationRule(ExpressionRewriter &rewriter);
|
20
20
|
|
21
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
21
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
22
22
|
bool is_root) override;
|
23
23
|
|
24
24
|
unique_ptr<Expression> ApplyRule(BoundFunctionExpression &expr, ScalarFunction function, string pattern,
|
@@ -18,7 +18,7 @@ class MoveConstantsRule : public Rule {
|
|
18
18
|
public:
|
19
19
|
explicit MoveConstantsRule(ExpressionRewriter &rewriter);
|
20
20
|
|
21
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
21
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
22
22
|
bool is_root) override;
|
23
23
|
};
|
24
24
|
|
@@ -17,7 +17,7 @@ class OrderedAggregateOptimizer : public Rule {
|
|
17
17
|
public:
|
18
18
|
explicit OrderedAggregateOptimizer(ExpressionRewriter &rewriter);
|
19
19
|
|
20
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
20
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
21
21
|
bool is_root) override;
|
22
22
|
};
|
23
23
|
|
@@ -17,7 +17,7 @@ class RegexOptimizationRule : public Rule {
|
|
17
17
|
public:
|
18
18
|
explicit RegexOptimizationRule(ExpressionRewriter &rewriter);
|
19
19
|
|
20
|
-
unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
20
|
+
unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings, bool &changes_made,
|
21
21
|
bool is_root) override;
|
22
22
|
|
23
23
|
unique_ptr<Expression> ApplyRule(BoundFunctionExpression *expr, ScalarFunction function, string pattern,
|
@@ -29,8 +29,8 @@ public:
|
|
29
29
|
unique_ptr<ExpressionMatcher> root;
|
30
30
|
|
31
31
|
ClientContext &GetContext() const;
|
32
|
-
virtual unique_ptr<Expression> Apply(LogicalOperator &op, vector<Expression
|
33
|
-
bool is_root) = 0;
|
32
|
+
virtual unique_ptr<Expression> Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
33
|
+
bool &fixed_point, bool is_root) = 0;
|
34
34
|
};
|
35
35
|
|
36
36
|
} // namespace duckdb
|
@@ -73,7 +73,7 @@ public:
|
|
73
73
|
//! Returns true if this expression is equal to another expression
|
74
74
|
virtual bool Equals(const BaseExpression *other) const;
|
75
75
|
|
76
|
-
static bool Equals(BaseExpression *left, BaseExpression *right) {
|
76
|
+
static bool Equals(const BaseExpression *left, const BaseExpression *right) {
|
77
77
|
if (left == right) {
|
78
78
|
return true;
|
79
79
|
}
|
@@ -11,25 +11,38 @@
|
|
11
11
|
#include "duckdb/common/unordered_map.hpp"
|
12
12
|
#include "duckdb/common/unordered_set.hpp"
|
13
13
|
#include "duckdb/parser/base_expression.hpp"
|
14
|
+
#include "duckdb/parser/parsed_expression.hpp"
|
15
|
+
#include "duckdb/planner/expression.hpp"
|
14
16
|
|
15
17
|
namespace duckdb {
|
16
18
|
class Expression;
|
17
19
|
|
20
|
+
template <class T>
|
18
21
|
struct ExpressionHashFunction {
|
19
|
-
uint64_t operator()(const
|
20
|
-
return (uint64_t)expr
|
22
|
+
uint64_t operator()(const reference<T> &expr) const {
|
23
|
+
return (uint64_t)expr.get().Hash();
|
21
24
|
}
|
22
25
|
};
|
23
26
|
|
27
|
+
template <class T>
|
24
28
|
struct ExpressionEquality {
|
25
|
-
bool operator()(const
|
26
|
-
return a
|
29
|
+
bool operator()(const reference<T> &a, const reference<T> &b) const {
|
30
|
+
return a.get().Equals(&b.get());
|
27
31
|
}
|
28
32
|
};
|
29
33
|
|
30
34
|
template <typename T>
|
31
|
-
using expression_map_t =
|
35
|
+
using expression_map_t =
|
36
|
+
unordered_map<reference<Expression>, T, ExpressionHashFunction<Expression>, ExpressionEquality<Expression>>;
|
32
37
|
|
33
|
-
using expression_set_t =
|
38
|
+
using expression_set_t =
|
39
|
+
unordered_set<reference<Expression>, ExpressionHashFunction<Expression>, ExpressionEquality<Expression>>;
|
40
|
+
|
41
|
+
template <typename T>
|
42
|
+
using parsed_expression_map_t = unordered_map<reference<ParsedExpression>, T, ExpressionHashFunction<ParsedExpression>,
|
43
|
+
ExpressionEquality<ParsedExpression>>;
|
44
|
+
|
45
|
+
using parsed_expression_set_t = unordered_set<reference<ParsedExpression>, ExpressionHashFunction<ParsedExpression>,
|
46
|
+
ExpressionEquality<ParsedExpression>>;
|
34
47
|
|
35
48
|
} // namespace duckdb
|
@@ -28,7 +28,7 @@ public:
|
|
28
28
|
private:
|
29
29
|
template <class T>
|
30
30
|
static bool ExpressionListEquals(const vector<unique_ptr<T>> &a, const vector<unique_ptr<T>> &b);
|
31
|
-
template <class T>
|
31
|
+
template <class T, class EXPRESSION_MAP>
|
32
32
|
static bool ExpressionSetEquals(const vector<unique_ptr<T>> &a, const vector<unique_ptr<T>> &b);
|
33
33
|
};
|
34
34
|
|
@@ -13,6 +13,7 @@
|
|
13
13
|
#include "duckdb/parser/query_node.hpp"
|
14
14
|
#include "duckdb/parser/column_list.hpp"
|
15
15
|
#include "duckdb/parser/simplified_token.hpp"
|
16
|
+
#include "duckdb/parser/parser_options.hpp"
|
16
17
|
|
17
18
|
namespace duckdb_libpgquery {
|
18
19
|
struct PGNode;
|
@@ -20,13 +21,6 @@ struct PGList;
|
|
20
21
|
} // namespace duckdb_libpgquery
|
21
22
|
|
22
23
|
namespace duckdb {
|
23
|
-
class ParserExtension;
|
24
|
-
|
25
|
-
struct ParserOptions {
|
26
|
-
bool preserve_identifier_case = true;
|
27
|
-
idx_t max_expression_depth = 1000;
|
28
|
-
const vector<ParserExtension> *extensions = nullptr;
|
29
|
-
};
|
30
24
|
|
31
25
|
//! The parser is responsible for parsing the query and converting it into a set
|
32
26
|
//! of parsed statements. The parsed statements can then be converted into a
|
@@ -0,0 +1,23 @@
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
2
|
+
// DuckDB
|
3
|
+
//
|
4
|
+
// duckdb/parser/parser_options.hpp
|
5
|
+
//
|
6
|
+
//
|
7
|
+
//===----------------------------------------------------------------------===//
|
8
|
+
|
9
|
+
#pragma once
|
10
|
+
|
11
|
+
#include "duckdb/common/common.hpp"
|
12
|
+
|
13
|
+
namespace duckdb {
|
14
|
+
class ParserExtension;
|
15
|
+
|
16
|
+
struct ParserOptions {
|
17
|
+
bool preserve_identifier_case = true;
|
18
|
+
bool integer_division = false;
|
19
|
+
idx_t max_expression_depth = 1000;
|
20
|
+
const vector<ParserExtension> *extensions = nullptr;
|
21
|
+
};
|
22
|
+
|
23
|
+
} // namespace duckdb
|
@@ -33,6 +33,7 @@ struct CommonTableExpressionInfo;
|
|
33
33
|
struct GroupingExpressionMap;
|
34
34
|
class OnConflictInfo;
|
35
35
|
class UpdateSetInfo;
|
36
|
+
struct ParserOptions;
|
36
37
|
struct PivotColumn;
|
37
38
|
|
38
39
|
//! The transformer class is responsible for transforming the internal Postgres
|
@@ -47,7 +48,7 @@ class Transformer {
|
|
47
48
|
};
|
48
49
|
|
49
50
|
public:
|
50
|
-
explicit Transformer(
|
51
|
+
explicit Transformer(ParserOptions &options);
|
51
52
|
explicit Transformer(Transformer *parent);
|
52
53
|
~Transformer();
|
53
54
|
|
@@ -61,7 +62,8 @@ public:
|
|
61
62
|
|
62
63
|
private:
|
63
64
|
Transformer *parent;
|
64
|
-
|
65
|
+
//! Parser options
|
66
|
+
ParserOptions &options;
|
65
67
|
//! The current prepared statement parameter index
|
66
68
|
idx_t prepared_statement_parameter_index = 0;
|
67
69
|
//! Map from named parameter to parameter index;
|
@@ -292,7 +294,7 @@ private:
|
|
292
294
|
CommonTableExpressionInfo &info);
|
293
295
|
|
294
296
|
unique_ptr<ParsedExpression> TransformUnaryOperator(const string &op, unique_ptr<ParsedExpression> child);
|
295
|
-
unique_ptr<ParsedExpression> TransformBinaryOperator(
|
297
|
+
unique_ptr<ParsedExpression> TransformBinaryOperator(string op, unique_ptr<ParsedExpression> left,
|
296
298
|
unique_ptr<ParsedExpression> right);
|
297
299
|
//===--------------------------------------------------------------------===//
|
298
300
|
// TableRef transform
|
@@ -48,8 +48,11 @@ public:
|
|
48
48
|
return return_type == ((Expression *)other)->return_type;
|
49
49
|
}
|
50
50
|
|
51
|
-
static bool Equals(Expression *left, Expression *right) {
|
52
|
-
return BaseExpression::Equals((BaseExpression *)left, (BaseExpression *)right);
|
51
|
+
static bool Equals(const Expression *left, const Expression *right) {
|
52
|
+
return BaseExpression::Equals((const BaseExpression *)left, (const BaseExpression *)right);
|
53
|
+
}
|
54
|
+
static bool Equals(const Expression &left, const Expression &right) {
|
55
|
+
return left.Equals(&right);
|
53
56
|
}
|
54
57
|
//! Create a copy of this expression
|
55
58
|
virtual unique_ptr<Expression> Copy() = 0;
|