duckdb 0.4.1-dev26.0 → 0.4.1-dev29.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.4.1-dev26.0",
4
+ "version": "0.4.1-dev29.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -62322,6 +62322,12 @@ class DuckDB;
62322
62322
 
62323
62323
  enum class ExtensionLoadResult : uint8_t { LOADED_EXTENSION = 0, EXTENSION_UNKNOWN = 1, NOT_LOADED = 2 };
62324
62324
 
62325
+ struct DefaultExtension {
62326
+ const char *name;
62327
+ const char *description;
62328
+ bool statically_loaded;
62329
+ };
62330
+
62325
62331
  class ExtensionHelper {
62326
62332
  public:
62327
62333
  static void LoadAllExtensions(DuckDB &db);
@@ -62331,6 +62337,11 @@ public:
62331
62337
  static void InstallExtension(DatabaseInstance &db, const string &extension, bool force_install);
62332
62338
  static void LoadExternalExtension(DatabaseInstance &db, const string &extension);
62333
62339
 
62340
+ static string ExtensionDirectory(FileSystem &fs);
62341
+
62342
+ static idx_t DefaultExtensionCount();
62343
+ static DefaultExtension GetDefaultExtension(idx_t index);
62344
+
62334
62345
  private:
62335
62346
  static const vector<string> PathComponents();
62336
62347
 
@@ -107071,6 +107082,10 @@ struct DuckDBDependenciesFun {
107071
107082
  static void RegisterFunction(BuiltinFunctions &set);
107072
107083
  };
107073
107084
 
107085
+ struct DuckDBExtensionsFun {
107086
+ static void RegisterFunction(BuiltinFunctions &set);
107087
+ };
107088
+
107074
107089
  struct DuckDBFunctionsFun {
107075
107090
  static void RegisterFunction(BuiltinFunctions &set);
107076
107091
  };
@@ -108669,6 +108684,152 @@ void DuckDBDependenciesFun::RegisterFunction(BuiltinFunctions &set) {
108669
108684
 
108670
108685
 
108671
108686
 
108687
+ namespace duckdb {
108688
+
108689
+ struct ExtensionInformation {
108690
+ string name;
108691
+ bool loaded = false;
108692
+ bool installed = false;
108693
+ string file_path;
108694
+ string description;
108695
+ };
108696
+
108697
+ struct DuckDBExtensionsData : public GlobalTableFunctionState {
108698
+ DuckDBExtensionsData() : offset(0) {
108699
+ }
108700
+
108701
+ vector<ExtensionInformation> entries;
108702
+ idx_t offset;
108703
+ };
108704
+
108705
+ static unique_ptr<FunctionData> DuckDBExtensionsBind(ClientContext &context, TableFunctionBindInput &input,
108706
+ vector<LogicalType> &return_types, vector<string> &names) {
108707
+ names.emplace_back("extension_name");
108708
+ return_types.emplace_back(LogicalType::VARCHAR);
108709
+
108710
+ names.emplace_back("loaded");
108711
+ return_types.emplace_back(LogicalType::BOOLEAN);
108712
+
108713
+ names.emplace_back("installed");
108714
+ return_types.emplace_back(LogicalType::BOOLEAN);
108715
+
108716
+ names.emplace_back("install_path");
108717
+ return_types.emplace_back(LogicalType::VARCHAR);
108718
+
108719
+ names.emplace_back("description");
108720
+ return_types.emplace_back(LogicalType::VARCHAR);
108721
+
108722
+ return nullptr;
108723
+ }
108724
+
108725
+ unique_ptr<GlobalTableFunctionState> DuckDBExtensionsInit(ClientContext &context, TableFunctionInitInput &input) {
108726
+ auto result = make_unique<DuckDBExtensionsData>();
108727
+
108728
+ auto &fs = FileSystem::GetFileSystem(context);
108729
+ auto &db = DatabaseInstance::GetDatabase(context);
108730
+
108731
+ map<string, ExtensionInformation> installed_extensions;
108732
+ auto extension_count = ExtensionHelper::DefaultExtensionCount();
108733
+ for (idx_t i = 0; i < extension_count; i++) {
108734
+ auto extension = ExtensionHelper::GetDefaultExtension(i);
108735
+ ExtensionInformation info;
108736
+ info.name = extension.name;
108737
+ info.installed = extension.statically_loaded;
108738
+ info.loaded = false;
108739
+ info.file_path = extension.statically_loaded ? "(BUILT-IN)" : string();
108740
+ info.description = extension.description;
108741
+ installed_extensions[info.name] = move(info);
108742
+ }
108743
+
108744
+ // scan the install directory for installed extensions
108745
+ auto ext_directory = ExtensionHelper::ExtensionDirectory(fs);
108746
+ fs.ListFiles(ext_directory, [&](const string &path, bool is_directory) {
108747
+ if (!StringUtil::EndsWith(path, ".duckdb_extension")) {
108748
+ return;
108749
+ }
108750
+ ExtensionInformation info;
108751
+ info.name = fs.ExtractBaseName(path);
108752
+ info.loaded = false;
108753
+ info.file_path = fs.JoinPath(ext_directory, path);
108754
+ auto entry = installed_extensions.find(info.name);
108755
+ if (entry == installed_extensions.end()) {
108756
+ installed_extensions[info.name] = move(info);
108757
+ } else {
108758
+ if (!entry->second.loaded) {
108759
+ entry->second.file_path = info.file_path;
108760
+ }
108761
+ entry->second.installed = true;
108762
+ }
108763
+ });
108764
+
108765
+ // now check the list of currently loaded extensions
108766
+ auto &loaded_extensions = db.LoadedExtensions();
108767
+ for (auto &ext_name : loaded_extensions) {
108768
+ auto entry = installed_extensions.find(ext_name);
108769
+ if (entry == installed_extensions.end()) {
108770
+ ExtensionInformation info;
108771
+ info.name = ext_name;
108772
+ info.loaded = true;
108773
+ installed_extensions[ext_name] = move(info);
108774
+ } else {
108775
+ entry->second.loaded = true;
108776
+ }
108777
+ }
108778
+
108779
+ result->entries.reserve(installed_extensions.size());
108780
+ for (auto &kv : installed_extensions) {
108781
+ result->entries.push_back(move(kv.second));
108782
+ }
108783
+ return move(result);
108784
+ }
108785
+
108786
+ void DuckDBExtensionsFunction(ClientContext &context, TableFunctionInput &data_p, DataChunk &output) {
108787
+ auto &data = (DuckDBExtensionsData &)*data_p.global_state;
108788
+ if (data.offset >= data.entries.size()) {
108789
+ // finished returning values
108790
+ return;
108791
+ }
108792
+ // start returning values
108793
+ // either fill up the chunk or return all the remaining columns
108794
+ idx_t count = 0;
108795
+ while (data.offset < data.entries.size() && count < STANDARD_VECTOR_SIZE) {
108796
+ auto &entry = data.entries[data.offset];
108797
+
108798
+ // return values:
108799
+ // extension_name LogicalType::VARCHAR
108800
+ output.SetValue(0, count, Value(entry.name));
108801
+ // loaded LogicalType::BOOLEAN
108802
+ output.SetValue(1, count, Value::BOOLEAN(entry.loaded));
108803
+ // installed LogicalType::BOOLEAN
108804
+ output.SetValue(2, count, !entry.installed && entry.loaded ? Value() : Value::BOOLEAN(entry.installed));
108805
+ // install_path LogicalType::VARCHAR
108806
+ output.SetValue(3, count, Value(entry.file_path));
108807
+ // description LogicalType::VARCHAR
108808
+ output.SetValue(4, count, Value(entry.description));
108809
+
108810
+ data.offset++;
108811
+ count++;
108812
+ }
108813
+ output.SetCardinality(count);
108814
+ }
108815
+
108816
+ void DuckDBExtensionsFun::RegisterFunction(BuiltinFunctions &set) {
108817
+ TableFunctionSet functions("duckdb_extensions");
108818
+ functions.AddFunction(TableFunction({}, DuckDBExtensionsFunction, DuckDBExtensionsBind, DuckDBExtensionsInit));
108819
+ set.AddFunction(functions);
108820
+ }
108821
+
108822
+ } // namespace duckdb
108823
+
108824
+
108825
+
108826
+
108827
+
108828
+
108829
+
108830
+
108831
+
108832
+
108672
108833
 
108673
108834
 
108674
108835
 
@@ -111312,6 +111473,7 @@ void BuiltinFunctions::RegisterSQLiteFunctions() {
111312
111473
  DuckDBIndexesFun::RegisterFunction(*this);
111313
111474
  DuckDBSchemasFun::RegisterFunction(*this);
111314
111475
  DuckDBDependenciesFun::RegisterFunction(*this);
111476
+ DuckDBExtensionsFun::RegisterFunction(*this);
111315
111477
  DuckDBSequencesFun::RegisterFunction(*this);
111316
111478
  DuckDBSettingsFun::RegisterFunction(*this);
111317
111479
  DuckDBTablesFun::RegisterFunction(*this);
@@ -117879,6 +118041,10 @@ idx_t DatabaseInstance::NumberOfThreads() {
117879
118041
  return scheduler->NumberOfThreads();
117880
118042
  }
117881
118043
 
118044
+ const unordered_set<std::string> &DatabaseInstance::LoadedExtensions() {
118045
+ return loaded_extensions;
118046
+ }
118047
+
117882
118048
  idx_t DuckDB::NumberOfThreads() {
117883
118049
  return instance->NumberOfThreads();
117884
118050
  }
@@ -117907,31 +118073,52 @@ string ClientConfig::ExtractTimezoneFromConfig(ClientConfig &config) {
117907
118073
 
117908
118074
 
117909
118075
  #if defined(BUILD_ICU_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118076
+ #define ICU_STATICALLY_LOADED true
117910
118077
  #include "icu-extension.hpp"
118078
+ #else
118079
+ #define ICU_STATICALLY_LOADED false
117911
118080
  #endif
117912
118081
 
117913
118082
  #if defined(BUILD_PARQUET_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118083
+ #define PARQUET_STATICALLY_LOADED true
117914
118084
  #include "parquet-extension.hpp"
118085
+ #else
118086
+ #define PARQUET_STATICALLY_LOADED false
117915
118087
  #endif
117916
118088
 
117917
118089
  #if defined(BUILD_TPCH_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118090
+ #define TPCH_STATICALLY_LOADED true
117918
118091
  #include "tpch-extension.hpp"
118092
+ #else
118093
+ #define TPCH_STATICALLY_LOADED false
117919
118094
  #endif
117920
118095
 
117921
118096
  #if defined(BUILD_TPCDS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118097
+ #define TPCDS_STATICALLY_LOADED true
117922
118098
  #include "tpcds-extension.hpp"
118099
+ #else
118100
+ #define TPCDS_STATICALLY_LOADED false
117923
118101
  #endif
117924
118102
 
117925
118103
  #if defined(BUILD_SUBSTRAIT_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118104
+ #define SUBSTRAIT_STATICALLY_LOADED true
117926
118105
  #include "substrait-extension.hpp"
118106
+ #else
118107
+ #define SUBSTRAIT_STATICALLY_LOADED false
117927
118108
  #endif
117928
118109
 
117929
118110
  #if defined(BUILD_FTS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118111
+ #define FTS_STATICALLY_LOADED true
117930
118112
  #include "fts-extension.hpp"
118113
+ #else
118114
+ #define FTS_STATICALLY_LOADED false
117931
118115
  #endif
117932
118116
 
117933
118117
  #if defined(BUILD_HTTPFS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118118
+ #define HTTPFS_STATICALLY_LOADED true
117934
118119
  #include "httpfs-extension.hpp"
118120
+ #else
118121
+ #define HTTPFS_STATICALLY_LOADED false
117935
118122
  #endif
117936
118123
 
117937
118124
  #if defined(BUILD_VISUALIZER_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
@@ -117939,7 +118126,10 @@ string ClientConfig::ExtractTimezoneFromConfig(ClientConfig &config) {
117939
118126
  #endif
117940
118127
 
117941
118128
  #if defined(BUILD_JSON_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118129
+ #define JSON_STATICALLY_LOADED true
117942
118130
  #include "json-extension.hpp"
118131
+ #else
118132
+ #define JSON_STATICALLY_LOADED false
117943
118133
  #endif
117944
118134
 
117945
118135
  #if defined(BUILD_EXCEL_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
@@ -117952,6 +118142,37 @@ string ClientConfig::ExtractTimezoneFromConfig(ClientConfig &config) {
117952
118142
 
117953
118143
  namespace duckdb {
117954
118144
 
118145
+ //===--------------------------------------------------------------------===//
118146
+ // Default Extensions
118147
+ //===--------------------------------------------------------------------===//
118148
+ static DefaultExtension internal_extensions[] = {
118149
+ {"icu", "Adds support for time zones and collations using the ICU library", ICU_STATICALLY_LOADED},
118150
+ {"parquet", "Adds support for reading and writing parquet files", PARQUET_STATICALLY_LOADED},
118151
+ {"tpch", "Adds TPC-H data generation and query support", TPCH_STATICALLY_LOADED},
118152
+ {"tpcds", "Adds TPC-DS data generation and query support", TPCDS_STATICALLY_LOADED},
118153
+ {"substrait", "Adds support for the Substrait integration", SUBSTRAIT_STATICALLY_LOADED},
118154
+ {"fts", "Adds support for Full-Text Search Indexes", FTS_STATICALLY_LOADED},
118155
+ {"httpfs", "Adds support for reading and writing files over a HTTP(S) connection", HTTPFS_STATICALLY_LOADED},
118156
+ {"json", "Adds support for JSON operations", JSON_STATICALLY_LOADED},
118157
+ {"sqlite_scanner", "Adds support for reading SQLite database files", false},
118158
+ {"postgres_scanner", "Adds support for reading from a Postgres database", false},
118159
+ {nullptr, nullptr, false}};
118160
+
118161
+ idx_t ExtensionHelper::DefaultExtensionCount() {
118162
+ idx_t index;
118163
+ for (index = 0; internal_extensions[index].name != nullptr; index++) {
118164
+ }
118165
+ return index;
118166
+ }
118167
+
118168
+ DefaultExtension ExtensionHelper::GetDefaultExtension(idx_t index) {
118169
+ D_ASSERT(index < DefaultExtensionCount());
118170
+ return internal_extensions[index];
118171
+ }
118172
+
118173
+ //===--------------------------------------------------------------------===//
118174
+ // Load Statically Compiled Extension
118175
+ //===--------------------------------------------------------------------===//
117955
118176
  void ExtensionHelper::LoadAllExtensions(DuckDB &db) {
117956
118177
  unordered_set<string> extensions {"parquet", "icu", "tpch", "tpcds", "fts", "httpfs",
117957
118178
  "substrait", "visualizer", "json", "excel", "sqlsmith"};
@@ -117960,9 +118181,6 @@ void ExtensionHelper::LoadAllExtensions(DuckDB &db) {
117960
118181
  }
117961
118182
  }
117962
118183
 
117963
- //===--------------------------------------------------------------------===//
117964
- // Load Statically Compiled Extension
117965
- //===--------------------------------------------------------------------===//
117966
118184
  ExtensionLoadResult ExtensionHelper::LoadExtension(DuckDB &db, const std::string &extension) {
117967
118185
  return LoadExtensionInternal(db, extension, false);
117968
118186
  }
@@ -117986,28 +118204,28 @@ ExtensionLoadResult ExtensionHelper::LoadExtensionInternal(DuckDB &db, const std
117986
118204
  }
117987
118205
  #endif
117988
118206
  if (extension == "parquet") {
117989
- #if defined(BUILD_PARQUET_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118207
+ #if PARQUET_STATICALLY_LOADED
117990
118208
  db.LoadExtension<ParquetExtension>();
117991
118209
  #else
117992
118210
  // parquet extension required but not build: skip this test
117993
118211
  return ExtensionLoadResult::NOT_LOADED;
117994
118212
  #endif
117995
118213
  } else if (extension == "icu") {
117996
- #if defined(BUILD_ICU_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118214
+ #if ICU_STATICALLY_LOADED
117997
118215
  db.LoadExtension<ICUExtension>();
117998
118216
  #else
117999
118217
  // icu extension required but not build: skip this test
118000
118218
  return ExtensionLoadResult::NOT_LOADED;
118001
118219
  #endif
118002
118220
  } else if (extension == "tpch") {
118003
- #if defined(BUILD_TPCH_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118221
+ #if TPCH_STATICALLY_LOADED
118004
118222
  db.LoadExtension<TPCHExtension>();
118005
118223
  #else
118006
118224
  // icu extension required but not build: skip this test
118007
118225
  return ExtensionLoadResult::NOT_LOADED;
118008
118226
  #endif
118009
118227
  } else if (extension == "substrait") {
118010
- #if defined(BUILD_SUBSTRAIT_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118228
+ #if SUBSTRAIT_STATICALLY_LOADED
118011
118229
 
118012
118230
  db.LoadExtension<SubstraitExtension>();
118013
118231
  #else
@@ -118015,21 +118233,21 @@ ExtensionLoadResult ExtensionHelper::LoadExtensionInternal(DuckDB &db, const std
118015
118233
  return ExtensionLoadResult::NOT_LOADED;
118016
118234
  #endif
118017
118235
  } else if (extension == "tpcds") {
118018
- #if defined(BUILD_TPCDS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118236
+ #if TPCDS_STATICALLY_LOADED
118019
118237
  db.LoadExtension<TPCDSExtension>();
118020
118238
  #else
118021
118239
  // icu extension required but not build: skip this test
118022
118240
  return ExtensionLoadResult::NOT_LOADED;
118023
118241
  #endif
118024
118242
  } else if (extension == "fts") {
118025
- #if defined(BUILD_FTS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118243
+ #if FTS_STATICALLY_LOADED
118026
118244
  db.LoadExtension<FTSExtension>();
118027
118245
  #else
118028
118246
  // fts extension required but not build: skip this test
118029
118247
  return ExtensionLoadResult::NOT_LOADED;
118030
118248
  #endif
118031
118249
  } else if (extension == "httpfs") {
118032
- #if defined(BUILD_HTTPFS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118250
+ #if HTTPFS_STATICALLY_LOADED
118033
118251
  db.LoadExtension<HTTPFsExtension>();
118034
118252
  #else
118035
118253
  return ExtensionLoadResult::NOT_LOADED;
@@ -118042,7 +118260,7 @@ ExtensionLoadResult ExtensionHelper::LoadExtensionInternal(DuckDB &db, const std
118042
118260
  return ExtensionLoadResult::NOT_LOADED;
118043
118261
  #endif
118044
118262
  } else if (extension == "json") {
118045
- #if defined(BUILD_JSON_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
118263
+ #if JSON_STATICALLY_LOADED
118046
118264
  db.LoadExtension<JSONExtension>();
118047
118265
  #else
118048
118266
  // json extension required but not build: skip this test
@@ -126285,13 +126503,7 @@ const vector<string> ExtensionHelper::PathComponents() {
126285
126503
  return vector<string> {".duckdb", "extensions", DuckDB::SourceID(), DuckDB::Platform()};
126286
126504
  }
126287
126505
 
126288
- void ExtensionHelper::InstallExtension(DatabaseInstance &db, const string &extension, bool force_install) {
126289
- auto &config = DBConfig::GetConfig(db);
126290
- if (!config.enable_external_access) {
126291
- throw PermissionException("Installing extensions is disabled through configuration");
126292
- }
126293
- auto &fs = FileSystem::GetFileSystem(db);
126294
-
126506
+ string ExtensionHelper::ExtensionDirectory(FileSystem &fs) {
126295
126507
  string local_path = fs.GetHomeDirectory();
126296
126508
  if (!fs.DirectoryExists(local_path)) {
126297
126509
  throw InternalException("Can't find the home directory at " + local_path);
@@ -126303,6 +126515,17 @@ void ExtensionHelper::InstallExtension(DatabaseInstance &db, const string &exten
126303
126515
  fs.CreateDirectory(local_path);
126304
126516
  }
126305
126517
  }
126518
+ return local_path;
126519
+ }
126520
+
126521
+ void ExtensionHelper::InstallExtension(DatabaseInstance &db, const string &extension, bool force_install) {
126522
+ auto &config = DBConfig::GetConfig(db);
126523
+ if (!config.enable_external_access) {
126524
+ throw PermissionException("Installing extensions is disabled through configuration");
126525
+ }
126526
+ auto &fs = FileSystem::GetFileSystem(db);
126527
+
126528
+ string local_path = ExtensionDirectory(fs);
126306
126529
 
126307
126530
  auto extension_name = fs.ExtractBaseName(extension);
126308
126531
 
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 "8e602ba1d"
15
- #define DUCKDB_VERSION "v0.4.1-dev26"
14
+ #define DUCKDB_SOURCE_ID "b70bf98b5"
15
+ #define DUCKDB_VERSION "v0.4.1-dev29"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -18742,6 +18742,8 @@ public:
18742
18742
 
18743
18743
  DUCKDB_API static DatabaseInstance &GetDatabase(ClientContext &context);
18744
18744
 
18745
+ DUCKDB_API const unordered_set<std::string> &LoadedExtensions();
18746
+
18745
18747
  private:
18746
18748
  void Initialize(const char *path, DBConfig *config);
18747
18749