duckdb 0.3.2-dev1046.0 → 0.3.2-dev1095.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.2-dev1046.0",
4
+ "version": "0.3.2-dev1095.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -13124,6 +13124,9 @@ extern "C" WINBASEAPI BOOL WINAPI GetPhysicallyInstalledSystemMemory(PULONGLONG)
13124
13124
 
13125
13125
  namespace duckdb {
13126
13126
 
13127
+ FileSystem::~FileSystem() {
13128
+ }
13129
+
13127
13130
  FileSystem &FileSystem::GetFileSystem(ClientContext &context) {
13128
13131
  return *context.db->config.file_system;
13129
13132
  }
@@ -13347,6 +13350,12 @@ bool FileSystem::OnDiskFile(FileHandle &handle) {
13347
13350
  }
13348
13351
  // LCOV_EXCL_STOP
13349
13352
 
13353
+ FileHandle::FileHandle(FileSystem &file_system, string path_p) : file_system(file_system), path(move(path_p)) {
13354
+ }
13355
+
13356
+ FileHandle::~FileHandle() {
13357
+ }
13358
+
13350
13359
  int64_t FileHandle::Read(void *buffer, idx_t nr_bytes) {
13351
13360
  return file_system.Read(*this, buffer, nr_bytes);
13352
13361
  }
@@ -78550,7 +78559,8 @@ string StrTimeFormat::ParseFormatSpecifier(const string &format_string, StrTimeF
78550
78559
  break;
78551
78560
  case 'c':
78552
78561
  case 'x':
78553
- case 'X': {
78562
+ case 'X':
78563
+ case 'T': {
78554
78564
  string subformat;
78555
78565
  if (format_char == 'c') {
78556
78566
  // %c: Locale’s appropriate date and time representation.
@@ -78560,7 +78570,7 @@ string StrTimeFormat::ParseFormatSpecifier(const string &format_string, StrTimeF
78560
78570
  // %x - Locale’s appropriate date representation.
78561
78571
  // we push the ISO date format here
78562
78572
  subformat = "%Y-%m-%d";
78563
- } else if (format_char == 'X') {
78573
+ } else if (format_char == 'X' || format_char == 'T') {
78564
78574
  // %X - Locale’s appropriate time representation.
78565
78575
  // we push the ISO time format here
78566
78576
  subformat = "%H:%M:%S";
@@ -79035,7 +79045,18 @@ bool StrpTimeFormat::Parse(string_t str, ParseResult &result) {
79035
79045
  result_data[4] -= minute_offset;
79036
79046
  break;
79037
79047
  }
79038
-
79048
+ case StrTimeSpecifier::TZ_NAME: {
79049
+ // skip leading spaces
79050
+ while (pos < size && StringUtil::CharacterIsSpace(data[pos])) {
79051
+ pos++;
79052
+ }
79053
+ // stop when we encounter a space or the end of the string
79054
+ while (pos < size && !StringUtil::CharacterIsSpace(data[pos])) {
79055
+ pos++;
79056
+ }
79057
+ // FIXME: actually use the timestamp...
79058
+ break;
79059
+ }
79039
79060
  default:
79040
79061
  throw NotImplementedException("Unsupported specifier for strptime");
79041
79062
  }
@@ -79134,6 +79155,20 @@ static unique_ptr<FunctionData> StrpTimeBindFunction(ClientContext &context, Sca
79134
79155
  return make_unique<StrpTimeBindData>(format);
79135
79156
  }
79136
79157
 
79158
+ StrpTimeFormat::ParseResult StrpTimeFormat::Parse(const string &format_string, const string &text) {
79159
+ StrpTimeFormat format;
79160
+ format.format_specifier = format_string;
79161
+ string error = StrTimeFormat::ParseFormatSpecifier(format_string, format);
79162
+ if (!error.empty()) {
79163
+ throw InvalidInputException("Failed to parse format specifier %s: %s", format_string, error);
79164
+ }
79165
+ StrpTimeFormat::ParseResult result;
79166
+ if (!format.Parse(text, result)) {
79167
+ throw InvalidInputException("Failed to parse string \"%s\" with format specifier \"%s\"", text, format_string);
79168
+ }
79169
+ return result;
79170
+ }
79171
+
79137
79172
  string StrpTimeFormat::FormatStrpTimeError(const string &input, idx_t position) {
79138
79173
  if (position == DConstants::INVALID_INDEX) {
79139
79174
  return string();
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 "59838eae3"
15
- #define DUCKDB_VERSION "0.3.2-dev1046"
14
+ #define DUCKDB_SOURCE_ID "b8f633b51"
15
+ #define DUCKDB_VERSION "0.3.2-dev1095"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -1812,30 +1812,28 @@ enum class FileType {
1812
1812
 
1813
1813
  struct FileHandle {
1814
1814
  public:
1815
- FileHandle(FileSystem &file_system, string path) : file_system(file_system), path(path) {
1816
- }
1815
+ DUCKDB_API FileHandle(FileSystem &file_system, string path);
1817
1816
  FileHandle(const FileHandle &) = delete;
1818
- virtual ~FileHandle() {
1819
- }
1817
+ DUCKDB_API virtual ~FileHandle();
1820
1818
 
1821
- int64_t Read(void *buffer, idx_t nr_bytes);
1822
- int64_t Write(void *buffer, idx_t nr_bytes);
1823
- void Read(void *buffer, idx_t nr_bytes, idx_t location);
1824
- void Write(void *buffer, idx_t nr_bytes, idx_t location);
1825
- void Seek(idx_t location);
1826
- void Reset();
1827
- idx_t SeekPosition();
1828
- void Sync();
1829
- void Truncate(int64_t new_size);
1830
- string ReadLine();
1819
+ DUCKDB_API int64_t Read(void *buffer, idx_t nr_bytes);
1820
+ DUCKDB_API int64_t Write(void *buffer, idx_t nr_bytes);
1821
+ DUCKDB_API void Read(void *buffer, idx_t nr_bytes, idx_t location);
1822
+ DUCKDB_API void Write(void *buffer, idx_t nr_bytes, idx_t location);
1823
+ DUCKDB_API void Seek(idx_t location);
1824
+ DUCKDB_API void Reset();
1825
+ DUCKDB_API idx_t SeekPosition();
1826
+ DUCKDB_API void Sync();
1827
+ DUCKDB_API void Truncate(int64_t new_size);
1828
+ DUCKDB_API string ReadLine();
1831
1829
 
1832
- bool CanSeek();
1833
- bool OnDiskFile();
1834
- idx_t GetFileSize();
1835
- FileType GetType();
1830
+ DUCKDB_API bool CanSeek();
1831
+ DUCKDB_API bool OnDiskFile();
1832
+ DUCKDB_API idx_t GetFileSize();
1833
+ DUCKDB_API FileType GetType();
1836
1834
 
1837
1835
  //! Closes the file handle.
1838
- virtual void Close() = 0;
1836
+ DUCKDB_API virtual void Close() = 0;
1839
1837
 
1840
1838
  public:
1841
1839
  FileSystem &file_system;
@@ -1862,107 +1860,107 @@ public:
1862
1860
 
1863
1861
  class FileSystem {
1864
1862
  public:
1865
- virtual ~FileSystem() {
1866
- }
1863
+ DUCKDB_API virtual ~FileSystem();
1867
1864
 
1868
1865
  public:
1869
- static constexpr FileLockType DEFAULT_LOCK = FileLockType::NO_LOCK;
1870
- static constexpr FileCompressionType DEFAULT_COMPRESSION = FileCompressionType::UNCOMPRESSED;
1871
- static FileSystem &GetFileSystem(ClientContext &context);
1872
- static FileSystem &GetFileSystem(DatabaseInstance &db);
1873
- static FileOpener *GetFileOpener(ClientContext &context);
1866
+ DUCKDB_API static constexpr FileLockType DEFAULT_LOCK = FileLockType::NO_LOCK;
1867
+ DUCKDB_API static constexpr FileCompressionType DEFAULT_COMPRESSION = FileCompressionType::UNCOMPRESSED;
1868
+ DUCKDB_API static FileSystem &GetFileSystem(ClientContext &context);
1869
+ DUCKDB_API static FileSystem &GetFileSystem(DatabaseInstance &db);
1870
+ DUCKDB_API static FileOpener *GetFileOpener(ClientContext &context);
1874
1871
 
1875
- virtual unique_ptr<FileHandle> OpenFile(const string &path, uint8_t flags, FileLockType lock = DEFAULT_LOCK,
1876
- FileCompressionType compression = DEFAULT_COMPRESSION,
1877
- FileOpener *opener = nullptr);
1872
+ DUCKDB_API virtual unique_ptr<FileHandle> OpenFile(const string &path, uint8_t flags,
1873
+ FileLockType lock = DEFAULT_LOCK,
1874
+ FileCompressionType compression = DEFAULT_COMPRESSION,
1875
+ FileOpener *opener = nullptr);
1878
1876
 
1879
1877
  //! Read exactly nr_bytes from the specified location in the file. Fails if nr_bytes could not be read. This is
1880
1878
  //! equivalent to calling SetFilePointer(location) followed by calling Read().
1881
- virtual void Read(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location);
1879
+ DUCKDB_API virtual void Read(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location);
1882
1880
  //! Write exactly nr_bytes to the specified location in the file. Fails if nr_bytes could not be read. This is
1883
1881
  //! equivalent to calling SetFilePointer(location) followed by calling Write().
1884
- virtual void Write(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location);
1882
+ DUCKDB_API virtual void Write(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location);
1885
1883
  //! Read nr_bytes from the specified file into the buffer, moving the file pointer forward by nr_bytes. Returns the
1886
1884
  //! amount of bytes read.
1887
- virtual int64_t Read(FileHandle &handle, void *buffer, int64_t nr_bytes);
1885
+ DUCKDB_API virtual int64_t Read(FileHandle &handle, void *buffer, int64_t nr_bytes);
1888
1886
  //! Write nr_bytes from the buffer into the file, moving the file pointer forward by nr_bytes.
1889
- virtual int64_t Write(FileHandle &handle, void *buffer, int64_t nr_bytes);
1887
+ DUCKDB_API virtual int64_t Write(FileHandle &handle, void *buffer, int64_t nr_bytes);
1890
1888
 
1891
1889
  //! Returns the file size of a file handle, returns -1 on error
1892
- virtual int64_t GetFileSize(FileHandle &handle);
1890
+ DUCKDB_API virtual int64_t GetFileSize(FileHandle &handle);
1893
1891
  //! Returns the file last modified time of a file handle, returns timespec with zero on all attributes on error
1894
- virtual time_t GetLastModifiedTime(FileHandle &handle);
1892
+ DUCKDB_API virtual time_t GetLastModifiedTime(FileHandle &handle);
1895
1893
  //! Returns the file last modified time of a file handle, returns timespec with zero on all attributes on error
1896
- virtual FileType GetFileType(FileHandle &handle);
1894
+ DUCKDB_API virtual FileType GetFileType(FileHandle &handle);
1897
1895
  //! Truncate a file to a maximum size of new_size, new_size should be smaller than or equal to the current size of
1898
1896
  //! the file
1899
- virtual void Truncate(FileHandle &handle, int64_t new_size);
1897
+ DUCKDB_API virtual void Truncate(FileHandle &handle, int64_t new_size);
1900
1898
 
1901
1899
  //! Check if a directory exists
1902
- virtual bool DirectoryExists(const string &directory);
1900
+ DUCKDB_API virtual bool DirectoryExists(const string &directory);
1903
1901
  //! Create a directory if it does not exist
1904
- virtual void CreateDirectory(const string &directory);
1902
+ DUCKDB_API virtual void CreateDirectory(const string &directory);
1905
1903
  //! Recursively remove a directory and all files in it
1906
- virtual void RemoveDirectory(const string &directory);
1904
+ DUCKDB_API virtual void RemoveDirectory(const string &directory);
1907
1905
  //! List files in a directory, invoking the callback method for each one with (filename, is_dir)
1908
- virtual bool ListFiles(const string &directory, const std::function<void(string, bool)> &callback);
1906
+ DUCKDB_API virtual bool ListFiles(const string &directory, const std::function<void(string, bool)> &callback);
1909
1907
  //! Move a file from source path to the target, StorageManager relies on this being an atomic action for ACID
1910
1908
  //! properties
1911
- virtual void MoveFile(const string &source, const string &target);
1909
+ DUCKDB_API virtual void MoveFile(const string &source, const string &target);
1912
1910
  //! Check if a file exists
1913
- virtual bool FileExists(const string &filename);
1911
+ DUCKDB_API virtual bool FileExists(const string &filename);
1914
1912
  //! Remove a file from disk
1915
- virtual void RemoveFile(const string &filename);
1913
+ DUCKDB_API virtual void RemoveFile(const string &filename);
1916
1914
  //! Sync a file handle to disk
1917
- virtual void FileSync(FileHandle &handle);
1915
+ DUCKDB_API virtual void FileSync(FileHandle &handle);
1918
1916
 
1919
1917
  //! Sets the working directory
1920
- static void SetWorkingDirectory(const string &path);
1918
+ DUCKDB_API static void SetWorkingDirectory(const string &path);
1921
1919
  //! Gets the working directory
1922
- static string GetWorkingDirectory();
1920
+ DUCKDB_API static string GetWorkingDirectory();
1923
1921
  //! Gets the users home directory
1924
- static string GetHomeDirectory();
1922
+ DUCKDB_API static string GetHomeDirectory();
1925
1923
  //! Returns the system-available memory in bytes
1926
- static idx_t GetAvailableMemory();
1924
+ DUCKDB_API static idx_t GetAvailableMemory();
1927
1925
  //! Path separator for the current file system
1928
- static string PathSeparator();
1926
+ DUCKDB_API static string PathSeparator();
1929
1927
  //! Join two paths together
1930
- static string JoinPath(const string &a, const string &path);
1928
+ DUCKDB_API static string JoinPath(const string &a, const string &path);
1931
1929
  //! Convert separators in a path to the local separators (e.g. convert "/" into \\ on windows)
1932
- static string ConvertSeparators(const string &path);
1930
+ DUCKDB_API static string ConvertSeparators(const string &path);
1933
1931
  //! Extract the base name of a file (e.g. if the input is lib/example.dll the base name is example)
1934
- static string ExtractBaseName(const string &path);
1932
+ DUCKDB_API static string ExtractBaseName(const string &path);
1935
1933
 
1936
1934
  //! Runs a glob on the file system, returning a list of matching files
1937
- virtual vector<string> Glob(const string &path);
1935
+ DUCKDB_API virtual vector<string> Glob(const string &path);
1938
1936
 
1939
1937
  //! registers a sub-file system to handle certain file name prefixes, e.g. http:// etc.
1940
- virtual void RegisterSubSystem(unique_ptr<FileSystem> sub_fs);
1941
- virtual void RegisterSubSystem(FileCompressionType compression_type, unique_ptr<FileSystem> fs);
1938
+ DUCKDB_API virtual void RegisterSubSystem(unique_ptr<FileSystem> sub_fs);
1939
+ DUCKDB_API virtual void RegisterSubSystem(FileCompressionType compression_type, unique_ptr<FileSystem> fs);
1942
1940
 
1943
1941
  //! Whether or not a sub-system can handle a specific file path
1944
- virtual bool CanHandleFile(const string &fpath);
1942
+ DUCKDB_API virtual bool CanHandleFile(const string &fpath);
1945
1943
 
1946
1944
  //! Set the file pointer of a file handle to a specified location. Reads and writes will happen from this location
1947
- virtual void Seek(FileHandle &handle, idx_t location);
1945
+ DUCKDB_API virtual void Seek(FileHandle &handle, idx_t location);
1948
1946
  //! Reset a file to the beginning (equivalent to Seek(handle, 0) for simple files)
1949
- virtual void Reset(FileHandle &handle);
1950
- virtual idx_t SeekPosition(FileHandle &handle);
1947
+ DUCKDB_API virtual void Reset(FileHandle &handle);
1948
+ DUCKDB_API virtual idx_t SeekPosition(FileHandle &handle);
1951
1949
 
1952
1950
  //! Whether or not we can seek into the file
1953
- virtual bool CanSeek();
1951
+ DUCKDB_API virtual bool CanSeek();
1954
1952
  //! Whether or not the FS handles plain files on disk. This is relevant for certain optimizations, as random reads
1955
1953
  //! in a file on-disk are much cheaper than e.g. random reads in a file over the network
1956
- virtual bool OnDiskFile(FileHandle &handle);
1954
+ DUCKDB_API virtual bool OnDiskFile(FileHandle &handle);
1957
1955
 
1958
- virtual unique_ptr<FileHandle> OpenCompressedFile(unique_ptr<FileHandle> handle, bool write);
1956
+ DUCKDB_API virtual unique_ptr<FileHandle> OpenCompressedFile(unique_ptr<FileHandle> handle, bool write);
1959
1957
 
1960
1958
  //! Create a LocalFileSystem.
1961
- static unique_ptr<FileSystem> CreateLocal();
1959
+ DUCKDB_API static unique_ptr<FileSystem> CreateLocal();
1962
1960
 
1963
1961
  protected:
1964
1962
  //! Return the name of the filesytem. Used for forming diagnosis messages.
1965
- virtual std::string GetName() const = 0;
1963
+ DUCKDB_API virtual std::string GetName() const = 0;
1966
1964
  };
1967
1965
 
1968
1966
  } // namespace duckdb
@@ -11506,17 +11504,17 @@ public:
11506
11504
  DBConfig config;
11507
11505
 
11508
11506
  public:
11509
- StorageManager &GetStorageManager();
11510
- Catalog &GetCatalog();
11511
- FileSystem &GetFileSystem();
11512
- TransactionManager &GetTransactionManager();
11513
- TaskScheduler &GetScheduler();
11514
- ObjectCache &GetObjectCache();
11515
- ConnectionManager &GetConnectionManager();
11507
+ DUCKDB_API StorageManager &GetStorageManager();
11508
+ DUCKDB_API Catalog &GetCatalog();
11509
+ DUCKDB_API FileSystem &GetFileSystem();
11510
+ DUCKDB_API TransactionManager &GetTransactionManager();
11511
+ DUCKDB_API TaskScheduler &GetScheduler();
11512
+ DUCKDB_API ObjectCache &GetObjectCache();
11513
+ DUCKDB_API ConnectionManager &GetConnectionManager();
11516
11514
 
11517
11515
  idx_t NumberOfThreads();
11518
11516
 
11519
- static DatabaseInstance &GetDatabase(ClientContext &context);
11517
+ DUCKDB_API static DatabaseInstance &GetDatabase(ClientContext &context);
11520
11518
 
11521
11519
  private:
11522
11520
  void Initialize(const char *path, DBConfig *config);
@@ -20513,7 +20511,7 @@ struct StrfTimeFormat : public StrTimeFormat {
20513
20511
  void FormatString(date_t date, int32_t data[7], char *target);
20514
20512
  void FormatString(date_t date, dtime_t time, char *target);
20515
20513
 
20516
- static string Format(timestamp_t timestamp, const string &format);
20514
+ DUCKDB_API static string Format(timestamp_t timestamp, const string &format);
20517
20515
 
20518
20516
  protected:
20519
20517
  //! The variable-length specifiers. To determine total string size, these need to be checked.
@@ -20547,9 +20545,14 @@ public:
20547
20545
  timestamp_t ToTimestamp();
20548
20546
  string FormatError(string_t input, const string &format_specifier);
20549
20547
  };
20548
+
20549
+ public:
20550
20550
  //! The full format specifier, for error messages
20551
20551
  string format_specifier;
20552
20552
 
20553
+ public:
20554
+ DUCKDB_API static ParseResult Parse(const string &format, const string &text);
20555
+
20553
20556
  bool Parse(string_t str, ParseResult &result);
20554
20557
 
20555
20558
  bool TryParseDate(string_t str, date_t &result, string &error_message);