diff --git a/cmake/env.inc b/cmake/env.inc index 356bd61442c51a9b697e375e9fe7ee7c1ad3d24b..fa15ec6aee01a619139417fceb21b3a71bd96364 100755 --- a/cmake/env.inc +++ b/cmake/env.inc @@ -39,7 +39,7 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMMON_C_FLAGS} ${DEBUG_FLAGS} SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMMON_C_FLAGS} ${RELEASE_FLAGS}") # Set c++ compiler options -SET(COMMON_CXX_FLAGS "${COMMON_FLAGS} -std=c++11") +SET(COMMON_CXX_FLAGS "${COMMON_FLAGS} -std=c++11 -Wno-unused-function") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} ${DEBUG_FLAGS}") SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} ${RELEASE_FLAGS}") diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index bd79f81846cbfd730fd9b3134b89ba0b328472a1..355f8a403c782a4512690603262605e972699104 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -45,6 +45,7 @@ int32_t tscNumOfObj = 0; // number of sqlObj in current process. static void *tscCheckDiskUsageTmr; void *tscRpcCache; // cache to keep rpc obj int32_t tscNumOfThreads = 1; // num of rpc threads +char tscLogFileName[12] = "taoslog"; static pthread_mutex_t rpcObjMutex; // mutex to protect open the rpc obj concurrently static pthread_once_t tscinit = PTHREAD_ONCE_INIT; static volatile int tscInitRes = 0; @@ -132,7 +133,7 @@ void taos_init_imp(void) { printf("failed to create log dir:%s\n", tsLogDir); } - sprintf(temp, "%s/taoslog", tsLogDir); + sprintf(temp, "%s/%s", tsLogDir, tscLogFileName); if (taosInitLog(temp, tsNumOfLogLines, 10) < 0) { printf("failed to open log file in directory:%s\n", tsLogDir); } diff --git a/src/client/tests/timeParseTest.cpp b/src/client/tests/timeParseTest.cpp index ba06a6b9aa775dc9cad6191e5d85f6475c017f1b..3cc6d541e002a9167b5e2668d4914ad1aa6f94f0 100644 --- a/src/client/tests/timeParseTest.cpp +++ b/src/client/tests/timeParseTest.cpp @@ -98,7 +98,7 @@ TEST(testCase, parse_time) { taosParseTime(t41, &time, strlen(t41), TSDB_TIME_PRECISION_MILLI, 0); EXPECT_EQ(time, 852048000999); - int64_t k = timezone; + // int64_t k = timezone; char t42[] = "1997-1-1T0:0:0.999999999Z"; taosParseTime(t42, &time, strlen(t42), TSDB_TIME_PRECISION_MILLI, 0); EXPECT_EQ(time, 852048000999 - timezone * MILLISECOND_PER_SECOND); @@ -163,7 +163,7 @@ TEST(testCase, parse_time) { taosParseTime(t13, &time, strlen(t13), TSDB_TIME_PRECISION_MILLI, 0); EXPECT_EQ(time, -28800 * MILLISECOND_PER_SECOND); - char* t = "2021-01-08T02:11:40.000+00:00"; + char t[] = "2021-01-08T02:11:40.000+00:00"; taosParseTime(t, &time, strlen(t), TSDB_TIME_PRECISION_MILLI, 0); printf("%ld\n", time); } diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 4202a833ea3a46f4c3cfdca65451aa5cc42ec880..6b12e66cb951ac1b3aadc6371bf058d654ac050b 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -6000,6 +6000,12 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) { verbosePrint("%s() LN%d: tid=%d seq=%"PRId64" tableName=%s\n", __func__, __LINE__, pThreadInfo->threadID, tableSeq, tableName); + if (0 == strlen(tableName)) { + errorPrint("[%d] %s() LN%d, getTableName return null\n", + pThreadInfo->threadID, __func__, __LINE__); + free(pThreadInfo->buffer); + return NULL; + } int64_t remainderBufLen = maxSqlLen; char *pstr = pThreadInfo->buffer; diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index f80ac069a02e3df028f3356e2d13d58c219108e9..8525496b0ed3bcbe24c50ec6c20d88670bff37a7 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -1858,13 +1858,13 @@ int taosDumpTableData(FILE *fp, char *tbname, struct arguments *arguments, TAOS* converStringToReadable((char *)row[col], length[col], tbuf, COMMAND_SIZE); //pstr = stpcpy(pstr, tbuf); //*(pstr++) = '\''; - pstr += sprintf(pstr + curr_sqlstr_len, "\'%s\'", tbuf); + curr_sqlstr_len += sprintf(pstr + curr_sqlstr_len, "\'%s\'", tbuf); break; } case TSDB_DATA_TYPE_NCHAR: { char tbuf[COMMAND_SIZE] = {0}; convertNCharToReadable((char *)row[col], length[col], tbuf, COMMAND_SIZE); - pstr += sprintf(pstr + curr_sqlstr_len, "\'%s\'", tbuf); + curr_sqlstr_len += sprintf(pstr + curr_sqlstr_len, "\'%s\'", tbuf); break; } case TSDB_DATA_TYPE_TIMESTAMP: @@ -1897,7 +1897,8 @@ int taosDumpTableData(FILE *fp, char *tbname, struct arguments *arguments, TAOS* total_sqlstr_len += curr_sqlstr_len; - if ((count >= arguments->data_batch) || (sql_buf_len - total_sqlstr_len < TSDB_MAX_BYTES_PER_ROW)) { + if ((count >= arguments->data_batch) + || (sql_buf_len - total_sqlstr_len < TSDB_MAX_BYTES_PER_ROW)) { fprintf(fp, ";\n"); count = 0; } //else { @@ -1905,6 +1906,8 @@ int taosDumpTableData(FILE *fp, char *tbname, struct arguments *arguments, TAOS* //} } + printf("total_sqlstr_len: %d\n", total_sqlstr_len); + fprintf(fp, "\n"); atomic_add_fetch_64(&totalDumpOutRows, totalRows); diff --git a/src/os/inc/osDef.h b/src/os/inc/osDef.h index bbe0f98ec0b632deb39691f74350bced6d2a6515..07fb5c283b92aafffaec49c11fc7d5e6dcba9c19 100644 --- a/src/os/inc/osDef.h +++ b/src/os/inc/osDef.h @@ -40,10 +40,9 @@ extern "C" { #define ASSERT(x) #endif -#ifdef UNUSED -#undefine UNUSED -#endif +#ifndef UNUSED #define UNUSED(x) ((void)(x)) +#endif #ifdef UNUSED_FUNC #undefine UNUSED_FUNC diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index f97a0c4a747856bc72fd59d742e6405052a131c6..69242adc2a15242a7ec4228b9d7fad10627f8fe5 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -6720,7 +6720,11 @@ int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQInfo *p if (pQueryMsg->tsLen > 0) { // open new file to save the result char *tsBlock = (char *) pQueryMsg + pQueryMsg->tsOffset; pTsBuf = tsBufCreateFromCompBlocks(tsBlock, pQueryMsg->tsNumOfBlocks, pQueryMsg->tsLen, pQueryMsg->tsOrder, vgId); - + if (pTsBuf == NULL) { + code = TSDB_CODE_QRY_NO_DISKSPACE; + goto _error; + } + tsBufResetPos(pTsBuf); bool ret = tsBufNextPos(pTsBuf); diff --git a/src/query/src/qTsbuf.c b/src/query/src/qTsbuf.c index 1f43c5b33cca044744a2783a251f76bcb827d34a..9c04c7c929c2596a58093bdfdf6d0aa1a0037061 100644 --- a/src/query/src/qTsbuf.c +++ b/src/query/src/qTsbuf.c @@ -2,6 +2,7 @@ #include "taoserror.h" #include "tscompression.h" #include "tutil.h" +#include "queryLog.h" static int32_t getDataStartOffset(); static void TSBufUpdateGroupInfo(STSBuf* pTSBuf, int32_t index, STSGroupBlockInfo* pBlockInfo); @@ -633,10 +634,15 @@ int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader) { int32_t r = fseek(pTSBuf->f, 0, SEEK_SET); if (r != 0) { + qError("fseek failed, errno:%d", errno); + return -1; + } + + size_t ws = fwrite(pHeader, sizeof(STSBufFileHeader), 1, pTSBuf->f); + if (ws != 1) { + qError("ts update header fwrite failed, size:%d, expected size:%d", (int32_t)ws, (int32_t)sizeof(STSBufFileHeader)); return -1; } - - fwrite(pHeader, sizeof(STSBufFileHeader), 1, pTSBuf->f); return 0; } @@ -856,9 +862,17 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_ TSBufUpdateGroupInfo(pTSBuf, pTSBuf->numOfGroups - 1, pBlockInfo); int32_t ret = fseek(pTSBuf->f, pBlockInfo->offset, SEEK_SET); - UNUSED(ret); + if (ret == -1) { + qError("fseek failed, errno:%d", errno); + tsBufDestroy(pTSBuf); + return NULL; + } size_t sz = fwrite((void*)pData, 1, len, pTSBuf->f); - UNUSED(sz); + if (sz != len) { + qError("ts data fwrite failed, write size:%d, expected size:%d", (int32_t)sz, len); + tsBufDestroy(pTSBuf); + return NULL; + } pTSBuf->fileSize += len; pTSBuf->tsOrder = order; @@ -866,9 +880,16 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_ STSBufFileHeader header = { .magic = TS_COMP_FILE_MAGIC, .numOfGroup = pTSBuf->numOfGroups, .tsOrder = pTSBuf->tsOrder}; - STSBufUpdateHeader(pTSBuf, &header); + if (STSBufUpdateHeader(pTSBuf, &header) < 0) { + tsBufDestroy(pTSBuf); + return NULL; + } - fsync(fileno(pTSBuf->f)); + if (fsync(fileno(pTSBuf->f)) == -1) { + qError("fsync failed, errno:%d", errno); + tsBufDestroy(pTSBuf); + return NULL; + } return pTSBuf; } diff --git a/src/query/tests/astTest.cpp b/src/query/tests/astTest.cpp index ce7b2f94a177576c8046b299bcb2e695fb5ead2d..1143d00e8da9e77cd0f740d98fe77ffd1beac4bc 100644 --- a/src/query/tests/astTest.cpp +++ b/src/query/tests/astTest.cpp @@ -10,6 +10,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wwrite-strings" +#pragma GCC diagnostic ignored "-Wunused-function" typedef struct ResultObj { int32_t numOfResult; diff --git a/src/query/tests/histogramTest.cpp b/src/query/tests/histogramTest.cpp index 3088d6f8078483c39ec3780250e8bfa2d613f218..0266ecffc11348dcd0184030584ed7b721d39aff 100644 --- a/src/query/tests/histogramTest.cpp +++ b/src/query/tests/histogramTest.cpp @@ -5,6 +5,10 @@ #include "taos.h" #include "qHistogram.h" + +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-variable" + namespace { void doHistogramAddTest() { SHistogramInfo* pHisto = NULL; diff --git a/src/query/tests/patternMatchTest.cpp b/src/query/tests/patternMatchTest.cpp index f3e0d3e119259d0a7cc8a94a6b43f4c71558bf78..091604c65c0e8b7fcf998fdd69f6f82f101f8157 100644 --- a/src/query/tests/patternMatchTest.cpp +++ b/src/query/tests/patternMatchTest.cpp @@ -6,6 +6,9 @@ #include "qAggMain.h" #include "tcompare.h" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-variable" + TEST(testCase, patternMatchTest) { SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; diff --git a/src/query/tests/percentileTest.cpp b/src/query/tests/percentileTest.cpp index 104bfb3c06a9613bafcd4e0b3f39af4f9d102b04..1b6951201af5908378fb253b38cea01de1210d57 100644 --- a/src/query/tests/percentileTest.cpp +++ b/src/query/tests/percentileTest.cpp @@ -7,6 +7,9 @@ #include "qPercentile.h" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-variable" + namespace { tMemBucket *createBigIntDataBucket(int32_t start, int32_t end) { tMemBucket *pBucket = tMemBucketCreate(sizeof(int64_t), TSDB_DATA_TYPE_BIGINT, start, end); diff --git a/src/query/tests/resultBufferTest.cpp b/src/query/tests/resultBufferTest.cpp index 491d75ccb9c8104a8e7760aa15918bd212646de6..54ac0bf4e5c78f2fcc7f0e3271eb3409ea072db7 100644 --- a/src/query/tests/resultBufferTest.cpp +++ b/src/query/tests/resultBufferTest.cpp @@ -6,6 +6,9 @@ #include "taos.h" #include "tsdb.h" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-variable" + namespace { // simple test void simpleTest() { diff --git a/src/query/tests/tsBufTest.cpp b/src/query/tests/tsBufTest.cpp index dd7f03a494ac37229b117c678fc461d455067850..04c5a152520d08329408253af271c4d43c5c0fe3 100644 --- a/src/query/tests/tsBufTest.cpp +++ b/src/query/tests/tsBufTest.cpp @@ -9,6 +9,10 @@ #include "ttoken.h" #include "tutil.h" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" + namespace { /** * diff --git a/src/query/tests/unitTest.cpp b/src/query/tests/unitTest.cpp index d2b058cf7cb9400c64149ff8f18f68788735ba96..fcfed49140d04d19658518544aee7c8937bfc309 100644 --- a/src/query/tests/unitTest.cpp +++ b/src/query/tests/unitTest.cpp @@ -6,14 +6,17 @@ #include "taos.h" #include "tsdb.h" +#pragma GCC diagnostic ignored "-Wwrite-strings" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" +#pragma GCC diagnostic ignored "-Wsign-compare" + #include "../../client/inc/tscUtil.h" #include "tutil.h" #include "tvariant.h" #include "ttokendef.h" -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wwrite-strings" - namespace { int32_t testValidateName(char* name) { SStrToken token = {0};