提交 def1a16f 编写于 作者: G Ganlin Zhao

[TD-10700]<enhance>: The escape char backstick can be used for both tag name and column name

上级 60cd0395
......@@ -6607,7 +6607,7 @@ int32_t validateColumnName(char* name) {
return validateColumnName(token.z);
} else if (token.type == TK_ID) {
tscRmEscapeAndTrimToken(&token);
strRmquoteEscape(name, token.n);
return TSDB_CODE_SUCCESS;
} else {
if (isNumber(&token)) {
......@@ -7664,7 +7664,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
SCreatedTableInfo* pCreateTableInfo = taosArrayGet(pCreateTable->childTableInfo, j);
SStrToken* pToken = &pCreateTableInfo->stableName;
bool dbIncluded = false;
char buf[TSDB_TABLE_FNAME_LEN];
SStrToken sTblToken;
......@@ -7728,6 +7728,10 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
tscDequoteAndTrimToken(sToken);
}
if (TK_ID == sToken->type) {
tscRmEscapeAndTrimToken(sToken);
}
tVariantListItem* pItem = taosArrayGet(pValList, i);
findColumnIndex = false;
......
......@@ -53,13 +53,13 @@ int32_t strdequote(char *z) {
}
int32_t strRmquote(char *z, int32_t len){
int32_t strRmquote(char *z, int32_t len){
// delete escape character: \\, \', \"
char delim = z[0];
if (delim != '\'' && delim != '\"') {
return len;
}
int32_t cnt = 0;
int32_t j = 0;
for (uint32_t k = 1; k < len - 1; ++k) {
......@@ -74,23 +74,24 @@ int32_t strRmquote(char *z, int32_t len){
continue;
}
}
z[j] = z[k];
j++;
}
z[j] = 0;
return len - 2 - cnt;
}
int32_t strRmquoteEscape(char *z, int32_t len) {
if (len <= 0) return len;
if (z[0] == '\'' || z[0] == '\"') {
return strRmquote(z, len);
} else if (len > 1 && z[0] == TS_ESCAPE_CHAR && z[len - 1] == TS_ESCAPE_CHAR) {
memmove(z, z + 1, len - 2);
z[len - 2] = '\0';
return len - 2;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册