duckdb 0.3.2-dev277.0 → 0.3.2-dev281.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-dev277.0",
4
+ "version": "0.3.2-dev281.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -21229,21 +21229,37 @@ idx_t LocalFileSystem::GetFilePointer(FileHandle &handle) {
21229
21229
  return ((WindowsFileHandle &)handle).position;
21230
21230
  }
21231
21231
 
21232
- void LocalFileSystem::Read(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location) {
21233
- HANDLE hFile = ((WindowsFileHandle &)handle).fd;
21234
- DWORD bytes_read;
21232
+ static DWORD FSInternalRead(FileHandle &handle, HANDLE hFile, void *buffer, int64_t nr_bytes, idx_t location) {
21233
+ DWORD bytes_read = 0;
21234
+ bool overlapped_read = false;
21235
21235
  OVERLAPPED ov = {};
21236
21236
  ov.Internal = 0;
21237
21237
  ov.InternalHigh = 0;
21238
21238
  ov.Offset = location & 0xFFFFFFFF;
21239
21239
  ov.OffsetHigh = location >> 32;
21240
21240
  ov.hEvent = 0;
21241
- ReadFile(hFile, buffer, (DWORD)nr_bytes, NULL, &ov);
21242
- auto rc = GetOverlappedResult(hFile, &ov, &bytes_read, true);
21241
+ auto rc = ReadFile(hFile, buffer, (DWORD)nr_bytes, &bytes_read, &ov);
21243
21242
  if (rc == 0) {
21244
- auto error = GetLastErrorAsString();
21245
- throw IOException("Could not read file \"%s\": %s", handle.path, error);
21243
+ if (GetLastError() != ERROR_IO_PENDING) {
21244
+ auto error = GetLastErrorAsString();
21245
+ throw IOException("Could not read file \"%s\" (error in ReadFile): %s", handle.path, error);
21246
+ } else {
21247
+ overlapped_read = true;
21248
+ }
21246
21249
  }
21250
+ if (overlapped_read) {
21251
+ rc = GetOverlappedResult(hFile, &ov, &bytes_read, true);
21252
+ if (rc == 0) {
21253
+ auto error = GetLastErrorAsString();
21254
+ throw IOException("Could not read file \"%s\" (error in GetOverlappedResult): %s", handle.path, error);
21255
+ }
21256
+ }
21257
+ return bytes_read;
21258
+ }
21259
+
21260
+ void LocalFileSystem::Read(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location) {
21261
+ HANDLE hFile = ((WindowsFileHandle &)handle).fd;
21262
+ auto bytes_read = FSInternalRead(handle, hFile, buffer, nr_bytes, location);
21247
21263
  if (bytes_read != nr_bytes) {
21248
21264
  throw IOException("Could not read all bytes from file \"%s\": wanted=%lld read=%lld", handle.path, nr_bytes,
21249
21265
  bytes_read);
@@ -21252,40 +21268,44 @@ void LocalFileSystem::Read(FileHandle &handle, void *buffer, int64_t nr_bytes, i
21252
21268
 
21253
21269
  int64_t LocalFileSystem::Read(FileHandle &handle, void *buffer, int64_t nr_bytes) {
21254
21270
  HANDLE hFile = ((WindowsFileHandle &)handle).fd;
21255
- DWORD bytes_read;
21256
21271
  auto &pos = ((WindowsFileHandle &)handle).position;
21257
- OVERLAPPED ov = {};
21258
- ov.Internal = 0;
21259
- ov.InternalHigh = 0;
21260
- ov.Offset = pos & 0xFFFFFFFF;
21261
- ov.OffsetHigh = pos >> 32;
21262
- ov.hEvent = 0;
21263
21272
  auto n = std::min<idx_t>(std::max<idx_t>(GetFileSize(handle), pos) - pos, nr_bytes);
21264
- ReadFile(hFile, buffer, (DWORD)n, NULL, &ov);
21265
- auto rc = GetOverlappedResult(hFile, &ov, &bytes_read, true);
21266
- if (rc == 0) {
21267
- auto error = GetLastErrorAsString();
21268
- throw IOException("Could not read file \"%s\": %s", handle.path, error);
21269
- }
21273
+ auto bytes_read = FSInternalRead(handle, hFile, buffer, n, pos);
21270
21274
  pos += bytes_read;
21271
21275
  return bytes_read;
21272
21276
  }
21273
21277
 
21274
- void LocalFileSystem::Write(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location) {
21275
- HANDLE hFile = ((WindowsFileHandle &)handle).fd;
21276
- DWORD bytes_written;
21278
+ static DWORD FSInternalWrite(FileHandle &handle, HANDLE hFile, void *buffer, int64_t nr_bytes, idx_t location) {
21279
+ DWORD bytes_written = 0;
21280
+ bool overlapped_write = false;
21277
21281
  OVERLAPPED ov = {};
21278
21282
  ov.Internal = 0;
21279
21283
  ov.InternalHigh = 0;
21280
21284
  ov.Offset = location & 0xFFFFFFFF;
21281
21285
  ov.OffsetHigh = location >> 32;
21282
21286
  ov.hEvent = 0;
21283
- WriteFile(hFile, buffer, (DWORD)nr_bytes, NULL, &ov);
21284
- auto rc = GetOverlappedResult(hFile, &ov, &bytes_written, true);
21287
+ auto rc = WriteFile(hFile, buffer, (DWORD)nr_bytes, &bytes_written, &ov);
21285
21288
  if (rc == 0) {
21286
- auto error = GetLastErrorAsString();
21287
- throw IOException("Could not write file \"%s\": %s", handle.path, error);
21289
+ if (GetLastError() != ERROR_IO_PENDING) {
21290
+ auto error = GetLastErrorAsString();
21291
+ throw IOException("Could not write file \"%s\" (error in WriteFile): %s", handle.path, error);
21292
+ } else {
21293
+ overlapped_write = true;
21294
+ }
21288
21295
  }
21296
+ if (overlapped_write) {
21297
+ rc = GetOverlappedResult(hFile, &ov, &bytes_written, true);
21298
+ if (rc == 0) {
21299
+ auto error = GetLastErrorAsString();
21300
+ throw IOException("Could not write file \"%s\" (error in GetOverlappedResult): %s", handle.path, error);
21301
+ }
21302
+ }
21303
+ return bytes_written;
21304
+ }
21305
+
21306
+ void LocalFileSystem::Write(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location) {
21307
+ HANDLE hFile = ((WindowsFileHandle &)handle).fd;
21308
+ auto bytes_written = FSInternalWrite(handle, hFile, buffer, nr_bytes, location);
21289
21309
  if (bytes_written != nr_bytes) {
21290
21310
  throw IOException("Could not write all bytes from file \"%s\": wanted=%lld wrote=%lld", handle.path, nr_bytes,
21291
21311
  bytes_written);
@@ -21294,20 +21314,8 @@ void LocalFileSystem::Write(FileHandle &handle, void *buffer, int64_t nr_bytes,
21294
21314
 
21295
21315
  int64_t LocalFileSystem::Write(FileHandle &handle, void *buffer, int64_t nr_bytes) {
21296
21316
  HANDLE hFile = ((WindowsFileHandle &)handle).fd;
21297
- DWORD bytes_written;
21298
21317
  auto &pos = ((WindowsFileHandle &)handle).position;
21299
- OVERLAPPED ov = {};
21300
- ov.Internal = 0;
21301
- ov.InternalHigh = 0;
21302
- ov.Offset = pos & 0xFFFFFFFF;
21303
- ov.OffsetHigh = pos >> 32;
21304
- ov.hEvent = 0;
21305
- WriteFile(hFile, buffer, (DWORD)nr_bytes, NULL, &ov);
21306
- auto rc = GetOverlappedResult(hFile, &ov, &bytes_written, true);
21307
- if (rc == 0) {
21308
- auto error = GetLastErrorAsString();
21309
- throw IOException("Could not write file \"%s\": %s", handle.path, error);
21310
- }
21318
+ auto bytes_written = FSInternalWrite(handle, hFile, buffer, nr_bytes, pos);
21311
21319
  pos += bytes_written;
21312
21320
  return bytes_written;
21313
21321
  }
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 "b10ef8b11"
14
- #define DUCKDB_VERSION "0.3.2-dev277"
13
+ #define DUCKDB_SOURCE_ID "b56295f32"
14
+ #define DUCKDB_VERSION "0.3.2-dev281"
15
15
  //===----------------------------------------------------------------------===//
16
16
  // DuckDB
17
17
  //