Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
28d66616
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看板
提交
28d66616
编写于
6月 24, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fix invalid write
上级
41ae1e30
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
45 addition
and
6 deletion
+45
-6
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+1
-0
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+18
-0
source/libs/parser/src/parCalcConst.c
source/libs/parser/src/parCalcConst.c
+4
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+2
-2
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+3
-0
source/libs/planner/test/planTestMain.cpp
source/libs/planner/test/planTestMain.cpp
+8
-1
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+9
-2
未找到文件。
include/libs/nodes/nodes.h
浏览文件 @
28d66616
...
@@ -285,6 +285,7 @@ int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
...
@@ -285,6 +285,7 @@ int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
void
nodesListInsertList
(
SNodeList
*
pTarget
,
SListCell
*
pPos
,
SNodeList
*
pSrc
);
void
nodesListInsertList
(
SNodeList
*
pTarget
,
SListCell
*
pPos
,
SNodeList
*
pSrc
);
SNode
*
nodesListGetNode
(
SNodeList
*
pList
,
int32_t
index
);
SNode
*
nodesListGetNode
(
SNodeList
*
pList
,
int32_t
index
);
SListCell
*
nodesListGetCell
(
SNodeList
*
pList
,
int32_t
index
);
void
nodesDestroyList
(
SNodeList
*
pList
);
void
nodesDestroyList
(
SNodeList
*
pList
);
// Only clear the linked list structure, without releasing the elements inside
// Only clear the linked list structure, without releasing the elements inside
void
nodesClearList
(
SNodeList
*
pList
);
void
nodesClearList
(
SNodeList
*
pList
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
28d66616
...
@@ -372,6 +372,8 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) {
...
@@ -372,6 +372,8 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) {
static
void
destroyDataSinkNode
(
SDataSinkNode
*
pNode
)
{
nodesDestroyNode
((
SNode
*
)
pNode
->
pInputDataBlockDesc
);
}
static
void
destroyDataSinkNode
(
SDataSinkNode
*
pNode
)
{
nodesDestroyNode
((
SNode
*
)
pNode
->
pInputDataBlockDesc
);
}
static
void
destroyExprNode
(
SExprNode
*
pExpr
)
{
taosArrayDestroy
(
pExpr
->
pAssociation
);
}
void
nodesDestroyNode
(
SNode
*
pNode
)
{
void
nodesDestroyNode
(
SNode
*
pNode
)
{
if
(
NULL
==
pNode
)
{
if
(
NULL
==
pNode
)
{
return
;
return
;
...
@@ -379,9 +381,11 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -379,9 +381,11 @@ void nodesDestroyNode(SNode* pNode) {
switch
(
nodeType
(
pNode
))
{
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_COLUMN
:
// pProjectRef is weak reference, no need to release
case
QUERY_NODE_COLUMN
:
// pProjectRef is weak reference, no need to release
destroyExprNode
((
SExprNode
*
)
pNode
);
break
;
break
;
case
QUERY_NODE_VALUE
:
{
case
QUERY_NODE_VALUE
:
{
SValueNode
*
pValue
=
(
SValueNode
*
)
pNode
;
SValueNode
*
pValue
=
(
SValueNode
*
)
pNode
;
destroyExprNode
((
SExprNode
*
)
pNode
);
taosMemoryFreeClear
(
pValue
->
literal
);
taosMemoryFreeClear
(
pValue
->
literal
);
if
(
IS_VAR_DATA_TYPE
(
pValue
->
node
.
resType
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pValue
->
node
.
resType
.
type
))
{
taosMemoryFreeClear
(
pValue
->
datum
.
p
);
taosMemoryFreeClear
(
pValue
->
datum
.
p
);
...
@@ -390,14 +394,17 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -390,14 +394,17 @@ void nodesDestroyNode(SNode* pNode) {
}
}
case
QUERY_NODE_OPERATOR
:
{
case
QUERY_NODE_OPERATOR
:
{
SOperatorNode
*
pOp
=
(
SOperatorNode
*
)
pNode
;
SOperatorNode
*
pOp
=
(
SOperatorNode
*
)
pNode
;
destroyExprNode
((
SExprNode
*
)
pNode
);
nodesDestroyNode
(
pOp
->
pLeft
);
nodesDestroyNode
(
pOp
->
pLeft
);
nodesDestroyNode
(
pOp
->
pRight
);
nodesDestroyNode
(
pOp
->
pRight
);
break
;
break
;
}
}
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_LOGIC_CONDITION
:
destroyExprNode
((
SExprNode
*
)
pNode
);
nodesDestroyList
(((
SLogicConditionNode
*
)
pNode
)
->
pParameterList
);
nodesDestroyList
(((
SLogicConditionNode
*
)
pNode
)
->
pParameterList
);
break
;
break
;
case
QUERY_NODE_FUNCTION
:
case
QUERY_NODE_FUNCTION
:
destroyExprNode
((
SExprNode
*
)
pNode
);
nodesDestroyList
(((
SFunctionNode
*
)
pNode
)
->
pParameterList
);
nodesDestroyList
(((
SFunctionNode
*
)
pNode
)
->
pParameterList
);
break
;
break
;
case
QUERY_NODE_REAL_TABLE
:
{
case
QUERY_NODE_REAL_TABLE
:
{
...
@@ -833,6 +840,7 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -833,6 +840,7 @@ void nodesDestroyNode(SNode* pNode) {
destroyPhysiNode
((
SPhysiNode
*
)
pPhyNode
);
destroyPhysiNode
((
SPhysiNode
*
)
pPhyNode
);
nodesDestroyList
(
pPhyNode
->
pExprs
);
nodesDestroyList
(
pPhyNode
->
pExprs
);
nodesDestroyList
(
pPhyNode
->
pSortKeys
);
nodesDestroyList
(
pPhyNode
->
pSortKeys
);
nodesDestroyList
(
pPhyNode
->
pTargets
);
break
;
break
;
}
}
case
QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL
:
...
@@ -1096,6 +1104,16 @@ SNode* nodesListGetNode(SNodeList* pList, int32_t index) {
...
@@ -1096,6 +1104,16 @@ SNode* nodesListGetNode(SNodeList* pList, int32_t index) {
return
NULL
;
return
NULL
;
}
}
SListCell
*
nodesListGetCell
(
SNodeList
*
pList
,
int32_t
index
)
{
SNode
*
node
;
FOREACH
(
node
,
pList
)
{
if
(
0
==
index
--
)
{
return
cell
;
}
}
return
NULL
;
}
void
nodesDestroyList
(
SNodeList
*
pList
)
{
void
nodesDestroyList
(
SNodeList
*
pList
)
{
if
(
NULL
==
pList
)
{
if
(
NULL
==
pList
)
{
return
;
return
;
...
...
source/libs/parser/src/parCalcConst.c
浏览文件 @
28d66616
...
@@ -183,12 +183,15 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) {
...
@@ -183,12 +183,15 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) {
int32_t
size
=
taosArrayGetSize
(
pAssociation
);
int32_t
size
=
taosArrayGetSize
(
pAssociation
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SNode
**
pCol
=
taosArrayGetP
(
pAssociation
,
i
);
SNode
**
pCol
=
taosArrayGetP
(
pAssociation
,
i
);
nodesDestroyNode
(
*
pCol
);
*
pCol
=
nodesCloneNode
(
*
pNew
);
*
pCol
=
nodesCloneNode
(
*
pNew
);
if
(
NULL
==
*
pCol
)
{
if
(
NULL
==
*
pCol
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
break
;
}
}
}
}
}
}
taosArrayDestroy
(
pAssociation
);
return
code
;
return
code
;
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
28d66616
...
@@ -517,8 +517,9 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p
...
@@ -517,8 +517,9 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p
if
(
NULL
==
pCol
)
{
if
(
NULL
==
pCol
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_OUT_OF_MEMORY
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_OUT_OF_MEMORY
);
}
}
setColumnInfoByExpr
(
pTable
,
(
SExprNode
*
)
pNode
,
&
pCol
);
nodesListAppend
(
pList
,
(
SNode
*
)
pCol
);
nodesListAppend
(
pList
,
(
SNode
*
)
pCol
);
SListCell
*
pCell
=
nodesListGetCell
(
pList
,
LIST_LENGTH
(
pList
)
-
1
);
setColumnInfoByExpr
(
pTable
,
(
SExprNode
*
)
pNode
,
(
SColumnNode
**
)
&
pCell
->
pNode
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -4658,7 +4659,6 @@ static int32_t extractShowLocalVariablesResultSchema(int32_t* numOfCols, SSchema
...
@@ -4658,7 +4659,6 @@ static int32_t extractShowLocalVariablesResultSchema(int32_t* numOfCols, SSchema
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
extractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
int32_t
extractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
if
(
NULL
==
pRoot
)
{
if
(
NULL
==
pRoot
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
28d66616
...
@@ -1197,6 +1197,9 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
...
@@ -1197,6 +1197,9 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
nodesDestroyNode
((
SNode
*
)
pSort
);
nodesDestroyNode
((
SNode
*
)
pSort
);
}
}
nodesDestroyList
(
pPrecalcExprs
);
nodesDestroyList
(
pSortKeys
);
return
code
;
return
code
;
}
}
...
...
source/libs/planner/test/planTestMain.cpp
浏览文件 @
28d66616
...
@@ -16,9 +16,11 @@
...
@@ -16,9 +16,11 @@
#include <string>
#include <string>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include "functionMgt.h"
#include "functionMgt.h"
#include "getopt.h"
#include "getopt.h"
#include "mockCatalog.h"
#include "mockCatalog.h"
#include "parser.h"
#include "planTestUtil.h"
#include "planTestUtil.h"
class
PlannerEnv
:
public
testing
::
Environment
{
class
PlannerEnv
:
public
testing
::
Environment
{
...
@@ -30,7 +32,12 @@ class PlannerEnv : public testing::Environment {
...
@@ -30,7 +32,12 @@ class PlannerEnv : public testing::Environment {
initLog
(
TD_TMP_DIR_PATH
"td"
);
initLog
(
TD_TMP_DIR_PATH
"td"
);
}
}
virtual
void
TearDown
()
{
destroyMetaDataEnv
();
}
virtual
void
TearDown
()
{
destroyMetaDataEnv
();
qCleanupKeywordsTable
();
fmFuncMgtDestroy
();
taosCloseLog
();
}
PlannerEnv
()
{}
PlannerEnv
()
{}
virtual
~
PlannerEnv
()
{}
virtual
~
PlannerEnv
()
{}
...
...
source/libs/planner/test/planTestUtil.cpp
浏览文件 @
28d66616
...
@@ -102,12 +102,15 @@ class PlannerTestBaseImpl {
...
@@ -102,12 +102,15 @@ class PlannerTestBaseImpl {
try
{
try
{
SQuery
*
pQuery
=
nullptr
;
SQuery
*
pQuery
=
nullptr
;
doParseSql
(
sql
,
&
pQuery
);
doParseSql
(
sql
,
&
pQuery
);
unique_ptr
<
SQuery
,
void
(
*
)(
SQuery
*
)
>
query
(
pQuery
,
qDestroyQuery
);
SPlanContext
cxt
=
{
0
};
SPlanContext
cxt
=
{
0
};
setPlanContext
(
pQuery
,
&
cxt
);
setPlanContext
(
pQuery
,
&
cxt
);
SLogicSubplan
*
pLogicSubplan
=
nullptr
;
SLogicSubplan
*
pLogicSubplan
=
nullptr
;
doCreateLogicPlan
(
&
cxt
,
&
pLogicSubplan
);
doCreateLogicPlan
(
&
cxt
,
&
pLogicSubplan
);
unique_ptr
<
SLogicSubplan
,
void
(
*
)(
SLogicSubplan
*
)
>
logicSubplan
(
pLogicSubplan
,
(
void
(
*
)(
SLogicSubplan
*
))
nodesDestroyNode
);
doOptimizeLogicPlan
(
&
cxt
,
pLogicSubplan
);
doOptimizeLogicPlan
(
&
cxt
,
pLogicSubplan
);
...
@@ -115,9 +118,12 @@ class PlannerTestBaseImpl {
...
@@ -115,9 +118,12 @@ class PlannerTestBaseImpl {
SQueryLogicPlan
*
pLogicPlan
=
nullptr
;
SQueryLogicPlan
*
pLogicPlan
=
nullptr
;
doScaleOutLogicPlan
(
&
cxt
,
pLogicSubplan
,
&
pLogicPlan
);
doScaleOutLogicPlan
(
&
cxt
,
pLogicSubplan
,
&
pLogicPlan
);
unique_ptr
<
SQueryLogicPlan
,
void
(
*
)(
SQueryLogicPlan
*
)
>
logicPlan
(
pLogicPlan
,
(
void
(
*
)(
SQueryLogicPlan
*
))
nodesDestroyNode
);
SQueryPlan
*
pPlan
=
nullptr
;
SQueryPlan
*
pPlan
=
nullptr
;
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
);
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
);
unique_ptr
<
SQueryPlan
,
void
(
*
)(
SQueryPlan
*
)
>
plan
(
pPlan
,
(
void
(
*
)(
SQueryPlan
*
))
nodesDestroyNode
);
dump
(
g_dumpModule
);
dump
(
g_dumpModule
);
}
catch
(...)
{
}
catch
(...)
{
...
@@ -345,8 +351,9 @@ class PlannerTestBaseImpl {
...
@@ -345,8 +351,9 @@ class PlannerTestBaseImpl {
}
}
void
doCreatePhysiPlan
(
SPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
)
{
void
doCreatePhysiPlan
(
SPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
)
{
SArray
*
pExecNodeList
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
sizeof
(
SQueryNodeAddr
));
unique_ptr
<
SArray
,
void
(
*
)(
SArray
*
)
>
execNodeList
((
SArray
*
)
taosArrayInit
(
TARRAY_MIN_SIZE
,
sizeof
(
SQueryNodeAddr
)),
DO_WITH_THROW
(
createPhysiPlan
,
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
(
void
(
*
)(
SArray
*
))
taosArrayDestroy
);
DO_WITH_THROW
(
createPhysiPlan
,
pCxt
,
pLogicPlan
,
pPlan
,
execNodeList
.
get
());
res_
.
physiPlan_
=
toString
((
SNode
*
)(
*
pPlan
));
res_
.
physiPlan_
=
toString
((
SNode
*
)(
*
pPlan
));
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
(
*
pPlan
)
->
pSubplans
)
{
FOREACH
(
pNode
,
(
*
pPlan
)
->
pSubplans
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录