duckdb 0.4.1-dev368.0 → 0.4.1-dev396.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/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 "40e47cd36"
15
- #define DUCKDB_VERSION "v0.4.1-dev368"
14
+ #define DUCKDB_SOURCE_ID "8c2ffa6e1"
15
+ #define DUCKDB_VERSION "v0.4.1-dev396"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -1060,6 +1060,8 @@ struct LogicalType {
1060
1060
 
1061
1061
  DUCKDB_API void Verify() const;
1062
1062
 
1063
+ DUCKDB_API bool IsValid() const;
1064
+
1063
1065
  private:
1064
1066
  LogicalTypeId id_;
1065
1067
  PhysicalType physical_type_;
@@ -1364,9 +1366,11 @@ enum class ExceptionType {
1364
1366
  FATAL = 30, // Fatal exception: fatal exceptions are non-recoverable, and render the entire DB in an unusable state
1365
1367
  INTERNAL =
1366
1368
  31, // Internal exception: exception that indicates something went wrong internally (i.e. bug in the code base)
1367
- INVALID_INPUT = 32, // Input or arguments error
1368
- OUT_OF_MEMORY = 33, // out of memory
1369
- PERMISSION = 34 // insufficient permissions
1369
+ INVALID_INPUT = 32, // Input or arguments error
1370
+ OUT_OF_MEMORY = 33, // out of memory
1371
+ PERMISSION = 34, // insufficient permissions
1372
+ PARAMETER_NOT_RESOLVED = 35, // parameter types could not be resolved
1373
+ PARAMETER_NOT_ALLOWED = 36 // parameter types not allowed
1370
1374
  };
1371
1375
 
1372
1376
  class Exception : public std::exception {
@@ -1607,6 +1611,24 @@ public:
1607
1611
  DUCKDB_API ValueOutOfRangeException(const PhysicalType varType, const idx_t length);
1608
1612
  };
1609
1613
 
1614
+ class ParameterNotAllowedException : public StandardException {
1615
+ public:
1616
+ DUCKDB_API explicit ParameterNotAllowedException(const string &msg);
1617
+
1618
+ template <typename... Args>
1619
+ explicit ParameterNotAllowedException(const string &msg, Args... params)
1620
+ : ParameterNotAllowedException(ConstructMessage(msg, params...)) {
1621
+ }
1622
+ };
1623
+
1624
+ //! Special exception that should be thrown in the binder if parameter types could not be resolved
1625
+ //! This will cause prepared statements to be forcibly rebound with the actual parameter values
1626
+ //! This exception is fatal if thrown outside of the binder (i.e. it should never be thrown outside of the binder)
1627
+ class ParameterNotResolvedException : public Exception {
1628
+ public:
1629
+ DUCKDB_API explicit ParameterNotResolvedException();
1630
+ };
1631
+
1610
1632
  } // namespace duckdb
1611
1633
 
1612
1634
 
@@ -6676,14 +6698,11 @@ public:
6676
6698
  //! Bind a scalar function from the set of functions and input arguments. Returns the index of the chosen function,
6677
6699
  //! returns DConstants::INVALID_INDEX and sets error if none could be found
6678
6700
  DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
6679
- vector<LogicalType> &arguments, string &error, bool &cast_parameters);
6701
+ vector<LogicalType> &arguments, string &error);
6680
6702
  DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
6681
- vector<unique_ptr<Expression>> &arguments, string &error,
6682
- bool &cast_parameters);
6703
+ vector<unique_ptr<Expression>> &arguments, string &error);
6683
6704
  //! Bind an aggregate function from the set of functions and input arguments. Returns the index of the chosen
6684
6705
  //! function, returns DConstants::INVALID_INDEX and sets error if none could be found
6685
- DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
6686
- vector<LogicalType> &arguments, string &error, bool &cast_parameters);
6687
6706
  DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
6688
6707
  vector<LogicalType> &arguments, string &error);
6689
6708
  DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
@@ -6751,8 +6770,7 @@ public:
6751
6770
  DUCKDB_API hash_t Hash() const;
6752
6771
 
6753
6772
  //! Cast a set of expressions to the arguments of this function
6754
- DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children,
6755
- bool cast_parameter_expressions = true);
6773
+ DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children);
6756
6774
 
6757
6775
  DUCKDB_API string ToString() override;
6758
6776
  };
@@ -7717,9 +7735,10 @@ public:
7717
7735
  vector<unique_ptr<Expression>> children, string &error,
7718
7736
  bool is_operator = false, Binder *binder = nullptr);
7719
7737
 
7720
- DUCKDB_API static unique_ptr<BoundFunctionExpression>
7721
- BindScalarFunction(ClientContext &context, ScalarFunction bound_function, vector<unique_ptr<Expression>> children,
7722
- bool is_operator = false, bool cast_parameters = true);
7738
+ DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
7739
+ ScalarFunction bound_function,
7740
+ vector<unique_ptr<Expression>> children,
7741
+ bool is_operator = false);
7723
7742
 
7724
7743
  DUCKDB_API bool operator==(const ScalarFunction &rhs) const;
7725
7744
  DUCKDB_API bool operator!=(const ScalarFunction &rhs) const;
@@ -9501,8 +9520,7 @@ public:
9501
9520
  DUCKDB_API static unique_ptr<BoundAggregateExpression>
9502
9521
  BindAggregateFunction(ClientContext &context, AggregateFunction bound_function,
9503
9522
  vector<unique_ptr<Expression>> children, unique_ptr<Expression> filter = nullptr,
9504
- bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr,
9505
- bool cast_parameters = true);
9523
+ bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr);
9506
9524
 
9507
9525
  DUCKDB_API static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
9508
9526
  vector<unique_ptr<Expression>> &children,
@@ -12862,6 +12880,7 @@ public:
12862
12880
 
12863
12881
  public:
12864
12882
  LogicalType source_type() {
12883
+ D_ASSERT(child->return_type.IsValid());
12865
12884
  return child->return_type;
12866
12885
  }
12867
12886
 
@@ -13145,6 +13164,49 @@ public:
13145
13164
 
13146
13165
 
13147
13166
 
13167
+ //===----------------------------------------------------------------------===//
13168
+ // DuckDB
13169
+ //
13170
+ // duckdb/planner/expression/bound_parameter_data.hpp
13171
+ //
13172
+ //
13173
+ //===----------------------------------------------------------------------===//
13174
+
13175
+
13176
+
13177
+
13178
+
13179
+
13180
+ namespace duckdb {
13181
+
13182
+ struct BoundParameterData {
13183
+ BoundParameterData() {
13184
+ }
13185
+ BoundParameterData(Value val) : value(move(val)), return_type(value.type()) {
13186
+ }
13187
+
13188
+ Value value;
13189
+ LogicalType return_type;
13190
+ };
13191
+
13192
+ using bound_parameter_map_t = unordered_map<idx_t, shared_ptr<BoundParameterData>>;
13193
+
13194
+ struct BoundParameterMap {
13195
+ BoundParameterMap(vector<BoundParameterData> &parameter_data) : parameter_data(parameter_data) {
13196
+ }
13197
+
13198
+ bound_parameter_map_t parameters;
13199
+ vector<BoundParameterData> &parameter_data;
13200
+
13201
+ LogicalType GetReturnType(idx_t index) {
13202
+ if (index >= parameter_data.size()) {
13203
+ return LogicalTypeId::UNKNOWN;
13204
+ }
13205
+ return parameter_data[index].return_type;
13206
+ }
13207
+ };
13208
+
13209
+ } // namespace duckdb
13148
13210
 
13149
13211
 
