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

[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: NShuduo Sang <sdsang@taosdata.com>
上级 0a390c16
...@@ -214,8 +214,8 @@ static struct argp_option options[] = { ...@@ -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) { ...@@ -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]) {
if (tmp) { char *tmp = strdup(argv[++i]);
int64_t tmpEpoch;
if (strchr(tmp, ':') && strchr(tmp, '-')) { if (tmp) {
if (TSDB_CODE_SUCCESS != taosParseTime( int64_t tmpEpoch;
tmp, &tmpEpoch, strlen(tmp), TSDB_TIME_PRECISION_MILLI, 0)) { if (strchr(tmp, ':') && strchr(tmp, '-')) {
fprintf(stderr, "Input end time error!\n"); if (TSDB_CODE_SUCCESS != taosParseTime(
free(tmp); tmp, &tmpEpoch, strlen(tmp), TSDB_TIME_PRECISION_MILLI, 0)) {
return; fprintf(stderr, "Input end time error!\n");
free(tmp);
return;
}
} 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);
} else { } else {
tmpEpoch = atoll(tmp); errorPrint("%s() LN%d, strdup() cannot allocate memory\n", __func__, __LINE__);
exit(-1);
} }
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 { } 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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册