duckdb 0.4.1-dev61.0 → 0.4.1-dev71.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-dev61.0",
4
+ "version": "0.4.1-dev71.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -24177,6 +24177,9 @@ bool TryCast::Operation(timestamp_t input, date_t &result, bool strict) {
24177
24177
 
24178
24178
  template <>
24179
24179
  bool TryCast::Operation(timestamp_t input, dtime_t &result, bool strict) {
24180
+ if (!Timestamp::IsFinite(input)) {
24181
+ return false;
24182
+ }
24180
24183
  result = Timestamp::GetTime(input);
24181
24184
  return true;
24182
24185
  }
@@ -25537,9 +25540,9 @@ duckdb::string_t StringCast::Operation(hugeint_t input, Vector &vector) {
25537
25540
  template <>
25538
25541
  duckdb::string_t StringCast::Operation(date_t input, Vector &vector) {
25539
25542
  if (input == date_t::infinity()) {
25540
- return "infinity";
25543
+ return StringVector::AddString(vector, Date::PINF);
25541
25544
  } else if (input == date_t::ninfinity()) {
25542
- return "-infinity";
25545
+ return StringVector::AddString(vector, Date::NINF);
25543
25546
  }
25544
25547
  int32_t date[3];
25545
25548
  Date::Convert(input, date[0], date[1], date[2]);
@@ -25577,9 +25580,9 @@ duckdb::string_t StringCast::Operation(dtime_t input, Vector &vector) {
25577
25580
  template <>
25578
25581
  duckdb::string_t StringCast::Operation(timestamp_t input, Vector &vector) {
25579
25582
  if (input == timestamp_t::infinity()) {
25580
- return string_t("infinity");
25583
+ return StringVector::AddString(vector, Date::PINF);
25581
25584
  } else if (input == timestamp_t::ninfinity()) {
25582
- return string_t("-infinity");
25585
+ return StringVector::AddString(vector, Date::NINF);
25583
25586
  }
25584
25587
  date_t date_entry;
25585
25588
  dtime_t time_entry;
@@ -25639,6 +25642,11 @@ string_t StringCastTZ::Operation(dtime_t input, Vector &vector) {
25639
25642
 
25640
25643
  template <>
25641
25644
  string_t StringCastTZ::Operation(timestamp_t input, Vector &vector) {
25645
+ if (input == timestamp_t::infinity()) {
25646
+ return StringVector::AddString(vector, Date::PINF);
25647
+ } else if (input == timestamp_t::ninfinity()) {
25648
+ return StringVector::AddString(vector, Date::NINF);
25649
+ }
25642
25650
  date_t date_entry;
25643
25651
  dtime_t time_entry;
25644
25652
  Timestamp::Convert(input, date_entry, time_entry);
@@ -40109,6 +40117,10 @@ namespace duckdb {
40109
40117
 
40110
40118
  static_assert(sizeof(date_t) == sizeof(int32_t), "date_t was padded");
40111
40119
 
40120
+ const char *Date::PINF = "infinity"; // NOLINT
40121
+ const char *Date::NINF = "-infinity"; // NOLINT
40122
+ const char *Date::EPOCH = "epoch"; // NOLINT
40123
+
40112
40124
  const string_t Date::MONTH_NAMES_ABBREVIATED[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
40113
40125
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
40114
40126
  const string_t Date::MONTH_NAMES[] = {"January", "February", "March", "April", "May", "June",
@@ -40320,9 +40332,9 @@ bool Date::TryConvertDate(const char *buf, idx_t len, idx_t &pos, date_t &result
40320
40332
  }
40321
40333
  if (!StringUtil::CharacterIsDigit(buf[pos])) {
40322
40334
  // Check for special values
40323
- if (TryConvertDateSpecial(buf, len, pos, "infinity")) {
40335
+ if (TryConvertDateSpecial(buf, len, pos, PINF)) {
40324
40336
  result = yearneg ? date_t::ninfinity() : date_t::infinity();
40325
- } else if (TryConvertDateSpecial(buf, len, pos, "epoch")) {
40337
+ } else if (TryConvertDateSpecial(buf, len, pos, EPOCH)) {
40326
40338
  result = date_t::epoch();
40327
40339
  } else {
40328
40340
  return false;
@@ -40435,9 +40447,9 @@ string Date::ToString(date_t date) {
40435
40447
  // PG displays temporal infinities in lowercase,
40436
40448
  // but numerics in Titlecase.
40437
40449
  if (date == date_t::infinity()) {
40438
- return "infinity";
40450
+ return PINF;
40439
40451
  } else if (date == date_t::ninfinity()) {
40440
- return "-infinity";
40452
+ return NINF;
40441
40453
  }
40442
40454
  int32_t date_units[3];
40443
40455
  idx_t year_length;
@@ -43502,9 +43514,9 @@ timestamp_t Timestamp::FromString(const string &str) {
43502
43514
 
43503
43515
  string Timestamp::ToString(timestamp_t timestamp) {
43504
43516
  if (timestamp == timestamp_t::infinity()) {
43505
- return "infinity";
43517
+ return Date::PINF;
43506
43518
  } else if (timestamp == timestamp_t::ninfinity()) {
43507
- return "-infinity";
43519
+ return Date::NINF;
43508
43520
  }
43509
43521
  date_t date;
43510
43522
  dtime_t time;
@@ -43522,6 +43534,9 @@ date_t Timestamp::GetDate(timestamp_t timestamp) {
43522
43534
  }
43523
43535
 
43524
43536
  dtime_t Timestamp::GetTime(timestamp_t timestamp) {
43537
+ if (!IsFinite(timestamp)) {
43538
+ throw ConversionException("Can't get TIME of infinite TIMESTAMP");
43539
+ }
43525
43540
  date_t date = Timestamp::GetDate(timestamp);
43526
43541
  return dtime_t(timestamp.value - (int64_t(date.days) * int64_t(Interval::MICROS_PER_DAY)));
43527
43542
  }
@@ -52576,7 +52591,6 @@ static inline void TemplatedLoopHash(Vector &input, Vector &result, const Select
52576
52591
 
52577
52592
  template <bool HAS_RSEL, bool FIRST_HASH>
52578
52593
  static inline void StructLoopHash(Vector &input, Vector &hashes, const SelectionVector *rsel, idx_t count) {
52579
- input.Normalify(count);
52580
52594
  auto &children = StructVector::GetEntries(input);
52581
52595
 
52582
52596
  D_ASSERT(!children.empty());
@@ -126548,19 +126562,26 @@ void ExtensionHelper::InstallExtension(DatabaseInstance &db, const string &exten
126548
126562
  return;
126549
126563
  }
126550
126564
 
126565
+ string temp_path = local_extension_path + ".tmp";
126566
+ if (fs.FileExists(temp_path)) {
126567
+ fs.RemoveFile(temp_path);
126568
+ }
126551
126569
  auto is_http_url = StringUtil::Contains(extension, "http://");
126552
126570
  if (fs.FileExists(extension)) {
126571
+
126553
126572
  std::ifstream in(extension, std::ios::binary);
126554
126573
  if (in.bad()) {
126555
126574
  throw IOException("Failed to read extension from \"%s\"", extension);
126556
126575
  }
126557
- std::ofstream out(local_extension_path, std::ios::binary);
126576
+ std::ofstream out(temp_path, std::ios::binary);
126558
126577
  out << in.rdbuf();
126559
126578
  if (out.bad()) {
126560
- throw IOException("Failed to write extension to \"%s\"", local_extension_path);
126579
+ throw IOException("Failed to write extension to \"%s\"", temp_path);
126561
126580
  }
126562
126581
  in.close();
126563
126582
  out.close();
126583
+
126584
+ fs.MoveFile(temp_path, local_extension_path);
126564
126585
  return;
126565
126586
  } else if (StringUtil::Contains(extension, "/") && !is_http_url) {
126566
126587
  throw IOException("Failed to read extension from \"%s\": no such file", extension);
@@ -126602,11 +126623,13 @@ void ExtensionHelper::InstallExtension(DatabaseInstance &db, const string &exten
126602
126623
  throw IOException("Failed to download extension %s%s", url_base, url_local_part);
126603
126624
  }
126604
126625
  auto decompressed_body = GZipFileSystem::UncompressGZIPString(res->body);
126605
- std::ofstream out(local_extension_path, std::ios::binary);
126626
+ std::ofstream out(temp_path, std::ios::binary);
126606
126627
  out.write(decompressed_body.data(), decompressed_body.size());
126607
126628
  if (out.bad()) {
126608
- throw IOException("Failed to write extension to %s", local_extension_path);
126629
+ throw IOException("Failed to write extension to %s", temp_path);
126609
126630
  }
126631
+ out.close();
126632
+ fs.MoveFile(temp_path, local_extension_path);
126610
126633
  #endif
126611
126634
  }
126612
126635
 
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 "cdb786d7e"
15
- #define DUCKDB_VERSION "v0.4.1-dev61"
14
+ #define DUCKDB_SOURCE_ID "b3c5e47e0"
15
+ #define DUCKDB_VERSION "v0.4.1-dev71"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -18876,6 +18876,10 @@ namespace duckdb {
18876
18876
  //! The Date class is a static class that holds helper functions for the Date type.
18877
18877
  class Date {
18878
18878
  public:
18879
+ static const char *PINF; // NOLINT
18880
+ static const char *NINF; // NOLINT
18881
+ static const char *EPOCH; // NOLINT
18882
+
18879
18883
  static const string_t MONTH_NAMES[12];
18880
18884
  static const string_t MONTH_NAMES_ABBREVIATED[12];
18881
18885
  static const string_t DAY_NAMES[7];