Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c571c38b
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c571c38b
编写于
8月 10, 2019
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
revise issue #124
上级
0da8e9ad
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
22 deletion
+37
-22
src/modules/http/inc/httpJson.h
src/modules/http/inc/httpJson.h
+2
-2
src/modules/http/inc/restJson.h
src/modules/http/inc/restJson.h
+2
-2
src/modules/http/src/httpJson.c
src/modules/http/src/httpJson.c
+31
-16
src/modules/http/src/restJson.c
src/modules/http/src/restJson.c
+2
-2
未找到文件。
src/modules/http/inc/httpJson.h
浏览文件 @
c571c38b
...
...
@@ -63,8 +63,8 @@ void httpJsonString(JsonBuf* buf, char* sVal, int len);
void
httpJsonOriginString
(
JsonBuf
*
buf
,
char
*
sVal
,
int
len
);
void
httpJsonStringForTransMean
(
JsonBuf
*
buf
,
char
*
SVal
,
int
maxLen
);
void
httpJsonInt64
(
JsonBuf
*
buf
,
int64_t
num
);
void
httpJsonTimestamp
(
JsonBuf
*
buf
,
int64_t
t
);
void
httpJsonUtcTimestamp
(
JsonBuf
*
buf
,
int64_t
t
);
void
httpJsonTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
bool
us
);
void
httpJsonUtcTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
bool
us
);
void
httpJsonInt
(
JsonBuf
*
buf
,
int
num
);
void
httpJsonFloat
(
JsonBuf
*
buf
,
float
num
);
void
httpJsonDouble
(
JsonBuf
*
buf
,
double
num
);
...
...
src/modules/http/inc/restJson.h
浏览文件 @
c571c38b
...
...
@@ -40,8 +40,8 @@
#define REST_JSON_AFFECT_ROWS_LEN 13
#define REST_TIMESTAMP_FMT_LOCAL_STRING 0
#define REST_TIMESTAMP_FMT_TIMESTAMP 1
#define REST_TIMESTAMP_FMT_UTC_STRING 2
#define REST_TIMESTAMP_FMT_TIMESTAMP
1
#define REST_TIMESTAMP_FMT_UTC_STRING
2
void
restBuildSqlAffectRowsJson
(
HttpContext
*
pContext
,
HttpSqlCmd
*
cmd
,
int
affect_rows
);
...
...
src/modules/http/src/httpJson.c
浏览文件 @
c571c38b
...
...
@@ -260,30 +260,45 @@ void httpJsonInt64(JsonBuf* buf, int64_t num) {
buf
->
lst
+=
snprintf
(
buf
->
lst
,
MAX_NUM_STR_SZ
,
"%ld"
,
num
);
}
void
httpJsonTimestamp
(
JsonBuf
*
buf
,
int64_t
t
)
{
char
ts
[
30
]
=
{
0
};
void
httpJsonTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
bool
us
)
{
char
ts
[
35
]
=
{
0
};
struct
tm
*
ptm
;
int
precision
=
1000
;
if
(
us
)
{
precision
=
1000000
;
}
struct
tm
*
ptm
;
time_t
tt
=
t
/
1000
;
time_t
tt
=
t
/
precision
;
ptm
=
localtime
(
&
tt
);
int
length
=
(
int
)
strftime
(
ts
,
30
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
snprintf
(
ts
+
length
,
MAX_NUM_STR_SZ
,
".%03ld"
,
t
%
1000
);
int
length
=
(
int
)
strftime
(
ts
,
35
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
if
(
us
)
{
length
+=
snprintf
(
ts
+
length
,
8
,
".%06ld"
,
t
%
precision
);
}
else
{
length
+=
snprintf
(
ts
+
length
,
5
,
".%03ld"
,
t
%
precision
);
}
httpJsonString
(
buf
,
ts
,
length
+
4
);
httpJsonString
(
buf
,
ts
,
length
);
}
void
httpJsonUtcTimestamp
(
JsonBuf
*
buf
,
int64_t
t
)
{
char
ts
[
35
]
=
{
0
};
void
httpJsonUtcTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
bool
us
)
{
char
ts
[
40
]
=
{
0
};
struct
tm
*
ptm
;
time_t
tt
=
t
/
1000
;
int
precision
=
1000
;
if
(
us
)
{
precision
=
1000000
;
}
time_t
tt
=
t
/
precision
;
ptm
=
localtime
(
&
tt
);
int
length
=
(
int
)
strftime
(
ts
,
35
,
"%Y-%m-%dT%H:%M:%S"
,
ptm
);
length
+=
snprintf
(
ts
+
length
,
MAX_NUM_STR_SZ
,
".%03ld"
,
t
%
1000
);
length
+=
(
int
)
strftime
(
ts
+
length
,
35
-
length
,
"%z"
,
ptm
);
int
length
=
(
int
)
strftime
(
ts
,
40
,
"%Y-%m-%dT%H:%M:%S"
,
ptm
);
if
(
us
)
{
length
+=
snprintf
(
ts
+
length
,
8
,
".%06ld"
,
t
%
precision
);
}
else
{
length
+=
snprintf
(
ts
+
length
,
5
,
".%03ld"
,
t
%
precision
);
}
length
+=
(
int
)
strftime
(
ts
+
length
,
40
-
length
,
"%z"
,
ptm
);
httpJsonString
(
buf
,
ts
,
length
+
4
);
httpJsonString
(
buf
,
ts
,
length
);
}
void
httpJsonInt
(
JsonBuf
*
buf
,
int
num
)
{
...
...
src/modules/http/src/restJson.c
浏览文件 @
c571c38b
...
...
@@ -135,11 +135,11 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
if
(
timestampFormat
==
REST_TIMESTAMP_FMT_LOCAL_STRING
)
{
httpJsonTimestamp
(
jsonBuf
,
*
((
int64_t
*
)
row
[
i
]));
httpJsonTimestamp
(
jsonBuf
,
*
((
int64_t
*
)
row
[
i
])
,
taos_result_precision
(
result
)
==
TSDB_TIME_PRECISION_MICRO
);
}
else
if
(
timestampFormat
==
REST_TIMESTAMP_FMT_TIMESTAMP
)
{
httpJsonInt64
(
jsonBuf
,
*
((
int64_t
*
)
row
[
i
]));
}
else
{
httpJsonUtcTimestamp
(
jsonBuf
,
*
((
int64_t
*
)
row
[
i
]));
httpJsonUtcTimestamp
(
jsonBuf
,
*
((
int64_t
*
)
row
[
i
])
,
taos_result_precision
(
result
)
==
TSDB_TIME_PRECISION_MICRO
);
}
break
;
default:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录