Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
17d15e10
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,发现更多精彩内容 >>
未验证
提交
17d15e10
编写于
8月 05, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
8月 05, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15779 from taosdata/feature/3.0_wxy
fix: plan problem of create stream statement
上级
06b41779
9bfc7ba6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
18 deletion
+37
-18
source/libs/parser/inc/parUtil.h
source/libs/parser/inc/parUtil.h
+2
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+12
-8
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+5
-4
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+7
-4
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+4
-1
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+7
-0
未找到文件。
source/libs/parser/inc/parUtil.h
浏览文件 @
17d15e10
...
...
@@ -31,7 +31,8 @@ extern "C" {
#define parserDebug(param, ...) qDebug("PARSER: " param, ##__VA_ARGS__)
#define parserTrace(param, ...) qTrace("PARSER: " param, ##__VA_ARGS__)
#define PK_TS_COL_INTERNAL_NAME "_rowts"
#define ROWTS_PSEUDO_COLUMN_NAME "_rowts"
#define C0_PSEUDO_COLUMN_NAME "_c0"
typedef
struct
SMsgBuf
{
int32_t
len
;
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
17d15e10
...
...
@@ -443,19 +443,23 @@ SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft,
createOperatorNode
(
pCxt
,
OP_TYPE_GREATER_THAN
,
nodesCloneNode
(
pExpr
),
pRight
));
}
static
SNode
*
createPrimaryKeyCol
(
SAstCreateContext
*
pCxt
)
{
static
SNode
*
createPrimaryKeyCol
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFuncName
)
{
CHECK_PARSER_STATUS
(
pCxt
);
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
CHECK_OUT_OF_MEM
(
pCol
);
pCol
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
strcpy
(
pCol
->
colName
,
PK_TS_COL_INTERNAL_NAME
);
if
(
NULL
==
pFuncName
)
{
strcpy
(
pCol
->
colName
,
ROWTS_PSEUDO_COLUMN_NAME
);
}
else
{
strncpy
(
pCol
->
colName
,
pFuncName
->
z
,
pFuncName
->
n
);
}
return
(
SNode
*
)
pCol
;
}
SNode
*
createFunctionNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFuncName
,
SNodeList
*
pParameterList
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
0
==
strncasecmp
(
"_rowts"
,
pFuncName
->
z
,
pFuncName
->
n
)
||
0
==
strncasecmp
(
"_c0"
,
pFuncName
->
z
,
pFuncName
->
n
))
{
return
createPrimaryKeyCol
(
pCxt
);
return
createPrimaryKeyCol
(
pCxt
,
pFuncName
);
}
SFunctionNode
*
func
=
(
SFunctionNode
*
)
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
CHECK_OUT_OF_MEM
(
func
);
...
...
@@ -586,7 +590,7 @@ SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) {
CHECK_PARSER_STATUS
(
pCxt
);
SStateWindowNode
*
state
=
(
SStateWindowNode
*
)
nodesMakeNode
(
QUERY_NODE_STATE_WINDOW
);
CHECK_OUT_OF_MEM
(
state
);
state
->
pCol
=
createPrimaryKeyCol
(
pCxt
);
state
->
pCol
=
createPrimaryKeyCol
(
pCxt
,
NULL
);
if
(
NULL
==
state
->
pCol
)
{
nodesDestroyNode
((
SNode
*
)
state
);
CHECK_OUT_OF_MEM
(
state
->
pCol
);
...
...
@@ -600,7 +604,7 @@ SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode
CHECK_PARSER_STATUS
(
pCxt
);
SIntervalWindowNode
*
interval
=
(
SIntervalWindowNode
*
)
nodesMakeNode
(
QUERY_NODE_INTERVAL_WINDOW
);
CHECK_OUT_OF_MEM
(
interval
);
interval
->
pCol
=
createPrimaryKeyCol
(
pCxt
);
interval
->
pCol
=
createPrimaryKeyCol
(
pCxt
,
NULL
);
if
(
NULL
==
interval
->
pCol
)
{
nodesDestroyNode
((
SNode
*
)
interval
);
CHECK_OUT_OF_MEM
(
interval
->
pCol
);
...
...
@@ -639,7 +643,7 @@ SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode) {
SNode
*
createInterpTimeRange
(
SAstCreateContext
*
pCxt
,
SNode
*
pStart
,
SNode
*
pEnd
)
{
CHECK_PARSER_STATUS
(
pCxt
);
return
createBetweenAnd
(
pCxt
,
createPrimaryKeyCol
(
pCxt
),
pStart
,
pEnd
);
return
createBetweenAnd
(
pCxt
,
createPrimaryKeyCol
(
pCxt
,
NULL
),
pStart
,
pEnd
);
}
SNode
*
setProjectionAlias
(
SAstCreateContext
*
pCxt
,
SNode
*
pNode
,
SToken
*
pAlias
)
{
...
...
@@ -752,7 +756,7 @@ SNode* addFillClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pFill) {
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
)
&&
NULL
!=
pFill
)
{
SFillNode
*
pFillClause
=
(
SFillNode
*
)
pFill
;
nodesDestroyNode
(
pFillClause
->
pWStartTs
);
pFillClause
->
pWStartTs
=
createPrimaryKeyCol
(
pCxt
);
pFillClause
->
pWStartTs
=
createPrimaryKeyCol
(
pCxt
,
NULL
);
((
SSelectStmt
*
)
pStmt
)
->
pFill
=
(
SNode
*
)
pFillClause
;
}
return
pStmt
;
...
...
@@ -1731,7 +1735,7 @@ SNode* createCountFuncForDelete(SAstCreateContext* pCxt) {
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
CHECK_OUT_OF_MEM
(
pFunc
);
strcpy
(
pFunc
->
functionName
,
"count"
);
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pFunc
->
pParameterList
,
createPrimaryKeyCol
(
pCxt
)))
{
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pFunc
->
pParameterList
,
createPrimaryKeyCol
(
pCxt
,
NULL
)))
{
nodesDestroyNode
((
SNode
*
)
pFunc
);
CHECK_OUT_OF_MEM
(
NULL
);
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
17d15e10
...
...
@@ -612,7 +612,8 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p
}
static
bool
isInternalPrimaryKey
(
const
SColumnNode
*
pCol
)
{
return
PRIMARYKEY_TIMESTAMP_COL_ID
==
pCol
->
colId
&&
0
==
strcmp
(
pCol
->
colName
,
PK_TS_COL_INTERNAL_NAME
);
return
PRIMARYKEY_TIMESTAMP_COL_ID
==
pCol
->
colId
&&
(
0
==
strcmp
(
pCol
->
colName
,
ROWTS_PSEUDO_COLUMN_NAME
)
||
0
==
strcmp
(
pCol
->
colName
,
C0_PSEUDO_COLUMN_NAME
));
}
static
int32_t
findAndSetColumn
(
STranslateContext
*
pCxt
,
SColumnNode
**
pColRef
,
const
STableNode
*
pTable
,
...
...
@@ -2566,7 +2567,7 @@ static int32_t createDefaultFillNode(STranslateContext* pCxt, SNode** pOutput) {
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pCol
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
strcpy
(
pCol
->
colName
,
PK_TS_COL_INTERNAL
_NAME
);
strcpy
(
pCol
->
colName
,
ROWTS_PSEUDO_COLUMN
_NAME
);
pFill
->
pWStartTs
=
(
SNode
*
)
pCol
;
*
pOutput
=
(
SNode
*
)
pFill
;
...
...
@@ -2652,7 +2653,7 @@ static int32_t createPrimaryKeyColByTable(STranslateContext* pCxt, STableNode* p
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pCol
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
strcpy
(
pCol
->
colName
,
PK_TS_COL_INTERNAL
_NAME
);
strcpy
(
pCol
->
colName
,
ROWTS_PSEUDO_COLUMN
_NAME
);
bool
found
=
false
;
int32_t
code
=
findAndSetColumn
(
pCxt
,
&
pCol
,
pTable
,
&
found
);
if
(
TSDB_CODE_SUCCESS
!=
code
||
!
found
)
{
...
...
@@ -3878,7 +3879,7 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch
return
TSDB_CODE_OUT_OF_MEMORY
;
}
((
SColumnNode
*
)
pInterval
->
pCol
)
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
strcpy
(((
SColumnNode
*
)
pInterval
->
pCol
)
->
colName
,
PK_TS_COL_INTERNAL
_NAME
);
strcpy
(((
SColumnNode
*
)
pInterval
->
pCol
)
->
colName
,
ROWTS_PSEUDO_COLUMN
_NAME
);
pCxt
->
createStream
=
true
;
int32_t
code
=
translateQuery
(
pCxt
,
(
SNode
*
)
pSelect
);
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
17d15e10
...
...
@@ -436,8 +436,8 @@ static int32_t pushDownCondOptDealScan(SOptimizeContext* pCxt, SScanLogicNode* p
SNode
*
pPrimaryKeyCond
=
NULL
;
SNode
*
pOtherCond
=
NULL
;
int32_t
code
=
filterPartitionCond
(
&
pScan
->
node
.
pConditions
,
&
pPrimaryKeyCond
,
&
pScan
->
pTagIndexCond
,
&
pScan
->
pTagCond
,
&
pOtherCond
);
int32_t
code
=
filterPartitionCond
(
&
pScan
->
node
.
pConditions
,
&
pPrimaryKeyCond
,
&
pScan
->
pTagIndexCond
,
&
pScan
->
pTagCond
,
&
pOtherCond
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pScan
->
pTagCond
)
{
code
=
pushDownCondOptRebuildTbanme
(
&
pScan
->
pTagCond
);
}
...
...
@@ -1711,7 +1711,7 @@ static bool eliminateProjOptCanChildConditionUseChildTargets(SLogicNode* pChild,
if
(
!
cxt
.
canUse
)
return
false
;
}
if
(
QUERY_NODE_LOGIC_PLAN_JOIN
==
nodeType
(
pChild
)
&&
NULL
!=
((
SJoinLogicNode
*
)
pChild
)
->
pOnConditions
)
{
SJoinLogicNode
*
pJoinLogicNode
=
(
SJoinLogicNode
*
)
pChild
;
SJoinLogicNode
*
pJoinLogicNode
=
(
SJoinLogicNode
*
)
pChild
;
CheckNewChildTargetsCxt
cxt
=
{.
pNewChildTargets
=
pNewChildTargets
,
.
canUse
=
false
};
nodesWalkExpr
(
pJoinLogicNode
->
pOnConditions
,
eliminateProjOptCanUseNewChildTargetsImpl
,
&
cxt
);
if
(
!
cxt
.
canUse
)
return
false
;
...
...
@@ -1768,7 +1768,7 @@ static int32_t eliminateProjOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan*
if
(
TSDB_CODE_SUCCESS
==
code
)
{
NODES_CLEAR_LIST
(
pProjectNode
->
node
.
pChildren
);
nodesDestroyNode
((
SNode
*
)
pProjectNode
);
//if pChild is a project logic node, remove its projection which is not reference by its target.
//
if pChild is a project logic node, remove its projection which is not reference by its target.
alignProjectionWithTarget
(
pChild
);
}
pCxt
->
optimized
=
true
;
...
...
@@ -2404,6 +2404,9 @@ static const SOptimizeRule optimizeRuleSet[] = {
static
const
int32_t
optimizeRuleNum
=
(
sizeof
(
optimizeRuleSet
)
/
sizeof
(
SOptimizeRule
));
static
void
dumpLogicSubplan
(
const
char
*
pRuleName
,
SLogicSubplan
*
pSubplan
)
{
if
(
0
==
(
qDebugFlag
&
DEBUG_DEBUG
))
{
return
;
}
char
*
pStr
=
NULL
;
nodesNodeToString
((
SNode
*
)
pSubplan
,
false
,
&
pStr
,
NULL
);
if
(
NULL
==
pRuleName
)
{
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
17d15e10
...
...
@@ -264,7 +264,7 @@ static bool stbSplNeedSplitJoin(bool streamQuery, SJoinLogicNode* pJoin) {
static
bool
stbSplNeedSplit
(
bool
streamQuery
,
SLogicNode
*
pNode
)
{
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
stbSplIsMultiTbScan
(
streamQuery
,
(
SScanLogicNode
*
)
pNode
);
return
st
reamQuery
?
false
:
st
bSplIsMultiTbScan
(
streamQuery
,
(
SScanLogicNode
*
)
pNode
);
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
return
stbSplNeedSplitJoin
(
streamQuery
,
(
SJoinLogicNode
*
)
pNode
);
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
...
...
@@ -1423,6 +1423,9 @@ static const SSplitRule splitRuleSet[] = {
static
const
int32_t
splitRuleNum
=
(
sizeof
(
splitRuleSet
)
/
sizeof
(
SSplitRule
));
static
void
dumpLogicSubplan
(
const
char
*
pRuleName
,
SLogicSubplan
*
pSubplan
)
{
if
(
0
==
(
qDebugFlag
&
DEBUG_DEBUG
))
{
return
;
}
char
*
pStr
=
NULL
;
nodesNodeToString
((
SNode
*
)
pSubplan
,
false
,
&
pStr
,
NULL
);
if
(
NULL
==
pRuleName
)
{
...
...
source/libs/planner/src/planner.c
浏览文件 @
17d15e10
...
...
@@ -19,6 +19,9 @@
#include "scalar.h"
static
void
dumpQueryPlan
(
SQueryPlan
*
pPlan
)
{
if
(
0
==
(
qDebugFlag
&
DEBUG_DEBUG
))
{
return
;
}
char
*
pStr
=
NULL
;
nodesNodeToString
((
SNode
*
)
pPlan
,
false
,
&
pStr
,
NULL
);
planDebugL
(
"QID:0x%"
PRIx64
" Query Plan: %s"
,
pPlan
->
queryId
,
pStr
);
...
...
@@ -42,6 +45,9 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createPhysiPlan
(
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
dumpQueryPlan
(
*
pPlan
);
}
nodesDestroyNode
((
SNode
*
)
pLogicSubplan
);
nodesDestroyNode
((
SNode
*
)
pLogicPlan
);
...
...
@@ -79,6 +85,7 @@ static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDown
}
int32_t
qSetSubplanExecutionNode
(
SSubplan
*
subplan
,
int32_t
groupId
,
SDownstreamSourceNode
*
pSource
)
{
planDebug
(
"QID:0x%"
PRIx64
" set subplan execution node, groupId:%d"
,
subplan
->
id
.
groupId
,
groupId
);
return
setSubplanExecutionNode
(
subplan
->
pNode
,
groupId
,
pSource
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录