mirror of https://github.com/citusdata/citus.git
add missing headers
parent
dc53350652
commit
1b3f4d79fe
|
@ -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$@ $< > $@
|
||||||
|
|
|
@ -105,9 +105,10 @@ JobExecutorType(DistributedPlan *distributedPlan)
|
||||||
if (!EnableRepartitionJoins)
|
if (!EnableRepartitionJoins)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (
|
ereport(ERROR, (
|
||||||
errmsg("the query contains a join that requires repartitioning"),
|
errmsg(
|
||||||
errhint("Set citus.enable_repartition_joins to on "
|
"the query contains a join that requires repartitioning"),
|
||||||
"to enable repartitioning")));
|
errhint("Set citus.enable_repartition_joins to on "
|
||||||
|
"to enable repartitioning")));
|
||||||
}
|
}
|
||||||
if (HasReplicatedDistributedTable(distributedPlan->relationIdList))
|
if (HasReplicatedDistributedTable(distributedPlan->relationIdList))
|
||||||
{
|
{
|
||||||
|
@ -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:
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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"
|
||||||
|
@ -17,59 +17,78 @@
|
||||||
#define BACKTRACE_SKIP 2
|
#define BACKTRACE_SKIP 2
|
||||||
|
|
||||||
static int BacktraceFullCallback(void *data, uintptr_t pc,
|
static int BacktraceFullCallback(void *data, uintptr_t pc,
|
||||||
const char *filename, int lineno,
|
const char *filename, int lineno,
|
||||||
const char *function);
|
const char *function);
|
||||||
|
|
||||||
static void BacktraceErrorCallback(void *data, const char *msg, int errnum);
|
static void BacktraceErrorCallback(void *data, const char *msg, int errnum);
|
||||||
static void InitBackTrace(void);
|
static void InitBackTrace(void);
|
||||||
static bool ShouldLogBacktrace(int elevel);
|
static bool ShouldLogBacktrace(int elevel);
|
||||||
static char* GenerateBackTrace(void);
|
static char * GenerateBackTrace(void);
|
||||||
|
|
||||||
static struct backtrace_state* backTracestate;
|
static struct backtrace_state *backTracestate;
|
||||||
|
|
||||||
static void InitBackTrace(void) {
|
static void
|
||||||
const char* filename = NULL;
|
InitBackTrace(void)
|
||||||
void* data = NULL;
|
{
|
||||||
backTracestate = backtrace_create_state(filename, BACKTRACE_SUPPORTS_THREADS,
|
const char *filename = NULL;
|
||||||
BacktraceErrorCallback, data);
|
void *data = NULL;
|
||||||
}
|
backTracestate = backtrace_create_state(filename, 0,
|
||||||
|
BacktraceErrorCallback, data);
|
||||||
static bool ShouldLogBacktrace(int elevel) {
|
|
||||||
return elevel >= ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Backtrace(int elevel) {
|
static bool
|
||||||
if (!ShouldLogBacktrace(elevel)) {
|
ShouldLogBacktrace(int elevel)
|
||||||
return;
|
{
|
||||||
}
|
return elevel >= ERROR;
|
||||||
errdetail("%s", GenerateBackTrace());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static char* GenerateBackTrace(void) {
|
|
||||||
if (backTracestate == NULL) {
|
void
|
||||||
InitBackTrace();
|
Backtrace(int elevel)
|
||||||
}
|
{
|
||||||
StringInfo msgWithBacktrace = makeStringInfo();
|
if (!ShouldLogBacktrace(elevel))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
errdetail("%s", GenerateBackTrace());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *
|
||||||
|
GenerateBackTrace(void)
|
||||||
|
{
|
||||||
|
if (backTracestate == NULL)
|
||||||
|
{
|
||||||
|
InitBackTrace();
|
||||||
|
}
|
||||||
|
StringInfo msgWithBacktrace = makeStringInfo();
|
||||||
|
|
||||||
appendStringInfoString(msgWithBacktrace, BACKTRACE_HEADER);
|
appendStringInfoString(msgWithBacktrace, BACKTRACE_HEADER);
|
||||||
backtrace_full(backTracestate, BACKTRACE_SKIP, BacktraceFullCallback,
|
backtrace_full(backTracestate, BACKTRACE_SKIP, BacktraceFullCallback,
|
||||||
BacktraceErrorCallback, msgWithBacktrace);
|
BacktraceErrorCallback, msgWithBacktrace);
|
||||||
|
|
||||||
return msgWithBacktrace->data;
|
return msgWithBacktrace->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int BacktraceFullCallback(void *data, uintptr_t pc, const char *filename, int lineno,
|
|
||||||
const char *function) {
|
|
||||||
|
|
||||||
StringInfo str = (StringInfo) data;
|
static int
|
||||||
if (function && filename) {
|
BacktraceFullCallback(void *data, uintptr_t pc, const char *filename, int lineno,
|
||||||
appendStringInfo(str, "%s:%s:%d\n",filename, function, lineno);
|
const char *function)
|
||||||
}
|
{
|
||||||
/* returning 0 means we will continue the backtrace */
|
StringInfo str = (StringInfo) data;
|
||||||
return 0;
|
if (function && filename)
|
||||||
|
{
|
||||||
|
appendStringInfo(str, "%s:%s:%d\n", filename, function, lineno);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returning 0 means we will continue the backtrace */
|
||||||
|
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 */
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,5 +14,3 @@
|
||||||
void Backtrace(int elevel);
|
void Backtrace(int elevel);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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,29 +25,37 @@ 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 { \
|
||||||
pg_prevent_errno_in_scope(); \
|
pg_prevent_errno_in_scope(); \
|
||||||
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, ...) \
|
||||||
do { \
|
do { \
|
||||||
const int elevel_ = (elevel); \
|
const int elevel_ = (elevel); \
|
||||||
pg_prevent_errno_in_scope(); \
|
pg_prevent_errno_in_scope(); \
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue