From 939dfae8d484558c869a4217bdd5e2749dace07c Mon Sep 17 00:00:00 2001 From: jiacy-jcy <714897623@qq.com> Date: Tue, 25 Oct 2022 15:08:06 +0800 Subject: [PATCH 1/8] test:update test case for TD-19816 --- tests/system-test/0-others/show.py | 76 ++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 5 deletions(-) diff --git a/tests/system-test/0-others/show.py b/tests/system-test/0-others/show.py index 673e795297..c25d1d1f33 100644 --- a/tests/system-test/0-others/show.py +++ b/tests/system-test/0-others/show.py @@ -15,28 +15,30 @@ from util.log import * from util.cases import * from util.sql import * -import subprocess from util.common import * +from util.sqlset import * class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) - self.dbname = 'db' + self.setsql = TDSetSql() self.ins_param_list = ['dnodes','mnodes','qnodes','cluster','functions','users','grants','topics','subscriptions','streams'] self.perf_param = ['apps','connections','consumers','queries','transactions'] self.perf_param_list = ['apps','connections','consumers','queries','trans'] def ins_check(self): + tdSql.prepare() for param in self.ins_param_list: tdSql.query(f'show {param}') show_result = tdSql.queryResult tdSql.query(f'select * from information_schema.ins_{param}') select_result = tdSql.queryResult tdSql.checkEqual(show_result,select_result) - + tdSql.execute('drop database db') def perf_check(self): + tdSql.prepare() for param in range(len(self.perf_param_list)): tdSql.query(f'show {self.perf_param[param]}') if len(tdSql.queryResult) != 0: @@ -46,11 +48,74 @@ class TDTestCase: tdSql.checkEqual(show_result,select_result) else : continue - def run(self): + tdSql.execute('drop database db') + def set_stb_sql(self,stbname,column_dict,tag_dict): + column_sql = '' + tag_sql = '' + for k,v in column_dict.items(): + column_sql += f"{k} {v}, " + for k,v in tag_dict.items(): + tag_sql += f"{k} {v}, " + create_stb_sql = f'create stable {stbname} ({column_sql[:-2]}) tags ({tag_sql[:-2]})' + return create_stb_sql + def show_sql(self): tdSql.prepare() + tdSql.execute('use db') + stbname = f'`{tdCom.getLongName(5)}`' + tbname = f'`{tdCom.getLongName(3)}`' + column_dict = { + '`ts`': 'timestamp', + '`col1`': 'tinyint', + '`col2`': 'smallint', + '`col3`': 'int', + '`col4`': 'bigint', + '`col5`': 'tinyint unsigned', + '`col6`': 'smallint unsigned', + '`col7`': 'int unsigned', + '`col8`': 'bigint unsigned', + '`col9`': 'float', + '`col10`': 'double', + '`col11`': 'bool', + '`col12`': 'varchar(20)', + '`col13`': 'nchar(20)' + + } + tag_dict = { + '`t1`': 'tinyint', + '`t2`': 'smallint', + '`t3`': 'int', + '`t4`': 'bigint', + '`t5`': 'tinyint unsigned', + '`t6`': 'smallint unsigned', + '`t7`': 'int unsigned', + '`t8`': 'bigint unsigned', + '`t9`': 'float', + '`t10`': 'double', + '`t11`': 'bool', + '`t12`': 'varchar(20)', + '`t13`': 'nchar(20)', + '`t14`': 'timestamp' + + } + create_table_sql = self.set_stb_sql(stbname,column_dict,tag_dict) + tdSql.execute(create_table_sql) + tdSql.query(f'show create table {stbname}') + query_result = tdSql.queryResult + tdSql.checkEqual(query_result[0][1].lower(),create_table_sql) + tdSql.execute(f'create table {tbname} using {stbname} tags(1,1,1,1,1,1,1,1,1.000000e+00,1.000000e+00,true,"abc","abc123",0)') + tag_sql = '(' + for tag_keys in tag_dict.keys(): + tag_sql += f'{tag_keys}, ' + tags = f'{tag_sql[:-2]})' + sql = f'create table {tbname} using {stbname} {tags} tags (1, 1, 1, 1, 1, 1, 1, 1, 1.000000e+00, 1.000000e+00, true, "abc", "abc123", 0)' + tdSql.query(f'show create table {tbname}') + query_result = tdSql.queryResult + tdSql.checkEqual(query_result[0][1].lower(),sql) + tdSql.execute('drop database db') + def run(self): self.ins_check() self.perf_check() - + self.show_sql() def stop(self): tdSql.close() @@ -58,3 +123,4 @@ class TDTestCase: tdCases.addWindows(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase()) + From 9d3ceb1b3202ce95bbae511b80e72f10ddcd9e96 Mon Sep 17 00:00:00 2001 From: jiacy-jcy <714897623@qq.com> Date: Wed, 26 Oct 2022 10:35:20 +0800 Subject: [PATCH 2/8] =?UTF-8?q?test=EF=BC=9Aupdate=20test=20case=20for=20c?= =?UTF-8?q?overage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/system-test/2-query/Timediff.py | 81 +++++++++++++++-------- tests/system-test/2-query/avg.py | 53 +++++++++++++-- tests/system-test/2-query/stddev.py | 79 ++++++++++++++++++++++ tests/system-test/2-query/timetruncate.py | 3 +- 4 files changed, 184 insertions(+), 32 deletions(-) create mode 100644 tests/system-test/2-query/stddev.py diff --git a/tests/system-test/2-query/Timediff.py b/tests/system-test/2-query/Timediff.py index d9bac2e930..1f73215dd5 100644 --- a/tests/system-test/2-query/Timediff.py +++ b/tests/system-test/2-query/Timediff.py @@ -16,6 +16,7 @@ class TDTestCase: '2020-5-1 00:00:00.001002001' ] + self.rest_tag = str(conn).lower().split('.')[0].replace(" Date: Wed, 26 Oct 2022 11:35:15 +0800 Subject: [PATCH 3/8] fix: memory leak --- source/common/src/tmsg.c | 11 +++++++++-- source/dnode/vnode/src/tq/tq.c | 13 +++---------- source/libs/wal/src/walRef.c | 4 ++++ source/libs/wal/src/walSeek.c | 4 ++++ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index aea689c0de..a001126b21 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5988,7 +5988,11 @@ int32_t tDecodeSMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) { if (pRsp->withSchema) { SSchemaWrapper *pSW = (SSchemaWrapper *)taosMemoryCalloc(1, sizeof(SSchemaWrapper)); if (pSW == NULL) return -1; - if (tDecodeSSchemaWrapper(pDecoder, pSW) < 0) return -1; + if (tDecodeSSchemaWrapper(pDecoder, pSW) < 0) { + taosMemoryFree(pSW); + return -1; + } + taosArrayPush(pRsp->blockSchema, &pSW); } @@ -6069,7 +6073,10 @@ int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, STaosxRsp *pRsp) { if (pRsp->withSchema) { SSchemaWrapper *pSW = (SSchemaWrapper *)taosMemoryCalloc(1, sizeof(SSchemaWrapper)); if (pSW == NULL) return -1; - if (tDecodeSSchemaWrapper(pDecoder, pSW) < 0) return -1; + if (tDecodeSSchemaWrapper(pDecoder, pSW) < 0) { + taosMemoryFree(pSW); + return -1; + } taosArrayPush(pRsp->blockSchema, &pSW); } diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 8bf1522d6c..42a597a305 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -433,16 +433,9 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su } #endif - if (subType == TOPIC_SUB_TYPE__COLUMN) { - pRsp->withSchema = false; - } else { - pRsp->withSchema = true; - pRsp->blockSchema = taosArrayInit(0, sizeof(void*)); - if (pRsp->blockSchema == NULL) { - // TODO free - return -1; - } - } + ASSERT(subType == TOPIC_SUB_TYPE__COLUMN); + pRsp->withSchema = false; + return 0; } diff --git a/source/libs/wal/src/walRef.c b/source/libs/wal/src/walRef.c index 5a14bcf962..f9994fd315 100644 --- a/source/libs/wal/src/walRef.c +++ b/source/libs/wal/src/walRef.c @@ -32,6 +32,7 @@ SWalRef *walOpenRef(SWal *pWal) { return pRef; } +#if 0 void walCloseRef(SWal *pWal, int64_t refId) { SWalRef **ppRef = taosHashGet(pWal->pRefHash, &refId, sizeof(int64_t)); if (ppRef == NULL) return; @@ -39,6 +40,7 @@ void walCloseRef(SWal *pWal, int64_t refId) { taosHashRemove(pWal->pRefHash, &refId, sizeof(int64_t)); taosMemoryFree(pRef); } +#endif int32_t walRefVer(SWalRef *pRef, int64_t ver) { SWal *pWal = pRef->pWal; @@ -65,10 +67,12 @@ int32_t walRefVer(SWalRef *pRef, int64_t ver) { return 0; } +#if 0 void walUnrefVer(SWalRef *pRef) { pRef->refId = -1; pRef->refFile = -1; } +#endif SWalRef *walRefCommittedVer(SWal *pWal) { SWalRef *pRef = walOpenRef(pWal); diff --git a/source/libs/wal/src/walSeek.c b/source/libs/wal/src/walSeek.c index 4b75db52b7..2cb6614b01 100644 --- a/source/libs/wal/src/walSeek.c +++ b/source/libs/wal/src/walSeek.c @@ -19,6 +19,7 @@ #include "tref.h" #include "walInt.h" +#if 0 static int64_t walSeekWritePos(SWal* pWal, int64_t ver) { int64_t code = 0; @@ -47,6 +48,7 @@ static int64_t walSeekWritePos(SWal* pWal, int64_t ver) { } return 0; } +#endif int walInitWriteFile(SWal* pWal) { TdFilePtr pIdxTFile, pLogTFile; @@ -134,6 +136,7 @@ int64_t walChangeWrite(SWal* pWal, int64_t ver) { return fileFirstVer; } +#if 0 int walSeekWriteVer(SWal* pWal, int64_t ver) { int64_t code; if (ver == pWal->vers.lastVer) { @@ -158,3 +161,4 @@ int walSeekWriteVer(SWal* pWal, int64_t ver) { return 0; } +#endif From 88e5fa75e64336fbee76b20dbc14556998667cab Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Wed, 26 Oct 2022 12:43:29 +0800 Subject: [PATCH 4/8] fix(query): fix interp crash issue TD-19858 --- source/libs/executor/src/timewindowoperator.c | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 29b2edfcf5..a22371331a 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -2324,9 +2324,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } } @@ -2336,6 +2333,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { } if (ts == pSliceInfo->current) { + blockDataEnsureCapacity(pResBlock, pResBlock->info.rows + 1); for (int32_t j = 0; j < pOperator->exprSupp.numOfExprs; ++j) { SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[j]; @@ -2376,9 +2374,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } if (pSliceInfo->current > pSliceInfo->win.ekey) { @@ -2397,10 +2392,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { doSetOperatorCompleted(pOperator); break; } - - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } } else if (ts < pSliceInfo->current) { // in case of interpolation window starts and ends between two datapoints, fill(prev) need to interpolate @@ -2418,9 +2409,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } if (pSliceInfo->current > pSliceInfo->win.ekey) { @@ -2442,9 +2430,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } if (pSliceInfo->current > pSliceInfo->win.ekey) { @@ -2466,13 +2451,11 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } // add current row if timestamp match if (ts == pSliceInfo->current && pSliceInfo->current <= pSliceInfo->win.ekey) { + blockDataEnsureCapacity(pResBlock, pResBlock->info.rows + 1); for (int32_t j = 0; j < pOperator->exprSupp.numOfExprs; ++j) { SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[j]; @@ -2509,9 +2492,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } if (pSliceInfo->current > pSliceInfo->win.ekey) { @@ -2527,9 +2507,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } } @@ -2548,9 +2525,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } // restore the value From 8dbe7ac37720f5f512edcc1afb72faaf4dd4cac1 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 26 Oct 2022 14:02:36 +0800 Subject: [PATCH 5/8] fix: failed case --- source/client/src/clientTmq.c | 2 +- tests/system-test/7-tmq/tmqConsFromTsdb1.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index a4ca1f796b..c18e1e3e40 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -1619,7 +1619,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { taosGetQitem(tmq->qall, (void**)&rspWrapper); if (rspWrapper == NULL) { - tscDebug("consumer %" PRId64 " mqueue empty", tmq->consumerId); + /*tscDebug("consumer %" PRId64 " mqueue empty", tmq->consumerId);*/ return NULL; } } diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1.py b/tests/system-test/7-tmq/tmqConsFromTsdb1.py index 499f837ccc..d0ab8d4fe3 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1.py @@ -86,7 +86,7 @@ class TDTestCase: 'rowsPerTbl': 10000, 'batchNum': 10, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 15, + 'pollDelay': 25, 'showMsg': 1, 'showRow': 1, 'snapshot': 1} @@ -157,7 +157,7 @@ class TDTestCase: 'rowsPerTbl': 10000, 'batchNum': 10, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 10, + 'pollDelay': 25, 'showMsg': 1, 'showRow': 1, 'snapshot': 1} From 68ac4f9782fb663b8c86189df5637306793358ee Mon Sep 17 00:00:00 2001 From: jiajingbin Date: Wed, 26 Oct 2022 15:36:58 +0800 Subject: [PATCH 6/8] test: finish testcases for TD-19851 --- .../1-insert/tb_100w_data_order.py | 77 +++++++++++++++++++ tests/system-test/fulltest.sh | 1 + 2 files changed, 78 insertions(+) create mode 100644 tests/system-test/1-insert/tb_100w_data_order.py diff --git a/tests/system-test/1-insert/tb_100w_data_order.py b/tests/system-test/1-insert/tb_100w_data_order.py new file mode 100644 index 0000000000..d489ba21bc --- /dev/null +++ b/tests/system-test/1-insert/tb_100w_data_order.py @@ -0,0 +1,77 @@ +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.ts = 1537146000000 + self.binary_str = 'taosdata' + self.nchar_str = '涛思数据' + + def set_create_normaltable_sql(self, ntbname, column_dict): + column_sql = '' + for k, v in column_dict.items(): + column_sql += f"{k} {v}," + create_ntb_sql = f'create table {ntbname} (ts timestamp,{column_sql[:-1]})' + return create_ntb_sql + + def set_create_stable_sql(self,stbname,column_dict,tag_dict): + column_sql = '' + tag_sql = '' + for k,v in column_dict.items(): + column_sql += f"{k} {v}," + for k,v in tag_dict.items(): + tag_sql += f"{k} {v}," + create_stb_sql = f'create table {stbname} (ts timestamp,{column_sql[:-1]}) tags({tag_sql[:-1]})' + return create_stb_sql + + def gen_batch_sql(self, ntbname, batch=10): + values_str = "" + for i in range(batch): + values_str += f'({self.ts}, 1, 1, 1, {i+1}, 1, 1, 1, {i+1}, {i+0.1}, {i+0.1}, {i%2}, {i+1}, {i+1}),' + self.ts += 1 + return f'insert into {ntbname} values {values_str[:-1]};' + + def query_ntb_order_by_col(self, batch_num, rows_count): + tdSql.prepare() + ntbname = f'db.{tdCom.getLongName(5, "letters")}' + column_dict = { + 'col1': 'tinyint', + 'col2': 'smallint', + 'col3': 'int', + 'col4': 'bigint', + 'col5': 'tinyint unsigned', + 'col6': 'smallint unsigned', + 'col7': 'int unsigned', + 'col8': 'bigint unsigned', + 'col9': 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': 'binary(20)', + 'col13': 'nchar(20)' + } + range_times = int(rows_count/batch_num) + create_ntb_sql = self.set_create_normaltable_sql(ntbname, column_dict) + tdSql.execute(create_ntb_sql) + for i in range(range_times): + tdSql.execute(self.gen_batch_sql(ntbname, batch_num)) + tdSql.query(f'select count(*) from {ntbname}') + tdSql.checkEqual(tdSql.queryResult[0][0], rows_count) + tdSql.query(f'select * from {ntbname} order by col1') + tdSql.execute(f'flush database db') + + + def run(self): + self.query_ntb_order_by_col(batch_num=1000, rows_count=1000000) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index e05f375cdd..fd2ff916fd 100644 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -207,6 +207,7 @@ python3 ./test.py -f 2-query/varchar.py -R python3 ./test.py -f 1-insert/update_data.py +python3 ./test.py -f 1-insert/tb_100w_data_order.py python3 ./test.py -f 1-insert/delete_data.py python3 ./test.py -f 1-insert/keep_expired.py From 4b5807c7f020a6bc2c10d146145a39ac9da2fe61 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 26 Oct 2022 15:54:00 +0800 Subject: [PATCH 7/8] fix(tmq): set precision --- examples/c/tmq.c | 4 ++-- source/dnode/vnode/src/inc/tq.h | 2 +- source/dnode/vnode/src/tq/tqExec.c | 15 +++++++++------ source/dnode/vnode/src/tq/tqPush.c | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/examples/c/tmq.c b/examples/c/tmq.c index d3fc803c94..1147671ea1 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -47,7 +47,7 @@ static int32_t msg_process(TAOS_RES* msg) { int32_t precision = taos_result_precision(msg); rows++; taos_print_row(buf, row, fields, numOfFields); - printf("row content: %s\n", buf); + printf("precision: %d, row content: %s\n", precision, buf); } return rows; @@ -70,7 +70,7 @@ static int32_t init_env() { taos_free_result(pRes); // create database - pRes = taos_query(pConn, "create database tmqdb"); + pRes = taos_query(pConn, "create database tmqdb precision 'ns'"); if (taos_errno(pRes) != 0) { printf("error in create tmqdb, reason:%s\n", taos_errstr(pRes)); return -1; diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index edd23c80be..ef54adf0d6 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -155,7 +155,7 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea // tqExec int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp* pRsp); -int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols); +int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision); int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp); int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry); diff --git a/source/dnode/vnode/src/tq/tqExec.c b/source/dnode/vnode/src/tq/tqExec.c index 30f6f81aa9..a6e8767a4d 100644 --- a/source/dnode/vnode/src/tq/tqExec.c +++ b/source/dnode/vnode/src/tq/tqExec.c @@ -15,14 +15,14 @@ #include "tq.h" -int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols) { +int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision) { int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); void* buf = taosMemoryCalloc(1, dataStrLen); if (buf == NULL) return -1; SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)buf; pRetrieve->useconds = 0; - pRetrieve->precision = TSDB_DEFAULT_PRECISION; + pRetrieve->precision = precision; pRetrieve->compressed = 0; pRetrieve->completed = 1; pRetrieve->numOfRows = htonl(pBlock->info.rows); @@ -95,7 +95,7 @@ int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffs break; } - tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols); + tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision); pRsp->blockNum++; if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { @@ -174,7 +174,8 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta } } - tqAddBlockDataToRsp(pDataBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pDataBlock->pDataBlock)); + tqAddBlockDataToRsp(pDataBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pDataBlock->pDataBlock), + pTq->pVnode->config.tsdbCfg.precision); pRsp->blockNum++; if (pOffset->type == TMQ_OFFSET__LOG) { continue; @@ -256,7 +257,8 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp pRsp->createTableNum++; } } - tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock)); + tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock), + pTq->pVnode->config.tsdbCfg.precision); blockDataFreeRes(&block); tqAddBlockSchemaToRsp(pExec, (SMqDataRsp*)pRsp); pRsp->blockNum++; @@ -291,7 +293,8 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp pRsp->createTableNum++; } } - tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock)); + tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock), + pTq->pVnode->config.tsdbCfg.precision); blockDataFreeRes(&block); tqAddBlockSchemaToRsp(pExec, (SMqDataRsp*)pRsp); pRsp->blockNum++; diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index 35cb305042..12d5b4112b 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -270,7 +270,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) break; } - tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols); + tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision); pRsp->blockNum++; } From a27335c7865d3c1e3caabd91aeccacae6da10511 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang <1296468573@qq.com> Date: Wed, 26 Oct 2022 16:14:32 +0800 Subject: [PATCH 8/8] fix: add windows libtaosws (#17666) --- cmake/cmake.define | 2 ++ packaging/tools/make_install.bat | 12 +++++++ tools/CMakeLists.txt | 62 +++++++++++--------------------- tools/shell/CMakeLists.txt | 4 +++ 4 files changed, 39 insertions(+), 41 deletions(-) diff --git a/cmake/cmake.define b/cmake/cmake.define index 78eab0a59a..3f152f1f09 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -100,6 +100,8 @@ IF (TD_WINDOWS) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}") + SET(JEMALLOC_ENABLED OFF) + ELSE () IF (${TD_DARWIN}) set(CMAKE_MACOSX_RPATH 0) diff --git a/packaging/tools/make_install.bat b/packaging/tools/make_install.bat index d4dde391c8..f777d10918 100644 --- a/packaging/tools/make_install.bat +++ b/packaging/tools/make_install.bat @@ -47,6 +47,15 @@ copy %binary_dir%\\build\\bin\\udfd.exe %tagert_dir% > nul if exist %binary_dir%\\build\\bin\\taosBenchmark.exe ( copy %binary_dir%\\build\\bin\\taosBenchmark.exe %tagert_dir% > nul ) +if exist %binary_dir%\\build\\lib\\taosws.dll.lib ( + copy %binary_dir%\\build\\lib\\taosws.dll.lib %tagert_dir%\\driver > nul +) +if exist %binary_dir%\\build\\lib\\taosws.dll ( + copy %binary_dir%\\build\\lib\\taosws.dll %tagert_dir%\\driver > nul +) +if exist %binary_dir%\\build\\bin\\taosdump.exe ( + copy %binary_dir%\\build\\bin\\taosdump.exe %tagert_dir% > nul +) if exist %binary_dir%\\build\\bin\\taosadapter.exe ( copy %binary_dir%\\build\\bin\\taosadapter.exe %tagert_dir% > nul ) @@ -54,4 +63,7 @@ if exist %binary_dir%\\build\\bin\\taosadapter.exe ( mshta vbscript:createobject("shell.application").shellexecute("%~s0",":hasAdmin","","runas",1)(window.close)&& echo To start/stop TDengine with administrator privileges: sc start/stop taosd &goto :eof :hasAdmin copy /y C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32 > nul +if exist C:\\TDengine\\driver\\taosws.dll ( + copy /y C:\\TDengine\\driver\\taosws.dll C:\\Windows\\System32 > nul +) sc query "taosd" >nul || sc create "taosd" binPath= "C:\\TDengine\\taosd.exe --win_service" start= DEMAND diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index c6a5e33735..214e83ae00 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -3,49 +3,29 @@ IF (TD_WEBSOCKET) SET(websocket_lib_file "libtaosws.so") ELSEIF (TD_DARWIN) SET(websocket_lib_file "libtaosws.dylib") + ELSEIF (TD_WINDOWS) + SET(websocket_lib_file "{taosws.dll,taosws.dll.lib}") ENDIF () MESSAGE("${Green} use libtaos-ws${ColourReset}") - IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/${websocket_lib_file}" OR "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/${websocket_lib_file}" IS_NEWER_THAN "${CMAKE_SOURCE_DIR}/.git/modules/tools/taosws-rs/FETCH_HEAD") - include(ExternalProject) - ExternalProject_Add(taosws-rs - PREFIX "taosws-rs" - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs - BUILD_ALWAYS off - DEPENDS taos - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config" - PATCH_COMMAND - COMMAND git clean -f -d - BUILD_COMMAND - COMMAND cargo update - COMMAND cargo build --release -p taos-ws-sys --features native-tls-vendored - COMMAND ./taos-ws-sys/ci/package.sh - INSTALL_COMMAND - COMMAND cmake -E copy target/libtaosws/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib - COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include - COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include - ) - ELSE() - include(ExternalProject) - ExternalProject_Add(taosws-rs - PREFIX "taosws-rs" - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs - BUILD_ALWAYS on - DEPENDS taos - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config" - PATCH_COMMAND - COMMAND git clean -f -d - BUILD_COMMAND - COMMAND cargo update - COMMAND cargo build --release -p taos-ws-sys --features native-tls-vendored - COMMAND ./taos-ws-sys/ci/package.sh - INSTALL_COMMAND - COMMAND cmake -E copy target/libtaosws/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib - COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include - COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include - ) - ENDIF () + + include(ExternalProject) + ExternalProject_Add(taosws-rs + PREFIX "taosws-rs" + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs + BUILD_ALWAYS on + DEPENDS taos + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config" + PATCH_COMMAND + COMMAND git clean -f -d + BUILD_COMMAND + COMMAND cargo update + COMMAND cargo build --release -p taos-ws-sys --features native-tls-vendored + INSTALL_COMMAND + COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib + COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include + COMMAND cmake -E copy target/release/taosws.h ${CMAKE_BINARY_DIR}/build/include + ) ENDIF () IF (TD_TAOS_TOOLS) diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 552b77e6e9..31dcde036d 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -10,6 +10,10 @@ ELSEIF (TD_DARWIN AND TD_WEBSOCKET) ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include) SET(LINK_WEBSOCKET "${CMAKE_BINARY_DIR}/build/lib/libtaosws.dylib") ADD_DEPENDENCIES(shell taosws-rs) +ELSEIF (TD_WINDOWS AND TD_WEBSOCKET) + ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include) + SET(LINK_WEBSOCKET "${CMAKE_BINARY_DIR}/build/lib/taosws.dll.lib") + ADD_DEPENDENCIES(shell taosws-rs) ELSE () SET(LINK_WEBSOCKET "") ENDIF ()