add missing headers

pull/4044/head
Sait Talha Nisanci 2020-07-13 16:35:00 +03:00
parent dc53350652
commit 1b3f4d79fe
6 changed files with 93 additions and 61 deletions

View File

@ -54,7 +54,7 @@ utils/citus_version.o: $(CITUS_VERSION_INVALIDATE)
SHLIB_LINK += $(filter -lssl -lcrypto -lssleay32 -leay32, $(LIBS)) SHLIB_LINK += $(filter -lssl -lcrypto -lssleay32 -leay32, $(LIBS))
override LDFLAGS += $(libbacktrace_a) override LDFLAGS += $(libbacktrace_a)
override CPPFLAGS += -I$(libpq_srcdir) -I$(safestringlib_srcdir)/include -I$(libbacktrace_builddir)/include/ override CPPFLAGS += -I$(libpq_srcdir) -I$(safestringlib_srcdir)/include -I$(libbacktrace_srcdir)
SQL_DEPDIR=.deps/sql SQL_DEPDIR=.deps/sql
SQL_BUILDDIR=build/sql SQL_BUILDDIR=build/sql
@ -66,6 +66,8 @@ $(libbacktrace_a): $(libbacktrace_sources)
citus.so: $(libbacktrace_a) citus.so: $(libbacktrace_a)
$(OBJS): $(libbacktrace_a)
$(generated_sql_files): $(citus_abs_srcdir)/build/%: % $(generated_sql_files): $(citus_abs_srcdir)/build/%: %
@mkdir -p $(citus_abs_srcdir)/$(SQL_DEPDIR) $(citus_abs_srcdir)/$(SQL_BUILDDIR) @mkdir -p $(citus_abs_srcdir)/$(SQL_DEPDIR) $(citus_abs_srcdir)/$(SQL_BUILDDIR)
cd $(citus_abs_srcdir) && cpp -undef -w -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@ cd $(citus_abs_srcdir) && cpp -undef -w -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@

View File

@ -105,7 +105,8 @@ JobExecutorType(DistributedPlan *distributedPlan)
if (!EnableRepartitionJoins) if (!EnableRepartitionJoins)
{ {
ereport(ERROR, ( ereport(ERROR, (
errmsg("the query contains a join that requires repartitioning"), errmsg(
"the query contains a join that requires repartitioning"),
errhint("Set citus.enable_repartition_joins to on " errhint("Set citus.enable_repartition_joins to on "
"to enable repartitioning"))); "to enable repartitioning")));
} }
@ -134,6 +135,7 @@ JobExecutorType(DistributedPlan *distributedPlan)
return executorType; return executorType;
} }
/* /*
* HasReplicatedDistributedTable returns true if there is any * HasReplicatedDistributedTable returns true if there is any
* table in the given list that is: * table in the given list that is:

View File

@ -368,6 +368,7 @@ multi_log_hook(ErrorData *edata)
} }
} }
/* /*
* StartupCitusBackend initializes per-backend infrastructure, and is called * StartupCitusBackend initializes per-backend infrastructure, and is called
* the first time citus is used in a database. * the first time citus is used in a database.

View File

@ -8,7 +8,7 @@
#include "postgres.h" #include "postgres.h"
#include "backtrace.h" #include "backtrace.h"
#include "backtrace-supported.h" // #include "backtrace-supported.h"
#include "lib/stringinfo.h" #include "lib/stringinfo.h"
#include "distributed/backtrace.h" #include "distributed/backtrace.h"
@ -27,27 +27,39 @@ static char* GenerateBackTrace(void);
static struct backtrace_state *backTracestate; static struct backtrace_state *backTracestate;
static void InitBackTrace(void) { static void
InitBackTrace(void)
{
const char *filename = NULL; const char *filename = NULL;
void *data = NULL; void *data = NULL;
backTracestate = backtrace_create_state(filename, BACKTRACE_SUPPORTS_THREADS, backTracestate = backtrace_create_state(filename, 0,
BacktraceErrorCallback, data); BacktraceErrorCallback, data);
} }
static bool ShouldLogBacktrace(int elevel) {
static bool
ShouldLogBacktrace(int elevel)
{
return elevel >= ERROR; return elevel >= ERROR;
} }
void Backtrace(int elevel) { void
if (!ShouldLogBacktrace(elevel)) { Backtrace(int elevel)
{
if (!ShouldLogBacktrace(elevel))
{
return; return;
} }
errdetail("%s", GenerateBackTrace()); errdetail("%s", GenerateBackTrace());
} }
static char* GenerateBackTrace(void) {
if (backTracestate == NULL) { static char *
GenerateBackTrace(void)
{
if (backTracestate == NULL)
{
InitBackTrace(); InitBackTrace();
} }
StringInfo msgWithBacktrace = makeStringInfo(); StringInfo msgWithBacktrace = makeStringInfo();
@ -59,17 +71,24 @@ static char* GenerateBackTrace(void) {
return msgWithBacktrace->data; return msgWithBacktrace->data;
} }
static int BacktraceFullCallback(void *data, uintptr_t pc, const char *filename, int lineno,
const char *function) {
static int
BacktraceFullCallback(void *data, uintptr_t pc, const char *filename, int lineno,
const char *function)
{
StringInfo str = (StringInfo) data; StringInfo str = (StringInfo) data;
if (function && filename) { if (function && filename)
{
appendStringInfo(str, "%s:%s:%d\n", filename, function, lineno); appendStringInfo(str, "%s:%s:%d\n", filename, function, lineno);
} }
/* returning 0 means we will continue the backtrace */ /* returning 0 means we will continue the backtrace */
return 0; return 0;
} }
static void BacktraceErrorCallback(void *data, const char *msg, int errnum) {
// currently NO-OP static void
BacktraceErrorCallback(void *data, const char *msg, int errnum)
{
/* currently NO-OP */
} }

