Skip to content

Commit 86e7ac2

Browse files
duckdblabs-botgithub-actions[bot]
authored andcommitted
Update vendored DuckDB sources to 46beeea72f
1 parent 09fb9e4 commit 86e7ac2

8 files changed

Lines changed: 41 additions & 72 deletions

File tree

src/duckdb/src/function/scalar/operator/arithmetic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ hugeint_t InterpolateOperator::Operation(const hugeint_t &lo, const double d, co
12201220

12211221
template <>
12221222
uhugeint_t InterpolateOperator::Operation(const uhugeint_t &lo, const double d, const uhugeint_t &hi) {
1223-
return Hugeint::Convert(Operation(Uhugeint::Cast<double>(lo), d, Uhugeint::Cast<double>(hi)));
1223+
return Uhugeint::Convert(Operation(Uhugeint::Cast<double>(lo), d, Uhugeint::Cast<double>(hi)));
12241224
}
12251225

12261226
static interval_t MultiplyByDouble(const interval_t &i, const double &d) { // NOLINT

src/duckdb/src/function/table/version/pragma_version.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef DUCKDB_PATCH_VERSION
2-
#define DUCKDB_PATCH_VERSION "2-dev21"
2+
#define DUCKDB_PATCH_VERSION "2-dev31"
33
#endif
44
#ifndef DUCKDB_MINOR_VERSION
55
#define DUCKDB_MINOR_VERSION 4
@@ -8,10 +8,10 @@
88
#define DUCKDB_MAJOR_VERSION 1
99
#endif
1010
#ifndef DUCKDB_VERSION
11-
#define DUCKDB_VERSION "v1.4.2-dev21"
11+
#define DUCKDB_VERSION "v1.4.2-dev31"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "716e174217"
14+
#define DUCKDB_SOURCE_ID "46beeea72f"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

src/duckdb/src/include/duckdb/common/hugeint.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct hugeint_t { // NOLINT: use numeric casing
7676
DUCKDB_API explicit operator int16_t() const;
7777
DUCKDB_API explicit operator int32_t() const;
7878
DUCKDB_API explicit operator int64_t() const;
79-
DUCKDB_API operator uhugeint_t() const; // NOLINT: Allow implicit conversion from `hugeint_t`
79+
DUCKDB_API explicit operator uhugeint_t() const;
8080
};
8181

8282
} // namespace duckdb

src/duckdb/src/include/duckdb/common/operator/comparison_operators.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,4 @@ inline bool GreaterThan::Operation(const interval_t &left, const interval_t &rig
210210
return Interval::GreaterThan(left, right);
211211
}
212212

213-
//===--------------------------------------------------------------------===//
214-
// Specialized Hugeint Comparison Operators
215-
//===--------------------------------------------------------------------===//
216-
template <>
217-
inline bool Equals::Operation(const hugeint_t &left, const hugeint_t &right) {
218-
return Hugeint::Equals(left, right);
219-
}
220-
template <>
221-
inline bool GreaterThan::Operation(const hugeint_t &left, const hugeint_t &right) {
222-
return Hugeint::GreaterThan(left, right);
223-
}
224213
} // namespace duckdb

