Hotfix/sangshuduo/td 5398 taosdemo 4096col for master (#6940)

* [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.

* remove space between columns and tags.

* change sql buffer to 1M align with taosdef.h.

* column buffer length be calculated.

Co-authored-by: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
Shuduo Sang 2021-07-21 05:51:43 +08:00 committed by GitHub
parent 31fe3946e9
commit 151f3ac161
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 44 additions and 45 deletions

View File

@ -71,9 +71,9 @@ extern char configDir[];
#define HEAD_BUFF_LEN TSDB_MAX_COLUMNS*24 // 16*MAX_COLUMNS + (192+32)*2 + insert into ..
#define COL_BUFFER_LEN (TSDB_MAX_BYTES_PER_ROW - 50)
#define BUFFER_SIZE (50 + TSDB_DB_NAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_MAX_BYTES_PER_ROW + TSDB_MAX_TAGS_LEN)
#define BUFFER_SIZE TSDB_MAX_ALLOWED_SQL_LEN
#define COND_BUF_LEN (BUFFER_SIZE - 30)
#define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS)
#define MAX_USERNAME_SIZE 64
#define MAX_PASSWORD_SIZE 64
#define MAX_HOSTNAME_SIZE 64
@ -946,7 +946,6 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
for (int col = arguments->num_of_CPR; col < MAX_NUM_COLUMNS; col++) {
arguments->datatype[col] = NULL;
}
} else if (strcmp(argv[i], "-b") == 0) {
arguments->demo_mode = false;
if (argc == i+1) {
@ -1141,7 +1140,6 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
if (arguments->disorderRatio) {
printf("# Data order: %d\n", arguments->disorderRatio);
printf("# Data out of order rate: %d\n", arguments->disorderRange);
}
printf("# Delete method: %d\n", arguments->method_of_delete);
printf("# Answer yes when prompt: %d\n", arguments->answer_yes);
@ -2196,7 +2194,6 @@ static void printfQuerySystemInfo(TAOS * taos) {
snprintf(buffer, MAX_QUERY_SQL_LENGTH, "show %s.stables;", dbInfos[i]->name);
res = taos_query(taos, buffer);
xDumpResultToFile(filename, res);
free(dbInfos[i]);
}
@ -2370,7 +2367,7 @@ static char* getTagValueFromTagSample(SSuperTable* stbInfo, int tagUsePos) {
return dataBuf;
}
static char* generateTagVaulesForStb(SSuperTable* stbInfo, int32_t tableSeq) {
static char* generateTagValuesForStb(SSuperTable* stbInfo, int32_t tableSeq) {
char* dataBuf = (char*)calloc(TSDB_MAX_SQL_LEN+1, 1);
if (NULL == dataBuf) {
printf("calloc failed! size:%d\n", TSDB_MAX_SQL_LEN+1);
@ -2454,7 +2451,7 @@ static char* generateTagVaulesForStb(SSuperTable* stbInfo, int32_t tableSeq) {
}
}
dataLen -= 2;
dataLen -= 1;
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, ")");
return dataBuf;
}
@ -2821,13 +2818,13 @@ static int createSuperTable(
superTbl->tags[tagIndex].dataLen);
} else {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"t%d %s(%d), ", tagIndex, "BINARY",
"T%d %s(%d),", tagIndex, "BINARY",
superTbl->tags[tagIndex].dataLen);
}
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 3;
} else if (strcasecmp(dataType, "NCHAR") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"t%d %s(%d), ", tagIndex,
"T%d %s(%d),", tagIndex,
"NCHAR", superTbl->tags[tagIndex].dataLen);
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 3;
} else if (strcasecmp(dataType, "INT") == 0) {
@ -2836,32 +2833,32 @@ static int createSuperTable(
"groupId INT, ");
} else {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"t%d %s, ", tagIndex, "INT");
"T%d %s,", tagIndex, "INT");
}
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 11;
} else if (strcasecmp(dataType, "BIGINT") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"t%d %s, ", tagIndex, "BIGINT");
"T%d %s,", tagIndex, "BIGINT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 21;
} else if (strcasecmp(dataType, "SMALLINT") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"t%d %s, ", tagIndex, "SMALLINT");
"T%d %s,", tagIndex, "SMALLINT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 6;
} else if (strcasecmp(dataType, "TINYINT") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"t%d %s, ", tagIndex, "TINYINT");
"T%d %s,", tagIndex, "TINYINT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 4;
} else if (strcasecmp(dataType, "BOOL") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"t%d %s, ", tagIndex, "BOOL");
"T%d %s,", tagIndex, "BOOL");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 6;
} else if (strcasecmp(dataType, "FLOAT") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"t%d %s, ", tagIndex, "FLOAT");
"T%d %s,", tagIndex, "FLOAT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 22;
} else if (strcasecmp(dataType, "DOUBLE") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"t%d %s, ", tagIndex, "DOUBLE");
"T%d %s,", tagIndex, "DOUBLE");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 42;
} else {
taos_close(taos);
@ -2871,7 +2868,7 @@ static int createSuperTable(
}
}
len -= 2;
len -= 1;
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len, ")");
superTbl->lenOfTagOfOneRow = lenOfTagOfOneRow;
@ -3069,7 +3066,7 @@ static void* createTable(void *sarg)
}
char* tagsValBuf = NULL;
if (0 == superTblInfo->tagSource) {
tagsValBuf = generateTagVaulesForStb(superTblInfo, i);
tagsValBuf = generateTagValuesForStb(superTblInfo, i);
} else {
tagsValBuf = getTagValueFromTagSample(
superTblInfo,
@ -5332,7 +5329,7 @@ static int generateStbSQLHead(
if (AUTO_CREATE_SUBTBL == superTblInfo->autoCreateTable) {
char* tagsValBuf = NULL;
if (0 == superTblInfo->tagSource) {
tagsValBuf = generateTagVaulesForStb(superTblInfo, tableSeq);
tagsValBuf = generateTagValuesForStb(superTblInfo, tableSeq);
} else {
tagsValBuf = getTagValueFromTagSample(
superTblInfo,
@ -5347,7 +5344,7 @@ static int generateStbSQLHead(
len = snprintf(
headBuf,
HEAD_BUFF_LEN,
"%s.%s using %s.%s tags %s values",
"%s.%s using %s.%s TAGS%s values",
dbName,
tableName,
dbName,
@ -5900,7 +5897,7 @@ static int32_t prepareStbStmtProgressive(
stbInfo,
stmt,
tableName,
batch,
g_args.num_of_RPR,
insertRows, recordFrom, startTime,
pSamplePos);
}
@ -6593,6 +6590,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
} else {
start_time = 1500000000000;
}
debugPrint("%s() LN%d, start_time= %"PRId64"\n",
__func__, __LINE__, start_time);
int64_t start = taosGetTimestampMs();