duckdb 0.3.2-dev10.0 → 0.3.2-dev145.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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb.cpp +17186 -15600
  3. package/src/duckdb.hpp +151 -63
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 "44e2d9e20"
14
- #define DUCKDB_VERSION "0.3.2-dev10"
13
+ #define DUCKDB_SOURCE_ID "1f9b8f4d6"
14
+ #define DUCKDB_VERSION "0.3.2-dev145"
15
15
  //===----------------------------------------------------------------------===//
16
16
  // DuckDB
17
17
  //
@@ -198,6 +198,12 @@ enum class ProfilerPrintFormat : uint8_t { NONE, QUERY_TREE, JSON, QUERY_TREE_OP
198
198
  #define suint64_t int64_t
199
199
  #endif
200
200
 
201
+ #if defined(_WIN32) || defined(_WIN64)
202
+ #define DUCKDB_WINDOWS
203
+ #elif defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
204
+ #define DUCKDB_POSIX
205
+ #endif
206
+
201
207
  namespace duckdb {
202
208
  #if !defined(_MSC_VER) && (__cplusplus < 201402L)
203
209
  template <typename T, typename... Args>
@@ -1923,6 +1929,7 @@ public:
1923
1929
  FileOpener *opener = nullptr);
1924
1930
 
1925
1931
  FileSystem &fs;
1932
+ string path;
1926
1933
  unique_ptr<data_t[]> data;
1927
1934
  idx_t offset;
1928
1935
  idx_t total_written;
@@ -6014,8 +6021,9 @@ public:
6014
6021
  static constexpr const int32_t MONTHS_PER_YEAR = 12;
6015
6022
  static constexpr const int32_t MONTHS_PER_QUARTER = 3;
6016
6023
  static constexpr const int32_t DAYS_PER_WEEK = 7;
6017
- static constexpr const int64_t DAYS_PER_MONTH =
6018
- 30; // only used for interval comparison/ordering purposes, in which case a month counts as 30 days
6024
+ //! only used for interval comparison/ordering purposes, in which case a month counts as 30 days
6025
+ static constexpr const int64_t DAYS_PER_MONTH = 30;
6026
+ static constexpr const int64_t DAYS_PER_YEAR = 365;
6019
6027
  static constexpr const int64_t MSECS_PER_SEC = 1000;
6020
6028
  static constexpr const int32_t SECS_PER_MINUTE = 60;
6021
6029
  static constexpr const int32_t MINS_PER_HOUR = 60;
@@ -6066,6 +6074,12 @@ public:
6066
6074
  //! Returns the exact difference between two timestamps (days and seconds)
6067
6075
  static interval_t GetDifference(timestamp_t timestamp_1, timestamp_t timestamp_2);
6068
6076
 
6077
+ //! Add an interval to a date
6078
+ static date_t Add(date_t left, interval_t right);
6079
+ //! Add an interval to a time. In case the time overflows or underflows, modify the date by the overflow.
6080
+ //! For example if we go from 23:00 to 02:00, we add a day to the date
6081
+ static dtime_t Add(dtime_t left, interval_t right, date_t &date);
6082
+
6069
6083
  //! Comparison operators
6070
6084
  static bool Equals(interval_t left, interval_t right);
6071
6085
  static bool GreaterThan(interval_t left, interval_t right);
@@ -7975,7 +7989,7 @@ public:
7975
7989
 
7976
7990
  virtual string GetName() const;
7977
7991
  virtual string ParamsToString() const;
7978
- virtual string ToString(idx_t depth = 0) const;
7992
+ virtual string ToString() const;
7979
7993
  void Print();
7980
7994
  //! Debug method: verify that the integrity of expressions & child nodes are maintained
7981
7995
  virtual void Verify();
@@ -9462,6 +9476,8 @@ public:
9462
9476
  static void PrintProgress(int percentage, const char *pbstr, int pbwidth);
9463
9477
  //! Prints an empty line when progress bar is done
9464
9478
  static void FinishProgressBarPrint(const char *pbstr, int pbwidth);
9479
+ //! Whether or not we are printing to a terminal
9480
+ static bool IsTerminal();
9465
9481
  };
9466
9482
  } // namespace duckdb
9467
9483
 
@@ -10061,6 +10077,29 @@ enum class WindowAggregationMode : uint32_t {
10061
10077
 
10062
10078
  } // namespace duckdb
