duckdb 0.3.2-dev10.0 → 0.3.2-dev121.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 +16992 -15510
  3. package/src/duckdb.hpp +142 -62
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 "3c9727ac2"
14
+ #define DUCKDB_VERSION "0.3.2-dev121"
15
15
  //===----------------------------------------------------------------------===//
16
16
  // DuckDB
17
17
  //
@@ -1923,6 +1923,7 @@ public:
1923
1923
  FileOpener *opener = nullptr);
1924
1924
 
1925
1925
  FileSystem &fs;
1926
+ string path;
1926
1927
  unique_ptr<data_t[]> data;
1927
1928
  idx_t offset;
1928
1929
  idx_t total_written;
@@ -6014,8 +6015,9 @@ public:
6014
6015
  static constexpr const int32_t MONTHS_PER_YEAR = 12;
6015
6016
  static constexpr const int32_t MONTHS_PER_QUARTER = 3;
6016
6017
  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
6018
+ //! only used for interval comparison/ordering purposes, in which case a month counts as 30 days
6019
+ static constexpr const int64_t DAYS_PER_MONTH = 30;
6020
+ static constexpr const int64_t DAYS_PER_YEAR = 365;
6019
6021
  static constexpr const int64_t MSECS_PER_SEC = 1000;
6020
6022
  static constexpr const int32_t SECS_PER_MINUTE = 60;
6021
6023
  static constexpr const int32_t MINS_PER_HOUR = 60;
@@ -6066,6 +6068,12 @@ public:
6066
6068
  //! Returns the exact difference between two timestamps (days and seconds)
6067
6069
  static interval_t GetDifference(timestamp_t timestamp_1, timestamp_t timestamp_2);
6068
6070
 
6071
+ //! Add an interval to a date
6072
+ static date_t Add(date_t left, interval_t right);
6073
+ //! Add an interval to a time. In case the time overflows or underflows, modify the date by the overflow.
6074
+ //! For example if we go from 23:00 to 02:00, we add a day to the date
6075
+ static dtime_t Add(dtime_t left, interval_t right, date_t &date);
6076
+
6069
6077
  //! Comparison operators
6070
6078
  static bool Equals(interval_t left, interval_t right);
6071
6079
  static bool GreaterThan(interval_t left, interval_t right);
@@ -10061,6 +10069,29 @@ enum class WindowAggregationMode : uint32_t {
10061
10069
 
10062
10070
  } // namespace duckdb
10063
10071
 
10072
+ //===----------------------------------------------------------------------===//
10073
+ // DuckDB
10074
+ //
10075
+ // duckdb/common/enums/set_scope.hpp
10076
+ //
10077
+ //
10078
+ //===----------------------------------------------------------------------===//
10079
+
10080
+
10081
+
10082
+
10083
+
10084
+ namespace duckdb {
10085
+
10086
+ enum class SetScope : uint8_t {
10087
+ AUTOMATIC = 0,
10088
+ LOCAL = 1, /* unused */
10089
+ SESSION = 2,
10090
+ GLOBAL = 3
10091
+ };
10092
+
10093
+ } // namespace duckdb
10094
+
10064
10095
 
10065
10096
  namespace duckdb {
10066
10097
  class ClientContext;
@@ -10068,6 +10099,7 @@ class TableFunctionRef;
10068
10099
  class CompressionFunction;
10069
10100
 
10070
10101
  struct CompressionFunctionSet;
10102
+ struct DBConfig;
10071
10103
 
10072
10104
  enum class AccessMode : uint8_t { UNDEFINED = 0, AUTOMATIC = 1, READ_ONLY = 2, READ_WRITE = 3 };
10073
10105
 
@@ -10078,25 +10110,31 @@ enum class CheckpointAbort : uint8_t {
10078
10110
  DEBUG_ABORT_AFTER_FREE_LIST_WRITE = 3
10079
10111
  };
10080
10112
 
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
- };
10113
+ typedef void (*set_global_function_t)(DatabaseInstance *db, DBConfig &config, const Value &parameter);
10114
+ typedef void (*set_local_function_t)(ClientContext &context, const Value &parameter);
10115
+ typedef Value (*get_setting_function_t)(ClientContext &context);
10091
10116
 
