Merge branch '3.0' of https://github.com/taosdata/TDengine into feat/TS-4994-3.0

This commit is contained in:
Hongze Cheng 2024-11-28 14:50:10 +08:00
commit 544447c724
10 changed files with 331 additions and 32 deletions

View File

@ -233,7 +233,7 @@ int32_t smlBuildSuperTableInfo(SSmlHandle *info, SSmlLineInfo *currElement, SSml
goto END; goto END;
} }
SML_CHECK_CODE(smlBuildSTableMeta(info->dataFormat, sMeta)); SML_CHECK_CODE(smlBuildSTableMeta(info->dataFormat, sMeta));
for (int i = 1; i < pTableMeta->tableInfo.numOfTags + pTableMeta->tableInfo.numOfColumns; i++) { for (int i = 0; i < pTableMeta->tableInfo.numOfTags + pTableMeta->tableInfo.numOfColumns; i++) {
SSchema *col = pTableMeta->schema + i; SSchema *col = pTableMeta->schema + i;
SSmlKv kv = {.key = col->name, .keyLen = strlen(col->name), .type = col->type}; SSmlKv kv = {.key = col->name, .keyLen = strlen(col->name), .type = col->type};
if (col->type == TSDB_DATA_TYPE_NCHAR) { if (col->type == TSDB_DATA_TYPE_NCHAR) {
@ -772,22 +772,26 @@ END:
RETURN RETURN
} }
static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols, bool isTag) { static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols) {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0; int32_t lino = 0;
SHashObj *hashTmp = taosHashInit(length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); SHashObj *hashTmp = taosHashInit(length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
SML_CHECK_NULL(hashTmp); SML_CHECK_NULL(hashTmp);
int32_t i = 0; for (int32_t i = 0; i < length; i++) {
for (; i < length; i++) { SML_CHECK_CODE(taosHashPut(hashTmp, schema[i].name, strlen(schema[i].name), &schema[i], sizeof(SSchema)));
SML_CHECK_CODE(taosHashPut(hashTmp, schema[i].name, strlen(schema[i].name), &i, SHORT_BYTES));
} }
i = isTag ? 0 : 1; for (int32_t i = 0; i < taosArrayGetSize(cols); i++) {
for (; i < taosArrayGetSize(cols); i++) {
SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, i); SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, i);
SML_CHECK_NULL(kv); SML_CHECK_NULL(kv);
if (taosHashGet(hashTmp, kv->key, kv->keyLen) == NULL) { SSchema *sTmp = taosHashGet(hashTmp, kv->key, kv->keyLen);
if (sTmp == NULL) {
SML_CHECK_CODE(TSDB_CODE_SML_INVALID_DATA); SML_CHECK_CODE(TSDB_CODE_SML_INVALID_DATA);
} }
if ((IS_VAR_DATA_TYPE(kv->type) && kv->length + VARSTR_HEADER_SIZE > sTmp->bytes)){
uError("column %s (type %s) bytes invalid. db bytes:%d, kv bytes:%zu", sTmp->name,
tDataTypes[sTmp->type].name, sTmp->bytes, kv->length);
SML_CHECK_CODE(TSDB_CODE_INTERNAL_ERROR);
}
} }
END: END:
@ -1132,8 +1136,8 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
} }
if (needCheckMeta) { if (needCheckMeta) {
SML_CHECK_CODE(smlCheckMeta(&(pTableMeta->schema[pTableMeta->tableInfo.numOfColumns]), pTableMeta->tableInfo.numOfTags, sTableData->tags, true)); SML_CHECK_CODE(smlCheckMeta(&(pTableMeta->schema[pTableMeta->tableInfo.numOfColumns]), pTableMeta->tableInfo.numOfTags, sTableData->tags));
SML_CHECK_CODE(smlCheckMeta(&(pTableMeta->schema[0]), pTableMeta->tableInfo.numOfColumns, sTableData->cols, false)); SML_CHECK_CODE(smlCheckMeta(&(pTableMeta->schema[0]), pTableMeta->tableInfo.numOfColumns, sTableData->cols));
} }
taosMemoryFreeClear(sTableData->tableMeta); taosMemoryFreeClear(sTableData->tableMeta);

