replace unsafe functions
This commit is contained in:
parent
8205565288
commit
718b0ad16e
|
@ -398,7 +398,6 @@ int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t
|
|||
int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol);
|
||||
|
||||
#define TSMA_RES_STB_POSTFIX "_tsma_res_stb_"
|
||||
#define MD5_OUTPUT_LEN 32
|
||||
#define TSMA_RES_STB_EXTRA_COLUMN_NUM 4 // 3 columns: _wstart, _wend, _wduration, 1 tag: tbname
|
||||
|
||||
static inline bool isTsmaResSTb(const char* stbName) {
|
||||
|
|
|
@ -50,12 +50,12 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define COPY_STRING_FORM_ID_TOKEN(buf, pToken) strncpy(buf, (pToken)->z, TMIN((pToken)->n, sizeof(buf) - 1))
|
||||
#define COPY_STRING_FORM_STR_TOKEN(buf, pToken) \
|
||||
do { \
|
||||
if ((pToken)->n > 2) { \
|
||||
strncpy(buf, (pToken)->z + 1, TMIN((pToken)->n - 2, sizeof(buf) - 1)); \
|
||||
} \
|
||||
#define COPY_STRING_FORM_ID_TOKEN(buf, pToken) tstrncpy(buf, (pToken)->z, TMIN((pToken)->n + 1, sizeof(buf)))
|
||||
#define COPY_STRING_FORM_STR_TOKEN(buf, pToken) \
|
||||
do { \
|
||||
if ((pToken)->n > 2) { \
|
||||
tstrncpy(buf, (pToken)->z + 1, TMIN((pToken)->n - 1, sizeof(buf))); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
SToken nil_token = {.type = TK_NK_NIL, .n = 0, .z = NULL};
|
||||
|
@ -113,7 +113,7 @@ static bool checkPassword(SAstCreateContext* pCxt, const SToken* pPasswordToken,
|
|||
} else if (pPasswordToken->n >= (TSDB_USET_PASSWORD_LEN + 2)) {
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||
} else {
|
||||
strncpy(pPassword, pPasswordToken->z, pPasswordToken->n);
|
||||
tstrncpy(pPassword, pPasswordToken->z, TMIN(TSDB_USET_PASSWORD_LEN, pPasswordToken->n + 1));
|
||||
(void)strdequote(pPassword);
|
||||
if (strtrim(pPassword) <= 0) {
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_PASSWD_EMPTY);
|
||||
|
@ -142,16 +142,16 @@ static int32_t parseEndpoint(SAstCreateContext* pCxt, const SToken* pEp, char* p
|
|||
(void)strdequote(ep);
|
||||
(void)strtrim(ep);
|
||||
if (NULL == pPort) {
|
||||
strcpy(pFqdn, ep);
|
||||
tstrncpy(pFqdn, ep, TSDB_FQDN_LEN);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
char* pColon = strchr(ep, ':');
|
||||
if (NULL == pColon) {
|
||||
*pPort = tsServerPort;
|
||||
strcpy(pFqdn, ep);
|
||||
tstrncpy(pFqdn, ep, TSDB_FQDN_LEN);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
strncpy(pFqdn, ep, pColon - ep);
|
||||
tstrncpy(pFqdn, ep, pColon - ep + 1);
|
||||
return parsePort(pCxt, pColon + 1, pPort);
|
||||
}
|
||||
|
||||
|
@ -320,22 +320,21 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
|
|||
if (nodesIsExprNode(pRealizedExpr)) {
|
||||
SExprNode* pExpr = (SExprNode*)pRealizedExpr;
|
||||
if (QUERY_NODE_COLUMN == nodeType(pExpr)) {
|
||||
strcpy(pExpr->aliasName, ((SColumnNode*)pExpr)->colName);
|
||||
strcpy(pExpr->userAlias, ((SColumnNode*)pExpr)->colName);
|
||||
tstrncpy(pExpr->aliasName, ((SColumnNode*)pExpr)->colName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pExpr->userAlias, ((SColumnNode*)pExpr)->colName, TSDB_COL_NAME_LEN);
|
||||
} else if (pRawExpr->isPseudoColumn) {
|
||||
// all pseudo column are translate to function with same name
|
||||
strcpy(pExpr->userAlias, ((SFunctionNode*)pExpr)->functionName);
|
||||
strcpy(pExpr->aliasName, ((SFunctionNode*)pExpr)->functionName);
|
||||
tstrncpy(pExpr->userAlias, ((SFunctionNode*)pExpr)->functionName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pExpr->aliasName, ((SFunctionNode*)pExpr)->functionName, TSDB_COL_NAME_LEN);
|
||||
} else {
|
||||
int32_t len = TMIN(sizeof(pExpr->aliasName) - 1, pRawExpr->n);
|
||||
int32_t len = TMIN(sizeof(pExpr->aliasName), pRawExpr->n + 1);
|
||||
|
||||
// See TS-3398.
|
||||
// Len of pRawExpr->p could be larger than len of aliasName[TSDB_COL_NAME_LEN].
|
||||
// If aliasName is truncated, hash value of aliasName could be the same.
|
||||
uint64_t hashVal = MurmurHash3_64(pRawExpr->p, pRawExpr->n);
|
||||
sprintf(pExpr->aliasName, "%" PRIu64, hashVal);
|
||||
strncpy(pExpr->userAlias, pRawExpr->p, len);
|
||||
pExpr->userAlias[len] = '\0';
|
||||
tstrncpy(pExpr->userAlias, pRawExpr->p, len);
|
||||
}
|
||||
}
|
||||
pRawExpr->pNode = NULL;
|
||||
|
@ -1021,9 +1020,9 @@ static SNode* createPrimaryKeyCol(SAstCreateContext* pCxt, const SToken* pFuncNa
|
|||
CHECK_MAKE_NODE(pCol);
|
||||
pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
if (NULL == pFuncName) {
|
||||
strcpy(pCol->colName, ROWTS_PSEUDO_COLUMN_NAME);
|
||||
tstrncpy(pCol->colName, ROWTS_PSEUDO_COLUMN_NAME, TSDB_COL_NAME_LEN);
|
||||
} else {
|
||||
strncpy(pCol->colName, pFuncName->z, pFuncName->n);
|
||||
tstrncpy(pCol->colName, pFuncName->z, pFuncName->n + 1);
|
||||
}
|
||||
pCol->isPrimTs = true;
|
||||
return (SNode*)pCol;
|
||||
|
@ -1052,7 +1051,7 @@ SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType d
|
|||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&func);
|
||||
CHECK_MAKE_NODE(func);
|
||||
strcpy(func->functionName, "cast");
|
||||
tstrncpy(func->functionName, "cast", TSDB_FUNC_NAME_LEN);
|
||||
func->node.resType = dt;
|
||||
if (TSDB_DATA_TYPE_VARCHAR == dt.type || TSDB_DATA_TYPE_GEOMETRY == dt.type || TSDB_DATA_TYPE_VARBINARY == dt.type) {
|
||||
func->node.resType.bytes = func->node.resType.bytes + VARSTR_HEADER_SIZE;
|
||||
|
@ -1073,7 +1072,7 @@ SNode* createPositionFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SNode*
|
|||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&func);
|
||||
CHECK_MAKE_NODE(func);
|
||||
strcpy(func->functionName, "position");
|
||||
tstrncpy(func->functionName, "position", TSDB_FUNC_NAME_LEN);
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr2);
|
||||
|
@ -1091,7 +1090,7 @@ SNode* createTrimFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, ETrimType t
|
|||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&func);
|
||||
CHECK_MAKE_NODE(func);
|
||||
strcpy(func->functionName, "trim");
|
||||
tstrncpy(func->functionName, "trim", TSDB_FUNC_NAME_LEN);
|
||||
func->trimType = type;
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
|
@ -1107,7 +1106,7 @@ SNode* createTrimFunctionNodeExt(SAstCreateContext* pCxt, SNode* pExpr, SNode* p
|
|||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&func);
|
||||
CHECK_MAKE_NODE(func);
|
||||
strcpy(func->functionName, "trim");
|
||||
tstrncpy(func->functionName, "trim", TSDB_FUNC_NAME_LEN);
|
||||
func->trimType = type;
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
|
@ -1126,7 +1125,7 @@ SNode* createSubstrFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SNode* pE
|
|||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&func);
|
||||
CHECK_MAKE_NODE(func);
|
||||
strcpy(func->functionName, "substr");
|
||||
tstrncpy(func->functionName, "substr", TSDB_FUNC_NAME_LEN);
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr2);
|
||||
|
@ -1144,7 +1143,7 @@ SNode* createSubstrFunctionNodeExt(SAstCreateContext* pCxt, SNode* pExpr, SNode*
|
|||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&func);
|
||||
CHECK_MAKE_NODE(func);
|
||||
strcpy(func->functionName, "substr");
|
||||
tstrncpy(func->functionName, "substr", TSDB_FUNC_NAME_LEN);
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr2);
|
||||
|
@ -1228,10 +1227,10 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, SToken* pT
|
|||
taosRandStr(tempTable->table.tableAlias, 8);
|
||||
}
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pSubquery)) {
|
||||
strcpy(((SSelectStmt*)pSubquery)->stmtName, tempTable->table.tableAlias);
|
||||
tstrncpy(((SSelectStmt*)pSubquery)->stmtName, tempTable->table.tableAlias, TSDB_TABLE_NAME_LEN);
|
||||
((SSelectStmt*)pSubquery)->isSubquery = true;
|
||||
} else if (QUERY_NODE_SET_OPERATOR == nodeType(pSubquery)) {
|
||||
strcpy(((SSetOperator*)pSubquery)->stmtName, tempTable->table.tableAlias);
|
||||
tstrncpy(((SSetOperator*)pSubquery)->stmtName, tempTable->table.tableAlias, TSDB_TABLE_NAME_LEN);
|
||||
}
|
||||
return (SNode*)tempTable;
|
||||
_err:
|
||||
|
@ -1434,7 +1433,7 @@ SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues) {
|
|||
fill->pWStartTs = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&(fill->pWStartTs));
|
||||
CHECK_MAKE_NODE(fill->pWStartTs);
|
||||
strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstart");
|
||||
tstrncpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstart", TSDB_FUNC_NAME_LEN);
|
||||
return (SNode*)fill;
|
||||
_err:
|
||||
nodesDestroyNode((SNode*)fill);
|
||||
|
@ -1525,11 +1524,9 @@ SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, SToken* pAlias)
|
|||
CHECK_PARSER_STATUS(pCxt);
|
||||
trimEscape(pAlias);
|
||||
SExprNode* pExpr = (SExprNode*)pNode;
|
||||
int32_t len = TMIN(sizeof(pExpr->aliasName) - 1, pAlias->n);
|
||||
strncpy(pExpr->aliasName, pAlias->z, len);
|
||||
pExpr->aliasName[len] = '\0';
|
||||
strncpy(pExpr->userAlias, pAlias->z, len);
|
||||
pExpr->userAlias[len] = '\0';
|
||||
int32_t len = TMIN(sizeof(pExpr->aliasName), pAlias->n + 1);
|
||||
tstrncpy(pExpr->aliasName, pAlias->z, len);
|
||||
tstrncpy(pExpr->userAlias, pAlias->z, len);
|
||||
pExpr->asAlias = true;
|
||||
return pNode;
|
||||
_err:
|
||||
|
@ -2245,7 +2242,7 @@ SNode* setColumnOptions(SAstCreateContext* pCxt, SNode* pOptions, const SToken*
|
|||
char optionType[TSDB_CL_OPTION_LEN];
|
||||
|
||||
memset(optionType, 0, TSDB_CL_OPTION_LEN);
|
||||
strncpy(optionType, pVal1->z, TMIN(pVal1->n, TSDB_CL_OPTION_LEN));
|
||||
tstrncpy(optionType, pVal1->z, TMIN(pVal1->n, TSDB_CL_OPTION_LEN));
|
||||
if (0 == strlen(optionType)) {
|
||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
return pOptions;
|
||||
|
@ -2322,8 +2319,8 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode*
|
|||
SCreateTableStmt* pStmt = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
pStmt->ignoreExists = ignoreExists;
|
||||
pStmt->pCols = pCols;
|
||||
pStmt->pTags = pTags;
|
||||
|
@ -2344,10 +2341,10 @@ SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SN
|
|||
SCreateSubTableClause* pStmt = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_CREATE_SUBTABLE_CLAUSE, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
strcpy(pStmt->useDbName, ((SRealTableNode*)pUseRealTable)->table.dbName);
|
||||
strcpy(pStmt->useTableName, ((SRealTableNode*)pUseRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pStmt->useDbName, ((SRealTableNode*)pUseRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->useTableName, ((SRealTableNode*)pUseRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
pStmt->ignoreExists = ignoreExists;
|
||||
pStmt->pSpecificTags = pSpecificTags;
|
||||
pStmt->pValsOfTags = pValsOfTags;
|
||||
|
@ -2370,14 +2367,14 @@ SNode* createCreateSubTableFromFileClause(SAstCreateContext* pCxt, bool ignoreEx
|
|||
SCreateSubTableFromFileClause* pStmt = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_CREATE_SUBTABLE_FROM_FILE_CLAUSE, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
strcpy(pStmt->useDbName, ((SRealTableNode*)pUseRealTable)->table.dbName);
|
||||
strcpy(pStmt->useTableName, ((SRealTableNode*)pUseRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->useDbName, ((SRealTableNode*)pUseRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->useTableName, ((SRealTableNode*)pUseRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
pStmt->ignoreExists = ignoreExists;
|
||||
pStmt->pSpecificTags = pSpecificTags;
|
||||
if (TK_NK_STRING == pFilePath->type) {
|
||||
(void)trimString(pFilePath->z, pFilePath->n, pStmt->filePath, PATH_MAX);
|
||||
} else {
|
||||
strncpy(pStmt->filePath, pFilePath->z, pFilePath->n);
|
||||
tstrncpy(pStmt->filePath, pFilePath->z, TMIN(PATH_MAX, pFilePath->n + 1));
|
||||
}
|
||||
|
||||
nodesDestroyNode(pUseRealTable);
|
||||
|
@ -2405,8 +2402,8 @@ SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNod
|
|||
SDropTableClause* pStmt = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_DROP_TABLE_CLAUSE, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
pStmt->ignoreNotExists = ignoreNotExists;
|
||||
nodesDestroyNode(pRealTable);
|
||||
return (SNode*)pStmt;
|
||||
|
@ -2433,8 +2430,8 @@ SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool withOpt, bool igno
|
|||
SDropSuperTableStmt* pStmt = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_DROP_SUPER_TABLE_STMT, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
pStmt->ignoreNotExists = ignoreNotExists;
|
||||
pStmt->withOpt = withOpt;
|
||||
nodesDestroyNode(pRealTable);
|
||||
|
@ -2445,8 +2442,8 @@ _err:
|
|||
}
|
||||
|
||||
static SNode* createAlterTableStmtFinalize(SNode* pRealTable, SAlterTableStmt* pStmt) {
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
nodesDestroyNode(pRealTable);
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
@ -2765,8 +2762,8 @@ SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode*
|
|||
SShowCreateTableStmt* pStmt = NULL;
|
||||
pCxt->errCode = nodesMakeNode(type, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
nodesDestroyNode(pRealTable);
|
||||
return (SNode*)pStmt;
|
||||
_err:
|
||||
|
@ -2779,8 +2776,8 @@ SNode* createShowCreateViewStmt(SAstCreateContext* pCxt, ENodeType type, SNode*
|
|||
SShowCreateViewStmt* pStmt = NULL;
|
||||
pCxt->errCode = nodesMakeNode(type, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->viewName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->viewName, ((SRealTableNode*)pRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
nodesDestroyNode(pRealTable);
|
||||
return (SNode*)pStmt;
|
||||
_err:
|
||||
|
@ -2793,8 +2790,8 @@ SNode* createShowTableDistributedStmt(SAstCreateContext* pCxt, SNode* pRealTable
|
|||
SShowTableDistributedStmt* pStmt = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
nodesDestroyNode(pRealTable);
|
||||
return (SNode*)pStmt;
|
||||
_err:
|
||||
|
@ -2950,7 +2947,7 @@ SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const ST
|
|||
pCxt->errCode = nodesMakeNode(QUERY_NODE_CREATE_USER_STMT, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
COPY_STRING_FORM_ID_TOKEN(pStmt->userName, pUserName);
|
||||
strcpy(pStmt->password, password);
|
||||
tstrncpy(pStmt->password, password, TSDB_USET_PASSWORD_LEN);
|
||||
pStmt->sysinfo = sysinfo;
|
||||
pStmt->createDb = createDb;
|
||||
pStmt->isImport = is_import;
|
||||
|
@ -2972,7 +2969,7 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t al
|
|||
char password[TSDB_USET_PASSWORD_LEN] = {0};
|
||||
SToken* pVal = pAlterInfo;
|
||||
CHECK_NAME(checkPassword(pCxt, pVal, password));
|
||||
strcpy(pStmt->password, password);
|
||||
tstrncpy(pStmt->password, password, TSDB_USET_PASSWORD_LEN);
|
||||
break;
|
||||
}
|
||||
case TSDB_ALTER_USER_ENABLE: {
|
||||
|
@ -3282,8 +3279,8 @@ SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists,
|
|||
pStmt->withMeta = withMeta;
|
||||
pStmt->pWhere = pWhere;
|
||||
|
||||
strcpy(pStmt->subDbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->subSTbName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->subDbName, ((SRealTableNode*)pRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->subSTbName, ((SRealTableNode*)pRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
nodesDestroyNode(pRealTable);
|
||||
return (SNode*)pStmt;
|
||||
_err:
|
||||
|
@ -3396,8 +3393,8 @@ SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable) {
|
|||
SDescribeStmt* pStmt = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_DESCRIBE_STMT, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
nodesDestroyNode(pRealTable);
|
||||
return (SNode*)pStmt;
|
||||
_err:
|
||||
|
@ -3477,8 +3474,8 @@ SNode* createCreateViewStmt(SAstCreateContext* pCxt, bool orReplace, SNode* pVie
|
|||
}
|
||||
pStmt->pQuerySql = tstrdup(pAs->z + i);
|
||||
CHECK_OUT_OF_MEM(pStmt->pQuerySql);
|
||||
strcpy(pStmt->dbName, ((SViewNode*)pView)->table.dbName);
|
||||
strcpy(pStmt->viewName, ((SViewNode*)pView)->table.tableName);
|
||||
tstrncpy(pStmt->dbName, ((SViewNode*)pView)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->viewName, ((SViewNode*)pView)->table.tableName, TSDB_VIEW_NAME_LEN);
|
||||
nodesDestroyNode(pView);
|
||||
pStmt->orReplace = orReplace;
|
||||
pStmt->pQuery = pQuery;
|
||||
|
@ -3496,8 +3493,8 @@ SNode* createDropViewStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode*
|
|||
pCxt->errCode = nodesMakeNode(QUERY_NODE_DROP_VIEW_STMT, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
pStmt->ignoreNotExists = ignoreNotExists;
|
||||
strcpy(pStmt->dbName, ((SViewNode*)pView)->table.dbName);
|
||||
strcpy(pStmt->viewName, ((SViewNode*)pView)->table.tableName);
|
||||
tstrncpy(pStmt->dbName, ((SViewNode*)pView)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->viewName, ((SViewNode*)pView)->table.tableName, TSDB_VIEW_NAME_LEN);
|
||||
nodesDestroyNode(pView);
|
||||
return (SNode*)pStmt;
|
||||
_err:
|
||||
|
@ -3582,8 +3579,8 @@ SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken
|
|||
pCxt->errCode = nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
COPY_STRING_FORM_ID_TOKEN(pStmt->streamName, pStreamName);
|
||||
strcpy(pStmt->targetDbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->targetTabName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
tstrncpy(pStmt->targetDbName, ((SRealTableNode*)pRealTable)->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pStmt->targetTabName, ((SRealTableNode*)pRealTable)->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
nodesDestroyNode(pRealTable);
|
||||
pStmt->ignoreExists = ignoreExists;
|
||||
pStmt->pOptions = (SStreamOptions*)pOptions;
|
||||
|
@ -3837,9 +3834,9 @@ SNode* createInsertStmt(SAstCreateContext* pCxt, SNode* pTable, SNodeList* pCols
|
|||
pStmt->pCols = pCols;
|
||||
pStmt->pQuery = pQuery;
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pQuery)) {
|
||||
strcpy(((SSelectStmt*)pQuery)->stmtName, ((STableNode*)pTable)->tableAlias);
|
||||
tstrncpy(((SSelectStmt*)pQuery)->stmtName, ((STableNode*)pTable)->tableAlias, TSDB_TABLE_NAME_LEN);
|
||||
} else if (QUERY_NODE_SET_OPERATOR == nodeType(pQuery)) {
|
||||
strcpy(((SSetOperator*)pQuery)->stmtName, ((STableNode*)pTable)->tableAlias);
|
||||
tstrncpy(((SSetOperator*)pQuery)->stmtName, ((STableNode*)pTable)->tableAlias, TSDB_TABLE_NAME_LEN);
|
||||
}
|
||||
return (SNode*)pStmt;
|
||||
_err:
|
||||
|
|
|
@ -480,8 +480,8 @@ static int32_t collectMetaKeyFromExplain(SCollectMetaKeyCxt* pCxt, SExplainStmt*
|
|||
|
||||
static int32_t collectMetaKeyFromDescribe(SCollectMetaKeyCxt* pCxt, SDescribeStmt* pStmt) {
|
||||
SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId};
|
||||
strcpy(name.dbname, pStmt->dbName);
|
||||
strcpy(name.tname, pStmt->tableName);
|
||||
tstrncpy(name.dbname, pStmt->dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(name.tname, pStmt->tableName, TSDB_TABLE_NAME_LEN);
|
||||
int32_t code = catalogRemoveTableMeta(pCxt->pParseCxt->pCatalog, &name);
|
||||
#ifdef TD_ENTERPRISE
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -781,8 +781,8 @@ static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SS
|
|||
|
||||
static int32_t collectMetaKeyFromShowCreateTable(SCollectMetaKeyCxt* pCxt, SShowCreateTableStmt* pStmt) {
|
||||
SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId};
|
||||
strcpy(name.dbname, pStmt->dbName);
|
||||
strcpy(name.tname, pStmt->tableName);
|
||||
tstrncpy(name.dbname, pStmt->dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(name.tname, pStmt->tableName, TSDB_TABLE_NAME_LEN);
|
||||
int32_t code = catalogRemoveTableMeta(pCxt->pParseCxt->pCatalog, &name);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = reserveTableCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
||||
|
@ -799,8 +799,8 @@ static int32_t collectMetaKeyFromShowCreateTable(SCollectMetaKeyCxt* pCxt, SShow
|
|||
|
||||
static int32_t collectMetaKeyFromShowCreateView(SCollectMetaKeyCxt* pCxt, SShowCreateViewStmt* pStmt) {
|
||||
SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId};
|
||||
strcpy(name.dbname, pStmt->dbName);
|
||||
strcpy(name.tname, pStmt->viewName);
|
||||
tstrncpy(name.dbname, pStmt->dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(name.tname, pStmt->viewName, TSDB_TABLE_NAME_LEN);
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
(void)tNameGetFullDbName(&name, dbFName);
|
||||
int32_t code = catalogRemoveViewMeta(pCxt->pParseCxt->pCatalog, dbFName, 0, pStmt->viewName, 0);
|
||||
|
@ -841,8 +841,8 @@ static int32_t collectMetaKeyFromInsert(SCollectMetaKeyCxt* pCxt, SInsertStmt* p
|
|||
|
||||
static int32_t collectMetaKeyFromShowBlockDist(SCollectMetaKeyCxt* pCxt, SShowTableDistributedStmt* pStmt) {
|
||||
SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId};
|
||||
strcpy(name.dbname, pStmt->dbName);
|
||||
strcpy(name.tname, pStmt->tableName);
|
||||
tstrncpy(name.dbname, pStmt->dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(name.tname, pStmt->tableName, TSDB_TABLE_NAME_LEN);
|
||||
int32_t code = catalogRemoveTableMeta(pCxt->pParseCxt->pCatalog, &name);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = collectMetaKeyFromRealTableImpl(pCxt, pStmt->dbName, pStmt->tableName, AUTH_TYPE_READ);
|
||||
|
|
|
@ -131,8 +131,8 @@ EDealRes rewriteAuthTable(SNode* pNode, void* pContext) {
|
|||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||
SAuthRewriteCxt* pCxt = (SAuthRewriteCxt*)pContext;
|
||||
strcpy(pCol->tableName, pCxt->pTarget->tableName);
|
||||
strcpy(pCol->tableAlias, pCxt->pTarget->tableAlias);
|
||||
tstrncpy(pCol->tableName, pCxt->pTarget->tableName, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pCol->tableAlias, pCxt->pTarget->tableAlias, TSDB_TABLE_NAME_LEN);
|
||||
}
|
||||
|
||||
return DEAL_RES_CONTINUE;
|
||||
|
|
|
@ -178,14 +178,14 @@ static EDealRes doFindAndReplaceNode(SNode** pNode, void* pContext) {
|
|||
SCalcConstContext* pCxt = pContext;
|
||||
if (pCxt->replaceCxt.pTarget == *pNode) {
|
||||
char aliasName[TSDB_COL_NAME_LEN] = {0};
|
||||
strcpy(aliasName, ((SExprNode*)*pNode)->aliasName);
|
||||
tstrncpy(aliasName, ((SExprNode*)*pNode)->aliasName, TSDB_COL_NAME_LEN);
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = NULL;
|
||||
pCxt->code = nodesCloneNode(pCxt->replaceCxt.pNew, pNode);
|
||||
if (NULL == *pNode) {
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
strcpy(((SExprNode*)*pNode)->aliasName, aliasName);
|
||||
tstrncpy(((SExprNode*)*pNode)->aliasName, aliasName, TSDB_COL_NAME_LEN);
|
||||
|
||||
pCxt->replaceCxt.replaced = true;
|
||||
return DEAL_RES_END;
|
||||
|
@ -228,14 +228,14 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d
|
|||
SAssociationNode* pAssNode = taosArrayGet(pAssociation, i);
|
||||
SNode** pCol = pAssNode->pPlace;
|
||||
if (*pCol == pAssNode->pAssociationNode) {
|
||||
strcpy(aliasName, ((SExprNode*)*pCol)->aliasName);
|
||||
tstrncpy(aliasName, ((SExprNode*)*pCol)->aliasName, TSDB_COL_NAME_LEN);
|
||||
SArray* pOrigAss = NULL;
|
||||
TSWAP(((SExprNode*)*pCol)->pAssociation, pOrigAss);
|
||||
nodesDestroyNode(*pCol);
|
||||
*pCol = NULL;
|
||||
code = nodesCloneNode(*pNew, pCol);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
strcpy(((SExprNode*)*pCol)->aliasName, aliasName);
|
||||
tstrncpy(((SExprNode*)*pCol)->aliasName, aliasName, TSDB_COL_NAME_LEN);
|
||||
TSWAP(pOrigAss, ((SExprNode*)*pCol)->pAssociation);
|
||||
}
|
||||
taosArrayDestroy(pOrigAss);
|
||||
|
|
|
@ -903,7 +903,7 @@ int32_t buildBoundFields(int32_t numOfBound, int16_t* boundColumns, SSchema* pSc
|
|||
|
||||
for (int32_t i = 0; i < numOfBound; ++i) {
|
||||
schema = &pSchema[boundColumns[i]];
|
||||
strcpy((*fields)[i].name, schema->name);
|
||||
tstrncpy((*fields)[i].name, schema->name, 65);
|
||||
(*fields)[i].type = schema->type;
|
||||
(*fields)[i].bytes = schema->bytes;
|
||||
}
|
||||
|
|
|
@ -1299,15 +1299,15 @@ static bool hasPkInTable(const STableMeta* pTableMeta) {
|
|||
|
||||
static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* pColSchema, int32_t tagFlag,
|
||||
SColumnNode* pCol) {
|
||||
strcpy(pCol->dbName, pTable->table.dbName);
|
||||
strcpy(pCol->tableAlias, pTable->table.tableAlias);
|
||||
strcpy(pCol->tableName, pTable->table.tableName);
|
||||
strcpy(pCol->colName, pColSchema->name);
|
||||
tstrncpy(pCol->dbName, pTable->table.dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pCol->tableAlias, pTable->table.tableAlias, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pCol->tableName, pTable->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pCol->colName, pColSchema->name, TSDB_COL_NAME_LEN);
|
||||
if ('\0' == pCol->node.aliasName[0]) {
|
||||
strcpy(pCol->node.aliasName, pColSchema->name);
|
||||
tstrncpy(pCol->node.aliasName, pColSchema->name, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
if ('\0' == pCol->node.userAlias[0]) {
|
||||
strcpy(pCol->node.userAlias, pColSchema->name);
|
||||
tstrncpy(pCol->node.userAlias, pColSchema->name, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
pCol->tableId = pTable->pMeta->uid;
|
||||
pCol->tableType = pTable->pMeta->tableType;
|
||||
|
@ -1338,7 +1338,7 @@ static int32_t setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SCo
|
|||
return terrno;
|
||||
}
|
||||
|
||||
strcpy(pCol->tableAlias, pTable->table.tableAlias);
|
||||
tstrncpy(pCol->tableAlias, pTable->table.tableAlias, TSDB_TABLE_NAME_LEN);
|
||||
pCol->isPrimTs = isPrimaryKeyImpl((SNode*)pExpr);
|
||||
pCol->colId = pCol->isPrimTs ? PRIMARYKEY_TIMESTAMP_COL_ID : 0;
|
||||
if (QUERY_NODE_COLUMN == nodeType(pExpr)) {
|
||||
|
@ -1346,12 +1346,12 @@ static int32_t setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SCo
|
|||
// strcpy(pCol->dbName, ((SColumnNode*)pExpr)->dbName);
|
||||
// strcpy(pCol->tableName, ((SColumnNode*)pExpr)->tableName);
|
||||
}
|
||||
strcpy(pCol->colName, pExpr->aliasName);
|
||||
tstrncpy(pCol->colName, pExpr->aliasName, TSDB_COL_NAME_LEN);
|
||||
if ('\0' == pCol->node.aliasName[0]) {
|
||||
strcpy(pCol->node.aliasName, pCol->colName);
|
||||
tstrncpy(pCol->node.aliasName, pExpr->aliasName, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
if ('\0' == pCol->node.userAlias[0]) {
|
||||
strcpy(pCol->node.userAlias, pExpr->userAlias);
|
||||
tstrncpy(pCol->node.userAlias, pExpr->aliasName, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
pCol->node.resType = pExpr->resType;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1667,7 +1667,7 @@ static int32_t biMakeTbnameProjectAstNode(char* funcName, char* tableAlias, SNod
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
snprintf(tbNameFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias), (tableAlias) ? "%s.tbname" : "%stbname",
|
||||
(tableAlias) ? tableAlias : "");
|
||||
strncpy(tbNameFunc->node.aliasName, tbNameFunc->functionName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(tbNameFunc->node.aliasName, tbNameFunc->functionName, TSDB_COL_NAME_LEN);
|
||||
if (funcName == NULL) {
|
||||
*pOutNode = (SNode*)tbNameFunc;
|
||||
return code;
|
||||
|
@ -1685,7 +1685,7 @@ static int32_t biMakeTbnameProjectAstNode(char* funcName, char* tableAlias, SNod
|
|||
if (tsKeepColumnName) {
|
||||
snprintf(multiResFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias),
|
||||
(tableAlias) ? "%s.tbname" : "%stbname", (tableAlias) ? tableAlias : "");
|
||||
strcpy(multiResFunc->node.aliasName, tbNameFunc->functionName);
|
||||
tstrncpy(multiResFunc->node.aliasName, tbNameFunc->functionName, TSDB_COL_NAME_LEN);
|
||||
} else {
|
||||
snprintf(multiResFunc->node.userAlias, sizeof(multiResFunc->node.userAlias),
|
||||
tableAlias ? "%s(%s.tbname)" : "%s(%stbname)", funcName, tableAlias ? tableAlias : "");
|
||||
|
@ -1812,8 +1812,8 @@ int32_t biRewriteToTbnameFunc(STranslateContext* pCxt, SNode** ppNode, bool* pRe
|
|||
(SNode**)&tbnameFuncNode);
|
||||
if (TSDB_CODE_SUCCESS != code) return code;
|
||||
tbnameFuncNode->node.resType = pCol->node.resType;
|
||||
strcpy(tbnameFuncNode->node.aliasName, pCol->node.aliasName);
|
||||
strcpy(tbnameFuncNode->node.userAlias, pCol->node.userAlias);
|
||||
tstrncpy(tbnameFuncNode->node.aliasName, pCol->node.aliasName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(tbnameFuncNode->node.userAlias, pCol->node.userAlias, TSDB_COL_NAME_LEN);
|
||||
|
||||
nodesDestroyNode(*ppNode);
|
||||
*ppNode = (SNode*)tbnameFuncNode;
|
||||
|
@ -2131,7 +2131,7 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
|||
return generateDealNodeErrMsg(pCxt, terrno);
|
||||
}
|
||||
varDataSetLen(pVal->datum.p, len);
|
||||
strncpy(varDataVal(pVal->datum.p), pVal->literal, len);
|
||||
tstrncpy(varDataVal(pVal->datum.p), pVal->literal, len);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_TIMESTAMP: {
|
||||
|
@ -2796,7 +2796,8 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu
|
|||
}
|
||||
}
|
||||
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias && !pFunc->node.asParam) {
|
||||
strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias);
|
||||
tstrncpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias,
|
||||
TSDB_COL_NAME_LEN);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -2871,8 +2872,8 @@ static int32_t rewriteFuncToValue(STranslateContext* pCxt, char** pLiteral, SNod
|
|||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pVal->node.aliasName, ((SExprNode*)*pNode)->aliasName);
|
||||
strcpy(pVal->node.userAlias, ((SExprNode*)*pNode)->userAlias);
|
||||
tstrncpy(pVal->node.aliasName, ((SExprNode*)*pNode)->aliasName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pVal->node.userAlias, ((SExprNode*)*pNode)->userAlias, TSDB_COL_NAME_LEN);
|
||||
pVal->node.resType = ((SExprNode*)*pNode)->resType;
|
||||
if (NULL == pLiteral || NULL == *pLiteral) {
|
||||
pVal->isNull = true;
|
||||
|
@ -2987,10 +2988,10 @@ static int32_t replacePsedudoColumnFuncWithColumn(STranslateContext* pCxt, SNode
|
|||
if (0 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
SValueNode* pVal = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||
pCol->node.resType = pOldExpr->resType;
|
||||
strcpy(pCol->tableAlias, pVal->literal);
|
||||
strcpy(pCol->colName, pFunc->functionName);
|
||||
strcpy(pCol->node.aliasName, pCol->colName);
|
||||
strcpy(pCol->node.userAlias, pCol->colName);
|
||||
tstrncpy(pCol->node.aliasName, pVal->literal, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pCol->colName, pFunc->functionName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pCol->node.aliasName, pCol->colName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pCol->node.userAlias, pCol->colName, TSDB_COL_NAME_LEN);
|
||||
nodesDestroyNode(*ppNode);
|
||||
*ppNode = (SNode*)pCol;
|
||||
|
||||
|
@ -2998,9 +2999,9 @@ static int32_t replacePsedudoColumnFuncWithColumn(STranslateContext* pCxt, SNode
|
|||
}
|
||||
}
|
||||
pCol->node.resType = pOldExpr->resType;
|
||||
strcpy(pCol->node.aliasName, pOldExpr->aliasName);
|
||||
strcpy(pCol->node.userAlias, pOldExpr->userAlias);
|
||||
strcpy(pCol->colName, pOldExpr->aliasName);
|
||||
tstrncpy(pCol->node.aliasName, pOldExpr->aliasName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pCol->node.userAlias, pOldExpr->userAlias, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pCol->colName, pOldExpr->aliasName, TSDB_COL_NAME_LEN);
|
||||
|
||||
nodesDestroyNode(*ppNode);
|
||||
*ppNode = (SNode*)pCol;
|
||||
|
@ -3255,7 +3256,7 @@ static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType d
|
|||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pFunc->functionName, "cast");
|
||||
tstrncpy(pFunc->functionName, "cast", TSDB_FUNC_NAME_LEN);
|
||||
pFunc->node.resType = dt;
|
||||
if (TSDB_CODE_SUCCESS != nodesListMakeAppend(&pFunc->pParameterList, pExpr)) {
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
|
@ -3471,9 +3472,9 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode
|
|||
pCxt->errCode = code;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
strcpy(pFunc->functionName, "_select_value");
|
||||
strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName);
|
||||
strcpy(pFunc->node.userAlias, ((SExprNode*)*pNode)->userAlias);
|
||||
tstrncpy(pFunc->functionName, "_select_value", TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pFunc->node.userAlias, ((SExprNode*)*pNode)->userAlias, TSDB_COL_NAME_LEN);
|
||||
pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode);
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
pCxt->errCode = getFuncInfo(pCxt, pFunc);
|
||||
|
@ -3495,9 +3496,9 @@ static EDealRes rewriteExprToGroupKeyFunc(STranslateContext* pCxt, SNode** pNode
|
|||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
strcpy(pFunc->functionName, "_group_key");
|
||||
strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName);
|
||||
strcpy(pFunc->node.userAlias, ((SExprNode*)*pNode)->userAlias);
|
||||
tstrncpy(pFunc->functionName, "_group_key", TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pFunc->node.userAlias, ((SExprNode*)*pNode)->userAlias, TSDB_COL_NAME_LEN);
|
||||
pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode);
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
*pNode = (SNode*)pFunc;
|
||||
|
@ -3514,9 +3515,9 @@ static EDealRes rewriteExprToSelectTagFunc(STranslateContext* pCxt, SNode** pNod
|
|||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
strcpy(pFunc->functionName, "_group_const_value");
|
||||
strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName);
|
||||
strcpy(pFunc->node.userAlias, ((SExprNode*)*pNode)->userAlias);
|
||||
tstrncpy(pFunc->functionName, "_group_const_value", TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pFunc->node.userAlias, ((SExprNode*)*pNode)->userAlias, TSDB_COL_NAME_LEN);
|
||||
pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode);
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
*pNode = (SNode*)pFunc;
|
||||
|
@ -4288,7 +4289,7 @@ static int32_t setTableTsmas(STranslateContext* pCxt, SName* pName, SRealTableNo
|
|||
int32_t len = tsnprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName,
|
||||
pTsma->name, pRealTable->table.tableName);
|
||||
len = taosCreateMD5Hash(buf, len);
|
||||
strncpy(tsmaTargetTbName.tname, buf, MD5_OUTPUT_LEN);
|
||||
tstrncpy(tsmaTargetTbName.tname, buf, TSDB_TABLE_NAME_LEN);
|
||||
code = collectUseTable(&tsmaTargetTbName, pCxt->pTargetTables);
|
||||
if (TSDB_CODE_SUCCESS == code)
|
||||
code = catalogGetCachedTableHashVgroup(pCxt->pParseCxt->pCatalog, &tsmaTargetTbName, &vgInfo, &exists);
|
||||
|
@ -4394,10 +4395,9 @@ static EDealRes doTranslateTbName(SNode** pNode, void* pContext) {
|
|||
return DEAL_RES_ERROR;
|
||||
}
|
||||
varDataSetLen(pVal->datum.p, tbLen);
|
||||
strncpy(varDataVal(pVal->datum.p), pVal->literal, tbLen);
|
||||
strcpy(pVal->node.userAlias, pFunc->node.userAlias);
|
||||
strcpy(pVal->node.aliasName, pFunc->node.aliasName);
|
||||
|
||||
tstrncpy(varDataVal(pVal->datum.p), pVal->literal, tbLen);
|
||||
tstrncpy(pVal->node.userAlias, pFunc->node.userAlias, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pVal->node.aliasName, pFunc->node.aliasName, TSDB_COL_NAME_LEN);
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)pVal;
|
||||
}
|
||||
|
@ -4462,9 +4462,9 @@ static int32_t addPrimJoinEqCond(SNode** pCond, SRealTableNode* leftTable, SReal
|
|||
pLeft->tableId = pLMeta->uid;
|
||||
pLeft->colId = pLMeta->schema[0].colId;
|
||||
pLeft->colType = COLUMN_TYPE_COLUMN;
|
||||
strcpy(pLeft->tableName, leftTable->table.tableName);
|
||||
strcpy(pLeft->tableAlias, leftTable->table.tableAlias);
|
||||
strcpy(pLeft->colName, pLMeta->schema[0].name);
|
||||
tstrncpy(pLeft->tableName, leftTable->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pLeft->tableAlias, leftTable->table.tableAlias, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pLeft->colName, pLMeta->schema[0].name, TSDB_COL_NAME_LEN);
|
||||
|
||||
pOp->pLeft = (SNode*)pLeft;
|
||||
|
||||
|
@ -4479,9 +4479,9 @@ static int32_t addPrimJoinEqCond(SNode** pCond, SRealTableNode* leftTable, SReal
|
|||
pRight->tableId = pRMeta->uid;
|
||||
pRight->colId = pRMeta->schema[0].colId;
|
||||
pRight->colType = COLUMN_TYPE_COLUMN;
|
||||
strcpy(pRight->tableName, rightTable->table.tableName);
|
||||
strcpy(pRight->tableAlias, rightTable->table.tableAlias);
|
||||
strcpy(pRight->colName, pRMeta->schema[0].name);
|
||||
tstrncpy(pRight->tableName, rightTable->table.tableName, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pRight->tableAlias, rightTable->table.tableAlias, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pRight->colName, pRMeta->schema[0].name, TSDB_COL_NAME_LEN);
|
||||
|
||||
pOp->pRight = (SNode*)pRight;
|
||||
|
||||
|
@ -5084,29 +5084,29 @@ static int32_t createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr, SNo
|
|||
pFunc->node.resType = pExpr->resType;
|
||||
pFunc->funcId = pSrcFunc->funcId;
|
||||
pFunc->funcType = pSrcFunc->funcType;
|
||||
strcpy(pFunc->functionName, pSrcFunc->functionName);
|
||||
tstrncpy(pFunc->functionName, pSrcFunc->functionName, TSDB_FUNC_NAME_LEN);
|
||||
char buf[TSDB_FUNC_NAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN + TSDB_NAME_DELIMITER_LEN + 3] = {0};
|
||||
int32_t len = 0;
|
||||
if (QUERY_NODE_COLUMN == nodeType(pExpr)) {
|
||||
SColumnNode* pCol = (SColumnNode*)pExpr;
|
||||
if (tsKeepColumnName) {
|
||||
strcpy(pFunc->node.userAlias, pCol->colName);
|
||||
strcpy(pFunc->node.aliasName, pCol->colName);
|
||||
tstrncpy(pFunc->node.userAlias, pCol->colName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pFunc->node.aliasName, pCol->colName, TSDB_COL_NAME_LEN);
|
||||
} else {
|
||||
len = tsnprintf(buf, sizeof(buf) - 1, "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName);
|
||||
(void)taosHashBinary(buf, len);
|
||||
strncpy(pFunc->node.aliasName, buf, TSDB_COL_NAME_LEN - 1);
|
||||
tstrncpy(pFunc->node.aliasName, buf, TSDB_COL_NAME_LEN);
|
||||
len = tsnprintf(buf, sizeof(buf) - 1, "%s(%s)", pSrcFunc->functionName, pCol->colName);
|
||||
// note: userAlias could be truncated here
|
||||
strncpy(pFunc->node.userAlias, buf, TSDB_COL_NAME_LEN - 1);
|
||||
tstrncpy(pFunc->node.userAlias, buf, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
} else {
|
||||
len = tsnprintf(buf, sizeof(buf) - 1, "%s(%s)", pSrcFunc->functionName, pExpr->aliasName);
|
||||
(void)taosHashBinary(buf, len);
|
||||
strncpy(pFunc->node.aliasName, buf, TSDB_COL_NAME_LEN - 1);
|
||||
tstrncpy(pFunc->node.aliasName, buf, TSDB_COL_NAME_LEN);
|
||||
len = tsnprintf(buf, sizeof(buf) - 1, "%s(%s)", pSrcFunc->functionName, pExpr->userAlias);
|
||||
// note: userAlias could be truncated here
|
||||
strncpy(pFunc->node.userAlias, buf, TSDB_COL_NAME_LEN - 1);
|
||||
tstrncpy(pFunc->node.userAlias, buf, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
*ppNodeOut = (SNode*)pFunc;
|
||||
return code;
|
||||
|
@ -5435,7 +5435,7 @@ static int32_t rewriteProjectAlias(SNodeList* pProjectionList) {
|
|||
FOREACH(pProject, pProjectionList) {
|
||||
SExprNode* pExpr = (SExprNode*)pProject;
|
||||
if ('\0' == pExpr->userAlias[0]) {
|
||||
strcpy(pExpr->userAlias, pExpr->aliasName);
|
||||
tstrncpy(pExpr->userAlias, pExpr->aliasName, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
sprintf(pExpr->aliasName, "#expr_%d", no++);
|
||||
}
|
||||
|
@ -6129,7 +6129,7 @@ static int32_t createDefaultFillNode(STranslateContext* pCxt, SNode** pOutput) {
|
|||
return code;
|
||||
}
|
||||
pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
strcpy(pCol->colName, ROWTS_PSEUDO_COLUMN_NAME);
|
||||
tstrncpy(pCol->colName, ROWTS_PSEUDO_COLUMN_NAME, TSDB_COL_NAME_LEN);
|
||||
pFill->pWStartTs = (SNode*)pCol;
|
||||
|
||||
*pOutput = (SNode*)pFill;
|
||||
|
@ -6734,7 +6734,7 @@ static int32_t replaceToChildTableQuery(STranslateContext* pCxt, SEqCondTbNameTa
|
|||
int32_t len = tsnprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name,
|
||||
pRealTable->table.tableName);
|
||||
len = taosCreateMD5Hash(buf, len);
|
||||
strncpy(tsmaTargetTbName.tname, buf, MD5_OUTPUT_LEN);
|
||||
tstrncpy(tsmaTargetTbName.tname, buf, TSDB_TABLE_NAME_LEN);
|
||||
STsmaTargetTbInfo ctbInfo = {0};
|
||||
if (!pRealTable->tsmaTargetTbInfo) {
|
||||
pRealTable->tsmaTargetTbInfo = taosArrayInit(pRealTable->pTsmas->size, sizeof(STsmaTargetTbInfo));
|
||||
|
@ -6897,7 +6897,7 @@ static int32_t createPrimaryKeyColByTable(STranslateContext* pCxt, STableNode* p
|
|||
return code;
|
||||
}
|
||||
pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
strcpy(pCol->colName, ROWTS_PSEUDO_COLUMN_NAME);
|
||||
tstrncpy(pCol->colName, ROWTS_PSEUDO_COLUMN_NAME, TSDB_COL_NAME_LEN);
|
||||
bool found = false;
|
||||
code = findAndSetColumn(pCxt, &pCol, pTable, &found, true);
|
||||
if (TSDB_CODE_SUCCESS != code || !found) {
|
||||
|
@ -6996,7 +6996,7 @@ static int32_t createPkColByTable(STranslateContext* pCxt, SRealTableNode* pTabl
|
|||
return code;
|
||||
}
|
||||
pCol->colId = pTable->pMeta->schema[1].colId;
|
||||
strcpy(pCol->colName, pTable->pMeta->schema[1].name);
|
||||
tstrncpy(pCol->colName, pTable->pMeta->schema[1].name, TSDB_COL_NAME_LEN);
|
||||
bool found = false;
|
||||
code = findAndSetColumn(pCxt, &pCol, (STableNode*)pTable, &found, true);
|
||||
if (TSDB_CODE_SUCCESS != code || !found) {
|
||||
|
@ -8462,7 +8462,7 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray, bool calB
|
|||
field.bytes = pCol->dataType.bytes;
|
||||
}
|
||||
|
||||
strcpy(field.name, pCol->colName);
|
||||
tstrncpy(field.name, pCol->colName, TSDB_COL_NAME_LEN);
|
||||
if (pCol->pOptions) {
|
||||
setColEncode(&field.compress, columnEncodeVal(((SColumnOptions*)pCol->pOptions)->encode));
|
||||
setColCompress(&field.compress, columnCompressVal(((SColumnOptions*)pCol->pOptions)->compress));
|
||||
|
@ -8500,7 +8500,7 @@ static int32_t tagDefNodeToField(SNodeList* pList, SArray** pArray, bool calByte
|
|||
} else {
|
||||
field.bytes = pCol->dataType.bytes;
|
||||
}
|
||||
strcpy(field.name, pCol->colName);
|
||||
tstrncpy(field.name, pCol->colName, TSDB_COL_NAME_LEN);
|
||||
if (pCol->sma) {
|
||||
field.flags |= COL_SMA_ON;
|
||||
}
|
||||
|
@ -8905,7 +8905,7 @@ static void toSchema(const SColumnDefNode* pCol, col_id_t colId, SSchema* pSchem
|
|||
pSchema->type = pCol->dataType.type;
|
||||
pSchema->bytes = calcTypeBytes(pCol->dataType);
|
||||
pSchema->flags = flags;
|
||||
strcpy(pSchema->name, pCol->colName);
|
||||
tstrncpy(pSchema->name, pCol->colName, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
|
||||
typedef struct SSampleAstInfo {
|
||||
|
@ -8942,8 +8942,8 @@ static int32_t addWstartToSampleProjects(SNodeList* pProjectionList) {
|
|||
if (NULL == pFunc) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pFunc->functionName, "_wstart");
|
||||
strcpy(pFunc->node.userAlias, "_wstart");
|
||||
tstrncpy(pFunc->functionName, "_wstart", TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.userAlias, "_wstart", TSDB_FUNC_NAME_LEN);
|
||||
return nodesListPushFront(pProjectionList, (SNode*)pFunc);
|
||||
}
|
||||
|
||||
|
@ -8953,8 +8953,8 @@ static int32_t addWendToSampleProjects(SNodeList* pProjectionList) {
|
|||
if (NULL == pFunc) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pFunc->functionName, "_wend");
|
||||
strcpy(pFunc->node.userAlias, "_wend");
|
||||
tstrncpy(pFunc->functionName, "_wend", TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.userAlias, "_wend", TSDB_FUNC_NAME_LEN);
|
||||
return nodesListAppend(pProjectionList, (SNode*)pFunc);
|
||||
}
|
||||
|
||||
|
@ -8964,8 +8964,8 @@ static int32_t addWdurationToSampleProjects(SNodeList* pProjectionList) {
|
|||
if (NULL == pFunc) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pFunc->functionName, "_wduration");
|
||||
strcpy(pFunc->node.userAlias, "_wduration");
|
||||
tstrncpy(pFunc->functionName, "_wduration", TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.userAlias, "_wduration", TSDB_FUNC_NAME_LEN);
|
||||
return nodesListAppend(pProjectionList, (SNode*)pFunc);
|
||||
}
|
||||
|
||||
|
@ -9011,7 +9011,7 @@ static int32_t buildIntervalForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput)
|
|||
return code;
|
||||
}
|
||||
((SColumnNode*)pInterval->pCol)->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
strcpy(((SColumnNode*)pInterval->pCol)->colName, ROWTS_PSEUDO_COLUMN_NAME);
|
||||
tstrncpy(((SColumnNode*)pInterval->pCol)->colName, ROWTS_PSEUDO_COLUMN_NAME, TSDB_COL_NAME_LEN);
|
||||
*pOutput = (SNode*)pInterval;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -9091,7 +9091,7 @@ static int32_t createColumnFromDef(SColumnDefNode* pDef, SNode** ppCol) {
|
|||
if (NULL == pCol) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pCol->colName, pDef->colName);
|
||||
tstrncpy(pCol->colName, pDef->colName, TSDB_COL_NAME_LEN);
|
||||
*ppCol = (SNode*)pCol;
|
||||
return code;
|
||||
}
|
||||
|
@ -9184,9 +9184,9 @@ static int32_t createTbnameFunction(SFunctionNode** ppFunc) {
|
|||
if (NULL == pFunc) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pFunc->functionName, "tbname");
|
||||
strcpy(pFunc->node.aliasName, "tbname");
|
||||
strcpy(pFunc->node.userAlias, "tbname");
|
||||
tstrncpy(pFunc->functionName, "tbname", TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.aliasName, "tbname", TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pFunc->node.userAlias, "tbname", TSDB_COL_NAME_LEN);
|
||||
*ppFunc = pFunc;
|
||||
return code;
|
||||
}
|
||||
|
@ -9383,7 +9383,7 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt*
|
|||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||
case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES: {
|
||||
TAOS_FIELD field = {.type = pStmt->dataType.type, .bytes = calcTypeBytes(pStmt->dataType)};
|
||||
strcpy(field.name, pStmt->colName);
|
||||
tstrncpy(field.name, pStmt->colName, 65);
|
||||
if (NULL == taosArrayPush(pAlterReq->pFields, &field)) {
|
||||
return terrno;
|
||||
}
|
||||
|
@ -9392,12 +9392,12 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt*
|
|||
case TSDB_ALTER_TABLE_UPDATE_TAG_NAME:
|
||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME: {
|
||||
TAOS_FIELD oldField = {0};
|
||||
strcpy(oldField.name, pStmt->colName);
|
||||
tstrncpy(oldField.name, pStmt->colName, 65);
|
||||
if (NULL == taosArrayPush(pAlterReq->pFields, &oldField)) {
|
||||
return terrno;
|
||||
}
|
||||
TAOS_FIELD newField = {0};
|
||||
strcpy(newField.name, pStmt->newColName);
|
||||
tstrncpy(newField.name, pStmt->newColName, 65);
|
||||
if (NULL == taosArrayPush(pAlterReq->pFields, &newField)) {
|
||||
return terrno;
|
||||
}
|
||||
|
@ -9405,7 +9405,7 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt*
|
|||
}
|
||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS: {
|
||||
TAOS_FIELD field = {0};
|
||||
strcpy(field.name, pStmt->colName);
|
||||
tstrncpy(field.name, pStmt->colName, 65);
|
||||
if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR;
|
||||
if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR;
|
||||
|
@ -9428,7 +9428,7 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt*
|
|||
if (!pAlterReq->pFields) return terrno;
|
||||
SFieldWithOptions field = {.type = pStmt->dataType.type, .bytes = calcTypeBytes(pStmt->dataType)};
|
||||
// TAOS_FIELD field = {.type = pStmt->dataType.type, .bytes = calcTypeBytes(pStmt->dataType)};
|
||||
strcpy(field.name, pStmt->colName);
|
||||
tstrncpy(field.name, pStmt->colName, TSDB_COL_NAME_LEN);
|
||||
if (pStmt->pColOptions != NULL) {
|
||||
if (!checkColumnEncodeOrSetDefault(pStmt->dataType.type, pStmt->pColOptions->encode))
|
||||
return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
|
@ -9669,12 +9669,12 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt
|
|||
if ((code = checkRangeOption(pCxt, TSDB_CODE_INVALID_OPTION, "sysinfo", pStmt->sysinfo, 0, 1, false))) {
|
||||
return code;
|
||||
}
|
||||
strcpy(createReq.user, pStmt->userName);
|
||||
tstrncpy(createReq.user, pStmt->userName, TSDB_USER_LEN);
|
||||
createReq.createType = 0;
|
||||
createReq.superUser = 0;
|
||||
createReq.sysInfo = pStmt->sysinfo;
|
||||
createReq.enable = 1;
|
||||
strcpy(createReq.pass, pStmt->password);
|
||||
tstrncpy(createReq.pass, pStmt->password, TSDB_USET_PASSWORD_LEN);
|
||||
createReq.isImport = pStmt->isImport;
|
||||
createReq.createDb = pStmt->createDb;
|
||||
|
||||
|
@ -9713,7 +9713,7 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt
|
|||
if ((code = checkAlterUser(pCxt, pStmt))) {
|
||||
return code;
|
||||
}
|
||||
strcpy(alterReq.user, pStmt->userName);
|
||||
tstrncpy(alterReq.user, pStmt->userName, TSDB_USER_LEN);
|
||||
alterReq.alterType = pStmt->alterType;
|
||||
alterReq.superUser = 0;
|
||||
alterReq.enable = pStmt->enable;
|
||||
|
@ -9739,7 +9739,7 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt
|
|||
|
||||
static int32_t translateDropUser(STranslateContext* pCxt, SDropUserStmt* pStmt) {
|
||||
SDropUserReq dropReq = {0};
|
||||
strcpy(dropReq.user, pStmt->userName);
|
||||
tstrncpy(dropReq.user, pStmt->userName, TSDB_USER_LEN);
|
||||
|
||||
int32_t code = buildCmdMsg(pCxt, TDMT_MND_DROP_USER, (FSerializeFunc)tSerializeSDropUserReq, &dropReq);
|
||||
tFreeSDropUserReq(&dropReq);
|
||||
|
@ -9785,7 +9785,7 @@ static int32_t translateUpdateAnode(STranslateContext* pCxt, SUpdateAnodeStmt* p
|
|||
|
||||
static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* pStmt) {
|
||||
SCreateDnodeReq createReq = {0};
|
||||
strcpy(createReq.fqdn, pStmt->fqdn);
|
||||
tstrncpy(createReq.fqdn, pStmt->fqdn, TSDB_FQDN_LEN);
|
||||
createReq.port = pStmt->port;
|
||||
|
||||
int32_t code = buildCmdMsg(pCxt, TDMT_MND_CREATE_DNODE, (FSerializeFunc)tSerializeSCreateDnodeReq, &createReq);
|
||||
|
@ -9796,7 +9796,7 @@ static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* p
|
|||
static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt) {
|
||||
SDropDnodeReq dropReq = {0};
|
||||
dropReq.dnodeId = pStmt->dnodeId;
|
||||
strcpy(dropReq.fqdn, pStmt->fqdn);
|
||||
tstrncpy(dropReq.fqdn, pStmt->fqdn, TSDB_FQDN_LEN);
|
||||
dropReq.port = pStmt->port;
|
||||
dropReq.force = pStmt->force;
|
||||
dropReq.unsafe = pStmt->unsafe;
|
||||
|
@ -9809,8 +9809,8 @@ static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt
|
|||
static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pStmt) {
|
||||
SMCfgDnodeReq cfgReq = {0};
|
||||
cfgReq.dnodeId = pStmt->dnodeId;
|
||||
strcpy(cfgReq.config, pStmt->config);
|
||||
strcpy(cfgReq.value, pStmt->value);
|
||||
tstrncpy(cfgReq.config, pStmt->config, TSDB_DNODE_CONFIG_LEN);
|
||||
tstrncpy(cfgReq.value, pStmt->value, TSDB_DNODE_VALUE_LEN);
|
||||
|
||||
int32_t code = 0;
|
||||
if (0 == strncasecmp(cfgReq.config, "encrypt_key", 12)) {
|
||||
|
@ -9857,8 +9857,8 @@ static int32_t translateRestoreDnode(STranslateContext* pCxt, SRestoreComponentN
|
|||
|
||||
static int32_t translateAlterCluster(STranslateContext* pCxt, SAlterClusterStmt* pStmt) {
|
||||
SMCfgClusterReq cfgReq = {0};
|
||||
strcpy(cfgReq.config, pStmt->config);
|
||||
strcpy(cfgReq.value, pStmt->value);
|
||||
tstrncpy(cfgReq.config, pStmt->config, TSDB_DNODE_CONFIG_LEN);
|
||||
tstrncpy(cfgReq.value, pStmt->value, TSDB_CLUSTER_VALUE_LEN);
|
||||
|
||||
int32_t code = buildCmdMsg(pCxt, TDMT_MND_CONFIG_CLUSTER, (FSerializeFunc)tSerializeSMCfgClusterReq, &cfgReq);
|
||||
tFreeSMCfgClusterReq(&cfgReq);
|
||||
|
@ -10329,9 +10329,9 @@ static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt*
|
|||
if (NULL == col) {
|
||||
return code;
|
||||
}
|
||||
strcpy(col->colName, column->name);
|
||||
strcpy(col->node.aliasName, col->colName);
|
||||
strcpy(col->node.userAlias, col->colName);
|
||||
tstrncpy(col->colName, column->name, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(col->node.aliasName, col->colName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(col->node.userAlias, col->colName, TSDB_COL_NAME_LEN);
|
||||
code = addTagList(&colCxt.pTags, (SNode*)col);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode((SNode*)col);
|
||||
|
@ -10368,9 +10368,9 @@ static int32_t buildQueryForTableTopic(STranslateContext* pCxt, SCreateTopicStmt
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesMakeNode(QUERY_NODE_REAL_TABLE, (SNode**)&realTable);
|
||||
if (realTable) {
|
||||
strcpy(realTable->table.dbName, pStmt->subDbName);
|
||||
strcpy(realTable->table.tableName, pStmt->subSTbName);
|
||||
strcpy(realTable->table.tableAlias, pStmt->subSTbName);
|
||||
tstrncpy(realTable->table.dbName, pStmt->subDbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(realTable->table.tableName, pStmt->subSTbName, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(realTable->table.tableAlias, pStmt->subSTbName, TSDB_TABLE_NAME_LEN);
|
||||
code = createSelectStmtImpl(true, pProjection, (SNode*)realTable, NULL, ppSelect);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -10443,7 +10443,7 @@ static int32_t translateDropCGroup(STranslateContext* pCxt, SDropCGroupStmt* pSt
|
|||
if (TSDB_CODE_SUCCESS != code) return code;
|
||||
(void)tNameGetFullDbName(&name, dropReq.topic);
|
||||
dropReq.igNotExists = pStmt->ignoreNotExists;
|
||||
strcpy(dropReq.cgroup, pStmt->cgroup);
|
||||
tstrncpy(dropReq.cgroup, pStmt->cgroup, TSDB_CGROUP_LEN);
|
||||
|
||||
return buildCmdMsg(pCxt, TDMT_MND_TMQ_DROP_CGROUP, (FSerializeFunc)tSerializeSMDropCgroupReq, &dropReq);
|
||||
}
|
||||
|
@ -10558,7 +10558,7 @@ static int32_t translateKillCompact(STranslateContext* pCxt, SKillStmt* pStmt) {
|
|||
|
||||
static int32_t translateKillQuery(STranslateContext* pCxt, SKillQueryStmt* pStmt) {
|
||||
SKillQueryReq killReq = {0};
|
||||
strcpy(killReq.queryStrId, pStmt->queryId);
|
||||
tstrncpy(killReq.queryStrId, pStmt->queryId, TSDB_QUERY_ID_LEN);
|
||||
return buildCmdMsg(pCxt, TDMT_MND_KILL_QUERY, (FSerializeFunc)tSerializeSKillQueryReq, &killReq);
|
||||
}
|
||||
|
||||
|
@ -10614,7 +10614,7 @@ static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pSt
|
|||
|
||||
static void getSourceDatabase(SNode* pStmt, int32_t acctId, char* pDbFName) {
|
||||
SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId};
|
||||
strcpy(name.dbname, ((SRealTableNode*)(((SSelectStmt*)pStmt)->pFromTable))->table.dbName);
|
||||
tstrncpy(name.dbname, ((SRealTableNode*)(((SSelectStmt*)pStmt)->pFromTable))->table.dbName, TSDB_DB_NAME_LEN);
|
||||
(void)tNameGetFullDbName(&name, pDbFName);
|
||||
}
|
||||
|
||||
|
@ -10673,7 +10673,7 @@ static int32_t addIrowTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSelect
|
|||
SColumnDefNode* pColDef = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_COLUMN_DEF, (SNode**)&pColDef);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
strcpy(pColDef->colName, pFunc->node.aliasName);
|
||||
tstrncpy(pColDef->colName, pFunc->node.aliasName, TSDB_COL_NAME_LEN);
|
||||
pColDef->dataType = pFunc->node.resType;
|
||||
pColDef->sma = true;
|
||||
code = setColumnDefNodePrimaryKey(pColDef, false);
|
||||
|
@ -10697,8 +10697,8 @@ static int32_t addWstartTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSele
|
|||
if (NULL == pFunc) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pFunc->functionName, "_wstart");
|
||||
strcpy(pFunc->node.userAlias, "_irowts");
|
||||
tstrncpy(pFunc->functionName, "_wstart", TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.userAlias, "_irowts", TSDB_COL_NAME_LEN);
|
||||
char* defaultName[] = {"_wstart", "ts", NULL};
|
||||
getStreamQueryFirstProjectAliasName(pUserAliasSet, pFunc->node.aliasName, sizeof(pFunc->node.aliasName), defaultName);
|
||||
code = getFuncInfo(pCxt, pFunc);
|
||||
|
@ -10710,7 +10710,7 @@ static int32_t addWstartTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSele
|
|||
SColumnDefNode* pColDef = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_COLUMN_DEF, (SNode**)&pColDef);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
strcpy(pColDef->colName, pFunc->node.aliasName);
|
||||
tstrncpy(pColDef->colName, pFunc->node.aliasName, TSDB_COL_NAME_LEN);
|
||||
pColDef->dataType = pFunc->node.resType;
|
||||
pColDef->sma = true;
|
||||
code = setColumnDefNodePrimaryKey(pColDef, false);
|
||||
|
@ -10870,7 +10870,7 @@ static int32_t addColDefNodeByProj(SNodeList** ppCols, const SNode* pProject, in
|
|||
SColumnDefNode* pColDef = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN_DEF, (SNode**)&pColDef);
|
||||
if (TSDB_CODE_SUCCESS != code) return code;
|
||||
strcpy(pColDef->colName, pExpr->userAlias);
|
||||
tstrncpy(pColDef->colName, pExpr->userAlias, TSDB_COL_NAME_LEN);
|
||||
pColDef->dataType = pExpr->resType;
|
||||
pColDef->sma = flags & COL_SMA_ON;
|
||||
code = setColumnDefNodePrimaryKey(pColDef, flags & COL_IS_KEY);
|
||||
|
@ -11171,7 +11171,7 @@ static int32_t adjustDataTypeOfProjections(STranslateContext* pCxt, const STable
|
|||
SColumnDefNode* pColDef = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN_DEF, (SNode**)&pColDef);
|
||||
if (TSDB_CODE_SUCCESS != code) return code;
|
||||
strcpy(pColDef->colName, pSchema->name);
|
||||
tstrncpy(pColDef->colName, pSchema->name, TSDB_COL_NAME_LEN);
|
||||
pColDef->dataType = dt;
|
||||
pColDef->sma = pSchema->flags & COL_SMA_ON;
|
||||
code = setColumnDefNodePrimaryKey(pColDef, pSchema->flags & COL_IS_KEY);
|
||||
|
@ -11214,7 +11214,7 @@ static int32_t addProjToProjColPos(STranslateContext* pCxt, const SSchema* pSche
|
|||
if (!dataTypeEqual(&dt, &((SExprNode*)pNewProj)->resType)) {
|
||||
SNode* pFunc = NULL;
|
||||
code = createCastFunc(pCxt, pNewProj, dt, &pFunc);
|
||||
strcpy(((SExprNode*)pFunc)->userAlias, ((SExprNode*)pNewProj)->userAlias);
|
||||
tstrncpy(((SExprNode*)pFunc)->userAlias, ((SExprNode*)pNewProj)->userAlias, TSDB_COL_NAME_LEN);
|
||||
pNewProj = pFunc;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -11783,8 +11783,8 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
|
|||
(void)tNameGetFullDbName(&name, pReq->name);
|
||||
|
||||
if ('\0' != pStmt->targetTabName[0]) {
|
||||
strcpy(name.dbname, pStmt->targetDbName);
|
||||
strcpy(name.tname, pStmt->targetTabName);
|
||||
tstrncpy(name.dbname, pStmt->targetDbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(name.tname, pStmt->targetTabName, TSDB_TABLE_NAME_LEN);
|
||||
code = tNameExtractFullName(&name, pReq->targetStbFullName);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -12010,7 +12010,7 @@ static int32_t translateCreateView(STranslateContext* pCxt, SCreateViewStmt* pSt
|
|||
pStmt->createReq.precision = res.schemaRes.precision;
|
||||
pStmt->createReq.numOfCols = res.schemaRes.numOfCols;
|
||||
pStmt->createReq.pSchema = res.schemaRes.pSchema;
|
||||
strncpy(pStmt->createReq.name, pStmt->viewName, sizeof(pStmt->createReq.name) - 1);
|
||||
tstrncpy(pStmt->createReq.name, pStmt->viewName, TSDB_VIEW_NAME_LEN);
|
||||
tstrncpy(pStmt->createReq.dbFName, dbFName, sizeof(pStmt->createReq.dbFName));
|
||||
snprintf(pStmt->createReq.fullname, sizeof(pStmt->createReq.fullname) - 1, "%s.%s", pStmt->createReq.dbFName,
|
||||
pStmt->viewName);
|
||||
|
@ -12039,7 +12039,7 @@ static int32_t translateDropView(STranslateContext* pCxt, SDropViewStmt* pStmt)
|
|||
int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
(void)tNameGetFullDbName(&name, dropReq.dbFName);
|
||||
strncpy(dropReq.name, pStmt->viewName, sizeof(dropReq.name) - 1);
|
||||
tstrncpy(dropReq.name, pStmt->viewName, TSDB_VIEW_NAME_LEN);
|
||||
snprintf(dropReq.fullname, sizeof(dropReq.fullname) - 1, "%s.%s", dropReq.dbFName, dropReq.name);
|
||||
dropReq.sql = (char*)pCxt->pParseCxt->pSql;
|
||||
if (NULL == dropReq.sql) {
|
||||
|
@ -12106,7 +12106,7 @@ static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionS
|
|||
}
|
||||
|
||||
SCreateFuncReq req = {0};
|
||||
strcpy(req.name, pStmt->funcName);
|
||||
tstrncpy(req.name, pStmt->funcName, TSDB_FUNC_NAME_LEN);
|
||||
req.orReplace = pStmt->orReplace;
|
||||
req.igExists = pStmt->ignoreExists;
|
||||
req.funcType = pStmt->isAgg ? TSDB_FUNC_TYPE_AGGREGATE : TSDB_FUNC_TYPE_SCALAR;
|
||||
|
@ -12125,7 +12125,7 @@ static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionS
|
|||
|
||||
static int32_t translateDropFunction(STranslateContext* pCxt, SDropFunctionStmt* pStmt) {
|
||||
SDropFuncReq req = {0};
|
||||
strcpy(req.name, pStmt->funcName);
|
||||
tstrncpy(req.name, pStmt->funcName, TSDB_FUNC_NAME_LEN);
|
||||
req.igNotExists = pStmt->ignoreNotExists;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_DROP_FUNC, (FSerializeFunc)tSerializeSDropFuncReq, &req);
|
||||
}
|
||||
|
@ -12136,9 +12136,9 @@ static int32_t createRealTableForGrantTable(SGrantStmt* pStmt, SRealTableNode**
|
|||
if (NULL == pRealTable) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pRealTable->table.dbName, pStmt->objName);
|
||||
strcpy(pRealTable->table.tableName, pStmt->tabName);
|
||||
strcpy(pRealTable->table.tableAlias, pStmt->tabName);
|
||||
tstrncpy(pRealTable->table.dbName, pStmt->objName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pRealTable->table.tableName, pStmt->tabName, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pRealTable->table.tableAlias, pStmt->tabName, TSDB_TABLE_NAME_LEN);
|
||||
*pTable = pRealTable;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -12213,7 +12213,7 @@ static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) {
|
|||
}
|
||||
#endif
|
||||
|
||||
strcpy(req.user, pStmt->userName);
|
||||
tstrncpy(req.user, pStmt->userName, TSDB_USER_LEN);
|
||||
sprintf(req.objname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->objName);
|
||||
sprintf(req.tabName, "%s", pStmt->tabName);
|
||||
if (!req.isView) {
|
||||
|
@ -12249,7 +12249,7 @@ static int32_t translateRevoke(STranslateContext* pCxt, SRevokeStmt* pStmt) {
|
|||
}
|
||||
#endif
|
||||
|
||||
strcpy(req.user, pStmt->userName);
|
||||
tstrncpy(req.user, pStmt->userName, TSDB_USER_LEN);
|
||||
sprintf(req.objname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->objName);
|
||||
sprintf(req.tabName, "%s", pStmt->tabName);
|
||||
code = buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req);
|
||||
|
@ -12267,7 +12267,7 @@ static int32_t translateBalanceVgroup(STranslateContext* pCxt, SBalanceVgroupStm
|
|||
static int32_t translateBalanceVgroupLeader(STranslateContext* pCxt, SBalanceVgroupLeaderStmt* pStmt) {
|
||||
SBalanceVgroupLeaderReq req = {0};
|
||||
req.vgId = pStmt->vgId;
|
||||
strcpy(req.db, pStmt->dbName);
|
||||
tstrncpy(req.db, pStmt->dbName, TSDB_DB_FNAME_LEN);
|
||||
int32_t code =
|
||||
buildCmdMsg(pCxt, TDMT_MND_BALANCE_VGROUP_LEADER, (FSerializeFunc)tSerializeSBalanceVgroupLeaderReq, &req);
|
||||
tFreeSBalanceVgroupLeaderReq(&req);
|
||||
|
@ -12553,7 +12553,7 @@ static int32_t createColumnBySchema(const SSchema* pSchema, SColumnNode** ppCol)
|
|||
(*ppCol)->colId = pSchema->colId;
|
||||
(*ppCol)->node.resType.type = pSchema->type;
|
||||
(*ppCol)->node.resType.bytes = pSchema->bytes;
|
||||
strcpy((*ppCol)->colName, pSchema->name);
|
||||
tstrncpy((*ppCol)->colName, pSchema->name, TSDB_COL_NAME_LEN);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -13102,9 +13102,9 @@ static int32_t extractQueryResultSchema(const SNodeList* pProjections, int32_t*
|
|||
}
|
||||
(*pSchema)[index].colId = index + 1;
|
||||
if ('\0' != pExpr->userAlias[0]) {
|
||||
strcpy((*pSchema)[index].name, pExpr->userAlias);
|
||||
tstrncpy((*pSchema)[index].name, pExpr->userAlias, TSDB_COL_NAME_LEN);
|
||||
} else {
|
||||
strcpy((*pSchema)[index].name, pExpr->aliasName);
|
||||
tstrncpy((*pSchema)[index].name, pExpr->aliasName, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
|
@ -13122,7 +13122,7 @@ static int32_t extractExplainResultSchema(int32_t* numOfCols, SSchema** pSchema)
|
|||
}
|
||||
(*pSchema)[0].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[0].bytes = TSDB_EXPLAIN_RESULT_ROW_SIZE;
|
||||
strcpy((*pSchema)[0].name, TSDB_EXPLAIN_RESULT_COLUMN_NAME);
|
||||
tstrncpy((*pSchema)[0].name, TSDB_EXPLAIN_RESULT_COLUMN_NAME, TSDB_COL_NAME_LEN);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -13136,32 +13136,32 @@ static int32_t extractDescribeResultSchema(STableMeta* pMeta, int32_t* numOfCols
|
|||
|
||||
(*pSchema)[0].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[0].bytes = DESCRIBE_RESULT_FIELD_LEN;
|
||||
strcpy((*pSchema)[0].name, "field");
|
||||
tstrncpy((*pSchema)[0].name, "field", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[1].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[1].bytes = DESCRIBE_RESULT_TYPE_LEN;
|
||||
strcpy((*pSchema)[1].name, "type");
|
||||
tstrncpy((*pSchema)[1].name, "type", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[2].type = TSDB_DATA_TYPE_INT;
|
||||
(*pSchema)[2].bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes;
|
||||
strcpy((*pSchema)[2].name, "length");
|
||||
tstrncpy((*pSchema)[2].name, "length", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[3].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[3].bytes = DESCRIBE_RESULT_NOTE_LEN;
|
||||
strcpy((*pSchema)[3].name, "note");
|
||||
tstrncpy((*pSchema)[3].name, "note", TSDB_COL_NAME_LEN);
|
||||
|
||||
if (pMeta && useCompress(pMeta->tableType)) {
|
||||
(*pSchema)[4].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[4].bytes = DESCRIBE_RESULT_COPRESS_OPTION_LEN;
|
||||
strcpy((*pSchema)[4].name, "encode");
|
||||
tstrncpy((*pSchema)[4].name, "encode", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[5].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[5].bytes = DESCRIBE_RESULT_COPRESS_OPTION_LEN;
|
||||
strcpy((*pSchema)[5].name, "compress");
|
||||
tstrncpy((*pSchema)[5].name, "compress", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[6].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[6].bytes = DESCRIBE_RESULT_COPRESS_OPTION_LEN;
|
||||
strcpy((*pSchema)[6].name, "level");
|
||||
tstrncpy((*pSchema)[6].name, "level", TSDB_COL_NAME_LEN);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -13176,11 +13176,11 @@ static int32_t extractShowCreateDatabaseResultSchema(int32_t* numOfCols, SSchema
|
|||
|
||||
(*pSchema)[0].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[0].bytes = TSDB_DB_NAME_LEN;
|
||||
strcpy((*pSchema)[0].name, "Database");
|
||||
tstrncpy((*pSchema)[0].name, "Database", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[1].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[1].bytes = TSDB_MAX_BINARY_LEN;
|
||||
strcpy((*pSchema)[1].name, "Create Database");
|
||||
tstrncpy((*pSchema)[1].name, "Create Database", TSDB_COL_NAME_LEN);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -13194,11 +13194,11 @@ static int32_t extractShowCreateTableResultSchema(int32_t* numOfCols, SSchema**
|
|||
|
||||
(*pSchema)[0].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[0].bytes = SHOW_CREATE_TB_RESULT_FIELD1_LEN;
|
||||
strcpy((*pSchema)[0].name, "Table");
|
||||
tstrncpy((*pSchema)[0].name, "Table", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[1].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[1].bytes = SHOW_CREATE_TB_RESULT_FIELD2_LEN;
|
||||
strcpy((*pSchema)[1].name, "Create Table");
|
||||
tstrncpy((*pSchema)[1].name, "Create Table", TSDB_COL_NAME_LEN);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -13212,11 +13212,11 @@ static int32_t extractShowCreateViewResultSchema(int32_t* numOfCols, SSchema** p
|
|||
|
||||
(*pSchema)[0].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[0].bytes = SHOW_CREATE_VIEW_RESULT_FIELD1_LEN;
|
||||
strcpy((*pSchema)[0].name, "View");
|
||||
tstrncpy((*pSchema)[0].name, "View", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[1].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[1].bytes = SHOW_CREATE_VIEW_RESULT_FIELD2_LEN;
|
||||
strcpy((*pSchema)[1].name, "Create View");
|
||||
tstrncpy((*pSchema)[1].name, "Create View", TSDB_COL_NAME_LEN);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -13230,19 +13230,19 @@ static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pS
|
|||
|
||||
(*pSchema)[0].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[0].bytes = TSDB_CONFIG_OPTION_LEN;
|
||||
strcpy((*pSchema)[0].name, "name");
|
||||
tstrncpy((*pSchema)[0].name, "name", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[1].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[1].bytes = TSDB_CONFIG_PATH_LEN;
|
||||
strcpy((*pSchema)[1].name, "value");
|
||||
tstrncpy((*pSchema)[1].name, "value", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[2].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[2].bytes = TSDB_CONFIG_SCOPE_LEN;
|
||||
strcpy((*pSchema)[2].name, "scope");
|
||||
tstrncpy((*pSchema)[2].name, "scope", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[3].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[3].bytes = TSDB_CONFIG_INFO_LEN;
|
||||
strcpy((*pSchema)[3].name, "info");
|
||||
tstrncpy((*pSchema)[3].name, "info", TSDB_COL_NAME_LEN);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -13256,15 +13256,15 @@ static int32_t extractCompactDbResultSchema(int32_t* numOfCols, SSchema** pSchem
|
|||
|
||||
(*pSchema)[0].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[0].bytes = COMPACT_DB_RESULT_FIELD1_LEN;
|
||||
strcpy((*pSchema)[0].name, "result");
|
||||
tstrncpy((*pSchema)[0].name, "result", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[1].type = TSDB_DATA_TYPE_INT;
|
||||
(*pSchema)[1].bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes;
|
||||
strcpy((*pSchema)[1].name, "id");
|
||||
tstrncpy((*pSchema)[1].name, "id", TSDB_COL_NAME_LEN);
|
||||
|
||||
(*pSchema)[2].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[2].bytes = COMPACT_DB_RESULT_FIELD3_LEN;
|
||||
strcpy((*pSchema)[2].name, "reason");
|
||||
tstrncpy((*pSchema)[2].name, "reason", TSDB_COL_NAME_LEN);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -13309,7 +13309,7 @@ static int32_t createStarCol(SNode** ppNode) {
|
|||
if (NULL == pCol) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pCol->colName, "*");
|
||||
tstrncpy(pCol->colName, "*", TSDB_COL_NAME_LEN);
|
||||
*ppNode = (SNode*)pCol;
|
||||
return code;
|
||||
}
|
||||
|
@ -13453,8 +13453,8 @@ static int32_t createParOperatorNode(EOperatorType opType, const char* pLeftCol,
|
|||
nodesDestroyNode((SNode*)pOper);
|
||||
return code;
|
||||
}
|
||||
strcpy(((SColumnNode*)pOper->pLeft)->colName, pLeftCol);
|
||||
strcpy(((SColumnNode*)pOper->pRight)->colName, pRightCol);
|
||||
tstrncpy(((SColumnNode*)pOper->pLeft)->colName, pLeftCol, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(((SColumnNode*)pOper->pRight)->colName, pRightCol, TSDB_COL_NAME_LEN);
|
||||
|
||||
*ppResOp = (SNode*)pOper;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -13721,7 +13721,7 @@ static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect)
|
|||
}
|
||||
|
||||
if (NULL != pShow->pDbName) {
|
||||
strcpy(((SRealTableNode*)pSelect->pFromTable)->qualDbName, ((SValueNode*)pShow->pDbName)->literal);
|
||||
tstrncpy(((SRealTableNode*)pSelect->pFromTable)->qualDbName, ((SValueNode*)pShow->pDbName)->literal, TSDB_DB_NAME_LEN);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -13794,7 +13794,7 @@ static int32_t createTagsFunction(SFunctionNode** ppNode) {
|
|||
if (NULL == pFunc) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pFunc->functionName, "_tags");
|
||||
tstrncpy(pFunc->functionName, "_tags", TSDB_FUNC_NAME_LEN);
|
||||
*ppNode = pFunc;
|
||||
return code;
|
||||
}
|
||||
|
@ -13892,8 +13892,8 @@ static int32_t createBlockDistInfoFunc(SFunctionNode** ppNode) {
|
|||
return code;
|
||||
}
|
||||
|
||||
strcpy(pFunc->functionName, "_block_dist_info");
|
||||
strcpy(pFunc->node.aliasName, "_block_dist_info");
|
||||
tstrncpy(pFunc->functionName, "_block_dist_info", TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.aliasName, "_block_dist_info", TSDB_COL_NAME_LEN);
|
||||
*ppNode = pFunc;
|
||||
return code;
|
||||
}
|
||||
|
@ -13905,8 +13905,8 @@ static int32_t createBlockDistFunc(SFunctionNode** ppNode) {
|
|||
return code;
|
||||
}
|
||||
|
||||
strcpy(pFunc->functionName, "_block_dist");
|
||||
strcpy(pFunc->node.aliasName, "_block_dist");
|
||||
tstrncpy(pFunc->functionName, "_block_dist", TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.aliasName, "_block_dist", TSDB_COL_NAME_LEN);
|
||||
SFunctionNode* pFuncNew = NULL;
|
||||
code = createBlockDistInfoFunc(&pFuncNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -13948,7 +13948,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
|
|||
SVgroupCreateTableBatch* pBatch) {
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId};
|
||||
(void)strcpy(name.dbname, pStmt->dbName);
|
||||
tstrncpy(name.dbname, pStmt->dbName, TSDB_DB_NAME_LEN);
|
||||
(void)tNameGetFullDbName(&name, dbFName);
|
||||
|
||||
SVCreateTbReq req = {0};
|
||||
|
@ -14004,7 +14004,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
|
|||
++index;
|
||||
}
|
||||
pBatch->info = *pVgroupInfo;
|
||||
(void)strcpy(pBatch->dbName, pStmt->dbName);
|
||||
tstrncpy(pBatch->dbName, pStmt->dbName, TSDB_DB_NAME_LEN);
|
||||
pBatch->req.pArray = taosArrayInit(1, sizeof(struct SVCreateTbReq));
|
||||
if (NULL == pBatch->req.pArray) {
|
||||
tdDestroySVCreateTbReq(&req);
|
||||
|
@ -14180,7 +14180,7 @@ static int32_t addCreateTbReqIntoVgroup(SHashObj* pVgroupHashmap, const char* db
|
|||
if (pTableBatch == NULL) {
|
||||
SVgroupCreateTableBatch tBatch = {0};
|
||||
tBatch.info = *pVgInfo;
|
||||
strcpy(tBatch.dbName, dbName);
|
||||
tstrncpy(tBatch.dbName, dbName, TSDB_DB_NAME_LEN);
|
||||
|
||||
tBatch.req.pArray = taosArrayInit(4, sizeof(struct SVCreateTbReq));
|
||||
if (!tBatch.req.pArray) {
|
||||
|
@ -14683,7 +14683,7 @@ static int32_t constructParseFileContext(SCreateSubTableFromFileClause* pStmt, S
|
|||
pParFileCxt->pTag = NULL;
|
||||
pParFileCxt->ctbName.type = TSDB_TABLE_NAME_T;
|
||||
pParFileCxt->ctbName.acctId = acctId;
|
||||
strcpy(pParFileCxt->ctbName.dbname, pStmt->useDbName);
|
||||
tstrncpy(pParFileCxt->ctbName.dbname, pStmt->useDbName, TSDB_DB_NAME_LEN);
|
||||
|
||||
if (NULL == pParFileCxt->aTagNames) {
|
||||
pParFileCxt->aTagNames = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||
|
@ -14757,8 +14757,8 @@ static int32_t prepareReadCsvFile(STranslateContext* pCxt, SCreateSubTableFromFi
|
|||
}
|
||||
|
||||
pCreateInfo->ignoreExists = pCreateStmt->ignoreExists;
|
||||
strncpy(pCreateInfo->useDbName, pCreateStmt->useDbName, TSDB_DB_NAME_LEN);
|
||||
strncpy(pCreateInfo->useTableName, pCreateStmt->useTableName, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pCreateInfo->useDbName, pCreateStmt->useDbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pCreateInfo->useTableName, pCreateStmt->useTableName, TSDB_TABLE_NAME_LEN);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -15958,8 +15958,8 @@ static int32_t createParCaseWhenNode(SNode* pCase, SNodeList* pWhenThenList, SNo
|
|||
pCaseWhen->pWhenThenList = pWhenThenList;
|
||||
pCaseWhen->pElse = pElse;
|
||||
if (pAias) {
|
||||
strcpy(pCaseWhen->node.aliasName, pAias);
|
||||
strcpy(pCaseWhen->node.userAlias, pAias);
|
||||
tstrncpy(pCaseWhen->node.aliasName, pAias, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pCaseWhen->node.userAlias, pAias, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
*ppResCaseWhen = (SNode*)pCaseWhen;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -15972,9 +15972,9 @@ static int32_t createParFunctionNode(const char* pFunName, const char* pAias, SN
|
|||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pFunc->functionName, pFunName);
|
||||
strcpy(pFunc->node.aliasName, pAias);
|
||||
strcpy(pFunc->node.userAlias, pAias);
|
||||
tstrncpy(pFunc->functionName, pFunName, TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.aliasName, pAias, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pFunc->node.userAlias, pAias, TSDB_COL_NAME_LEN);
|
||||
pFunc->pParameterList = pParameterList;
|
||||
*ppResFunc = (SNode*)pFunc;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -15999,7 +15999,7 @@ static int32_t createParTempTableNode(SSelectStmt* pSubquery, SNode** ppResTempT
|
|||
}
|
||||
pTempTable->pSubquery = (SNode*)pSubquery;
|
||||
taosRandStr(pTempTable->table.tableAlias, 8);
|
||||
strcpy(pSubquery->stmtName, pTempTable->table.tableAlias);
|
||||
tstrncpy(pSubquery->stmtName, pTempTable->table.tableAlias, TSDB_TABLE_NAME_LEN);
|
||||
pSubquery->isSubquery = true;
|
||||
*ppResTempTable = (SNode*)pTempTable;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -250,7 +250,7 @@ int32_t generateSyntaxErrMsgExt(SMsgBuf* pBuf, int32_t errCode, const char* pFor
|
|||
|
||||
int32_t buildInvalidOperationMsg(SMsgBuf* pBuf, const char* msg) {
|
||||
if (pBuf->buf) {
|
||||
strncpy(pBuf->buf, msg, pBuf->len);
|
||||
tstrncpy(pBuf->buf, msg, pBuf->len);
|
||||
}
|
||||
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
|
@ -277,7 +277,7 @@ int32_t buildSyntaxErrMsg(SMsgBuf* pBuf, const char* additionalInfo, const char*
|
|||
}
|
||||
|
||||
char buf[64] = {0}; // only extract part of sql string
|
||||
strncpy(buf, sourceStr, tListLen(buf) - 1);
|
||||
tstrncpy(buf, sourceStr, tListLen(buf));
|
||||
|
||||
if (additionalInfo != NULL) {
|
||||
snprintf(pBuf->buf, pBuf->len, msgFormat2, buf, additionalInfo);
|
||||
|
@ -454,7 +454,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
|
|||
continue;
|
||||
}
|
||||
STagVal val = {0};
|
||||
// strcpy(val.colName, colName);
|
||||
// TSDB_DB_FNAME_LENme, colName);
|
||||
val.pKey = jsonKey;
|
||||
retCode = taosHashPut(keyHash, jsonKey, keyLen, &keyLen,
|
||||
CHAR_BYTES); // add key to hash to remove dumplicate, value is useless
|
||||
|
@ -603,10 +603,10 @@ static int32_t getIntegerFromAuthStr(const char* pStart, char** pNext) {
|
|||
char* p = strchr(pStart, '*');
|
||||
char buf[10] = {0};
|
||||
if (NULL == p) {
|
||||
strcpy(buf, pStart);
|
||||
tstrncpy(buf, pStart, 10);
|
||||
*pNext = NULL;
|
||||
} else {
|
||||
strncpy(buf, pStart, p - pStart);
|
||||
tstrncpy(buf, pStart, p - pStart + 1);
|
||||
*pNext = ++p;
|
||||
}
|
||||
return taosStr2Int32(buf, NULL, 10);
|
||||
|
@ -615,10 +615,10 @@ static int32_t getIntegerFromAuthStr(const char* pStart, char** pNext) {
|
|||
static void getStringFromAuthStr(const char* pStart, char* pStr, char** pNext) {
|
||||
char* p = strchr(pStart, '*');
|
||||
if (NULL == p) {
|
||||
strcpy(pStr, pStart);
|
||||
tstrncpy(pStr, pStart, strlen(pStart) + 1);
|
||||
*pNext = NULL;
|
||||
} else {
|
||||
strncpy(pStr, pStart, p - pStart);
|
||||
tstrncpy(pStr, pStart, p - pStart + 1);
|
||||
*pNext = ++p;
|
||||
}
|
||||
if (*pStart == '`' && *(pStart + 1) == '`') {
|
||||
|
@ -652,7 +652,7 @@ static int32_t buildTableReq(SHashObj* pTablesHash, SArray** pTables) {
|
|||
size_t len = 0;
|
||||
char* pKey = taosHashGetKey(p, &len);
|
||||
char fullName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
strncpy(fullName, pKey, len);
|
||||
tstrncpy(fullName, pKey, len);
|
||||
SName name = {0};
|
||||
int32_t code = tNameFromString(&name, fullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -683,7 +683,7 @@ static int32_t buildDbReq(SHashObj* pDbsHash, SArray** pDbs) {
|
|||
size_t len = 0;
|
||||
char* pKey = taosHashGetKey(p, &len);
|
||||
char fullName[TSDB_DB_FNAME_LEN] = {0};
|
||||
strncpy(fullName, pKey, len);
|
||||
tstrncpy(fullName, pKey, len);
|
||||
if (NULL == taosArrayPush(*pDbs, fullName)) {
|
||||
taosHashCancelIterate(pDbsHash, p);
|
||||
taosArrayDestroy(*pDbs);
|
||||
|
@ -707,7 +707,7 @@ static int32_t buildTableReqFromDb(SHashObj* pDbsHash, SArray** pDbs) {
|
|||
SParseTablesMetaReq* p = taosHashIterate(pDbsHash, NULL);
|
||||
while (NULL != p) {
|
||||
STablesReq req = {0};
|
||||
strcpy(req.dbFName, p->dbFName);
|
||||
tstrncpy(req.dbFName, p->dbFName, TSDB_DB_FNAME_LEN);
|
||||
int32_t code = buildTableReq(p->pTables, &req.pTables);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL == taosArrayPush(*pDbs, &req)) {
|
||||
|
@ -737,7 +737,7 @@ static int32_t buildUserAuthReq(SHashObj* pUserAuthHash, SArray** pUserAuth) {
|
|||
size_t len = 0;
|
||||
char* pKey = taosHashGetKey(p, &len);
|
||||
char key[USER_AUTH_KEY_MAX_LEN] = {0};
|
||||
strncpy(key, pKey, len);
|
||||
tstrncpy(key, pKey, len);
|
||||
SUserAuthInfo userAuth = {0};
|
||||
stringToUserAuth(key, len, &userAuth);
|
||||
if (NULL == taosArrayPush(*pUserAuth, &userAuth)) {
|
||||
|
@ -763,7 +763,7 @@ static int32_t buildUdfReq(SHashObj* pUdfHash, SArray** pUdf) {
|
|||
size_t len = 0;
|
||||
char* pFunc = taosHashGetKey(p, &len);
|
||||
char func[TSDB_FUNC_NAME_LEN] = {0};
|
||||
strncpy(func, pFunc, len);
|
||||
tstrncpy(func, pFunc, len);
|
||||
if (NULL == taosArrayPush(*pUdf, func)) {
|
||||
taosHashCancelIterate(pUdfHash, p);
|
||||
taosArrayDestroy(*pUdf);
|
||||
|
|
|
@ -5489,8 +5489,8 @@ static int32_t tbCntScanOptCreateSumFunc(SFunctionNode* pCntFunc, SNode* pParam,
|
|||
if (NULL == pFunc) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pFunc->functionName, "sum");
|
||||
strcpy(pFunc->node.aliasName, pCntFunc->node.aliasName);
|
||||
tstrncpy(pFunc->functionName, "sum", TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pFunc->node.aliasName, pCntFunc->node.aliasName, TSDB_COL_NAME_LEN);
|
||||
code = createColumnByRewriteExpr(pParam, &pFunc->pParameterList);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = fmGetFuncInfo(pFunc, NULL, 0);
|
||||
|
|
|
@ -428,7 +428,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex, uint8_t pr
|
|||
if (NULL == pWStart) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pWStart->functionName, "_wstart");
|
||||
tstrncpy(pWStart->functionName, "_wstart", TSDB_FUNC_NAME_LEN);
|
||||
int64_t pointer = (int64_t)pWStart;
|
||||
char name[TSDB_COL_NAME_LEN + TSDB_POINTER_PRINT_BYTES + TSDB_NAME_DELIMITER_LEN + 1] = {0};
|
||||
int32_t len = tsnprintf(name, sizeof(name) - 1, "%s.%" PRId64 "", pWStart->functionName, pointer);
|
||||
|
@ -460,7 +460,7 @@ static int32_t stbSplAppendWEnd(SWindowLogicNode* pWin, int32_t* pIndex) {
|
|||
if (NULL == pWEnd) {
|
||||
return code;
|
||||
}
|
||||
strcpy(pWEnd->functionName, "_wend");
|
||||
tstrncpy(pWEnd->functionName, "_wend", TSDB_FUNC_NAME_LEN);
|
||||
int64_t pointer = (int64_t)pWEnd;
|
||||
char name[TSDB_COL_NAME_LEN + TSDB_POINTER_PRINT_BYTES + TSDB_NAME_DELIMITER_LEN + 1] = {0};
|
||||
int32_t len = tsnprintf(name, sizeof(name) - 1, "%s.%" PRId64 "", pWEnd->functionName, pointer);
|
||||
|
@ -1137,8 +1137,8 @@ static int32_t stbSplAggNodeCreateMerge(SSplitContext* pCtx, SStableSplitInfo* p
|
|||
if (!nodesEqualNode(pParam, (SNode*)pCol)) continue;
|
||||
|
||||
// use the colName of group_key func to make sure finding the right slot id for merge keys.
|
||||
strcpy(pCol->colName, pFunc->node.aliasName);
|
||||
strcpy(pCol->node.aliasName, pFunc->node.aliasName);
|
||||
tstrncpy(pCol->colName, pFunc->node.aliasName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pCol->node.aliasName, pFunc->node.aliasName, TSDB_COL_NAME_LEN);
|
||||
memset(pCol->tableAlias, 0, TSDB_TABLE_NAME_LEN);
|
||||
break;
|
||||
}
|
||||
|
@ -1267,15 +1267,15 @@ static int32_t stbSplCreateColumnNode(SExprNode* pExpr, SNode** ppNode) {
|
|||
return code;
|
||||
}
|
||||
if (QUERY_NODE_COLUMN == nodeType(pExpr)) {
|
||||
strcpy(pCol->dbName, ((SColumnNode*)pExpr)->dbName);
|
||||
strcpy(pCol->tableName, ((SColumnNode*)pExpr)->tableName);
|
||||
strcpy(pCol->tableAlias, ((SColumnNode*)pExpr)->tableAlias);
|
||||
strcpy(pCol->colName, ((SColumnNode*)pExpr)->colName);
|
||||
tstrncpy(pCol->dbName, ((SColumnNode*)pExpr)->dbName, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pCol->tableName, ((SColumnNode*)pExpr)->tableName, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pCol->tableAlias, ((SColumnNode*)pExpr)->tableAlias, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pCol->colName, ((SColumnNode*)pExpr)->colName, TSDB_COL_NAME_LEN);
|
||||
} else {
|
||||
strcpy(pCol->colName, pExpr->aliasName);
|
||||
tstrncpy(pCol->colName, pExpr->aliasName, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
strcpy(pCol->node.aliasName, pExpr->aliasName);
|
||||
strcpy(pCol->node.userAlias, pExpr->userAlias);
|
||||
tstrncpy(pCol->node.aliasName, pExpr->aliasName, TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pCol->node.userAlias, pExpr->userAlias, TSDB_COL_NAME_LEN);
|
||||
pCol->node.resType = pExpr->resType;
|
||||
*ppNode = (SNode*)pCol;
|
||||
return code;
|
||||
|
|
Loading…
Reference in New Issue