提交 6e01c527 编写于 作者: H hjxilinx

supress some warnings from clang-tidy,valgrind etc.

上级 25ff54c9
...@@ -23,7 +23,7 @@ extern "C" { ...@@ -23,7 +23,7 @@ extern "C" {
#include "taosmsg.h" #include "taosmsg.h"
#include "tsdb.h" #include "tsdb.h"
extern int sdbDebugFlag; extern uint32_t sdbDebugFlag;
extern short sdbPeerPort; extern short sdbPeerPort;
extern short sdbSyncPort; extern short sdbSyncPort;
extern int sdbMaxNodes; extern int sdbMaxNodes;
......
...@@ -146,19 +146,19 @@ extern char tsInternalPass[]; ...@@ -146,19 +146,19 @@ extern char tsInternalPass[];
extern int tsMonitorInterval; extern int tsMonitorInterval;
extern int tsNumOfLogLines; extern int tsNumOfLogLines;
extern int ddebugFlag; extern uint32_t ddebugFlag;
extern int mdebugFlag; extern uint32_t mdebugFlag;
extern int cdebugFlag; extern uint32_t cdebugFlag;
extern int jnidebugFlag; extern uint32_t jnidebugFlag;
extern int tmrDebugFlag; extern uint32_t tmrDebugFlag;
extern int sdbDebugFlag; extern uint32_t sdbDebugFlag;
extern int httpDebugFlag; extern uint32_t httpDebugFlag;
extern int monitorDebugFlag; extern uint32_t monitorDebugFlag;
extern int uDebugFlag; extern uint32_t uDebugFlag;
extern int rpcDebugFlag; extern uint32_t rpcDebugFlag;
extern int debugFlag; extern uint32_t debugFlag;
extern int odbcdebugFlag; extern uint32_t odbcdebugFlag;
extern int qdebugFlag; extern uint32_t qdebugFlag;
extern int tsRpcTimer; extern int tsRpcTimer;
extern int tsRpcMaxTime; extern int tsRpcMaxTime;
......
...@@ -25,16 +25,14 @@ extern "C" { ...@@ -25,16 +25,14 @@ extern "C" {
#include <string.h> #include <string.h>
#include "tglobalcfg.h" #include "tglobalcfg.h"
#define DEBUG_ERROR 1 #define DEBUG_ERROR 1U
#define DEBUG_WARN 2 #define DEBUG_WARN 2U
#define DEBUG_TRACE 4 #define DEBUG_TRACE 4U
#define DEBUG_DUMP 8 #define DEBUG_DUMP 8U
#define DEBUG_FILE 0x80 #define DEBUG_FILE 0x80
#define DEBUG_SCREEN 0x40 #define DEBUG_SCREEN 0x40
extern int uDebugFlag;
extern void (*taosLogFp)(int level, const char *const format, ...); extern void (*taosLogFp)(int level, const char *const format, ...);
extern void (*taosLogSqlFp)(char *sql); extern void (*taosLogSqlFp)(char *sql);
...@@ -99,7 +97,7 @@ void taosResetLogFile(); ...@@ -99,7 +97,7 @@ void taosResetLogFile();
{ tprintf("UTL ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); } { tprintf("UTL ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }
// client log function // client log function
extern int cdebugFlag; extern uint32_t cdebugFlag;
#define tscError(...) \ #define tscError(...) \
if (cdebugFlag & DEBUG_ERROR) { \ if (cdebugFlag & DEBUG_ERROR) { \
...@@ -132,7 +130,6 @@ extern int cdebugFlag; ...@@ -132,7 +130,6 @@ extern int cdebugFlag;
{ tprintf("JNI ", 255, __VA_ARGS__); } { tprintf("JNI ", 255, __VA_ARGS__); }
// rpc log function // rpc log function
extern int rpcDebugFlag;
#define tError(...) \ #define tError(...) \
if (rpcDebugFlag & DEBUG_ERROR) { \ if (rpcDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR RPC ", rpcDebugFlag, __VA_ARGS__); \ tprintf("ERROR RPC ", rpcDebugFlag, __VA_ARGS__); \
......
...@@ -73,7 +73,6 @@ typedef struct { ...@@ -73,7 +73,6 @@ typedef struct {
char * ckey; // ciphering key char * ckey; // ciphering key
} SRpcConnInit; } SRpcConnInit;
extern int rpcDebugFlag;
extern int tsRpcHeadSize; extern int tsRpcHeadSize;
void *taosOpenRpc(SRpcInit *pRpc); void *taosOpenRpc(SRpcInit *pRpc);
......
...@@ -22,7 +22,7 @@ extern "C" { ...@@ -22,7 +22,7 @@ extern "C" {
typedef void *tmr_h; typedef void *tmr_h;
extern int tmrDebugFlag; extern uint32_t tmrDebugFlag;
extern int taosTmrThreads; extern int taosTmrThreads;
void *taosTmrInit(int maxTmr, int resoultion, int longest, char *label); void *taosTmrInit(int maxTmr, int resoultion, int longest, char *label);
......
...@@ -39,10 +39,13 @@ ...@@ -39,10 +39,13 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <sys/un.h> #include <sys/un.h>
#include <sys/stat.h>
#include <stdint.h> #include <stdint.h>
#include <pthread.h> #include <pthread.h>
#include <stdbool.h> #include <stdbool.h>
#include <limits.h> #include <limits.h>
#include <linux/limits.h>
#include <strings.h>
#include <sys/sendfile.h> #include <sys/sendfile.h>
bool taosCheckPthreadValid(pthread_t thread); bool taosCheckPthreadValid(pthread_t thread);
...@@ -65,4 +68,11 @@ void taosKillSystem(); ...@@ -65,4 +68,11 @@ void taosKillSystem();
bool taosIsRunningWSLv1(); bool taosIsRunningWSLv1();
int64_t str2int64(char *str);
#define BUILDIN_CLZL(val) __builtin_clzl(val)
#define BUILDIN_CLZ(val) __builtin_clz(val)
#define BUILDIN_CTZL(val) __builtin_ctzl(val)
#define BUILDIN_CTZ(val) __builtin_ctz(val)
#endif #endif
\ No newline at end of file
...@@ -116,7 +116,7 @@ typedef struct rpc_server { ...@@ -116,7 +116,7 @@ typedef struct rpc_server {
} STaosRpc; } STaosRpc;
// configurable // configurable
int rpcDebugFlag = 131; uint32_t rpcDebugFlag = 131;
int tsRpcTimer = 300; int tsRpcTimer = 300;
int tsRpcMaxTime = 600; // seconds; int tsRpcMaxTime = 600; // seconds;
int tsRpcProgressTime = 10; // milliseocnds int tsRpcProgressTime = 10; // milliseocnds
......
...@@ -136,7 +136,6 @@ typedef struct { ...@@ -136,7 +136,6 @@ typedef struct {
extern SSdbTable *tableList[]; extern SSdbTable *tableList[];
extern int sdbMaxPeers; extern int sdbMaxPeers;
extern int sdbDebugFlag;
extern int sdbNumOfTables; extern int sdbNumOfTables;
extern int64_t sdbVersion; extern int64_t sdbVersion;
......
...@@ -19,42 +19,31 @@ ...@@ -19,42 +19,31 @@
* To compress integers (including char, short, int, int64_t), the difference * To compress integers (including char, short, int, int64_t), the difference
* between two integers is calculated at first. Then the difference is * between two integers is calculated at first. Then the difference is
* transformed to positive by zig-zag encoding method * transformed to positive by zig-zag encoding method
* (https://gist.github.com/mfuerstenau/ba870a29e16536fdbaba). Then the value * (https://gist.github.com/mfuerstenau/ba870a29e16536fdbaba). Then the value is
* is
* encoded using simple 8B method. For more information about simple 8B, * encoded using simple 8B method. For more information about simple 8B,
* refer to https://en.wikipedia.org/wiki/8b/10b_encoding. * refer to https://en.wikipedia.org/wiki/8b/10b_encoding.
* *
* NOTE : For bigint, only 59 bits can be used, which means data from -(2**59) * NOTE : For bigint, only 59 bits can be used, which means data from -(2**59) to (2**59)-1
* to (2**59)-1
* are allowed. * are allowed.
* *
* BOOLEAN Compression Algorithm: * BOOLEAN Compression Algorithm:
* We provide two methods for compress boolean types. Because boolean types in * We provide two methods for compress boolean types. Because boolean types in C
* C * code are char bytes with 0 and 1 values only, only one bit can used to discrimenate
* code are char bytes with 0 and 1 values only, only one bit can used to
* discrimenate
* the values. * the values.
* 1. The first method is using only 1 bit to represent the boolean value with * 1. The first method is using only 1 bit to represent the boolean value with 1 for
* 1 for
* true and 0 for false. Then the compression rate is 1/8. * true and 0 for false. Then the compression rate is 1/8.
* 2. The second method is using run length encoding (RLE) methods. This * 2. The second method is using run length encoding (RLE) methods. This methos works
* methos works
* better when there are a lot of consecutive true values or false values. * better when there are a lot of consecutive true values or false values.
* *
* STRING Compression Algorithm: * STRING Compression Algorithm:
* We us LZ4 method to compress the string type. * We us LZ4 method to compress the string type.
* *
* FLOAT Compression Algorithm: * FLOAT Compression Algorithm:
* We use the same method with Akumuli to compress float and double types. The * We use the same method with Akumuli to compress float and double types. The compression
* compression * algorithm assumes the float/double values change slightly. So we take the XOR between two
* algorithm assumes the float/double values change slightly. So we take the * adjacent values. Then compare the number of leading zeros and trailing zeros. If the number
* XOR between two * of leading zeros are larger than the trailing zeros, then record the last serveral bytes
* adjacent values. Then compare the number of leading zeros and trailing * of the XORed value with informations. If not, record the first corresponding bytes.
* zeros. If the number
* of leading zeros are larger than the trailing zeros, then record the last
* serveral bytes
* of the XORed value with informations. If not, record the first
* corresponding bytes.
* *
*/ */
#include <assert.h> #include <assert.h>
...@@ -64,6 +53,7 @@ ...@@ -64,6 +53,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "os.h"
#include "lz4.h" #include "lz4.h"
#include "tscompression.h" #include "tscompression.h"
#include "tsdb.h" #include "tsdb.h"
...@@ -368,7 +358,7 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o ...@@ -368,7 +358,7 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o
// Take care here, __builtin_clzl give wrong anser for value 0; // Take care here, __builtin_clzl give wrong anser for value 0;
tmp_bit = 0; tmp_bit = 0;
} else { } else {
tmp_bit = (LONG_BYTES * BITS_PER_BYTE) - __builtin_clzl(zigzag_value); tmp_bit = (LONG_BYTES * BITS_PER_BYTE) - BUILDIN_CLZL(zigzag_value);
} }
if (elems + 1 <= selector_to_elems[selector] && elems + 1 <= selector_to_elems[bit_to_selector[tmp_bit]]) { if (elems + 1 <= selector_to_elems[selector] && elems + 1 <= selector_to_elems[bit_to_selector[tmp_bit]]) {
...@@ -695,14 +685,14 @@ int tsCompressTimestampImp(const char *const input, const int nelements, char *c ...@@ -695,14 +685,14 @@ int tsCompressTimestampImp(const char *const input, const int nelements, char *c
if (dd1 == 0) { if (dd1 == 0) {
flag1 = 0; flag1 = 0;
} else { } else {
flag1 = LONG_BYTES - __builtin_clzl(dd1) / BITS_PER_BYTE; flag1 = LONG_BYTES - BUILDIN_CLZL(dd1) / BITS_PER_BYTE;
} }
} else { } else {
dd2 = zigzag_value; dd2 = zigzag_value;
if (dd2 == 0) { if (dd2 == 0) {
flag2 = 0; flag2 = 0;
} else { } else {
flag2 = LONG_BYTES - __builtin_clzl(dd2) / BITS_PER_BYTE; flag2 = LONG_BYTES - BUILDIN_CLZL(dd2) / BITS_PER_BYTE;
} }
flags = flag1 | (flag2 << 4); flags = flag1 | (flag2 << 4);
// Encode the flag. // Encode the flag.
...@@ -869,8 +859,8 @@ int tsCompressDoubleImp(const char *const input, const int nelements, char *cons ...@@ -869,8 +859,8 @@ int tsCompressDoubleImp(const char *const input, const int nelements, char *cons
int trailing_zeros = leading_zeros; int trailing_zeros = leading_zeros;
if (diff) { if (diff) {
trailing_zeros = __builtin_ctzl(diff); trailing_zeros = BUILDIN_CTZL(diff);
leading_zeros = __builtin_clzl(diff); leading_zeros = BUILDIN_CLZL(diff);
} }
uint8_t nbytes = 0; uint8_t nbytes = 0;
...@@ -1016,8 +1006,8 @@ int tsCompressFloatImp(const char *const input, const int nelements, char *const ...@@ -1016,8 +1006,8 @@ int tsCompressFloatImp(const char *const input, const int nelements, char *const
int trailing_zeros = leading_zeros; int trailing_zeros = leading_zeros;
if (diff) { if (diff) {
trailing_zeros = __builtin_ctz(diff); trailing_zeros = BUILDIN_CTZ(diff);
leading_zeros = __builtin_clz(diff); leading_zeros = BUILDIN_CLZ(diff);
} }
uint8_t nbytes = 0; uint8_t nbytes = 0;
......
...@@ -1178,7 +1178,9 @@ void tColDataQSort(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta ...@@ -1178,7 +1178,9 @@ void tColDataQSort(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta
while (right > end_same && left <= end_same) { while (right > end_same && left <= end_same) {
swap(pDescriptor, numOfRows, left++, data, right--); swap(pDescriptor, numOfRows, left++, data, right--);
} }
rightx += (end - end_same); // (pivotal+1) + steps of number that are identical pivotal
// (pivotal+1) + steps of number that are identical pivotal
rightx += (end - end_same);
#ifdef _DEBUG_VIEW #ifdef _DEBUG_VIEW
tRowModelDisplay(pDescriptor, numOfRows, data, end - start + 1); tRowModelDisplay(pDescriptor, numOfRows, data, end - start + 1);
...@@ -1193,7 +1195,9 @@ void tColDataQSort(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta ...@@ -1193,7 +1195,9 @@ void tColDataQSort(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta
while (left < start_same && right >= start_same) { while (left < start_same && right >= start_same) {
swap(pDescriptor, numOfRows, left++, data, right--); swap(pDescriptor, numOfRows, left++, data, right--);
} }
leftx -= (start_same - start); // (pivotal-1) - steps of number that are identical pivotal
// (pivotal-1) - steps of number that are identical pivotal
leftx -= (start_same - start);
#ifdef _DEBUG_VIEW #ifdef _DEBUG_VIEW
tRowModelDisplay(pDescriptor, numOfRows, data, end - start + 1); tRowModelDisplay(pDescriptor, numOfRows, data, end - start + 1);
......
...@@ -140,16 +140,16 @@ char tsLocale[TSDB_LOCALE_LEN] = {0}; ...@@ -140,16 +140,16 @@ char tsLocale[TSDB_LOCALE_LEN] = {0};
char tsCharset[TSDB_LOCALE_LEN] = {0}; // default encode string char tsCharset[TSDB_LOCALE_LEN] = {0}; // default encode string
int tsNumOfLogLines = 10000000; int tsNumOfLogLines = 10000000;
int ddebugFlag = 131; uint32_t ddebugFlag = 131;
int mdebugFlag = 135; uint32_t mdebugFlag = 135;
int sdbDebugFlag = 135; uint32_t sdbDebugFlag = 135;
int cdebugFlag = 131; uint32_t cdebugFlag = 131;
int jnidebugFlag = 131; uint32_t jnidebugFlag = 131;
int httpDebugFlag = 131; uint32_t httpDebugFlag = 131;
int monitorDebugFlag = 131; uint32_t monitorDebugFlag = 131;
int debugFlag = 131; uint32_t debugFlag = 131;
int odbcdebugFlag = 131; uint32_t odbcdebugFlag = 131;
int qdebugFlag = 131; uint32_t qdebugFlag = 131;
SGlobalConfig *tsGlobalConfig = NULL; SGlobalConfig *tsGlobalConfig = NULL;
int tsGlobalConfigNum = 0; int tsGlobalConfigNum = 0;
......
...@@ -58,7 +58,7 @@ typedef struct { ...@@ -58,7 +58,7 @@ typedef struct {
sem_t buffNotEmpty; sem_t buffNotEmpty;
} SLogBuff; } SLogBuff;
int uDebugFlag = 131; // all the messages uint32_t uDebugFlag = 131; // all the messages
short tsAsyncLog = 1; short tsAsyncLog = 1;
static SLogBuff *logHandle; static SLogBuff *logHandle;
......
...@@ -242,7 +242,6 @@ tSkipList* tSkipListCreate(int16_t nMaxLevel, int16_t keyType, int16_t nMaxKeyLe ...@@ -242,7 +242,6 @@ tSkipList* tSkipListCreate(int16_t nMaxLevel, int16_t keyType, int16_t nMaxKeyLe
srand(time(NULL)); srand(time(NULL));
pSkipList->state.nTotalMemSize += sizeof(tSkipList); pSkipList->state.nTotalMemSize += sizeof(tSkipList);
return pSkipList; return pSkipList;
} }
......
...@@ -95,7 +95,7 @@ typedef struct _tmr_ctrl_t { ...@@ -95,7 +95,7 @@ typedef struct _tmr_ctrl_t {
int tmrCtrlId; int tmrCtrlId;
} tmr_ctrl_t; } tmr_ctrl_t;
int tmrDebugFlag = DEBUG_ERROR | DEBUG_WARN | DEBUG_FILE; uint32_t tmrDebugFlag = DEBUG_ERROR | DEBUG_WARN | DEBUG_FILE;
void taosTmrProcessList(tmr_ctrl_t *); void taosTmrProcessList(tmr_ctrl_t *);
tmr_ctrl_t tmrCtrl[maxNumOfTmrCtrl]; tmr_ctrl_t tmrCtrl[maxNumOfTmrCtrl];
...@@ -132,8 +132,8 @@ void *taosProcessAlarmSignal(void *tharg) { ...@@ -132,8 +132,8 @@ void *taosProcessAlarmSignal(void *tharg) {
sigaddset(&sigset, SIGALRM); sigaddset(&sigset, SIGALRM);
sigprocmask(SIG_BLOCK, &sigset, NULL); sigprocmask(SIG_BLOCK, &sigset, NULL);
timer_t timerId; timer_t timerId = {0};
struct sigevent sevent; struct sigevent sevent = {0};
sevent.sigev_notify = SIGEV_THREAD_ID; sevent.sigev_notify = SIGEV_THREAD_ID;
sevent._sigev_un._tid = syscall(__NR_gettid); sevent._sigev_un._tid = syscall(__NR_gettid);
sevent.sigev_signo = SIGALRM; sevent.sigev_signo = SIGALRM;
......
...@@ -218,6 +218,7 @@ static SKeyword keywordTable[] = { ...@@ -218,6 +218,7 @@ static SKeyword keywordTable[] = {
{"STABLE", TK_STABLE} {"STABLE", TK_STABLE}
}; };
/* This is the hash table */
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static const char isIdChar[] = { static const char isIdChar[] = {
...@@ -273,11 +274,11 @@ int tSQLKeywordCode(const char* z, int n) { ...@@ -273,11 +274,11 @@ int tSQLKeywordCode(const char* z, int n) {
} }
/* /*
** Return the length of the token that begins at z[0]. * Return the length of the token that begins at z[0].
** Store the token type in *type before returning. * Store the token type in *type before returning.
*/ */
uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
int i; uint32_t i;
switch (*z) { switch (*z) {
case ' ': case ' ':
case '\t': case '\t':
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "os.h" #include "os.h"
#include "taos.h" #include "taos.h"
#include "tsdb.h" #include "tsdb.h"
#include "tsql.h"
#include "tsqldef.h" #include "tsqldef.h"
#include "ttypes.h" #include "ttypes.h"
#include "tutil.h" #include "tutil.h"
...@@ -43,7 +44,7 @@ tDataDescriptor tDataTypeDesc[11] = { ...@@ -43,7 +44,7 @@ tDataDescriptor tDataTypeDesc[11] = {
{TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR"}, {TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR"},
}; };
char tTokenTypeSwitcher[] = { char tTokenTypeSwitcher[13] = {
TSDB_DATA_TYPE_NULL, // no type TSDB_DATA_TYPE_NULL, // no type
TSDB_DATA_TYPE_BINARY, // TK_ID TSDB_DATA_TYPE_BINARY, // TK_ID
TSDB_DATA_TYPE_BOOL, // TK_BOOL TSDB_DATA_TYPE_BOOL, // TK_BOOL
...@@ -65,7 +66,7 @@ bool isValidDataType(int32_t type, int32_t length) { ...@@ -65,7 +66,7 @@ bool isValidDataType(int32_t type, int32_t length) {
} }
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
return length >= 0 && length <= TSDB_MAX_BINARY_LEN; // return length >= 0 && length <= TSDB_MAX_BINARY_LEN;
} }
return true; return true;
...@@ -105,8 +106,10 @@ void tVariantCreateN(tVariant *pVar, char *pz, uint32_t len, uint32_t type) { ...@@ -105,8 +106,10 @@ void tVariantCreateN(tVariant *pVar, char *pz, uint32_t len, uint32_t type) {
pVar->nLen = strdequote(pVar->pz); pVar->nLen = strdequote(pVar->pz);
break; break;
} }
default:
assert(false); default: { // nType == 0 means the null value
type = TSDB_DATA_TYPE_NULL;
}
} }
pVar->nType = type; pVar->nType = type;
...@@ -123,56 +126,58 @@ void tVariantCreateB(tVariant *pVar, char *pz, uint32_t len, uint32_t type) { ...@@ -123,56 +126,58 @@ void tVariantCreateB(tVariant *pVar, char *pz, uint32_t len, uint32_t type) {
switch (type) { switch (type) {
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
case TSDB_DATA_TYPE_TINYINT: { case TSDB_DATA_TYPE_TINYINT: {
pVar->i64Key = *(int8_t *)pz; pVar->i64Key = GET_INT8_VAL(pz);
break; break;
} }
case TSDB_DATA_TYPE_SMALLINT: { case TSDB_DATA_TYPE_SMALLINT: {
pVar->i64Key = *(int16_t *)pz; pVar->i64Key = GET_INT16_VAL(pz);
break; break;
} }
case TSDB_DATA_TYPE_INT: { case TSDB_DATA_TYPE_INT: {
pVar->i64Key = *(int32_t *)pz; pVar->i64Key = GET_INT32_VAL(pz);
break; break;
} }
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_TIMESTAMP: { case TSDB_DATA_TYPE_TIMESTAMP: {
pVar->i64Key = *(int64_t *)pz; pVar->i64Key = GET_INT64_VAL(pz);
break; break;
} }
case TSDB_DATA_TYPE_DOUBLE: { case TSDB_DATA_TYPE_DOUBLE: {
pVar->dKey = *(double *)pz; pVar->dKey = GET_DOUBLE_VAL(pz);
break; break;
} }
case TSDB_DATA_TYPE_FLOAT: { case TSDB_DATA_TYPE_FLOAT: {
pVar->dKey = *(float *)pz; pVar->dKey = GET_FLOAT_VAL(pz);
break; break;
} }
case TSDB_DATA_TYPE_NCHAR: { case TSDB_DATA_TYPE_NCHAR: {
/* here we get the nchar length from raw binary bits length */ /* here we get the nchar length from raw binary bits length */
int32_t wlen = len / TSDB_NCHAR_SIZE; pVar->nLen = len / TSDB_NCHAR_SIZE;
pVar->wpz = malloc((len + 1) * wlen); pVar->wpz = malloc((pVar->nLen + 1) * TSDB_NCHAR_SIZE);
wcsncpy(pVar->wpz, (wchar_t *)pz, wlen); wcsncpy(pVar->wpz, (wchar_t *)pz, pVar->nLen);
pVar->nLen = wlen; pVar->wpz[pVar->nLen] = 0;
pVar->wpz[wlen] = 0;
break; break;
} }
case TSDB_DATA_TYPE_BINARY: { case TSDB_DATA_TYPE_BINARY: {
pVar->pz = malloc(len + 1); pVar->pz = malloc(len + 1);
strncpy(pVar->pz, pz, len); strncpy(pVar->pz, pz, len);
pVar->nLen = len; pVar->nLen = len;
pVar->pz[len] = 0; pVar->pz[len] = 0;
strdequote(pVar->pz); pVar->nLen = strdequote(pVar->pz);
pVar->nLen = strlen(pVar->pz);
break; break;
} }
default:
pVar->i64Key = GET_INT32_VAL(pVar);
} }
pVar->nType = type; pVar->nType = type;
} }
void tVariantDestroy(tVariant *pVar) { void tVariantDestroy(tVariant *pVar) {
if (pVar == NULL) return; if (pVar == NULL) return;
...@@ -780,29 +785,29 @@ void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems) { ...@@ -780,29 +785,29 @@ void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems) {
void assignVal(char *val, char *src, int32_t len, int32_t type) { void assignVal(char *val, char *src, int32_t len, int32_t type) {
switch (type) { switch (type) {
case TSDB_DATA_TYPE_INT: { case TSDB_DATA_TYPE_INT: {
*((int32_t *)val) = *(int32_t *)src; *((int32_t *)val) = GET_INT32_VAL(src);
break; break;
} }
case TSDB_DATA_TYPE_FLOAT: { case TSDB_DATA_TYPE_FLOAT: {
*((float *)val) = *(float *)src; *((float *)val) = GET_FLOAT_VAL(src);
break; break;
}; };
case TSDB_DATA_TYPE_DOUBLE: { case TSDB_DATA_TYPE_DOUBLE: {
*((double *)val) = *(double *)src; *((double *)val) = GET_DOUBLE_VAL(src);
break; break;
}; };
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
case TSDB_DATA_TYPE_BIGINT: { case TSDB_DATA_TYPE_BIGINT: {
*((int64_t *)val) = *(int64_t *)src; *((int64_t *)val) = GET_INT64_VAL(src);
break; break;
}; };
case TSDB_DATA_TYPE_SMALLINT: { case TSDB_DATA_TYPE_SMALLINT: {
*((int16_t *)val) = *(int16_t *)src; *((int16_t *)val) = GET_INT16_VAL(src);
break; break;
}; };
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
case TSDB_DATA_TYPE_TINYINT: { case TSDB_DATA_TYPE_TINYINT: {
*((int8_t *)val) = *(int8_t *)src; *((int8_t *)val) = GET_INT8_VAL(src);
break; break;
}; };
default: { default: {
......
...@@ -498,4 +498,13 @@ bool taosGetVersionNumber(char *versionStr, int *versionNubmer) { ...@@ -498,4 +498,13 @@ bool taosGetVersionNumber(char *versionStr, int *versionNubmer) {
versionStr[versionNumberPos[3] - 1] = '.'; versionStr[versionNumberPos[3] - 1] = '.';
return true; return true;
} }
\ No newline at end of file
char *taosIpStr(int ipInt) {
static char ipStrArray[3][30];
static int ipStrIndex = 0;
char *ipStr = ipStrArray[(ipStrIndex++) % 3];
sprintf(ipStr, "0x%x:%d.%d.%d.%d", ipInt, ipInt & 0xFF, (ipInt >> 8) & 0xFF, (ipInt >> 16) & 0xFF, ipInt >> 24);
return ipStr;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册