From ce59e4fff4266715ceec0209407a15760e06aec5 Mon Sep 17 00:00:00 2001 From: jiacy-jcy <714897623@qq.com> Date: Tue, 22 Nov 2022 11:45:25 +0800 Subject: [PATCH 01/18] add test case --- tests/parallel_test/cases.task | 2 + tests/system-test/1-insert/drop.py | 128 +++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 tests/system-test/1-insert/drop.py diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index a9a02d8380..7b06fa5eab 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -616,6 +616,8 @@ ,,,system-test,python3 ./test.py -f 1-insert/delete_childtable.py ,,,system-test,python3 ./test.py -f 1-insert/delete_normaltable.py ,,,system-test,python3 ./test.py -f 1-insert/keep_expired.py +,,,system-test,python3 ./test.py -f 1-insert/drop.py +,,,system-test,python3 ./test.py -f 1-insert/drop.py -N 3 -M 3 -i False -n 3 ,,,system-test,python3 ./test.py -f 2-query/join2.py ,,,system-test,python3 ./test.py -f 2-query/union1.py ,,,system-test,python3 ./test.py -f 2-query/concat2.py diff --git a/tests/system-test/1-insert/drop.py b/tests/system-test/1-insert/drop.py new file mode 100644 index 0000000000..d511d1aa7a --- /dev/null +++ b/tests/system-test/1-insert/drop.py @@ -0,0 +1,128 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + + +import math +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * +from util.sqlset import * + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.setsql = TDSetSql() + self.dbname = 'db' + self.ntbname = f"{self.dbname}.ntb" + self.rowNum = 10 + self.tbnum = 20 + self.ts = 1537146000000 + self.binary_str = 'taosdata' + self.nchar_str = '涛思数据' + self.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': 'binary(20)', + 'col13': 'nchar(20)' + } + def insert_data(self,column_dict,tbname,row_num): + insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str) + for i in range(row_num): + insert_list = [] + self.setsql.insert_values(column_dict,i,insert_sql,insert_list,self.ts) + def drop_ntb_check(self): + tdSql.execute(f'create database if not exists {self.dbname} replica {self.replicaVar}') + tdSql.execute(f'use {self.dbname}') + tdSql.execute(self.setsql.set_create_normaltable_sql(self.ntbname,self.column_dict)) + self.insert_data(self.column_dict,self.ntbname,self.rowNum) + for k,v in self.column_dict.items(): + if v.lower() == "timestamp": + tdSql.query(f'select * from {self.ntbname} where {k} = {self.ts}') + tdSql.checkRows(1) + tdSql.execute(f'drop table {self.ntbname}') + tdSql.execute(f'flush database {self.dbname}') + tdSql.execute(self.setsql.set_create_normaltable_sql(self.ntbname,self.column_dict)) + self.insert_data(self.column_dict,self.ntbname,self.rowNum) + for k,v in self.column_dict.items(): + if v.lower() == "timestamp": + tdSql.query(f'select * from {self.ntbname} where {k} = {self.ts}') + tdSql.checkRows(1) + tdSql.execute(f'drop database {self.dbname}') + + def drop_stb_ctb_check(self): + stbname = f'{self.dbname}.{tdCom.getLongName(5,"letters")}' + tag_dict = { + 't0':'int' + } + tag_values = [ + f'1' + ] + tdSql.execute(f"create database if not exists {self.dbname} replica {self.replicaVar}") + tdSql.execute(f'use {self.dbname}') + tdSql.execute(self.setsql.set_create_stable_sql(stbname,self.column_dict,tag_dict)) + for i in range(self.tbnum): + tdSql.execute(f"create table {stbname}_{i} using {stbname} tags({tag_values[0]})") + self.insert_data(self.column_dict,f'{stbname}_{i}',self.rowNum) + for k,v in self.column_dict.items(): + for i in range(self.tbnum): + if v.lower() == "timestamp": + tdSql.query(f'select * from {stbname}_{i} where {k} = {self.ts}') + tdSql.checkRows(1) + tdSql.execute(f'drop table {stbname}_{i}') + tdSql.execute(f'flush database {self.dbname}') + for i in range(self.tbnum): + tdSql.execute(f"create table {stbname}_{i} using {stbname} tags({tag_values[0]})") + self.insert_data(self.column_dict,f'{stbname}_{i}',self.rowNum) + for k,v in self.column_dict.items(): + for i in range(self.tbnum): + if v.lower() == "timestamp": + tdSql.query(f'select * from {stbname}_{i} where {k} = {self.ts}') + tdSql.checkRows(1) + if v.lower() == "timestamp": + tdSql.query(f'select * from {stbname} where {k} = {self.ts}') + tdSql.checkRows(self.tbnum) + tdSql.execute(f'drop table {stbname}') + tdSql.execute(f'flush database {self.dbname}') + tdSql.execute(self.setsql.set_create_stable_sql(stbname,self.column_dict,tag_dict)) + for i in range(self.tbnum): + tdSql.execute(f"create table {stbname}_{i} using {stbname} tags({tag_values[0]})") + self.insert_data(self.column_dict,f'{stbname}_{i}',self.rowNum) + for k,v in self.column_dict.items(): + if v.lower() == "timestamp": + tdSql.query(f'select * from {stbname} where {k} = {self.ts}') + tdSql.checkRows(self.tbnum) + tdSql.execute(f'drop database {self.dbname}') + + def run(self): + self.drop_ntb_check() + self.drop_stb_ctb_check() + pass + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file From 526f8261525cbeefb053719e4cdcdb3b37717ade Mon Sep 17 00:00:00 2001 From: jiacy-jcy <714897623@qq.com> Date: Wed, 23 Nov 2022 12:01:21 +0800 Subject: [PATCH 02/18] update test case --- tests/system-test/1-insert/alter_table.py | 7 ++++- tests/system-test/1-insert/drop.py | 37 +++++++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/tests/system-test/1-insert/alter_table.py b/tests/system-test/1-insert/alter_table.py index 6a437d4601..f9f20096a7 100644 --- a/tests/system-test/1-insert/alter_table.py +++ b/tests/system-test/1-insert/alter_table.py @@ -87,7 +87,6 @@ class TDTestCase: } def alter_check_ntb(self): - tdSql.prepare() tdSql.execute(self.setsql.set_create_normaltable_sql(self.ntbname,self.column_dict)) for i in self.values_list: @@ -107,6 +106,7 @@ class TDTestCase: v = f'binary({self.binary_length+1})' v_error = f'binary({self.binary_length-1})' tdSql.error(f'alter table {self.ntbname} modify column {key} {v_error}') + tdSql.error(f'alter table {self.ntbname} set tag {key} = "abcd1"') tdSql.execute(f'alter table {self.ntbname} modify column {key} {v}') tdSql.query(f'describe {self.ntbname}') result = tdCom.getOneRow(1,'VARCHAR') @@ -115,6 +115,7 @@ class TDTestCase: v = f'nchar({self.binary_length+1})' v_error = f'nchar({self.binary_length-1})' tdSql.error(f'alter table {self.ntbname} modify column {key} {v_error}') + tdSql.error(f'alter table {self.ntbname} set tag {key} = "abcd1"') tdSql.execute(f'alter table {self.ntbname} modify column {key} {v}') tdSql.query(f'describe {self.ntbname}') result = tdCom.getOneRow(1,'NCHAR') @@ -122,6 +123,7 @@ class TDTestCase: else: for v in self.column_dict.values(): tdSql.error(f'alter table {self.ntbname} modify column {key} {v}') + tdSql.error(f'alter table {self.ntbname} set tag {key} = "abcd1"') for key,values in self.column_dict.items(): rename_str = f'{tdCom.getLongName(constant.COL_NAME_LENGTH_MAX,"letters")}' tdSql.execute(f'alter table {self.ntbname} rename column {key} {rename_str}') @@ -285,6 +287,7 @@ class TDTestCase: v = f'binary({self.binary_length+1})' v_error = f'binary({self.binary_length-1})' tdSql.error(f'alter table {self.stbname} modify column {key} {v_error}') + tdSql.error(f'alter table {self.stbname} set tag {key} = "abcd1"') tdSql.execute(f'alter table {self.stbname} modify column {key} {v}') tdSql.query(f'describe {self.stbname}') result = tdCom.getOneRow(1,'VARCHAR') @@ -297,6 +300,7 @@ class TDTestCase: v = f'nchar({self.binary_length+1})' v_error = f'nchar({self.binary_length-1})' tdSql.error(f'alter table {self.stbname} modify column {key} {v_error}') + tdSql.error(f'alter table {self.stbname} set tag {key} = "abcd1"') tdSql.execute(f'alter table {self.stbname} modify column {key} {v}') tdSql.query(f'describe {self.stbname}') result = tdCom.getOneRow(1,'NCHAR') @@ -308,6 +312,7 @@ class TDTestCase: else: for v in self.column_dict.values(): tdSql.error(f'alter table {self.stbname} modify column {key} {v}') + tdSql.error(f'alter table {self.stbname} set tag {key} = "abcd1"') for key,values in self.column_dict.items(): rename_str = f'{tdCom.getLongName(constant.COL_NAME_LENGTH_MAX,"letters")}' tdSql.error(f'alter table {self.stbname} rename column {key} {rename_str}') diff --git a/tests/system-test/1-insert/drop.py b/tests/system-test/1-insert/drop.py index d511d1aa7a..bbb0b512e9 100644 --- a/tests/system-test/1-insert/drop.py +++ b/tests/system-test/1-insert/drop.py @@ -115,10 +115,41 @@ class TDTestCase: tdSql.query(f'select * from {stbname} where {k} = {self.ts}') tdSql.checkRows(self.tbnum) tdSql.execute(f'drop database {self.dbname}') - + def drop_topic_check(self): + tdSql.execute(f'create database {self.dbname} replica {self.replicaVar}') + tdSql.execute(f'use {self.dbname}') + stbname = tdCom.getLongName(5,"letters") + topic_name = tdCom.getLongName(5,"letters") + tdSql.execute(f'create table {stbname} (ts timestamp,c0 int) tags(t0 int)') + tdSql.execute(f'create topic {topic_name} as select * from {self.dbname}.{stbname}') + tdSql.query(f'select * from information_schema.ins_topics where topic_name = "{topic_name}"') + tdSql.checkEqual(tdSql.queryResult[0][3],f'create topic {topic_name} as select * from {self.dbname}.{stbname}') + tdSql.execute(f'drop topic {topic_name}') + tdSql.execute(f'create topic {topic_name} as select c0 from {self.dbname}.{stbname}') + tdSql.query(f'select * from information_schema.ins_topics where topic_name = "{topic_name}"') + tdSql.checkEqual(tdSql.queryResult[0][3],f'create topic {topic_name} as select c0 from {self.dbname}.{stbname}') + tdSql.execute(f'drop topic {topic_name}') + tdSql.execute(f'drop database {self.dbname}') + + def drop_stream_check(self): + tdSql.execute(f'create database {self.dbname} replica {self.replicaVar}') + tdSql.execute(f'use {self.dbname}') + stbname = tdCom.getLongName(5,"letters") + stream_name = tdCom.getLongName(5,"letters") + tdSql.execute(f'create table {stbname} (ts timestamp,c0 int) tags(t0 int)') + tdSql.execute(f'create stream {stream_name} into stb as select * from {self.dbname}.{stbname} partition by tbname') + tdSql.query(f'select * from information_schema.ins_streams where stream_name = "{stream_name}"') + print(tdSql.queryResult) + tdSql.checkEqual(tdSql.queryResult[0][2],f'create stream {stream_name} into stb as select * from {self.dbname}.{stbname} partition by tbname') + tdSql.execute(f'drop stream {stream_name}') + tdSql.execute(f'create stream {stream_name} into stb as select c0 from {self.dbname}.{stbname} partition by tbname') + tdSql.query(f'select * from information_schema.ins_streams where stream_name = "{stream_name}"') + tdSql.checkEqual(tdSql.queryResult[0][2],f'create stream {stream_name} into stb as select c0 from {stbname} partition by tbname') def run(self): - self.drop_ntb_check() - self.drop_stb_ctb_check() + # self.drop_ntb_check() + # self.drop_stb_ctb_check() + # self.drop_topic_check() + self.drop_stream_check() pass def stop(self): tdSql.close() From 6b53003f94aad0bd5d315fc15b01cfdf701c0fea Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 23 Nov 2022 12:18:38 +0800 Subject: [PATCH 03/18] refactor: add some logs. --- source/libs/executor/src/exchangeoperator.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/source/libs/executor/src/exchangeoperator.c b/source/libs/executor/src/exchangeoperator.c index c858536bb1..3c27c8064a 100644 --- a/source/libs/executor/src/exchangeoperator.c +++ b/source/libs/executor/src/exchangeoperator.c @@ -75,6 +75,8 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn } while (1) { + qDebug("prepare wait for ready, %p, %s", pExchangeInfo, GET_TASKID(pTaskInfo)); + tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { longjmp(pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED); @@ -360,7 +362,7 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { SExchangeInfo* pExchangeInfo = taosAcquireRef(exchangeObjRefPool, pWrapper->exchangeId); if (pExchangeInfo == NULL) { - qWarn("failed to acquire exchange operator, since it may have been released"); + qWarn("failed to acquire exchange operator, since it may have been released, %p", pExchangeInfo); taosMemoryFree(pMsg->pData); return TSDB_CODE_SUCCESS; } @@ -368,6 +370,9 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { int32_t index = pWrapper->sourceIndex; SSourceDataInfo* pSourceDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, index); + int32_t v = 0; + sem_getvalue(&pExchangeInfo->ready, &v); + if (code == TSDB_CODE_SUCCESS) { pSourceDataInfo->pRsp = pMsg->pData; @@ -379,19 +384,20 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { pRsp->numOfBlocks = htonl(pRsp->numOfBlocks); ASSERT(pRsp != NULL); - qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%d", pSourceDataInfo->taskId, index, pRsp->numOfBlocks, - pRsp->numOfRows); + qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%d, sem:%d, %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks, + pRsp->numOfRows, v, pExchangeInfo); } else { taosMemoryFree(pMsg->pData); pSourceDataInfo->code = code; - qDebug("%s fetch rsp received, index:%d, error:%s", pSourceDataInfo->taskId, index, tstrerror(code)); + qDebug("%s fetch rsp received, index:%d, error:%s, sem:%d, %p", pSourceDataInfo->taskId, index, tstrerror(code), v, pExchangeInfo); } pSourceDataInfo->status = EX_SOURCE_DATA_READY; - tsem_post(&pExchangeInfo->ready); - taosReleaseRef(exchangeObjRefPool, pWrapper->exchangeId); + code = tsem_post(&pExchangeInfo->ready); + ASSERT(code == TSDB_CODE_SUCCESS); + taosReleaseRef(exchangeObjRefPool, pWrapper->exchangeId); return TSDB_CODE_SUCCESS; } @@ -557,6 +563,9 @@ int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) { pOperator->status = OP_RES_TO_RETURN; pOperator->cost.openCost = taosGetTimestampUs() - startTs; + int32_t value = 0; + sem_getvalue(&pExchangeInfo->ready, &value); + tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { longjmp(pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED); From f92c1d4271293f5a1ec2e05b75699f62434aeb55 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 23 Nov 2022 13:48:15 +0800 Subject: [PATCH 04/18] refactor: add some logs. --- source/libs/executor/src/exchangeoperator.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/libs/executor/src/exchangeoperator.c b/source/libs/executor/src/exchangeoperator.c index 3c27c8064a..cff0c50644 100644 --- a/source/libs/executor/src/exchangeoperator.c +++ b/source/libs/executor/src/exchangeoperator.c @@ -75,7 +75,9 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn } while (1) { - qDebug("prepare wait for ready, %p, %s", pExchangeInfo, GET_TASKID(pTaskInfo)); + int32_t v = 0; + sem_getvalue(&pExchangeInfo->ready, &v); + qDebug("prepare wait for ready, sem:(%d,%p), %p, %s", v, pExchangeInfo->ready.__align, pExchangeInfo, GET_TASKID(pTaskInfo)); tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { @@ -370,7 +372,7 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { int32_t index = pWrapper->sourceIndex; SSourceDataInfo* pSourceDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, index); - int32_t v = 0; + int32_t v = 0, v1 = 0; sem_getvalue(&pExchangeInfo->ready, &v); if (code == TSDB_CODE_SUCCESS) { @@ -384,12 +386,13 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { pRsp->numOfBlocks = htonl(pRsp->numOfBlocks); ASSERT(pRsp != NULL); - qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%d, sem:%d, %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks, - pRsp->numOfRows, v, pExchangeInfo); + qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%d, sem:(%d,%p), %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks, + pRsp->numOfRows, v, pExchangeInfo->ready.__align, pExchangeInfo); } else { taosMemoryFree(pMsg->pData); pSourceDataInfo->code = code; - qDebug("%s fetch rsp received, index:%d, error:%s, sem:%d, %p", pSourceDataInfo->taskId, index, tstrerror(code), v, pExchangeInfo); + qDebug("%s fetch rsp received, index:%d, error:%s, sem:(%d,%p), %p", pSourceDataInfo->taskId, index, tstrerror(code), v, + pExchangeInfo->ready.__align, pExchangeInfo); } pSourceDataInfo->status = EX_SOURCE_DATA_READY; @@ -429,9 +432,9 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas return pTaskInfo->code; } - qDebug("%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%" PRIx64 ", execId:%d, %d/%" PRIzu, + qDebug("%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%" PRIx64 ", execId:%d, %p, %d/%" PRIzu, GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, - pSource->execId, sourceIndex, totalSources); + pSource->execId, pExchangeInfo, sourceIndex, totalSources); pMsg->header.vgId = htonl(pSource->addr.nodeId); pMsg->sId = htobe64(pSource->schedId); From c623336b6ed2f758e6be80703eacb7f9bdbe4ea8 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 23 Nov 2022 13:59:38 +0800 Subject: [PATCH 05/18] refactor: enable continue query when the buffer of sink node is lower or empty. --- source/libs/executor/src/dataDispatcher.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c index 3d9757c96f..d4248fc420 100644 --- a/source/libs/executor/src/dataDispatcher.c +++ b/source/libs/executor/src/dataDispatcher.c @@ -138,7 +138,9 @@ static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, toDataCacheEntry(pDispatcher, pInput, pBuf); taosWriteQitem(pDispatcher->pDataBlocks, pBuf); - *pContinue = (DS_BUF_LOW == updateStatus(pDispatcher) ? true : false); + + int32_t status = updateStatus(pDispatcher); + *pContinue = (status == DS_BUF_LOW || status == DS_BUF_EMPTY); return TSDB_CODE_SUCCESS; } From 852f52687672eb67881c9c90bff4dd178881c869 Mon Sep 17 00:00:00 2001 From: jiacy-jcy <714897623@qq.com> Date: Wed, 23 Nov 2022 14:41:30 +0800 Subject: [PATCH 06/18] update --- tests/system-test/1-insert/drop.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/system-test/1-insert/drop.py b/tests/system-test/1-insert/drop.py index bbb0b512e9..f8796bcf6a 100644 --- a/tests/system-test/1-insert/drop.py +++ b/tests/system-test/1-insert/drop.py @@ -137,18 +137,20 @@ class TDTestCase: stbname = tdCom.getLongName(5,"letters") stream_name = tdCom.getLongName(5,"letters") tdSql.execute(f'create table {stbname} (ts timestamp,c0 int) tags(t0 int)') + tdSql.execute(f'create table tb using {stbname} tags(1)') tdSql.execute(f'create stream {stream_name} into stb as select * from {self.dbname}.{stbname} partition by tbname') tdSql.query(f'select * from information_schema.ins_streams where stream_name = "{stream_name}"') print(tdSql.queryResult) tdSql.checkEqual(tdSql.queryResult[0][2],f'create stream {stream_name} into stb as select * from {self.dbname}.{stbname} partition by tbname') tdSql.execute(f'drop stream {stream_name}') - tdSql.execute(f'create stream {stream_name} into stb as select c0 from {self.dbname}.{stbname} partition by tbname') + tdSql.execute(f'create stream {stream_name} into stb1 as select * from tb') tdSql.query(f'select * from information_schema.ins_streams where stream_name = "{stream_name}"') - tdSql.checkEqual(tdSql.queryResult[0][2],f'create stream {stream_name} into stb as select c0 from {stbname} partition by tbname') + tdSql.checkEqual(tdSql.queryResult[0][2],f'create stream {stream_name} into stb1 as select * from tb') + tdSql.execute(f'drop database {self.dbname}') def run(self): - # self.drop_ntb_check() - # self.drop_stb_ctb_check() - # self.drop_topic_check() + self.drop_ntb_check() + self.drop_stb_ctb_check() + self.drop_topic_check() self.drop_stream_check() pass def stop(self): From 37735cf861963e4c3f0179cafbfeed7b27212500 Mon Sep 17 00:00:00 2001 From: jiacy-jcy <714897623@qq.com> Date: Wed, 23 Nov 2022 15:09:39 +0800 Subject: [PATCH 07/18] remove test case --- tests/parallel_test/cases.task | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index e5ab69396e..07937c817c 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -424,7 +424,7 @@ ,,,system-test,python3 ./test.py -f 1-insert/test_stmt_muti_insert_query.py ,,,system-test,python3 ./test.py -f 1-insert/test_stmt_set_tbname_tag.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_stable.py -,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_table.py +#,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_table.py ,,,system-test,python3 ./test.py -f 1-insert/boundary.py ,,,system-test,python3 ./test.py -f 1-insert/insertWithMoreVgroup.py ,,,system-test,python3 ./test.py -f 1-insert/table_comment.py From 05f84c184e0db320bfff1c946b732a016ad27b3c Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 23 Nov 2022 15:36:38 +0800 Subject: [PATCH 08/18] fix(query): fix syntax error. --- source/libs/executor/src/exchangeoperator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/libs/executor/src/exchangeoperator.c b/source/libs/executor/src/exchangeoperator.c index cff0c50644..04caccbf8f 100644 --- a/source/libs/executor/src/exchangeoperator.c +++ b/source/libs/executor/src/exchangeoperator.c @@ -77,7 +77,7 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn while (1) { int32_t v = 0; sem_getvalue(&pExchangeInfo->ready, &v); - qDebug("prepare wait for ready, sem:(%d,%p), %p, %s", v, pExchangeInfo->ready.__align, pExchangeInfo, GET_TASKID(pTaskInfo)); + qDebug("prepare wait for ready, sem:(%d,%p), %p, %s", v, (void*)pExchangeInfo->ready.__align, pExchangeInfo, GET_TASKID(pTaskInfo)); tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { @@ -387,12 +387,12 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { ASSERT(pRsp != NULL); qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%d, sem:(%d,%p), %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks, - pRsp->numOfRows, v, pExchangeInfo->ready.__align, pExchangeInfo); + pRsp->numOfRows, v, (void*)pExchangeInfo->ready.__align, pExchangeInfo); } else { taosMemoryFree(pMsg->pData); pSourceDataInfo->code = code; qDebug("%s fetch rsp received, index:%d, error:%s, sem:(%d,%p), %p", pSourceDataInfo->taskId, index, tstrerror(code), v, - pExchangeInfo->ready.__align, pExchangeInfo); + (void*) pExchangeInfo->ready.__align, pExchangeInfo); } pSourceDataInfo->status = EX_SOURCE_DATA_READY; From 0a8fc50024eca59f7d01f80b4c84b208308bd0e8 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 23 Nov 2022 15:47:12 +0800 Subject: [PATCH 09/18] test:update test cases. --- source/client/test/clientTests.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 85814305bd..007e0bd931 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -692,7 +692,6 @@ TEST(testCase, insert_test) { taos_free_result(pRes); taos_close(pConn); } -#endif TEST(testCase, projection_query_tables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); @@ -752,9 +751,6 @@ TEST(testCase, projection_query_tables) { taos_close(pConn); } - -#if 0 - TEST(testCase, tsbs_perf_test) { TdThread qid[20] = {0}; @@ -764,15 +760,16 @@ TEST(testCase, tsbs_perf_test) { getchar(); } +#endif TEST(testCase, projection_query_stables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); - TAOS_RES* pRes = taos_query(pConn, "use abc1"); + TAOS_RES* pRes = taos_query(pConn, "use test"); taos_free_result(pRes); - pRes = taos_query(pConn, "select ts from st1"); + pRes = taos_query(pConn, "select * from meters"); if (taos_errno(pRes) != 0) { printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); @@ -793,6 +790,7 @@ TEST(testCase, projection_query_stables) { taos_close(pConn); } +#if 0 TEST(testCase, agg_query_tables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); From 4d75bd69b255977f9cd46beb8c466125035f314d Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 23 Nov 2022 15:49:59 +0800 Subject: [PATCH 10/18] test: disable print result. --- source/client/test/clientTests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 007e0bd931..78a14d3292 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -782,8 +782,8 @@ TEST(testCase, projection_query_stables) { char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { - int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); +// int32_t code = taos_print_row(str, pRow, pFields, numOfFields); +// printf("%s\n", str); } taos_free_result(pRes); From ca1dcf4ea1a2f1d4934b670e7bbec4b09d8b63a7 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 23 Nov 2022 15:54:00 +0800 Subject: [PATCH 11/18] test: limit the output --- source/client/test/clientTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 78a14d3292..dcacaf3471 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -769,7 +769,7 @@ TEST(testCase, projection_query_stables) { TAOS_RES* pRes = taos_query(pConn, "use test"); taos_free_result(pRes); - pRes = taos_query(pConn, "select * from meters"); + pRes = taos_query(pConn, "select * from meters limit 30000000"); if (taos_errno(pRes) != 0) { printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); From f9e338ba2d25bdb93b4a03b3f1320553804944ab Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 23 Nov 2022 15:54:30 +0800 Subject: [PATCH 12/18] test: limit the output. --- source/client/test/clientTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index dcacaf3471..82202b8820 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -769,7 +769,7 @@ TEST(testCase, projection_query_stables) { TAOS_RES* pRes = taos_query(pConn, "use test"); taos_free_result(pRes); - pRes = taos_query(pConn, "select * from meters limit 30000000"); + pRes = taos_query(pConn, "select * from meters limit 50000000"); if (taos_errno(pRes) != 0) { printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); From f7a058c87c5d9d7c7d5bdf337ff48c8341ac3922 Mon Sep 17 00:00:00 2001 From: Jason-Jia <714897623@qq.com> Date: Wed, 23 Nov 2022 20:34:28 +0800 Subject: [PATCH 13/18] Update alter_database.py --- tests/system-test/1-insert/alter_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/1-insert/alter_database.py b/tests/system-test/1-insert/alter_database.py index aec18a1cf1..12b8861707 100644 --- a/tests/system-test/1-insert/alter_database.py +++ b/tests/system-test/1-insert/alter_database.py @@ -53,7 +53,7 @@ class TDTestCase: tdSql.execute('drop database db') def run(self): - tdSql.error('create database db1 vgroups 10 buffer 12289') + self.alter_buffer() self.alter_pages() From f49e44c256f106a015de536a3f73ff5399f588ed Mon Sep 17 00:00:00 2001 From: Jason-Jia <714897623@qq.com> Date: Thu, 24 Nov 2022 09:05:42 +0800 Subject: [PATCH 14/18] Update alter_database.py --- tests/system-test/1-insert/alter_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/1-insert/alter_database.py b/tests/system-test/1-insert/alter_database.py index 12b8861707..1fca294a47 100644 --- a/tests/system-test/1-insert/alter_database.py +++ b/tests/system-test/1-insert/alter_database.py @@ -18,7 +18,7 @@ class TDTestCase: tdSql.init(conn.cursor(), logSql) self.buffer_boundary = [3, 4097, 8193, 12289, 16384] self.buffer_error = [self.buffer_boundary[0] - - 1, self.buffer_boundary[-1]+1, 12289, 256] + 1, self.buffer_boundary[-1]+1, 256] # pages_boundary >= 64 self.pages_boundary = [64, 128, 512] self.pages_error = [self.pages_boundary[0]-1] From b27faba7efb06f9789c240be1285e15d4453af8a Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao@163.com> Date: Wed, 23 Nov 2022 17:07:45 +0800 Subject: [PATCH 15/18] fix:initialize maxts --- source/libs/executor/src/scanoperator.c | 2 +- source/libs/executor/src/timewindowoperator.c | 15 +++-- tests/script/tsim/stream/state0.sim | 60 +++++++++++++++++++ 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index de2a7b9dac..8db450ad50 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1849,12 +1849,12 @@ FETCH_NEXT_BLOCK: prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes); pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA; - pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; printDataBlock(pDelBlock, "stream scan delete data"); if (pInfo->tqReader) { blockDataDestroy(pDelBlock); } if (pInfo->pDeleteDataRes->info.rows > 0) { + pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; return pInfo->pDeleteDataRes; } else { goto FETCH_NEXT_BLOCK; diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index dd02ce9cd4..7fd2fcb5b8 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -3364,22 +3364,23 @@ void initDummyFunction(SqlFunctionCtx* pDummy, SqlFunctionCtx* pCtx, int32_t num } } -void initDownStream(SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, int64_t waterMark, uint16_t type, - int32_t tsColIndex) { +void initDownStream(SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, uint16_t type, int32_t tsColIndex, + STimeWindowAggSupp* pTwSup) { if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION) { SStreamPartitionOperatorInfo* pScanInfo = downstream->info; pScanInfo->tsColIndex = tsColIndex; } if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { - initDownStream(downstream->pDownstream[0], pAggSup, waterMark, type, tsColIndex); + initDownStream(downstream->pDownstream[0], pAggSup, type, tsColIndex, pTwSup); return; } SStreamScanInfo* pScanInfo = downstream->info; pScanInfo->windowSup = (SWindowSupporter){.pStreamAggSup = pAggSup, .gap = pAggSup->gap, .parentType = type}; if (!pScanInfo->pUpdateInfo) { - pScanInfo->pUpdateInfo = updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, waterMark); + pScanInfo->pUpdateInfo = updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, pTwSup->waterMark); } + pScanInfo->twAggSup = *pTwSup; } int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, int64_t gap, @@ -4102,8 +4103,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh createOperatorFpSet(operatorDummyOpenFn, doStreamSessionAgg, NULL, destroyStreamSessionAggOperatorInfo, NULL); if (downstream) { - initDownStream(downstream, &pInfo->streamAggSup, pInfo->twAggSup.waterMark, pOperator->operatorType, - pInfo->primaryTsIndex); + initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup); code = appendDownstream(pOperator, &downstream, 1); } return pOperator; @@ -4606,8 +4606,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys pInfo, pTaskInfo); pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamStateAgg, NULL, destroyStreamStateOperatorInfo, NULL); - initDownStream(downstream, &pInfo->streamAggSup, pInfo->twAggSup.waterMark, pOperator->operatorType, - pInfo->primaryTsIndex); + initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { goto _error; diff --git a/tests/script/tsim/stream/state0.sim b/tests/script/tsim/stream/state0.sim index 87d7d4b7fc..7c922658c9 100644 --- a/tests/script/tsim/stream/state0.sim +++ b/tests/script/tsim/stream/state0.sim @@ -731,5 +731,65 @@ if $data32 != 1 then goto loop9 endi +sql drop stream if exists streams5; +sql drop database if exists test5; +sql create database test5; +sql use test5; +sql create table tb (ts timestamp, a int); +sql insert into tb values (now + 1m , 1 ); +sql create table b (c timestamp, d int, e int , f int, g double); +sql create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3 from tb state_window(a); +sql insert into b values(1648791213000,NULL,NULL,NULL,NULL); +sql select * from streamt order by c1, c2, c3; + +print data00:$data00 +print data01:$data01 + +sql insert into b values(1648791213000,NULL,NULL,NULL,NULL); +sql select * from streamt order by c1, c2, c3; + +print data00:$data00 +print data01:$data01 + +sql insert into b values(1648791213001,1,2,2,2.0); +sql insert into b values(1648791213002,1,3,3,3.0); +sql insert into tb values(1648791213003,1); + +sql select * from streamt; +print data00:$data00 +print data01:$data01 + +sql delete from b where c >= 1648791213001 and c <= 1648791213002; +sql insert into b values(1648791223003,2,2,3,1.0); insert into b values(1648791223002,2,3,3,3.0); +sql insert into tb values (now + 1m , 1 ); + +sql select * from streamt; +print data00:$data00 +print data01:$data01 + +sql insert into b(c,d) values (now + 6m , 6 ); +sql delete from b where c >= 1648791213001 and c <= 1648791233005;; + +$loop_count = 0 +loop10: + +sleep 200 + +sql select c2 from streamt; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $rows != 1 then + print =====rows=$rows + goto loop10 +endi + +if $data00 != 2 then + print =====data00=$data00 + goto loop10 +endi system sh/exec.sh -n dnode1 -s stop -x SIGINT From b460974f43d248edceee368e371d043136bbbdca Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 24 Nov 2022 10:32:31 +0800 Subject: [PATCH 16/18] fix(query): fix syntax error. --- source/libs/executor/src/exchangeoperator.c | 27 ++++++++------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/source/libs/executor/src/exchangeoperator.c b/source/libs/executor/src/exchangeoperator.c index 04caccbf8f..2c79b77e16 100644 --- a/source/libs/executor/src/exchangeoperator.c +++ b/source/libs/executor/src/exchangeoperator.c @@ -75,11 +75,9 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn } while (1) { - int32_t v = 0; - sem_getvalue(&pExchangeInfo->ready, &v); - qDebug("prepare wait for ready, sem:(%d,%p), %p, %s", v, (void*)pExchangeInfo->ready.__align, pExchangeInfo, GET_TASKID(pTaskInfo)); - + qDebug("prepare wait for ready, %p, %s", pExchangeInfo, GET_TASKID(pTaskInfo)); tsem_wait(&pExchangeInfo->ready); + if (isTaskKilled(pTaskInfo)) { longjmp(pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED); } @@ -372,9 +370,6 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { int32_t index = pWrapper->sourceIndex; SSourceDataInfo* pSourceDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, index); - int32_t v = 0, v1 = 0; - sem_getvalue(&pExchangeInfo->ready, &v); - if (code == TSDB_CODE_SUCCESS) { pSourceDataInfo->pRsp = pMsg->pData; @@ -386,22 +381,23 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { pRsp->numOfBlocks = htonl(pRsp->numOfBlocks); ASSERT(pRsp != NULL); - qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%d, sem:(%d,%p), %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks, - pRsp->numOfRows, v, (void*)pExchangeInfo->ready.__align, pExchangeInfo); + qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%d, %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks, + pRsp->numOfRows, pExchangeInfo); } else { taosMemoryFree(pMsg->pData); pSourceDataInfo->code = code; - qDebug("%s fetch rsp received, index:%d, error:%s, sem:(%d,%p), %p", pSourceDataInfo->taskId, index, tstrerror(code), v, - (void*) pExchangeInfo->ready.__align, pExchangeInfo); + qDebug("%s fetch rsp received, index:%d, error:%s, %p", pSourceDataInfo->taskId, index, tstrerror(code), pExchangeInfo); } pSourceDataInfo->status = EX_SOURCE_DATA_READY; - code = tsem_post(&pExchangeInfo->ready); - ASSERT(code == TSDB_CODE_SUCCESS); + if (code != TSDB_CODE_SUCCESS) { + code = TAOS_SYSTEM_ERROR(code); + qError("failed to invoke post when fetch rsp is ready, code:%s, %p", tstrerror(code), pExchangeInfo); + } taosReleaseRef(exchangeObjRefPool, pWrapper->exchangeId); - return TSDB_CODE_SUCCESS; + return code; } int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTaskInfo, int32_t sourceIndex) { @@ -566,9 +562,6 @@ int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) { pOperator->status = OP_RES_TO_RETURN; pOperator->cost.openCost = taosGetTimestampUs() - startTs; - int32_t value = 0; - sem_getvalue(&pExchangeInfo->ready, &value); - tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { longjmp(pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED); From cd46ca0f5a3a5cb9e3fbb80f8a12724bd6d91787 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 24 Nov 2022 11:12:08 +0800 Subject: [PATCH 17/18] fix(shell): add help command and fix crete table filed complete include binary --- tools/shell/inc/shellAuto.h | 3 +++ tools/shell/src/shellAuto.c | 43 +++++++++++++++++++++++------------ tools/shell/src/shellEngine.c | 6 +++++ 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/tools/shell/inc/shellAuto.h b/tools/shell/inc/shellAuto.h index f86090d618..b7bf5fa101 100644 --- a/tools/shell/inc/shellAuto.h +++ b/tools/shell/inc/shellAuto.h @@ -39,4 +39,7 @@ void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb); // introduction void printfIntroduction(); +// show all commands help +void showHelp(); + #endif diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 534ecf3c4d..01c8042c0e 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -108,6 +108,7 @@ SWords shellCommands[] = { {"drop topic ;", 0, 0, NULL}, {"drop stream ;", 0, 0, NULL}, {"explain select", 0, 0, NULL}, // 44 append sub sql + {"help;", 0, 0, NULL}, {"grant all on to ;", 0, 0, NULL}, {"grant read on to ;", 0, 0, NULL}, {"grant write on to ;", 0, 0, NULL}, @@ -386,6 +387,8 @@ void showHelp() { drop stream ;\n\ ----- E ----- \n\ explain select clause ...\n\ + ----- H ----- \n\ + help;\n\ ----- I ----- \n\ insert into values(...) ;\n\ insert into using tags(...) values(...) ;\n\ @@ -1478,24 +1481,36 @@ bool matchSelectQuery(TAOS* con, SShellCmd* cmd) { // if is input create fields or tags area, return true bool isCreateFieldsArea(char* p) { - char* left = strrchr(p, '('); - if (left == NULL) { - // like 'create table st' - return false; - } + // put to while, support like create table st(ts timestamp, bin1 binary(16), bin2 + blank + TAB + char* p1 = strdup(p); + bool ret = false; + while (1) { + char* left = strrchr(p1, '('); + if (left == NULL) { + // like 'create table st' + ret = false; + break; + } - char* right = strrchr(p, ')'); - if (right == NULL) { - // like 'create table st( ' - return true; - } + char* right = strrchr(p1, ')'); + if (right == NULL) { + // like 'create table st( ' + ret = true; + break; + } - if (left > right) { - // like 'create table st( ts timestamp, age int) tags(area ' - return true; + if (left > right) { + // like 'create table st( ts timestamp, age int) tags(area ' + ret = true; + break; + } + + // set string end by small for next strrchr search + *left = 0; } + taosMemoryFree(p1); - return false; + return ret; } bool matchCreateTable(TAOS* con, SShellCmd* cmd) { diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 8402a5a589..577021f460 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -134,6 +134,12 @@ int32_t shellRunCommand(char *command, bool recordHistory) { return 0; } + // add help or help; + if(strcmp(command, "help") == 0 || strcmp(command, "help;") == 0) { + showHelp(); + return 0; + } + if (recordHistory) shellRecordCommandToHistory(command); char quote = 0, *cmd = command; From a0aa07b41dabde141d880d40b4ebbb7f7afd6ceb Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 24 Nov 2022 11:45:40 +0800 Subject: [PATCH 18/18] test: adjust asan case --- tests/parallel_test/cases.task | 6 +++--- tests/system-test/2-query/smaTest.py | 25 ++++++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 27611a1a17..ee6f0a393c 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -417,7 +417,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_control.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/fsync.py ,,n,system-test,python3 ./test.py -f 0-others/compatibility.py -#,,,system-test,python3 ./test.py -f 1-insert/alter_database.py +,,,system-test,python3 ./test.py -f 1-insert/alter_database.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py ,,,system-test,python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py @@ -561,8 +561,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sample.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sin.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sin.py -R -,,,system-test,python3 ./test.py -f 2-query/smaTest.py -,,,system-test,python3 ./test.py -f 2-query/smaTest.py -R +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/smaTest.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/smaTest.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sml.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sml.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/spread.py diff --git a/tests/system-test/2-query/smaTest.py b/tests/system-test/2-query/smaTest.py index 0390bae114..04fb893e75 100644 --- a/tests/system-test/2-query/smaTest.py +++ b/tests/system-test/2-query/smaTest.py @@ -44,8 +44,8 @@ class TDTestCase: def run(self): # insert data dbname = "db" - self.insert_data1(f"{dbname}.t1", self.ts, 1000*10000) - self.insert_data1(f"{dbname}.t4", self.ts, 1000*10000) + self.insert_data1(f"{dbname}.t1", self.ts, 10*10000) + self.insert_data1(f"{dbname}.t4", self.ts, 10*10000) # test base case # self.test_case1() tdLog.debug(" LIMIT test_case1 ............ [OK]") @@ -53,7 +53,6 @@ class TDTestCase: # self.test_case2() tdLog.debug(" LIMIT test_case2 ............ [OK]") - # stop def stop(self): tdSql.close() @@ -77,15 +76,17 @@ class TDTestCase: # insert data1 def insert_data(self, tbname, ts_start, count): - pre_insert = "insert into %s values"%tbname + pre_insert = "insert into %s values" % tbname sql = pre_insert - tdLog.debug("insert table %s rows=%d ..."%(tbname, count)) + tdLog.debug("insert table %s rows=%d ..." % (tbname, count)) for i in range(count): - sql += " (%d,%d)"%(ts_start + i*1000, i ) - if i >0 and i%30000 == 0: + sql += " (%d,%d)" % (ts_start + i*1000, i) + if i > 0 and i % 20000 == 0: + tdLog.info("%d rows inserted" % i) tdSql.execute(sql) sql = pre_insert # end sql + tdLog.info("insert_data end") if sql != pre_insert: tdSql.execute(sql) @@ -93,15 +94,17 @@ class TDTestCase: return def insert_data1(self, tbname, ts_start, count): - pre_insert = "insert into %s values"%tbname + pre_insert = "insert into %s values" % tbname sql = pre_insert - tdLog.debug("insert table %s rows=%d ..."%(tbname, count)) + tdLog.debug("insert table %s rows=%d ..." % (tbname, count)) for i in range(count): - sql += " (%d,%d,%d)"%(ts_start + i*1000, i , i+1) - if i >0 and i%30000 == 0: + sql += " (%d,%d,%d)" % (ts_start + i*1000, i, i+1) + if i > 0 and i % 20000 == 0: + tdLog.info("%d rows inserted" % i) tdSql.execute(sql) sql = pre_insert # end sql + tdLog.info("insert_data1 end") if sql != pre_insert: tdSql.execute(sql)