View File

@ -1239,6 +1239,7 @@ static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *p
mndTransSetDbName(pTrans, pOld->name, NULL); mndTransSetDbName(pTrans, pOld->name, NULL);
TAOS_CHECK_GOTO(mndTransCheckConflict(pMnode, pTrans), NULL, _OVER); TAOS_CHECK_GOTO(mndTransCheckConflict(pMnode, pTrans), NULL, _OVER);
TAOS_CHECK_GOTO(mndTransCheckConflictWithCompact(pMnode, pTrans), NULL, _OVER);
TAOS_CHECK_GOTO(mndSetAlterDbPrepareLogs(pMnode, pTrans, pOld, pNew), NULL, _OVER); TAOS_CHECK_GOTO(mndSetAlterDbPrepareLogs(pMnode, pTrans, pOld, pNew), NULL, _OVER);
TAOS_CHECK_GOTO(mndSetAlterDbCommitLogs(pMnode, pTrans, pOld, pNew), NULL, _OVER); TAOS_CHECK_GOTO(mndSetAlterDbCommitLogs(pMnode, pTrans, pOld, pNew), NULL, _OVER);

View File

@ -867,6 +867,7 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
if (pIter == NULL) break; if (pIter == NULL) break;
if (pNew->conflict == TRN_CONFLICT_GLOBAL) conflict = true; if (pNew->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
if (pNew->conflict == TRN_CONFLICT_DB) { if (pNew->conflict == TRN_CONFLICT_DB) {
if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true; if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) { if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) {
@ -874,6 +875,7 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
mndTransLogConflict(pNew, pTrans, mndCheckStbConflict(pNew->stbname, pTrans), &conflict); mndTransLogConflict(pNew, pTrans, mndCheckStbConflict(pNew->stbname, pTrans), &conflict);
} }
} }
if (pNew->conflict == TRN_CONFLICT_DB_INSIDE) { if (pNew->conflict == TRN_CONFLICT_DB_INSIDE) {
if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true; if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
if (pTrans->conflict == TRN_CONFLICT_DB) { if (pTrans->conflict == TRN_CONFLICT_DB) {
@ -885,22 +887,6 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
} }
} }
// if (pNew->conflict == TRN_CONFLICT_TOPIC) {
// if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
// if (pTrans->conflict == TRN_CONFLICT_TOPIC || pTrans->conflict == TRN_CONFLICT_TOPIC_INSIDE) {
// if (strcasecmp(pNew->dbname, pTrans->dbname) == 0) conflict = true;
// }
// }
// if (pNew->conflict == TRN_CONFLICT_TOPIC_INSIDE) {
// if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
// if (pTrans->conflict == TRN_CONFLICT_TOPIC) {
// if (strcasecmp(pNew->dbname, pTrans->dbname) == 0) conflict = true;
// }
// if (pTrans->conflict == TRN_CONFLICT_TOPIC_INSIDE) {
// if (strcasecmp(pNew->dbname, pTrans->dbname) == 0 && strcasecmp(pNew->stbname, pTrans->stbname) == 0)
// conflict = true;
// }
// }
if (pNew->conflict == TRN_CONFLICT_ARBGROUP) { if (pNew->conflict == TRN_CONFLICT_ARBGROUP) {
if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true; if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
if (pTrans->conflict == TRN_CONFLICT_ARBGROUP) { if (pTrans->conflict == TRN_CONFLICT_ARBGROUP) {
@ -963,8 +949,10 @@ int32_t mndTransCheckConflictWithCompact(SMnode *pMnode, STrans *pTrans) {
pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT, pIter, (void **)&pCompact); pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT, pIter, (void **)&pCompact);
if (pIter == NULL) break; if (pIter == NULL) break;
if (pTrans->conflict == TRN_CONFLICT_GLOBAL || pTrans->conflict == TRN_CONFLICT_DB || if (pTrans->conflict == TRN_CONFLICT_GLOBAL) {
pTrans->conflict == TRN_CONFLICT_DB_INSIDE) { thisConflict = true;
}
if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) {
if (strcasecmp(pTrans->dbname, pCompact->dbname) == 0) thisConflict = true; if (strcasecmp(pTrans->dbname, pCompact->dbname) == 0) thisConflict = true;
} }

View File

@ -3193,6 +3193,7 @@ int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgro
mInfo("trans:%d, used to split vgroup, vgId:%d", pTrans->id, pVgroup->vgId); mInfo("trans:%d, used to split vgroup, vgId:%d", pTrans->id, pVgroup->vgId);
mndTransSetDbName(pTrans, pDb->name, NULL); mndTransSetDbName(pTrans, pDb->name, NULL);
TAOS_CHECK_GOTO(mndTransCheckConflictWithCompact(pMnode, pTrans), NULL, _OVER);
SVgObj newVg1 = {0}; SVgObj newVg1 = {0};
memcpy(&newVg1, pVgroup, sizeof(SVgObj)); memcpy(&newVg1, pVgroup, sizeof(SVgObj));
@ -3441,6 +3442,8 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) {
} }
mndTransSetSerial(pTrans); mndTransSetSerial(pTrans);
mInfo("trans:%d, used to balance vgroup", pTrans->id); mInfo("trans:%d, used to balance vgroup", pTrans->id);
TAOS_CHECK_GOTO(mndTransCheckConflict(pMnode, pTrans), NULL, _OVER);
TAOS_CHECK_GOTO(mndTransCheckConflictWithCompact(pMnode, pTrans), NULL, _OVER);
while (1) { while (1) {
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes); taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);

