Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vendor: Update vendored sources to duckdb/duckdb@d707b4432b74b51f8a176c533b98e24d48f4d165 #998

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/duckdb/src/common/random_engine.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#include "duckdb/common/random_engine.hpp"
#include "duckdb/common/numeric_utils.hpp"
#include "pcg_random.hpp"
#include <random>

#ifdef __linux__
#include <sys/syscall.h>
#include <unistd.h>
#else
#include <random>
#endif
namespace duckdb {

struct RandomState {
@@ -14,7 +19,18 @@ struct RandomState {

RandomEngine::RandomEngine(int64_t seed) : random_state(make_uniq<RandomState>()) {
if (seed < 0) {
#ifdef __linux__
idx_t random_seed;
auto result = syscall(SYS_getrandom, &random_seed, sizeof(random_seed), 0);
if (result == -1) {
// Something went wrong with the syscall, we use chrono
const auto now = std::chrono::high_resolution_clock::now();
random_seed = now.time_since_epoch().count();
}
random_state->pcg.seed(random_seed);
#else
random_state->pcg.seed(pcg_extras::seed_seq_from<std::random_device>());
#endif
} else {
random_state->pcg.seed(NumericCast<uint64_t>(seed));
}
9 changes: 3 additions & 6 deletions src/duckdb/src/common/string_util.cpp
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
#include "duckdb/common/to_string.hpp"
#include "duckdb/common/helper.hpp"
#include "duckdb/common/exception/parser_exception.hpp"
#include "duckdb/common/random_engine.hpp"
#include "jaro_winkler.hpp"
#include "utf8proc_wrapper.hpp"

@@ -16,7 +17,6 @@
#include <sstream>
#include <stdarg.h>
#include <string.h>
#include <random>
#include <stack>

#include "yyjson.hpp"
@@ -26,13 +26,10 @@ using namespace duckdb_yyjson; // NOLINT
namespace duckdb {

string StringUtil::GenerateRandomName(idx_t length) {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, 15);

RandomEngine engine;
std::stringstream ss;
for (idx_t i = 0; i < length; i++) {
ss << "0123456789abcdef"[dis(gen)];
ss << "0123456789abcdef"[engine.NextRandomInteger(0, 15)];
}
return ss.str();
}
6 changes: 3 additions & 3 deletions src/duckdb/src/function/table/version/pragma_version.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef DUCKDB_PATCH_VERSION
#define DUCKDB_PATCH_VERSION "4-dev4255"
#define DUCKDB_PATCH_VERSION "4-dev4271"
#endif
#ifndef DUCKDB_MINOR_VERSION
#define DUCKDB_MINOR_VERSION 1
@@ -8,10 +8,10 @@
#define DUCKDB_MAJOR_VERSION 1
#endif
#ifndef DUCKDB_VERSION
#define DUCKDB_VERSION "v1.1.4-dev4255"
#define DUCKDB_VERSION "v1.1.4-dev4271"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "d3444ef141"
#define DUCKDB_SOURCE_ID "d707b4432b"
#endif
#include "duckdb/function/table/system_functions.hpp"
#include "duckdb/main/database.hpp"
17 changes: 3 additions & 14 deletions src/duckdb/third_party/httplib/httplib.hpp
Original file line number Diff line number Diff line change
@@ -237,7 +237,6 @@ using socket_t = int;
#include <map>
#include <memory>
#include <mutex>
#include <random>
#include <regex>
#include <set>
#include <sstream>
@@ -246,9 +245,8 @@ using socket_t = int;
#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <utility>

#include "duckdb/common/re2_regex.hpp"
#include "duckdb/common/random_engine.hpp"

#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
#ifdef _WIN32
@@ -4646,19 +4644,10 @@ inline std::string make_multipart_data_boundary() {
static const char data[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

// std::random_device might actually be deterministic on some
// platforms, but due to lack of support in the c++ standard library,
// doing better requires either some ugly hacks or breaking portability.
std::random_device seed_gen;

// Request 128 bits of entropy for initialization
std::seed_seq seed_sequence{seed_gen(), seed_gen(), seed_gen(), seed_gen()};
std::mt19937 engine(seed_sequence);

std::string result = "--cpp-httplib-multipart-data-";

duckdb::RandomEngine engine;
for (auto i = 0; i < 16; i++) {
result += data[engine() % (sizeof(data) - 1)];
result += data[engine.NextRandomInteger32(0,sizeof(data) - 1)];
}

return result;
1 change: 0 additions & 1 deletion src/duckdb/third_party/skiplist/SkipList.h
Original file line number Diff line number Diff line change
@@ -446,7 +446,6 @@
#include <vector>
#include <set> // Used for HeadNode::_lacksIntegrityNodeReferencesNotInList()
#include <string> // Used for class Exception
#include <random>
#include "pcg_random.hpp"

#ifdef DEBUG