commit
a66106ea76
|
@ -64,7 +64,7 @@ static char* getAccountId(SSqlObj* pSql);
|
||||||
|
|
||||||
static bool has(SArray* pFieldList, int32_t startIdx, const char* name);
|
static bool has(SArray* pFieldList, int32_t startIdx, const char* name);
|
||||||
static char* cloneCurrentDBName(SSqlObj* pSql);
|
static char* cloneCurrentDBName(SSqlObj* pSql);
|
||||||
static bool hasSpecifyDB(SStrToken* pTableName);
|
static int32_t getDelimiterIndex(SStrToken* pTableName);
|
||||||
static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd);
|
static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd);
|
||||||
static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pCmd);
|
static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pCmd);
|
||||||
|
|
||||||
|
@ -426,17 +426,11 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
|
|
||||||
case TSDB_SQL_DESCRIBE_TABLE: {
|
case TSDB_SQL_DESCRIBE_TABLE: {
|
||||||
const char* msg1 = "invalid table name";
|
const char* msg1 = "invalid table name";
|
||||||
const char* msg2 = "table name too long";
|
|
||||||
|
|
||||||
SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||||
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tscValidateTableNameLength(pToken->n)) {
|
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// additional msg has been attached already
|
// additional msg has been attached already
|
||||||
code = tscSetTableFullName(pTableMetaInfo, pToken, pSql);
|
code = tscSetTableFullName(pTableMetaInfo, pToken, pSql);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -447,17 +441,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
}
|
}
|
||||||
case TSDB_SQL_SHOW_CREATE_TABLE: {
|
case TSDB_SQL_SHOW_CREATE_TABLE: {
|
||||||
const char* msg1 = "invalid table name";
|
const char* msg1 = "invalid table name";
|
||||||
const char* msg2 = "table name is too long";
|
|
||||||
|
|
||||||
SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||||
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tscValidateTableNameLength(pToken->n)) {
|
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
code = tscSetTableFullName(pTableMetaInfo, pToken, pSql);
|
code = tscSetTableFullName(pTableMetaInfo, pToken, pSql);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -987,11 +976,13 @@ int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pTableNam
|
||||||
const char* msg1 = "name too long";
|
const char* msg1 = "name too long";
|
||||||
const char* msg2 = "acctId too long";
|
const char* msg2 = "acctId too long";
|
||||||
const char* msg3 = "no acctId";
|
const char* msg3 = "no acctId";
|
||||||
|
const char* msg4 = "db name too long";
|
||||||
|
const char* msg5 = "table name too long";
|
||||||
|
|
||||||
SSqlCmd* pCmd = &pSql->cmd;
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t idx = getDelimiterIndex(pTableName);
|
||||||
if (hasSpecifyDB(pTableName)) { // db has been specified in sql string so we ignore current db path
|
if (idx != -1) { // db has been specified in sql string so we ignore current db path
|
||||||
char* acctId = getAccountId(pSql);
|
char* acctId = getAccountId(pSql);
|
||||||
if (acctId == NULL || strlen(acctId) <= 0) {
|
if (acctId == NULL || strlen(acctId) <= 0) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||||
|
@ -1001,6 +992,13 @@ int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pTableNam
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
}
|
}
|
||||||
|
if (idx >= TSDB_DB_NAME_LEN) {
|
||||||
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4);
|
||||||
|
}
|
||||||
|
if (pTableName->n - 1 - idx >= TSDB_TABLE_NAME_LEN) {
|
||||||
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg5);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
strncpy(name, pTableName->z, pTableName->n);
|
strncpy(name, pTableName->z, pTableName->n);
|
||||||
|
@ -1345,14 +1343,13 @@ static char* cloneCurrentDBName(SSqlObj* pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* length limitation, strstr cannot be applied */
|
/* length limitation, strstr cannot be applied */
|
||||||
static bool hasSpecifyDB(SStrToken* pTableName) {
|
static int32_t getDelimiterIndex(SStrToken* pTableName) {
|
||||||
for (uint32_t i = 0; i < pTableName->n; ++i) {
|
for (uint32_t i = 0; i < pTableName->n; ++i) {
|
||||||
if (pTableName->z[i] == TS_PATH_DELIMITER[0]) {
|
if (pTableName->z[i] == TS_PATH_DELIMITER[0]) {
|
||||||
return true;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t setObjFullName(char* fullName, const char* account, SStrToken* pDB, SStrToken* tableName, int32_t* xlen) {
|
int32_t setObjFullName(char* fullName, const char* account, SStrToken* pDB, SStrToken* tableName, int32_t* xlen) {
|
||||||
|
@ -7483,11 +7480,3 @@ bool hasNormalColumnFilter(SQueryInfo* pQueryInfo) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ typedef struct SAcctObj {
|
||||||
} SAcctObj;
|
} SAcctObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char db[TSDB_DB_NAME_LEN];
|
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
||||||
int8_t type;
|
int8_t type;
|
||||||
int16_t numOfColumns;
|
int16_t numOfColumns;
|
||||||
int32_t index;
|
int32_t index;
|
||||||
|
|
|
@ -129,7 +129,7 @@ static int32_t mnodeProcessShowMsg(SMnodeMsg *pMsg) {
|
||||||
SShowObj *pShow = calloc(1, showObjSize);
|
SShowObj *pShow = calloc(1, showObjSize);
|
||||||
pShow->type = pShowMsg->type;
|
pShow->type = pShowMsg->type;
|
||||||
pShow->payloadLen = htons(pShowMsg->payloadLen);
|
pShow->payloadLen = htons(pShowMsg->payloadLen);
|
||||||
tstrncpy(pShow->db, pShowMsg->db, TSDB_DB_NAME_LEN);
|
tstrncpy(pShow->db, pShowMsg->db, TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN);
|
||||||
memcpy(pShow->payload, pShowMsg->payload, pShow->payloadLen);
|
memcpy(pShow->payload, pShowMsg->payload, pShow->payloadLen);
|
||||||
|
|
||||||
pShow = mnodePutShowObj(pShow);
|
pShow = mnodePutShowObj(pShow);
|
||||||
|
|
Loading…
Reference in New Issue