View File

@ -97,6 +97,11 @@ class TDTestCase(TBase):
self.alterReplica(1) self.alterReplica(1)
self.checkAggCorrect() self.checkAggCorrect()
self.compactDb() self.compactDb()
if self.waitCompactsZero() is False:
tdLog.exit(f"compact not finished")
return False
self.alterReplica3() self.alterReplica3()
vgids = self.getVGroup(self.db) vgids = self.getVGroup(self.db)

View File

@ -283,6 +283,18 @@ class TBase:
time.sleep(interval) time.sleep(interval)
return False return False
def waitCompactsZero(self, seconds = 300, interval = 1):
# wait end
for i in range(seconds):
sql ="show compacts;"
rows = tdSql.query(sql)
if rows == 0:
tdLog.info("compacts count became zero.")
return True
#tdLog.info(f"i={i} wait ...")
time.sleep(interval)
return False
# check file exist # check file exist
def checkFileExist(self, pathFile): def checkFileExist(self, pathFile):

View File

@ -753,6 +753,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py -N 4 -M 1 ,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py -N 4 -M 1
,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py -N 4 -M 1 ,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py -N 4 -M 1
,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py -N 4 -M 1 ,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py -N 4 -M 1
,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/compactDBConflict.py -N 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/between.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/between.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/distinct.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/distinct.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/varchar.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/varchar.py -Q 2

View File