10092
10117
  struct ConfigurationOption {
10093
- ConfigurationOptionType type;
10094
10118
  const char *name;
10095
10119
  const char *description;
10096
10120
  LogicalTypeId parameter_type;
10121
+ set_global_function_t set_global;
10122
+ set_local_function_t set_local;
10123
+ get_setting_function_t get_setting;
10124
+ };
10125
+
10126
+ typedef void (*set_option_callback_t)(ClientContext &context, SetScope scope, Value &parameter);
10127
+
10128
+ struct ExtensionOption {
10129
+ ExtensionOption(string description_p, LogicalType type_p, set_option_callback_t set_function_p)
10130
+ : description(move(description_p)), type(move(type_p)), set_function(set_function_p) {
10131
+ }
10132
+
10133
+ string description;
10134
+ LogicalType type;
10135
+ set_option_callback_t set_function;
10097
10136
  };
10098
10137
 
10099
- // this is optional and only used in tests at the moment
10100
10138
  struct DBConfig {
10101
10139
  friend class DatabaseInstance;
10102
10140
  friend class StorageManager;
@@ -10136,8 +10174,6 @@ public:
10136
10174
  bool enable_external_access = true;
10137
10175
  //! Whether or not object cache is used
10138
10176
  bool object_cache_enable = false;
10139
- //! Database configuration variables as controlled by SET
10140
- case_insensitive_map_t<Value> set_variables;
10141
10177
  //! Force checkpoint when CHECKPOINT is called or on shutdown, even if no changes have been made
10142
10178
  bool force_checkpoint = false;
10143
10179
  //! Run a checkpoint on successful shutdown and delete the WAL, to leave only a single database file behind
@@ -10158,6 +10194,17 @@ public:
10158
10194
  //! Debug setting for window aggregation mode: (window, combine, separate)
10159
10195
  WindowAggregationMode window_mode = WindowAggregationMode::WINDOW;
10160
10196
 
10197
+ //! Extra parameters that can be SET for loaded extensions
10198
+ case_insensitive_map_t<ExtensionOption> extension_parameters;
10199
+ //! Database configuration variables as controlled by SET
10200
+ case_insensitive_map_t<Value> set_variables;
10201
+
10202
+ void AddExtensionOption(string name, string description, LogicalType parameter,
10203
+ set_option_callback_t function = nullptr) {
10204
+ extension_parameters.insert(
10205
+ make_pair(move(name), ExtensionOption(move(description), move(parameter), function)));
10206
+ }
10207
+
10161
10208
  public:
10162
10209
  DUCKDB_API static DBConfig &GetConfig(ClientContext &context);
10163
10210
  DUCKDB_API static DBConfig &GetConfig(DatabaseInstance &db);
@@ -12505,7 +12552,6 @@ private:
12505
12552
  } // namespace duckdb
12506
12553
 
12507
12554
 
12508
-
12509
12555
  //===----------------------------------------------------------------------===//
12510
12556
  // DuckDB
12511
12557
  //
@@ -12521,24 +12567,6 @@ private:
12521
12567
  namespace duckdb {
12522
12568
  using std::deque;
12523
12569
  }
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
12570
 
12543
12571
  //===----------------------------------------------------------------------===//
12544
12572
  // DuckDB
