Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3d16404e
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
3d16404e
编写于
7月 18, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bugs in tags retrieval
上级
7fd0fc2b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
39 deletion
+60
-39
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+45
-39
tests/script/general/parser/null_char.sim
tests/script/general/parser/null_char.sim
+15
-0
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
3d16404e
...
...
@@ -6417,6 +6417,22 @@ int32_t qKillQuery(qinfo_t qinfo) {
return
TSDB_CODE_SUCCESS
;
}
static
void
doSetTagValueToResultBuf
(
char
*
output
,
const
char
*
val
,
int16_t
type
,
int16_t
bytes
)
{
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
val
==
NULL
)
{
setVardataNull
(
output
,
type
);
}
else
{
memcpy
(
output
,
val
,
varDataTLen
(
val
));
}
}
else
{
if
(
val
==
NULL
)
{
setNull
(
output
,
type
,
bytes
);
}
else
{
// todo here stop will cause client crash
memcpy
(
output
,
val
,
bytes
);
}
}
}
static
void
buildTagQueryResult
(
SQInfo
*
pQInfo
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
...
...
@@ -6473,25 +6489,11 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
output
+=
sizeof
(
pQInfo
->
vgId
);
if
(
pExprInfo
->
base
.
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
char
*
data
=
tsdbGetTableName
(
item
->
pTable
);
char
*
data
=
tsdbGetTableName
(
item
->
pTable
);
memcpy
(
output
,
data
,
varDataTLen
(
data
));
}
else
{
char
*
val
=
tsdbGetTableTagVal
(
item
->
pTable
,
pExprInfo
->
base
.
colInfo
.
colId
,
type
,
bytes
);
// todo refactor
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
val
==
NULL
)
{
setVardataNull
(
output
,
type
);
}
else
{
memcpy
(
output
,
val
,
varDataTLen
(
val
));
}
}
else
{
if
(
val
==
NULL
)
{
setNull
(
output
,
type
,
bytes
);
}
else
{
// todo here stop will cause client crash
memcpy
(
output
,
val
,
bytes
);
}
}
char
*
data
=
tsdbGetTableTagVal
(
item
->
pTable
,
pExprInfo
->
base
.
colInfo
.
colId
,
type
,
bytes
);
doSetTagValueToResultBuf
(
output
,
data
,
type
,
bytes
);
}
count
+=
1
;
...
...
@@ -6509,39 +6511,43 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
count
=
0
;
SSchema
tbnameSchema
=
tGetTableNameColumnSchema
();
int32_t
maxNumOfTables
=
(
pQuery
->
limit
.
limit
<
pQuery
->
rec
.
capacity
)
?
pQuery
->
limit
.
limit
:
pQuery
->
rec
.
capacity
;
int32_t
maxNumOfTables
=
pQuery
->
rec
.
capacity
;
if
(
pQuery
->
limit
.
limit
>=
0
&&
pQuery
->
limit
.
limit
<
pQuery
->
rec
.
capacity
)
{
maxNumOfTables
=
pQuery
->
limit
.
limit
;
}
while
(
pQInfo
->
tableIndex
<
num
&&
count
<
maxNumOfTables
)
{
int32_t
i
=
pQInfo
->
tableIndex
++
;
// discard current result due to offset
if
(
pQuery
->
limit
.
offset
>
0
)
{
pQuery
->
limit
.
offset
-=
1
;
continue
;
}
SExprInfo
*
pExprInfo
=
pQuery
->
pSelectExpr
;
STableQueryInfo
*
item
=
taosArrayGetP
(
pa
,
i
);
char
*
data
=
NULL
,
*
dst
=
NULL
;
int16_t
type
=
0
,
bytes
=
0
;
for
(
int32_t
j
=
0
;
j
<
pQuery
->
numOfOutput
;
++
j
)
{
if
(
pExprInfo
[
j
].
base
.
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
char
*
data
=
tsdbGetTableName
(
item
->
pTable
);
char
*
dst
=
pQuery
->
sdata
[
j
]
->
data
+
count
*
tbnameSchema
.
bytes
;
memcpy
(
dst
,
data
,
varDataTLen
(
data
));
}
else
{
// todo refactor
int16_t
type
=
pExprInfo
[
j
].
type
;
int16_t
bytes
=
pExprInfo
[
j
].
bytes
;
bytes
=
tbnameSchema
.
bytes
;
type
=
tbnameSchema
.
type
;
data
=
tsdbGetTableName
(
item
->
pTable
);
dst
=
pQuery
->
sdata
[
j
]
->
data
+
count
*
tbnameSchema
.
bytes
;
}
else
{
type
=
pExprInfo
[
j
].
type
;
bytes
=
pExprInfo
[
j
].
bytes
;
char
*
data
=
tsdbGetTableTagVal
(
item
->
pTable
,
pExprInfo
[
j
].
base
.
colInfo
.
colId
,
type
,
bytes
);
char
*
dst
=
pQuery
->
sdata
[
j
]
->
data
+
count
*
pExprInfo
[
j
].
bytes
;
data
=
tsdbGetTableTagVal
(
item
->
pTable
,
pExprInfo
[
j
].
base
.
colInfo
.
colId
,
type
,
bytes
);
dst
=
pQuery
->
sdata
[
j
]
->
data
+
count
*
pExprInfo
[
j
].
bytes
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
data
==
NULL
)
{
setVardataNull
(
dst
,
type
);
}
else
{
memcpy
(
dst
,
data
,
varDataTLen
(
data
));
}
}
else
{
if
(
data
==
NULL
)
{
setNull
(
dst
,
type
,
bytes
);
}
else
{
memcpy
(
dst
,
data
,
pExprInfo
[
j
].
bytes
);
}
}
}
doSetTagValueToResultBuf
(
dst
,
data
,
type
,
bytes
);
}
count
+=
1
;
}
...
...
tests/script/general/parser/null_char.sim
浏览文件 @
3d16404e
...
...
@@ -105,6 +105,21 @@ if $data03 != 1 then
return -1
endi
sql select tag1 from st2 limit 20 offset 1
if $rows != 0 then
return -1
endi
sql select tag1 from st2 limit 10 offset 2
if $rows != 0 then
return -1
endi
sql select tag1 from st2 limit 0 offset 0
if $rows != 0 then
return -1
endi
sql create table st3 using mt2 tags (NULL, 'ABC', 103, 'FALSE')
sql select tag1, tag2, tag3, tag5 from st3
if $rows != 1 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录