提交 2e12fbfa 编写于 作者: S Shengliang Guan

[TD-705] autoIndex

上级 2586095f
...@@ -463,7 +463,9 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) { ...@@ -463,7 +463,9 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) {
sdbIncRef(pTable, pOper->pObj); sdbIncRef(pTable, pOper->pObj);
atomic_add_fetch_32(&pTable->numOfRows, 1); atomic_add_fetch_32(&pTable->numOfRows, 1);
if (pTable->tableId == SDB_TABLE_ACCOUNT) { if (pTable->keyType == SDB_KEY_AUTO) {
pTable->autoIndex = MAX(pTable->autoIndex, *((uint32_t *)pOper->pObj));
} else {
atomic_add_fetch_32(&pTable->autoIndex, 1); atomic_add_fetch_32(&pTable->autoIndex, 1);
} }
......
...@@ -95,7 +95,7 @@ void createDbAndTable() { ...@@ -95,7 +95,7 @@ void createDbAndTable() {
pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con)); pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con));
exit(0); exit(0);
} }
taos_stop_query(pSql); taos_free_result(pSql);
gettimeofday(&systemTime, NULL); gettimeofday(&systemTime, NULL);
st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; st = systemTime.tv_sec * 1000000 + systemTime.tv_usec;
...@@ -114,7 +114,7 @@ void createDbAndTable() { ...@@ -114,7 +114,7 @@ void createDbAndTable() {
pError("failed to create stable, code:%d reason:%s", taos_errno(con), taos_errstr(con)); pError("failed to create stable, code:%d reason:%s", taos_errno(con), taos_errstr(con));
exit(0); exit(0);
} }
taos_stop_query(pSql); taos_free_result(pSql);
for (int64_t t = 0; t < totalTables; ++t) { for (int64_t t = 0; t < totalTables; ++t) {
sprintf(qstr, "create table if not exists %s%ld using %s tags(%ld)", stableName, t, stableName, t); sprintf(qstr, "create table if not exists %s%ld using %s tags(%ld)", stableName, t, stableName, t);
...@@ -124,7 +124,7 @@ void createDbAndTable() { ...@@ -124,7 +124,7 @@ void createDbAndTable() {
pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con)); pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con));
exit(0); exit(0);
} }
taos_stop_query(pSql); taos_free_result(pSql);
} }
} else { } else {
for (int64_t t = 0; t < totalTables; ++t) { for (int64_t t = 0; t < totalTables; ++t) {
...@@ -140,7 +140,7 @@ void createDbAndTable() { ...@@ -140,7 +140,7 @@ void createDbAndTable() {
pError("failed to create table %s%ld, reason:%s", stableName, t, taos_errstr(con)); pError("failed to create table %s%ld, reason:%s", stableName, t, taos_errstr(con));
exit(0); exit(0);
} }
taos_stop_query(pSql); taos_free_result(pSql);
} }
} }
...@@ -148,6 +148,7 @@ void createDbAndTable() { ...@@ -148,6 +148,7 @@ void createDbAndTable() {
et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; et = systemTime.tv_sec * 1000000 + systemTime.tv_usec;
float seconds = (et - st) / 1000.0 / 1000.0; float seconds = (et - st) / 1000.0 / 1000.0;
pPrint("%.1f seconds to create %ld tables, speed:%.1f", seconds, totalTables, totalTables / seconds); pPrint("%.1f seconds to create %ld tables, speed:%.1f", seconds, totalTables, totalTables / seconds);
taos_close(con);
} }
void insertData() { void insertData() {
...@@ -257,7 +258,7 @@ void *syncTest(void *param) { ...@@ -257,7 +258,7 @@ void *syncTest(void *param) {
pError("thread:%d, failed to insert table:%s%ld row:%ld, reason:%s", pInfo->threadIndex, pInfo->stableName, pError("thread:%d, failed to insert table:%s%ld row:%ld, reason:%s", pInfo->threadIndex, pInfo->stableName,
table, row, taos_errstr(con)); table, row, taos_errstr(con));
} }
taos_stop_query(pSql); taos_free_result(pSql);
// "insert into" // "insert into"
len = sprintf(sql, "%s", inserStr); len = sprintf(sql, "%s", inserStr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册