提交 c8262d44 编写于 作者: D dapan1121

fix bug

上级 31529614
...@@ -3078,7 +3078,7 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumn* pColumn) { ...@@ -3078,7 +3078,7 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumn* pColumn) {
return pColFilterInfo; return pColFilterInfo;
} }
static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SColumnFilterInfo* pColumnFilter, static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, STableMeta* pTableMeta, SColumnFilterInfo* pColumnFilter,
int16_t colType, tSqlExpr* pExpr) { int16_t colType, tSqlExpr* pExpr) {
const char* msg = "not supported filter condition"; const char* msg = "not supported filter condition";
...@@ -3093,6 +3093,12 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, ...@@ -3093,6 +3093,12 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
if (TSDB_CODE_SUCCESS != retVal) { if (TSDB_CODE_SUCCESS != retVal) {
return retVal; return retVal;
} }
} else if ((colType == TSDB_DATA_TYPE_TIMESTAMP) && (TSDB_DATA_TYPE_BIGINT == pRight->value.nType)) {
STableComInfo tinfo = tscGetTableInfo(pTableMeta);
if ((tinfo.precision == TSDB_TIME_PRECISION_MILLI) && (pRight->flags & (1 << EXPR_FLAG_NOW))) {
pRight->value.i64 /= 1000;
}
} }
int32_t retVal = TSDB_CODE_SUCCESS; int32_t retVal = TSDB_CODE_SUCCESS;
...@@ -3291,7 +3297,7 @@ static int32_t extractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SC ...@@ -3291,7 +3297,7 @@ static int32_t extractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SC
int16_t colType = pSchema->type; int16_t colType = pSchema->type;
return doExtractColumnFilterInfo(pCmd, pQueryInfo, pColFilter, colType, pExpr); return doExtractColumnFilterInfo(pCmd, pQueryInfo, pTableMeta, pColFilter, colType, pExpr);
} }
static int32_t getTablenameCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pTableCond, SStringBuilder* sb) { static int32_t getTablenameCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pTableCond, SStringBuilder* sb) {
...@@ -6927,7 +6933,10 @@ static int32_t handleExprInHavingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t ...@@ -6927,7 +6933,10 @@ static int32_t handleExprInHavingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
} }
} }
int32_t ret = doExtractColumnFilterInfo(pCmd, pQueryInfo, pColFilter, pInfo->field.type, pExpr); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
int32_t ret = doExtractColumnFilterInfo(pCmd, pQueryInfo, pTableMeta, pColFilter, pInfo->field.type, pExpr);
if (ret) { if (ret) {
return ret; return ret;
} }
......
...@@ -44,6 +44,10 @@ enum SQL_NODE_FROM_TYPE { ...@@ -44,6 +44,10 @@ enum SQL_NODE_FROM_TYPE {
SQL_NODE_FROM_NAMELIST = 2, SQL_NODE_FROM_NAMELIST = 2,
}; };
enum SQL_EXPR_FLAG {
EXPR_FLAG_NOW = 1
};
extern char tTokenTypeSwitcher[13]; extern char tTokenTypeSwitcher[13];
#define toTSDBType(x) \ #define toTSDBType(x) \
...@@ -237,6 +241,7 @@ typedef struct tSqlExpr { ...@@ -237,6 +241,7 @@ typedef struct tSqlExpr {
SStrToken colInfo; // table column info SStrToken colInfo; // table column info
tVariant value; // the use input value tVariant value; // the use input value
SStrToken token; // original sql expr string SStrToken token; // original sql expr string
uint32_t flags;
struct tSqlExpr *pLeft; // left child struct tSqlExpr *pLeft; // left child
struct tSqlExpr *pRight; // right child struct tSqlExpr *pRight; // right child
......
...@@ -144,6 +144,7 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) { ...@@ -144,6 +144,7 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) {
pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT;
pSqlExpr->tokenId = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond pSqlExpr->tokenId = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond
pSqlExpr->type = SQL_NODE_VALUE; pSqlExpr->type = SQL_NODE_VALUE;
pSqlExpr->flags |= 1 << EXPR_FLAG_NOW;
} else if (optrType == TK_VARIABLE) { } else if (optrType == TK_VARIABLE) {
int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64); int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
...@@ -217,6 +218,7 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) { ...@@ -217,6 +218,7 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
pExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pExpr->value.nType = TSDB_DATA_TYPE_BIGINT;
pExpr->tokenId = pLeft->tokenId; pExpr->tokenId = pLeft->tokenId;
pExpr->type = SQL_NODE_VALUE; pExpr->type = SQL_NODE_VALUE;
pExpr->flags = pLeft->flags | pRight->flags;
switch (optrType) { switch (optrType) {
case TK_PLUS: { case TK_PLUS: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册