@ -14,7 +14,7 @@ sys.path.append("./7-tmq")
from tmqCommon import * from tmqCommon import *
class TDTestCase: class TDTestCase:
updatecfgDict = {'clientCfg': {'smlChildTableName': 'dataModelName', 'fqdn': 'localhost', 'smlTsDefaultName': "times"}, 'fqdn': 'localhost'} updatecfgDict = {'clientCfg': {'smlChildTableName': 'dataModelName', 'fqdn': 'localhost'}, 'fqdn': 'localhost'}
print("===================: ", updatecfgDict) print("===================: ", updatecfgDict)
def init(self, conn, logSql, replicaVar=1): def init(self, conn, logSql, replicaVar=1):
@ -58,7 +58,7 @@ class TDTestCase:
tdSql.query(f"select distinct tbname from {dbname}.readings") tdSql.query(f"select distinct tbname from {dbname}.readings")
tdSql.checkRows(4) tdSql.checkRows(4)
tdSql.query(f"select * from {dbname}.t_0799064f5487946e5d22164a822acfc8 order by times") tdSql.query(f"select * from {dbname}.t_0799064f5487946e5d22164a822acfc8 order by _ts")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 3, "kk") tdSql.checkData(0, 3, "kk")
tdSql.checkData(1, 3, "") tdSql.checkData(1, 3, "")
@ -67,7 +67,7 @@ class TDTestCase:
tdSql.query(f"select distinct tbname from {dbname}.`sys_if_bytes_out`") tdSql.query(f"select distinct tbname from {dbname}.`sys_if_bytes_out`")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query(f"select * from {dbname}.t_f67972b49aa8adf8bca5d0d54f0d850d order by times") tdSql.query(f"select * from {dbname}.t_f67972b49aa8adf8bca5d0d54f0d850d order by _ts")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 1, 1.300000000) tdSql.checkData(0, 1, 1.300000000)
tdSql.checkData(1, 1, 13.000000000) tdSql.checkData(1, 1, 13.000000000)
@ -80,7 +80,7 @@ class TDTestCase:
tdSql.query(f"select distinct tbname from {dbname}.`sys_cpu_nice`") tdSql.query(f"select distinct tbname from {dbname}.`sys_cpu_nice`")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.query(f"select * from {dbname}.`sys_cpu_nice` order by times") tdSql.query(f"select * from {dbname}.`sys_cpu_nice` order by _ts")
tdSql.checkRows(4) tdSql.checkRows(4)
tdSql.checkData(0, 1, 13.000000000) tdSql.checkData(0, 1, 13.000000000)
tdSql.checkData(0, 2, "web01") tdSql.checkData(0, 2, "web01")

View File