@@ -12690,6 +12718,7 @@ enum class PhysicalOperatorType : uint8_t {
12690
12718
  // Helpers
12691
12719
  // -----------------------------
12692
12720
  EXPLAIN,
12721
+ EXPLAIN_ANALYZE,
12693
12722
  EMPTY_RESULT,
12694
12723
  EXECUTE,
12695
12724
  PREPARE,
@@ -13170,6 +13199,7 @@ namespace duckdb {
13170
13199
  struct ConcurrentQueue;
13171
13200
  struct QueueProducerToken;
13172
13201
  class ClientContext;
13202
+ class DatabaseInstance;
13173
13203
  class TaskScheduler;
13174
13204
 
13175
13205
  struct SchedulerThread;
@@ -13193,6 +13223,7 @@ public:
13193
13223
  ~TaskScheduler();
13194
13224
 
13195
13225
  static TaskScheduler &GetScheduler(ClientContext &context);
13226
+ static TaskScheduler &GetScheduler(DatabaseInstance &db);
13196
13227
 
13197
13228
  unique_ptr<ProducerToken> CreateProducer();
13198
13229
  //! Schedule a task to be executed by the task scheduler
@@ -13437,7 +13468,7 @@ public:
13437
13468
  //! Starts the thread
13438
13469
  void Start();
13439
13470
  //! Stops the thread
13440
- void Stop();
13471
+ void Stop(bool success = true);
13441
13472
  //! Gets current percentage
13442
13473
  int GetCurrentPercentage();
13443
13474
 
@@ -13454,7 +13485,7 @@ private:
13454
13485
  std::condition_variable c;
13455
13486
  mutex m;
13456
13487
  #endif
13457
- idx_t show_progress_after;
13488
+ atomic<idx_t> show_progress_after;
13458
13489
  idx_t time_update_bar;
13459
13490
  atomic<int> current_percentage;
13460
13491
  atomic<bool> stop;
@@ -13540,6 +13571,75 @@ private:
13540
13571
 
13541
13572
  #include <random>
13542
13573
 
13574
+ //===----------------------------------------------------------------------===//
13575
+ // DuckDB
13576
+ //
13577
+ // duckdb/main/client_config.hpp
13578
+ //
13579
+ //
13580
+ //===----------------------------------------------------------------------===//
13581
+
13582
+
13583
+
13584
+
13585
+
13586
+ //===----------------------------------------------------------------------===//
13587
+ // DuckDB
13588
+ //
13589
+ // duckdb/common/enums/output_type.hpp
13590
+ //
13591
+ //
13592
+ //===----------------------------------------------------------------------===//
13593
+
13594
+
13595
+
13596
+
13597
+
13598
+ namespace duckdb {
13599
+
13600
+ enum class ExplainOutputType : uint8_t { ALL = 0, OPTIMIZED_ONLY = 1, PHYSICAL_ONLY = 2 };
13601
+
13602
+ } // namespace duckdb
13603
+
13604
+
13605
+
13606
+ namespace duckdb {
13607
+ class ClientContext;
13608
+
13609
+ struct ClientConfig {
13610
+ //! If the progress bar is enabled or not.
13611
+ bool enable_progress_bar = false;
13612
+ //! If the print of the progress bar is enabled
13613
+ bool print_progress_bar = true;
13614
+ //! The wait time before showing the progress bar
13615
+ int wait_time = 2000;
13616
+
13617
+ // Whether or not aggressive query verification is enabled
13618
+ bool query_verification_enabled = false;
13619
+ //! Enable the running of optimizers
13620
+ bool enable_optimizer = true;
13621
+ //! Force parallelism of small tables, used for testing
13622
+ bool verify_parallelism = false;
13623
+ //! Force index join independent of table cardinality, used for testing
13624
+ bool force_index_join = false;
13625
+ //! Force out-of-core computation for operators that support it, used for testing
13626
+ bool force_external = false;
13627
+ //! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
13628
+ //! elements)
13629
+ idx_t perfect_ht_threshold = 12;
13630
+
13631
+ //! The explain output type used when none is specified (default: PHYSICAL_ONLY)
13632
+ ExplainOutputType explain_output_type = ExplainOutputType::PHYSICAL_ONLY;
13633
+
13634
+ //! Generic options
13635
+ case_insensitive_map_t<Value> set_variables;
13636
+
13637
+ public:
13638
+ static ClientConfig &GetConfig(ClientContext &context);
13639
+ };
13640
+
13641
+ } // namespace duckdb
13642
+
13543
13643
 
13544
13644
  namespace duckdb {
13545
13645
  class Appender;
@@ -13584,35 +13684,12 @@ public:
13584
13684
 
13585
13685
  //! The Progress Bar
13586
13686
  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
13687
 
13594
13688
  unique_ptr<SchemaCatalogEntry> temporary_objects;
13595
13689
  unordered_map<string, shared_ptr<PreparedStatementData>> prepared_statements;
13596
13690
 
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
13691
  //! The writer used to log queries (if logging is enabled)
13613
13692
  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
13693
  //! The random generator used by random(). Its seed value can be set by setseed().
13617
13694
  std::mt19937 random_engine;
13618
13695
 
@@ -13620,6 +13697,9 @@ public:
13620
13697
 
13621
13698
  unique_ptr<FileOpener> file_opener;
13622
13699
 
13700
+ //! The client configuration
13701
+ ClientConfig config;
13702
+
13623
13703
  public:
13624
13704
  DUCKDB_API Transaction &ActiveTransaction() {
13625
13705
  return transaction.ActiveTransaction();