提交 3368e490 编写于 作者: D dapan1121

add assert

上级 be152567
......@@ -902,13 +902,17 @@ int32_t parseSlidingClause(SSqlObj* pSql, SQueryInfo* pQueryInfo, SQuerySQL* pQu
int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pTableName, SSqlObj* pSql) {
const char* msg1 = "name too long";
const char* msg2 = "acctId too long";
SSqlCmd* pCmd = &pSql->cmd;
int32_t code = TSDB_CODE_SUCCESS;
if (hasSpecifyDB(pTableName)) { // db has been specified in sql string so we ignore current db path
tNameSetAcctId(&pTableMetaInfo->name, getAccountId(pSql));
code = tNameSetAcctId(&pTableMetaInfo->name, getAccountId(pSql));
if (code != 0) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
char name[TSDB_TABLE_FNAME_LEN] = {0};
strncpy(name, pTableName->z, pTableName->n);
......
......@@ -367,6 +367,9 @@ int32_t tNameSetAcctId(SName* dst, const char* acct) {
}
tstrncpy(dst->acctId, acct, tListLen(dst->acctId));
assert(strlen(dst->acctId) > 0);
return 0;
}
......@@ -383,12 +386,14 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) {
int32_t len = (int32_t)(p - str);
// too long account id or too long db name
if (len >= tListLen(dst->acctId) || len == 0) {
if ((len >= tListLen(dst->acctId)) || (len <= 0)) {
return -1;
}
memcpy (dst->acctId, str, len);
dst->acctId[len] = 0;
assert(strlen(dst->acctId) > 0);
}
if ((type & T_NAME_DB) == T_NAME_DB) {
......@@ -404,7 +409,7 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) {
}
// too long account id or too long db name
if (len >= tListLen(dst->dbname) || len == 0) {
if ((len >= tListLen(dst->dbname)) || (len <= 0)) {
return -1;
}
......@@ -419,7 +424,7 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) {
int32_t len = (int32_t) strlen(start);
// too long account id or too long db name
if (len >= tListLen(dst->tname) || len == 0) {
if ((len >= tListLen(dst->tname)) || (len <= 0)) {
return -1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册