10063
10079
 
10080
+ //===----------------------------------------------------------------------===//
10081
+ // DuckDB
10082
+ //
10083
+ // duckdb/common/enums/set_scope.hpp
10084
+ //
10085
+ //
10086
+ //===----------------------------------------------------------------------===//
10087
+
10088
+
10089
+
10090
+
10091
+
10092
+ namespace duckdb {
10093
+
10094
+ enum class SetScope : uint8_t {
10095
+ AUTOMATIC = 0,
10096
+ LOCAL = 1, /* unused */
10097
+ SESSION = 2,
10098
+ GLOBAL = 3
10099
+ };
10100
+
10101
+ } // namespace duckdb
10102
+
10064
10103
 
10065
10104
  namespace duckdb {
10066
10105
  class ClientContext;
@@ -10068,6 +10107,7 @@ class TableFunctionRef;
10068
10107
  class CompressionFunction;
10069
10108
 
10070
10109
  struct CompressionFunctionSet;
10110
+ struct DBConfig;
10071
10111
 
10072
10112
  enum class AccessMode : uint8_t { UNDEFINED = 0, AUTOMATIC = 1, READ_ONLY = 2, READ_WRITE = 3 };
10073
10113
 
@@ -10078,25 +10118,31 @@ enum class CheckpointAbort : uint8_t {
10078
10118
  DEBUG_ABORT_AFTER_FREE_LIST_WRITE = 3
10079
10119
  };
10080
10120
 
10081
- enum class ConfigurationOptionType : uint32_t {
10082
- INVALID = 0,
10083
- ACCESS_MODE,
10084
- DEFAULT_ORDER_TYPE,
10085
- DEFAULT_NULL_ORDER,
10086
- ENABLE_EXTERNAL_ACCESS,
10087
- ENABLE_OBJECT_CACHE,
10088
- MAXIMUM_MEMORY,
10089
- THREADS
10090
- };
10121
+ typedef void (*set_global_function_t)(DatabaseInstance *db, DBConfig &config, const Value &parameter);
10122
+ typedef void (*set_local_function_t)(ClientContext &context, const Value &parameter);
10123
+ typedef Value (*get_setting_function_t)(ClientContext &context);
10091
10124
 
10092
10125
  struct ConfigurationOption {
10093
- ConfigurationOptionType type;
10094
10126
  const char *name;
10095
10127
  const char *description;
10096
10128
  LogicalTypeId parameter_type;
10129
+ set_global_function_t set_global;
10130
+ set_local_function_t set_local;
10131
+ get_setting_function_t get_setting;
10132
+ };
10133
+
10134
+ typedef void (*set_option_callback_t)(ClientContext &context, SetScope scope, Value &parameter);
10135
+
10136
+ struct ExtensionOption {
10137
+ ExtensionOption(string description_p, LogicalType type_p, set_option_callback_t set_function_p)
10138
+ : description(move(description_p)), type(move(type_p)), set_function(set_function_p) {
10139
+ }
10140
+
10141
+ string description;
10142
+ LogicalType type;
10143
+ set_option_callback_t set_function;
10097
10144
  };
10098
10145
 
10099
- // this is optional and only used in tests at the moment
10100
10146
  struct DBConfig {
10101
10147
  friend class DatabaseInstance;
10102
10148
  friend class StorageManager;
@@ -10136,8 +10182,6 @@ public:
10136
10182
  bool enable_external_access = true;
10137
10183
  //! Whether or not object cache is used
10138
10184
  bool object_cache_enable = false;
10139
- //! Database configuration variables as controlled by SET
10140
- case_insensitive_map_t<Value> set_variables;
10141
10185
  //! Force checkpoint when CHECKPOINT is called or on shutdown, even if no changes have been made
10142
10186
  bool force_checkpoint = false;
10143
10187
  //! Run a checkpoint on successful shutdown and delete the WAL, to leave only a single database file behind
@@ -10158,6 +10202,17 @@ public:
10158
10202
  //! Debug setting for window aggregation mode: (window, combine, separate)
10159
10203
  WindowAggregationMode window_mode = WindowAggregationMode::WINDOW;
10160
10204
 
10205
+ //! Extra parameters that can be SET for loaded extensions
10206
+ case_insensitive_map_t<ExtensionOption> extension_parameters;
10207
+ //! Database configuration variables as controlled by SET
10208
+ case_insensitive_map_t<Value> set_variables;
10209
+
10210
+ void AddExtensionOption(string name, string description, LogicalType parameter,
10211
+ set_option_callback_t function = nullptr) {
10212
+ extension_parameters.insert(
10213
+ make_pair(move(name), ExtensionOption(move(description), move(parameter), function)));
10214
+ }
10215
+
10161
10216
  public:
10162
10217
  DUCKDB_API static DBConfig &GetConfig(ClientContext &context);
10163
10218
  DUCKDB_API static DBConfig &GetConfig(DatabaseInstance &db);
@@ -12505,7 +12560,6 @@ private:
12505
12560
  } // namespace duckdb
12506
12561
 
12507
12562
 
12508
-
12509
12563
  //===----------------------------------------------------------------------===//
12510
12564
  // DuckDB
12511
12565
  //
@@ -12521,24 +12575,6 @@ private:
12521
12575
  namespace duckdb {
12522
12576
  using std::deque;
12523
12577
  }
12524
- //===----------------------------------------------------------------------===//
12525
- // DuckDB
12526
- //
12527
- // duckdb/common/enums/output_type.hpp
12528
- //
12529
- //
12530
- //===----------------------------------------------------------------------===//
12531
-
12532
-
12533
-
12534
-
12535
-
12536
- namespace duckdb {
12537
-
12538
- enum class ExplainOutputType : uint8_t { ALL = 0, OPTIMIZED_ONLY = 1, PHYSICAL_ONLY = 2 };
12539
-
12540
- } // namespace duckdb
12541
-
12542
12578
 
12543
12579
  //===----------------------------------------------------------------------===//
12544
12580
  // DuckDB
@@ -12690,6 +12726,7 @@ enum class PhysicalOperatorType : uint8_t {
12690
12726
  // Helpers
12691
12727
  // -----------------------------
12692
12728
  EXPLAIN,
12729
+ EXPLAIN_ANALYZE,
12693
12730
  EMPTY_RESULT,
12694
12731
  EXECUTE,
12695
12732
  PREPARE,
@@ -13170,6 +13207,7 @@ namespace duckdb {
13170
13207
  struct ConcurrentQueue;
13171
13208
  struct QueueProducerToken;
13172
13209
  class ClientContext;
13210
+ class DatabaseInstance;
13173
13211
  class TaskScheduler;
13174
13212
 
13175
13213
  struct SchedulerThread;
@@ -13193,6 +13231,7 @@ public:
13193
13231
  ~TaskScheduler();
13194
13232
 
13195
13233
  static TaskScheduler &GetScheduler(ClientContext &context);
13234
+ static TaskScheduler &GetScheduler(DatabaseInstance &db);
13196
13235
 
13197
13236
  unique_ptr<ProducerToken> CreateProducer();
13198
13237
  //! Schedule a task to be executed by the task scheduler
@@ -13437,7 +13476,7 @@ public:
13437
13476
  //! Starts the thread
13438
13477
  void Start();
13439
13478
  //! Stops the thread
13440
- void Stop();
13479
+ void Stop(bool success = true);
13441
13480
  //! Gets current percentage
13442
13481
  int GetCurrentPercentage();
13443
13482
 
@@ -13454,7 +13493,7 @@ private:
13454
13493
  std::condition_variable c;
13455
13494
  mutex m;
13456
13495
  #endif
13457
- idx_t show_progress_after;
13496
+ atomic<idx_t> show_progress_after;
13458
13497
  idx_t time_update_bar;
13459
13498
  atomic<int> current_percentage;
13460
13499
  atomic<bool> stop;
@@ -13540,6 +13579,75 @@ private:
13540
13579
 
13541
13580
  #include <random>
13542
13581
 
13582
+ //===----------------------------------------------------------------------===//
13583
+ // DuckDB
13584
+ //
13585
+ // duckdb/main/client_config.hpp
13586
+ //
13587
+ //
13588
+ //===----------------------------------------------------------------------===//
13589
+
13590
+
13591
+
13592
+
13593
+
13594
+ //===----------------------------------------------------------------------===//
13595
+ // DuckDB
13596
+ //
13597
+ // duckdb/common/enums/output_type.hpp
13598
+ //
13599
+ //
13600
+ //===----------------------------------------------------------------------===//
13601
+
13602
+
13603
+
13604
+
13605
+
13606
+ namespace duckdb {
13607
+
13608
+ enum class ExplainOutputType : uint8_t { ALL = 0, OPTIMIZED_ONLY = 1, PHYSICAL_ONLY = 2 };
13609
+
13610
+ } // namespace duckdb
13611
+
13612
+
13613
+
13614
+ namespace duckdb {
13615
+ class ClientContext;
13616
+
13617
+ struct ClientConfig {
13618
+ //! If the progress bar is enabled or not.
13619
+ bool enable_progress_bar = false;
13620
+ //! If the print of the progress bar is enabled
13621
+ bool print_progress_bar = true;
13622
+ //! The wait time before showing the progress bar
13623
+ int wait_time = 2000;
13624
+
13625
+ // Whether or not aggressive query verification is enabled
13626
+ bool query_verification_enabled = false;
13627
+ //! Enable the running of optimizers
13628
+ bool enable_optimizer = true;
13629
+ //! Force parallelism of small tables, used for testing
13630
+ bool verify_parallelism = false;
13631
+ //! Force index join independent of table cardinality, used for testing
13632
+ bool force_index_join = false;
13633
+ //! Force out-of-core computation for operators that support it, used for testing
13634
+ bool force_external = false;
13635
+ //! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
13636
+ //! elements)
13637
+ idx_t perfect_ht_threshold = 12;
13638
+
13639
+ //! The explain output type used when none is specified (default: PHYSICAL_ONLY)
13640
+ ExplainOutputType explain_output_type = ExplainOutputType::PHYSICAL_ONLY;
13641
+
13642
+ //! Generic options
13643
+ case_insensitive_map_t<Value> set_variables;
13644
+
13645
+ public:
13646
+ static ClientConfig &GetConfig(ClientContext &context);
13647
+ };
13648
+
13649
+ } // namespace duckdb
13650
+
13543
13651
 
13544
13652
  namespace duckdb {
13545
13653
  class Appender;
@@ -13584,35 +13692,12 @@ public:
13584
13692
 
13585
13693
  //! The Progress Bar
13586
13694
  unique_ptr<ProgressBar> progress_bar;
13587
- //! If the progress bar is enabled or not.
13588
- bool enable_progress_bar = false;
13589
- //! If the print of the progress bar is enabled
13590
- bool print_progress_bar = true;
13591
- //! The wait time before showing the progress bar
13592
- int wait_time = 2000;
13593
13695
 
13594
13696
  unique_ptr<SchemaCatalogEntry> temporary_objects;
13595
13697
  unordered_map<string, shared_ptr<PreparedStatementData>> prepared_statements;
13596
13698
 
13597
- case_insensitive_map_t<Value> set_variables;
13598
-
13599
- // Whether or not aggressive query verification is enabled
13600
- bool query_verification_enabled = false;
13601
- //! Enable the running of optimizers
13602
- bool enable_optimizer = true;
13603
- //! Force parallelism of small tables, used for testing
13604
- bool verify_parallelism = false;
13605
- //! Force index join independent of table cardinality, used for testing
13606
- bool force_index_join = false;
13607
- //! Force out-of-core computation for operators that support it, used for testing
13608
- bool force_external = false;
13609
- //! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
13610
- //! elements)
13611
- idx_t perfect_ht_threshold = 12;
13612
13699
  //! The writer used to log queries (if logging is enabled)
13613
13700
  unique_ptr<BufferedFileWriter> log_query_writer;
13614
- //! The explain output type used when none is specified (default: PHYSICAL_ONLY)
13615
- ExplainOutputType explain_output_type = ExplainOutputType::PHYSICAL_ONLY;
13616
13701
  //! The random generator used by random(). Its seed value can be set by setseed().
13617
13702
  std::mt19937 random_engine;
13618
13703
 
@@ -13620,6 +13705,9 @@ public:
13620
13705
 
13621
13706
  unique_ptr<FileOpener> file_opener;
13622
13707
 
13708
+ //! The client configuration
13709
+ ClientConfig config;
13710
+
13623
13711
  public:
13624
13712
  DUCKDB_API Transaction &ActiveTransaction() {
13625
13713
  return transaction.ActiveTransaction();