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

Run clang-format on all headers too #508

Merged
merged 1 commit into from
Dec 20, 2024
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ format:
ruff format

format-all:
find src include -iname '*.h' -o -iname '*.cpp' -o -iname '*.c' | xargs clang-format -i
find src include -iname '*.hpp' -o -iname '*.h' -o -iname '*.cpp' -o -iname '*.c' | xargs clang-format -i
ruff format
50 changes: 24 additions & 26 deletions include/pgduckdb/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
extern "C" {
bool errstart(int elevel, const char *domain);
void errfinish(const char *filename, int lineno, const char *funcname);
int errmsg_internal(const char *fmt,...);
int errmsg_internal(const char *fmt, ...);
bool message_level_is_interesting(int elevel);
}

namespace pgduckdb {

/* PG Error level codes */
#define DEBUG5 10
#define DEBUG4 11
#define DEBUG3 12
#define DEBUG2 13
#define DEBUG1 14
#define LOG 15
#define INFO 17
#define NOTICE 18
#define WARNING 19
#define PGWARNING 19
#define WARNING_CLIENT_ONLY 20
#define DEBUG5 10
#define DEBUG4 11
#define DEBUG3 12
#define DEBUG2 13
#define DEBUG1 14
#define LOG 15
#define INFO 17
#define NOTICE 18
#define WARNING 19
#define PGWARNING 19
#define WARNING_CLIENT_ONLY 20

// From PG elog.h
#ifdef __GNUC__
Expand All @@ -41,23 +41,21 @@ namespace pgduckdb {
#define pd_prevent_errno_in_scope()
#endif

#define pd_ereport_domain(elevel, domain, ...) \
do { \
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::mutex> lock(DuckdbProcessLock::GetLock()); \
if (errstart(elevel, domain)) \
__VA_ARGS__, errfinish(__FILE__, __LINE__, __func__); \
} \
} while(0)
#define pd_ereport_domain(elevel, domain, ...) \
do { \
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::mutex> lock(DuckdbProcessLock::GetLock()); \
if (errstart(elevel, domain)) \
__VA_ARGS__, errfinish(__FILE__, __LINE__, __func__); \
} \
} while (0)

#define TEXTDOMAIN NULL

#define pd_ereport(elevel, ...) \
pd_ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
#define pd_ereport(elevel, ...) pd_ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)

#define pd_log(elevel, ...) \
pd_ereport(elevel, errmsg_internal(__VA_ARGS__))
#define pd_log(elevel, ...) pd_ereport(elevel, errmsg_internal(__VA_ARGS__))

} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/pg/error_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ struct ErrorData;
}

namespace pgduckdb::pg {
const char* GetErrorDataMessage(ErrorData* error_data);
const char *GetErrorDataMessage(ErrorData *error_data);
}
3 changes: 1 addition & 2 deletions include/pgduckdb/pgduckdb_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef struct MemoryContextData *MemoryContext;
extern sigjmp_buf *PG_exception_stack;
extern MemoryContext CurrentMemoryContext;
extern ErrorContextCallback *error_context_stack;
extern ErrorData * CopyErrorData();
extern ErrorData *CopyErrorData();
extern void FlushErrorState();
}

Expand Down Expand Up @@ -74,7 +74,6 @@ __PostgresFunctionGuard__(const char *func_name, FuncArgs... args) {
#define PostgresFunctionGuard(FUNC, ...) \
pgduckdb::__PostgresFunctionGuard__<decltype(&FUNC), &FUNC>(__func__, __VA_ARGS__)


duckdb::unique_ptr<duckdb::QueryResult> DuckDBQueryOrThrow(duckdb::ClientContext &context, const std::string &query);

duckdb::unique_ptr<duckdb::QueryResult> DuckDBQueryOrThrow(duckdb::Connection &connection, const std::string &query);
Expand Down
21 changes: 14 additions & 7 deletions include/pgduckdb/utility/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ struct DuckDBMallocator {

DuckDBMallocator() = default;

template<class U>
constexpr DuckDBMallocator(const DuckDBMallocator <U>&) noexcept {}
template <class U>
constexpr DuckDBMallocator(const DuckDBMallocator<U> &) noexcept {
}

[[nodiscard]] T *
allocate(std::size_t n) {
Expand All @@ -31,10 +32,16 @@ struct DuckDBMallocator {
}
};

template<class T, class U>
bool operator==(const DuckDBMallocator <T>&, const DuckDBMallocator <U>&) { return true; }

template<class T, class U>
bool operator!=(const DuckDBMallocator <T>&, const DuckDBMallocator <U>&) { return false; }
template <class T, class U>
bool
operator==(const DuckDBMallocator<T> &, const DuckDBMallocator<U> &) {
return true;
}

template <class T, class U>
bool
operator!=(const DuckDBMallocator<T> &, const DuckDBMallocator<U> &) {
return false;
}

} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/utility/copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ extern "C" {
#include "nodes/plannodes.h"
}

const char* MakeDuckdbCopyQuery(PlannedStmt *pstmt, const char *query_string, struct QueryEnvironment *query_env);
const char *MakeDuckdbCopyQuery(PlannedStmt *pstmt, const char *query_string, struct QueryEnvironment *query_env);
2 changes: 1 addition & 1 deletion include/pgduckdb/utility/cpp_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ __CPPFunctionGuard__(const char *func_name, FuncArgs... args) {
elog(ERROR, "(PGDuckDB/%s) %s", func_name, error_message);
}

}
} // namespace pgduckdb

#define InvokeCPPFunc(FUNC, ...) pgduckdb::__CPPFunctionGuard__<decltype(&FUNC), &FUNC>(__FUNCTION__, __VA_ARGS__)

Expand Down