Merge pull request #2196 from taosdata/patch/string-length
Patch/string length
This commit is contained in:
commit
f00012d0cd
|
@ -285,8 +285,8 @@ typedef struct STscObj {
|
||||||
void * pTimer;
|
void * pTimer;
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
char pass[TSDB_KEY_LEN];
|
char pass[TSDB_KEY_LEN];
|
||||||
char acctId[TSDB_DB_NAME_LEN];
|
char acctId[TSDB_ACCT_LEN];
|
||||||
char db[TSDB_TABLE_ID_LEN];
|
char db[TSDB_DB_NAME_LEN];
|
||||||
char sversion[TSDB_VERSION_LEN];
|
char sversion[TSDB_VERSION_LEN];
|
||||||
char writeAuth : 1;
|
char writeAuth : 1;
|
||||||
char superAuth : 1;
|
char superAuth : 1;
|
||||||
|
|
|
@ -132,7 +132,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
|
||||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||||
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 0);
|
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 0);
|
||||||
char* dst = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 0) * totalNumOfRows + pField->bytes * i;
|
char* dst = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 0) * totalNumOfRows + pField->bytes * i;
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(dst, pSchema[i].name, TSDB_COL_NAME_LEN);
|
STR_WITH_MAXSIZE_TO_VARSTR(dst, pSchema[i].name, TSDB_COL_NAME_LEN - 1);
|
||||||
|
|
||||||
char *type = tDataTypeDesc[pSchema[i].type].aName;
|
char *type = tDataTypeDesc[pSchema[i].type].aName;
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
|
||||||
// field name
|
// field name
|
||||||
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 0);
|
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 0);
|
||||||
char* output = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 0) * totalNumOfRows + pField->bytes * i;
|
char* output = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 0) * totalNumOfRows + pField->bytes * i;
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(output, pSchema[i].name, TSDB_COL_NAME_LEN);
|
STR_WITH_MAXSIZE_TO_VARSTR(output, pSchema[i].name, TSDB_COL_NAME_LEN - 1);
|
||||||
|
|
||||||
// type name
|
// type name
|
||||||
pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 1);
|
pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 1);
|
||||||
|
@ -211,18 +211,18 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||||
pQueryInfo->order.order = TSDB_ORDER_ASC;
|
pQueryInfo->order.order = TSDB_ORDER_ASC;
|
||||||
|
|
||||||
TAOS_FIELD f = {.type = TSDB_DATA_TYPE_BINARY, .bytes = TSDB_COL_NAME_LEN + VARSTR_HEADER_SIZE};
|
TAOS_FIELD f = {.type = TSDB_DATA_TYPE_BINARY, .bytes = (TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE};
|
||||||
strncpy(f.name, "Field", TSDB_COL_NAME_LEN);
|
tstrncpy(f.name, "Field", sizeof(f.name));
|
||||||
|
|
||||||
SFieldSupInfo* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
SFieldSupInfo* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY,
|
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY,
|
||||||
TSDB_COL_NAME_LEN + VARSTR_HEADER_SIZE, TSDB_COL_NAME_LEN, false);
|
(TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE, (TSDB_COL_NAME_LEN - 1), false);
|
||||||
|
|
||||||
rowLen += (TSDB_COL_NAME_LEN + VARSTR_HEADER_SIZE);
|
rowLen += ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE);
|
||||||
|
|
||||||
f.bytes = typeColLength;
|
f.bytes = typeColLength;
|
||||||
f.type = TSDB_DATA_TYPE_BINARY;
|
f.type = TSDB_DATA_TYPE_BINARY;
|
||||||
strncpy(f.name, "Type", TSDB_COL_NAME_LEN);
|
tstrncpy(f.name, "Type", sizeof(f.name));
|
||||||
|
|
||||||
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, typeColLength,
|
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, typeColLength,
|
||||||
|
@ -232,7 +232,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
|
||||||
|
|
||||||
f.bytes = sizeof(int32_t);
|
f.bytes = sizeof(int32_t);
|
||||||
f.type = TSDB_DATA_TYPE_INT;
|
f.type = TSDB_DATA_TYPE_INT;
|
||||||
strncpy(f.name, "Length", TSDB_COL_NAME_LEN);
|
tstrncpy(f.name, "Length", sizeof(f.name));
|
||||||
|
|
||||||
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_INT, sizeof(int32_t),
|
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_INT, sizeof(int32_t),
|
||||||
|
@ -242,7 +242,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
|
||||||
|
|
||||||
f.bytes = noteColLength;
|
f.bytes = noteColLength;
|
||||||
f.type = TSDB_DATA_TYPE_BINARY;
|
f.type = TSDB_DATA_TYPE_BINARY;
|
||||||
strncpy(f.name, "Note", TSDB_COL_NAME_LEN);
|
tstrncpy(f.name, "Note", sizeof(f.name));
|
||||||
|
|
||||||
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, noteColLength,
|
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, noteColLength,
|
||||||
|
@ -286,7 +286,7 @@ static void tscProcessCurrentUser(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tscProcessCurrentDB(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);
|
extractDBName(pSql->pTscObj->db, db);
|
||||||
|
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||||
|
|
|
@ -795,7 +795,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
|
||||||
STableMetaInfo *pSTableMeterMetaInfo = tscGetMetaInfo(pQueryInfo, STABLE_INDEX);
|
STableMetaInfo *pSTableMeterMetaInfo = tscGetMetaInfo(pQueryInfo, STABLE_INDEX);
|
||||||
tscSetTableFullName(pSTableMeterMetaInfo, &sToken, pSql);
|
tscSetTableFullName(pSTableMeterMetaInfo, &sToken, pSql);
|
||||||
|
|
||||||
strncpy(pTag->name, pSTableMeterMetaInfo->name, TSDB_TABLE_ID_LEN);
|
tstrncpy(pTag->name, pSTableMeterMetaInfo->name, sizeof(pTag->name));
|
||||||
code = tscGetTableMeta(pSql, pSTableMeterMetaInfo);
|
code = tscGetTableMeta(pSql, pSTableMeterMetaInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -989,7 +989,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
|
||||||
|
|
||||||
int validateTableName(char *tblName, int len) {
|
int validateTableName(char *tblName, int len) {
|
||||||
char buf[TSDB_TABLE_ID_LEN] = {0};
|
char buf[TSDB_TABLE_ID_LEN] = {0};
|
||||||
strncpy(buf, tblName, len);
|
tstrncpy(buf, tblName, sizeof(buf));
|
||||||
|
|
||||||
SSQLToken token = {.n = len, .type = TK_ID, .z = buf};
|
SSQLToken token = {.n = len, .type = TK_ID, .z = buf};
|
||||||
tSQLGetToken(buf, &token.type);
|
tSQLGetToken(buf, &token.type);
|
||||||
|
@ -1512,7 +1512,7 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
pCmd->count = 1;
|
pCmd->count = 1;
|
||||||
|
|
||||||
strncpy(path, pDataBlock->filename, PATH_MAX);
|
tstrncpy(path, pDataBlock->filename, sizeof(path));
|
||||||
|
|
||||||
FILE *fp = fopen(path, "r");
|
FILE *fp = fopen(path, "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
|
@ -1520,7 +1520,7 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(pTableMetaInfo->name, pDataBlock->tableId, TSDB_TABLE_ID_LEN);
|
tstrncpy(pTableMetaInfo->name, pDataBlock->tableId, sizeof(pTableMetaInfo->name));
|
||||||
memset(pDataBlock->pData, 0, pDataBlock->nAllocSize);
|
memset(pDataBlock->pData, 0, pDataBlock->nAllocSize);
|
||||||
|
|
||||||
int32_t ret = tscGetTableMeta(pSql, pTableMetaInfo);
|
int32_t ret = tscGetTableMeta(pSql, pTableMetaInfo);
|
||||||
|
|
|
@ -239,8 +239,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(pQdesc->sql, pSql->sqlstr, TSDB_SHOW_SQL_LEN - 1);
|
tstrncpy(pQdesc->sql, pSql->sqlstr, sizeof(pQdesc->sql));
|
||||||
pQdesc->sql[TSDB_SHOW_SQL_LEN - 1] = 0;
|
|
||||||
pQdesc->stime = htobe64(pSql->stime);
|
pQdesc->stime = htobe64(pSql->stime);
|
||||||
pQdesc->queryId = htonl(pSql->queryId);
|
pQdesc->queryId = htonl(pSql->queryId);
|
||||||
pQdesc->useconds = htobe64(pSql->res.useconds);
|
pQdesc->useconds = htobe64(pSql->res.useconds);
|
||||||
|
@ -256,8 +255,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
|
||||||
|
|
||||||
SSqlStream *pStream = pObj->streamList;
|
SSqlStream *pStream = pObj->streamList;
|
||||||
while (pStream) {
|
while (pStream) {
|
||||||
strncpy(pSdesc->sql, pStream->pSql->sqlstr, TSDB_SHOW_SQL_LEN - 1);
|
tstrncpy(pSdesc->sql, pStream->pSql->sqlstr, sizeof(pSdesc->sql));
|
||||||
pSdesc->sql[TSDB_SHOW_SQL_LEN - 1] = 0;
|
|
||||||
pSdesc->streamId = htonl(pStream->streamId);
|
pSdesc->streamId = htonl(pStream->streamId);
|
||||||
pSdesc->num = htobe64(pStream->num);
|
pSdesc->num = htobe64(pStream->num);
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pToken->n > TSDB_TABLE_NAME_LEN) {
|
if (pToken->n >= TSDB_TABLE_NAME_LEN) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -933,7 +933,7 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
|
||||||
SSchema* pSchema = tscGetTableSchema(pTableMeta);
|
SSchema* pSchema = tscGetTableSchema(pTableMeta);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTags + numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfTags + numOfCols; ++i) {
|
||||||
if (strncasecmp(pTagField->name, pSchema[i].name, TSDB_COL_NAME_LEN) == 0) {
|
if (strncasecmp(pTagField->name, pSchema[i].name, sizeof(pTagField->name) - 1) == 0) {
|
||||||
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -993,7 +993,7 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
|
||||||
|
|
||||||
// field name must be unique
|
// field name must be unique
|
||||||
for (int32_t i = 0; i < numOfTags + numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfTags + numOfCols; ++i) {
|
||||||
if (strncasecmp(pColField->name, pSchema[i].name, TSDB_COL_NAME_LEN) == 0) {
|
if (strncasecmp(pColField->name, pSchema[i].name, sizeof(pColField->name) - 1) == 0) {
|
||||||
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1005,7 +1005,8 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
|
||||||
/* is contained in pFieldList or not */
|
/* is contained in pFieldList or not */
|
||||||
static bool has(tFieldList* pFieldList, int32_t startIdx, const char* name) {
|
static bool has(tFieldList* pFieldList, int32_t startIdx, const char* name) {
|
||||||
for (int32_t j = startIdx; j < pFieldList->nField; ++j) {
|
for (int32_t j = startIdx; j < pFieldList->nField; ++j) {
|
||||||
if (strncasecmp(name, pFieldList->p[j].name, TSDB_COL_NAME_LEN) == 0) return true;
|
TAOS_FIELD* field = pFieldList->p + j;
|
||||||
|
if (strncasecmp(name, field->name, sizeof(field->name) - 1) == 0) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1041,7 +1042,7 @@ int32_t setObjFullName(char* fullName, const char* account, SSQLToken* pDB, SSQL
|
||||||
|
|
||||||
/* db name is not specified, the tableName dose not include db name */
|
/* db name is not specified, the tableName dose not include db name */
|
||||||
if (pDB != NULL) {
|
if (pDB != NULL) {
|
||||||
if (pDB->n > TSDB_DB_NAME_LEN) {
|
if (pDB->n >= TSDB_DB_NAME_LEN) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1060,7 +1061,7 @@ int32_t setObjFullName(char* fullName, const char* account, SSQLToken* pDB, SSQL
|
||||||
}
|
}
|
||||||
} else { // pDB == NULL, the db prefix name is specified in tableName
|
} else { // pDB == NULL, the db prefix name is specified in tableName
|
||||||
/* the length limitation includes tablename + dbname + sep */
|
/* 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;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1166,7 +1167,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
|
||||||
|
|
||||||
/* todo alias name should use the original sql string */
|
/* todo alias name should use the original sql string */
|
||||||
char* name = (pItem->aliasName != NULL)? pItem->aliasName:arithmeticExprStr;
|
char* name = (pItem->aliasName != NULL)? pItem->aliasName:arithmeticExprStr;
|
||||||
strncpy(pExpr->aliasName, name, TSDB_COL_NAME_LEN);
|
tstrncpy(pExpr->aliasName, name, sizeof(pExpr->aliasName));
|
||||||
|
|
||||||
tExprNode* pNode = NULL;
|
tExprNode* pNode = NULL;
|
||||||
SArray* colList = taosArrayInit(10, sizeof(SColIndex));
|
SArray* colList = taosArrayInit(10, sizeof(SColIndex));
|
||||||
|
@ -1308,7 +1309,7 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
|
||||||
SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, pIndex->columnIndex);
|
SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, pIndex->columnIndex);
|
||||||
|
|
||||||
char* colName = (pItem->aliasName == NULL) ? pSchema->name : pItem->aliasName;
|
char* colName = (pItem->aliasName == NULL) ? pSchema->name : pItem->aliasName;
|
||||||
strncpy(pExpr->aliasName, colName, tListLen(pExpr->aliasName));
|
tstrncpy(pExpr->aliasName, colName, sizeof(pExpr->aliasName));
|
||||||
|
|
||||||
SColumnList ids = {0};
|
SColumnList ids = {0};
|
||||||
ids.num = 1;
|
ids.num = 1;
|
||||||
|
@ -1358,7 +1359,7 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfTotalColumns; ++j) {
|
for (int32_t j = 0; j < numOfTotalColumns; ++j) {
|
||||||
SSqlExpr* pExpr = doAddProjectCol(pQueryInfo, startPos + j, j, pIndex->tableIndex);
|
SSqlExpr* pExpr = doAddProjectCol(pQueryInfo, startPos + j, j, pIndex->tableIndex);
|
||||||
strncpy(pExpr->aliasName, pSchema[j].name, tListLen(pExpr->aliasName));
|
tstrncpy(pExpr->aliasName, pSchema[j].name, sizeof(pExpr->aliasName));
|
||||||
|
|
||||||
pIndex->columnIndex = j;
|
pIndex->columnIndex = j;
|
||||||
SColumnList ids = {0};
|
SColumnList ids = {0};
|
||||||
|
@ -1401,7 +1402,7 @@ int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprItem* pI
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE};
|
SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE};
|
||||||
strcpy(colSchema.name, TSQL_TBNAME_L);
|
strcpy(colSchema.name, TSQL_TBNAME_L);
|
||||||
|
|
||||||
tscAddSpecialColumnForSelect(pQueryInfo, startPos, TSDB_FUNC_TAGPRJ, &index, &colSchema, true);
|
tscAddSpecialColumnForSelect(pQueryInfo, startPos, TSDB_FUNC_TAGPRJ, &index, &colSchema, true);
|
||||||
|
@ -1448,11 +1449,11 @@ static int32_t setExprInfoForFunctions(SQueryInfo* pQueryInfo, SSchema* pSchema,
|
||||||
if (aliasName != NULL) {
|
if (aliasName != NULL) {
|
||||||
strcpy(columnName, aliasName);
|
strcpy(columnName, aliasName);
|
||||||
} else {
|
} else {
|
||||||
getRevisedName(columnName, functionID, TSDB_COL_NAME_LEN, pSchema[pColIndex->columnIndex].name);
|
getRevisedName(columnName, functionID, sizeof(columnName) - 1, pSchema[pColIndex->columnIndex].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSqlExpr* pExpr = tscSqlExprAppend(pQueryInfo, functionID, pColIndex, type, bytes, bytes, false);
|
SSqlExpr* pExpr = tscSqlExprAppend(pQueryInfo, functionID, pColIndex, type, bytes, bytes, false);
|
||||||
strncpy(pExpr->aliasName, columnName, tListLen(pExpr->aliasName));
|
tstrncpy(pExpr->aliasName, columnName, sizeof(pExpr->aliasName));
|
||||||
|
|
||||||
// for all queries, the timestamp column needs to be loaded
|
// for all queries, the timestamp column needs to be loaded
|
||||||
SColumnIndex index = {.tableIndex = pColIndex->tableIndex, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
SColumnIndex index = {.tableIndex = pColIndex->tableIndex, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||||
|
@ -1536,7 +1537,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(pExpr->aliasName, 0, tListLen(pExpr->aliasName));
|
memset(pExpr->aliasName, 0, tListLen(pExpr->aliasName));
|
||||||
getColumnName(pItem, pExpr->aliasName, TSDB_COL_NAME_LEN);
|
getColumnName(pItem, pExpr->aliasName, sizeof(pExpr->aliasName) - 1);
|
||||||
|
|
||||||
SColumnList ids = getColumnList(1, index.tableIndex, index.columnIndex);
|
SColumnList ids = getColumnList(1, index.tableIndex, index.columnIndex);
|
||||||
if (finalResult) {
|
if (finalResult) {
|
||||||
|
@ -1651,7 +1652,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
|
||||||
ids.ids[0] = index;
|
ids.ids[0] = index;
|
||||||
|
|
||||||
memset(pExpr->aliasName, 0, tListLen(pExpr->aliasName));
|
memset(pExpr->aliasName, 0, tListLen(pExpr->aliasName));
|
||||||
getColumnName(pItem, pExpr->aliasName, TSDB_COL_NAME_LEN);
|
getColumnName(pItem, pExpr->aliasName, sizeof(pExpr->aliasName) - 1);
|
||||||
|
|
||||||
if (finalResult) {
|
if (finalResult) {
|
||||||
int32_t numOfOutput = tscNumOfFields(pQueryInfo);
|
int32_t numOfOutput = tscNumOfFields(pQueryInfo);
|
||||||
|
@ -1851,7 +1852,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(pExpr->aliasName, 0, tListLen(pExpr->aliasName));
|
memset(pExpr->aliasName, 0, tListLen(pExpr->aliasName));
|
||||||
getColumnName(pItem, pExpr->aliasName, TSDB_COL_NAME_LEN);
|
getColumnName(pItem, pExpr->aliasName, sizeof(pExpr->aliasName) - 1);
|
||||||
|
|
||||||
SColumnList ids = getColumnList(1, 0, index.columnIndex);
|
SColumnList ids = getColumnList(1, 0, index.columnIndex);
|
||||||
if (finalResult) {
|
if (finalResult) {
|
||||||
|
@ -2202,7 +2203,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
if (pDbPrefixToken->type != 0) {
|
if (pDbPrefixToken->type != 0) {
|
||||||
assert(pDbPrefixToken->n >= 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);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2229,7 +2230,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCmd->payloadLen > TSDB_TABLE_NAME_LEN) {
|
if (pCmd->payloadLen >= TSDB_TABLE_NAME_LEN) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3997,7 +3998,7 @@ int32_t tsRewriteFieldNameIfNecessary(SQueryInfo* pQueryInfo) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||||
char* fieldName = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i)->name;
|
char* fieldName = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i)->name;
|
||||||
for (int32_t j = 0; j < TSDB_COL_NAME_LEN && fieldName[j] != 0; ++j) {
|
for (int32_t j = 0; j < (TSDB_COL_NAME_LEN - 1) && fieldName[j] != 0; ++j) {
|
||||||
for (int32_t k = 0; k < tListLen(rep); ++k) {
|
for (int32_t k = 0; k < tListLen(rep); ++k) {
|
||||||
if (fieldName[j] == rep[k]) {
|
if (fieldName[j] == rep[k]) {
|
||||||
fieldName[j] = '_';
|
fieldName[j] = '_';
|
||||||
|
@ -4013,7 +4014,7 @@ int32_t tsRewriteFieldNameIfNecessary(SQueryInfo* pQueryInfo) {
|
||||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||||
char* fieldName = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i)->name;
|
char* fieldName = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i)->name;
|
||||||
for (int32_t j = i + 1; j < pQueryInfo->fieldsInfo.numOfOutput; ++j) {
|
for (int32_t j = i + 1; j < pQueryInfo->fieldsInfo.numOfOutput; ++j) {
|
||||||
if (strncasecmp(fieldName, tscFieldInfoGetField(&pQueryInfo->fieldsInfo, j)->name, TSDB_COL_NAME_LEN) == 0) {
|
if (strncasecmp(fieldName, tscFieldInfoGetField(&pQueryInfo->fieldsInfo, j)->name, (TSDB_COL_NAME_LEN - 1)) == 0) {
|
||||||
const char* msg = "duplicated column name in new table";
|
const char* msg = "duplicated column name in new table";
|
||||||
return invalidSqlErrMsg(pQueryInfo->msg, msg);
|
return invalidSqlErrMsg(pQueryInfo->msg, msg);
|
||||||
}
|
}
|
||||||
|
@ -4368,7 +4369,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tVariantListItem* pItem = &pAlterSQL->varList->a[0];
|
tVariantListItem* pItem = &pAlterSQL->varList->a[0];
|
||||||
if (pItem->pVar.nLen > TSDB_COL_NAME_LEN) {
|
if (pItem->pVar.nLen >= TSDB_COL_NAME_LEN) {
|
||||||
return invalidSqlErrMsg(pQueryInfo->msg, msg9);
|
return invalidSqlErrMsg(pQueryInfo->msg, msg9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4420,7 +4421,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char name[TSDB_COL_NAME_LEN + 1] = {0};
|
char name[TSDB_COL_NAME_LEN] = {0};
|
||||||
strncpy(name, pVarList->a[0].pVar.pz, pVarList->a[0].pVar.nLen);
|
strncpy(name, pVarList->a[0].pVar.pz, pVarList->a[0].pVar.nLen);
|
||||||
TAOS_FIELD f = tscCreateField(TSDB_DATA_TYPE_INT, name, tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize);
|
TAOS_FIELD f = tscCreateField(TSDB_DATA_TYPE_INT, name, tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize);
|
||||||
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||||
|
@ -4522,8 +4523,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
return invalidSqlErrMsg(pQueryInfo->msg, msg18);
|
return invalidSqlErrMsg(pQueryInfo->msg, msg18);
|
||||||
}
|
}
|
||||||
|
|
||||||
char name1[TSDB_COL_NAME_LEN + 1] = {0};
|
char name1[TSDB_COL_NAME_LEN] = {0};
|
||||||
strncpy(name1, pItem->pVar.pz, pItem->pVar.nLen);
|
tstrncpy(name1, pItem->pVar.pz, sizeof(name1));
|
||||||
TAOS_FIELD f = tscCreateField(TSDB_DATA_TYPE_INT, name1, tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize);
|
TAOS_FIELD f = tscCreateField(TSDB_DATA_TYPE_INT, name1, tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize);
|
||||||
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||||
}
|
}
|
||||||
|
@ -5232,7 +5233,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SQueryInfo* pQueryInfo) {
|
||||||
int16_t colIndex = pColIndex->colIndex;
|
int16_t colIndex = pColIndex->colIndex;
|
||||||
if (colIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
if (colIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
type = TSDB_DATA_TYPE_BINARY;
|
type = TSDB_DATA_TYPE_BINARY;
|
||||||
bytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE; // todo extract method
|
bytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE; // todo extract method
|
||||||
name = TSQL_TBNAME_L;
|
name = TSQL_TBNAME_L;
|
||||||
} else {
|
} else {
|
||||||
if (TSDB_COL_IS_TAG(pColIndex->flag)) {
|
if (TSDB_COL_IS_TAG(pColIndex->flag)) {
|
||||||
|
@ -5254,8 +5255,8 @@ static int32_t doAddGroupbyColumnsOnDemand(SQueryInfo* pQueryInfo) {
|
||||||
SColumnIndex index = {.tableIndex = pQueryInfo->groupbyExpr.tableIndex, .columnIndex = colIndex};
|
SColumnIndex index = {.tableIndex = pQueryInfo->groupbyExpr.tableIndex, .columnIndex = colIndex};
|
||||||
SSqlExpr* pExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TAG, &index, type, bytes, bytes, true);
|
SSqlExpr* pExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TAG, &index, type, bytes, bytes, true);
|
||||||
|
|
||||||
memset(pExpr->aliasName, 0, tListLen(pExpr->aliasName));
|
memset(pExpr->aliasName, 0, sizeof(pExpr->aliasName));
|
||||||
strncpy(pExpr->aliasName, name, TSDB_COL_NAME_LEN);
|
tstrncpy(pExpr->aliasName, name, sizeof(pExpr->aliasName));
|
||||||
|
|
||||||
pExpr->colInfo.flag = TSDB_COL_TAG;
|
pExpr->colInfo.flag = TSDB_COL_TAG;
|
||||||
|
|
||||||
|
@ -6019,7 +6020,7 @@ int32_t exprTreeFromSqlExpr(tExprNode **pExpr, const tSQLExpr* pSqlExpr, SArray*
|
||||||
|
|
||||||
if (pCols != NULL) { // record the involved columns
|
if (pCols != NULL) { // record the involved columns
|
||||||
SColIndex colIndex = {0};
|
SColIndex colIndex = {0};
|
||||||
strncpy(colIndex.name, pSchema->name, TSDB_COL_NAME_LEN);
|
tstrncpy(colIndex.name, pSchema->name, sizeof(colIndex.name));
|
||||||
colIndex.colId = pSchema->colId;
|
colIndex.colId = pSchema->colId;
|
||||||
colIndex.colIndex = index.columnIndex;
|
colIndex.colIndex = index.columnIndex;
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols) {
|
||||||
|
|
||||||
// 3. valid column names
|
// 3. valid column names
|
||||||
for (int32_t j = i + 1; j < numOfCols; ++j) {
|
for (int32_t j = i + 1; j < numOfCols; ++j) {
|
||||||
if (strncasecmp(pSchema[i].name, pSchema[j].name, TSDB_COL_NAME_LEN) == 0) {
|
if (strncasecmp(pSchema[i].name, pSchema[j].name, sizeof(pSchema[i].name) - 1) == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -866,7 +866,7 @@ int32_t tscBuildCreateDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
assert(pCmd->numOfClause == 1);
|
assert(pCmd->numOfClause == 1);
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
strncpy(pCreateDbMsg->db, pTableMetaInfo->name, tListLen(pCreateDbMsg->db));
|
tstrncpy(pCreateDbMsg->db, pTableMetaInfo->name, sizeof(pCreateDbMsg->db));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1430,9 +1430,9 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
char *db; // ugly code to move the space
|
char *db; // ugly code to move the space
|
||||||
db = strstr(pObj->db, TS_PATH_DELIMITER);
|
db = strstr(pObj->db, TS_PATH_DELIMITER);
|
||||||
db = (db == NULL) ? pObj->db : db + 1;
|
db = (db == NULL) ? pObj->db : db + 1;
|
||||||
strcpy(pConnect->db, db);
|
tstrncpy(pConnect->db, db, sizeof(pConnect->db));
|
||||||
strcpy(pConnect->clientVersion, version);
|
tstrncpy(pConnect->clientVersion, version, sizeof(pConnect->clientVersion));
|
||||||
strcpy(pConnect->msgVersion, "");
|
tstrncpy(pConnect->msgVersion, "", sizeof(pConnect->msgVersion));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2153,8 +2153,8 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
|
||||||
strcpy(pObj->acctId, pConnect->acctId); // copy acctId from response
|
strcpy(pObj->acctId, pConnect->acctId); // copy acctId from response
|
||||||
int32_t len = sprintf(temp, "%s%s%s", pObj->acctId, TS_PATH_DELIMITER, pObj->db);
|
int32_t len = sprintf(temp, "%s%s%s", pObj->acctId, TS_PATH_DELIMITER, pObj->db);
|
||||||
|
|
||||||
assert(len <= tListLen(pObj->db));
|
assert(len <= sizeof(pObj->db));
|
||||||
strncpy(pObj->db, temp, tListLen(pObj->db));
|
tstrncpy(pObj->db, temp, sizeof(pObj->db));
|
||||||
|
|
||||||
if (pConnect->ipList.numOfIps > 0)
|
if (pConnect->ipList.numOfIps > 0)
|
||||||
tscSetMgmtIpList(&pConnect->ipList);
|
tscSetMgmtIpList(&pConnect->ipList);
|
||||||
|
@ -2338,7 +2338,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
|
||||||
STableMetaInfo *pNewMeterMetaInfo = tscAddEmptyMetaInfo(pNewQueryInfo);
|
STableMetaInfo *pNewMeterMetaInfo = tscAddEmptyMetaInfo(pNewQueryInfo);
|
||||||
assert(pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1);
|
assert(pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1);
|
||||||
|
|
||||||
strncpy(pNewMeterMetaInfo->name, pTableMetaInfo->name, tListLen(pNewMeterMetaInfo->name));
|
tstrncpy(pNewMeterMetaInfo->name, pTableMetaInfo->name, sizeof(pNewMeterMetaInfo->name));
|
||||||
memcpy(pNew->cmd.payload, pSql->cmd.payload, pSql->cmd.payloadLen); // tag information if table does not exists.
|
memcpy(pNew->cmd.payload, pSql->cmd.payload, pSql->cmd.payloadLen); // tag information if table does not exists.
|
||||||
pNew->cmd.payloadLen = pSql->cmd.payloadLen;
|
pNew->cmd.payloadLen = pSql->cmd.payloadLen;
|
||||||
tscTrace("%p new pSqlObj:%p to get tableMeta, auto create:%d", pSql, pNew, pNew->cmd.autoCreated);
|
tscTrace("%p new pSqlObj:%p to get tableMeta, auto create:%d", pSql, pNew, pNew->cmd.autoCreated);
|
||||||
|
|
|
@ -86,21 +86,21 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
|
||||||
|
|
||||||
pObj->signature = pObj;
|
pObj->signature = pObj;
|
||||||
|
|
||||||
strncpy(pObj->user, user, TSDB_USER_LEN);
|
tstrncpy(pObj->user, user, sizeof(pObj->user));
|
||||||
taosEncryptPass((uint8_t *)pass, strlen(pass), pObj->pass);
|
taosEncryptPass((uint8_t *)pass, strlen(pass), pObj->pass);
|
||||||
|
|
||||||
if (db) {
|
if (db) {
|
||||||
int32_t len = strlen(db);
|
int32_t len = strlen(db);
|
||||||
/* db name is too long */
|
/* db name is too long */
|
||||||
if (len > TSDB_DB_NAME_LEN) {
|
if (len >= TSDB_DB_NAME_LEN) {
|
||||||
terrno = TSDB_CODE_TSC_INVALID_DB_LENGTH;
|
terrno = TSDB_CODE_TSC_INVALID_DB_LENGTH;
|
||||||
rpcClose(pDnodeConn);
|
rpcClose(pDnodeConn);
|
||||||
free(pObj);
|
free(pObj);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char tmp[TSDB_DB_NAME_LEN + 1] = {0};
|
char tmp[TSDB_DB_NAME_LEN] = {0};
|
||||||
strcpy(tmp, db);
|
tstrncpy(tmp, db, sizeof(tmp));
|
||||||
|
|
||||||
strdequote(tmp);
|
strdequote(tmp);
|
||||||
strtolower(pObj->db, tmp);
|
strtolower(pObj->db, tmp);
|
||||||
|
|
|
@ -1921,7 +1921,7 @@ static char *getArithemicInputSrc(void *param, const char *name, int32_t colId)
|
||||||
|
|
||||||
for (int32_t i = 0; i < pSupport->numOfCols; ++i) {
|
for (int32_t i = 0; i < pSupport->numOfCols; ++i) {
|
||||||
pExpr = taosArrayGetP(pSupport->exprList, i);
|
pExpr = taosArrayGetP(pSupport->exprList, i);
|
||||||
if (strncmp(name, pExpr->aliasName, TSDB_COL_NAME_LEN) == 0) {
|
if (strncmp(name, pExpr->aliasName, sizeof(pExpr->aliasName) - 1) == 0) {
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
||||||
assert(cfg != NULL);
|
assert(cfg != NULL);
|
||||||
|
|
||||||
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
|
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
|
||||||
strncpy(configDir, pStr, TSDB_FILENAME_LEN);
|
tstrncpy(configDir, pStr, TSDB_FILENAME_LEN);
|
||||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||||
tscPrint("set config file directory:%s", pStr);
|
tscPrint("set config file directory:%s", pStr);
|
||||||
} else {
|
} else {
|
||||||
|
@ -234,7 +234,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
||||||
tscPrint("failed to set locale:%s, current locale:%s", pStr, tsLocale);
|
tscPrint("failed to set locale:%s, current locale:%s", pStr, tsLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(tsLocale, locale, tListLen(tsLocale));
|
tstrncpy(tsLocale, locale, sizeof(tsLocale));
|
||||||
|
|
||||||
char *charset = strrchr(tsLocale, sep);
|
char *charset = strrchr(tsLocale, sep);
|
||||||
if (charset != NULL) {
|
if (charset != NULL) {
|
||||||
|
@ -249,7 +249,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
||||||
tscPrint("charset changed from %s to %s", tsCharset, charset);
|
tscPrint("charset changed from %s to %s", tsCharset, charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(tsCharset, charset, tListLen(tsCharset));
|
tstrncpy(tsCharset, charset, sizeof(tsCharset));
|
||||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -286,7 +286,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
||||||
tscPrint("charset changed from %s to %s", tsCharset, pStr);
|
tscPrint("charset changed from %s to %s", tsCharset, pStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(tsCharset, pStr, tListLen(tsCharset));
|
tstrncpy(tsCharset, pStr, sizeof(tsCharset));
|
||||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||||
} else {
|
} else {
|
||||||
tscPrint("charset:%s not valid", pStr);
|
tscPrint("charset:%s not valid", pStr);
|
||||||
|
@ -324,7 +324,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
||||||
// return -1;
|
// return -1;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
strncpy(tsSocketType, pStr, tListLen(tsSocketType));
|
tstrncpy(tsSocketType, pStr, sizeof(tsSocketType));
|
||||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||||
tscPrint("socket type is set:%s", tsSocketType);
|
tscPrint("socket type is set:%s", tsSocketType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -801,7 +801,7 @@ int tscAllocPayload(SSqlCmd* pCmd, int size) {
|
||||||
|
|
||||||
TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes) {
|
TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes) {
|
||||||
TAOS_FIELD f = { .type = type, .bytes = bytes, };
|
TAOS_FIELD f = { .type = type, .bytes = bytes, };
|
||||||
strncpy(f.name, name, TSDB_COL_NAME_LEN);
|
tstrncpy(f.name, name, sizeof(f.name));
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -966,12 +966,12 @@ static SSqlExpr* doBuildSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SCol
|
||||||
if (isTagCol) {
|
if (isTagCol) {
|
||||||
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
|
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
|
||||||
pExpr->colInfo.colId = pSchema[pColIndex->columnIndex].colId;
|
pExpr->colInfo.colId = pSchema[pColIndex->columnIndex].colId;
|
||||||
strncpy(pExpr->colInfo.name, pSchema[pColIndex->columnIndex].name, TSDB_COL_NAME_LEN);
|
tstrncpy(pExpr->colInfo.name, pSchema[pColIndex->columnIndex].name, sizeof(pExpr->colInfo.name));
|
||||||
} else if (pTableMetaInfo->pTableMeta != NULL) {
|
} else if (pTableMetaInfo->pTableMeta != NULL) {
|
||||||
// in handling select database/version/server_status(), the pTableMeta is NULL
|
// in handling select database/version/server_status(), the pTableMeta is NULL
|
||||||
SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pColIndex->columnIndex);
|
SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pColIndex->columnIndex);
|
||||||
pExpr->colInfo.colId = pSchema->colId;
|
pExpr->colInfo.colId = pSchema->colId;
|
||||||
strncpy(pExpr->colInfo.name, pSchema->name, TSDB_COL_NAME_LEN);
|
tstrncpy(pExpr->colInfo.name, pSchema->name, sizeof(pExpr->colInfo.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -708,7 +708,7 @@ static void doInitGlobalConfig() {
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
|
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
|
||||||
cfg.minValue = 0;
|
cfg.minValue = 0;
|
||||||
cfg.maxValue = 0;
|
cfg.maxValue = 0;
|
||||||
cfg.ptrLength = TSDB_DB_NAME_LEN;
|
cfg.ptrLength = TSDB_DB_NAME_LEN - 1;
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
taosInitConfigOption(cfg);
|
taosInitConfigOption(cfg);
|
||||||
|
|
||||||
|
@ -923,7 +923,7 @@ static void doInitGlobalConfig() {
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
||||||
cfg.minValue = 0;
|
cfg.minValue = 0;
|
||||||
cfg.maxValue = 0;
|
cfg.maxValue = 0;
|
||||||
cfg.ptrLength = TSDB_DB_NAME_LEN;
|
cfg.ptrLength = TSDB_DB_NAME_LEN - 1;
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
taosInitConfigOption(cfg);
|
taosInitConfigOption(cfg);
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,7 @@ void extractTableName(const char* tableId, char* name) {
|
||||||
size_t s1 = strcspn(tableId, &TS_PATH_DELIMITER[0]);
|
size_t s1 = strcspn(tableId, &TS_PATH_DELIMITER[0]);
|
||||||
size_t s2 = strcspn(&tableId[s1 + 1], &TS_PATH_DELIMITER[0]);
|
size_t s2 = strcspn(&tableId[s1 + 1], &TS_PATH_DELIMITER[0]);
|
||||||
|
|
||||||
strncpy(name, &tableId[s1 + s2 + 2], TSDB_TABLE_NAME_LEN);
|
tstrncpy(name, &tableId[s1 + s2 + 2], TSDB_TABLE_NAME_LEN);
|
||||||
name[TSDB_TABLE_NAME_LEN] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char* extractDBName(const char* tableId, char* name) {
|
char* extractDBName(const char* tableId, char* name) {
|
||||||
|
|
|
@ -130,9 +130,9 @@ _CONVERT_FUNC = {
|
||||||
|
|
||||||
# Corresponding TAOS_FIELD structure in C
|
# Corresponding TAOS_FIELD structure in C
|
||||||
class TaosField(ctypes.Structure):
|
class TaosField(ctypes.Structure):
|
||||||
_fields_ = [('name', ctypes.c_char * 64),
|
_fields_ = [('name', ctypes.c_char * 65),
|
||||||
('bytes', ctypes.c_short),
|
('type', ctypes.c_char),
|
||||||
('type', ctypes.c_char)]
|
('bytes', ctypes.c_short)]
|
||||||
|
|
||||||
# C interface class
|
# C interface class
|
||||||
class CTaosInterface(object):
|
class CTaosInterface(object):
|
||||||
|
|
|
@ -53,9 +53,9 @@ typedef enum {
|
||||||
} TSDB_OPTION;
|
} TSDB_OPTION;
|
||||||
|
|
||||||
typedef struct taosField {
|
typedef struct taosField {
|
||||||
char name[64];
|
char name[65];
|
||||||
short bytes;
|
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
|
short bytes;
|
||||||
} TAOS_FIELD;
|
} TAOS_FIELD;
|
||||||
|
|
||||||
#ifdef _TD_GO_DLL_
|
#ifdef _TD_GO_DLL_
|
||||||
|
|
|
@ -189,7 +189,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
|
||||||
#define TSDB_USERID_LEN 9
|
#define TSDB_USERID_LEN 9
|
||||||
#define TS_PATH_DELIMITER_LEN 1
|
#define TS_PATH_DELIMITER_LEN 1
|
||||||
|
|
||||||
#define TSDB_METER_ID_LEN_MARGIN 10
|
#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_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_UNI_LEN 24
|
||||||
#define TSDB_USER_LEN TSDB_UNI_LEN
|
#define TSDB_USER_LEN TSDB_UNI_LEN
|
||||||
|
@ -200,9 +200,9 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
|
||||||
#define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns
|
#define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns
|
||||||
|
|
||||||
#define TSDB_NODE_NAME_LEN 64
|
#define TSDB_NODE_NAME_LEN 64
|
||||||
#define TSDB_TABLE_NAME_LEN 192
|
#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_COL_NAME_LEN 65
|
||||||
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
|
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
|
||||||
#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE
|
#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE
|
||||||
#define TSDB_MAX_SQL_SHOW_LEN 256
|
#define TSDB_MAX_SQL_SHOW_LEN 256
|
||||||
|
|
|
@ -224,7 +224,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct SSchema {
|
typedef struct SSchema {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
char name[TSDB_COL_NAME_LEN + 1];
|
char name[TSDB_COL_NAME_LEN];
|
||||||
int16_t colId;
|
int16_t colId;
|
||||||
int16_t bytes;
|
int16_t bytes;
|
||||||
} SSchema;
|
} SSchema;
|
||||||
|
@ -250,7 +250,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char tableId[TSDB_TABLE_ID_LEN + 1];
|
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 igExists;
|
||||||
int8_t getMeta;
|
int8_t getMeta;
|
||||||
int16_t numOfTags;
|
int16_t numOfTags;
|
||||||
|
@ -268,7 +268,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char tableId[TSDB_TABLE_ID_LEN + 1];
|
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 type; /* operation type */
|
||||||
int16_t numOfCols; /* number of schema */
|
int16_t numOfCols; /* number of schema */
|
||||||
int32_t tagValLen;
|
int32_t tagValLen;
|
||||||
|
@ -502,7 +502,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char acct[TSDB_USER_LEN + 1];
|
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 cacheBlockSize; //MB
|
||||||
int32_t totalBlocks;
|
int32_t totalBlocks;
|
||||||
int32_t maxTables;
|
int32_t maxTables;
|
||||||
|
@ -606,7 +606,7 @@ typedef struct {
|
||||||
} SMDVnodeDesc;
|
} SMDVnodeDesc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char db[TSDB_DB_NAME_LEN + 1];
|
char db[TSDB_DB_NAME_LEN];
|
||||||
SMDVnodeCfg cfg;
|
SMDVnodeCfg cfg;
|
||||||
SMDVnodeDesc nodes[TSDB_MAX_REPLICA];
|
SMDVnodeDesc nodes[TSDB_MAX_REPLICA];
|
||||||
} SMDCreateVnodeMsg;
|
} SMDCreateVnodeMsg;
|
||||||
|
@ -671,7 +671,7 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
char db[TSDB_DB_NAME_LEN + 1];
|
char db[TSDB_DB_NAME_LEN];
|
||||||
uint16_t payloadLen;
|
uint16_t payloadLen;
|
||||||
char payload[];
|
char payload[];
|
||||||
} SCMShowMsg;
|
} SCMShowMsg;
|
||||||
|
|
|
@ -88,21 +88,21 @@ enum _describe_table_index {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char field[TSDB_COL_NAME_LEN + 1];
|
char field[TSDB_COL_NAME_LEN];
|
||||||
char type[16];
|
char type[16];
|
||||||
int length;
|
int length;
|
||||||
char note[128];
|
char note[128];
|
||||||
} SColDes;
|
} SColDes;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_COL_NAME_LEN + 1];
|
char name[TSDB_COL_NAME_LEN];
|
||||||
SColDes cols[];
|
SColDes cols[];
|
||||||
} STableDef;
|
} STableDef;
|
||||||
|
|
||||||
extern char version[];
|
extern char version[];
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_DB_NAME_LEN + 1];
|
char name[TSDB_DB_NAME_LEN];
|
||||||
int32_t replica;
|
int32_t replica;
|
||||||
int32_t days;
|
int32_t days;
|
||||||
int32_t keep;
|
int32_t keep;
|
||||||
|
|
|
@ -115,7 +115,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct SVgObj {
|
typedef struct SVgObj {
|
||||||
uint32_t vgId;
|
uint32_t vgId;
|
||||||
char dbName[TSDB_DB_NAME_LEN + 1];
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
SVnodeGid vnodeGid[TSDB_MAX_REPLICA];
|
SVnodeGid vnodeGid[TSDB_MAX_REPLICA];
|
||||||
int32_t numOfVnodes;
|
int32_t numOfVnodes;
|
||||||
|
@ -154,7 +154,7 @@ typedef struct {
|
||||||
} SDbCfg;
|
} SDbCfg;
|
||||||
|
|
||||||
typedef struct SDbObj {
|
typedef struct SDbObj {
|
||||||
char name[TSDB_DB_NAME_LEN + 1];
|
char name[TSDB_DB_NAME_LEN];
|
||||||
char acct[TSDB_USER_LEN + 1];
|
char acct[TSDB_USER_LEN + 1];
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
int32_t cfgVersion;
|
int32_t cfgVersion;
|
||||||
|
@ -219,7 +219,7 @@ typedef struct SAcctObj {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
int32_t index;
|
int32_t index;
|
||||||
char db[TSDB_DB_NAME_LEN + 1];
|
char db[TSDB_DB_NAME_LEN];
|
||||||
void * pIter;
|
void * pIter;
|
||||||
int16_t numOfColumns;
|
int16_t numOfColumns;
|
||||||
int32_t rowSize;
|
int32_t rowSize;
|
||||||
|
|
|
@ -328,8 +328,8 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
|
||||||
if (code != 0) return code;
|
if (code != 0) return code;
|
||||||
|
|
||||||
pDb = calloc(1, sizeof(SDbObj));
|
pDb = calloc(1, sizeof(SDbObj));
|
||||||
strncpy(pDb->name, pCreate->db, TSDB_DB_NAME_LEN);
|
tstrncpy(pDb->name, pCreate->db, sizeof(pDb->name));
|
||||||
strncpy(pDb->acct, pAcct->user, TSDB_USER_LEN);
|
tstrncpy(pDb->acct, pAcct->user, sizeof(pDb->acct));
|
||||||
pDb->createdTime = taosGetTimestampMs();
|
pDb->createdTime = taosGetTimestampMs();
|
||||||
pDb->cfg = (SDbCfg) {
|
pDb->cfg = (SDbCfg) {
|
||||||
.cacheBlockSize = pCreate->cacheBlockSize,
|
.cacheBlockSize = pCreate->cacheBlockSize,
|
||||||
|
@ -373,7 +373,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mnodeCheckIsMonitorDB(char *db, char *monitordb) {
|
bool mnodeCheckIsMonitorDB(char *db, char *monitordb) {
|
||||||
char dbName[TSDB_DB_NAME_LEN + 1] = {0};
|
char dbName[TSDB_DB_NAME_LEN] = {0};
|
||||||
extractDBName(db, dbName);
|
extractDBName(db, dbName);
|
||||||
|
|
||||||
size_t len = strlen(dbName);
|
size_t len = strlen(dbName);
|
||||||
|
@ -453,7 +453,7 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
|
||||||
SUserObj *pUser = mnodeGetUserFromConn(pConn);
|
SUserObj *pUser = mnodeGetUserFromConn(pConn);
|
||||||
if (pUser == NULL) return 0;
|
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;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "name");
|
strcpy(pSchema[cols].name, "name");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
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;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
|
||||||
char* name = mnodeGetDbStr(pDb->name);
|
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++;
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
|
|
@ -43,7 +43,7 @@ typedef enum {
|
||||||
} ESdbStatus;
|
} ESdbStatus;
|
||||||
|
|
||||||
typedef struct _SSdbTable {
|
typedef struct _SSdbTable {
|
||||||
char tableName[TSDB_DB_NAME_LEN + 1];
|
char tableName[TSDB_DB_NAME_LEN];
|
||||||
ESdbTable tableId;
|
ESdbTable tableId;
|
||||||
ESdbKey keyType;
|
ESdbKey keyType;
|
||||||
int32_t hashSessions;
|
int32_t hashSessions;
|
||||||
|
|
|
@ -951,7 +951,7 @@ static int32_t mnodeModifySuperTableTagName(SSuperTableObj *pStable, char *oldTa
|
||||||
|
|
||||||
// update
|
// update
|
||||||
SSchema *schema = (SSchema *) (pStable->schema + pStable->numOfColumns + col);
|
SSchema *schema = (SSchema *) (pStable->schema + pStable->numOfColumns + col);
|
||||||
strncpy(schema->name, newTagName, TSDB_COL_NAME_LEN);
|
tstrncpy(schema->name, newTagName, sizeof(schema->name));
|
||||||
|
|
||||||
SSdbOper oper = {
|
SSdbOper oper = {
|
||||||
.type = SDB_OPER_GLOBAL,
|
.type = SDB_OPER_GLOBAL,
|
||||||
|
@ -1078,7 +1078,7 @@ static int32_t mnodeGetShowSuperTableMeta(STableMetaMsg *pMeta, SShowObj *pShow,
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
SSchema *pSchema = pMeta->schema;
|
SSchema *pSchema = pMeta->schema;
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
pShow->bytes[cols] = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "name");
|
strcpy(pSchema[cols].name, "name");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
|
@ -1138,7 +1138,7 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
|
||||||
prefixLen = strlen(prefix);
|
prefixLen = strlen(prefix);
|
||||||
|
|
||||||
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
||||||
char stableName[TSDB_TABLE_NAME_LEN + 1] = {0};
|
char stableName[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
pShow->pIter = mnodeGetNextSuperTable(pShow->pIter, &pTable);
|
pShow->pIter = mnodeGetNextSuperTable(pShow->pIter, &pTable);
|
||||||
|
@ -1151,7 +1151,7 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
|
||||||
memset(stableName, 0, tListLen(stableName));
|
memset(stableName, 0, tListLen(stableName));
|
||||||
mnodeExtractTableName(pTable->info.tableId, stableName);
|
mnodeExtractTableName(pTable->info.tableId, stableName);
|
||||||
|
|
||||||
if (pShow->payloadLen > 0 && patternMatch(pShow->payload, stableName, TSDB_TABLE_NAME_LEN, &info) != TSDB_PATTERN_MATCH) {
|
if (pShow->payloadLen > 0 && patternMatch(pShow->payload, stableName, sizeof(stableName) - 1, &info) != TSDB_PATTERN_MATCH) {
|
||||||
mnodeDecTableRef(pTable);
|
mnodeDecTableRef(pTable);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1160,7 +1160,7 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
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;
|
*(int16_t*) pWrite = len;
|
||||||
pWrite += sizeof(int16_t); // todo refactor
|
pWrite += sizeof(int16_t); // todo refactor
|
||||||
|
|
||||||
|
@ -1228,7 +1228,7 @@ static int32_t mnodeSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pT
|
||||||
assert(numOfCols <= TSDB_MAX_COLUMNS);
|
assert(numOfCols <= TSDB_MAX_COLUMNS);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
strncpy(pSchema->name, pTable->schema[i].name, TSDB_COL_NAME_LEN);
|
tstrncpy(pSchema->name, pTable->schema[i].name, sizeof(pSchema->name));
|
||||||
pSchema->type = pTable->schema[i].type;
|
pSchema->type = pTable->schema[i].type;
|
||||||
pSchema->bytes = htons(pTable->schema[i].bytes);
|
pSchema->bytes = htons(pTable->schema[i].bytes);
|
||||||
pSchema->colId = htons(pTable->schema[i].colId);
|
pSchema->colId = htons(pTable->schema[i].colId);
|
||||||
|
@ -2079,7 +2079,7 @@ static int32_t mnodeGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
SSchema *pSchema = pMeta->schema;
|
SSchema *pSchema = pMeta->schema;
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
pShow->bytes[cols] = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "table_name");
|
strcpy(pSchema[cols].name, "table_name");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
|
@ -2097,7 +2097,7 @@ static int32_t mnodeGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
pShow->bytes[cols] = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "stable_name");
|
strcpy(pSchema[cols].name, "stable_name");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
|
@ -2141,12 +2141,12 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char tableName[TSDB_TABLE_NAME_LEN + 1] = {0};
|
char tableName[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
|
|
||||||
// pattern compare for table name
|
// pattern compare for table name
|
||||||
mnodeExtractTableName(pTable->info.tableId, tableName);
|
mnodeExtractTableName(pTable->info.tableId, tableName);
|
||||||
|
|
||||||
if (pShow->payloadLen > 0 && patternMatch(pShow->payload, tableName, TSDB_TABLE_NAME_LEN, &info) != TSDB_PATTERN_MATCH) {
|
if (pShow->payloadLen > 0 && patternMatch(pShow->payload, tableName, sizeof(tableName) - 1, &info) != TSDB_PATTERN_MATCH) {
|
||||||
mnodeDecTableRef(pTable);
|
mnodeDecTableRef(pTable);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2155,7 +2155,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
|
||||||
|
|
||||||
char *pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
char *pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, tableName, TSDB_TABLE_NAME_LEN);
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, tableName, sizeof(tableName) - 1);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
@ -2173,10 +2173,10 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
|
||||||
memset(tableName, 0, tListLen(tableName));
|
memset(tableName, 0, sizeof(tableName));
|
||||||
if (pTable->info.type == TSDB_CHILD_TABLE) {
|
if (pTable->info.type == TSDB_CHILD_TABLE) {
|
||||||
mnodeExtractTableName(pTable->superTable->info.tableId, tableName);
|
mnodeExtractTableName(pTable->superTable->info.tableId, tableName);
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, tableName, TSDB_TABLE_NAME_LEN);
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, tableName, sizeof(tableName) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cols++;
|
cols++;
|
||||||
|
@ -2268,7 +2268,7 @@ static int32_t mnodeGetStreamTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, vo
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
SSchema *pSchema = pMeta->schema;
|
SSchema *pSchema = pMeta->schema;
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
pShow->bytes[cols] = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "table_name");
|
strcpy(pSchema[cols].name, "table_name");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
|
@ -2331,12 +2331,12 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char tableName[TSDB_TABLE_NAME_LEN + 1] = {0};
|
char tableName[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
|
|
||||||
// pattern compare for table name
|
// pattern compare for table name
|
||||||
mnodeExtractTableName(pTable->info.tableId, tableName);
|
mnodeExtractTableName(pTable->info.tableId, tableName);
|
||||||
|
|
||||||
if (pShow->payloadLen > 0 && patternMatch(pShow->payload, tableName, TSDB_TABLE_NAME_LEN, &info) != TSDB_PATTERN_MATCH) {
|
if (pShow->payloadLen > 0 && patternMatch(pShow->payload, tableName, sizeof(tableName) - 1, &info) != TSDB_PATTERN_MATCH) {
|
||||||
mnodeDecTableRef(pTable);
|
mnodeDecTableRef(pTable);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2345,7 +2345,7 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro
|
||||||
|
|
||||||
char *pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
char *pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, tableName, TSDB_TABLE_NAME_LEN);
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, tableName, sizeof(tableName) - 1);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
|
|
@ -189,7 +189,7 @@ void taosGetSystemLocale() {
|
||||||
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
|
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
|
||||||
char *locale = setlocale(LC_CTYPE, "chs");
|
char *locale = setlocale(LC_CTYPE, "chs");
|
||||||
if (locale != NULL) {
|
if (locale != NULL) {
|
||||||
strncpy(tsLocale, locale, sizeof(tsLocale) / sizeof(tsLocale[0]));
|
tstrncpy(tsLocale, locale, sizeof(tsLocale));
|
||||||
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
|
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
|
||||||
uPrint("locale not configured, set to default:%s", tsLocale);
|
uPrint("locale not configured, set to default:%s", tsLocale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,7 @@ static void taosGetSystemLocale() { // get and set default locale
|
||||||
uError("can't get locale from system, set it to en_US.UTF-8");
|
uError("can't get locale from system, set it to en_US.UTF-8");
|
||||||
strcpy(tsLocale, "en_US.UTF-8");
|
strcpy(tsLocale, "en_US.UTF-8");
|
||||||
} else {
|
} else {
|
||||||
tstrncpy(tsLocale, locale, tListLen(tsLocale));
|
tstrncpy(tsLocale, locale, sizeof(tsLocale));
|
||||||
uError("locale not configured, set to system default:%s", tsLocale);
|
uError("locale not configured, set to system default:%s", tsLocale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ static void taosGetSystemLocale() { // get and set default locale
|
||||||
str++;
|
str++;
|
||||||
|
|
||||||
char *revisedCharset = taosCharsetReplace(str);
|
char *revisedCharset = taosCharsetReplace(str);
|
||||||
strncpy(tsCharset, revisedCharset, tListLen(tsCharset));
|
tstrncpy(tsCharset, revisedCharset, sizeof(tsCharset));
|
||||||
|
|
||||||
free(revisedCharset);
|
free(revisedCharset);
|
||||||
uWarn("charset not configured, set to system default:%s", tsCharset);
|
uWarn("charset not configured, set to system default:%s", tsCharset);
|
||||||
|
|
|
@ -226,7 +226,7 @@ void taosGetSystemLocale() {
|
||||||
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
|
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
|
||||||
char *locale = setlocale(LC_CTYPE, "chs");
|
char *locale = setlocale(LC_CTYPE, "chs");
|
||||||
if (locale != NULL) {
|
if (locale != NULL) {
|
||||||
strncpy(tsLocale, locale, sizeof(tsLocale) / sizeof(tsLocale[0]));
|
tstrncpy(tsLocale, locale, sizeof(tsLocale));
|
||||||
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
|
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
|
||||||
uPrint("locale not configured, set to default:%s", tsLocale);
|
uPrint("locale not configured, set to default:%s", tsLocale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,7 +307,7 @@ void httpTrimTableName(char *name) {
|
||||||
for (int i = 0; name[i] != 0; i++) {
|
for (int i = 0; name[i] != 0; i++) {
|
||||||
if (name[i] == ' ' || name[i] == ':' || name[i] == '.' || name[i] == '-' || name[i] == '/' || name[i] == '\'')
|
if (name[i] == ' ' || name[i] == ':' || name[i] == '.' || name[i] == '-' || name[i] == '/' || name[i] == '\'')
|
||||||
name[i] = '_';
|
name[i] = '_';
|
||||||
if (i == TSDB_TABLE_NAME_LEN + 1) {
|
if (i == TSDB_TABLE_NAME_LEN) {
|
||||||
name[i] = 0;
|
name[i] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ int httpShrinkTableName(HttpContext *pContext, int pos, char *name) {
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len < TSDB_TABLE_NAME_LEN) {
|
if (len < TSDB_TABLE_NAME_LEN - 1) {
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ void tgParseSchemaMetric(cJSON *metric) {
|
||||||
goto ParseEnd;
|
goto ParseEnd;
|
||||||
}
|
}
|
||||||
int nameLen = (int)strlen(field->valuestring);
|
int nameLen = (int)strlen(field->valuestring);
|
||||||
if (nameLen == 0 || nameLen > TSDB_TABLE_NAME_LEN) {
|
if (nameLen == 0 || nameLen >= TSDB_TABLE_NAME_LEN) {
|
||||||
parsedOk = false;
|
parsedOk = false;
|
||||||
goto ParseEnd;
|
goto ParseEnd;
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
|
||||||
httpSendErrorResp(pContext, HTTP_TG_METRIC_NAME_NULL);
|
httpSendErrorResp(pContext, HTTP_TG_METRIC_NAME_NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (nameLen >= TSDB_TABLE_NAME_LEN - 7) {
|
if (nameLen >= TSDB_TABLE_NAME_LEN - 8) {
|
||||||
httpSendErrorResp(pContext, HTTP_TG_METRIC_NAME_LONG);
|
httpSendErrorResp(pContext, HTTP_TG_METRIC_NAME_LONG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(host->valuestring) >= TSDB_TABLE_NAME_LEN) {
|
if (strlen(host->valuestring) >= TSDB_TABLE_NAME_LEN - 1) {
|
||||||
httpSendErrorResp(pContext, HTTP_TG_TABLE_SIZE);
|
httpSendErrorResp(pContext, HTTP_TG_TABLE_SIZE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1368,7 +1368,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order
|
||||||
int32_t index = pSqlFuncMsg->colInfo.colIndex;
|
int32_t index = pSqlFuncMsg->colInfo.colIndex;
|
||||||
if (TSDB_COL_IS_TAG(pIndex->flag)) {
|
if (TSDB_COL_IS_TAG(pIndex->flag)) {
|
||||||
if (pIndex->colId == TSDB_TBNAME_COLUMN_INDEX) { // todo refactor
|
if (pIndex->colId == TSDB_TBNAME_COLUMN_INDEX) { // todo refactor
|
||||||
pCtx->inputBytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
pCtx->inputBytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||||
pCtx->inputType = TSDB_DATA_TYPE_BINARY;
|
pCtx->inputType = TSDB_DATA_TYPE_BINARY;
|
||||||
} else {
|
} else {
|
||||||
pCtx->inputBytes = pQuery->tagColList[index].bytes;
|
pCtx->inputBytes = pQuery->tagColList[index].bytes;
|
||||||
|
@ -5148,8 +5148,8 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
|
||||||
bytes = tDataTypeDesc[type].nSize;
|
bytes = tDataTypeDesc[type].nSize;
|
||||||
} else if (pExprs[i].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX && pExprs[i].base.functionId == TSDB_FUNC_TAGPRJ) { // parse the normal column
|
} else if (pExprs[i].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX && pExprs[i].base.functionId == TSDB_FUNC_TAGPRJ) { // parse the normal column
|
||||||
type = TSDB_DATA_TYPE_BINARY;
|
type = TSDB_DATA_TYPE_BINARY;
|
||||||
bytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
bytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||||
} else {
|
} else{
|
||||||
int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
|
int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
|
||||||
assert(j < pQueryMsg->numOfCols || j < pQueryMsg->numOfTags || j == TSDB_TBNAME_COLUMN_INDEX);
|
assert(j < pQueryMsg->numOfCols || j < pQueryMsg->numOfTags || j == TSDB_TBNAME_COLUMN_INDEX);
|
||||||
|
|
||||||
|
@ -6038,7 +6038,7 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
|
||||||
for(int32_t j = 0; j < pQuery->numOfOutput; ++j) {
|
for(int32_t j = 0; j < pQuery->numOfOutput; ++j) {
|
||||||
if (pExprInfo[j].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
if (pExprInfo[j].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
char* data = tsdbGetTableName(pQInfo->tsdb, &item->id);
|
char* data = tsdbGetTableName(pQInfo->tsdb, &item->id);
|
||||||
char* dst = pQuery->sdata[j]->data + count * (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE);
|
char* dst = pQuery->sdata[j]->data + count * ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE);
|
||||||
memcpy(dst, data, varDataTLen(data));
|
memcpy(dst, data, varDataTLen(data));
|
||||||
} else {// todo refactor
|
} else {// todo refactor
|
||||||
int16_t type = pExprInfo[j].type;
|
int16_t type = pExprInfo[j].type;
|
||||||
|
|
|
@ -138,7 +138,7 @@ static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken
|
||||||
memcpy(pNode->pSchema, &pSchema[i], sizeof(SSchema));
|
memcpy(pNode->pSchema, &pSchema[i], sizeof(SSchema));
|
||||||
} else {
|
} else {
|
||||||
pNode->pSchema->type = TSDB_DATA_TYPE_BINARY;
|
pNode->pSchema->type = TSDB_DATA_TYPE_BINARY;
|
||||||
pNode->pSchema->bytes = TSDB_TABLE_NAME_LEN;
|
pNode->pSchema->bytes = TSDB_TABLE_NAME_LEN - 1;
|
||||||
strcpy(pNode->pSchema->name, TSQL_TBNAME_L);
|
strcpy(pNode->pSchema->name, TSQL_TBNAME_L);
|
||||||
pNode->pSchema->colId = -1;
|
pNode->pSchema->colId = -1;
|
||||||
}
|
}
|
||||||
|
@ -1127,7 +1127,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
|
||||||
left->pSchema = pSchema;
|
left->pSchema = pSchema;
|
||||||
|
|
||||||
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
||||||
pSchema->bytes = TSDB_TABLE_NAME_LEN;
|
pSchema->bytes = TSDB_TABLE_NAME_LEN - 1;
|
||||||
strcpy(pSchema->name, TSQL_TBNAME_L);
|
strcpy(pSchema->name, TSQL_TBNAME_L);
|
||||||
pSchema->colId = -1;
|
pSchema->colId = -1;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(pTSBuf->path, path, PATH_MAX);
|
tstrncpy(pTSBuf->path, path, sizeof(pTSBuf->path));
|
||||||
|
|
||||||
pTSBuf->f = fopen(pTSBuf->path, "r+");
|
pTSBuf->f = fopen(pTSBuf->path, "r+");
|
||||||
if (pTSBuf->f == NULL) {
|
if (pTSBuf->f == NULL) {
|
||||||
|
|
|
@ -458,7 +458,7 @@ int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo) {
|
||||||
pInfo->clientPort = pConn->peerPort;
|
pInfo->clientPort = pConn->peerPort;
|
||||||
// pInfo->serverIp = pConn->destIp;
|
// pInfo->serverIp = pConn->destIp;
|
||||||
|
|
||||||
strncpy(pInfo->user, pConn->user, sizeof(pInfo->user));
|
tstrncpy(pInfo->user, pConn->user, sizeof(pInfo->user));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -334,7 +334,7 @@ static STable *tsdbNewTable(STableCfg *pCfg, bool isSuper) {
|
||||||
pTable->schema[0] = tdDupSchema(pCfg->schema);
|
pTable->schema[0] = tdDupSchema(pCfg->schema);
|
||||||
pTable->tagSchema = tdDupSchema(pCfg->tagSchema);
|
pTable->tagSchema = tdDupSchema(pCfg->tagSchema);
|
||||||
|
|
||||||
tsize = strnlen(pCfg->sname, TSDB_TABLE_NAME_LEN);
|
tsize = strnlen(pCfg->sname, TSDB_TABLE_NAME_LEN - 1);
|
||||||
pTable->name = calloc(1, tsize + VARSTR_HEADER_SIZE + 1);
|
pTable->name = calloc(1, tsize + VARSTR_HEADER_SIZE + 1);
|
||||||
if (pTable->name == NULL) {
|
if (pTable->name == NULL) {
|
||||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
@ -355,7 +355,7 @@ static STable *tsdbNewTable(STableCfg *pCfg, bool isSuper) {
|
||||||
pTable->tableId.tid = pCfg->tableId.tid;
|
pTable->tableId.tid = pCfg->tableId.tid;
|
||||||
pTable->lastKey = TSKEY_INITIAL_VAL;
|
pTable->lastKey = TSKEY_INITIAL_VAL;
|
||||||
|
|
||||||
tsize = strnlen(pCfg->name, TSDB_TABLE_NAME_LEN);
|
tsize = strnlen(pCfg->name, TSDB_TABLE_NAME_LEN - 1);
|
||||||
pTable->name = calloc(1, tsize + VARSTR_HEADER_SIZE + 1);
|
pTable->name = calloc(1, tsize + VARSTR_HEADER_SIZE + 1);
|
||||||
if (pTable->name == NULL) {
|
if (pTable->name == NULL) {
|
||||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -2011,7 +2011,7 @@ int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) {
|
||||||
f1 = (char*) pTable1->name;
|
f1 = (char*) pTable1->name;
|
||||||
f2 = (char*) pTable2->name;
|
f2 = (char*) pTable2->name;
|
||||||
type = TSDB_DATA_TYPE_BINARY;
|
type = TSDB_DATA_TYPE_BINARY;
|
||||||
bytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
bytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||||
} else {
|
} else {
|
||||||
STColumn* pCol = schemaColAt(pTableGroupSupp->pTagSchema, colIndex);
|
STColumn* pCol = schemaColAt(pTableGroupSupp->pTagSchema, colIndex);
|
||||||
bytes = pCol->bytes;
|
bytes = pCol->bytes;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
|
#include "tutil.h"
|
||||||
#include "tulog.h"
|
#include "tulog.h"
|
||||||
#include "tsched.h"
|
#include "tsched.h"
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
|
@ -62,8 +63,7 @@ void *taosInitScheduler(int queueSize, int numOfThreads, const char *label) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pSched->queueSize = queueSize;
|
pSched->queueSize = queueSize;
|
||||||
strncpy(pSched->label, label, sizeof(pSched->label)); // fix buffer overflow
|
tstrncpy(pSched->label, label, sizeof(pSched->label)); // fix buffer overflow
|
||||||
pSched->label[sizeof(pSched->label)-1] = '\0';
|
|
||||||
|
|
||||||
pSched->fullSlot = 0;
|
pSched->fullSlot = 0;
|
||||||
pSched->emptySlot = 0;
|
pSched->emptySlot = 0;
|
||||||
|
|
|
@ -552,8 +552,7 @@ void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* lab
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(ctrl->label, label, sizeof(ctrl->label));
|
tstrncpy(ctrl->label, label, sizeof(ctrl->label));
|
||||||
ctrl->label[sizeof(ctrl->label) - 1] = 0;
|
|
||||||
tmrTrace("%s timer controller is initialized, number of timer controllers: %d.", label, numOfTmrCtrl);
|
tmrTrace("%s timer controller is initialized, number of timer controllers: %d.", label, numOfTmrCtrl);
|
||||||
return ctrl;
|
return ctrl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -582,13 +582,13 @@ bool taosGetVersionNumber(char *versionStr, int *versionNubmer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taosCheckVersion(char *input_client_version, char *input_server_version, int comparedSegments) {
|
int taosCheckVersion(char *input_client_version, char *input_server_version, int comparedSegments) {
|
||||||
char client_version[64] = {0};
|
char client_version[TSDB_VERSION_LEN] = {0};
|
||||||
char server_version[64] = {0};
|
char server_version[TSDB_VERSION_LEN] = {0};
|
||||||
int clientVersionNumber[4] = {0};
|
int clientVersionNumber[4] = {0};
|
||||||
int serverVersionNumber[4] = {0};
|
int serverVersionNumber[4] = {0};
|
||||||
|
|
||||||
strcpy(client_version, input_client_version);
|
tstrncpy(client_version, input_client_version, sizeof(client_version));
|
||||||
strcpy(server_version, input_server_version);
|
tstrncpy(server_version, input_server_version, sizeof(server_version));
|
||||||
|
|
||||||
if (!taosGetVersionNumber(client_version, clientVersionNumber)) {
|
if (!taosGetVersionNumber(client_version, clientVersionNumber)) {
|
||||||
uError("invalid client version:%s", client_version);
|
uError("invalid client version:%s", client_version);
|
||||||
|
|
|
@ -51,7 +51,7 @@ typedef struct {
|
||||||
SSyncCfg syncCfg;
|
SSyncCfg syncCfg;
|
||||||
SWalCfg walCfg;
|
SWalCfg walCfg;
|
||||||
char *rootDir;
|
char *rootDir;
|
||||||
char db[TSDB_DB_NAME_LEN + 1];
|
char db[TSDB_DB_NAME_LEN];
|
||||||
} SVnodeObj;
|
} SVnodeObj;
|
||||||
|
|
||||||
int vnodeWriteToQueue(void *param, void *pHead, int type);
|
int vnodeWriteToQueue(void *param, void *pHead, int type);
|
||||||
|
|
|
@ -96,14 +96,14 @@ class TDTestCase:
|
||||||
tdLog.notice("table name max length is %d" % maxTableNameLen)
|
tdLog.notice("table name max length is %d" % maxTableNameLen)
|
||||||
|
|
||||||
# create a super table with name exceed max length
|
# create a super table with name exceed max length
|
||||||
sname = self.generateString(maxTableNameLen + 1)
|
sname = self.generateString(maxTableNameLen)
|
||||||
tdLog.info("create a super table with length %d" % len(sname))
|
tdLog.info("create a super table with length %d" % len(sname))
|
||||||
tdSql.error(
|
tdSql.error(
|
||||||
"create table %s (ts timestamp, value int) tags(id int)" %
|
"create table %s (ts timestamp, value int) tags(id int)" %
|
||||||
sname)
|
sname)
|
||||||
|
|
||||||
# create a super table with name of max length
|
# create a super table with name of max length
|
||||||
sname = self.generateString(maxTableNameLen)
|
sname = self.generateString(maxTableNameLen - 1)
|
||||||
tdLog.info("create a super table with length %d" % len(sname))
|
tdLog.info("create a super table with length %d" % len(sname))
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
"create table %s (ts timestamp, value int) tags(id int)" %
|
"create table %s (ts timestamp, value int) tags(id int)" %
|
||||||
|
@ -113,12 +113,12 @@ class TDTestCase:
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
# create a child table with name exceed max length
|
# create a child table with name exceed max length
|
||||||
name = self.generateString(maxTableNameLen + 1)
|
name = self.generateString(maxTableNameLen)
|
||||||
tdLog.info("create a child table with length %d" % len(name))
|
tdLog.info("create a child table with length %d" % len(name))
|
||||||
tdSql.error("create table %s using %s tags(0)" % (name, sname))
|
tdSql.error("create table %s using %s tags(0)" % (name, sname))
|
||||||
|
|
||||||
# create a child table with name of max length
|
# create a child table with name of max length
|
||||||
name = self.generateString(maxTableNameLen)
|
name = self.generateString(maxTableNameLen - 1)
|
||||||
tdLog.info("create a child table with length %d" % len(name))
|
tdLog.info("create a child table with length %d" % len(name))
|
||||||
tdSql.execute("create table %s using %s tags(0)" % (name, sname))
|
tdSql.execute("create table %s using %s tags(0)" % (name, sname))
|
||||||
tdSql.query('show tables')
|
tdSql.query('show tables')
|
||||||
|
|
|
@ -18,9 +18,7 @@ class TDTestCase:
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
getTableNameLen = "grep -w '#define TSDB_TABLE_NAME_LEN' ../../src/inc/taosdef.h|awk '{print $3}'"
|
getTableNameLen = "grep -w '#define TSDB_TABLE_NAME_LEN' ../../src/inc/taosdef.h|awk '{print $3}'"
|
||||||
tableNameMaxLen = int(
|
tableNameMaxLen = int( subprocess.check_output(getTableNameLen, shell=True)) - 1
|
||||||
subprocess.check_output(
|
|
||||||
getTableNameLen, shell=True))
|
|
||||||
tdLog.info("table name max length is %d" % tableNameMaxLen)
|
tdLog.info("table name max length is %d" % tableNameMaxLen)
|
||||||
chars = string.ascii_uppercase + string.ascii_lowercase
|
chars = string.ascii_uppercase + string.ascii_lowercase
|
||||||
tb_name = ''.join(random.choices(chars, k=tableNameMaxLen))
|
tb_name = ''.join(random.choices(chars, k=tableNameMaxLen))
|
||||||
|
|
|
@ -165,7 +165,7 @@ SScript *simBuildScriptObj(char *fileName) {
|
||||||
|
|
||||||
script->type = SIM_SCRIPT_TYPE_MAIN;
|
script->type = SIM_SCRIPT_TYPE_MAIN;
|
||||||
script->numOfLines = numOfLines;
|
script->numOfLines = numOfLines;
|
||||||
strncpy(script->fileName, fileName, MAX_FILE_NAME_LEN);
|
tstrncpy(script->fileName, fileName, sizeof(script->fileName));
|
||||||
|
|
||||||
script->optionBuffer = malloc(optionOffset);
|
script->optionBuffer = malloc(optionOffset);
|
||||||
memcpy(script->optionBuffer, optionBuffer, optionOffset);
|
memcpy(script->optionBuffer, optionBuffer, optionOffset);
|
||||||
|
|
Loading…
Reference in New Issue