diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 73337469b2b9a7ad696ba9a6dc24c734accd109a..c5719dde276abecd667efc95a960ab1a45af6962 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -70,6 +70,10 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1 if (pToken->type == TK_NOW) { 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) { // do nothing } else if (pToken->type == TK_INTEGER) { @@ -473,7 +477,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i } 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) || (sToken.n == 0) || (type == TK_RP)) { return tscSQLSyntaxErrMsg(pInsertParam->msg, "invalid data or symbol", sToken.z); diff --git a/src/util/src/ttokenizer.c b/src/util/src/ttokenizer.c index 8b9791298476681d41d79f82437f732434bb3c8f..a480fa5d6a0a7437ab8e71250645cec82cbee691 100644 --- a/src/util/src/ttokenizer.c +++ b/src/util/src/ttokenizer.c @@ -667,8 +667,9 @@ SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr) { #endif } - //for now() function used in insert clause - if (t0.type == TK_NOW && str[t0.n] == '(' && str[t0.n + 1] == ')') { + //for now(),today() function used in insert clause + if ((t0.type == TK_NOW || t0.type == TK_TODAY) && + str[t0.n] == '(' && str[t0.n + 1] == ')') { t0.n += 2; }