@ -0,0 +1,204 @@
###################################################################
# 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 -*-
from util.log import *
from util.cases import *
from util.dnodes import *
from util.sql import *
from util.common import tdCom
import threading
class TDTestCase:
def init(self, conn, logSql, replicaVar=1):
tdLog.debug(f"start to init {__file__}")
self.replicaVar = int(replicaVar)
tdSql.init(conn.cursor(), logSql) # output sql.txt file
def run(self):
tdLog.debug(f"start to excute {__file__}")
tdSql.execute('CREATE DATABASE db vgroups 4 replica 1;')
tdSql.execute('use db;')
tdLog.debug("start test1")
event = threading.Event()
newTdSql=tdCom.newTdSql()
t0 = threading.Thread(target=self.compactDBThread, args=('', event, newTdSql))
t0.start()
tdLog.info("t0 threading started,wait compact db tran start")
event.wait()
tdSql.error('ALTER DATABASE db REPLICA 3;', expectErrInfo="Transaction not completed due to conflict with compact")
tdLog.info("wait compact db finish")
t0.join()
tdLog.debug("start test2")
event1 = threading.Event()
newTdSql1=tdCom.newTdSql()
t1 = threading.Thread(target=self.compactDBThread, args=('', event1, newTdSql1))
t1.start()
tdLog.info("t1 threading started,wait compact db tran start")
event1.wait()
tdSql.error('REDISTRIBUTE VGROUP 5 DNODE 1;', expectErrInfo="Transaction not completed due to conflict with compact")
tdLog.info("wait compact db finish")
t1.join()
tdLog.debug("start test3")
event2 = threading.Event()
newTdSql2=tdCom.newTdSql()
t2 = threading.Thread(target=self.compactDBThread, args=('', event2, newTdSql2))
t2.start()
tdLog.info("t2 threading started,wait compact db tran start")
event2.wait()
rowLen = tdSql.query('show vgroups')
if rowLen > 0:
vgroupId = tdSql.getData(0, 0)
tdLog.info(f"split Vgroup vgroupId:{vgroupId} start")
tdSql.error(f"split vgroup {vgroupId}", expectErrInfo="Transaction not completed due to conflict with compact")
else:
tdLog.exit("get vgroupId fail!")
tdLog.info("wait compact db finish")
t2.join()
tdLog.debug("start test4")
event3 = threading.Event()
newTdSql3=tdCom.newTdSql()
t3 = threading.Thread(target=self.compactDBThread, args=('', event3, newTdSql3))
t3.start()
tdLog.info("t3 threading started!!!!!")
event3.wait()
tdSql.error('BALANCE VGROUP;', expectErrInfo="Transaction not completed due to conflict with compact")
t3.join()
tdLog.debug("start test5")
newTdSql4=tdCom.newTdSql()
t4 = threading.Thread(target=self.splitVgroupThread, args=('', newTdSql4))
t4.start()
tdLog.info("t4 threading started!!!!!")
time.sleep(1)
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
t4.join()
tdLog.debug("start test6")
newTdSql5=tdCom.newTdSql()
t5 = threading.Thread(target=self.RedistributeVGroups, args=('', newTdSql5))
t5.start()
tdLog.info("t5 threading started!!!!!")
time.sleep(1)
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
t5.join()
tdLog.debug("start test7")
newTdSql6=tdCom.newTdSql()
t6 = threading.Thread(target=self.balanceVGROUPThread, args=('', newTdSql6))
t6.start()
tdLog.info("t6 threading started!!!!!")
time.sleep(1)
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
t6.join()
tdLog.debug("start test8")
newTdSql7=tdCom.newTdSql()
t7 = threading.Thread(target=self.alterDBThread, args=('', newTdSql7))
t7.start()
tdLog.info("t7 threading started!!!!!")
time.sleep(1)
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
t7.join()
def compactDBThread(self, p, event, newtdSql):
tdLog.info("compact db start")
newtdSql.execute('compact DATABASE db')
event.set()
if self.waitCompactsZero(atdSql=newtdSql) is False:
tdLog.info(f"compact not finished")
def alterDBThread(self, p, newtdSql):
tdLog.info("alter db start")
newtdSql.execute('ALTER DATABASE db REPLICA 3')
if self.waitTransactionZero(atdSql=newtdSql) is False:
tdLog.info(f"transaction not finished")
def balanceVGROUPThread(self, p, newtdSql):
tdLog.info("balance VGROUP start")
newtdSql.execute('BALANCE VGROUP')
if self.waitTransactionZero(atdSql=newtdSql) is False:
tdLog.info(f"transaction not finished")
def RedistributeVGroups(self, p, newtdSql):
tdLog.info("REDISTRIBUTE VGROUP start")
sql = f"REDISTRIBUTE VGROUP 5 DNODE 1"
newtdSql.execute(sql, show=True)
if self.waitTransactionZero(atdSql=newtdSql) is False:
tdLog.exit(f"{sql} transaction not finished")
return False
sql = f"REDISTRIBUTE VGROUP 4 DNODE 1"
newtdSql.execute(sql, show=True)
if self.waitTransactionZero(atdSql=newtdSql) is False:
tdLog.exit(f"{sql} transaction not finished")
return False
sql = f"REDISTRIBUTE VGROUP 3 DNODE 1"
newtdSql.execute(sql, show=True)
if self.waitTransactionZero(atdSql=newtdSql) is False:
tdLog.exit(f"{sql} transaction not finished")
return False
return True
def splitVgroupThread(self, p, newtdSql):
newtdSql.execute(f"use db;")
rowLen = newtdSql.query('show vgroups')
if rowLen > 0:
vgroupId = newtdSql.getData(0, 0)
tdLog.info(f"splitVgroupThread vgroupId:{vgroupId} start")
newtdSql.execute(f"split vgroup {vgroupId}")
else:
tdLog.exit("get vgroupId fail!")
if self.waitTransactionZero(atdSql=newtdSql) is False:
tdLog.info(f"transaction not finished")
def waitTransactionZero(self, atdSql, seconds = 300, interval = 1):
# wait end
for i in range(seconds):
sql ="show transactions;"
rows = atdSql.query(sql)
if rows == 0:
tdLog.info("transaction count became zero.")
return True
#tdLog.info(f"i={i} wait ...")
time.sleep(interval)
return False
def waitCompactsZero(self, atdSql, seconds = 300, interval = 1):
# wait end
for i in range(seconds):
sql ="show compacts;"
rows = atdSql.query(sql)
if rows == 0:
tdLog.info("compacts count became zero.")
return True
#tdLog.info(f"i={i} wait ...")
time.sleep(interval)
return False
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -2253,6 +2253,83 @@ int sml_ts5528_test(){
return 0; return 0;
} }
int sml_td33048_Test() {
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
TAOS_RES *pRes = taos_query(taos, "drop database if exists td33048");
taos_free_result(pRes);
pRes = taos_query(taos, "create database if not exists td33048");
taos_free_result(pRes);
// check column name duplication
const char *sql[] = {
"alarm_record,tag=alarm_record uid=\"3+8001+c939604c\",deviceId=\"3\",alarmId=\"8001\",alarmStatus=\"false\",lotNo=\"2411A0302\",subMode=\"11\",occurTime=\"2024-11-25 09:31:52.702\" 1732527117484",
};
pRes = taos_query(taos, "use td33048");
taos_free_result(pRes);
pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL,
TSDB_SML_TIMESTAMP_MILLI_SECONDS);
int code = taos_errno(pRes);
printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes));
ASSERT(code == 0);
taos_free_result(pRes);
// check tag name duplication
const char *sql1[] = {
"alarm_record,tag=alarm_record uid=\"2+100012+303fe9b5\",deviceId=\"2\",alarmId=\"100012\",alarmStatus=\"false\",lotNo=\"2411A0202\",subMode=\"11\",occurTime=\"2024-11-25 09:31:55.591\" 1732527119493",
};
pRes = taos_schemaless_insert(taos, (char **)sql1, sizeof(sql1) / sizeof(sql1[0]), TSDB_SML_LINE_PROTOCOL,
TSDB_SML_TIMESTAMP_MILLI_SECONDS);
code = taos_errno(pRes);
printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes));
ASSERT(code == 0);
taos_free_result(pRes);
pRes = taos_query(taos, "select * from alarm_record");
code = taos_errno(pRes);
printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes));
ASSERT(code == 0);
taos_free_result(pRes);
taos_close(taos);
return code;
}
int sml_td17324_Test() {
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
TAOS_RES *pRes = taos_query(taos, "drop database if exists gcbacaefqk");
taos_free_result(pRes);
pRes = taos_query(taos, "create database if not exists gcbacaefqk PRECISION 'ns'");
taos_free_result(pRes);
pRes = taos_query(taos, "use gcbacaefqk");
taos_free_result(pRes);
pRes = taos_query(taos, "create stable gcbacaefqk.test_stb(_ts timestamp, f int) tags(t1 bigint)");
taos_free_result(pRes);
// check column name duplication
const char *sql[] = {
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1732700000364000000",
"st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1732700000361000000",
"test_stb,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1732700000364316532"
};
pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL,
TSDB_SML_TIMESTAMP_NANO_SECONDS);
int code = taos_errno(pRes);
printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes));
ASSERT(code == 0);
taos_free_result(pRes);
taos_close(taos);
return code;
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if (argc == 2) { if (argc == 2) {
taos_options(TSDB_OPTION_CONFIGDIR, argv[1]); taos_options(TSDB_OPTION_CONFIGDIR, argv[1]);
@ -2262,6 +2339,10 @@ int main(int argc, char *argv[]) {
ASSERT(!ret); ASSERT(!ret);
ret = sml_ts5528_test(); ret = sml_ts5528_test();
ASSERT(!ret); ASSERT(!ret);
ret = sml_td33048_Test();
ASSERT(!ret);
ret = sml_td17324_Test();
ASSERT(!ret);
ret = sml_td29691_Test(); ret = sml_td29691_Test();
ASSERT(ret); ASSERT(ret);
ret = sml_td29373_Test(); ret = sml_td29373_Test();