fix:defects in coverity
This commit is contained in:
parent
212c782531
commit
d212be8a37
|
@ -30,7 +30,7 @@ extern "C" {
|
|||
#define tscDebug(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSC ", DEBUG_DEBUG, cDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", DEBUG_TRACE, cDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define tscDebugL(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLongString("TSC ", DEBUG_DEBUG, cDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define tscPerf(...) do { taosPrintLog("TSC ", 0, cDebugFlag, __VA_ARGS__); } while(0)
|
||||
//#define tscPerf(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", DEBUG_INFO, cDebugFlag, __VA_ARGS__); }} while(0)
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -77,19 +77,19 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
pRequest->self, pTscObj->id, pRequest->requestId, duration / 1000.0, num, currentInst);
|
||||
|
||||
if (QUERY_NODE_VNODE_MODIF_STMT == pRequest->stmtType) {
|
||||
tscPerf("insert duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64
|
||||
"us, exec:%" PRId64 "us",
|
||||
duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart,
|
||||
pRequest->metric.ctgEnd - pRequest->metric.ctgStart, pRequest->metric.semanticEnd - pRequest->metric.ctgEnd,
|
||||
pRequest->metric.execEnd - pRequest->metric.semanticEnd);
|
||||
// tscPerf("insert duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64
|
||||
// "us, exec:%" PRId64 "us",
|
||||
// duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart,
|
||||
// pRequest->metric.ctgEnd - pRequest->metric.ctgStart, pRequest->metric.semanticEnd - pRequest->metric.ctgEnd,
|
||||
// pRequest->metric.execEnd - pRequest->metric.semanticEnd);
|
||||
atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration);
|
||||
} else if (QUERY_NODE_SELECT_STMT == pRequest->stmtType) {
|
||||
tscPerf("select duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64
|
||||
"us, planner:%" PRId64 "us, exec:%" PRId64 "us, reqId:0x%" PRIx64,
|
||||
duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart,
|
||||
pRequest->metric.ctgEnd - pRequest->metric.ctgStart, pRequest->metric.semanticEnd - pRequest->metric.ctgEnd,
|
||||
pRequest->metric.planEnd - pRequest->metric.semanticEnd,
|
||||
pRequest->metric.resultReady - pRequest->metric.planEnd, pRequest->requestId);
|
||||
// tscPerf("select duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64
|
||||
// "us, planner:%" PRId64 "us, exec:%" PRId64 "us, reqId:0x%" PRIx64,
|
||||
// duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart,
|
||||
// pRequest->metric.ctgEnd - pRequest->metric.ctgStart, pRequest->metric.semanticEnd - pRequest->metric.ctgEnd,
|
||||
// pRequest->metric.planEnd - pRequest->metric.semanticEnd,
|
||||
// pRequest->metric.resultReady - pRequest->metric.planEnd, pRequest->requestId);
|
||||
|
||||
atomic_add_fetch_64((int64_t *)&pActivity->queryElapsedTime, duration);
|
||||
}
|
||||
|
|
|
@ -507,29 +507,29 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char
|
|||
double tmp = time;
|
||||
switch (toUnit) {
|
||||
case 's': {
|
||||
tmp /= (NANOSECOND_PER_SEC / factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_SEC / factors[fromPrecision]);
|
||||
tmp = (double)time;
|
||||
break;
|
||||
}
|
||||
case 'm':
|
||||
tmp /= (NANOSECOND_PER_MINUTE / factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_MINUTE / factors[fromPrecision]);
|
||||
tmp = (double)time;
|
||||
break;
|
||||
case 'h':
|
||||
tmp /= (NANOSECOND_PER_HOUR / factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_HOUR / factors[fromPrecision]);
|
||||
tmp = (double)time;
|
||||
break;
|
||||
case 'd':
|
||||
tmp /= (NANOSECOND_PER_DAY / factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_DAY / factors[fromPrecision]);
|
||||
tmp = (double)time;
|
||||
break;
|
||||
case 'w':
|
||||
tmp /= (NANOSECOND_PER_WEEK / factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_WEEK / factors[fromPrecision]);
|
||||
tmp = (double)time;
|
||||
break;
|
||||
case 'a':
|
||||
tmp /= (NANOSECOND_PER_MSEC / factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_MSEC / factors[fromPrecision]);
|
||||
tmp = (double)time;
|
||||
break;
|
||||
case 'u':
|
||||
// the result of (NANOSECOND_PER_USEC/(double)factors[fromPrecision]) maybe a double
|
||||
|
@ -540,13 +540,13 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char
|
|||
break;
|
||||
}
|
||||
case TSDB_TIME_PRECISION_MICRO: {
|
||||
tmp /= 1;
|
||||
time /= 1;
|
||||
tmp = (double)time;
|
||||
break;
|
||||
}
|
||||
case TSDB_TIME_PRECISION_NANO: {
|
||||
tmp /= 1000;
|
||||
time /= 1000;
|
||||
tmp = (double)time;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,9 +248,9 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
|
|||
}
|
||||
}
|
||||
|
||||
if (optr == OP_TYPE_JSON_CONTAINS && type == TSDB_DATA_TYPE_JSON) {
|
||||
return 28;
|
||||
}
|
||||
// if (optr == OP_TYPE_JSON_CONTAINS && type == TSDB_DATA_TYPE_JSON) {
|
||||
// return 28;
|
||||
// }
|
||||
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
|
|
|
@ -505,7 +505,7 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
|
|||
(*pLeftData)++;
|
||||
}
|
||||
if (typeRight == TSDB_DATA_TYPE_JSON) {
|
||||
if (tTagIsJson(*pLeftData)) {
|
||||
if (tTagIsJson(*pRightData)) {
|
||||
terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ void taosStringBuilderAppendChar(SStringBuilder* sb, char c) {
|
|||
|
||||
void taosStringBuilderAppendStringLen(SStringBuilder* sb, const char* str, size_t len) {
|
||||
taosStringBuilderEnsureCapacity(sb, len);
|
||||
if(!sb->buf) return;
|
||||
memcpy(sb->buf + sb->pos, str, len);
|
||||
sb->pos += len;
|
||||
}
|
||||
|
|
|
@ -1084,6 +1084,35 @@ int sml_19221_Test() {
|
|||
return code;
|
||||
}
|
||||
|
||||
int sml_time_Test() {
|
||||
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
|
||||
TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1");
|
||||
taos_free_result(pRes);
|
||||
|
||||
const char *sql[] = {
|
||||
"meters,location=California.LosAngeles,groupid=2 current=11.8,voltage=221,phase='2022-02-02 10:22:22' 1626006833639000000",
|
||||
};
|
||||
|
||||
pRes = taos_query(taos, "use sml_db");
|
||||
taos_free_result(pRes);
|
||||
|
||||
char* tmp = (char*)taosMemoryCalloc(1024, 1);
|
||||
memcpy(tmp, sql[0], strlen(sql[0]));
|
||||
*(char*)(tmp+44) = 0;
|
||||
int32_t totalRows = 0;
|
||||
pRes = taos_schemaless_insert_raw(taos, tmp, strlen(sql[0]), &totalRows, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
||||
|
||||
ASSERT(totalRows == 3);
|
||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||
int code = taos_errno(pRes);
|
||||
taos_free_result(pRes);
|
||||
taos_close(taos);
|
||||
taosMemoryFree(tmp);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int ret = 0;
|
||||
ret = smlProcess_influx_Test();
|
||||
|
|
Loading…
Reference in New Issue