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

[TD-4272]<fix>: taosdemo specify columns. (#6173)

Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 f0b77fa3
......@@ -189,6 +189,8 @@ typedef struct {
} SColDes;
/* Used by main to communicate with parse_opt. */
static char *g_dupstr = NULL;
typedef struct SArguments_S {
char * metaFile;
uint32_t test_mode;
......@@ -526,7 +528,6 @@ static int taosRandom()
#endif // ifdef Windows
static void prompt();
static void prompt2();
static int createDatabasesAndStables();
static void createChildTables();
static int queryDbExec(TAOS *taos, char *command, QUERY_TYPE type, bool quiet);
......@@ -679,8 +680,9 @@ static void printHelp() {
"The data_type of columns, default: INT,INT,INT,INT.");
printf("%s%s%s%s\n", indent, "-w", indent,
"The length of data_type 'BINARY' or 'NCHAR'. Default is 16");
printf("%s%s%s%s\n", indent, "-l", indent,
"The number of columns per record. Default is 4.");
printf("%s%s%s%s%d\n", indent, "-l", indent,
"The number of columns per record. Default is 4. Max values is ",
MAX_NUM_DATATYPE);
printf("%s%s%s%s\n", indent, "-T", indent,
"The number of threads. Default is 10.");
printf("%s%s%s%s\n", indent, "-i", indent,
......@@ -724,7 +726,6 @@ static bool isStringNumber(char *input)
}
static void parse_args(int argc, char *argv[], SArguments *arguments) {
char **sptr;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-f") == 0) {
......@@ -851,20 +852,31 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
}
arguments->database = argv[++i];
} else if (strcmp(argv[i], "-l") == 0) {
if ((argc == i+1) ||
(!isStringNumber(argv[i+1]))) {
printHelp();
errorPrint("%s", "\n\t-l need a number following!\n");
exit(EXIT_FAILURE);
if (argc == i+1) {
if (!isStringNumber(argv[i+1])) {
printHelp();
errorPrint("%s", "\n\t-l need a number following!\n");
exit(EXIT_FAILURE);
}
}
arguments->num_of_CPR = atoi(argv[++i]);
if (arguments->num_of_CPR > MAX_NUM_DATATYPE) {
printf("WARNING: max acceptible columns count is %d\n", MAX_NUM_DATATYPE);
prompt();
arguments->num_of_CPR = MAX_NUM_DATATYPE;
}
for (int col = arguments->num_of_CPR; col < MAX_NUM_DATATYPE; col++) {
arguments->datatype[col] = NULL;
}
} else if (strcmp(argv[i], "-b") == 0) {
if (argc == i+1) {
printHelp();
errorPrint("%s", "\n\t-b need valid string following!\n");
exit(EXIT_FAILURE);
}
sptr = arguments->datatype;
++i;
if (strstr(argv[i], ",") == NULL) {
// only one col
......@@ -881,12 +893,12 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrint("%s", "-b: Invalid data_type!\n");
exit(EXIT_FAILURE);
}
sptr[0] = argv[i];
arguments->datatype[0] = argv[i];
} else {
// more than one col
int index = 0;
char *dupstr = strdup(argv[i]);
char *running = dupstr;
g_dupstr = strdup(argv[i]);
char *running = g_dupstr;
char *token = strsep(&running, ",");
while(token != NULL) {
if (strcasecmp(token, "INT")
......@@ -899,16 +911,15 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
&& strcasecmp(token, "BINARY")
&& strcasecmp(token, "NCHAR")) {
printHelp();
free(dupstr);
free(g_dupstr);
errorPrint("%s", "-b: Invalid data_type!\n");
exit(EXIT_FAILURE);
}
sptr[index++] = token;
arguments->datatype[index++] = token;
token = strsep(&running, ",");
if (index >= MAX_NUM_DATATYPE) break;
}
free(dupstr);
sptr[index] = NULL;
arguments->datatype[index] = NULL;
}
} else if (strcmp(argv[i], "-w") == 0) {
if ((argc == i+1) ||
......@@ -3449,7 +3460,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_args.interlace_rows, g_args.num_of_RPR);
printf(" interlace rows value will be set to num_of_records_per_req %"PRIu64"\n\n",
g_args.num_of_RPR);
prompt2();
prompt();
g_args.interlace_rows = g_args.num_of_RPR;
}
} else if (!interlaceRows) {
......@@ -5759,19 +5770,13 @@ static void startMultiThreadInsertData(int threads, char* db_name,
&& ((superTblInfo->childTblOffset + superTblInfo->childTblLimit )
> superTblInfo->childTblCount)) {
printf("WARNING: specified offset + limit > child table count!\n");
if (!g_args.answer_yes) {
printf(" Press enter key to continue or Ctrl-C to stop\n\n");
(void)getchar();
}
prompt();
}
if ((superTblInfo->childTblExists != TBL_NO_EXISTS)
&& (0 == superTblInfo->childTblLimit)) {
printf("WARNING: specified limit = 0, which cannot find table name to insert or query! \n");
if (!g_args.answer_yes) {
printf(" Press enter key to continue or Ctrl-C to stop\n\n");
(void)getchar();
}
prompt();
}
superTblInfo->childTblName = (char*)calloc(1,
......@@ -6093,19 +6098,11 @@ static void *readMetric(void *sarg) {
static void prompt()
{
if (!g_args.answer_yes) {
printf("Press enter key to continue\n\n");
printf(" Press enter key to continue or Ctrl-C to stop\n\n");
(void)getchar();
}
}
static void prompt2()
{
if (!g_args.answer_yes) {
printf(" press Enter key to continue or Ctrl-C to stop.");
(void)getchar();
}
}
static int insertTestProcess() {
setupForAnsiEscape();
......@@ -7325,6 +7322,9 @@ int main(int argc, char *argv[]) {
} else {
testCmdLine();
}
if (g_dupstr)
free(g_dupstr);
}
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册