13150
13212
  namespace duckdb {
@@ -13154,9 +13216,14 @@ public:
13154
13216
  explicit BoundParameterExpression(idx_t parameter_nr);
13155
13217
 
13156
13218
  idx_t parameter_nr;
13157
- Value *value;
13219
+ shared_ptr<BoundParameterData> parameter_data;
13158
13220
 
13159
13221
  public:
13222
+ //! Invalidate a bound parameter expression - forcing a rebind on any subsequent filters
13223
+ DUCKDB_API static void Invalidate(Expression &expr);
13224
+ //! Invalidate all parameters within an expression
13225
+ DUCKDB_API static void InvalidateRecursive(Expression &expr);
13226
+
13160
13227
  bool IsScalar() const override;
13161
13228
  bool HasParameter() const override;
13162
13229
  bool IsFoldable() const override;
@@ -13168,6 +13235,7 @@ public:
13168
13235
 
13169
13236
  unique_ptr<Expression> Copy() override;
13170
13237
  };
13238
+
13171
13239
  } // namespace duckdb
13172
13240
 
13173
13241
  //===----------------------------------------------------------------------===//
@@ -14355,6 +14423,7 @@ struct CreateInfo;
14355
14423
  struct BoundCreateTableInfo;
14356
14424
  struct BoundCreateFunctionInfo;
14357
14425
  struct CommonTableExpressionInfo;
14426
+ struct BoundParameterMap;
14358
14427
 
14359
14428
  enum class BindingMode : uint8_t { STANDARD_BINDING, EXTRACT_NAMES };
14360
14429
 
@@ -14402,9 +14471,7 @@ public:
14402
14471
  //! vector)
14403
14472
  vector<CorrelatedColumnInfo> correlated_columns;
14404
14473
  //! The set of parameter expressions bound by this binder
14405
- vector<BoundParameterExpression *> *parameters;
14406
- //! The types of the prepared statement parameters, if any
14407
- vector<LogicalType> *parameter_types;
14474
+ BoundParameterMap *parameters;
14408
14475
  //! Statement properties
14409
14476
  StatementProperties properties;
14410
14477
  //! The alias for the currently processing subquery, if it exists
@@ -14481,8 +14548,7 @@ public:
14481
14548
  void AddTableName(string table_name);
14482
14549
  const unordered_set<string> &GetTableNames();
14483
14550
 
14484
- //! Removes the BoundParameterExpressions from Binder::parameters if they occur in 'expressions'
14485
- void RemoveParameters(vector<unique_ptr<Expression>> &expressions);
14551
+ void SetCanContainNulls(bool can_contain_nulls);
14486
14552
 
14487
14553
  private:
14488
14554
  //! The parent binder (if any)
@@ -14529,6 +14595,8 @@ private:
14529
14595
  BoundStatement Bind(CreateStatement &stmt);
14530
14596
  BoundStatement Bind(DropStatement &stmt);
14531
14597
  BoundStatement Bind(AlterStatement &stmt);
14598
+ BoundStatement Bind(PrepareStatement &stmt);
14599
+ BoundStatement Bind(ExecuteStatement &stmt);
14532
14600
  BoundStatement Bind(TransactionStatement &stmt);
14533
14601
  BoundStatement Bind(PragmaStatement &stmt);
14534
14602
  BoundStatement Bind(ExplainStatement &stmt);
@@ -23796,7 +23864,9 @@ public:
23796
23864
  return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
23797
23865
  entry.children[2]->ToString() + "]";
23798
23866
  case ExpressionType::STRUCT_EXTRACT: {
23799
- D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
23867
+ if (entry.children[1]->type != ExpressionType::VALUE_CONSTANT) {
23868
+ return string();
23869
+ }
23800
23870
  auto child_string = entry.children[1]->ToString();
23801
23871
  D_ASSERT(child_string.size() >= 3);
23802
23872
  D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
@@ -23847,6 +23917,8 @@ public:
23847
23917
 
23848
23918
  string ToString() const override;
23849
23919
 
23920
+ static bool Equals(const ParameterExpression *a, const ParameterExpression *b);
23921
+
23850
23922
  unique_ptr<ParsedExpression> Copy() const override;
23851
23923
  hash_t Hash() const override;
23852
23924