src/duckdb/src/include/duckdb/common/types/hugeint.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,38 +129,38 @@ class Hugeint {
129129
static int Sign(hugeint_t n);
130130
static hugeint_t Abs(hugeint_t n);
131131
// comparison operators
132-
static bool Equals(hugeint_t lhs, hugeint_t rhs) {
132+
static bool Equals(const hugeint_t &lhs, const hugeint_t &rhs) {
133133
bool lower_equals = lhs.lower == rhs.lower;
134134
bool upper_equals = lhs.upper == rhs.upper;
135135
return lower_equals && upper_equals;
136136
}
137137

138-
static bool NotEquals(hugeint_t lhs, hugeint_t rhs) {
138+
static bool NotEquals(const hugeint_t &lhs, const hugeint_t &rhs) {
139139
return !Equals(lhs, rhs);
140140
}
141141

142-
static bool GreaterThan(hugeint_t lhs, hugeint_t rhs) {
142+
static bool GreaterThan(const hugeint_t &lhs, const hugeint_t &rhs) {
143143
bool upper_bigger = lhs.upper > rhs.upper;
144144
bool upper_equal = lhs.upper == rhs.upper;
145145
bool lower_bigger = lhs.lower > rhs.lower;
146146
return upper_bigger || (upper_equal && lower_bigger);
147147
}
148148

149-
static bool GreaterThanEquals(hugeint_t lhs, hugeint_t rhs) {
149+
static bool GreaterThanEquals(const hugeint_t &lhs, const hugeint_t &rhs) {
150150
bool upper_bigger = lhs.upper > rhs.upper;
151151
bool upper_equal = lhs.upper == rhs.upper;
152152
bool lower_bigger_equals = lhs.lower >= rhs.lower;
153153
return upper_bigger || (upper_equal && lower_bigger_equals);
154154
}
155155

156-
static bool LessThan(hugeint_t lhs, hugeint_t rhs) {
156+
static bool LessThan(const hugeint_t &lhs, const hugeint_t &rhs) {
157157
bool upper_smaller = lhs.upper < rhs.upper;
158158
bool upper_equal = lhs.upper == rhs.upper;
159159
bool lower_smaller = lhs.lower < rhs.lower;
160160
return upper_smaller || (upper_equal && lower_smaller);
161161
}
162162

163-
static bool LessThanEquals(hugeint_t lhs, hugeint_t rhs) {
163+
static bool LessThanEquals(const hugeint_t &lhs, const hugeint_t &rhs) {
164164
bool upper_smaller = lhs.upper < rhs.upper;
165165
bool upper_equal = lhs.upper == rhs.upper;
166166
bool lower_smaller_equals = lhs.lower <= rhs.lower;

src/duckdb/src/include/duckdb/main/database_file_path_manager.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "duckdb/common/mutex.hpp"
1313
#include "duckdb/common/case_insensitive_map.hpp"
1414
#include "duckdb/common/enums/on_create_conflict.hpp"
15+
#include "duckdb/common/enums/access_mode.hpp"
1516

1617
namespace duckdb {
1718
struct AttachInfo;
@@ -20,11 +21,14 @@ struct AttachOptions;
2021
enum class InsertDatabasePathResult { SUCCESS, ALREADY_EXISTS };
2122

2223
struct DatabasePathInfo {
23-
explicit DatabasePathInfo(string name_p) : name(std::move(name_p)), is_attached(true) {
24+
explicit DatabasePathInfo(string name_p, AccessMode access_mode)
25+
: name(std::move(name_p)), access_mode(access_mode), is_attached(true) {
2426
}
2527

2628
string name;
29+
AccessMode access_mode;
2730
bool is_attached;
31+
idx_t reference_count = 1;
2832
};
2933

3034
//! The DatabaseFilePathManager is used to ensure we only ever open a single database file once

src/duckdb/src/include/duckdb/planner/tableref/bound_pos_join_ref.hpp

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/duckdb/src/main/database_file_path_manager.cpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,27 @@ InsertDatabasePathResult DatabaseFilePathManager::InsertDatabasePath(const strin
1818
}
1919

2020
lock_guard<mutex> path_lock(db_paths_lock);
21-
auto entry = db_paths.emplace(path, DatabasePathInfo(name));
21+
auto entry = db_paths.emplace(path, DatabasePathInfo(name, options.access_mode));
2222
if (!entry.second) {
2323
auto &existing = entry.first->second;
24-
if (on_conflict == OnCreateConflict::IGNORE_ON_CONFLICT && existing.name == name) {
25-
if (existing.is_attached) {
26-
return InsertDatabasePathResult::ALREADY_EXISTS;
24+
if (options.access_mode == AccessMode::READ_ONLY && existing.access_mode == AccessMode::READ_ONLY) {
25+
// all attaches are in read-only mode - there is no conflict, just increase the reference count
26+
existing.reference_count++;
27+
} else {
28+
if (on_conflict == OnCreateConflict::IGNORE_ON_CONFLICT && existing.name == name) {
29+
if (existing.is_attached) {
30+
return InsertDatabasePathResult::ALREADY_EXISTS;
31+
}
32+
throw BinderException(
33+
"Unique file handle conflict: Cannot attach \"%s\" - the database file \"%s\" is in "
34+
"the process of being detached",
35+
name, path);
2736
}
28-
throw BinderException("Unique file handle conflict: Cannot attach \"%s\" - the database file \"%s\" is in "
29-
"the process of being detached",
30-
name, path);
37+
throw BinderException(
38+
"Unique file handle conflict: Cannot attach \"%s\" - the database file \"%s\" is already "
39+
"attached by database \"%s\"",
40+
name, path, existing.name);
3141
}
32-
throw BinderException("Unique file handle conflict: Cannot attach \"%s\" - the database file \"%s\" is already "
33-
"attached by database \"%s\"",
34-
name, path, existing.name);
3542
}
3643
options.stored_database_path = make_uniq<StoredDatabasePath>(*this, path, name);
3744
return InsertDatabasePathResult::SUCCESS;
@@ -42,7 +49,14 @@ void DatabaseFilePathManager::EraseDatabasePath(const string &path) {
4249
return;
4350
}
4451
lock_guard<mutex> path_lock(db_paths_lock);
45-
db_paths.erase(path);
52+
auto entry = db_paths.find(path);
53+
if (entry != db_paths.end()) {
54+
if (entry->second.reference_count <= 1) {
55+
db_paths.erase(entry);
56+
} else {
57+
entry->second.reference_count--;
58+
}
59+
}
4660
}
4761

4862
void DatabaseFilePathManager::DetachDatabase(const string &path) {

0 commit comments

Comments
 (0)