未验证 提交 211c7f38 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

[TD-5398]<fix>: taosdemo 4096 columns table creation failed. (#6931)

* [TD-5398]<fix>: taosdemo 4096 columns table creation failed.

* change column name prefix from col to c for maxium column number to fix buffer length.

* use accurate buffer length.

* fix test case for column name be shorter.
Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 16b9fc88
...@@ -71,16 +71,15 @@ extern char configDir[]; ...@@ -71,16 +71,15 @@ extern char configDir[];
#define HEAD_BUFF_LEN TSDB_MAX_COLUMNS*24 // 16*MAX_COLUMNS + (192+32)*2 + insert into .. #define HEAD_BUFF_LEN TSDB_MAX_COLUMNS*24 // 16*MAX_COLUMNS + (192+32)*2 + insert into ..
#define MAX_SQL_SIZE 65536 #define COL_BUFFER_LEN (TSDB_MAX_BYTES_PER_ROW - 50)
#define BUFFER_SIZE (65536*2) #define BUFFER_SIZE (50 + TSDB_DB_NAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_MAX_BYTES_PER_ROW + TSDB_MAX_TAGS_LEN)
#define COND_BUF_LEN (BUFFER_SIZE - 30) #define COND_BUF_LEN (BUFFER_SIZE - 30)
#define MAX_USERNAME_SIZE 64 #define MAX_USERNAME_SIZE 64
#define MAX_PASSWORD_SIZE 64 #define MAX_PASSWORD_SIZE 64
#define MAX_HOSTNAME_SIZE 64 #define MAX_HOSTNAME_SIZE 64
#define MAX_TB_NAME_SIZE 64 #define MAX_TB_NAME_SIZE 64
#define MAX_DATA_SIZE (16*TSDB_MAX_COLUMNS)+20 // max record len: 16*MAX_COLUMNS, timestamp string and ,('') need extra space #define MAX_DATA_SIZE (16*TSDB_MAX_COLUMNS)+20 // max record len: 16*MAX_COLUMNS, timestamp string and ,('') need extra space
#define OPT_ABORT 1 /* –abort */ #define OPT_ABORT 1 /* –abort */
#define STRING_LEN 60000
#define MAX_PREPARED_RAND 1000000 #define MAX_PREPARED_RAND 1000000
#define MAX_FILE_NAME_LEN 256 // max file name length on linux is 255. #define MAX_FILE_NAME_LEN 256 // max file name length on linux is 255.
...@@ -2710,7 +2709,7 @@ static int createSuperTable( ...@@ -2710,7 +2709,7 @@ static int createSuperTable(
char command[BUFFER_SIZE] = "\0"; char command[BUFFER_SIZE] = "\0";
char cols[STRING_LEN] = "\0"; char cols[COL_BUFFER_LEN] = "\0";
int colIndex; int colIndex;
int len = 0; int len = 0;
...@@ -2726,55 +2725,55 @@ static int createSuperTable( ...@@ -2726,55 +2725,55 @@ static int createSuperTable(
char* dataType = superTbl->columns[colIndex].dataType; char* dataType = superTbl->columns[colIndex].dataType;
if (strcasecmp(dataType, "BINARY") == 0) { if (strcasecmp(dataType, "BINARY") == 0) {
len += snprintf(cols + len, STRING_LEN - len, len += snprintf(cols + len, COL_BUFFER_LEN - len,
", col%d %s(%d)", colIndex, "BINARY", ", C%d %s(%d)", colIndex, "BINARY",
superTbl->columns[colIndex].dataLen); superTbl->columns[colIndex].dataLen);
lenOfOneRow += superTbl->columns[colIndex].dataLen + 3; lenOfOneRow += superTbl->columns[colIndex].dataLen + 3;
} else if (strcasecmp(dataType, "NCHAR") == 0) { } else if (strcasecmp(dataType, "NCHAR") == 0) {
len += snprintf(cols + len, STRING_LEN - len, len += snprintf(cols + len, COL_BUFFER_LEN - len,
", col%d %s(%d)", colIndex, "NCHAR", ", C%d %s(%d)", colIndex, "NCHAR",
superTbl->columns[colIndex].dataLen); superTbl->columns[colIndex].dataLen);
lenOfOneRow += superTbl->columns[colIndex].dataLen + 3; lenOfOneRow += superTbl->columns[colIndex].dataLen + 3;
} else if (strcasecmp(dataType, "INT") == 0) { } else if (strcasecmp(dataType, "INT") == 0) {
if ((g_args.demo_mode) && (colIndex == 1)) { if ((g_args.demo_mode) && (colIndex == 1)) {
len += snprintf(cols + len, STRING_LEN - len, len += snprintf(cols + len, COL_BUFFER_LEN - len,
", VOLTAGE INT"); ", VOLTAGE INT");
} else { } else {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "INT"); len += snprintf(cols + len, COL_BUFFER_LEN - len, ", C%d %s", colIndex, "INT");
} }
lenOfOneRow += 11; lenOfOneRow += 11;
} else if (strcasecmp(dataType, "BIGINT") == 0) { } else if (strcasecmp(dataType, "BIGINT") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", len += snprintf(cols + len, COL_BUFFER_LEN - len, ", C%d %s",
colIndex, "BIGINT"); colIndex, "BIGINT");
lenOfOneRow += 21; lenOfOneRow += 21;
} else if (strcasecmp(dataType, "SMALLINT") == 0) { } else if (strcasecmp(dataType, "SMALLINT") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", len += snprintf(cols + len, COL_BUFFER_LEN - len, ", C%d %s",
colIndex, "SMALLINT"); colIndex, "SMALLINT");
lenOfOneRow += 6; lenOfOneRow += 6;
} else if (strcasecmp(dataType, "TINYINT") == 0) { } else if (strcasecmp(dataType, "TINYINT") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "TINYINT"); len += snprintf(cols + len, COL_BUFFER_LEN - len, ", C%d %s", colIndex, "TINYINT");
lenOfOneRow += 4; lenOfOneRow += 4;
} else if (strcasecmp(dataType, "BOOL") == 0) { } else if (strcasecmp(dataType, "BOOL") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "BOOL"); len += snprintf(cols + len, COL_BUFFER_LEN - len, ", C%d %s", colIndex, "BOOL");
lenOfOneRow += 6; lenOfOneRow += 6;
} else if (strcasecmp(dataType, "FLOAT") == 0) { } else if (strcasecmp(dataType, "FLOAT") == 0) {
if (g_args.demo_mode) { if (g_args.demo_mode) {
if (colIndex == 0) { if (colIndex == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", CURRENT FLOAT"); len += snprintf(cols + len, COL_BUFFER_LEN - len, ", CURRENT FLOAT");
} else if (colIndex == 2) { } else if (colIndex == 2) {
len += snprintf(cols + len, STRING_LEN - len, ", PHASE FLOAT"); len += snprintf(cols + len, COL_BUFFER_LEN - len, ", PHASE FLOAT");
} }
} else { } else {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "FLOAT"); len += snprintf(cols + len, COL_BUFFER_LEN - len, ", C%d %s", colIndex, "FLOAT");
} }
lenOfOneRow += 22; lenOfOneRow += 22;
} else if (strcasecmp(dataType, "DOUBLE") == 0) { } else if (strcasecmp(dataType, "DOUBLE") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", len += snprintf(cols + len, COL_BUFFER_LEN - len, ", C%d %s",
colIndex, "DOUBLE"); colIndex, "DOUBLE");
lenOfOneRow += 42; lenOfOneRow += 42;
} else if (strcasecmp(dataType, "TIMESTAMP") == 0) { } else if (strcasecmp(dataType, "TIMESTAMP") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", len += snprintf(cols + len, COL_BUFFER_LEN - len, ", C%d %s",
colIndex, "TIMESTAMP"); colIndex, "TIMESTAMP");
lenOfOneRow += 21; lenOfOneRow += 21;
} else { } else {
...@@ -2806,60 +2805,63 @@ static int createSuperTable( ...@@ -2806,60 +2805,63 @@ static int createSuperTable(
return -1; return -1;
} }
char tags[STRING_LEN] = "\0"; char tags[TSDB_MAX_TAGS_LEN] = "\0";
int tagIndex; int tagIndex;
len = 0; len = 0;
int lenOfTagOfOneRow = 0; int lenOfTagOfOneRow = 0;
len += snprintf(tags + len, STRING_LEN - len, "("); len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len, "(");
for (tagIndex = 0; tagIndex < superTbl->tagCount; tagIndex++) { for (tagIndex = 0; tagIndex < superTbl->tagCount; tagIndex++) {
char* dataType = superTbl->tags[tagIndex].dataType; char* dataType = superTbl->tags[tagIndex].dataType;
if (strcasecmp(dataType, "BINARY") == 0) { if (strcasecmp(dataType, "BINARY") == 0) {
if ((g_args.demo_mode) && (tagIndex == 1)) { if ((g_args.demo_mode) && (tagIndex == 1)) {
len += snprintf(tags + len, STRING_LEN - len, len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"location BINARY(%d), ", "location BINARY(%d), ",
superTbl->tags[tagIndex].dataLen); superTbl->tags[tagIndex].dataLen);
} else { } else {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s(%d), ", len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
tagIndex, "BINARY", superTbl->tags[tagIndex].dataLen); "t%d %s(%d), ", tagIndex, "BINARY",
superTbl->tags[tagIndex].dataLen);
} }
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 3; lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 3;
} else if (strcasecmp(dataType, "NCHAR") == 0) { } else if (strcasecmp(dataType, "NCHAR") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s(%d), ", tagIndex, len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"t%d %s(%d), ", tagIndex,
"NCHAR", superTbl->tags[tagIndex].dataLen); "NCHAR", superTbl->tags[tagIndex].dataLen);
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 3; lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 3;
} else if (strcasecmp(dataType, "INT") == 0) { } else if (strcasecmp(dataType, "INT") == 0) {
if ((g_args.demo_mode) && (tagIndex == 0)) { if ((g_args.demo_mode) && (tagIndex == 0)) {
len += snprintf(tags + len, STRING_LEN - len, "groupId INT, "); len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"groupId INT, ");
} else { } else {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex, len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"INT"); "t%d %s, ", tagIndex, "INT");
} }
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 11; lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 11;
} else if (strcasecmp(dataType, "BIGINT") == 0) { } else if (strcasecmp(dataType, "BIGINT") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex, len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"BIGINT"); "t%d %s, ", tagIndex, "BIGINT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 21; lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 21;
} else if (strcasecmp(dataType, "SMALLINT") == 0) { } else if (strcasecmp(dataType, "SMALLINT") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex, len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"SMALLINT"); "t%d %s, ", tagIndex, "SMALLINT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 6; lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 6;
} else if (strcasecmp(dataType, "TINYINT") == 0) { } else if (strcasecmp(dataType, "TINYINT") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex, len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"TINYINT"); "t%d %s, ", tagIndex, "TINYINT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 4; lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 4;
} else if (strcasecmp(dataType, "BOOL") == 0) { } else if (strcasecmp(dataType, "BOOL") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex, len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"BOOL"); "t%d %s, ", tagIndex, "BOOL");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 6; lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 6;
} else if (strcasecmp(dataType, "FLOAT") == 0) { } else if (strcasecmp(dataType, "FLOAT") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex, len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"FLOAT"); "t%d %s, ", tagIndex, "FLOAT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 22; lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 22;
} else if (strcasecmp(dataType, "DOUBLE") == 0) { } else if (strcasecmp(dataType, "DOUBLE") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex, len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"DOUBLE"); "t%d %s, ", tagIndex, "DOUBLE");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 42; lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 42;
} else { } else {
taos_close(taos); taos_close(taos);
...@@ -2870,7 +2872,7 @@ static int createSuperTable( ...@@ -2870,7 +2872,7 @@ static int createSuperTable(
} }
len -= 2; len -= 2;
len += snprintf(tags + len, STRING_LEN - len, ")"); len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len, ")");
superTbl->lenOfTagOfOneRow = lenOfTagOfOneRow; superTbl->lenOfTagOfOneRow = lenOfTagOfOneRow;
...@@ -3023,175 +3025,175 @@ static int createDatabasesAndStables() { ...@@ -3023,175 +3025,175 @@ static int createDatabasesAndStables() {
static void* createTable(void *sarg) static void* createTable(void *sarg)
{ {
threadInfo *pThreadInfo = (threadInfo *)sarg; threadInfo *pThreadInfo = (threadInfo *)sarg;
SSuperTable* superTblInfo = pThreadInfo->superTblInfo; SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
uint64_t lastPrintTime = taosGetTimestampMs(); uint64_t lastPrintTime = taosGetTimestampMs();
int buff_len; int buff_len;
buff_len = BUFFER_SIZE / 8; buff_len = BUFFER_SIZE;
pThreadInfo->buffer = calloc(buff_len, 1); pThreadInfo->buffer = calloc(buff_len, 1);
if (pThreadInfo->buffer == NULL) { if (pThreadInfo->buffer == NULL) {
errorPrint("%s() LN%d, Memory allocated failed!\n", __func__, __LINE__); errorPrint("%s() LN%d, Memory allocated failed!\n", __func__, __LINE__);
exit(-1);
}
int len = 0;
int batchNum = 0;
verbosePrint("%s() LN%d: Creating table from %"PRIu64" to %"PRIu64"\n",
__func__, __LINE__,
pThreadInfo->start_table_from, pThreadInfo->end_table_to);
for (uint64_t i = pThreadInfo->start_table_from;
i <= pThreadInfo->end_table_to; i++) {
if (0 == g_Dbs.use_metric) {
snprintf(pThreadInfo->buffer, buff_len,
"create table if not exists %s.%s%"PRIu64" %s;",
pThreadInfo->db_name,
g_args.tb_prefix, i,
pThreadInfo->cols);
} else {
if (superTblInfo == NULL) {
errorPrint("%s() LN%d, use metric, but super table info is NULL\n",
__func__, __LINE__);
free(pThreadInfo->buffer);
exit(-1); exit(-1);
} else { }
if (0 == len) {
batchNum = 0; int len = 0;
memset(pThreadInfo->buffer, 0, buff_len); int batchNum = 0;
len += snprintf(pThreadInfo->buffer + len,
buff_len - len, "create table "); verbosePrint("%s() LN%d: Creating table from %"PRIu64" to %"PRIu64"\n",
} __func__, __LINE__,
char* tagsValBuf = NULL; pThreadInfo->start_table_from, pThreadInfo->end_table_to);
if (0 == superTblInfo->tagSource) {
tagsValBuf = generateTagVaulesForStb(superTblInfo, i); for (uint64_t i = pThreadInfo->start_table_from;
i <= pThreadInfo->end_table_to; i++) {
if (0 == g_Dbs.use_metric) {
snprintf(pThreadInfo->buffer, buff_len,
"create table if not exists %s.%s%"PRIu64" %s;",
pThreadInfo->db_name,
g_args.tb_prefix, i,
pThreadInfo->cols);
} else { } else {
tagsValBuf = getTagValueFromTagSample( if (superTblInfo == NULL) {
superTblInfo, errorPrint("%s() LN%d, use metric, but super table info is NULL\n",
i % superTblInfo->tagSampleCount); __func__, __LINE__);
} free(pThreadInfo->buffer);
if (NULL == tagsValBuf) { exit(-1);
free(pThreadInfo->buffer); } else {
return NULL; if (0 == len) {
} batchNum = 0;
len += snprintf(pThreadInfo->buffer + len, memset(pThreadInfo->buffer, 0, buff_len);
buff_len - len, len += snprintf(pThreadInfo->buffer + len,
"if not exists %s.%s%"PRIu64" using %s.%s tags %s ", buff_len - len, "create table ");
pThreadInfo->db_name, superTblInfo->childTblPrefix, }
i, pThreadInfo->db_name, char* tagsValBuf = NULL;
superTblInfo->sTblName, tagsValBuf); if (0 == superTblInfo->tagSource) {
free(tagsValBuf); tagsValBuf = generateTagVaulesForStb(superTblInfo, i);
batchNum++; } else {
if ((batchNum < superTblInfo->batchCreateTableNum) tagsValBuf = getTagValueFromTagSample(
&& ((buff_len - len) superTblInfo,
>= (superTblInfo->lenOfTagOfOneRow + 256))) { i % superTblInfo->tagSampleCount);
continue; }
if (NULL == tagsValBuf) {
free(pThreadInfo->buffer);
return NULL;
}
len += snprintf(pThreadInfo->buffer + len,
buff_len - len,
"if not exists %s.%s%"PRIu64" using %s.%s tags %s ",
pThreadInfo->db_name, superTblInfo->childTblPrefix,
i, pThreadInfo->db_name,
superTblInfo->sTblName, tagsValBuf);
free(tagsValBuf);
batchNum++;
if ((batchNum < superTblInfo->batchCreateTableNum)
&& ((buff_len - len)
>= (superTblInfo->lenOfTagOfOneRow + 256))) {
continue;
}
}
} }
}
}
len = 0; len = 0;
if (0 != queryDbExec(pThreadInfo->taos, pThreadInfo->buffer, if (0 != queryDbExec(pThreadInfo->taos, pThreadInfo->buffer,
NO_INSERT_TYPE, false)){ NO_INSERT_TYPE, false)){
errorPrint( "queryDbExec() failed. buffer:\n%s\n", pThreadInfo->buffer); errorPrint( "queryDbExec() failed. buffer:\n%s\n", pThreadInfo->buffer);
free(pThreadInfo->buffer); free(pThreadInfo->buffer);
return NULL; return NULL;
} }
uint64_t currentPrintTime = taosGetTimestampMs(); uint64_t currentPrintTime = taosGetTimestampMs();
if (currentPrintTime - lastPrintTime > 30*1000) { if (currentPrintTime - lastPrintTime > 30*1000) {
printf("thread[%d] already create %"PRIu64" - %"PRIu64" tables\n", printf("thread[%d] already create %"PRIu64" - %"PRIu64" tables\n",
pThreadInfo->threadID, pThreadInfo->start_table_from, i); pThreadInfo->threadID, pThreadInfo->start_table_from, i);
lastPrintTime = currentPrintTime; lastPrintTime = currentPrintTime;
}
} }
}
if (0 != len) { if (0 != len) {
if (0 != queryDbExec(pThreadInfo->taos, pThreadInfo->buffer, if (0 != queryDbExec(pThreadInfo->taos, pThreadInfo->buffer,
NO_INSERT_TYPE, false)) { NO_INSERT_TYPE, false)) {
errorPrint( "queryDbExec() failed. buffer:\n%s\n", pThreadInfo->buffer); errorPrint( "queryDbExec() failed. buffer:\n%s\n", pThreadInfo->buffer);
}
} }
}
free(pThreadInfo->buffer); free(pThreadInfo->buffer);
return NULL; return NULL;
} }
static int startMultiThreadCreateChildTable( static int startMultiThreadCreateChildTable(
char* cols, int threads, uint64_t tableFrom, int64_t ntables, char* cols, int threads, uint64_t tableFrom, int64_t ntables,
char* db_name, SSuperTable* superTblInfo) { char* db_name, SSuperTable* superTblInfo) {
pthread_t *pids = calloc(1, threads * sizeof(pthread_t)); pthread_t *pids = calloc(1, threads * sizeof(pthread_t));
threadInfo *infos = calloc(1, threads * sizeof(threadInfo)); threadInfo *infos = calloc(1, threads * sizeof(threadInfo));
if ((NULL == pids) || (NULL == infos)) {
printf("malloc failed\n");
exit(-1);
}
if (threads < 1) { if ((NULL == pids) || (NULL == infos)) {
threads = 1; printf("malloc failed\n");
} exit(-1);
}
int64_t a = ntables / threads; if (threads < 1) {
if (a < 1) { threads = 1;
threads = ntables; }
a = 1;
}
int64_t b = 0; int64_t a = ntables / threads;
b = ntables % threads; if (a < 1) {
threads = ntables;
for (int64_t i = 0; i < threads; i++) { a = 1;
threadInfo *pThreadInfo = infos + i;
pThreadInfo->threadID = i;
tstrncpy(pThreadInfo->db_name, db_name, TSDB_DB_NAME_LEN);
pThreadInfo->superTblInfo = superTblInfo;
verbosePrint("%s() %d db_name: %s\n", __func__, __LINE__, db_name);
pThreadInfo->taos = taos_connect(
g_Dbs.host,
g_Dbs.user,
g_Dbs.password,
db_name,
g_Dbs.port);
if (pThreadInfo->taos == NULL) {
errorPrint( "%s() LN%d, Failed to connect to TDengine, reason:%s\n",
__func__, __LINE__, taos_errstr(NULL));
free(pids);
free(infos);
return -1;
} }
pThreadInfo->start_table_from = tableFrom; int64_t b = 0;
pThreadInfo->ntables = i<b?a+1:a; b = ntables % threads;
pThreadInfo->end_table_to = i < b ? tableFrom + a : tableFrom + a - 1;
tableFrom = pThreadInfo->end_table_to + 1;
pThreadInfo->use_metric = true;
pThreadInfo->cols = cols;
pThreadInfo->minDelay = UINT64_MAX;
pthread_create(pids + i, NULL, createTable, pThreadInfo);
}
for (int i = 0; i < threads; i++) { for (int64_t i = 0; i < threads; i++) {
pthread_join(pids[i], NULL); threadInfo *pThreadInfo = infos + i;
} pThreadInfo->threadID = i;
tstrncpy(pThreadInfo->db_name, db_name, TSDB_DB_NAME_LEN);
pThreadInfo->superTblInfo = superTblInfo;
verbosePrint("%s() %d db_name: %s\n", __func__, __LINE__, db_name);
pThreadInfo->taos = taos_connect(
g_Dbs.host,
g_Dbs.user,
g_Dbs.password,
db_name,
g_Dbs.port);
if (pThreadInfo->taos == NULL) {
errorPrint( "%s() LN%d, Failed to connect to TDengine, reason:%s\n",
__func__, __LINE__, taos_errstr(NULL));
free(pids);
free(infos);
return -1;
}
for (int i = 0; i < threads; i++) { pThreadInfo->start_table_from = tableFrom;
threadInfo *pThreadInfo = infos + i; pThreadInfo->ntables = i<b?a+1:a;
taos_close(pThreadInfo->taos); pThreadInfo->end_table_to = i < b ? tableFrom + a : tableFrom + a - 1;
} tableFrom = pThreadInfo->end_table_to + 1;
pThreadInfo->use_metric = true;
pThreadInfo->cols = cols;
pThreadInfo->minDelay = UINT64_MAX;
pthread_create(pids + i, NULL, createTable, pThreadInfo);
}
free(pids); for (int i = 0; i < threads; i++) {
free(infos); pthread_join(pids[i], NULL);
}
return 0; for (int i = 0; i < threads; i++) {
threadInfo *pThreadInfo = infos + i;
taos_close(pThreadInfo->taos);
}
free(pids);
free(infos);
return 0;
} }
static void createChildTables() { static void createChildTables() {
char tblColsBuf[MAX_SQL_SIZE]; char tblColsBuf[TSDB_MAX_BYTES_PER_ROW];
int len; int len;
for (int i = 0; i < g_Dbs.dbCount; i++) { for (int i = 0; i < g_Dbs.dbCount; i++) {
...@@ -3223,21 +3225,21 @@ static void createChildTables() { ...@@ -3223,21 +3225,21 @@ static void createChildTables() {
} }
} else { } else {
// normal table // normal table
len = snprintf(tblColsBuf, MAX_SQL_SIZE, "(TS TIMESTAMP"); len = snprintf(tblColsBuf, TSDB_MAX_BYTES_PER_ROW, "(TS TIMESTAMP");
for (int j = 0; j < g_args.num_of_CPR; j++) { for (int j = 0; j < g_args.num_of_CPR; j++) {
if ((strncasecmp(g_args.datatype[j], "BINARY", strlen("BINARY")) == 0) if ((strncasecmp(g_args.datatype[j], "BINARY", strlen("BINARY")) == 0)
|| (strncasecmp(g_args.datatype[j], || (strncasecmp(g_args.datatype[j],
"NCHAR", strlen("NCHAR")) == 0)) { "NCHAR", strlen("NCHAR")) == 0)) {
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, snprintf(tblColsBuf + len, TSDB_MAX_BYTES_PER_ROW - len,
", COL%d %s(%d)", j, g_args.datatype[j], g_args.len_of_binary); ",C%d %s(%d)", j, g_args.datatype[j], g_args.len_of_binary);
} else { } else {
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, snprintf(tblColsBuf + len, TSDB_MAX_BYTES_PER_ROW - len,
", COL%d %s", j, g_args.datatype[j]); ",C%d %s", j, g_args.datatype[j]);
} }
len = strlen(tblColsBuf); len = strlen(tblColsBuf);
} }
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, ")"); snprintf(tblColsBuf + len, TSDB_MAX_BYTES_PER_ROW - len, ")");
verbosePrint("%s() LN%d: dbName: %s num of tb: %"PRId64" schema: %s\n", verbosePrint("%s() LN%d: dbName: %s num of tb: %"PRId64" schema: %s\n",
__func__, __LINE__, __func__, __LINE__,
...@@ -7989,7 +7991,7 @@ static void initOfQueryMeta() { ...@@ -7989,7 +7991,7 @@ static void initOfQueryMeta() {
tstrncpy(g_queryInfo.password, TSDB_DEFAULT_PASS, MAX_PASSWORD_SIZE); tstrncpy(g_queryInfo.password, TSDB_DEFAULT_PASS, MAX_PASSWORD_SIZE);
} }
static void setParaFromArg(){ static void setParaFromArg() {
if (g_args.host) { if (g_args.host) {
tstrncpy(g_Dbs.host, g_args.host, MAX_HOSTNAME_SIZE); tstrncpy(g_Dbs.host, g_args.host, MAX_HOSTNAME_SIZE);
} else { } else {
...@@ -8025,10 +8027,10 @@ static void setParaFromArg(){ ...@@ -8025,10 +8027,10 @@ static void setParaFromArg(){
g_Dbs.do_aggreFunc = true; g_Dbs.do_aggreFunc = true;
char dataString[STRING_LEN]; char dataString[TSDB_MAX_BYTES_PER_ROW];
char **data_type = g_args.datatype; char **data_type = g_args.datatype;
memset(dataString, 0, STRING_LEN); memset(dataString, 0, TSDB_MAX_BYTES_PER_ROW);
if (strcasecmp(data_type[0], "BINARY") == 0 if (strcasecmp(data_type[0], "BINARY") == 0
|| strcasecmp(data_type[0], "BOOL") == 0 || strcasecmp(data_type[0], "BOOL") == 0
...@@ -8146,7 +8148,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile) ...@@ -8146,7 +8148,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile)
} }
int read_len = 0; int read_len = 0;
char * cmd = calloc(1, MAX_SQL_SIZE); char * cmd = calloc(1, TSDB_MAX_BYTES_PER_ROW);
size_t cmd_len = 0; size_t cmd_len = 0;
char * line = NULL; char * line = NULL;
size_t line_len = 0; size_t line_len = 0;
...@@ -8154,7 +8156,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile) ...@@ -8154,7 +8156,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile)
double t = taosGetTimestampMs(); double t = taosGetTimestampMs();
while((read_len = tgetline(&line, &line_len, fp)) != -1) { while((read_len = tgetline(&line, &line_len, fp)) != -1) {
if (read_len >= MAX_SQL_SIZE) continue; if (read_len >= TSDB_MAX_BYTES_PER_ROW) continue;
line[--read_len] = '\0'; line[--read_len] = '\0';
if (read_len == 0 || isCommentLine(line)) { // line starts with # if (read_len == 0 || isCommentLine(line)) { // line starts with #
...@@ -8177,7 +8179,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile) ...@@ -8177,7 +8179,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile)
tmfclose(fp); tmfclose(fp);
return; return;
} }
memset(cmd, 0, MAX_SQL_SIZE); memset(cmd, 0, TSDB_MAX_BYTES_PER_ROW);
cmd_len = 0; cmd_len = 0;
} }
......
...@@ -187,19 +187,19 @@ class TDTestCase: ...@@ -187,19 +187,19 @@ class TDTestCase:
"select * from t9 where t9.ts > '1969-12-31 22:00:00.000' and t9.ts <'1970-01-01 02:00:00.000' " "select * from t9 where t9.ts > '1969-12-31 22:00:00.000' and t9.ts <'1970-01-01 02:00:00.000' "
) )
tdSql.checkRows(719) tdSql.checkRows(719)
tdSql.query( tdSql.query(
"select * from t0,t1 where t0.ts=t1.ts and t1.ts >= '1970-01-01 00:00:00.000' " "select * from t0,t1 where t0.ts=t1.ts and t1.ts >= '1970-01-01 00:00:00.000' "
) )
tdSql.checkRows(680) tdSql.checkRows(680)
tdSql.query( tdSql.query(
"select diff(col1) from t0 where t0.ts >= '1970-01-01 00:00:00.000' " "select diff(c1) from t0 where t0.ts >= '1970-01-01 00:00:00.000' "
) )
tdSql.checkRows(679) tdSql.checkRows(679)
tdSql.query( tdSql.query(
"select t0,col1 from stb2 where stb2.ts < '1970-01-01 00:00:00.000' order by ts" "select t0,c1 from stb2 where stb2.ts < '1970-01-01 00:00:00.000' order by ts"
) )
tdSql.checkRows(43200) tdSql.checkRows(43200)
......
...@@ -23,7 +23,7 @@ class TDTestCase: ...@@ -23,7 +23,7 @@ class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -39,7 +39,7 @@ class TDTestCase: ...@@ -39,7 +39,7 @@ class TDTestCase:
buildPath = root[:len(root)-len("/build/bin")] buildPath = root[:len(root)-len("/build/bin")]
break break
return buildPath return buildPath
def run(self): def run(self):
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
if (buildPath == ""): if (buildPath == ""):
...@@ -48,7 +48,7 @@ class TDTestCase: ...@@ -48,7 +48,7 @@ class TDTestCase:
tdLog.info("taosd found in %s" % buildPath) tdLog.info("taosd found in %s" % buildPath)
binPath = buildPath+ "/build/bin/" binPath = buildPath+ "/build/bin/"
# insert: create one or mutiple tables per sql and insert multiple rows per sql # insert: create one or mutiple tables per sql and insert multiple rows per sql
# test case for https://jira.taosdata.com:18080/browse/TD-4985 # test case for https://jira.taosdata.com:18080/browse/TD-4985
os.system("%staosdemo -f tools/taosdemoAllTest/TD-4985/query-limit-offset.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/TD-4985/query-limit-offset.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
...@@ -56,27 +56,27 @@ class TDTestCase: ...@@ -56,27 +56,27 @@ class TDTestCase:
tdSql.checkData(0, 0, 10000) tdSql.checkData(0, 0, 10000)
for i in range(1000): for i in range(1000):
tdSql.execute('''insert into stb00_9999 values(%d, %d, %d,'test99.%s')''' tdSql.execute('''insert into stb00_9999 values(%d, %d, %d,'test99.%s')'''
% (1600000000000 + i, i, -10000+i, i)) % (1600000000000 + i, i, -10000+i, i))
tdSql.execute('''insert into stb00_8888 values(%d, %d, %d,'test98.%s')''' tdSql.execute('''insert into stb00_8888 values(%d, %d, %d,'test98.%s')'''
% (1600000000000 + i, i, -10000+i, i)) % (1600000000000 + i, i, -10000+i, i))
tdSql.execute('''insert into stb00_7777 values(%d, %d, %d,'test97.%s')''' tdSql.execute('''insert into stb00_7777 values(%d, %d, %d,'test97.%s')'''
% (1600000000000 + i, i, -10000+i, i)) % (1600000000000 + i, i, -10000+i, i))
tdSql.execute('''insert into stb00_6666 values(%d, %d, %d,'test96.%s')''' tdSql.execute('''insert into stb00_6666 values(%d, %d, %d,'test96.%s')'''
% (1600000000000 + i, i, -10000+i, i)) % (1600000000000 + i, i, -10000+i, i))
tdSql.execute('''insert into stb00_5555 values(%d, %d, %d,'test95.%s')''' tdSql.execute('''insert into stb00_5555 values(%d, %d, %d,'test95.%s')'''
% (1600000000000 + i, i, -10000+i, i)) % (1600000000000 + i, i, -10000+i, i))
tdSql.execute('''insert into stb00_4444 values(%d, %d, %d,'test94.%s')''' tdSql.execute('''insert into stb00_4444 values(%d, %d, %d,'test94.%s')'''
% (1600000000000 + i, i, -10000+i, i)) % (1600000000000 + i, i, -10000+i, i))
tdSql.execute('''insert into stb00_3333 values(%d, %d, %d,'test93.%s')''' tdSql.execute('''insert into stb00_3333 values(%d, %d, %d,'test93.%s')'''
% (1600000000000 + i, i, -10000+i, i)) % (1600000000000 + i, i, -10000+i, i))
tdSql.execute('''insert into stb00_2222 values(%d, %d, %d,'test92.%s')''' tdSql.execute('''insert into stb00_2222 values(%d, %d, %d,'test92.%s')'''
% (1600000000000 + i, i, -10000+i, i)) % (1600000000000 + i, i, -10000+i, i))
tdSql.execute('''insert into stb00_1111 values(%d, %d, %d,'test91.%s')''' tdSql.execute('''insert into stb00_1111 values(%d, %d, %d,'test91.%s')'''
% (1600000000000 + i, i, -10000+i, i)) % (1600000000000 + i, i, -10000+i, i))
tdSql.execute('''insert into stb00_100 values(%d, %d, %d,'test90.%s')''' tdSql.execute('''insert into stb00_100 values(%d, %d, %d,'test90.%s')'''
% (1600000000000 + i, i, -10000+i, i)) % (1600000000000 + i, i, -10000+i, i))
tdSql.query("select * from stb0 where col2 like 'test99%' ") tdSql.query("select * from stb0 where c2 like 'test99%' ")
tdSql.checkRows(1000) tdSql.checkRows(1000)
tdSql.query("select * from stb0 where tbname like 'stb00_9999' limit 10" ) tdSql.query("select * from stb0 where tbname like 'stb00_9999' limit 10" )
tdSql.checkData(0, 1, 0) tdSql.checkData(0, 1, 0)
...@@ -86,7 +86,7 @@ class TDTestCase: ...@@ -86,7 +86,7 @@ class TDTestCase:
tdSql.checkData(0, 1, 5) tdSql.checkData(0, 1, 5)
tdSql.checkData(1, 1, 6) tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 7) tdSql.checkData(2, 1, 7)
tdSql.query("select * from stb0 where col2 like 'test98%' ") tdSql.query("select * from stb0 where c2 like 'test98%' ")
tdSql.checkRows(1000) tdSql.checkRows(1000)
tdSql.query("select * from stb0 where tbname like 'stb00_8888' limit 10" ) tdSql.query("select * from stb0 where tbname like 'stb00_8888' limit 10" )
tdSql.checkData(0, 1, 0) tdSql.checkData(0, 1, 0)
...@@ -96,7 +96,7 @@ class TDTestCase: ...@@ -96,7 +96,7 @@ class TDTestCase:
tdSql.checkData(0, 1, 5) tdSql.checkData(0, 1, 5)
tdSql.checkData(1, 1, 6) tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 7) tdSql.checkData(2, 1, 7)
tdSql.query("select * from stb0 where col2 like 'test97%' ") tdSql.query("select * from stb0 where c2 like 'test97%' ")
tdSql.checkRows(1000) tdSql.checkRows(1000)
tdSql.query("select * from stb0 where tbname like 'stb00_7777' limit 10" ) tdSql.query("select * from stb0 where tbname like 'stb00_7777' limit 10" )
tdSql.checkData(0, 1, 0) tdSql.checkData(0, 1, 0)
...@@ -106,7 +106,7 @@ class TDTestCase: ...@@ -106,7 +106,7 @@ class TDTestCase:
tdSql.checkData(0, 1, 5) tdSql.checkData(0, 1, 5)
tdSql.checkData(1, 1, 6) tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 7) tdSql.checkData(2, 1, 7)
tdSql.query("select * from stb0 where col2 like 'test96%' ") tdSql.query("select * from stb0 where c2 like 'test96%' ")
tdSql.checkRows(1000) tdSql.checkRows(1000)
tdSql.query("select * from stb0 where tbname like 'stb00_6666' limit 10" ) tdSql.query("select * from stb0 where tbname like 'stb00_6666' limit 10" )
tdSql.checkData(0, 1, 0) tdSql.checkData(0, 1, 0)
...@@ -116,7 +116,7 @@ class TDTestCase: ...@@ -116,7 +116,7 @@ class TDTestCase:
tdSql.checkData(0, 1, 5) tdSql.checkData(0, 1, 5)
tdSql.checkData(1, 1, 6) tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 7) tdSql.checkData(2, 1, 7)
tdSql.query("select * from stb0 where col2 like 'test95%' ") tdSql.query("select * from stb0 where c2 like 'test95%' ")
tdSql.checkRows(1000) tdSql.checkRows(1000)
tdSql.query("select * from stb0 where tbname like 'stb00_5555' limit 10" ) tdSql.query("select * from stb0 where tbname like 'stb00_5555' limit 10" )
tdSql.checkData(0, 1, 0) tdSql.checkData(0, 1, 0)
...@@ -126,7 +126,7 @@ class TDTestCase: ...@@ -126,7 +126,7 @@ class TDTestCase:
tdSql.checkData(0, 1, 5) tdSql.checkData(0, 1, 5)
tdSql.checkData(1, 1, 6) tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 7) tdSql.checkData(2, 1, 7)
tdSql.query("select * from stb0 where col2 like 'test94%' ") tdSql.query("select * from stb0 where c2 like 'test94%' ")
tdSql.checkRows(1000) tdSql.checkRows(1000)
tdSql.query("select * from stb0 where tbname like 'stb00_4444' limit 10" ) tdSql.query("select * from stb0 where tbname like 'stb00_4444' limit 10" )
tdSql.checkData(0, 1, 0) tdSql.checkData(0, 1, 0)
...@@ -136,7 +136,7 @@ class TDTestCase: ...@@ -136,7 +136,7 @@ class TDTestCase:
tdSql.checkData(0, 1, 5) tdSql.checkData(0, 1, 5)
tdSql.checkData(1, 1, 6) tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 7) tdSql.checkData(2, 1, 7)
tdSql.query("select * from stb0 where col2 like 'test93%' ") tdSql.query("select * from stb0 where c2 like 'test93%' ")
tdSql.checkRows(1000) tdSql.checkRows(1000)
tdSql.query("select * from stb0 where tbname like 'stb00_3333' limit 100" ) tdSql.query("select * from stb0 where tbname like 'stb00_3333' limit 100" )
tdSql.checkData(0, 1, 0) tdSql.checkData(0, 1, 0)
...@@ -146,7 +146,7 @@ class TDTestCase: ...@@ -146,7 +146,7 @@ class TDTestCase:
tdSql.checkData(0, 1, 5) tdSql.checkData(0, 1, 5)
tdSql.checkData(1, 1, 6) tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 7) tdSql.checkData(2, 1, 7)
tdSql.query("select * from stb0 where col2 like 'test92%' ") tdSql.query("select * from stb0 where c2 like 'test92%' ")
tdSql.checkRows(1000) tdSql.checkRows(1000)
tdSql.query("select * from stb0 where tbname like 'stb00_2222' limit 100" ) tdSql.query("select * from stb0 where tbname like 'stb00_2222' limit 100" )
tdSql.checkData(0, 1, 0) tdSql.checkData(0, 1, 0)
...@@ -156,7 +156,7 @@ class TDTestCase: ...@@ -156,7 +156,7 @@ class TDTestCase:
tdSql.checkData(0, 1, 5) tdSql.checkData(0, 1, 5)
tdSql.checkData(1, 1, 6) tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 7) tdSql.checkData(2, 1, 7)
tdSql.query("select * from stb0 where col2 like 'test91%' ") tdSql.query("select * from stb0 where c2 like 'test91%' ")
tdSql.checkRows(1000) tdSql.checkRows(1000)
tdSql.query("select * from stb0 where tbname like 'stb00_1111' limit 100" ) tdSql.query("select * from stb0 where tbname like 'stb00_1111' limit 100" )
tdSql.checkData(0, 1, 0) tdSql.checkData(0, 1, 0)
...@@ -166,7 +166,7 @@ class TDTestCase: ...@@ -166,7 +166,7 @@ class TDTestCase:
tdSql.checkData(0, 1, 5) tdSql.checkData(0, 1, 5)
tdSql.checkData(1, 1, 6) tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 7) tdSql.checkData(2, 1, 7)
tdSql.query("select * from stb0 where col2 like 'test90%' ") tdSql.query("select * from stb0 where c2 like 'test90%' ")
tdSql.checkRows(1000) tdSql.checkRows(1000)
tdSql.query("select * from stb0 where tbname like 'stb00_100' limit 100" ) tdSql.query("select * from stb0 where tbname like 'stb00_100' limit 100" )
tdSql.checkData(0, 1, 0) tdSql.checkData(0, 1, 0)
...@@ -177,11 +177,8 @@ class TDTestCase: ...@@ -177,11 +177,8 @@ class TDTestCase:
tdSql.checkData(1, 1, 6) tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 7) tdSql.checkData(2, 1, 7)
os.system("rm -rf tools/taosdemoAllTest/TD-4985/query-limit-offset.py.sql")
os.system("rm -rf tools/taosdemoAllTest/TD-4985/query-limit-offset.py.sql")
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
......
...@@ -23,7 +23,7 @@ class TDTestCase: ...@@ -23,7 +23,7 @@ class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -39,7 +39,7 @@ class TDTestCase: ...@@ -39,7 +39,7 @@ class TDTestCase:
buildPath = root[:len(root)-len("/build/bin")] buildPath = root[:len(root)-len("/build/bin")]
break break
return buildPath return buildPath
def run(self): def run(self):
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
if (buildPath == ""): if (buildPath == ""):
...@@ -48,7 +48,7 @@ class TDTestCase: ...@@ -48,7 +48,7 @@ class TDTestCase:
tdLog.info("taosd found in %s" % buildPath) tdLog.info("taosd found in %s" % buildPath)
binPath = buildPath+ "/build/bin/" binPath = buildPath+ "/build/bin/"
# insert: create one or mutiple tables per sql and insert multiple rows per sql # insert: create one or mutiple tables per sql and insert multiple rows per sql
os.system("%staosdemo -f tools/taosdemoAllTest/insert-1s1tnt1r.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-1s1tnt1r.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("select count (tbname) from stb0") tdSql.query("select count (tbname) from stb0")
...@@ -62,7 +62,7 @@ class TDTestCase: ...@@ -62,7 +62,7 @@ class TDTestCase:
tdSql.query("select count(*) from stb01_1") tdSql.query("select count(*) from stb01_1")
tdSql.checkData(0, 0, 200) tdSql.checkData(0, 0, 200)
tdSql.query("select count(*) from stb1") tdSql.query("select count(*) from stb1")
tdSql.checkData(0, 0, 200000) tdSql.checkData(0, 0, 200000)
# restful connector insert data # restful connector insert data
os.system("%staosdemo -f tools/taosdemoAllTest/insertRestful.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertRestful.json -y " % binPath)
...@@ -81,7 +81,7 @@ class TDTestCase: ...@@ -81,7 +81,7 @@ class TDTestCase:
tdSql.checkData(0, 0, 200) tdSql.checkData(0, 0, 200)
# insert: create mutiple tables per sql and insert one rows per sql . # insert: create mutiple tables per sql and insert one rows per sql .
os.system("%staosdemo -f tools/taosdemoAllTest/insert-1s1tntmr.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-1s1tntmr.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("select count (tbname) from stb0") tdSql.query("select count (tbname) from stb0")
...@@ -89,34 +89,34 @@ class TDTestCase: ...@@ -89,34 +89,34 @@ class TDTestCase:
tdSql.query("select count (tbname) from stb1") tdSql.query("select count (tbname) from stb1")
tdSql.checkData(0, 0, 20) tdSql.checkData(0, 0, 20)
tdSql.query("select count(*) from stb00_0") tdSql.query("select count(*) from stb00_0")
tdSql.checkData(0, 0, 10000) tdSql.checkData(0, 0, 10000)
tdSql.query("select count(*) from stb0") tdSql.query("select count(*) from stb0")
tdSql.checkData(0, 0, 100000) tdSql.checkData(0, 0, 100000)
tdSql.query("select count(*) from stb01_0") tdSql.query("select count(*) from stb01_0")
tdSql.checkData(0, 0, 20000) tdSql.checkData(0, 0, 20000)
tdSql.query("select count(*) from stb1") tdSql.query("select count(*) from stb1")
tdSql.checkData(0, 0, 400000) tdSql.checkData(0, 0, 400000)
# insert: using parament "insert_interval to controls spped of insert. # insert: using parament "insert_interval to controls spped of insert.
# but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。
os.system("%staosdemo -f tools/taosdemoAllTest/insert-interval-speed.json -y" % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-interval-speed.json -y" % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("show stables") tdSql.query("show stables")
tdSql.checkData(0, 4, 100) tdSql.checkData(0, 4, 100)
tdSql.query("select count(*) from stb00_0") tdSql.query("select count(*) from stb00_0")
tdSql.checkData(0, 0, 20000) tdSql.checkData(0, 0, 20000)
tdSql.query("select count(*) from stb0") tdSql.query("select count(*) from stb0")
tdSql.checkData(0, 0, 2000000) tdSql.checkData(0, 0, 2000000)
tdSql.query("show stables") tdSql.query("show stables")
tdSql.checkData(1, 4, 100) tdSql.checkData(1, 4, 100)
tdSql.query("select count(*) from stb01_0") tdSql.query("select count(*) from stb01_0")
tdSql.checkData(0, 0, 20000) tdSql.checkData(0, 0, 20000)
tdSql.query("select count(*) from stb1") tdSql.query("select count(*) from stb1")
tdSql.checkData(0, 0, 2000000) tdSql.checkData(0, 0, 2000000)
# spend 2min30s for 3 testcases. # spend 2min30s for 3 testcases.
# insert: drop and child_table_exists combination test # insert: drop and child_table_exists combination test
# insert: using parament "childtable_offset and childtable_limit" to control table'offset point and offset # insert: using parament "childtable_offset and childtable_limit" to control table'offset point and offset
os.system("%staosdemo -f tools/taosdemoAllTest/insert-nodbnodrop.json -y" % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-nodbnodrop.json -y" % binPath)
tdSql.error("show dbno.stables") tdSql.error("show dbno.stables")
os.system("%staosdemo -f tools/taosdemoAllTest/insert-newdb.json -y" % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-newdb.json -y" % binPath)
...@@ -128,41 +128,41 @@ class TDTestCase: ...@@ -128,41 +128,41 @@ class TDTestCase:
tdSql.query("select count (tbname) from stb2") tdSql.query("select count (tbname) from stb2")
tdSql.checkData(0, 0, 7) tdSql.checkData(0, 0, 7)
tdSql.query("select count (tbname) from stb3") tdSql.query("select count (tbname) from stb3")
tdSql.checkData(0, 0, 8) tdSql.checkData(0, 0, 8)
tdSql.query("select count (tbname) from stb4") tdSql.query("select count (tbname) from stb4")
tdSql.checkData(0, 0, 8) tdSql.checkData(0, 0, 8)
os.system("%staosdemo -f tools/taosdemoAllTest/insert-offset.json -y" % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-offset.json -y" % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("select count(*) from stb0") tdSql.query("select count(*) from stb0")
tdSql.checkData(0, 0, 50) tdSql.checkData(0, 0, 50)
tdSql.query("select count(*) from stb1") tdSql.query("select count(*) from stb1")
tdSql.checkData(0, 0, 240) tdSql.checkData(0, 0, 240)
tdSql.query("select count(*) from stb2") tdSql.query("select count(*) from stb2")
tdSql.checkData(0, 0, 220) tdSql.checkData(0, 0, 220)
tdSql.query("select count(*) from stb3") tdSql.query("select count(*) from stb3")
tdSql.checkData(0, 0, 180) tdSql.checkData(0, 0, 180)
tdSql.query("select count(*) from stb4") tdSql.query("select count(*) from stb4")
tdSql.checkData(0, 0, 160) tdSql.checkData(0, 0, 160)
os.system("%staosdemo -f tools/taosdemoAllTest/insert-newtable.json -y" % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-newtable.json -y" % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("select count(*) from stb0") tdSql.query("select count(*) from stb0")
tdSql.checkData(0, 0, 150) tdSql.checkData(0, 0, 150)
tdSql.query("select count(*) from stb1") tdSql.query("select count(*) from stb1")
tdSql.checkData(0, 0, 360) tdSql.checkData(0, 0, 360)
tdSql.query("select count(*) from stb2") tdSql.query("select count(*) from stb2")
tdSql.checkData(0, 0, 360) tdSql.checkData(0, 0, 360)
tdSql.query("select count(*) from stb3") tdSql.query("select count(*) from stb3")
tdSql.checkData(0, 0, 340) tdSql.checkData(0, 0, 340)
tdSql.query("select count(*) from stb4") tdSql.query("select count(*) from stb4")
tdSql.checkData(0, 0, 400) tdSql.checkData(0, 0, 400)
os.system("%staosdemo -f tools/taosdemoAllTest/insert-renewdb.json -y" % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-renewdb.json -y" % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("select count(*) from stb0") tdSql.query("select count(*) from stb0")
tdSql.checkData(0, 0, 50) tdSql.checkData(0, 0, 50)
tdSql.query("select count(*) from stb1") tdSql.query("select count(*) from stb1")
tdSql.checkData(0, 0, 120) tdSql.checkData(0, 0, 120)
tdSql.query("select count(*) from stb2") tdSql.query("select count(*) from stb2")
tdSql.checkData(0, 0, 140) tdSql.checkData(0, 0, 140)
tdSql.query("select count(*) from stb3") tdSql.query("select count(*) from stb3")
tdSql.checkData(0, 0, 160) tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from stb4") tdSql.query("select count(*) from stb4")
...@@ -170,59 +170,59 @@ class TDTestCase: ...@@ -170,59 +170,59 @@ class TDTestCase:
# insert: let parament in json file is illegal, it'll expect error. # insert: let parament in json file is illegal, it'll expect error.
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNumLarge1024.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNumLarge1024.json -y " % binPath)
tdSql.error("use db") tdSql.error("use db")
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertSigcolumnsNum1024.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertSigcolumnsNum1024.json -y " % binPath)
tdSql.error("select * from db.stb0") tdSql.error("select * from db.stb0")
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNum1024.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNum1024.json -y " % binPath)
tdSql.query("select count(*) from db.stb0") tdSql.query("select count(*) from db.stb0")
tdSql.checkData(0, 0, 10000) tdSql.checkData(0, 0, 10000)
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json -y " % binPath)
tdSql.query("select count(*) from db.stb0") tdSql.query("select count(*) from db.stb0")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsNum0.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsNum0.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("show stables like 'stb0%' ") tdSql.query("show stables like 'stb0%' ")
tdSql.checkData(0, 2, 11) tdSql.checkData(0, 2, 11)
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertTagsNumLarge128.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertTagsNumLarge128.json -y " % binPath)
tdSql.error("use db1") tdSql.error("use db1")
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar16384.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar16384.json -y " % binPath)
tdSql.query("select count(*) from db.stb0") tdSql.query("select count(*) from db.stb0")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select count(*) from db.stb1") tdSql.query("select count(*) from db.stb1")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.error("select * from db.stb3") tdSql.error("select * from db.stb3")
tdSql.error("select * from db.stb2") tdSql.error("select * from db.stb2")
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertNumOfrecordPerReq0.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertNumOfrecordPerReq0.json -y " % binPath)
tdSql.error("select count(*) from db.stb0") tdSql.error("select count(*) from db.stb0")
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json -y " % binPath)
tdSql.error("use db") tdSql.error("use db")
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertChildTab0.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertChildTab0.json -y " % binPath)
tdSql.error("use db") tdSql.error("use db")
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertChildTabLess0.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertChildTabLess0.json -y " % binPath)
tdSql.error("use db") tdSql.error("use db")
tdSql.execute("drop database if exists blf") tdSql.execute("drop database if exists blf")
os.system("%staosdemo -f tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json -y " % binPath)
tdSql.execute("use blf") tdSql.execute("use blf")
tdSql.query("select ts from blf.p_0_topics_7 limit 262800,1") tdSql.query("select ts from blf.p_0_topics_7 limit 262800,1")
tdSql.checkData(0, 0, "2020-03-31 12:00:00.000") tdSql.checkData(0, 0, "2020-03-31 12:00:00.000")
tdSql.query("select first(ts) from blf.p_0_topics_2") tdSql.query("select first(ts) from blf.p_0_topics_2")
tdSql.checkData(0, 0, "2019-10-01 00:00:00") tdSql.checkData(0, 0, "2019-10-01 00:00:00")
tdSql.query("select last(ts) from blf.p_0_topics_6 ") tdSql.query("select last(ts) from blf.p_0_topics_6 ")
tdSql.checkData(0, 0, "2020-09-29 23:59:00") tdSql.checkData(0, 0, "2020-09-29 23:59:00")
os.system("%staosdemo -f tools/taosdemoAllTest/insertMaxNumPerReq.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertMaxNumPerReq.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("select count(*) from stb0") tdSql.query("select count(*) from stb0")
tdSql.checkData(0, 0, 5000000) tdSql.checkData(0, 0, 5000000)
tdSql.query("select count(*) from stb1") tdSql.query("select count(*) from stb1")
...@@ -230,7 +230,7 @@ class TDTestCase: ...@@ -230,7 +230,7 @@ class TDTestCase:
# insert: timestamp and step # insert: timestamp and step
os.system("%staosdemo -f tools/taosdemoAllTest/insert-timestep.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-timestep.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("show stables") tdSql.query("show stables")
...@@ -239,13 +239,13 @@ class TDTestCase: ...@@ -239,13 +239,13 @@ class TDTestCase:
tdSql.query("select count (tbname) from stb1") tdSql.query("select count (tbname) from stb1")
tdSql.checkData(0, 0, 20) tdSql.checkData(0, 0, 20)
tdSql.query("select last(ts) from db.stb00_0") tdSql.query("select last(ts) from db.stb00_0")
tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000")
tdSql.query("select count(*) from stb0") tdSql.query("select count(*) from stb0")
tdSql.checkData(0, 0, 200) tdSql.checkData(0, 0, 200)
tdSql.query("select last(ts) from db.stb01_0") tdSql.query("select last(ts) from db.stb01_0")
tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000")
tdSql.query("select count(*) from stb1") tdSql.query("select count(*) from stb1")
tdSql.checkData(0, 0, 400) tdSql.checkData(0, 0, 400)
# # insert: disorder_ratio # # insert: disorder_ratio
os.system("%staosdemo -f tools/taosdemoAllTest/insert-disorder.json -g 2>&1 -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-disorder.json -g 2>&1 -y " % binPath)
...@@ -255,14 +255,14 @@ class TDTestCase: ...@@ -255,14 +255,14 @@ class TDTestCase:
tdSql.query("select count (tbname) from stb1") tdSql.query("select count (tbname) from stb1")
tdSql.checkData(0, 0, 1) tdSql.checkData(0, 0, 1)
tdSql.query("select count(*) from stb0") tdSql.query("select count(*) from stb0")
tdSql.checkData(0, 0, 10) tdSql.checkData(0, 0, 10)
tdSql.query("select count(*) from stb1") tdSql.query("select count(*) from stb1")
tdSql.checkData(0, 0, 10) tdSql.checkData(0, 0, 10)
# insert: sample json # insert: sample json
os.system("%staosdemo -f tools/taosdemoAllTest/insert-sample.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-sample.json -y " % binPath)
tdSql.execute("use dbtest123") tdSql.execute("use dbtest123")
tdSql.query("select col2 from stb0") tdSql.query("select c2 from stb0")
tdSql.checkData(0, 0, 2147483647) tdSql.checkData(0, 0, 2147483647)
tdSql.query("select * from stb1 where t1=-127") tdSql.query("select * from stb1 where t1=-127")
tdSql.checkRows(20) tdSql.checkRows(20)
...@@ -271,13 +271,13 @@ class TDTestCase: ...@@ -271,13 +271,13 @@ class TDTestCase:
tdSql.query("select * from stb1 where t2=126") tdSql.query("select * from stb1 where t2=126")
tdSql.checkRows(10) tdSql.checkRows(10)
# insert: test interlace parament # insert: test interlace parament
os.system("%staosdemo -f tools/taosdemoAllTest/insert-interlace-row.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insert-interlace-row.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("select count (tbname) from stb0") tdSql.query("select count (tbname) from stb0")
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
tdSql.query("select count (*) from stb0") tdSql.query("select count (*) from stb0")
tdSql.checkData(0, 0, 15000) tdSql.checkData(0, 0, 15000)
# # insert: auto_create # # insert: auto_create
...@@ -317,10 +317,8 @@ class TDTestCase: ...@@ -317,10 +317,8 @@ class TDTestCase:
tdSql.checkRows(20) tdSql.checkRows(20)
os.system("rm -rf ./insert_res.txt") os.system("rm -rf ./insert_res.txt")
os.system("rm -rf tools/taosdemoAllTest/taosdemoTestInsertWithJson.py.sql") os.system("rm -rf tools/taosdemoAllTest/taosdemoTestInsertWithJson.py.sql")
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
......
...@@ -59,11 +59,11 @@ class TDTestCase: ...@@ -59,11 +59,11 @@ class TDTestCase:
tdSql.checkData(0, 0, self.numberOfTables * self.numberOfRecords) tdSql.checkData(0, 0, self.numberOfTables * self.numberOfRecords)
tdSql.query( tdSql.query(
"select sum(col1) from test.meters interval(1h) sliding(30m)") "select sum(c1) from test.meters interval(1h) sliding(30m)")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query( tdSql.query(
"select apercentile(col1, 1) from test.meters interval(100s)") "select apercentile(c1, 1) from test.meters interval(100s)")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.error("select loc, count(loc) from test.meters") tdSql.error("select loc, count(loc) from test.meters")
......
...@@ -98,8 +98,8 @@ class TDTestCase: ...@@ -98,8 +98,8 @@ class TDTestCase:
break break
time.sleep(1) time.sleep(1)
print("alter table test.meters add column col10 int") print("alter table test.meters add column c10 int")
tdSql.execute("alter table test.meters add column col10 int") tdSql.execute("alter table test.meters add column c10 int")
print("insert into test.t9 values (now, 1, 2, 3, 4, 0)") print("insert into test.t9 values (now, 1, 2, 3, 4, 0)")
tdSql.execute("insert into test.t9 values (now, 1, 2, 3, 4, 0)") tdSql.execute("insert into test.t9 values (now, 1, 2, 3, 4, 0)")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册