Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4f0c6d3a
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
4f0c6d3a
编写于
8月 11, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: show command optimize
上级
c6699e19
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
253 addition
and
132 deletion
+253
-132
include/common/ttokendef.h
include/common/ttokendef.h
+1
-1
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+6
-9
source/libs/function/inc/builtins.h
source/libs/function/inc/builtins.h
+1
-1
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+1
-5
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+2
-6
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+2
-2
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+1
-1
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+1
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+229
-100
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+6
-6
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+3
-0
未找到文件。
include/common/ttokendef.h
浏览文件 @
4f0c6d3a
...
...
@@ -154,7 +154,7 @@
#define TK_ACCOUNTS 136
#define TK_APPS 137
#define TK_CONNECTIONS 138
#define TK_LICENCE
139
#define TK_LICENCE
S
139
#define TK_GRANTS 140
#define TK_QUERIES 141
#define TK_SCORES 142
...
...
include/libs/nodes/nodes.h
浏览文件 @
4f0c6d3a
...
...
@@ -172,27 +172,24 @@ typedef enum ENodeType {
QUERY_NODE_SHOW_TABLES_STMT
,
QUERY_NODE_SHOW_TAGS_STMT
,
QUERY_NODE_SHOW_USERS_STMT
,
QUERY_NODE_SHOW_LICENCE_STMT
,
QUERY_NODE_SHOW_LICENCE
S
_STMT
,
QUERY_NODE_SHOW_VGROUPS_STMT
,
QUERY_NODE_SHOW_TOPICS_STMT
,
QUERY_NODE_SHOW_CONSUMERS_STMT
,
QUERY_NODE_SHOW_SUBSCRIBES_STMT
,
QUERY_NODE_SHOW_SMAS_STMT
,
QUERY_NODE_SHOW_CONFIGS_STMT
,
QUERY_NODE_SHOW_CONNECTIONS_STMT
,
QUERY_NODE_SHOW_QUERIES_STMT
,
QUERY_NODE_SHOW_VNODES_STMT
,
QUERY_NODE_SHOW_APPS_STMT
,
QUERY_NODE_SHOW_SCORES_STMT
,
QUERY_NODE_SHOW_VARIABLES_STMT
,
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT
,
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
,
QUERY_NODE_SHOW_TRANSACTIONS_STMT
,
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
,
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
,
QUERY_NODE_SHOW_CREATE_TABLE_STMT
,
QUERY_NODE_SHOW_CREATE_STABLE_STMT
,
QUERY_NODE_SHOW_TRANSACTIONS_STMT
,
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT
,
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
,
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT
,
QUERY_NODE_SHOW_VNODES_STMT
,
QUERY_NODE_SHOW_SCORES_STMT
,
QUERY_NODE_KILL_CONNECTION_STMT
,
QUERY_NODE_KILL_QUERY_STMT
,
QUERY_NODE_KILL_TRANSACTION_STMT
,
...
...
source/libs/function/inc/builtins.h
浏览文件 @
4f0c6d3a
...
...
@@ -49,7 +49,7 @@ typedef struct SBuiltinFuncDefinition {
}
SBuiltinFuncDefinition
;
extern
const
SBuiltinFuncDefinition
funcMgtBuiltins
[];
extern
const
int
funcMgtBuiltinsNum
;
extern
const
int
32_t
funcMgtBuiltinsNum
;
#ifdef __cplusplus
}
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
4f0c6d3a
...
...
@@ -163,7 +163,7 @@ const char* nodesNodeName(ENodeType type) {
return
"ShowTagsStmt"
;
case
QUERY_NODE_SHOW_USERS_STMT
:
return
"ShowUsersStmt"
;
case
QUERY_NODE_SHOW_LICENCE_STMT
:
case
QUERY_NODE_SHOW_LICENCE
S
_STMT
:
return
"ShowGrantsStmt"
;
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
return
"ShowVgroupsStmt"
;
...
...
@@ -171,10 +171,6 @@ const char* nodesNodeName(ENodeType type) {
return
"ShowTopicsStmt"
;
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
return
"ShowConsumersStmt"
;
case
QUERY_NODE_SHOW_SUBSCRIBES_STMT
:
return
"ShowSubscribesStmt"
;
case
QUERY_NODE_SHOW_SMAS_STMT
:
return
"ShowSmasStmt"
;
case
QUERY_NODE_SHOW_QUERIES_STMT
:
return
"ShowQueriesStmt"
;
case
QUERY_NODE_SHOW_VNODES_STMT
:
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
4f0c6d3a
...
...
@@ -201,12 +201,10 @@ SNode* nodesMakeNode(ENodeType type) {
case
QUERY_NODE_SHOW_STREAMS_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_USERS_STMT
:
case
QUERY_NODE_SHOW_LICENCE_STMT
:
case
QUERY_NODE_SHOW_LICENCE
S
_STMT
:
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
case
QUERY_NODE_SHOW_SUBSCRIBES_STMT
:
case
QUERY_NODE_SHOW_SMAS_STMT
:
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_VNODES_STMT
:
...
...
@@ -687,12 +685,10 @@ void nodesDestroyNode(SNode* pNode) {
case
QUERY_NODE_SHOW_STREAMS_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_USERS_STMT
:
case
QUERY_NODE_SHOW_LICENCE_STMT
:
case
QUERY_NODE_SHOW_LICENCE
S
_STMT
:
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
case
QUERY_NODE_SHOW_SUBSCRIBES_STMT
:
case
QUERY_NODE_SHOW_SMAS_STMT
:
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_VNODES_STMT
:
...
...
source/libs/parser/inc/sql.y
浏览文件 @
4f0c6d3a
...
...
@@ -391,8 +391,8 @@ cmd ::= SHOW STREAMS.
cmd ::= SHOW ACCOUNTS. { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
cmd ::= SHOW APPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); }
cmd ::= SHOW CONNECTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); }
cmd ::= SHOW LICENCE
. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE
_STMT); }
cmd ::= SHOW GRANTS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT); }
cmd ::= SHOW LICENCE
S. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES
_STMT); }
cmd ::= SHOW GRANTS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE
S
_STMT); }
cmd ::= SHOW CREATE DATABASE db_name(A). { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &A); }
cmd ::= SHOW CREATE TABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, A); }
cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, A); }
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
4f0c6d3a
...
...
@@ -570,7 +570,7 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromShowTags
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_USERS_STMT
:
return
collectMetaKeyFromShowUsers
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_LICENCE_STMT
:
case
QUERY_NODE_SHOW_LICENCE
S
_STMT
:
return
collectMetaKeyFromShowLicence
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
return
collectMetaKeyFromShowVgroups
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
4f0c6d3a
...
...
@@ -118,7 +118,7 @@ static SKeyword keywordTable[] = {
{
"KILL"
,
TK_KILL
},
{
"LAST"
,
TK_LAST
},
{
"LAST_ROW"
,
TK_LAST_ROW
},
{
"LICENCE
"
,
TK_LICENCE
},
{
"LICENCE
S"
,
TK_LICENCES
},
{
"LIKE"
,
TK_LIKE
},
{
"LIMIT"
,
TK_LIMIT
},
{
"LINEAR"
,
TK_LINEAR
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
4f0c6d3a
...
...
@@ -28,6 +28,8 @@
#define generateDealNodeErrMsg(pCxt, code, ...) \
(pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, code, ##__VA_ARGS__), DEAL_RES_ERROR)
#define SYSTABLE_SHOW_TYPE_OFFSET QUERY_NODE_SHOW_DNODES_STMT
typedef
struct
STranslateContext
{
SParseContext
*
pParseCxt
;
int32_t
errCode
;
...
...
@@ -51,6 +53,201 @@ typedef struct SFullDatabaseName {
char
fullDbName
[
TSDB_DB_FNAME_LEN
];
}
SFullDatabaseName
;
typedef
struct
SSysTableShowAdapter
{
ENodeType
showType
;
const
char
*
pDbName
;
const
char
*
pTableName
;
int32_t
numOfShowCols
;
const
char
*
pShowCols
[
2
];
}
SSysTableShowAdapter
;
// clang-format off
static
const
SSysTableShowAdapter
sysTableShowAdapter
[]
=
{
{
.
showType
=
QUERY_NODE_SHOW_DNODES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_DNODES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"endpoint"
}
},
{
.
showType
=
QUERY_NODE_SHOW_MNODES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_MNODES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"endpoint"
}
},
{
.
showType
=
QUERY_NODE_SHOW_MODULES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_MODULES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"module"
}
},
{
.
showType
=
QUERY_NODE_SHOW_QNODES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_QNODES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"endpoint"
}
},
{
.
showType
=
QUERY_NODE_SHOW_SNODES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_SNODES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"endpoint"
}
},
{
.
showType
=
QUERY_NODE_SHOW_BNODES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_BNODES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"endpoint"
}
},
{
.
showType
=
QUERY_NODE_SHOW_CLUSTER_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_CLUSTER
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"name"
}
},
{
.
showType
=
QUERY_NODE_SHOW_DATABASES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_DATABASES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"name"
}
},
{
.
showType
=
QUERY_NODE_SHOW_FUNCTIONS_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_FUNCTIONS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"name"
}
},
{
.
showType
=
QUERY_NODE_SHOW_INDEXES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_INDEXES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"index_name"
}
},
{
.
showType
=
QUERY_NODE_SHOW_STABLES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_STABLES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"stable_name"
}
},
{
.
showType
=
QUERY_NODE_SHOW_STREAMS_STMT
,
.
pDbName
=
TSDB_PERFORMANCE_SCHEMA_DB
,
.
pTableName
=
TSDB_PERFS_TABLE_STREAMS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"stream_name"
}
},
{
.
showType
=
QUERY_NODE_SHOW_TABLES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_TABLES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"table_name"
}
},
{
.
showType
=
QUERY_NODE_SHOW_TAGS_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_TAGS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_USERS_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_USERS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"name"
}
},
{
.
showType
=
QUERY_NODE_SHOW_LICENCES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_LICENCES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_VGROUPS_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_VGROUPS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_TOPICS_STMT
,
.
pDbName
=
TSDB_PERFORMANCE_SCHEMA_DB
,
.
pTableName
=
TSDB_PERFS_TABLE_TOPICS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"topic_name"
}
},
{
.
showType
=
QUERY_NODE_SHOW_CONSUMERS_STMT
,
.
pDbName
=
TSDB_PERFORMANCE_SCHEMA_DB
,
.
pTableName
=
TSDB_PERFS_TABLE_CONSUMERS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_CONNECTIONS_STMT
,
.
pDbName
=
TSDB_PERFORMANCE_SCHEMA_DB
,
.
pTableName
=
TSDB_PERFS_TABLE_CONNECTIONS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_QUERIES_STMT
,
.
pDbName
=
TSDB_PERFORMANCE_SCHEMA_DB
,
.
pTableName
=
TSDB_PERFS_TABLE_QUERIES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_APPS_STMT
,
.
pDbName
=
TSDB_PERFORMANCE_SCHEMA_DB
,
.
pTableName
=
TSDB_PERFS_TABLE_APPS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_VARIABLES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_CONFIGS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_DNODE_VARIABLES
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_TRANSACTIONS_STMT
,
.
pDbName
=
TSDB_PERFORMANCE_SCHEMA_DB
,
.
pTableName
=
TSDB_PERFS_TABLE_TRANS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
,
.
pDbName
=
TSDB_PERFORMANCE_SCHEMA_DB
,
.
pTableName
=
TSDB_PERFS_TABLE_SUBSCRIPTIONS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
};
// clang-format on
static
int32_t
translateSubquery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
);
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
);
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
);
...
...
@@ -5328,112 +5525,42 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS
return
TSDB_CODE_FAILED
;
}
static
const
char
*
getSysDbName
(
ENodeType
type
)
{
switch
(
type
)
{
case
QUERY_NODE_SHOW_DATABASES_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
case
QUERY_NODE_SHOW_USERS_STMT
:
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_MODULES_STMT
:
case
QUERY_NODE_SHOW_QNODES_STMT
:
case
QUERY_NODE_SHOW_FUNCTIONS_STMT
:
case
QUERY_NODE_SHOW_INDEXES_STMT
:
case
QUERY_NODE_SHOW_BNODES_STMT
:
case
QUERY_NODE_SHOW_SNODES_STMT
:
case
QUERY_NODE_SHOW_LICENCE_STMT
:
case
QUERY_NODE_SHOW_CLUSTER_STMT
:
case
QUERY_NODE_SHOW_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_TAGS_STMT
:
return
TSDB_INFORMATION_SCHEMA_DB
;
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
case
QUERY_NODE_SHOW_STREAMS_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
case
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
:
return
TSDB_PERFORMANCE_SCHEMA_DB
;
default:
break
;
}
return
NULL
;
}
static
const
char
*
getSysTableName
(
ENodeType
type
)
{
switch
(
type
)
{
case
QUERY_NODE_SHOW_DATABASES_STMT
:
return
TSDB_INS_TABLE_DATABASES
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
return
TSDB_INS_TABLE_TABLES
;
case
QUERY_NODE_SHOW_TAGS_STMT
:
return
TSDB_INS_TABLE_TAGS
;
case
QUERY_NODE_SHOW_STABLES_STMT
:
return
TSDB_INS_TABLE_STABLES
;
case
QUERY_NODE_SHOW_USERS_STMT
:
return
TSDB_INS_TABLE_USERS
;
case
QUERY_NODE_SHOW_DNODES_STMT
:
return
TSDB_INS_TABLE_DNODES
;
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
return
TSDB_INS_TABLE_VGROUPS
;
case
QUERY_NODE_SHOW_MNODES_STMT
:
return
TSDB_INS_TABLE_MNODES
;
case
QUERY_NODE_SHOW_MODULES_STMT
:
return
TSDB_INS_TABLE_MODULES
;
case
QUERY_NODE_SHOW_QNODES_STMT
:
return
TSDB_INS_TABLE_QNODES
;
case
QUERY_NODE_SHOW_FUNCTIONS_STMT
:
return
TSDB_INS_TABLE_FUNCTIONS
;
case
QUERY_NODE_SHOW_INDEXES_STMT
:
return
TSDB_INS_TABLE_INDEXES
;
case
QUERY_NODE_SHOW_STREAMS_STMT
:
return
TSDB_PERFS_TABLE_STREAMS
;
case
QUERY_NODE_SHOW_BNODES_STMT
:
return
TSDB_INS_TABLE_BNODES
;
case
QUERY_NODE_SHOW_SNODES_STMT
:
return
TSDB_INS_TABLE_SNODES
;
case
QUERY_NODE_SHOW_LICENCE_STMT
:
return
TSDB_INS_TABLE_LICENCES
;
case
QUERY_NODE_SHOW_CLUSTER_STMT
:
return
TSDB_INS_TABLE_CLUSTER
;
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
return
TSDB_PERFS_TABLE_CONNECTIONS
;
case
QUERY_NODE_SHOW_QUERIES_STMT
:
return
TSDB_PERFS_TABLE_QUERIES
;
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
TSDB_PERFS_TABLE_TOPICS
;
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
return
TSDB_PERFS_TABLE_TRANS
;
case
QUERY_NODE_SHOW_VARIABLES_STMT
:
return
TSDB_INS_TABLE_CONFIGS
;
case
QUERY_NODE_SHOW_APPS_STMT
:
return
TSDB_PERFS_TABLE_APPS
;
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
return
TSDB_INS_TABLE_DNODE_VARIABLES
;
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
return
TSDB_PERFS_TABLE_CONSUMERS
;
case
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
:
return
TSDB_PERFS_TABLE_SUBSCRIPTIONS
;
default:
break
;
static
SNode
*
createStarCol
()
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
return
NULL
;
}
return
NULL
;
strcpy
(
pCol
->
colName
,
"*"
);
return
(
SNode
*
)
pCol
;
}
static
SNode
*
create
StarCol
(
)
{
static
SNode
*
create
ProjectCol
(
const
char
*
pProjCol
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
return
NULL
;
}
strcpy
(
pCol
->
colName
,
"*"
);
strcpy
(
pCol
->
colName
,
pProjCol
);
return
(
SNode
*
)
pCol
;
}
static
int32_t
createSimpleSelectStmt
(
const
char
*
pDb
,
const
char
*
pTable
,
SSelectStmt
**
pStmt
)
{
static
SNodeList
*
createProjectCols
(
int32_t
ncols
,
const
char
*
const
pCols
[])
{
SNodeList
*
pProjections
=
NULL
;
if
(
ncols
<=
0
)
{
nodesListMakeStrictAppend
(
&
pProjections
,
createStarCol
());
return
pProjections
;
}
for
(
int32_t
i
=
0
;
i
<
ncols
;
++
i
)
{
int32_t
code
=
nodesListMakeStrictAppend
(
&
pProjections
,
createProjectCol
(
pCols
[
i
]));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyList
(
pProjections
);
return
NULL
;
}
}
return
pProjections
;
}
static
int32_t
createSimpleSelectStmt
(
const
char
*
pDb
,
const
char
*
pTable
,
int32_t
numOfProjs
,
const
char
*
const
pProjCol
[],
SSelectStmt
**
pStmt
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
nodesMakeNode
(
QUERY_NODE_SELECT_STMT
);
if
(
NULL
==
pSelect
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -5450,7 +5577,8 @@ static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, SSele
strcpy
(
pRealTable
->
table
.
tableAlias
,
pTable
);
pSelect
->
pFromTable
=
(
SNode
*
)
pRealTable
;
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pSelect
->
pProjectionList
,
createStarCol
()))
{
pSelect
->
pProjectionList
=
createProjectCols
(
numOfProjs
,
pProjCol
);
if
(
NULL
==
pSelect
->
pProjectionList
)
{
nodesDestroyNode
((
SNode
*
)
pSelect
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
@@ -5461,11 +5589,12 @@ static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, SSele
}
static
int32_t
createSelectStmtForShow
(
ENodeType
showType
,
SSelectStmt
**
pStmt
)
{
return
createSimpleSelectStmt
(
getSysDbName
(
showType
),
getSysTableName
(
showType
),
pStmt
);
const
SSysTableShowAdapter
*
pShow
=
&
sysTableShowAdapter
[
showType
-
SYSTABLE_SHOW_TYPE_OFFSET
];
return
createSimpleSelectStmt
(
pShow
->
pDbName
,
pShow
->
pTableName
,
pShow
->
numOfShowCols
,
pShow
->
pShowCols
,
pStmt
);
}
static
int32_t
createSelectStmtForShowTableDist
(
SShowTableDistributedStmt
*
pStmt
,
SSelectStmt
**
pOutput
)
{
return
createSimpleSelectStmt
(
pStmt
->
dbName
,
pStmt
->
tableName
,
pOutput
);
return
createSimpleSelectStmt
(
pStmt
->
dbName
,
pStmt
->
tableName
,
0
,
NULL
,
pOutput
);
}
static
int32_t
createOperatorNode
(
EOperatorType
opType
,
const
char
*
pColName
,
SNode
*
pRight
,
SNode
**
pOp
)
{
...
...
@@ -6653,7 +6782,7 @@ static int32_t rewriteFlushDatabase(STranslateContext* pCxt, SQuery* pQuery) {
static
int32_t
rewriteQuery
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pQuery
->
pRoot
))
{
case
QUERY_NODE_SHOW_LICENCE_STMT
:
case
QUERY_NODE_SHOW_LICENCE
S
_STMT
:
case
QUERY_NODE_SHOW_DATABASES_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
...
...
source/libs/parser/src/sql.c
浏览文件 @
4f0c6d3a
...
...
@@ -1044,7 +1044,7 @@ static const YYCODETYPE yyFallback[] = {
0
,
/* ACCOUNTS => nothing */
0
,
/* APPS => nothing */
0
,
/* CONNECTIONS => nothing */
0
,
/*
LICENCE
=> nothing */
0
,
/*
LICENCES
=> nothing */
0
,
/* GRANTS => nothing */
0
,
/* QUERIES => nothing */
0
,
/* SCORES => nothing */
...
...
@@ -1388,7 +1388,7 @@ static const char *const yyTokenName[] = {
/* 136 */
"ACCOUNTS"
,
/* 137 */
"APPS"
,
/* 138 */
"CONNECTIONS"
,
/* 139 */
"LICENCE"
,
/* 139 */
"LICENCE
S
"
,
/* 140 */
"GRANTS"
,
/* 141 */
"QUERIES"
,
/* 142 */
"SCORES"
,
...
...
@@ -1843,7 +1843,7 @@ static const char *const yyRuleName[] = {
/* 205 */
"cmd ::= SHOW ACCOUNTS"
,
/* 206 */
"cmd ::= SHOW APPS"
,
/* 207 */
"cmd ::= SHOW CONNECTIONS"
,
/* 208 */
"cmd ::= SHOW LICENCE"
,
/* 208 */
"cmd ::= SHOW LICENCE
S
"
,
/* 209 */
"cmd ::= SHOW GRANTS"
,
/* 210 */
"cmd ::= SHOW CREATE DATABASE db_name"
,
/* 211 */
"cmd ::= SHOW CREATE TABLE full_table_name"
,
...
...
@@ -2932,7 +2932,7 @@ static const struct {
{
257
,
-
2
},
/* (205) cmd ::= SHOW ACCOUNTS */
{
257
,
-
2
},
/* (206) cmd ::= SHOW APPS */
{
257
,
-
2
},
/* (207) cmd ::= SHOW CONNECTIONS */
{
257
,
-
2
},
/* (208) cmd ::= SHOW LICENCE */
{
257
,
-
2
},
/* (208) cmd ::= SHOW LICENCE
S
*/
{
257
,
-
2
},
/* (209) cmd ::= SHOW GRANTS */
{
257
,
-
4
},
/* (210) cmd ::= SHOW CREATE DATABASE db_name */
{
257
,
-
4
},
/* (211) cmd ::= SHOW CREATE TABLE full_table_name */
...
...
@@ -3984,9 +3984,9 @@ static YYACTIONTYPE yy_reduce(
case
207
:
/* cmd ::= SHOW CONNECTIONS */
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_CONNECTIONS_STMT
);
}
break
;
case
208
:
/* cmd ::= SHOW LICENCE */
case
208
:
/* cmd ::= SHOW LICENCE
S
*/
case
209
:
/* cmd ::= SHOW GRANTS */
yytestcase
(
yyruleno
==
209
);
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_LICENCE_STMT
);
}
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_LICENCE
S
_STMT
);
}
break
;
case
210
:
/* cmd ::= SHOW CREATE DATABASE db_name */
{
pCxt
->
pRootNode
=
createShowCreateDatabaseStmt
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy361
);
}
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
4f0c6d3a
...
...
@@ -1615,6 +1615,9 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
if
(
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
))
{
TSWAP
(((
SPartitionLogicNode
*
)
pNode
)
->
pPartitionKeys
,
pScan
->
pGroupTags
);
int32_t
code
=
replaceLogicNode
(
pLogicSubplan
,
pNode
,
(
SLogicNode
*
)
pScan
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
adjustLogicNodeDataRequirement
((
SLogicNode
*
)
pScan
,
pNode
->
resultDataOrder
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
NODES_CLEAR_LIST
(
pNode
->
pChildren
);
nodesDestroyNode
((
SNode
*
)
pNode
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录