Merge branch '3.0' of https://github.com/taosdata/TDengine into fix/TD-32474-3.0
This commit is contained in:
commit
97e99cf09e
|
@ -214,7 +214,7 @@ extern int64_t tsMinDiskFreeSize;
|
|||
// udf
|
||||
extern bool tsStartUdfd;
|
||||
extern char tsUdfdResFuncs[];
|
||||
extern char tsUdfdLdLibPath[];
|
||||
extern char tsUdfdLdLibPath[512];
|
||||
|
||||
// schemaless
|
||||
extern char tsSmlChildTableName[];
|
||||
|
|
|
@ -29,6 +29,6 @@ int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs)
|
|||
int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp);
|
||||
int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t groupId, SRetrieveTableRsp **pRsp);
|
||||
void qExplainFreeCtx(SExplainCtx *pCtx);
|
||||
int32_t formatDurationOrKeep(char* buffer, int32_t timeInMinutes);
|
||||
int32_t formatDurationOrKeep(char* buffer, int64_t bufSize, int32_t timeInMinutes);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -336,7 +336,7 @@ char* jobTaskStatusStr(int32_t status);
|
|||
SSchema createSchema(int8_t type, int32_t bytes, col_id_t colId, const char* name);
|
||||
|
||||
void destroyQueryExecRes(SExecResult* pRes);
|
||||
int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t* len);
|
||||
int32_t dataConverToStr(char* str, int64_t capacity, int type, void* buf, int32_t bufSize, int32_t* len);
|
||||
void parseTagDatatoJson(void* p, char** jsonStr);
|
||||
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
|
||||
void getColumnTypeFromMeta(STableMeta* pMeta, char* pName, ETableColumnType* pType);
|
||||
|
|
|
@ -68,6 +68,7 @@ typedef enum { M2C = 0, C2M } ConvType;
|
|||
#define TAOS_STRCPY(_dst, _src) ((void)strcpy(_dst, _src))
|
||||
#define TAOS_STRNCPY(_dst, _src, _size) ((void)strncpy(_dst, _src, _size))
|
||||
#define TAOS_STRCAT(_dst, _src) ((void)strcat(_dst, _src))
|
||||
#define TAOS_STRNCAT(_dst, _src, len) ((void)strncat(_dst, _src, len))
|
||||
|
||||
char *tstrdup(const char *src);
|
||||
int32_t taosUcs4len(TdUcs4 *ucs4);
|
||||
|
|
|
@ -458,15 +458,17 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
|||
cJSON* tvalue = NULL;
|
||||
if (IS_VAR_DATA_TYPE(pTagVal->type)) {
|
||||
char* buf = NULL;
|
||||
int64_t bufSize = 0;
|
||||
if (pTagVal->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||
buf = taosMemoryCalloc(pTagVal->nData * 2 + 2 + 3, 1);
|
||||
bufSize = pTagVal->nData * 2 + 2 + 3;
|
||||
} else {
|
||||
buf = taosMemoryCalloc(pTagVal->nData + 3, 1);
|
||||
bufSize = pTagVal->nData + 3;
|
||||
}
|
||||
buf = taosMemoryCalloc(bufSize, 1);
|
||||
|
||||
RAW_NULL_CHECK(buf);
|
||||
if (!buf) goto end;
|
||||
if (dataConverToStr(buf, pTagVal->type, pTagVal->pData, pTagVal->nData, NULL) != TSDB_CODE_SUCCESS) {
|
||||
if (dataConverToStr(buf, bufSize, pTagVal->type, pTagVal->pData, pTagVal->nData, NULL) != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(buf);
|
||||
goto end;
|
||||
}
|
||||
|
@ -736,13 +738,15 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
goto end;
|
||||
}
|
||||
} else {
|
||||
int64_t bufSize = 0;
|
||||
if (vAlterTbReq.tagType == TSDB_DATA_TYPE_VARBINARY) {
|
||||
buf = taosMemoryCalloc(vAlterTbReq.nTagVal * 2 + 2 + 3, 1);
|
||||
bufSize = vAlterTbReq.nTagVal * 2 + 2 + 3;
|
||||
} else {
|
||||
buf = taosMemoryCalloc(vAlterTbReq.nTagVal + 3, 1);
|
||||
bufSize = vAlterTbReq.nTagVal + 3;
|
||||
}
|
||||
buf = taosMemoryCalloc(bufSize, 1);
|
||||
RAW_NULL_CHECK(buf);
|
||||
if (dataConverToStr(buf, vAlterTbReq.tagType, vAlterTbReq.pTagVal, vAlterTbReq.nTagVal, NULL) !=
|
||||
if (dataConverToStr(buf, bufSize, vAlterTbReq.tagType, vAlterTbReq.pTagVal, vAlterTbReq.nTagVal, NULL) !=
|
||||
TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(buf);
|
||||
goto end;
|
||||
|
|
|
@ -2366,7 +2366,7 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
|||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, rows, (const char *)strictVstr, false), &lino, _OVER);
|
||||
|
||||
char durationVstr[128] = {0};
|
||||
int32_t len = formatDurationOrKeep(&durationVstr[VARSTR_HEADER_SIZE], pDb->cfg.daysPerFile);
|
||||
int32_t len = formatDurationOrKeep(&durationVstr[VARSTR_HEADER_SIZE], sizeof(durationVstr) - VARSTR_HEADER_SIZE, pDb->cfg.daysPerFile);
|
||||
|
||||
varDataSetLen(durationVstr, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -2377,9 +2377,9 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
|||
char keep1Str[128] = {0};
|
||||
char keep2Str[128] = {0};
|
||||
|
||||
int32_t lenKeep0 = formatDurationOrKeep(keep0Str, pDb->cfg.daysToKeep0);
|
||||
int32_t lenKeep1 = formatDurationOrKeep(keep1Str, pDb->cfg.daysToKeep1);
|
||||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, pDb->cfg.daysToKeep2);
|
||||
int32_t lenKeep0 = formatDurationOrKeep(keep0Str, sizeof(keep0Str), pDb->cfg.daysToKeep0);
|
||||
int32_t lenKeep1 = formatDurationOrKeep(keep1Str, sizeof(keep1Str), pDb->cfg.daysToKeep1);
|
||||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, sizeof(keep2Str), pDb->cfg.daysToKeep2);
|
||||
|
||||
if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) {
|
||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep1Str, keep2Str, keep0Str);
|
||||
|
|
|
@ -157,7 +157,7 @@ static void *mndBuildDropIdxReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStbOb
|
|||
pHead->contLen = htonl(len);
|
||||
pHead->vgId = htonl(pVgroup->vgId);
|
||||
|
||||
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
||||
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
||||
int32_t ret = 0;
|
||||
if ((ret = tSerializeSDropIdxReq(pBuf, len - sizeof(SMsgHead), &req)) < 0) {
|
||||
terrno = ret;
|
||||
|
@ -662,6 +662,8 @@ static int32_t mndSetUpdateIdxStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb
|
|||
|
||||
pNew->pTags = NULL;
|
||||
pNew->pColumns = NULL;
|
||||
pNew->pCmpr = NULL;
|
||||
pNew->pTags = NULL;
|
||||
pNew->updateTime = taosGetTimestampMs();
|
||||
pNew->lock = 0;
|
||||
|
||||
|
|
|
@ -291,7 +291,8 @@ static int32_t buildRetension(SArray* pRetension, char** ppRetentions) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char* p1 = taosMemoryCalloc(1, 100);
|
||||
const int lMaxLen = 128;
|
||||
char* p1 = taosMemoryCalloc(1, lMaxLen);
|
||||
if (NULL == p1) {
|
||||
return terrno;
|
||||
}
|
||||
|
@ -302,13 +303,13 @@ static int32_t buildRetension(SArray* pRetension, char** ppRetentions) {
|
|||
int64_t v1 = getValOfDiffPrecision(p->freqUnit, p->freq);
|
||||
int64_t v2 = getValOfDiffPrecision(p->keepUnit, p->keep);
|
||||
if (i == 0) {
|
||||
len += sprintf(p1 + len, "-:%" PRId64 "%c", v2, p->keepUnit);
|
||||
len += snprintf(p1 + len, lMaxLen - len, "-:%" PRId64 "%c", v2, p->keepUnit);
|
||||
} else {
|
||||
len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit);
|
||||
len += snprintf(p1 + len, lMaxLen - len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit);
|
||||
}
|
||||
|
||||
if (i < size - 1) {
|
||||
len += sprintf(p1 + len, ",");
|
||||
len += snprintf(p1 + len, lMaxLen - len, ",");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,16 +345,19 @@ static const char* encryptAlgorithmStr(int8_t encryptAlgorithm) {
|
|||
return TSDB_CACHE_MODEL_NONE_STR;
|
||||
}
|
||||
|
||||
int32_t formatDurationOrKeep(char* buffer, int32_t timeInMinutes) {
|
||||
int32_t formatDurationOrKeep(char* buffer, int64_t bufSize, int32_t timeInMinutes) {
|
||||
if (buffer == NULL || bufSize <= 0) {
|
||||
return 0;
|
||||
}
|
||||
int32_t len = 0;
|
||||
if (timeInMinutes % 1440 == 0) {
|
||||
int32_t days = timeInMinutes / 1440;
|
||||
len = sprintf(buffer, "%dd", days);
|
||||
int32_t days = timeInMinutes / 1440;
|
||||
len = snprintf(buffer, bufSize, "%dd", days);
|
||||
} else if (timeInMinutes % 60 == 0) {
|
||||
int32_t hours = timeInMinutes / 60;
|
||||
len = sprintf(buffer, "%dh", hours);
|
||||
int32_t hours = timeInMinutes / 60;
|
||||
len = snprintf(buffer, bufSize, "%dh", hours);
|
||||
} else {
|
||||
len = sprintf(buffer, "%dm", timeInMinutes);
|
||||
len = snprintf(buffer, bufSize, "%dm", timeInMinutes);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
@ -400,15 +404,15 @@ static int32_t setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName,
|
|||
char keep1Str[128] = {0};
|
||||
char keep2Str[128] = {0};
|
||||
|
||||
int32_t lenDuration = formatDurationOrKeep(durationStr, pCfg->daysPerFile);
|
||||
int32_t lenKeep0 = formatDurationOrKeep(keep0Str, pCfg->daysToKeep0);
|
||||
int32_t lenKeep1 = formatDurationOrKeep(keep1Str, pCfg->daysToKeep1);
|
||||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, pCfg->daysToKeep2);
|
||||
int32_t lenDuration = formatDurationOrKeep(durationStr, sizeof(durationStr), pCfg->daysPerFile);
|
||||
int32_t lenKeep0 = formatDurationOrKeep(keep0Str, sizeof(keep0Str), pCfg->daysToKeep0);
|
||||
int32_t lenKeep1 = formatDurationOrKeep(keep1Str, sizeof(keep1Str), pCfg->daysToKeep1);
|
||||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, sizeof(keep2Str), pCfg->daysToKeep2);
|
||||
|
||||
if (IS_SYS_DBNAME(dbName)) {
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE DATABASE `%s`", dbName);
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, "CREATE DATABASE `%s`", dbName);
|
||||
} else {
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE,
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
"CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %s "
|
||||
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %s,%s,%s PAGES %d PAGESIZE %d "
|
||||
"PRECISION '%s' REPLICA %d "
|
||||
|
@ -426,7 +430,7 @@ static int32_t setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName,
|
|||
pCfg->s3KeepLocal, pCfg->s3Compact);
|
||||
|
||||
if (pRetentions) {
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", pRetentions);
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, " RETENTIONS %s", pRetentions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -503,28 +507,32 @@ static int32_t buildCreateViewResultDataBlock(SSDataBlock** pOutput) {
|
|||
void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||
for (int32_t i = 0; i < pCfg->numOfColumns; ++i) {
|
||||
SSchema* pSchema = pCfg->pSchemas + i;
|
||||
char type[32 + 60]; // 60 byte for compress info
|
||||
sprintf(type, "%s", tDataTypes[pSchema->type].name);
|
||||
#define LTYPE_LEN (32 + 60) // 60 byte for compress info
|
||||
char type[LTYPE_LEN];
|
||||
snprintf(type, LTYPE_LEN, "%s", tDataTypes[pSchema->type].name);
|
||||
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type ||
|
||||
TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||
snprintf(type + strlen(type), LTYPE_LEN - strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||
} else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
snprintf(type + strlen(type), LTYPE_LEN - strlen(type), "(%d)",
|
||||
(int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
}
|
||||
|
||||
if (useCompress(pCfg->tableType) && pCfg->pSchemaExt) {
|
||||
sprintf(type + strlen(type), " ENCODE \'%s\'",
|
||||
columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||
sprintf(type + strlen(type), " COMPRESS \'%s\'",
|
||||
columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||
sprintf(type + strlen(type), " LEVEL \'%s\'",
|
||||
columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress)));
|
||||
snprintf(type + strlen(type), LTYPE_LEN - strlen(type), " ENCODE \'%s\'",
|
||||
columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||
snprintf(type + strlen(type), LTYPE_LEN - strlen(type), " COMPRESS \'%s\'",
|
||||
columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||
snprintf(type + strlen(type), LTYPE_LEN - strlen(type), " LEVEL \'%s\'",
|
||||
columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress)));
|
||||
}
|
||||
if (!(pSchema->flags & COL_IS_KEY)) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s",
|
||||
((i > 0) ? ", " : ""), pSchema->name, type);
|
||||
} else {
|
||||
char* pk = "PRIMARY KEY";
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s %s", ((i > 0) ? ", " : ""), pSchema->name, type, pk);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s %s",
|
||||
((i > 0) ? ", " : ""), pSchema->name, type, pk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -533,22 +541,25 @@ void appendTagFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
for (int32_t i = 0; i < pCfg->numOfTags; ++i) {
|
||||
SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i;
|
||||
char type[32];
|
||||
sprintf(type, "%s", tDataTypes[pSchema->type].name);
|
||||
snprintf(type, sizeof(type), "%s", tDataTypes[pSchema->type].name);
|
||||
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type ||
|
||||
TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||
snprintf(type + strlen(type), sizeof(type) - strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||
} else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
snprintf(type + strlen(type), sizeof(type) - strlen(type), "(%d)",
|
||||
(int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
}
|
||||
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, sizeof(type) - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s",
|
||||
((i > 0) ? ", " : ""), pSchema->name, type);
|
||||
}
|
||||
}
|
||||
|
||||
void appendTagNameFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||
for (int32_t i = 0; i < pCfg->numOfTags; ++i) {
|
||||
SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i;
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s`", ((i > 0) ? ", " : ""), pSchema->name);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
"%s`%s`", ((i > 0) ? ", " : ""), pSchema->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -565,11 +576,12 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
if (tTagIsJson(pTag)) {
|
||||
char* pJson = NULL;
|
||||
parseTagDatatoJson(pTag, &pJson);
|
||||
if(NULL == pJson) {
|
||||
if (NULL == pJson) {
|
||||
qError("failed to parse tag to json, pJson is NULL");
|
||||
return terrno;
|
||||
}
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
"%s", pJson);
|
||||
taosMemoryFree(pJson);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -582,11 +594,13 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
for (int32_t i = 0; i < pCfg->numOfTags; ++i) {
|
||||
SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i;
|
||||
if (i > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", ");
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
", ");
|
||||
}
|
||||
|
||||
if (j >= valueNum) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "NULL");
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
"NULL");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -599,17 +613,24 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
char type = pTagVal->type;
|
||||
int32_t tlen = 0;
|
||||
|
||||
int64_t leftSize = SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len);
|
||||
if (leftSize <= 0) {
|
||||
qError("no enough space to store tag value, leftSize:%" PRId64, leftSize);
|
||||
code = TSDB_CODE_APP_ERROR;
|
||||
TAOS_CHECK_ERRNO(code);
|
||||
}
|
||||
if (IS_VAR_DATA_TYPE(type)) {
|
||||
code = dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, type, pTagVal->pData, pTagVal->nData, &tlen);
|
||||
code = dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, leftSize, type, pTagVal->pData, pTagVal->nData, &tlen);
|
||||
TAOS_CHECK_ERRNO(code);
|
||||
} else {
|
||||
code = dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, type, &pTagVal->i64, tDataTypes[type].bytes, &tlen);
|
||||
code = dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, leftSize, type, &pTagVal->i64, tDataTypes[type].bytes, &tlen);
|
||||
TAOS_CHECK_ERRNO(code);
|
||||
}
|
||||
*len += tlen;
|
||||
j++;
|
||||
} else {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "NULL");
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
"NULL");
|
||||
}
|
||||
}
|
||||
_exit:
|
||||
|
@ -620,37 +641,47 @@ _exit:
|
|||
|
||||
void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg* pCfg) {
|
||||
if (pCfg->commentLen > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " COMMENT '%s'", pCfg->pComment);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" COMMENT '%s'", pCfg->pComment);
|
||||
} else if (0 == pCfg->commentLen) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " COMMENT ''");
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" COMMENT ''");
|
||||
}
|
||||
|
||||
if (NULL != pDbCfg->pRetensions && pCfg->watermark1 > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " WATERMARK %" PRId64 "a", pCfg->watermark1);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" WATERMARK %" PRId64 "a", pCfg->watermark1);
|
||||
if (pCfg->watermark2 > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", %" PRId64 "a", pCfg->watermark2);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
", %" PRId64 "a", pCfg->watermark2);
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL != pDbCfg->pRetensions && pCfg->delay1 > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " MAX_DELAY %" PRId64 "a", pCfg->delay1);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" MAX_DELAY %" PRId64 "a", pCfg->delay1);
|
||||
if (pCfg->delay2 > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", %" PRId64 "a", pCfg->delay2);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
", %" PRId64 "a", pCfg->delay2);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t funcNum = taosArrayGetSize(pCfg->pFuncs);
|
||||
if (NULL != pDbCfg->pRetensions && funcNum > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " ROLLUP(");
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" ROLLUP(");
|
||||
for (int32_t i = 0; i < funcNum; ++i) {
|
||||
char* pFunc = taosArrayGet(pCfg->pFuncs, i);
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s%s", ((i > 0) ? ", " : ""), pFunc);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
"%s%s", ((i > 0) ? ", " : ""), pFunc);
|
||||
}
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ")");
|
||||
*len +=
|
||||
snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), ")");
|
||||
}
|
||||
|
||||
if (pCfg->ttl > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " TTL %d", pCfg->ttl);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" TTL %d", pCfg->ttl);
|
||||
}
|
||||
|
||||
if (TSDB_SUPER_TABLE == pCfg->tableType || TSDB_NORMAL_TABLE == pCfg->tableType) {
|
||||
|
@ -663,18 +694,23 @@ void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg*
|
|||
|
||||
if (nSma < pCfg->numOfColumns && nSma > 0) {
|
||||
bool smaOn = false;
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " SMA(");
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" SMA(");
|
||||
for (int32_t i = 0; i < pCfg->numOfColumns; ++i) {
|
||||
if (IS_BSMA_ON(pCfg->pSchemas + i)) {
|
||||
if (smaOn) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ",`%s`", (pCfg->pSchemas + i)->name);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len,
|
||||
SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), ",`%s`",
|
||||
(pCfg->pSchemas + i)->name);
|
||||
} else {
|
||||
smaOn = true;
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "`%s`", (pCfg->pSchemas + i)->name);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len,
|
||||
SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "`%s`",
|
||||
(pCfg->pSchemas + i)->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ")");
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -698,24 +734,32 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p
|
|||
int32_t len = 0;
|
||||
|
||||
if (TSDB_SUPER_TABLE == pCfg->tableType) {
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE STABLE `%s` (", tbName);
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
"CREATE STABLE `%s` (", tbName);
|
||||
appendColumnFields(buf2, &len, pCfg);
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ") TAGS (");
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len),
|
||||
") TAGS (");
|
||||
appendTagFields(buf2, &len, pCfg);
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")");
|
||||
len +=
|
||||
snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len), ")");
|
||||
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
||||
} else if (TSDB_CHILD_TABLE == pCfg->tableType) {
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE TABLE `%s` USING `%s` (", tbName, pCfg->stbName);
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
"CREATE TABLE `%s` USING `%s` (", tbName, pCfg->stbName);
|
||||
appendTagNameFields(buf2, &len, pCfg);
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ") TAGS (");
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len),
|
||||
") TAGS (");
|
||||
code = appendTagValues(buf2, &len, pCfg);
|
||||
TAOS_CHECK_ERRNO(code);
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")");
|
||||
len +=
|
||||
snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len), ")");
|
||||
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
||||
} else {
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE TABLE `%s` (", tbName);
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
"CREATE TABLE `%s` (", tbName);
|
||||
appendColumnFields(buf2, &len, pCfg);
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")");
|
||||
len +=
|
||||
snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len), ")");
|
||||
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
||||
}
|
||||
|
||||
|
@ -792,9 +836,21 @@ static int32_t execAlterCmd(char* cmd, char* value, bool* processed) {
|
|||
taosResetLog();
|
||||
cfgDumpCfg(tsCfg, 0, false);
|
||||
} else if (0 == strcasecmp(cmd, COMMAND_SCHEDULE_POLICY)) {
|
||||
code = schedulerUpdatePolicy(atoi(value));
|
||||
int32_t tmp = 0;
|
||||
code = taosStr2int32(value, &tmp);
|
||||
if (code) {
|
||||
qError("invalid value:%s, error:%s", value, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
code = schedulerUpdatePolicy(tmp);
|
||||
} else if (0 == strcasecmp(cmd, COMMAND_ENABLE_RESCHEDULE)) {
|
||||
code = schedulerEnableReSchedule(atoi(value));
|
||||
int32_t tmp = 0;
|
||||
code = taosStr2int32(value, &tmp);
|
||||
if (code) {
|
||||
qError("invalid value:%s, error:%s", value, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
code = schedulerEnableReSchedule(tmp != 0);
|
||||
} else if (0 == strcasecmp(cmd, COMMAND_CATALOG_DEBUG)) {
|
||||
code = ctgdHandleDbgCommand(value);
|
||||
} else if (0 == strcasecmp(cmd, COMMAND_ENABLE_MEM_DEBUG)) {
|
||||
|
|
|
@ -833,6 +833,9 @@ void cleanupResultInfoInStream(SExecTaskInfo* pTaskInfo, void* pState, SExpr
|
|||
SGroupResInfo* pGroupResInfo);
|
||||
void cleanupResultInfo(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf,
|
||||
SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap);
|
||||
void cleanupResultInfoWithoutHash(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf,
|
||||
SGroupResInfo* pGroupResInfo);
|
||||
|
||||
int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize,
|
||||
const char* pkey, void* pState, SFunctionStateStore* pStore);
|
||||
void cleanupAggSup(SAggSupporter* pAggSup);
|
||||
|
|
|
@ -159,8 +159,8 @@ void destroyAggOperatorInfo(void* param) {
|
|||
cleanupBasicInfo(&pInfo->binfo);
|
||||
|
||||
if (pInfo->pOperator) {
|
||||
cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf,
|
||||
&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable);
|
||||
cleanupResultInfoWithoutHash(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf,
|
||||
&pInfo->groupResInfo);
|
||||
pInfo->pOperator = NULL;
|
||||
}
|
||||
cleanupAggSup(&pInfo->aggSup);
|
||||
|
@ -627,6 +627,42 @@ void cleanupResultInfoInStream(SExecTaskInfo* pTaskInfo, void* pState, SExprSupp
|
|||
}
|
||||
}
|
||||
|
||||
void cleanupResultInfoWithoutHash(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf,
|
||||
SGroupResInfo* pGroupResInfo) {
|
||||
int32_t numOfExprs = pSup->numOfExprs;
|
||||
int32_t* rowEntryOffset = pSup->rowEntryInfoOffset;
|
||||
SqlFunctionCtx* pCtx = pSup->pCtx;
|
||||
int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
|
||||
bool needCleanup = false;
|
||||
|
||||
for (int32_t j = 0; j < numOfExprs; ++j) {
|
||||
needCleanup |= pCtx[j].needCleanup;
|
||||
}
|
||||
if (!needCleanup) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32_t i = pGroupResInfo->index; i < numOfRows; i += 1) {
|
||||
SResultRow* pRow = NULL;
|
||||
SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i);
|
||||
SFilePage* page = getBufPage(pBuf, pPos->pos.pageId);
|
||||
if (page == NULL) {
|
||||
qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
|
||||
continue;
|
||||
}
|
||||
pRow = (SResultRow*)((char*)page + pPos->pos.offset);
|
||||
|
||||
|
||||
for (int32_t j = 0; j < numOfExprs; ++j) {
|
||||
pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
|
||||
if (pCtx[j].fpSet.cleanup) {
|
||||
pCtx[j].fpSet.cleanup(&pCtx[j]);
|
||||
}
|
||||
}
|
||||
releaseBufPage(pBuf, page);
|
||||
}
|
||||
}
|
||||
|
||||
void cleanupResultInfo(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf,
|
||||
SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap) {
|
||||
int32_t numOfExprs = pSup->numOfExprs;
|
||||
|
|
|
@ -1229,10 +1229,9 @@ static void destroyStateWindowOperatorInfo(void* param) {
|
|||
SStateWindowOperatorInfo* pInfo = (SStateWindowOperatorInfo*)param;
|
||||
cleanupBasicInfo(&pInfo->binfo);
|
||||
taosMemoryFreeClear(pInfo->stateKey.pData);
|
||||
|
||||
if (pInfo->pOperator != NULL) {
|
||||
cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf,
|
||||
&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable);
|
||||
if (pInfo->pOperator) {
|
||||
cleanupResultInfoWithoutHash(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf,
|
||||
&pInfo->groupResInfo);
|
||||
pInfo->pOperator = NULL;
|
||||
}
|
||||
|
||||
|
@ -1257,10 +1256,9 @@ void destroyIntervalOperatorInfo(void* param) {
|
|||
SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)param;
|
||||
|
||||
cleanupBasicInfo(&pInfo->binfo);
|
||||
|
||||
if (pInfo->pOperator != NULL) {
|
||||
cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf,
|
||||
&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable);
|
||||
if (pInfo->pOperator) {
|
||||
cleanupResultInfoWithoutHash(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf,
|
||||
&pInfo->groupResInfo);
|
||||
pInfo->pOperator = NULL;
|
||||
}
|
||||
|
||||
|
@ -1764,10 +1762,9 @@ void destroySWindowOperatorInfo(void* param) {
|
|||
|
||||
cleanupBasicInfo(&pInfo->binfo);
|
||||
colDataDestroy(&pInfo->twAggSup.timeWindowData);
|
||||
|
||||
if (pInfo->pOperator != NULL) {
|
||||
cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf,
|
||||
&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable);
|
||||
if (pInfo->pOperator) {
|
||||
cleanupResultInfoWithoutHash(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf,
|
||||
&pInfo->groupResInfo);
|
||||
pInfo->pOperator = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,10 +143,10 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
|||
|
||||
char udfdPathLdLib[1024] = {0};
|
||||
size_t udfdLdLibPathLen = strlen(tsUdfdLdLibPath);
|
||||
strncpy(udfdPathLdLib, tsUdfdLdLibPath, tListLen(udfdPathLdLib));
|
||||
tstrncpy(udfdPathLdLib, tsUdfdLdLibPath, sizeof(udfdPathLdLib) < sizeof(tsUdfdLdLibPath) ? sizeof(udfdPathLdLib) : sizeof(tsUdfdLdLibPath));
|
||||
|
||||
udfdPathLdLib[udfdLdLibPathLen] = ':';
|
||||
strncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen - 1);
|
||||
tstrncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen - 1);
|
||||
if (udfdLdLibPathLen + taosdLdLibPathLen < 1024) {
|
||||
fnInfo("[UDFD]udfd LD_LIBRARY_PATH: %s", udfdPathLdLib);
|
||||
} else {
|
||||
|
@ -158,10 +158,11 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
|||
char *taosFqdnEnvItem = NULL;
|
||||
char *taosFqdn = getenv("TAOS_FQDN");
|
||||
if (taosFqdn != NULL) {
|
||||
taosFqdnEnvItem = taosMemoryMalloc(strlen("TAOS_FQDN=") + strlen(taosFqdn) + 1);
|
||||
int len = strlen("TAOS_FQDN=") + strlen(taosFqdn) + 1;
|
||||
taosFqdnEnvItem = taosMemoryMalloc(len);
|
||||
if (taosFqdnEnvItem != NULL) {
|
||||
strcpy(taosFqdnEnvItem, "TAOS_FQDN=");
|
||||
TAOS_STRCAT(taosFqdnEnvItem, taosFqdn);
|
||||
tstrncpy(taosFqdnEnvItem, "TAOS_FQDN=", len);
|
||||
TAOS_STRNCAT(taosFqdnEnvItem, taosFqdn, strlen(taosFqdn));
|
||||
fnInfo("[UDFD]Succsess to set TAOS_FQDN:%s", taosFqdn);
|
||||
} else {
|
||||
fnError("[UDFD]Failed to allocate memory for TAOS_FQDN");
|
||||
|
@ -1072,7 +1073,7 @@ int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle) {
|
|||
int32_t code = 0, line = 0;
|
||||
uv_mutex_lock(&gUdfcProxy.udfStubsMutex);
|
||||
SUdfcFuncStub key = {0};
|
||||
strncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
int32_t stubIndex = taosArraySearchIdx(gUdfcProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
||||
if (stubIndex != -1) {
|
||||
SUdfcFuncStub *foundStub = taosArrayGet(gUdfcProxy.udfStubs, stubIndex);
|
||||
|
@ -1105,7 +1106,7 @@ int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle) {
|
|||
code = doSetupUdf(udfName, pHandle);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
SUdfcFuncStub stub = {0};
|
||||
strncpy(stub.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(stub.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
stub.handle = *pHandle;
|
||||
++stub.refCount;
|
||||
stub.createTime = taosGetTimestampUs();
|
||||
|
@ -1129,7 +1130,7 @@ _exit:
|
|||
void releaseUdfFuncHandle(char *udfName, UdfcFuncHandle handle) {
|
||||
uv_mutex_lock(&gUdfcProxy.udfStubsMutex);
|
||||
SUdfcFuncStub key = {0};
|
||||
strncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
SUdfcFuncStub *foundStub = taosArraySearch(gUdfcProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
||||
SUdfcFuncStub *expiredStub = taosArraySearch(gUdfcProxy.expiredUdfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
||||
if (!foundStub && !expiredStub) {
|
||||
|
@ -2020,7 +2021,7 @@ int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) {
|
|||
task->type = UDF_TASK_SETUP;
|
||||
|
||||
SUdfSetupRequest *req = &task->_setup.req;
|
||||
strncpy(req->udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(req->udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
|
||||
code = udfcRunUdfUvTask(task, UV_TASK_CONNECT);
|
||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||
|
@ -2033,7 +2034,7 @@ int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) {
|
|||
task->session->outputType = rsp->outputType;
|
||||
task->session->bytes = rsp->bytes;
|
||||
task->session->bufSize = rsp->bufSize;
|
||||
strncpy(task->session->udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(task->session->udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
fnInfo("successfully setup udf func handle. udfName: %s, handle: %p", udfName, task->session);
|
||||
*funcHandle = task->session;
|
||||
taosMemoryFree(task);
|
||||
|
|
|
@ -396,7 +396,7 @@ int32_t udfdLoadSharedLib(char *libPath, uv_lib_t *pLib, const char *funcName[],
|
|||
int32_t udfdInitializePythonPlugin(SUdfScriptPlugin *plugin) {
|
||||
plugin->scriptType = TSDB_FUNC_SCRIPT_PYTHON;
|
||||
// todo: windows support
|
||||
sprintf(plugin->libPath, "%s", "libtaospyudf.so");
|
||||
snprintf(plugin->libPath, PATH_MAX, "%s", "libtaospyudf.so");
|
||||
plugin->libLoaded = false;
|
||||
const char *funcName[UDFD_MAX_PLUGIN_FUNCS] = {"pyOpen", "pyClose", "pyUdfInit",
|
||||
"pyUdfDestroy", "pyUdfScalarProc", "pyUdfAggStart",
|
||||
|
@ -617,7 +617,7 @@ int32_t udfdNewUdf(SUdf **pUdf, const char *udfName) {
|
|||
}
|
||||
udfNew->refCount = 1;
|
||||
udfNew->lastFetchTime = taosGetTimestampMs();
|
||||
strncpy(udfNew->name, udfName, TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(udfNew->name, udfName, TSDB_FUNC_NAME_LEN);
|
||||
|
||||
udfNew->state = UDF_STATE_INIT;
|
||||
if (uv_mutex_init(&udfNew->lock) != 0) return TSDB_CODE_UDF_UV_EXEC_FAILURE;
|
||||
|
@ -997,7 +997,7 @@ int32_t udfdSaveFuncBodyToFile(SFuncInfo *pFuncInfo, SUdf *udf) {
|
|||
udfdGetFuncBodyPath(udf, path);
|
||||
bool fileExist = !(taosStatFile(path, NULL, NULL, NULL) < 0);
|
||||
if (fileExist) {
|
||||
strncpy(udf->path, path, PATH_MAX);
|
||||
tstrncpy(udf->path, path, PATH_MAX);
|
||||
fnInfo("udfd func body file. reuse existing file %s", path);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1017,7 +1017,7 @@ int32_t udfdSaveFuncBodyToFile(SFuncInfo *pFuncInfo, SUdf *udf) {
|
|||
return TSDB_CODE_FILE_CORRUPTED;
|
||||
}
|
||||
|
||||
strncpy(udf->path, path, PATH_MAX);
|
||||
tstrncpy(udf->path, path, PATH_MAX);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1612,7 +1612,7 @@ int32_t udfdInitResidentFuncs() {
|
|||
char *token;
|
||||
while ((token = strtok_r(pSave, ",", &pSave)) != NULL) {
|
||||
char func[TSDB_FUNC_NAME_LEN + 1] = {0};
|
||||
strncpy(func, token, TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(func, token, TSDB_FUNC_NAME_LEN);
|
||||
fnInfo("udfd add resident function %s", func);
|
||||
if(taosArrayPush(global.residentFuncs, func) == NULL)
|
||||
{
|
||||
|
|
|
@ -313,42 +313,41 @@ void destroyQueryExecRes(SExecResult* pRes) {
|
|||
}
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t* len) {
|
||||
int32_t dataConverToStr(char* str, int64_t capacity, int type, void* buf, int32_t bufSize, int32_t* len) {
|
||||
int32_t n = 0;
|
||||
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_NULL:
|
||||
n = sprintf(str, "null");
|
||||
n = snprintf(str, capacity, "null");
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
n = sprintf(str, (*(int8_t*)buf) ? "true" : "false");
|
||||
n = snprintf(str, capacity, (*(int8_t*)buf) ? "true" : "false");
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
n = sprintf(str, "%d", *(int8_t*)buf);
|
||||
n = snprintf(str, capacity, "%d", *(int8_t*)buf);
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
n = sprintf(str, "%d", *(int16_t*)buf);
|
||||
n = snprintf(str, capacity, "%d", *(int16_t*)buf);
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
n = sprintf(str, "%d", *(int32_t*)buf);
|
||||
n = snprintf(str, capacity, "%d", *(int32_t*)buf);
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
n = sprintf(str, "%" PRId64, *(int64_t*)buf);
|
||||
n = snprintf(str, capacity, "%" PRId64, *(int64_t*)buf);
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
n = sprintf(str, "%e", GET_FLOAT_VAL(buf));
|
||||
n = snprintf(str, capacity, "%e", GET_FLOAT_VAL(buf));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
n = sprintf(str, "%e", GET_DOUBLE_VAL(buf));
|
||||
n = snprintf(str, capacity, "%e", GET_DOUBLE_VAL(buf));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_VARBINARY: {
|
||||
|
@ -395,19 +394,19 @@ int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t
|
|||
n = length + 2;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
n = sprintf(str, "%d", *(uint8_t*)buf);
|
||||
n = snprintf(str, capacity, "%d", *(uint8_t*)buf);
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
n = sprintf(str, "%d", *(uint16_t*)buf);
|
||||
n = snprintf(str, capacity, "%d", *(uint16_t*)buf);
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
n = sprintf(str, "%u", *(uint32_t*)buf);
|
||||
n = snprintf(str, capacity, "%u", *(uint32_t*)buf);
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
n = sprintf(str, "%" PRIu64, *(uint64_t*)buf);
|
||||
n = snprintf(str, capacity, "%" PRIu64, *(uint64_t*)buf);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -107,7 +107,7 @@ int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *ms
|
|||
}
|
||||
|
||||
SUseDbReq usedbReq = {0};
|
||||
strncpy(usedbReq.db, pInput->db, sizeof(usedbReq.db));
|
||||
tstrncpy(usedbReq.db, pInput->db, TSDB_DB_FNAME_LEN);
|
||||
usedbReq.db[sizeof(usedbReq.db) - 1] = 0;
|
||||
usedbReq.vgVersion = pInput->vgVersion;
|
||||
usedbReq.dbId = pInput->dbId;
|
||||
|
@ -207,7 +207,7 @@ int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
|
|||
}
|
||||
|
||||
SDbCfgReq dbCfgReq = {0};
|
||||
strncpy(dbCfgReq.db, input, sizeof(dbCfgReq.db) - 1);
|
||||
tstrncpy(dbCfgReq.db, input, TSDB_DB_FNAME_LEN);
|
||||
|
||||
int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
|
@ -231,7 +231,7 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t
|
|||
}
|
||||
|
||||
SUserIndexReq indexReq = {0};
|
||||
strncpy(indexReq.indexFName, input, sizeof(indexReq.indexFName) - 1);
|
||||
tstrncpy(indexReq.indexFName, input, TSDB_INDEX_FNAME_LEN);
|
||||
|
||||
int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
|
@ -293,7 +293,7 @@ int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32
|
|||
}
|
||||
|
||||
SGetUserAuthReq req = {0};
|
||||
strncpy(req.user, input, sizeof(req.user) - 1);
|
||||
tstrncpy(req.user, input, TSDB_USER_LEN);
|
||||
|
||||
int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
|
@ -316,7 +316,7 @@ int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_
|
|||
}
|
||||
|
||||
STableIndexReq indexReq = {0};
|
||||
strncpy(indexReq.tbFName, input, sizeof(indexReq.tbFName) - 1);
|
||||
tstrncpy(indexReq.tbFName, input, TSDB_TABLE_FNAME_LEN);
|
||||
|
||||
int32_t bufLen = tSerializeSTableIndexReq(NULL, 0, &indexReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
|
@ -342,8 +342,8 @@ int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
|
|||
SBuildTableInput *pInput = input;
|
||||
STableCfgReq cfgReq = {0};
|
||||
cfgReq.header.vgId = pInput->vgId;
|
||||
strncpy(cfgReq.dbFName, pInput->dbFName, sizeof(cfgReq.dbFName) - 1);
|
||||
strncpy(cfgReq.tbName, pInput->tbName, sizeof(cfgReq.tbName) - 1);
|
||||
tstrncpy(cfgReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
|
||||
tstrncpy(cfgReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
|
||||
|
||||
int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
|
@ -367,7 +367,7 @@ int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32
|
|||
}
|
||||
|
||||
SViewMetaReq req = {0};
|
||||
strncpy(req.fullname, input, sizeof(req.fullname) - 1);
|
||||
tstrncpy(req.fullname, input, TSDB_VIEW_FNAME_LEN);
|
||||
|
||||
int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
|
@ -392,7 +392,7 @@ int32_t queryBuildGetTableTSMAMsg(void *input, char **msg, int32_t msgSize, int3
|
|||
}
|
||||
|
||||
STableTSMAInfoReq req = {0};
|
||||
strncpy(req.name, input, sizeof(req.name) - 1);
|
||||
tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
|
||||
|
||||
int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
|
||||
void * pBuf = (*mallcFp)(bufLen);
|
||||
|
@ -417,7 +417,7 @@ int32_t queryBuildGetTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *
|
|||
|
||||
STableTSMAInfoReq req = {0};
|
||||
req.fetchingWithTsmaName = true;
|
||||
strncpy(req.name, input, sizeof(req.name) - 1);
|
||||
tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
|
||||
|
||||
int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
|
||||
void * pBuf = (*mallcFp)(bufLen);
|
||||
|
@ -688,14 +688,14 @@ int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
|
|||
}
|
||||
|
||||
STableMetaOutput *pOut = output;
|
||||
strcpy(pOut->dbFName, metaRsp.dbFName);
|
||||
tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
|
||||
pOut->dbId = metaRsp.dbId;
|
||||
|
||||
if (metaRsp.tableType == TSDB_CHILD_TABLE) {
|
||||
SET_META_TYPE_BOTH_TABLE(pOut->metaType);
|
||||
|
||||
strcpy(pOut->ctbName, metaRsp.tbName);
|
||||
strcpy(pOut->tbName, metaRsp.stbName);
|
||||
tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
|
||||
|
||||
pOut->ctbMeta.vgId = metaRsp.vgId;
|
||||
pOut->ctbMeta.tableType = metaRsp.tableType;
|
||||
|
@ -705,7 +705,7 @@ int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
|
|||
code = queryCreateTableMetaFromMsg(&metaRsp, true, &pOut->tbMeta);
|
||||
} else {
|
||||
SET_META_TYPE_TABLE(pOut->metaType);
|
||||
strcpy(pOut->tbName, metaRsp.tbName);
|
||||
tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
|
||||
code = queryCreateTableMetaFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
|
||||
}
|
||||
|
||||
|
@ -744,14 +744,14 @@ static int32_t queryProcessTableNameRsp(void *output, char *msg, int32_t msgSize
|
|||
}
|
||||
|
||||
STableMetaOutput *pOut = output;
|
||||
strcpy(pOut->dbFName, metaRsp.dbFName);
|
||||
tstrncpy(pOut->dbFName, metaRsp.dbFName, TSDB_DB_FNAME_LEN);
|
||||
pOut->dbId = metaRsp.dbId;
|
||||
|
||||
if (metaRsp.tableType == TSDB_CHILD_TABLE) {
|
||||
SET_META_TYPE_BOTH_TABLE(pOut->metaType);
|
||||
|
||||
strcpy(pOut->ctbName, metaRsp.tbName);
|
||||
strcpy(pOut->tbName, metaRsp.stbName);
|
||||
tstrncpy(pOut->ctbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pOut->tbName, metaRsp.stbName, TSDB_TABLE_NAME_LEN);
|
||||
|
||||
pOut->ctbMeta.vgId = metaRsp.vgId;
|
||||
pOut->ctbMeta.tableType = metaRsp.tableType;
|
||||
|
@ -761,7 +761,7 @@ static int32_t queryProcessTableNameRsp(void *output, char *msg, int32_t msgSize
|
|||
code = queryCreateTableMetaExFromMsg(&metaRsp, true, &pOut->tbMeta);
|
||||
} else {
|
||||
SET_META_TYPE_TABLE(pOut->metaType);
|
||||
strcpy(pOut->tbName, metaRsp.tbName);
|
||||
tstrncpy(pOut->tbName, metaRsp.tbName, TSDB_TABLE_NAME_LEN);
|
||||
code = queryCreateTableMetaExFromMsg(&metaRsp, (metaRsp.tableType == TSDB_SUPER_TABLE), &pOut->tbMeta);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue