提交 c0c4b5c8 编写于 作者: D dapan1121

feature/qnode

上级 5dc9d977
......@@ -102,6 +102,10 @@ SNode* nodesMakeNode(ENodeType type) {
}
static EDealRes destroyNode(SNode** pNode, void* pContext) {
if (NULL == pNode || NULL == *pNode) {
return DEAL_RES_IGNORE_CHILD;
}
switch (nodeType(*pNode)) {
case QUERY_NODE_VALUE: {
SValueNode* pValue = (SValueNode*)*pNode;
......@@ -133,6 +137,10 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) {
}
void nodesDestroyNode(SNode* pNode) {
if (NULL == pNode) {
return;
}
nodesRewriteNodePostOrder(&pNode, destroyNode, NULL);
}
......
......@@ -793,15 +793,16 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
SCL_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
}
taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES);
sclMoveParamListData(res, 1, 0);
*pDst = *res;
taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES);
}
_return:
nodesDestroyNode(pNode);
//nodesDestroyNode(pNode);
sclFreeRes(ctx.pRes);
return code;
......
......@@ -220,7 +220,7 @@ void flttMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
}
TEST(timerangeTest, greater) {
SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL;
SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL;
bool eRes[5] = {false, false, true, true, true};
SScalarParam res = {0};
int64_t tsmall = 222, tbig = 333;
......@@ -236,6 +236,8 @@ TEST(timerangeTest, greater) {
ASSERT_EQ(code, 0);
ASSERT_EQ(win.skey, tsmall);
ASSERT_EQ(win.ekey, INT64_MAX);
filterFreeInfo(filter);
nodesDestroyNode(opNode1);
}
TEST(timerangeTest, greater_and_lower) {
......@@ -263,6 +265,8 @@ TEST(timerangeTest, greater_and_lower) {
ASSERT_EQ(code, 0);
ASSERT_EQ(win.skey, tsmall);
ASSERT_EQ(win.ekey, tbig);
filterFreeInfo(filter);
nodesDestroyNode(logicNode);
}
......@@ -315,6 +319,10 @@ TEST(columnTest, smallint_column_greater_double_value) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
blockDataDestroy(src);
nodesDestroyNode(opNode);
}
TEST(columnTest, int_column_greater_smallint_value) {
......@@ -366,6 +374,10 @@ TEST(columnTest, int_column_greater_smallint_value) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
......@@ -408,7 +420,10 @@ TEST(columnTest, int_column_in_double_list) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
......@@ -470,6 +485,10 @@ TEST(columnTest, binary_column_in_binary_list) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
......@@ -515,6 +534,10 @@ TEST(columnTest, binary_column_like_binary) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
......@@ -559,6 +582,10 @@ TEST(columnTest, binary_column_is_null) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
TEST(columnTest, binary_column_is_not_null) {
......@@ -602,6 +629,10 @@ TEST(columnTest, binary_column_is_not_null) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
......@@ -637,6 +668,10 @@ TEST(opTest, smallint_column_greater_int_column) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
......@@ -672,6 +707,10 @@ TEST(opTest, smallint_value_add_int_column) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
......@@ -713,6 +752,10 @@ TEST(opTest, bigint_column_multi_binary_column) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
TEST(opTest, smallint_column_and_binary_column) {
......@@ -752,6 +795,10 @@ TEST(opTest, smallint_column_and_binary_column) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
TEST(opTest, smallint_column_or_float_column) {
......@@ -786,6 +833,10 @@ TEST(opTest, smallint_column_or_float_column) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
......@@ -822,6 +873,10 @@ TEST(opTest, smallint_column_or_double_value) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
......@@ -863,6 +918,10 @@ TEST(opTest, binary_column_is_true) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(opNode);
blockDataDestroy(src);
}
......@@ -931,6 +990,10 @@ TEST(filterModelogicTest, diff_columns_and_or_and) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(logicNode1);
blockDataDestroy(src);
}
TEST(filterModelogicTest, same_column_and_or_and) {
......@@ -993,6 +1056,10 @@ TEST(filterModelogicTest, same_column_and_or_and) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(logicNode1);
blockDataDestroy(src);
}
......@@ -1059,6 +1126,10 @@ TEST(filterModelogicTest, diff_columns_or_and_or) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(logicNode1);
blockDataDestroy(src);
}
TEST(filterModelogicTest, same_column_or_and_or) {
......@@ -1121,6 +1192,10 @@ TEST(filterModelogicTest, same_column_or_and_or) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(logicNode1);
blockDataDestroy(src);
}
......@@ -1190,6 +1265,10 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) {
for (int32_t i = 0; i < rowNum; ++i) {
ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]);
}
tfree(rowRes);
filterFreeInfo(filter);
nodesDestroyNode(logicNode1);
blockDataDestroy(src);
}
......
......@@ -378,7 +378,8 @@ TEST(constantTest, tinyint_lower_ubigint) {
TEST(constantTest, usmallint_lower_equal_ubigint) {
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
int32_t leftv = 1, rightv = 1;
int32_t leftv = 1;
int64_t rightv = 1;
scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_USMALLINT, &leftv);
scltMakeValueNode(&pRight, TSDB_DATA_TYPE_UBIGINT, &rightv);
scltMakeOpNode(&opNode, OP_TYPE_LOWER_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight);
......@@ -395,7 +396,8 @@ TEST(constantTest, usmallint_lower_equal_ubigint) {
TEST(constantTest, int_equal_smallint1) {
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
int32_t leftv = 1, rightv = 1;
int32_t leftv = 1;
int16_t rightv = 1;
scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv);
scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv);
scltMakeOpNode(&opNode, OP_TYPE_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight);
......@@ -930,6 +932,7 @@ TEST(columnTest, smallint_value_add_int_column) {
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
TEST(columnTest, bigint_column_multi_binary_column) {
......@@ -968,6 +971,7 @@ TEST(columnTest, bigint_column_multi_binary_column) {
ASSERT_EQ(*((double *)colDataGet(column, i)), eRes[i]);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
TEST(columnTest, smallint_column_and_binary_column) {
......@@ -1005,6 +1009,7 @@ TEST(columnTest, smallint_column_and_binary_column) {
ASSERT_EQ(*((int64_t *)colDataGet(column, i)), eRes[i]);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
TEST(columnTest, smallint_column_or_float_column) {
......@@ -1037,6 +1042,7 @@ TEST(columnTest, smallint_column_or_float_column) {
ASSERT_EQ(*((int64_t *)colDataGet(column, i)), eRes[i]);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
TEST(columnTest, smallint_column_or_double_value) {
......@@ -1069,6 +1075,7 @@ TEST(columnTest, smallint_column_or_double_value) {
ASSERT_EQ(*((int64_t *)colDataGet(column, i)), eRes[i]);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
TEST(columnTest, smallint_column_greater_double_value) {
......@@ -1101,6 +1108,7 @@ TEST(columnTest, smallint_column_greater_double_value) {
ASSERT_EQ(*((bool *)colDataGet(column, i)), eRes[i]);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
TEST(columnTest, int_column_in_double_list) {
......@@ -1140,6 +1148,7 @@ TEST(columnTest, int_column_in_double_list) {
ASSERT_EQ(*((bool *)colDataGet(column, i)), eRes[i]);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
TEST(columnTest, binary_column_in_binary_list) {
......@@ -1198,6 +1207,7 @@ TEST(columnTest, binary_column_in_binary_list) {
ASSERT_EQ(*((bool *)colDataGet(column, i)), eRes[i]);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
TEST(columnTest, binary_column_like_binary) {
......@@ -1242,6 +1252,7 @@ TEST(columnTest, binary_column_like_binary) {
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
......@@ -1282,6 +1293,7 @@ TEST(columnTest, binary_column_is_true) {
ASSERT_EQ(*((bool *)colDataGet(column, i)), eRes[i]);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
TEST(columnTest, binary_column_is_null) {
......@@ -1325,6 +1337,7 @@ TEST(columnTest, binary_column_is_null) {
ASSERT_EQ(*((bool *)colDataGet(column, i)), eRes[i]);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
TEST(columnTest, binary_column_is_not_null) {
......@@ -1367,6 +1380,7 @@ TEST(columnTest, binary_column_is_not_null) {
ASSERT_EQ(*((bool *)colDataGet(column, i)), eRes[i]);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(opNode);
}
TEST(columnTest, greater_and_lower) {
......@@ -1408,6 +1422,7 @@ TEST(columnTest, greater_and_lower) {
ASSERT_EQ(*((bool *)colDataGet(column, i)), eRes[i]);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
nodesDestroyNode(logicNode);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册