duckdb 0.3.3-dev105.0 → 0.3.3-dev149.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.3.3-dev105.0",
4
+ "version": "0.3.3-dev149.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -15826,6 +15826,10 @@ public:
15826
15826
  return "LocalFileSystem";
15827
15827
  }
15828
15828
 
15829
+ //! Returns the last Win32 error, in string format. Returns an empty string if there is no error, or on non-Windows
15830
+ //! systems.
15831
+ static std::string GetLastErrorAsString();
15832
+
15829
15833
  private:
15830
15834
  //! Set the file pointer of a file handle to a specified location. Reads and writes will happen from this location
15831
15835
  void SetFilePointer(FileHandle &handle, idx_t location);
@@ -16273,12 +16277,16 @@ void LocalFileSystem::MoveFile(const string &source, const string &target) {
16273
16277
  }
16274
16278
  }
16275
16279
 
16280
+ std::string LocalFileSystem::GetLastErrorAsString() {
16281
+ return string();
16282
+ }
16283
+
16276
16284
  #else
16277
16285
 
16278
16286
  constexpr char PIPE_PREFIX[] = "\\\\.\\pipe\\";
16279
16287
 
16280
16288
  // Returns the last Win32 error, in string format. Returns an empty string if there is no error.
16281
- std::string GetLastErrorAsString() {
16289
+ std::string LocalFileSystem::GetLastErrorAsString() {
16282
16290
  // Get the error message, if any.
16283
16291
  DWORD errorMessageID = GetLastError();
16284
16292
  if (errorMessageID == 0)
@@ -16354,7 +16362,7 @@ unique_ptr<FileHandle> LocalFileSystem::OpenFile(const string &path, uint8_t fla
16354
16362
  HANDLE hFile = CreateFileW(unicode_path.c_str(), desired_access, share_mode, NULL, creation_disposition,
16355
16363
  flags_and_attributes, NULL);
16356
16364
  if (hFile == INVALID_HANDLE_VALUE) {
16357
- auto error = GetLastErrorAsString();
16365
+ auto error = LocalFileSystem::GetLastErrorAsString();
16358
16366
  throw IOException("Cannot open file \"%s\": %s", path.c_str(), error);
16359
16367
  }
16360
16368
  auto handle = make_unique<WindowsFileHandle>(*this, path.c_str(), hFile);
@@ -16383,7 +16391,7 @@ static DWORD FSInternalRead(FileHandle &handle, HANDLE hFile, void *buffer, int6
16383
16391
  ov.hEvent = 0;
16384
16392
  auto rc = ReadFile(hFile, buffer, (DWORD)nr_bytes, &bytes_read, &ov);
16385
16393
  if (!rc) {
16386
- auto error = GetLastErrorAsString();
16394
+ auto error = LocalFileSystem::GetLastErrorAsString();
16387
16395
  throw IOException("Could not read file \"%s\" (error in ReadFile): %s", handle.path, error);
16388
16396
  }
16389
16397
  return bytes_read;
@@ -16417,7 +16425,7 @@ static DWORD FSInternalWrite(FileHandle &handle, HANDLE hFile, void *buffer, int
16417
16425
  ov.hEvent = 0;
16418
16426
  auto rc = WriteFile(hFile, buffer, (DWORD)nr_bytes, &bytes_written, &ov);
16419
16427
  if (!rc) {
16420
- auto error = GetLastErrorAsString();
16428
+ auto error = LocalFileSystem::GetLastErrorAsString();
16421
16429
  throw IOException("Could not write file \"%s\" (error in WriteFile): %s", handle.path, error);
16422
16430
  }
16423
16431
  return bytes_written;
@@ -16481,7 +16489,7 @@ void LocalFileSystem::Truncate(FileHandle &handle, int64_t new_size) {
16481
16489
  SetFilePointer(handle, new_size);
16482
16490
  // now set the end of file position
16483
16491
  if (!SetEndOfFile(hFile)) {
16484
- auto error = GetLastErrorAsString();
16492
+ auto error = LocalFileSystem::GetLastErrorAsString();
16485
16493
  throw IOException("Failure in SetEndOfFile call on file \"%s\": %s", handle.path, error);
16486
16494
  }
16487
16495
  }
@@ -42511,12 +42519,18 @@ void VectorOperations::Copy(const Vector &source, Vector &target, idx_t source_c
42511
42519
  namespace duckdb {
42512
42520
 
42513
42521
  struct HashOp {
42522
+ static const hash_t NULL_HASH = 0xbf58476d1ce4e5b9;
42523
+
42514
42524
  template <class T>
42515
42525
  static inline hash_t Operation(T input, bool is_null) {
42516
- return duckdb::Hash<T>(is_null ? duckdb::NullValue<T>() : input);
42526
+ return is_null ? NULL_HASH : duckdb::Hash<T>(input);
42517
42527
  }
42518
42528
  };
42519
42529
 
42530
+ static inline hash_t CombineHashScalar(hash_t a, hash_t b) {
42531
+ return (a * UINT64_C(0xbf58476d1ce4e5b9)) ^ b;
42532
+ }
42533
+
42520
42534
  template <bool HAS_RSEL, class T>
42521
42535
  static inline void TightLoopHash(T *__restrict ldata, hash_t *__restrict result_data, const SelectionVector *rsel,
42522
42536
  idx_t count, const SelectionVector *__restrict sel_vector, ValidityMask &mask) {
@@ -42558,7 +42572,7 @@ template <bool HAS_RSEL, bool FIRST_HASH>
42558
42572
  static inline void StructLoopHash(Vector &input, Vector &hashes, const SelectionVector *rsel, idx_t count) {
42559
42573
  auto &children = StructVector::GetEntries(input);
42560
42574
 
42561
- D_ASSERT(children.size() > 0);
42575
+ D_ASSERT(!children.empty());
42562
42576
  idx_t col_no = 0;
42563
42577
  if (HAS_RSEL) {
42564
42578
  if (FIRST_HASH) {
@@ -42588,14 +42602,81 @@ static inline void ListLoopHash(Vector &input, Vector &hashes, const SelectionVe
42588
42602
  VectorData idata;
42589
42603
  input.Orrify(count, idata);
42590
42604
  const auto ldata = (const list_entry_t *)idata.data;
42591
- for (idx_t i = 0; i < count; i++) {
42605
+
42606
+ // Hash the children into a temporary
42607
+ auto &child = ListVector::GetEntry(input);
42608
+ const auto child_count = ListVector::GetListSize(input);
42609
+
42610
+ Vector child_hashes(LogicalType::HASH, child_count);
42611
+ VectorOperations::Hash(child, child_hashes, child_count);
42612
+ auto chdata = FlatVector::GetData<hash_t>(child_hashes);
42613
+
42614
+ // Reduce the number of entries to check to the non-empty ones
42615
+ SelectionVector unprocessed(count);
42616
+ SelectionVector cursor(HAS_RSEL ? STANDARD_VECTOR_SIZE : count);
42617
+ idx_t remaining = 0;
42618
+ for (idx_t i = 0; i < count; ++i) {
42592
42619
  const idx_t ridx = HAS_RSEL ? rsel->get_index(i) : i;
42593
42620
  const auto lidx = idata.sel->get_index(ridx);
42594
42621
  const auto &entry = ldata[lidx];
42595
- if (idata.validity.RowIsValid(lidx)) {
42596
- hdata[ridx] = duckdb::Hash(entry.length);
42597
- } else {
42598
- hdata[ridx] = 0;
42622
+ if (idata.validity.RowIsValid(lidx) && entry.length > 0) {
42623
+ unprocessed.set_index(remaining++, ridx);
42624
+ cursor.set_index(ridx, entry.offset);
42625
+ } else if (FIRST_HASH) {
42626
+ hdata[ridx] = HashOp::NULL_HASH;
42627
+ }
42628
+ // Empty or NULL non-first elements have no effect.
42629
+ }
42630
+
42631
+ count = remaining;
42632
+ if (count == 0) {
42633
+ return;
42634
+ }
42635
+
42636
+ // Merge the first position hash into the main hash
42637
+ idx_t position = 1;
42638
+ if (FIRST_HASH) {
42639
+ remaining = 0;
42640
+ for (idx_t i = 0; i < count; ++i) {
42641
+ const auto ridx = unprocessed.get_index(i);
42642
+ const auto cidx = cursor.get_index(ridx);
42643
+ hdata[ridx] = chdata[cidx];
42644
+
42645
+ const auto lidx = idata.sel->get_index(ridx);
42646
+ const auto &entry = ldata[lidx];
42647
+ if (entry.length > position) {
42648
+ // Entry still has values to hash
42649
+ unprocessed.set_index(remaining++, ridx);
42650
+ cursor.set_index(ridx, cidx + 1);
42651
+ }
42652
+ }
42653
+ count = remaining;
42654
+ if (count == 0) {
42655
+ return;
42656
+ }
42657
+ ++position;
42658
+ }
42659
+
42660
+ // Combine the hashes for the remaining positions until there are none left
42661
+ for (;; ++position) {
42662
+ remaining = 0;
42663
+ for (idx_t i = 0; i < count; ++i) {
42664
+ const auto ridx = unprocessed.get_index(i);
42665
+ const auto cidx = cursor.get_index(ridx);
42666
+ hdata[ridx] = CombineHashScalar(hdata[ridx], chdata[cidx]);
42667
+
42668
+ const auto lidx = idata.sel->get_index(ridx);
42669
+ const auto &entry = ldata[lidx];
42670
+ if (entry.length > position) {
42671
+ // Entry still has values to hash
42672
+ unprocessed.set_index(remaining++, ridx);
42673
+ cursor.set_index(ridx, cidx + 1);
42674
+ }
42675
+ }
42676
+
42677
+ count = remaining;
42678
+ if (count == 0) {
42679
+ break;
42599
42680
  }
42600
42681
  }
42601
42682
  }
@@ -42664,10 +42745,6 @@ void VectorOperations::Hash(Vector &input, Vector &result, const SelectionVector
42664
42745
  HashTypeSwitch<true>(input, result, &sel, count);
42665
42746
  }
42666
42747
 
42667
- static inline hash_t CombineHashScalar(hash_t a, hash_t b) {
42668
- return (a * UINT64_C(0xbf58476d1ce4e5b9)) ^ b;
42669
- }
42670
-
42671
42748
  template <bool HAS_RSEL, class T>
42672
42749
  static inline void TightLoopCombineHashConstant(T *__restrict ldata, hash_t constant_hash, hash_t *__restrict hash_data,
42673
42750
  const SelectionVector *rsel, idx_t count,
@@ -80222,6 +80299,10 @@ struct AliasFun {
80222
80299
  static void RegisterFunction(BuiltinFunctions &set);
80223
80300
  };
80224
80301
 
80302
+ struct HashFun {
80303
+ static void RegisterFunction(BuiltinFunctions &set);
80304
+ };
80305
+
80225
80306
  struct LeastFun {
80226
80307
  static void RegisterFunction(BuiltinFunctions &set);
80227
80308
  };
@@ -80423,6 +80504,21 @@ void CurrentSettingFun::RegisterFunction(BuiltinFunctions &set) {
80423
80504
  } // namespace duckdb
80424
80505
 
80425
80506
 
80507
+ namespace duckdb {
80508
+
80509
+ static void HashFunction(DataChunk &args, ExpressionState &state, Vector &result) {
80510
+ args.Hash(result);
80511
+ }
80512
+
80513
+ void HashFun::RegisterFunction(BuiltinFunctions &set) {
80514
+ auto hash_fun = ScalarFunction("hash", {LogicalType::ANY}, LogicalType::HASH, HashFunction);
80515
+ hash_fun.varargs = LogicalType::ANY;
80516
+ set.AddFunction(hash_fun);
80517
+ }
80518
+
80519
+ } // namespace duckdb
80520
+
80521
+
80426
80522
 
80427
80523
  namespace duckdb {
80428
80524
 
@@ -80623,6 +80719,7 @@ namespace duckdb {
80623
80719
 
80624
80720
  void BuiltinFunctions::RegisterGenericFunctions() {
80625
80721
  Register<AliasFun>();
80722
+ Register<HashFun>();
80626
80723
  Register<LeastFun>();
80627
80724
  Register<GreatestFun>();
80628
80725
  Register<StatsFun>();
@@ -101741,35 +101838,35 @@ void DuckDB::SetExtensionLoaded(const std::string &name) {
101741
101838
 
101742
101839
 
101743
101840
 
101744
- #ifdef BUILD_ICU_EXTENSION
101841
+ #if defined(BUILD_ICU_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101745
101842
  #include "icu-extension.hpp"
101746
101843
  #endif
101747
101844
 
101748
- #ifdef BUILD_PARQUET_EXTENSION
101845
+ #if defined(BUILD_PARQUET_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101749
101846
  #include "parquet-extension.hpp"
101750
101847
  #endif
101751
101848
 
101752
- #ifdef BUILD_TPCH_EXTENSION
101849
+ #if defined(BUILD_TPCH_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101753
101850
  #include "tpch-extension.hpp"
101754
101851
  #endif
101755
101852
 
101756
- #ifdef BUILD_TPCDS_EXTENSION
101853
+ #if defined(BUILD_TPCDS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101757
101854
  #include "tpcds-extension.hpp"
101758
101855
  #endif
101759
101856
 
101760
- #ifdef BUILD_FTS_EXTENSION
101857
+ #if defined(BUILD_FTS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101761
101858
  #include "fts-extension.hpp"
101762
101859
  #endif
101763
101860
 
101764
- #ifdef BUILD_HTTPFS_EXTENSION
101861
+ #if defined(BUILD_HTTPFS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101765
101862
  #include "httpfs-extension.hpp"
101766
101863
  #endif
101767
101864
 
101768
- #ifdef BUILD_VISUALIZER_EXTENSION
101865
+ #if defined(BUILD_VISUALIZER_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101769
101866
  #include "visualizer-extension.hpp"
101770
101867
  #endif
101771
101868
 
101772
- #ifdef BUILD_EXCEL_EXTENSION
101869
+ #if defined(BUILD_EXCEL_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101773
101870
  #include "excel-extension.hpp"
101774
101871
  #endif
101775
101872
 
@@ -101808,55 +101905,55 @@ ExtensionLoadResult ExtensionHelper::LoadExtensionInternal(DuckDB &db, const std
101808
101905
  }
101809
101906
  #endif
101810
101907
  if (extension == "parquet") {
101811
- #ifdef BUILD_PARQUET_EXTENSION
101908
+ #if defined(BUILD_PARQUET_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101812
101909
  db.LoadExtension<ParquetExtension>();
101813
101910
  #else
101814
101911
  // parquet extension required but not build: skip this test
101815
101912
  return ExtensionLoadResult::NOT_LOADED;
101816
101913
  #endif
101817
101914
  } else if (extension == "icu") {
101818
- #ifdef BUILD_ICU_EXTENSION
101915
+ #if defined(BUILD_ICU_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101819
101916
  db.LoadExtension<ICUExtension>();
101820
101917
  #else
101821
101918
  // icu extension required but not build: skip this test
101822
101919
  return ExtensionLoadResult::NOT_LOADED;
101823
101920
  #endif
101824
101921
  } else if (extension == "tpch") {
101825
- #ifdef BUILD_TPCH_EXTENSION
101922
+ #if defined(BUILD_TPCH_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101826
101923
  db.LoadExtension<TPCHExtension>();
101827
101924
  #else
101828
101925
  // icu extension required but not build: skip this test
101829
101926
  return ExtensionLoadResult::NOT_LOADED;
101830
101927
  #endif
101831
101928
  } else if (extension == "tpcds") {
101832
- #ifdef BUILD_TPCDS_EXTENSION
101929
+ #if defined(BUILD_TPCDS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101833
101930
  db.LoadExtension<TPCDSExtension>();
101834
101931
  #else
101835
101932
  // icu extension required but not build: skip this test
101836
101933
  return ExtensionLoadResult::NOT_LOADED;
101837
101934
  #endif
101838
101935
  } else if (extension == "fts") {
101839
- #ifdef BUILD_FTS_EXTENSION
101936
+ #if defined(BUILD_FTS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101840
101937
  db.LoadExtension<FTSExtension>();
101841
101938
  #else
101842
101939
  // fts extension required but not build: skip this test
101843
101940
  return ExtensionLoadResult::NOT_LOADED;
101844
101941
  #endif
101845
101942
  } else if (extension == "httpfs") {
101846
- #ifdef BUILD_HTTPFS_EXTENSION
101943
+ #if defined(BUILD_HTTPFS_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101847
101944
  db.LoadExtension<HTTPFsExtension>();
101848
101945
  #else
101849
101946
  return ExtensionLoadResult::NOT_LOADED;
101850
101947
  #endif
101851
101948
  } else if (extension == "visualizer") {
101852
- #ifdef BUILD_VISUALIZER_EXTENSION
101949
+ #if defined(BUILD_VISUALIZER_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101853
101950
  db.LoadExtension<VisualizerExtension>();
101854
101951
  #else
101855
101952
  // visualizer extension required but not build: skip this test
101856
101953
  return ExtensionLoadResult::NOT_LOADED;
101857
101954
  #endif
101858
101955
  } else if (extension == "excel") {
101859
- #ifdef BUILD_EXCEL_EXTENSION
101956
+ #if defined(BUILD_EXCEL_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
101860
101957
  db.LoadExtension<EXCELExtension>();
101861
101958
  #else
101862
101959
  // excel extension required but not build: skip this test
@@ -109432,6 +109529,7 @@ void ExtensionHelper::InstallExtension(DatabaseInstance &db, const string &exten
109432
109529
 
109433
109530
 
109434
109531
 
109532
+
109435
109533
  #ifndef _WIN32
109436
109534
  #include <dlfcn.h>
109437
109535
  #else
@@ -109452,6 +109550,17 @@ void *dlsym(void *handle, const char *name) {
109452
109550
  D_ASSERT(handle);
109453
109551
  return (void *)GetProcAddress((HINSTANCE)handle, name);
109454
109552
  }
109553
+
109554
+ std::string GetDLError(void) {
109555
+ return LocalFileSystem::GetLastErrorAsString();
109556
+ }
109557
+
109558
+ #else
109559
+
109560
+ std::string GetDLError(void) {
109561
+ return dlerror();
109562
+ }
109563
+
109455
109564
  #endif
109456
109565
 
109457
109566
  } // namespace duckdb
@@ -109469,7 +109578,7 @@ template <class T>
109469
109578
  static T LoadFunctionFromDLL(void *dll, const string &function_name, const string &filename) {
109470
109579
  auto function = dlsym(dll, function_name.c_str());
109471
109580
  if (!function) {
109472
- throw IOException("File \"%s\" did not contain function \"%s\"", filename, function_name);
109581
+ throw IOException("File \"%s\" did not contain function \"%s\": %s", filename, function_name, GetDLError());
109473
109582
  }
109474
109583
  return (T)function;
109475
109584
  }
@@ -109497,7 +109606,7 @@ void ExtensionHelper::LoadExternalExtension(DatabaseInstance &db, const string &
109497
109606
  }
109498
109607
  auto lib_hdl = dlopen(filename.c_str(), RTLD_LAZY | RTLD_LOCAL);
109499
109608
  if (!lib_hdl) {
109500
- throw IOException("File \"%s\" could not be loaded", filename);
109609
+ throw IOException("File \"%s\" could not be loaded: %s", filename, GetDLError());
109501
109610
  }
109502
109611
 
109503
109612
  auto basename = fs.ExtractBaseName(filename);
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 "e25230541"
15
- #define DUCKDB_VERSION "v0.3.3-dev105"
14
+ #define DUCKDB_SOURCE_ID "2230af054"
15
+ #define DUCKDB_VERSION "v0.3.3-dev149"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //