td-459: TSDB_DB_NAME_LEN
This commit is contained in:
parent
5e8969d661
commit
daafb42e08
|
@ -285,8 +285,8 @@ typedef struct STscObj {
|
|||
void * pTimer;
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_KEY_LEN];
|
||||
char acctId[TSDB_DB_NAME_LEN];
|
||||
char db[TSDB_TABLE_ID_LEN];
|
||||
char acctId[TSDB_ACCT_LEN];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
char sversion[TSDB_VERSION_LEN];
|
||||
char writeAuth : 1;
|
||||
char superAuth : 1;
|
||||
|
|
|
@ -286,7 +286,7 @@ static void tscProcessCurrentUser(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
static void tscProcessCurrentDB(SSqlObj *pSql) {
|
||||
char db[TSDB_DB_NAME_LEN + 1] = {0};
|
||||
char db[TSDB_DB_NAME_LEN] = {0};
|
||||
extractDBName(pSql->pTscObj->db, db);
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
|
|
|
@ -1041,7 +1041,7 @@ int32_t setObjFullName(char* fullName, const char* account, SSQLToken* pDB, SSQL
|
|||
|
||||
/* db name is not specified, the tableName dose not include db name */
|
||||
if (pDB != NULL) {
|
||||
if (pDB->n > TSDB_DB_NAME_LEN) {
|
||||
if (pDB->n >= TSDB_DB_NAME_LEN) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
|
||||
|
@ -1060,7 +1060,7 @@ int32_t setObjFullName(char* fullName, const char* account, SSQLToken* pDB, SSQL
|
|||
}
|
||||
} else { // pDB == NULL, the db prefix name is specified in tableName
|
||||
/* the length limitation includes tablename + dbname + sep */
|
||||
if (tableName->n > TSDB_TABLE_NAME_LEN + TSDB_DB_NAME_LEN + tListLen(TS_PATH_DELIMITER)) {
|
||||
if (tableName->n > (TSDB_TABLE_NAME_LEN - 1) + (TSDB_DB_NAME_LEN - 1) + sizeof(TS_PATH_DELIMITER)) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
}
|
||||
|
@ -2202,7 +2202,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
if (pDbPrefixToken->type != 0) {
|
||||
assert(pDbPrefixToken->n >= 0);
|
||||
|
||||
if (pDbPrefixToken->n > TSDB_DB_NAME_LEN) { // db name is too long
|
||||
if (pDbPrefixToken->n >= TSDB_DB_NAME_LEN) { // db name is too long
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,15 +92,15 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
|
|||
if (db) {
|
||||
int32_t len = strlen(db);
|
||||
/* db name is too long */
|
||||
if (len > TSDB_DB_NAME_LEN) {
|
||||
if (len >= TSDB_DB_NAME_LEN) {
|
||||
terrno = TSDB_CODE_TSC_INVALID_DB_LENGTH;
|
||||
rpcClose(pDnodeConn);
|
||||
free(pObj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char tmp[TSDB_DB_NAME_LEN + 1] = {0};
|
||||
strcpy(tmp, db);
|
||||
char tmp[TSDB_DB_NAME_LEN] = {0};
|
||||
tstrncpy(tmp, db, sizeof(tmp));
|
||||
|
||||
strdequote(tmp);
|
||||
strtolower(pObj->db, tmp);
|
||||
|
|
|
@ -708,7 +708,7 @@ static void doInitGlobalConfig() {
|
|||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
|
||||
cfg.minValue = 0;
|
||||
cfg.maxValue = 0;
|
||||
cfg.ptrLength = TSDB_DB_NAME_LEN;
|
||||
cfg.ptrLength = TSDB_DB_NAME_LEN - 1;
|
||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||
taosInitConfigOption(cfg);
|
||||
|
||||
|
@ -923,7 +923,7 @@ static void doInitGlobalConfig() {
|
|||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
||||
cfg.minValue = 0;
|
||||
cfg.maxValue = 0;
|
||||
cfg.ptrLength = TSDB_DB_NAME_LEN;
|
||||
cfg.ptrLength = TSDB_DB_NAME_LEN - 1;
|
||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||
taosInitConfigOption(cfg);
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
|
|||
#define TSDB_USERID_LEN 9
|
||||
#define TS_PATH_DELIMITER_LEN 1
|
||||
|
||||
#define TSDB_METER_ID_LEN_MARGIN 9
|
||||
#define TSDB_METER_ID_LEN_MARGIN 8
|
||||
#define TSDB_TABLE_ID_LEN (TSDB_DB_NAME_LEN+TSDB_TABLE_NAME_LEN+2*TS_PATH_DELIMITER_LEN+TSDB_USERID_LEN+TSDB_METER_ID_LEN_MARGIN) //TSDB_DB_NAME_LEN+TSDB_TABLE_NAME_LEN+2*strlen(TS_PATH_DELIMITER)+strlen(USERID)
|
||||
#define TSDB_UNI_LEN 24
|
||||
#define TSDB_USER_LEN TSDB_UNI_LEN
|
||||
|
@ -201,7 +201,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
|
|||
|
||||
#define TSDB_NODE_NAME_LEN 64
|
||||
#define TSDB_TABLE_NAME_LEN 193
|
||||
#define TSDB_DB_NAME_LEN 32
|
||||
#define TSDB_DB_NAME_LEN 33
|
||||
#define TSDB_COL_NAME_LEN 64
|
||||
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
|
||||
#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE
|
||||
|
|
|
@ -250,7 +250,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
char tableId[TSDB_TABLE_ID_LEN + 1];
|
||||
char db[TSDB_DB_NAME_LEN + 1];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
int8_t igExists;
|
||||
int8_t getMeta;
|
||||
int16_t numOfTags;
|
||||
|
@ -268,7 +268,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
char tableId[TSDB_TABLE_ID_LEN + 1];
|
||||
char db[TSDB_DB_NAME_LEN + 1];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
int16_t type; /* operation type */
|
||||
int16_t numOfCols; /* number of schema */
|
||||
int32_t tagValLen;
|
||||
|
@ -502,7 +502,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
char acct[TSDB_USER_LEN + 1];
|
||||
char db[TSDB_DB_NAME_LEN + 1];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
int32_t cacheBlockSize; //MB
|
||||
int32_t totalBlocks;
|
||||
int32_t maxTables;
|
||||
|
@ -606,7 +606,7 @@ typedef struct {
|
|||
} SMDVnodeDesc;
|
||||
|
||||
typedef struct {
|
||||
char db[TSDB_DB_NAME_LEN + 1];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
SMDVnodeCfg cfg;
|
||||
SMDVnodeDesc nodes[TSDB_MAX_REPLICA];
|
||||
} SMDCreateVnodeMsg;
|
||||
|
@ -671,7 +671,7 @@ typedef struct {
|
|||
*/
|
||||
typedef struct {
|
||||
int8_t type;
|
||||
char db[TSDB_DB_NAME_LEN + 1];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
uint16_t payloadLen;
|
||||
char payload[];
|
||||
} SCMShowMsg;
|
||||
|
|
|
@ -102,7 +102,7 @@ typedef struct {
|
|||
extern char version[];
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_DB_NAME_LEN + 1];
|
||||
char name[TSDB_DB_NAME_LEN];
|
||||
int32_t replica;
|
||||
int32_t days;
|
||||
int32_t keep;
|
||||
|
|
|
@ -115,7 +115,7 @@ typedef struct {
|
|||
|
||||
typedef struct SVgObj {
|
||||
uint32_t vgId;
|
||||
char dbName[TSDB_DB_NAME_LEN + 1];
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
int64_t createdTime;
|
||||
SVnodeGid vnodeGid[TSDB_MAX_REPLICA];
|
||||
int32_t numOfVnodes;
|
||||
|
@ -154,7 +154,7 @@ typedef struct {
|
|||
} SDbCfg;
|
||||
|
||||
typedef struct SDbObj {
|
||||
char name[TSDB_DB_NAME_LEN + 1];
|
||||
char name[TSDB_DB_NAME_LEN];
|
||||
char acct[TSDB_USER_LEN + 1];
|
||||
int64_t createdTime;
|
||||
int32_t cfgVersion;
|
||||
|
@ -219,7 +219,7 @@ typedef struct SAcctObj {
|
|||
typedef struct {
|
||||
int8_t type;
|
||||
int32_t index;
|
||||
char db[TSDB_DB_NAME_LEN + 1];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
void * pIter;
|
||||
int16_t numOfColumns;
|
||||
int32_t rowSize;
|
||||
|
|
|
@ -328,8 +328,8 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
|
|||
if (code != 0) return code;
|
||||
|
||||
pDb = calloc(1, sizeof(SDbObj));
|
||||
strncpy(pDb->name, pCreate->db, TSDB_DB_NAME_LEN);
|
||||
strncpy(pDb->acct, pAcct->user, TSDB_USER_LEN);
|
||||
tstrncpy(pDb->name, pCreate->db, sizeof(pDb->name));
|
||||
tstrncpy(pDb->acct, pAcct->user, sizeof(pDb->acct));
|
||||
pDb->createdTime = taosGetTimestampMs();
|
||||
pDb->cfg = (SDbCfg) {
|
||||
.cacheBlockSize = pCreate->cacheBlockSize,
|
||||
|
@ -373,7 +373,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
|
|||
}
|
||||
|
||||
bool mnodeCheckIsMonitorDB(char *db, char *monitordb) {
|
||||
char dbName[TSDB_DB_NAME_LEN + 1] = {0};
|
||||
char dbName[TSDB_DB_NAME_LEN] = {0};
|
||||
extractDBName(db, dbName);
|
||||
|
||||
size_t len = strlen(dbName);
|
||||
|
@ -453,7 +453,7 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
|
|||
SUserObj *pUser = mnodeGetUserFromConn(pConn);
|
||||
if (pUser == NULL) return 0;
|
||||
|
||||
pShow->bytes[cols] = TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE;
|
||||
pShow->bytes[cols] = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "name");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
|
@ -610,7 +610,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
|
|||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
|
||||
char* name = mnodeGetDbStr(pDb->name);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, name, TSDB_DB_NAME_LEN);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, name, TSDB_DB_NAME_LEN - 1);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
|
|
|
@ -43,7 +43,7 @@ typedef enum {
|
|||
} ESdbStatus;
|
||||
|
||||
typedef struct _SSdbTable {
|
||||
char tableName[TSDB_DB_NAME_LEN + 1];
|
||||
char tableName[TSDB_DB_NAME_LEN];
|
||||
ESdbTable tableId;
|
||||
ESdbKey keyType;
|
||||
int32_t hashSessions;
|
||||
|
|
|
@ -1160,7 +1160,7 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
|
|||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
|
||||
int16_t len = strnlen(stableName, TSDB_DB_NAME_LEN);
|
||||
int16_t len = strnlen(stableName, TSDB_DB_NAME_LEN - 1);
|
||||
*(int16_t*) pWrite = len;
|
||||
pWrite += sizeof(int16_t); // todo refactor
|
||||
|
||||
|
|
|
@ -6037,9 +6037,9 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
|
|||
|
||||
for(int32_t j = 0; j < pQuery->numOfOutput; ++j) {
|
||||
if (pExprInfo[j].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
data = tsdbGetTableName(pQInfo->tsdb, &item->id, &bytes);
|
||||
char* data = tsdbGetTableName(pQInfo->tsdb, &item->id);
|
||||
|
||||
char* dst = pQuery->sdata[j]->data + i * ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE);
|
||||
char* dst = pQuery->sdata[j]->data + count * ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE);
|
||||
memcpy(dst, data, varDataTLen(data));
|
||||
} else {// todo refactor
|
||||
int16_t type = pExprInfo[j].type;
|
||||
|
|
|
@ -51,7 +51,7 @@ typedef struct {
|
|||
SSyncCfg syncCfg;
|
||||
SWalCfg walCfg;
|
||||
char *rootDir;
|
||||
char db[TSDB_DB_NAME_LEN + 1];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
} SVnodeObj;
|
||||
|
||||
int vnodeWriteToQueue(void *param, void *pHead, int type);
|
||||
|
|
Loading…
Reference in New Issue