Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d6374a72
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看板
提交
d6374a72
编写于
10月 12, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: some problems of parser
上级
6954d490
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
29 addition
and
14 deletion
+29
-14
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+3
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+1
-0
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+5
-4
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+2
-1
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+1
-0
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+15
-9
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+1
-0
未找到文件。
include/libs/nodes/plannodes.h
浏览文件 @
d6374a72
...
...
@@ -99,6 +99,7 @@ typedef struct SScanLogicNode {
int8_t
cacheLastMode
;
bool
hasNormalCols
;
// neither tag column nor primary key tag column
bool
sortPrimaryKey
;
bool
igLastNull
;
}
SScanLogicNode
;
typedef
struct
SJoinLogicNode
{
...
...
@@ -115,6 +116,7 @@ typedef struct SAggLogicNode {
SNodeList
*
pGroupKeys
;
SNodeList
*
pAggFuncs
;
bool
hasLastRow
;
bool
hasLast
;
bool
hasTimeLineFunc
;
bool
onlyHasKeepOrderFunc
;
}
SAggLogicNode
;
...
...
@@ -317,6 +319,7 @@ typedef struct SLastRowScanPhysiNode {
SScanPhysiNode
scan
;
SNodeList
*
pGroupTags
;
bool
groupSort
;
bool
ignoreNull
;
}
SLastRowScanPhysiNode
;
typedef
struct
SSystemTableScanPhysiNode
{
...
...
include/libs/nodes/querynodes.h
浏览文件 @
d6374a72
...
...
@@ -291,6 +291,7 @@ typedef struct SSelectStmt {
bool
hasTailFunc
;
bool
hasInterpFunc
;
bool
hasLastRowFunc
;
bool
hasLastFunc
;
bool
hasTimeLineFunc
;
bool
hasUdaf
;
bool
hasStateKey
;
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
d6374a72
...
...
@@ -383,6 +383,7 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
COPY_SCALAR_FIELD
(
groupSort
);
CLONE_NODE_LIST_FIELD
(
pTags
);
CLONE_NODE_FIELD
(
pSubtable
);
COPY_SCALAR_FIELD
(
igLastNull
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
d6374a72
...
...
@@ -97,7 +97,7 @@ typedef struct SCollectMetaKeyCxt {
typedef
struct
SCollectMetaKeyFromExprCxt
{
SCollectMetaKeyCxt
*
pComCxt
;
bool
hasLastRow
;
bool
hasLastRow
OrLast
;
int32_t
errCode
;
}
SCollectMetaKeyFromExprCxt
;
...
...
@@ -106,7 +106,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt);
static
EDealRes
collectMetaKeyFromFunction
(
SCollectMetaKeyFromExprCxt
*
pCxt
,
SFunctionNode
*
pFunc
)
{
switch
(
fmGetFuncType
(
pFunc
->
functionName
))
{
case
FUNCTION_TYPE_LAST_ROW
:
pCxt
->
hasLastRow
=
true
;
case
FUNCTION_TYPE_LAST
:
pCxt
->
hasLastRowOrLast
=
true
;
break
;
case
FUNCTION_TYPE_UDF
:
pCxt
->
errCode
=
reserveUdfInCache
(
pFunc
->
functionName
,
pCxt
->
pComCxt
->
pMetaCache
);
...
...
@@ -221,9 +222,9 @@ static int32_t reserveDbCfgForLastRow(SCollectMetaKeyCxt* pCxt, SNode* pTable) {
}
static
int32_t
collectMetaKeyFromSelect
(
SCollectMetaKeyCxt
*
pCxt
,
SSelectStmt
*
pStmt
)
{
SCollectMetaKeyFromExprCxt
cxt
=
{.
pComCxt
=
pCxt
,
.
hasLastRow
=
false
,
.
errCode
=
TSDB_CODE_SUCCESS
};
SCollectMetaKeyFromExprCxt
cxt
=
{.
pComCxt
=
pCxt
,
.
hasLastRow
OrLast
=
false
,
.
errCode
=
TSDB_CODE_SUCCESS
};
nodesWalkSelectStmt
(
pStmt
,
SQL_CLAUSE_FROM
,
collectMetaKeyFromExprImpl
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
==
cxt
.
errCode
&&
cxt
.
hasLastRow
)
{
if
(
TSDB_CODE_SUCCESS
==
cxt
.
errCode
&&
cxt
.
hasLastRow
OrLast
)
{
cxt
.
errCode
=
reserveDbCfgForLastRow
(
pCxt
,
pStmt
->
pFromTable
);
}
return
cxt
.
errCode
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
d6374a72
...
...
@@ -1609,6 +1609,7 @@ static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) {
pSelect
->
hasTailFunc
=
pSelect
->
hasTailFunc
?
true
:
(
FUNCTION_TYPE_TAIL
==
pFunc
->
funcType
);
pSelect
->
hasInterpFunc
=
pSelect
->
hasInterpFunc
?
true
:
(
FUNCTION_TYPE_INTERP
==
pFunc
->
funcType
);
pSelect
->
hasLastRowFunc
=
pSelect
->
hasLastRowFunc
?
true
:
(
FUNCTION_TYPE_LAST_ROW
==
pFunc
->
funcType
);
pSelect
->
hasLastFunc
=
pSelect
->
hasLastFunc
?
true
:
(
FUNCTION_TYPE_LAST
==
pFunc
->
funcType
);
pSelect
->
hasTimeLineFunc
=
pSelect
->
hasTimeLineFunc
?
true
:
fmIsTimelineFunc
(
pFunc
->
funcId
);
pSelect
->
hasUdaf
=
pSelect
->
hasUdaf
?
true
:
fmIsUserDefinedFunc
(
pFunc
->
funcId
)
&&
fmIsAggFunc
(
pFunc
->
funcId
);
pSelect
->
onlyHasKeepOrderFunc
=
pSelect
->
onlyHasKeepOrderFunc
?
fmIsKeepOrderFunc
(
pFunc
->
funcId
)
:
false
;
...
...
@@ -2349,7 +2350,7 @@ static int32_t setTableIndex(STranslateContext* pCxt, SName* pName, SRealTableNo
}
static
int32_t
setTableCacheLastMode
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
if
(
!
pSelect
->
hasLastRowFunc
||
QUERY_NODE_REAL_TABLE
!=
nodeType
(
pSelect
->
pFromTable
))
{
if
(
(
!
pSelect
->
hasLastRowFunc
&&
!
pSelect
->
hasLastFunc
)
||
QUERY_NODE_REAL_TABLE
!=
nodeType
(
pSelect
->
pFromTable
))
{
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
d6374a72
...
...
@@ -514,6 +514,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
}
pAgg
->
hasLastRow
=
pSelect
->
hasLastRowFunc
;
pAgg
->
hasLast
=
pSelect
->
hasLastFunc
;
pAgg
->
hasTimeLineFunc
=
pSelect
->
hasTimeLineFunc
;
pAgg
->
onlyHasKeepOrderFunc
=
pSelect
->
onlyHasKeepOrderFunc
;
pAgg
->
node
.
groupAction
=
getGroupAction
(
pCxt
,
pSelect
);
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
d6374a72
...
...
@@ -124,8 +124,9 @@ static void optSetParentOrder(SLogicNode* pNode, EOrder order) {
EDealRes
scanPathOptHaveNormalColImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
*
((
bool
*
)
pContext
)
=
(
COLUMN_TYPE_TAG
!=
((
SColumnNode
*
)
pNode
)
->
colType
&&
COLUMN_TYPE_TBNAME
!=
((
SColumnNode
*
)
pNode
)
->
colType
);
// *((bool*)pContext) =
// (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType && COLUMN_TYPE_TBNAME != ((SColumnNode*)pNode)->colType);
*
((
bool
*
)
pContext
)
=
true
;
return
*
((
bool
*
)
pContext
)
?
DEAL_RES_END
:
DEAL_RES_IGNORE_CHILD
;
}
return
DEAL_RES_CONTINUE
;
...
...
@@ -2195,14 +2196,16 @@ static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) {
SAggLogicNode
*
pAgg
=
(
SAggLogicNode
*
)
pNode
;
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
);
if
(
!
pAgg
->
hasLastRow
||
NULL
!=
pAgg
->
pGroupKeys
||
NULL
!=
pScan
->
node
.
pConditions
||
0
==
pScan
->
cacheLastMode
||
IS_TSWINDOW_SPECIFIED
(
pScan
->
scanRange
))
{
// Only one of LAST and LASTROW can appear
if
(
pAgg
->
hasLastRow
==
pAgg
->
hasLast
||
NULL
!=
pAgg
->
pGroupKeys
||
NULL
!=
pScan
->
node
.
pConditions
||
0
==
pScan
->
cacheLastMode
||
IS_TSWINDOW_SPECIFIED
(
pScan
->
scanRange
))
{
return
false
;
}
SNode
*
pFunc
=
NULL
;
FOREACH
(
pFunc
,
((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
)
{
if
(
FUNCTION_TYPE_LAST_ROW
!=
((
SFunctionNode
*
)
pFunc
)
->
funcType
&&
// FUNCTION_TYPE_LAST != ((SFunctionNode*)pFunc)->funcType &&
FUNCTION_TYPE_SELECT_VALUE
!=
((
SFunctionNode
*
)
pFunc
)
->
funcType
&&
FUNCTION_TYPE_GROUP_KEY
!=
((
SFunctionNode
*
)
pFunc
)
->
funcType
)
{
return
false
;
...
...
@@ -2222,7 +2225,7 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pAgg
->
pAggFuncs
)
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
pNode
;
if
(
FUNCTION_TYPE_LAST_ROW
==
pFunc
->
funcType
)
{
if
(
FUNCTION_TYPE_LAST_ROW
==
pFunc
->
funcType
||
FUNCTION_TYPE_LAST
==
pFunc
->
funcType
)
{
int32_t
len
=
snprintf
(
pFunc
->
functionName
,
sizeof
(
pFunc
->
functionName
),
"_cache_last_row"
);
pFunc
->
functionName
[
len
]
=
'\0'
;
int32_t
code
=
fmGetFuncInfo
(
pFunc
,
NULL
,
0
);
...
...
@@ -2231,9 +2234,12 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic
}
}
}
pAgg
->
hasLastRow
=
false
;
((
SScanLogicNode
*
)
nodesListGetNode
(
pAgg
->
node
.
pChildren
,
0
))
->
scanType
=
SCAN_TYPE_LAST_ROW
;
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
nodesListGetNode
(
pAgg
->
node
.
pChildren
,
0
);
pScan
->
scanType
=
SCAN_TYPE_LAST_ROW
;
pScan
->
igLastNull
=
pAgg
->
hasLast
?
true
:
false
;
pAgg
->
hasLastRow
=
false
;
pAgg
->
hasLast
=
false
;
pCxt
->
optimized
=
true
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2405,8 +2411,8 @@ static const SOptimizeRule optimizeRuleSet[] = {
{.
pName
=
"EliminateSetOperator"
,
.
optimizeFunc
=
eliminateSetOpOptimize
},
{.
pName
=
"RewriteTail"
,
.
optimizeFunc
=
rewriteTailOptimize
},
{.
pName
=
"RewriteUnique"
,
.
optimizeFunc
=
rewriteUniqueOptimize
},
{.
pName
=
"LastRowScan"
,
.
optimizeFunc
=
lastRowScanOptimize
},
{.
pName
=
"TagScan"
,
.
optimizeFunc
=
tagScanOptimize
}
{.
pName
=
"LastRowScan"
,
.
optimizeFunc
=
lastRowScanOptimize
},
{.
pName
=
"TagScan"
,
.
optimizeFunc
=
tagScanOptimize
}
};
// clang-format on
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
d6374a72
...
...
@@ -521,6 +521,7 @@ static int32_t createLastRowScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSu
}
pScan
->
groupSort
=
pScanLogicNode
->
groupSort
;
pScan
->
ignoreNull
=
pScanLogicNode
->
igLastNull
;
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录