未验证 提交 9d7fb6ed 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #18138 from taosdata/szhou/fixbugs26

fix: core caused by memory address changed during set db.table tag
......@@ -7339,18 +7339,19 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
bool dbIncluded = false;
SStrToken tmpToken = pAlterSQL->name;
tmpToken.z= strndup(pAlterSQL->name.z, pAlterSQL->name.n);
char* z0 = strndup(pAlterSQL->name.z, pAlterSQL->name.n);
tmpToken.z = z0;
if (tscValidateName(&tmpToken, true, &dbIncluded) != TSDB_CODE_SUCCESS) {
free(tmpToken.z);
free(z0);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
}
code = tscSetTableFullName(&pTableMetaInfo->name, &tmpToken, pSql, dbIncluded);
if (code != TSDB_CODE_SUCCESS) {
free(tmpToken.z);
free(z0);
return code;
}
free(tmpToken.z);
free(z0);
code = tscGetTableMeta(pSql, pTableMetaInfo);
if (code != TSDB_CODE_SUCCESS) {
......
......@@ -225,59 +225,66 @@ char *tstrstr(char *src, char *dst, bool ignoreInEsc) {
}
char* strtolower(char *dst, const char *src) {
if (src == NULL || dst == NULL) {
return dst;
}
char* const ret = dst;
while (*src) {
const char ch = *(src++);
*(dst++) = (ch >= 'A' && ch <= 'Z') ? ch - 'A' + 'a' : ch;
if (ch == '\'' || ch == '"') {
char prev = ch;
while (*src) {
const char next = *(src++);
*(dst++) = next;
if (prev != '\\' && next == ch) break;
prev = next;
}
} else if (ch == '`') {
while (*src) {
const char next = *(src++);
*(dst++) = next;
if (next == ch) break;
int esc = 0;
char quote = 0, *p = dst, c;
assert(dst != NULL);
for (c = *src++; c; c = *src++) {
if (esc) {
esc = 0;
} else if (quote) {
if (c == '\\') {
esc = 1;
} else if (c == quote) {
quote = 0;
}
} else if (c >= 'A' && c <= 'Z') {
c -= 'A' - 'a';
} else if (c == '\'' || c == '"') {
quote = c;
}
*p++ = c;
}
*(dst) = 0;
return ret;
*p = 0;
return dst;
}
char* strntolower(char *dst, const char *src, int32_t n) {
int esc = 0, inEsc = 0;
char quote = 0, *p = dst, c;
assert(dst != NULL);
char* const end = dst + n;
while (dst != end) {
const char ch = *(src++);
*(dst++) = (ch >= 'A' && ch <= 'Z') ? ch - 'A' + 'a' : ch;
if (ch == '\'' || ch == '"') {
char prev = ch;
while (dst != end) {
const char next = *(src++);
*(dst++) = next;
if (prev != '\\' && next == ch) break;
prev = next;
if (n == 0) {
*p = 0;
return dst;
}
for (c = *src++; n-- > 0; c = *src++) {
if (esc) {
esc = 0;
} else if (quote) {
if (c == '\\') {
esc = 1;
} else if (c == quote) {
quote = 0;
}
} else if (ch == '`') {
while (dst != end) {
const char next = *(src++);
*(dst++) = next;
if (next == ch) break;
} else if (inEsc) {
if (c == '`') {
inEsc = 0;
}
} else if (c >= 'A' && c <= 'Z') {
c -= 'A' - 'a';
} else if (inEsc == 0 && (c == '\'' || c == '"')) {
quote = c;
} else if (c == '`' && quote == 0) {
inEsc = 1;
}
*p++ = c;
}
*(dst) = 0;
return dst - n;
*p = 0;
return dst;
}
char* strntolower_s(char *dst, const char *src, int32_t n) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册