duckdb 0.3.2-dev890.0 → 0.3.2-dev930.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 "a3178f09c"
15
- #define DUCKDB_VERSION "0.3.2-dev890"
14
+ #define DUCKDB_SOURCE_ID "7e441464b"
15
+ #define DUCKDB_VERSION "0.3.2-dev930"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -109,6 +109,25 @@ using std::string;
109
109
 
110
110
  namespace duckdb {
111
111
 
112
+ // API versions
113
+ // if no explicit API version is defined, the latest API version is used
114
+ // Note that using older API versions (i.e. not using DUCKDB_API_LATEST) is deprecated.
115
+ // These will not be supported long-term, and will be removed in future versions.
116
+
117
+ #ifndef DUCKDB_API_0_3_1
118
+ #define DUCKDB_API_0_3_1 1
119
+ #endif
120
+ #ifndef DUCKDB_API_0_3_2
121
+ #define DUCKDB_API_0_3_2 2
122
+ #endif
123
+ #ifndef DUCKDB_API_LATEST
124
+ #define DUCKDB_API_LATEST DUCKDB_API_0_3_2
125
+ #endif
126
+
127
+ #ifndef DUCKDB_API_VERSION
128
+ #define DUCKDB_API_VERSION DUCKDB_API_LATEST
129
+ #endif
130
+
112
131
  //! inline std directives that we use frequently
113
132
  using std::move;
114
133
  using std::shared_ptr;
@@ -972,7 +991,7 @@ struct LogicalType {
972
991
  return *this;
973
992
  }
974
993
  // move assignment
975
- inline LogicalType& operator=(LogicalType&& other) {
994
+ inline LogicalType& operator=(LogicalType&& other) noexcept {
976
995
  id_ = other.id_;
977
996
  physical_type_ = other.physical_type_;
978
997
  type_info_ = move(other.type_info_);
@@ -2549,7 +2568,9 @@ class Serializer;
2549
2568
  //! The Value object holds a single arbitrary value of any type that can be
2550
2569
  //! stored in the database.
2551
2570
  class Value {
2552
- friend class Vector;
2571
+ friend struct StringValue;
2572
+ friend struct StructValue;
2573
+ friend struct ListValue;
2553
2574
 
2554
2575
  public:
2555
2576
  //! Create an empty NULL value of the specified type
@@ -2570,10 +2591,24 @@ public:
2570
2591
  DUCKDB_API Value(string_t val); // NOLINT: Allow implicit conversion from `string_t`
2571
2592
  //! Create a VARCHAR value
2572
2593
  DUCKDB_API Value(string val); // NOLINT: Allow implicit conversion from `string`
2594
+ //! Copy constructor
2595
+ DUCKDB_API Value(const Value &other);
2596
+ //! Move constructor
2597
+ DUCKDB_API Value(Value &&other) noexcept;
2598
+ //! Destructor
2599
+ DUCKDB_API ~Value();
2600
+
2601
+ // copy assignment
2602
+ DUCKDB_API Value &operator=(const Value &other);
2603
+ // move assignment
2604
+ DUCKDB_API Value &operator=(Value &&other) noexcept;
2573
2605
 
2574
2606
  inline const LogicalType &type() const {
2575
2607
  return type_;
2576
2608
  }
2609
+ inline bool IsNull() const {
2610
+ return is_null;
2611
+ }
2577
2612
 
2578
2613
  //! Create the lowest possible value of a given type (numeric only)
2579
2614
  DUCKDB_API static Value MinimumValue(const LogicalType &type);
@@ -2653,7 +2688,7 @@ public:
2653
2688
  DUCKDB_API static Value LIST(vector<Value> values);
2654
2689
  //! Create a list value with the given entries
2655
2690
  DUCKDB_API static Value LIST(LogicalType child_type, vector<Value> values);
2656
- //! Create an empty list with the specified type
2691
+ //! Create an empty list with the specified child-type
2657
2692
  DUCKDB_API static Value EMPTYLIST(LogicalType child_type);
2658
2693
  //! Creat a map value from a (key, value) pair
2659
2694
  DUCKDB_API static Value MAP(Value key, Value value);
@@ -2668,17 +2703,22 @@ public:
2668
2703
 
2669
2704
  template <class T>
2670
2705
  T GetValue() const {
2671
- throw NotImplementedException("Unimplemented template type for Value::GetValue");
2706
+ throw InternalException("Unimplemented template type for Value::GetValue");
2672
2707
  }
2673
2708
  template <class T>
2674
2709
  static Value CreateValue(T value) {
2675
- throw NotImplementedException("Unimplemented template type for Value::CreateValue");
2710
+ throw InternalException("Unimplemented template type for Value::CreateValue");
2676
2711
  }
2677
2712
  // Returns the internal value. Unlike GetValue(), this method does not perform casting, and assumes T matches the
2678
2713
  // type of the value. Only use this if you know what you are doing.
2679
2714
  template <class T>
2680
- T &GetValueUnsafe() {
2681
- throw NotImplementedException("Unimplemented template type for Value::GetValueUnsafe");
2715
+ T GetValueUnsafe() const {
2716
+ throw InternalException("Unimplemented template type for Value::GetValueUnsafe");
2717
+ }
2718
+ //! Returns a reference to the internal value. This can only be used for primitive types.
2719
+ template <class T>
2720
+ T &GetReferenceUnsafe() {
2721
+ throw InternalException("Unimplemented template type for Value::GetReferenceUnsafe");
2682
2722
  }
2683
2723
 
2684
2724
  //! Return a copy of this value
@@ -2686,6 +2726,8 @@ public:
2686
2726
  return Value(*this);
2687
2727
  }
2688
2728
 
2729
+ //! Hashes the Value
2730
+ DUCKDB_API hash_t Hash() const;
2689
2731
  //! Convert this value to a string
2690
2732
  DUCKDB_API string ToString() const;
2691
2733
 
@@ -2704,15 +2746,6 @@ public:
2704
2746
  //! Deserializes a Value from a blob
2705
2747
  DUCKDB_API static Value Deserialize(Deserializer &source);
2706
2748
 
2707
- //===--------------------------------------------------------------------===//
2708
- // Numeric Operators
2709
- //===--------------------------------------------------------------------===//
2710
- DUCKDB_API Value operator+(const Value &rhs) const;
2711
- DUCKDB_API Value operator-(const Value &rhs) const;
2712
- DUCKDB_API Value operator*(const Value &rhs) const;
2713
- DUCKDB_API Value operator/(const Value &rhs) const;
2714
- DUCKDB_API Value operator%(const Value &rhs) const;
2715
-
2716
2749
  //===--------------------------------------------------------------------===//
2717
2750
  // Comparison Operators
2718
2751
  //===--------------------------------------------------------------------===//
@@ -2756,7 +2789,9 @@ private:
2756
2789
  //! The logical of the value
2757
2790
  LogicalType type_;
2758
2791
 
2792
+ #if DUCKDB_API_VERSION < DUCKDB_API_0_3_2
2759
2793
  public:
2794
+ #endif
2760
2795
  //! Whether or not the value is NULL
2761
2796
  bool is_null;
2762
2797
 
@@ -2791,17 +2826,93 @@ public:
2791
2826
  private:
2792
2827
  template <class T>
2793
2828
  T GetValueInternal() const;
2794
- //! Templated helper function for casting
2795
- template <class DST, class OP>
2796
- static DST _cast(const Value &v);
2829
+ };
2797
2830
 
2798
- //! Templated helper function for binary operations
2799
- template <class OP>
2800
- static void _templated_binary_operation(const Value &left, const Value &right, Value &result, bool ignore_null);
2831
+ //===--------------------------------------------------------------------===//
2832
+ // Type-specific getters
2833
+ //===--------------------------------------------------------------------===//
2834
+ // Note that these are equivalent to calling GetValueUnsafe<X>, meaning no cast will be performed
2835
+ // instead, an assertion will be triggered if the value is not of the correct type
2836
+ struct BooleanValue {
2837
+ DUCKDB_API static bool Get(const Value &value);
2838
+ };
2801
2839
 
2802
- //! Templated helper function for boolean operations
2803
- template <class OP>
2804
- static bool _templated_boolean_operation(const Value &left, const Value &right);
2840
+ struct TinyIntValue {
2841
+ DUCKDB_API static int8_t Get(const Value &value);
2842
+ };
2843
+
2844
+ struct SmallIntValue {
2845
+ DUCKDB_API static int16_t Get(const Value &value);
2846
+ };
2847
+
2848
+ struct IntegerValue {
2849
+ DUCKDB_API static int32_t Get(const Value &value);
2850
+ };
2851
+
2852
+ struct BigIntValue {
2853
+ DUCKDB_API static int64_t Get(const Value &value);
2854
+ };
2855
+
2856
+ struct HugeIntValue {
2857
+ DUCKDB_API static hugeint_t Get(const Value &value);
2858
+ };
2859
+
2860
+ struct UTinyIntValue {
2861
+ DUCKDB_API static uint8_t Get(const Value &value);
2862
+ };
2863
+
2864
+ struct USmallIntValue {
2865
+ DUCKDB_API static uint16_t Get(const Value &value);
2866
+ };
2867
+
2868
+ struct UIntegerValue {
2869
+ DUCKDB_API static uint32_t Get(const Value &value);
2870
+ };
2871
+
2872
+ struct UBigIntValue {
2873
+ DUCKDB_API static uint64_t Get(const Value &value);
2874
+ };
2875
+
2876
+ struct FloatValue {
2877
+ DUCKDB_API static float Get(const Value &value);
2878
+ };
2879
+
2880
+ struct DoubleValue {
2881
+ DUCKDB_API static double Get(const Value &value);
2882
+ };
2883
+
2884
+ struct StringValue {
2885
+ DUCKDB_API static const string &Get(const Value &value);
2886
+ };
2887
+
2888
+ struct DateValue {
2889
+ DUCKDB_API static date_t Get(const Value &value);
2890
+ };
2891
+
2892
+ struct TimeValue {
2893
+ DUCKDB_API static dtime_t Get(const Value &value);
2894
+ };
2895
+
2896
+ struct TimestampValue {
2897
+ DUCKDB_API static timestamp_t Get(const Value &value);
2898
+ };
2899
+
2900
+ struct IntervalValue {
2901
+ DUCKDB_API static interval_t Get(const Value &value);
2902
+ };
2903
+
2904
+ struct StructValue {
2905
+ DUCKDB_API static const vector<Value> &GetChildren(const Value &value);
2906
+ };
2907
+
2908
+ struct ListValue {
2909
+ DUCKDB_API static const vector<Value> &GetChildren(const Value &value);
2910
+ };
2911
+
2912
+ //! Return the internal integral value for any type that is stored as an integral value internally
2913
+ //! This can be used on values of type integer, uinteger, but also date, timestamp, decimal, etc
2914
+ struct IntegralValue {
2915
+ static hugeint_t Get(const Value &value);
2805
2916
  };
2806
2917
 
2807
2918
  template <>
@@ -2881,37 +2992,72 @@ template <>
2881
2992
  DUCKDB_API interval_t Value::GetValue() const;
2882
2993
 
2883
2994
  template <>
2884
- DUCKDB_API int8_t &Value::GetValueUnsafe();
2995
+ DUCKDB_API bool Value::GetValueUnsafe() const;
2996
+ template <>
2997
+ DUCKDB_API int8_t Value::GetValueUnsafe() const;
2998
+ template <>
2999
+ DUCKDB_API int16_t Value::GetValueUnsafe() const;
3000
+ template <>
3001
+ DUCKDB_API int32_t Value::GetValueUnsafe() const;
3002
+ template <>
3003
+ DUCKDB_API int64_t Value::GetValueUnsafe() const;
3004
+ template <>
3005
+ DUCKDB_API hugeint_t Value::GetValueUnsafe() const;
3006
+ template <>
3007
+ DUCKDB_API uint8_t Value::GetValueUnsafe() const;
3008
+ template <>
3009
+ DUCKDB_API uint16_t Value::GetValueUnsafe() const;
3010
+ template <>
3011
+ DUCKDB_API uint32_t Value::GetValueUnsafe() const;
3012
+ template <>
3013
+ DUCKDB_API uint64_t Value::GetValueUnsafe() const;
3014
+ template <>
3015
+ DUCKDB_API string Value::GetValueUnsafe() const;
3016
+ template <>
3017
+ DUCKDB_API string_t Value::GetValueUnsafe() const;
3018
+ template <>
3019
+ DUCKDB_API float Value::GetValueUnsafe() const;
3020
+ template <>
3021
+ DUCKDB_API double Value::GetValueUnsafe() const;
3022
+ template <>
3023
+ DUCKDB_API date_t Value::GetValueUnsafe() const;
3024
+ template <>
3025
+ DUCKDB_API dtime_t Value::GetValueUnsafe() const;
2885
3026
  template <>
2886
- DUCKDB_API int16_t &Value::GetValueUnsafe();
3027
+ DUCKDB_API timestamp_t Value::GetValueUnsafe() const;
2887
3028
  template <>
2888
- DUCKDB_API int32_t &Value::GetValueUnsafe();
3029
+ DUCKDB_API interval_t Value::GetValueUnsafe() const;
3030
+
3031
+ template <>
3032
+ DUCKDB_API int8_t &Value::GetReferenceUnsafe();
2889
3033
  template <>
2890
- DUCKDB_API int64_t &Value::GetValueUnsafe();
3034
+ DUCKDB_API int16_t &Value::GetReferenceUnsafe();
2891
3035
  template <>
2892
- DUCKDB_API hugeint_t &Value::GetValueUnsafe();
3036
+ DUCKDB_API int32_t &Value::GetReferenceUnsafe();
2893
3037
  template <>
2894
- DUCKDB_API uint8_t &Value::GetValueUnsafe();
3038
+ DUCKDB_API int64_t &Value::GetReferenceUnsafe();
2895
3039
  template <>
2896
- DUCKDB_API uint16_t &Value::GetValueUnsafe();
3040
+ DUCKDB_API hugeint_t &Value::GetReferenceUnsafe();
2897
3041
  template <>
2898
- DUCKDB_API uint32_t &Value::GetValueUnsafe();
3042
+ DUCKDB_API uint8_t &Value::GetReferenceUnsafe();
2899
3043
  template <>
2900
- DUCKDB_API uint64_t &Value::GetValueUnsafe();
3044
+ DUCKDB_API uint16_t &Value::GetReferenceUnsafe();
2901
3045
  template <>
2902
- DUCKDB_API string &Value::GetValueUnsafe();
3046
+ DUCKDB_API uint32_t &Value::GetReferenceUnsafe();
2903
3047
  template <>
2904
- DUCKDB_API float &Value::GetValueUnsafe();
3048
+ DUCKDB_API uint64_t &Value::GetReferenceUnsafe();
2905
3049
  template <>
2906
- DUCKDB_API double &Value::GetValueUnsafe();
3050
+ DUCKDB_API float &Value::GetReferenceUnsafe();
2907
3051
  template <>
2908
- DUCKDB_API date_t &Value::GetValueUnsafe();
3052
+ DUCKDB_API double &Value::GetReferenceUnsafe();
2909
3053
  template <>
2910
- DUCKDB_API dtime_t &Value::GetValueUnsafe();
3054
+ DUCKDB_API date_t &Value::GetReferenceUnsafe();
2911
3055
  template <>
2912
- DUCKDB_API timestamp_t &Value::GetValueUnsafe();
3056
+ DUCKDB_API dtime_t &Value::GetReferenceUnsafe();
2913
3057
  template <>
2914
- DUCKDB_API interval_t &Value::GetValueUnsafe();
3058
+ DUCKDB_API timestamp_t &Value::GetReferenceUnsafe();
3059
+ template <>
3060
+ DUCKDB_API interval_t &Value::GetReferenceUnsafe();
2915
3061
 
2916
3062
  template <>
2917
3063
  DUCKDB_API bool Value::IsValid(float value);
@@ -3274,7 +3420,7 @@ public:
3274
3420
  void Append(const Vector &to_append, idx_t to_append_size, idx_t source_offset = 0);
3275
3421
  void Append(const Vector &to_append, const SelectionVector &sel, idx_t to_append_size, idx_t source_offset = 0);
3276
3422
 
3277
- void PushBack(Value &insert);
3423
+ void PushBack(const Value &insert);
3278
3424
 
3279
3425
  idx_t capacity = 0;
3280
3426
  idx_t size = 0;
@@ -3592,8 +3738,8 @@ struct ListVector {
3592
3738
  DUCKDB_API static void Append(Vector &target, const Vector &source, idx_t source_size, idx_t source_offset = 0);
3593
3739
  DUCKDB_API static void Append(Vector &target, const Vector &source, const SelectionVector &sel, idx_t source_size,
3594
3740
  idx_t source_offset = 0);
3595
- DUCKDB_API static void PushBack(Vector &target, Value &insert);
3596
- DUCKDB_API static vector<idx_t> Search(Vector &list, Value &key, idx_t row);
3741
+ DUCKDB_API static void PushBack(Vector &target, const Value &insert);
3742
+ DUCKDB_API static vector<idx_t> Search(Vector &list, const Value &key, idx_t row);
3597
3743
  DUCKDB_API static Value GetValuesFromOffsets(Vector &list, vector<idx_t> &offsets);
3598
3744
  //! Share the entry of the other list vector
3599
3745
  DUCKDB_API static void ReferenceEntry(Vector &vector, Vector &other);
@@ -11443,6 +11589,7 @@ ExternC const PfnDliHook __pfnDliFailureHook2 = duckdb_dllimport_delay_hook;
11443
11589
 
11444
11590
 
11445
11591
 
11592
+ // duplicate of duckdb/main/winapi.hpp
11446
11593
  #ifndef DUCKDB_API
11447
11594
  #ifdef _WIN32
11448
11595
  #if defined(DUCKDB_BUILD_LIBRARY) && !defined(DUCKDB_BUILD_LOADABLE_EXTENSION)
@@ -11455,6 +11602,21 @@ ExternC const PfnDliHook __pfnDliFailureHook2 = duckdb_dllimport_delay_hook;
11455
11602
  #endif
11456
11603
  #endif
11457
11604
 
11605
+ // duplicate of duckdb/common/constants.hpp
11606
+ #ifndef DUCKDB_API_0_3_1
11607
+ #define DUCKDB_API_0_3_1 1
11608
+ #endif
11609
+ #ifndef DUCKDB_API_0_3_2
11610
+ #define DUCKDB_API_0_3_2 2
11611
+ #endif
11612
+ #ifndef DUCKDB_API_LATEST
11613
+ #define DUCKDB_API_LATEST DUCKDB_API_0_3_2
11614
+ #endif
11615
+
11616
+ #ifndef DUCKDB_API_VERSION
11617
+ #define DUCKDB_API_VERSION DUCKDB_API_LATEST
11618
+ #endif
11619
+
11458
11620
  #include <stdbool.h>
11459
11621
  #include <stdint.h>
11460
11622
  #include <stdlib.h>
@@ -11564,19 +11726,43 @@ typedef struct {
11564
11726
  } duckdb_blob;
11565
11727
 
11566
11728
  typedef struct {
11729
+ #if DUCKDB_API_VERSION < DUCKDB_API_0_3_2
11567
11730
  void *data;
11568
11731
  bool *nullmask;
11569
11732
  duckdb_type type;
11570
11733
  char *name;
11734
+ #else
11735
+ // deprecated, use duckdb_column_data
11736
+ void *__deprecated_data;
11737
+ // deprecated, use duckdb_nullmask_data
11738
+ bool *__deprecated_nullmask;
11739
+ // deprecated, use duckdb_column_type
11740
+ duckdb_type __deprecated_type;
11741
+ // deprecated, use duckdb_column_name
11742
+ char *__deprecated_name;
11743
+ #endif
11571
11744
  void *internal_data;
11572
11745
  } duckdb_column;
11573
11746
 
11574
11747
  typedef struct {
11748
+ #if DUCKDB_API_VERSION < DUCKDB_API_0_3_2
11575
11749
  idx_t column_count;
11576
11750
  idx_t row_count;
11577
11751
  idx_t rows_changed;
11578
11752
  duckdb_column *columns;
11579
11753
  char *error_message;
11754
+ #else
11755
+ // deprecated, use duckdb_column_count
11756
+ idx_t __deprecated_column_count;
11757
+ // deprecated, use duckdb_row_count
11758
+ idx_t __deprecated_row_count;
11759
+ // deprecated, use duckdb_rows_changed
11760
+ idx_t __deprecated_rows_changed;
11761
+ // deprecated, use duckdb_column_ family of functions
11762
+ duckdb_column *__deprecated_columns;
11763
+ // deprecated, use duckdb_result_error
11764
+ char *__deprecated_error_message;
11765
+ #endif
11580
11766
  void *internal_data;
11581
11767
  } duckdb_result;
11582
11768
 
@@ -20058,31 +20244,12 @@ public:
20058
20244
  }
20059
20245
 
20060
20246
  template <class T>
20061
- static inline void Update(SegmentStatistics &stats, T new_value);
20247
+ static inline void Update(SegmentStatistics &stats, T new_value) {
20248
+ auto &nstats = (NumericStatistics &)*stats.statistics;
20249
+ UpdateValue<T>(new_value, nstats.min.GetReferenceUnsafe<T>(), nstats.max.GetReferenceUnsafe<T>());
20250
+ }
20062
20251
  };
20063
20252
 
20064
- template <>
20065
- void NumericStatistics::Update<int8_t>(SegmentStatistics &stats, int8_t new_value);
20066
- template <>
20067
- void NumericStatistics::Update<int16_t>(SegmentStatistics &stats, int16_t new_value);
20068
- template <>
20069
- void NumericStatistics::Update<int32_t>(SegmentStatistics &stats, int32_t new_value);
20070
- template <>
20071
- void NumericStatistics::Update<int64_t>(SegmentStatistics &stats, int64_t new_value);
20072
- template <>
20073
- void NumericStatistics::Update<uint8_t>(SegmentStatistics &stats, uint8_t new_value);
20074
- template <>
20075
- void NumericStatistics::Update<uint16_t>(SegmentStatistics &stats, uint16_t new_value);
20076
- template <>
20077
- void NumericStatistics::Update<uint32_t>(SegmentStatistics &stats, uint32_t new_value);
20078
- template <>
20079
- void NumericStatistics::Update<uint64_t>(SegmentStatistics &stats, uint64_t new_value);
20080
- template <>
20081
- void NumericStatistics::Update<hugeint_t>(SegmentStatistics &stats, hugeint_t new_value);
20082
- template <>
20083
- void NumericStatistics::Update<float>(SegmentStatistics &stats, float new_value);
20084
- template <>
20085
- void NumericStatistics::Update<double>(SegmentStatistics &stats, double new_value);
20086
20253
  template <>
20087
20254
  void NumericStatistics::Update<interval_t>(SegmentStatistics &stats, interval_t new_value);
20088
20255
  template <>