Skip to content

Commit 5d6df66

Browse files
committed
vendor: Update vendored sources to duckdb/duckdb@a76ff3f
Add connection and transaction identifiers (duckdb/duckdb#16296)
1 parent ccfb06c commit 5d6df66

25 files changed

+278
-38
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
From 3b7fe14657de5b964af2fd5f79e46f699aff8814 Mon Sep 17 00:00:00 2001
1+
From 4eb5358996358ec8d64c6614846a6ae83d5d66fb Mon Sep 17 00:00:00 2001
22
From: =?UTF-8?q?Kirill=20M=C3=BCller?= <[email protected]>
3-
Date: Sun, 2 Feb 2025 12:12:26 +0100
4-
Subject: [PATCH] Disable print
3+
Date: Fri, 16 May 2025 03:50:15 +0200
4+
Subject: [PATCH] DUCKDB_DISABLE_PRINT
55

66
---
77
.../duckdb/execution/operator/csv_scanner/csv_state_machine.hpp | 2 ++
88
src/duckdb/src/logging/log_storage.cpp | 2 ++
99
2 files changed, 4 insertions(+)
1010

1111
diff --git a/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine.hpp b/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine.hpp
12-
index 71eb1c11e..7c9cb3420 100644
12+
index 71eb1c11e..eca9fec11 100644
1313
--- a/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine.hpp
1414
+++ b/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine.hpp
1515
@@ -129,12 +129,14 @@ public:
@@ -28,20 +28,20 @@ index 71eb1c11e..7c9cb3420 100644
2828
//! The Transition Array is a Finite State Machine
2929
//! It holds the transitions of all states, on all 256 possible different characters
3030
diff --git a/src/duckdb/src/logging/log_storage.cpp b/src/duckdb/src/logging/log_storage.cpp
31-
index 909bddf75..502e685e3 100644
31+
index 625757490..253db8514 100644
3232
--- a/src/duckdb/src/logging/log_storage.cpp
3333
+++ b/src/duckdb/src/logging/log_storage.cpp
34-
@@ -34,12 +34,14 @@ StdOutLogStorage::~StdOutLogStorage() {
34+
@@ -37,12 +37,14 @@ StdOutLogStorage::~StdOutLogStorage() {
3535

3636
void StdOutLogStorage::WriteLogEntry(timestamp_t timestamp, LogLevel level, const string &log_type,
3737
const string &log_message, const RegisteredLoggingContext &context) {
3838
+#ifndef DUCKDB_DISABLE_PRINT
3939
std::cout << StringUtil::Format(
4040
"[LOG] %s, %s, %s, %s, %s, %s, %s, %s\n", Value::TIMESTAMP(timestamp).ToString(), log_type,
4141
EnumUtil::ToString(level), log_message, EnumUtil::ToString(context.context.scope),
42-
context.context.client_context.IsValid() ? to_string(context.context.client_context.GetIndex()) : "NULL",
42+
context.context.connection_id.IsValid() ? to_string(context.context.connection_id.GetIndex()) : "NULL",
4343
context.context.transaction_id.IsValid() ? to_string(context.context.transaction_id.GetIndex()) : "NULL",
44-
context.context.thread.IsValid() ? to_string(context.context.thread.GetIndex()) : "NULL");
44+
context.context.thread_id.IsValid() ? to_string(context.context.thread_id.GetIndex()) : "NULL");
4545
+#endif
4646
}
4747

src/duckdb/src/function/function_list.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ static const StaticFunctionDefinition function[] = {
9191
DUCKDB_AGGREGATE_FUNCTION_SET(CountFun),
9292
DUCKDB_AGGREGATE_FUNCTION(CountStarFun),
9393
DUCKDB_SCALAR_FUNCTION(CreateSortKeyFun),
94+
DUCKDB_SCALAR_FUNCTION(CurrentConnectionId),
95+
DUCKDB_SCALAR_FUNCTION(CurrentQueryId),
96+
DUCKDB_SCALAR_FUNCTION(CurrentTransactionId),
9497
DUCKDB_SCALAR_FUNCTION(CurrvalFun),
9598
DUCKDB_SCALAR_FUNCTION_SET_ALIAS(DivideFun),
9699
DUCKDB_SCALAR_FUNCTION_ALIAS(EndsWithFun),

src/duckdb/src/function/pragma/pragma_functions.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ static void PragmaDisableCheckpointOnShutdown(ClientContext &context, const Func
116116
DBConfig::GetConfig(context).options.checkpoint_on_shutdown = false;
117117
}
118118

119+
static void PragmaEnableLogging(ClientContext &context, const FunctionParameters &parameters) {
120+
context.db->GetLogManager().SetEnableLogging(true);
121+
}
122+
123+
static void PragmaDisableLogging(ClientContext &context, const FunctionParameters &parameters) {
124+
context.db->GetLogManager().SetEnableLogging(false);
125+
}
126+
119127
static void PragmaEnableOptimizer(ClientContext &context, const FunctionParameters &parameters) {
120128
ClientConfig::GetConfig(context).enable_optimizer = true;
121129
}
@@ -148,6 +156,9 @@ void PragmaFunctions::RegisterFunction(BuiltinFunctions &set) {
148156
set.AddFunction(PragmaFunction::PragmaStatement("enable_object_cache", PragmaEnableObjectCache));
149157
set.AddFunction(PragmaFunction::PragmaStatement("disable_object_cache", PragmaDisableObjectCache));
150158

159+
set.AddFunction(PragmaFunction::PragmaStatement("enable_logging", PragmaEnableLogging));
160+
set.AddFunction(PragmaFunction::PragmaStatement("disable_logging", PragmaDisableLogging));
161+
151162
set.AddFunction(PragmaFunction::PragmaStatement("enable_optimizer", PragmaEnableOptimizer));
152163
set.AddFunction(PragmaFunction::PragmaStatement("disable_optimizer", PragmaDisableOptimizer));
153164

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "duckdb/function/scalar/system_functions.hpp"
2+
#include "duckdb/execution/expression_executor.hpp"
3+
#include "duckdb/main/client_data.hpp"
4+
#include "duckdb/planner/expression/bound_function_expression.hpp"
5+
6+
#include "utf8proc.hpp"
7+
8+
namespace duckdb {
9+
10+
struct CurrentConnectionIdData : FunctionData {
11+
explicit CurrentConnectionIdData(Value connection_id_p) : connection_id(std::move(connection_id_p)) {
12+
}
13+
Value connection_id;
14+
15+
unique_ptr<FunctionData> Copy() const override {
16+
return make_uniq<CurrentConnectionIdData>(connection_id);
17+
}
18+
bool Equals(const FunctionData &other_p) const override {
19+
return connection_id == other_p.Cast<CurrentConnectionIdData>().connection_id;
20+
}
21+
};
22+
23+
unique_ptr<FunctionData> CurrentConnectionIdBind(ClientContext &context, ScalarFunction &bound_function,
24+
vector<unique_ptr<Expression>> &arguments) {
25+
return make_uniq<CurrentConnectionIdData>(Value::UBIGINT(context.GetConnectionId()));
26+
}
27+
28+
static void CurrentConnectionIdFunction(DataChunk &args, ExpressionState &state, Vector &result) {
29+
auto &func_expr = state.expr.Cast<BoundFunctionExpression>();
30+
const auto &info = func_expr.bind_info->Cast<CurrentConnectionIdData>();
31+
result.Reference(info.connection_id);
32+
}
33+
34+
ScalarFunction CurrentConnectionId::GetFunction() {
35+
return ScalarFunction({}, LogicalType::UBIGINT, CurrentConnectionIdFunction, CurrentConnectionIdBind, nullptr,
36+
nullptr, nullptr, LogicalType(LogicalTypeId::INVALID), FunctionStability::VOLATILE);
37+
}
38+
39+
} // namespace duckdb
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "duckdb/function/scalar/system_functions.hpp"
2+
#include "duckdb/execution/expression_executor.hpp"
3+
#include "duckdb/main/client_data.hpp"
4+
#include "duckdb/planner/expression/bound_function_expression.hpp"
5+
6+
#include "utf8proc.hpp"
7+
8+
namespace duckdb {
9+
10+
struct CurrentQueryIdData : FunctionData {
11+
explicit CurrentQueryIdData(Value query_id_p) : query_id(std::move(query_id_p)) {
12+
}
13+
Value query_id;
14+
15+
unique_ptr<FunctionData> Copy() const override {
16+
return make_uniq<CurrentQueryIdData>(query_id);
17+
}
18+
bool Equals(const FunctionData &other_p) const override {
19+
return query_id == other_p.Cast<CurrentQueryIdData>().query_id;
20+
}
21+
};
22+
23+
unique_ptr<FunctionData> CurrentQueryIdBind(ClientContext &context, ScalarFunction &bound_function,
24+
vector<unique_ptr<Expression>> &arguments) {
25+
Value query_id;
26+
if (context.transaction.HasActiveTransaction()) {
27+
query_id = Value::UBIGINT(context.transaction.GetActiveQuery());
28+
} else {
29+
query_id = Value();
30+
}
31+
return make_uniq<CurrentQueryIdData>(query_id);
32+
}
33+
34+
static void CurrentQueryIdFunction(DataChunk &args, ExpressionState &state, Vector &result) {
35+
auto &func_expr = state.expr.Cast<BoundFunctionExpression>();
36+
const auto &info = func_expr.bind_info->Cast<CurrentQueryIdData>();
37+
result.Reference(info.query_id);
38+
}
39+
40+
ScalarFunction CurrentQueryId::GetFunction() {
41+
return ScalarFunction({}, LogicalType::UBIGINT, CurrentQueryIdFunction, CurrentQueryIdBind, nullptr, nullptr,
42+
nullptr, LogicalType(LogicalTypeId::INVALID), FunctionStability::VOLATILE);
43+
}
44+
45+
} // namespace duckdb
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include "duckdb/function/scalar/system_functions.hpp"
2+
#include "duckdb/execution/expression_executor.hpp"
3+
#include "duckdb/main/client_data.hpp"
4+
#include "duckdb/planner/expression/bound_function_expression.hpp"
5+
#include "duckdb/common/types/value.hpp"
6+
7+
#include "utf8proc.hpp"
8+
9+
namespace duckdb {
10+
11+
struct CurrentTransactionIdData : FunctionData {
12+
explicit CurrentTransactionIdData(Value transaction_id_p) : transaction_id(std::move(transaction_id_p)) {
13+
}
14+
Value transaction_id;
15+
16+
unique_ptr<FunctionData> Copy() const override {
17+
return make_uniq<CurrentTransactionIdData>(transaction_id);
18+
}
19+
bool Equals(const FunctionData &other_p) const override {
20+
return transaction_id == other_p.Cast<CurrentTransactionIdData>().transaction_id;
21+
}
22+
};
23+
24+
unique_ptr<FunctionData> CurrentTransactionIdBind(ClientContext &context, ScalarFunction &bound_function,
25+
vector<unique_ptr<Expression>> &arguments) {
26+
Value transaction_id;
27+
if (context.transaction.HasActiveTransaction()) {
28+
transaction_id = Value::UBIGINT(context.transaction.ActiveTransaction().global_transaction_id);
29+
} else {
30+
transaction_id = Value();
31+
}
32+
return make_uniq<CurrentTransactionIdData>(transaction_id);
33+
}
34+
35+
static void CurrentTransactionIdFunction(DataChunk &args, ExpressionState &state, Vector &result) {
36+
auto &func_expr = state.expr.Cast<BoundFunctionExpression>();
37+
const auto &info = func_expr.bind_info->Cast<CurrentTransactionIdData>();
38+
result.Reference(info.transaction_id);
39+
}
40+
41+
ScalarFunction CurrentTransactionId::GetFunction() {
42+
return ScalarFunction({}, LogicalType::UBIGINT, CurrentTransactionIdFunction, CurrentTransactionIdBind, nullptr,
43+
nullptr, nullptr, LogicalType(LogicalTypeId::INVALID), FunctionStability::VOLATILE);
44+
}
45+
46+
} // namespace duckdb

src/duckdb/src/function/table/system/duckdb_log_contexts.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ static unique_ptr<FunctionData> DuckDBLogContextBind(ClientContext &context, Tab
3131
names.emplace_back("scope");
3232
return_types.emplace_back(LogicalType::VARCHAR);
3333

34-
names.emplace_back("client_context");
34+
names.emplace_back("connection_id");
3535
return_types.emplace_back(LogicalType::UBIGINT);
3636

3737
names.emplace_back("transaction_id");
3838
return_types.emplace_back(LogicalType::UBIGINT);
3939

40-
names.emplace_back("thread");
40+
names.emplace_back("query_id");
41+
return_types.emplace_back(LogicalType::UBIGINT);
42+
43+
names.emplace_back("thread_id");
4144
return_types.emplace_back(LogicalType::UBIGINT);
4245

4346
return nullptr;

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 "1-dev725"
2+
#define DUCKDB_PATCH_VERSION "1-dev732"
33
#endif
44
#ifndef DUCKDB_MINOR_VERSION
55
#define DUCKDB_MINOR_VERSION 2
@@ -8,10 +8,10 @@
88
#define DUCKDB_MAJOR_VERSION 1
99
#endif
1010
#ifndef DUCKDB_VERSION
11-
#define DUCKDB_VERSION "v1.2.1-dev725"
11+
#define DUCKDB_VERSION "v1.2.1-dev732"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "87cf773033"
14+
#define DUCKDB_SOURCE_ID "a76ff3f10b"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

src/duckdb/src/include/duckdb/common/typedefs.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ typedef uint32_t sel_t;
3131
//! Type used for transaction timestamps
3232
typedef idx_t transaction_t;
3333

34+
//! Type used to identify connections
35+
typedef idx_t connection_t;
36+
3437
//! Type used for column identifiers
3538
typedef idx_t column_t;
3639
//! Type used for storage (column) identifiers

src/duckdb/src/include/duckdb/function/scalar/system_functions.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,31 @@ struct WriteLogFun {
4242
static ScalarFunctionSet GetFunctions();
4343
};
4444

45+
struct CurrentConnectionId {
46+
static constexpr const char *Name = "current_connection_id";
47+
static constexpr const char *Parameters = "";
48+
static constexpr const char *Description = "Get the current connection_id";
49+
static constexpr const char *Example = "current_connection_id()";
50+
51+
static ScalarFunction GetFunction();
52+
};
53+
54+
struct CurrentTransactionId {
55+
static constexpr const char *Name = "current_transaction_id";
56+
static constexpr const char *Parameters = "";
57+
static constexpr const char *Description = "Get the current global transaction_id";
58+
static constexpr const char *Example = "current_transaction_id()";
59+
60+
static ScalarFunction GetFunction();
61+
};
62+
63+
struct CurrentQueryId {
64+
static constexpr const char *Name = "current_query_id";
65+
static constexpr const char *Parameters = "";
66+
static constexpr const char *Description = "Get the current query_id";
67+
static constexpr const char *Example = "current_transaction_id('Hello')";
68+
69+
static ScalarFunction GetFunction();
70+
};
71+
4572
} // namespace duckdb

0 commit comments

Comments
 (0)