Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8f0788e9
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
8f0788e9
编写于
11月 24, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change ouput data format for json tag [change json type with qid return logic]
上级
2e6f68ab
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
35 deletion
+46
-35
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+1
-8
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+45
-27
未找到文件。
src/client/src/tscSubquery.c
浏览文件 @
8f0788e9
...
...
@@ -3687,14 +3687,7 @@ TAOS_ROW doSetResultRowData(SSqlObj *pSql) {
int32_t
type
=
pInfo
->
field
.
type
;
int32_t
bytes
=
pInfo
->
field
.
bytes
;
if
(
type
==
TSDB_DATA_TYPE_JSON
){
char
*
p
=
pRes
->
urow
[
i
];
if
(
*
p
==
TSDB_DATA_TYPE_NCHAR
&&
isNull
(
POINTER_SHIFT
(
p
,
CHAR_BYTES
),
type
))
{
pRes
->
tsrow
[
j
]
=
NULL
;
}
else
{
pRes
->
tsrow
[
j
]
=
pRes
->
urow
[
i
];
}
}
else
if
(
!
IS_VAR_DATA_TYPE
(
type
))
{
if
(
!
IS_VAR_DATA_TYPE
(
type
)
&&
type
!=
TSDB_DATA_TYPE_JSON
)
{
pRes
->
tsrow
[
j
]
=
isNull
(
pRes
->
urow
[
i
],
type
)
?
NULL
:
pRes
->
urow
[
i
];
}
else
{
pRes
->
tsrow
[
j
]
=
isNull
(
pRes
->
urow
[
i
],
type
)
?
NULL
:
varDataVal
(
pRes
->
urow
[
i
]);
...
...
src/client/src/tscUtil.c
浏览文件 @
8f0788e9
...
...
@@ -701,7 +701,51 @@ int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
static
void
setResRawPtrImpl
(
SSqlRes
*
pRes
,
SInternalField
*
pInfo
,
int32_t
i
,
bool
convertNchar
)
{
// generated the user-defined column result
if
(
pInfo
->
pExpr
->
pExpr
==
NULL
&&
TSDB_COL_IS_UD_COL
(
pInfo
->
pExpr
->
base
.
colInfo
.
flag
))
{
if
(
pInfo
->
field
.
type
==
TSDB_DATA_TYPE_JSON
){
char
*
buffer
=
realloc
(
pRes
->
buffer
[
i
],
pInfo
->
field
.
bytes
*
pRes
->
numOfRows
);
if
(
buffer
==
NULL
)
return
;
pRes
->
buffer
[
i
]
=
buffer
;
// string terminated char for binary data
memset
(
pRes
->
buffer
[
i
],
0
,
pInfo
->
field
.
bytes
*
pRes
->
numOfRows
);
char
*
p
=
pRes
->
urow
[
i
];
int32_t
offset
=
0
;
for
(
int32_t
k
=
0
;
k
<
pRes
->
numOfRows
;
++
k
)
{
char
*
dst
=
pRes
->
buffer
[
i
]
+
k
*
offset
;
char
*
realData
=
p
+
CHAR_BYTES
;
char
type
=
*
p
;
if
(
type
==
TSDB_DATA_TYPE_NCHAR
&&
isNull
(
realData
,
TSDB_DATA_TYPE_JSON
))
{
memcpy
(
dst
,
realData
,
varDataTLen
(
realData
));
offset
=
pInfo
->
field
.
bytes
;
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
convertNchar
){
int32_t
length
=
taosUcs4ToMbs
(
varDataVal
(
realData
),
varDataLen
(
realData
),
varDataVal
(
dst
));
varDataSetLen
(
dst
,
length
);
if
(
length
==
0
)
{
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
(
char
*
)
varDataVal
(
realData
));
}
}
else
{
memcpy
(
dst
,
realData
,
varDataTLen
(
realData
));
}
offset
=
pInfo
->
field
.
bytes
;
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
)
{
memcpy
(
dst
,
realData
,
DOUBLE_BYTES
);
offset
=
DOUBLE_BYTES
;
}
else
if
(
type
==
TSDB_DATA_TYPE_BIGINT
)
{
memcpy
(
dst
,
realData
,
LONG_BYTES
);
offset
=
LONG_BYTES
;
}
else
if
(
type
==
TSDB_DATA_TYPE_BOOL
)
{
memcpy
(
dst
,
realData
,
CHAR_BYTES
);
offset
=
CHAR_BYTES
;
}
else
{
assert
(
0
);
}
p
+=
pInfo
->
field
.
bytes
;
}
memcpy
(
pRes
->
urow
[
i
],
pRes
->
buffer
[
i
],
pInfo
->
field
.
bytes
*
pRes
->
numOfRows
);
}
else
if
(
pInfo
->
pExpr
->
pExpr
==
NULL
&&
TSDB_COL_IS_UD_COL
(
pInfo
->
pExpr
->
base
.
colInfo
.
flag
))
{
if
(
pInfo
->
pExpr
->
base
.
param
[
0
].
nType
==
TSDB_DATA_TYPE_NULL
)
{
setNullN
(
pRes
->
urow
[
i
],
pInfo
->
field
.
type
,
pInfo
->
field
.
bytes
,
(
int32_t
)
pRes
->
numOfRows
);
}
else
{
...
...
@@ -750,32 +794,6 @@ static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bo
p
+=
pInfo
->
field
.
bytes
;
}
memcpy
(
pRes
->
urow
[
i
],
pRes
->
buffer
[
i
],
pInfo
->
field
.
bytes
*
pRes
->
numOfRows
);
}
else
if
(
convertNchar
&&
pInfo
->
field
.
type
==
TSDB_DATA_TYPE_JSON
&&
*
(
char
*
)(
pRes
->
urow
[
i
])
==
TSDB_DATA_TYPE_NCHAR
&&
!
isNull
(
POINTER_SHIFT
(
pRes
->
urow
[
i
],
CHAR_BYTES
),
TSDB_DATA_TYPE_JSON
))
{
// convert unicode to native code in a temporary buffer extra one byte for terminated symbol
char
*
buffer
=
realloc
(
pRes
->
buffer
[
i
],
pInfo
->
field
.
bytes
*
pRes
->
numOfRows
);
if
(
buffer
==
NULL
)
return
;
pRes
->
buffer
[
i
]
=
buffer
;
// string terminated char for binary data
memset
(
pRes
->
buffer
[
i
],
0
,
pInfo
->
field
.
bytes
*
pRes
->
numOfRows
);
char
*
p
=
pRes
->
urow
[
i
];
for
(
int32_t
k
=
0
;
k
<
pRes
->
numOfRows
;
++
k
)
{
char
*
dst
=
pRes
->
buffer
[
i
]
+
k
*
pInfo
->
field
.
bytes
;
char
*
realData
=
p
+
CHAR_BYTES
;
*
dst
=
*
p
;
dst
+=
CHAR_BYTES
;
int32_t
length
=
taosUcs4ToMbs
(
varDataVal
(
realData
),
varDataLen
(
realData
),
varDataVal
(
dst
));
varDataSetLen
(
dst
,
length
);
if
(
length
==
0
)
{
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
(
char
*
)
p
);
}
p
+=
pInfo
->
field
.
bytes
;
}
memcpy
(
pRes
->
urow
[
i
],
pRes
->
buffer
[
i
],
pInfo
->
field
.
bytes
*
pRes
->
numOfRows
);
}
if
(
convertNchar
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录