diff --git a/src/client/src/tscDelete.c b/src/client/src/tscDelete.c index b5d044d9dba7d98763666ee6bde7ba5de4d41ba3..c03f7d0574fc56fb898f88d60b86a3a4062d0ae6 100644 --- a/src/client/src/tscDelete.c +++ b/src/client/src/tscDelete.c @@ -198,6 +198,10 @@ int32_t executeDelete(SSqlObj* pSql, SQueryInfo* pQueryInfo) { SSubqueryState *pState = &pSql->subState; int32_t numOfSub = pTableMetaInfo->vgroupList->numOfVgroups; + if(numOfSub == 0) { + tscInfo(":CDEL SQL:%p tablename=%s numOfVgroups is zero, maybe empty table.", pSql, pTableMetaInfo->name.tname); + return TSDB_CODE_FAILED; + } ret = doInitSubState(pSql, numOfSub); if (ret != 0) { diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 6979465a0f41db6e527f003bd4703f46de0e8523..8c92c86c194034f17f3cb05b15dec0e8e1b87f1e 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -2087,7 +2087,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index, switch (tag_state) { case tag_common: if (back_slash == true) { - if (*cur != ',' && *cur != '=' && *cur != ' ') { + if (*cur != ',' && *cur != '=' && *cur != ' ' && *cur != 'n' ) { tscError("SML:0x%"PRIx64" tag value: state(%d), incorrect character(%c) escaped", info->id, tag_state, *cur); ret = TSDB_CODE_TSC_LINE_SYNTAX_ERROR; goto error; @@ -2152,7 +2152,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index, break; case tag_lqoute: if (back_slash == true) { - if (*cur != ',' && *cur != '=' && *cur != ' ') { + if (*cur != ',' && *cur != '=' && *cur != ' ' && *cur != 'n') { tscError("SML:0x%"PRIx64" tag value: state(%d), incorrect character(%c) escaped", info->id, tag_state, *cur); ret = TSDB_CODE_TSC_LINE_SYNTAX_ERROR; goto error; @@ -2223,7 +2223,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index, switch (val_state) { case val_common: if (back_slash == true) { - if (*cur != '\\' && *cur != '"') { + if (*cur != '\\' && *cur != '"' && *cur != 'n') { tscError("SML:0x%"PRIx64" field value: state(%d), incorrect character(%c) escaped", info->id, val_state, *cur); ret = TSDB_CODE_TSC_LINE_SYNTAX_ERROR; goto error; @@ -2318,7 +2318,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index, break; case val_lqoute: if (back_slash == true) { - if (*cur != '\\' && *cur != '"') { + if (*cur != '\\' && *cur != '"' && *cur != 'n') { tscError("SML:0x%"PRIx64" field value: state(%d), incorrect character(%c) escaped", info->id, val_state, *cur); ret = TSDB_CODE_TSC_LINE_SYNTAX_ERROR; goto error; @@ -2488,12 +2488,15 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs, if (isField) { capacity = 64; *pKVs = malloc(capacity * sizeof(TAOS_SML_KV)); + memset(*pKVs, 0, capacity * sizeof(TAOS_SML_KV)); // leave space for timestamp; pkv = *pKVs; pkv++; + *num_kvs = 1; // ts fixed column } else { capacity = 8; *pKVs = malloc(capacity * sizeof(TAOS_SML_KV)); + memset(*pKVs, 0, capacity * sizeof(TAOS_SML_KV)); pkv = *pKVs; } @@ -2554,7 +2557,7 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs, *pKVs = more_kvs; //move pKV points to next TAOS_SML_KV block if (isField) { - pkv = *pKVs + *num_kvs + 1; + pkv = *pKVs + *num_kvs; // first ts column reserved } else { pkv = *pKVs + *num_kvs; } @@ -2576,7 +2579,7 @@ static void moveTimeStampToFirstKv(TAOS_SML_DATA_POINT** smlData, TAOS_SML_KV *t tsField->key = malloc(strlen(ts->key) + 1); memcpy(tsField->key, ts->key, strlen(ts->key) + 1); memcpy(tsField->value, ts->value, ts->length); - (*smlData)->fieldNum = (*smlData)->fieldNum + 1; + //(*smlData)->fieldNum = (*smlData)->fieldNum + 1; // already reserved for first ts column free(ts->key); free(ts->value); @@ -2634,14 +2637,21 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf //========================================================================= void destroySmlDataPoint(TAOS_SML_DATA_POINT* point) { + TAOS_SML_KV *pkv; for (int i=0; itagNum; ++i) { - free((point->tags+i)->key); - free((point->tags+i)->value); + pkv = point->tags + i; + if (pkv->key) + free(pkv->key); + if (pkv->value) + free(pkv->value); } free(point->tags); for (int i=0; ifieldNum; ++i) { - free((point->fields+i)->key); - free((point->fields+i)->value); + pkv = point->fields + i; + if (pkv->key) + free(pkv->key); + if (pkv->value) + free(pkv->value); } free(point->fields); free(point->stableName); diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 3fadc7abaf0aa2ae96e87cae77c6ce1a2b3df742..449d816e76e606f070af310ef7840027a388d396 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -3921,9 +3921,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr } else if (pQueryAttr->pExpr2 != NULL) { pEx = pQueryAttr->pExpr2; num = pQueryAttr->numOfExpr2; - } - - if ( num < pQueryAttr->numOfOutput) { + } else { pEx = pQueryAttr->pExpr1; num = pQueryAttr->numOfOutput; } diff --git a/src/tsdb/src/tsdbDelete.c b/src/tsdb/src/tsdbDelete.c index 180f577db2e87b0950a9c2ac20ce41e1a42a778b..50931b00f1bc0910377fb2bf0c6a16d461c93b5e 100644 --- a/src/tsdb/src/tsdbDelete.c +++ b/src/tsdb/src/tsdbDelete.c @@ -125,7 +125,7 @@ static int tsdbDeleteImplCommon(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo) { pRepo->deleteState = TSDB_NO_DELETE; tsem_post(&(pRepo->readyToCommit)); tsdbInfo("vgId:%d :SDEL delete over, no meta or data file", REPO_ID(pRepo)); - return -1; + return TSDB_CODE_SUCCESS; } SArray* aUpdates = taosArrayInit(10, sizeof(STable *)); diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index fda76ba216e3e68321d02db16b49ffb422443d81..3edfe997495c3ecda8933bca7133fd5ae3532caa 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -270,6 +270,7 @@ 24,,script,./test.sh -f general/connection/test_old_data.sim 24,,script,./test.sh -f general/cache/restart_metrics.sim 24,,script,./test.sh -f general/alter/insert2.sim +24,,pytest,python3 test.py -f multilevel/addAnotherLevel.py 24,,pytest,python3 test.py -f tag_lite/datatype-without-alter.py 23,,script,./test.sh -f general/parser/select_from_cache_disk.sim 23,,script,./test.sh -f general/parser/mixed_blocks.sim @@ -319,6 +320,7 @@ 20,,pytest,python3 test.py -f table/create.py 19,,script,./test.sh -f unique/stable/dnode2.sim 19,,script,./test.sh -f general/db/vnodes.sim +19,,pytest,python3 test.py -f multilevel/addAnotherDir.py 19,,pytest,python3 test.py -f tools/taosdumpTest3.py 19,,pytest,python3 test.py -f query/udf.py 19,,pytest,python3 test.py -f import_merge/importLastTPO.py diff --git a/tests/pytest/multilevel/addAnotherDir.py b/tests/pytest/multilevel/addAnotherDir.py new file mode 100644 index 0000000000000000000000000000000000000000..66a0a72010ddc0041e0b7900a24a3f66894ab260 --- /dev/null +++ b/tests/pytest/multilevel/addAnotherDir.py @@ -0,0 +1,65 @@ +################################################################### +# 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 sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + cfg={ + 'monitor': 1, + '/mnt/data1 0 1' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + + tdLog.info("================= step1") + tdDnodes.stop(1) + tdDnodes.deploy(1,cfg) + tdDnodes.start(1) + + tdSql.execute("create database db") + tdSql.execute("create table db.tb (ts timestamp, f1 int)") + sql = "insert into db.tb values " + ts = 1622390400000 + for i in range(1000): + sql += "(%d, %d)" % (ts + i, i) + tdSql.execute(sql) + + tdDnodes.stop(1) + tdDnodes.cfg(1, 'dataDir', '/mnt/data2 0 0') + tdSql.createDir('/mnt/data2') + tdDnodes.start(1) + + tdSql.query("select * from db.tb") + tdSql.checkRows(1000) + + + def stop(self): + tdSql.close() + os.system("rm -rf /mnt/data1") + os.system("rm -rf /mnt/data2") + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/addAnotherLevel.py b/tests/pytest/multilevel/addAnotherLevel.py new file mode 100644 index 0000000000000000000000000000000000000000..e949296952f35bd76a060a37b0a3da7179eb8db9 --- /dev/null +++ b/tests/pytest/multilevel/addAnotherLevel.py @@ -0,0 +1,64 @@ +################################################################### +# 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 sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + cfg={ + '/mnt/data1 0 1' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + + tdLog.info("================= step1") + tdDnodes.stop(1) + tdDnodes.deploy(1,cfg) + tdDnodes.start(1) + + tdSql.execute("create database db") + tdSql.execute("create table db.tb (ts timestamp, f1 int)") + + tdDnodes.stop(1) + tdDnodes.cfg(1, 'dataDir', '/mnt/data2 1 0') + tdSql.createDir('/mnt/data2') + tdDnodes.start(1) + + tdSql.execute("insert into db.tb values('2015-1-1', 1);") + tdSql.execute("alter database db keep 365,3650,3650") + + tdDnodes.stop(1) + + tdLog.info("================= step2") + tdSql.haveFile('/mnt/data2',1) + + + def stop(self): + tdSql.close() + os.system("rm -rf /mnt/data1") + os.system("rm -rf /mnt/data2") + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tsdb/delete.py b/tests/pytest/tsdb/delete.py index 402ba888b858161191556fa7237b4425a5fc92af..e81dc2cdd42ded99aed222b2b8e4c2a41518410e 100644 --- a/tests/pytest/tsdb/delete.py +++ b/tests/pytest/tsdb/delete.py @@ -80,10 +80,16 @@ class TDTestCase: def create_tables(self): # super table tdSql.execute("create table st(ts timestamp, i1 int) tags(area int)") + # test delete empty super table + tdSql.execute("delete from st") + # child table for i in range(10): sql = "create table t%d using st tags(%d)"%(i, i) tdSql.execute(sql) + + # test delete empty table + tdSql.execute("delete from t0") return