Skip to content

Commit

Permalink
Avoid shadowing locks with locks taken in macros (#603)
Browse files Browse the repository at this point in the history
I got some warnings when using pd_log in certain places. This fixes
those. It also changes the name in the `__PostgresFunctionGuard__`
template to `lock`, because variables in templates don't shadow
variables at invocation.
  • Loading branch information
JelteF authored Feb 14, 2025
1 parent b4c552d commit 3789e4c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/pgduckdb/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace pgduckdb {
pd_prevent_errno_in_scope(); \
static_assert(elevel >= DEBUG5 && elevel <= WARNING_CLIENT_ONLY, "Invalid error level"); \
if (message_level_is_interesting(elevel)) { \
std::lock_guard<std::recursive_mutex> lock(pgduckdb::GlobalProcessLock::GetLock()); \
std::lock_guard<std::recursive_mutex> __pd_log_lock(pgduckdb::GlobalProcessLock::GetLock()); \
if (errstart(elevel, domain)) \
__VA_ARGS__, errfinish(__FILE__, __LINE__, __func__); \
} \
Expand Down
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct PostgresScopedStackReset {
template <typename Func, Func func, typename... FuncArgs>
typename std::invoke_result<Func, FuncArgs...>::type
__PostgresFunctionGuard__(const char *func_name, FuncArgs... args) {
std::lock_guard<std::recursive_mutex> lk(pgduckdb::GlobalProcessLock::GetLock());
std::lock_guard<std::recursive_mutex> lock(pgduckdb::GlobalProcessLock::GetLock());
MemoryContext ctx = CurrentMemoryContext;
ErrorData *edata = nullptr;
{ // Scope for PG_END_TRY
Expand Down

0 comments on commit 3789e4c

Please sign in to comment.