diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 489635420a1f278ec4e52db5e87513d4a9e55239..d655bdcfe3b82fe0b97fff29fb5ec847bd97955e 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -174,7 +174,7 @@ typedef struct { #define keyCol(pCols) (&((pCols)->cols[0])) // Key column #define dataColsKeyAt(pCols, idx) ((TSKEY *)(keyCol(pCols)->pData))[(idx)] #define dataColsKeyFirst(pCols) dataColsKeyAt(pCols, 0) -#define dataColsKeyLast(pCols) dataColsKeyAt(pCols, (pCols)->numOfPoints - 1) +#define dataColsKeyLast(pCols) ((pCols->numOfPoints == 0) ? 0 : dataColsKeyAt(pCols, (pCols)->numOfPoints - 1)) SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows); void tdResetDataCols(SDataCols *pCols); diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index fb77975d25c742b84f2adb41631cc521e152c4eb..39808ab02fd23373a14aae8027604cf4f37b026d 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -20,11 +20,29 @@ #include "tsdb.h" #include "tskiplist.h" #include "tutil.h" +#include "tlog.h" #ifdef __cplusplus extern "C" { #endif +extern int tsdbDebugFlag; + +#define tsdbError(...) \ + if (tsdbDebugFlag & DEBUG_ERROR) { \ + taosPrintLog("ERROR TSDB ", tsdbDebugFlag, __VA_ARGS__); \ + } +#define tsdbWarn(...) \ + if (tsdbDebugFlag & DEBUG_WARN) { \ + taosPrintLog("WARN TSDB ", tsdbDebugFlag, __VA_ARGS__); \ + } +#define tsdbTrace(...) \ + if (tsdbDebugFlag & DEBUG_TRACE) { \ + taosPrintLog("TSDB ", tsdbDebugFlag, __VA_ARGS__); \ + } +#define tsdbPrint(...) \ + { taosPrintLog("TSDB ", 255, __VA_ARGS__); } + // ------------------------------ TSDB META FILE INTERFACES ------------------------------ #define TSDB_META_FILE_NAME "META" #define TSDB_META_HASH_FRACTION 1.1 diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index fcfbcc9014c6dc56bb961b771357a1f07a53b776..b1ef3d2d9ce38e0c0e0347ac9d1c6b9a61905cb3 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -7,6 +7,8 @@ #include "tscompression.h" #include "tchecksum.h" +int tsdbDebugFlag = 135; + #define TSDB_DEFAULT_PRECISION TSDB_PRECISION_MILLI // default precision #define IS_VALID_PRECISION(precision) (((precision) >= TSDB_PRECISION_MILLI) && ((precision) <= TSDB_PRECISION_NANO)) #define TSDB_DEFAULT_COMPRESSION TWO_STAGE_COMP