duckdb 0.3.2-dev281.0 → 0.3.2-dev296.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.3.2-dev281.0",
4
+ "version": "0.3.2-dev296.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -11086,42 +11086,53 @@ string LogicalOperatorToString(LogicalOperatorType type) {
11086
11086
 
11087
11087
 
11088
11088
 
11089
+
11089
11090
  namespace duckdb {
11090
11091
 
11092
+ struct DefaultOptimizerType {
11093
+ const char *name;
11094
+ OptimizerType type;
11095
+ };
11096
+
11097
+ static DefaultOptimizerType internal_optimizer_types[] = {
11098
+ {"expression_rewriter", OptimizerType::EXPRESSION_REWRITER},
11099
+ {"filter_pullup", OptimizerType::FILTER_PULLUP},
11100
+ {"filter_pushdown", OptimizerType::FILTER_PUSHDOWN},
11101
+ {"regex_range", OptimizerType::REGEX_RANGE},
11102
+ {"in_clause", OptimizerType::IN_CLAUSE},
11103
+ {"join_order", OptimizerType::JOIN_ORDER},
11104
+ {"deliminator", OptimizerType::DELIMINATOR},
11105
+ {"unused_columns", OptimizerType::UNUSED_COLUMNS},
11106
+ {"statistics_propagation", OptimizerType::STATISTICS_PROPAGATION},
11107
+ {"common_subexpressions", OptimizerType::COMMON_SUBEXPRESSIONS},
11108
+ {"common_aggregate", OptimizerType::COMMON_AGGREGATE},
11109
+ {"column_lifetime", OptimizerType::COLUMN_LIFETIME},
11110
+ {"top_n", OptimizerType::TOP_N},
11111
+ {"reorder_filter", OptimizerType::REORDER_FILTER},
11112
+ {nullptr, OptimizerType::INVALID}};
11113
+
11091
11114
  string OptimizerTypeToString(OptimizerType type) {
11092
- switch (type) {
11093
- case OptimizerType::EXPRESSION_REWRITER:
11094
- return "expression_rewriter";
11095
- case OptimizerType::FILTER_PULLUP:
11096
- return "filter_pullup";
11097
- case OptimizerType::FILTER_PUSHDOWN:
11098
- return "filter_pushdown";
11099
- case OptimizerType::REGEX_RANGE:
11100
- return "regex_range";
11101
- case OptimizerType::IN_CLAUSE:
11102
- return "in_clause";
11103
- case OptimizerType::JOIN_ORDER:
11104
- return "join_order";
11105
- case OptimizerType::DELIMINATOR:
11106
- return "deliminator";
11107
- case OptimizerType::UNUSED_COLUMNS:
11108
- return "unused_columns";
11109
- case OptimizerType::STATISTICS_PROPAGATION:
11110
- return "statistics_propagation";
11111
- case OptimizerType::COMMON_SUBEXPRESSIONS:
11112
- return "common_subexpressions";
11113
- case OptimizerType::COMMON_AGGREGATE:
11114
- return "common_aggregate";
11115
- case OptimizerType::COLUMN_LIFETIME:
11116
- return "column_lifetime";
11117
- case OptimizerType::TOP_N:
11118
- return "top_n";
11119
- case OptimizerType::REORDER_FILTER:
11120
- return "reorder_filter";
11121
- case OptimizerType::INVALID: // LCOV_EXCL_START
11122
- break;
11115
+ for (idx_t i = 0; internal_optimizer_types[i].name; i++) {
11116
+ if (internal_optimizer_types[i].type == type) {
11117
+ return internal_optimizer_types[i].name;
11118
+ }
11123
11119
  }
11124
- return "INVALID"; // LCOV_EXCL_STOP
11120
+ throw InternalException("Invalid optimizer type");
11121
+ }
11122
+
11123
+ OptimizerType OptimizerTypeFromString(const string &str) {
11124
+ for (idx_t i = 0; internal_optimizer_types[i].name; i++) {
11125
+ if (internal_optimizer_types[i].name == str) {
11126
+ return internal_optimizer_types[i].type;
11127
+ }
11128
+ }
11129
+ // optimizer not found, construct candidate list
11130
+ vector<string> optimizer_names;
11131
+ for (idx_t i = 0; internal_optimizer_types[i].name; i++) {
11132
+ optimizer_names.emplace_back(internal_optimizer_types[i].name);
11133
+ }
11134
+ throw ParserException("Optimizer type \"%s\" not recognized\n%s", str,
11135
+ StringUtil::CandidatesErrorMessage(optimizer_names, str, "Candidate optimizers"));
11125
11136
  }
11126
11137
 
11127
11138
  } // namespace duckdb
@@ -32743,6 +32754,12 @@ string StringUtil::CandidatesMessage(const vector<string> &candidates, const str
32743
32754
  return result_str;
32744
32755
  }
32745
32756
 
32757
+ string StringUtil::CandidatesErrorMessage(const vector<string> &strings, const string &target,
32758
+ const string &message_prefix, idx_t n) {
32759
+ auto closest_strings = StringUtil::TopNLevenshtein(strings, target, n);
32760
+ return StringUtil::CandidatesMessage(closest_strings, message_prefix);
32761
+ }
32762
+
32746
32763
  } // namespace duckdb
32747
32764
  //===----------------------------------------------------------------------===//
32748
32765
  // DuckDB
@@ -57797,9 +57814,9 @@ void PhysicalSet::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSou
57797
57814
  for (auto &entry : config.extension_parameters) {
57798
57815
  potential_names.push_back(entry.first);
57799
57816
  }
57800
- auto closest_settings = StringUtil::TopNLevenshtein(potential_names, name);
57817
+
57801
57818
  throw CatalogException("unrecognized configuration parameter \"%s\"\n%s", name,
57802
- StringUtil::CandidatesMessage(closest_settings, "Did you mean"));
57819
+ StringUtil::CandidatesErrorMessage(potential_names, name, "Did you mean"));
57803
57820
  }
57804
57821
  //! it is!
57805
57822
  auto &extension_option = entry->second;
@@ -88766,6 +88783,7 @@ struct CurrvalFun {
88766
88783
 
88767
88784
 
88768
88785
 
88786
+
88769
88787
  namespace duckdb {
88770
88788
 
88771
88789
  struct NextvalBindData : public FunctionData {
@@ -88798,9 +88816,12 @@ struct NextSequenceValueOperator {
88798
88816
  static int64_t Operation(Transaction &transaction, SequenceCatalogEntry *seq) {
88799
88817
  lock_guard<mutex> seqlock(seq->lock);
88800
88818
  int64_t result;
88819
+ result = seq->counter;
88820
+ bool overflow = !TryAddOperator::Operation(seq->counter, seq->increment, seq->counter);
88801
88821
  if (seq->cycle) {
88802
- result = seq->counter;
88803
- seq->counter += seq->increment;
88822
+ if (overflow) {
88823
+ throw SequenceException("overflow in sequence");
88824
+ }
88804
88825
  if (result < seq->min_value) {
88805
88826
  result = seq->max_value;
88806
88827
  seq->counter = seq->max_value + seq->increment;
@@ -88809,13 +88830,11 @@ struct NextSequenceValueOperator {
88809
88830
  seq->counter = seq->min_value + seq->increment;
88810
88831
  }
88811
88832
  } else {
88812
- result = seq->counter;
88813
- seq->counter += seq->increment;
88814
- if (result < seq->min_value) {
88833
+ if (result < seq->min_value || (overflow && seq->increment < 0)) {
88815
88834
  throw SequenceException("nextval: reached minimum value of sequence \"%s\" (%lld)", seq->name,
88816
88835
  seq->min_value);
88817
88836
  }
88818
- if (result > seq->max_value) {
88837
+ if (result > seq->max_value || overflow) {
88819
88838
  throw SequenceException("nextval: reached maximum value of sequence \"%s\" (%lld)", seq->name,
88820
88839
  seq->max_value);
88821
88840
  }
@@ -103322,6 +103341,14 @@ struct DefaultNullOrderSetting {
103322
103341
  static Value GetSetting(ClientContext &context);
103323
103342
  };
103324
103343
 
103344
+ struct DisabledOptimizersSetting {
103345
+ static constexpr const char *Name = "disabled_optimizers";
103346
+ static constexpr const char *Description = "DEBUG SETTING: disable a specific set of optimizers (comma separated)";
103347
+ static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
103348
+ static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
103349
+ static Value GetSetting(ClientContext &context);
103350
+ };
103351
+
103325
103352
  struct EnableExternalAccessSetting {
103326
103353
  static constexpr const char *Name = "enable_external_access";
103327
103354
  static constexpr const char *Description =
@@ -103498,6 +103525,7 @@ static ConfigurationOption internal_options[] = {DUCKDB_GLOBAL(AccessModeSetting
103498
103525
  DUCKDB_GLOBAL_LOCAL(DefaultCollationSetting),
103499
103526
  DUCKDB_GLOBAL(DefaultOrderSetting),
103500
103527
  DUCKDB_GLOBAL(DefaultNullOrderSetting),
103528
+ DUCKDB_GLOBAL(DisabledOptimizersSetting),
103501
103529
  DUCKDB_GLOBAL(EnableExternalAccessSetting),
103502
103530
  DUCKDB_GLOBAL(EnableObjectCacheSetting),
103503
103531
  DUCKDB_LOCAL(EnableProfilingSetting),
@@ -115955,6 +115983,35 @@ Value DefaultNullOrderSetting::GetSetting(ClientContext &context) {
115955
115983
  }
115956
115984
  }
115957
115985
 
115986
+ //===--------------------------------------------------------------------===//
115987
+ // Disabled Optimizer
115988
+ //===--------------------------------------------------------------------===//
115989
+ void DisabledOptimizersSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &input) {
115990
+ auto list = StringUtil::Split(input.ToString(), ",");
115991
+ set<OptimizerType> disabled_optimizers;
115992
+ for (auto &entry : list) {
115993
+ auto param = StringUtil::Lower(entry);
115994
+ StringUtil::Trim(param);
115995
+ if (param.empty()) {
115996
+ continue;
115997
+ }
115998
+ disabled_optimizers.insert(OptimizerTypeFromString(param));
115999
+ }
116000
+ config.disabled_optimizers = move(disabled_optimizers);
116001
+ }
116002
+
116003
+ Value DisabledOptimizersSetting::GetSetting(ClientContext &context) {
116004
+ auto &config = DBConfig::GetConfig(context);
116005
+ string result;
116006
+ for (auto &optimizer : config.disabled_optimizers) {
116007
+ if (!result.empty()) {
116008
+ result += ",";
116009
+ }
116010
+ result += OptimizerTypeToString(optimizer);
116011
+ }
116012
+ return Value(result);
116013
+ }
116014
+
115958
116015
  //===--------------------------------------------------------------------===//
115959
116016
  // Enable External Access
115960
116017
  //===--------------------------------------------------------------------===//
@@ -116723,6 +116780,9 @@ void CommonSubExpressionOptimizer::CountExpressions(Expression &expr, CSEReplace
116723
116780
  case ExpressionClass::BOUND_COLUMN_REF:
116724
116781
  case ExpressionClass::BOUND_CONSTANT:
116725
116782
  case ExpressionClass::BOUND_PARAMETER:
116783
+ // skip conjunctions and case, since short-circuiting might be incorrectly disabled otherwise
116784
+ case ExpressionClass::BOUND_CONJUNCTION:
116785
+ case ExpressionClass::BOUND_CASE:
116726
116786
  return;
116727
116787
  default:
116728
116788
  break;
@@ -116762,7 +116822,9 @@ void CommonSubExpressionOptimizer::PerformCSEReplacement(unique_ptr<Expression>
116762
116822
  return;
116763
116823
  }
116764
116824
  // check if this child is eligible for CSE elimination
116765
- if (state.expression_count.find(&expr) != state.expression_count.end()) {
116825
+ bool can_cse = expr.expression_class != ExpressionClass::BOUND_CONJUNCTION &&
116826
+ expr.expression_class != ExpressionClass::BOUND_CASE;
116827
+ if (can_cse && state.expression_count.find(&expr) != state.expression_count.end()) {
116766
116828
  auto &node = state.expression_count[&expr];
116767
116829
  if (node.count > 1) {
116768
116830
  // this expression occurs more than once! push it into the projection
@@ -123053,7 +123115,7 @@ unique_ptr<Expression> InClauseSimplificationRule::Apply(LogicalOperator &op, ve
123053
123115
  }
123054
123116
  //! Here we check if we can apply the expression on the constant side
123055
123117
  auto target_type = cast_expression->source_type();
123056
- if (!BoundCastExpression::CastIsInvertible(target_type, cast_expression->return_type)) {
123118
+ if (!BoundCastExpression::CastIsInvertible(cast_expression->return_type, target_type)) {
123057
123119
  return nullptr;
123058
123120
  }
123059
123121
  vector<unique_ptr<BoundConstantExpression>> cast_list;
package/src/duckdb.hpp CHANGED
@@ -10,8 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
10
10
 
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
- #define DUCKDB_SOURCE_ID "b56295f32"
14
- #define DUCKDB_VERSION "0.3.2-dev281"
13
+ #define DUCKDB_SOURCE_ID "5dc59692d"
14
+ #define DUCKDB_VERSION "0.3.2-dev296"
15
15
  //===----------------------------------------------------------------------===//
16
16
  // DuckDB
17
17
  //
@@ -9863,7 +9863,13 @@ public:
9863
9863
  idx_t threshold = 5);
9864
9864
  DUCKDB_API static string CandidatesMessage(const vector<string> &candidates,
9865
9865
  const string &candidate = "Candidate bindings");
9866
+
9867
+ //! Generate an error message in the form of "{message_prefix}: nearest_string, nearest_string2, ...
9868
+ //! Equivalent to calling TopNLevenshtein followed by CandidatesMessage
9869
+ DUCKDB_API static string CandidatesErrorMessage(const vector<string> &strings, const string &target,
9870
+ const string &message_prefix, idx_t n = 5);
9866
9871
  };
9872
+
9867
9873
  } // namespace duckdb
9868
9874
 
9869
9875
 
@@ -9976,6 +9982,7 @@ enum class OptimizerType : uint32_t {
9976
9982
  };
9977
9983
 
9978
9984
  string OptimizerTypeToString(OptimizerType type);
9985
+ OptimizerType OptimizerTypeFromString(const string &str);
9979
9986
 
9980
9987
  } // namespace duckdb
9981
9988