Merge remote-tracking branch 'origin/3.0' into feat/TD-30268
This commit is contained in:
commit
dfc3fc4987
|
@ -32,8 +32,8 @@ typedef struct SBlockOrderInfo {
|
|||
SColumnInfoData* pColData;
|
||||
} SBlockOrderInfo;
|
||||
|
||||
#define BLOCK_VERSION_1 1
|
||||
#define BLOCK_VERSION_2 2
|
||||
#define BLOCK_VERSION_1 1
|
||||
#define BLOCK_VERSION_2 2
|
||||
|
||||
#define NBIT (3u)
|
||||
#define BitPos(_n) ((_n) & ((1 << NBIT) - 1))
|
||||
|
@ -41,15 +41,24 @@ typedef struct SBlockOrderInfo {
|
|||
#define BMCharPos(bm_, r_) ((bm_)[(r_) >> NBIT])
|
||||
#define colDataIsNull_f(bm_, r_) ((BMCharPos(bm_, r_) & (1u << (7u - BitPos(r_)))) == (1u << (7u - BitPos(r_))))
|
||||
|
||||
#define QRY_OPTR_CHECK(_o) \
|
||||
do { \
|
||||
if ((_o) == NULL) { \
|
||||
return TSDB_CODE_INVALID_PARA; \
|
||||
} else { \
|
||||
*(_o) = NULL; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define colDataSetNull_f(bm_, r_) \
|
||||
do { \
|
||||
BMCharPos(bm_, r_) |= (1u << (7u - BitPos(r_))); \
|
||||
} while (0)
|
||||
|
||||
#define colDataSetNull_f_s(c_, r_) \
|
||||
do { \
|
||||
colDataSetNull_f((c_)->nullbitmap, r_); \
|
||||
memset(((char*)(c_)->pData) + (c_)->info.bytes * (r_), 0, (c_)->info.bytes); \
|
||||
#define colDataSetNull_f_s(c_, r_) \
|
||||
do { \
|
||||
colDataSetNull_f((c_)->nullbitmap, r_); \
|
||||
(void)memset(((char*)(c_)->pData) + (c_)->info.bytes * (r_), 0, (c_)->info.bytes); \
|
||||
} while (0)
|
||||
|
||||
#define colDataClearNull_f(bm_, r_) \
|
||||
|
@ -143,7 +152,7 @@ static FORCE_INLINE void colDataSetNNULL(SColumnInfoData* pColumnInfoData, uint3
|
|||
for (int32_t i = start; i < start + nRows; ++i) {
|
||||
colDataSetNull_f(pColumnInfoData->nullbitmap, i);
|
||||
}
|
||||
memset(pColumnInfoData->pData + start * pColumnInfoData->info.bytes, 0, pColumnInfoData->info.bytes * nRows);
|
||||
(void)memset(pColumnInfoData->pData + start * pColumnInfoData->info.bytes, 0, pColumnInfoData->info.bytes * nRows);
|
||||
}
|
||||
|
||||
pColumnInfoData->hasNull = true;
|
||||
|
@ -192,15 +201,17 @@ int32_t getJsonValueLen(const char* data);
|
|||
|
||||
int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull);
|
||||
int32_t colDataReassignVal(SColumnInfoData* pColumnInfoData, uint32_t dstRowIdx, uint32_t srcRowIdx, const char* pData);
|
||||
int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows, bool trimValue);
|
||||
void colDataSetNItemsNull(SColumnInfoData* pColumnInfoData, uint32_t currentRow, uint32_t numOfRows);
|
||||
int32_t colDataCopyNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData,
|
||||
uint32_t numOfRows, bool isNull);
|
||||
int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows,
|
||||
bool trimValue);
|
||||
void colDataSetNItemsNull(SColumnInfoData* pColumnInfoData, uint32_t currentRow, uint32_t numOfRows);
|
||||
int32_t colDataCopyNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, uint32_t numOfRows,
|
||||
bool isNull);
|
||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity,
|
||||
const SColumnInfoData* pSource, int32_t numOfRow2);
|
||||
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows,
|
||||
const SDataBlockInfo* pBlockInfo);
|
||||
int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnInfoData* pSrc, int32_t srcIdx, int32_t numOfRows);
|
||||
int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnInfoData* pSrc, int32_t srcIdx,
|
||||
int32_t numOfRows);
|
||||
int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex);
|
||||
int32_t blockDataUpdatePkRange(SSDataBlock* pDataBlock, int32_t pkColumnIndex, bool asc);
|
||||
|
||||
|
@ -214,14 +225,13 @@ size_t blockDataGetNumOfRows(const SSDataBlock* pBlock);
|
|||
|
||||
int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc);
|
||||
int32_t blockDataMergeNRows(SSDataBlock* pDest, const SSDataBlock* pSrc, int32_t srcIdx, int32_t numOfRows);
|
||||
void blockDataShrinkNRows(SSDataBlock* pBlock, int32_t numOfRows);
|
||||
void blockDataShrinkNRows(SSDataBlock* pBlock, int32_t numOfRows);
|
||||
int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startIndex, int32_t* stopIndex,
|
||||
int32_t pageSize);
|
||||
int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock);
|
||||
int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf);
|
||||
int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity);
|
||||
|
||||
SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int32_t rowCount);
|
||||
int32_t blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int32_t rowCount, SSDataBlock** pResBlock);
|
||||
|
||||
size_t blockDataGetSize(const SSDataBlock* pBlock);
|
||||
size_t blockDataGetRowSize(SSDataBlock* pBlock);
|
||||
|
@ -237,12 +247,12 @@ int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo);
|
|||
int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows, bool clearPayload);
|
||||
int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows);
|
||||
|
||||
void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows);
|
||||
void blockDataCleanup(SSDataBlock* pDataBlock);
|
||||
void blockDataReset(SSDataBlock* pDataBlock);
|
||||
void blockDataEmpty(SSDataBlock* pDataBlock);
|
||||
void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows);
|
||||
void blockDataCleanup(SSDataBlock* pDataBlock);
|
||||
void blockDataReset(SSDataBlock* pDataBlock);
|
||||
void blockDataEmpty(SSDataBlock* pDataBlock);
|
||||
int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* pBlockInfo, uint32_t numOfRows,
|
||||
bool clearPayload);
|
||||
bool clearPayload);
|
||||
|
||||
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize, int32_t extraSize);
|
||||
|
||||
|
@ -252,35 +262,35 @@ void blockDataKeepFirstNRows(SSDataBlock* pBlock, size_t n);
|
|||
int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src);
|
||||
int32_t copyDataBlock(SSDataBlock* pDst, const SSDataBlock* pSrc);
|
||||
|
||||
SSDataBlock* createDataBlock();
|
||||
void blockDataDestroy(SSDataBlock* pBlock);
|
||||
void blockDataFreeRes(SSDataBlock* pBlock);
|
||||
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData);
|
||||
SSDataBlock* createSpecialDataBlock(EStreamType type);
|
||||
int32_t createDataBlock(SSDataBlock** pResBlock);
|
||||
void blockDataDestroy(SSDataBlock* pBlock);
|
||||
void blockDataFreeRes(SSDataBlock* pBlock);
|
||||
int32_t createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData, SSDataBlock** pResBlock);
|
||||
int32_t createSpecialDataBlock(EStreamType type, SSDataBlock** pBlock);
|
||||
|
||||
SSDataBlock* blockCopyOneRow(const SSDataBlock* pDataBlock, int32_t rowIdx);
|
||||
int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData);
|
||||
int32_t blockCopyOneRow(const SSDataBlock* pDataBlock, int32_t rowIdx, SSDataBlock** pResBlock);
|
||||
int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData);
|
||||
|
||||
SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId);
|
||||
SColumnInfoData* bdGetColumnInfoData(const SSDataBlock* pBlock, int32_t index);
|
||||
SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId);
|
||||
int32_t bdGetColumnInfoData(const SSDataBlock* pBlock, int32_t index, SColumnInfoData** pColInfoData);
|
||||
|
||||
int32_t blockGetEncodeSize(const SSDataBlock* pBlock);
|
||||
int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols);
|
||||
const char* blockDecode(SSDataBlock* pBlock, const char* pData);
|
||||
int32_t blockDecode(SSDataBlock* pBlock, const char* pData, const char** pEndPos);
|
||||
|
||||
// for debug
|
||||
char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf, const char* taskIdStr);
|
||||
int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf, const char* taskIdStr);
|
||||
|
||||
int32_t buildSubmitReqFromDataBlock(SSubmitReq2** pReq, const SSDataBlock* pDataBlocks, const STSchema* pTSchema, int64_t uid, int32_t vgId,
|
||||
tb_uid_t suid);
|
||||
int32_t buildSubmitReqFromDataBlock(SSubmitReq2** pReq, const SSDataBlock* pDataBlocks, const STSchema* pTSchema,
|
||||
int64_t uid, int32_t vgId, tb_uid_t suid);
|
||||
|
||||
bool alreadyAddGroupId(char* ctbName, int64_t groupId);
|
||||
bool isAutoTableName(char* ctbName);
|
||||
void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId);
|
||||
char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId);
|
||||
bool alreadyAddGroupId(char* ctbName, int64_t groupId);
|
||||
bool isAutoTableName(char* ctbName);
|
||||
void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId);
|
||||
int32_t buildCtbNameByGroupId(const char* stbName, uint64_t groupId, char** pName);
|
||||
int32_t buildCtbNameByGroupIdImpl(const char* stbName, uint64_t groupId, char* pBuf);
|
||||
|
||||
void trimDataBlock(SSDataBlock* pBlock, int32_t totalRows, const bool* pBoolList);
|
||||
int32_t trimDataBlock(SSDataBlock* pBlock, int32_t totalRows, const bool* pBoolList);
|
||||
|
||||
void copyPkVal(SDataBlockInfo* pDst, const SDataBlockInfo* pSrc);
|
||||
|
||||
|
|
|
@ -315,7 +315,7 @@ struct STag {
|
|||
do { \
|
||||
VarDataLenT __len = (VarDataLenT)strlen(str); \
|
||||
*(VarDataLenT *)(x) = __len; \
|
||||
memcpy(varDataVal(x), (str), __len); \
|
||||
(void)memcpy(varDataVal(x), (str), __len); \
|
||||
} while (0);
|
||||
|
||||
#define STR_WITH_MAXSIZE_TO_VARSTR(x, str, _maxs) \
|
||||
|
@ -324,10 +324,10 @@ struct STag {
|
|||
varDataSetLen(x, (_e - (x)-VARSTR_HEADER_SIZE)); \
|
||||
} while (0)
|
||||
|
||||
#define STR_WITH_SIZE_TO_VARSTR(x, str, _size) \
|
||||
do { \
|
||||
*(VarDataLenT *)(x) = (VarDataLenT)(_size); \
|
||||
memcpy(varDataVal(x), (str), (_size)); \
|
||||
#define STR_WITH_SIZE_TO_VARSTR(x, str, _size) \
|
||||
do { \
|
||||
*(VarDataLenT *)(x) = (VarDataLenT)(_size); \
|
||||
(void)memcpy(varDataVal(x), (str), (_size)); \
|
||||
} while (0);
|
||||
|
||||
// STSchema ================================
|
||||
|
|
|
@ -279,11 +279,11 @@ int32_t taosCfgDynamicOptions(SConfig *pCfg, const char *name, bool forServer);
|
|||
|
||||
struct SConfig *taosGetCfg();
|
||||
|
||||
void taosSetGlobalDebugFlag(int32_t flag);
|
||||
void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal);
|
||||
void taosLocalCfgForbiddenToChange(char *name, bool *forbidden);
|
||||
int8_t taosGranted(int8_t type);
|
||||
int32_t taosSetSlowLogScope(char *pScope);
|
||||
int32_t taosSetGlobalDebugFlag(int32_t flag);
|
||||
int32_t taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal);
|
||||
void taosLocalCfgForbiddenToChange(char *name, bool *forbidden);
|
||||
int8_t taosGranted(int8_t type);
|
||||
int32_t taosSetSlowLogScope(char *pScopeStr, int32_t *pScope);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ int32_t generateEncryptCode(const char *key, const char *machineId, char **encry
|
|||
int64_t grantRemain(EGrantType grant);
|
||||
int32_t grantCheck(EGrantType grant);
|
||||
int32_t grantCheckExpire(EGrantType grant);
|
||||
char *tGetMachineId();
|
||||
int32_t tGetMachineId(char **result);
|
||||
|
||||
// #ifndef GRANTS_CFG
|
||||
#ifdef TD_ENTERPRISE
|
||||
|
|
|
@ -683,36 +683,55 @@ typedef struct {
|
|||
} SColCmprWrapper;
|
||||
|
||||
static FORCE_INLINE SColCmprWrapper* tCloneSColCmprWrapper(const SColCmprWrapper* pSrcWrapper) {
|
||||
if (pSrcWrapper->pColCmpr == NULL || pSrcWrapper->nCols == 0) return NULL;
|
||||
if (pSrcWrapper->pColCmpr == NULL || pSrcWrapper->nCols == 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SColCmprWrapper* pDstWrapper = (SColCmprWrapper*)taosMemoryMalloc(sizeof(SColCmprWrapper));
|
||||
if (pDstWrapper == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
pDstWrapper->nCols = pSrcWrapper->nCols;
|
||||
pDstWrapper->version = pSrcWrapper->version;
|
||||
|
||||
int32_t size = sizeof(SColCmpr) * pDstWrapper->nCols;
|
||||
pDstWrapper->pColCmpr = (SColCmpr*)taosMemoryCalloc(1, size);
|
||||
memcpy(pDstWrapper->pColCmpr, pSrcWrapper->pColCmpr, size);
|
||||
if (pDstWrapper->pColCmpr == NULL) {
|
||||
taosMemoryFree(pDstWrapper);
|
||||
return NULL;
|
||||
}
|
||||
(void)memcpy(pDstWrapper->pColCmpr, pSrcWrapper->pColCmpr, size);
|
||||
|
||||
return pDstWrapper;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tInitDefaultSColCmprWrapperByCols(SColCmprWrapper* pCmpr, int32_t nCols) {
|
||||
static FORCE_INLINE int32_t tInitDefaultSColCmprWrapperByCols(SColCmprWrapper* pCmpr, int32_t nCols) {
|
||||
assert(!pCmpr->pColCmpr);
|
||||
pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(nCols, sizeof(SColCmpr));
|
||||
if (pCmpr->pColCmpr == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
pCmpr->nCols = nCols;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tInitDefaultSColCmprWrapper(SColCmprWrapper* pCmpr, SSchemaWrapper* pSchema) {
|
||||
static FORCE_INLINE int32_t tInitDefaultSColCmprWrapper(SColCmprWrapper* pCmpr, SSchemaWrapper* pSchema) {
|
||||
pCmpr->nCols = pSchema->nCols;
|
||||
assert(!pCmpr->pColCmpr);
|
||||
pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(pCmpr->nCols, sizeof(SColCmpr));
|
||||
if (pCmpr->pColCmpr == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
for (int32_t i = 0; i < pCmpr->nCols; i++) {
|
||||
SColCmpr* pColCmpr = &pCmpr->pColCmpr[i];
|
||||
SSchema* pColSchema = &pSchema->pSchema[i];
|
||||
pColCmpr->id = pColSchema->colId;
|
||||
pColCmpr->alg = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tDeleteSColCmprWrapper(SColCmprWrapper* pWrapper) {
|
||||
if (pWrapper == NULL) return;
|
||||
|
||||
|
@ -723,7 +742,9 @@ static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* p
|
|||
if (pSchemaWrapper->pSchema == NULL) return NULL;
|
||||
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
|
||||
if (pSW == NULL) return pSW;
|
||||
if (pSW == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
pSW->nCols = pSchemaWrapper->nCols;
|
||||
pSW->version = pSchemaWrapper->version;
|
||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||
|
@ -732,7 +753,7 @@ static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* p
|
|||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
|
||||
(void)memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
|
||||
return pSW;
|
||||
}
|
||||
|
||||
|
@ -770,32 +791,32 @@ static FORCE_INLINE void* taosDecodeSSchema(const void* buf, SSchema* pSchema) {
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSSchema(SEncoder* pEncoder, const SSchema* pSchema) {
|
||||
if (tEncodeI8(pEncoder, pSchema->type) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pSchema->flags) < 0) return -1;
|
||||
if (tEncodeI32v(pEncoder, pSchema->bytes) < 0) return -1;
|
||||
if (tEncodeI16v(pEncoder, pSchema->colId) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pSchema->name) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pSchema->type));
|
||||
TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pSchema->flags));
|
||||
TAOS_CHECK_RETURN(tEncodeI32v(pEncoder, pSchema->bytes));
|
||||
TAOS_CHECK_RETURN(tEncodeI16v(pEncoder, pSchema->colId));
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pSchema->name));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeSSchema(SDecoder* pDecoder, SSchema* pSchema) {
|
||||
if (tDecodeI8(pDecoder, &pSchema->type) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pSchema->flags) < 0) return -1;
|
||||
if (tDecodeI32v(pDecoder, &pSchema->bytes) < 0) return -1;
|
||||
if (tDecodeI16v(pDecoder, &pSchema->colId) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pSchema->name) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pSchema->type));
|
||||
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pSchema->flags));
|
||||
TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSchema->bytes));
|
||||
TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &pSchema->colId));
|
||||
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pSchema->name));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSSchemaExt(SEncoder* pEncoder, const SSchemaExt* pSchemaExt) {
|
||||
if (tEncodeI16v(pEncoder, pSchemaExt->colId) < 0) return -1;
|
||||
if (tEncodeU32(pEncoder, pSchemaExt->compress) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI16v(pEncoder, pSchemaExt->colId));
|
||||
TAOS_CHECK_RETURN(tEncodeU32(pEncoder, pSchemaExt->compress));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeSSchemaExt(SDecoder* pDecoder, SSchemaExt* pSchemaExt) {
|
||||
if (tDecodeI16v(pDecoder, &pSchemaExt->colId) < 0) return -1;
|
||||
if (tDecodeU32(pDecoder, &pSchemaExt->compress) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &pSchemaExt->colId));
|
||||
TAOS_CHECK_RETURN(tDecodeU32(pDecoder, &pSchemaExt->compress));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -828,36 +849,39 @@ static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapp
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSchemaWrapper* pSW) {
|
||||
if (tEncodeI32v(pEncoder, pSW->nCols) < 0) return -1;
|
||||
if (tEncodeI32v(pEncoder, pSW->version) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI32v(pEncoder, pSW->nCols));
|
||||
TAOS_CHECK_RETURN(tEncodeI32v(pEncoder, pSW->version));
|
||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||
if (tEncodeSSchema(pEncoder, &pSW->pSchema[i]) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeSSchema(pEncoder, &pSW->pSchema[i]));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWrapper* pSW) {
|
||||
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
|
||||
if (tDecodeI32v(pDecoder, &pSW->version) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->nCols));
|
||||
TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->version));
|
||||
|
||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||
if (pSW->pSchema == NULL) return -1;
|
||||
if (pSW->pSchema == NULL) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||
if (tDecodeSSchema(pDecoder, &pSW->pSchema[i]) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeSSchema(pDecoder, &pSW->pSchema[i]));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeSSchemaWrapperEx(SDecoder* pDecoder, SSchemaWrapper* pSW) {
|
||||
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
|
||||
if (tDecodeI32v(pDecoder, &pSW->version) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->nCols));
|
||||
TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->version));
|
||||
|
||||
pSW->pSchema = (SSchema*)tDecoderMalloc(pDecoder, pSW->nCols * sizeof(SSchema));
|
||||
if (pSW->pSchema == NULL) return -1;
|
||||
if (pSW->pSchema == NULL) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||
if (tDecodeSSchema(pDecoder, &pSW->pSchema[i]) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeSSchema(pDecoder, &pSW->pSchema[i]));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -2828,19 +2852,24 @@ static FORCE_INLINE int32_t tSerializeSCMSubscribeReq(void** buf, const SCMSubsc
|
|||
return tlen;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq* pReq) {
|
||||
static FORCE_INLINE int32_t tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq* pReq) {
|
||||
buf = taosDecodeFixedI64(buf, &pReq->consumerId);
|
||||
buf = taosDecodeStringTo(buf, pReq->cgroup);
|
||||
buf = taosDecodeStringTo(buf, pReq->clientId);
|
||||
|
||||
int32_t topicNum;
|
||||
int32_t topicNum = 0;
|
||||
buf = taosDecodeFixedI32(buf, &topicNum);
|
||||
|
||||
pReq->topicNames = taosArrayInit(topicNum, sizeof(void*));
|
||||
if (pReq->topicNames == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
for (int32_t i = 0; i < topicNum; i++) {
|
||||
char* name;
|
||||
char* name = NULL;
|
||||
buf = taosDecodeString(buf, &name);
|
||||
taosArrayPush(pReq->topicNames, &name);
|
||||
if (taosArrayPush(pReq->topicNames, &name) == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
buf = taosDecodeFixedI8(buf, &pReq->withTbName);
|
||||
|
@ -2849,7 +2878,7 @@ static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq
|
|||
buf = taosDecodeFixedI8(buf, &pReq->resetOffsetCfg);
|
||||
buf = taosDecodeFixedI8(buf, &pReq->enableReplay);
|
||||
buf = taosDecodeFixedI8(buf, &pReq->enableBatchMeta);
|
||||
return buf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -3353,30 +3382,32 @@ int32_t tDeserializeSClientHbBatchRsp(void* buf, int32_t bufLen, SClientHbBatchR
|
|||
void tFreeSClientHbBatchRsp(SClientHbBatchRsp* pBatchRsp);
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSKv(SEncoder* pEncoder, const SKv* pKv) {
|
||||
if (tEncodeI32(pEncoder, pKv->key) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pKv->valueLen) < 0) return -1;
|
||||
if (tEncodeBinary(pEncoder, (uint8_t*)pKv->value, pKv->valueLen) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pKv->key));
|
||||
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pKv->valueLen));
|
||||
TAOS_CHECK_RETURN(tEncodeBinary(pEncoder, (uint8_t*)pKv->value, pKv->valueLen));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeSKv(SDecoder* pDecoder, SKv* pKv) {
|
||||
if (tDecodeI32(pDecoder, &pKv->key) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pKv->valueLen) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pKv->key));
|
||||
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pKv->valueLen));
|
||||
pKv->value = taosMemoryMalloc(pKv->valueLen + 1);
|
||||
if (pKv->value == NULL) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, (char*)pKv->value) < 0) return -1;
|
||||
if (pKv->value == NULL) {
|
||||
TAOS_CHECK_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, (char*)pKv->value));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSClientHbKey(SEncoder* pEncoder, const SClientHbKey* pKey) {
|
||||
if (tEncodeI64(pEncoder, pKey->tscRid) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pKey->connType) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pKey->tscRid));
|
||||
TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pKey->connType));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeSClientHbKey(SDecoder* pDecoder, SClientHbKey* pKey) {
|
||||
if (tDecodeI64(pDecoder, &pKey->tscRid) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pKey->connType) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pKey->tscRid));
|
||||
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pKey->connType));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3423,11 +3454,15 @@ static FORCE_INLINE void* taosDecodeSMqTopicInfoMsg(void* buf, SMqTopicInfo* pTo
|
|||
buf = taosDecodeStringTo(buf, pTopicInfo->name);
|
||||
int32_t sz;
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pTopicInfo->pVgInfo = taosArrayInit(sz, sizeof(SMqReportVgInfo));
|
||||
if ((pTopicInfo->pVgInfo = taosArrayInit(sz, sizeof(SMqReportVgInfo))) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqReportVgInfo vgInfo;
|
||||
buf = taosDecodeSMqVgInfo(buf, &vgInfo);
|
||||
taosArrayPush(pTopicInfo->pVgInfo, &vgInfo);
|
||||
if (taosArrayPush(pTopicInfo->pVgInfo, &vgInfo) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
@ -3459,11 +3494,15 @@ static FORCE_INLINE void* taosDecodeSMqReportMsg(void* buf, SMqReportReq* pMsg)
|
|||
buf = taosDecodeFixedI64(buf, &pMsg->consumerId);
|
||||
int32_t sz;
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pMsg->pTopics = taosArrayInit(sz, sizeof(SMqTopicInfo));
|
||||
if ((pMsg->pTopics = taosArrayInit(sz, sizeof(SMqTopicInfo))) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqTopicInfo topicInfo;
|
||||
buf = taosDecodeSMqTopicInfoMsg(buf, &topicInfo);
|
||||
taosArrayPush(pMsg->pTopics, &topicInfo);
|
||||
if (taosArrayPush(pMsg->pTopics, &topicInfo) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
@ -3602,7 +3641,7 @@ int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal);
|
|||
int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal);
|
||||
int32_t tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal);
|
||||
bool tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
||||
void tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pOffsetVal);
|
||||
int32_t tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
||||
void tOffsetDestroy(void* pVal);
|
||||
|
||||
typedef struct {
|
||||
|
@ -3803,17 +3842,17 @@ int32_t tEncodeTSma(SEncoder* pCoder, const STSma* pSma);
|
|||
int32_t tDecodeTSma(SDecoder* pCoder, STSma* pSma, bool deepCopy);
|
||||
|
||||
static int32_t tEncodeTSmaWrapper(SEncoder* pEncoder, const STSmaWrapper* pReq) {
|
||||
if (tEncodeI32(pEncoder, pReq->number) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pReq->number));
|
||||
for (int32_t i = 0; i < pReq->number; ++i) {
|
||||
tEncodeTSma(pEncoder, pReq->tSma + i);
|
||||
TAOS_CHECK_RETURN(tEncodeTSma(pEncoder, pReq->tSma + i));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq, bool deepCopy) {
|
||||
if (tDecodeI32(pDecoder, &pReq->number) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pReq->number));
|
||||
for (int32_t i = 0; i < pReq->number; ++i) {
|
||||
tDecodeTSma(pDecoder, pReq->tSma + i, deepCopy);
|
||||
TAOS_CHECK_RETURN(tDecodeTSma(pDecoder, pReq->tSma + i, deepCopy));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -4036,7 +4075,12 @@ static FORCE_INLINE void* tDecodeSMqAskEpRsp(void* buf, SMqAskEpRsp* pRsp) {
|
|||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqSubTopicEp topicEp;
|
||||
buf = tDecodeMqSubTopicEp(buf, &topicEp);
|
||||
taosArrayPush(pRsp->topics, &topicEp);
|
||||
if (buf == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if ((taosArrayPush(pRsp->topics, &topicEp) == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
|
|||
: 1000000000;
|
||||
time_t t = taosTime(NULL);
|
||||
struct tm tm;
|
||||
taosLocalTime(&t, &tm, NULL);
|
||||
(void) taosLocalTime(&t, &tm, NULL);
|
||||
tm.tm_hour = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_sec = 0;
|
||||
|
@ -86,11 +86,11 @@ void deltaToUtcInitOnce();
|
|||
char getPrecisionUnit(int32_t precision);
|
||||
|
||||
int64_t convertTimePrecision(int64_t ts, int32_t fromPrecision, int32_t toPrecision);
|
||||
int64_t convertTimeFromPrecisionToUnit(int64_t ts, int32_t fromPrecision, char toUnit);
|
||||
int32_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit, int64_t* pRes);
|
||||
int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec, int64_t* timeVal);
|
||||
int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision);
|
||||
|
||||
void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t ts, int32_t precision);
|
||||
int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t ts, int32_t precision);
|
||||
|
||||
struct STm {
|
||||
struct tm tm;
|
||||
|
@ -117,7 +117,7 @@ int32_t taosTs2Char(const char* format, SArray** formats, int64_t ts, int32_t pr
|
|||
int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int64_t* ts, int32_t precision, char* errMsg,
|
||||
int32_t errMsgLen);
|
||||
|
||||
void TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out, int32_t outLen);
|
||||
int32_t TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out, int32_t outLen);
|
||||
int32_t TEST_char2ts(const char* format, int64_t* ts, int32_t precision, const char* tsStr);
|
||||
|
||||
/// @brief get offset seconds from zero timezone to input timezone
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_COMMON_TTSZIP_H_
|
||||
#define _TD_COMMON_TTSZIP_H_
|
||||
|
||||
#include "os.h"
|
||||
#include "tdef.h"
|
||||
#include "tvariant.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MEM_BUF_SIZE (1 << 20)
|
||||
#define TS_COMP_FILE_MAGIC 0x87F5EC4C
|
||||
#define TS_COMP_FILE_GROUP_MAX 512
|
||||
|
||||
typedef struct STSList {
|
||||
char* rawBuf;
|
||||
int32_t allocSize;
|
||||
int32_t threshold;
|
||||
int32_t len;
|
||||
} STSList;
|
||||
|
||||
typedef struct STSElem {
|
||||
TSKEY ts;
|
||||
SVariant* tag;
|
||||
int32_t id;
|
||||
} STSElem;
|
||||
|
||||
typedef struct STSCursor {
|
||||
int32_t vgroupIndex;
|
||||
int32_t blockIndex;
|
||||
int32_t tsIndex;
|
||||
uint32_t order;
|
||||
} STSCursor;
|
||||
|
||||
typedef struct STSBlock {
|
||||
SVariant tag; // tag value
|
||||
int32_t numOfElem; // number of elements
|
||||
int32_t compLen; // size after compressed
|
||||
int32_t padding; // 0xFFFFFFFF by default, after the payload
|
||||
char* payload; // actual data that is compressed
|
||||
} STSBlock;
|
||||
|
||||
/*
|
||||
* The size of buffer file should not be greater than 2G,
|
||||
* and the offset of int32_t type is enough
|
||||
*/
|
||||
typedef struct STSGroupBlockInfo {
|
||||
int32_t id; // group id
|
||||
int32_t offset; // offset set value in file
|
||||
int32_t numOfBlocks; // number of total blocks
|
||||
int32_t compLen; // compressed size
|
||||
} STSGroupBlockInfo;
|
||||
|
||||
typedef struct STSGroupBlockInfoEx {
|
||||
STSGroupBlockInfo info;
|
||||
int32_t len; // length before compress
|
||||
} STSGroupBlockInfoEx;
|
||||
|
||||
typedef struct STSBuf {
|
||||
TdFilePtr pFile;
|
||||
char path[PATH_MAX];
|
||||
uint32_t fileSize;
|
||||
|
||||
// todo use array
|
||||
STSGroupBlockInfoEx* pData;
|
||||
uint32_t numOfAlloc;
|
||||
uint32_t numOfGroups;
|
||||
|
||||
char* assistBuf;
|
||||
int32_t bufSize;
|
||||
STSBlock block;
|
||||
STSList tsData; // uncompressed raw ts data
|
||||
uint64_t numOfTotal;
|
||||
bool autoDelete;
|
||||
bool remainOpen;
|
||||
int32_t tsOrder; // order of timestamp in ts comp buffer
|
||||
STSCursor cur;
|
||||
} STSBuf;
|
||||
|
||||
typedef struct STSBufFileHeader {
|
||||
uint32_t magic; // file magic number
|
||||
uint32_t numOfGroup; // number of group stored in current file
|
||||
int32_t tsOrder; // timestamp order in current file
|
||||
} STSBufFileHeader;
|
||||
|
||||
STSBuf* tsBufCreate(bool autoDelete, int32_t order);
|
||||
STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete);
|
||||
STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_t len, int32_t tsOrder, int32_t id);
|
||||
|
||||
void* tsBufDestroy(STSBuf* pTSBuf);
|
||||
|
||||
void tsBufAppend(STSBuf* pTSBuf, int32_t id, SVariant* tag, const char* pData, int32_t len);
|
||||
int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf);
|
||||
|
||||
STSBuf* tsBufClone(STSBuf* pTSBuf);
|
||||
|
||||
STSGroupBlockInfo* tsBufGetGroupBlockInfo(STSBuf* pTSBuf, int32_t id);
|
||||
|
||||
void tsBufFlush(STSBuf* pTSBuf);
|
||||
void tsBufResetPos(STSBuf* pTSBuf);
|
||||
bool tsBufNextPos(STSBuf* pTSBuf);
|
||||
|
||||
STSElem tsBufGetElem(STSBuf* pTSBuf);
|
||||
STSElem tsBufGetElemStartPos(STSBuf* pTSBuf, int32_t id, SVariant* tag);
|
||||
|
||||
STSCursor tsBufGetCursor(STSBuf* pTSBuf);
|
||||
void tsBufSetTraverseOrder(STSBuf* pTSBuf, int32_t order);
|
||||
|
||||
void tsBufSetCursor(STSBuf* pTSBuf, STSCursor* pCur);
|
||||
|
||||
/**
|
||||
* display all data in comp block file, for debug purpose only
|
||||
* @param pTSBuf
|
||||
*/
|
||||
void tsBufDisplay(STSBuf* pTSBuf);
|
||||
|
||||
int32_t tsBufGetNumOfGroup(STSBuf* pTSBuf);
|
||||
|
||||
void tsBufGetGroupIdList(STSBuf* pTSBuf, int32_t* num, int32_t** id);
|
||||
|
||||
int32_t dumpFileBlockByGroupId(STSBuf* pTSBuf, int32_t id, void* buf, int32_t* len, int32_t* numOfBlocks);
|
||||
|
||||
STSElem tsBufFindElemStartPosByTag(STSBuf* pTSBuf, SVariant* pTag);
|
||||
|
||||
bool tsBufIsValidElem(STSElem* pElem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_COMMON_TTSZIP_H_*/
|
|
@ -46,7 +46,7 @@ typedef struct {
|
|||
#pragma pack(pop)
|
||||
|
||||
#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v))
|
||||
#define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v))
|
||||
#define varDataCopy(dst, v) (void)memcpy((dst), (void *)(v), varDataTLen(v))
|
||||
#define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE))
|
||||
#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len))
|
||||
|
||||
|
|
|
@ -34,9 +34,10 @@ typedef struct {
|
|||
* @brief Start one Qnode in Dnode.
|
||||
*
|
||||
* @param pOption Option of the qnode.
|
||||
* @return SQnode* The qnode object.
|
||||
* @param pQnode The qnode object.
|
||||
* @return int32_t The error code.
|
||||
*/
|
||||
SQnode *qndOpen(const SQnodeOpt *pOption);
|
||||
int32_t qndOpen(const SQnodeOpt *pOption, SQnode **pQnode);
|
||||
|
||||
/**
|
||||
* @brief Stop Qnode in Dnode.
|
||||
|
|
|
@ -213,7 +213,7 @@ const char* qExtractTbnameFromTask(qTaskInfo_t tinfo);
|
|||
|
||||
void* qExtractReaderFromStreamScanner(void* scanner);
|
||||
|
||||
int32_t qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner);
|
||||
void qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner);
|
||||
|
||||
int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo);
|
||||
int32_t qStreamSourceScanParamForHistoryScanStep1(qTaskInfo_t tinfo, SVersionRange *pVerRange, STimeWindow* pWindow);
|
||||
|
|
|
@ -195,7 +195,7 @@ typedef struct SStoreCacheReader {
|
|||
int32_t (*openReader)(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||
SArray *pCidList, int32_t *pSlotIds, uint64_t suid, void **pReader, const char *idstr,
|
||||
SArray *pFuncTypeList, SColumnInfo* pPkCol, int32_t numOfPks);
|
||||
void *(*closeReader)(void *pReader);
|
||||
void (*closeReader)(void *pReader);
|
||||
int32_t (*retrieveRows)(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, const int32_t *dstSlotIds,
|
||||
SArray *pTableUidList);
|
||||
int32_t (*reuseReader)(void *pReader, void *pTableIdList, int32_t numOfTables);
|
||||
|
@ -218,10 +218,10 @@ typedef struct SStoreTqReader {
|
|||
int32_t (*tqGetStreamExecProgress)();
|
||||
|
||||
void (*tqReaderSetColIdList)();
|
||||
int32_t (*tqReaderSetQueryTableList)();
|
||||
void (*tqReaderSetQueryTableList)();
|
||||
|
||||
int32_t (*tqReaderAddTables)();
|
||||
int32_t (*tqReaderRemoveTables)();
|
||||
void (*tqReaderAddTables)();
|
||||
void (*tqReaderRemoveTables)();
|
||||
|
||||
void (*tqSetTablePrimaryKey)();
|
||||
bool (*tqGetTablePrimaryKey)();
|
||||
|
@ -239,8 +239,8 @@ typedef struct SStoreSnapshotFn {
|
|||
bool (*taosXGetTablePrimaryKey)(SSnapContext* ctx);
|
||||
void (*taosXSetTablePrimaryKey)(SSnapContext* ctx, int64_t uid);
|
||||
int32_t (*setForSnapShot)(SSnapContext* ctx, int64_t uid);
|
||||
int32_t (*destroySnapshot)(SSnapContext* ctx);
|
||||
SMetaTableInfo (*getMetaTableInfoFromSnapshot)(SSnapContext* ctx);
|
||||
void (*destroySnapshot)(SSnapContext* ctx);
|
||||
int32_t (*getMetaTableInfoFromSnapshot)(SSnapContext* ctx, SMetaTableInfo* info);
|
||||
int32_t (*getTableInfoFromSnapshot)(SSnapContext* ctx, void** pBuf, int32_t* contLen, int16_t* type, int64_t* uid);
|
||||
} SStoreSnapshotFn;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef struct SFuncExecEnv {
|
|||
} SFuncExecEnv;
|
||||
|
||||
typedef bool (*FExecGetEnv)(struct SFunctionNode *pFunc, SFuncExecEnv *pEnv);
|
||||
typedef bool (*FExecInit)(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo);
|
||||
typedef int32_t (*FExecInit)(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo);
|
||||
typedef int32_t (*FExecProcess)(struct SqlFunctionCtx *pCtx);
|
||||
typedef int32_t (*FExecFinalize)(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock);
|
||||
typedef int32_t (*FScalarExecProcess)(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
|
|
@ -138,6 +138,7 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_CACHE_LAST_ROW,
|
||||
FUNCTION_TYPE_CACHE_LAST,
|
||||
FUNCTION_TYPE_TABLE_COUNT,
|
||||
FUNCTION_TYPE_GROUP_CONST_VALUE,
|
||||
|
||||
// distributed splitting functions
|
||||
FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000,
|
||||
|
@ -256,9 +257,10 @@ bool fmIsConstantResFunc(SFunctionNode* pFunc);
|
|||
bool fmIsSkipScanCheckFunc(int32_t funcId);
|
||||
bool fmIsPrimaryKeyFunc(int32_t funcId);
|
||||
bool fmIsProcessByRowFunc(int32_t funcId);
|
||||
bool fmisSelectGroupConstValueFunc(int32_t funcId);
|
||||
|
||||
void getLastCacheDataType(SDataType* pType, int32_t pkBytes);
|
||||
SFunctionNode* createFunction(const char* pName, SNodeList* pParameterList);
|
||||
int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNode** pFunc);
|
||||
|
||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMidFunc, SFunctionNode** pMergeFunc);
|
||||
|
||||
|
@ -271,7 +273,7 @@ typedef enum EFuncDataRequired {
|
|||
} EFuncDataRequired;
|
||||
|
||||
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||
EFuncDataRequired fmFuncDynDataRequired(int32_t funcId, void* pRes, SDataBlockInfo* pBlockInfo);
|
||||
int32_t fmFuncDynDataRequired(int32_t funcId, void* pRes, SDataBlockInfo* pBlockInfo, int32_t *reqStatus);
|
||||
|
||||
int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
||||
int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet);
|
||||
|
|
|
@ -33,6 +33,15 @@ extern "C" {
|
|||
#else
|
||||
#define FORCE_INLINE
|
||||
#endif
|
||||
|
||||
#define TAOS_UDF_CHECK_RETURN(CMD) \
|
||||
do { \
|
||||
int32_t code = (CMD); \
|
||||
if (code != TSDB_CODE_SUCCESS) { \
|
||||
return (CMD); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
typedef struct SUdfColumnMeta {
|
||||
int16_t type;
|
||||
int32_t bytes;
|
||||
|
@ -105,12 +114,14 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 65535
|
|||
#define varDataLen(v) ((VarDataLenT *)(v))[0]
|
||||
#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE)
|
||||
#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v))
|
||||
#define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v))
|
||||
#define varDataCopy(dst, v) (void)memcpy((dst), (void *)(v), varDataTLen(v))
|
||||
#define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE))
|
||||
#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len))
|
||||
#define IS_VAR_DATA_TYPE(t) \
|
||||
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON) || ((t) == TSDB_DATA_TYPE_GEOMETRY))
|
||||
#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR))
|
||||
#define IS_VAR_DATA_TYPE(t) \
|
||||
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR) || \
|
||||
((t) == TSDB_DATA_TYPE_JSON) || ((t) == TSDB_DATA_TYPE_GEOMETRY))
|
||||
#define IS_STR_DATA_TYPE(t) \
|
||||
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR))
|
||||
|
||||
static FORCE_INLINE char *udfColDataGetData(const SUdfColumn *pColumn, int32_t row) {
|
||||
if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) {
|
||||
|
@ -158,7 +169,7 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn *pColumn, int32_t ne
|
|||
}
|
||||
data->varLenCol.varOffsets = (int32_t *)tmp;
|
||||
data->varLenCol.varOffsetsLen = sizeof(int32_t) * allocCapacity;
|
||||
memset(&data->varLenCol.varOffsets[existedRows], 0, sizeof(int32_t) * (allocCapacity - existedRows));
|
||||
(void)memset(&data->varLenCol.varOffsets[existedRows], 0, sizeof(int32_t) * (allocCapacity - existedRows));
|
||||
// for payload, add data in udfColDataAppend
|
||||
} else {
|
||||
char *tmp = (char *)realloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity));
|
||||
|
@ -166,11 +177,11 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn *pColumn, int32_t ne
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
uint32_t extend = BitmapLen(allocCapacity) - BitmapLen(data->rowsAlloc);
|
||||
memset(tmp + BitmapLen(data->rowsAlloc), 0, extend);
|
||||
(void)memset(tmp + BitmapLen(data->rowsAlloc), 0, extend);
|
||||
data->fixLenCol.nullBitmap = tmp;
|
||||
data->fixLenCol.nullBitmapLen = BitmapLen(allocCapacity);
|
||||
int32_t oldLen = BitmapLen(existedRows);
|
||||
memset(&data->fixLenCol.nullBitmap[oldLen], 0, BitmapLen(allocCapacity) - oldLen);
|
||||
(void)memset(&data->fixLenCol.nullBitmap[oldLen], 0, BitmapLen(allocCapacity) - oldLen);
|
||||
|
||||
if (meta->type == TSDB_DATA_TYPE_NULL) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -190,8 +201,11 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn *pColumn, int32_t ne
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void udfColDataSetNull(SUdfColumn *pColumn, int32_t row) {
|
||||
udfColEnsureCapacity(pColumn, row + 1);
|
||||
static FORCE_INLINE int32_t udfColDataSetNull(SUdfColumn *pColumn, int32_t row) {
|
||||
int32_t code = udfColEnsureCapacity(pColumn, row + 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) {
|
||||
udfColDataSetNull_var(pColumn, row);
|
||||
} else {
|
||||
|
@ -199,19 +213,20 @@ static FORCE_INLINE void udfColDataSetNull(SUdfColumn *pColumn, int32_t row) {
|
|||
}
|
||||
pColumn->hasNull = true;
|
||||
pColumn->colData.numOfRows = ((int32_t)(row + 1) > pColumn->colData.numOfRows) ? (int32_t)(row + 1) : pColumn->colData.numOfRows;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentRow, const char *pData, bool isNull) {
|
||||
SUdfColumnMeta *meta = &pColumn->colMeta;
|
||||
SUdfColumnData *data = &pColumn->colData;
|
||||
udfColEnsureCapacity(pColumn, currentRow + 1);
|
||||
TAOS_UDF_CHECK_RETURN(udfColEnsureCapacity(pColumn, currentRow + 1));
|
||||
bool isVarCol = IS_VAR_DATA_TYPE(meta->type);
|
||||
if (isNull) {
|
||||
udfColDataSetNull(pColumn, currentRow);
|
||||
TAOS_UDF_CHECK_RETURN(udfColDataSetNull(pColumn, currentRow));
|
||||
} else {
|
||||
if (!isVarCol) {
|
||||
udfColDataSetNotNull_f(pColumn, currentRow);
|
||||
memcpy(data->fixLenCol.data + meta->bytes * currentRow, pData, meta->bytes);
|
||||
(void)memcpy(data->fixLenCol.data + meta->bytes * currentRow, pData, meta->bytes);
|
||||
} else {
|
||||
int32_t dataLen = varDataTLen(pData);
|
||||
if (meta->type == TSDB_DATA_TYPE_JSON) {
|
||||
|
@ -249,7 +264,7 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentR
|
|||
uint32_t len = data->varLenCol.payloadLen;
|
||||
data->varLenCol.varOffsets[currentRow] = len;
|
||||
|
||||
memcpy(data->varLenCol.payload + len, pData, dataLen);
|
||||
(void)memcpy(data->varLenCol.payload + len, pData, dataLen);
|
||||
data->varLenCol.payloadLen += dataLen;
|
||||
}
|
||||
}
|
||||
|
@ -278,8 +293,8 @@ typedef enum EUdfFuncType { UDF_FUNC_TYPE_SCALAR = 1, UDF_FUNC_TYPE_AGG = 2 } EU
|
|||
|
||||
typedef struct SScriptUdfInfo {
|
||||
const char *name;
|
||||
int32_t version;
|
||||
int64_t createdTime;
|
||||
int32_t version;
|
||||
int64_t createdTime;
|
||||
|
||||
EUdfFuncType funcType;
|
||||
int8_t scriptType;
|
||||
|
|
|
@ -43,6 +43,25 @@ extern "C" {
|
|||
#endif
|
||||
#define UDF_DNODE_ID_ENV_NAME "DNODE_ID"
|
||||
|
||||
#define TAOS_UV_LIB_ERROR_RET(ret) \
|
||||
do { \
|
||||
if (0 != ret) { \
|
||||
terrno = TSDB_CODE_UDF_UV_EXEC_FAILURE; \
|
||||
return TSDB_CODE_UDF_UV_EXEC_FAILURE; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define TAOS_UV_CHECK_ERRNO(CODE) \
|
||||
do { \
|
||||
if (0 != CODE) { \
|
||||
terrln = __LINE__; \
|
||||
terrno = (CODE); \
|
||||
goto _exit; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
// low level APIs
|
||||
/**
|
||||
* setup udf
|
||||
|
@ -77,7 +96,7 @@ void freeUdfInterBuf(SUdfInterBuf *buf);
|
|||
|
||||
// high level APIs
|
||||
bool udfAggGetEnv(struct SFunctionNode *pFunc, SFuncExecEnv *pEnv);
|
||||
bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo);
|
||||
int32_t udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo);
|
||||
int32_t udfAggProcess(struct SqlFunctionCtx *pCtx);
|
||||
int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock);
|
||||
|
||||
|
@ -109,13 +128,13 @@ int32_t udfStartUdfd(int32_t startDnodeId);
|
|||
* stop udfd
|
||||
* @return
|
||||
*/
|
||||
int32_t udfStopUdfd();
|
||||
void udfStopUdfd();
|
||||
|
||||
/**
|
||||
* get udfd pid
|
||||
*
|
||||
*/
|
||||
int32_t udfGetUdfdPid(int32_t* pUdfdPid);
|
||||
// int32_t udfGetUdfdPid(int32_t* pUdfdPid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ void indexMultiTermQueryDestroy(SIndexMultiTermQuery* pQuery);
|
|||
* @param type (input, single query type)
|
||||
* @return error code
|
||||
*/
|
||||
int indexMultiTermQueryAdd(SIndexMultiTermQuery* pQuery, SIndexTerm* term, EIndexQueryType type);
|
||||
int32_t indexMultiTermQueryAdd(SIndexMultiTermQuery* pQuery, SIndexTerm* term, EIndexQueryType type);
|
||||
/*
|
||||
* open index
|
||||
* @param opt (input, index opt)
|
||||
|
@ -91,7 +91,7 @@ int indexMultiTermQueryAdd(SIndexMultiTermQuery* pQuery, SIndexTerm* term, EInde
|
|||
* @param index (output, index object)
|
||||
* @return error code
|
||||
*/
|
||||
int indexOpen(SIndexOpts* opt, const char* path, SIndex** index);
|
||||
int32_t indexOpen(SIndexOpts* opt, const char* path, SIndex** index);
|
||||
/*
|
||||
* close index
|
||||
* @param index (input, index to be closed)
|
||||
|
@ -106,7 +106,7 @@ void indexClose(SIndex* index);
|
|||
* @param uid (input, uid of terms)
|
||||
* @return error code
|
||||
*/
|
||||
int indexPut(SIndex* index, SIndexMultiTerm* terms, uint64_t uid);
|
||||
int32_t indexPut(SIndex* index, SIndexMultiTerm* terms, uint64_t uid);
|
||||
/*
|
||||
* delete terms that meet query condition
|
||||
* @param index (input, index object)
|
||||
|
@ -114,7 +114,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* terms, uint64_t uid);
|
|||
* @return error code
|
||||
*/
|
||||
|
||||
int indexDelete(SIndex* index, SIndexMultiTermQuery* query);
|
||||
int32_t indexDelete(SIndex* index, SIndexMultiTermQuery* query);
|
||||
/*
|
||||
* search index
|
||||
* @param index (input, index object)
|
||||
|
@ -122,7 +122,7 @@ int indexDelete(SIndex* index, SIndexMultiTermQuery* query);
|
|||
* @param result(output, query result)
|
||||
* @return error code
|
||||
*/
|
||||
int indexSearch(SIndex* index, SIndexMultiTermQuery* query, SArray* result);
|
||||
int32_t indexSearch(SIndex* index, SIndexMultiTermQuery* query, SArray* result);
|
||||
/*
|
||||
* rebuild index
|
||||
* @param index (input, index object)
|
||||
|
@ -138,7 +138,7 @@ int indexSearch(SIndex* index, SIndexMultiTermQuery* query, SArray* result);
|
|||
* @param index (output, index json object)
|
||||
* @return error code
|
||||
*/
|
||||
int indexJsonOpen(SIndexJsonOpts* opts, const char* path, SIndexJson** index);
|
||||
int32_t indexJsonOpen(SIndexJsonOpts* opts, const char* path, SIndexJson** index);
|
||||
/*
|
||||
* close index
|
||||
* @param index (input, index to be closed)
|
||||
|
@ -154,7 +154,7 @@ void indexJsonClose(SIndexJson* index);
|
|||
* @param uid (input, uid of terms)
|
||||
* @return error code
|
||||
*/
|
||||
int indexJsonPut(SIndexJson* index, SIndexJsonMultiTerm* terms, uint64_t uid);
|
||||
int32_t indexJsonPut(SIndexJson* index, SIndexJsonMultiTerm* terms, uint64_t uid);
|
||||
/*
|
||||
* search index
|
||||
* @param index (input, index object)
|
||||
|
@ -163,7 +163,7 @@ int indexJsonPut(SIndexJson* index, SIndexJsonMultiTerm* terms, uint64_t uid);
|
|||
* @return error code
|
||||
*/
|
||||
|
||||
int indexJsonSearch(SIndexJson* index, SIndexJsonMultiTermQuery* query, SArray* result);
|
||||
int32_t indexJsonSearch(SIndexJson* index, SIndexJsonMultiTermQuery* query, SArray* result);
|
||||
/*
|
||||
* @param
|
||||
* @param
|
||||
|
|
|
@ -112,11 +112,11 @@ int64_t nodesMakeAllocatorWeakRef(int64_t allocatorId);
|
|||
int64_t nodesReleaseAllocatorWeakRef(int64_t allocatorId);
|
||||
void nodesDestroyAllocator(int64_t allocatorId);
|
||||
|
||||
SNode* nodesMakeNode(ENodeType type);
|
||||
int32_t nodesMakeNode(ENodeType type, SNode** ppNodeOut);
|
||||
void nodesDestroyNode(SNode* pNode);
|
||||
void nodesFree(void* p);
|
||||
|
||||
SNodeList* nodesMakeList();
|
||||
int32_t nodesMakeList(SNodeList** ppListOut);
|
||||
int32_t nodesListAppend(SNodeList* pList, SNode* pNode);
|
||||
int32_t nodesListStrictAppend(SNodeList* pList, SNode* pNode);
|
||||
int32_t nodesListMakeAppend(SNodeList** pList, SNode* pNode);
|
||||
|
@ -156,8 +156,8 @@ bool nodeListNodeEqual(const SNodeList* a, const SNode* b);
|
|||
|
||||
bool nodesMatchNode(const SNode* pSub, const SNode* pNode);
|
||||
|
||||
SNode* nodesCloneNode(const SNode* pNode);
|
||||
SNodeList* nodesCloneList(const SNodeList* pList);
|
||||
int32_t nodesCloneNode(const SNode* pNode, SNode** ppNodeOut);
|
||||
int32_t nodesCloneList(const SNodeList* pList, SNodeList** ppList);
|
||||
|
||||
const char* nodesNodeName(ENodeType type);
|
||||
int32_t nodesNodeToString(const SNode* pNode, bool format, char** pStr, int32_t* pLen);
|
||||
|
|
|
@ -636,9 +636,9 @@ void* nodesGetValueFromNode(SValueNode* pNode);
|
|||
int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value);
|
||||
char* nodesGetStrValueFromNode(SValueNode* pNode);
|
||||
void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
|
||||
SValueNode* nodesMakeValueNodeFromString(char* literal);
|
||||
SValueNode* nodesMakeValueNodeFromBool(bool b);
|
||||
SNode* nodesMakeValueNodeFromInt32(int32_t value);
|
||||
int32_t nodesMakeValueNodeFromString(char* literal, SValueNode** ppValNode);
|
||||
int32_t nodesMakeValueNodeFromBool(bool b, SValueNode** ppValNode);
|
||||
int32_t nodesMakeValueNodeFromInt32(int32_t value, SNode** ppNode);
|
||||
|
||||
char* nodesGetFillModeString(EFillMode mode);
|
||||
int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc);
|
||||
|
|
|
@ -118,6 +118,7 @@ void qDestroyQuery(SQuery* pQueryNode);
|
|||
|
||||
int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
||||
int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid);
|
||||
int32_t qInitKeywordsTable();
|
||||
void qCleanupKeywordsTable();
|
||||
|
||||
int32_t qAppendStmtTableOutput(SQuery* pQuery, SHashObj* pAllVgHash, STableColsData* pTbData, STableDataCxt* pTbCtx, SStbInterlaceInfo* pBuildInfo);
|
||||
|
|
|
@ -686,7 +686,7 @@ int32_t streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration);
|
|||
bool streamHistoryTaskSetVerRangeStep2(SStreamTask* pTask, int64_t latestVer);
|
||||
|
||||
// checkpoint related
|
||||
int32_t streamTaskGetActiveCheckpointInfo(const SStreamTask* pTask, int32_t* pTransId, int64_t* pCheckpointId);
|
||||
void streamTaskGetActiveCheckpointInfo(const SStreamTask* pTask, int32_t* pTransId, int64_t* pCheckpointId);
|
||||
int32_t streamTaskSetActiveCheckpointInfo(SStreamTask* pTask, int64_t activeCheckpointId);
|
||||
int32_t streamTaskSetFailedChkptInfo(SStreamTask* pTask, int32_t transId, int64_t checkpointId);
|
||||
bool streamTaskAlreadySendTrigger(SStreamTask* pTask, int32_t downstreamNodeId);
|
||||
|
@ -770,9 +770,9 @@ bool streamMetaAllTasksReady(const SStreamMeta* pMeta);
|
|||
int32_t streamTaskSendRestoreChkptMsg(SStreamTask* pTask);
|
||||
|
||||
// timer
|
||||
tmr_h streamTimerGetInstance();
|
||||
void streamTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void* param, void* handle, tmr_h* pTmrId, int32_t vgId,
|
||||
const char* pMsg);
|
||||
int32_t streamTimerGetInstance(tmr_h* pTmr);
|
||||
void streamTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void* param, void* handle, tmr_h* pTmrId, int32_t vgId,
|
||||
const char* pMsg);
|
||||
|
||||
// checkpoint
|
||||
int32_t streamProcessCheckpointSourceReq(SStreamTask* pTask, SStreamCheckpointSourceReq* pReq);
|
||||
|
@ -809,6 +809,9 @@ void streamTaskSendRetrieveRsp(SStreamRetrieveReq* pReq, SRpcMsg* pRsp);
|
|||
int32_t streamProcessHeartbeatRsp(SStreamMeta* pMeta, SMStreamHbRspMsg* pRsp);
|
||||
int32_t streamTaskSendCheckpointsourceRsp(SStreamTask* pTask);
|
||||
|
||||
void streamMutexLock(TdThreadMutex *pMutex);
|
||||
void streamMutexUnlock(TdThreadMutex *pMutex);
|
||||
void streamMutexDestroy(TdThreadMutex *pMutex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -44,9 +44,9 @@ typedef struct {
|
|||
*
|
||||
* @param pCfg Config of the fs.
|
||||
* @param ndisk Length of the config.
|
||||
* @return STfs* The fs object.
|
||||
* @param ppTfs The fs object.
|
||||
*/
|
||||
STfs *tfsOpen(SDiskCfg *pCfg, int32_t ndisk);
|
||||
int32_t tfsOpen(SDiskCfg *pCfg, int32_t ndisk, STfs **ppTfs);
|
||||
|
||||
/**
|
||||
* @brief Close a fs.
|
||||
|
@ -275,7 +275,7 @@ int32_t tfsCopyFile(const STfsFile *pFile1, const STfsFile *pFile2);
|
|||
* @param rname The rel name of file.
|
||||
* @return STfsDir* The dir object.
|
||||
*/
|
||||
STfsDir *tfsOpendir(STfs *pTfs, const char *rname);
|
||||
int32_t tfsOpendir(STfs *pTfs, const char *rname, STfsDir **ppDir);
|
||||
|
||||
/**
|
||||
* @brief Get a file from dir and move to next pos.
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_WAL_H_
|
||||
#define _TD_WAL_H_
|
||||
|
||||
|
@ -20,19 +21,11 @@
|
|||
#include "tdef.h"
|
||||
#include "tlog.h"
|
||||
#include "tmsg.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
#define wFatal(...) { if (wDebugFlag & DEBUG_FATAL) { taosPrintLog("WAL FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
|
||||
#define wError(...) { if (wDebugFlag & DEBUG_ERROR) { taosPrintLog("WAL ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
|
||||
#define wWarn(...) { if (wDebugFlag & DEBUG_WARN) { taosPrintLog("WAL WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
|
||||
#define wInfo(...) { if (wDebugFlag & DEBUG_INFO) { taosPrintLog("WAL ", DEBUG_INFO, 255, __VA_ARGS__); }}
|
||||
#define wDebug(...) { if (wDebugFlag & DEBUG_DEBUG) { taosPrintLog("WAL ", DEBUG_DEBUG, wDebugFlag, __VA_ARGS__); }}
|
||||
#define wTrace(...) { if (wDebugFlag & DEBUG_TRACE) { taosPrintLog("WAL ", DEBUG_TRACE, wDebugFlag, __VA_ARGS__); }}
|
||||
// clang-format on
|
||||
|
||||
#define WAL_PROTO_VER 0
|
||||
#define WAL_NOSUFFIX_LEN 20
|
||||
#define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1)
|
||||
|
@ -131,8 +124,7 @@ typedef struct SWal {
|
|||
typedef struct {
|
||||
int64_t refId;
|
||||
int64_t refVer;
|
||||
// int64_t refFile;
|
||||
SWal *pWal;
|
||||
SWal *pWal;
|
||||
} SWalRef;
|
||||
|
||||
typedef struct {
|
||||
|
@ -143,10 +135,8 @@ typedef struct {
|
|||
int8_t enableRef;
|
||||
} SWalFilterCond;
|
||||
|
||||
typedef struct SWalReader SWalReader;
|
||||
|
||||
// todo hide this struct
|
||||
struct SWalReader {
|
||||
typedef struct SWalReader {
|
||||
SWal *pWal;
|
||||
int64_t readerId;
|
||||
TdFilePtr pLogFile;
|
||||
|
@ -159,7 +149,7 @@ struct SWalReader {
|
|||
TdThreadMutex mutex;
|
||||
SWalFilterCond cond;
|
||||
SWalCkHead *pHead;
|
||||
};
|
||||
} SWalReader;
|
||||
|
||||
// module initialization
|
||||
int32_t walInit();
|
||||
|
@ -172,17 +162,9 @@ int32_t walPersist(SWal *);
|
|||
void walClose(SWal *);
|
||||
|
||||
// write interfaces
|
||||
|
||||
// By assigning index by the caller, wal gurantees linearizability
|
||||
int32_t walWrite(SWal *, int64_t index, tmsg_t msgType, const void *body, int32_t bodyLen);
|
||||
int32_t walWriteWithSyncInfo(SWal *, int64_t index, tmsg_t msgType, SWalSyncInfo syncMeta, const void *body,
|
||||
int32_t bodyLen);
|
||||
|
||||
// Assign version automatically and return to caller,
|
||||
// -1 will be returned for failed writes
|
||||
int64_t walAppendLog(SWal *, int64_t index, tmsg_t msgType, SWalSyncInfo syncMeta, const void *body, int32_t bodyLen);
|
||||
|
||||
void walFsync(SWal *, bool force);
|
||||
int32_t walAppendLog(SWal *, int64_t index, tmsg_t msgType, SWalSyncInfo syncMeta, const void *body, int32_t bodyLen);
|
||||
int32_t walFsync(SWal *, bool force);
|
||||
|
||||
// apis for lifecycle management
|
||||
int32_t walCommit(SWal *, int64_t ver);
|
||||
|
@ -191,17 +173,13 @@ int32_t walRollback(SWal *, int64_t ver);
|
|||
int32_t walBeginSnapshot(SWal *, int64_t ver, int64_t logRetention);
|
||||
int32_t walEndSnapshot(SWal *);
|
||||
int32_t walRestoreFromSnapshot(SWal *, int64_t ver);
|
||||
// for tq
|
||||
int32_t walApplyVer(SWal *, int64_t ver);
|
||||
|
||||
// int32_t walDataCorrupted(SWal*);
|
||||
|
||||
// wal reader
|
||||
SWalReader *walOpenReader(SWal *, SWalFilterCond *pCond, int64_t id);
|
||||
void walCloseReader(SWalReader *pRead);
|
||||
void walReadReset(SWalReader *pReader);
|
||||
int32_t walReadVer(SWalReader *pRead, int64_t ver);
|
||||
void decryptBody(SWalCfg *cfg, SWalCkHead *pHead, int32_t plainBodyLen, const char *func);
|
||||
int32_t walReaderSeekVer(SWalReader *pRead, int64_t ver);
|
||||
int32_t walNextValidMsg(SWalReader *pRead);
|
||||
int64_t walReaderGetCurrentVer(const SWalReader *pReader);
|
||||
|
@ -216,12 +194,11 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver);
|
|||
int32_t walFetchBody(SWalReader *pRead);
|
||||
int32_t walSkipFetchBody(SWalReader *pRead);
|
||||
|
||||
void walRefFirstVer(SWal *, SWalRef *);
|
||||
void walRefLastVer(SWal *, SWalRef *);
|
||||
|
||||
SWalRef *walOpenRef(SWal *);
|
||||
void walCloseRef(SWal *pWal, int64_t refId);
|
||||
int32_t walSetRefVer(SWalRef *, int64_t ver);
|
||||
void walRefFirstVer(SWal *, SWalRef *);
|
||||
void walRefLastVer(SWal *, SWalRef *);
|
||||
|
||||
// helper function for raft
|
||||
bool walLogExist(SWal *, int64_t ver);
|
||||
|
|
|
@ -97,6 +97,7 @@ extern "C" {
|
|||
#include <nmmintrin.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "osThread.h"
|
||||
|
||||
#include "osAtomic.h"
|
||||
|
|
|
@ -65,7 +65,7 @@ typedef int (*__compar_fn_t)(const void *, const void *);
|
|||
#endif
|
||||
#define ssize_t int
|
||||
#define _SSIZE_T_
|
||||
#define bzero(ptr, size) memset((ptr), 0, (size))
|
||||
#define bzero(ptr, size) (void)memset((ptr), 0, (size))
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#define wcsncasecmp _wcsnicmp
|
||||
|
|
|
@ -79,6 +79,8 @@ extern "C" {
|
|||
typedef struct TdDir *TdDirPtr;
|
||||
typedef struct TdDirEntry *TdDirEntryPtr;
|
||||
|
||||
#define TAOS_DIRNAME(name) ((void)taosDirName(name))
|
||||
|
||||
void taosRemoveDir(const char *dirname);
|
||||
bool taosDirExist(const char *dirname);
|
||||
int32_t taosMkDir(const char *dirname);
|
||||
|
|
|
@ -54,7 +54,7 @@ extern SDiskSpace tsDataSpace;
|
|||
extern SDiskSpace tsLogSpace;
|
||||
extern SDiskSpace tsTempSpace;
|
||||
|
||||
void osDefaultInit();
|
||||
int32_t osDefaultInit();
|
||||
void osUpdate();
|
||||
void osCleanup();
|
||||
|
||||
|
@ -66,7 +66,7 @@ bool osLogSpaceSufficient();
|
|||
bool osDataSpaceSufficient();
|
||||
bool osTempSpaceSufficient();
|
||||
|
||||
void osSetTimezone(const char *timezone);
|
||||
int32_t osSetTimezone(const char *timezone);
|
||||
void osSetSystemLocale(const char *inLocale, const char *inCharSet);
|
||||
void osSetProcPath(int32_t argc, char **argv);
|
||||
|
||||
|
|
|
@ -114,8 +114,6 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
|
|||
|
||||
bool taosValidFile(TdFilePtr pFile);
|
||||
|
||||
int32_t taosGetErrorFile(TdFilePtr pFile);
|
||||
|
||||
int32_t taosCompressFile(char *srcFileName, char *destFileName);
|
||||
|
||||
int32_t taosSetFileHandlesLimit();
|
||||
|
|
|
@ -30,7 +30,7 @@ extern "C" {
|
|||
|
||||
char *taosCharsetReplace(char *charsetstr);
|
||||
void taosGetSystemLocale(char *outLocale, char *outCharset);
|
||||
void taosSetSystemLocale(const char *inLocale, const char *inCharSet);
|
||||
int32_t taosSetSystemLocale(const char *inLocale, const char *inCharSet);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -61,6 +61,15 @@ void *taosMemMallocAlign(uint32_t alignment, int64_t size);
|
|||
} while (0)
|
||||
|
||||
#include "osMemPool.h"
|
||||
#define TAOS_MEMORY_REALLOC(ptr, len) \
|
||||
do { \
|
||||
void *tmp = taosMemoryRealloc(ptr, (len)); \
|
||||
if (tmp) { \
|
||||
(ptr) = tmp; \
|
||||
} else { \
|
||||
taosMemoryFreeClear(ptr); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -49,11 +49,14 @@ typedef BOOL (*FSignalHandler)(DWORD fdwCtrlType);
|
|||
#else
|
||||
typedef void (*FSignalHandler)(int32_t signum, void *sigInfo, void *context);
|
||||
#endif
|
||||
void taosSetSignal(int32_t signum, FSignalHandler sigfp);
|
||||
void taosIgnSignal(int32_t signum);
|
||||
void taosDflSignal(int32_t signum);
|
||||
|
||||
void taosKillChildOnParentStopped();
|
||||
typedef void (*sighandler_t)(int);
|
||||
|
||||
int32_t taosSetSignal(int32_t signum, FSignalHandler sigfp);
|
||||
int32_t taosIgnSignal(int32_t signum);
|
||||
int32_t taosDflSignal(int32_t signum);
|
||||
|
||||
int32_t taosKillChildOnParentStopped();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -159,13 +159,12 @@ TdSocketPtr taosAcceptTcpConnectSocket(TdSocketServerPtr pServerSocket, st
|
|||
|
||||
int32_t taosGetSocketName(TdSocketPtr pSocket, struct sockaddr *destAddr, int *addrLen);
|
||||
|
||||
void taosBlockSIGPIPE();
|
||||
uint32_t taosGetIpv4FromFqdn(const char *);
|
||||
int32_t taosBlockSIGPIPE();
|
||||
int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t* ip);
|
||||
int32_t taosGetFqdn(char *);
|
||||
void tinet_ntoa(char *ipstr, uint32_t ip);
|
||||
uint32_t ip2uint(const char *const ip_addr);
|
||||
void taosIgnSIGPIPE();
|
||||
void taosSetMaskSIGPIPE();
|
||||
int32_t taosIgnSIGPIPE();
|
||||
uint32_t taosInetAddr(const char *ipAddr);
|
||||
const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len);
|
||||
|
||||
|
|
|
@ -61,6 +61,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))
|
||||
|
||||
char *tstrdup(const char *src);
|
||||
int32_t taosUcs4len(TdUcs4 *ucs4);
|
||||
|
@ -74,7 +75,7 @@ int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs);
|
|||
int32_t taosUcs4ToMbsEx(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, iconv_t conv);
|
||||
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len);
|
||||
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
||||
TdUcs4 *tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||
int32_t tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||
bool taosValidateEncodec(const char *encodec);
|
||||
int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len);
|
||||
int32_t taosHexDecode(const char *src, char *dst, int32_t len);
|
||||
|
|
|
@ -39,7 +39,7 @@ int64_t taosGetOsUptime();
|
|||
int32_t taosGetEmail(char *email, int32_t maxLen);
|
||||
int32_t taosGetOsReleaseName(char *releaseName, char* sName, char* ver, int32_t maxLen);
|
||||
int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores);
|
||||
int32_t taosGetCpuCores(float *numOfCores, bool physical);
|
||||
void taosGetCpuCores(float *numOfCores, bool physical);
|
||||
void taosGetCpuUsage(double *cpu_system, double *cpu_engine);
|
||||
int32_t taosGetCpuInstructions(char* sse42, char* avx, char* avx2, char* fma, char* avx512);
|
||||
int32_t taosGetTotalMemory(int64_t *totalKB);
|
||||
|
|
|
@ -44,7 +44,7 @@ int64_t taosGetLineCmd(TdCmdPtr pCmd, char **__restrict ptrBuf);
|
|||
|
||||
int32_t taosEOFCmd(TdCmdPtr pCmd);
|
||||
|
||||
int64_t taosCloseCmd(TdCmdPtr *ppCmd);
|
||||
void taosCloseCmd(TdCmdPtr *ppCmd);
|
||||
|
||||
void *taosLoadDll(const char *filename);
|
||||
|
||||
|
@ -54,11 +54,11 @@ void taosCloseDll(void *handle);
|
|||
|
||||
int32_t taosSetConsoleEcho(bool on);
|
||||
|
||||
void taosSetTerminalMode();
|
||||
int32_t taosSetTerminalMode();
|
||||
|
||||
int32_t taosGetOldTerminalMode();
|
||||
|
||||
void taosResetTerminalMode();
|
||||
int32_t taosResetTerminalMode();
|
||||
|
||||
#define STACKSIZE 100
|
||||
|
||||
|
|
|
@ -65,28 +65,28 @@ int32_t taosGetTimestampSec();
|
|||
//@return timestamp in millisecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampMs() {
|
||||
struct timeval systemTime;
|
||||
taosGetTimeOfDay(&systemTime);
|
||||
(void)taosGetTimeOfDay(&systemTime);
|
||||
return (int64_t)systemTime.tv_sec * 1000LL + (int64_t)systemTime.tv_usec / 1000;
|
||||
}
|
||||
|
||||
//@return timestamp in microsecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampUs() {
|
||||
struct timeval systemTime;
|
||||
taosGetTimeOfDay(&systemTime);
|
||||
(void)taosGetTimeOfDay(&systemTime);
|
||||
return (int64_t)systemTime.tv_sec * 1000000LL + (int64_t)systemTime.tv_usec;
|
||||
}
|
||||
|
||||
//@return timestamp in nanosecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampNs() {
|
||||
struct timespec systemTime = {0};
|
||||
taosClockGetTime(CLOCK_REALTIME, &systemTime);
|
||||
(void)taosClockGetTime(CLOCK_REALTIME, &systemTime);
|
||||
return (int64_t)systemTime.tv_sec * 1000000000LL + (int64_t)systemTime.tv_nsec;
|
||||
}
|
||||
|
||||
//@return timestamp of monotonic clock in millisecond
|
||||
static FORCE_INLINE int64_t taosGetMonoTimestampMs() {
|
||||
struct timespec systemTime = {0};
|
||||
taosClockGetTime(CLOCK_MONOTONIC, &systemTime);
|
||||
(void)taosClockGetTime(CLOCK_MONOTONIC, &systemTime);
|
||||
return (int64_t)systemTime.tv_sec * 1000LL + (int64_t)systemTime.tv_nsec / 1000000;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ enum TdTimezone {
|
|||
};
|
||||
|
||||
void taosGetSystemTimezone(char *outTimezone, enum TdTimezone *tsTimezone);
|
||||
void taosSetSystemTimezone(const char *inTimezone, char *outTimezone, int8_t *outDaylight, enum TdTimezone *tsTimezone);
|
||||
int32_t taosSetSystemTimezone(const char *inTimezone, char *outTimezone, int8_t *outDaylight, enum TdTimezone *tsTimezone);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ static FORCE_INLINE int32_t tRealloc(uint8_t **ppBuf, int64_t size) {
|
|||
|
||||
pBuf = (uint8_t *)taosMemoryRealloc(pBuf, bsize + sizeof(int64_t));
|
||||
if (pBuf == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,8 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_TSC_ENCODE_PARAM_ERROR TAOS_DEF_ERROR_CODE(0, 0X0231)
|
||||
#define TSDB_CODE_TSC_ENCODE_PARAM_NULL TAOS_DEF_ERROR_CODE(0, 0X0232)
|
||||
#define TSDB_CODE_TSC_COMPRESS_PARAM_ERROR TAOS_DEF_ERROR_CODE(0, 0X0233)
|
||||
#define TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR TAOS_DEF_ERROR_CODE(0, 0X0234)
|
||||
#define TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR TAOS_DEF_ERROR_CODE(0, 0X0234)
|
||||
#define TSDB_CODE_TSC_FAIL_GENERATE_JSON TAOS_DEF_ERROR_CODE(0, 0X0235)
|
||||
#define TSDB_CODE_TSC_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0X02FF)
|
||||
|
||||
// mnode-common
|
||||
|
@ -673,8 +674,16 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_SYN_BUFFER_FULL TAOS_DEF_ERROR_CODE(0, 0x0916)
|
||||
#define TSDB_CODE_SYN_WRITE_STALL TAOS_DEF_ERROR_CODE(0, 0x0917)
|
||||
#define TSDB_CODE_SYN_NEGOTIATION_WIN_FULL TAOS_DEF_ERROR_CODE(0, 0x0918)
|
||||
#define TSDB_CODE_SYN_WRONG_TERM TAOS_DEF_ERROR_CODE(0, 0x0919)
|
||||
#define TSDB_CODE_SYN_WRONG_FSM_STATE TAOS_DEF_ERROR_CODE(0, 0x091A)
|
||||
#define TSDB_CODE_SYN_WRONG_SYNC_STATE TAOS_DEF_ERROR_CODE(0, 0x091B)
|
||||
#define TSDB_CODE_SYN_WRONG_REF TAOS_DEF_ERROR_CODE(0, 0x091C)
|
||||
#define TSDB_CODE_SYN_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x091D)
|
||||
#define TSDB_CODE_SYN_RETURN_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x091E)
|
||||
#define TSDB_CODE_SYN_WRONG_ROLE TAOS_DEF_ERROR_CODE(0, 0x091F)
|
||||
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
||||
|
||||
|
||||
// tq
|
||||
#define TSDB_CODE_TQ_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0A00)
|
||||
#define TSDB_CODE_TQ_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0A01)
|
||||
|
@ -865,6 +874,11 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED_TS_ERR TAOS_DEF_ERROR_CODE(0, 0x2807)
|
||||
#define TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED_NOT_SUPPORTED TAOS_DEF_ERROR_CODE(0, 0x2808)
|
||||
#define TSDB_CODE_FUNC_TO_CHAR_NOT_SUPPORTED TAOS_DEF_ERROR_CODE(0, 0x2809)
|
||||
#define TSDB_CODE_FUNC_TIME_UNIT_INVALID TAOS_DEF_ERROR_CODE(0, 0x280A)
|
||||
#define TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x280B)
|
||||
#define TSDB_CODE_FUNC_INVALID_VALUE_RANGE TAOS_DEF_ERROR_CODE(0, 0x280C)
|
||||
#define TSDB_CODE_FUNC_SETUP_ERROR TAOS_DEF_ERROR_CODE(0, 0x280D)
|
||||
|
||||
|
||||
//udf
|
||||
#define TSDB_CODE_UDF_STOPPING TAOS_DEF_ERROR_CODE(0, 0x2901)
|
||||
|
@ -877,6 +891,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_UDF_INVALID_OUTPUT_TYPE TAOS_DEF_ERROR_CODE(0, 0x2908)
|
||||
#define TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED TAOS_DEF_ERROR_CODE(0, 0x2909)
|
||||
#define TSDB_CODE_UDF_FUNC_EXEC_FAILURE TAOS_DEF_ERROR_CODE(0, 0x290A)
|
||||
#define TSDB_CODE_UDF_UV_EXEC_FAILURE TAOS_DEF_ERROR_CODE(0, 0x290B)
|
||||
|
||||
// sml
|
||||
#define TSDB_CODE_SML_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x3000)
|
||||
|
|
|
@ -55,7 +55,7 @@ static FORCE_INLINE int32_t tarray2_make_room(void *arr, int32_t expSize, int32_
|
|||
capacity <<= 1;
|
||||
}
|
||||
void *p = taosMemoryRealloc(a->data, capacity * eleSize);
|
||||
if (p == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (p == NULL) return terrno;
|
||||
a->capacity = capacity;
|
||||
a->data = p;
|
||||
return 0;
|
||||
|
@ -71,9 +71,9 @@ static FORCE_INLINE int32_t tarray2InsertBatch(void *arr, int32_t idx, const voi
|
|||
}
|
||||
if (ret == 0) {
|
||||
if (idx < a->size) {
|
||||
memmove(a->data + (idx + numEle) * eleSize, a->data + idx * eleSize, (a->size - idx) * eleSize);
|
||||
(void)memmove(a->data + (idx + numEle) * eleSize, a->data + idx * eleSize, (a->size - idx) * eleSize);
|
||||
}
|
||||
memcpy(a->data + idx * eleSize, elePtr, numEle * eleSize);
|
||||
(void)memcpy(a->data + idx * eleSize, elePtr, numEle * eleSize);
|
||||
a->size += numEle;
|
||||
}
|
||||
return ret;
|
||||
|
@ -145,18 +145,18 @@ static FORCE_INLINE int32_t tarray2SortInsert(void *arr, const void *elePtr, int
|
|||
#define TARRAY2_SORT_INSERT(a, e, cmp) tarray2SortInsert(a, &(e), sizeof(((a)->data[0])), (__compar_fn_t)cmp)
|
||||
#define TARRAY2_SORT_INSERT_P(a, ep, cmp) tarray2SortInsert(a, ep, sizeof(((a)->data[0])), (__compar_fn_t)cmp)
|
||||
|
||||
#define TARRAY2_REMOVE(a, idx, cb) \
|
||||
do { \
|
||||
if ((idx) < (a)->size) { \
|
||||
if (cb) { \
|
||||
TArray2Cb cb_ = (TArray2Cb)(cb); \
|
||||
cb_((a)->data + (idx)); \
|
||||
} \
|
||||
if ((idx) < (a)->size - 1) { \
|
||||
memmove((a)->data + (idx), (a)->data + (idx) + 1, sizeof((*(a)->data)) * ((a)->size - (idx)-1)); \
|
||||
} \
|
||||
(a)->size--; \
|
||||
} \
|
||||
#define TARRAY2_REMOVE(a, idx, cb) \
|
||||
do { \
|
||||
if ((idx) < (a)->size) { \
|
||||
if (cb) { \
|
||||
TArray2Cb cb_ = (TArray2Cb)(cb); \
|
||||
cb_((a)->data + (idx)); \
|
||||
} \
|
||||
if ((idx) < (a)->size - 1) { \
|
||||
(void)memmove((a)->data + (idx), (a)->data + (idx) + 1, sizeof((*(a)->data)) * ((a)->size - (idx)-1)); \
|
||||
} \
|
||||
(a)->size--; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TARRAY2_FOREACH(a, e) for (int32_t __i = 0; __i < (a)->size && ((e) = (a)->data[__i], 1); __i++)
|
||||
|
|
|
@ -25,8 +25,8 @@ extern "C" {
|
|||
#define TBASE_MAX_ILEN 4096
|
||||
#define TBASE_MAX_OLEN 5653
|
||||
|
||||
uint8_t *base58_decode(const char *value, size_t inlen, int32_t *outlen);
|
||||
char *base58_encode(const uint8_t *value, int32_t vlen);
|
||||
int32_t base58_decode(const char *value, size_t inlen, int32_t *outlen, uint8_t **result);
|
||||
int32_t base58_encode(const uint8_t *value, int32_t vlen, char **result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint8_t *base64_decode(const char *value, int32_t inlen, int32_t *outlen);
|
||||
char *base64_encode(const uint8_t *value, int32_t vlen);
|
||||
int32_t base64_decode(const char *value, int32_t inlen, int32_t *outlen, uint8_t **result);
|
||||
int32_t base64_encode(const uint8_t *value, int32_t vlen, char **result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ typedef struct SBufferReader SBufferReader;
|
|||
|
||||
// SBuffer
|
||||
#define BUFFER_INITIALIZER ((SBuffer){0, 0, NULL})
|
||||
static int32_t tBufferInit(SBuffer *buffer);
|
||||
static int32_t tBufferDestroy(SBuffer *buffer);
|
||||
static int32_t tBufferClear(SBuffer *buffer);
|
||||
static void tBufferInit(SBuffer *buffer);
|
||||
static void tBufferDestroy(SBuffer *buffer);
|
||||
static void tBufferClear(SBuffer *buffer);
|
||||
static int32_t tBufferEnsureCapacity(SBuffer *buffer, uint32_t capacity);
|
||||
static int32_t tBufferPut(SBuffer *buffer, const void *data, uint32_t size);
|
||||
static int32_t tBufferPutAt(SBuffer *buffer, uint32_t offset, const void *data, uint32_t size);
|
||||
|
|
|
@ -29,27 +29,22 @@ struct SBufferReader {
|
|||
};
|
||||
|
||||
// SBuffer
|
||||
static FORCE_INLINE int32_t tBufferInit(SBuffer *buffer) {
|
||||
static FORCE_INLINE void tBufferInit(SBuffer *buffer) {
|
||||
buffer->size = 0;
|
||||
buffer->capacity = 0;
|
||||
buffer->data = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tBufferDestroy(SBuffer *buffer) {
|
||||
static FORCE_INLINE void tBufferDestroy(SBuffer *buffer) {
|
||||
buffer->size = 0;
|
||||
buffer->capacity = 0;
|
||||
if (buffer->data) {
|
||||
taosMemoryFree(buffer->data);
|
||||
buffer->data = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tBufferClear(SBuffer *buffer) {
|
||||
buffer->size = 0;
|
||||
return 0;
|
||||
}
|
||||
static FORCE_INLINE void tBufferClear(SBuffer *buffer) { buffer->size = 0; }
|
||||
|
||||
static FORCE_INLINE int32_t tBufferEnsureCapacity(SBuffer *buffer, uint32_t capacity) {
|
||||
if (buffer->capacity < capacity) {
|
||||
|
|
|
@ -79,7 +79,7 @@ static FORCE_INLINE void *taosDecodeFixedBool(const void *buf, bool *value) {
|
|||
static FORCE_INLINE int32_t taosEncodeFixedU16(void **buf, uint16_t value) {
|
||||
if (buf != NULL) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(*buf, &value, sizeof(value));
|
||||
TAOS_MEMCPY(*buf, &value, sizeof(value));
|
||||
} else {
|
||||
((uint8_t *)(*buf))[0] = value & 0xff;
|
||||
((uint8_t *)(*buf))[1] = (value >> 8) & 0xff;
|
||||
|
@ -92,7 +92,7 @@ static FORCE_INLINE int32_t taosEncodeFixedU16(void **buf, uint16_t value) {
|
|||
|
||||
static FORCE_INLINE void *taosDecodeFixedU16(const void *buf, uint16_t *value) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(value, buf, sizeof(*value));
|
||||
TAOS_MEMCPY(value, buf, sizeof(*value));
|
||||
} else {
|
||||
((uint8_t *)value)[1] = ((uint8_t *)buf)[0];
|
||||
((uint8_t *)value)[0] = ((uint8_t *)buf)[1];
|
||||
|
@ -117,7 +117,7 @@ static FORCE_INLINE void *taosDecodeFixedI16(const void *buf, int16_t *value) {
|
|||
static FORCE_INLINE int32_t taosEncodeFixedU32(void **buf, uint32_t value) {
|
||||
if (buf != NULL) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(*buf, &value, sizeof(value));
|
||||
TAOS_MEMCPY(*buf, &value, sizeof(value));
|
||||
} else {
|
||||
((uint8_t *)(*buf))[0] = value & 0xff;
|
||||
((uint8_t *)(*buf))[1] = (value >> 8) & 0xff;
|
||||
|
@ -132,7 +132,7 @@ static FORCE_INLINE int32_t taosEncodeFixedU32(void **buf, uint32_t value) {
|
|||
|
||||
static FORCE_INLINE void *taosDecodeFixedU32(const void *buf, uint32_t *value) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(value, buf, sizeof(*value));
|
||||
TAOS_MEMCPY(value, buf, sizeof(*value));
|
||||
} else {
|
||||
((uint8_t *)value)[3] = ((uint8_t *)buf)[0];
|
||||
((uint8_t *)value)[2] = ((uint8_t *)buf)[1];
|
||||
|
@ -159,7 +159,7 @@ static FORCE_INLINE void *taosDecodeFixedI32(const void *buf, int32_t *value) {
|
|||
static FORCE_INLINE int32_t taosEncodeFixedU64(void **buf, uint64_t value) {
|
||||
if (buf != NULL) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(*buf, &value, sizeof(value));
|
||||
TAOS_MEMCPY(*buf, &value, sizeof(value));
|
||||
} else {
|
||||
((uint8_t *)(*buf))[0] = value & 0xff;
|
||||
((uint8_t *)(*buf))[1] = (value >> 8) & 0xff;
|
||||
|
@ -179,7 +179,7 @@ static FORCE_INLINE int32_t taosEncodeFixedU64(void **buf, uint64_t value) {
|
|||
|
||||
static FORCE_INLINE void *taosDecodeFixedU64(const void *buf, uint64_t *value) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(value, buf, sizeof(*value));
|
||||
TAOS_MEMCPY(value, buf, sizeof(*value));
|
||||
} else {
|
||||
((uint8_t *)value)[7] = ((uint8_t *)buf)[0];
|
||||
((uint8_t *)value)[6] = ((uint8_t *)buf)[1];
|
||||
|
@ -357,7 +357,7 @@ static FORCE_INLINE int32_t taosEncodeString(void **buf, const char *value) {
|
|||
|
||||
tlen += taosEncodeVariantU64(buf, size);
|
||||
if (buf != NULL) {
|
||||
memcpy(*buf, value, size);
|
||||
TAOS_MEMCPY(*buf, value, size);
|
||||
*buf = POINTER_SHIFT(*buf, size);
|
||||
}
|
||||
tlen += (int32_t)size;
|
||||
|
@ -372,7 +372,7 @@ static FORCE_INLINE void *taosDecodeString(const void *buf, char **value) {
|
|||
*value = (char *)taosMemoryMalloc((size_t)size + 1);
|
||||
|
||||
if (*value == NULL) return NULL;
|
||||
memcpy(*value, buf, (size_t)size);
|
||||
TAOS_MEMCPY(*value, buf, (size_t)size);
|
||||
|
||||
(*value)[size] = '\0';
|
||||
|
||||
|
@ -383,7 +383,7 @@ static FORCE_INLINE void *taosDecodeStringTo(const void *buf, char *value) {
|
|||
uint64_t size = 0;
|
||||
|
||||
buf = taosDecodeVariantU64(buf, &size);
|
||||
memcpy(value, buf, (size_t)size);
|
||||
TAOS_MEMCPY(value, buf, (size_t)size);
|
||||
|
||||
value[size] = '\0';
|
||||
|
||||
|
@ -395,7 +395,7 @@ static FORCE_INLINE int32_t taosEncodeBinary(void **buf, const void *value, int3
|
|||
int32_t tlen = 0;
|
||||
|
||||
if (buf != NULL) {
|
||||
memcpy(*buf, value, valueLen);
|
||||
TAOS_MEMCPY(*buf, value, valueLen);
|
||||
*buf = POINTER_SHIFT(*buf, valueLen);
|
||||
}
|
||||
tlen += (int32_t)valueLen;
|
||||
|
@ -406,13 +406,13 @@ static FORCE_INLINE int32_t taosEncodeBinary(void **buf, const void *value, int3
|
|||
static FORCE_INLINE void *taosDecodeBinary(const void *buf, void **value, int32_t valueLen) {
|
||||
*value = taosMemoryMalloc((size_t)valueLen);
|
||||
if (*value == NULL) return NULL;
|
||||
memcpy(*value, buf, (size_t)valueLen);
|
||||
TAOS_MEMCPY(*value, buf, (size_t)valueLen);
|
||||
|
||||
return POINTER_SHIFT(buf, valueLen);
|
||||
}
|
||||
|
||||
static FORCE_INLINE void *taosDecodeBinaryTo(const void *buf, void *value, int32_t valueLen) {
|
||||
memcpy(value, buf, (size_t)valueLen);
|
||||
TAOS_MEMCPY(value, buf, (size_t)valueLen);
|
||||
return POINTER_SHIFT(buf, valueLen);
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ typedef struct {
|
|||
typedef struct SConfig SConfig;
|
||||
typedef struct SConfigIter SConfigIter;
|
||||
|
||||
SConfig *cfgInit();
|
||||
int32_t cfgInit(SConfig **ppCfg);
|
||||
int32_t cfgLoad(SConfig *pCfg, ECfgSrcType cfgType, const void *sourceStr);
|
||||
int32_t cfgLoadFromArray(SConfig *pCfg, SArray *pArgs); // SConfigPair
|
||||
void cfgCleanup(SConfig *pCfg);
|
||||
|
@ -110,7 +110,7 @@ SConfigItem *cfgGetItem(SConfig *pCfg, const char *pName);
|
|||
int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcType stype, bool lock);
|
||||
int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *pVal, bool isServer);
|
||||
|
||||
SConfigIter *cfgCreateIter(SConfig *pConf);
|
||||
int32_t cfgCreateIter(SConfig *pConf, SConfigIter **ppIter);
|
||||
SConfigItem *cfgNextIter(SConfigIter *pIter);
|
||||
void cfgDestroyIter(SConfigIter *pIter);
|
||||
void cfgLock(SConfig *pCfg);
|
||||
|
@ -131,8 +131,8 @@ int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal,
|
|||
const char *cfgStypeStr(ECfgSrcType type);
|
||||
const char *cfgDtypeStr(ECfgDataType type);
|
||||
|
||||
void cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
|
||||
void cfgDumpItemScope(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
|
||||
int32_t cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
|
||||
int32_t cfgDumpItemScope(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
|
||||
|
||||
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump);
|
||||
void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump);
|
||||
|
|
|
@ -131,10 +131,10 @@ static const int64_t TICK_PER_SECOND[] = {
|
|||
: ((precision) == TSDB_TIME_PRECISION_MICRO ? 1000000LL : 1000000000LL)))
|
||||
|
||||
#define T_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
|
||||
#define T_APPEND_MEMBER(dst, ptr, type, member) \
|
||||
do { \
|
||||
memcpy((void *)(dst), (void *)(&((ptr)->member)), T_MEMBER_SIZE(type, member)); \
|
||||
dst = (void *)((char *)(dst) + T_MEMBER_SIZE(type, member)); \
|
||||
#define T_APPEND_MEMBER(dst, ptr, type, member) \
|
||||
do { \
|
||||
(void)memcpy((void *)(dst), (void *)(&((ptr)->member)), T_MEMBER_SIZE(type, member)); \
|
||||
dst = (void *)((char *)(dst) + T_MEMBER_SIZE(type, member)); \
|
||||
} while (0)
|
||||
#define T_READ_MEMBER(src, type, target) \
|
||||
do { \
|
||||
|
@ -556,7 +556,8 @@ typedef struct {
|
|||
char name[TSDB_LOG_VAR_LEN];
|
||||
} SLogVar;
|
||||
|
||||
#define TMQ_SEPARATOR ':'
|
||||
#define TMQ_SEPARATOR ":"
|
||||
#define TMQ_SEPARATOR_CHAR ':'
|
||||
|
||||
enum {
|
||||
SND_WORKER_TYPE__SHARED = 1,
|
||||
|
|
|
@ -64,10 +64,10 @@ typedef struct TDigest {
|
|||
} TDigest;
|
||||
|
||||
TDigest *tdigestNewFrom(void *pBuf, int32_t compression);
|
||||
void tdigestAdd(TDigest *t, double x, int64_t w);
|
||||
void tdigestMerge(TDigest *t1, TDigest *t2);
|
||||
int32_t tdigestAdd(TDigest *t, double x, int64_t w);
|
||||
int32_t tdigestMerge(TDigest *t1, TDigest *t2);
|
||||
double tdigestQuantile(TDigest *t, double q);
|
||||
void tdigestCompress(TDigest *t);
|
||||
int32_t tdigestCompress(TDigest *t);
|
||||
void tdigestFreeFrom(TDigest *t);
|
||||
void tdigestAutoFill(TDigest *t, int32_t compression);
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ static FORCE_INLINE int32_t tEncodeFixed(SEncoder* pCoder, const void* val, uint
|
|||
if (pCoder->pos + size > pCoder->size) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
memcpy(pCoder->data + pCoder->pos, val, size);
|
||||
TAOS_MEMCPY(pCoder->data + pCoder->pos, val, size);
|
||||
}
|
||||
|
||||
pCoder->pos += size;
|
||||
|
@ -212,7 +212,7 @@ static FORCE_INLINE int32_t tEncodeBinary(SEncoder* pCoder, const uint8_t* val,
|
|||
if (pCoder->pos + len > pCoder->size) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
memcpy(pCoder->data + pCoder->pos, val, len);
|
||||
TAOS_MEMCPY(pCoder->data + pCoder->pos, val, len);
|
||||
}
|
||||
|
||||
pCoder->pos += len;
|
||||
|
@ -233,7 +233,7 @@ static int32_t tDecodeFixed(SDecoder* pCoder, void* val, uint32_t size) {
|
|||
if (pCoder->pos + size > pCoder->size) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
} else if (val) {
|
||||
memcpy(val, pCoder->data + pCoder->pos, size);
|
||||
TAOS_MEMCPY(val, pCoder->data + pCoder->pos, size);
|
||||
}
|
||||
pCoder->pos += size;
|
||||
return 0;
|
||||
|
@ -427,7 +427,7 @@ static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val) {
|
|||
uint32_t len;
|
||||
TAOS_CHECK_RETURN(tDecodeCStrAndLen(pCoder, &pStr, &len));
|
||||
|
||||
memcpy(val, pStr, len + 1);
|
||||
TAOS_MEMCPY(val, pStr, len + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -446,7 +446,7 @@ static FORCE_INLINE int32_t tDecodeBinaryAlloc(SDecoder* pCoder, void** val, uin
|
|||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
memcpy(*val, pCoder->data + pCoder->pos, length);
|
||||
TAOS_MEMCPY(*val, pCoder->data + pCoder->pos, length);
|
||||
|
||||
pCoder->pos += length;
|
||||
} else {
|
||||
|
@ -468,7 +468,7 @@ static FORCE_INLINE int32_t tDecodeBinaryAlloc32(SDecoder* pCoder, void** val, u
|
|||
if (*val == NULL) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(*val, pCoder->data + pCoder->pos, length);
|
||||
TAOS_MEMCPY(*val, pCoder->data + pCoder->pos, length);
|
||||
|
||||
pCoder->pos += length;
|
||||
} else {
|
||||
|
@ -757,7 +757,7 @@ static FORCE_INLINE int32_t tPutBinary(uint8_t* p, uint8_t* pData, uint32_t nDat
|
|||
int n = 0;
|
||||
|
||||
n += tPutU32v(p ? p + n : p, nData);
|
||||
if (p) memcpy(p + n, pData, nData);
|
||||
if (p) TAOS_MEMCPY(p + n, pData, nData);
|
||||
n += nData;
|
||||
|
||||
return n;
|
||||
|
|
|
@ -156,7 +156,7 @@ void setBufPageCompressOnDisk(SDiskbasedBuf* pBuf, bool comp);
|
|||
* @param pBuf
|
||||
* @param pageId
|
||||
*/
|
||||
void dBufSetBufPageRecycled(SDiskbasedBuf* pBuf, void* pPage);
|
||||
int32_t dBufSetBufPageRecycled(SDiskbasedBuf* pBuf, void* pPage);
|
||||
|
||||
/**
|
||||
* Print the statistics when closing this buffer
|
||||
|
|
|
@ -17,15 +17,12 @@
|
|||
#define TDENGINE_TSIMPLEHASH_H
|
||||
|
||||
#include "tarray.h"
|
||||
#include "thash.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef uint32_t (*_hash_fn_t)(const char *, uint32_t);
|
||||
typedef int32_t (*_equal_fn_t)(const void *, const void *, size_t len);
|
||||
typedef void (*_hash_free_fn_t)(void *);
|
||||
|
||||
/**
|
||||
* @brief single thread hash
|
||||
*
|
||||
|
|
|
@ -16,12 +16,10 @@
|
|||
#ifndef _TD_UTIL_UTIL_H_
|
||||
#define _TD_UTIL_UTIL_H_
|
||||
|
||||
#include "os.h"
|
||||
#include "tcrc32c.h"
|
||||
#include "tdef.h"
|
||||
#include "thash.h"
|
||||
#include "tmd5.h"
|
||||
#include "tutil.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -64,7 +62,7 @@ static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *tar
|
|||
tMD5Init(&context);
|
||||
tMD5Update(&context, inBuf, (uint32_t)inLen);
|
||||
tMD5Final(&context);
|
||||
memcpy(target, context.digest, tListLen(context.digest));
|
||||
(void)memcpy(target, context.digest, tListLen(context.digest));
|
||||
}
|
||||
|
||||
static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *target) {
|
||||
|
@ -75,11 +73,11 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
|
|||
char buf[TSDB_PASSWORD_LEN + 1];
|
||||
|
||||
buf[TSDB_PASSWORD_LEN] = 0;
|
||||
sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], context.digest[1],
|
||||
(void)sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], context.digest[1],
|
||||
context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6],
|
||||
context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11],
|
||||
context.digest[12], context.digest[13], context.digest[14], context.digest[15]);
|
||||
memcpy(target, buf, TSDB_PASSWORD_LEN);
|
||||
(void)memcpy(target, buf, TSDB_PASSWORD_LEN);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t taosCreateMD5Hash(char *pBuf, int32_t len) {
|
||||
|
@ -108,10 +106,10 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
int32_t offset = 0;
|
||||
if (prefix < 0) {
|
||||
offset = -1 * prefix;
|
||||
strncpy(tbName, tbname, offset);
|
||||
(void)strncpy(tbName, tbname, offset);
|
||||
}
|
||||
if (suffix < 0) {
|
||||
strncpy(tbName + offset, tbname + tblen + suffix, -1 * suffix);
|
||||
(void)strncpy(tbName + offset, tbname + tblen + suffix, -1 * suffix);
|
||||
offset += -1 * suffix;
|
||||
}
|
||||
return MurmurHash3_32(tbName, offset);
|
||||
|
@ -152,17 +150,20 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
|
||||
#define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr)-offsetof(type, member)))
|
||||
|
||||
#define TAOS_RETURN(code) \
|
||||
#define TAOS_GET_TERRNO(code) \
|
||||
(terrno == 0 ? code : terrno)
|
||||
|
||||
#define TAOS_RETURN(CODE) \
|
||||
do { \
|
||||
return (terrno = (code)); \
|
||||
return (terrno = (CODE)); \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_RETURN(CMD) \
|
||||
do { \
|
||||
int32_t code = (CMD); \
|
||||
if (code != TSDB_CODE_SUCCESS) { \
|
||||
TAOS_RETURN(code); \
|
||||
} \
|
||||
#define TAOS_CHECK_RETURN(CMD) \
|
||||
do { \
|
||||
int32_t __c = (CMD); \
|
||||
if (__c != TSDB_CODE_SUCCESS) { \
|
||||
TAOS_RETURN(__c); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_GOTO(CMD, LINO, LABEL) \
|
||||
|
@ -176,6 +177,15 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_EXIT(CMD) \
|
||||
do { \
|
||||
code = (CMD); \
|
||||
if (code < TSDB_CODE_SUCCESS) { \
|
||||
lino = __LINE__; \
|
||||
goto _exit; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_UNUSED(expr) (void)(expr)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -38,7 +38,7 @@ static FORCE_INLINE float taos_align_get_float(const char *pBuf) {
|
|||
assert(sizeof(float) == sizeof(uint32_t));
|
||||
#endif
|
||||
float fv = 0;
|
||||
memcpy(&fv, pBuf, sizeof(fv)); // in ARM, return *((const float*)(pBuf)) may cause problem
|
||||
(void)memcpy(&fv, pBuf, sizeof(fv)); // in ARM, return *((const float*)(pBuf)) may cause problem
|
||||
return fv;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ static FORCE_INLINE double taos_align_get_double(const char *pBuf) {
|
|||
assert(sizeof(double) == sizeof(uint64_t));
|
||||
#endif
|
||||
double dv = 0;
|
||||
memcpy(&dv, pBuf, sizeof(dv)); // in ARM, return *((const double*)(pBuf)) may cause problem
|
||||
(void)memcpy(&dv, pBuf, sizeof(dv)); // in ARM, return *((const double*)(pBuf)) may cause problem
|
||||
return dv;
|
||||
}
|
||||
|
||||
|
|
|
@ -310,7 +310,7 @@ void setResPrecision(SReqResultInfo* pResInfo, int32_t precision);
|
|||
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4);
|
||||
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows,
|
||||
bool convertUcs4);
|
||||
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
||||
int32_t setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
||||
void doFreeReqResultInfo(SReqResultInfo* pResInfo);
|
||||
int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq);
|
||||
void syncCatalogFn(SMetaData* pResult, void* param, int32_t code);
|
||||
|
@ -332,8 +332,7 @@ static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
|||
return (SReqResultInfo*)&msg->common.resInfo;
|
||||
}
|
||||
|
||||
SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4);
|
||||
|
||||
int32_t tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4, SReqResultInfo** pResInfo);
|
||||
static FORCE_INLINE SReqResultInfo* tscGetCurResInfo(TAOS_RES* res) {
|
||||
if (TD_RES_QUERY(res)) return &(((SRequestObj*)res)->body.resInfo);
|
||||
return tmqGetCurResInfo(res);
|
||||
|
@ -349,15 +348,16 @@ __async_send_cb_fn_t getMsgRspHandle(int32_t msgType);
|
|||
|
||||
SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pReqObj);
|
||||
|
||||
void* createTscObj(const char* user, const char* auth, const char* db, int32_t connType, SAppInstInfo* pAppInfo);
|
||||
int32_t createTscObj(const char *user, const char *auth, const char *db, int32_t connType, SAppInstInfo *pAppInfo,
|
||||
STscObj **p);
|
||||
void destroyTscObj(void* pObj);
|
||||
STscObj* acquireTscObj(int64_t rid);
|
||||
int32_t releaseTscObj(int64_t rid);
|
||||
void releaseTscObj(int64_t rid);
|
||||
void destroyAppInst(void* pAppInfo);
|
||||
|
||||
uint64_t generateRequestId();
|
||||
|
||||
void* createRequest(uint64_t connId, int32_t type, int64_t reqid);
|
||||
int32_t createRequest(uint64_t connId, int32_t type, int64_t reqid, SRequestObj **pRequest);
|
||||
void destroyRequest(SRequestObj* pRequest);
|
||||
SRequestObj* acquireRequest(int64_t rid);
|
||||
int32_t releaseRequest(int64_t rid);
|
||||
|
@ -371,7 +371,7 @@ void resetConnectDB(STscObj* pTscObj);
|
|||
|
||||
int taos_options_imp(TSDB_OPTION option, const char* str);
|
||||
|
||||
void* openTransporter(const char* user, const char* auth, int32_t numOfThreads);
|
||||
int32_t openTransporter(const char* user, const char* auth, int32_t numOfThreads, void **pDnodeConn);
|
||||
void tscStopCrashReport();
|
||||
|
||||
typedef struct AsyncArg {
|
||||
|
@ -382,8 +382,8 @@ typedef struct AsyncArg {
|
|||
bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType);
|
||||
void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
|
||||
|
||||
STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||
uint16_t port, int connType);
|
||||
int32_t taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||
uint16_t port, int connType, STscObj** pObj);
|
||||
|
||||
int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb);
|
||||
|
||||
|
@ -396,11 +396,11 @@ void taos_close_internal(void* taos);
|
|||
|
||||
// --- heartbeat
|
||||
// global, called by mgmt
|
||||
int hbMgrInit();
|
||||
void hbMgrCleanUp();
|
||||
int32_t hbMgrInit();
|
||||
void hbMgrCleanUp();
|
||||
|
||||
// cluster level
|
||||
SAppHbMgr* appHbMgrInit(SAppInstInfo* pAppInstInfo, char* key);
|
||||
int32_t appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key, SAppHbMgr **pAppHbMgr);
|
||||
void appHbMgrCleanup(void);
|
||||
void hbRemoveAppHbMrg(SAppHbMgr** pAppHbMgr);
|
||||
void destroyAllRequests(SHashObj* pRequests);
|
||||
|
@ -409,7 +409,7 @@ void stopAllRequests(SHashObj* pRequests);
|
|||
//SAppInstInfo* getAppInstInfo(const char* clusterKey);
|
||||
|
||||
// conn level
|
||||
int hbRegisterConn(SAppHbMgr* pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType);
|
||||
int32_t hbRegisterConn(SAppHbMgr* pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType);
|
||||
void hbDeregisterConn(STscObj* pTscObj, SClientHbKey connKey);
|
||||
|
||||
typedef struct SSqlCallbackWrapper {
|
||||
|
@ -428,7 +428,7 @@ void doAsyncQuery(SRequestObj* pRequest, bool forceUpdateMeta);
|
|||
int32_t removeMeta(STscObj* pTscObj, SArray* tbList, bool isView);
|
||||
int32_t handleAlterTbExecRes(void* res, struct SCatalog* pCatalog);
|
||||
int32_t handleCreateTbExecRes(void* res, SCatalog* pCatalog);
|
||||
bool qnodeRequired(SRequestObj* pRequest);
|
||||
int32_t qnodeRequired(SRequestObj* pRequest, bool *required);
|
||||
void continueInsertFromCsv(SSqlCallbackWrapper* pWrapper, SRequestObj* pRequest);
|
||||
void destorySqlCallbackWrapper(SSqlCallbackWrapper* pWrapper);
|
||||
void handleQueryAnslyseRes(SSqlCallbackWrapper *pWrapper, SMetaData *pResultMeta, int32_t code);
|
||||
|
@ -444,6 +444,30 @@ void freeQueryParam(SSyncQueryParam* param);
|
|||
int32_t clientParseSqlImpl(void* param, const char* dbName, const char* sql, bool parseOnly, const char* effeciveUser, SParseSqlRes* pRes);
|
||||
#endif
|
||||
|
||||
#define TSC_ERR_RET(c) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = _code; \
|
||||
return _code; \
|
||||
} \
|
||||
} while (0)
|
||||
#define TSC_RET(c) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = _code; \
|
||||
} \
|
||||
return _code; \
|
||||
} while (0)
|
||||
#define TSC_ERR_JRET(c) \
|
||||
do { \
|
||||
code = c; \
|
||||
if (code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = code; \
|
||||
goto _return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void slowQueryLog(int64_t rid, bool killed, int32_t code, int32_t cost);
|
||||
|
||||
|
|
|
@ -44,6 +44,26 @@
|
|||
#define TSC_VAR_NOT_RELEASE 1
|
||||
#define TSC_VAR_RELEASED 0
|
||||
|
||||
#define ENV_JSON_FALSE_CHECK(c) \
|
||||
do { \
|
||||
if (!c) { \
|
||||
tscError("faild to add item to JSON object");\
|
||||
code = TSDB_CODE_TSC_FAIL_GENERATE_JSON; \
|
||||
goto _end; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ENV_ERR_RET(c,info) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
errno = _code; \
|
||||
tscInitRes = _code; \
|
||||
tscError(info); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
STscDbg tscDbg = {0};
|
||||
SAppInfo appInfo;
|
||||
int64_t lastClusterId = 0;
|
||||
|
@ -57,8 +77,14 @@ static TdThreadOnce tscinit = PTHREAD_ONCE_INIT;
|
|||
volatile int32_t tscInitRes = 0;
|
||||
|
||||
static int32_t registerRequest(SRequestObj *pRequest, STscObj *pTscObj) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
// connection has been released already, abort creating request.
|
||||
pRequest->self = taosAddRef(clientReqRefPool, pRequest);
|
||||
if (pRequest->self < 0) {
|
||||
tscError("failed to add ref to request");
|
||||
code = terrno;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t num = atomic_add_fetch_32(&pTscObj->numOfReqs, 1);
|
||||
|
||||
|
@ -72,19 +98,23 @@ static int32_t registerRequest(SRequestObj *pRequest, STscObj *pTscObj) {
|
|||
pRequest->self, pRequest->pTscObj->id, num, currentInst, total, pRequest->requestId);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
static void concatStrings(SArray *list, char* buf, int size){
|
||||
int len = 0;
|
||||
for(int i = 0; i < taosArrayGetSize(list); i++){
|
||||
char* db = taosArrayGet(list, i);
|
||||
if (NULL == db) {
|
||||
tscError("get dbname failed, buf:%s", buf);
|
||||
break;
|
||||
}
|
||||
char* dot = strchr(db, '.');
|
||||
if (dot != NULL) {
|
||||
db = dot + 1;
|
||||
}
|
||||
if (i != 0){
|
||||
strcat(buf, ",");
|
||||
(void)strcat(buf, ",");
|
||||
len += 1;
|
||||
}
|
||||
int ret = snprintf(buf + len, size - len, "%s", db);
|
||||
|
@ -100,61 +130,70 @@ static void concatStrings(SArray *list, char* buf, int size){
|
|||
}
|
||||
}
|
||||
|
||||
static void generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_t reqType, int64_t duration){
|
||||
static int32_t generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_t reqType, int64_t duration){
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (json == NULL) {
|
||||
tscError("[monitor] cJSON_CreateObject failed");
|
||||
return;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
char clusterId[32] = {0};
|
||||
if (snprintf(clusterId, sizeof(clusterId), "%" PRId64, pTscObj->pAppInfo->clusterId) < 0){
|
||||
tscError("failed to generate clusterId:%" PRId64, pTscObj->pAppInfo->clusterId);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
char startTs[32] = {0};
|
||||
if (snprintf(startTs, sizeof(startTs), "%" PRId64, pRequest->metric.start/1000) < 0){
|
||||
tscError("failed to generate startTs:%" PRId64, pRequest->metric.start/1000);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
char requestId[32] = {0};
|
||||
if (snprintf(requestId, sizeof(requestId), "%" PRIu64, pRequest->requestId) < 0){
|
||||
tscError("failed to generate requestId:%" PRIu64, pRequest->requestId);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "cluster_id", cJSON_CreateString(clusterId));
|
||||
cJSON_AddItemToObject(json, "start_ts", cJSON_CreateString(startTs));
|
||||
cJSON_AddItemToObject(json, "request_id", cJSON_CreateString(requestId));
|
||||
cJSON_AddItemToObject(json, "query_time", cJSON_CreateNumber(duration/1000));
|
||||
cJSON_AddItemToObject(json, "code", cJSON_CreateNumber(pRequest->code));
|
||||
cJSON_AddItemToObject(json, "error_info", cJSON_CreateString(tstrerror(pRequest->code)));
|
||||
cJSON_AddItemToObject(json, "type", cJSON_CreateNumber(reqType));
|
||||
cJSON_AddItemToObject(json, "rows_num", cJSON_CreateNumber(pRequest->body.resInfo.numOfRows + pRequest->body.resInfo.totalRows));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "cluster_id", cJSON_CreateString(clusterId)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "start_ts", cJSON_CreateString(startTs)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "request_id", cJSON_CreateString(requestId)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "query_time", cJSON_CreateNumber(duration/1000)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "code", cJSON_CreateNumber(pRequest->code)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "error_info", cJSON_CreateString(tstrerror(pRequest->code))));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "type", cJSON_CreateNumber(reqType)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "rows_num", cJSON_CreateNumber(pRequest->body.resInfo.numOfRows + pRequest->body.resInfo.totalRows)));
|
||||
if(pRequest->sqlstr != NULL && strlen(pRequest->sqlstr) > pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen){
|
||||
char tmp = pRequest->sqlstr[pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen];
|
||||
pRequest->sqlstr[pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen] = '\0';
|
||||
cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr)));
|
||||
pRequest->sqlstr[pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen] = tmp;
|
||||
}else{
|
||||
cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr)));
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject(json, "user", cJSON_CreateString(pTscObj->user));
|
||||
cJSON_AddItemToObject(json, "process_name", cJSON_CreateString(appInfo.appName));
|
||||
cJSON_AddItemToObject(json, "ip", cJSON_CreateString(tsLocalFqdn));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "user", cJSON_CreateString(pTscObj->user)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "process_name", cJSON_CreateString(appInfo.appName)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "ip", cJSON_CreateString(tsLocalFqdn)));
|
||||
|
||||
char pid[32] = {0};
|
||||
if (snprintf(pid, sizeof(pid), "%d", appInfo.pid) < 0){
|
||||
tscError("failed to generate pid:%d", appInfo.pid);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject(json, "process_id", cJSON_CreateString(pid));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "process_id", cJSON_CreateString(pid)));
|
||||
if(pRequest->dbList != NULL){
|
||||
char dbList[1024] = {0};
|
||||
concatStrings(pRequest->dbList, dbList, sizeof(dbList) - 1);
|
||||
cJSON_AddItemToObject(json, "db", cJSON_CreateString(dbList));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "db", cJSON_CreateString(dbList)));
|
||||
}else if(pRequest->pDb != NULL){
|
||||
cJSON_AddItemToObject(json, "db", cJSON_CreateString(pRequest->pDb));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "db", cJSON_CreateString(pRequest->pDb)));
|
||||
}else{
|
||||
cJSON_AddItemToObject(json, "db", cJSON_CreateString(""));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "db", cJSON_CreateString("")));
|
||||
}
|
||||
|
||||
char* value = cJSON_PrintUnformatted(json);
|
||||
|
@ -162,11 +201,15 @@ static void generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_
|
|||
data.clusterId = pTscObj->pAppInfo->clusterId;
|
||||
data.type = SLOW_LOG_WRITE;
|
||||
data.data = value;
|
||||
if(monitorPutData2MonitorQueue(data) < 0){
|
||||
code = monitorPutData2MonitorQueue(data);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosMemoryFree(value);
|
||||
goto _end;
|
||||
}
|
||||
|
||||
_end:
|
||||
cJSON_Delete(json);
|
||||
return code;
|
||||
}
|
||||
|
||||
static bool checkSlowLogExceptDb(SRequestObj *pRequest, char* exceptDb) {
|
||||
|
@ -176,6 +219,10 @@ static bool checkSlowLogExceptDb(SRequestObj *pRequest, char* exceptDb) {
|
|||
|
||||
for (int i = 0; i < taosArrayGetSize(pRequest->dbList); i++) {
|
||||
char *db = taosArrayGet(pRequest->dbList, i);
|
||||
if (NULL == db) {
|
||||
tscError("get dbname failed, exceptDb:%s", exceptDb);
|
||||
return false;
|
||||
}
|
||||
char *dot = strchr(db, '.');
|
||||
if (dot != NULL) {
|
||||
db = dot + 1;
|
||||
|
@ -215,7 +262,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
"us, planCost:%" PRId64 "us, exec:%" PRId64 "us",
|
||||
duration, pRequest->metric.parseCostUs, pRequest->metric.ctgCostUs, pRequest->metric.analyseCostUs,
|
||||
pRequest->metric.planCostUs, pRequest->metric.execCostUs);
|
||||
atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration);
|
||||
(void)atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration);
|
||||
reqType = SLOW_LOG_TYPE_INSERT;
|
||||
} else if (QUERY_NODE_SELECT_STMT == pRequest->stmtType) {
|
||||
tscDebug("query duration %" PRId64 "us: parseCost:%" PRId64 "us, ctgCost:%" PRId64 "us, analyseCost:%" PRId64
|
||||
|
@ -223,11 +270,13 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
duration, pRequest->metric.parseCostUs, pRequest->metric.ctgCostUs, pRequest->metric.analyseCostUs,
|
||||
pRequest->metric.planCostUs, pRequest->metric.execCostUs);
|
||||
|
||||
atomic_add_fetch_64((int64_t *)&pActivity->queryElapsedTime, duration);
|
||||
(void)atomic_add_fetch_64((int64_t *)&pActivity->queryElapsedTime, duration);
|
||||
reqType = SLOW_LOG_TYPE_QUERY;
|
||||
}
|
||||
|
||||
nodesSimReleaseAllocator(pRequest->allocatorRefId);
|
||||
if (TSDB_CODE_SUCCESS != nodesSimReleaseAllocator(pRequest->allocatorRefId)) {
|
||||
tscError("failed to release allocator");
|
||||
}
|
||||
}
|
||||
|
||||
if(pTscObj->pAppInfo->monitorParas.tsEnableMonitor){
|
||||
|
@ -242,14 +291,16 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
|
||||
if ((duration >= pTscObj->pAppInfo->monitorParas.tsSlowLogThreshold * 1000000UL || duration >= pTscObj->pAppInfo->monitorParas.tsSlowLogThresholdTest * 1000000UL) &&
|
||||
checkSlowLogExceptDb(pRequest, pTscObj->pAppInfo->monitorParas.tsSlowLogExceptDb)) {
|
||||
atomic_add_fetch_64((int64_t *)&pActivity->numOfSlowQueries, 1);
|
||||
(void)atomic_add_fetch_64((int64_t *)&pActivity->numOfSlowQueries, 1);
|
||||
if (pTscObj->pAppInfo->monitorParas.tsSlowLogScope & reqType) {
|
||||
taosPrintSlowLog("PID:%d, Conn:%u, QID:0x%" PRIx64 ", Start:%" PRId64 " us, Duration:%" PRId64 "us, SQL:%s",
|
||||
taosGetPId(), pTscObj->connId, pRequest->requestId, pRequest->metric.start, duration,
|
||||
pRequest->sqlstr);
|
||||
if(pTscObj->pAppInfo->monitorParas.tsEnableMonitor){
|
||||
slowQueryLog(pTscObj->id, pRequest->killed, pRequest->code, duration);
|
||||
generateWriteSlowLog(pTscObj, pRequest, reqType, duration);
|
||||
if (TSDB_CODE_SUCCESS != generateWriteSlowLog(pTscObj, pRequest, reqType, duration)) {
|
||||
tscError("failed to generate write slow log");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,9 +340,9 @@ static bool clientRpcTfp(int32_t code, tmsg_t msgType) {
|
|||
}
|
||||
|
||||
// TODO refactor
|
||||
void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
||||
int32_t openTransporter(const char *user, const char *auth, int32_t numOfThread, void **pDnodeConn) {
|
||||
SRpcInit rpcInit;
|
||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||
(void)memset(&rpcInit, 0, sizeof(rpcInit));
|
||||
rpcInit.localPort = 0;
|
||||
rpcInit.label = "TSC";
|
||||
rpcInit.numOfThreads = tsNumOfRpcThreads;
|
||||
|
@ -315,15 +366,19 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
|||
rpcInit.connLimitNum = connLimitNum;
|
||||
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
||||
|
||||
taosVersionStrToInt(version, &(rpcInit.compatibilityVer));
|
||||
|
||||
void *pDnodeConn = rpcOpen(&rpcInit);
|
||||
if (pDnodeConn == NULL) {
|
||||
tscError("failed to init connection to server");
|
||||
return NULL;
|
||||
int32_t code = taosVersionStrToInt(version, &(rpcInit.compatibilityVer));
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("invalid version string.");
|
||||
return code;
|
||||
}
|
||||
|
||||
return pDnodeConn;
|
||||
*pDnodeConn = rpcOpen(&rpcInit);
|
||||
if (*pDnodeConn == NULL) {
|
||||
tscError("failed to init connection to server.");
|
||||
code = TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
void destroyAllRequests(SHashObj *pRequests) {
|
||||
|
@ -334,7 +389,7 @@ void destroyAllRequests(SHashObj *pRequests) {
|
|||
SRequestObj *pRequest = acquireRequest(*rid);
|
||||
if (pRequest) {
|
||||
destroyRequest(pRequest);
|
||||
releaseRequest(*rid);
|
||||
(void)releaseRequest(*rid); // ignore error
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(pRequests, pIter);
|
||||
|
@ -349,7 +404,7 @@ void stopAllRequests(SHashObj *pRequests) {
|
|||
SRequestObj *pRequest = acquireRequest(*rid);
|
||||
if (pRequest) {
|
||||
taos_stop_query(pRequest);
|
||||
releaseRequest(*rid);
|
||||
(void)releaseRequest(*rid); // ignore error
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(pRequests, pIter);
|
||||
|
@ -360,18 +415,31 @@ void destroyAppInst(void *info) {
|
|||
SAppInstInfo* pAppInfo = *(SAppInstInfo**)info;
|
||||
tscDebug("destroy app inst mgr %p", pAppInfo);
|
||||
|
||||
taosThreadMutexLock(&appInfo.mutex);
|
||||
int32_t code = taosThreadMutexLock(&appInfo.mutex);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to lock app info, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code)));
|
||||
}
|
||||
|
||||
hbRemoveAppHbMrg(&pAppInfo->pAppHbMgr);
|
||||
|
||||
taosThreadMutexUnlock(&appInfo.mutex);
|
||||
code = taosThreadMutexUnlock(&appInfo.mutex);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to unlock app info, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code)));
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(pAppInfo->instKey);
|
||||
closeTransporter(pAppInfo);
|
||||
|
||||
taosThreadMutexLock(&pAppInfo->qnodeMutex);
|
||||
code = taosThreadMutexLock(&pAppInfo->qnodeMutex);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to lock qnode mutex, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code)));
|
||||
}
|
||||
|
||||
taosArrayDestroy(pAppInfo->pQnodeList);
|
||||
taosThreadMutexUnlock(&pAppInfo->qnodeMutex);
|
||||
code = taosThreadMutexUnlock(&pAppInfo->qnodeMutex);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to unlock qnode mutex, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code)));
|
||||
}
|
||||
|
||||
taosMemoryFree(pAppInfo);
|
||||
}
|
||||
|
@ -396,97 +464,110 @@ void destroyTscObj(void *pObj) {
|
|||
pTscObj->pAppInfo->numOfConns);
|
||||
|
||||
// In any cases, we should not free app inst here. Or an race condition rises.
|
||||
/*int64_t connNum = */ atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||
/*int64_t connNum = */ (void)atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||
|
||||
taosThreadMutexDestroy(&pTscObj->mutex);
|
||||
(void)taosThreadMutexDestroy(&pTscObj->mutex);
|
||||
taosMemoryFree(pTscObj);
|
||||
|
||||
tscTrace("end to destroy tscObj %" PRIx64 " p:%p", tscId, pTscObj);
|
||||
}
|
||||
|
||||
void *createTscObj(const char *user, const char *auth, const char *db, int32_t connType, SAppInstInfo *pAppInfo) {
|
||||
STscObj *pObj = (STscObj *)taosMemoryCalloc(1, sizeof(STscObj));
|
||||
if (NULL == pObj) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
int32_t createTscObj(const char *user, const char *auth, const char *db, int32_t connType, SAppInstInfo *pAppInfo,
|
||||
STscObj **pObj) {
|
||||
*pObj = (STscObj *)taosMemoryCalloc(1, sizeof(STscObj));
|
||||
if (NULL == *pObj) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pObj->pRequests = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (NULL == pObj->pRequests) {
|
||||
taosMemoryFree(pObj);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
(*pObj)->pRequests = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (NULL == (*pObj)->pRequests) {
|
||||
taosMemoryFree(*pObj);
|
||||
return terrno ? terrno : TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pObj->connType = connType;
|
||||
pObj->pAppInfo = pAppInfo;
|
||||
pObj->appHbMgrIdx = pAppInfo->pAppHbMgr->idx;
|
||||
tstrncpy(pObj->user, user, sizeof(pObj->user));
|
||||
memcpy(pObj->pass, auth, TSDB_PASSWORD_LEN);
|
||||
(*pObj)->connType = connType;
|
||||
(*pObj)->pAppInfo = pAppInfo;
|
||||
(*pObj)->appHbMgrIdx = pAppInfo->pAppHbMgr->idx;
|
||||
tstrncpy((*pObj)->user, user, sizeof((*pObj)->user));
|
||||
(void)memcpy((*pObj)->pass, auth, TSDB_PASSWORD_LEN);
|
||||
|
||||
if (db != NULL) {
|
||||
tstrncpy(pObj->db, db, tListLen(pObj->db));
|
||||
tstrncpy((*pObj)->db, db, tListLen((*pObj)->db));
|
||||
}
|
||||
|
||||
taosThreadMutexInit(&pObj->mutex, NULL);
|
||||
pObj->id = taosAddRef(clientConnRefPool, pObj);
|
||||
TSC_ERR_RET(taosThreadMutexInit(&(*pObj)->mutex, NULL));
|
||||
|
||||
atomic_add_fetch_64(&pObj->pAppInfo->numOfConns, 1);
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
tscDebug("connObj created, 0x%" PRIx64 ",p:%p", pObj->id, pObj);
|
||||
return pObj;
|
||||
(*pObj)->id = taosAddRef(clientConnRefPool, *pObj);
|
||||
if ((*pObj)->id < 0) {
|
||||
tscError("failed to add object to clientConnRefPool");
|
||||
code = terrno;
|
||||
taosMemoryFree(*pObj);
|
||||
return code;
|
||||
}
|
||||
|
||||
(void)atomic_add_fetch_64(&(*pObj)->pAppInfo->numOfConns, 1);
|
||||
|
||||
tscDebug("connObj created, 0x%" PRIx64 ",p:%p", (*pObj)->id, *pObj);
|
||||
return code;
|
||||
}
|
||||
|
||||
STscObj *acquireTscObj(int64_t rid) { return (STscObj *)taosAcquireRef(clientConnRefPool, rid); }
|
||||
|
||||
int32_t releaseTscObj(int64_t rid) { return taosReleaseRef(clientConnRefPool, rid); }
|
||||
void releaseTscObj(int64_t rid) {
|
||||
int32_t code = taosReleaseRef(clientConnRefPool, rid);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscWarn("failed to release TscObj, code:%s", tstrerror(code));
|
||||
}
|
||||
}
|
||||
|
||||
void *createRequest(uint64_t connId, int32_t type, int64_t reqid) {
|
||||
SRequestObj *pRequest = (SRequestObj *)taosMemoryCalloc(1, sizeof(SRequestObj));
|
||||
if (NULL == pRequest) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
int32_t createRequest(uint64_t connId, int32_t type, int64_t reqid, SRequestObj **pRequest) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
*pRequest = (SRequestObj *)taosMemoryCalloc(1, sizeof(SRequestObj));
|
||||
if (NULL == *pRequest) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
STscObj *pTscObj = acquireTscObj(connId);
|
||||
if (pTscObj == NULL) {
|
||||
taosMemoryFree(pRequest);
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return NULL;
|
||||
code = TSDB_CODE_TSC_DISCONNECTED;
|
||||
goto _return;
|
||||
}
|
||||
SSyncQueryParam *interParam = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
||||
if (interParam == NULL) {
|
||||
releaseTscObj(connId);
|
||||
doDestroyRequest(pRequest);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return;
|
||||
}
|
||||
tsem_init(&interParam->sem, 0, 0);
|
||||
interParam->pRequest = pRequest;
|
||||
pRequest->body.interParam = interParam;
|
||||
TSC_ERR_JRET(tsem_init(&interParam->sem, 0, 0));
|
||||
interParam->pRequest = *pRequest;
|
||||
(*pRequest)->body.interParam = interParam;
|
||||
|
||||
pRequest->resType = RES_TYPE__QUERY;
|
||||
pRequest->requestId = reqid == 0 ? generateRequestId() : reqid;
|
||||
pRequest->metric.start = taosGetTimestampUs();
|
||||
(*pRequest)->resType = RES_TYPE__QUERY;
|
||||
(*pRequest)->requestId = reqid == 0 ? generateRequestId() : reqid;
|
||||
(*pRequest)->metric.start = taosGetTimestampUs();
|
||||
|
||||
pRequest->body.resInfo.convertUcs4 = true; // convert ucs4 by default
|
||||
pRequest->type = type;
|
||||
pRequest->allocatorRefId = -1;
|
||||
(*pRequest)->body.resInfo.convertUcs4 = true; // convert ucs4 by default
|
||||
(*pRequest)->type = type;
|
||||
(*pRequest)->allocatorRefId = -1;
|
||||
|
||||
pRequest->pDb = getDbOfConnection(pTscObj);
|
||||
pRequest->pTscObj = pTscObj;
|
||||
pRequest->inCallback = false;
|
||||
|
||||
pRequest->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
|
||||
pRequest->msgBufLen = ERROR_MSG_BUF_DEFAULT_SIZE;
|
||||
tsem_init(&pRequest->body.rspSem, 0, 0);
|
||||
|
||||
if (registerRequest(pRequest, pTscObj)) {
|
||||
doDestroyRequest(pRequest);
|
||||
return NULL;
|
||||
(*pRequest)->pDb = getDbOfConnection(pTscObj);
|
||||
(*pRequest)->pTscObj = pTscObj;
|
||||
(*pRequest)->inCallback = false;
|
||||
(*pRequest)->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
|
||||
if (NULL == (*pRequest)->msgBuf) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return;
|
||||
}
|
||||
(*pRequest)->msgBufLen = ERROR_MSG_BUF_DEFAULT_SIZE;
|
||||
TSC_ERR_JRET(tsem_init(&(*pRequest)->body.rspSem, 0, 0));
|
||||
TSC_ERR_JRET(registerRequest(*pRequest, pTscObj));
|
||||
|
||||
return pRequest;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_return:
|
||||
doDestroyRequest(*pRequest);
|
||||
return code;
|
||||
}
|
||||
|
||||
void doFreeReqResultInfo(SReqResultInfo *pResInfo) {
|
||||
|
@ -521,12 +602,12 @@ int64_t removeFromMostPrevReq(SRequestObj* pRequest) {
|
|||
pTmp = acquireRequest(pTmp->relation.prevRefId);
|
||||
if (pTmp) {
|
||||
mostPrevReqRefId = pTmp->self;
|
||||
releaseRequest(mostPrevReqRefId);
|
||||
(void)releaseRequest(mostPrevReqRefId); // ignore error
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
removeRequest(mostPrevReqRefId);
|
||||
(void)removeRequest(mostPrevReqRefId); // ignore error
|
||||
return mostPrevReqRefId;
|
||||
}
|
||||
|
||||
|
@ -534,8 +615,8 @@ void destroyNextReq(int64_t nextRefId) {
|
|||
if (nextRefId) {
|
||||
SRequestObj* pObj = acquireRequest(nextRefId);
|
||||
if (pObj) {
|
||||
releaseRequest(nextRefId);
|
||||
releaseRequest(nextRefId);
|
||||
(void)releaseRequest(nextRefId); // ignore error
|
||||
(void)releaseRequest(nextRefId); // ignore error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -555,7 +636,7 @@ void destroySubRequests(SRequestObj *pRequest) {
|
|||
pTmp = acquireRequest(tmpRefId);
|
||||
if (pTmp) {
|
||||
pReqList[++reqIdx] = pTmp;
|
||||
releaseRequest(tmpRefId);
|
||||
(void)releaseRequest(tmpRefId); // ignore error
|
||||
} else {
|
||||
tscError("prev req ref 0x%" PRIx64 " is not there", tmpRefId);
|
||||
break;
|
||||
|
@ -563,7 +644,7 @@ void destroySubRequests(SRequestObj *pRequest) {
|
|||
}
|
||||
|
||||
for (int32_t i = reqIdx; i >= 0; i--) {
|
||||
removeRequest(pReqList[i]->self);
|
||||
(void)removeRequest(pReqList[i]->self); // ignore error
|
||||
}
|
||||
|
||||
tmpRefId = pRequest->relation.nextRefId;
|
||||
|
@ -571,8 +652,8 @@ void destroySubRequests(SRequestObj *pRequest) {
|
|||
pTmp = acquireRequest(tmpRefId);
|
||||
if (pTmp) {
|
||||
tmpRefId = pTmp->relation.nextRefId;
|
||||
removeRequest(pTmp->self);
|
||||
releaseRequest(pTmp->self);
|
||||
(void)removeRequest(pTmp->self); // ignore error
|
||||
(void)releaseRequest(pTmp->self); // ignore error
|
||||
} else {
|
||||
tscError("next req ref 0x%" PRIx64 " is not there", tmpRefId);
|
||||
break;
|
||||
|
@ -592,8 +673,10 @@ void doDestroyRequest(void *p) {
|
|||
|
||||
int64_t nextReqRefId = pRequest->relation.nextRefId;
|
||||
|
||||
taosHashRemove(pRequest->pTscObj->pRequests, &pRequest->self, sizeof(pRequest->self));
|
||||
|
||||
int32_t code = taosHashRemove(pRequest->pTscObj->pRequests, &pRequest->self, sizeof(pRequest->self));
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to remove request from hash, code:%s", tstrerror(code));
|
||||
}
|
||||
schedulerFreeJob(&pRequest->body.queryJob, 0);
|
||||
|
||||
destorySqlCallbackWrapper(pRequest->pWrapper);
|
||||
|
@ -601,7 +684,7 @@ void doDestroyRequest(void *p) {
|
|||
taosMemoryFreeClear(pRequest->msgBuf);
|
||||
|
||||
doFreeReqResultInfo(&pRequest->body.resInfo);
|
||||
tsem_destroy(&pRequest->body.rspSem);
|
||||
(void)tsem_destroy(&pRequest->body.rspSem);
|
||||
|
||||
taosArrayDestroy(pRequest->tableList);
|
||||
taosArrayDestroy(pRequest->targetTableList);
|
||||
|
@ -615,13 +698,15 @@ void doDestroyRequest(void *p) {
|
|||
taosMemoryFreeClear(pRequest->pDb);
|
||||
taosArrayDestroy(pRequest->dbList);
|
||||
if (pRequest->body.interParam) {
|
||||
tsem_destroy(&((SSyncQueryParam *)pRequest->body.interParam)->sem);
|
||||
(void)tsem_destroy(&((SSyncQueryParam *)pRequest->body.interParam)->sem);
|
||||
}
|
||||
taosMemoryFree(pRequest->body.interParam);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == nodesSimAcquireAllocator(pRequest->allocatorRefId)) {
|
||||
qDestroyQuery(pRequest->pQuery);
|
||||
nodesSimReleaseAllocator(pRequest->allocatorRefId);
|
||||
if (TSDB_CODE_SUCCESS != nodesSimReleaseAllocator(pRequest->allocatorRefId)) {
|
||||
tscError("failed to release allocator");
|
||||
}
|
||||
}
|
||||
nodesDestroyAllocator(pRequest->allocatorRefId);
|
||||
|
||||
|
@ -638,7 +723,7 @@ void destroyRequest(SRequestObj *pRequest) {
|
|||
}
|
||||
|
||||
taos_stop_query(pRequest);
|
||||
removeFromMostPrevReq(pRequest);
|
||||
(void)removeFromMostPrevReq(pRequest);
|
||||
}
|
||||
|
||||
void taosStopQueryImpl(SRequestObj *pRequest) {
|
||||
|
@ -677,7 +762,7 @@ void stopAllQueries(SRequestObj *pRequest) {
|
|||
|
||||
for (int32_t i = reqIdx; i >= 0; i--) {
|
||||
taosStopQueryImpl(pReqList[i]);
|
||||
releaseRequest(pReqList[i]->self);
|
||||
(void)releaseRequest(pReqList[i]->self); // ignore error
|
||||
}
|
||||
|
||||
taosStopQueryImpl(pRequest);
|
||||
|
@ -688,7 +773,7 @@ void stopAllQueries(SRequestObj *pRequest) {
|
|||
if (pTmp) {
|
||||
tmpRefId = pTmp->relation.nextRefId;
|
||||
taosStopQueryImpl(pTmp);
|
||||
releaseRequest(pTmp->self);
|
||||
(void)releaseRequest(pTmp->self); // ignore error
|
||||
} else {
|
||||
tscError("next req ref 0x%" PRIx64 " is not there", tmpRefId);
|
||||
break;
|
||||
|
@ -701,7 +786,7 @@ void crashReportThreadFuncUnexpectedStopped(void) { atomic_store_32(&clientStop,
|
|||
static void *tscCrashReportThreadFp(void *param) {
|
||||
setThreadName("client-crashReport");
|
||||
char filepath[PATH_MAX] = {0};
|
||||
snprintf(filepath, sizeof(filepath), "%s%s.taosCrashLog", tsLogDir, TD_DIRSEP);
|
||||
(void)snprintf(filepath, sizeof(filepath), "%s%s.taosCrashLog", tsLogDir, TD_DIRSEP);
|
||||
char *pMsg = NULL;
|
||||
int64_t msgLen = 0;
|
||||
TdFilePtr pFile = NULL;
|
||||
|
@ -770,20 +855,27 @@ static void *tscCrashReportThreadFp(void *param) {
|
|||
|
||||
int32_t tscCrashReportInit() {
|
||||
if (!tsEnableCrashReport) {
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
TdThreadAttr thAttr;
|
||||
taosThreadAttrInit(&thAttr);
|
||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
TSC_ERR_JRET(taosThreadAttrInit(&thAttr));
|
||||
TSC_ERR_JRET(taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE));
|
||||
TdThread crashReportThread;
|
||||
if (taosThreadCreate(&crashReportThread, &thAttr, tscCrashReportThreadFp, NULL) != 0) {
|
||||
tscError("failed to create crashReport thread since %s", strerror(errno));
|
||||
return -1;
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
TSC_ERR_RET(errno);
|
||||
}
|
||||
|
||||
taosThreadAttrDestroy(&thAttr);
|
||||
return 0;
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
_return:
|
||||
if (code) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
TSC_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void tscStopCrashReport() {
|
||||
|
@ -824,17 +916,17 @@ void taos_init_imp(void) {
|
|||
if (tscDbg.memEnable) {
|
||||
int32_t code = taosMemoryDbgInit();
|
||||
if (code) {
|
||||
printf("failed to init memory dbg, error:%s\n", tstrerror(code));
|
||||
(void)printf("failed to init memory dbg, error:%s\n", tstrerror(code));
|
||||
} else {
|
||||
tsAsyncLog = false;
|
||||
printf("memory dbg enabled\n");
|
||||
(void)printf("memory dbg enabled\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// In the APIs of other program language, taos_cleanup is not available yet.
|
||||
// So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning.
|
||||
atexit(taos_cleanup);
|
||||
(void)atexit(taos_cleanup);
|
||||
errno = TSDB_CODE_SUCCESS;
|
||||
taosSeedRand(taosGetTimestampSec());
|
||||
|
||||
|
@ -842,6 +934,11 @@ void taos_init_imp(void) {
|
|||
appInfo.startTime = taosGetTimestampMs();
|
||||
appInfo.pInstMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
appInfo.pInstMapByClusterId = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||
if (NULL == appInfo.pInstMap || NULL == appInfo.pInstMapByClusterId) {
|
||||
tscError("failed to allocate memory when init appInfo");
|
||||
tscInitRes = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
taosHashSetFreeFp(appInfo.pInstMap, destroyAppInst);
|
||||
deltaToUtcInitOnce();
|
||||
|
||||
|
@ -849,32 +946,20 @@ void taos_init_imp(void) {
|
|||
#ifdef CUS_PROMPT
|
||||
snprintf(logDirName, 64, "%slog", CUS_PROMPT);
|
||||
#else
|
||||
snprintf(logDirName, 64, "taoslog");
|
||||
(void)snprintf(logDirName, 64, "taoslog");
|
||||
#endif
|
||||
if (taosCreateLog(logDirName, 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) {
|
||||
printf(" WARING: Create %s failed:%s. configDir=%s\n", logDirName, strerror(errno), configDir);
|
||||
(void)printf(" WARING: Create %s failed:%s. configDir=%s\n", logDirName, strerror(errno), configDir);
|
||||
tscInitRes = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1) != 0) {
|
||||
tscInitRes = -1;
|
||||
return;
|
||||
}
|
||||
ENV_ERR_RET(taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1), "failed to init cfg");
|
||||
|
||||
initQueryModuleMsgHandle();
|
||||
|
||||
if (taosConvInit() != 0) {
|
||||
tscInitRes = -1;
|
||||
tscError("failed to init conv");
|
||||
return;
|
||||
}
|
||||
if (monitorInit() != 0){
|
||||
tscInitRes = -1;
|
||||
tscError("failed to init monitor");
|
||||
return;
|
||||
}
|
||||
rpcInit();
|
||||
ENV_ERR_RET(taosConvInit(), "failed to init conv");
|
||||
ENV_ERR_RET(monitorInit(), "failed to init monitor");
|
||||
ENV_ERR_RET(rpcInit(), "failed to init rpc");
|
||||
|
||||
if (InitRegexCache() != 0) {
|
||||
tscInitRes = -1;
|
||||
|
@ -883,36 +968,32 @@ void taos_init_imp(void) {
|
|||
}
|
||||
|
||||
SCatalogCfg cfg = {.maxDBCacheNum = 100, .maxTblCacheNum = 100};
|
||||
catalogInit(&cfg);
|
||||
ENV_ERR_RET(catalogInit(&cfg), "failed to init catalog");
|
||||
ENV_ERR_RET(schedulerInit(), "failed to init scheduler");
|
||||
|
||||
schedulerInit();
|
||||
tscDebug("starting to initialize TAOS driver");
|
||||
|
||||
#ifndef WINDOWS
|
||||
taosSetCoreDump(true);
|
||||
#endif
|
||||
|
||||
if (initTaskQueue() != 0){
|
||||
tscInitRes = -1;
|
||||
tscError("failed to init task queue");
|
||||
return;
|
||||
}
|
||||
fmFuncMgtInit();
|
||||
nodesInitAllocatorSet();
|
||||
ENV_ERR_RET(initTaskQueue(), "failed to init task queue");
|
||||
ENV_ERR_RET(fmFuncMgtInit(), "failed to init funcMgt");
|
||||
ENV_ERR_RET(nodesInitAllocatorSet(), "failed to init allocator set");
|
||||
|
||||
clientConnRefPool = taosOpenRef(200, destroyTscObj);
|
||||
clientReqRefPool = taosOpenRef(40960, doDestroyRequest);
|
||||
|
||||
taosGetAppName(appInfo.appName, NULL);
|
||||
taosThreadMutexInit(&appInfo.mutex, NULL);
|
||||
|
||||
tscCrashReportInit();
|
||||
ENV_ERR_RET(taosGetAppName(appInfo.appName, NULL), "failed to get app name");
|
||||
ENV_ERR_RET(taosThreadMutexInit(&appInfo.mutex, NULL), "failed to init thread mutex");
|
||||
ENV_ERR_RET(tscCrashReportInit(), "failed to init crash report");
|
||||
ENV_ERR_RET(qInitKeywordsTable(), "failed to init parser keywords table");
|
||||
|
||||
tscDebug("client is initialized successfully");
|
||||
}
|
||||
|
||||
int taos_init() {
|
||||
taosThreadOnce(&tscinit, taos_init_imp);
|
||||
(void)taosThreadOnce(&tscinit, taos_init_imp);
|
||||
return tscInitRes;
|
||||
}
|
||||
|
||||
|
@ -953,7 +1034,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
return -1;
|
||||
}
|
||||
newstr[0] = '"';
|
||||
memcpy(newstr+1, str, len);
|
||||
(void)memcpy(newstr+1, str, len);
|
||||
newstr[len + 1] = '"';
|
||||
newstr[len + 2] = '\0';
|
||||
str = newstr;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -73,7 +73,7 @@ void jniGetGlobalMethod(JNIEnv *env) {
|
|||
}
|
||||
|
||||
if (g_vm == NULL) {
|
||||
(*env)->GetJavaVM(env, &g_vm);
|
||||
(void)(*env)->GetJavaVM(env, &g_vm);
|
||||
}
|
||||
|
||||
jclass arrayListClass = (*env)->FindClass(env, "java/util/ArrayList");
|
||||
|
@ -484,7 +484,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getSchemaMetaData
|
|||
(*env)->SetIntField(env, metadataObj, g_metadataColindexField, i);
|
||||
jstring metadataObjColname = (*env)->NewStringUTF(env, fields[i].name);
|
||||
(*env)->SetObjectField(env, metadataObj, g_metadataColnameField, metadataObjColname);
|
||||
(*env)->CallBooleanMethod(env, arrayListObj, g_arrayListAddFp, metadataObj);
|
||||
(void)(*env)->CallBooleanMethod(env, arrayListObj, g_arrayListAddFp, metadataObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -582,20 +582,20 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn
|
|||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
case TSDB_DATA_TYPE_GEOMETRY: {
|
||||
memcpy(tmp, row[i], length[i]); // handle the case that terminated does not exist
|
||||
(void)memcpy(tmp, row[i], length[i]); // handle the case that terminated does not exist
|
||||
(*env)->CallVoidMethod(env, rowobj, g_rowdataSetStringFp, i, (*env)->NewStringUTF(env, tmp));
|
||||
|
||||
memset(tmp, 0, length[i]);
|
||||
(void)memset(tmp, 0, length[i]);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
(*env)->CallVoidMethod(env, rowobj, g_rowdataSetByteArrayFp, i,
|
||||
jniFromNCharToByteArray(env, (char *)row[i], length[i]));
|
||||
jniFromNCharToByteArray(env, (char *)row[i], length[i]));
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_JSON: {
|
||||
(*env)->CallVoidMethod(env, rowobj, g_rowdataSetByteArrayFp, i,
|
||||
jniFromNCharToByteArray(env, (char *)row[i], length[i]));
|
||||
jniFromNCharToByteArray(env, (char *)row[i], length[i]));
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_TIMESTAMP: {
|
||||
|
@ -680,6 +680,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
|
|||
jsize len = (*env)->GetArrayLength(env, jsql);
|
||||
|
||||
char *str = (char *)taosMemoryCalloc(1, sizeof(char) * (len + 1));
|
||||
if (str == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, jsql, 0, len, (jbyte *)str);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
// todo handle error
|
||||
|
@ -843,6 +847,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
|
|||
|
||||
jsize len = (*env)->GetArrayLength(env, tags);
|
||||
char *tagsData = (char *)taosMemoryCalloc(1, len);
|
||||
if (tagsData == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tsconn);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, tags, 0, len, (jbyte *)tagsData);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
// todo handle error
|
||||
|
@ -850,18 +858,30 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
|
|||
|
||||
len = (*env)->GetArrayLength(env, lengthList);
|
||||
int32_t *lengthArray = (int32_t *)taosMemoryCalloc(1, len);
|
||||
if (lengthArray == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tsconn);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, lengthList, 0, len, (jbyte *)lengthArray);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
}
|
||||
|
||||
len = (*env)->GetArrayLength(env, typeList);
|
||||
char *typeArray = (char *)taosMemoryCalloc(1, len);
|
||||
if (typeArray == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tsconn);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, typeList, 0, len, (jbyte *)typeArray);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
}
|
||||
|
||||
len = (*env)->GetArrayLength(env, nullList);
|
||||
char *nullArray = (char *)taosMemoryCalloc(1, len);
|
||||
if (nullArray == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tsconn);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, nullList, 0, len, (jbyte *)nullArray);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
}
|
||||
|
@ -870,6 +890,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
|
|||
char *curTags = tagsData;
|
||||
|
||||
TAOS_MULTI_BIND *tagsBind = taosMemoryCalloc(numOfTags, sizeof(TAOS_MULTI_BIND));
|
||||
if (tagsBind == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tsconn);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < numOfTags; ++i) {
|
||||
tagsBind[i].buffer_type = typeArray[i];
|
||||
tagsBind[i].buffer = curTags;
|
||||
|
@ -916,6 +940,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_bindColDataImp(
|
|||
// todo refactor
|
||||
jsize len = (*env)->GetArrayLength(env, colDataList);
|
||||
char *colBuf = (char *)taosMemoryCalloc(1, len);
|
||||
if (colBuf == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, colDataList, 0, len, (jbyte *)colBuf);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
// todo handle error
|
||||
|
@ -923,18 +951,30 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_bindColDataImp(
|
|||
|
||||
len = (*env)->GetArrayLength(env, lengthList);
|
||||
char *lengthArray = (char *)taosMemoryCalloc(1, len);
|
||||
if (lengthArray == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, lengthList, 0, len, (jbyte *)lengthArray);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
}
|
||||
|
||||
len = (*env)->GetArrayLength(env, nullList);
|
||||
char *nullArray = (char *)taosMemoryCalloc(1, len);
|
||||
if (nullArray == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, nullList, 0, len, (jbyte *)nullArray);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
}
|
||||
|
||||
// bind multi-rows with only one invoke.
|
||||
TAOS_MULTI_BIND *b = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND));
|
||||
if (b == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
b->num = numOfRows;
|
||||
b->buffer_type = dataType; // todo check data type
|
||||
|
@ -1043,14 +1083,14 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_stmtErrorMsgIm
|
|||
TAOS *tscon = (TAOS *)con;
|
||||
if (tscon == NULL) {
|
||||
jniError("jobj:%p, connection already closed", jobj);
|
||||
sprintf(errMsg, "jobj:%p, connection already closed", jobj);
|
||||
(void)sprintf(errMsg, "jobj:%p, connection already closed", jobj);
|
||||
return (*env)->NewStringUTF(env, errMsg);
|
||||
}
|
||||
|
||||
TAOS_STMT *pStmt = (TAOS_STMT *)stmt;
|
||||
if (pStmt == NULL) {
|
||||
jniError("jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
||||
sprintf(errMsg, "jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
||||
(void)sprintf(errMsg, "jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
||||
return (*env)->NewStringUTF(env, errMsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
|||
for (int i = 1; atomic_val_compare_exchange_32(&lock, 0, 1) != 0; ++i) {
|
||||
if (i % 1000 == 0) {
|
||||
tscInfo("haven't acquire lock after spin %d times.", i);
|
||||
sched_yield();
|
||||
(void)sched_yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,15 +69,21 @@ void taos_cleanup(void) {
|
|||
qCleanupKeywordsTable();
|
||||
nodesDestroyAllocatorSet();
|
||||
|
||||
cleanupTaskQueue();
|
||||
if (TSDB_CODE_SUCCESS != cleanupTaskQueue()) {
|
||||
tscWarn("failed to cleanup task queue");
|
||||
}
|
||||
|
||||
int32_t id = clientReqRefPool;
|
||||
clientReqRefPool = -1;
|
||||
taosCloseRef(id);
|
||||
if (TSDB_CODE_SUCCESS != taosCloseRef(id)) {
|
||||
tscWarn("failed to close clientReqRefPool");
|
||||
}
|
||||
|
||||
id = clientConnRefPool;
|
||||
clientConnRefPool = -1;
|
||||
taosCloseRef(id);
|
||||
if (TSDB_CODE_SUCCESS != taosCloseRef(id)) {
|
||||
tscWarn("failed to close clientReqRefPool");
|
||||
}
|
||||
|
||||
DestroyRegexCache();
|
||||
rpcCleanup();
|
||||
|
@ -115,11 +121,19 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
|
|||
pass = TSDB_DEFAULT_PASS;
|
||||
}
|
||||
|
||||
STscObj *pObj = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY);
|
||||
if (pObj) {
|
||||
STscObj *pObj = NULL;
|
||||
int32_t code = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY, &pObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
int64_t *rid = taosMemoryCalloc(1, sizeof(int64_t));
|
||||
if (NULL == rid) {
|
||||
tscError("out of memory when taos connect to %s:%u, user:%s db:%s", ip, port, user, db);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
*rid = pObj->id;
|
||||
return (TAOS *)rid;
|
||||
} else {
|
||||
terrno = code;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -140,24 +154,24 @@ int taos_set_notify_cb(TAOS *taos, __taos_notify_fn_t fp, void *param, int type)
|
|||
|
||||
switch (type) {
|
||||
case TAOS_NOTIFY_PASSVER: {
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexLock(&pObj->mutex));
|
||||
pObj->passInfo.fp = fp;
|
||||
pObj->passInfo.param = param;
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexUnlock(&pObj->mutex));
|
||||
break;
|
||||
}
|
||||
case TAOS_NOTIFY_WHITELIST_VER: {
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexLock(&pObj->mutex));
|
||||
pObj->whiteListInfo.fp = fp;
|
||||
pObj->whiteListInfo.param = param;
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexUnlock(&pObj->mutex));
|
||||
break;
|
||||
}
|
||||
case TAOS_NOTIFY_USER_DROPPED: {
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexLock(&pObj->mutex));
|
||||
pObj->userDroppedInfo.fp = fp;
|
||||
pObj->userDroppedInfo.param = param;
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexUnlock(&pObj->mutex));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
@ -189,7 +203,13 @@ int32_t fetchWhiteListCallbackFn(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
|
||||
SGetUserWhiteListRsp wlRsp;
|
||||
tDeserializeSGetUserWhiteListRsp(pMsg->pData, pMsg->len, &wlRsp);
|
||||
if (TSDB_CODE_SUCCESS != tDeserializeSGetUserWhiteListRsp(pMsg->pData, pMsg->len, &wlRsp)) {
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
taosMemoryFree(pInfo);
|
||||
tFreeSGetUserWhiteListRsp(&wlRsp);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
uint64_t* pWhiteLists = taosMemoryMalloc(wlRsp.numWhiteLists * sizeof(uint64_t));
|
||||
if (pWhiteLists == NULL) {
|
||||
|
@ -229,8 +249,14 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
|
|||
}
|
||||
|
||||
SGetUserWhiteListReq req;
|
||||
memcpy(req.user, pTsc->user, TSDB_USER_LEN);
|
||||
(void)memcpy(req.user, pTsc->user, TSDB_USER_LEN);
|
||||
int32_t msgLen = tSerializeSGetUserWhiteListReq(NULL, 0, &req);
|
||||
if (msgLen < 0) {
|
||||
fp(param, TSDB_CODE_INVALID_PARA, taos, 0, NULL);
|
||||
releaseTscObj(connId);
|
||||
return;
|
||||
}
|
||||
|
||||
void* pReq = taosMemoryMalloc(msgLen);
|
||||
if (pReq == NULL) {
|
||||
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
|
||||
|
@ -274,7 +300,9 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
|
|||
|
||||
int64_t transportId = 0;
|
||||
SEpSet epSet = getEpSet_s(&pTsc->pAppInfo->mgmtEp);
|
||||
asyncSendMsgToServer(pTsc->pAppInfo->pTransporter, &epSet, &transportId, pSendInfo);
|
||||
if (TSDB_CODE_SUCCESS != asyncSendMsgToServer(pTsc->pAppInfo->pTransporter, &epSet, &transportId, pSendInfo)) {
|
||||
tscWarn("failed to async send msg to server");
|
||||
}
|
||||
releaseTscObj(connId);
|
||||
return;
|
||||
}
|
||||
|
@ -287,7 +315,7 @@ void taos_close_internal(void *taos) {
|
|||
STscObj *pTscObj = (STscObj *)taos;
|
||||
tscDebug("0x%" PRIx64 " try to close connection, numOfReq:%d", pTscObj->id, pTscObj->numOfReqs);
|
||||
|
||||
taosRemoveRef(clientConnRefPool, pTscObj->id);
|
||||
(void)taosRemoveRef(clientConnRefPool, pTscObj->id);
|
||||
}
|
||||
|
||||
void taos_close(TAOS *taos) {
|
||||
|
@ -426,9 +454,11 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
return doAsyncFetchRows(pRequest, true, true);
|
||||
} else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
SMqRspObj *msg = ((SMqRspObj *)res);
|
||||
SReqResultInfo *pResultInfo;
|
||||
SReqResultInfo *pResultInfo = NULL;
|
||||
if (msg->common.resIter == -1) {
|
||||
pResultInfo = tmqGetNextResInfo(res, true);
|
||||
if(tmqGetNextResInfo(res, true, &pResultInfo) != 0){
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
pResultInfo = tmqGetCurResInfo(res);
|
||||
}
|
||||
|
@ -438,8 +468,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
pResultInfo->current += 1;
|
||||
return pResultInfo->row;
|
||||
} else {
|
||||
pResultInfo = tmqGetNextResInfo(res, true);
|
||||
if (pResultInfo == NULL) {
|
||||
if (tmqGetNextResInfo(res, true, &pResultInfo) != 0){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -452,6 +481,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
} else {
|
||||
// assert to avoid un-initialization error
|
||||
tscError("invalid result passed to taos_fetch_row");
|
||||
terrno = TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -520,7 +550,7 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
|||
if(taosAscii2Hex(row[i], charLen, &data, &size) < 0){
|
||||
break;
|
||||
}
|
||||
memcpy(str + len, data, size);
|
||||
(void)memcpy(str + len, data, size);
|
||||
len += size;
|
||||
taosMemoryFree(data);
|
||||
}break;
|
||||
|
@ -538,7 +568,7 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
|||
}
|
||||
}
|
||||
|
||||
memcpy(str + len, row[i], charLen);
|
||||
(void)memcpy(str + len, row[i], charLen);
|
||||
len += charLen;
|
||||
} break;
|
||||
|
||||
|
@ -685,7 +715,7 @@ int taos_select_db(TAOS *taos, const char *db) {
|
|||
}
|
||||
|
||||
char sql[256] = {0};
|
||||
snprintf(sql, tListLen(sql), "use %s", db);
|
||||
(void)snprintf(sql, tListLen(sql), "use %s", db);
|
||||
|
||||
TAOS_RES *pRequest = taos_query(taos, sql);
|
||||
int32_t code = taos_errno(pRequest);
|
||||
|
@ -724,7 +754,7 @@ bool taos_is_update_query(TAOS_RES *res) { return taos_num_fields(res) == 0; }
|
|||
|
||||
int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
|
||||
int32_t numOfRows = 0;
|
||||
/*int32_t code = */ taos_fetch_block_s(res, &numOfRows, rows);
|
||||
/*int32_t code = */ terrno = taos_fetch_block_s(res, &numOfRows, rows);
|
||||
return numOfRows;
|
||||
}
|
||||
|
||||
|
@ -741,10 +771,10 @@ int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) {
|
|||
|
||||
if (pRequest->type == TSDB_SQL_RETRIEVE_EMPTY_RESULT || pRequest->type == TSDB_SQL_INSERT ||
|
||||
pRequest->code != TSDB_CODE_SUCCESS || taos_num_fields(res) == 0) {
|
||||
return 0;
|
||||
return pRequest->code;
|
||||
}
|
||||
|
||||
doAsyncFetchRows(pRequest, false, true);
|
||||
(void)doAsyncFetchRows(pRequest, false, true);
|
||||
|
||||
// TODO refactor
|
||||
SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
|
||||
|
@ -754,8 +784,9 @@ int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) {
|
|||
(*numOfRows) = pResultInfo->numOfRows;
|
||||
return pRequest->code;
|
||||
} else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
SReqResultInfo *pResultInfo = tmqGetNextResInfo(res, true);
|
||||
if (pResultInfo == NULL) return -1;
|
||||
SReqResultInfo *pResultInfo = NULL;
|
||||
int32_t code = tmqGetNextResInfo(res, true, &pResultInfo);
|
||||
if (code != 0) return code;
|
||||
|
||||
pResultInfo->current = pResultInfo->numOfRows;
|
||||
(*rows) = pResultInfo->row;
|
||||
|
@ -776,8 +807,9 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
|
|||
}
|
||||
|
||||
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
SReqResultInfo *pResultInfo = tmqGetNextResInfo(res, false);
|
||||
if (pResultInfo == NULL) {
|
||||
SReqResultInfo *pResultInfo = NULL;
|
||||
int32_t code = tmqGetNextResInfo(res, false, &pResultInfo);
|
||||
if (code != 0) {
|
||||
(*numOfRows) = 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -792,10 +824,10 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
|
|||
|
||||
if (pRequest->type == TSDB_SQL_RETRIEVE_EMPTY_RESULT || pRequest->type == TSDB_SQL_INSERT ||
|
||||
pRequest->code != TSDB_CODE_SUCCESS || taos_num_fields(res) == 0) {
|
||||
return 0;
|
||||
return pRequest->code;
|
||||
}
|
||||
|
||||
doAsyncFetchRows(pRequest, false, false);
|
||||
(void)doAsyncFetchRows(pRequest, false, false);
|
||||
|
||||
SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
|
||||
|
||||
|
@ -803,7 +835,7 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
|
|||
(*numOfRows) = pResultInfo->numOfRows;
|
||||
(*pData) = (void *)pResultInfo->pData;
|
||||
|
||||
return 0;
|
||||
return pRequest->code;
|
||||
}
|
||||
|
||||
int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
|
||||
|
@ -861,26 +893,24 @@ const char *taos_get_server_info(TAOS *taos) {
|
|||
int taos_get_current_db(TAOS *taos, char *database, int len, int *required) {
|
||||
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
|
||||
if (pTscObj == NULL) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_DISCONNECTED;
|
||||
}
|
||||
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
taosThreadMutexLock(&pTscObj->mutex);
|
||||
(void)taosThreadMutexLock(&pTscObj->mutex);
|
||||
if (database == NULL || len <= 0) {
|
||||
if (required != NULL) *required = strlen(pTscObj->db) + 1;
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
code = -1;
|
||||
TSC_ERR_JRET(TSDB_CODE_INVALID_PARA);
|
||||
} else if (len < strlen(pTscObj->db) + 1) {
|
||||
tstrncpy(database, pTscObj->db, len);
|
||||
if (required) *required = strlen(pTscObj->db) + 1;
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
code = -1;
|
||||
TSC_ERR_JRET(TSDB_CODE_INVALID_PARA);
|
||||
} else {
|
||||
strcpy(database, pTscObj->db);
|
||||
(void)strcpy(database, pTscObj->db);
|
||||
code = 0;
|
||||
}
|
||||
taosThreadMutexUnlock(&pTscObj->mutex);
|
||||
_return:
|
||||
(void)taosThreadMutexUnlock(&pTscObj->mutex);
|
||||
releaseTscObj(*(int64_t *)taos);
|
||||
return code;
|
||||
}
|
||||
|
@ -921,8 +951,8 @@ static void doAsyncQueryFromAnalyse(SMetaData *pResultMeta, void *param, int32_t
|
|||
pRequest->metric.analyseCostUs += taosGetTimestampUs() - analyseStart;
|
||||
|
||||
if (pRequest->parseOnly) {
|
||||
memcpy(&pRequest->parseMeta, pResultMeta, sizeof(*pResultMeta));
|
||||
memset(pResultMeta, 0, sizeof(*pResultMeta));
|
||||
(void)memcpy(&pRequest->parseMeta, pResultMeta, sizeof(*pResultMeta));
|
||||
(void)memset(pResultMeta, 0, sizeof(*pResultMeta));
|
||||
}
|
||||
|
||||
handleQueryAnslyseRes(pWrapper, pResultMeta, code);
|
||||
|
@ -969,10 +999,9 @@ void handleSubQueryFromAnalyse(SSqlCallbackWrapper *pWrapper, SMetaData *pResult
|
|||
return;
|
||||
}
|
||||
|
||||
pNewRequest->pQuery = (SQuery *)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
if (NULL == pNewRequest->pQuery) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
pNewRequest->pQuery = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pNewRequest->pQuery);
|
||||
if (pNewRequest->pQuery) {
|
||||
pNewRequest->pQuery->pRoot = pRoot;
|
||||
pRoot = NULL;
|
||||
pNewRequest->pQuery->execStage = QUERY_EXEC_STAGE_ANALYSE;
|
||||
|
@ -1010,10 +1039,12 @@ void handleQueryAnslyseRes(SSqlCallbackWrapper *pWrapper, SMetaData *pResultMeta
|
|||
}
|
||||
|
||||
if (pQuery->haveResultSet) {
|
||||
setResSchemaInfo(&pRequest->body.resInfo, pQuery->pResSchema, pQuery->numOfResCols);
|
||||
code = setResSchemaInfo(&pRequest->body.resInfo, pQuery->pResSchema, pQuery->numOfResCols);
|
||||
setResPrecision(&pRequest->body.resInfo, pQuery->precision);
|
||||
}
|
||||
}
|
||||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
TSWAP(pRequest->dbList, (pQuery)->pDbList);
|
||||
TSWAP(pRequest->tableList, (pQuery)->pTableList);
|
||||
TSWAP(pRequest->targetTableList, (pQuery)->pTargetTableList);
|
||||
|
@ -1198,7 +1229,7 @@ int32_t prepareAndParseSqlSyntax(SSqlCallbackWrapper **ppWrapper, SRequestObj *p
|
|||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
pWrapper->pCatalogReq->forceUpdate = updateMetaForce;
|
||||
pWrapper->pCatalogReq->qNodeRequired = qnodeRequired(pRequest);
|
||||
TSC_ERR_RET(qnodeRequired(pRequest, &pWrapper->pCatalogReq->qNodeRequired));
|
||||
code = qParseSqlSyntax(pWrapper->pParseCtx, &pRequest->pQuery, pWrapper->pCatalogReq);
|
||||
}
|
||||
|
||||
|
@ -1241,7 +1272,7 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
|||
if (NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64,
|
||||
pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||
refreshMeta(pRequest->pTscObj, pRequest);
|
||||
(void)refreshMeta(pRequest->pTscObj, pRequest); //ignore return code,try again
|
||||
pRequest->prevCode = code;
|
||||
doAsyncQuery(pRequest, true);
|
||||
return;
|
||||
|
@ -1256,13 +1287,13 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
|||
void restartAsyncQuery(SRequestObj *pRequest, int32_t code) {
|
||||
tscInfo("restart request: %s p: %p", pRequest->sqlstr, pRequest);
|
||||
SRequestObj* pUserReq = pRequest;
|
||||
acquireRequest(pRequest->self);
|
||||
(void)acquireRequest(pRequest->self);
|
||||
while (pUserReq) {
|
||||
if (pUserReq->self == pUserReq->relation.userRefId || pUserReq->relation.userRefId == 0) {
|
||||
break;
|
||||
} else {
|
||||
int64_t nextRefId = pUserReq->relation.nextRefId;
|
||||
releaseRequest(pUserReq->self);
|
||||
(void)releaseRequest(pUserReq->self);
|
||||
if (nextRefId) {
|
||||
pUserReq = acquireRequest(nextRefId);
|
||||
}
|
||||
|
@ -1272,16 +1303,16 @@ void restartAsyncQuery(SRequestObj *pRequest, int32_t code) {
|
|||
if (pUserReq) {
|
||||
destroyCtxInRequest(pUserReq);
|
||||
pUserReq->prevCode = code;
|
||||
memset(&pUserReq->relation, 0, sizeof(pUserReq->relation));
|
||||
(void)memset(&pUserReq->relation, 0, sizeof(pUserReq->relation));
|
||||
} else {
|
||||
tscError("User req is missing");
|
||||
removeFromMostPrevReq(pRequest);
|
||||
(void)removeFromMostPrevReq(pRequest);
|
||||
return;
|
||||
}
|
||||
if (hasSubRequest)
|
||||
removeFromMostPrevReq(pRequest);
|
||||
(void)removeFromMostPrevReq(pRequest);
|
||||
else
|
||||
releaseRequest(pUserReq->self);
|
||||
(void)releaseRequest(pUserReq->self);
|
||||
doAsyncQuery(pUserReq, true);
|
||||
}
|
||||
|
||||
|
@ -1371,7 +1402,7 @@ int taos_get_db_route_info(TAOS *taos, const char *db, TAOS_DB_ROUTE_INFO *dbInf
|
|||
conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
||||
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
snprintf(dbFName, sizeof(dbFName), "%d.%s", pTscObj->acctId, db);
|
||||
(void)snprintf(dbFName, sizeof(dbFName), "%d.%s", pTscObj->acctId, db);
|
||||
|
||||
code = catalogGetDBVgInfo(pCtg, &conn, dbFName, dbInfo);
|
||||
if (code) {
|
||||
|
@ -1421,7 +1452,7 @@ int taos_get_table_vgId(TAOS *taos, const char *db, const char *table, int *vgId
|
|||
conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
||||
|
||||
SName tableName;
|
||||
toName(pTscObj->acctId, db, table, &tableName);
|
||||
(void)toName(pTscObj->acctId, db, table, &tableName);
|
||||
|
||||
SVgroupInfo vgInfo;
|
||||
code = catalogGetTableHashVgroup(pCtg, &conn, &tableName, &vgInfo);
|
||||
|
@ -1542,7 +1573,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
|||
}
|
||||
|
||||
SSyncQueryParam *pParam = pRequest->body.interParam;
|
||||
tsem_wait(&pParam->sem);
|
||||
(void)tsem_wait(&pParam->sem);
|
||||
|
||||
_return:
|
||||
destoryCatalogReq(&catalogReq);
|
||||
|
@ -1559,7 +1590,9 @@ TAOS_STMT *taos_stmt_init(TAOS *taos) {
|
|||
}
|
||||
|
||||
TAOS_STMT *pStmt = stmtInit(pObj, 0, NULL);
|
||||
|
||||
if (NULL == pStmt) {
|
||||
tscError("stmt init failed, errcode:%s", terrstr());
|
||||
}
|
||||
releaseTscObj(*(int64_t *)taos);
|
||||
|
||||
return pStmt;
|
||||
|
@ -1574,7 +1607,9 @@ TAOS_STMT *taos_stmt_init_with_reqid(TAOS *taos, int64_t reqid) {
|
|||
}
|
||||
|
||||
TAOS_STMT *pStmt = stmtInit(pObj, reqid, NULL);
|
||||
|
||||
if (NULL == pStmt) {
|
||||
tscError("stmt init failed, errcode:%s", terrstr());
|
||||
}
|
||||
releaseTscObj(*(int64_t *)taos);
|
||||
|
||||
return pStmt;
|
||||
|
@ -1589,7 +1624,9 @@ TAOS_STMT *taos_stmt_init_with_options(TAOS *taos, TAOS_STMT_OPTIONS *options) {
|
|||
}
|
||||
|
||||
TAOS_STMT *pStmt = stmtInit(pObj, options->reqId, options);
|
||||
|
||||
if (NULL == pStmt) {
|
||||
tscError("stmt init failed, errcode:%s", terrstr());
|
||||
}
|
||||
releaseTscObj(*(int64_t *)taos);
|
||||
|
||||
return pStmt;
|
||||
|
@ -1704,7 +1741,11 @@ int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
|
|||
}
|
||||
|
||||
int32_t insert = 0;
|
||||
stmtIsInsert(stmt, &insert);
|
||||
int32_t code = stmtIsInsert(stmt, &insert);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("stmt insert failed, errcode:%s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
if (0 == insert && bind->num > 1) {
|
||||
tscError("only one row data allowed for query");
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
|
@ -1728,7 +1769,11 @@ int taos_stmt_bind_single_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, in
|
|||
}
|
||||
|
||||
int32_t insert = 0;
|
||||
stmtIsInsert(stmt, &insert);
|
||||
int32_t code = stmtIsInsert(stmt, &insert);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("stmt insert failed, errcode:%s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
if (0 == insert && bind->num > 1) {
|
||||
tscError("only one row data allowed for query");
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
|
@ -1855,4 +1900,4 @@ int taos_set_conn_mode(TAOS* taos, int mode, int value) {
|
|||
|
||||
char* getBuildInfo(){
|
||||
return buildinfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,13 +21,10 @@ SHashObj* monitorSlowLogHash;
|
|||
char tmpSlowLogPath[PATH_MAX] = {0};
|
||||
|
||||
static int32_t getSlowLogTmpDir(char* tmpPath, int32_t size) {
|
||||
if (tsTempDir == NULL) {
|
||||
return -1;
|
||||
}
|
||||
int ret = snprintf(tmpPath, size, "%s/tdengine_slow_log/", tsTempDir);
|
||||
if (ret < 0) {
|
||||
tscError("failed to get tmp path ret:%d", ret);
|
||||
return ret;
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -71,10 +68,9 @@ static void destroyMonitorClient(void* data) {
|
|||
if (pMonitor == NULL) {
|
||||
return;
|
||||
}
|
||||
taosTmrStopA(&pMonitor->timer);
|
||||
(void)taosTmrStopA(&pMonitor->timer);
|
||||
taosHashCleanup(pMonitor->counters);
|
||||
taos_collector_registry_destroy(pMonitor->registry);
|
||||
// taos_collector_destroy(pMonitor->colector);
|
||||
(void)taos_collector_registry_destroy(pMonitor->registry);
|
||||
taosMemoryFree(pMonitor);
|
||||
}
|
||||
|
||||
|
@ -142,15 +138,17 @@ static int32_t sendReport(void* pTransporter, SEpSet* epSet, char* pCont, MONITO
|
|||
void* buf = taosMemoryMalloc(tlen);
|
||||
if (buf == NULL) {
|
||||
tscError("sendReport failed, out of memory, len:%d", tlen);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto FAILED;
|
||||
}
|
||||
tSerializeSStatisReq(buf, tlen, &sStatisReq);
|
||||
tlen = tSerializeSStatisReq(buf, tlen, &sStatisReq);
|
||||
if (tlen < 0) {
|
||||
taosMemoryFree(buf);
|
||||
goto FAILED;
|
||||
}
|
||||
|
||||
SMsgSendInfo* pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (pInfo == NULL) {
|
||||
tscError("sendReport failed, out of memory send info");
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(buf);
|
||||
goto FAILED;
|
||||
}
|
||||
|
@ -168,12 +166,12 @@ static int32_t sendReport(void* pTransporter, SEpSet* epSet, char* pCont, MONITO
|
|||
|
||||
FAILED:
|
||||
monitorFreeSlowLogDataEx(param);
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_TSC_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
static void generateClusterReport(taos_collector_registry_t* registry, void* pTransporter, SEpSet* epSet) {
|
||||
char ts[50] = {0};
|
||||
sprintf(ts, "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI));
|
||||
(void)sprintf(ts, "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI));
|
||||
char* pCont = (char*)taos_collector_registry_bridge_new(registry, ts, "%" PRId64, NULL);
|
||||
if (NULL == pCont) {
|
||||
tscError("generateClusterReport failed, get null content.");
|
||||
|
@ -181,7 +179,7 @@ static void generateClusterReport(taos_collector_registry_t* registry, void* pTr
|
|||
}
|
||||
|
||||
if (strlen(pCont) != 0 && sendReport(pTransporter, epSet, pCont, MONITOR_TYPE_COUNTER, NULL) == 0) {
|
||||
taos_collector_registry_clear_batch(registry);
|
||||
(void)taos_collector_registry_clear_batch(registry);
|
||||
}
|
||||
taosMemoryFreeClear(pCont);
|
||||
}
|
||||
|
@ -202,7 +200,7 @@ static void reportSendProcess(void* param, void* tmrId) {
|
|||
|
||||
SEpSet ep = getEpSet_s(&pInst->mgmtEp);
|
||||
generateClusterReport(pMonitor->registry, pInst->pTransporter, &ep);
|
||||
taosTmrReset(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, param, monitorTimer, &tmrId);
|
||||
(void)taosTmrReset(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, param, monitorTimer, &tmrId);
|
||||
taosRUnLockLatch(&monitorLock);
|
||||
}
|
||||
|
||||
|
@ -250,14 +248,13 @@ void monitorCreateClient(int64_t clusterId) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
taos_collector_registry_register_collector(pMonitor->registry, pMonitor->colector);
|
||||
(void)taos_collector_registry_register_collector(pMonitor->registry, pMonitor->colector);
|
||||
pMonitor->counters =
|
||||
(SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
if (pMonitor->counters == NULL) {
|
||||
tscError("failed to create monitor counters");
|
||||
goto fail;
|
||||
}
|
||||
// taosHashSetFreeFp(pMonitor->counters, destroyCounter);
|
||||
|
||||
if (taosHashPut(monitorCounterHash, &clusterId, LONG_BYTES, &pMonitor, POINTER_BYTES) != 0) {
|
||||
tscError("failed to put monitor client to hash");
|
||||
|
@ -300,10 +297,14 @@ void monitorCreateClientCounter(int64_t clusterId, const char* name, const char*
|
|||
taos_counter_t* newCounter = taos_counter_new(name, help, label_key_count, label_keys);
|
||||
if (newCounter == NULL) return;
|
||||
MonitorClient* pMonitor = *ppMonitor;
|
||||
taos_collector_add_metric(pMonitor->colector, newCounter);
|
||||
if (taos_collector_add_metric(pMonitor->colector, newCounter) != 0){
|
||||
tscError("failed to add metric to collector");
|
||||
(void)taos_counter_destroy(newCounter);
|
||||
goto end;
|
||||
}
|
||||
if (taosHashPut(pMonitor->counters, name, strlen(name), &newCounter, POINTER_BYTES) != 0) {
|
||||
tscError("failed to put counter to monitor");
|
||||
taos_counter_destroy(newCounter);
|
||||
(void)taos_counter_destroy(newCounter);
|
||||
goto end;
|
||||
}
|
||||
tscInfo("[monitor] monitorCreateClientCounter %" PRIx64 "(%p):%s : %p.", pMonitor->clusterId, pMonitor, name,
|
||||
|
@ -332,7 +333,10 @@ void monitorCounterInc(int64_t clusterId, const char* counterName, const char**
|
|||
tscError("monitorCounterInc not found pCounter %" PRIx64 ":%s.", clusterId, counterName);
|
||||
goto end;
|
||||
}
|
||||
taos_counter_inc(*ppCounter, label_values);
|
||||
if (taos_counter_inc(*ppCounter, label_values) != 0){
|
||||
tscError("monitorCounterInc failed to inc %" PRIx64 ":%s.", clusterId, counterName);
|
||||
goto end;
|
||||
}
|
||||
tscDebug("[monitor] monitorCounterInc %" PRIx64 "(%p):%s", pMonitor->clusterId, pMonitor, counterName);
|
||||
|
||||
end:
|
||||
|
@ -360,24 +364,23 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
|
|||
tscInfo("[monitor] create slow log file:%s", path);
|
||||
pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_READ | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tscError("failed to open file:%s since %s", path, terrstr());
|
||||
tscError("failed to open file:%s since %d", path, errno);
|
||||
return;
|
||||
}
|
||||
|
||||
SlowLogClient* pClient = taosMemoryCalloc(1, sizeof(SlowLogClient));
|
||||
if (pClient == NULL) {
|
||||
tscError("failed to allocate memory for slow log client");
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
return;
|
||||
}
|
||||
pClient->lastCheckTime = taosGetMonoTimestampMs();
|
||||
strcpy(pClient->path, path);
|
||||
(void)strcpy(pClient->path, path);
|
||||
pClient->offset = 0;
|
||||
pClient->pFile = pFile;
|
||||
if (taosHashPut(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES, &pClient, POINTER_BYTES) != 0) {
|
||||
tscError("failed to put clusterId:%" PRId64 " to hash table", slowLogData->clusterId);
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
taosMemoryFree(pClient);
|
||||
return;
|
||||
}
|
||||
|
@ -423,7 +426,7 @@ static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) {
|
|||
return NULL;
|
||||
}
|
||||
char* buf = pCont;
|
||||
strcat(buf++, "[");
|
||||
(void)strcat(buf++, "[");
|
||||
int64_t readSize = taosReadFile(pFile, buf, SLOW_LOG_SEND_SIZE_MAX);
|
||||
if (readSize <= 0) {
|
||||
if (readSize < 0) {
|
||||
|
@ -454,7 +457,7 @@ static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) {
|
|||
static int64_t getFileSize(char* path) {
|
||||
int64_t fileSize = 0;
|
||||
if (taosStatFile(path, &fileSize, NULL, NULL) < 0) {
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return fileSize;
|
||||
|
@ -464,13 +467,13 @@ static int32_t sendSlowLog(int64_t clusterId, char* data, TdFilePtr pFile, int64
|
|||
char* fileName, void* pTransporter, SEpSet* epSet) {
|
||||
if (data == NULL) {
|
||||
taosMemoryFree(fileName);
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
MonitorSlowLogData* pParam = taosMemoryMalloc(sizeof(MonitorSlowLogData));
|
||||
if (pParam == NULL) {
|
||||
taosMemoryFree(data);
|
||||
taosMemoryFree(fileName);
|
||||
return -1;
|
||||
return terrno;
|
||||
}
|
||||
pParam->data = data;
|
||||
pParam->offset = offset;
|
||||
|
@ -486,7 +489,7 @@ static int32_t monitorReadSend(int64_t clusterId, TdFilePtr pFile, int64_t* offs
|
|||
SAppInstInfo* pInst = getAppInstByClusterId(clusterId);
|
||||
if (pInst == NULL) {
|
||||
tscError("failed to get app instance by clusterId:%" PRId64, clusterId);
|
||||
return -1;
|
||||
return terrno;
|
||||
}
|
||||
SEpSet ep = getEpSet_s(&pInst->mgmtEp);
|
||||
char* data = readFile(pFile, offset, size);
|
||||
|
@ -495,13 +498,20 @@ static int32_t monitorReadSend(int64_t clusterId, TdFilePtr pFile, int64_t* offs
|
|||
}
|
||||
|
||||
static void monitorSendSlowLogAtBeginning(int64_t clusterId, char** fileName, TdFilePtr pFile, int64_t offset) {
|
||||
if (fileName == NULL){
|
||||
return;
|
||||
}
|
||||
int64_t size = getFileSize(*fileName);
|
||||
if (size <= offset) {
|
||||
processFileInTheEnd(pFile, *fileName);
|
||||
tscDebug("[monitor] monitorSendSlowLogAtBeginning delete file:%s", *fileName);
|
||||
} else {
|
||||
int32_t code = monitorReadSend(clusterId, pFile, &offset, size, SLOW_LOG_READ_BEGINNIG, *fileName);
|
||||
tscDebug("[monitor] monitorSendSlowLogAtBeginning send slow log clusterId:%" PRId64 ",ret:%d", clusterId, code);
|
||||
if (code == 0){
|
||||
tscDebug("[monitor] monitorSendSlowLogAtBeginning send slow log succ, clusterId:%" PRId64, clusterId);
|
||||
}else{
|
||||
tscError("[monitor] monitorSendSlowLogAtBeginning send slow log failed, clusterId:%" PRId64 ",ret:%d", clusterId, code);
|
||||
}
|
||||
*fileName = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -509,10 +519,12 @@ static void monitorSendSlowLogAtBeginning(int64_t clusterId, char** fileName, Td
|
|||
static void monitorSendSlowLogAtRunning(int64_t clusterId) {
|
||||
void* tmp = taosHashGet(monitorSlowLogHash, &clusterId, LONG_BYTES);
|
||||
if (tmp == NULL) {
|
||||
tscError("failed to get slow log client by clusterId:%" PRId64, clusterId);
|
||||
return;
|
||||
}
|
||||
SlowLogClient* pClient = (*(SlowLogClient**)tmp);
|
||||
if (pClient == NULL) {
|
||||
tscError("failed to get slow log client by clusterId:%" PRId64, clusterId);
|
||||
return;
|
||||
}
|
||||
int64_t size = getFileSize(pClient->path);
|
||||
|
@ -574,14 +586,16 @@ static void monitorSendAllSlowLogAtQuit() {
|
|||
}
|
||||
|
||||
static void processFileRemoved(SlowLogClient* pClient) {
|
||||
taosUnLockFile(pClient->pFile);
|
||||
taosCloseFile(&(pClient->pFile));
|
||||
if (taosUnLockFile(pClient->pFile) != 0) {
|
||||
tscError("failed to unlock file:%s since %d", pClient->path, errno);
|
||||
return;
|
||||
}
|
||||
(void)taosCloseFile(&(pClient->pFile));
|
||||
|
||||
TdFilePtr pFile =
|
||||
taosOpenFile(pClient->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_READ | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tscError("failed to open file:%s since %s", pClient->path, terrstr());
|
||||
tscError("failed to open file:%s since %d", pClient->path, errno);
|
||||
} else {
|
||||
pClient->pFile = pFile;
|
||||
}
|
||||
|
@ -594,7 +608,7 @@ static void monitorSendAllSlowLog() {
|
|||
int64_t* clusterId = (int64_t*)taosHashGetKey(pIter, NULL);
|
||||
SAppInstInfo* pInst = getAppInstByClusterId(*clusterId);
|
||||
SlowLogClient* pClient = (*(SlowLogClient**)pIter);
|
||||
if (pClient == NULL) {
|
||||
if (pClient == NULL || pInst == NULL) {
|
||||
taosHashCancelIterate(monitorSlowLogHash, pIter);
|
||||
return;
|
||||
}
|
||||
|
@ -604,7 +618,7 @@ static void monitorSendAllSlowLog() {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (pInst != NULL && pClient->offset == 0) {
|
||||
if (pClient->offset == 0) {
|
||||
int64_t size = getFileSize(pClient->path);
|
||||
if (size <= 0) {
|
||||
if (size < 0) {
|
||||
|
@ -657,7 +671,7 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) {
|
|||
}
|
||||
|
||||
char filename[PATH_MAX] = {0};
|
||||
snprintf(filename, sizeof(filename), "%s%s", tmpPath, name);
|
||||
(void)snprintf(filename, sizeof(filename), "%s%s", tmpPath, name);
|
||||
TdFilePtr pFile = taosOpenFile(filename, TD_FILE_READ | TD_FILE_WRITE);
|
||||
if (pFile == NULL) {
|
||||
tscError("failed to open file:%s since %s", filename, terrstr());
|
||||
|
@ -665,7 +679,7 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) {
|
|||
}
|
||||
if (taosLockFile(pFile) < 0) {
|
||||
tscError("failed to lock file:%s since %s, maybe used by other process", filename, terrstr());
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
continue;
|
||||
}
|
||||
char* tmp = taosStrdup(filename);
|
||||
|
@ -673,7 +687,7 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) {
|
|||
taosMemoryFree(tmp);
|
||||
}
|
||||
|
||||
taosCloseDir(&pDir);
|
||||
(void)taosCloseDir(&pDir);
|
||||
}
|
||||
|
||||
static void* monitorThreadFunc(void* param) {
|
||||
|
@ -707,7 +721,7 @@ static void* monitorThreadFunc(void* param) {
|
|||
}
|
||||
|
||||
MonitorSlowLogData* slowLogData = NULL;
|
||||
taosReadQitem(monitorQueue, (void**)&slowLogData);
|
||||
(void)taosReadQitem(monitorQueue, (void**)&slowLogData);
|
||||
if (slowLogData != NULL) {
|
||||
if (slowLogData->type == SLOW_LOG_READ_BEGINNIG) {
|
||||
if (slowLogData->pFile != NULL) {
|
||||
|
@ -735,7 +749,7 @@ static void* monitorThreadFunc(void* param) {
|
|||
if (quitCnt == 0) {
|
||||
monitorSendAllSlowLog();
|
||||
}
|
||||
tsem2_timewait(&monitorSem, 100);
|
||||
(void)tsem2_timewait(&monitorSem, 100);
|
||||
}
|
||||
atomic_store_32(&slowLogFlag, -2);
|
||||
return NULL;
|
||||
|
@ -743,15 +757,22 @@ static void* monitorThreadFunc(void* param) {
|
|||
|
||||
static int32_t tscMonitortInit() {
|
||||
TdThreadAttr thAttr;
|
||||
taosThreadAttrInit(&thAttr);
|
||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
if (taosThreadAttrInit(&thAttr) != 0) {
|
||||
tscError("failed to init thread attr since %s", strerror(errno));
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
if (taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE) != 0) {
|
||||
tscError("failed to set thread attr since %s", strerror(errno));
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
TdThread monitorThread;
|
||||
if (taosThreadCreate(&monitorThread, &thAttr, monitorThreadFunc, NULL) != 0) {
|
||||
tscError("failed to create monitor thread since %s", strerror(errno));
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
taosThreadAttrDestroy(&thAttr);
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -767,15 +788,14 @@ static void tscMonitorStop() {
|
|||
}
|
||||
|
||||
int32_t monitorInit() {
|
||||
int32_t code;
|
||||
int32_t code = 0;
|
||||
|
||||
tscInfo("[monitor] tscMonitor init");
|
||||
monitorCounterHash =
|
||||
(SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (monitorCounterHash == NULL) {
|
||||
tscError("failed to create monitorCounterHash");
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosHashSetFreeFp(monitorCounterHash, destroyMonitorClient);
|
||||
|
||||
|
@ -783,47 +803,39 @@ int32_t monitorInit() {
|
|||
(SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (monitorSlowLogHash == NULL) {
|
||||
tscError("failed to create monitorSlowLogHash");
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosHashSetFreeFp(monitorSlowLogHash, destroySlowLogClient);
|
||||
|
||||
monitorTimer = taosTmrInit(0, 0, 0, "MONITOR");
|
||||
if (monitorTimer == NULL) {
|
||||
tscError("failed to create monitor timer");
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
if (getSlowLogTmpDir(tmpSlowLogPath, sizeof(tmpSlowLogPath)) < 0) {
|
||||
terrno = TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
return -1;
|
||||
code = getSlowLogTmpDir(tmpSlowLogPath, sizeof(tmpSlowLogPath));
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
|
||||
if (taosMulModeMkDir(tmpSlowLogPath, 0777, true) != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tscError("failed to create dir:%s since %s", tmpSlowLogPath, terrstr());
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
if (tsem2_init(&monitorSem, 0, 0) != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tscError("sem init error since %s", terrstr());
|
||||
return -1;
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
}
|
||||
|
||||
code = taosOpenQueue(&monitorQueue);
|
||||
if (code) {
|
||||
terrno = code;
|
||||
tscError("open queue error since %s", terrstr());
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(code);
|
||||
}
|
||||
|
||||
taosInitRWLatch(&monitorLock);
|
||||
if (tscMonitortInit() != 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
return tscMonitortInit();
|
||||
}
|
||||
|
||||
void monitorClose() {
|
||||
|
@ -839,13 +851,13 @@ void monitorClose() {
|
|||
taosHashCleanup(monitorSlowLogHash);
|
||||
taosTmrCleanUp(monitorTimer);
|
||||
taosCloseQueue(monitorQueue);
|
||||
tsem2_destroy(&monitorSem);
|
||||
(void)tsem2_destroy(&monitorSem);
|
||||
taosWUnLockLatch(&monitorLock);
|
||||
}
|
||||
|
||||
int32_t monitorPutData2MonitorQueue(MonitorSlowLogData data) {
|
||||
int32_t code;
|
||||
MonitorSlowLogData* slowLogData;
|
||||
int32_t code = 0;
|
||||
MonitorSlowLogData* slowLogData = NULL;
|
||||
|
||||
if (atomic_load_32(&slowLogFlag) == -2) {
|
||||
tscError("[monitor] slow log thread is exiting");
|
||||
|
@ -855,13 +867,13 @@ int32_t monitorPutData2MonitorQueue(MonitorSlowLogData data) {
|
|||
code = taosAllocateQitem(sizeof(MonitorSlowLogData), DEF_QITEM, 0, (void**)&slowLogData);
|
||||
if (code) {
|
||||
tscError("[monitor] failed to allocate slow log data");
|
||||
return terrno = code;
|
||||
return code;
|
||||
}
|
||||
*slowLogData = data;
|
||||
tscDebug("[monitor] write slow log to queue, clusterId:%" PRIx64 " type:%s, data:%s", slowLogData->clusterId,
|
||||
queueTypeStr[slowLogData->type], slowLogData->data);
|
||||
if (taosWriteQitem(monitorQueue, slowLogData) == 0) {
|
||||
tsem2_post(&monitorSem);
|
||||
(void)tsem2_post(&monitorSem);
|
||||
} else {
|
||||
monitorFreeSlowLogData(slowLogData);
|
||||
taosFreeQitem(slowLogData);
|
||||
|
|
|
@ -69,7 +69,7 @@ void slowQueryLog(int64_t rid, bool killed, int32_t code, int32_t cost) {
|
|||
} else {
|
||||
clientSlowQueryLog(pTscObj->pAppInfo->clusterId, pTscObj->user, result, cost);
|
||||
}
|
||||
releaseTscObj(rid);
|
||||
(void)releaseTscObj(rid);
|
||||
} else {
|
||||
tscLog("slowQueryLog, not found rid");
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ void sqlReqLog(int64_t rid, bool killed, int32_t code, int8_t type) {
|
|||
} else {
|
||||
clientSQLReqLog(pTscObj->pAppInfo->clusterId, pTscObj->user, result, type);
|
||||
}
|
||||
releaseTscObj(rid);
|
||||
(void)releaseTscObj(rid);
|
||||
} else {
|
||||
tscLog("sqlReqLog, not found rid");
|
||||
}
|
||||
|
|
|
@ -40,7 +40,9 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
setErrno(pRequest, code);
|
||||
|
||||
if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) {
|
||||
removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type));
|
||||
if (removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)) != 0){
|
||||
tscError("failed to remove meta data for table");
|
||||
}
|
||||
}
|
||||
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
|
@ -48,7 +50,7 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (pRequest->body.queryFp != NULL) {
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -61,7 +63,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
setErrno(pRequest, code);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
@ -70,7 +72,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (NULL == pTscObj->pAppInfo) {
|
||||
code = TSDB_CODE_TSC_DISCONNECTED;
|
||||
setErrno(pRequest, code);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
@ -78,14 +80,14 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (tDeserializeSConnectRsp(pMsg->pData, pMsg->len, &connectRsp) != 0) {
|
||||
code = TSDB_CODE_TSC_INVALID_VERSION;
|
||||
setErrno(pRequest, code);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
if ((code = taosCheckVersionCompatibleFromStr(version, connectRsp.sVer, 3)) != 0) {
|
||||
tscError("version not compatible. client version: %s, server version: %s", version, connectRsp.sVer);
|
||||
setErrno(pRequest, code);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
@ -95,14 +97,14 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
code = TSDB_CODE_TIME_UNSYNCED;
|
||||
tscError("time diff:%ds is too big", delta);
|
||||
setErrno(pRequest, code);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
if (connectRsp.epSet.numOfEps == 0) {
|
||||
code = TSDB_CODE_APP_ERROR;
|
||||
setErrno(pRequest, code);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
@ -111,8 +113,10 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
SEpSet srcEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
||||
SEpSet dstEpSet = connectRsp.epSet;
|
||||
if (srcEpSet.numOfEps == 1) {
|
||||
rpcSetDefaultAddr(pTscObj->pAppInfo->pTransporter, srcEpSet.eps[srcEpSet.inUse].fqdn,
|
||||
dstEpSet.eps[dstEpSet.inUse].fqdn);
|
||||
if (rpcSetDefaultAddr(pTscObj->pAppInfo->pTransporter, srcEpSet.eps[srcEpSet.inUse].fqdn,
|
||||
dstEpSet.eps[dstEpSet.inUse].fqdn) != 0){
|
||||
tscError("failed to set default addr for rpc");
|
||||
}
|
||||
updateEpSet = 0;
|
||||
}
|
||||
}
|
||||
|
@ -158,33 +162,35 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
MonitorSlowLogData data = {0};
|
||||
data.clusterId = pTscObj->pAppInfo->clusterId;
|
||||
data.type = SLOW_LOG_READ_BEGINNIG;
|
||||
monitorPutData2MonitorQueue(data);
|
||||
(void)monitorPutData2MonitorQueue(data); // ignore
|
||||
monitorClientSlowQueryInit(connectRsp.clusterId);
|
||||
monitorClientSQLReqInit(connectRsp.clusterId);
|
||||
}
|
||||
}
|
||||
|
||||
taosThreadMutexLock(&clientHbMgr.lock);
|
||||
(void)taosThreadMutexLock(&clientHbMgr.lock);
|
||||
SAppHbMgr* pAppHbMgr = taosArrayGetP(clientHbMgr.appHbMgrs, pTscObj->appHbMgrIdx);
|
||||
if (pAppHbMgr) {
|
||||
hbRegisterConn(pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType);
|
||||
if (hbRegisterConn(pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType) != 0){
|
||||
tscError("0x%" PRIx64 " failed to register conn to hbMgr", pRequest->requestId);
|
||||
}
|
||||
} else {
|
||||
taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||
(void)taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||
code = TSDB_CODE_TSC_DISCONNECTED;
|
||||
setErrno(pRequest, code);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||
(void)taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||
|
||||
tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId,
|
||||
pTscObj->pAppInfo->numOfConns);
|
||||
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
End:
|
||||
|
||||
if (pRequest) {
|
||||
releaseRequest(pRequest->self);
|
||||
(void)releaseRequest(pRequest->self);
|
||||
}
|
||||
|
||||
taosMemoryFree(param);
|
||||
|
@ -216,7 +222,7 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
setErrno(pRequest, code);
|
||||
} else {
|
||||
struct SCatalog* pCatalog = NULL;
|
||||
int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STscObj* pTscObj = pRequest->pTscObj;
|
||||
|
||||
|
@ -225,28 +231,33 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB);
|
||||
catalogRefreshDBVgInfo(pCatalog, &conn, dbFName);
|
||||
snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB);
|
||||
catalogRefreshDBVgInfo(pCatalog, &conn, dbFName);
|
||||
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB);
|
||||
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0){
|
||||
tscError("0x%" PRIx64 " failed to refresh db vg info", pRequest->requestId);
|
||||
}
|
||||
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB);
|
||||
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0){
|
||||
tscError("0x%" PRIx64 " failed to refresh db vg info", pRequest->requestId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pRequest->body.queryFp) {
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
SRequestObj* pRequest = param;
|
||||
|
||||
if (TSDB_CODE_MND_DB_NOT_EXIST == code || TSDB_CODE_MND_DB_IN_CREATING == code ||
|
||||
TSDB_CODE_MND_DB_IN_DROPPING == code) {
|
||||
SUseDbRsp usedbRsp = {0};
|
||||
tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp);
|
||||
if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0){
|
||||
tscError("0x%" PRIx64 " deserialize SUseDbRsp failed", pRequest->requestId);
|
||||
}
|
||||
struct SCatalog* pCatalog = NULL;
|
||||
|
||||
if (usedbRsp.vgVersion >= 0) { // cached in local
|
||||
|
@ -256,10 +267,12 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tscWarn("0x%" PRIx64 "catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->requestId, clusterId,
|
||||
tstrerror(code1));
|
||||
} else {
|
||||
catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid);
|
||||
if (catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid) != 0){
|
||||
tscError("0x%" PRIx64 "catalogRemoveDB failed, db:%s, uid:%" PRId64, pRequest->requestId, usedbRsp.db,
|
||||
usedbRsp.uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tFreeSUsedbRsp(&usedbRsp);
|
||||
}
|
||||
|
||||
|
@ -272,14 +285,16 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
doRequestCallback(pRequest, pRequest->code);
|
||||
|
||||
} else {
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
SUseDbRsp usedbRsp = {0};
|
||||
tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp);
|
||||
if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0){
|
||||
tscError("0x%" PRIx64 " deserialize SUseDbRsp failed", pRequest->requestId);
|
||||
}
|
||||
|
||||
if (strlen(usedbRsp.db) == 0) {
|
||||
if (usedbRsp.errCode != 0) {
|
||||
|
@ -292,6 +307,9 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tscTrace("db:%s, usedbRsp received, numOfVgroups:%d", usedbRsp.db, usedbRsp.vgNum);
|
||||
for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
|
||||
SVgroupInfo* pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
|
||||
if (pInfo == NULL){
|
||||
continue;
|
||||
}
|
||||
tscTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
|
||||
for (int32_t j = 0; j < pInfo->epSet.numOfEps; ++j) {
|
||||
tscTrace("vgId:%d, index:%d epset:%s:%u", pInfo->vgId, j, pInfo->epSet.eps[j].fqdn, pInfo->epSet.eps[j].port);
|
||||
|
@ -299,11 +317,12 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
|
||||
SName name = {0};
|
||||
tNameFromString(&name, usedbRsp.db, T_NAME_ACCT | T_NAME_DB);
|
||||
if(tNameFromString(&name, usedbRsp.db, T_NAME_ACCT | T_NAME_DB) != TSDB_CODE_SUCCESS) {
|
||||
tscError("0x%" PRIx64 " failed to parse db name:%s", pRequest->requestId, usedbRsp.db);
|
||||
}
|
||||
|
||||
SUseDbOutput output = {0};
|
||||
code = queryBuildUseDbOutput(&output, &usedbRsp);
|
||||
|
||||
if (code != 0) {
|
||||
terrno = code;
|
||||
if (output.dbVgroup) taosHashCleanup(output.dbVgroup->vgHash);
|
||||
|
@ -317,26 +336,31 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId,
|
||||
tstrerror(code1));
|
||||
} else {
|
||||
catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup);
|
||||
if (catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup) != 0){
|
||||
tscError("0x%" PRIx64 " failed to update db vg info, db:%s, dbId:%" PRId64, pRequest->requestId, output.db,
|
||||
output.dbId);
|
||||
}
|
||||
output.dbVgroup = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(output.dbVgroup);
|
||||
|
||||
tFreeSUsedbRsp(&usedbRsp);
|
||||
|
||||
char db[TSDB_DB_NAME_LEN] = {0};
|
||||
tNameGetDbName(&name, db);
|
||||
if(tNameGetDbName(&name, db) != TSDB_CODE_SUCCESS) {
|
||||
tscError("0x%" PRIx64 " failed to get db name since %s", pRequest->requestId, tstrerror(code));
|
||||
}
|
||||
|
||||
setConnectionDB(pRequest->pTscObj, db);
|
||||
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
|
||||
if (pRequest->body.queryFp != NULL) {
|
||||
doRequestCallback(pRequest, pRequest->code);
|
||||
} else {
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -353,7 +377,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
SMCreateStbRsp createRsp = {0};
|
||||
SDecoder coder = {0};
|
||||
tDecoderInit(&coder, pMsg->pData, pMsg->len);
|
||||
tDecodeSMCreateStbRsp(&coder, &createRsp);
|
||||
(void)tDecodeSMCreateStbRsp(&coder, &createRsp); // pMsg->len == 0
|
||||
tDecoderClear(&coder);
|
||||
|
||||
pRequest->body.resInfo.execRes.msgType = TDMT_MND_CREATE_STB;
|
||||
|
@ -380,7 +404,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -391,33 +415,41 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
setErrno(pRequest, code);
|
||||
} else {
|
||||
SDropDbRsp dropdbRsp = {0};
|
||||
tDeserializeSDropDbRsp(pMsg->pData, pMsg->len, &dropdbRsp);
|
||||
|
||||
if (tDeserializeSDropDbRsp(pMsg->pData, pMsg->len, &dropdbRsp) != 0){
|
||||
tscError("0x%" PRIx64 " deserialize SDropDbRsp failed", pRequest->requestId);
|
||||
}
|
||||
struct SCatalog* pCatalog = NULL;
|
||||
int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid);
|
||||
if (catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid) != 0){
|
||||
tscError("0x%" PRIx64 " failed to remove db:%s", pRequest->requestId, dropdbRsp.db);
|
||||
}
|
||||
STscObj* pTscObj = pRequest->pTscObj;
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB);
|
||||
catalogRefreshDBVgInfo(pCatalog, &conn, dbFName);
|
||||
snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB);
|
||||
catalogRefreshDBVgInfo(pCatalog, &conn, dbFName);
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB);
|
||||
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != TSDB_CODE_SUCCESS) {
|
||||
tscError("0x%" PRIx64 " failed to refresh db vg info, db:%s", pRequest->requestId, dbFName);
|
||||
}
|
||||
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB);
|
||||
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0) {
|
||||
tscError("0x%" PRIx64 " failed to refresh db vg info, db:%s", pRequest->requestId, dbFName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
END:
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
|
||||
if (pRequest->body.queryFp != NULL) {
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -430,7 +462,7 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
SMAlterStbRsp alterRsp = {0};
|
||||
SDecoder coder = {0};
|
||||
tDecoderInit(&coder, pMsg->pData, pMsg->len);
|
||||
tDecodeSMAlterStbRsp(&coder, &alterRsp);
|
||||
(void)tDecodeSMAlterStbRsp(&coder, &alterRsp); // pMsg->len = 0
|
||||
tDecoderClear(&coder);
|
||||
|
||||
pRequest->body.resInfo.execRes.msgType = TDMT_MND_ALTER_STB;
|
||||
|
@ -457,57 +489,72 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
|
||||
int32_t code = 0;
|
||||
int32_t line = 0;
|
||||
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||
TSDB_CHECK_NULL(pBlock, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
pBlock->info.hasVarCol = true;
|
||||
|
||||
pBlock->pDataBlock = taosArrayInit(SHOW_VARIABLES_RESULT_COLS, sizeof(SColumnInfoData));
|
||||
|
||||
TSDB_CHECK_NULL(pBlock->pDataBlock, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
SColumnInfoData infoData = {0};
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD1_LEN;
|
||||
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD2_LEN;
|
||||
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD3_LEN;
|
||||
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
||||
int32_t numOfCfg = taosArrayGetSize(pVars);
|
||||
blockDataEnsureCapacity(pBlock, numOfCfg);
|
||||
code = blockDataEnsureCapacity(pBlock, numOfCfg);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) {
|
||||
SVariablesInfo* pInfo = taosArrayGet(pVars, i);
|
||||
TSDB_CHECK_NULL(pInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
||||
char name[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(name, pInfo->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE);
|
||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||
colDataSetVal(pColInfo, i, name, false);
|
||||
TSDB_CHECK_NULL(pColInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
code = colDataSetVal(pColInfo, i, name, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(value, pInfo->value, TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||
colDataSetVal(pColInfo, i, value, false);
|
||||
TSDB_CHECK_NULL(pColInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
code = colDataSetVal(pColInfo, i, value, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
char scope[TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(scope, pInfo->scope, TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||
colDataSetVal(pColInfo, i, scope, false);
|
||||
TSDB_CHECK_NULL(pColInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
code = colDataSetVal(pColInfo, i, scope, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
}
|
||||
|
||||
pBlock->info.rows = numOfCfg;
|
||||
|
||||
*block = pBlock;
|
||||
return code;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
END:
|
||||
taosArrayDestroy(pBlock->pDataBlock);
|
||||
taosMemoryFree(pBlock);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
|
||||
|
@ -577,55 +624,72 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (pRequest->body.queryFp != NULL) {
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildCompactDbBlock(SCompactDbRsp* pRsp, SSDataBlock** block) {
|
||||
int32_t code = 0;
|
||||
int32_t line = 0;
|
||||
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||
TSDB_CHECK_NULL(pBlock, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
pBlock->info.hasVarCol = true;
|
||||
|
||||
pBlock->pDataBlock = taosArrayInit(COMPACT_DB_RESULT_COLS, sizeof(SColumnInfoData));
|
||||
|
||||
TSDB_CHECK_NULL(pBlock->pDataBlock, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
SColumnInfoData infoData = {0};
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = COMPACT_DB_RESULT_FIELD1_LEN;
|
||||
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
||||
infoData.info.type = TSDB_DATA_TYPE_INT;
|
||||
infoData.info.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes;
|
||||
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = COMPACT_DB_RESULT_FIELD3_LEN;
|
||||
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
||||
blockDataEnsureCapacity(pBlock, 1);
|
||||
code = blockDataEnsureCapacity(pBlock, 1);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
SColumnInfoData* pResultCol = taosArrayGet(pBlock->pDataBlock, 0);
|
||||
TSDB_CHECK_NULL(pResultCol, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
SColumnInfoData* pIdCol = taosArrayGet(pBlock->pDataBlock, 1);
|
||||
TSDB_CHECK_NULL(pIdCol, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
SColumnInfoData* pReasonCol = taosArrayGet(pBlock->pDataBlock, 2);
|
||||
TSDB_CHECK_NULL(pReasonCol, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
||||
char result[COMPACT_DB_RESULT_FIELD1_LEN] = {0};
|
||||
char reason[COMPACT_DB_RESULT_FIELD3_LEN] = {0};
|
||||
if (pRsp->bAccepted) {
|
||||
STR_TO_VARSTR(result, "accepted");
|
||||
colDataSetVal(pResultCol, 0, result, false);
|
||||
colDataSetVal(pIdCol, 0, (void*)&pRsp->compactId, false);
|
||||
code = colDataSetVal(pResultCol, 0, result, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
code = colDataSetVal(pIdCol, 0, (void*)&pRsp->compactId, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
STR_TO_VARSTR(reason, "success");
|
||||
colDataSetVal(pReasonCol, 0, reason, false);
|
||||
code = colDataSetVal(pReasonCol, 0, reason, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
} else {
|
||||
STR_TO_VARSTR(result, "rejected");
|
||||
colDataSetVal(pResultCol, 0, result, false);
|
||||
code = colDataSetVal(pResultCol, 0, result, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
colDataSetNULL(pIdCol, 0);
|
||||
STR_TO_VARSTR(reason, "compaction is ongoing");
|
||||
colDataSetVal(pReasonCol, 0, reason, false);
|
||||
code = colDataSetVal(pReasonCol, 0, reason, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
}
|
||||
pBlock->info.rows = 1;
|
||||
|
||||
*block = pBlock;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
END:
|
||||
taosMemoryFree(pBlock);
|
||||
taosArrayDestroy(pBlock->pDataBlock);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildRetriveTableRspForCompactDb(SCompactDbRsp* pCompactDb, SRetrieveTableRsp** pRsp) {
|
||||
|
@ -696,7 +760,7 @@ int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (pRequest->body.queryFp != NULL) {
|
||||
pRequest->body.queryFp(((SSyncQueryParam *)pRequest->body.interParam)->userParam, pRequest, code);
|
||||
} else {
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -484,7 +484,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
|||
|
||||
end:
|
||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tags", tags));
|
||||
(void)taosArrayDestroy(pTagVals);
|
||||
taosArrayDestroy(pTagVals);
|
||||
}
|
||||
|
||||
static void buildCreateCTableJson(SVCreateTbReq* pCreateReq, int32_t nReqs, cJSON** pJson) {
|
||||
|
@ -588,7 +588,7 @@ end:
|
|||
tDecoderClear(&decoder[i]);
|
||||
taosMemoryFreeClear(pCreateReq[i].comment);
|
||||
if (pCreateReq[i].type == TSDB_CHILD_TABLE) {
|
||||
(void)taosArrayDestroy(pCreateReq[i].ctb.tagName);
|
||||
taosArrayDestroy(pCreateReq[i].ctb.tagName);
|
||||
}
|
||||
}
|
||||
taosMemoryFree(decoder);
|
||||
|
@ -1097,7 +1097,7 @@ typedef struct SVgroupCreateTableBatch {
|
|||
|
||||
static void destroyCreateTbReqBatch(void* data) {
|
||||
SVgroupCreateTableBatch* pTbBatch = (SVgroupCreateTableBatch*)data;
|
||||
(void)taosArrayDestroy(pTbBatch->req.pArray);
|
||||
taosArrayDestroy(pTbBatch->req.pArray);
|
||||
}
|
||||
|
||||
static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||
|
@ -1214,12 +1214,14 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
SArray* pBufArray = NULL;
|
||||
RAW_RETURN_CHECK(serializeVgroupsCreateTableBatch(pVgroupHashmap, &pBufArray));
|
||||
pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
RAW_NULL_CHECK(pQuery);
|
||||
pQuery = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
if (TSDB_CODE_SUCCESS != code) goto end;
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->msgType = TDMT_VND_CREATE_TABLE;
|
||||
pQuery->stableQuery = false;
|
||||
pQuery->pRoot = nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT);
|
||||
code = nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT, &pQuery->pRoot);
|
||||
if (TSDB_CODE_SUCCESS != code) goto end;
|
||||
RAW_NULL_CHECK(pQuery->pRoot);
|
||||
|
||||
RAW_RETURN_CHECK(rewriteToVnodeModifyOpStmt(pQuery, pBufArray));
|
||||
|
@ -1250,7 +1252,7 @@ typedef struct SVgroupDropTableBatch {
|
|||
|
||||
static void destroyDropTbReqBatch(void* data) {
|
||||
SVgroupDropTableBatch* pTbBatch = (SVgroupDropTableBatch*)data;
|
||||
(void)taosArrayDestroy(pTbBatch->req.pArray);
|
||||
taosArrayDestroy(pTbBatch->req.pArray);
|
||||
}
|
||||
|
||||
static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||
|
@ -1343,13 +1345,14 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
SArray* pBufArray = NULL;
|
||||
RAW_RETURN_CHECK(serializeVgroupsDropTableBatch(pVgroupHashmap, &pBufArray));
|
||||
pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
RAW_NULL_CHECK(pQuery);
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
if (TSDB_CODE_SUCCESS != code) goto end;
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->msgType = TDMT_VND_DROP_TABLE;
|
||||
pQuery->stableQuery = false;
|
||||
pQuery->pRoot = nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT);
|
||||
RAW_NULL_CHECK(pQuery->pRoot);
|
||||
pQuery->pRoot = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT, &pQuery->pRoot);
|
||||
if (TSDB_CODE_SUCCESS != code) goto end;
|
||||
RAW_RETURN_CHECK(rewriteToVnodeModifyOpStmt(pQuery, pBufArray));
|
||||
|
||||
(void)launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
|
@ -1486,13 +1489,15 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
pVgData->numOfTables = 1;
|
||||
RAW_NULL_CHECK(taosArrayPush(pArray, &pVgData));
|
||||
|
||||
pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
RAW_NULL_CHECK(pQuery);
|
||||
pQuery = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
if (NULL == pQuery) goto end;
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->msgType = TDMT_VND_ALTER_TABLE;
|
||||
pQuery->stableQuery = false;
|
||||
pQuery->pRoot = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
RAW_NULL_CHECK(pQuery->pRoot);
|
||||
pQuery->pRoot = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT, &pQuery->pRoot);
|
||||
if (TSDB_CODE_SUCCESS != code) goto end;
|
||||
RAW_RETURN_CHECK(rewriteToVnodeModifyOpStmt(pQuery, pArray));
|
||||
|
||||
|
||||
|
@ -1513,7 +1518,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
end:
|
||||
uDebug(LOG_ID_TAG " alter table return, meta:%p, len:%d, msg:%s", LOG_ID_VALUE, meta, metaLen, tstrerror(code));
|
||||
(void)taosArrayDestroy(pArray);
|
||||
taosArrayDestroy(pArray);
|
||||
if (pVgData) taosMemoryFreeClear(pVgData->pData);
|
||||
taosMemoryFreeClear(pVgData);
|
||||
destroyRequest(pRequest);
|
||||
|
@ -1537,8 +1542,8 @@ int taos_write_raw_block_with_fields_with_reqid(TAOS* taos, int rows, char* pDat
|
|||
SQuery* pQuery = NULL;
|
||||
SHashObj* pVgHash = NULL;
|
||||
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, reqid);
|
||||
RAW_NULL_CHECK(pRequest);
|
||||
SRequestObj* pRequest = NULL;
|
||||
RAW_RETURN_CHECK(createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, reqid, &pRequest));
|
||||
|
||||
uDebug(LOG_ID_TAG " write raw block with field, rows:%d, pData:%p, tbname:%s, fields:%p, numFields:%d", LOG_ID_VALUE,
|
||||
rows, pData, tbname, fields, numFields);
|
||||
|
@ -1597,8 +1602,8 @@ int taos_write_raw_block_with_reqid(TAOS* taos, int rows, char* pData, const cha
|
|||
SQuery* pQuery = NULL;
|
||||
SHashObj* pVgHash = NULL;
|
||||
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, reqid);
|
||||
RAW_NULL_CHECK(pRequest);
|
||||
SRequestObj* pRequest = NULL;
|
||||
RAW_RETURN_CHECK(createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, reqid, &pRequest));
|
||||
|
||||
uDebug(LOG_ID_TAG " write raw block, rows:%d, pData:%p, tbname:%s", LOG_ID_VALUE, rows, pData, tbname);
|
||||
|
||||
|
@ -1667,8 +1672,8 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
SDecoder decoder = {0};
|
||||
STableMeta* pTableMeta = NULL;
|
||||
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
|
||||
RAW_NULL_CHECK(pRequest);
|
||||
SRequestObj* pRequest = NULL;
|
||||
RAW_RETURN_CHECK(createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0, &pRequest));
|
||||
|
||||
uDebug(LOG_ID_TAG " write raw data, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
||||
pRequest->syncQuery = true;
|
||||
|
@ -1778,8 +1783,8 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
STableMeta* pTableMeta = NULL;
|
||||
SVCreateTbReq* pCreateReqDst = NULL;
|
||||
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
|
||||
RAW_NULL_CHECK(pRequest);
|
||||
SRequestObj* pRequest = NULL;
|
||||
RAW_RETURN_CHECK(createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0, &pRequest));
|
||||
|
||||
uDebug(LOG_ID_TAG " write raw metadata, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
||||
pRequest->syncQuery = true;
|
||||
|
|
|
@ -197,8 +197,8 @@ static void smlDestroySTableMeta(void *para) {
|
|||
SSmlSTableMeta *meta = *(SSmlSTableMeta **)para;
|
||||
taosHashCleanup(meta->tagHash);
|
||||
taosHashCleanup(meta->colHash);
|
||||
(void)taosArrayDestroy(meta->tags);
|
||||
(void)taosArrayDestroy(meta->cols);
|
||||
taosArrayDestroy(meta->tags);
|
||||
taosArrayDestroy(meta->cols);
|
||||
taosMemoryFreeClear(meta->tableMeta);
|
||||
taosMemoryFree(meta);
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ int32_t smlSetCTableName(SSmlTableInfo *oneTable) {
|
|||
if (code != TSDB_CODE_SUCCESS){
|
||||
return code;
|
||||
}
|
||||
(void)taosArrayDestroy(dst);
|
||||
taosArrayDestroy(dst);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1198,25 +1198,25 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
SArray *pTags = taosArrayInit(taosArrayGetSize(sTableData->tags), sizeof(SField));
|
||||
if (pTags == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
goto end;
|
||||
}
|
||||
code = smlBuildFieldsList(info, NULL, NULL, sTableData->tags, pTags, 0, true);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag1 failed. %s", info->id, pName.tname);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
code = smlBuildFieldsList(info, NULL, NULL, sTableData->cols, pColumns, 0, false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList col1 failed. %s", info->id, pName.tname);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, NULL, SCHEMA_ACTION_CREATE_STABLE);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
|
@ -1271,7 +1271,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
SArray *pTags =
|
||||
taosArrayInit(taosArrayGetSize(sTableData->tags) + pTableMeta->tableInfo.numOfTags, sizeof(SField));
|
||||
if (pTags == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1282,15 +1282,15 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
tstrncpy(field.name, pTableMeta->schema[i].name, sizeof(field.name));
|
||||
if (i < pTableMeta->tableInfo.numOfColumns) {
|
||||
if (taosArrayPush(pColumns, &field) == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
if (taosArrayPush(pTags, &field) == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1300,28 +1300,28 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
pTableMeta->tableInfo.numOfColumns, true);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag2 failed. %s", info->id, pName.tname);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pTags) + pTableMeta->tableInfo.numOfColumns > TSDB_MAX_COLUMNS) {
|
||||
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
||||
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
if (taosArrayGetSize(pTags) > TSDB_MAX_TAGS) {
|
||||
uError("SML:0x%" PRIx64 " too many tags than 128", info->id);
|
||||
code = TSDB_CODE_PAR_INVALID_TAGS_NUM;
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
|
@ -1367,7 +1367,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
SArray *pTags =
|
||||
taosArrayInit(taosArrayGetSize(sTableData->tags) + pTableMeta->tableInfo.numOfTags, sizeof(SField));
|
||||
if (pTags == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1378,15 +1378,15 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
tstrncpy(field.name, pTableMeta->schema[i].name, sizeof(field.name));
|
||||
if (i < pTableMeta->tableInfo.numOfColumns) {
|
||||
if (taosArrayPush(pColumns, &field) == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
if (taosArrayPush(pTags, &field) == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1397,21 +1397,21 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
pTableMeta->tableInfo.numOfColumns, false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList col2 failed. %s", info->id, pName.tname);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pColumns) + pTableMeta->tableInfo.numOfTags > TSDB_MAX_COLUMNS) {
|
||||
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
||||
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
|
@ -1555,7 +1555,7 @@ void smlDestroyTableInfo(void *para) {
|
|||
taosHashCleanup(kvHash);
|
||||
}
|
||||
|
||||
(void)taosArrayDestroy(tag->cols);
|
||||
taosArrayDestroy(tag->cols);
|
||||
taosArrayDestroyEx(tag->tags, freeSSmlKv);
|
||||
taosMemoryFree(tag);
|
||||
}
|
||||
|
@ -1581,13 +1581,13 @@ void smlDestroyInfo(SSmlHandle *info) {
|
|||
cJSON *tags = (cJSON *)taosArrayGetP(info->tagJsonArray, i);
|
||||
cJSON_Delete(tags);
|
||||
}
|
||||
(void)taosArrayDestroy(info->tagJsonArray);
|
||||
taosArrayDestroy(info->tagJsonArray);
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(info->valueJsonArray); i++) {
|
||||
cJSON *value = (cJSON *)taosArrayGetP(info->valueJsonArray, i);
|
||||
cJSON_Delete(value);
|
||||
}
|
||||
(void)taosArrayDestroy(info->valueJsonArray);
|
||||
taosArrayDestroy(info->valueJsonArray);
|
||||
|
||||
taosArrayDestroyEx(info->preLineTagKV, freeSSmlKv);
|
||||
|
||||
|
@ -2137,8 +2137,8 @@ TAOS_RES *taos_schemaless_insert_inner(TAOS *taos, char *lines[], char *rawLine,
|
|||
SSmlHandle *info = NULL;
|
||||
int cnt = 0;
|
||||
while (1) {
|
||||
request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT, reqid);
|
||||
if (request == NULL) {
|
||||
code = createRequest(*(int64_t *)taos, TSDB_SQL_INSERT, reqid, &request);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
uError("SML:taos_schemaless_insert error request is null");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -14,15 +14,20 @@ static FORCE_INLINE int32_t stmtAllocQNodeFromBuf(STableBufInfo* pTblBuf, void**
|
|||
pTblBuf->buffOffset += pTblBuf->buffUnit;
|
||||
} else if (pTblBuf->buffIdx < taosArrayGetSize(pTblBuf->pBufList)) {
|
||||
pTblBuf->pCurBuff = taosArrayGetP(pTblBuf->pBufList, pTblBuf->buffIdx++);
|
||||
if (NULL == pTblBuf->pCurBuff) {
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
*pBuf = pTblBuf->pCurBuff;
|
||||
pTblBuf->buffOffset = pTblBuf->buffUnit;
|
||||
} else {
|
||||
void* buff = taosMemoryMalloc(pTblBuf->buffSize);
|
||||
if (NULL == buff) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
taosArrayPush(pTblBuf->pBufList, &buff);
|
||||
if(taosArrayPush(pTblBuf->pBufList, &buff) == NULL){
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pTblBuf->buffIdx++;
|
||||
pTblBuf->pCurBuff = buff;
|
||||
|
@ -48,7 +53,7 @@ bool stmtDequeue(STscStmt* pStmt, SStmtQNode** param) {
|
|||
|
||||
*param = node;
|
||||
|
||||
atomic_sub_fetch_64(&pStmt->queue.qRemainNum, 1);
|
||||
(void)atomic_sub_fetch_64(&pStmt->queue.qRemainNum, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -58,7 +63,7 @@ void stmtEnqueue(STscStmt* pStmt, SStmtQNode* param) {
|
|||
pStmt->queue.tail = param;
|
||||
|
||||
pStmt->stat.bindDataNum++;
|
||||
atomic_add_fetch_64(&pStmt->queue.qRemainNum, 1);
|
||||
(void)atomic_add_fetch_64(&pStmt->queue.qRemainNum, 1);
|
||||
}
|
||||
|
||||
static int32_t stmtCreateRequest(STscStmt* pStmt) {
|
||||
|
@ -183,8 +188,8 @@ int32_t stmtBackupQueryFields(STscStmt* pStmt) {
|
|||
if (NULL == pRes->fields || NULL == pRes->userFields) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
|
||||
memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
|
||||
(void)memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
|
||||
(void)memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -201,7 +206,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
|||
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size);
|
||||
(void)memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size);
|
||||
}
|
||||
|
||||
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||
|
@ -209,7 +214,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
|||
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size);
|
||||
(void)memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -219,10 +224,13 @@ int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags,
|
|||
bool autoCreateTbl) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(tbName, tbFName);
|
||||
int32_t code = tNameExtractFullName(tbName, tbFName);
|
||||
if (code != 0){
|
||||
return code;
|
||||
}
|
||||
|
||||
memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName));
|
||||
strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1);
|
||||
(void)memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName));
|
||||
(void)strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1);
|
||||
pStmt->bInfo.tbFName[sizeof(pStmt->bInfo.tbFName) - 1] = 0;
|
||||
|
||||
pStmt->bInfo.tbUid = autoCreateTbl ? 0 : pTableMeta->uid;
|
||||
|
@ -383,17 +391,21 @@ int32_t stmtCleanBindInfo(STscStmt* pStmt) {
|
|||
taosMemoryFreeClear(pStmt->bInfo.boundTags);
|
||||
}
|
||||
pStmt->bInfo.stbFName[0] = 0;
|
||||
;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void stmtFreeTableBlkList(STableColsData* pTb) {
|
||||
qResetStmtColumns(pTb->aCol, true);
|
||||
(void)qResetStmtColumns(pTb->aCol, true);
|
||||
taosArrayDestroy(pTb->aCol);
|
||||
}
|
||||
|
||||
void stmtResetQueueTableBuf(STableBufInfo* pTblBuf, SStmtQueue* pQueue) {
|
||||
pTblBuf->pCurBuff = taosArrayGetP(pTblBuf->pBufList, 0);
|
||||
if (NULL == pTblBuf->pCurBuff) {
|
||||
tscError("QInfo:%p, failed to get buffer from list", pTblBuf);
|
||||
return;
|
||||
}
|
||||
pTblBuf->buffIdx = 1;
|
||||
pTblBuf->buffOffset = sizeof(*pQueue->head);
|
||||
|
||||
|
@ -438,7 +450,7 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool deepClean) {
|
|||
}
|
||||
|
||||
qDestroyStmtDataBlock(pBlocks);
|
||||
taosHashRemove(pStmt->exec.pBlockHash, key, keyLen);
|
||||
STMT_ERR_RET(taosHashRemove(pStmt->exec.pBlockHash, key, keyLen));
|
||||
|
||||
pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
|
||||
}
|
||||
|
@ -505,7 +517,7 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
|
|||
qDestroyStmtDataBlock(pStmt->sql.siInfo.pDataCtx);
|
||||
taosArrayDestroyEx(pStmt->sql.siInfo.pTableCols, stmtFreeTbCols);
|
||||
|
||||
memset(&pStmt->sql, 0, sizeof(pStmt->sql));
|
||||
(void)memset(&pStmt->sql, 0, sizeof(pStmt->sql));
|
||||
pStmt->sql.siInfo.tableColsReady = true;
|
||||
|
||||
STMT_DLOG_E("end to free SQL info");
|
||||
|
@ -628,7 +640,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
|
|||
|
||||
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
|
||||
tscDebug("tb %s not exist", pStmt->bInfo.tbFName);
|
||||
stmtCleanBindInfo(pStmt);
|
||||
STMT_ERR_RET(stmtCleanBindInfo(pStmt));
|
||||
|
||||
STMT_ERR_RET(code);
|
||||
}
|
||||
|
@ -726,6 +738,9 @@ int32_t stmtAsyncOutput(STscStmt* pStmt, void* param) {
|
|||
for (int32_t i = 0; i < pStmt->sql.siInfo.pTableColsIdx; ++i) {
|
||||
SArray** p = (SArray**)TARRAY_GET_ELEM(pStmt->sql.siInfo.pTableCols, i);
|
||||
*p = taosArrayInit(20, POINTER_BYTES);
|
||||
if (*p == NULL) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
atomic_store_8((int8_t*)&pStmt->sql.siInfo.tableColsReady, true);
|
||||
|
@ -735,7 +750,7 @@ int32_t stmtAsyncOutput(STscStmt* pStmt, void* param) {
|
|||
|
||||
// taosMemoryFree(pParam->pTbData);
|
||||
|
||||
atomic_sub_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1);
|
||||
(void)atomic_sub_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -757,7 +772,7 @@ void* stmtBindThreadFunc(void* param) {
|
|||
continue;
|
||||
}
|
||||
|
||||
stmtAsyncOutput(pStmt, asyncParam);
|
||||
(void)stmtAsyncOutput(pStmt, asyncParam);
|
||||
}
|
||||
|
||||
qInfo("stmt bind thread stopped");
|
||||
|
@ -767,8 +782,12 @@ void* stmtBindThreadFunc(void* param) {
|
|||
|
||||
int32_t stmtStartBindThread(STscStmt* pStmt) {
|
||||
TdThreadAttr thAttr;
|
||||
taosThreadAttrInit(&thAttr);
|
||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
if (taosThreadAttrInit(&thAttr) != 0) {
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
if (taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE) != 0) {
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (taosThreadCreate(&pStmt->bindThread, &thAttr, stmtBindThreadFunc, pStmt) != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -777,7 +796,7 @@ int32_t stmtStartBindThread(STscStmt* pStmt) {
|
|||
|
||||
pStmt->bindThreadInUse = true;
|
||||
|
||||
taosThreadAttrDestroy(&thAttr);
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -800,7 +819,9 @@ int32_t stmtInitTableBuf(STableBufInfo* pTblBuf) {
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
taosArrayPush(pTblBuf->pBufList, &buff);
|
||||
if (taosArrayPush(pTblBuf->pBufList, &buff) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pTblBuf->pCurBuff = buff;
|
||||
pTblBuf->buffIdx = 1;
|
||||
|
@ -834,7 +855,7 @@ TAOS_STMT* stmtInit(STscObj* taos, int64_t reqid, TAOS_STMT_OPTIONS* pOptions) {
|
|||
pStmt->errCode = TSDB_CODE_SUCCESS;
|
||||
|
||||
if (NULL != pOptions) {
|
||||
memcpy(&pStmt->options, pOptions, sizeof(pStmt->options));
|
||||
(void)memcpy(&pStmt->options, pOptions, sizeof(pStmt->options));
|
||||
if (pOptions->singleStbInsert && pOptions->singleTableBindOnce) {
|
||||
pStmt->stbInterlaceMode = true;
|
||||
}
|
||||
|
@ -848,24 +869,26 @@ TAOS_STMT* stmtInit(STscObj* taos, int64_t reqid, TAOS_STMT_OPTIONS* pOptions) {
|
|||
pStmt->sql.siInfo.pTableHash = tSimpleHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY));
|
||||
if (NULL == pStmt->sql.siInfo.pTableHash) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
stmtClose(pStmt);
|
||||
(void)stmtClose(pStmt);
|
||||
return NULL;
|
||||
}
|
||||
pStmt->sql.siInfo.pTableCols = taosArrayInit(STMT_TABLE_COLS_NUM, POINTER_BYTES);
|
||||
if (NULL == pStmt->sql.siInfo.pTableCols) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
stmtClose(pStmt);
|
||||
(void)stmtClose(pStmt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
code = stmtInitTableBuf(&pStmt->sql.siInfo.tbBuf);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
stmtInitQueue(pStmt);
|
||||
code = stmtInitQueue(pStmt);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = stmtStartBindThread(pStmt);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
terrno = code;
|
||||
stmtClose(pStmt);
|
||||
(void)stmtClose(pStmt);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -904,7 +927,7 @@ int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
|
|||
|
||||
char* dbName = NULL;
|
||||
if (qParseDbName(sql, length, &dbName)) {
|
||||
stmtSetDbName(stmt, dbName);
|
||||
STMT_ERR_RET(stmtSetDbName(stmt, dbName));
|
||||
taosMemoryFreeClear(dbName);
|
||||
}
|
||||
|
||||
|
@ -928,7 +951,9 @@ int32_t stmtInitStbInterlaceTableInfo(STscStmt* pStmt) {
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols);
|
||||
if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
pStmt->sql.siInfo.boundTags = pStmt->bInfo.boundTags;
|
||||
|
@ -966,7 +991,7 @@ int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
|
|||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTBNAME));
|
||||
|
||||
int32_t insert = 0;
|
||||
stmtIsInsert(stmt, &insert);
|
||||
STMT_ERR_RET(stmtIsInsert(stmt, &insert));
|
||||
if (0 == insert) {
|
||||
tscError("set tb name not available for none insert statement");
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||
|
@ -977,18 +1002,18 @@ int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
|
|||
|
||||
STMT_ERR_RET(qCreateSName(&pStmt->bInfo.sname, tbName, pStmt->taos->acctId, pStmt->exec.pRequest->pDb,
|
||||
pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen));
|
||||
tNameExtractFullName(&pStmt->bInfo.sname, pStmt->bInfo.tbFName);
|
||||
STMT_ERR_RET(tNameExtractFullName(&pStmt->bInfo.sname, pStmt->bInfo.tbFName));
|
||||
|
||||
STMT_ERR_RET(stmtGetFromCache(pStmt));
|
||||
|
||||
if (pStmt->bInfo.needParse) {
|
||||
strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
||||
(void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
||||
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
||||
|
||||
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||
}
|
||||
} else {
|
||||
strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
||||
(void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
||||
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
||||
pStmt->exec.pRequest->requestId++;
|
||||
pStmt->bInfo.needParse = false;
|
||||
|
@ -1136,13 +1161,13 @@ int32_t stmtAppendTablePostHandle(STscStmt* pStmt, SStmtQNode* param) {
|
|||
}
|
||||
|
||||
if (0 == pStmt->sql.siInfo.firstName[0]) {
|
||||
strcpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName);
|
||||
(void)strcpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName);
|
||||
}
|
||||
|
||||
param->tblData.getFromHash = pStmt->sql.siInfo.tbFromHash;
|
||||
param->next = NULL;
|
||||
|
||||
atomic_add_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1);
|
||||
(void)atomic_add_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1);
|
||||
|
||||
stmtEnqueue(pStmt, param);
|
||||
|
||||
|
@ -1162,7 +1187,9 @@ static FORCE_INLINE int32_t stmtGetTableColsFromCache(STscStmt* pStmt, SArray**
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols);
|
||||
if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1221,8 +1248,8 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
|||
STMT_ERR_RET(qStmtParseQuerySql(&ctx, pStmt->sql.pQuery));
|
||||
|
||||
if (pStmt->sql.pQuery->haveResultSet) {
|
||||
setResSchemaInfo(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->pResSchema,
|
||||
pStmt->sql.pQuery->numOfResCols);
|
||||
STMT_ERR_RET(setResSchemaInfo(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->pResSchema,
|
||||
pStmt->sql.pQuery->numOfResCols));
|
||||
taosMemoryFreeClear(pStmt->sql.pQuery->pResSchema);
|
||||
setResPrecision(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->precision);
|
||||
}
|
||||
|
@ -1274,7 +1301,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
|||
// param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
|
||||
|
||||
param->restoreTbCols = false;
|
||||
strcpy(param->tblData.tbName, pStmt->bInfo.tbName);
|
||||
(void)strcpy(param->tblData.tbName, pStmt->bInfo.tbName);
|
||||
}
|
||||
|
||||
int64_t startUs3 = taosGetTimestampUs();
|
||||
|
@ -1428,7 +1455,7 @@ int stmtUpdateTableUid(STscStmt* pStmt, SSubmitRsp* pRsp) {
|
|||
.requestId = pStmt->exec.pRequest->requestId,
|
||||
.requestObjRefId = pStmt->exec.pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp)};
|
||||
int32_t code = catalogGetTableMeta(pStmt->pCatalog, &conn, &pStmt->bInfo.sname, &pTableMeta);
|
||||
code = catalogGetTableMeta(pStmt->pCatalog, &conn, &pStmt->bInfo.sname, &pTableMeta);
|
||||
|
||||
pStmt->stat.ctgGetTbMetaNum++;
|
||||
|
||||
|
@ -1515,7 +1542,7 @@ int stmtExec(TAOS_STMT* stmt) {
|
|||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
|
||||
|
||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||
launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL);
|
||||
(void)launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL);
|
||||
} else {
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
int64_t startTs = taosGetTimestampUs();
|
||||
|
@ -1537,7 +1564,7 @@ int stmtExec(TAOS_STMT* stmt) {
|
|||
STMT_ERR_RET(qBuildStmtOutput(pStmt->sql.pQuery, pStmt->sql.pVgHash, pStmt->exec.pBlockHash));
|
||||
}
|
||||
|
||||
launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL);
|
||||
(void)launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL);
|
||||
}
|
||||
|
||||
if (pStmt->exec.pRequest->code && NEED_CLIENT_HANDLE_ERROR(pStmt->exec.pRequest->code)) {
|
||||
|
@ -1562,7 +1589,7 @@ _return:
|
|||
taosUsleep(1);
|
||||
}
|
||||
|
||||
stmtCleanExecInfo(pStmt, (code ? false : true), false);
|
||||
STMT_ERR_RET(stmtCleanExecInfo(pStmt, (code ? false : true), false));
|
||||
|
||||
tFreeSSubmitRsp(pRsp);
|
||||
|
||||
|
@ -1582,7 +1609,7 @@ int stmtClose(TAOS_STMT* stmt) {
|
|||
pStmt->queue.stopQueue = true;
|
||||
|
||||
if (pStmt->bindThreadInUse) {
|
||||
taosThreadJoin(pStmt->bindThread, NULL);
|
||||
(void)taosThreadJoin(pStmt->bindThread, NULL);
|
||||
pStmt->bindThreadInUse = false;
|
||||
}
|
||||
|
||||
|
@ -1597,7 +1624,7 @@ int stmtClose(TAOS_STMT* stmt) {
|
|||
pStmt->stat.bindDataUs1, pStmt->stat.bindDataUs2, pStmt->stat.bindDataUs3, pStmt->stat.bindDataUs4,
|
||||
pStmt->stat.addBatchUs, pStmt->stat.execWaitUs, pStmt->stat.execUseUs);
|
||||
|
||||
stmtCleanSQLInfo(pStmt);
|
||||
STMT_ERR_RET(stmtCleanSQLInfo(pStmt));
|
||||
taosMemoryFree(stmt);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -41,7 +41,7 @@ void tmqGlobalMethod(JNIEnv *env) {
|
|||
}
|
||||
|
||||
if (g_vm == NULL) {
|
||||
(*env)->GetJavaVM(env, &g_vm);
|
||||
(void)((*env)->GetJavaVM(env, &g_vm));
|
||||
}
|
||||
|
||||
jclass offset = (*env)->FindClass(env, "com/taosdata/jdbc/tmq/OffsetWaitCallback");
|
||||
|
@ -68,7 +68,7 @@ void tmqAssignmentMethod(JNIEnv *env) {
|
|||
}
|
||||
|
||||
if (g_vm == NULL) {
|
||||
(*env)->GetJavaVM(env, &g_vm);
|
||||
(void)((*env)->GetJavaVM(env, &g_vm));
|
||||
}
|
||||
|
||||
jclass assignment = (*env)->FindClass(env, "com/taosdata/jdbc/tmq/Assignment");
|
||||
|
@ -104,7 +104,7 @@ void commit_cb(tmq_t *tmq, int32_t code, void *param) {
|
|||
param = NULL;
|
||||
|
||||
if (needDetach) {
|
||||
(*g_vm)->DetachCurrentThread(g_vm);
|
||||
(void)((*g_vm)->DetachCurrentThread(g_vm));
|
||||
}
|
||||
env = NULL;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ void consumer_callback(tmq_t *tmq, int32_t code, void *param) {
|
|||
param = NULL;
|
||||
|
||||
if (needDetach) {
|
||||
(*g_vm)->DetachCurrentThread(g_vm);
|
||||
(void)((*g_vm)->DetachCurrentThread(g_vm));
|
||||
}
|
||||
env = NULL;
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_fetchRawBlockImp(
|
|||
(*env)->SetIntField(env, metadataObj, g_metadataColindexField, i);
|
||||
jstring metadataObjColname = (*env)->NewStringUTF(env, fields[i].name);
|
||||
(*env)->SetObjectField(env, metadataObj, g_metadataColnameField, metadataObjColname);
|
||||
(*env)->CallBooleanMethod(env, arrayListObj, g_arrayListAddFp, metadataObj);
|
||||
(void)(*env)->CallBooleanMethod(env, arrayListObj, g_arrayListAddFp, metadataObj);
|
||||
}
|
||||
|
||||
(*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfRowsFp, (jint)numOfRows);
|
||||
|
@ -567,7 +567,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqGetTopicAssign
|
|||
(*env)->CallVoidMethod(env, jassignment, g_assignmentSetCurrentOffset, assignment.currentOffset);
|
||||
(*env)->CallVoidMethod(env, jassignment, g_assignmentSetBegin, assignment.begin);
|
||||
(*env)->CallVoidMethod(env, jassignment, g_assignmentSetEnd, assignment.end);
|
||||
(*env)->CallBooleanMethod(env, jarrayList, g_arrayListAddFp, jassignment);
|
||||
(void)(*env)->CallBooleanMethod(env, jarrayList, g_arrayListAddFp, jassignment);
|
||||
}
|
||||
tmq_free_assignment(pAssign);
|
||||
return JNI_SUCCESS;
|
||||
|
|
|
@ -86,7 +86,7 @@ static char* readFile(TdFilePtr pFile, int64_t *offset, int64_t size){
|
|||
return NULL;
|
||||
}
|
||||
char* buf = pCont;
|
||||
strcat(buf++, "[");
|
||||
(void)strcat(buf++, "[");
|
||||
int64_t readSize = taosReadFile(pFile, buf, SLOW_LOG_SEND_SIZE_MAX);
|
||||
if (readSize <= 0) {
|
||||
if (readSize < 0){
|
||||
|
@ -153,7 +153,7 @@ TEST(clientMonitorTest, ReadOneFile) {
|
|||
const int size = 10;
|
||||
for(int i = 0; i < batch; i++){
|
||||
char value[size] = {0};
|
||||
memset(value, '0' + i, size - 1);
|
||||
(void)memset(value, '0' + i, size - 1);
|
||||
if (taosWriteFile(pFile, value, strlen(value) + 1) < 0){
|
||||
uError("failed to write len to file:%p since %s", pFile, terrstr());
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -65,7 +65,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
|
||||
ASSERT_EQ(elements.timestamp, sql + elements.measureTagsLen + 1 + elements.colsLen + 1);
|
||||
ASSERT_EQ(elements.timestampLen, strlen("1626006833639000000"));
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
// case 2 false
|
||||
|
@ -74,7 +74,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||
ASSERT_NE(ret, 0);
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
// case 4 tag is null
|
||||
|
@ -95,7 +95,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
|
||||
ASSERT_EQ(elements.timestamp, sql + elements.measureTagsLen + 1 + elements.colsLen + 1);
|
||||
ASSERT_EQ(elements.timestampLen, strlen("1626006833639000000"));
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
// case 5 tag is null
|
||||
|
@ -115,7 +115,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
|
||||
ASSERT_EQ(elements.timestamp, sql + 1 + elements.measureTagsLen + 3 + elements.colsLen + 2);
|
||||
ASSERT_EQ(elements.timestampLen, strlen("1626006833639000000"));
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
// case 6
|
||||
|
@ -124,7 +124,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||
ASSERT_EQ(ret, 0);
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
ASSERT_EQ(smlClearForRerun(info), 0);
|
||||
|
||||
|
@ -134,7 +134,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||
ASSERT_NE(ret, 0);
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
// case 8 false
|
||||
|
@ -143,7 +143,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||
ASSERT_NE(ret, 0);
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
taosMemoryFree(sql);
|
||||
|
@ -250,7 +250,7 @@ TEST(testCase, smlParseCols_Error_Test) {
|
|||
// printf("i:%d\n", i);
|
||||
ASSERT_NE(ret, TSDB_CODE_SUCCESS);
|
||||
taosMemoryFree(sql);
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
}
|
||||
smlDestroyInfo(info);
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ TEST(testCase, smlParseCols_Test) {
|
|||
ASSERT_EQ(kv->length, 4);
|
||||
ASSERT_EQ(strncasecmp(kv->value, "iuwq", 4), 0);
|
||||
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
taosMemoryFree(sql);
|
||||
smlDestroyInfo(info);
|
||||
}
|
||||
|
|
|
@ -65,13 +65,13 @@ int32_t s3CheckCfg() {
|
|||
int32_t code = 0, lino = 0;
|
||||
|
||||
if (!tsS3Enabled) {
|
||||
fprintf(stderr, "s3 not configured.\n");
|
||||
(void)fprintf(stderr, "s3 not configured.\n");
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
code = s3Begin();
|
||||
if (code != 0) {
|
||||
fprintf(stderr, "failed to initialize s3.\n");
|
||||
(void)fprintf(stderr, "failed to initialize s3.\n");
|
||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||
}
|
||||
|
||||
|
@ -82,72 +82,72 @@ int32_t s3CheckCfg() {
|
|||
int ds_len = strlen(TD_DIRSEP);
|
||||
int tmp_len = strlen(tsTempDir);
|
||||
|
||||
snprintf(path, PATH_MAX, "%s", tsTempDir);
|
||||
(void)snprintf(path, PATH_MAX, "%s", tsTempDir);
|
||||
if (strncmp(tsTempDir + tmp_len - ds_len, TD_DIRSEP, ds_len) != 0) {
|
||||
snprintf(path + tmp_len, PATH_MAX - tmp_len, "%s", TD_DIRSEP);
|
||||
snprintf(path + tmp_len + ds_len, PATH_MAX - tmp_len - ds_len, "%s", objectname[0]);
|
||||
(void)snprintf(path + tmp_len, PATH_MAX - tmp_len, "%s", TD_DIRSEP);
|
||||
(void)snprintf(path + tmp_len + ds_len, PATH_MAX - tmp_len - ds_len, "%s", objectname[0]);
|
||||
} else {
|
||||
snprintf(path + tmp_len, PATH_MAX - tmp_len, "%s", objectname[0]);
|
||||
(void)snprintf(path + tmp_len, PATH_MAX - tmp_len, "%s", objectname[0]);
|
||||
}
|
||||
|
||||
TdFilePtr fp = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC);
|
||||
if (!fp) {
|
||||
fprintf(stderr, "failed to open test file: %s.\n", path);
|
||||
(void)fprintf(stderr, "failed to open test file: %s.\n", path);
|
||||
// uError("ERROR: %s Failed to open %s", __func__, path);
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
}
|
||||
if (taosWriteFile(fp, testdata, strlen(testdata)) < 0) {
|
||||
fprintf(stderr, "failed to write test file: %s.\n", path);
|
||||
(void)fprintf(stderr, "failed to write test file: %s.\n", path);
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
}
|
||||
if (taosFsyncFile(fp) < 0) {
|
||||
fprintf(stderr, "failed to fsync test file: %s.\n", path);
|
||||
(void)fprintf(stderr, "failed to fsync test file: %s.\n", path);
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
}
|
||||
taosCloseFile(&fp);
|
||||
(void)taosCloseFile(&fp);
|
||||
|
||||
fprintf(stderr, "\nstart to put object: %s, file: %s content: %s\n", objectname[0], path, testdata);
|
||||
(void)fprintf(stderr, "\nstart to put object: %s, file: %s content: %s\n", objectname[0], path, testdata);
|
||||
code = s3PutObjectFromFileOffset(path, objectname[0], 0, 16);
|
||||
if (code != 0) {
|
||||
fprintf(stderr, "put object %s : failed.\n", objectname[0]);
|
||||
(void)fprintf(stderr, "put object %s : failed.\n", objectname[0]);
|
||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||
}
|
||||
fprintf(stderr, "put object %s: success.\n\n", objectname[0]);
|
||||
(void)fprintf(stderr, "put object %s: success.\n\n", objectname[0]);
|
||||
|
||||
// list buckets
|
||||
fprintf(stderr, "start to list bucket %s by prefix s3.\n", tsS3BucketName);
|
||||
(void)fprintf(stderr, "start to list bucket %s by prefix s3.\n", tsS3BucketName);
|
||||
code = s3ListBucket(tsS3BucketName);
|
||||
if (code != 0) {
|
||||
fprintf(stderr, "listing bucket %s : failed.\n", tsS3BucketName);
|
||||
(void)fprintf(stderr, "listing bucket %s : failed.\n", tsS3BucketName);
|
||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||
}
|
||||
fprintf(stderr, "listing bucket %s: success.\n\n", tsS3BucketName);
|
||||
(void)fprintf(stderr, "listing bucket %s: success.\n\n", tsS3BucketName);
|
||||
|
||||
// test range get
|
||||
uint8_t *pBlock = NULL;
|
||||
int c_offset = 10;
|
||||
int c_len = 6;
|
||||
|
||||
fprintf(stderr, "start to range get object %s offset: %d len: %d.\n", objectname[0], c_offset, c_len);
|
||||
(void)fprintf(stderr, "start to range get object %s offset: %d len: %d.\n", objectname[0], c_offset, c_len);
|
||||
code = s3GetObjectBlock(objectname[0], c_offset, c_len, true, &pBlock);
|
||||
if (code != 0) {
|
||||
fprintf(stderr, "get object %s : failed.\n", objectname[0]);
|
||||
(void)fprintf(stderr, "get object %s : failed.\n", objectname[0]);
|
||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||
}
|
||||
char buf[7] = {0};
|
||||
memcpy(buf, pBlock, c_len);
|
||||
(void)memcpy(buf, pBlock, c_len);
|
||||
taosMemoryFree(pBlock);
|
||||
fprintf(stderr, "object content: %s\n", buf);
|
||||
fprintf(stderr, "get object %s: success.\n\n", objectname[0]);
|
||||
(void)fprintf(stderr, "object content: %s\n", buf);
|
||||
(void)fprintf(stderr, "get object %s: success.\n\n", objectname[0]);
|
||||
|
||||
// delete test object
|
||||
fprintf(stderr, "start to delete object: %s.\n", objectname[0]);
|
||||
(void)fprintf(stderr, "start to delete object: %s.\n", objectname[0]);
|
||||
code = s3DeleteObjects(objectname, 1);
|
||||
if (code != 0) {
|
||||
fprintf(stderr, "delete object %s : failed.\n", objectname[0]);
|
||||
(void)fprintf(stderr, "delete object %s : failed.\n", objectname[0]);
|
||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||
}
|
||||
fprintf(stderr, "delete object %s: success.\n\n", objectname[0]);
|
||||
(void)fprintf(stderr, "delete object %s: success.\n\n", objectname[0]);
|
||||
|
||||
s3End();
|
||||
|
||||
|
@ -252,9 +252,9 @@ static int32_t s3ListBucket(char const *bucketname) {
|
|||
const char **object_name = TARRAY_DATA(objectArray);
|
||||
int size = TARRAY_SIZE(objectArray);
|
||||
|
||||
fprintf(stderr, "objects:\n");
|
||||
(void)fprintf(stderr, "objects:\n");
|
||||
for (int i = 0; i < size; ++i) {
|
||||
fprintf(stderr, "%s\n", object_name[i]);
|
||||
(void)fprintf(stderr, "%s\n", object_name[i]);
|
||||
}
|
||||
|
||||
taosArrayDestroyEx(objectArray, s3FreeObjectKey);
|
||||
|
@ -300,7 +300,7 @@ static int growbuffer_append(growbuffer **gb, const char *data, int dataLen) {
|
|||
toCopy = dataLen;
|
||||
}
|
||||
|
||||
memcpy(&(buf->data[buf->size]), data, toCopy);
|
||||
(void)memcpy(&(buf->data[buf->size]), data, toCopy);
|
||||
|
||||
buf->size += toCopy, data += toCopy, dataLen -= toCopy;
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ static void growbuffer_read(growbuffer **gb, int amt, int *amtReturn, char *buff
|
|||
|
||||
*amtReturn = (buf->size > amt) ? amt : buf->size;
|
||||
|
||||
memcpy(buffer, &(buf->data[buf->start]), *amtReturn);
|
||||
(void)memcpy(buffer, &(buf->data[buf->start]), *amtReturn);
|
||||
|
||||
buf->start += *amtReturn, buf->size -= *amtReturn;
|
||||
|
||||
|
@ -440,7 +440,7 @@ S3Status initial_multipart_callback(const char *upload_id, void *callbackData) {
|
|||
}
|
||||
|
||||
S3Status MultipartResponseProperiesCallback(const S3ResponseProperties *properties, void *callbackData) {
|
||||
responsePropertiesCallbackNull(properties, callbackData);
|
||||
(void)responsePropertiesCallbackNull(properties, callbackData);
|
||||
|
||||
MultipartPartData *data = (MultipartPartData *)callbackData;
|
||||
int seq = data->seq;
|
||||
|
@ -451,7 +451,7 @@ S3Status MultipartResponseProperiesCallback(const S3ResponseProperties *properti
|
|||
}
|
||||
|
||||
S3Status MultipartResponseProperiesCallbackWithCp(const S3ResponseProperties *properties, void *callbackData) {
|
||||
responsePropertiesCallbackNull(properties, callbackData);
|
||||
(void)responsePropertiesCallbackNull(properties, callbackData);
|
||||
|
||||
MultipartPartData *data = (MultipartPartData *)callbackData;
|
||||
int seq = data->seq;
|
||||
|
@ -624,7 +624,7 @@ static int32_t s3PutObjectFromFileWithoutCp(S3BucketContext *bucket_context, cha
|
|||
}
|
||||
|
||||
MultipartPartData partData;
|
||||
memset(&partData, 0, sizeof(MultipartPartData));
|
||||
(void)memset(&partData, 0, sizeof(MultipartPartData));
|
||||
int partContentLength = 0;
|
||||
|
||||
S3MultipartInitialHandler handler = {{&responsePropertiesCallbackNull, &responseCompleteCallback},
|
||||
|
@ -739,7 +739,7 @@ static int32_t s3PutObjectFromFileWithCp(S3BucketContext *bucket_context, const
|
|||
|
||||
bool need_init_upload = true;
|
||||
char file_cp_path[TSDB_FILENAME_LEN];
|
||||
snprintf(file_cp_path, TSDB_FILENAME_LEN, "%s.cp", file);
|
||||
(void)snprintf(file_cp_path, TSDB_FILENAME_LEN, "%s.cp", file);
|
||||
|
||||
SCheckpoint cp = {0};
|
||||
cp.parts = taosMemoryCalloc(max_part_num, sizeof(SCheckpointPart));
|
||||
|
@ -781,7 +781,7 @@ static int32_t s3PutObjectFromFileWithCp(S3BucketContext *bucket_context, const
|
|||
// cos_cp_get_undo_parts(&cp, &part_num, parts, &consume_bytes);
|
||||
|
||||
MultipartPartData partData;
|
||||
memset(&partData, 0, sizeof(MultipartPartData));
|
||||
(void)memset(&partData, 0, sizeof(MultipartPartData));
|
||||
int partContentLength = 0;
|
||||
|
||||
S3PutObjectHandler putObjectHandler = {{&MultipartResponseProperiesCallbackWithCp, &responseCompleteCallback},
|
||||
|
@ -920,7 +920,7 @@ int32_t s3PutObjectFromFile2(const char *file, const char *object_name, int8_t w
|
|||
char useServerSideEncryption = 0;
|
||||
put_object_callback_data data = {0};
|
||||
|
||||
if (taosStatFile(file, &contentLength, &lmtime, NULL) < 0) {
|
||||
if (taosStatFile(file, (int64_t *)&contentLength, &lmtime, NULL) < 0) {
|
||||
uError("ERROR: %s Failed to stat file %s: ", __func__, file);
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
|
@ -953,7 +953,7 @@ int32_t s3PutObjectFromFile2(const char *file, const char *object_name, int8_t w
|
|||
}
|
||||
|
||||
if (data.infileFD) {
|
||||
taosCloseFile(&data.infileFD);
|
||||
(void)taosCloseFile(&data.infileFD);
|
||||
} else if (data.gb) {
|
||||
growbuffer_destroy(data.gb);
|
||||
}
|
||||
|
@ -975,7 +975,7 @@ int32_t s3PutObjectFromFileOffset(const char *file, const char *object_name, int
|
|||
char useServerSideEncryption = 0;
|
||||
put_object_callback_data data = {0};
|
||||
|
||||
if (taosStatFile(file, &contentLength, &lmtime, NULL) < 0) {
|
||||
if (taosStatFile(file, (int64_t *)&contentLength, &lmtime, NULL) < 0) {
|
||||
uError("ERROR: %s Failed to stat file %s: ", __func__, file);
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
|
@ -987,7 +987,7 @@ int32_t s3PutObjectFromFileOffset(const char *file, const char *object_name, int
|
|||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
if (taosLSeekFile(data.infileFD, offset, SEEK_SET) < 0) {
|
||||
taosCloseFile(&data.infileFD);
|
||||
(void)taosCloseFile(&data.infileFD);
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
|
||||
|
@ -1010,7 +1010,7 @@ int32_t s3PutObjectFromFileOffset(const char *file, const char *object_name, int
|
|||
}
|
||||
|
||||
if (data.infileFD) {
|
||||
taosCloseFile(&data.infileFD);
|
||||
(void)taosCloseFile(&data.infileFD);
|
||||
} else if (data.gb) {
|
||||
growbuffer_destroy(data.gb);
|
||||
}
|
||||
|
@ -1038,7 +1038,7 @@ static S3Status listBucketCallback(int isTruncated, const char *nextMarker, int
|
|||
nextMarker = contents[contentsCount - 1].key;
|
||||
}
|
||||
if (nextMarker) {
|
||||
snprintf(data->nextMarker, sizeof(data->nextMarker), "%s", nextMarker);
|
||||
(void)snprintf(data->nextMarker, sizeof(data->nextMarker), "%s", nextMarker);
|
||||
} else {
|
||||
data->nextMarker[0] = 0;
|
||||
}
|
||||
|
@ -1052,7 +1052,7 @@ static S3Status listBucketCallback(int isTruncated, const char *nextMarker, int
|
|||
const S3ListBucketContent *content = &(contents[i]);
|
||||
// printf("%-50s", content->key);
|
||||
char *object_key = strdup(content->key);
|
||||
taosArrayPush(data->objectArray, &object_key);
|
||||
(void)taosArrayPush(data->objectArray, &object_key);
|
||||
}
|
||||
data->keyCount += contentsCount;
|
||||
|
||||
|
@ -1139,7 +1139,7 @@ int32_t s3DeleteObjects(const char *object_name[], int nobject) {
|
|||
void s3DeleteObjectsByPrefix(const char *prefix) {
|
||||
SArray *objectArray = getListByPrefix(prefix);
|
||||
if (objectArray == NULL) return;
|
||||
s3DeleteObjects(TARRAY_DATA(objectArray), TARRAY_SIZE(objectArray));
|
||||
(void)s3DeleteObjects(TARRAY_DATA(objectArray), TARRAY_SIZE(objectArray));
|
||||
taosArrayDestroyEx(objectArray, s3FreeObjectKey);
|
||||
}
|
||||
|
||||
|
@ -1156,7 +1156,7 @@ static S3Status getObjectDataCallback(int bufferSize, const char *buffer, void *
|
|||
}
|
||||
|
||||
if (cbd->buf) {
|
||||
memcpy(cbd->buf + cbd->buf_pos, buffer, bufferSize);
|
||||
(void)memcpy(cbd->buf + cbd->buf_pos, buffer, bufferSize);
|
||||
cbd->buf_pos += bufferSize;
|
||||
cbd->status = S3StatusOK;
|
||||
return S3StatusOK;
|
||||
|
@ -1196,7 +1196,7 @@ int32_t s3GetObjectBlock(const char *object_name, int64_t offset, int64_t size,
|
|||
TAOS_RETURN(TAOS_SYSTEM_ERROR(EIO));
|
||||
}
|
||||
|
||||
*ppBlock = cbd.buf;
|
||||
*ppBlock = (uint8_t *)cbd.buf;
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -1231,11 +1231,11 @@ int32_t s3GetObjectToFile(const char *object_name, const char *fileName) {
|
|||
|
||||
if (cbd.status != S3StatusOK) {
|
||||
uError("%s: %d(%s)", __func__, cbd.status, cbd.err_msg);
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(EIO));
|
||||
}
|
||||
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -1250,9 +1250,9 @@ int32_t s3GetObjectsByPrefix(const char *prefix, const char *path) {
|
|||
tmp = (tmp == NULL) ? object : tmp + 1;
|
||||
char fileName[PATH_MAX] = {0};
|
||||
if (path[strlen(path) - 1] != TD_DIRSEP_CHAR) {
|
||||
snprintf(fileName, PATH_MAX, "%s%s%s", path, TD_DIRSEP, tmp);
|
||||
(void)snprintf(fileName, PATH_MAX, "%s%s%s", path, TD_DIRSEP, tmp);
|
||||
} else {
|
||||
snprintf(fileName, PATH_MAX, "%s%s", path, tmp);
|
||||
(void)snprintf(fileName, PATH_MAX, "%s%s", path, tmp);
|
||||
}
|
||||
if (s3GetObjectToFile(object, fileName) != 0) {
|
||||
taosArrayDestroyEx(objectArray, s3FreeObjectKey);
|
||||
|
|
|
@ -43,12 +43,12 @@ static int32_t cos_cp_parse_body(char* cp_body, SCheckpoint* cp) {
|
|||
|
||||
item = cJSON_GetObjectItem(json, "md5");
|
||||
if (cJSON_IsString(item)) {
|
||||
memcpy(cp->md5, item->valuestring, strlen(item->valuestring));
|
||||
(void)memcpy(cp->md5, item->valuestring, strlen(item->valuestring));
|
||||
}
|
||||
|
||||
item = cJSON_GetObjectItem(json, "upload_id");
|
||||
if (cJSON_IsString(item)) {
|
||||
strncpy(cp->upload_id, item->valuestring, 128);
|
||||
(void)strncpy(cp->upload_id, item->valuestring, 128);
|
||||
}
|
||||
|
||||
item2 = cJSON_GetObjectItem(json, "file");
|
||||
|
@ -65,12 +65,12 @@ static int32_t cos_cp_parse_body(char* cp_body, SCheckpoint* cp) {
|
|||
|
||||
item = cJSON_GetObjectItem(item2, "path");
|
||||
if (cJSON_IsString(item)) {
|
||||
strncpy(cp->file_path, item->valuestring, TSDB_FILENAME_LEN);
|
||||
(void)strncpy(cp->file_path, item->valuestring, TSDB_FILENAME_LEN);
|
||||
}
|
||||
|
||||
item = cJSON_GetObjectItem(item2, "file_md5");
|
||||
if (cJSON_IsString(item)) {
|
||||
strncpy(cp->file_md5, item->valuestring, 64);
|
||||
(void)strncpy(cp->file_md5, item->valuestring, 64);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,17 +83,17 @@ static int32_t cos_cp_parse_body(char* cp_body, SCheckpoint* cp) {
|
|||
|
||||
item = cJSON_GetObjectItem(item2, "object_name");
|
||||
if (cJSON_IsString(item)) {
|
||||
strncpy(cp->object_name, item->valuestring, 128);
|
||||
(void)strncpy(cp->object_name, item->valuestring, 128);
|
||||
}
|
||||
|
||||
item = cJSON_GetObjectItem(item2, "object_last_modified");
|
||||
if (cJSON_IsString(item)) {
|
||||
strncpy(cp->object_last_modified, item->valuestring, 64);
|
||||
(void)strncpy(cp->object_last_modified, item->valuestring, 64);
|
||||
}
|
||||
|
||||
item = cJSON_GetObjectItem(item2, "object_etag");
|
||||
if (cJSON_IsString(item)) {
|
||||
strncpy(cp->object_etag, item->valuestring, 128);
|
||||
(void)strncpy(cp->object_etag, item->valuestring, 128);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ static int32_t cos_cp_parse_body(char* cp_body, SCheckpoint* cp) {
|
|||
|
||||
item3 = cJSON_GetObjectItem(item, "etag");
|
||||
if (cJSON_IsString(item3)) {
|
||||
strncpy(cp->parts[index].etag, item3->valuestring, 128);
|
||||
(void)strncpy(cp->parts[index].etag, item3->valuestring, 128);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ int32_t cos_cp_load(char const* filepath, SCheckpoint* checkpoint) {
|
|||
} else if (n != size) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_FILE_CORRUPTED, &lino, _exit);
|
||||
}
|
||||
taosCloseFile(&fd);
|
||||
(void)taosCloseFile(&fd);
|
||||
cp_body[size] = '\0';
|
||||
|
||||
return cos_cp_parse_body(cp_body, checkpoint);
|
||||
|
@ -189,7 +189,7 @@ _exit:
|
|||
uError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
if (fd) {
|
||||
taosCloseFile(&fd);
|
||||
(void)taosCloseFile(&fd);
|
||||
}
|
||||
if (cp_body) {
|
||||
taosMemoryFree(cp_body);
|
||||
|
@ -309,7 +309,7 @@ int32_t cos_cp_dump(SCheckpoint* cp) {
|
|||
if (!item) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit);
|
||||
}
|
||||
cJSON_AddItemToArray(ajson, item);
|
||||
(void)cJSON_AddItemToArray(ajson, item);
|
||||
|
||||
if (NULL == cJSON_AddNumberToObject(item, "index", cp->parts[i].index)) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit);
|
||||
|
@ -346,7 +346,7 @@ void cos_cp_get_undo_parts(SCheckpoint* checkpoint, int* part_num, SCheckpointPa
|
|||
|
||||
void cos_cp_update(SCheckpoint* checkpoint, int32_t part_index, char const* etag, uint64_t crc64) {
|
||||
checkpoint->parts[part_index].completed = 1;
|
||||
strncpy(checkpoint->parts[part_index].etag, etag, 127);
|
||||
(void)strncpy(checkpoint->parts[part_index].etag, etag, 127);
|
||||
checkpoint->parts[part_index].crc64 = crc64;
|
||||
}
|
||||
|
||||
|
@ -355,12 +355,12 @@ void cos_cp_build_upload(SCheckpoint* checkpoint, char const* filepath, int64_t
|
|||
int i = 0;
|
||||
|
||||
checkpoint->cp_type = COS_CP_TYPE_UPLOAD;
|
||||
memset(checkpoint->file_path, 0, TSDB_FILENAME_LEN);
|
||||
strncpy(checkpoint->file_path, filepath, TSDB_FILENAME_LEN - 1);
|
||||
(void)memset(checkpoint->file_path, 0, TSDB_FILENAME_LEN);
|
||||
(void)strncpy(checkpoint->file_path, filepath, TSDB_FILENAME_LEN - 1);
|
||||
|
||||
checkpoint->file_size = size;
|
||||
checkpoint->file_last_modified = mtime;
|
||||
strncpy(checkpoint->upload_id, upload_id, 127);
|
||||
(void)strncpy(checkpoint->upload_id, upload_id, 127);
|
||||
|
||||
checkpoint->part_size = part_size;
|
||||
for (; i * part_size < size; i++) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -310,7 +310,7 @@ static int32_t tRowBuildTupleRow(SArray *aColVal, const SRowBuildScanInfo *sinfo
|
|||
}
|
||||
} else {
|
||||
(void)memcpy(fixed + schema->columns[i].offset, &colValArray[colValIndex].value.val,
|
||||
tDataTypes[schema->columns[i].type].bytes);
|
||||
tDataTypes[schema->columns[i].type].bytes);
|
||||
}
|
||||
} else if (COL_VAL_IS_NULL(&colValArray[colValIndex])) { // NULL
|
||||
ROW_SET_BITMAP(bitmap, sinfo->tupleFlag, i - 1, BIT_FLG_NULL);
|
||||
|
@ -384,13 +384,14 @@ static int32_t tRowBuildKVRow(SArray *aColVal, const SRowBuildScanInfo *sinfo, c
|
|||
payloadSize += tPutI16v(payload + payloadSize, colValArray[colValIndex].cid);
|
||||
payloadSize += tPutU32v(payload + payloadSize, colValArray[colValIndex].value.nData);
|
||||
if (colValArray[colValIndex].value.nData > 0) {
|
||||
(void)memcpy(payload + payloadSize, colValArray[colValIndex].value.pData, colValArray[colValIndex].value.nData);
|
||||
(void)memcpy(payload + payloadSize, colValArray[colValIndex].value.pData,
|
||||
colValArray[colValIndex].value.nData);
|
||||
}
|
||||
payloadSize += colValArray[colValIndex].value.nData;
|
||||
} else {
|
||||
payloadSize += tPutI16v(payload + payloadSize, colValArray[colValIndex].cid);
|
||||
(void)memcpy(payload + payloadSize, &colValArray[colValIndex].value.val,
|
||||
tDataTypes[schema->columns[i].type].bytes);
|
||||
tDataTypes[schema->columns[i].type].bytes);
|
||||
payloadSize += tDataTypes[schema->columns[i].type].bytes;
|
||||
}
|
||||
} else if (COL_VAL_IS_NULL(&colValArray[colValIndex])) { // NULL
|
||||
|
@ -458,7 +459,7 @@ int32_t tRowBuildFromBind(SBindInfo *infos, int32_t numOfInfos, bool infoSorted,
|
|||
SColVal colVal;
|
||||
|
||||
if ((colValArray = taosArrayInit(numOfInfos, sizeof(SColVal))) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
for (int32_t iRow = 0; iRow < numOfRows; iRow++) {
|
||||
|
@ -476,11 +477,14 @@ int32_t tRowBuildFromBind(SBindInfo *infos, int32_t numOfInfos, bool infoSorted,
|
|||
value.pData = (uint8_t *)infos[iInfo].bind->buffer + infos[iInfo].bind->buffer_length * iRow;
|
||||
} else {
|
||||
(void)memcpy(&value.val, (uint8_t *)infos[iInfo].bind->buffer + infos[iInfo].bind->buffer_length * iRow,
|
||||
infos[iInfo].bind->buffer_length);
|
||||
infos[iInfo].bind->buffer_length);
|
||||
}
|
||||
colVal = COL_VAL_VALUE(infos[iInfo].columnId, value);
|
||||
}
|
||||
taosArrayPush(colValArray, &colVal);
|
||||
if (taosArrayPush(colValArray, &colVal) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
||||
SRow *row;
|
||||
|
@ -666,7 +670,7 @@ static int32_t tRowMergeImpl(SArray *aRowP, STSchema *pTSchema, int32_t iStart,
|
|||
// merge
|
||||
aColVal = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal));
|
||||
if (aColVal == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
@ -689,7 +693,12 @@ static int32_t tRowMergeImpl(SArray *aRowP, STSchema *pTSchema, int32_t iStart,
|
|||
}
|
||||
}
|
||||
|
||||
if (pColVal) taosArrayPush(aColVal, pColVal);
|
||||
if (pColVal) {
|
||||
if (taosArrayPush(aColVal, pColVal) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// build
|
||||
|
@ -1739,7 +1748,7 @@ int32_t tTagToValArray(const STag *pTag, SArray **ppArray) {
|
|||
|
||||
(*ppArray) = taosArrayInit(pTag->nTag + 1, sizeof(STagVal));
|
||||
if (*ppArray == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -1750,7 +1759,10 @@ int32_t tTagToValArray(const STag *pTag, SArray **ppArray) {
|
|||
offset = pTag->idx[iTag];
|
||||
}
|
||||
tGetTagVal(p + offset, &tv, pTag->flags & TD_TAG_JSON);
|
||||
taosArrayPush(*ppArray, &tv);
|
||||
if (taosArrayPush(*ppArray, &tv) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1783,6 +1795,7 @@ void tTagSetCid(const STag *pTag, int16_t iTag, int16_t cid) {
|
|||
STSchema *tBuildTSchema(SSchema *aSchema, int32_t numOfCols, int32_t version) {
|
||||
STSchema *pTSchema = taosMemoryCalloc(1, sizeof(STSchema) + sizeof(STColumn) * numOfCols);
|
||||
if (pTSchema == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2592,7 +2605,8 @@ static FORCE_INLINE void tColDataGetValue4(SColData *pColData, int32_t iVal, SCo
|
|||
}
|
||||
value.pData = pColData->pData + pColData->aOffset[iVal];
|
||||
} else {
|
||||
(void)memcpy(&value.val, pColData->pData + tDataTypes[pColData->type].bytes * iVal, tDataTypes[pColData->type].bytes);
|
||||
(void)memcpy(&value.val, pColData->pData + tDataTypes[pColData->type].bytes * iVal,
|
||||
tDataTypes[pColData->type].bytes);
|
||||
}
|
||||
*pColVal = COL_VAL_VALUE(pColData->cid, value);
|
||||
}
|
||||
|
@ -3118,10 +3132,10 @@ static int32_t tColDataCopyRowCell(SColData *pFromColData, int32_t iFromRow, SCo
|
|||
}
|
||||
|
||||
(void)memcpy(pToColData->pData + pToColData->aOffset[iToRow], pFromColData->pData + pFromColData->aOffset[iFromRow],
|
||||
nData);
|
||||
nData);
|
||||
} else {
|
||||
(void)memcpy(&pToColData->pData[TYPE_BYTES[pToColData->type] * iToRow],
|
||||
&pFromColData->pData[TYPE_BYTES[pToColData->type] * iFromRow], TYPE_BYTES[pToColData->type]);
|
||||
&pFromColData->pData[TYPE_BYTES[pToColData->type] * iFromRow], TYPE_BYTES[pToColData->type]);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -3209,12 +3223,12 @@ static int32_t tColDataMergeSortMerge(SColData *aColData, int32_t start, int32_t
|
|||
|
||||
if (end > start) {
|
||||
aDstColData = taosMemoryCalloc(1, sizeof(SColData) * nColData);
|
||||
for (int c = 0; c < nColData; ++c) {
|
||||
tColDataInit(&aDstColData[c], aColData[c].cid, aColData[c].type, aColData[c].cflag);
|
||||
}
|
||||
if (aDstColData == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int c = 0; c < nColData; ++c) {
|
||||
tColDataInit(&aDstColData[c], aColData[c].cid, aColData[c].type, aColData[c].cflag);
|
||||
}
|
||||
}
|
||||
|
||||
tColDataArrGetRowKey(aColData, nColData, i, &keyi);
|
||||
|
@ -3360,7 +3374,7 @@ static void tColDataMergeImpl(SColData *pColData, int32_t iStart, int32_t iEnd /
|
|||
} else {
|
||||
if (iv != iStart) {
|
||||
(void)memcpy(&pColData->pData[TYPE_BYTES[pColData->type] * iStart],
|
||||
&pColData->pData[TYPE_BYTES[pColData->type] * iv], TYPE_BYTES[pColData->type]);
|
||||
&pColData->pData[TYPE_BYTES[pColData->type] * iv], TYPE_BYTES[pColData->type]);
|
||||
}
|
||||
memmove(&pColData->pData[TYPE_BYTES[pColData->type] * (iStart + 1)],
|
||||
&pColData->pData[TYPE_BYTES[pColData->type] * iEnd],
|
||||
|
@ -4476,6 +4490,9 @@ int32_t tDecompressData(void *input, // input
|
|||
buffer = &local;
|
||||
}
|
||||
code = tBufferEnsureCapacity(buffer, info->originalSize + COMP_OVERFLOW_BYTES);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t decompressedSize = tDataCompress[info->dataType].decompFunc(
|
||||
input, // input
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -150,7 +150,6 @@ int32_t epsetToStr(const SEpSet* pEpSet, char* pBuf, int32_t cap) {
|
|||
cap -= nwrite;
|
||||
|
||||
for (int _i = 0; (_i < pEpSet->numOfEps) && (cap > 0); _i++) {
|
||||
int32_t ret = 0;
|
||||
if (_i == pEpSet->numOfEps - 1) {
|
||||
ret = snprintf(pBuf + nwrite, cap, "%d. %s:%d", _i, pEpSet->eps[_i].fqdn, pEpSet->eps[_i].port);
|
||||
} else {
|
||||
|
@ -271,11 +270,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
|||
|
||||
TAOS_CHECK_GOTO(blockDataEnsureCapacity(pBlock, cfgGetSize(pConf)), NULL, _exit);
|
||||
|
||||
pIter = cfgCreateIter(pConf);
|
||||
if (pIter == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
TAOS_CHECK_GOTO(code, NULL, _exit);
|
||||
}
|
||||
TAOS_CHECK_GOTO(cfgCreateIter(pConf, &pIter), NULL, _exit);
|
||||
|
||||
cfgLock(pConf);
|
||||
locked = 1;
|
||||
|
@ -297,7 +292,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
|||
|
||||
char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
int32_t valueLen = 0;
|
||||
cfgDumpItemValue(pItem, &value[VARSTR_HEADER_SIZE], TSDB_CONFIG_VALUE_LEN, &valueLen);
|
||||
TAOS_CHECK_GOTO(cfgDumpItemValue(pItem, &value[VARSTR_HEADER_SIZE], TSDB_CONFIG_VALUE_LEN, &valueLen), NULL, _exit);
|
||||
varDataSetLen(value, valueLen);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
||||
|
@ -309,7 +304,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
|||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, value, false), NULL, _exit);
|
||||
|
||||
char scope[TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
cfgDumpItemScope(pItem, &scope[VARSTR_HEADER_SIZE], TSDB_CONFIG_SCOPE_LEN, &valueLen);
|
||||
TAOS_CHECK_GOTO(cfgDumpItemScope(pItem, &scope[VARSTR_HEADER_SIZE], TSDB_CONFIG_SCOPE_LEN, &valueLen), NULL, _exit);
|
||||
varDataSetLen(scope, valueLen);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -181,7 +181,7 @@ int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t name
|
|||
int32_t tNameAddTbName(SName* dst, const char* tbName, size_t nameLen) {
|
||||
// too long account id or too long db name
|
||||
if (nameLen >= tListLen(dst->tname) || nameLen <= 0) {
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
dst->type = TSDB_TABLE_NAME_T;
|
||||
|
@ -225,14 +225,14 @@ bool tNameTbNameEqual(SName* left, SName* right) {
|
|||
|
||||
int32_t tNameFromString(SName* dst, const char* str, uint32_t type) {
|
||||
if (strlen(str) == 0) {
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
char* p = NULL;
|
||||
if ((type & T_NAME_ACCT) == T_NAME_ACCT) {
|
||||
p = strstr(str, TS_PATH_DELIMITER);
|
||||
if (p == NULL) {
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
dst->acctId = taosStr2Int32(str, NULL, 10);
|
||||
|
@ -252,7 +252,7 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) {
|
|||
|
||||
// too long account id or too long db name
|
||||
if ((len >= tListLen(dst->dbname)) || (len <= 0)) {
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
memcpy(dst->dbname, start, len);
|
||||
|
@ -266,7 +266,7 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) {
|
|||
// too long account id or too long db name
|
||||
int32_t len = (int32_t)strlen(start);
|
||||
if ((len >= tListLen(dst->tname)) || (len <= 0)) {
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
memcpy(dst->tname, start, len);
|
||||
|
@ -298,13 +298,15 @@ int32_t buildChildTableName(RandTableName* rName) {
|
|||
if (sb.buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
taosArraySort(rName->tags, compareKv);
|
||||
for (int j = 0; j < taosArrayGetSize(rName->tags); ++j) {
|
||||
taosStringBuilderAppendChar(&sb, ',');
|
||||
SSmlKv* tagKv = taosArrayGet(rName->tags, j);
|
||||
if(tagKv == NULL) {
|
||||
if (tagKv == NULL) {
|
||||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
}
|
||||
|
||||
taosStringBuilderAppendStringLen(&sb, tagKv->key, tagKv->keyLen);
|
||||
taosStringBuilderAppendChar(&sb, '=');
|
||||
if (IS_VAR_DATA_TYPE(tagKv->type)) {
|
||||
|
@ -313,6 +315,7 @@ int32_t buildChildTableName(RandTableName* rName) {
|
|||
taosStringBuilderAppendStringLen(&sb, (char*)(&(tagKv->value)), tagKv->length);
|
||||
}
|
||||
}
|
||||
|
||||
size_t len = 0;
|
||||
char* keyJoined = taosStringBuilderGetResult(&sb, &len);
|
||||
T_MD5_CTX context;
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
#include "trow.h"
|
||||
#include "tlog.h"
|
||||
|
||||
static bool tdSTSRowIterGetTpVal(STSRowIter *pIter, col_type_t colType, int32_t offset, SCellVal *pVal);
|
||||
static bool tdSTSRowIterGetKvVal(STSRowIter *pIter, col_id_t colId, col_id_t *nIdx, SCellVal *pVal);
|
||||
static bool tdSTSRowIterGetTpVal(STSRowIter *pIter, col_type_t colType, int32_t offset, SCellVal *pVal);
|
||||
static bool tdSTSRowIterGetKvVal(STSRowIter *pIter, col_id_t colId, col_id_t *nIdx, SCellVal *pVal);
|
||||
|
||||
void tdSTSRowIterInit(STSRowIter *pIter, STSchema *pSchema) {
|
||||
pIter->pSchema = pSchema;
|
||||
|
@ -110,8 +110,7 @@ bool tdSTSRowIterGetTpVal(STSRowIter *pIter, col_type_t colType, int32_t offset,
|
|||
|
||||
int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pValType) {
|
||||
if (!pBitmap || colIdx < 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
int16_t nBytes = colIdx / TD_VTYPE_PARTS;
|
||||
int16_t nOffset = colIdx & TD_VTYPE_OPTR;
|
||||
|
@ -131,59 +130,15 @@ int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pVa
|
|||
*pValType = ((*pDestByte) & 0x03);
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pValType) {
|
||||
if (!pBitmap || colIdx < 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
int16_t nBytes = colIdx / TD_VTYPE_PARTS_I;
|
||||
int16_t nOffset = colIdx & TD_VTYPE_OPTR_I;
|
||||
char *pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes);
|
||||
// use literal value directly and not use formula to simplify the codes
|
||||
switch (nOffset) {
|
||||
case 0:
|
||||
*pValType = (((*pDestByte) & 0x80) >> 7);
|
||||
break;
|
||||
case 1:
|
||||
*pValType = (((*pDestByte) & 0x40) >> 6);
|
||||
break;
|
||||
case 2:
|
||||
*pValType = (((*pDestByte) & 0x20) >> 5);
|
||||
break;
|
||||
case 3:
|
||||
*pValType = (((*pDestByte) & 0x10) >> 4);
|
||||
break;
|
||||
case 4:
|
||||
*pValType = (((*pDestByte) & 0x08) >> 3);
|
||||
break;
|
||||
case 5:
|
||||
*pValType = (((*pDestByte) & 0x04) >> 2);
|
||||
break;
|
||||
case 6:
|
||||
*pValType = (((*pDestByte) & 0x02) >> 1);
|
||||
break;
|
||||
case 7:
|
||||
*pValType = ((*pDestByte) & 0x01);
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValType, int8_t bitmapMode) {
|
||||
switch (bitmapMode) {
|
||||
case 0:
|
||||
tdGetBitmapValTypeII(pBitmap, colIdx, pValType);
|
||||
(void)tdGetBitmapValTypeII(pBitmap, colIdx, pValType);
|
||||
break;
|
||||
#if 0
|
||||
case -1:
|
||||
|
@ -192,10 +147,9 @@ int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValT
|
|||
break;
|
||||
#endif
|
||||
default:
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return TSDB_CODE_FAILED;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
bool tdSTSRowIterGetKvVal(STSRowIter *pIter, col_id_t colId, col_id_t *nIdx, SCellVal *pVal) {
|
||||
|
@ -400,8 +354,8 @@ bool tdSKvRowGetVal(STSRow *pRow, col_id_t colId, col_id_t colIdx, SCellVal *pVa
|
|||
}
|
||||
|
||||
void *pBitmap = tdGetBitmapAddrKv(pRow, tdRowGetNCols(pRow));
|
||||
tdGetKvRowValOfCol(pVal, pRow, pBitmap, pColIdx->offset,
|
||||
POINTER_DISTANCE(pColIdx, TD_ROW_COL_IDX(pRow)) / sizeof(SKvRowIdx));
|
||||
(void)tdGetKvRowValOfCol(pVal, pRow, pBitmap, pColIdx->offset,
|
||||
POINTER_DISTANCE(pColIdx, TD_ROW_COL_IDX(pRow)) / sizeof(SKvRowIdx));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -412,11 +366,10 @@ bool tdSTpRowGetVal(STSRow *pRow, col_id_t colId, col_type_t colType, int32_t fl
|
|||
return true;
|
||||
}
|
||||
void *pBitmap = tdGetBitmapAddrTp(pRow, flen);
|
||||
tdGetTpRowValOfCol(pVal, pRow, pBitmap, colType, offset, colIdx);
|
||||
(void)tdGetTpRowValOfCol(pVal, pRow, pBitmap, colType, offset, colIdx);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool tdSTSRowIterNext(STSRowIter *pIter, SCellVal *pVal) {
|
||||
if (pIter->colIdx >= pIter->pSchema->numOfCols) {
|
||||
return false;
|
||||
|
@ -432,9 +385,9 @@ bool tdSTSRowIterNext(STSRowIter *pIter, SCellVal *pVal) {
|
|||
}
|
||||
|
||||
if (TD_IS_TP_ROW(pIter->pRow)) {
|
||||
tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal);
|
||||
(void)tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal);
|
||||
} else if (TD_IS_KV_ROW(pIter->pRow)) {
|
||||
tdSTSRowIterGetKvVal(pIter, pCol->colId, &pIter->kvIdx, pVal);
|
||||
(void)tdSTSRowIterGetKvVal(pIter, pCol->colId, &pIter->kvIdx, pVal);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -452,6 +405,7 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t r
|
|||
int32_t maxVarDataLen = 0;
|
||||
int32_t iColVal = 0;
|
||||
int32_t nBound = 0;
|
||||
int32_t code = 0;
|
||||
void *varBuf = NULL;
|
||||
bool isAlloc = false;
|
||||
|
||||
|
@ -481,7 +435,8 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t r
|
|||
}
|
||||
} else {
|
||||
varDataLen += sizeof(VarDataLenT);
|
||||
if (pTColumn->type == TSDB_DATA_TYPE_VARCHAR || pTColumn->type == TSDB_DATA_TYPE_VARBINARY || pTColumn->type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
if (pTColumn->type == TSDB_DATA_TYPE_VARCHAR || pTColumn->type == TSDB_DATA_TYPE_VARBINARY ||
|
||||
pTColumn->type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
varDataLen += CHAR_BYTES;
|
||||
if (maxVarDataLen < CHAR_BYTES + sizeof(VarDataLenT)) {
|
||||
maxVarDataLen = CHAR_BYTES + sizeof(VarDataLenT);
|
||||
|
@ -494,7 +449,7 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t r
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if(pColVal && COL_VAL_IS_VALUE(pColVal)) {
|
||||
if (pColVal && COL_VAL_IS_VALUE(pColVal)) {
|
||||
nonVarDataLen += TYPE_BYTES[pTColumn->type];
|
||||
}
|
||||
}
|
||||
|
@ -516,8 +471,7 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t r
|
|||
}
|
||||
|
||||
if (!(*ppRow)) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
if (maxVarDataLen > 0) {
|
||||
|
@ -526,15 +480,14 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t r
|
|||
if (isAlloc) {
|
||||
taosMemoryFreeClear(*ppRow);
|
||||
}
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
SRowBuilder rb = {.rowType = rowType};
|
||||
tdSRowInit(&rb, pTSchema->version);
|
||||
tdSRowSetInfo(&rb, pTSchema->numOfCols, nBound, pTSchema->flen);
|
||||
tdSRowResetBuf(&rb, *ppRow);
|
||||
(void)tdSRowSetInfo(&rb, pTSchema->numOfCols, nBound, pTSchema->flen);
|
||||
(void)tdSRowResetBuf(&rb, *ppRow);
|
||||
int32_t iBound = 0;
|
||||
|
||||
iColVal = 0;
|
||||
|
@ -553,7 +506,7 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t r
|
|||
} else if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||
varDataSetLen(varBuf, pColVal->value.nData);
|
||||
if (pColVal->value.nData != 0) {
|
||||
memcpy(varDataVal(varBuf), pColVal->value.pData, pColVal->value.nData);
|
||||
(void)memcpy(varDataVal(varBuf), pColVal->value.pData, pColVal->value.nData);
|
||||
}
|
||||
val = varBuf;
|
||||
++iBound;
|
||||
|
@ -567,18 +520,28 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t r
|
|||
}
|
||||
|
||||
if (TD_IS_TP_ROW(rb.pBuf)) {
|
||||
tdAppendColValToRow(&rb, pTColumn->colId, pTColumn->type, valType, val, true, pTColumn->offset, iColVal);
|
||||
TAOS_CHECK_GOTO(
|
||||
tdAppendColValToRow(&rb, pTColumn->colId, pTColumn->type, valType, val, true, pTColumn->offset, iColVal),
|
||||
NULL, _exit);
|
||||
} else {
|
||||
tdAppendColValToRow(&rb, pTColumn->colId, pTColumn->type, valType, val, true, rb.offset, iBound - 1);
|
||||
TAOS_CHECK_GOTO(
|
||||
tdAppendColValToRow(&rb, pTColumn->colId, pTColumn->type, valType, val, true, rb.offset, iBound - 1), NULL,
|
||||
_exit);
|
||||
}
|
||||
|
||||
++iColVal;
|
||||
}
|
||||
tdSRowEnd(&rb);
|
||||
|
||||
_exit:
|
||||
taosMemoryFreeClear(varBuf);
|
||||
if (code < 0) {
|
||||
if (isAlloc) {
|
||||
taosMemoryFreeClear(*ppRow);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tdCompareColId(const void *arg1, const void *arg2) {
|
||||
|
@ -615,7 +578,7 @@ bool tdSTSRowGetVal(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCell
|
|||
#ifdef TD_SUPPORT_BITMAP
|
||||
colIdx = POINTER_DISTANCE(pCol, pSchema->columns) / sizeof(STColumn);
|
||||
#endif
|
||||
tdGetTpRowValOfCol(pVal, pRow, pIter->pBitmap, pCol->type, pCol->offset, colIdx - 1);
|
||||
(void)tdGetTpRowValOfCol(pVal, pRow, pIter->pBitmap, pCol->type, pCol->offset, colIdx - 1);
|
||||
} else if (TD_IS_KV_ROW(pRow)) {
|
||||
SKvRowIdx *pIdx = (SKvRowIdx *)taosbsearch(&colId, TD_ROW_COL_IDX(pRow), tdRowGetNCols(pRow), sizeof(SKvRowIdx),
|
||||
compareKvRowColId, TD_EQ);
|
||||
|
@ -624,7 +587,7 @@ bool tdSTSRowGetVal(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCell
|
|||
colIdx = POINTER_DISTANCE(pIdx, TD_ROW_COL_IDX(pRow)) / sizeof(SKvRowIdx);
|
||||
}
|
||||
#endif
|
||||
tdGetKvRowValOfCol(pVal, pRow, pIter->pBitmap, pIdx ? pIdx->offset : -1, colIdx);
|
||||
(void)tdGetKvRowValOfCol(pVal, pRow, pIter->pBitmap, pIdx ? pIdx->offset : -1, colIdx);
|
||||
} else {
|
||||
if (COL_REACH_END(colId, pIter->maxColId)) return false;
|
||||
pVal->valType = TD_VTYPE_NONE;
|
||||
|
@ -632,83 +595,31 @@ bool tdSTSRowGetVal(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCell
|
|||
|
||||
return true;
|
||||
}
|
||||
#if 0
|
||||
int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, TDRowValT valType) {
|
||||
if (!pBitmap || colIdx < 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
int16_t nBytes = colIdx / TD_VTYPE_PARTS_I;
|
||||
int16_t nOffset = colIdx & TD_VTYPE_OPTR_I;
|
||||
char *pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes);
|
||||
// use literal value directly and not use formula to simplify the codes
|
||||
switch (nOffset) {
|
||||
case 0:
|
||||
*pDestByte = ((*pDestByte) & 0x7F) | (valType << 7);
|
||||
// set the value and clear other partitions for offset 0
|
||||
// *pDestByte |= (valType << 7);
|
||||
break;
|
||||
case 1:
|
||||
*pDestByte = ((*pDestByte) & 0xBF) | (valType << 6);
|
||||
// *pDestByte |= (valType << 6);
|
||||
break;
|
||||
case 2:
|
||||
*pDestByte = ((*pDestByte) & 0xDF) | (valType << 5);
|
||||
// *pDestByte |= (valType << 5);
|
||||
break;
|
||||
case 3:
|
||||
*pDestByte = ((*pDestByte) & 0xEF) | (valType << 4);
|
||||
// *pDestByte |= (valType << 4);
|
||||
break;
|
||||
case 4:
|
||||
*pDestByte = ((*pDestByte) & 0xF7) | (valType << 3);
|
||||
// *pDestByte |= (valType << 3);
|
||||
break;
|
||||
case 5:
|
||||
*pDestByte = ((*pDestByte) & 0xFB) | (valType << 2);
|
||||
// *pDestByte |= (valType << 2);
|
||||
break;
|
||||
case 6:
|
||||
*pDestByte = ((*pDestByte) & 0xFD) | (valType << 1);
|
||||
// *pDestByte |= (valType << 1);
|
||||
break;
|
||||
case 7:
|
||||
*pDestByte = ((*pDestByte) & 0xFE) | valType;
|
||||
// *pDestByte |= (valType);
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t tdGetKvRowValOfCol(SCellVal *output, STSRow *pRow, void *pBitmap, int32_t offset, int16_t colIdx) {
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
ASSERT(colIdx < tdRowGetNCols(pRow) - 1);
|
||||
if (tdGetBitmapValType(pBitmap, colIdx, &output->valType, 0) != TSDB_CODE_SUCCESS) {
|
||||
int32_t code = 0;
|
||||
if ((code = tdGetBitmapValType(pBitmap, colIdx, &output->valType, 0)) != TSDB_CODE_SUCCESS) {
|
||||
output->valType = TD_VTYPE_NONE;
|
||||
return terrno;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
if (tdValTypeIsNorm(output->valType)) {
|
||||
if (offset < 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
output->valType = TD_VTYPE_NONE;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
output->val = POINTER_SHIFT(pRow, offset);
|
||||
}
|
||||
#else
|
||||
if (offset < 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
output->valType = TD_VTYPE_NONE;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
output->val = POINTER_SHIFT(pRow, offset);
|
||||
output->valType = isNull(output->val, colType) ? TD_VTYPE_NULL : TD_VTYPE_NORM;
|
||||
#endif
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t tdGetTpRowValOfCol(SCellVal *output, STSRow *pRow, void *pBitmap, int8_t colType, int32_t offset,
|
||||
|
@ -720,12 +631,13 @@ int32_t tdGetTpRowValOfCol(SCellVal *output, STSRow *pRow, void *pBitmap, int8_t
|
|||
} else {
|
||||
output->val = POINTER_SHIFT(TD_ROW_DATA(pRow), offset);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
if (tdGetBitmapValType(pBitmap, colIdx, &output->valType, 0) != TSDB_CODE_SUCCESS) {
|
||||
int32_t code = 0;
|
||||
if ((code = tdGetBitmapValType(pBitmap, colIdx, &output->valType, 0)) != TSDB_CODE_SUCCESS) {
|
||||
output->valType = TD_VTYPE_NONE;
|
||||
return terrno;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
if (output->valType == TD_VTYPE_NORM) {
|
||||
|
@ -736,7 +648,7 @@ int32_t tdGetTpRowValOfCol(SCellVal *output, STSRow *pRow, void *pBitmap, int8_t
|
|||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colType, TDRowValT valType, const void *val,
|
||||
|
@ -745,23 +657,21 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp
|
|||
if (!val) {
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
if (valType == TD_VTYPE_NORM) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
#else
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
d
|
||||
#endif
|
||||
}
|
||||
// TS KEY is stored in STSRow.ts and not included in STSRow.data field.
|
||||
if (colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
if (!val) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
TD_ROW_KEY(pRow) = *(TSKEY *)val;
|
||||
// The primary TS key is Norm all the time, thus its valType is not stored in bitmap.
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
// TODO: We can avoid the type judegement by FP, but would prevent the inline scheme.
|
||||
|
||||
|
@ -773,33 +683,29 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp
|
|||
break;
|
||||
case TD_VTYPE_NONE:
|
||||
if (!pBuilder->hasNone) pBuilder->hasNone = true;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
default:
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
if (TD_IS_TP_ROW(pRow)) {
|
||||
tdAppendColValToTpRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset);
|
||||
(void)tdAppendColValToTpRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset);
|
||||
} else {
|
||||
tdAppendColValToKvRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset, colId);
|
||||
(void)tdAppendColValToKvRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset, colId);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val, bool isCopyVarData,
|
||||
int8_t colType, int16_t colIdx, int32_t offset, col_id_t colId) {
|
||||
if (colIdx < 1) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
ASSERTS(0, "colIdx is %" PRIi64, colIdx);
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
--colIdx;
|
||||
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
if (tdSetBitmapValType(pBuilder->pBitmap, colIdx, valType, 0) != TSDB_CODE_SUCCESS) {
|
||||
return terrno;
|
||||
}
|
||||
TAOS_CHECK_RETURN(tdSetBitmapValType(pBuilder->pBitmap, colIdx, valType, 0));
|
||||
#endif
|
||||
|
||||
STSRow *row = pBuilder->pBuf;
|
||||
|
@ -812,30 +718,27 @@ int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const vo
|
|||
char *ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row));
|
||||
if (IS_VAR_DATA_TYPE(colType)) {
|
||||
if (isCopyVarData) {
|
||||
memcpy(ptr, val, varDataTLen(val));
|
||||
(void)memcpy(ptr, val, varDataTLen(val));
|
||||
}
|
||||
TD_ROW_LEN(row) += varDataTLen(val);
|
||||
} else {
|
||||
memcpy(ptr, val, TYPE_BYTES[colType]);
|
||||
(void)memcpy(ptr, val, TYPE_BYTES[colType]);
|
||||
TD_ROW_LEN(row) += TYPE_BYTES[colType];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val, bool isCopyVarData,
|
||||
int8_t colType, int16_t colIdx, int32_t offset) {
|
||||
if (colIdx < 1) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
--colIdx;
|
||||
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
if (tdSetBitmapValType(pBuilder->pBitmap, colIdx, valType, 0) != TSDB_CODE_SUCCESS) {
|
||||
return terrno;
|
||||
}
|
||||
TAOS_CHECK_RETURN(tdSetBitmapValType(pBuilder->pBitmap, colIdx, valType, 0));
|
||||
#endif
|
||||
|
||||
STSRow *row = pBuilder->pBuf;
|
||||
|
@ -849,59 +752,21 @@ int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowValT valType, const vo
|
|||
// ts key stored in STSRow.ts
|
||||
*(VarDataOffsetT *)POINTER_SHIFT(TD_ROW_DATA(row), offset) = TD_ROW_LEN(row);
|
||||
if (isCopyVarData) {
|
||||
memcpy(POINTER_SHIFT(row, TD_ROW_LEN(row)), val, varDataTLen(val));
|
||||
(void)memcpy(POINTER_SHIFT(row, TD_ROW_LEN(row)), val, varDataTLen(val));
|
||||
}
|
||||
TD_ROW_LEN(row) += varDataTLen(val);
|
||||
} else {
|
||||
memcpy(POINTER_SHIFT(TD_ROW_DATA(row), offset), val, TYPE_BYTES[colType]);
|
||||
(void)memcpy(POINTER_SHIFT(TD_ROW_DATA(row), offset), val, TYPE_BYTES[colType]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
#if 0
|
||||
int32_t tdSRowSetExtendedInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols, int32_t flen,
|
||||
int32_t allNullLen, int32_t boundNullLen) {
|
||||
if ((boundNullLen > 0) && (allNullLen > 0) && (nBoundCols > 0)) {
|
||||
uint32_t tpLen = allNullLen;
|
||||
uint32_t kvLen = sizeof(col_id_t) + sizeof(SKvRowIdx) * nBoundCols + boundNullLen;
|
||||
if (isSelectKVRow(kvLen, tpLen)) {
|
||||
pBuilder->rowType = TD_ROW_KV;
|
||||
} else {
|
||||
pBuilder->rowType = TD_ROW_TP;
|
||||
}
|
||||
|
||||
} else {
|
||||
pBuilder->rowType = TD_ROW_TP;
|
||||
}
|
||||
pBuilder->flen = flen;
|
||||
pBuilder->nCols = nCols;
|
||||
pBuilder->nBoundCols = nBoundCols;
|
||||
if (pBuilder->flen <= 0 || pBuilder->nCols <= 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
// the primary TS key is stored separatedly
|
||||
pBuilder->nBitmaps = (col_id_t)TD_BITMAP_BYTES(pBuilder->nCols - 1);
|
||||
if (nBoundCols > 0) {
|
||||
pBuilder->nBoundBitmaps = (col_id_t)TD_BITMAP_BYTES(pBuilder->nBoundCols - 1);
|
||||
} else {
|
||||
pBuilder->nBoundBitmaps = 0;
|
||||
}
|
||||
#else
|
||||
pBuilder->nBitmaps = 0;
|
||||
pBuilder->nBoundBitmaps = 0;
|
||||
#endif
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
|
||||
pBuilder->pBuf = (STSRow *)pBuf;
|
||||
if (!pBuilder->pBuf) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
if (pBuilder->hasNone) pBuilder->hasNone = false;
|
||||
|
@ -917,7 +782,7 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
|
|||
case TD_ROW_TP:
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
pBuilder->pBitmap = tdGetBitmapAddrTp(pBuilder->pBuf, pBuilder->flen);
|
||||
memset(pBuilder->pBitmap, TD_VTYPE_NONE_BYTE_II, pBuilder->nBitmaps);
|
||||
(void)memset(pBuilder->pBitmap, TD_VTYPE_NONE_BYTE_II, pBuilder->nBitmaps);
|
||||
#endif
|
||||
// the primary TS key is stored separatedly
|
||||
len = TD_ROW_HEAD_LEN + pBuilder->flen + pBuilder->nBitmaps;
|
||||
|
@ -927,7 +792,7 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
|
|||
case TD_ROW_KV:
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
pBuilder->pBitmap = tdGetBitmapAddrKv(pBuilder->pBuf, pBuilder->nBoundCols);
|
||||
memset(pBuilder->pBitmap, TD_VTYPE_NONE_BYTE_II, pBuilder->nBoundBitmaps);
|
||||
(void)memset(pBuilder->pBitmap, TD_VTYPE_NONE_BYTE_II, pBuilder->nBoundBitmaps);
|
||||
#endif
|
||||
len = TD_ROW_HEAD_LEN + TD_ROW_NCOLS_LEN + (pBuilder->nBoundCols - 1) * sizeof(SKvRowIdx) +
|
||||
pBuilder->nBoundBitmaps; // add
|
||||
|
@ -937,18 +802,16 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
|
|||
pBuilder->offset = 0;
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t tdSRowGetBuf(SRowBuilder *pBuilder, void *pBuf) {
|
||||
pBuilder->pBuf = (STSRow *)pBuf;
|
||||
if (!pBuilder->pBuf) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
ASSERT(pBuilder->nBitmaps > 0 && pBuilder->flen > 0);
|
||||
|
@ -966,10 +829,9 @@ int32_t tdSRowGetBuf(SRowBuilder *pBuilder, void *pBuf) {
|
|||
#endif
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
void tdSRowReset(SRowBuilder *pBuilder) {
|
||||
|
@ -985,8 +847,7 @@ int32_t tdSRowSetTpInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t flen) {
|
|||
pBuilder->flen = flen;
|
||||
pBuilder->nCols = nCols;
|
||||
if (pBuilder->flen <= 0 || pBuilder->nCols <= 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
// the primary TS key is stored separatedly
|
||||
|
@ -995,7 +856,7 @@ int32_t tdSRowSetTpInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t flen) {
|
|||
pBuilder->nBitmaps = 0;
|
||||
pBuilder->nBoundBitmaps = 0;
|
||||
#endif
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols, int32_t flen) {
|
||||
|
@ -1003,8 +864,7 @@ int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols,
|
|||
pBuilder->nCols = nCols;
|
||||
pBuilder->nBoundCols = nBoundCols;
|
||||
if (pBuilder->flen <= 0 || pBuilder->nCols <= 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
// the primary TS key is stored separatedly
|
||||
|
@ -1018,24 +878,12 @@ int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols,
|
|||
pBuilder->nBitmaps = 0;
|
||||
pBuilder->nBoundBitmaps = 0;
|
||||
#endif
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool tdIsBitmapValTypeNorm(const void *pBitmap, int16_t idx, int8_t bitmapMode) {
|
||||
TDRowValT valType = 0;
|
||||
tdGetBitmapValType(pBitmap, idx, &valType, bitmapMode);
|
||||
if (tdValTypeIsNorm(valType)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT valType) {
|
||||
if (!pBitmap || colIdx < 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
int16_t nBytes = colIdx / TD_VTYPE_PARTS;
|
||||
int16_t nOffset = colIdx & TD_VTYPE_OPTR;
|
||||
|
@ -1060,10 +908,9 @@ int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT valType) {
|
|||
// *pDestByte |= (valType);
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT valType, int8_t bitmapMode) {
|
||||
|
@ -1078,14 +925,11 @@ int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT valType, int
|
|||
break;
|
||||
#endif
|
||||
default:
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return TSDB_CODE_FAILED;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColVal) {
|
||||
STColumn *pTColumn = &pTSchema->columns[iCol];
|
||||
SCellVal cv = {0};
|
||||
|
@ -1093,9 +937,9 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV
|
|||
ASSERT((pTColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) || (iCol > 0));
|
||||
|
||||
if (TD_IS_TP_ROW(pRow)) {
|
||||
tdSTpRowGetVal(pRow, pTColumn->colId, pTColumn->type, pTSchema->flen, pTColumn->offset, iCol - 1, &cv);
|
||||
(void)tdSTpRowGetVal(pRow, pTColumn->colId, pTColumn->type, pTSchema->flen, pTColumn->offset, iCol - 1, &cv);
|
||||
} else if (TD_IS_KV_ROW(pRow)) {
|
||||
tdSKvRowGetVal(pRow, pTColumn->colId, iCol - 1, &cv);
|
||||
(void)tdSKvRowGetVal(pRow, pTColumn->colId, iCol - 1, &cv);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -1113,7 +957,7 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV
|
|||
pColVal->value.nData = varDataLen(cv.val);
|
||||
pColVal->value.pData = varDataVal(cv.val);
|
||||
} else {
|
||||
memcpy(&pColVal->value.val, cv.val, tDataTypes[pTColumn->type].bytes);
|
||||
(void)memcpy(&pColVal->value.val, cv.val, tDataTypes[pTColumn->type].bytes);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ void deltaToUtcInitOnce() {
|
|||
// printf("====delta:%lld\n\n", seconds);
|
||||
}
|
||||
|
||||
static int64_t parseFraction(char* str, char** end, int32_t timePrec);
|
||||
static int32_t parseFraction(char* str, char** end, int32_t timePrec, int64_t* pFraction);
|
||||
static int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, char delim);
|
||||
static int32_t parseLocaltime(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim);
|
||||
static int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim);
|
||||
|
@ -95,7 +95,7 @@ char* forwardToTimeStringEnd(char* str) {
|
|||
return &str[i];
|
||||
}
|
||||
|
||||
int64_t parseFraction(char* str, char** end, int32_t timePrec) {
|
||||
int32_t parseFraction(char* str, char** end, int32_t timePrec, int64_t* pFraction) {
|
||||
int32_t i = 0;
|
||||
int64_t fraction = 0;
|
||||
|
||||
|
@ -112,7 +112,7 @@ int64_t parseFraction(char* str, char** end, int32_t timePrec) {
|
|||
|
||||
int32_t totalLen = i;
|
||||
if (totalLen <= 0) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
/* parse the fraction */
|
||||
|
@ -134,13 +134,14 @@ int64_t parseFraction(char* str, char** end, int32_t timePrec) {
|
|||
}
|
||||
times = NANO_SEC_FRACTION_LEN - i;
|
||||
} else {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
fraction = strnatoi(str, i) * factor[times];
|
||||
*end = str + totalLen;
|
||||
*pFraction = fraction;
|
||||
|
||||
return fraction;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
||||
|
@ -148,7 +149,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
|||
|
||||
int32_t i = 0;
|
||||
if (str[i] != '+' && str[i] != '-') {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
i++;
|
||||
|
@ -160,7 +161,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
|||
continue;
|
||||
}
|
||||
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
char* sep = strchr(&str[i], ':');
|
||||
|
@ -175,18 +176,18 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
|||
}
|
||||
|
||||
if (hour > 12 || hour < 0) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
// return error if there're illegal charaters after min(2 Digits)
|
||||
char* minStr = &str[i];
|
||||
if (minStr[1] != '\0' && minStr[2] != '\0') {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
int64_t minute = strnatoi(&str[i], 2);
|
||||
if (minute > 59 || (hour == 12 && minute > 0)) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
if (str[0] == '+') {
|
||||
|
@ -195,13 +196,13 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
|||
*tzOffset = hour * 3600 + minute * 60;
|
||||
}
|
||||
|
||||
return 0;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t offsetOfTimezone(char* tzStr, int64_t* offset) {
|
||||
if (tzStr && (tzStr[0] == 'z' || tzStr[0] == 'Z')) {
|
||||
*offset = 0;
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return parseTimezone(tzStr, offset);
|
||||
}
|
||||
|
@ -234,7 +235,7 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch
|
|||
}
|
||||
|
||||
if (str == NULL) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
/* mktime will be affected by TZ, set by using taos_options */
|
||||
|
@ -253,22 +254,18 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch
|
|||
*time = seconds * factor;
|
||||
} else if (str[0] == '.') {
|
||||
str += 1;
|
||||
if ((fraction = parseFraction(str, &str, timePrec)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
TAOS_CHECK_RETURN(parseFraction(str, &str, timePrec, &fraction));
|
||||
|
||||
*time = seconds * factor + fraction;
|
||||
|
||||
char seg = str[0];
|
||||
if (seg != 'Z' && seg != 'z' && seg != '+' && seg != '-') {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
} else if ((seg == 'Z' || seg == 'z') && str[1] != '\0') {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
} else if (seg == '+' || seg == '-') {
|
||||
// parse the timezone
|
||||
if (parseTimezone(str, &tzOffset) == -1) {
|
||||
return -1;
|
||||
}
|
||||
TAOS_CHECK_RETURN(parseTimezone(str, &tzOffset));
|
||||
|
||||
*time += tzOffset * factor;
|
||||
}
|
||||
|
@ -277,16 +274,14 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch
|
|||
*time = seconds * factor + fraction;
|
||||
|
||||
// parse the timezone
|
||||
if (parseTimezone(str, &tzOffset) == -1) {
|
||||
return -1;
|
||||
}
|
||||
TAOS_CHECK_RETURN(parseTimezone(str, &tzOffset));
|
||||
|
||||
*time += tzOffset * factor;
|
||||
} else {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
return 0;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
static FORCE_INLINE bool validateTm(struct tm* pTm) {
|
||||
|
@ -330,7 +325,7 @@ int32_t parseLocaltime(char* timestr, int32_t len, int64_t* utime, int32_t timeP
|
|||
// if parse failed, try "%Y-%m-%d" format
|
||||
str = taosStrpTime(timestr, "%Y-%m-%d", &tm);
|
||||
if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,13 +342,11 @@ int32_t parseLocaltime(char* timestr, int32_t len, int64_t* utime, int32_t timeP
|
|||
|
||||
if (*str == '.') {
|
||||
/* parse the second fraction part */
|
||||
if ((fraction = parseFraction(str + 1, &str, timePrec)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
TAOS_CHECK_RETURN(parseFraction(str + 1, &str, timePrec, &fraction));
|
||||
}
|
||||
|
||||
*utime = TSDB_TICK_PER_SECOND(timePrec) * seconds + fraction;
|
||||
return 0;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) {
|
||||
|
@ -374,7 +367,7 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t ti
|
|||
// if parse failed, try "%Y-%m-%d" format
|
||||
str = taosStrpTime(timestr, "%Y-%m-%d", &tm);
|
||||
if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -384,13 +377,11 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t ti
|
|||
int64_t fraction = 0;
|
||||
if (*str == '.') {
|
||||
/* parse the second fraction part */
|
||||
if ((fraction = parseFraction(str + 1, &str, timePrec)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
TAOS_CHECK_RETURN(parseFraction(str + 1, &str, timePrec, &fraction));
|
||||
}
|
||||
|
||||
*utime = TSDB_TICK_PER_SECOND(timePrec) * seconds + fraction;
|
||||
return 0;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
char getPrecisionUnit(int32_t precision) {
|
||||
|
@ -482,10 +473,10 @@ int64_t convertTimePrecision(int64_t utime, int32_t fromPrecision, int32_t toPre
|
|||
|
||||
// !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double =
|
||||
// 1626006833631000064
|
||||
int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit) {
|
||||
int32_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit, int64_t* pRes) {
|
||||
if (fromPrecision != TSDB_TIME_PRECISION_MILLI && fromPrecision != TSDB_TIME_PRECISION_MICRO &&
|
||||
fromPrecision != TSDB_TIME_PRECISION_NANO) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
int64_t factors[3] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1};
|
||||
|
@ -541,12 +532,18 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char
|
|||
time *= factors[fromPrecision];
|
||||
break;
|
||||
default: {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
}
|
||||
if (tmp >= (double)INT64_MAX) return INT64_MAX;
|
||||
if (tmp <= (double)INT64_MIN) return INT64_MIN;
|
||||
return time;
|
||||
if (tmp >= (double)INT64_MAX) {
|
||||
*pRes = INT64_MAX;
|
||||
} else if (tmp <= (double)INT64_MIN) {
|
||||
*pRes = INT64_MIN;
|
||||
} else {
|
||||
*pRes = time;
|
||||
}
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec, int64_t* timeVal) {
|
||||
|
@ -554,62 +551,68 @@ int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec
|
|||
char* newColData;
|
||||
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY) {
|
||||
newColData = taosMemoryCalloc(1, charLen + 1);
|
||||
memcpy(newColData, varDataVal(inputData), charLen);
|
||||
if (NULL == newColData) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
(void)memcpy(newColData, varDataVal(inputData), charLen);
|
||||
int32_t ret = taosParseTime(newColData, timeVal, charLen, (int32_t)timePrec, tsDaylight);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(newColData);
|
||||
return TSDB_CODE_INVALID_TIMESTAMP;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_TIMESTAMP);
|
||||
}
|
||||
taosMemoryFree(newColData);
|
||||
} else if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||
newColData = taosMemoryCalloc(1, charLen + TSDB_NCHAR_SIZE);
|
||||
if (NULL == newColData) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
int len = taosUcs4ToMbs((TdUcs4*)varDataVal(inputData), charLen, newColData);
|
||||
if (len < 0) {
|
||||
taosMemoryFree(newColData);
|
||||
return TSDB_CODE_FAILED;
|
||||
TAOS_RETURN(TSDB_CODE_FAILED);
|
||||
}
|
||||
newColData[len] = 0;
|
||||
int32_t ret = taosParseTime(newColData, timeVal, len, (int32_t)timePrec, tsDaylight);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(newColData);
|
||||
return ret;
|
||||
TAOS_RETURN(ret);
|
||||
}
|
||||
taosMemoryFree(newColData);
|
||||
} else {
|
||||
return TSDB_CODE_FAILED;
|
||||
TAOS_RETURN(TSDB_CODE_FAILED);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
|
||||
switch (unit) {
|
||||
case 's':
|
||||
if (val > INT64_MAX / MILLISECOND_PER_SECOND) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_SECOND, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||
break;
|
||||
case 'm':
|
||||
if (val > INT64_MAX / MILLISECOND_PER_MINUTE) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_MINUTE, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||
break;
|
||||
case 'h':
|
||||
if (val > INT64_MAX / MILLISECOND_PER_MINUTE) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_HOUR, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||
break;
|
||||
case 'd':
|
||||
if (val > INT64_MAX / MILLISECOND_PER_DAY) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_DAY, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||
break;
|
||||
case 'w':
|
||||
if (val > INT64_MAX / MILLISECOND_PER_WEEK) {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_WEEK, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||
break;
|
||||
|
@ -623,10 +626,10 @@ int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecisi
|
|||
(*result) = convertTimePrecision(val, TSDB_TIME_PRECISION_NANO, timePrecision);
|
||||
break;
|
||||
default: {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -651,41 +654,40 @@ int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* dura
|
|||
/* get the basic numeric value */
|
||||
int64_t timestamp = taosStr2Int64(token, &endPtr, 10);
|
||||
if ((timestamp == 0 && token[0] != '0') || errno != 0) {
|
||||
return -1;
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
|
||||
/* natual month/year are not allowed in absolute duration */
|
||||
*unit = token[tokenlen - 1];
|
||||
if (*unit == 'n' || *unit == 'y') {
|
||||
return -1;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
return getDuration(timestamp, *unit, duration, timePrecision);
|
||||
}
|
||||
|
||||
int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit, int32_t timePrecision, bool negativeAllow) {
|
||||
int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit, int32_t timePrecision,
|
||||
bool negativeAllow) {
|
||||
errno = 0;
|
||||
|
||||
/* get the basic numeric value */
|
||||
*duration = taosStr2Int64(token, NULL, 10);
|
||||
if ((*duration < 0 && !negativeAllow) || errno != 0) {
|
||||
return -1;
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
|
||||
*unit = token[tokenLen - 1];
|
||||
if (*unit == 'n' || *unit == 'y') {
|
||||
return 0;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
if(isdigit(*unit)) {
|
||||
if (isdigit(*unit)) {
|
||||
*unit = getPrecisionUnit(timePrecision);
|
||||
}
|
||||
|
||||
return getDuration(*duration, *unit, duration, timePrecision);
|
||||
}
|
||||
|
||||
static bool taosIsLeapYear(int32_t year) {
|
||||
return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
|
||||
}
|
||||
static bool taosIsLeapYear(int32_t year) { return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); }
|
||||
|
||||
int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
||||
if (duration == 0) {
|
||||
|
@ -702,7 +704,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
|||
|
||||
struct tm tm;
|
||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||
taosLocalTime(&tt, &tm, NULL);
|
||||
(void)taosLocalTime(&tt, &tm, NULL);
|
||||
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth;
|
||||
tm.tm_year = mon / 12;
|
||||
tm.tm_mon = mon % 12;
|
||||
|
@ -763,11 +765,11 @@ int32_t taosTimeCountIntervalForFill(int64_t skey, int64_t ekey, int64_t interva
|
|||
|
||||
struct tm tm;
|
||||
time_t t = (time_t)skey;
|
||||
taosLocalTime(&t, &tm, NULL);
|
||||
(void)taosLocalTime(&t, &tm, NULL);
|
||||
int32_t smon = tm.tm_year * 12 + tm.tm_mon;
|
||||
|
||||
t = (time_t)ekey;
|
||||
taosLocalTime(&t, &tm, NULL);
|
||||
(void)taosLocalTime(&t, &tm, NULL);
|
||||
int32_t emon = tm.tm_year * 12 + tm.tm_mon;
|
||||
|
||||
if (unit == 'y') {
|
||||
|
@ -792,7 +794,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
|
|||
start /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
|
||||
struct tm tm;
|
||||
time_t tt = (time_t)start;
|
||||
taosLocalTime(&tt, &tm, NULL);
|
||||
(void)taosLocalTime(&tt, &tm, NULL);
|
||||
tm.tm_sec = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_hour = 0;
|
||||
|
@ -900,7 +902,8 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
|
|||
// used together with taosTimeTruncate. when offset is great than zero, slide-start/slide-end is the anchor point
|
||||
int64_t taosTimeGetIntervalEnd(int64_t intervalStart, const SInterval* pInterval) {
|
||||
if (pInterval->offset > 0) {
|
||||
int64_t slideStart = taosTimeAdd(intervalStart, -1 * pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||
int64_t slideStart =
|
||||
taosTimeAdd(intervalStart, -1 * pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||
int64_t slideEnd = taosTimeAdd(slideStart, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||
int64_t result = taosTimeAdd(slideEnd, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||
return result;
|
||||
|
@ -960,7 +963,7 @@ const char* fmtts(int64_t ts) {
|
|||
return buf;
|
||||
}
|
||||
|
||||
void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision) {
|
||||
int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision) {
|
||||
char ts[40] = {0};
|
||||
struct tm ptm;
|
||||
|
||||
|
@ -996,23 +999,26 @@ void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision)
|
|||
|
||||
default:
|
||||
fractionLen = 0;
|
||||
return;
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
if (taosLocalTime(", &ptm, buf) == NULL) {
|
||||
return;
|
||||
if (NULL == taosLocalTime(", &ptm, buf)) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", &ptm);
|
||||
length += snprintf(ts + length, fractionLen, format, mod);
|
||||
length += (int32_t)strftime(ts + length, 40 - length, "%z", &ptm);
|
||||
|
||||
tstrncpy(buf, ts, bufLen);
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t taosTs2Tm(int64_t ts, int32_t precision, struct STm* tm) {
|
||||
tm->fsec = ts % TICK_PER_SECOND[precision] * (TICK_PER_SECOND[TSDB_TIME_PRECISION_NANO] / TICK_PER_SECOND[precision]);
|
||||
time_t t = ts / TICK_PER_SECOND[precision];
|
||||
taosLocalTime(&t, &tm->tm, NULL);
|
||||
if (NULL == taosLocalTime(&t, &tm->tm, NULL)) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1055,7 +1061,7 @@ typedef enum {
|
|||
TSFKW_Mon,
|
||||
TSFKW_MS,
|
||||
TSFKW_NS,
|
||||
//TSFKW_OF,
|
||||
// TSFKW_OF,
|
||||
TSFKW_PM,
|
||||
TSFKW_P_M,
|
||||
TSFKW_SS,
|
||||
|
@ -1076,7 +1082,7 @@ typedef enum {
|
|||
TSFKW_day,
|
||||
TSFKW_ddd,
|
||||
TSFKW_dd,
|
||||
TSFKW_dy, // mon, tue
|
||||
TSFKW_dy, // mon, tue
|
||||
TSFKW_d,
|
||||
TSFKW_hh24,
|
||||
TSFKW_hh12,
|
||||
|
@ -1246,13 +1252,13 @@ static bool isSeperatorChar(char c) {
|
|||
return (c > 0x20 && c < 0x7F && !(c >= 'A' && c <= 'Z') && !(c >= 'a' && c <= 'z') && !(c >= '0' && c <= '9'));
|
||||
}
|
||||
|
||||
static void parseTsFormat(const char* formatStr, SArray* formats) {
|
||||
static int32_t parseTsFormat(const char* formatStr, SArray* formats) {
|
||||
TSFormatNode* lastOtherFormat = NULL;
|
||||
while (*formatStr) {
|
||||
const TSFormatKeyWord* key = keywordSearch(formatStr);
|
||||
if (key) {
|
||||
TSFormatNode format = {.key = key, .type = TS_FORMAT_NODE_TYPE_KEYWORD};
|
||||
taosArrayPush(formats, &format);
|
||||
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
formatStr += key->len;
|
||||
lastOtherFormat = NULL;
|
||||
} else {
|
||||
|
@ -1268,7 +1274,7 @@ static void parseTsFormat(const char* formatStr, SArray* formats) {
|
|||
}
|
||||
if (*formatStr == '\\' && *(formatStr + 1)) {
|
||||
formatStr++;
|
||||
last = NULL; // stop expanding last format, create new format
|
||||
last = NULL; // stop expanding last format, create new format
|
||||
}
|
||||
if (last) {
|
||||
// expand
|
||||
|
@ -1280,7 +1286,7 @@ static void parseTsFormat(const char* formatStr, SArray* formats) {
|
|||
TSFormatNode format = {.type = TS_FORMAT_NODE_TYPE_CHAR, .key = NULL};
|
||||
format.c = formatStr;
|
||||
format.len = 1;
|
||||
taosArrayPush(formats, &format);
|
||||
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
formatStr++;
|
||||
last = taosArrayGetLast(formats);
|
||||
}
|
||||
|
@ -1289,7 +1295,7 @@ static void parseTsFormat(const char* formatStr, SArray* formats) {
|
|||
// for other strings
|
||||
if (*formatStr == '\\' && *(formatStr + 1)) {
|
||||
formatStr++;
|
||||
lastOtherFormat = NULL; // stop expanding
|
||||
lastOtherFormat = NULL; // stop expanding
|
||||
} else {
|
||||
if (lastOtherFormat && !isSeperatorChar(*formatStr)) {
|
||||
// expanding
|
||||
|
@ -1304,27 +1310,28 @@ static void parseTsFormat(const char* formatStr, SArray* formats) {
|
|||
formatStr++;
|
||||
} else {
|
||||
TSFormatNode format = {
|
||||
.type = isSeperatorChar(*formatStr) ? TS_FORMAT_NODE_TYPE_SEPARATOR : TS_FORMAT_NODE_TYPE_CHAR,
|
||||
.key = NULL};
|
||||
.type = isSeperatorChar(*formatStr) ? TS_FORMAT_NODE_TYPE_SEPARATOR : TS_FORMAT_NODE_TYPE_CHAR,
|
||||
.key = NULL};
|
||||
format.c = formatStr;
|
||||
format.len = 1;
|
||||
taosArrayPush(formats, &format);
|
||||
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
formatStr++;
|
||||
if (format.type == TS_FORMAT_NODE_TYPE_CHAR) lastOtherFormat = taosArrayGetLast(formats);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int32_t outLen) {
|
||||
int32_t size = taosArrayGetSize(formats);
|
||||
int32_t size = taosArrayGetSize(formats);
|
||||
const char* start = s;
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
TSFormatNode* format = taosArrayGet(formats, i);
|
||||
if (format->type != TS_FORMAT_NODE_TYPE_KEYWORD) {
|
||||
if (s - start + format->len + 1 > outLen) break;
|
||||
strncpy(s, format->c, format->len);
|
||||
(void)strncpy(s, format->c, format->len);
|
||||
s += format->len;
|
||||
continue;
|
||||
}
|
||||
|
@ -1333,37 +1340,37 @@ static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int
|
|||
switch (format->key->id) {
|
||||
case TSFKW_AM:
|
||||
case TSFKW_PM:
|
||||
sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "PM" : "AM");
|
||||
(void)sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "PM" : "AM");
|
||||
s += 2;
|
||||
break;
|
||||
case TSFKW_A_M:
|
||||
case TSFKW_P_M:
|
||||
sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "P.M." : "A.M.");
|
||||
(void)sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "P.M." : "A.M.");
|
||||
s += 4;
|
||||
break;
|
||||
case TSFKW_am:
|
||||
case TSFKW_pm:
|
||||
sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "pm" : "am");
|
||||
(void)sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "pm" : "am");
|
||||
s += 2;
|
||||
break;
|
||||
case TSFKW_a_m:
|
||||
case TSFKW_p_m:
|
||||
sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "p.m." : "a.m.");
|
||||
(void)sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "p.m." : "a.m.");
|
||||
s += 4;
|
||||
break;
|
||||
case TSFKW_DDD:
|
||||
#ifdef WINDOWS
|
||||
return TSDB_CODE_FUNC_TO_CHAR_NOT_SUPPORTED;
|
||||
#endif
|
||||
sprintf(s, "%03d", tm->tm.tm_yday + 1);
|
||||
(void)sprintf(s, "%03d", tm->tm.tm_yday + 1);
|
||||
s += strlen(s);
|
||||
break;
|
||||
case TSFKW_DD:
|
||||
sprintf(s, "%02d", tm->tm.tm_mday);
|
||||
(void)sprintf(s, "%02d", tm->tm.tm_mday);
|
||||
s += 2;
|
||||
break;
|
||||
case TSFKW_D:
|
||||
sprintf(s, "%d", tm->tm.tm_wday + 1);
|
||||
(void)sprintf(s, "%d", tm->tm.tm_wday + 1);
|
||||
s += 1;
|
||||
break;
|
||||
case TSFKW_DAY: {
|
||||
|
@ -1371,20 +1378,20 @@ static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int
|
|||
const char* wd = weekDays[tm->tm.tm_wday];
|
||||
char buf[10] = {0};
|
||||
for (int32_t i = 0; i < strlen(wd); ++i) buf[i] = toupper(wd[i]);
|
||||
sprintf(s, "%-9s", buf);
|
||||
(void)sprintf(s, "%-9s", buf);
|
||||
s += strlen(s);
|
||||
break;
|
||||
}
|
||||
case TSFKW_Day:
|
||||
// Monday, TuesDay...
|
||||
sprintf(s, "%-9s", weekDays[tm->tm.tm_wday]);
|
||||
(void)sprintf(s, "%-9s", weekDays[tm->tm.tm_wday]);
|
||||
s += strlen(s);
|
||||
break;
|
||||
case TSFKW_day: {
|
||||
const char* wd = weekDays[tm->tm.tm_wday];
|
||||
char buf[10] = {0};
|
||||
for (int32_t i = 0; i < strlen(wd); ++i) buf[i] = tolower(wd[i]);
|
||||
sprintf(s, "%-9s", buf);
|
||||
(void)sprintf(s, "%-9s", buf);
|
||||
s += strlen(s);
|
||||
break;
|
||||
}
|
||||
|
@ -1393,13 +1400,13 @@ static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int
|
|||
const char* wd = shortWeekDays[tm->tm.tm_wday];
|
||||
char buf[8] = {0};
|
||||
for (int32_t i = 0; i < strlen(wd); ++i) buf[i] = toupper(wd[i]);
|
||||
sprintf(s, "%3s", buf);
|
||||
(void)sprintf(s, "%3s", buf);
|
||||
s += 3;
|
||||
break;
|
||||
}
|
||||
case TSFKW_Dy:
|
||||
// Mon, Tue
|
||||
sprintf(s, "%3s", shortWeekDays[tm->tm.tm_wday]);
|
||||
(void)sprintf(s, "%3s", shortWeekDays[tm->tm.tm_wday]);
|
||||
s += 3;
|
||||
break;
|
||||
case TSFKW_dy: {
|
||||
|
@ -1407,33 +1414,33 @@ static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int
|
|||
const char* wd = shortWeekDays[tm->tm.tm_wday];
|
||||
char buf[8] = {0};
|
||||
for (int32_t i = 0; i < strlen(wd); ++i) buf[i] = tolower(wd[i]);
|
||||
sprintf(s, "%3s", buf);
|
||||
(void)sprintf(s, "%3s", buf);
|
||||
s += 3;
|
||||
break;
|
||||
}
|
||||
case TSFKW_HH24:
|
||||
sprintf(s, "%02d", tm->tm.tm_hour);
|
||||
(void)sprintf(s, "%02d", tm->tm.tm_hour);
|
||||
s += 2;
|
||||
break;
|
||||
case TSFKW_HH:
|
||||
case TSFKW_HH12:
|
||||
// 0 or 12 o'clock in 24H coresponds to 12 o'clock (AM/PM) in 12H
|
||||
sprintf(s, "%02d", tm->tm.tm_hour % 12 == 0 ? 12 : tm->tm.tm_hour % 12);
|
||||
(void)sprintf(s, "%02d", tm->tm.tm_hour % 12 == 0 ? 12 : tm->tm.tm_hour % 12);
|
||||
s += 2;
|
||||
break;
|
||||
case TSFKW_MI:
|
||||
sprintf(s, "%02d", tm->tm.tm_min);
|
||||
(void)sprintf(s, "%02d", tm->tm.tm_min);
|
||||
s += 2;
|
||||
break;
|
||||
case TSFKW_MM:
|
||||
sprintf(s, "%02d", tm->tm.tm_mon + 1);
|
||||
(void)sprintf(s, "%02d", tm->tm.tm_mon + 1);
|
||||
s += 2;
|
||||
break;
|
||||
case TSFKW_MONTH: {
|
||||
const char* mon = fullMonths[tm->tm.tm_mon];
|
||||
char buf[10] = {0};
|
||||
for (int32_t i = 0; i < strlen(mon); ++i) buf[i] = toupper(mon[i]);
|
||||
sprintf(s, "%-9s", buf);
|
||||
(void)sprintf(s, "%-9s", buf);
|
||||
s += strlen(s);
|
||||
break;
|
||||
}
|
||||
|
@ -1441,68 +1448,68 @@ static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int
|
|||
const char* mon = months[tm->tm.tm_mon];
|
||||
char buf[10] = {0};
|
||||
for (int32_t i = 0; i < strlen(mon); ++i) buf[i] = toupper(mon[i]);
|
||||
sprintf(s, "%s", buf);
|
||||
(void)sprintf(s, "%s", buf);
|
||||
s += strlen(s);
|
||||
break;
|
||||
}
|
||||
case TSFKW_Month:
|
||||
sprintf(s, "%-9s", fullMonths[tm->tm.tm_mon]);
|
||||
(void)sprintf(s, "%-9s", fullMonths[tm->tm.tm_mon]);
|
||||
s += strlen(s);
|
||||
break;
|
||||
case TSFKW_month: {
|
||||
const char* mon = fullMonths[tm->tm.tm_mon];
|
||||
char buf[10] = {0};
|
||||
for (int32_t i = 0; i < strlen(mon); ++i) buf[i] = tolower(mon[i]);
|
||||
sprintf(s, "%-9s", buf);
|
||||
(void)sprintf(s, "%-9s", buf);
|
||||
s += strlen(s);
|
||||
break;
|
||||
}
|
||||
case TSFKW_Mon:
|
||||
sprintf(s, "%s", months[tm->tm.tm_mon]);
|
||||
(void)sprintf(s, "%s", months[tm->tm.tm_mon]);
|
||||
s += strlen(s);
|
||||
break;
|
||||
case TSFKW_mon: {
|
||||
const char* mon = months[tm->tm.tm_mon];
|
||||
char buf[10] = {0};
|
||||
for (int32_t i = 0; i < strlen(mon); ++i) buf[i] = tolower(mon[i]);
|
||||
sprintf(s, "%s", buf);
|
||||
(void)sprintf(s, "%s", buf);
|
||||
s += strlen(s);
|
||||
break;
|
||||
}
|
||||
case TSFKW_SS:
|
||||
sprintf(s, "%02d", tm->tm.tm_sec);
|
||||
(void)sprintf(s, "%02d", tm->tm.tm_sec);
|
||||
s += 2;
|
||||
break;
|
||||
case TSFKW_MS:
|
||||
sprintf(s, "%03" PRId64, tm->fsec / 1000000L);
|
||||
(void)sprintf(s, "%03" PRId64, tm->fsec / 1000000L);
|
||||
s += 3;
|
||||
break;
|
||||
case TSFKW_US:
|
||||
sprintf(s, "%06" PRId64, tm->fsec / 1000L);
|
||||
(void)sprintf(s, "%06" PRId64, tm->fsec / 1000L);
|
||||
s += 6;
|
||||
break;
|
||||
case TSFKW_NS:
|
||||
sprintf(s, "%09" PRId64, tm->fsec);
|
||||
(void)sprintf(s, "%09" PRId64, tm->fsec);
|
||||
s += 9;
|
||||
break;
|
||||
case TSFKW_TZH:
|
||||
sprintf(s, "%s%02d", tsTimezone < 0 ? "-" : "+", tsTimezone);
|
||||
(void)sprintf(s, "%s%02d", tsTimezone < 0 ? "-" : "+", tsTimezone);
|
||||
s += strlen(s);
|
||||
break;
|
||||
case TSFKW_YYYY:
|
||||
sprintf(s, "%04d", tm->tm.tm_year + 1900);
|
||||
(void)sprintf(s, "%04d", tm->tm.tm_year + 1900);
|
||||
s += strlen(s);
|
||||
break;
|
||||
case TSFKW_YYY:
|
||||
sprintf(s, "%03d", (tm->tm.tm_year + 1900) % 1000);
|
||||
(void)sprintf(s, "%03d", (tm->tm.tm_year + 1900) % 1000);
|
||||
s += strlen(s);
|
||||
break;
|
||||
case TSFKW_YY:
|
||||
sprintf(s, "%02d", (tm->tm.tm_year + 1900) % 100);
|
||||
(void)sprintf(s, "%02d", (tm->tm.tm_year + 1900) % 100);
|
||||
s += strlen(s);
|
||||
break;
|
||||
case TSFKW_Y:
|
||||
sprintf(s, "%01d", (tm->tm.tm_year + 1900) % 10);
|
||||
(void)sprintf(s, "%01d", (tm->tm.tm_year + 1900) % 10);
|
||||
s += strlen(s);
|
||||
break;
|
||||
default:
|
||||
|
@ -1537,7 +1544,7 @@ static const char* tsFormatStr2Int32(int32_t* dest, const char* str, int32_t len
|
|||
s = last;
|
||||
} else {
|
||||
char buf[16] = {0};
|
||||
strncpy(buf, s, len);
|
||||
(void)strncpy(buf, s, len);
|
||||
int32_t copiedLen = strlen(buf);
|
||||
if (copiedLen < len) {
|
||||
if (!needMoreDigit) {
|
||||
|
@ -1916,20 +1923,26 @@ static int32_t char2ts(const char* s, SArray* formats, int64_t* ts, int32_t prec
|
|||
int32_t taosTs2Char(const char* format, SArray** formats, int64_t ts, int32_t precision, char* out, int32_t outLen) {
|
||||
if (!*formats) {
|
||||
*formats = taosArrayInit(8, sizeof(TSFormatNode));
|
||||
parseTsFormat(format, *formats);
|
||||
if (!*formats){
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
TAOS_CHECK_RETURN(parseTsFormat(format, *formats));
|
||||
}
|
||||
struct STm tm;
|
||||
taosTs2Tm(ts, precision, &tm);
|
||||
TAOS_CHECK_RETURN(taosTs2Tm(ts, precision, &tm));
|
||||
return tm2char(*formats, &tm, out, outLen);
|
||||
}
|
||||
|
||||
int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int64_t* ts, int32_t precision, char* errMsg,
|
||||
int32_t errMsgLen) {
|
||||
int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int64_t* ts, int32_t precision,
|
||||
char* errMsg, int32_t errMsgLen) {
|
||||
const char* sErrPos;
|
||||
int32_t fErrIdx;
|
||||
if (!*formats) {
|
||||
*formats = taosArrayInit(4, sizeof(TSFormatNode));
|
||||
parseTsFormat(format, *formats);
|
||||
if (!*formats) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
TAOS_CHECK_RETURN(parseTsFormat(format, *formats));
|
||||
}
|
||||
int32_t code = char2ts(tsStr, *formats, ts, precision, &sErrPos, &fErrIdx);
|
||||
if (code == -1) {
|
||||
|
@ -1944,27 +1957,35 @@ int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int
|
|||
snprintf(errMsg, errMsgLen, "timestamp format not supported");
|
||||
code = TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED_NOT_SUPPORTED;
|
||||
}
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
void TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out, int32_t outLen) {
|
||||
int32_t TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out, int32_t outLen) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
SArray* formats = taosArrayInit(4, sizeof(TSFormatNode));
|
||||
parseTsFormat(format, formats);
|
||||
if (!formats) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
TAOS_CHECK_RETURN(parseTsFormat(format, formats));
|
||||
struct STm tm;
|
||||
taosTs2Tm(ts, precision, &tm);
|
||||
tm2char(formats, &tm, out, outLen);
|
||||
TAOS_CHECK_GOTO(taosTs2Tm(ts, precision, &tm), NULL, _exit);
|
||||
TAOS_CHECK_GOTO(tm2char(formats, &tm, out, outLen), NULL, _exit);
|
||||
|
||||
_exit:
|
||||
taosArrayDestroy(formats);
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t TEST_char2ts(const char* format, int64_t* ts, int32_t precision, const char* tsStr) {
|
||||
const char* sErrPos;
|
||||
int32_t fErrIdx;
|
||||
SArray* formats = taosArrayInit(4, sizeof(TSFormatNode));
|
||||
parseTsFormat(format, formats);
|
||||
TAOS_CHECK_RETURN(parseTsFormat(format, formats));
|
||||
int32_t code = char2ts(tsStr, formats, ts, precision, &sErrPos, &fErrIdx);
|
||||
if (code == -1) {
|
||||
printf("failed position: %s\n", sErrPos);
|
||||
printf("failed format: %s\n", ((TSFormatNode*)taosArrayGet(formats, fErrIdx))->key->name);
|
||||
(void)printf("failed position: %s\n", sErrPos);
|
||||
(void)printf("failed format: %s\n", ((TSFormatNode*)taosArrayGet(formats, fErrIdx))->key->name);
|
||||
}
|
||||
taosArrayDestroy(formats);
|
||||
return code;
|
||||
|
@ -1977,6 +1998,7 @@ static int8_t UNIT_INDEX[26] = {/*a*/ 2, 0, -1, 6, -1, -1, -1,
|
|||
|
||||
#define GET_UNIT_INDEX(idx) UNIT_INDEX[(idx) - 97]
|
||||
|
||||
// clang-format off
|
||||
static int64_t UNIT_MATRIX[10][11] = { /* ns, us, ms, s, min, h, d, w, month, y*/
|
||||
/*ns*/ { 1, 1000, 0},
|
||||
/*us*/ {1000, 1, 1000, 0},
|
||||
|
@ -1988,15 +2010,17 @@ static int64_t UNIT_MATRIX[10][11] = { /* ns, us, ms, s, min, h,
|
|||
/*w*/ { 0, 0, 0, 0, 0, 0, 7, 1, -1, 0},
|
||||
/*mon*/ { 0, 0, 0, 0, 0, 0, 0, 0, 1, 12, 0},
|
||||
/*y*/ { 0, 0, 0, 0, 0, 0, 0, 0, 12, 1, 0}};
|
||||
// clang-format on
|
||||
|
||||
static bool recursiveTsmaCheckRecursive(int64_t baseInterval, int8_t baseIdx, int64_t interval, int8_t idx, bool checkEq) {
|
||||
static bool recursiveTsmaCheckRecursive(int64_t baseInterval, int8_t baseIdx, int64_t interval, int8_t idx,
|
||||
bool checkEq) {
|
||||
if (UNIT_MATRIX[baseIdx][idx] == -1) return false;
|
||||
if (baseIdx == idx) {
|
||||
if (interval < baseInterval) return false;
|
||||
if (checkEq && interval == baseInterval) return false;
|
||||
return interval % baseInterval == 0;
|
||||
}
|
||||
int8_t next = baseIdx + 1;
|
||||
int8_t next = baseIdx + 1;
|
||||
int64_t val = UNIT_MATRIX[baseIdx][next];
|
||||
while (val != 0 && next <= idx) {
|
||||
if (val == -1) {
|
||||
|
@ -2006,7 +2030,7 @@ static bool recursiveTsmaCheckRecursive(int64_t baseInterval, int8_t baseIdx, in
|
|||
}
|
||||
if (val % baseInterval == 0 || baseInterval % val == 0) {
|
||||
int8_t extra = baseInterval >= val ? 0 : 1;
|
||||
bool needCheckEq = baseInterval >= val && !(baseIdx < next && val == 1);
|
||||
bool needCheckEq = baseInterval >= val && !(baseIdx < next && val == 1);
|
||||
if (!recursiveTsmaCheckRecursive(baseInterval / val + extra, next, interval, idx, needCheckEq && checkEq)) {
|
||||
next++;
|
||||
val = UNIT_MATRIX[baseIdx][next];
|
||||
|
@ -2021,7 +2045,8 @@ static bool recursiveTsmaCheckRecursive(int64_t baseInterval, int8_t baseIdx, in
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool recursiveTsmaCheckRecursiveReverse(int64_t baseInterval, int8_t baseIdx, int64_t interval, int8_t idx, bool checkEq) {
|
||||
static bool recursiveTsmaCheckRecursiveReverse(int64_t baseInterval, int8_t baseIdx, int64_t interval, int8_t idx,
|
||||
bool checkEq) {
|
||||
if (UNIT_MATRIX[baseIdx][idx] == -1) return false;
|
||||
|
||||
if (baseIdx == idx) {
|
||||
|
@ -2030,7 +2055,7 @@ static bool recursiveTsmaCheckRecursiveReverse(int64_t baseInterval, int8_t base
|
|||
return interval % baseInterval == 0;
|
||||
}
|
||||
|
||||
int8_t next = baseIdx - 1;
|
||||
int8_t next = baseIdx - 1;
|
||||
int64_t val = UNIT_MATRIX[baseIdx][next];
|
||||
while (val != 0 && next >= 0) {
|
||||
return recursiveTsmaCheckRecursiveReverse(baseInterval * val, next, interval, idx, checkEq);
|
||||
|
@ -2041,18 +2066,27 @@ static bool recursiveTsmaCheckRecursiveReverse(int64_t baseInterval, int8_t base
|
|||
/*
|
||||
* @breif check if tsma with param [interval], [unit] can create based on base tsma with baseInterval and baseUnit
|
||||
* @param baseInterval, baseUnit, interval/unit of base tsma
|
||||
* @param interval the tsma interval going to create. Not that if unit is not calander unit, then interval has already been
|
||||
* translated to TICKS of [precision]
|
||||
* @param interval the tsma interval going to create. Not that if unit is not calander unit, then interval has already
|
||||
* been translated to TICKS of [precision]
|
||||
* @param unit the tsma unit going to create
|
||||
* @param precision the precision of this db
|
||||
* @param checkEq pass true if same interval is not acceptable, false if acceptable.
|
||||
* @ret true the tsma can be created, else cannot
|
||||
* */
|
||||
bool checkRecursiveTsmaInterval(int64_t baseInterval, int8_t baseUnit, int64_t interval, int8_t unit, int8_t precision, bool checkEq) {
|
||||
bool checkRecursiveTsmaInterval(int64_t baseInterval, int8_t baseUnit, int64_t interval, int8_t unit, int8_t precision,
|
||||
bool checkEq) {
|
||||
bool baseIsCalendarDuration = IS_CALENDAR_TIME_DURATION(baseUnit);
|
||||
if (!baseIsCalendarDuration) baseInterval = convertTimeFromPrecisionToUnit(baseInterval, precision, baseUnit);
|
||||
if (!baseIsCalendarDuration) {
|
||||
if (TSDB_CODE_SUCCESS != convertTimeFromPrecisionToUnit(baseInterval, precision, baseUnit, &baseInterval)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool isCalendarDuration = IS_CALENDAR_TIME_DURATION(unit);
|
||||
if (!isCalendarDuration) interval = convertTimeFromPrecisionToUnit(interval, precision, unit);
|
||||
if (!isCalendarDuration) {
|
||||
if (TSDB_CODE_SUCCESS != convertTimeFromPrecisionToUnit(interval, precision, unit, &interval)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool needCheckEq = baseIsCalendarDuration == isCalendarDuration && checkEq;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -175,7 +175,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) {
|
|||
break;
|
||||
default: {
|
||||
if (len > 0) {
|
||||
memcpy(val, src, len);
|
||||
(void)memcpy(val, src, len);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -426,7 +426,7 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin
|
|||
size_t lenInwchar = len / TSDB_NCHAR_SIZE;
|
||||
|
||||
pVar->ucs4 = taosMemoryCalloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE);
|
||||
memcpy(pVar->ucs4, pz, lenInwchar * TSDB_NCHAR_SIZE);
|
||||
(void)memcpy(pVar->ucs4, pz, lenInwchar * TSDB_NCHAR_SIZE);
|
||||
pVar->nLen = (int32_t)len;
|
||||
|
||||
break;
|
||||
|
@ -435,7 +435,7 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin
|
|||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
case TSDB_DATA_TYPE_GEOMETRY: { // todo refactor, extract a method
|
||||
pVar->pz = taosMemoryCalloc(len + 1, sizeof(char));
|
||||
memcpy(pVar->pz, pz, len);
|
||||
(void)memcpy(pVar->pz, pz, len);
|
||||
pVar->nLen = (int32_t)len;
|
||||
break;
|
||||
}
|
||||
|
@ -470,10 +470,10 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
|
|||
char *p = taosMemoryRealloc(pDst->pz, len);
|
||||
ASSERT(p);
|
||||
|
||||
memset(p, 0, len);
|
||||
(void)memset(p, 0, len);
|
||||
pDst->pz = p;
|
||||
|
||||
memcpy(pDst->pz, pSrc->pz, pSrc->nLen);
|
||||
(void)memcpy(pDst->pz, pSrc->pz, pSrc->nLen);
|
||||
pDst->nLen = pSrc->nLen;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -236,7 +236,9 @@ TEST(testCase, toInteger_test) {
|
|||
}
|
||||
|
||||
TEST(testCase, Datablock_test) {
|
||||
SSDataBlock* b = createDataBlock();
|
||||
SSDataBlock* b = NULL;
|
||||
int32_t code = createDataBlock(&b);
|
||||
ASSERT(code == 0);
|
||||
|
||||
SColumnInfoData infoData = createColumnInfoData(TSDB_DATA_TYPE_INT, 4, 1);
|
||||
taosArrayPush(b->pDataBlock, &infoData);
|
||||
|
@ -361,7 +363,9 @@ TEST(testCase, non_var_dataBlock_split_test) {
|
|||
TEST(testCase, var_dataBlock_split_test) {
|
||||
int32_t numOfRows = 1000000;
|
||||
|
||||
SSDataBlock* b = createDataBlock();
|
||||
SSDataBlock* b = NULL;
|
||||
int32_t code = createDataBlock(&b);
|
||||
ASSERT(code == 0);
|
||||
|
||||
SColumnInfoData infoData = createColumnInfoData(TSDB_DATA_TYPE_INT, 4, 1);
|
||||
blockDataAppendColInfo(b, &infoData);
|
||||
|
@ -465,7 +469,8 @@ TEST(timeTest, timestamp2tm) {
|
|||
|
||||
void test_ts2char(int64_t ts, const char* format, int32_t precison, const char* expected) {
|
||||
char buf[256] = {0};
|
||||
TEST_ts2char(format, ts, precison, buf, 256);
|
||||
int32_t code = TEST_ts2char(format, ts, precison, buf, 256);
|
||||
ASSERT_EQ(code, 0);
|
||||
printf("ts: %ld format: %s res: [%s], expected: [%s]\n", ts, format, buf, expected);
|
||||
ASSERT_STREQ(expected, buf);
|
||||
}
|
||||
|
@ -732,16 +737,17 @@ TEST(AlreadyAddGroupIdTest, GroupIdAddedWithDifferentLength) {
|
|||
#define SLOW_LOG_TYPE_OTHERS 0x4
|
||||
#define SLOW_LOG_TYPE_ALL 0x7
|
||||
|
||||
static int32_t taosSetSlowLogScope(char *pScope) {
|
||||
if (NULL == pScope || 0 == strlen(pScope)) {
|
||||
return SLOW_LOG_TYPE_QUERY;
|
||||
static int32_t taosSetSlowLogScope(char* pScopeStr, int32_t* pScope) {
|
||||
if (NULL == pScopeStr || 0 == strlen(pScopeStr)) {
|
||||
*pScope = SLOW_LOG_TYPE_QUERY;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t slowScope = 0;
|
||||
|
||||
char* scope = NULL;
|
||||
char *tmp = NULL;
|
||||
while((scope = strsep(&pScope, "|")) != NULL){
|
||||
while((scope = strsep(&pScopeStr, "|")) != NULL){
|
||||
taosMemoryFreeClear(tmp);
|
||||
tmp = taosStrdup(scope);
|
||||
strtrim(tmp);
|
||||
|
@ -771,73 +777,94 @@ static int32_t taosSetSlowLogScope(char *pScope) {
|
|||
}
|
||||
|
||||
taosMemoryFreeClear(tmp);
|
||||
uError("Invalid slowLog scope value:%s", pScope);
|
||||
terrno = TSDB_CODE_INVALID_CFG_VALUE;
|
||||
return -1;
|
||||
uError("Invalid slowLog scope value:%s", pScopeStr);
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_CFG_VALUE);
|
||||
}
|
||||
|
||||
*pScope = slowScope;
|
||||
taosMemoryFreeClear(tmp);
|
||||
return slowScope;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
TEST(TaosSetSlowLogScopeTest, NullPointerInput) {
|
||||
char *pScope = NULL;
|
||||
int32_t result = taosSetSlowLogScope(pScope);
|
||||
EXPECT_EQ(result, SLOW_LOG_TYPE_QUERY);
|
||||
char* pScopeStr = NULL;
|
||||
int32_t scope = 0;
|
||||
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||
EXPECT_EQ(scope, SLOW_LOG_TYPE_QUERY);
|
||||
}
|
||||
|
||||
TEST(TaosSetSlowLogScopeTest, EmptyStringInput) {
|
||||
char pScope[1] = "";
|
||||
int32_t result = taosSetSlowLogScope(pScope);
|
||||
EXPECT_EQ(result, SLOW_LOG_TYPE_QUERY);
|
||||
char pScopeStr[1] = "";
|
||||
int32_t scope = 0;
|
||||
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||
EXPECT_EQ(scope, SLOW_LOG_TYPE_QUERY);
|
||||
}
|
||||
|
||||
TEST(TaosSetSlowLogScopeTest, AllScopeInput) {
|
||||
char pScope[] = "all";
|
||||
int32_t result = taosSetSlowLogScope(pScope);
|
||||
EXPECT_EQ(result, SLOW_LOG_TYPE_ALL);
|
||||
char pScopeStr[] = "all";
|
||||
int32_t scope = 0;
|
||||
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||
|
||||
EXPECT_EQ(scope, SLOW_LOG_TYPE_ALL);
|
||||
}
|
||||
|
||||
TEST(TaosSetSlowLogScopeTest, QueryScopeInput) {
|
||||
char pScope[] = " query";
|
||||
int32_t result = taosSetSlowLogScope(pScope);
|
||||
EXPECT_EQ(result, SLOW_LOG_TYPE_QUERY);
|
||||
char pScopeStr[] = " query";
|
||||
int32_t scope = 0;
|
||||
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||
EXPECT_EQ(scope, SLOW_LOG_TYPE_QUERY);
|
||||
}
|
||||
|
||||
TEST(TaosSetSlowLogScopeTest, InsertScopeInput) {
|
||||
char pScope[] = "insert";
|
||||
int32_t result = taosSetSlowLogScope(pScope);
|
||||
EXPECT_EQ(result, SLOW_LOG_TYPE_INSERT);
|
||||
char pScopeStr[] = "insert";
|
||||
int32_t scope = 0;
|
||||
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||
EXPECT_EQ(scope, SLOW_LOG_TYPE_INSERT);
|
||||
}
|
||||
|
||||
TEST(TaosSetSlowLogScopeTest, OthersScopeInput) {
|
||||
char pScope[] = "others";
|
||||
int32_t result = taosSetSlowLogScope(pScope);
|
||||
EXPECT_EQ(result, SLOW_LOG_TYPE_OTHERS);
|
||||
char pScopeStr[] = "others";
|
||||
int32_t scope = 0;
|
||||
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||
EXPECT_EQ(scope, SLOW_LOG_TYPE_OTHERS);
|
||||
}
|
||||
|
||||
TEST(TaosSetSlowLogScopeTest, NoneScopeInput) {
|
||||
char pScope[] = "none";
|
||||
int32_t result = taosSetSlowLogScope(pScope);
|
||||
EXPECT_EQ(result, SLOW_LOG_TYPE_NULL);
|
||||
char pScopeStr[] = "none";
|
||||
int32_t scope = 0;
|
||||
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||
EXPECT_EQ(scope, SLOW_LOG_TYPE_NULL);
|
||||
}
|
||||
|
||||
TEST(TaosSetSlowLogScopeTest, InvalidScopeInput) {
|
||||
char pScope[] = "invalid";
|
||||
int32_t result = taosSetSlowLogScope(pScope);
|
||||
EXPECT_EQ(result, -1);
|
||||
char pScopeStr[] = "invalid";
|
||||
int32_t scope = 0;
|
||||
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||
EXPECT_EQ(scope, -1);
|
||||
}
|
||||
|
||||
TEST(TaosSetSlowLogScopeTest, MixedScopesInput) {
|
||||
char pScope[] = "query|insert|others|none";
|
||||
int32_t result = taosSetSlowLogScope(pScope);
|
||||
EXPECT_EQ(result, (SLOW_LOG_TYPE_QUERY | SLOW_LOG_TYPE_INSERT | SLOW_LOG_TYPE_OTHERS));
|
||||
char pScopeStr[] = "query|insert|others|none";
|
||||
int32_t scope = 0;
|
||||
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||
EXPECT_EQ(scope, (SLOW_LOG_TYPE_QUERY | SLOW_LOG_TYPE_INSERT | SLOW_LOG_TYPE_OTHERS));
|
||||
}
|
||||
|
||||
TEST(TaosSetSlowLogScopeTest, MixedScopesInputWithSpaces) {
|
||||
char pScope[] = "query | insert | others ";
|
||||
int32_t result = taosSetSlowLogScope(pScope);
|
||||
EXPECT_EQ(result, (SLOW_LOG_TYPE_QUERY | SLOW_LOG_TYPE_INSERT | SLOW_LOG_TYPE_OTHERS));
|
||||
char pScopeStr[] = "query | insert | others ";
|
||||
int32_t scope = 0;
|
||||
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||
EXPECT_EQ(scope, (SLOW_LOG_TYPE_QUERY | SLOW_LOG_TYPE_INSERT | SLOW_LOG_TYPE_OTHERS));
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -74,7 +74,7 @@ static struct {
|
|||
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
||||
} global = {0};
|
||||
|
||||
static void dmSetDebugFlag(int32_t signum, void *sigInfo, void *context) { taosSetGlobalDebugFlag(143); }
|
||||
static void dmSetDebugFlag(int32_t signum, void *sigInfo, void *context) { (void)taosSetGlobalDebugFlag(143); }
|
||||
static void dmSetAssert(int32_t signum, void *sigInfo, void *context) { tsAssert = 1; }
|
||||
|
||||
static void dmStopDnode(int signum, void *sigInfo, void *context) {
|
||||
|
|
|
@ -34,11 +34,8 @@ static void qmClose(SQnodeMgmt *pMgmt) {
|
|||
}
|
||||
|
||||
static int32_t qndOpenWrapper(SQnodeOpt *pOption, SQnode **pQnode) {
|
||||
*pQnode = qndOpen(pOption);
|
||||
if (*pQnode == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
return 0;
|
||||
int32_t code = qndOpen(pOption, pQnode);
|
||||
return code;
|
||||
}
|
||||
static int32_t qmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||
int32_t code = 0;
|
||||
|
@ -62,7 +59,7 @@ static int32_t qmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
|||
if (code != 0) {
|
||||
dError("failed to open qnode since %s", tstrerror(code));
|
||||
qmClose(pMgmt);
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
tmsgReportStartup("qnode-impl", "initialized");
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ static int32_t qmPutNodeMsgToWorker(SSingleWorker *pWorker, SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
int32_t qmPutNodeMsgToQueryQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
qndPreprocessQueryMsg(pMgmt->pQnode, pMsg);
|
||||
|
||||
int32_t code = qndPreprocessQueryMsg(pMgmt->pQnode, pMsg);
|
||||
if (code) return code;
|
||||
return qmPutNodeMsgToWorker(&pMgmt->queryWorker, pMsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,13 +109,6 @@ static int32_t dmCheckDiskSpace() {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tfsOpenWrapper(SDiskCfg *pCfg, int32_t ndisk, STfs **tfs) {
|
||||
*tfs = tfsOpen(pCfg, ndisk);
|
||||
if (*tfs == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int32_t dmDiskInit() {
|
||||
SDnode *pDnode = dmInstance();
|
||||
SDiskCfg dCfg = {.level = 0, .primary = 1, .disable = 0};
|
||||
|
@ -127,10 +120,10 @@ int32_t dmDiskInit() {
|
|||
numOfDisks = 1;
|
||||
}
|
||||
|
||||
int32_t code = tfsOpenWrapper(pDisks, numOfDisks, &pDnode->pTfs);
|
||||
int32_t code = tfsOpen(pDisks, numOfDisks, &pDnode->pTfs);
|
||||
if (code != 0) {
|
||||
dError("failed to init tfs since %s", tstrerror(code));
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -262,12 +255,12 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
|
|||
pWrapper = &pDnode->wrappers[ntype];
|
||||
if (taosMkDir(pWrapper->path) != 0) {
|
||||
dmReleaseWrapper(pWrapper);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to create dir:%s since %s", pWrapper->path, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
taosThreadMutexLock(&pDnode->mutex);
|
||||
(void)taosThreadMutexLock(&pDnode->mutex);
|
||||
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
||||
|
||||
dInfo("node:%s, start to create", pWrapper->name);
|
||||
|
@ -284,7 +277,7 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
|
|||
pWrapper->required = true;
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pDnode->mutex);
|
||||
(void)taosThreadMutexUnlock(&pDnode->mutex);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -323,7 +316,7 @@ static int32_t dmProcessAlterNodeTypeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
|
|||
|
||||
dInfo("node:%s, catched up leader, continue to process alter-node-type-request", pWrapper->name);
|
||||
|
||||
taosThreadMutexLock(&pDnode->mutex);
|
||||
(void)taosThreadMutexLock(&pDnode->mutex);
|
||||
|
||||
dInfo("node:%s, stopping node", pWrapper->name);
|
||||
dmStopNode(pWrapper);
|
||||
|
@ -332,8 +325,8 @@ static int32_t dmProcessAlterNodeTypeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
|
|||
|
||||
pWrapper = &pDnode->wrappers[ntype];
|
||||
if (taosMkDir(pWrapper->path) != 0) {
|
||||
taosThreadMutexUnlock(&pDnode->mutex);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
(void)taosThreadMutexUnlock(&pDnode->mutex);
|
||||
code = terrno;
|
||||
dError("failed to create dir:%s since %s", pWrapper->path, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
@ -354,7 +347,7 @@ static int32_t dmProcessAlterNodeTypeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
|
|||
pWrapper->required = true;
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pDnode->mutex);
|
||||
(void)taosThreadMutexUnlock(&pDnode->mutex);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -382,7 +375,7 @@ static int32_t dmProcessDropNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
|
|||
return terrno = code;
|
||||
}
|
||||
|
||||
taosThreadMutexLock(&pDnode->mutex);
|
||||
(void)taosThreadMutexLock(&pDnode->mutex);
|
||||
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
||||
|
||||
dInfo("node:%s, start to drop", pWrapper->name);
|
||||
|
@ -402,7 +395,7 @@ static int32_t dmProcessDropNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
|
|||
dmCloseNode(pWrapper);
|
||||
taosRemoveDir(pWrapper->path);
|
||||
}
|
||||
taosThreadMutexUnlock(&pDnode->mutex);
|
||||
(void)taosThreadMutexUnlock(&pDnode->mutex);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,8 @@ int32_t dmInitVars(SDnode *pDnode) {
|
|||
pData->rebootTime = taosGetTimestampMs();
|
||||
pData->dropped = 0;
|
||||
pData->stopped = 0;
|
||||
char *machineId = tGetMachineId();
|
||||
char *machineId = NULL;
|
||||
code = tGetMachineId(&machineId);
|
||||
if (machineId) {
|
||||
tstrncpy(pData->machineId, machineId, TSDB_MACHINE_ID_LEN + 1);
|
||||
taosMemoryFreeClear(machineId);
|
||||
|
@ -181,7 +182,7 @@ int32_t dmInitVars(SDnode *pDnode) {
|
|||
code = 0;
|
||||
strncpy(tsEncryptKey, tsAuthCode, 16);
|
||||
|
||||
if(code != 0) {
|
||||
if (code != 0) {
|
||||
if(code == -1){
|
||||
terrno = TSDB_CODE_DNODE_NO_ENCRYPT_KEY;
|
||||
dError("machine code changed, can't get crypt key");
|
||||
|
|
|
@ -21,7 +21,7 @@ int32_t dmOpenNode(SMgmtWrapper *pWrapper) {
|
|||
SDnode *pDnode = pWrapper->pDnode;
|
||||
|
||||
if (taosMkDir(pWrapper->path) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("node:%s, failed to create dir:%s since %s", pWrapper->name, pWrapper->path, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -380,6 +380,7 @@ _OVER:
|
|||
int32_t dmUpdateEncryptKey(char *key, bool toLogFile) {
|
||||
#ifdef TD_ENTERPRISE
|
||||
int32_t code = -1;
|
||||
int32_t lino = 0;
|
||||
char *machineId = NULL;
|
||||
char *encryptCode = NULL;
|
||||
|
||||
|
@ -417,7 +418,7 @@ int32_t dmUpdateEncryptKey(char *key, bool toLogFile) {
|
|||
}
|
||||
|
||||
if (taosMkDir(folder) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
encryptError("failed to create dir:%s since %s", folder, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -428,14 +429,9 @@ int32_t dmUpdateEncryptKey(char *key, bool toLogFile) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!(machineId = tGetMachineId())) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(tGetMachineId(&machineId), &lino, _OVER);
|
||||
|
||||
if ((code = generateEncryptCode(key, machineId, &encryptCode)) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(generateEncryptCode(key, machineId, &encryptCode), &lino, _OVER);
|
||||
|
||||
if ((code = dmWriteEncryptCodeFile(encryptFile, realEncryptFile, encryptCode, toLogFile)) != 0) {
|
||||
goto _OVER;
|
||||
|
@ -452,9 +448,9 @@ _OVER:
|
|||
taosMemoryFree(encryptCode);
|
||||
taosMemoryFree(machineId);
|
||||
if (code != 0) {
|
||||
encryptError("failed to update encrypt key since %s", tstrerror(code));
|
||||
encryptError("failed to update encrypt key at line %d since %s", lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -539,8 +535,7 @@ int32_t dmGetEncryptKey() {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
if (!(machineId = tGetMachineId())) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if ((code = tGetMachineId(&machineId)) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -574,8 +569,8 @@ _OVER:
|
|||
if (code != 0) {
|
||||
dError("failed to get encrypt key since %s", tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ enum {
|
|||
|
||||
int32_t mndInitConsumer(SMnode *pMnode);
|
||||
void mndCleanupConsumer(SMnode *pMnode);
|
||||
void mndSendConsumerMsg(SMnode *pMnode, int64_t consumerId, uint16_t msgType, SRpcHandleInfo* info);
|
||||
int32_t mndSendConsumerMsg(SMnode *pMnode, int64_t consumerId, uint16_t msgType, SRpcHandleInfo* info);
|
||||
|
||||
SMqConsumerObj *mndAcquireConsumer(SMnode *pMnode, int64_t consumerId);
|
||||
void mndReleaseConsumer(SMnode *pMnode, SMqConsumerObj *pConsumer);
|
||||
int32_t mndAcquireConsumer(SMnode *pMnode, int64_t consumerId, SMqConsumerObj** pConsumer);
|
||||
void mndReleaseConsumer(SMnode *pMnode, SMqConsumerObj *pConsumer);
|
||||
|
||||
SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer);
|
||||
SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw);
|
||||
|
@ -43,6 +43,22 @@ int32_t mndSetConsumerDropLogs(STrans *pTrans, SMqConsumerObj *pConsumer);
|
|||
|
||||
const char *mndConsumerStatusName(int status);
|
||||
|
||||
#define MND_TMQ_NULL_CHECK(c) \
|
||||
do { \
|
||||
if (c == NULL) { \
|
||||
code = TSDB_CODE_OUT_OF_MEMORY; \
|
||||
goto END; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define MND_TMQ_RETURN_CHECK(c) \
|
||||
do { \
|
||||
code = c; \
|
||||
if (code != 0) { \
|
||||
goto END; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -622,7 +622,8 @@ typedef struct {
|
|||
int32_t resetOffsetCfg;
|
||||
} SMqConsumerObj;
|
||||
|
||||
SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType, char *topic, SCMSubscribeReq *subscribe);
|
||||
int32_t tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType,
|
||||
char *topic, SCMSubscribeReq *subscribe, SMqConsumerObj** ppConsumer);
|
||||
void tClearSMqConsumerObj(SMqConsumerObj* pConsumer);
|
||||
void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer);
|
||||
int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer);
|
||||
|
@ -665,8 +666,8 @@ typedef struct {
|
|||
char* qmsg; // SubPlanToString
|
||||
} SMqSubscribeObj;
|
||||
|
||||
SMqSubscribeObj* tNewSubscribeObj(const char key[TSDB_SUBSCRIBE_KEY_LEN]);
|
||||
SMqSubscribeObj* tCloneSubscribeObj(const SMqSubscribeObj* pSub);
|
||||
int32_t tNewSubscribeObj(const char *key, SMqSubscribeObj **ppSub);
|
||||
int32_t tCloneSubscribeObj(const SMqSubscribeObj* pSub, SMqSubscribeObj **ppSub);
|
||||
void tDeleteSubscribeObj(SMqSubscribeObj* pSub);
|
||||
int32_t tEncodeSubscribeObj(void** buf, const SMqSubscribeObj* pSub);
|
||||
void* tDecodeSubscribeObj(const void* buf, SMqSubscribeObj* pSub, int8_t sver);
|
||||
|
|
|
@ -30,7 +30,7 @@ SEpSet mndGetDnodeEpset(SDnodeObj *pDnode);
|
|||
SEpSet mndGetDnodeEpsetById(SMnode *pMnode, int32_t dnodeId);
|
||||
int32_t mndGetDnodeSize(SMnode *pMnode);
|
||||
bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs);
|
||||
void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo);
|
||||
int32_t mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -23,11 +23,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define COL_DATA_SET_VAL_RET(pData, isNull, pObj) \
|
||||
#define COL_DATA_SET_VAL_GOTO(pData, isNull, pObj, LABEL) \
|
||||
do { \
|
||||
if ((code = colDataSetVal(pColInfo, numOfRows, (pData), (isNull))) != 0) { \
|
||||
if (pObj) sdbRelease(pSdb, (pObj)); \
|
||||
return code; \
|
||||
lino = __LINE__; \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
|
|
@ -96,57 +96,58 @@ typedef struct STaskChkptInfo {
|
|||
int8_t dropHTask;
|
||||
}STaskChkptInfo;
|
||||
|
||||
int32_t mndInitStream(SMnode *pMnode);
|
||||
void mndCleanupStream(SMnode *pMnode);
|
||||
SStreamObj *mndAcquireStream(SMnode *pMnode, char *streamName);
|
||||
void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream);
|
||||
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
||||
int32_t mndPersistStream(STrans *pTrans, SStreamObj *pStream);
|
||||
int32_t mndStreamRegisterTrans(STrans *pTrans, const char *pTransName, int64_t streamId);
|
||||
int32_t mndStreamClearFinishedTrans(SMnode *pMnode, int32_t *pNumOfActiveChkpt);
|
||||
bool mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *pTransName, bool lock);
|
||||
int32_t mndStreamGetRelTrans(SMnode *pMnode, int64_t streamId);
|
||||
int32_t mndInitStream(SMnode *pMnode);
|
||||
void mndCleanupStream(SMnode *pMnode);
|
||||
int32_t mndAcquireStream(SMnode *pMnode, char *streamName, SStreamObj **pStream);
|
||||
void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream);
|
||||
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
||||
int32_t mndPersistStream(STrans *pTrans, SStreamObj *pStream);
|
||||
int32_t mndStreamRegisterTrans(STrans *pTrans, const char *pTransName, int64_t streamId);
|
||||
int32_t mndStreamClearFinishedTrans(SMnode *pMnode, int32_t *pNumOfActiveChkpt);
|
||||
bool mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *pTransName, bool lock);
|
||||
int32_t mndStreamGetRelTrans(SMnode *pMnode, int64_t streamId);
|
||||
|
||||
int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams);
|
||||
int32_t mndGetNumOfStreamTasks(const SStreamObj *pStream);
|
||||
SArray *mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady);
|
||||
int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray** pList);
|
||||
void mndKillTransImpl(SMnode *pMnode, int32_t transId, const char *pDbName);
|
||||
int32_t setTransAction(STrans *pTrans, void *pCont, int32_t contLen, int32_t msgType, const SEpSet *pEpset,
|
||||
int32_t retryCode, int32_t acceptCode);
|
||||
STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, ETrnConflct conflict, const char *name, const char *pMsg);
|
||||
int32_t doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, ETrnConflct conflict, const char *name,
|
||||
const char *pMsg, STrans **pTrans1);
|
||||
int32_t mndPersistTransLog(SStreamObj *pStream, STrans *pTrans, int32_t status);
|
||||
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream);
|
||||
void killAllCheckpointTrans(SMnode *pMnode, SVgroupChangeInfo *pChangeInfo);
|
||||
int32_t mndStreamSetUpdateEpsetAction(SMnode *pMnode, SStreamObj *pStream, SVgroupChangeInfo *pInfo, STrans *pTrans);
|
||||
|
||||
SStreamObj *mndGetStreamObj(SMnode *pMnode, int64_t streamId);
|
||||
int32_t extractNodeEpset(SMnode *pMnode, SEpSet *pEpSet, bool *hasEpset, int32_t taskId, int32_t nodeId);
|
||||
int32_t mndProcessStreamHb(SRpcMsg *pReq);
|
||||
void saveTaskAndNodeInfoIntoBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode);
|
||||
int32_t extractStreamNodeList(SMnode *pMnode);
|
||||
int32_t mndStreamSetResumeAction(STrans *pTrans, SMnode *pMnode, SStreamObj *pStream, int8_t igUntreated);
|
||||
int32_t mndStreamSetPauseAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||
int32_t mndStreamSetDropAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||
int32_t mndStreamSetDropActionFromList(SMnode *pMnode, STrans *pTrans, SArray *pList);
|
||||
int32_t mndStreamSetResetTaskAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||
int32_t mndCreateStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream);
|
||||
int32_t mndStreamSetUpdateChkptAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||
int32_t mndCreateStreamChkptInfoUpdateTrans(SMnode *pMnode, SStreamObj *pStream, SArray *pChkptInfoList);
|
||||
int32_t mndScanCheckpointReportInfo(SRpcMsg *pReq);
|
||||
int32_t mndCreateSetConsensusChkptIdTrans(SMnode *pMnode, SStreamObj *pStream, int32_t taskId, int64_t checkpointId,
|
||||
int64_t ts);
|
||||
void removeTasksInBuf(SArray *pTaskIds, SStreamExecInfo *pExecInfo);
|
||||
int32_t mndGetStreamObj(SMnode *pMnode, int64_t streamId, SStreamObj** pStream);
|
||||
int32_t extractNodeEpset(SMnode *pMnode, SEpSet *pEpSet, bool *hasEpset, int32_t taskId, int32_t nodeId);
|
||||
int32_t mndProcessStreamHb(SRpcMsg *pReq);
|
||||
void saveTaskAndNodeInfoIntoBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode);
|
||||
int32_t extractStreamNodeList(SMnode *pMnode);
|
||||
int32_t mndStreamSetResumeAction(STrans *pTrans, SMnode *pMnode, SStreamObj *pStream, int8_t igUntreated);
|
||||
int32_t mndStreamSetPauseAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||
int32_t mndStreamSetDropAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||
int32_t mndStreamSetDropActionFromList(SMnode *pMnode, STrans *pTrans, SArray *pList);
|
||||
int32_t mndStreamSetResetTaskAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||
int32_t mndCreateStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream);
|
||||
int32_t mndStreamSetUpdateChkptAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||
int32_t mndCreateStreamChkptInfoUpdateTrans(SMnode *pMnode, SStreamObj *pStream, SArray *pChkptInfoList);
|
||||
int32_t mndScanCheckpointReportInfo(SRpcMsg *pReq);
|
||||
int32_t mndCreateSetConsensusChkptIdTrans(SMnode *pMnode, SStreamObj *pStream, int32_t taskId, int64_t checkpointId,
|
||||
int64_t ts);
|
||||
void removeTasksInBuf(SArray *pTaskIds, SStreamExecInfo *pExecInfo);
|
||||
|
||||
SStreamTaskIter *createStreamTaskIter(SStreamObj *pStream);
|
||||
void destroyStreamTaskIter(SStreamTaskIter *pIter);
|
||||
bool streamTaskIterNextTask(SStreamTaskIter *pIter);
|
||||
SStreamTask *streamTaskIterGetCurrent(SStreamTaskIter *pIter);
|
||||
void mndInitExecInfo();
|
||||
void mndInitStreamExecInfo(SMnode *pMnode, SStreamExecInfo *pExecInfo);
|
||||
int32_t removeExpiredNodeEntryAndTaskInBuf(SArray *pNodeSnapshot);
|
||||
void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode);
|
||||
int32_t createStreamTaskIter(SStreamObj *pStream, SStreamTaskIter **pIter);
|
||||
void destroyStreamTaskIter(SStreamTaskIter *pIter);
|
||||
bool streamTaskIterNextTask(SStreamTaskIter *pIter);
|
||||
int32_t streamTaskIterGetCurrent(SStreamTaskIter *pIter, SStreamTask **pTask);
|
||||
int32_t mndInitExecInfo();
|
||||
void mndInitStreamExecInfo(SMnode *pMnode, SStreamExecInfo *pExecInfo);
|
||||
int32_t removeExpiredNodeEntryAndTaskInBuf(SArray *pNodeSnapshot);
|
||||
void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode);
|
||||
|
||||
SCheckpointConsensusInfo *mndGetConsensusInfo(SHashObj *pHash, int64_t streamId, int32_t numOfTasks);
|
||||
int32_t mndGetConsensusInfo(SHashObj *pHash, int64_t streamId, int32_t numOfTasks, SCheckpointConsensusInfo **pInfo);
|
||||
void mndAddConsensusTasks(SCheckpointConsensusInfo *pInfo, const SRestoreCheckpointInfo *pRestoreInfo);
|
||||
void mndClearConsensusRspEntry(SCheckpointConsensusInfo *pInfo);
|
||||
int64_t mndClearConsensusCheckpointId(SHashObj* pHash, int64_t streamId);
|
||||
|
|
|
@ -26,12 +26,9 @@ int32_t mndInitSubscribe(SMnode *pMnode);
|
|||
void mndCleanupSubscribe(SMnode *pMnode);
|
||||
|
||||
int32_t mndGetGroupNumByTopic(SMnode *pMnode, const char *topicName);
|
||||
SMqSubscribeObj *mndAcquireSubscribe(SMnode *pMnode, const char *CGroup, const char *topicName);
|
||||
SMqSubscribeObj *mndAcquireSubscribeByKey(SMnode *pMnode, const char *key);
|
||||
int32_t mndAcquireSubscribeByKey(SMnode *pMnode, const char *key, SMqSubscribeObj** pSub);
|
||||
void mndReleaseSubscribe(SMnode *pMnode, SMqSubscribeObj *pSub);
|
||||
|
||||
void mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName);
|
||||
|
||||
int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topic);
|
||||
int32_t mndSetDropSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj *pSub);
|
||||
|
||||
|
|
|
@ -25,13 +25,12 @@ extern "C" {
|
|||
int32_t mndInitTopic(SMnode *pMnode);
|
||||
void mndCleanupTopic(SMnode *pMnode);
|
||||
|
||||
SMqTopicObj *mndAcquireTopic(SMnode *pMnode, const char *topicName);
|
||||
int32_t mndAcquireTopic(SMnode *pMnode, const char *topicName, SMqTopicObj **pTopic);
|
||||
void mndReleaseTopic(SMnode *pMnode, SMqTopicObj *pTopic);
|
||||
int32_t mndDropTopicByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
||||
bool mndTopicExistsForDb(SMnode *pMnode, SDbObj *pDb);
|
||||
const char *mndTopicGetShowName(const char topic[TSDB_TOPIC_FNAME_LEN]);
|
||||
void mndTopicGetShowName(const char* fullTopic, char* topic);
|
||||
|
||||
int32_t mndSetTopicCommitLogs(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic);
|
||||
int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTopics);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -27,29 +27,29 @@ enum {
|
|||
IP_WHITE_ADD,
|
||||
IP_WHITE_DROP,
|
||||
};
|
||||
int32_t mndInitUser(SMnode *pMnode);
|
||||
void mndCleanupUser(SMnode *pMnode);
|
||||
SUserObj *mndAcquireUser(SMnode *pMnode, const char *userName);
|
||||
void mndReleaseUser(SMnode *pMnode, SUserObj *pUser);
|
||||
int32_t mndInitUser(SMnode *pMnode);
|
||||
void mndCleanupUser(SMnode *pMnode);
|
||||
int32_t mndAcquireUser(SMnode *pMnode, const char *userName, SUserObj **ppUser);
|
||||
void mndReleaseUser(SMnode *pMnode, SUserObj *pUser);
|
||||
|
||||
// for trans test
|
||||
SSdbRaw *mndUserActionEncode(SUserObj *pUser);
|
||||
SHashObj *mndDupDbHash(SHashObj *pOld);
|
||||
SHashObj *mndDupTableHash(SHashObj *pOld);
|
||||
SHashObj *mndDupTopicHash(SHashObj *pOld);
|
||||
int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp,
|
||||
int32_t *pRspLen, int64_t ipWhiteListVer);
|
||||
int32_t mndUserRemoveDb(SMnode *pMnode, STrans *pTrans, char *db);
|
||||
int32_t mndUserRemoveStb(SMnode *pMnode, STrans *pTrans, char *stb);
|
||||
int32_t mndUserRemoveView(SMnode *pMnode, STrans *pTrans, char *view);
|
||||
int32_t mndUserRemoveTopic(SMnode *pMnode, STrans *pTrans, char *topic);
|
||||
SSdbRaw *mndUserActionEncode(SUserObj *pUser);
|
||||
int32_t mndDupDbHash(SHashObj *pOld, SHashObj **ppNew);
|
||||
int32_t mndDupTableHash(SHashObj *pOld, SHashObj **ppNew);
|
||||
int32_t mndDupTopicHash(SHashObj *pOld, SHashObj **ppNew);
|
||||
int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp,
|
||||
int32_t *pRspLen, int64_t ipWhiteListVer);
|
||||
int32_t mndUserRemoveDb(SMnode *pMnode, STrans *pTrans, char *db);
|
||||
int32_t mndUserRemoveStb(SMnode *pMnode, STrans *pTrans, char *stb);
|
||||
int32_t mndUserRemoveView(SMnode *pMnode, STrans *pTrans, char *view);
|
||||
int32_t mndUserRemoveTopic(SMnode *pMnode, STrans *pTrans, char *topic);
|
||||
|
||||
int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew);
|
||||
void mndUserFreeObj(SUserObj *pUser);
|
||||
|
||||
int64_t mndGetIpWhiteVer(SMnode *pMnode);
|
||||
|
||||
void mndUpdateIpWhiteForAllUser(SMnode *pMnode, char *user, char *fqdn, int8_t type, int8_t lock);
|
||||
int32_t mndUpdateIpWhiteForAllUser(SMnode *pMnode, char *user, char *fqdn, int8_t type, int8_t lock);
|
||||
|
||||
int32_t mndRefreshUserIpWhiteList(SMnode *pMnode);
|
||||
|
||||
|
|
|
@ -113,6 +113,8 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) {
|
|||
}
|
||||
|
||||
static SSdbRaw *mndAcctActionEncode(SAcctObj *pAcct) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_ACCT, ACCT_VER_NUMBER, sizeof(SAcctObj) + ACCT_RESERVE_SIZE);
|
||||
|
@ -153,6 +155,8 @@ _OVER:
|
|||
}
|
||||
|
||||
static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
SAcctObj *pAcct = NULL;
|
||||
SSdbRow *pRow = NULL;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue