[TD-4272]<fix>: taosdemo specify columns. (#6173)
Co-authored-by: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
parent
f0b77fa3c3
commit
608e67826d
|
@ -189,6 +189,8 @@ typedef struct {
|
||||||
} SColDes;
|
} SColDes;
|
||||||
|
|
||||||
/* Used by main to communicate with parse_opt. */
|
/* Used by main to communicate with parse_opt. */
|
||||||
|
static char *g_dupstr = NULL;
|
||||||
|
|
||||||
typedef struct SArguments_S {
|
typedef struct SArguments_S {
|
||||||
char * metaFile;
|
char * metaFile;
|
||||||
uint32_t test_mode;
|
uint32_t test_mode;
|
||||||
|
@ -526,7 +528,6 @@ static int taosRandom()
|
||||||
#endif // ifdef Windows
|
#endif // ifdef Windows
|
||||||
|
|
||||||
static void prompt();
|
static void prompt();
|
||||||
static void prompt2();
|
|
||||||
static int createDatabasesAndStables();
|
static int createDatabasesAndStables();
|
||||||
static void createChildTables();
|
static void createChildTables();
|
||||||
static int queryDbExec(TAOS *taos, char *command, QUERY_TYPE type, bool quiet);
|
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.");
|
"The data_type of columns, default: INT,INT,INT,INT.");
|
||||||
printf("%s%s%s%s\n", indent, "-w", indent,
|
printf("%s%s%s%s\n", indent, "-w", indent,
|
||||||
"The length of data_type 'BINARY' or 'NCHAR'. Default is 16");
|
"The length of data_type 'BINARY' or 'NCHAR'. Default is 16");
|
||||||
printf("%s%s%s%s\n", indent, "-l", indent,
|
printf("%s%s%s%s%d\n", indent, "-l", indent,
|
||||||
"The number of columns per record. Default is 4.");
|
"The number of columns per record. Default is 4. Max values is ",
|
||||||
|
MAX_NUM_DATATYPE);
|
||||||
printf("%s%s%s%s\n", indent, "-T", indent,
|
printf("%s%s%s%s\n", indent, "-T", indent,
|
||||||
"The number of threads. Default is 10.");
|
"The number of threads. Default is 10.");
|
||||||
printf("%s%s%s%s\n", indent, "-i", indent,
|
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) {
|
static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
char **sptr;
|
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (strcmp(argv[i], "-f") == 0) {
|
if (strcmp(argv[i], "-f") == 0) {
|
||||||
|
@ -851,20 +852,31 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
}
|
}
|
||||||
arguments->database = argv[++i];
|
arguments->database = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-l") == 0) {
|
} else if (strcmp(argv[i], "-l") == 0) {
|
||||||
if ((argc == i+1) ||
|
if (argc == i+1) {
|
||||||
(!isStringNumber(argv[i+1]))) {
|
if (!isStringNumber(argv[i+1])) {
|
||||||
printHelp();
|
printHelp();
|
||||||
errorPrint("%s", "\n\t-l need a number following!\n");
|
errorPrint("%s", "\n\t-l need a number following!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
arguments->num_of_CPR = atoi(argv[++i]);
|
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) {
|
} else if (strcmp(argv[i], "-b") == 0) {
|
||||||
if (argc == i+1) {
|
if (argc == i+1) {
|
||||||
printHelp();
|
printHelp();
|
||||||
errorPrint("%s", "\n\t-b need valid string following!\n");
|
errorPrint("%s", "\n\t-b need valid string following!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
sptr = arguments->datatype;
|
|
||||||
++i;
|
++i;
|
||||||
if (strstr(argv[i], ",") == NULL) {
|
if (strstr(argv[i], ",") == NULL) {
|
||||||
// only one col
|
// only one col
|
||||||
|
@ -881,12 +893,12 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
errorPrint("%s", "-b: Invalid data_type!\n");
|
errorPrint("%s", "-b: Invalid data_type!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
sptr[0] = argv[i];
|
arguments->datatype[0] = argv[i];
|
||||||
} else {
|
} else {
|
||||||
// more than one col
|
// more than one col
|
||||||
int index = 0;
|
int index = 0;
|
||||||
char *dupstr = strdup(argv[i]);
|
g_dupstr = strdup(argv[i]);
|
||||||
char *running = dupstr;
|
char *running = g_dupstr;
|
||||||
char *token = strsep(&running, ",");
|
char *token = strsep(&running, ",");
|
||||||
while(token != NULL) {
|
while(token != NULL) {
|
||||||
if (strcasecmp(token, "INT")
|
if (strcasecmp(token, "INT")
|
||||||
|
@ -899,16 +911,15 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
&& strcasecmp(token, "BINARY")
|
&& strcasecmp(token, "BINARY")
|
||||||
&& strcasecmp(token, "NCHAR")) {
|
&& strcasecmp(token, "NCHAR")) {
|
||||||
printHelp();
|
printHelp();
|
||||||
free(dupstr);
|
free(g_dupstr);
|
||||||
errorPrint("%s", "-b: Invalid data_type!\n");
|
errorPrint("%s", "-b: Invalid data_type!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
sptr[index++] = token;
|
arguments->datatype[index++] = token;
|
||||||
token = strsep(&running, ",");
|
token = strsep(&running, ",");
|
||||||
if (index >= MAX_NUM_DATATYPE) break;
|
if (index >= MAX_NUM_DATATYPE) break;
|
||||||
}
|
}
|
||||||
free(dupstr);
|
arguments->datatype[index] = NULL;
|
||||||
sptr[index] = NULL;
|
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-w") == 0) {
|
} else if (strcmp(argv[i], "-w") == 0) {
|
||||||
if ((argc == i+1) ||
|
if ((argc == i+1) ||
|
||||||
|
@ -3449,7 +3460,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
|
||||||
g_args.interlace_rows, g_args.num_of_RPR);
|
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",
|
printf(" interlace rows value will be set to num_of_records_per_req %"PRIu64"\n\n",
|
||||||
g_args.num_of_RPR);
|
g_args.num_of_RPR);
|
||||||
prompt2();
|
prompt();
|
||||||
g_args.interlace_rows = g_args.num_of_RPR;
|
g_args.interlace_rows = g_args.num_of_RPR;
|
||||||
}
|
}
|
||||||
} else if (!interlaceRows) {
|
} else if (!interlaceRows) {
|
||||||
|
@ -5759,19 +5770,13 @@ static void startMultiThreadInsertData(int threads, char* db_name,
|
||||||
&& ((superTblInfo->childTblOffset + superTblInfo->childTblLimit )
|
&& ((superTblInfo->childTblOffset + superTblInfo->childTblLimit )
|
||||||
> superTblInfo->childTblCount)) {
|
> superTblInfo->childTblCount)) {
|
||||||
printf("WARNING: specified offset + limit > child table count!\n");
|
printf("WARNING: specified offset + limit > child table count!\n");
|
||||||
if (!g_args.answer_yes) {
|
prompt();
|
||||||
printf(" Press enter key to continue or Ctrl-C to stop\n\n");
|
|
||||||
(void)getchar();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((superTblInfo->childTblExists != TBL_NO_EXISTS)
|
if ((superTblInfo->childTblExists != TBL_NO_EXISTS)
|
||||||
&& (0 == superTblInfo->childTblLimit)) {
|
&& (0 == superTblInfo->childTblLimit)) {
|
||||||
printf("WARNING: specified limit = 0, which cannot find table name to insert or query! \n");
|
printf("WARNING: specified limit = 0, which cannot find table name to insert or query! \n");
|
||||||
if (!g_args.answer_yes) {
|
prompt();
|
||||||
printf(" Press enter key to continue or Ctrl-C to stop\n\n");
|
|
||||||
(void)getchar();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
superTblInfo->childTblName = (char*)calloc(1,
|
superTblInfo->childTblName = (char*)calloc(1,
|
||||||
|
@ -6093,15 +6098,7 @@ static void *readMetric(void *sarg) {
|
||||||
static void prompt()
|
static void prompt()
|
||||||
{
|
{
|
||||||
if (!g_args.answer_yes) {
|
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();
|
(void)getchar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7325,6 +7322,9 @@ int main(int argc, char *argv[]) {
|
||||||
} else {
|
} else {
|
||||||
testCmdLine();
|
testCmdLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_dupstr)
|
||||||
|
free(g_dupstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue