提交 2e6ddb06 编写于 作者: G Ganlin Zhao

[TD-11220]<feature>(query): time related functions

上级 744c822d
...@@ -5163,6 +5163,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql ...@@ -5163,6 +5163,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
}else{ }else{
colName = &(pLeft->columnName); colName = &(pLeft->columnName);
} }
int32_t ret = TSDB_CODE_SUCCESS; int32_t ret = TSDB_CODE_SUCCESS;
SColumnIndex index = COLUMN_INDEX_INITIALIZER; SColumnIndex index = COLUMN_INDEX_INITIALIZER;
...@@ -5437,6 +5438,21 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr ...@@ -5437,6 +5438,21 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr
goto err_ret; goto err_ret;
} }
//for now(),today() function used in where clause.
if (pRight->tokenId == TK_ID && (strncmp(pRight->exprToken.z, "now()", pRight->exprToken.n) == 0 ||
strncmp(pRight->exprToken.z, "today()", pRight->exprToken.n) == 0)) {
pRight->type = SQL_NODE_VALUE;
pRight->tokenId = TK_TIMESTAMP;
pRight->exprToken.type = TSDB_DATA_TYPE_TIMESTAMP;
if (strncmp(pRight->exprToken.z, "now()", pRight->exprToken.n) == 0) {
tVariantCreateExt(&pRight->value, &pRight->exprToken, TK_NOW, false);
} else {
tVariantCreateExt(&pRight->value, &pRight->exprToken, TK_TODAY, false);
}
pRight->value.nType = TSDB_DATA_TYPE_BIGINT;
pRight->flags |= 1 << EXPR_FLAG_NS_TIMESTAMP;
}
ret = handleExprInQueryCond(pCmd, pQueryInfo, pExpr, pCondExpr, type, tbIdx, parentOptr, columnExpr, tsExpr, joinQuery); ret = handleExprInQueryCond(pCmd, pQueryInfo, pExpr, pCondExpr, type, tbIdx, parentOptr, columnExpr, tsExpr, joinQuery);
if (ret) { if (ret) {
goto err_ret; goto err_ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册