duckdb 0.4.1-dev75.0 → 0.4.1-dev85.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-dev75.0",
4
+ "version": "0.4.1-dev85.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -17291,12 +17291,12 @@ public:
17291
17291
 
17292
17292
  #include <cstdint>
17293
17293
  #include <cstdio>
17294
+ #include <sys/stat.h>
17294
17295
 
17295
17296
  #ifndef _WIN32
17296
17297
  #include <dirent.h>
17297
17298
  #include <fcntl.h>
17298
17299
  #include <string.h>
17299
- #include <sys/stat.h>
17300
17300
  #include <sys/types.h>
17301
17301
  #include <unistd.h>
17302
17302
  #else
@@ -17335,7 +17335,6 @@ public:
17335
17335
  #include <string>
17336
17336
 
17337
17337
  #ifdef __MINGW32__
17338
- #include <sys/stat.h>
17339
17338
  // need to manually define this for mingw
17340
17339
  extern "C" WINBASEAPI BOOL WINAPI GetPhysicallyInstalledSystemMemory(PULONGLONG);
17341
17340
  #endif
@@ -17360,33 +17359,6 @@ static void AssertValidFileFlags(uint8_t flags) {
17360
17359
  #endif
17361
17360
  }
17362
17361
 
17363
- #ifdef __MINGW32__
17364
- bool LocalFileSystem::FileExists(const string &filename) {
17365
- auto unicode_path = WindowsUtil::UTF8ToUnicode(filename.c_str());
17366
- const wchar_t *wpath = unicode_path.c_str();
17367
- if (_waccess(wpath, 0) == 0) {
17368
- struct _stat64i32 status;
17369
- _wstat64i32(wpath, &status);
17370
- if (status.st_size > 0) {
17371
- return true;
17372
- }
17373
- }
17374
- return false;
17375
- }
17376
- bool LocalFileSystem::IsPipe(const string &filename) {
17377
- auto unicode_path = WindowsUtil::UTF8ToUnicode(filename.c_str());
17378
- const wchar_t *wpath = unicode_path.c_str();
17379
- if (_waccess(wpath, 0) == 0) {
17380
- struct _stat64i32 status;
17381
- _wstat64i32(wpath, &status);
17382
- if (status.st_size == 0) {
17383
- return true;
17384
- }
17385
- }
17386
- return false;
17387
- }
17388
-
17389
- #else
17390
17362
  #ifndef _WIN32
17391
17363
  bool LocalFileSystem::FileExists(const string &filename) {
17392
17364
  if (!filename.empty()) {
@@ -17421,8 +17393,8 @@ bool LocalFileSystem::FileExists(const string &filename) {
17421
17393
  auto unicode_path = WindowsUtil::UTF8ToUnicode(filename.c_str());
17422
17394
  const wchar_t *wpath = unicode_path.c_str();
17423
17395
  if (_waccess(wpath, 0) == 0) {
17424
- struct _stat64i32 status;
17425
- _wstat(wpath, &status);
17396
+ struct _stati64 status;
17397
+ _wstati64(wpath, &status);
17426
17398
  if (status.st_mode & S_IFREG) {
17427
17399
  return true;
17428
17400
  }
@@ -17433,8 +17405,8 @@ bool LocalFileSystem::IsPipe(const string &filename) {
17433
17405
  auto unicode_path = WindowsUtil::UTF8ToUnicode(filename.c_str());
17434
17406
  const wchar_t *wpath = unicode_path.c_str();
17435
17407
  if (_waccess(wpath, 0) == 0) {
17436
- struct _stat64i32 status;
17437
- _wstat(wpath, &status);
17408
+ struct _stati64 status;
17409
+ _wstati64(wpath, &status);
17438
17410
  if (status.st_mode & _S_IFCHR) {
17439
17411
  return true;
17440
17412
  }
@@ -17442,7 +17414,6 @@ bool LocalFileSystem::IsPipe(const string &filename) {
17442
17414
  return false;
17443
17415
  }
17444
17416
  #endif
17445
- #endif
17446
17417
 
17447
17418
  #ifndef _WIN32
17448
17419
  // somehow sometimes this is missing
@@ -47744,7 +47715,7 @@ PhysicalType LogicalType::GetInternalType() {
47744
47715
  } else if (width <= Decimal::MAX_WIDTH_INT128) {
47745
47716
  return PhysicalType::INT128;
47746
47717
  } else {
47747
- throw InternalException("Widths bigger than 38 are not supported");
47718
+ throw InternalException("Widths bigger than %d are not supported", DecimalType::MaxWidth());
47748
47719
  }
47749
47720
  }
47750
47721
  case LogicalTypeId::VARCHAR:
@@ -48294,9 +48265,20 @@ LogicalType LogicalType::MaxLogicalType(const LogicalType &left, const LogicalTy
48294
48265
  return right;
48295
48266
  }
48296
48267
  } else if (type_id == LogicalTypeId::DECIMAL) {
48297
- // use max width/scale of the two types
48298
- auto width = MaxValue<uint8_t>(DecimalType::GetWidth(left), DecimalType::GetWidth(right));
48268
+ // unify the width/scale so that the resulting decimal always fits
48269
+ // "width - scale" gives us the number of digits on the left side of the decimal point
48270
+ // "scale" gives us the number of digits allowed on the right of the deciaml point
48271
+ // using the max of these of the two types gives us the new decimal size
48272
+ auto extra_width_left = DecimalType::GetWidth(left) - DecimalType::GetScale(left);
48273
+ auto extra_width_right = DecimalType::GetWidth(right) - DecimalType::GetScale(right);
48274
+ auto extra_width = MaxValue<uint8_t>(extra_width_left, extra_width_right);
48299
48275
  auto scale = MaxValue<uint8_t>(DecimalType::GetScale(left), DecimalType::GetScale(right));
48276
+ auto width = extra_width + scale;
48277
+ if (width > DecimalType::MaxWidth()) {
48278
+ // if the resulting decimal does not fit, we truncate the scale
48279
+ width = DecimalType::MaxWidth();
48280
+ scale = width - extra_width;
48281
+ }
48300
48282
  return LogicalType::DECIMAL(width, scale);
48301
48283
  } else if (type_id == LogicalTypeId::LIST) {
48302
48284
  // list: perform max recursively on child type
@@ -48493,6 +48475,10 @@ uint8_t DecimalType::GetScale(const LogicalType &type) {
48493
48475
  return ((DecimalTypeInfo &)*info).scale;
48494
48476
  }
48495
48477
 
48478
+ uint8_t DecimalType::MaxWidth() {
48479
+ return 38;
48480
+ }
48481
+
48496
48482
  LogicalType LogicalType::DECIMAL(int width, int scale) {
48497
48483
  auto type_info = make_shared<DecimalTypeInfo>(width, scale);
48498
48484
  return LogicalType(LogicalTypeId::DECIMAL, move(type_info));
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 "26d123fdc"
15
- #define DUCKDB_VERSION "v0.4.1-dev75"
14
+ #define DUCKDB_SOURCE_ID "4565d24b7"
15
+ #define DUCKDB_VERSION "v0.4.1-dev85"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -1124,6 +1124,7 @@ public:
1124
1124
  struct DecimalType {
1125
1125
  DUCKDB_API static uint8_t GetWidth(const LogicalType &type);
1126
1126
  DUCKDB_API static uint8_t GetScale(const LogicalType &type);
1127
+ DUCKDB_API static uint8_t MaxWidth();
1127
1128
  };
1128
1129
 
1129
1130
  struct StringType {