[TD-3580]<fix>: taosdump support human readable time format. (#5888)
* [TD-3580]<fix>: taosdump support human readable time format. support -S too. * [TD-3580]<fix>: taosdump support human readable time format. provide more info about time format Co-authored-by: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
parent
0a390c166c
commit
cde11227d9
|
@ -214,8 +214,8 @@ static struct argp_option options[] = {
|
||||||
// dump format options
|
// dump format options
|
||||||
{"schemaonly", 's', 0, 0, "Only dump schema.", 3},
|
{"schemaonly", 's', 0, 0, "Only dump schema.", 3},
|
||||||
{"with-property", 'M', 0, 0, "Dump schema with properties.", 3},
|
{"with-property", 'M', 0, 0, "Dump schema with properties.", 3},
|
||||||
{"start-time", 'S', "START_TIME", 0, "Start time to dump.", 3},
|
{"start-time", 'S', "START_TIME", 0, "Start time to dump. Either Epoch or ISO8601/RFC3339 format is acceptable. Epoch precision millisecond. ISO8601 format example: 2017-10-01T18:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 3},
|
||||||
{"end-time", 'E', "END_TIME", 0, "End time to dump. Epoch or ISO8601/RFC3339 format is acceptable. For example: 2017-10-01T18:00:00+0800", 3},
|
{"end-time", 'E', "END_TIME", 0, "End time to dump. Either Epoch or ISO8601/RFC3339 format is acceptable. Epoch precision millisecond. ISO8601 format example: 2017-10-01T18:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 3},
|
||||||
{"data-batch", 'N', "DATA_BATCH", 0, "Number of data point per insert statement. Default is 1.", 3},
|
{"data-batch", 'N', "DATA_BATCH", 0, "Number of data point per insert statement. Default is 1.", 3},
|
||||||
{"max-sql-len", 'L', "SQL_LEN", 0, "Max length of one sql. Default is 65480.", 3},
|
{"max-sql-len", 'L', "SQL_LEN", 0, "Max length of one sql. Default is 65480.", 3},
|
||||||
{"table-batch", 't', "TABLE_BATCH", 0, "Number of table dumpout into one output file. Default is 1.", 3},
|
{"table-batch", 't', "TABLE_BATCH", 0, "Number of table dumpout into one output file. Default is 1.", 3},
|
||||||
|
@ -482,29 +482,35 @@ static int queryDbImpl(TAOS *taos, char *command) {
|
||||||
|
|
||||||
static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (strcmp(argv[i], "-E") == 0) {
|
if ((strcmp(argv[i], "-S") == 0)
|
||||||
char *tmp = strdup(argv[++i]);
|
|| (strcmp(argv[i], "-E") == 0)) {
|
||||||
|
if (argv[i+1]) {
|
||||||
|
char *tmp = strdup(argv[++i]);
|
||||||
|
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
int64_t tmpEpoch;
|
int64_t tmpEpoch;
|
||||||
if (strchr(tmp, ':') && strchr(tmp, '-')) {
|
if (strchr(tmp, ':') && strchr(tmp, '-')) {
|
||||||
if (TSDB_CODE_SUCCESS != taosParseTime(
|
if (TSDB_CODE_SUCCESS != taosParseTime(
|
||||||
tmp, &tmpEpoch, strlen(tmp), TSDB_TIME_PRECISION_MILLI, 0)) {
|
tmp, &tmpEpoch, strlen(tmp), TSDB_TIME_PRECISION_MILLI, 0)) {
|
||||||
fprintf(stderr, "Input end time error!\n");
|
fprintf(stderr, "Input end time error!\n");
|
||||||
free(tmp);
|
free(tmp);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tmpEpoch = atoll(tmp);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
tmpEpoch = atoll(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(argv[i], "%"PRId64"", tmpEpoch);
|
|
||||||
debugPrint("%s() LN%d, tmp is: %s, argv[%d]: %s\n",
|
|
||||||
__func__, __LINE__, tmp, i, argv[i]);
|
|
||||||
|
|
||||||
free(tmp);
|
sprintf(argv[i], "%"PRId64"", tmpEpoch);
|
||||||
|
debugPrint("%s() LN%d, tmp is: %s, argv[%d]: %s\n",
|
||||||
|
__func__, __LINE__, tmp, i, argv[i]);
|
||||||
|
|
||||||
|
free(tmp);
|
||||||
|
} else {
|
||||||
|
errorPrint("%s() LN%d, strdup() cannot allocate memory\n", __func__, __LINE__);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
errorPrint("%s() LN%d, strdup() cannot allocate memory\n", __func__, __LINE__);
|
errorPrint("%s need a valid value following!\n", argv[i]);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-g") == 0) {
|
} else if (strcmp(argv[i], "-g") == 0) {
|
||||||
|
|
Loading…
Reference in New Issue