View File

@ -14,5 +14,3 @@
void Backtrace(int elevel); void Backtrace(int elevel);
#endif #endif

View File

@ -9,9 +9,11 @@
#ifndef LOG_UTILS_H #ifndef LOG_UTILS_H
#define LOG_UTILS_H #define LOG_UTILS_H
#include "c.h"
#include "postgres.h"
#include "utils/guc.h" #include "utils/guc.h"
#include "distributed/backtrace.h" #include "distributed/backtrace.h"
#include "utils/elog.h"
/* do not log */ /* do not log */
#define CITUS_LOG_LEVEL_OFF 0 #define CITUS_LOG_LEVEL_OFF 0
@ -23,6 +25,15 @@ extern char * HashLogMessage(const char *text);
#define ApplyLogRedaction(text) \ #define ApplyLogRedaction(text) \
(log_min_messages <= ereport_loglevel ? HashLogMessage(text) : text) (log_min_messages <= ereport_loglevel ? HashLogMessage(text) : text)
#undef ereport_domain #undef ereport_domain
#if defined(errno) && defined(__linux__)
#define pg_prevent_errno_in_scope() int __errno_location pg_attribute_unused()
#elif defined(errno) && (defined(__darwin__) || defined(__freebsd__))
#define pg_prevent_errno_in_scope() int __error pg_attribute_unused()
#else
#define pg_prevent_errno_in_scope()
#endif
#ifdef HAVE__BUILTIN_CONSTANT_P #ifdef HAVE__BUILTIN_CONSTANT_P
#define ereport_domain(elevel, domain, ...) \ #define ereport_domain(elevel, domain, ...) \
do { \ do { \
@ -30,8 +41,8 @@ extern char * HashLogMessage(const char *text);
if (errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain)) { \ if (errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain)) { \
__VA_ARGS__, Backtrace(elevel); errfinish(0); \ __VA_ARGS__, Backtrace(elevel); errfinish(0); \
} \ } \
if (__builtin_constant_p(elevel) && (elevel) >= ERROR) \ if (__builtin_constant_p(elevel) && (elevel) >= ERROR) { \
pg_unreachable(); \ pg_unreachable(); } \
} while (0) } while (0)
#else /* !HAVE__BUILTIN_CONSTANT_P */ #else /* !HAVE__BUILTIN_CONSTANT_P */
#define ereport_domain(elevel, domain, ...) \ #define ereport_domain(elevel, domain, ...) \
@ -41,13 +52,12 @@ extern char * HashLogMessage(const char *text);
if (errstart(elevel_, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain)) { \ if (errstart(elevel_, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain)) { \
__VA_ARGS__, Backtrace(elevel); errfinish(0); \ __VA_ARGS__, Backtrace(elevel); errfinish(0); \
} \ } \
if (elevel_ >= ERROR) \ if (elevel_ >= ERROR) { \
pg_unreachable(); \ pg_unreachable(); } \
} while (0) } while (0)
#endif /* HAVE__BUILTIN_CONSTANT_P */ #endif /* HAVE__BUILTIN_CONSTANT_P */
#undef ereport #undef ereport
#define ereport(elevel, rest) \ #define ereport(elevel, rest) \
do { \ do { \