Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e5b484f7
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e5b484f7
编写于
6月 05, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] support tbid(tbname) query
上级
6460c712
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
31 deletion
+55
-31
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+22
-6
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+33
-25
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
e5b484f7
...
...
@@ -1881,22 +1881,38 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
// functions can not be applied to normal columns
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
if
(
index
.
columnIndex
<
numOfCols
)
{
if
(
index
.
columnIndex
<
numOfCols
&&
index
.
columnIndex
!=
TSDB_TBNAME_COLUMN_INDEX
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
}
index
.
columnIndex
-=
numOfCols
;
if
(
index
.
columnIndex
>
0
)
{
index
.
columnIndex
-=
numOfCols
;
}
// 2. valid the column type
int16_t
colType
=
pSchema
[
index
.
columnIndex
].
type
;
if
(
colType
==
TSDB_DATA_TYPE_BOOL
||
colType
>=
TSDB_DATA_TYPE_BINARY
)
{
int16_t
colType
=
0
;
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
colType
=
TSDB_DATA_TYPE_BINARY
;
}
else
{
colType
=
pSchema
[
index
.
columnIndex
].
type
;
}
if
(
colType
==
TSDB_DATA_TYPE_BOOL
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
&
index
);
SSchema
*
pTagSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
SSchema
s
=
pTagSchema
[
index
.
columnIndex
];
SSchema
s
=
{
0
};
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
s
.
bytes
=
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
;
s
.
type
=
TSDB_DATA_TYPE_BINARY
;
s
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
}
else
{
s
=
pTagSchema
[
index
.
columnIndex
];
}
int16_t
bytes
=
0
;
int16_t
type
=
0
;
int32_t
inter
=
0
;
...
...
src/query/src/qExecutor.c
浏览文件 @
e5b484f7
...
...
@@ -4942,9 +4942,12 @@ static bool validateQuerySourceCols(SQueryTableMsg *pQueryMsg, SSqlFuncMsg** pEx
return
false
;
}
else
if
(
numOfTotal
==
0
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryMsg
->
numOfOutput
;
++
i
)
{
if
(
pExprMsg
[
i
]
->
functionId
!=
TSDB_FUNC_TAGPRJ
)
{
return
false
;
if
((
pExprMsg
[
i
]
->
functionId
==
TSDB_FUNC_TAGPRJ
)
||
(
pExprMsg
[
i
]
->
functionId
==
TSDB_FUNC_TID_TAG
&&
pExprMsg
[
i
]
->
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
))
{
continue
;
}
return
false
;
}
}
...
...
@@ -6035,53 +6038,58 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
num
=
taosArrayGetSize
(
pa
);
assert
(
num
==
pQInfo
->
groupInfo
.
numOfTables
);
// int16_t type, bytes;
int32_t
functionId
=
pQuery
->
pSelectExpr
[
0
].
base
.
functionId
;
if
(
functionId
==
TSDB_FUNC_TID_TAG
)
{
// return the tags & table Id
assert
(
pQuery
->
numOfOutput
==
1
);
SExprInfo
*
pExprInfo
=
&
pQuery
->
pSelectExpr
[
0
];
int32_t
rsize
=
pExprInfo
->
bytes
;
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SGroupItem
*
item
=
taosArrayGet
(
pa
,
i
);
SGroupItem
*
item
=
taosArrayGet
(
pa
,
i
);
char
*
output
=
pQuery
->
sdata
[
0
]
->
data
+
i
*
rsize
;
char
*
output
=
pQuery
->
sdata
[
0
]
->
data
+
i
*
rsize
;
varDataSetLen
(
output
,
rsize
-
VARSTR_HEADER_SIZE
);
output
=
varDataVal
(
output
);
*
(
int64_t
*
)
output
=
item
->
id
.
uid
;
// memory align problem, todo serialize
*
(
int64_t
*
)
output
=
item
->
id
.
uid
;
// memory align problem, todo serialize
output
+=
sizeof
(
item
->
id
.
uid
);
*
(
int32_t
*
)
output
=
item
->
id
.
tid
;
*
(
int32_t
*
)
output
=
item
->
id
.
tid
;
output
+=
sizeof
(
item
->
id
.
tid
);
*
(
int32_t
*
)
output
=
pQInfo
->
vgId
;
*
(
int32_t
*
)
output
=
pQInfo
->
vgId
;
output
+=
sizeof
(
pQInfo
->
vgId
);
int16_t
bytes
=
pExprInfo
->
bytes
;
int16_t
type
=
pExprInfo
->
type
;
char
*
val
=
tsdbGetTableTagVal
(
pQInfo
->
tsdb
,
&
item
->
id
,
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
));
}
if
(
pExprInfo
->
base
.
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
char
*
data
=
tsdbGetTableName
(
pQInfo
->
tsdb
,
&
item
->
id
);
memcpy
(
output
,
data
,
varDataTLen
(
data
));
}
else
{
if
(
val
==
NULL
)
{
setNull
(
output
,
type
,
bytes
);
char
*
val
=
tsdbGetTableTagVal
(
pQInfo
->
tsdb
,
&
item
->
id
,
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
{
memcpy
(
output
,
val
,
bytes
);
if
(
val
==
NULL
)
{
setNull
(
output
,
type
,
bytes
);
}
else
{
memcpy
(
output
,
val
,
bytes
);
}
}
}
}
pQInfo
->
tableIndex
=
pQInfo
->
groupInfo
.
numOfTables
;
qTrace
(
"QInfo:%p create (tableId, tag) info completed, rows:%d"
,
pQInfo
,
num
);
}
else
{
// return only the tags|table name etc.
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SExprInfo
*
pExprInfo
=
pQuery
->
pSelectExpr
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录