Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
daf91648
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
daf91648
编写于
8月 18, 2023
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: invalid read memory issue
上级
a1d6ddf9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
39 addition
and
12 deletion
+39
-12
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-1
source/libs/nodes/CMakeLists.txt
source/libs/nodes/CMakeLists.txt
+2
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+12
-2
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+15
-7
source/libs/planner/src/planUtil.c
source/libs/planner/src/planUtil.c
+8
-0
source/libs/qworker/src/qwUtil.c
source/libs/qworker/src/qwUtil.c
+1
-0
未找到文件。
include/libs/nodes/querynodes.h
浏览文件 @
daf91648
...
@@ -498,7 +498,7 @@ int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char*
...
@@ -498,7 +498,7 @@ int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char*
int32_t
nodesCollectColumnsFromNode
(
SNode
*
node
,
const
char
*
pTableAlias
,
ECollectColType
type
,
SNodeList
**
pCols
);
int32_t
nodesCollectColumnsFromNode
(
SNode
*
node
,
const
char
*
pTableAlias
,
ECollectColType
type
,
SNodeList
**
pCols
);
typedef
bool
(
*
FFuncClassifier
)(
int32_t
funcId
);
typedef
bool
(
*
FFuncClassifier
)(
int32_t
funcId
);
int32_t
nodesCollectFuncs
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
FFuncClassifier
classifier
,
SNodeList
**
pFuncs
);
int32_t
nodesCollectFuncs
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
char
*
tableAlias
,
FFuncClassifier
classifier
,
SNodeList
**
pFuncs
);
int32_t
nodesCollectSpecialNodes
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
ENodeType
type
,
SNodeList
**
pNodes
);
int32_t
nodesCollectSpecialNodes
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
ENodeType
type
,
SNodeList
**
pNodes
);
...
...
source/libs/nodes/CMakeLists.txt
浏览文件 @
daf91648
...
@@ -7,9 +7,9 @@ target_include_directories(
...
@@ -7,9 +7,9 @@ target_include_directories(
)
)
target_link_libraries
(
target_link_libraries
(
nodes
nodes
PRIVATE os util common qcom
PRIVATE os util common qcom
function
)
)
if
(
${
BUILD_TEST
}
)
if
(
${
BUILD_TEST
}
)
ADD_SUBDIRECTORY
(
test
)
ADD_SUBDIRECTORY
(
test
)
endif
(
${
BUILD_TEST
}
)
endif
(
${
BUILD_TEST
}
)
\ No newline at end of file
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
daf91648
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "tdatablock.h"
#include "tdatablock.h"
#include "thash.h"
#include "thash.h"
#include "tref.h"
#include "tref.h"
#include "functionMgt.h"
typedef
struct
SNodeMemChunk
{
typedef
struct
SNodeMemChunk
{
int32_t
availableSize
;
int32_t
availableSize
;
...
@@ -1920,7 +1921,7 @@ static EDealRes doCollect(SCollectColumnsCxt* pCxt, SColumnNode* pCol, SNode* pN
...
@@ -1920,7 +1921,7 @@ static EDealRes doCollect(SCollectColumnsCxt* pCxt, SColumnNode* pCol, SNode* pN
static
bool
isCollectType
(
ECollectColType
collectType
,
EColumnType
colType
)
{
static
bool
isCollectType
(
ECollectColType
collectType
,
EColumnType
colType
)
{
return
COLLECT_COL_TYPE_ALL
==
collectType
return
COLLECT_COL_TYPE_ALL
==
collectType
?
true
?
true
:
(
COLLECT_COL_TYPE_TAG
==
collectType
?
COLUMN_TYPE_TAG
==
colType
:
COLUMN_TYPE_TAG
!=
colType
);
:
(
COLLECT_COL_TYPE_TAG
==
collectType
?
COLUMN_TYPE_TAG
==
colType
:
(
COLUMN_TYPE_TAG
!=
colType
&&
COLUMN_TYPE_TBNAME
!=
colType
)
);
}
}
static
EDealRes
collectColumns
(
SNode
*
pNode
,
void
*
pContext
)
{
static
EDealRes
collectColumns
(
SNode
*
pNode
,
void
*
pContext
)
{
...
@@ -1999,6 +2000,7 @@ int32_t nodesCollectColumnsFromNode(SNode* node, const char* pTableAlias, EColle
...
@@ -1999,6 +2000,7 @@ int32_t nodesCollectColumnsFromNode(SNode* node, const char* pTableAlias, EColle
typedef
struct
SCollectFuncsCxt
{
typedef
struct
SCollectFuncsCxt
{
int32_t
errCode
;
int32_t
errCode
;
char
*
tableAlias
;
FFuncClassifier
classifier
;
FFuncClassifier
classifier
;
SNodeList
*
pFuncs
;
SNodeList
*
pFuncs
;
SHashObj
*
pFuncsSet
;
SHashObj
*
pFuncsSet
;
...
@@ -2008,6 +2010,13 @@ static EDealRes collectFuncs(SNode* pNode, void* pContext) {
...
@@ -2008,6 +2010,13 @@ static EDealRes collectFuncs(SNode* pNode, void* pContext) {
SCollectFuncsCxt
*
pCxt
=
(
SCollectFuncsCxt
*
)
pContext
;
SCollectFuncsCxt
*
pCxt
=
(
SCollectFuncsCxt
*
)
pContext
;
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
pCxt
->
classifier
(((
SFunctionNode
*
)
pNode
)
->
funcId
)
&&
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
pCxt
->
classifier
(((
SFunctionNode
*
)
pNode
)
->
funcId
)
&&
!
(((
SExprNode
*
)
pNode
)
->
orderAlias
))
{
!
(((
SExprNode
*
)
pNode
)
->
orderAlias
))
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
pNode
;
if
(
FUNCTION_TYPE_TBNAME
==
pFunc
->
funcType
&&
pCxt
->
tableAlias
)
{
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
strcmp
(
pVal
->
literal
,
pCxt
->
tableAlias
))
{
return
DEAL_RES_CONTINUE
;
}
}
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
if
(
NULL
==
taosHashGet
(
pCxt
->
pFuncsSet
,
&
pExpr
,
sizeof
(
SExprNode
*
)))
{
if
(
NULL
==
taosHashGet
(
pCxt
->
pFuncsSet
,
&
pExpr
,
sizeof
(
SExprNode
*
)))
{
pCxt
->
errCode
=
nodesListStrictAppend
(
pCxt
->
pFuncs
,
nodesCloneNode
(
pNode
));
pCxt
->
errCode
=
nodesListStrictAppend
(
pCxt
->
pFuncs
,
nodesCloneNode
(
pNode
));
...
@@ -2030,13 +2039,14 @@ static int32_t funcNodeEqual(const void* pLeft, const void* pRight, size_t len)
...
@@ -2030,13 +2039,14 @@ static int32_t funcNodeEqual(const void* pLeft, const void* pRight, size_t len)
return
nodesEqualNode
(
*
(
const
SNode
**
)
pLeft
,
*
(
const
SNode
**
)
pRight
)
?
0
:
1
;
return
nodesEqualNode
(
*
(
const
SNode
**
)
pLeft
,
*
(
const
SNode
**
)
pRight
)
?
0
:
1
;
}
}
int32_t
nodesCollectFuncs
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
FFuncClassifier
classifier
,
SNodeList
**
pFuncs
)
{
int32_t
nodesCollectFuncs
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
char
*
tableAlias
,
FFuncClassifier
classifier
,
SNodeList
**
pFuncs
)
{
if
(
NULL
==
pSelect
||
NULL
==
pFuncs
)
{
if
(
NULL
==
pSelect
||
NULL
==
pFuncs
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
SCollectFuncsCxt
cxt
=
{.
errCode
=
TSDB_CODE_SUCCESS
,
SCollectFuncsCxt
cxt
=
{.
errCode
=
TSDB_CODE_SUCCESS
,
.
classifier
=
classifier
,
.
classifier
=
classifier
,
.
tableAlias
=
tableAlias
,
.
pFuncs
=
(
NULL
==
*
pFuncs
?
nodesMakeList
()
:
*
pFuncs
),
.
pFuncs
=
(
NULL
==
*
pFuncs
?
nodesMakeList
()
:
*
pFuncs
),
.
pFuncsSet
=
taosHashInit
(
4
,
funcNodeHash
,
false
,
false
)};
.
pFuncsSet
=
taosHashInit
(
4
,
funcNodeHash
,
false
,
false
)};
if
(
NULL
==
cxt
.
pFuncs
||
NULL
==
cxt
.
pFuncsSet
)
{
if
(
NULL
==
cxt
.
pFuncs
||
NULL
==
cxt
.
pFuncsSet
)
{
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
daf91648
...
@@ -374,16 +374,24 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
...
@@ -374,16 +374,24 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_FROM
,
fmIsScanPseudoColumnFunc
,
&
pScan
->
pScanPseudoCols
);
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_FROM
,
pRealTable
->
table
.
tableAlias
,
fmIsScanPseudoColumnFunc
,
&
pScan
->
pScanPseudoCols
);
}
}
pScan
->
scanType
=
getScanType
(
pCxt
,
pScan
->
pScanPseudoCols
,
pScan
->
pScanCols
,
pScan
->
tableType
,
pSelect
->
tagScan
);
// rewrite the expression in subsequent clauses
// rewrite the expression in subsequent clauses
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SNodeList
*
pNewScanPseudoCols
=
NULL
;
code
=
rewriteExprsForSelect
(
pScan
->
pScanPseudoCols
,
pSelect
,
SQL_CLAUSE_FROM
,
NULL
);
code
=
rewriteExprsForSelect
(
pScan
->
pScanPseudoCols
,
pSelect
,
SQL_CLAUSE_FROM
,
NULL
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pScan
->
pScanPseudoCols
)
{
code
=
createColumnByRewriteExprs
(
pScan
->
pScanPseudoCols
,
&
pNewScanPseudoCols
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
nodesDestroyList
(
pScan
->
pScanPseudoCols
);
pScan
->
pScanPseudoCols
=
pNewScanPseudoCols
;
}
}
}
}
pScan
->
scanType
=
getScanType
(
pCxt
,
pScan
->
pScanPseudoCols
,
pScan
->
pScanCols
,
pScan
->
tableType
,
pSelect
->
tagScan
);
if
(
NULL
!=
pScan
->
pScanCols
)
{
if
(
NULL
!=
pScan
->
pScanCols
)
{
pScan
->
hasNormalCols
=
true
;
pScan
->
hasNormalCols
=
true
;
}
}
...
@@ -619,7 +627,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
...
@@ -619,7 +627,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
// set grouyp keys, agg funcs and having conditions
// set grouyp keys, agg funcs and having conditions
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_GROUP_BY
,
fmIsAggFunc
,
&
pAgg
->
pAggFuncs
);
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_GROUP_BY
,
NULL
,
fmIsAggFunc
,
&
pAgg
->
pAggFuncs
);
}
}
// rewrite the expression in subsequent clauses
// rewrite the expression in subsequent clauses
...
@@ -690,7 +698,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
...
@@ -690,7 +698,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
pIdfRowsFunc
->
node
.
resultDataOrder
=
pIdfRowsFunc
->
node
.
requireDataOrder
;
pIdfRowsFunc
->
node
.
resultDataOrder
=
pIdfRowsFunc
->
node
.
requireDataOrder
;
// indefinite rows functions and _select_values functions
// indefinite rows functions and _select_values functions
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_SELECT
,
fmIsVectorFunc
,
&
pIdfRowsFunc
->
pFuncs
);
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_SELECT
,
NULL
,
fmIsVectorFunc
,
&
pIdfRowsFunc
->
pFuncs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExprsForSelect
(
pIdfRowsFunc
->
pFuncs
,
pSelect
,
SQL_CLAUSE_SELECT
,
NULL
);
code
=
rewriteExprsForSelect
(
pIdfRowsFunc
->
pFuncs
,
pSelect
,
SQL_CLAUSE_SELECT
,
NULL
);
}
}
...
@@ -728,7 +736,7 @@ static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
...
@@ -728,7 +736,7 @@ static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
pInterpFunc
->
node
.
resultDataOrder
=
pInterpFunc
->
node
.
requireDataOrder
;
pInterpFunc
->
node
.
resultDataOrder
=
pInterpFunc
->
node
.
requireDataOrder
;
// interp functions and _group_key functions
// interp functions and _group_key functions
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_SELECT
,
isInterpFunc
,
&
pInterpFunc
->
pFuncs
);
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_SELECT
,
NULL
,
isInterpFunc
,
&
pInterpFunc
->
pFuncs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExprsForSelect
(
pInterpFunc
->
pFuncs
,
pSelect
,
SQL_CLAUSE_SELECT
,
NULL
);
code
=
rewriteExprsForSelect
(
pInterpFunc
->
pFuncs
,
pSelect
,
SQL_CLAUSE_SELECT
,
NULL
);
}
}
...
@@ -774,7 +782,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
...
@@ -774,7 +782,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
pWindow
->
node
.
inputTsOrder
=
ORDER_ASC
;
pWindow
->
node
.
inputTsOrder
=
ORDER_ASC
;
pWindow
->
node
.
outputTsOrder
=
ORDER_ASC
;
pWindow
->
node
.
outputTsOrder
=
ORDER_ASC
;
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_WINDOW
,
fmIsWindowClauseFunc
,
&
pWindow
->
pFuncs
);
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_WINDOW
,
NULL
,
fmIsWindowClauseFunc
,
&
pWindow
->
pFuncs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExprsForSelect
(
pWindow
->
pFuncs
,
pSelect
,
SQL_CLAUSE_WINDOW
,
NULL
);
code
=
rewriteExprsForSelect
(
pWindow
->
pFuncs
,
pSelect
,
SQL_CLAUSE_WINDOW
,
NULL
);
}
}
...
...
source/libs/planner/src/planUtil.c
浏览文件 @
daf91648
...
@@ -65,6 +65,14 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
...
@@ -65,6 +65,14 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
}
}
pCol
->
node
.
resType
=
pExpr
->
resType
;
pCol
->
node
.
resType
=
pExpr
->
resType
;
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
))
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
pNode
;
if
(
pFunc
->
funcType
==
FUNCTION_TYPE_TBNAME
)
{
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
strcpy
(
pCol
->
tableAlias
,
pVal
->
literal
);
strcpy
(
pCol
->
tableName
,
pVal
->
literal
);
}
}
return
(
TSDB_CODE_SUCCESS
==
nodesListStrictAppend
(
pCxt
->
pList
,
(
SNode
*
)
pCol
)
?
DEAL_RES_IGNORE_CHILD
return
(
TSDB_CODE_SUCCESS
==
nodesListStrictAppend
(
pCxt
->
pList
,
(
SNode
*
)
pCol
)
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
);
:
DEAL_RES_ERROR
);
}
}
...
...
source/libs/qworker/src/qwUtil.c
浏览文件 @
daf91648
...
@@ -314,6 +314,7 @@ void qwFreeTaskCtx(SQWTaskCtx *ctx) {
...
@@ -314,6 +314,7 @@ void qwFreeTaskCtx(SQWTaskCtx *ctx) {
}
}
taosArrayDestroy
(
ctx
->
tbInfo
);
taosArrayDestroy
(
ctx
->
tbInfo
);
ctx
->
tbInfo
=
NULL
;
}
}
int32_t
qwDropTaskCtx
(
QW_FPARAMS_DEF
)
{
int32_t
qwDropTaskCtx
(
QW_FPARAMS_DEF
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录