From 0f78a600cbc77054ae4563020150cbdc8afc2c14 Mon Sep 17 00:00:00 2001 From: jiacy-jcy <714897623@qq.com> Date: Fri, 16 Sep 2022 10:22:11 +0800 Subject: [PATCH 1/9] test:add test case for param ttl --- tests/system-test/1-insert/table_param_ttl.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/system-test/1-insert/table_param_ttl.py b/tests/system-test/1-insert/table_param_ttl.py index 5ef6548789..f5fc2d627b 100644 --- a/tests/system-test/1-insert/table_param_ttl.py +++ b/tests/system-test/1-insert/table_param_ttl.py @@ -67,9 +67,21 @@ class TDTestCase: tdSql.checkRows(self.tbnum - int(self.tbnum/2)) tdSql.execute('drop database db') + def ttl_check_insert(self): + tdSql.prepare() + tdSql.execute(f'create table {self.stbname} (ts timestamp,c0 int) tags(t0 int)') + for i in range(self.tbnum): + tdSql.execute(f'insert into {self.stbname}_{i} using {self.stbname} tags({i}) ttl {self.ttl_param} values(now,1)') + tdSql.query(f'show tables') + tdSql.checkRows(self.tbnum) + sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval']) + tdSql.query(f'show tables') + tdSql.checkRows(0) + tdSql.execute('drop database db') def run(self): self.ttl_check_ntb() self.ttl_check_ctb() + self.ttl_check_insert() def stop(self): tdSql.close() From 30b2bd98b8b88c298bf65f6a2b65adeb57c54671 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 19 Sep 2022 10:39:51 +0800 Subject: [PATCH 2/9] fix: STrans struct dbname2 naming ambiguity --- source/dnode/mnode/impl/inc/mndDef.h | 4 +- source/dnode/mnode/impl/inc/mndTrans.h | 2 +- source/dnode/mnode/impl/src/mndStream.c | 2 +- source/dnode/mnode/impl/src/mndTrans.c | 64 ++++++++++++------------- utils/test/c/sdbDump.c | 4 +- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index cd08ee4ad5..a9723abacc 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -165,8 +165,8 @@ typedef struct { SEpSet lastEpset; tmsg_t lastMsgType; tmsg_t originRpcType; - char dbname1[TSDB_TABLE_FNAME_LEN]; - char dbname2[TSDB_TABLE_FNAME_LEN]; + char dbname[TSDB_TABLE_FNAME_LEN]; + char stbname[TSDB_TABLE_FNAME_LEN]; int32_t startFunc; int32_t stopFunc; int32_t paramLen; diff --git a/source/dnode/mnode/impl/inc/mndTrans.h b/source/dnode/mnode/impl/inc/mndTrans.h index faf656a251..36d056a941 100644 --- a/source/dnode/mnode/impl/inc/mndTrans.h +++ b/source/dnode/mnode/impl/inc/mndTrans.h @@ -71,7 +71,7 @@ int32_t mndTransAppendRedoAction(STrans *pTrans, STransAction *pAction); int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction); void mndTransSetRpcRsp(STrans *pTrans, void *pCont, int32_t contLen); void mndTransSetCb(STrans *pTrans, ETrnFunc startFunc, ETrnFunc stopFunc, void *param, int32_t paramLen); -void mndTransSetDbName(STrans *pTrans, const char *dbname1, const char *dbname2); +void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname); void mndTransSetSerial(STrans *pTrans); void mndTransSetOper(STrans *pTrans, EOperType oper); diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index dd7a9e71ea..515d5987b9 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -671,7 +671,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr()); goto _OVER; } - mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb); + mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb); // hack way mDebug("trans:%d, used to create stream:%s", pTrans->id, createStreamReq.name); // create stb for stream diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 030f4542b9..8d42cdcfd6 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -127,8 +127,8 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { SDB_SET_INT8(pRaw, dataPos, 0, _OVER) SDB_SET_INT16(pRaw, dataPos, pTrans->originRpcType, _OVER) SDB_SET_INT64(pRaw, dataPos, pTrans->createdTime, _OVER) - SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_TABLE_FNAME_LEN, _OVER) - SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pTrans->stbname, TSDB_TABLE_FNAME_LEN, _OVER) SDB_SET_INT32(pRaw, dataPos, pTrans->redoActionPos, _OVER) int32_t redoActionNum = taosArrayGetSize(pTrans->redoActions); @@ -289,8 +289,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { pTrans->oper = oper; SDB_GET_INT16(pRaw, dataPos, &pTrans->originRpcType, _OVER) SDB_GET_INT64(pRaw, dataPos, &pTrans->createdTime, _OVER) - SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_TABLE_FNAME_LEN, _OVER) - SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pTrans->stbname, TSDB_TABLE_FNAME_LEN, _OVER) SDB_GET_INT32(pRaw, dataPos, &pTrans->redoActionPos, _OVER) SDB_GET_INT32(pRaw, dataPos, &redoActionNum, _OVER) SDB_GET_INT32(pRaw, dataPos, &undoActionNum, _OVER) @@ -706,7 +706,7 @@ int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, c if (pIter == NULL) break; if (pTrans->oper == oper) { - if (strcasecmp(dbname, pTrans->dbname1) == 0) { + if (strcasecmp(dbname, pTrans->dbname) == 0) { mInfo("trans:%d, db:%s oper:%d matched with input", pTrans->id, dbname, oper); if (pTrans->pRpcArray == NULL) { pTrans->pRpcArray = taosArrayInit(1, sizeof(SRpcHandleInfo)); @@ -725,12 +725,12 @@ int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, c return code; } -void mndTransSetDbName(STrans *pTrans, const char *dbname1, const char *dbname2) { - if (dbname1 != NULL) { - tstrncpy(pTrans->dbname1, dbname1, TSDB_TABLE_FNAME_LEN); +void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname) { + if (dbname != NULL) { + tstrncpy(pTrans->dbname, dbname, TSDB_TABLE_FNAME_LEN); } - if (dbname2 != NULL) { - tstrncpy(pTrans->dbname2, dbname2, TSDB_TABLE_FNAME_LEN); + if (stbname != NULL) { + tstrncpy(pTrans->stbname, stbname, TSDB_TABLE_FNAME_LEN); } } @@ -759,9 +759,9 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) { return 0; } -static bool mndCheckDbConflict(const char *db, STrans *pTrans) { - if (db[0] == 0) return false; - if (strcasecmp(db, pTrans->dbname1) == 0 || strcasecmp(db, pTrans->dbname2) == 0) return true; +static bool mndCheckDbConflict(const char *conflict, STrans *pTrans) { + if (conflict[0] == 0) return false; + if (strcasecmp(conflict, pTrans->dbname) == 0 || strcasecmp(conflict, pTrans->stbname) == 0) return true; return false; } @@ -780,28 +780,28 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) { if (pNew->conflict == TRN_CONFLICT_DB) { if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true; if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) { - if (mndCheckDbConflict(pNew->dbname1, pTrans)) conflict = true; - if (mndCheckDbConflict(pNew->dbname2, pTrans)) conflict = true; + if (mndCheckDbConflict(pNew->dbname, pTrans)) conflict = true; + if (mndCheckDbConflict(pNew->stbname, pTrans)) conflict = true; } } if (pNew->conflict == TRN_CONFLICT_DB_INSIDE) { if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true; if (pTrans->conflict == TRN_CONFLICT_DB) { - if (mndCheckDbConflict(pNew->dbname1, pTrans)) conflict = true; - if (mndCheckDbConflict(pNew->dbname2, pTrans)) conflict = true; + if (mndCheckDbConflict(pNew->dbname, pTrans)) conflict = true; + if (mndCheckDbConflict(pNew->stbname, pTrans)) conflict = true; } if (pTrans->conflict == TRN_CONFLICT_DB_INSIDE) { - if (mndCheckDbConflict(pNew->dbname2, pTrans)) conflict = true; // for stb + if (mndCheckDbConflict(pNew->stbname, pTrans)) conflict = true; // for stb } } if (conflict) { - mError("trans:%d, db1:%s db2:%s type:%d, can't execute since conflict with trans:%d db1:%s db2:%s type:%d", - pNew->id, pNew->dbname1, pNew->dbname2, pNew->conflict, pTrans->id, pTrans->dbname1, pTrans->dbname2, + mError("trans:%d, db:%s stb:%s type:%d, can't execute since conflict with trans:%d db:%s stb:%s type:%d", + pNew->id, pNew->dbname, pNew->stbname, pNew->conflict, pTrans->id, pTrans->dbname, pTrans->stbname, pTrans->conflict); } else { - mDebug("trans:%d, db1:%s db2:%s type:%d, not conflict with trans:%d db1:%s db2:%s type:%d", pNew->id, - pNew->dbname1, pNew->dbname2, pNew->conflict, pTrans->id, pTrans->dbname1, pTrans->dbname2, + mDebug("trans:%d, db:%s stb:%s type:%d, not conflict with trans:%d db:%s stb:%s type:%d", pNew->id, + pNew->dbname, pNew->stbname, pNew->conflict, pTrans->id, pTrans->dbname, pTrans->stbname, pTrans->conflict); } sdbRelease(pMnode->pSdb, pTrans); @@ -812,7 +812,7 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) { int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) { if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) { - if (strlen(pTrans->dbname1) == 0 && strlen(pTrans->dbname2) == 0) { + if (strlen(pTrans->dbname) == 0 && strlen(pTrans->stbname) == 0) { terrno = TSDB_CODE_MND_TRANS_CONFLICT; mError("trans:%d, failed to prepare conflict db not set", pTrans->id); return -1; @@ -913,12 +913,12 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { if (pTrans->originRpcType == TDMT_MND_CREATE_DB) { mInfo("trans:%d, origin msgtype:%s", pTrans->id, TMSG_INFO(pTrans->originRpcType)); - SDbObj *pDb = mndAcquireDb(pMnode, pTrans->dbname1); + SDbObj *pDb = mndAcquireDb(pMnode, pTrans->dbname); if (pDb != NULL) { for (int32_t j = 0; j < 12; j++) { bool ready = mndIsDbReady(pMnode, pDb); if (!ready) { - mInfo("trans:%d, db:%s not ready yet, wait %d times", pTrans->id, pTrans->dbname1, j); + mInfo("trans:%d, db:%s not ready yet, wait %d times", pTrans->id, pTrans->dbname, j); taosMsleep(1000); } else { break; @@ -929,7 +929,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { } else if (pTrans->originRpcType == TDMT_MND_CREATE_STB) { void *pCont = NULL; int32_t contLen = 0; - if (0 == mndBuildSMCreateStbRsp(pMnode, pTrans->dbname1, pTrans->dbname2, &pCont, &contLen) != 0) { + if (0 == mndBuildSMCreateStbRsp(pMnode, pTrans->dbname, pTrans->stbname, &pCont, &contLen) != 0) { mndTransSetRpcRsp(pTrans, pCont, contLen); } } @@ -1599,15 +1599,15 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)stage, false); - char dbname1[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - STR_WITH_MAXSIZE_TO_VARSTR(dbname1, mndGetDbStr(pTrans->dbname1), pShow->pMeta->pSchemas[cols].bytes); + char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char *)dbname1, false); + colDataAppend(pColInfo, numOfRows, (const char *)dbname, false); - char dbname2[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - STR_WITH_MAXSIZE_TO_VARSTR(dbname2, mndGetDbStr(pTrans->dbname2), pShow->pMeta->pSchemas[cols].bytes); + char stbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(stbname, mndGetDbStr(pTrans->stbname), pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char *)dbname2, false); + colDataAppend(pColInfo, numOfRows, (const char *)stbname, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false); diff --git a/utils/test/c/sdbDump.c b/utils/test/c/sdbDump.c index b90b781e44..b056fe58a3 100644 --- a/utils/test/c/sdbDump.c +++ b/utils/test/c/sdbDump.c @@ -294,8 +294,8 @@ void dumpTrans(SSdb *pSdb, SJson *json) { tjsonAddIntegerToObject(item, "conflict", pObj->conflict); tjsonAddIntegerToObject(item, "exec", pObj->exec); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); - tjsonAddStringToObject(item, "dbname1", pObj->dbname1); - tjsonAddStringToObject(item, "dbname2", pObj->dbname2); + tjsonAddStringToObject(item, "dbname", pObj->dbname); + tjsonAddStringToObject(item, "stbname", pObj->stbname); tjsonAddIntegerToObject(item, "commitLogNum", taosArrayGetSize(pObj->commitActions)); tjsonAddIntegerToObject(item, "redoActionNum", taosArrayGetSize(pObj->redoActions)); tjsonAddIntegerToObject(item, "undoActionNum", taosArrayGetSize(pObj->undoActions)); From 186b3e6086b8ce257d8a51b2372ebac9673e9a35 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 19 Sep 2022 10:41:49 +0800 Subject: [PATCH 3/9] fix: STrans struct dbname2 naming ambiguity --- source/common/src/systable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 496806d877..25abd65b40 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -227,8 +227,8 @@ static const SSysDbTableSchema transSchema[] = { {.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, {.name = "stage", .bytes = TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, - {.name = "db1", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, - {.name = "db2", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "stable", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, {.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, {.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, {.name = "last_action_info", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, From a6db31006f98a1c8c882f7864000a7909930c452 Mon Sep 17 00:00:00 2001 From: Jason-Jia <714897623@qq.com> Date: Mon, 19 Sep 2022 11:23:07 +0800 Subject: [PATCH 4/9] Update table_param_ttl.py --- tests/system-test/1-insert/table_param_ttl.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/system-test/1-insert/table_param_ttl.py b/tests/system-test/1-insert/table_param_ttl.py index f5fc2d627b..dcf8c76b1e 100644 --- a/tests/system-test/1-insert/table_param_ttl.py +++ b/tests/system-test/1-insert/table_param_ttl.py @@ -69,13 +69,13 @@ class TDTestCase: def ttl_check_insert(self): tdSql.prepare() - tdSql.execute(f'create table {self.stbname} (ts timestamp,c0 int) tags(t0 int)') + tdSql.execute(f'create table db.{self.stbname} (ts timestamp,c0 int) tags(t0 int)') for i in range(self.tbnum): - tdSql.execute(f'insert into {self.stbname}_{i} using {self.stbname} tags({i}) ttl {self.ttl_param} values(now,1)') - tdSql.query(f'show tables') + tdSql.execute(f'insert into db.{self.stbname}_{i} using db.{self.stbname} tags({i}) ttl {self.ttl_param} values(now,1)') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum) sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval']) - tdSql.query(f'show tables') + tdSql.query(f'show db.tables') tdSql.checkRows(0) tdSql.execute('drop database db') def run(self): From d5e900ecdb7845b8e87921487f7d80affe1ecf03 Mon Sep 17 00:00:00 2001 From: jiacy-jcy <714897623@qq.com> Date: Mon, 19 Sep 2022 11:27:26 +0800 Subject: [PATCH 5/9] update test case --- tests/system-test/1-insert/table_param_ttl.py | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/system-test/1-insert/table_param_ttl.py b/tests/system-test/1-insert/table_param_ttl.py index f5fc2d627b..21c591b07e 100644 --- a/tests/system-test/1-insert/table_param_ttl.py +++ b/tests/system-test/1-insert/table_param_ttl.py @@ -31,51 +31,51 @@ class TDTestCase: tdSql.prepare() for i in range(self.tbnum): - tdSql.execute(f'create table {self.ntbname}_{i} (ts timestamp,c0 int) ttl {self.ttl_param}') - tdSql.query(f'show tables') + tdSql.execute(f'create table db.{self.ntbname}_{i} (ts timestamp,c0 int) ttl {self.ttl_param}') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum) sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval']) - tdSql.query(f'show tables') + tdSql.query(f'show db.tables') tdSql.checkRows(0) for i in range(self.tbnum): - tdSql.execute(f'create table {self.ntbname}_{i} (ts timestamp,c0 int) ttl {self.default_ttl}') + tdSql.execute(f'create table db.{self.ntbname}_{i} (ts timestamp,c0 int) ttl {self.default_ttl}') for i in range(int(self.tbnum/2)): - tdSql.execute(f'alter table {self.ntbname}_{i} ttl {self.modify_ttl}') + tdSql.execute(f'alter table db.{self.ntbname}_{i} ttl {self.modify_ttl}') sleep(self.updatecfgDict['ttlUnit']*self.modify_ttl+self.updatecfgDict['ttlPushInterval']) - tdSql.query(f'show tables') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum - int(self.tbnum/2)) tdSql.execute('drop database db') def ttl_check_ctb(self): tdSql.prepare() - tdSql.execute(f'create table {self.stbname} (ts timestamp,c0 int) tags(t0 int)') + tdSql.execute(f'create table db.{self.stbname} (ts timestamp,c0 int) tags(t0 int)') for i in range(self.tbnum): - tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({i}) ttl {self.ttl_param}') - tdSql.query(f'show tables') + tdSql.execute(f'create table db.{self.stbname}_{i} using db.{self.stbname} tags({i}) ttl {self.ttl_param}') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum) sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval']) - tdSql.query(f'show tables') + tdSql.query(f'show db.tables') tdSql.checkRows(0) for i in range(self.tbnum): - tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({i}) ttl {self.default_ttl}') - tdSql.query(f'show tables') + tdSql.execute(f'create table db.{self.stbname}_{i} using db.{self.stbname} tags({i}) ttl {self.default_ttl}') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum) for i in range(int(self.tbnum/2)): - tdSql.execute(f'alter table {self.stbname}_{i} ttl {self.modify_ttl}') + tdSql.execute(f'alter table db.{self.stbname}_{i} ttl {self.modify_ttl}') sleep(self.updatecfgDict['ttlUnit']*self.modify_ttl+self.updatecfgDict['ttlPushInterval']) - tdSql.query(f'show tables') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum - int(self.tbnum/2)) tdSql.execute('drop database db') def ttl_check_insert(self): tdSql.prepare() - tdSql.execute(f'create table {self.stbname} (ts timestamp,c0 int) tags(t0 int)') + tdSql.execute(f'create table db.{self.stbname} (ts timestamp,c0 int) tags(t0 int)') for i in range(self.tbnum): - tdSql.execute(f'insert into {self.stbname}_{i} using {self.stbname} tags({i}) ttl {self.ttl_param} values(now,1)') - tdSql.query(f'show tables') + tdSql.execute(f'insert into db.{self.stbname}_{i} using db.{self.stbname} tags({i}) ttl {self.ttl_param} values(now,1)') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum) sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval']) - tdSql.query(f'show tables') + tdSql.query(f'show db.tables') tdSql.checkRows(0) tdSql.execute('drop database db') def run(self): From d0bfa65cc4fecc5be9d12f1db255839cbebd9952 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Mon, 19 Sep 2022 11:54:30 +0800 Subject: [PATCH 6/9] docs: add insert select description --- docs/en/12-taos-sql/05-insert.md | 6 +++++- docs/zh/12-taos-sql/05-insert.md | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/en/12-taos-sql/05-insert.md b/docs/en/12-taos-sql/05-insert.md index e7d56fb3c7..97bfc38c7e 100644 --- a/docs/en/12-taos-sql/05-insert.md +++ b/docs/en/12-taos-sql/05-insert.md @@ -16,6 +16,8 @@ INSERT INTO [(field1_name, ...)] VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path ...]; + +INSERT INTO tb_name [(field1_name, ...)] query ``` **Timestamps** @@ -37,7 +39,7 @@ INSERT INTO 4. The FILE clause inserts tags or data from a comma-separates values (CSV) file. Do not include headers in your CSV files. -5. A single INSERT statement can write data to multiple tables. +5. A single INSERT ... VALUES statement or INSERT ... FILE statement can write data to multiple tables. 6. The INSERT statement is fully parsed before being executed, so that if any element of the statement fails, the entire statement will fail. For example, the following statement will not create a table because the latter part of the statement is invalid: @@ -47,6 +49,8 @@ INSERT INTO 7. However, an INSERT statement that writes data to multiple subtables can succeed for some tables and fail for others. This situation is caused because vnodes perform write operations independently of each other. One vnode failing to write data does not affect the ability of other vnodes to write successfully. +8. Data from TDengine can be inserted into a specified table using the INSERT ... query statement. Arbitrary query statements are supported. This syntax can only be used for subtables and normal tables, and does not support automatic table creation. + ## Insert a Record Single row or multiple rows specified with VALUES can be inserted into a specific table. A single row is inserted using the below statement. diff --git a/docs/zh/12-taos-sql/05-insert.md b/docs/zh/12-taos-sql/05-insert.md index 59af9c55ed..c865bc8022 100644 --- a/docs/zh/12-taos-sql/05-insert.md +++ b/docs/zh/12-taos-sql/05-insert.md @@ -17,6 +17,8 @@ INSERT INTO [(field1_name, ...)] VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path ...]; + +INSERT INTO tb_name [(field1_name, ...)] query ``` **关于时间戳** @@ -38,7 +40,7 @@ INSERT INTO 4. FILE 语法表示数据来自于 CSV 文件(英文逗号分隔、英文单引号括住每个值),CSV 文件无需表头。 -5. 无论使用哪种语法,均可以在一条 INSERT 语句中同时向多个表插入数据。 +5. INSERT ... VALUES 语句和 INSERT ... FILE 语句均可以在一条 INSERT 语句中同时向多个表插入数据。 6. INSERT 语句是完整解析后再执行的,对如下语句,不会再出现数据错误但建表成功的情况: @@ -48,6 +50,8 @@ INSERT INTO 7. 对于向多个子表插入数据的情况,依然会有部分数据写入失败,部分数据写入成功的情况。这是因为多个子表可能分布在不同的 VNODE 上,客户端将 INSERT 语句完整解析后,将数据发往各个涉及的 VNODE 上,每个 VNODE 独立进行写入操作。如果某个 VNODE 因为某些原因(比如网络问题或磁盘故障)导致写入失败,并不会影响其他 VNODE 节点的写入。 +8. 可以使用 INSERT ... query 语句将 TDengine 中的数据插入到指定表中。query 可以是任意的查询语句。此语法只能用于子表和普通表,且不支持自动建表。 + ## 插入一条记录 指定已经创建好的数据子表的表名,并通过 VALUES 关键字提供一行或多行数据,即可向数据库写入这些数据。例如,执行如下语句可以写入一行记录: From 838ab9bddb5ba83d39275f0bb01dd630adcf5d2e Mon Sep 17 00:00:00 2001 From: jiacy-jcy <714897623@qq.com> Date: Mon, 19 Sep 2022 12:45:36 +0800 Subject: [PATCH 7/9] add test case into ci --- tests/system-test/fulltest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 0b45b24258..604add0eb3 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -32,7 +32,7 @@ python3 ./test.py -f 1-insert/block_wise.py python3 ./test.py -f 1-insert/create_retentions.py python3 ./test.py -f 1-insert/table_param_ttl.py python3 ./test.py -f 1-insert/mutil_stage.py - +python3 ./test.py -f 1-insert/table_param_ttl.py -R python3 ./test.py -f 1-insert/update_data_muti_rows.py python3 ./test.py -f 1-insert/db_tb_name_check.py From 23a243230a0d24fdf411079f9a9cc375b9cbfbc1 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Mon, 19 Sep 2022 13:11:05 +0800 Subject: [PATCH 8/9] docs: add insert select description --- docs/en/12-taos-sql/05-insert.md | 6 +++--- docs/zh/12-taos-sql/05-insert.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/12-taos-sql/05-insert.md b/docs/en/12-taos-sql/05-insert.md index 97bfc38c7e..da21896866 100644 --- a/docs/en/12-taos-sql/05-insert.md +++ b/docs/en/12-taos-sql/05-insert.md @@ -17,7 +17,7 @@ INSERT INTO VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path ...]; -INSERT INTO tb_name [(field1_name, ...)] query +INSERT INTO tb_name [(field1_name, ...)] subquery ``` **Timestamps** @@ -39,7 +39,7 @@ INSERT INTO tb_name [(field1_name, ...)] query 4. The FILE clause inserts tags or data from a comma-separates values (CSV) file. Do not include headers in your CSV files. -5. A single INSERT ... VALUES statement or INSERT ... FILE statement can write data to multiple tables. +5. A single `INSERT ... VALUES` statement and `INSERT ... FILE` statement can write data to multiple tables. 6. The INSERT statement is fully parsed before being executed, so that if any element of the statement fails, the entire statement will fail. For example, the following statement will not create a table because the latter part of the statement is invalid: @@ -49,7 +49,7 @@ INSERT INTO tb_name [(field1_name, ...)] query 7. However, an INSERT statement that writes data to multiple subtables can succeed for some tables and fail for others. This situation is caused because vnodes perform write operations independently of each other. One vnode failing to write data does not affect the ability of other vnodes to write successfully. -8. Data from TDengine can be inserted into a specified table using the INSERT ... query statement. Arbitrary query statements are supported. This syntax can only be used for subtables and normal tables, and does not support automatic table creation. +8. Data from TDengine can be inserted into a specified table using the `INSERT ... subquery` statement. Arbitrary query statements are supported. This syntax can only be used for subtables and normal tables, and does not support automatic table creation. ## Insert a Record diff --git a/docs/zh/12-taos-sql/05-insert.md b/docs/zh/12-taos-sql/05-insert.md index c865bc8022..5e64827a8f 100644 --- a/docs/zh/12-taos-sql/05-insert.md +++ b/docs/zh/12-taos-sql/05-insert.md @@ -18,7 +18,7 @@ INSERT INTO VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path ...]; -INSERT INTO tb_name [(field1_name, ...)] query +INSERT INTO tb_name [(field1_name, ...)] subquery ``` **关于时间戳** @@ -40,7 +40,7 @@ INSERT INTO tb_name [(field1_name, ...)] query 4. FILE 语法表示数据来自于 CSV 文件(英文逗号分隔、英文单引号括住每个值),CSV 文件无需表头。 -5. INSERT ... VALUES 语句和 INSERT ... FILE 语句均可以在一条 INSERT 语句中同时向多个表插入数据。 +5. `INSERT ... VALUES` 语句和 `INSERT ... FILE` 语句均可以在一条 INSERT 语句中同时向多个表插入数据。 6. INSERT 语句是完整解析后再执行的,对如下语句,不会再出现数据错误但建表成功的情况: @@ -50,7 +50,7 @@ INSERT INTO tb_name [(field1_name, ...)] query 7. 对于向多个子表插入数据的情况,依然会有部分数据写入失败,部分数据写入成功的情况。这是因为多个子表可能分布在不同的 VNODE 上,客户端将 INSERT 语句完整解析后,将数据发往各个涉及的 VNODE 上,每个 VNODE 独立进行写入操作。如果某个 VNODE 因为某些原因(比如网络问题或磁盘故障)导致写入失败,并不会影响其他 VNODE 节点的写入。 -8. 可以使用 INSERT ... query 语句将 TDengine 中的数据插入到指定表中。query 可以是任意的查询语句。此语法只能用于子表和普通表,且不支持自动建表。 +8. 可以使用 `INSERT ... subquery` 语句将 TDengine 中的数据插入到指定表中。subquery 可以是任意的查询语句。此语法只能用于子表和普通表,且不支持自动建表。 ## 插入一条记录 From 8c48dc4d581ba0a03f58574d5a1faef937b9a89d Mon Sep 17 00:00:00 2001 From: danielclow <106956386+danielclow@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:55:35 +0800 Subject: [PATCH 9/9] doc: update quick start docs for new edition --- docs/en/05-get-started/01-docker.md | 6 +++++- docs/en/05-get-started/03-package.md | 6 +++++- docs/en/05-get-started/index.md | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/en/05-get-started/01-docker.md b/docs/en/05-get-started/01-docker.md index 6191492b37..be61dfeb8e 100644 --- a/docs/en/05-get-started/01-docker.md +++ b/docs/en/05-get-started/01-docker.md @@ -3,7 +3,11 @@ sidebar_label: Docker title: Quick Install on Docker --- -This document describes how to install TDengine in a Docker container and perform queries and inserts. To get started with TDengine in a non-containerized environment, see [Quick Install](../../get-started/package). If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine). +This document describes how to install TDengine in a Docker container and perform queries and inserts. + +- To get started with TDengine in a non-containerized environment, see [Quick Install from Package](../../get-started/package). +- For a fully managed solution, see the [TDengine Cloud documentation](/cloud/). +- If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine). ## Run TDengine diff --git a/docs/en/05-get-started/03-package.md b/docs/en/05-get-started/03-package.md index 292fa82183..da06aca148 100644 --- a/docs/en/05-get-started/03-package.md +++ b/docs/en/05-get-started/03-package.md @@ -7,7 +7,11 @@ import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; import PkgListV3 from "/components/PkgListV3"; -For information about installing TDengine on Docker, see [Quick Install on Docker](../../get-started/docker). If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine). +This document describes how to install TDengine on Linux and Windows and perform queries and inserts. + +- To get started with TDengine on Docker, see [Quick Install on Docker](../../get-started/docker). +- For a fully managed solution, see the [TDengine Cloud documentation](/cloud/). +- If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine). The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface (CLI, taos), and some tools. Note that taosAdapter supports Linux only. In addition to connectors for multiple languages, TDengine also provides a [REST API](../../reference/rest-api) through [taosAdapter](../../reference/taosadapter). diff --git a/docs/en/05-get-started/index.md b/docs/en/05-get-started/index.md index cf475a8cd7..09875362f4 100644 --- a/docs/en/05-get-started/index.md +++ b/docs/en/05-get-started/index.md @@ -3,9 +3,9 @@ title: Get Started description: This article describes how to install TDengine and test its performance. --- -The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface, and some tools. In addition to connectors for multiple languages, TDengine also provides a [RESTful interface](/reference/rest-api) through [taosAdapter](/reference/taosadapter). +You can install and run TDengine on Linux and Windows machines as well as Docker containers. You can also deploy TDengine as a managed service with TDengine Cloud. -You can install and run TDengine on Linux and Windows machines as well as Docker containers. +The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface, and some tools. In addition to connectors for multiple languages, TDengine also provides a [RESTful interface](/reference/rest-api) through [taosAdapter](/reference/taosadapter). ```mdx-code-block import DocCardList from '@theme/DocCardList';