[TD-3906]<fix>: taosdemo back to 4 INT columns. (#5883)

* [TD-3906]<fix>: taosdemo back to 4 INT columns.

* [TD-3906]<fix>: taosdemo back to 4 columns.

test case need change correspondingly.

Co-authored-by: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
Shuduo Sang 2021-04-22 18:35:14 +08:00 committed by GitHub
parent c3bc607b99
commit 56969c41e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 23 deletions

View File

@ -554,19 +554,13 @@ SArguments g_args = {
"./output.txt", // output_file "./output.txt", // output_file
0, // mode : sync or async 0, // mode : sync or async
{ {
"TINYINT", // datatype "INT", // datatype
"SMALLINT", "INT", // datatype
"INT", "INT", // datatype
"BIGINT", "INT", // datatype
"FLOAT",
"DOUBLE",
"BINARY",
"NCHAR",
"BOOL",
"TIMESTAMP"
}, },
16, // len_of_binary 16, // len_of_binary
10, // num_of_CPR 4, // num_of_CPR
10, // num_of_connections/thread 10, // num_of_connections/thread
0, // insert_interval 0, // insert_interval
1, // query_times 1, // query_times
@ -2395,8 +2389,10 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
return 0; return 0;
} }
static int createSuperTable(TAOS * taos, char* dbName, static int createSuperTable(
TAOS * taos, char* dbName,
SSuperTable* superTbl) { SSuperTable* superTbl) {
char command[BUFFER_SIZE] = "\0"; char command[BUFFER_SIZE] = "\0";
char cols[STRING_LEN] = "\0"; char cols[STRING_LEN] = "\0";
@ -2885,19 +2881,17 @@ static void createChildTables() {
} else { } else {
// normal table // normal table
len = snprintf(tblColsBuf, MAX_SQL_SIZE, "(TS TIMESTAMP"); len = snprintf(tblColsBuf, MAX_SQL_SIZE, "(TS TIMESTAMP");
int j = 0; for (int j = 0; j < g_args.num_of_CPR; j++) {
while(g_args.datatype[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, MAX_SQL_SIZE - len,
", COL%d %s(60)", j, g_args.datatype[j]); ", COL%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, MAX_SQL_SIZE - len,
", COL%d %s", j, g_args.datatype[j]); ", COL%d %s", j, g_args.datatype[j]);
} }
len = strlen(tblColsBuf); len = strlen(tblColsBuf);
j++;
} }
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, ")"); snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, ")");
@ -4479,7 +4473,7 @@ static int32_t generateData(char *recBuf, char **data_type,
exit(-1); exit(-1);
} }
for (int i = 0; i < num_of_cols; i++) { for (int i = 0; i < c; i++) {
if (strcasecmp(data_type[i % c], "tinyint") == 0) { if (strcasecmp(data_type[i % c], "tinyint") == 0) {
pstr += sprintf(pstr, ", %d", rand_tinyint() ); pstr += sprintf(pstr, ", %d", rand_tinyint() );
} else if (strcasecmp(data_type[i % c], "smallint") == 0) { } else if (strcasecmp(data_type[i % c], "smallint") == 0) {
@ -4501,7 +4495,7 @@ static int32_t generateData(char *recBuf, char **data_type,
rand_string(s, lenOfBinary); rand_string(s, lenOfBinary);
pstr += sprintf(pstr, ", \"%s\"", s); pstr += sprintf(pstr, ", \"%s\"", s);
free(s); free(s);
}else if (strcasecmp(data_type[i % c], "nchar") == 0) { } else if (strcasecmp(data_type[i % c], "nchar") == 0) {
char *s = malloc(lenOfBinary); char *s = malloc(lenOfBinary);
rand_string(s, lenOfBinary); rand_string(s, lenOfBinary);
pstr += sprintf(pstr, ", \"%s\"", s); pstr += sprintf(pstr, ", \"%s\"", s);
@ -4685,7 +4679,7 @@ static int generateDataTail(
if (len > remainderBufLen) if (len > remainderBufLen)
break; break;
pstr += sprintf(pstr, " %s", data); pstr += sprintf(pstr, "%s", data);
k++; k++;
len += retLen; len += retLen;
remainderBufLen -= retLen; remainderBufLen -= retLen;
@ -5421,9 +5415,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
if (superTblInfo) { if (superTblInfo) {
int limit, offset; int limit, offset;
if ((superTblInfo->childTblExists == TBL_NO_EXISTS) && if ((NULL != g_args.sqlFile) && (superTblInfo->childTblExists == TBL_NO_EXISTS) &&
((superTblInfo->childTblOffset != 0) || (superTblInfo->childTblLimit >= 0))) { ((superTblInfo->childTblOffset != 0) || (superTblInfo->childTblLimit >= 0))) {
printf("WARNING: offset and limit will not be used since the child tables are not exists!\n"); printf("WARNING: offset and limit will not be used since the child tables not exists!\n");
} }
if ((superTblInfo->childTblExists == TBL_ALREADY_EXISTS) if ((superTblInfo->childTblExists == TBL_ALREADY_EXISTS)

View File

@ -100,8 +100,8 @@ class TDTestCase:
print("alter table test.meters add column col10 int") print("alter table test.meters add column col10 int")
tdSql.execute("alter table test.meters add column col10 int") tdSql.execute("alter table test.meters add column col10 int")
print("insert into test.t9 values (now, 1, 2, 3, 4, 0.1, 0.01,'test', '测试', TRUE, 1610000000000, 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.1, 0.01,'test', '测试', TRUE, 1610000000000, 0)") tdSql.execute("insert into test.t9 values (now, 1, 2, 3, 4, 0)")
def run(self): def run(self):
tdSql.prepare() tdSql.prepare()