diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 1a9b05ed34eb787ba6594c99f2fdf7c3f3b81945..0c310439bb0904da9252cb1c29e1652472f60df7 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -130,8 +130,15 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe int code = TSDB_CODE_SUCCESS; STableCfg *pCfg = tsdbCreateTableCfgFromMsg((SMDCreateTableMsg *)pCont); - if (pCfg == NULL) return terrno; - if (tsdbCreateTable(pVnode->tsdb, pCfg) < 0) code = terrno; + if (pCfg == NULL) { + ASSERT(terrno != 0); + return terrno; + } + + if (tsdbCreateTable(pVnode->tsdb, pCfg) < 0) { + code = terrno; + ASSERT(code != 0); + } tsdbClearTableCfg(pCfg); return code; diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index ffab39d41c0170074687684c23dfdc9f57322d44..c75316de8136aab2a54b6b638d994ca801014a6b 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -31,16 +31,16 @@ IF (TD_LINUX) #add_executable(createTablePerformance createTablePerformance.c) #target_link_libraries(createTablePerformance taos_static tutil common pthread) - #add_executable(createNormalTable createNormalTable.c) - #target_link_libraries(createNormalTable taos_static tutil common pthread) + add_executable(createNormalTable createNormalTable.c) + target_link_libraries(createNormalTable taos_static tutil common pthread) #add_executable(queryPerformance queryPerformance.c) #target_link_libraries(queryPerformance taos_static tutil common pthread) - add_executable(httpTest httpTest.c) - target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + #add_executable(httpTest httpTest.c) + #target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) - add_executable(cacheTest cacheTest.c) - target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + #add_executable(cacheTest cacheTest.c) + #target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) ENDIF() diff --git a/tests/test/c/createNormalTable.c b/tests/test/c/createNormalTable.c index 18a648b9e18a9bcc76a273aea4059fb2ce9f7364..60253e2add1ebaa1e6c2c00b073cf13672789346 100644 --- a/tests/test/c/createNormalTable.c +++ b/tests/test/c/createNormalTable.c @@ -50,7 +50,9 @@ void createDbAndSTable(); int main(int argc, char *argv[]) { shellParseArgument(argc, argv); taos_init(); - createDbAndSTable(); + if (replica != 0) { + createDbAndSTable(); + } pPrint("%d threads are spawned to create table", numOfThreads); @@ -134,14 +136,31 @@ void *threadFunc(void *param) { int64_t startMs = taosGetTimestampMs(); - for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { - sprintf(qstr, "create table %s%d (ts timestamp, i int)", stableName, t); - TAOS_RES *pSql = taos_query(con, qstr); - code = taos_errno(pSql); - if (code != 0) { - pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + if (replica != 0) { + for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "create table %s%d (ts timestamp, i int)", stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + } + taos_free_result(pSql); + } + } else { + for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "insert into %s%d values(now, 1)", stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + if (code != TSDB_CODE_MND_INVALID_TABLE_NAME) { + pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + } + if (code == TSDB_CODE_VND_INVALID_VGROUP_ID) { + exit(0); + } + } + taos_free_result(pSql); } - taos_free_result(pSql); } float createTableSpeed = 0;