[td-1603]

This commit is contained in:
Haojun Liao 2020-09-25 15:13:33 +08:00
parent 0dcef5b340
commit b2dd094ffa
1 changed files with 5 additions and 15 deletions

View File

@ -805,17 +805,13 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql) { int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql) {
const char* msg1 = "name too long"; const char* msg1 = "name too long";
const char* msg2 = "current database or database name invalid";
SSqlCmd* pCmd = &pSql->cmd; SSqlCmd* pCmd = &pSql->cmd;
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
// backup the old name in pTableMetaInfo // backup the old name in pTableMetaInfo
size_t size = strlen(pTableMetaInfo->name); char oldName[TSDB_TABLE_FNAME_LEN] = {0};
char* oldName = NULL; tstrncpy(oldName, pTableMetaInfo->name, tListLen(oldName));
if (size > 0) {
oldName = strdup(pTableMetaInfo->name);
}
if (hasSpecifyDB(pzTableName)) { // db has been specified in sql string so we ignore current db path if (hasSpecifyDB(pzTableName)) { // db has been specified in sql string so we ignore current db path
code = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), NULL, pzTableName, NULL); code = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), NULL, pzTableName, NULL);
@ -836,23 +832,17 @@ int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableNa
} }
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
taosTFree(oldName);
return code; return code;
} }
/* /*
* the old name exists and is not equalled to the new name. Release the metermeta/metricmeta * the old name exists and is not equalled to the new name. Release the table meta
* that are corresponding to the old name for the new table name. * that are corresponding to the old name for the new table name.
*/ */
if (size > 0) { if (strncasecmp(oldName, pTableMetaInfo->name, tListLen(pTableMetaInfo->name)) != 0) {
if (strncasecmp(oldName, pTableMetaInfo->name, tListLen(pTableMetaInfo->name)) != 0) { tscClearTableMetaInfo(pTableMetaInfo, false);
tscClearTableMetaInfo(pTableMetaInfo, false);
}
} else {
assert(pTableMetaInfo->pTableMeta == NULL);
} }
taosTFree(oldName);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }