提交 c640c034 编写于 作者: X Xiaoyu Wang

import format error

上级 8f28a9c9
...@@ -497,9 +497,14 @@ static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) { ...@@ -497,9 +497,14 @@ static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) {
static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* field, int32_t length, static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* field, int32_t length,
int32_t precision) { int32_t precision) {
if (val == NULL) { if (val == NULL) {
taosFprintfFile(pFile, "NULL");
return; return;
} }
char quotationStr[2];
quotationStr[0] = '\"';
quotationStr[1] = 0;
int n; int n;
char buf[TSDB_MAX_BYTES_PER_ROW]; char buf[TSDB_MAX_BYTES_PER_ROW];
switch (field->type) { switch (field->type) {
...@@ -545,33 +550,23 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* f ...@@ -545,33 +550,23 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* f
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_JSON:
{ {
char quotationStr[2];
int32_t bufIndex = 0; int32_t bufIndex = 0;
quotationStr[0] = 0;
quotationStr[1] = 0;
for (int32_t i = 0; i < length; i++) { for (int32_t i = 0; i < length; i++) {
buf[bufIndex] = val[i]; buf[bufIndex] = val[i];
bufIndex++; bufIndex++;
if (val[i] == '\"') { if (val[i] == '\"') {
buf[bufIndex] = val[i]; buf[bufIndex] = val[i];
bufIndex++; bufIndex++;
quotationStr[0] = '\"';
}
if (val[i] == ',') {
quotationStr[0] = '\"';
} }
} }
buf[bufIndex] = 0; buf[bufIndex] = 0;
if (length == 0) {
quotationStr[0] = '\"';
}
taosFprintfFile(pFile, "%s%s%s", quotationStr, buf, quotationStr); taosFprintfFile(pFile, "%s%s%s", quotationStr, buf, quotationStr);
} }
break; break;
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
shellFormatTimestamp(buf, *(int64_t*)val, precision); shellFormatTimestamp(buf, *(int64_t*)val, precision);
taosFprintfFile(pFile, "%s", buf); taosFprintfFile(pFile, "%s%s%s", quotationStr, buf, quotationStr);
break; break;
default: default:
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册