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

fix bug

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