From 7f3204ce062abf17dbd873b5d6f26f633c6f1096 Mon Sep 17 00:00:00 2001 From: xywang Date: Thu, 7 Jul 2022 15:48:27 +0800 Subject: [PATCH] fix: database name which is a key word should not permitted --- src/client/src/tscSQLParser.c | 10 ---------- src/client/src/tscUtil.c | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index e36a81b387..22456782d0 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1511,7 +1511,6 @@ int32_t tscSetTableFullName(SName* pName, SStrToken* pTableName, SSqlObj* pSql, const char* msg4 = "db name too long"; const char* msg5 = "table name too long"; const char* msg6 = "table name empty"; - const char* msg7 = "invalid table name"; SSqlCmd* pCmd = &pSql->cmd; int32_t code = TSDB_CODE_SUCCESS; @@ -1576,15 +1575,6 @@ int32_t tscSetTableFullName(SName* pName, SStrToken* pTableName, SSqlObj* pSql, } } - if (code != 0) { - return code; - } - - bool ret = taosIsKeyWordToken(pName->tname, (int32_t) strlen(pName->tname)); - if (ret) { - code = invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7); - } - return code; } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index c27ceac50c..5c6fb2dc75 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -3014,8 +3014,8 @@ int32_t tscValidateName(SStrToken* pToken, bool escapeEnabled, bool *dbIncluded) // single token, validate it if (len == pToken->n) { - if (strncmp(pToken->z, "string", len) == 0) { - return TSDB_CODE_SUCCESS; + if (taosIsKeyWordToken(pToken->z, (int32_t) pToken->n)) { + return TSDB_CODE_TSC_INVALID_OPERATION; } return validateQuoteToken(pToken, escapeEnabled, NULL); -- GitLab