FAQ
-1. When encoutered with the error "failed to connect to server", what can I do?
+1. When encountered with the error "failed to connect to server", what can I do?
The client may encounter connection errors. Please follow the steps below for troubleshooting:
- On the server side, execute
systemctl status taosd
to check the status of taosd service. If taosd is not running, start it and retry connecting.
diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c
index 80bf48364c2c634a47122b0834f07d8c229c0ef7..4ed4e0473bdf3c11c2838842b24c15d886a02f2e 100644
--- a/src/common/src/tglobal.c
+++ b/src/common/src/tglobal.c
@@ -430,10 +430,10 @@ static void doInitGlobalConfig(void) {
// port
cfg.option = "serverPort";
cfg.ptr = &tsServerPort;
- cfg.valType = TAOS_CFG_VTYPE_INT16;
+ cfg.valType = TAOS_CFG_VTYPE_UINT16;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 1;
- cfg.maxValue = 65535;
+ cfg.maxValue = 65056;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
diff --git a/src/dnode/src/dnodeCheck.c b/src/dnode/src/dnodeCheck.c
index 94d23609505bf952225b8dd2c752754dbd5d55b9..87baff30673afc68eb23a00bef279433a422ba67 100644
--- a/src/dnode/src/dnodeCheck.c
+++ b/src/dnode/src/dnodeCheck.c
@@ -29,7 +29,7 @@ typedef struct {
static SCheckItem tsCheckItem[TSDB_CHECK_ITEM_MAX] = {{0}};
int64_t tsMinFreeMemSizeForStart = 0;
-static int32_t bindTcpPort(int16_t port) {
+static int32_t bindTcpPort(uint16_t port) {
SOCKET serverSocket;
struct sockaddr_in server_addr;
@@ -85,9 +85,9 @@ static int32_t bindUdpPort(int16_t port) {
static int32_t dnodeCheckNetwork() {
int32_t ret;
- int16_t startPort = tsServerPort;
+ uint16_t startPort = tsServerPort;
- for (int16_t port = startPort; port < startPort + 12; port++) {
+ for (uint16_t port = startPort; port < startPort + 12; port++) {
ret = bindTcpPort(port);
if (0 != ret) {
dError("failed to tcp bind port %d, quit", port);
diff --git a/src/kit/taosdemo/insert.json b/src/kit/taosdemo/insert.json
index 33fd587509f776d777754c86897794665be42c65..c532448384ec44f06d7ccb0f85adbfd3d82a39e5 100644
--- a/src/kit/taosdemo/insert.json
+++ b/src/kit/taosdemo/insert.json
@@ -6,17 +6,17 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 1,
+ "thread_count_create_tbl": 4,
"result_file": "./insert_res.txt",
- "confirm_parameter_prompt": "no",
+ "confirm_parameter_prompt": "no",
"insert_interval": 0,
"num_of_records_per_req": 100,
"databases": [{
"dbinfo": {
- "name": "db",
- "drop": "no",
+ "name": "dbx",
+ "drop": "yes",
"replica": 1,
- "days": 2,
+ "days": 10,
"cache": 16,
"blocks": 8,
"precision": "ms",
@@ -25,6 +25,7 @@
"maxRows": 4096,
"comp":2,
"walLevel":1,
+ "cachelast":0,
"quorum":1,
"fsync":3000,
"update": 0
@@ -32,19 +33,19 @@
"super_tables": [{
"name": "stb",
"child_table_exists":"no",
- "childtable_count": 1,
+ "childtable_count": 100,
"childtable_prefix": "stb_",
"auto_create_table": "no",
"data_source": "rand",
"insert_mode": "taosc",
"insert_rows": 100000,
"multi_thread_write_one_tbl": "no",
- "number_of_tbl_in_one_sql": 1,
+ "number_of_tbl_in_one_sql": 0,
"rows_per_tbl": 100,
"max_sql_len": 1024000,
"disorder_ratio": 0,
"disorder_range": 1000,
- "timestamp_step": 10,
+ "timestamp_step": 1,
"start_timestamp": "2020-10-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "./sample.csv",
diff --git a/src/kit/taosdemo/query.json b/src/kit/taosdemo/query.json
index 4a5403a55d520681569b17adbd96c69bf411a15b..33ac120bdae283f64c4419d2885a93d36a7c8093 100644
--- a/src/kit/taosdemo/query.json
+++ b/src/kit/taosdemo/query.json
@@ -6,13 +6,14 @@
"user": "root",
"password": "taosdata",
"confirm_parameter_prompt": "yes",
- "databases": "db01",
+ "databases": "dbx",
"specified_table_query":
- {"query_interval":1, "concurrent":1,
- "sqls": [{"sql": "select count(*) from stb01", "result": "./query_res0.txt"}]
+ {"query_interval":1, "concurrent":4,
+ "sqls": [{"sql": "select last_row(*) from stb where color='red'", "result": "./query_res0.txt"},
+ {"sql": "select count(*) from stb_01", "result": "./query_res1.txt"}]
},
"super_table_query":
- {"stblname": "stb01", "query_interval":1, "threads":1,
- "sqls": [{"sql": "select count(*) from xxxx", "result": "./query_res1.txt"}]
+ {"stblname": "stb", "query_interval":1, "threads":4,
+ "sqls": [{"sql": "select last_row(*) from xxxx", "result": "./query_res2.txt"}]
}
}
diff --git a/src/kit/taosdemo/subscribe.json b/src/kit/taosdemo/subscribe.json
index f70b1213a884af7d593b3d7366268ce03de1d239..fd33a2e2e2515ac268764c0a7f3f8356e998becd 100644
--- a/src/kit/taosdemo/subscribe.json
+++ b/src/kit/taosdemo/subscribe.json
@@ -5,7 +5,7 @@
"port": 6030,
"user": "root",
"password": "taosdata",
- "databases": "db",
+ "databases": "dbx",
"specified_table_query":
{"concurrent":1, "mode":"sync", "interval":5000, "restart":"yes", "keepProgress":"yes",
"sqls": [{"sql": "select avg(col1) from stb01 where col1 > 1;", "result": "./subscribe_res0.txt"}]
diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c
index 449768bff5f170eaa2decd8df819ebc06f606ad7..de726ae81685dbfc387ca91cc633d83e2206f770 100644
--- a/src/kit/taosdemo/taosdemo.c
+++ b/src/kit/taosdemo/taosdemo.c
@@ -209,14 +209,14 @@ typedef struct SColumn_S {
} StrColumn;
typedef struct SSuperTable_S {
- char sTblName[MAX_TB_NAME_SIZE];
+ char sTblName[MAX_TB_NAME_SIZE+1];
int childTblCount;
bool superTblExists; // 0: no, 1: yes
bool childTblExists; // 0: no, 1: yes
int batchCreateTableNum; // 0: no batch, > 0: batch table number in one sql
int8_t autoCreateTable; // 0: create sub table, 1: auto create sub table
char childTblPrefix[MAX_TB_NAME_SIZE];
- char dataSource[MAX_TB_NAME_SIZE]; // rand_gen or sample
+ char dataSource[MAX_TB_NAME_SIZE+1]; // rand_gen or sample
char insertMode[MAX_TB_NAME_SIZE]; // taosc, restful
int multiThreadWriteOneTbl; // 0: no, 1: yes
@@ -230,8 +230,8 @@ typedef struct SSuperTable_S {
int timeStampStep;
char startTimestamp[MAX_TB_NAME_SIZE]; //
char sampleFormat[MAX_TB_NAME_SIZE]; // csv, json
- char sampleFile[MAX_FILE_NAME_LEN];
- char tagsFile[MAX_FILE_NAME_LEN];
+ char sampleFile[MAX_FILE_NAME_LEN+1];
+ char tagsFile[MAX_FILE_NAME_LEN+1];
int columnCount;
StrColumn columns[MAX_COLUMN_COUNT];
@@ -307,12 +307,12 @@ typedef struct SDataBase_S {
} SDataBase;
typedef struct SDbs_S {
- char cfgDir[MAX_FILE_NAME_LEN];
+ char cfgDir[MAX_FILE_NAME_LEN+1];
char host[MAX_DB_NAME_SIZE];
uint16_t port;
char user[MAX_DB_NAME_SIZE];
char password[MAX_DB_NAME_SIZE];
- char resultFile[MAX_FILE_NAME_LEN];
+ char resultFile[MAX_FILE_NAME_LEN+1];
bool use_metric;
bool insert_only;
bool do_aggreFunc;
@@ -340,13 +340,13 @@ typedef struct SuperQueryInfo_S {
int subscribeInterval; // ms
int subscribeRestart;
int subscribeKeepProgress;
- char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH];
- char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN];
+ char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH+1];
+ char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN+1];
TAOS_SUB* tsub[MAX_QUERY_SQL_COUNT];
} SuperQueryInfo;
typedef struct SubQueryInfo_S {
- char sTblName[MAX_TB_NAME_SIZE];
+ char sTblName[MAX_TB_NAME_SIZE+1];
int rate; // 0: unlimit > 0 loop/s
int threadCnt;
int subscribeMode; // 0: sync, 1: async
@@ -356,20 +356,20 @@ typedef struct SubQueryInfo_S {
int childTblCount;
char childTblPrefix[MAX_TB_NAME_SIZE];
int sqlCount;
- char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH];
- char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN];
+ char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH+1];
+ char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN+1];
TAOS_SUB* tsub[MAX_QUERY_SQL_COUNT];
char* childTblName;
} SubQueryInfo;
typedef struct SQueryMetaInfo_S {
- char cfgDir[MAX_FILE_NAME_LEN];
+ char cfgDir[MAX_FILE_NAME_LEN+1];
char host[MAX_DB_NAME_SIZE];
uint16_t port;
char user[MAX_DB_NAME_SIZE];
char password[MAX_DB_NAME_SIZE];
- char dbName[MAX_DB_NAME_SIZE];
+ char dbName[MAX_DB_NAME_SIZE+1];
char queryMode[MAX_TB_NAME_SIZE]; // taosc, restful
SuperQueryInfo superQueryInfo;
@@ -379,7 +379,7 @@ typedef struct SQueryMetaInfo_S {
typedef struct SThreadInfo_S {
TAOS *taos;
int threadID;
- char db_name[MAX_DB_NAME_SIZE];
+ char db_name[MAX_DB_NAME_SIZE+1];
char fp[4096];
char tb_prefix[MAX_TB_NAME_SIZE];
int start_table_id;
@@ -1791,7 +1791,7 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName, char* sTblName
char* pTblName = childTblName;
while ((row = taos_fetch_row(res)) != NULL) {
int32_t* len = taos_fetch_lengths(res);
- tstrncpy(pTblName, (char *)row[0], len[0]);
+ tstrncpy(pTblName, (char *)row[0], len[0]+1);
//printf("==== sub table name: %s\n", pTblName);
count++;
if (count >= childTblCount - 1) {
@@ -2853,7 +2853,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
if (batchCreateTbl && batchCreateTbl->type == cJSON_Number) {
g_Dbs.db[i].superTbls[j].batchCreateTableNum = batchCreateTbl->valueint;
} else if (!batchCreateTbl) {
- g_Dbs.db[i].superTbls[j].batchCreateTableNum = 2000;
+ g_Dbs.db[i].superTbls[j].batchCreateTableNum = 1000;
} else {
printf("failed to read json, batch_create_tbl_num not found");
goto PARSE_OVER;
@@ -4577,7 +4577,7 @@ void replaceSubTblName(char* inSql, char* outSql, int tblIndex) {
return;
}
- tstrncpy(outSql, inSql, pos - inSql);
+ tstrncpy(outSql, inSql, pos - inSql + 1);
//printf("1: %s\n", outSql);
strcat(outSql, subTblName);
//printf("2: %s\n", outSql);
@@ -4598,9 +4598,9 @@ void *subQueryProcess(void *sarg) {
st = taosGetTimestampMs();
for (int i = winfo->start_table_id; i <= winfo->end_table_id; i++) {
- for (int i = 0; i < g_queryInfo.subQueryInfo.sqlCount; i++) {
+ for (int j = 0; j < g_queryInfo.subQueryInfo.sqlCount; j++) {
memset(sqlstr,0,sizeof(sqlstr));
- replaceSubTblName(g_queryInfo.subQueryInfo.sql[i], sqlstr, i);
+ replaceSubTblName(g_queryInfo.subQueryInfo.sql[j], sqlstr, i);
char tmpFile[MAX_FILE_NAME_LEN*2] = {0};
if (g_queryInfo.subQueryInfo.result[i][0] != 0) {
sprintf(tmpFile, "%s-%d",
diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c
index 4fcedd82e3103f0ca807dd202b83a8a083cb34a8..b1ae118b4b8174d1ac9427a290e6b49efddbb33a 100644
--- a/src/mnode/src/mnodeTable.c
+++ b/src/mnode/src/mnodeTable.c
@@ -916,11 +916,13 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
return TSDB_CODE_MND_DB_IN_DROPPING;
}
+#if 0
if (mnodeCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) {
mError("msg:%p, app:%p table:%s, failed to drop table, in monitor database", pMsg, pMsg->rpcMsg.ahandle,
pDrop->name);
return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN;
}
+#endif
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pDrop->name);
if (pMsg->pTable == NULL) {
@@ -3020,10 +3022,12 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
return TSDB_CODE_MND_DB_IN_DROPPING;
}
+#if 0
if (mnodeCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) {
mError("msg:%p, app:%p table:%s, failed to alter table, its log db", pMsg, pMsg->rpcMsg.ahandle, pAlter->tableFname);
return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN;
}
+#endif
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pAlter->tableFname);
if (pMsg->pTable == NULL) {
diff --git a/src/plugins/http/inc/httpRestJson.h b/src/plugins/http/inc/httpRestJson.h
index 112e845f369c6ae3f0df76d880f84de5aeff5d8d..5f19983826a4f90bc3498ca82cc9fd495b4f300c 100644
--- a/src/plugins/http/inc/httpRestJson.h
+++ b/src/plugins/http/inc/httpRestJson.h
@@ -34,6 +34,8 @@
#define REST_JSON_DATA_LEN 4
#define REST_JSON_HEAD "head"
#define REST_JSON_HEAD_LEN 4
+#define REST_JSON_HEAD_INFO "column_meta"
+#define REST_JSON_HEAD_INFO_LEN 11
#define REST_JSON_ROWS "rows"
#define REST_JSON_ROWS_LEN 4
#define REST_JSON_AFFECT_ROWS "affected_rows"
@@ -51,4 +53,4 @@ bool restBuildSqlLocalTimeStringJson(HttpContext *pContext, HttpSqlCmd *cmd, TAO
bool restBuildSqlUtcTimeStringJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, int32_t numOfRows);
void restStopSqlJson(HttpContext *pContext, HttpSqlCmd *cmd);
-#endif
\ No newline at end of file
+#endif
diff --git a/src/plugins/http/src/httpQueue.c b/src/plugins/http/src/httpQueue.c
index aebba97fb8cd320afd7ba6a0f2b1e39dbaf4bee1..7f7ce404600b96b0efe8385ea0aed7be412a6ba0 100644
--- a/src/plugins/http/src/httpQueue.c
+++ b/src/plugins/http/src/httpQueue.c
@@ -59,7 +59,9 @@ void httpDispatchToResultQueue(void *param, TAOS_RES *result, int32_t code, int3
pMsg->fp = fp;
taosWriteQitem(tsHttpQueue, TAOS_QTYPE_RPC, pMsg);
} else {
- (*fp)(param, result, code, rows);
+ taos_stop_query(result);
+ taos_free_result(result);
+ //(*fp)(param, result, code, rows);
}
}
diff --git a/src/plugins/http/src/httpRestJson.c b/src/plugins/http/src/httpRestJson.c
index a620625d25919433a406856289dad0f8da1fc709..61a5a361c4865d6b3dbac73773cc0b8cfc562e56 100644
--- a/src/plugins/http/src/httpRestJson.c
+++ b/src/plugins/http/src/httpRestJson.c
@@ -75,6 +75,44 @@ void restStartSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result)
// head array end
httpJsonToken(jsonBuf, JsonArrEnd);
+ // column_meta begin
+ httpJsonItemToken(jsonBuf);
+ httpJsonPairHead(jsonBuf, REST_JSON_HEAD_INFO, REST_JSON_HEAD_INFO_LEN);
+ // column_meta array begin
+ httpJsonItemToken(jsonBuf);
+ httpJsonToken(jsonBuf, JsonArrStt);
+
+ if (num_fields == 0) {
+ httpJsonItemToken(jsonBuf);
+ httpJsonToken(jsonBuf, JsonArrStt);
+
+ httpJsonItemToken(jsonBuf);
+ httpJsonString(jsonBuf, REST_JSON_AFFECT_ROWS, REST_JSON_AFFECT_ROWS_LEN);
+ httpJsonItemToken(jsonBuf);
+ httpJsonInt(jsonBuf, TSDB_DATA_TYPE_INT);
+ httpJsonItemToken(jsonBuf);
+ httpJsonInt(jsonBuf, 4);
+
+ httpJsonToken(jsonBuf, JsonArrEnd);
+ } else {
+ for (int32_t i = 0; i < num_fields; ++i) {
+ httpJsonItemToken(jsonBuf);
+ httpJsonToken(jsonBuf, JsonArrStt);
+
+ httpJsonItemToken(jsonBuf);
+ httpJsonString(jsonBuf, fields[i].name, (int32_t)strlen(fields[i].name));
+ httpJsonItemToken(jsonBuf);
+ httpJsonInt(jsonBuf, fields[i].type);
+ httpJsonItemToken(jsonBuf);
+ httpJsonInt(jsonBuf, fields[i].bytes);
+
+ httpJsonToken(jsonBuf, JsonArrEnd);
+ }
+ }
+
+ // column_meta array end
+ httpJsonToken(jsonBuf, JsonArrEnd);
+
// data begin
httpJsonItemToken(jsonBuf);
httpJsonPairHead(jsonBuf, REST_JSON_DATA, REST_JSON_DATA_LEN);
diff --git a/src/tsdb/inc/tsdbMemTable.h b/src/tsdb/inc/tsdbMemTable.h
index 3b3f1dd1f6a9307bbe3954374b005a23a9f15ab0..bd64ed4a5238b3b8b60716d8732d59d27218c639 100644
--- a/src/tsdb/inc/tsdbMemTable.h
+++ b/src/tsdb/inc/tsdbMemTable.h
@@ -37,6 +37,7 @@ typedef struct {
TSKEY keyLast;
int64_t numOfRows;
SSkipList* pData;
+ T_REF_DECLARE()
} STableData;
typedef struct {
@@ -76,7 +77,7 @@ typedef struct {
int tsdbRefMemTable(STsdbRepo* pRepo, SMemTable* pMemTable);
int tsdbUnRefMemTable(STsdbRepo* pRepo, SMemTable* pMemTable);
-int tsdbTakeMemSnapshot(STsdbRepo* pRepo, SMemTable** pMem, SMemTable** pIMem);
+int tsdbTakeMemSnapshot(STsdbRepo* pRepo, SMemTable** pMem, SMemTable** pIMem, SArray* pATable);
void tsdbUnTakeMemSnapShot(STsdbRepo* pRepo, SMemTable* pMem, SMemTable* pIMem);
void* tsdbAllocBytes(STsdbRepo* pRepo, int bytes);
int tsdbAsyncCommit(STsdbRepo* pRepo);
diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c
index 69a35b3d7832a31528657df71d5c169f4a524974..8969f61596b33f37cabe934fdd56819b71575315 100644
--- a/src/tsdb/src/tsdbMain.c
+++ b/src/tsdb/src/tsdbMain.c
@@ -597,7 +597,7 @@ int tsdbRestoreInfo(STsdbRepo *pRepo) {
// Get the data in row
ASSERT(pTable->lastRow == NULL);
STSchema *pSchema = tsdbGetTableSchema(pTable);
- pTable->lastRow = taosTMalloc(schemaTLen(pSchema));
+ pTable->lastRow = taosTMalloc(dataRowMaxBytesFromSchema(pSchema));
if (pTable->lastRow == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
tsdbDestroyReadH(&readh);
diff --git a/src/tsdb/src/tsdbMemTable.c b/src/tsdb/src/tsdbMemTable.c
index 73a127079920bcdf0cdc2d3e244998310c4d8dbc..6818f2ed14c278bd5d203d0570f52772c159dcde 100644
--- a/src/tsdb/src/tsdbMemTable.c
+++ b/src/tsdb/src/tsdbMemTable.c
@@ -124,17 +124,66 @@ int tsdbUnRefMemTable(STsdbRepo *pRepo, SMemTable *pMemTable) {
return 0;
}
-int tsdbTakeMemSnapshot(STsdbRepo *pRepo, SMemTable **pMem, SMemTable **pIMem) {
+int tsdbTakeMemSnapshot(STsdbRepo *pRepo, SMemTable **pMem, SMemTable **pIMem, SArray *pATable) {
+ SMemTable *tmem;
+
+ // Get snap object
if (tsdbLockRepo(pRepo) < 0) return -1;
- *pMem = pRepo->mem;
+ tmem = pRepo->mem;
*pIMem = pRepo->imem;
- tsdbRefMemTable(pRepo, *pMem);
+ tsdbRefMemTable(pRepo, tmem);
tsdbRefMemTable(pRepo, *pIMem);
if (tsdbUnlockRepo(pRepo) < 0) return -1;
- if (*pMem != NULL) taosRLockLatch(&((*pMem)->latch));
+ // Copy mem objects and ref needed STableData
+ if (tmem) {
+ taosRLockLatch(&(tmem->latch));
+
+ *pMem = (SMemTable *)calloc(1, sizeof(**pMem));
+ if (*pMem == NULL) {
+ terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
+ taosRUnLockLatch(&(tmem->latch));
+ tsdbUnRefMemTable(pRepo, tmem);
+ tsdbUnRefMemTable(pRepo, *pIMem);
+ *pMem = NULL;
+ *pIMem = NULL;
+ return -1;
+ }
+
+ (*pMem)->tData = (STableData **)calloc(tmem->maxTables, sizeof(STableData *));
+ if ((*pMem)->tData == NULL) {
+ terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
+ taosRUnLockLatch(&(tmem->latch));
+ free(*pMem);
+ tsdbUnRefMemTable(pRepo, tmem);
+ tsdbUnRefMemTable(pRepo, *pIMem);
+ *pMem = NULL;
+ *pIMem = NULL;
+ return -1;
+ }
+
+ (*pMem)->keyFirst = tmem->keyFirst;
+ (*pMem)->keyLast = tmem->keyLast;
+ (*pMem)->numOfRows = tmem->numOfRows;
+ (*pMem)->maxTables = tmem->maxTables;
+
+ for (size_t i = 0; i < taosArrayGetSize(pATable); i++) {
+ STable * pTable = *(STable **)taosArrayGet(pATable, i);
+ int32_t tid = TABLE_TID(pTable);
+ STableData *pTableData = (tid < tmem->maxTables) ? tmem->tData[tid] : NULL;
+
+ if ((pTableData == NULL) || (TABLE_UID(pTable) != pTableData->uid)) continue;
+
+ (*pMem)->tData[tid] = tmem->tData[tid];
+ T_REF_INC(tmem->tData[tid]);
+ }
+
+ taosRUnLockLatch(&(tmem->latch));
+ }
+
+ tsdbUnRefMemTable(pRepo, tmem);
tsdbDebug("vgId:%d take memory snapshot, pMem %p pIMem %p", REPO_ID(pRepo), *pMem, *pIMem);
return 0;
@@ -144,8 +193,14 @@ void tsdbUnTakeMemSnapShot(STsdbRepo *pRepo, SMemTable *pMem, SMemTable *pIMem)
tsdbDebug("vgId:%d untake memory snapshot, pMem %p pIMem %p", REPO_ID(pRepo), pMem, pIMem);
if (pMem != NULL) {
- taosRUnLockLatch(&(pMem->latch));
- tsdbUnRefMemTable(pRepo, pMem);
+ for (size_t i = 0; i < pMem->maxTables; i++) {
+ STableData *pTableData = pMem->tData[i];
+ if (pTableData) {
+ tsdbFreeTableData(pTableData);
+ }
+ }
+ free(pMem->tData);
+ free(pMem);
}
if (pIMem != NULL) {
@@ -436,7 +491,7 @@ static STableData *tsdbNewTableData(STsdbCfg *pCfg, STable *pTable) {
STableData *pTableData = (STableData *)calloc(1, sizeof(*pTableData));
if (pTableData == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
- goto _err;
+ return NULL;
}
pTableData->uid = TABLE_UID(pTable);
@@ -449,20 +504,22 @@ static STableData *tsdbNewTableData(STsdbCfg *pCfg, STable *pTable) {
tkeyComparFn, pCfg->update ? SL_UPDATE_DUP_KEY : SL_DISCARD_DUP_KEY, tsdbGetTsTupleKey);
if (pTableData->pData == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
- goto _err;
+ free(pTableData);
+ return NULL;
}
- return pTableData;
+ T_REF_INC(pTableData);
-_err:
- tsdbFreeTableData(pTableData);
- return NULL;
+ return pTableData;
}
static void tsdbFreeTableData(STableData *pTableData) {
if (pTableData) {
- tSkipListDestroy(pTableData->pData);
- free(pTableData);
+ int32_t ref = T_REF_DEC(pTableData);
+ if (ref == 0) {
+ tSkipListDestroy(pTableData->pData);
+ free(pTableData);
+ }
}
}
diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c
index 7162f74d3ec2620449066bc28f9acaee64067622..486ff49f097df971d1a1130181a1c14b79f9fc01 100644
--- a/src/tsdb/src/tsdbRead.c
+++ b/src/tsdb/src/tsdbRead.c
@@ -187,13 +187,15 @@ static SArray* getDefaultLoadColumns(STsdbQueryHandle* pQueryHandle, bool loadTS
return pLocalIdList;
}
-static void tsdbMayTakeMemSnapshot(STsdbQueryHandle* pQueryHandle) {
+static void tsdbMayTakeMemSnapshot(STsdbQueryHandle* pQueryHandle, SArray* psTable) {
assert(pQueryHandle != NULL && pQueryHandle->pMemRef != NULL);
SMemRef* pMemRef = pQueryHandle->pMemRef;
if (pQueryHandle->pMemRef->ref++ == 0) {
- tsdbTakeMemSnapshot(pQueryHandle->pTsdb, (SMemTable**)&(pMemRef->mem), (SMemTable**)&(pMemRef->imem));
+ tsdbTakeMemSnapshot(pQueryHandle->pTsdb, (SMemTable**)&(pMemRef->mem), (SMemTable**)&(pMemRef->imem), psTable);
}
+
+ taosArrayDestroy(psTable);
}
static void tsdbMayUnTakeMemSnapshot(STsdbQueryHandle* pQueryHandle) {
@@ -242,7 +244,7 @@ int64_t tsdbGetNumOfRowsInMemTable(TsdbQueryHandleT* pHandle) {
return rows;
}
-static SArray* createCheckInfoFromTableGroup(STsdbQueryHandle* pQueryHandle, STableGroupInfo* pGroupList, STsdbMeta* pMeta) {
+static SArray* createCheckInfoFromTableGroup(STsdbQueryHandle* pQueryHandle, STableGroupInfo* pGroupList, STsdbMeta* pMeta, SArray** psTable) {
size_t sizeOfGroup = taosArrayGetSize(pGroupList->pGroupList);
assert(sizeOfGroup >= 1 && pMeta != NULL);
@@ -252,6 +254,12 @@ static SArray* createCheckInfoFromTableGroup(STsdbQueryHandle* pQueryHandle, STa
return NULL;
}
+ SArray* pTable = taosArrayInit(4, sizeof(STable*));
+ if (pTable == NULL) {
+ taosArrayDestroy(pTableCheckInfo);
+ return NULL;
+ }
+
// todo apply the lastkey of table check to avoid to load header file
for (int32_t i = 0; i < sizeOfGroup; ++i) {
SArray* group = *(SArray**) taosArrayGet(pGroupList->pGroupList, i);
@@ -277,31 +285,40 @@ static SArray* createCheckInfoFromTableGroup(STsdbQueryHandle* pQueryHandle, STa
assert(info.lastKey <= pQueryHandle->window.skey);
}
+ taosArrayPush(pTable, &pKeyInfo->pTable);
+
taosArrayPush(pTableCheckInfo, &info);
tsdbDebug("%p check table uid:%"PRId64", tid:%d from lastKey:%"PRId64" %p", pQueryHandle, info.tableId.uid,
info.tableId.tid, info.lastKey, pQueryHandle->qinfo);
}
}
+ *psTable = pTable;
+
taosArraySort(pTableCheckInfo, tsdbCheckInfoCompar);
return pTableCheckInfo;
}
-static SArray* createCheckInfoFromCheckInfo(SArray* pTableCheckInfo, TSKEY skey) {
+static SArray* createCheckInfoFromCheckInfo(SArray* pTableCheckInfo, TSKEY skey, SArray** psTable) {
size_t si = taosArrayGetSize(pTableCheckInfo);
SArray* pNew = taosArrayInit(si, sizeof(STableCheckInfo));
if (pNew == NULL) {
return NULL;
}
+ SArray* pTable = taosArrayInit(si, sizeof(STable*));
+
for (int32_t j = 0; j < si; ++j) {
STableCheckInfo* pCheckInfo = (STableCheckInfo*) taosArrayGet(pTableCheckInfo, j);
STableCheckInfo info = { .lastKey = skey, .pTableObj = pCheckInfo->pTableObj};
info.tableId = pCheckInfo->tableId;
taosArrayPush(pNew, &info);
+ taosArrayPush(pTable, &pCheckInfo->pTableObj);
}
+ *psTable = pTable;
+
// it is ordered already, no need to sort again.
taosArraySort(pNew, tsdbCheckInfoCompar);
return pNew;
@@ -332,7 +349,7 @@ static STsdbQueryHandle* tsdbQueryTablesImpl(STsdbRepo* tsdb, STsdbQueryCond* pC
goto out_of_memory;
}
- tsdbMayTakeMemSnapshot(pQueryHandle);
+ //tsdbMayTakeMemSnapshot(pQueryHandle);
assert(pCond != NULL && pCond->numOfCols > 0 && pMemRef != NULL);
if (ASCENDING_TRAVERSE(pCond->order)) {
@@ -393,14 +410,18 @@ TsdbQueryHandleT* tsdbQueryTables(STsdbRepo* tsdb, STsdbQueryCond* pCond, STable
STsdbMeta* pMeta = tsdbGetMeta(tsdb);
assert(pMeta != NULL);
+ SArray* psTable = NULL;
+
// todo apply the lastkey of table check to avoid to load header file
- pQueryHandle->pTableCheckInfo = createCheckInfoFromTableGroup(pQueryHandle, groupList, pMeta);
+ pQueryHandle->pTableCheckInfo = createCheckInfoFromTableGroup(pQueryHandle, groupList, pMeta, &psTable);
if (pQueryHandle->pTableCheckInfo == NULL) {
tsdbCleanupQueryHandle(pQueryHandle);
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return NULL;
}
+ tsdbMayTakeMemSnapshot(pQueryHandle, psTable);
+
tsdbDebug("%p total numOfTable:%" PRIzu " in query, %p", pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo), pQueryHandle->qinfo);
return (TsdbQueryHandleT) pQueryHandle;
}
@@ -2337,12 +2358,18 @@ static int32_t doGetExternalRow(STsdbQueryHandle* pQueryHandle, int16_t type, SM
pSecQueryHandle = tsdbQueryTablesImpl(pQueryHandle->pTsdb, &cond, pQueryHandle->qinfo, pMemRef);
tfree(cond.colList);
- pSecQueryHandle->pTableCheckInfo = createCheckInfoFromCheckInfo(pQueryHandle->pTableCheckInfo, pSecQueryHandle->window.skey);
+
+ SArray* psTable = NULL;
+
+ pSecQueryHandle->pTableCheckInfo = createCheckInfoFromCheckInfo(pQueryHandle->pTableCheckInfo, pSecQueryHandle->window.skey, &psTable);
if (pSecQueryHandle->pTableCheckInfo == NULL) {
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
goto out_of_memory;
}
+
+ tsdbMayTakeMemSnapshot(pSecQueryHandle, psTable);
+
if (!tsdbNextDataBlock((void*)pSecQueryHandle)) {
// no result in current query, free the corresponding result rows structure
if (type == TSDB_PREV_ROW) {
diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h
index 9923409885fad30cbadd9354349075708b1a7fda..fdb2595fd8d3b1659800ca3a5b88c32b6fe95e93 100644
--- a/src/util/inc/tconfig.h
+++ b/src/util/inc/tconfig.h
@@ -44,6 +44,7 @@ enum {
TAOS_CFG_VTYPE_INT8,
TAOS_CFG_VTYPE_INT16,
TAOS_CFG_VTYPE_INT32,
+ TAOS_CFG_VTYPE_UINT16,
TAOS_CFG_VTYPE_FLOAT,
TAOS_CFG_VTYPE_STRING,
TAOS_CFG_VTYPE_IPSTR,
diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c
index 7a92750f8f2e89a93557d367b0c4772a2faaa57d..c4bd57760222ac3da7d25510cc2f434fe0cf0cac 100644
--- a/src/util/src/tconfig.c
+++ b/src/util/src/tconfig.c
@@ -95,6 +95,23 @@ static void taosReadInt16Config(SGlobalCfg *cfg, char *input_value) {
}
}
+static void taosReadUInt16Config(SGlobalCfg *cfg, char *input_value) {
+ int32_t value = atoi(input_value);
+ uint16_t *option = (uint16_t *)cfg->ptr;
+ if (value < cfg->minValue || value > cfg->maxValue) {
+ uError("config option:%s, input value:%s, out of range[%f, %f], use default value:%d",
+ cfg->option, input_value, cfg->minValue, cfg->maxValue, *option);
+ } else {
+ if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) {
+ *option = (uint16_t)value;
+ cfg->cfgStatus = TAOS_CFG_CSTATUS_FILE;
+ } else {
+ uWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, input_value,
+ tsCfgStatusStr[cfg->cfgStatus], *option);
+ }
+ }
+}
+
static void taosReadInt8Config(SGlobalCfg *cfg, char *input_value) {
int32_t value = atoi(input_value);
int8_t *option = (int8_t *)cfg->ptr;
@@ -239,6 +256,9 @@ static void taosReadConfigOption(const char *option, char *value, char *value2,
case TAOS_CFG_VTYPE_INT32:
taosReadInt32Config(cfg, value);
break;
+ case TAOS_CFG_VTYPE_UINT16:
+ taosReadUInt16Config(cfg, value);
+ break;
case TAOS_CFG_VTYPE_FLOAT:
taosReadFloatConfig(cfg, value);
break;
@@ -422,6 +442,9 @@ void taosPrintGlobalCfg() {
case TAOS_CFG_VTYPE_INT32:
uInfo(" %s:%s%d%s", cfg->option, blank, *((int32_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
break;
+ case TAOS_CFG_VTYPE_UINT16:
+ uInfo(" %s:%s%d%s", cfg->option, blank, *((uint16_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
+ break;
case TAOS_CFG_VTYPE_FLOAT:
uInfo(" %s:%s%f%s", cfg->option, blank, *((float *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
break;
@@ -459,6 +482,9 @@ static void taosDumpCfg(SGlobalCfg *cfg) {
case TAOS_CFG_VTYPE_INT32:
printf(" %s:%s%d%s\n", cfg->option, blank, *((int32_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
break;
+ case TAOS_CFG_VTYPE_UINT16:
+ printf(" %s:%s%d%s\n", cfg->option, blank, *((uint16_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
+ break;
case TAOS_CFG_VTYPE_FLOAT:
printf(" %s:%s%f%s\n", cfg->option, blank, *((float *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
break;
diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c
index e08d667d6be42bef3dc4e058fab10ac68f0809e0..930a6075cae2767c0d50ca2e1574d6441430d1b3 100644
--- a/tests/examples/c/apitest.c
+++ b/tests/examples/c/apitest.c
@@ -467,7 +467,6 @@ int main(int argc, char *argv[]) {
const char* passwd = "taosdata";
taos_options(TSDB_OPTION_TIMEZONE, "GMT-8");
- taos_init();
TAOS* taos = taos_connect(host, user, passwd, "", 0);
if (taos == NULL) {
diff --git a/tests/examples/c/asyncdemo.c b/tests/examples/c/asyncdemo.c
index be3a908f11748a5ac414157bef6b9caed389b303..16a14e96549c5cd66f747ae0c6c63f20c3e7fbfa 100644
--- a/tests/examples/c/asyncdemo.c
+++ b/tests/examples/c/asyncdemo.c
@@ -99,8 +99,6 @@ int main(int argc, char *argv[])
tableList = (STable *)malloc(size);
memset(tableList, 0, size);
- taos_init();
-
taos = taos_connect(argv[1], "root", "taosdata", NULL, 0);
if (taos == NULL)
taos_error(taos);
diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c
index 0b12c3d3eabaf9a17ba0859c73e794f2e973dc3b..3853d81fb251809e1e6b18ffa1fad5c8ca882d16 100644
--- a/tests/examples/c/demo.c
+++ b/tests/examples/c/demo.c
@@ -61,11 +61,6 @@ int main(int argc, char *argv[]) {
return 0;
}
- // init TAOS
- if (taos_init()) {
- exit(1);
- }
-
TAOS *taos = taos_connect(argv[1], "root", "taosdata", NULL, 0);
if (taos == NULL) {
printf("failed to connect to server, reason:%s\n", "null taos"/*taos_errstr(taos)*/);
diff --git a/tests/examples/c/makefile b/tests/examples/c/makefile
index 7293a22c11d7c6049c220ca0951b5969fa344114..b06fe551dbde4b16e3ea197ca4c2bc1711ef63bb 100644
--- a/tests/examples/c/makefile
+++ b/tests/examples/c/makefile
@@ -6,7 +6,7 @@ TARGET=exe
LFLAGS = '-Wl,-rpath,/usr/local/taos/driver/' -ltaos -lpthread -lm -lrt
CFLAGS = -O3 -g -Wall -Wno-deprecated -fPIC -Wno-unused-result -Wconversion \
-Wno-char-subscripts -D_REENTRANT -Wno-format -D_REENTRANT -DLINUX \
- -msse4.2 -Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99
+ -Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99
all: $(TARGET)
diff --git a/tests/examples/c/prepare.c b/tests/examples/c/prepare.c
index bd650ed64b838d92a03bb5e023c2ca91ac5e2c2e..13d71beea6156aa32677c20ccc2d222d28826b24 100644
--- a/tests/examples/c/prepare.c
+++ b/tests/examples/c/prepare.c
@@ -22,12 +22,6 @@ int main(int argc, char *argv[])
return 0;
}
- // init TAOS
- if (taos_init()) {
- printf("failed to init taos\n");
- exit(1);
- }
-
taos = taos_connect(argv[1], "root", "taosdata", NULL, 0);
if (taos == NULL) {
printf("failed to connect to db, reason:%s\n", taos_errstr(taos));
diff --git a/tests/examples/c/stream.c b/tests/examples/c/stream.c
index e3053d1969b169767904d595c6ed5615e9d46ce5..30a790f061cd8ef2b870a371c2cadfb0e2a413c1 100644
--- a/tests/examples/c/stream.c
+++ b/tests/examples/c/stream.c
@@ -54,12 +54,6 @@ int main(int argc, char *argv[])
exit(0);
}
- // init TAOS
- if (taos_init()) {
- printf("failed to init taos\n");
- exit(1);
- }
-
strcpy(db_name, argv[2]);
strcpy(tbl_name, argv[3]);
diff --git a/tests/examples/c/subscribe.c b/tests/examples/c/subscribe.c
index 5a402976241133dcef219cb64be7b3492e464aac..1d3533fa5ee89f7425a9b0563e738b4e0703e6c8 100644
--- a/tests/examples/c/subscribe.c
+++ b/tests/examples/c/subscribe.c
@@ -216,12 +216,6 @@ int main(int argc, char *argv[]) {
}
}
- // init TAOS
- if (taos_init()) {
- printf("failed to init taos\n");
- exit(1);
- }
-
TAOS* taos = taos_connect(host, user, passwd, "", 0);
if (taos == NULL) {
printf("failed to connect to db, reason:%s\n", taos_errstr(taos));
diff --git a/tests/pytest/concurrent_inquiry.py b/tests/pytest/concurrent_inquiry.py
index d1f180373bbe0585bd6e01b224e64359e0449e77..333c2a0a578f6f399e742b0967db0185a22b5fde 100644
--- a/tests/pytest/concurrent_inquiry.py
+++ b/tests/pytest/concurrent_inquiry.py
@@ -350,18 +350,27 @@ class ConcurrentInquiry:
cl.execute("create database if not exists %s;" %self.dbname)
cl.execute("use %s" % self.dbname)
for k in range(stableNum):
- sql="create table %s (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool,c8 binary(20),c9 nchar(20)) \
- tags(t1 int, t2 float, t3 bigint, t4 smallint, t5 tinyint, t6 double, t7 bool,t8 binary(20),t9 nchar(20))" % (self.stb_prefix+str(k))
+ sql="create table %s (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool,c8 binary(20),c9 nchar(20),c11 int unsigned,c12 smallint unsigned,c13 tinyint unsigned,c14 bigint unsigned) \
+ tags(t1 int, t2 float, t3 bigint, t4 smallint, t5 tinyint, t6 double, t7 bool,t8 binary(20),t9 nchar(20), t11 int unsigned , t12 smallint unsigned , t13 tinyint unsigned , t14 bigint unsigned)" % (self.stb_prefix+str(k))
cl.execute(sql)
for j in range(subtableNum):
- sql = "create table %s using %s tags(%d,%d,%d,%d,%d,%d,%d,'%s','%s')" % \
- (self.subtb_prefix+str(k)+'_'+str(j),self.stb_prefix+str(k),j,j/2.0,j%41,j%51,j%53,j*1.0,j%2,'taos'+str(j),'涛思'+str(j))
+ if j % 100 == 0:
+ sql = "create table %s using %s tags(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)" % \
+ (self.subtb_prefix+str(k)+'_'+str(j),self.stb_prefix+str(k))
+ else:
+ sql = "create table %s using %s tags(%d,%d,%d,%d,%d,%d,%d,'%s','%s',%d,%d,%d,%d)" % \
+ (self.subtb_prefix+str(k)+'_'+str(j),self.stb_prefix+str(k),j,j/2.0,j%41,j%51,j%53,j*1.0,j%2,'taos'+str(j),'涛思'+str(j), j%43, j%23 , j%17 , j%3167)
print(sql)
cl.execute(sql)
for i in range(insertRows):
- ret = cl.execute(
- "insert into %s values (%d , %d,%d,%d,%d,%d,%d,%d,'%s','%s')" %
- (self.subtb_prefix+str(k)+'_'+str(j),t0+i,i%100,i/2.0,i%41,i%51,i%53,i*1.0,i%2,'taos'+str(i),'涛思'+str(i)))
+ if i % 100 == 0 :
+ ret = cl.execute(
+ "insert into %s values (%d , NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)" %
+ (self.subtb_prefix+str(k)+'_'+str(j), t0+i))
+ else:
+ ret = cl.execute(
+ "insert into %s values (%d , %d,%d,%d,%d,%d,%d,%d,'%s','%s',%d,%d,%d,%d)" %
+ (self.subtb_prefix+str(k)+'_'+str(j), t0+i, i%100, i/2.0, i%41, i%51, i%53, i*1.0, i%2,'taos'+str(i),'涛思'+str(i), i%43, i%23 , i%17 , i%3167))
cl.close()
conn.close()
diff --git a/tests/pytest/functions/function_operations.py b/tests/pytest/functions/function_operations.py
index c6a3b82800d224f9eedd79e0c3e3e5331d0575b2..8bbe6dc9a34b54ef1ddecff4e3f186312e5235b1 100644
--- a/tests/pytest/functions/function_operations.py
+++ b/tests/pytest/functions/function_operations.py
@@ -68,6 +68,15 @@ class TDTestCase:
tdSql.checkRows(11)
tdSql.checkData(10, 0, None)
+ # test for tarithoperator.c coverage
+ col_list = [ 'col1' , 'col2' , 'col3' , 'col4' , 'col5' , 'col6' , 'col11' , 'col12' , 'col13' , 'col14' , '1' ]
+ op_list = [ '+' , '-' , '*' , '/' , '%' ]
+ for i in col_list :
+ for j in col_list :
+ for k in op_list :
+ sql = " select %s %s %s from test1 " % ( i , k , j )
+ print(sql)
+ tdSql.query(sql)
def stop(self):
tdSql.close()
diff --git a/tests/pytest/query/last_row_cache.py b/tests/pytest/query/last_row_cache.py
index d9e09dae7acdcd8c7401f1370da9f544c850872d..a0e81477096e9c846e109ae71020b40e47b39a84 100644
--- a/tests/pytest/query/last_row_cache.py
+++ b/tests/pytest/query/last_row_cache.py
@@ -25,18 +25,23 @@ class TDTestCase:
self.tables = 10
self.rows = 20
+ self.columns = 50
self.perfix = 't'
self.ts = 1601481600000
def insertData(self):
- print("==============step1")
- tdSql.execute("create table st (ts timestamp, c1 int) tags(t1 int)")
+ print("==============step1")
+ sql = "create table st(ts timestamp, "
+ for i in range(self.columns - 1):
+ sql += "c%d int, " % (i + 1)
+ sql += "c50 int) tags(t1 int)"
+ tdSql.execute(sql)
for i in range(self.tables):
tdSql.execute("create table %s%d using st tags(%d)" % (self.perfix, i, i))
for j in range(self.rows):
tc = self.ts + j * 60000
- tdSql.execute("insert into %s%d values(%d, %d)" %(self.perfix, i, tc, j))
+ tdSql.execute("insert into %s%d(ts, c1) values(%d, %d)" %(self.perfix, i, tc, j))
def executeQueries(self):
print("==============step2")
@@ -66,29 +71,29 @@ class TDTestCase:
tdSql.checkData(0, 0, 19)
tc = self.ts + 1 * 3600000
- tdSql.execute("insert into %s%d values(%d, %d)" %(self.perfix, 1, tc, 10))
+ tdSql.execute("insert into %s%d(ts, c1) values(%d, %d)" %(self.perfix, 1, tc, 10))
tc = self.ts + 3 * 3600000
- tdSql.execute("insert into %s%d values(%d, null)" %(self.perfix, 1, tc))
+ tdSql.execute("insert into %s%d(ts, c1) values(%d, null)" %(self.perfix, 1, tc))
tc = self.ts + 5 * 3600000
- tdSql.execute("insert into %s%d values(%d, %d)" %(self.perfix, 1, tc, -1))
+ tdSql.execute("insert into %s%d(ts, c1) values(%d, %d)" %(self.perfix, 1, tc, -1))
tc = self.ts + 7 * 3600000
- tdSql.execute("insert into %s%d values(%d, null)" %(self.perfix, 1, tc))
+ tdSql.execute("insert into %s%d(ts, c1) values(%d, null)" %(self.perfix, 1, tc))
def insertData2(self):
tc = self.ts + 1 * 3600000
- tdSql.execute("insert into %s%d values(%d, %d)" %(self.perfix, 1, tc, 10))
+ tdSql.execute("insert into %s%d(ts, c1) values(%d, %d)" %(self.perfix, 1, tc, 10))
tc = self.ts + 3 * 3600000
- tdSql.execute("insert into %s%d values(%d, null)" %(self.perfix, 1, tc))
+ tdSql.execute("insert into %s%d(ts, c1) values(%d, null)" %(self.perfix, 1, tc))
tc = self.ts + 5 * 3600000
- tdSql.execute("insert into %s%d values(%d, %d)" %(self.perfix, 1, tc, -1))
+ tdSql.execute("insert into %s%d(ts, c1) values(%d, %d)" %(self.perfix, 1, tc, -1))
tc = self.ts + 7 * 3600000
- tdSql.execute("insert into %s%d values(%d, null)" %(self.perfix, 1, tc))
+ tdSql.execute("insert into %s%d(ts, c1) values(%d, null)" %(self.perfix, 1, tc))
def executeQueries2(self):
# For stable
@@ -164,6 +169,9 @@ class TDTestCase:
self.executeQueries()
self.insertData2()
self.executeQueries2()
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ self.executeQueries2()
tdSql.execute("alter database test2 cachelast 0")
self.executeQueries2()
diff --git a/tests/script/general/http/restful.sim b/tests/script/general/http/restful.sim
index fdde975238778176e447d01564851acc95b00c95..6ebf5644e7a99593ebac0302c3dcdbc0a27fc8c1 100644
--- a/tests/script/general/http/restful.sim
+++ b/tests/script/general/http/restful.sim
@@ -39,14 +39,14 @@ print =============== step3 - query data
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest' 127.0.0.1:7111/rest/sql
print curl 127.0.0.1:7111/rest/sql -----> $system_content
-if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10]],"rows":10}@ then
+if $system_content != @{"status":"succ","head":["ts","i"],"column_meta":[["ts",9,8],["i",4,4]],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10]],"rows":10}@ then
return -1
endi
print =============== step4 - insert data
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.table_rest values('2017-12-25 21:28:51.022', 11)" 127.0.0.1:7111/rest/sql
print curl 127.0.0.1:7111/rest/sql -----> $system_content
-if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[1]],"rows":1}@ then
return -1
endi
@@ -54,7 +54,7 @@ print =============== step5 - query data
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest' 127.0.0.1:7111/rest/sql
print curl 127.0.0.1:7111/rest/sql -----> $system_content
-if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then
+if $system_content != @{"status":"succ","head":["ts","i"],"column_meta":[["ts",9,8],["i",4,4]],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then
return -1
endi
@@ -79,4 +79,4 @@ if $system_content != @{"status":"error","code":3,"desc":"Authentication failure
return -1
endi
-system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
+system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/general/http/restful_full.sim b/tests/script/general/http/restful_full.sim
index 05f6a9ac9c372592b148ab83b211d733ced0dc9f..8094a943f507a702bb56a7d026da672134188b83 100644
--- a/tests/script/general/http/restful_full.sim
+++ b/tests/script/general/http/restful_full.sim
@@ -88,13 +88,13 @@ print =============== step2 - no db
#11
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql
print 11-> $system_content
-if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"data":[],"rows":0}@ then
+if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep(D)",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[],"rows":0}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d1' 127.0.0.1:7111/rest/sql
print 12-> $system_content
-if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then
return -1
endi
@@ -160,26 +160,26 @@ endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d1.t1 (ts timestamp, speed int)' 127.0.0.1:7111/rest/sql
print 22-> $system_content
-if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 127.0.0.1:7111/rest/sql
print 23-> $system_content
-if $system_content != @{"status":"succ","head":["ts","speed"],"data":[],"rows":0}@ then
+if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"data":[],"rows":0}@ then
return -1
endi
#24
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:41.022', 1)" 127.0.0.1:7111/rest/sql
print 24-> $system_content
-if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[1]],"rows":1}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 127.0.0.1:7111/rest/sql
print 25-> $system_content
-if $system_content != @{"status":"succ","head":["ts","speed"],"data":[["2017-12-25 21:28:41.022",1]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"data":[["2017-12-25 21:28:41.022",1]],"rows":1}@ then
return -1
endi
@@ -208,32 +208,32 @@ system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl
#27
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 127.0.0.1:7111/rest/sql
print 27-> $system_content
-if $system_content != @{"status":"succ","head":["ts","speed"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then
+if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d2' 127.0.0.1:7111/rest/sql
print 28-> $system_content
-if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d2.t1 (ts timestamp, speed int)' 127.0.0.1:7111/rest/sql
print 29-> $system_content
-if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then
return -1
endi
#30
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d2.t1 values('2017-12-25 21:28:41.022', 1)" 127.0.0.1:7111/rest/sql
print 30-> $system_content
-if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[1]],"rows":1}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d2.t1 ' 127.0.0.1:7111/rest/sql
print 31-> $system_content
-if $system_content != @{"status":"succ","head":["ts","speed"],"data":[["2017-12-25 21:28:41.022",1]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"data":[["2017-12-25 21:28:41.022",1]],"rows":1}@ then
return -1
endi
diff --git a/tests/script/general/http/telegraf.sim b/tests/script/general/http/telegraf.sim
index 6825e5c479774f2a8eca5df42d55910e12a975fd..f3426971864e6cf510ff6600b7731cf81f64f952 100644
--- a/tests/script/general/http/telegraf.sim
+++ b/tests/script/general/http/telegraf.sim
@@ -285,8 +285,8 @@ system_content curl -u root:taosdata -d 'select count(*) from db.win_cpu' 127.0
print $system_content
-if $system_content != @{"status":"succ","head":["count(*)"],"data":[[3]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["count(*)"],"column_meta":[["count(*)",5,8]],"data":[[3]],"rows":1}@ then
return -1
endi
-system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
+system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/general/user/monitor.sim b/tests/script/general/user/monitor.sim
index fe12df9baaf1f6ae3810e51d1fdc0020b67cbb40..016848c06d1a5a08f8e78a2e2ea8cdc5acc68744 100644
--- a/tests/script/general/user/monitor.sim
+++ b/tests/script/general/user/monitor.sim
@@ -15,18 +15,18 @@ print ========== step2
# return -1
#step21:
sql drop table log.dn -x step22
- return -1
+# return -1
step22:
sql drop user log -x step23
- return -1
+# return -1
step23:
print ========== step3
sleep 2000
-sql select * from log.dn
-if $rows == 0 then
- return -1
-endi
+#sql select * from log.dn
+#if $rows == 0 then
+# return -1
+#endi
-system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
+system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/unique/http/opentsdb.sim b/tests/script/unique/http/opentsdb.sim
index 3d8e5a8c4411f1ae92d04d95596b052c26fe6889..7d1e6b03d4547a6b0b2a6a7857000a8a6518a002 100644
--- a/tests/script/unique/http/opentsdb.sim
+++ b/tests/script/unique/http/opentsdb.sim
@@ -169,7 +169,7 @@ endi
system_content curl -u root:taosdata -d 'select * from db.sys_cpu_d_bbb_lga_1_web01' 127.0.0.1:7111/rest/sql/
print $system_content
-if $system_content != @{"status":"succ","head":["ts","value"],"data":[["2012-09-05 20:00:00.000",18.000000000]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["ts","value"],"column_meta":[["ts",9,8],["value",7,8]],"data":[["2012-09-05 20:00:00.000",18.000000000]],"rows":1}@ then
return -1
endi
@@ -186,7 +186,7 @@ system_content curl -u root:taosdata -d 'select * from db.sys_cpu_d_bbb_lga_1_w
print $system_content
-if $system_content != @{"status":"succ","head":["ts","value"],"data":[["2012-09-05 20:00:00.000",18.000000000],["2012-09-05 20:00:05.000",18.000000000]],"rows":2}@ then
+if $system_content != @{"status":"succ","head":["ts","value"],"column_meta":[["ts",9,8],["value",7,8]],"data":[["2012-09-05 20:00:00.000",18.000000000],["2012-09-05 20:00:05.000",18.000000000]],"rows":2}@ then
return -1
endi
@@ -194,7 +194,7 @@ system_content curl -u root:taosdata -d 'select count(*) from db.sys_cpu_d_bbb'
print $system_content
-if $system_content != @{"status":"succ","head":["count(*)"],"data":[[3]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["count(*)"],"column_meta":[["count(*)",5,8]],"data":[[3]],"rows":1}@ then
return -1
endi
@@ -211,7 +211,7 @@ system_content curl -u root:taosdata -d 'select * from db.sys_mem_d_bbb_lga_1_w
print $system_content
-if $system_content != @{"status":"succ","head":["ts","value"],"data":[["2012-09-05 20:00:00.000",8.000000000],["2012-09-05 20:00:05.000",9.000000000]],"rows":2}@ then
+if $system_content != @{"status":"succ","head":["ts","value"],"column_meta":[["ts",9,8],["value",7,8]],"data":[["2012-09-05 20:00:00.000",8.000000000],["2012-09-05 20:00:05.000",9.000000000]],"rows":2}@ then
return -1
endi
@@ -219,7 +219,7 @@ system_content curl -u root:taosdata -d 'select count(*) from db.sys_mem_d_bbb'
print $system_content
-if $system_content != @{"status":"succ","head":["count(*)"],"data":[[2]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["count(*)"],"column_meta":[["count(*)",5,8]],"data":[[2]],"rows":1}@ then
return -1
endi
@@ -233,7 +233,7 @@ system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 134
system_content curl -u root:taosdata -d 'select count(*) from db.sys_cpu_d_bbb' 127.0.0.1:7111/rest/sql/
print $system_content
-if $system_content != @{"status":"succ","head":["count(*)"],"data":[[7]],"rows":1}@ then
+if $system_content != @{"status":"succ","head":["count(*)"],"column_meta":[["count(*)",5,8]],"data":[[7]],"rows":1}@ then
return -1
endi
@@ -244,4 +244,4 @@ system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT
system sh/exec.sh -n dnode6 -s stop -x SIGINT
system sh/exec.sh -n dnode7 -s stop -x SIGINT
-system sh/exec.sh -n dnode8 -s stop -x SIGINT
\ No newline at end of file
+system sh/exec.sh -n dnode8 -s stop -x SIGINT
diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c
index 83ca46599cbb7e219bf1c67123373d81159db4ec..dbda5f1bbdd01a451376f8afe7717b7290980796 100644
--- a/tests/tsim/src/simExe.c
+++ b/tests/tsim/src/simExe.c
@@ -146,7 +146,7 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
int32_t simExecuteExpression(SScript *script, char *exp) {
char * op1, *op2, *var1, *var2, *var3, *rest;
int32_t op1Len, op2Len, var1Len, var2Len, var3Len, val0, val1;
- char t0[512], t1[512], t2[512], t3[1024];
+ char t0[1024], t1[1024], t2[1024], t3[2048];
int32_t result;
rest = paGetToken(exp, &var1, &var1Len);