Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4632c375
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4632c375
编写于
8月 30, 2022
作者:
wafwerar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature: shell csv rfc 4180
上级
8a34a321
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
22 deletion
+23
-22
tools/shell/inc/shellInt.h
tools/shell/inc/shellInt.h
+1
-1
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+22
-21
未找到文件。
tools/shell/inc/shellInt.h
浏览文件 @
4632c375
...
...
@@ -113,7 +113,7 @@ int32_t shellExecute();
int32_t
shellCalcColWidth
(
TAOS_FIELD
*
field
,
int32_t
precision
);
void
shellPrintHeader
(
TAOS_FIELD
*
fields
,
int32_t
*
width
,
int32_t
num_fields
);
void
shellPrintField
(
const
char
*
val
,
TAOS_FIELD
*
field
,
int32_t
width
,
int32_t
length
,
int32_t
precision
);
void
shellDumpFieldToFile
(
TdFilePtr
pFile
,
const
char
*
val
,
TAOS_FIELD
*
field
,
int32_t
length
,
int32_t
precision
,
bool
quotation
);
void
shellDumpFieldToFile
(
TdFilePtr
pFile
,
const
char
*
val
,
TAOS_FIELD
*
field
,
int32_t
length
,
int32_t
precision
);
// shellUtil.c
int32_t
shellCheckIntSize
();
void
shellPrintVersion
();
...
...
tools/shell/src/shellEngine.c
浏览文件 @
4632c375
...
...
@@ -264,15 +264,9 @@ char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) {
return
buf
;
}
void
shellDumpFieldToFile
(
TdFilePtr
pFile
,
const
char
*
val
,
TAOS_FIELD
*
field
,
int32_t
length
,
int32_t
precision
,
bool
quotation
)
{
char
quotationStr
[
2
];
quotationStr
[
0
]
=
0
;
quotationStr
[
1
]
=
0
;
if
(
quotation
)
{
quotationStr
[
0
]
=
'\"'
;
}
void
shellDumpFieldToFile
(
TdFilePtr
pFile
,
const
char
*
val
,
TAOS_FIELD
*
field
,
int32_t
length
,
int32_t
precision
)
{
if
(
val
==
NULL
)
{
taosFprintfFile
(
pFile
,
"%s
%s%s"
,
quotationStr
,
TSDB_DATA_NULL_STR
,
quotationStr
);
taosFprintfFile
(
pFile
,
"%s
"
,
TSDB_DATA_NULL_STR
);
return
;
}
...
...
@@ -280,39 +274,39 @@ void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, i
char
buf
[
TSDB_MAX_BYTES_PER_ROW
];
switch
(
field
->
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
taosFprintfFile
(
pFile
,
"%
s%d%s"
,
quotationStr
,
((((
int32_t
)(
*
((
char
*
)
val
)))
==
1
)
?
1
:
0
),
quotationStr
);
taosFprintfFile
(
pFile
,
"%
d"
,
((((
int32_t
)(
*
((
char
*
)
val
)))
==
1
)
?
1
:
0
)
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
taosFprintfFile
(
pFile
,
"%
s%d%s"
,
quotationStr
,
*
((
int8_t
*
)
val
),
quotationStr
);
taosFprintfFile
(
pFile
,
"%
d"
,
*
((
int8_t
*
)
val
)
);
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
taosFprintfFile
(
pFile
,
"%
s%u%s"
,
quotationStr
,
*
((
uint8_t
*
)
val
),
quotationStr
);
taosFprintfFile
(
pFile
,
"%
u"
,
*
((
uint8_t
*
)
val
)
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
taosFprintfFile
(
pFile
,
"%
s%d%s"
,
quotationStr
,
*
((
int16_t
*
)
val
),
quotationStr
);
taosFprintfFile
(
pFile
,
"%
d"
,
*
((
int16_t
*
)
val
)
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
taosFprintfFile
(
pFile
,
"%
s%u%s"
,
quotationStr
,
*
((
uint16_t
*
)
val
),
quotationStr
);
taosFprintfFile
(
pFile
,
"%
u"
,
*
((
uint16_t
*
)
val
)
);
break
;
case
TSDB_DATA_TYPE_INT
:
taosFprintfFile
(
pFile
,
"%
s%d%s"
,
quotationStr
,
*
((
int32_t
*
)
val
),
quotationStr
);
taosFprintfFile
(
pFile
,
"%
d"
,
*
((
int32_t
*
)
val
)
);
break
;
case
TSDB_DATA_TYPE_UINT
:
taosFprintfFile
(
pFile
,
"%
s%u%s"
,
quotationStr
,
*
((
uint32_t
*
)
val
),
quotationStr
);
taosFprintfFile
(
pFile
,
"%
u"
,
*
((
uint32_t
*
)
val
)
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
taosFprintfFile
(
pFile
,
"%
s%"
PRId64
"%s"
,
quotationStr
,
*
((
int64_t
*
)
val
),
quotationStr
);
taosFprintfFile
(
pFile
,
"%
"
PRId64
,
*
((
int64_t
*
)
val
)
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
taosFprintfFile
(
pFile
,
"%
s%"
PRIu64
"%s"
,
quotationStr
,
*
((
uint64_t
*
)
val
),
quotationStr
);
taosFprintfFile
(
pFile
,
"%
"
PRIu64
,
*
((
uint64_t
*
)
val
)
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
taosFprintfFile
(
pFile
,
"%
s%.5f%s"
,
quotationStr
,
GET_FLOAT_VAL
(
val
),
quotationStr
);
taosFprintfFile
(
pFile
,
"%
.5f"
,
GET_FLOAT_VAL
(
val
)
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
n
=
snprintf
(
buf
,
TSDB_MAX_BYTES_PER_ROW
,
"%
s%*.9f%s"
,
quotationStr
,
length
,
GET_DOUBLE_VAL
(
val
),
quotationStr
);
n
=
snprintf
(
buf
,
TSDB_MAX_BYTES_PER_ROW
,
"%
*.9f"
,
length
,
GET_DOUBLE_VAL
(
val
)
);
if
(
n
>
TMAX
(
25
,
length
))
{
taosFprintfFile
(
pFile
,
"%
s%*.15e%s"
,
quotationStr
,
length
,
GET_DOUBLE_VAL
(
val
),
quotationStr
);
taosFprintfFile
(
pFile
,
"%
*.15e"
,
length
,
GET_DOUBLE_VAL
(
val
)
);
}
else
{
taosFprintfFile
(
pFile
,
"%s"
,
buf
);
}
...
...
@@ -321,13 +315,20 @@ void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, i
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_JSON
:
{
char
quotationStr
[
2
];
int32_t
bufIndex
=
0
;
quotationStr
[
0
]
=
0
;
quotationStr
[
1
]
=
0
;
for
(
int32_t
i
=
0
;
i
<
length
;
i
++
)
{
buf
[
bufIndex
]
=
val
[
i
];
bufIndex
++
;
if
(
val
[
i
]
==
'\"'
)
{
buf
[
bufIndex
]
=
val
[
i
];
bufIndex
++
;
quotationStr
[
0
]
=
'\"'
;
}
if
(
val
[
i
]
==
','
)
{
quotationStr
[
0
]
=
'\"'
;
}
}
buf
[
bufIndex
]
=
0
;
...
...
@@ -336,7 +337,7 @@ void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, i
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
shellFormatTimestamp
(
buf
,
*
(
int64_t
*
)
val
,
precision
);
taosFprintfFile
(
pFile
,
"%s
%s%s"
,
quotationStr
,
buf
,
quotationStr
);
taosFprintfFile
(
pFile
,
"%s
"
,
buf
);
break
;
default:
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录