From c54ed52a1976ebc6b58733c1e6a6d5151aec9d4b Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 21 Jul 2022 16:03:33 +0800 Subject: [PATCH] fix: problem with insert 'null' into binary/nchar column --- source/libs/parser/src/parInsert.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 517df1a977..aa8af7e38f 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -434,8 +434,8 @@ static FORCE_INLINE int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, } static bool isNullStr(SToken* pToken) { - return (pToken->type == TK_NULL) || ((pToken->type == TK_NK_STRING) && (pToken->n != 0) && - (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)); + return ((pToken->type == TK_NK_STRING) && (pToken->n != 0) && + (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)); } static FORCE_INLINE int32_t toDouble(SToken* pToken, double* value, char** endPtr) { @@ -461,7 +461,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return code; } - if (isNullStr(pToken)) { + if (TK_NULL == pToken->type || (!IS_VAR_DATA_TYPE(pSchema->type) && isNullStr(pToken))) { if (TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) { return buildSyntaxErrMsg(pMsgBuf, "primary timestamp should not be null", pToken->z); }