Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
514da6e1
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
提交
514da6e1
编写于
8月 15, 2023
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: select tags and set tag scan execution mode
上级
9fb9d863
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
3087 addition
and
1822 deletion
+3087
-1822
include/common/ttokendef.h
include/common/ttokendef.h
+1
-1
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+7
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+3033
-1819
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+44
-1
未找到文件。
include/common/ttokendef.h
浏览文件 @
514da6e1
...
...
@@ -16,6 +16,7 @@
#ifndef _TD_COMMON_TOKEN_H_
#define _TD_COMMON_TOKEN_H_
#define TK_OR 1
#define TK_AND 2
#define TK_UNION 3
...
...
@@ -354,7 +355,6 @@
#define TK_VIEW 336
#define TK_WAL 337
#define TK_NK_SPACE 600
#define TK_NK_COMMENT 601
#define TK_NK_ILLEGAL 602
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
514da6e1
...
...
@@ -143,6 +143,7 @@ SNode* addRangeClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pRange);
SNode
*
addEveryClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pEvery
);
SNode
*
addFillClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pFill
);
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
);
SNode
*
setSelectStmtTagMode
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
bool
bSelectTags
);
SNode
*
createSetOperator
(
SAstCreateContext
*
pCxt
,
ESetOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
);
SDataType
createDataType
(
uint8_t
type
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
514da6e1
...
...
@@ -1013,7 +1013,7 @@ query_specification(A) ::=
where_clause_opt(E) partition_by_clause_opt(F) range_opt(J) every_opt(K)
fill_opt(L) twindow_clause_opt(G) group_by_clause_opt(H) having_clause_opt(I). {
A = createSelectStmt(pCxt, B, C, D);
A = setSelectStmtTagMode(pC
t
xt, A, M);
A = setSelectStmtTagMode(pCxt, A, M);
A = addWhereClause(pCxt, A, E);
A = addPartitionByClause(pCxt, A, F);
A = addWindowClauseClause(pCxt, A, G);
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
514da6e1
...
...
@@ -852,6 +852,13 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr
return
select
;
}
SNode
*
setSelectStmtTagMode
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
bool
bSelectTags
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
((
SSelectStmt
*
)
pStmt
)
->
tagScan
=
bSelectTags
;
}
return
pStmt
;
}
static
void
setSubquery
(
SNode
*
pStmt
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
((
SSelectStmt
*
)
pStmt
)
->
isSubquery
=
true
;
...
...
source/libs/parser/src/sql.c
浏览文件 @
514da6e1
此差异已折叠。
点击以展开。
source/libs/planner/src/planLogicCreater.c
浏览文件 @
514da6e1
...
...
@@ -14,7 +14,7 @@
*/
#include "planInt.h"
#include "filter.h"
#include "functionMgt.h"
typedef
struct
SLogicPlanContext
{
...
...
@@ -344,6 +344,45 @@ static int32_t makeScanLogicNode(SLogicPlanContext* pCxt, SRealTableNode* pRealT
static
bool
needScanDefaultCol
(
EScanType
scanType
)
{
return
SCAN_TYPE_TABLE_COUNT
!=
scanType
;
}
static
EDealRes
tagScanNodeHasTbnameFunc
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
if
(
COLUMN_TYPE_TBNAME
==
((
SColumnNode
*
)
pNode
)
->
colType
)
{
*
(
bool
*
)
pContext
=
true
;
return
DEAL_RES_END
;
}
}
return
DEAL_RES_CONTINUE
;
}
static
bool
tagScanNodeListHasTbname
(
SNodeList
*
pCols
)
{
bool
hasTbname
=
false
;
nodesWalkExprs
(
pCols
,
tagScanNodeHasTbnameFunc
,
&
hasTbname
);
return
hasTbname
;
}
static
bool
tagScanNodeHasTbname
(
SNode
*
pKeys
)
{
bool
hasTbname
=
false
;
nodesWalkExpr
(
pKeys
,
tagScanNodeHasTbnameFunc
,
&
hasTbname
);
return
hasTbname
;
}
static
int32_t
setTagScanOnlyMetaCtbIdx
(
SScanLogicNode
*
pScan
)
{
SNode
*
pCond
=
nodesCloneNode
(
pScan
->
node
.
pConditions
);
SNode
*
pTagCond
=
NULL
;
SNode
*
pTagIndexCond
=
NULL
;
bool
bOnlyMetaCtbIdx
=
false
;
filterPartitionCond
(
&
pCond
,
NULL
,
&
pTagIndexCond
,
&
pTagCond
,
NULL
);
if
(
pTagIndexCond
||
tagScanNodeListHasTbname
(
pScan
->
pScanPseudoCols
)
||
tagScanNodeHasTbname
(
pTagCond
))
{
bOnlyMetaCtbIdx
=
false
;
}
else
{
bOnlyMetaCtbIdx
=
true
;
}
nodesDestroyNode
(
pCond
);
nodesDestroyNode
(
pTagIndexCond
);
nodesDestroyNode
(
pTagCond
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
createScanLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SRealTableNode
*
pRealTable
,
SLogicNode
**
pLogicNode
)
{
SScanLogicNode
*
pScan
=
NULL
;
...
...
@@ -411,6 +450,10 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
code
=
createColumnByRewriteExprs
(
pScan
->
pScanPseudoCols
,
&
pScan
->
node
.
pTargets
);
}
if
(
pSelect
->
tagScan
)
{
code
=
setTagScanOnlyMetaCtbIdx
(
pScan
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pScan
;
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录