Skip to content
Merged
Show file tree
Hide file tree
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
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 "2-dev284"
#define DUCKDB_PATCH_VERSION "2-dev291"
#endif
#ifndef DUCKDB_MINOR_VERSION
#define DUCKDB_MINOR_VERSION 4
Expand All @@ -8,10 +8,10 @@
#define DUCKDB_MAJOR_VERSION 1
#endif
#ifndef DUCKDB_VERSION
#define DUCKDB_VERSION "v1.4.2-dev284"
#define DUCKDB_VERSION "v1.4.2-dev291"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "7ce99bc041"
#define DUCKDB_SOURCE_ID "396c86228b"
#endif
#include "duckdb/function/table/system_functions.hpp"
#include "duckdb/main/database.hpp"
Expand Down
6 changes: 6 additions & 0 deletions src/duckdb/src/include/duckdb/common/http_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "duckdb/common/types.hpp"
#include "duckdb/common/case_insensitive_map.hpp"
#include "duckdb/common/enums/http_status_code.hpp"
#include "duckdb/common/types/timestamp.hpp"
#include <functional>

namespace duckdb {
Expand Down Expand Up @@ -143,6 +144,11 @@ struct BaseRequest {
//! Whether or not to return failed requests (instead of throwing)
bool try_request = false;

// Requests will optionally contain their timings
bool have_request_timing = false;
timestamp_t request_start;
timestamp_t request_end;

template <class TARGET>
TARGET &Cast() {
return reinterpret_cast<TARGET &>(*this);
Expand Down
7 changes: 6 additions & 1 deletion src/duckdb/src/logging/log_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ LogicalType HTTPLogType::GetLogType() {
child_list_t<LogicalType> request_child_list = {
{"type", LogicalType::VARCHAR},
{"url", LogicalType::VARCHAR},
{"start_time", LogicalType::TIMESTAMP_TZ},
{"duration_ms", LogicalType::BIGINT},
{"headers", LogicalType::MAP(LogicalType::VARCHAR, LogicalType::VARCHAR)},
};
auto request_type = LogicalType::STRUCT(request_child_list);
Expand Down Expand Up @@ -91,7 +93,10 @@ string HTTPLogType::ConstructLogMessage(BaseRequest &request, optional_ptr<HTTPR
{"type", Value(EnumUtil::ToString(request.type))},
{"url", Value(request.url)},
{"headers", CreateHTTPHeadersValue(request.headers)},
};
{"start_time", request.have_request_timing ? Value::TIMESTAMP(request.request_start) : Value()},
{"duration_ms", request.have_request_timing ? Value::BIGINT(Timestamp::GetEpochMs(request.request_end) -
Timestamp::GetEpochMs(request.request_start))
: Value()}};
auto request_value = Value::STRUCT(request_child_list);
Value response_value;
if (response) {
Expand Down
15 changes: 15 additions & 0 deletions src/duckdb/src/main/http/http_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,27 @@ unique_ptr<HTTPResponse> HTTPUtil::SendRequest(BaseRequest &request, unique_ptr<

std::function<unique_ptr<HTTPResponse>(void)> on_request([&]() {
unique_ptr<HTTPResponse> response;

// When logging is enabled, we collect request timings
if (request.params.logger) {
request.have_request_timing = request.params.logger->ShouldLog(HTTPLogType::NAME, HTTPLogType::LEVEL);
}

try {
if (request.have_request_timing) {
request.request_start = Timestamp::GetCurrentTimestamp();
}
response = client->Request(request);
} catch (...) {
if (request.have_request_timing) {
request.request_end = Timestamp::GetCurrentTimestamp();
}
LogRequest(request, nullptr);
throw;
}
if (request.have_request_timing) {
request.request_end = Timestamp::GetCurrentTimestamp();
}
LogRequest(request, response ? response.get() : nullptr);
return response;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ unique_ptr<ParsedExpression> Transformer::TransformTypeCast(duckdb_libpgquery::P
parameters.query_location = NumericCast<idx_t>(root.location);
}
auto blob_data = Blob::ToBlob(string(c->val.val.str), parameters);
return make_uniq<ConstantExpression>(Value::BLOB_RAW(blob_data));
auto result = make_uniq<ConstantExpression>(Value::BLOB_RAW(blob_data));
SetQueryLocation(*result, root.location);
return std::move(result);
}
}
// transform the expression node
Expand Down