Hotfix/sangshuduo/td 3197 fix taosdemo coverity scan (#6907)
* [TD-3197] <fix>: fix taosdemo coverity scan issues. * [TD-3197] <fix>: fix taosdemo coverity scan issue. fix subscribeTest pids uninitialized. * [TD-3197] <fix>: fix taosdemo coverity scan issues. * [TD-3197] <fix>: fix coverity scan issues. check super tbl info pointer. * [TD-3197] <fix>: fix coverity scan issues. move sub tbl query thread join into loop * [TD-3197] <fix>: fix coverity scan issues. remove unused variable * [TD-3197] <fix>: fix coverity scan issues. use more secure random library * [TD-3197] <fix>: fix coverity scan issues. use strncpy for more safe * [TD-3197] <fix>: fix taosdemo coverity scan issue. replace arc4random with rand(). * [TD-3197] <fix>: fix coverity scan issues. check stb info pointer for start time * [TD-3197] <fix>: fix coverity scan issues. fix strcpy vulnerability * [TD-3197] <fix>: fix taosdemo coverity scan issue. modify taosdemoTest2. try to check database continously. * [TD-3197] <fix>: taosdemo coverity scan issues. * [TD-3197] <fix>: fix memory leak when parsing arguments. * [TD-3197] <fix>: fix cmake strip arguments. * [TD-3197] <fix>: taosdemo coverity scan. fix cmake string manipulation. * [TD-3197]<fix>: taosdemo coverity scan issue. configDir buffer overwrite. * [TD-3197]<fix>: coverity scan issue. taosdump argument validation. * [TD-3197]<fix>: taosdemo and taosdump coverity scan issues. * [TD-3197]<fix>: taosdemo coverity scan. append result buf to file. for develop branch. * exit if read sample file failed. * fix converity scan issue. * fix coverity scan issue. Co-authored-by: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
parent
93396bca69
commit
2e4f9508ce
|
@ -4972,62 +4972,64 @@ static int64_t generateStbRowData(
|
||||||
|
|
||||||
static int64_t generateData(char *recBuf, char **data_type,
|
static int64_t generateData(char *recBuf, char **data_type,
|
||||||
int64_t timestamp, int lenOfBinary) {
|
int64_t timestamp, int lenOfBinary) {
|
||||||
memset(recBuf, 0, MAX_DATA_SIZE);
|
memset(recBuf, 0, MAX_DATA_SIZE);
|
||||||
char *pstr = recBuf;
|
char *pstr = recBuf;
|
||||||
pstr += sprintf(pstr, "(%" PRId64, timestamp);
|
pstr += sprintf(pstr, "(%" PRId64, timestamp);
|
||||||
|
|
||||||
int columnCount = g_args.num_of_CPR;
|
int columnCount = g_args.num_of_CPR;
|
||||||
|
|
||||||
for (int i = 0; i < columnCount; i++) {
|
for (int i = 0; i < columnCount; i++) {
|
||||||
if (strcasecmp(data_type[i % columnCount], "TINYINT") == 0) {
|
if (strcasecmp(data_type[i % columnCount], "TINYINT") == 0) {
|
||||||
pstr += sprintf(pstr, ",%d", rand_tinyint() );
|
pstr += sprintf(pstr, ",%d", rand_tinyint() );
|
||||||
} else if (strcasecmp(data_type[i % columnCount], "SMALLINT") == 0) {
|
} else if (strcasecmp(data_type[i % columnCount], "SMALLINT") == 0) {
|
||||||
pstr += sprintf(pstr, ",%d", rand_smallint());
|
pstr += sprintf(pstr, ",%d", rand_smallint());
|
||||||
} else if (strcasecmp(data_type[i % columnCount], "INT") == 0) {
|
} else if (strcasecmp(data_type[i % columnCount], "INT") == 0) {
|
||||||
pstr += sprintf(pstr, ",%d", rand_int());
|
pstr += sprintf(pstr, ",%d", rand_int());
|
||||||
} else if (strcasecmp(data_type[i % columnCount], "BIGINT") == 0) {
|
} else if (strcasecmp(data_type[i % columnCount], "BIGINT") == 0) {
|
||||||
pstr += sprintf(pstr, ",%" PRId64, rand_bigint());
|
pstr += sprintf(pstr, ",%" PRId64, rand_bigint());
|
||||||
} else if (strcasecmp(data_type[i % columnCount], "TIMESTAMP") == 0) {
|
} else if (strcasecmp(data_type[i % columnCount], "TIMESTAMP") == 0) {
|
||||||
pstr += sprintf(pstr, ",%" PRId64, rand_bigint());
|
pstr += sprintf(pstr, ",%" PRId64, rand_bigint());
|
||||||
} else if (strcasecmp(data_type[i % columnCount], "FLOAT") == 0) {
|
} else if (strcasecmp(data_type[i % columnCount], "FLOAT") == 0) {
|
||||||
pstr += sprintf(pstr, ",%10.4f", rand_float());
|
pstr += sprintf(pstr, ",%10.4f", rand_float());
|
||||||
} else if (strcasecmp(data_type[i % columnCount], "DOUBLE") == 0) {
|
} else if (strcasecmp(data_type[i % columnCount], "DOUBLE") == 0) {
|
||||||
double t = rand_double();
|
double t = rand_double();
|
||||||
pstr += sprintf(pstr, ",%20.8f", t);
|
pstr += sprintf(pstr, ",%20.8f", t);
|
||||||
} else if (strcasecmp(data_type[i % columnCount], "BOOL") == 0) {
|
} else if (strcasecmp(data_type[i % columnCount], "BOOL") == 0) {
|
||||||
bool b = rand_bool() & 1;
|
bool b = rand_bool() & 1;
|
||||||
pstr += sprintf(pstr, ",%s", b ? "true" : "false");
|
pstr += sprintf(pstr, ",%s", b ? "true" : "false");
|
||||||
} else if (strcasecmp(data_type[i % columnCount], "BINARY") == 0) {
|
} else if (strcasecmp(data_type[i % columnCount], "BINARY") == 0) {
|
||||||
char *s = malloc(lenOfBinary + 1);
|
char *s = malloc(lenOfBinary + 1);
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
errorPrint("%s() LN%d, memory allocation %d bytes failed\n",
|
errorPrint("%s() LN%d, memory allocation %d bytes failed\n",
|
||||||
__func__, __LINE__, lenOfBinary + 1);
|
__func__, __LINE__, lenOfBinary + 1);
|
||||||
}
|
exit(-1);
|
||||||
rand_string(s, lenOfBinary);
|
}
|
||||||
pstr += sprintf(pstr, ",\"%s\"", s);
|
rand_string(s, lenOfBinary);
|
||||||
free(s);
|
pstr += sprintf(pstr, ",\"%s\"", s);
|
||||||
} else if (strcasecmp(data_type[i % columnCount], "NCHAR") == 0) {
|
free(s);
|
||||||
char *s = malloc(lenOfBinary + 1);
|
} else if (strcasecmp(data_type[i % columnCount], "NCHAR") == 0) {
|
||||||
if (s == NULL) {
|
char *s = malloc(lenOfBinary + 1);
|
||||||
errorPrint("%s() LN%d, memory allocation %d bytes failed\n",
|
if (s == NULL) {
|
||||||
__func__, __LINE__, lenOfBinary + 1);
|
errorPrint("%s() LN%d, memory allocation %d bytes failed\n",
|
||||||
}
|
__func__, __LINE__, lenOfBinary + 1);
|
||||||
rand_string(s, lenOfBinary);
|
exit(-1);
|
||||||
pstr += sprintf(pstr, ",\"%s\"", s);
|
}
|
||||||
free(s);
|
rand_string(s, lenOfBinary);
|
||||||
|
pstr += sprintf(pstr, ",\"%s\"", s);
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(recBuf) > MAX_DATA_SIZE) {
|
||||||
|
perror("column length too long, abort");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(recBuf) > MAX_DATA_SIZE) {
|
pstr += sprintf(pstr, ")");
|
||||||
perror("column length too long, abort");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pstr += sprintf(pstr, ")");
|
verbosePrint("%s() LN%d, recBuf:\n\t%s\n", __func__, __LINE__, recBuf);
|
||||||
|
|
||||||
verbosePrint("%s() LN%d, recBuf:\n\t%s\n", __func__, __LINE__, recBuf);
|
return (int32_t)strlen(recBuf);
|
||||||
|
|
||||||
return (int32_t)strlen(recBuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int prepareSampleDataForSTable(SSuperTable *superTblInfo) {
|
static int prepareSampleDataForSTable(SSuperTable *superTblInfo) {
|
||||||
|
@ -6747,7 +6749,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
|
||||||
char buffer[3000];
|
char buffer[3000];
|
||||||
char *pstr = buffer;
|
char *pstr = buffer;
|
||||||
|
|
||||||
if (AUTO_CREATE_SUBTBL == superTblInfo->autoCreateTable) {
|
if ((superTblInfo)
|
||||||
|
&& (AUTO_CREATE_SUBTBL
|
||||||
|
== superTblInfo->autoCreateTable)) {
|
||||||
pstr += sprintf(pstr, "INSERT INTO ? USING %s TAGS(?",
|
pstr += sprintf(pstr, "INSERT INTO ? USING %s TAGS(?",
|
||||||
superTblInfo->sTblName);
|
superTblInfo->sTblName);
|
||||||
for (int tag = 0; tag < (superTblInfo->tagCount - 1); tag ++ ) {
|
for (int tag = 0; tag < (superTblInfo->tagCount - 1); tag ++ ) {
|
||||||
|
|
Loading…
Reference in New Issue