Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
48c93736
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
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,发现更多精彩内容 >>
提交
48c93736
编写于
9月 28, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: query information_schema.ins_tags optimize
上级
fa8593e9
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
111 addition
and
6 deletion
+111
-6
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+105
-6
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+4
-0
source/libs/planner/test/planOtherTest.cpp
source/libs/planner/test/planOtherTest.cpp
+2
-0
未找到文件。
source/libs/parser/src/parTranslater.c
浏览文件 @
48c93736
...
@@ -2141,10 +2141,111 @@ static bool sysTableFromVnode(const char* pTable) {
...
@@ -2141,10 +2141,111 @@ static bool sysTableFromVnode(const char* pTable) {
static
bool
sysTableFromDnode
(
const
char
*
pTable
)
{
return
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_DNODE_VARIABLES
);
}
static
bool
sysTableFromDnode
(
const
char
*
pTable
)
{
return
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_DNODE_VARIABLES
);
}
static
int32_t
getTagsTableVgroupListImpl
(
STranslateContext
*
pCxt
,
SName
*
pTargetName
,
SName
*
pName
,
SArray
**
pVgroupList
)
{
if
(
0
==
pTargetName
->
acctId
)
{
return
getDBVgInfoImpl
(
pCxt
,
pName
,
pVgroupList
);
}
if
(
TSDB_DB_NAME_T
==
pTargetName
->
type
)
{
return
getDBVgInfoImpl
(
pCxt
,
pTargetName
,
pVgroupList
);
}
SVgroupInfo
vgInfo
=
{
0
};
int32_t
code
=
getTableHashVgroupImpl
(
pCxt
,
pTargetName
,
&
vgInfo
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pVgroupList
=
taosArrayInit
(
1
,
sizeof
(
SVgroupInfo
));
if
(
NULL
==
*
pVgroupList
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
taosArrayPush
(
*
pVgroupList
,
&
vgInfo
);
}
return
code
;
}
static
int32_t
getTagsTableTargetNameFromOp
(
STranslateContext
*
pCxt
,
SOperatorNode
*
pOper
,
SName
*
pName
)
{
if
(
OP_TYPE_EQUAL
!=
pOper
->
opType
)
{
return
TSDB_CODE_SUCCESS
;
}
SColumnNode
*
pCol
=
NULL
;
SValueNode
*
pVal
=
NULL
;
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pOper
->
pLeft
))
{
pCol
=
(
SColumnNode
*
)
pOper
->
pLeft
;
}
else
if
(
QUERY_NODE_VALUE
==
nodeType
(
pOper
->
pLeft
))
{
pVal
=
(
SValueNode
*
)
pOper
->
pLeft
;
}
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pOper
->
pRight
))
{
pCol
=
(
SColumnNode
*
)
pOper
->
pRight
;
}
else
if
(
QUERY_NODE_VALUE
==
nodeType
(
pOper
->
pRight
))
{
pVal
=
(
SValueNode
*
)
pOper
->
pRight
;
}
if
(
NULL
==
pCol
||
NULL
==
pVal
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
0
==
strcmp
(
pCol
->
colName
,
"db_name"
))
{
return
tNameSetDbName
(
pName
,
pCxt
->
pParseCxt
->
acctId
,
pVal
->
literal
,
strlen
(
pVal
->
literal
));
}
else
if
(
0
==
strcmp
(
pCol
->
colName
,
"table_name"
))
{
return
tNameAddTbName
(
pName
,
pVal
->
literal
,
strlen
(
pVal
->
literal
));
}
return
TSDB_CODE_SUCCESS
;
}
static
void
getTagsTableTargetObjName
(
STranslateContext
*
pCxt
,
SNode
*
pNode
,
SName
*
pName
)
{
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
pNode
))
{
getTagsTableTargetNameFromOp
(
pCxt
,
(
SOperatorNode
*
)
pNode
,
pName
);
}
}
static
int32_t
getTagsTableTargetNameFromCond
(
STranslateContext
*
pCxt
,
SLogicConditionNode
*
pCond
,
SName
*
pName
)
{
if
(
LOGIC_COND_TYPE_AND
!=
pCond
->
condType
)
{
return
TSDB_CODE_SUCCESS
;
}
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pCond
->
pParameterList
)
{
getTagsTableTargetObjName
(
pCxt
,
pNode
,
pName
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
getTagsTableTargetName
(
STranslateContext
*
pCxt
,
SNode
*
pWhere
,
SName
*
pName
)
{
if
(
NULL
==
pWhere
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
pWhere
))
{
return
getTagsTableTargetNameFromOp
(
pCxt
,
(
SOperatorNode
*
)
pWhere
,
pName
);
}
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pWhere
))
{
return
getTagsTableTargetNameFromCond
(
pCxt
,
(
SLogicConditionNode
*
)
pWhere
,
pName
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
getTagsTableVgroupList
(
STranslateContext
*
pCxt
,
SName
*
pName
,
SArray
**
pVgroupList
)
{
if
(
!
isSelectStmt
(
pCxt
->
pCurrStmt
))
{
return
TSDB_CODE_SUCCESS
;
}
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pCxt
->
pCurrStmt
;
SName
targetName
=
{
0
};
int32_t
code
=
getTagsTableTargetName
(
pCxt
,
pSelect
->
pWhere
,
&
targetName
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getTagsTableVgroupListImpl
(
pCxt
,
&
targetName
,
pName
,
pVgroupList
);
}
return
code
;
}
static
int32_t
setVnodeSysTableVgroupList
(
STranslateContext
*
pCxt
,
SName
*
pName
,
SRealTableNode
*
pRealTable
)
{
static
int32_t
setVnodeSysTableVgroupList
(
STranslateContext
*
pCxt
,
SName
*
pName
,
SRealTableNode
*
pRealTable
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SArray
*
vgroupList
=
NULL
;
SArray
*
vgroupList
=
NULL
;
if
(
'\0'
!=
pRealTable
->
qualDbName
[
0
])
{
if
(
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TAGS
))
{
code
=
getTagsTableVgroupList
(
pCxt
,
pName
,
&
vgroupList
);
}
else
if
(
'\0'
!=
pRealTable
->
qualDbName
[
0
])
{
if
(
0
!=
strcmp
(
pRealTable
->
qualDbName
,
TSDB_INFORMATION_SCHEMA_DB
))
{
if
(
0
!=
strcmp
(
pRealTable
->
qualDbName
,
TSDB_INFORMATION_SCHEMA_DB
))
{
code
=
getDBVgInfo
(
pCxt
,
pRealTable
->
qualDbName
,
&
vgroupList
);
code
=
getDBVgInfo
(
pCxt
,
pRealTable
->
qualDbName
,
&
vgroupList
);
}
}
...
@@ -2152,14 +2253,12 @@ static int32_t setVnodeSysTableVgroupList(STranslateContext* pCxt, SName* pName,
...
@@ -2152,14 +2253,12 @@ static int32_t setVnodeSysTableVgroupList(STranslateContext* pCxt, SName* pName,
code
=
getDBVgInfoImpl
(
pCxt
,
pName
,
&
vgroupList
);
code
=
getDBVgInfoImpl
(
pCxt
,
pName
,
&
vgroupList
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pRealTable
->
table
.
dbName
,
TSDB_INFORMATION_SCHEMA_DB
)
&&
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TAGS
)
&&
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TAGS
)
&&
isSelectStmt
(
pCxt
->
pCurrStmt
)
&&
isSelectStmt
(
pCxt
->
pCurrStmt
)
&&
0
==
taosArrayGetSize
(
vgroupList
))
{
0
==
taosArrayGetSize
(
vgroupList
))
{
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
isEmptyResult
=
true
;
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
isEmptyResult
=
true
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pRealTable
->
table
.
dbName
,
TSDB_INFORMATION_SCHEMA_DB
)
&&
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TABLES
))
{
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TABLES
))
{
code
=
addMnodeToVgroupList
(
&
pCxt
->
pParseCxt
->
mgmtEpSet
,
&
vgroupList
);
code
=
addMnodeToVgroupList
(
&
pCxt
->
pParseCxt
->
mgmtEpSet
,
&
vgroupList
);
}
}
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
48c93736
...
@@ -85,6 +85,10 @@ void generateInformationSchema(MockCatalogService* mcs) {
...
@@ -85,6 +85,10 @@ void generateInformationSchema(MockCatalogService* mcs) {
.
addColumn
(
"dnode_id"
,
TSDB_DATA_TYPE_INT
)
.
addColumn
(
"dnode_id"
,
TSDB_DATA_TYPE_INT
)
.
addColumn
(
"dnode_ep"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
)
.
addColumn
(
"dnode_ep"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
)
.
done
();
.
done
();
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_TAGS
,
TSDB_SYSTEM_TABLE
,
2
)
.
addColumn
(
"table_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
)
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
)
.
done
();
}
}
void
generatePerformanceSchema
(
MockCatalogService
*
mcs
)
{
void
generatePerformanceSchema
(
MockCatalogService
*
mcs
)
{
...
...
source/libs/planner/test/planOtherTest.cpp
浏览文件 @
48c93736
...
@@ -84,6 +84,8 @@ TEST_F(PlanOtherTest, show) {
...
@@ -84,6 +84,8 @@ TEST_F(PlanOtherTest, show) {
run
(
"SHOW TABLE DISTRIBUTED st1"
);
run
(
"SHOW TABLE DISTRIBUTED st1"
);
run
(
"SHOW DNODE 1 VARIABLES"
);
run
(
"SHOW DNODE 1 VARIABLES"
);
run
(
"SHOW TAGS FROM st1s1"
);
}
}
TEST_F
(
PlanOtherTest
,
delete
)
{
TEST_F
(
PlanOtherTest
,
delete
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录