From d3f5f8fd47b8eb40762b25b36144e7ca1517dde5 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Sat, 9 Oct 2021 09:33:41 +0800 Subject: [PATCH] fix bugs and case issue --- src/client/src/tscSQLParser.c | 11 ++++++++--- src/kit/shell/src/shellEngine.c | 3 ++- tests/script/general/parser/tbnameIn_query.sim | 16 ++-------------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index f3f9b9ab68..58668b661a 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -7559,11 +7559,16 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { SStrToken* pToken = &pCreateTableInfo->stableName; bool dbIncluded = false; - if (tscValidateName(pToken, true, &dbIncluded) != TSDB_CODE_SUCCESS) { + char buf[TSDB_TABLE_FNAME_LEN]; + SStrToken sTblToken; + sTblToken.z = buf; + + int32_t code = validateTableName(pToken->z, pToken->n, &sTblToken, &dbIncluded); + if (code != TSDB_CODE_SUCCESS) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } - int32_t code = tscSetTableFullName(&pStableMetaInfo->name, pToken, pSql, dbIncluded); + code = tscSetTableFullName(&pStableMetaInfo->name, &sTblToken, pSql, dbIncluded); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -7793,7 +7798,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { } SRelElementPair* p1 = taosArrayGet(pFromInfo->list, 0); - SStrToken srcToken = {.z = p1->tableName.z, .n = p1->tableName.n, .type = TK_STRING}; + SStrToken srcToken = {.z = p1->tableName.z, .n = p1->tableName.n, .type = p1->tableName.type}; bool dbIncluded2 = false; if (tscValidateName(&srcToken, true, &dbIncluded2) != TSDB_CODE_SUCCESS) { diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index d30b868bd5..21ac5e0b7e 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -250,6 +250,7 @@ int32_t shellRunCommand(TAOS* con, char* command) { break; case '\'': case '"': + case '`': if (quote) { *p++ = '\\'; } @@ -271,7 +272,7 @@ int32_t shellRunCommand(TAOS* con, char* command) { if (quote == c) { quote = 0; - } else if (quote == 0 && (c == '\'' || c == '"')) { + } else if (quote == 0 && (c == '\'' || c == '"' || c == '`')) { quote = c; } diff --git a/tests/script/general/parser/tbnameIn_query.sim b/tests/script/general/parser/tbnameIn_query.sim index 7fa579b9c2..f806418773 100644 --- a/tests/script/general/parser/tbnameIn_query.sim +++ b/tests/script/general/parser/tbnameIn_query.sim @@ -101,9 +101,9 @@ if $data11 != 2 then return -1 endi -## tbname in can accpet Upper case table name +## no support tbname in Upper case sql select count(*) from $stb where tbname in ('ti_tb0', 'TI_tb1', 'TI_TB2') group by t1 order by t1 -if $rows != 3 then +if $rows != 1 then return -1 endi if $data00 != 10 then @@ -112,18 +112,6 @@ endi if $data01 != 0 then return -1 endi -if $data10 != 10 then - return -1 -endi -if $data11 != 1 then - return -1 -endi -if $data20 != 10 then - return -1 -endi -if $data21 != 2 then - return -1 -endi sql select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and tbname in ('ti_tb5', 'ti_tb1000') group by t1 order by t1 asc if $rows != 0 then -- GitLab