提交 744c822d 编写于 作者: G Ganlin Zhao

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

上级 e161f478
...@@ -70,6 +70,10 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1 ...@@ -70,6 +70,10 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
if (pToken->type == TK_NOW) { if (pToken->type == TK_NOW) {
useconds = taosGetTimestamp(timePrec); useconds = taosGetTimestamp(timePrec);
} else if (pToken->type == TK_TODAY) {
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
(timePrec == TSDB_TIME_PRECISION_MICRO) ? 1000000 : 1000000000;
useconds = taosGetTimestampToday() * factor;
} else if (strncmp(pToken->z, "0", 1) == 0 && pToken->n == 1) { } else if (strncmp(pToken->z, "0", 1) == 0 && pToken->n == 1) {
// do nothing // do nothing
} else if (pToken->type == TK_INTEGER) { } else if (pToken->type == TK_INTEGER) {
...@@ -473,7 +477,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i ...@@ -473,7 +477,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
} }
int16_t type = sToken.type; int16_t type = sToken.type;
if ((type != TK_NOW && type != TK_INTEGER && type != TK_STRING && type != TK_FLOAT && type != TK_BOOL && if ((type != TK_NOW && type != TK_TODAY && type != TK_INTEGER && type != TK_STRING && type != TK_FLOAT && type != TK_BOOL &&
type != TK_NULL && type != TK_HEX && type != TK_OCT && type != TK_BIN) || type != TK_NULL && type != TK_HEX && type != TK_OCT && type != TK_BIN) ||
(sToken.n == 0) || (type == TK_RP)) { (sToken.n == 0) || (type == TK_RP)) {
return tscSQLSyntaxErrMsg(pInsertParam->msg, "invalid data or symbol", sToken.z); return tscSQLSyntaxErrMsg(pInsertParam->msg, "invalid data or symbol", sToken.z);
......
...@@ -667,8 +667,9 @@ SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr) { ...@@ -667,8 +667,9 @@ SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr) {
#endif #endif
} }
//for now() function used in insert clause //for now(),today() function used in insert clause
if (t0.type == TK_NOW && str[t0.n] == '(' && str[t0.n + 1] == ')') { if ((t0.type == TK_NOW || t0.type == TK_TODAY) &&
str[t0.n] == '(' && str[t0.n + 1] == ')') {
t0.n += 2; t0.n += 2;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册