提交 4b824dde 编写于 作者: D dapan1121

fix bug

上级 e8eb77b8
......@@ -131,6 +131,7 @@ typedef struct SColumn {
typedef struct SExprFilter {
tSQLExpr *pExpr; //used for having parse
SSqlExpr *pSqlExpr;
SArray *fp;
SColumn *pFilters; //having filter info
}SExprFilter;
......
......@@ -1287,8 +1287,7 @@ int32_t doHavingFilter(SQueryInfo* pQueryInfo, tFilePage* pOutput, bool* notSkip
int32_t type = pInterField->field.type;
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
char* pInput = pOutput->data + pOutput->num* pExpr->offset;
char* pInput = pOutput->data + pOutput->num* pFieldFilters->pSqlExpr->offset;
doFilterFieldData(pQueryInfo, pInput, pOutput, pFieldFilters, type, notSkipped);
if (*notSkipped == false) {
......
......@@ -6708,6 +6708,9 @@ static int32_t checkQueryRangeForFill(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
++pQueryInfo->havingFieldNum;
size_t n = tscSqlExprNumOfExprs(pQueryInfo);
SSqlExpr* pSqlExpr = tscSqlExprGet(pQueryInfo, n - 1);
int32_t slot = tscNumOfFields(pQueryInfo) - 1;
SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, slot);
pInfo->visible = false;
......@@ -6726,6 +6729,7 @@ static int32_t checkQueryRangeForFill(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
}
pFieldFilters->pFilters = pFilters;
pFieldFilters->pSqlExpr = pSqlExpr;
pInfo->pFieldFilters = pFieldFilters;
}
......@@ -6740,7 +6744,7 @@ int32_t tscGetExprFilters(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr* pExpr
SInternalField* pInfo = NULL;
for (int32_t i = pQueryInfo->havingFieldNum - 1; i >= 0; --i) {
pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, i);
pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, pQueryInfo->fieldsInfo.numOfOutput - 1 - i);
if (pInfo->pFieldFilters && 0 == tSqlExprCompare(pInfo->pFieldFilters->pExpr, pExpr)) {
*pField = pInfo;
......@@ -6818,10 +6822,12 @@ static int32_t handleExprInHavingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
} else if (sqlOptr == TK_OR) {
int32_t ret = tscInsertExprFields(pCmd, pQueryInfo, pExpr->pLeft, &pInfo);
int32_t ret = tscGetExprFilters(pCmd, pQueryInfo, pExpr->pLeft, &pInfo);
if (ret) {
return ret;
}
pColumn = pInfo->pFieldFilters->pFilters;
// TODO fixme: failed to invalid the filter expression: "col1 = 1 OR col2 = 2"
pColFilter = addColumnFilterInfo(pColumn);
......
......@@ -324,13 +324,15 @@ int32_t tSqlExprCompare(tSQLExpr *left, tSQLExpr *right) {
if (left->pParam && left->pParam->nExpr != right->pParam->nExpr) {
return 1;
}
for (int32_t i = 0; i < right->pParam->nExpr; i++) {
tSQLExpr* pSubLeft = left->pParam->a[i].pNode;
tSQLExpr* pSubRight = right->pParam->a[i].pNode;
if (tSqlExprCompare(pSubLeft, pSubRight)) {
return 1;
if (right->pParam && left->pParam) {
for (int32_t i = 0; i < right->pParam->nExpr; i++) {
tSQLExpr* pSubLeft = left->pParam->a[i].pNode;
tSQLExpr* pSubRight = right->pParam->a[i].pNode;
if (tSqlExprCompare(pSubLeft, pSubRight)) {
return 1;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册