Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5d7bafad
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看板
未验证
提交
5d7bafad
编写于
9月 28, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
9月 28, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17125 from taosdata/feat/3.0_parser_planner
enh: query information_schema.ins_tags optimize
上级
4ca305fd
06bb551b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
130 addition
and
8 deletion
+130
-8
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+4
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+108
-6
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+4
-0
source/libs/parser/test/parShowToUse.cpp
source/libs/parser/test/parShowToUse.cpp
+8
-2
source/libs/parser/test/parTestMain.cpp
source/libs/parser/test/parTestMain.cpp
+4
-0
source/libs/planner/test/planOtherTest.cpp
source/libs/planner/test/planOtherTest.cpp
+2
-0
未找到文件。
source/libs/parser/src/parAstParser.c
浏览文件 @
5d7bafad
...
...
@@ -407,6 +407,10 @@ static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* p
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pStmt
->
pTbName
)
{
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
((
SValueNode
*
)
pStmt
->
pTbName
)
->
literal
,
pCxt
->
pMetaCache
);
}
return
code
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
5d7bafad
...
...
@@ -2141,10 +2141,114 @@ static bool sysTableFromVnode(const char* pTable) {
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
->
type
)
{
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
);
}
if
(
'\0'
==
pName
->
dbname
[
0
])
{
pName
->
type
=
0
;
}
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
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
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
))
{
code
=
getDBVgInfo
(
pCxt
,
pRealTable
->
qualDbName
,
&
vgroupList
);
}
...
...
@@ -2152,14 +2256,12 @@ static int32_t setVnodeSysTableVgroupList(STranslateContext* pCxt, SName* pName,
code
=
getDBVgInfoImpl
(
pCxt
,
pName
,
&
vgroupList
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pRealTable
->
table
.
dbName
,
TSDB_INFORMATION_SCHEMA_DB
)
&&
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TAGS
)
&&
isSelectStmt
(
pCxt
->
pCurrStmt
)
&&
0
==
taosArrayGetSize
(
vgroupList
))
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TAGS
)
&&
isSelectStmt
(
pCxt
->
pCurrStmt
)
&&
0
==
taosArrayGetSize
(
vgroupList
))
{
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
isEmptyResult
=
true
;
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pRealTable
->
table
.
dbName
,
TSDB_INFORMATION_SCHEMA_DB
)
&&
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TABLES
))
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TABLES
))
{
code
=
addMnodeToVgroupList
(
&
pCxt
->
pParseCxt
->
mgmtEpSet
,
&
vgroupList
);
}
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
5d7bafad
...
...
@@ -85,6 +85,10 @@ void generateInformationSchema(MockCatalogService* mcs) {
.
addColumn
(
"dnode_id"
,
TSDB_DATA_TYPE_INT
)
.
addColumn
(
"dnode_ep"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
)
.
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
)
{
...
...
source/libs/parser/test/parShowToUse.cpp
浏览文件 @
5d7bafad
...
...
@@ -196,6 +196,12 @@ TEST_F(ParserShowToUseTest, showTableDistributed) {
run
(
"SHOW TABLE DISTRIBUTED st1"
);
}
TEST_F
(
ParserShowToUseTest
,
showTags
)
{
useDb
(
"root"
,
"test"
);
run
(
"SHOW TAGS FROM st1s1"
);
}
// todo SHOW topics
TEST_F
(
ParserShowToUseTest
,
showUsers
)
{
...
...
@@ -213,9 +219,9 @@ TEST_F(ParserShowToUseTest, showVariables) {
TEST_F
(
ParserShowToUseTest
,
showVgroups
)
{
useDb
(
"root"
,
"test"
);
run
(
"SHOW
vgroups
"
);
run
(
"SHOW
VGROUPS
"
);
run
(
"SHOW test.
vgroups
"
);
run
(
"SHOW test.
VGROUPS
"
);
}
TEST_F
(
ParserShowToUseTest
,
showVnodes
)
{
...
...
source/libs/parser/test/parTestMain.cpp
浏览文件 @
5d7bafad
...
...
@@ -86,6 +86,7 @@ static void parseArg(int argc, char* argv[]) {
{
"dump"
,
no_argument
,
NULL
,
'd'
},
{
"async"
,
required_argument
,
NULL
,
'a'
},
{
"skipSql"
,
required_argument
,
NULL
,
's'
},
{
"log"
,
required_argument
,
NULL
,
'l'
},
{
0
,
0
,
0
,
0
}
};
// clang-format on
...
...
@@ -100,6 +101,9 @@ static void parseArg(int argc, char* argv[]) {
case
's'
:
setSkipSqlNum
(
optarg
);
break
;
case
'l'
:
setLogLevel
(
optarg
);
break
;
default:
break
;
}
...
...
source/libs/planner/test/planOtherTest.cpp
浏览文件 @
5d7bafad
...
...
@@ -84,6 +84,8 @@ TEST_F(PlanOtherTest, show) {
run
(
"SHOW TABLE DISTRIBUTED st1"
);
run
(
"SHOW DNODE 1 VARIABLES"
);
run
(
"SHOW TAGS FROM st1s1"
);
}
TEST_F
(
PlanOtherTest
,
delete
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录