Merge branch '3.0' of https://github.com/taosdata/TDengine into fix/TD-30967
This commit is contained in:
commit
c5853ed720
|
@ -49,7 +49,7 @@ typedef struct SBlockOrderInfo {
|
|||
#define colDataSetNull_f_s(c_, r_) \
|
||||
do { \
|
||||
colDataSetNull_f((c_)->nullbitmap, r_); \
|
||||
memset(((char*)(c_)->pData) + (c_)->info.bytes * (r_), 0, (c_)->info.bytes); \
|
||||
(void)memset(((char*)(c_)->pData) + (c_)->info.bytes * (r_), 0, (c_)->info.bytes); \
|
||||
} while (0)
|
||||
|
||||
#define colDataClearNull_f(bm_, r_) \
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -260,7 +260,7 @@ 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);
|
||||
|
||||
|
@ -273,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);
|
||||
|
|
|
@ -77,7 +77,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);
|
||||
|
||||
|
|
|
@ -860,6 +860,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)
|
||||
|
|
|
@ -897,7 +897,11 @@ void taos_init_imp(void) {
|
|||
tscError("failed to init task queue");
|
||||
return;
|
||||
}
|
||||
fmFuncMgtInit();
|
||||
if (fmFuncMgtInit() != TSDB_CODE_SUCCESS) {
|
||||
tscInitRes = -1;
|
||||
tscError("failed to init function manager");
|
||||
return;
|
||||
}
|
||||
nodesInitAllocatorSet();
|
||||
|
||||
clientConnRefPool = taosOpenRef(200, destroyTscObj);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,173 +12,179 @@
|
|||
* 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/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndDef.h"
|
||||
#include "mndConsumer.h"
|
||||
#include "taoserror.h"
|
||||
|
||||
static void *freeStreamTasks(SArray *pTaskLevel);
|
||||
|
||||
int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
||||
if (tStartEncode(pEncoder) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pObj->name) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tStartEncode(pEncoder));
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->name));
|
||||
|
||||
if (tEncodeI64(pEncoder, pObj->createTime) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pObj->updateTime) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pObj->version) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pObj->totalLevel) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pObj->smaId) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->createTime));
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->updateTime));
|
||||
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pObj->version));
|
||||
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pObj->totalLevel));
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->smaId));
|
||||
|
||||
if (tEncodeI64(pEncoder, pObj->uid) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pObj->status) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->uid));
|
||||
TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->status));
|
||||
|
||||
if (tEncodeI8(pEncoder, pObj->conf.igExpired) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pObj->conf.trigger) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pObj->conf.fillHistory) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pObj->conf.triggerParam) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pObj->conf.watermark) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->conf.igExpired));
|
||||
TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->conf.trigger));
|
||||
TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->conf.fillHistory));
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->conf.triggerParam));
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->conf.watermark));
|
||||
|
||||
if (tEncodeI64(pEncoder, pObj->sourceDbUid) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pObj->targetDbUid) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pObj->sourceDb) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pObj->targetDb) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pObj->targetSTbName) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pObj->targetStbUid) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pObj->fixedSinkVgId) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->sourceDbUid));
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->targetDbUid));
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->sourceDb));
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->targetDb));
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->targetSTbName));
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->targetStbUid));
|
||||
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pObj->fixedSinkVgId));
|
||||
|
||||
if (pObj->sql != NULL) {
|
||||
if (tEncodeCStr(pEncoder, pObj->sql) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->sql));
|
||||
} else {
|
||||
if (tEncodeCStr(pEncoder, "") < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, ""));
|
||||
}
|
||||
|
||||
if (pObj->ast != NULL) {
|
||||
if (tEncodeCStr(pEncoder, pObj->ast) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->ast));
|
||||
} else {
|
||||
if (tEncodeCStr(pEncoder, "") < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, ""));
|
||||
}
|
||||
|
||||
if (pObj->physicalPlan != NULL) {
|
||||
if (tEncodeCStr(pEncoder, pObj->physicalPlan) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->physicalPlan));
|
||||
} else {
|
||||
if (tEncodeCStr(pEncoder, "") < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, ""));
|
||||
}
|
||||
|
||||
int32_t sz = taosArrayGetSize(pObj->tasks);
|
||||
if (tEncodeI32(pEncoder, sz) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, sz));
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SArray *pArray = taosArrayGetP(pObj->tasks, i);
|
||||
int32_t innerSz = taosArrayGetSize(pArray);
|
||||
if (tEncodeI32(pEncoder, innerSz) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, innerSz));
|
||||
for (int32_t j = 0; j < innerSz; j++) {
|
||||
SStreamTask *pTask = taosArrayGetP(pArray, j);
|
||||
if (pTask->ver < SSTREAM_TASK_SUBTABLE_CHANGED_VER){
|
||||
pTask->ver = SSTREAM_TASK_VER;
|
||||
}
|
||||
if (tEncodeStreamTask(pEncoder, pTask) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeStreamTask(pEncoder, pTask));
|
||||
}
|
||||
}
|
||||
|
||||
if (tEncodeSSchemaWrapper(pEncoder, &pObj->outputSchema) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pEncoder, &pObj->outputSchema));
|
||||
|
||||
// 3.0.20 ver =2
|
||||
if (tEncodeI64(pEncoder, pObj->checkpointFreq) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pObj->igCheckUpdate) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->checkpointFreq));
|
||||
TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->igCheckUpdate));
|
||||
|
||||
// 3.0.50 ver = 3
|
||||
if (tEncodeI64(pEncoder, pObj->checkpointId) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pObj->subTableWithoutMd5) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->checkpointId));
|
||||
TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->subTableWithoutMd5));
|
||||
|
||||
if (tEncodeCStrWithLen(pEncoder, pObj->reserve, sizeof(pObj->reserve) - 1) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeCStrWithLen(pEncoder, pObj->reserve, sizeof(pObj->reserve) - 1));
|
||||
|
||||
tEndEncode(pEncoder);
|
||||
return pEncoder->pos;
|
||||
}
|
||||
|
||||
int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj, int32_t sver) {
|
||||
if (tStartDecode(pDecoder) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pObj->name) < 0) return -1;
|
||||
int32_t code = 0;
|
||||
TAOS_CHECK_RETURN(tStartDecode(pDecoder));
|
||||
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->name));
|
||||
|
||||
if (tDecodeI64(pDecoder, &pObj->createTime) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pObj->updateTime) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pObj->version) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pObj->totalLevel) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pObj->smaId) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->createTime));
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->updateTime));
|
||||
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pObj->version));
|
||||
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pObj->totalLevel));
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->smaId));
|
||||
|
||||
if (tDecodeI64(pDecoder, &pObj->uid) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->uid));
|
||||
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->status));
|
||||
|
||||
if (tDecodeI8(pDecoder, &pObj->conf.igExpired) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pObj->conf.trigger) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pObj->conf.fillHistory) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pObj->conf.triggerParam) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pObj->conf.watermark) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->conf.igExpired));
|
||||
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->conf.trigger));
|
||||
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->conf.fillHistory));
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->conf.triggerParam));
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->conf.watermark));
|
||||
|
||||
if (tDecodeI64(pDecoder, &pObj->sourceDbUid) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pObj->targetDbUid) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pObj->sourceDb) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pObj->targetDb) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pObj->targetSTbName) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pObj->targetStbUid) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pObj->fixedSinkVgId) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->sourceDbUid));
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->targetDbUid));
|
||||
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->sourceDb));
|
||||
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->targetDb));
|
||||
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->targetSTbName));
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->targetStbUid));
|
||||
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pObj->fixedSinkVgId));
|
||||
|
||||
if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1;
|
||||
if (tDecodeCStrAlloc(pDecoder, &pObj->ast) < 0) return -1;
|
||||
if (tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeCStrAlloc(pDecoder, &pObj->sql));
|
||||
TAOS_CHECK_RETURN(tDecodeCStrAlloc(pDecoder, &pObj->ast));
|
||||
TAOS_CHECK_RETURN(tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan));
|
||||
|
||||
if (pObj->tasks != NULL) {
|
||||
pObj->tasks = freeStreamTasks(pObj->tasks);
|
||||
}
|
||||
|
||||
int32_t sz;
|
||||
if (tDecodeI32(pDecoder, &sz) < 0) {
|
||||
return -1;
|
||||
}
|
||||
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &sz));
|
||||
|
||||
if (sz != 0) {
|
||||
pObj->tasks = taosArrayInit(sz, sizeof(void *));
|
||||
if (pObj->tasks == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
int32_t innerSz;
|
||||
if (tDecodeI32(pDecoder, &innerSz) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &innerSz));
|
||||
SArray *pArray = taosArrayInit(innerSz, sizeof(void *));
|
||||
if (pArray != NULL) {
|
||||
for (int32_t j = 0; j < innerSz; j++) {
|
||||
SStreamTask *pTask = taosMemoryCalloc(1, sizeof(SStreamTask));
|
||||
if (pTask == NULL) {
|
||||
taosArrayDestroy(pArray);
|
||||
return -1;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
if (tDecodeStreamTask(pDecoder, pTask) < 0) {
|
||||
if ((code = tDecodeStreamTask(pDecoder, pTask)) < 0) {
|
||||
taosMemoryFree(pTask);
|
||||
taosArrayDestroy(pArray);
|
||||
return -1;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
taosArrayPush(pArray, &pTask);
|
||||
}
|
||||
}
|
||||
taosArrayPush(pObj->tasks, &pArray);
|
||||
}
|
||||
}
|
||||
|
||||
if (tDecodeSSchemaWrapper(pDecoder, &pObj->outputSchema) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeSSchemaWrapper(pDecoder, &pObj->outputSchema));
|
||||
|
||||
// 3.0.20
|
||||
if (sver >= 2) {
|
||||
if (tDecodeI64(pDecoder, &pObj->checkpointFreq) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->checkpointFreq));
|
||||
if (!tDecodeIsEnd(pDecoder)) {
|
||||
if (tDecodeI8(pDecoder, &pObj->igCheckUpdate) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->igCheckUpdate));
|
||||
}
|
||||
}
|
||||
if (sver >= 3) {
|
||||
if (tDecodeI64(pDecoder, &pObj->checkpointId) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->checkpointId));
|
||||
}
|
||||
|
||||
if (sver >= 5) {
|
||||
if (tDecodeI8(pDecoder, &pObj->subTableWithoutMd5) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pObj->subTableWithoutMd5));
|
||||
}
|
||||
if (tDecodeCStrTo(pDecoder, pObj->reserve) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->reserve));
|
||||
|
||||
tEndDecode(pDecoder);
|
||||
return 0;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
void *freeStreamTasks(SArray *pTaskLevel) {
|
||||
|
@ -220,7 +226,10 @@ void tFreeStreamObj(SStreamObj *pStream) {
|
|||
|
||||
SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) {
|
||||
SMqVgEp *pVgEpNew = taosMemoryMalloc(sizeof(SMqVgEp));
|
||||
if (pVgEpNew == NULL) return NULL;
|
||||
if (pVgEpNew == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
pVgEpNew->vgId = pVgEp->vgId;
|
||||
// pVgEpNew->qmsg = taosStrdup(pVgEp->qmsg);
|
||||
pVgEpNew->epSet = pVgEp->epSet;
|
||||
|
@ -256,6 +265,7 @@ void *tDecodeSMqVgEp(const void *buf, SMqVgEp *pVgEp, int8_t sver) {
|
|||
static void *topicNameDup(void *p) { return taosStrdup((char *)p); }
|
||||
|
||||
SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType, char *topic, SCMSubscribeReq *subscribe) {
|
||||
terrno = 0;
|
||||
SMqConsumerObj *pConsumer = taosMemoryCalloc(1, sizeof(SMqConsumerObj));
|
||||
if (pConsumer == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -531,8 +541,10 @@ void *tDecodeSMqConsumerEp(const void *buf, SMqConsumerEp *pConsumerEp, int8_t s
|
|||
}
|
||||
|
||||
SMqSubscribeObj *tNewSubscribeObj(const char *key) {
|
||||
terrno = 0;
|
||||
SMqSubscribeObj *pSubObj = taosMemoryCalloc(1, sizeof(SMqSubscribeObj));
|
||||
if (pSubObj == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -548,8 +560,12 @@ SMqSubscribeObj *tNewSubscribeObj(const char *key) {
|
|||
}
|
||||
|
||||
SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
|
||||
terrno = 0;
|
||||
SMqSubscribeObj *pSubNew = taosMemoryMalloc(sizeof(SMqSubscribeObj));
|
||||
if (pSubNew == NULL) return NULL;
|
||||
if (pSubNew == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
memcpy(pSubNew->key, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||
taosInitRWLatch(&pSubNew->lock);
|
||||
|
||||
|
|
|
@ -165,15 +165,24 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
|
|||
}
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
if (pTrans == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
mInfo("trans:%d, used to create dnode:%s on first deploy", pTrans->id, dnodeObj.ep);
|
||||
|
||||
pRaw = mndDnodeActionEncode(&dnodeObj);
|
||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
||||
if (pRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
pRaw = NULL;
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||
code = 0;
|
||||
mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, dnodeObj.fqdn, IP_WHITE_ADD, 1);
|
||||
|
||||
|
@ -563,10 +572,7 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
|||
SStatisReq statisReq = {0};
|
||||
int32_t code = -1;
|
||||
|
||||
if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return code;
|
||||
}
|
||||
TAOS_CHECK_RETURN(tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq));
|
||||
|
||||
if (tsMonitorLogProtocol) {
|
||||
mInfo("process statis req,\n %s", statisReq.pCont);
|
||||
|
@ -586,23 +592,28 @@ static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) {
|
|||
int32_t code = 0;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "update-dnode-obj");
|
||||
if (pTrans == NULL) {
|
||||
code = terrno;
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
pDnode->updateTime = taosGetTimestampMs();
|
||||
|
||||
SSdbRaw *pCommitRaw = mndDnodeActionEncode(pDnode);
|
||||
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
|
||||
if (pCommitRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
if ((code = mndTransAppendCommitlog(pTrans, pCommitRaw)) != 0) {
|
||||
mError("trans:%d, failed to append commit log since %s", pTrans->id, tstrerror(code));
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
code = terrno;
|
||||
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, tstrerror(code));
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
@ -617,10 +628,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
SDnodeObj *pDnode = NULL;
|
||||
int32_t code = -1;
|
||||
|
||||
if (tDeserializeSStatusReq(pReq->pCont, pReq->contLen, &statusReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(tDeserializeSStatusReq(pReq->pCont, pReq->contLen, &statusReq), NULL, _OVER);
|
||||
|
||||
int64_t clusterid = mndGetClusterId(pMnode);
|
||||
if (statusReq.clusterId != 0 && statusReq.clusterId != clusterid) {
|
||||
|
@ -634,6 +642,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
pDnode = mndAcquireDnodeByEp(pMnode, statusReq.dnodeEp);
|
||||
if (pDnode == NULL) {
|
||||
mInfo("dnode:%s, not created yet", statusReq.dnodeEp);
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
} else {
|
||||
|
@ -871,16 +881,25 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
|
|||
snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", pCreate->fqdn, pCreate->port);
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
if (pTrans == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
mInfo("trans:%d, used to create dnode:%s", pTrans->id, dnodeObj.ep);
|
||||
if (mndTransCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(mndTransCheckConflict(pMnode, pTrans), NULL, _OVER);
|
||||
|
||||
pRaw = mndDnodeActionEncode(&dnodeObj);
|
||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
||||
if (pRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
pRaw = NULL;
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||
code = 0;
|
||||
|
||||
mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, dnodeObj.fqdn, IP_WHITE_ADD, 1);
|
||||
|
@ -901,7 +920,7 @@ static int32_t mndProcessDnodeListReq(SRpcMsg *pReq) {
|
|||
rsp.dnodeList = taosArrayInit(5, sizeof(SEpSet));
|
||||
if (NULL == rsp.dnodeList) {
|
||||
mError("failed to alloc epSet while process dnode list req");
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -922,7 +941,7 @@ static int32_t mndProcessDnodeListReq(SRpcMsg *pReq) {
|
|||
int32_t rspLen = tSerializeSDnodeListRsp(NULL, 0, &rsp);
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -935,12 +954,12 @@ static int32_t mndProcessDnodeListReq(SRpcMsg *pReq) {
|
|||
_OVER:
|
||||
|
||||
if (code != 0) {
|
||||
mError("failed to get dnode list since %s", terrstr());
|
||||
mError("failed to get dnode list since %s", tstrerror(code));
|
||||
}
|
||||
|
||||
tFreeSDnodeListRsp(&rsp);
|
||||
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static void getSlowLogScopeString(int32_t scope, char* result){
|
||||
|
@ -980,7 +999,7 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
|
|||
rsp.variables = taosArrayInit(16, sizeof(SVariablesInfo));
|
||||
if (NULL == rsp.variables) {
|
||||
mError("failed to alloc SVariablesInfo array while process show variables req");
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -1036,7 +1055,7 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
|
|||
int32_t rspLen = tSerializeSShowVariablesRsp(NULL, 0, &rsp);
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -1049,11 +1068,11 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
|
|||
_OVER:
|
||||
|
||||
if (code != 0) {
|
||||
mError("failed to get show variables info since %s", terrstr());
|
||||
mError("failed to get show variables info since %s", tstrerror(code));
|
||||
}
|
||||
|
||||
tFreeSShowVariablesRsp(&rsp);
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
||||
|
@ -1062,23 +1081,17 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
|||
SDnodeObj *pDnode = NULL;
|
||||
SCreateDnodeReq createReq = {0};
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_DNODE)) != 0 || (terrno = grantCheck(TSDB_GRANT_CPU_CORES)) != 0) {
|
||||
code = terrno;
|
||||
if ((code = grantCheck(TSDB_GRANT_DNODE)) != 0 || (code = grantCheck(TSDB_GRANT_CPU_CORES)) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (tDeserializeSCreateDnodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(tDeserializeSCreateDnodeReq(pReq->pCont, pReq->contLen, &createReq), NULL, _OVER);
|
||||
|
||||
mInfo("dnode:%s:%d, start to create", createReq.fqdn, createReq.port);
|
||||
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CREATE_DNODE) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CREATE_DNODE), NULL, _OVER);
|
||||
|
||||
if (createReq.fqdn[0] == 0 || createReq.port <= 0 || createReq.port > UINT16_MAX) {
|
||||
terrno = TSDB_CODE_MND_INVALID_DNODE_EP;
|
||||
code = TSDB_CODE_MND_INVALID_DNODE_EP;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -1086,7 +1099,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
|||
snprintf(ep, TSDB_EP_LEN, "%s:%d", createReq.fqdn, createReq.port);
|
||||
pDnode = mndAcquireDnodeByEp(pMnode, ep);
|
||||
if (pDnode != NULL) {
|
||||
terrno = TSDB_CODE_MND_DNODE_ALREADY_EXIST;
|
||||
code = TSDB_CODE_MND_DNODE_ALREADY_EXIST;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -1103,12 +1116,12 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
|||
|
||||
_OVER:
|
||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("dnode:%s:%d, failed to create since %s", createReq.fqdn, createReq.port, terrstr());
|
||||
mError("dnode:%s:%d, failed to create since %s", createReq.fqdn, createReq.port, tstrerror(code));
|
||||
}
|
||||
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
tFreeSCreateDnodeReq(&createReq);
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
extern int32_t mndProcessRestoreDnodeReqImpl(SRpcMsg *pReq);
|
||||
|
@ -1126,44 +1139,56 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
|
|||
STrans *pTrans = NULL;
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "drop-dnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
if (pTrans == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to drop dnode:%d, force:%d", pTrans->id, pDnode->id, force);
|
||||
if (mndTransCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(mndTransCheckConflict(pMnode, pTrans), NULL, _OVER);
|
||||
|
||||
pRaw = mndDnodeActionEncode(pDnode);
|
||||
if (pRaw == NULL) goto _OVER;
|
||||
if (mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER;
|
||||
if (pRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendRedolog(pTrans, pRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPING);
|
||||
pRaw = NULL;
|
||||
|
||||
pRaw = mndDnodeActionEncode(pDnode);
|
||||
if (pRaw == NULL) goto _OVER;
|
||||
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
||||
if (pRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
|
||||
pRaw = NULL;
|
||||
|
||||
if (pMObj != NULL) {
|
||||
mInfo("trans:%d, mnode on dnode:%d will be dropped", pTrans->id, pDnode->id);
|
||||
if (mndSetDropMnodeInfoToTrans(pMnode, pTrans, pMObj, force) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(mndSetDropMnodeInfoToTrans(pMnode, pTrans, pMObj, force), NULL, _OVER);
|
||||
}
|
||||
|
||||
if (pQObj != NULL) {
|
||||
mInfo("trans:%d, qnode on dnode:%d will be dropped", pTrans->id, pDnode->id);
|
||||
if (mndSetDropQnodeInfoToTrans(pMnode, pTrans, pQObj, force) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(mndSetDropQnodeInfoToTrans(pMnode, pTrans, pQObj, force), NULL, _OVER);
|
||||
}
|
||||
|
||||
if (pSObj != NULL) {
|
||||
mInfo("trans:%d, snode on dnode:%d will be dropped", pTrans->id, pDnode->id);
|
||||
if (mndSetDropSnodeInfoToTrans(pMnode, pTrans, pSObj, force) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(mndSetDropSnodeInfoToTrans(pMnode, pTrans, pSObj, force), NULL, _OVER);
|
||||
}
|
||||
|
||||
if (numOfVnodes > 0) {
|
||||
mInfo("trans:%d, %d vnodes on dnode:%d will be dropped", pTrans->id, numOfVnodes, pDnode->id);
|
||||
if (mndSetMoveVgroupsInfoToTrans(pMnode, pTrans, pDnode->id, force, unsafe) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(mndSetMoveVgroupsInfoToTrans(pMnode, pTrans, pDnode->id, force, unsafe), NULL, _OVER);
|
||||
}
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||
|
||||
mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, pDnode->fqdn, IP_WHITE_DROP, 1);
|
||||
code = 0;
|
||||
|
@ -1171,7 +1196,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
|
|||
_OVER:
|
||||
mndTransDrop(pTrans);
|
||||
sdbFreeRaw(pRaw);
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static bool mndIsEmptyDnode(SMnode *pMnode, int32_t dnodeId) {
|
||||
|
@ -1209,16 +1234,11 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
|||
SSnodeObj *pSObj = NULL;
|
||||
SDropDnodeReq dropReq = {0};
|
||||
|
||||
if (tDeserializeSDropDnodeReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(tDeserializeSDropDnodeReq(pReq->pCont, pReq->contLen, &dropReq), NULL, _OVER);
|
||||
|
||||
mInfo("dnode:%d, start to drop, ep:%s:%d, force:%s, unsafe:%s", dropReq.dnodeId, dropReq.fqdn, dropReq.port,
|
||||
dropReq.force ? "true" : "false", dropReq.unsafe ? "true" : "false");
|
||||
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_DROP_MNODE) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_DROP_MNODE), NULL, _OVER);
|
||||
|
||||
bool force = dropReq.force;
|
||||
if (dropReq.unsafe) {
|
||||
|
@ -1232,7 +1252,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
|||
snprintf(ep, sizeof(ep), dropReq.fqdn, dropReq.port);
|
||||
pDnode = mndAcquireDnodeByEp(pMnode, ep);
|
||||
if (pDnode == NULL) {
|
||||
terrno = err;
|
||||
code = err;
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
@ -1242,11 +1262,11 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
|||
pMObj = mndAcquireMnode(pMnode, dropReq.dnodeId);
|
||||
if (pMObj != NULL) {
|
||||
if (sdbGetSize(pMnode->pSdb, SDB_MNODE) <= 1) {
|
||||
terrno = TSDB_CODE_MND_TOO_FEW_MNODES;
|
||||
code = TSDB_CODE_MND_TOO_FEW_MNODES;
|
||||
goto _OVER;
|
||||
}
|
||||
if (pMnode->selfDnodeId == dropReq.dnodeId) {
|
||||
terrno = TSDB_CODE_MND_CANT_DROP_LEADER;
|
||||
code = TSDB_CODE_MND_CANT_DROP_LEADER;
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
@ -1255,16 +1275,16 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
|||
bool isonline = mndIsDnodeOnline(pDnode, taosGetTimestampMs());
|
||||
|
||||
if (isonline && force) {
|
||||
terrno = TSDB_CODE_DNODE_ONLY_USE_WHEN_OFFLINE;
|
||||
mError("dnode:%d, failed to drop since %s, vnodes:%d mnode:%d qnode:%d snode:%d", pDnode->id, terrstr(),
|
||||
code = TSDB_CODE_DNODE_ONLY_USE_WHEN_OFFLINE;
|
||||
mError("dnode:%d, failed to drop since %s, vnodes:%d mnode:%d qnode:%d snode:%d", pDnode->id, tstrerror(code),
|
||||
numOfVnodes, pMObj != NULL, pQObj != NULL, pSObj != NULL);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
bool isEmpty = mndIsEmptyDnode(pMnode, pDnode->id);
|
||||
if (!isonline && !force && !isEmpty) {
|
||||
terrno = TSDB_CODE_DNODE_OFFLINE;
|
||||
mError("dnode:%d, failed to drop since %s, vnodes:%d mnode:%d qnode:%d snode:%d", pDnode->id, terrstr(),
|
||||
code = TSDB_CODE_DNODE_OFFLINE;
|
||||
mError("dnode:%d, failed to drop since %s, vnodes:%d mnode:%d qnode:%d snode:%d", pDnode->id, tstrerror(code),
|
||||
numOfVnodes, pMObj != NULL, pQObj != NULL, pSObj != NULL);
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -1279,7 +1299,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
|||
|
||||
_OVER:
|
||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("dnode:%d, failed to drop since %s", dropReq.dnodeId, terrstr());
|
||||
mError("dnode:%d, failed to drop since %s", dropReq.dnodeId, tstrerror(code));
|
||||
}
|
||||
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
|
@ -1287,11 +1307,11 @@ _OVER:
|
|||
mndReleaseQnode(pMnode, pQObj);
|
||||
mndReleaseSnode(pMnode, pSObj);
|
||||
tFreeSDropDnodeReq(&dropReq);
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndMCfg2DCfg(SMCfgDnodeReq *pMCfgReq, SDCfgDnodeReq *pDCfgReq) {
|
||||
terrno = 0;
|
||||
int32_t code = 0;
|
||||
char *p = pMCfgReq->config;
|
||||
while (*p) {
|
||||
if (*p == ' ') {
|
||||
|
@ -1314,12 +1334,12 @@ static int32_t mndMCfg2DCfg(SMCfgDnodeReq *pMCfgReq, SDCfgDnodeReq *pDCfgReq) {
|
|||
strcpy(pDCfgReq->value, pMCfgReq->value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
TAOS_RETURN(code);
|
||||
|
||||
_err:
|
||||
mError("dnode:%d, failed to config since invalid conf:%s", pMCfgReq->dnodeId, pMCfgReq->config);
|
||||
terrno = TSDB_CODE_INVALID_CFG;
|
||||
return -1;
|
||||
code = TSDB_CODE_INVALID_CFG;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndSendCfgDnodeReq(SMnode *pMnode, int32_t dnodeId, SDCfgDnodeReq *pDcfgReq) {
|
||||
|
@ -1349,23 +1369,21 @@ static int32_t mndSendCfgDnodeReq(SMnode *pMnode, int32_t dnodeId, SDCfgDnodeReq
|
|||
}
|
||||
|
||||
if (code == -1) {
|
||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
code = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
}
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||
int32_t code = 0;
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SMCfgDnodeReq cfgReq = {0};
|
||||
if (tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
TAOS_CHECK_RETURN(tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq));
|
||||
int8_t updateIpWhiteList = 0;
|
||||
mInfo("dnode:%d, start to config, option:%s, value:%s", cfgReq.dnodeId, cfgReq.config, cfgReq.value);
|
||||
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE) != 0) {
|
||||
if ((code = mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE)) != 0) {
|
||||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
return -1;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
SDCfgDnodeReq dcfgReq = {0};
|
||||
|
@ -1381,26 +1399,26 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
if (flag > 1024 * 1024 || (flag > -1 && flag < 1024) || flag < -1) {
|
||||
mError("dnode:%d, failed to config s3blocksize since value:%d. Valid range: -1 or [1024, 1024 * 1024]",
|
||||
cfgReq.dnodeId, flag);
|
||||
terrno = TSDB_CODE_INVALID_CFG;
|
||||
code = TSDB_CODE_INVALID_CFG;
|
||||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
return -1;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
strcpy(dcfgReq.config, "s3blocksize");
|
||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
||||
#endif
|
||||
} else {
|
||||
if (mndMCfg2DCfg(&cfgReq, &dcfgReq)) goto _err_out;
|
||||
TAOS_CHECK_GOTO (mndMCfg2DCfg(&cfgReq, &dcfgReq), NULL, _err_out);
|
||||
if (strlen(dcfgReq.config) > TSDB_DNODE_CONFIG_LEN) {
|
||||
mError("dnode:%d, failed to config since config is too long", cfgReq.dnodeId);
|
||||
terrno = TSDB_CODE_INVALID_CFG;
|
||||
code = TSDB_CODE_INVALID_CFG;
|
||||
goto _err_out;
|
||||
}
|
||||
if (strncasecmp(dcfgReq.config, "enableWhiteList", strlen("enableWhiteList")) == 0) {
|
||||
updateIpWhiteList = 1;
|
||||
}
|
||||
|
||||
if (cfgCheckRangeForDynUpdate(taosGetCfg(), dcfgReq.config, dcfgReq.value, true) != 0) goto _err_out;
|
||||
TAOS_CHECK_GOTO(cfgCheckRangeForDynUpdate(taosGetCfg(), dcfgReq.config, dcfgReq.value, true), NULL, _err_out);
|
||||
}
|
||||
|
||||
{ // audit
|
||||
|
@ -1412,15 +1430,15 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
|
||||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
|
||||
int32_t code = mndSendCfgDnodeReq(pMnode, cfgReq.dnodeId, &dcfgReq);
|
||||
code = mndSendCfgDnodeReq(pMnode, cfgReq.dnodeId, &dcfgReq);
|
||||
|
||||
// dont care suss or succ;
|
||||
if (updateIpWhiteList) mndRefreshUserIpWhiteList(pMnode);
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
|
||||
_err_out:
|
||||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
return -1;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) {
|
||||
|
@ -1503,17 +1521,16 @@ _exit:
|
|||
}
|
||||
|
||||
static int32_t mndProcessCreateEncryptKeyReq(SRpcMsg *pReq) {
|
||||
int32_t code = 0;
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SMCfgDnodeReq cfgReq = {0};
|
||||
if (tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
TAOS_CHECK_RETURN(tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq));
|
||||
|
||||
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE) != 0) {
|
||||
if ((code = mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE)) != 0) {
|
||||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
return -1;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
const STraceId *trace = &pReq->info.traceId;
|
||||
SDCfgDnodeReq dcfgReq = {0};
|
||||
|
@ -1523,13 +1540,13 @@ static int32_t mndProcessCreateEncryptKeyReq(SRpcMsg *pReq) {
|
|||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
return mndProcessCreateEncryptKeyReqImpl(pReq, cfgReq.dnodeId, &dcfgReq);
|
||||
} else {
|
||||
terrno = TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||
code = TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
return -1;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
#else
|
||||
return 0;
|
||||
TAOS_RETURN(code);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1710,7 +1727,7 @@ static void mndCancelGetNextDnode(SMnode *pMnode, void *pIter) {
|
|||
|
||||
// get int32_t value from 'SMCfgDnodeReq'
|
||||
static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32_t *pOutValue) {
|
||||
terrno = 0;
|
||||
int32_t code = 0;
|
||||
if (' ' != pMCfgReq->config[optLen] && 0 != pMCfgReq->config[optLen]) {
|
||||
goto _err;
|
||||
}
|
||||
|
@ -1725,12 +1742,12 @@ static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32
|
|||
*pOutValue = atoi(pMCfgReq->value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
TAOS_RETURN(code);
|
||||
|
||||
_err:
|
||||
mError("dnode:%d, failed to config since invalid conf:%s", pMCfgReq->dnodeId, pMCfgReq->config);
|
||||
terrno = TSDB_CODE_INVALID_CFG;
|
||||
return -1;
|
||||
code = TSDB_CODE_INVALID_CFG;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
SArray *mndGetAllDnodeFqdns(SMnode *pMnode) {
|
||||
|
|
|
@ -29,12 +29,14 @@ void reportStartup(const char *name, const char *desc) {}
|
|||
void sendRsp(SRpcMsg *pMsg) { rpcFreeCont(pMsg->pCont); }
|
||||
|
||||
int32_t sendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
return -1;
|
||||
int32_t code = 0;
|
||||
code = TSDB_CODE_INVALID_PTR;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
int32_t sendSyncReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
return -1;
|
||||
int32_t code = 0;
|
||||
code = TSDB_CODE_INVALID_PTR;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
char *i642str(int64_t val) {
|
||||
|
|
|
@ -223,6 +223,7 @@ static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) {
|
|||
}
|
||||
|
||||
static SFuncObj *mndAcquireFunc(SMnode *pMnode, char *funcName) {
|
||||
terrno = 0;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
SFuncObj *pFunc = sdbAcquire(pSdb, SDB_FUNC, funcName);
|
||||
if (pFunc == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) {
|
||||
|
@ -240,7 +241,7 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
|
|||
int32_t code = -1;
|
||||
STrans *pTrans = NULL;
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_USER)) < 0) {
|
||||
if ((code = grantCheck(TSDB_GRANT_USER)) < 0) {
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -260,7 +261,7 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
|
|||
func.codeSize = pCreate->codeLen;
|
||||
func.pCode = taosMemoryMalloc(func.codeSize);
|
||||
if (func.pCode == NULL || func.pCode == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -270,7 +271,11 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
|
|||
memcpy(func.pCode, pCreate->pCode, func.codeSize);
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-func");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
if (pTrans == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
mInfo("trans:%d, used to create func:%s", pTrans->id, pCreate->name);
|
||||
|
||||
SFuncObj *oldFunc = mndAcquireFunc(pMnode, pCreate->name);
|
||||
|
@ -279,31 +284,61 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
|
|||
func.createdTime = oldFunc->createdTime;
|
||||
|
||||
SSdbRaw *pRedoRaw = mndFuncActionEncode(oldFunc);
|
||||
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER;
|
||||
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY) != 0) goto _OVER;
|
||||
if (pRedoRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendRedolog(pTrans, pRedoRaw), NULL, _OVER);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY), NULL, _OVER);
|
||||
|
||||
SSdbRaw *pUndoRaw = mndFuncActionEncode(oldFunc);
|
||||
if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER;
|
||||
if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY) != 0) goto _OVER;
|
||||
if (pUndoRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendUndolog(pTrans, pUndoRaw), NULL, _OVER);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY), NULL, _OVER);
|
||||
|
||||
SSdbRaw *pCommitRaw = mndFuncActionEncode(&func);
|
||||
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER;
|
||||
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) goto _OVER;
|
||||
if (pCommitRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pCommitRaw), NULL, _OVER);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY), NULL, _OVER);
|
||||
} else {
|
||||
SSdbRaw *pRedoRaw = mndFuncActionEncode(&func);
|
||||
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER;
|
||||
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) goto _OVER;
|
||||
if (pRedoRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendRedolog(pTrans, pRedoRaw), NULL, _OVER);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING), NULL, _OVER);
|
||||
|
||||
SSdbRaw *pUndoRaw = mndFuncActionEncode(&func);
|
||||
if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER;
|
||||
if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED) != 0) goto _OVER;
|
||||
if (pUndoRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendUndolog(pTrans, pUndoRaw), NULL, _OVER);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED), NULL, _OVER);
|
||||
|
||||
SSdbRaw *pCommitRaw = mndFuncActionEncode(&func);
|
||||
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER;
|
||||
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) goto _OVER;
|
||||
if (pCommitRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pCommitRaw), NULL, _OVER);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY), NULL, _OVER);
|
||||
}
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||
|
||||
code = 0;
|
||||
|
||||
|
@ -315,32 +350,48 @@ _OVER:
|
|||
taosMemoryFree(func.pCode);
|
||||
taosMemoryFree(func.pComment);
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) {
|
||||
int32_t code = -1;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "drop-func");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
if (pTrans == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
mInfo("trans:%d, used to drop user:%s", pTrans->id, pFunc->name);
|
||||
|
||||
SSdbRaw *pRedoRaw = mndFuncActionEncode(pFunc);
|
||||
if (pRedoRaw == NULL) goto _OVER;
|
||||
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER;
|
||||
if (pRedoRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendRedolog(pTrans, pRedoRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING);
|
||||
|
||||
SSdbRaw *pUndoRaw = mndFuncActionEncode(pFunc);
|
||||
if (pUndoRaw == NULL) goto _OVER;
|
||||
if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER;
|
||||
if (pUndoRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendUndolog(pTrans, pUndoRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY);
|
||||
|
||||
SSdbRaw *pCommitRaw = mndFuncActionEncode(pFunc);
|
||||
if (pCommitRaw == NULL) goto _OVER;
|
||||
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER;
|
||||
if (pCommitRaw == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pCommitRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED);
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||
|
||||
code = 0;
|
||||
|
||||
|
@ -355,18 +406,14 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
|||
SFuncObj *pFunc = NULL;
|
||||
SCreateFuncReq createReq = {0};
|
||||
|
||||
if (tDeserializeSCreateFuncReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(tDeserializeSCreateFuncReq(pReq->pCont, pReq->contLen, &createReq), NULL, _OVER);
|
||||
|
||||
#ifdef WINDOWS
|
||||
terrno = TSDB_CODE_MND_INVALID_PLATFORM;
|
||||
code = TSDB_CODE_MND_INVALID_PLATFORM;
|
||||
goto _OVER;
|
||||
#endif
|
||||
mInfo("func:%s, start to create, size:%d", createReq.name, createReq.codeLen);
|
||||
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CREATE_FUNC) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CREATE_FUNC), NULL, _OVER);
|
||||
|
||||
pFunc = mndAcquireFunc(pMnode, createReq.name);
|
||||
if (pFunc != NULL) {
|
||||
|
@ -378,7 +425,7 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
|||
mInfo("func:%s, replace function is set", createReq.name);
|
||||
code = 0;
|
||||
} else {
|
||||
terrno = TSDB_CODE_MND_FUNC_ALREADY_EXIST;
|
||||
code = TSDB_CODE_MND_FUNC_ALREADY_EXIST;
|
||||
goto _OVER;
|
||||
}
|
||||
} else if (terrno == TSDB_CODE_MND_FUNC_ALREADY_EXIST) {
|
||||
|
@ -386,22 +433,22 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
if (createReq.name[0] == 0) {
|
||||
terrno = TSDB_CODE_MND_INVALID_FUNC_NAME;
|
||||
code = TSDB_CODE_MND_INVALID_FUNC_NAME;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (createReq.pCode == NULL) {
|
||||
terrno = TSDB_CODE_MND_INVALID_FUNC_CODE;
|
||||
code = TSDB_CODE_MND_INVALID_FUNC_CODE;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (createReq.codeLen <= 1) {
|
||||
terrno = TSDB_CODE_MND_INVALID_FUNC_CODE;
|
||||
code = TSDB_CODE_MND_INVALID_FUNC_CODE;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (createReq.bufSize < 0 || createReq.bufSize > TSDB_FUNC_BUF_SIZE) {
|
||||
terrno = TSDB_CODE_MND_INVALID_FUNC_BUFSIZE;
|
||||
code = TSDB_CODE_MND_INVALID_FUNC_BUFSIZE;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -410,12 +457,12 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
|||
|
||||
_OVER:
|
||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("func:%s, failed to create since %s", createReq.name, terrstr());
|
||||
mError("func:%s, failed to create since %s", createReq.name, tstrerror(code));
|
||||
}
|
||||
|
||||
mndReleaseFunc(pMnode, pFunc);
|
||||
tFreeSCreateFuncReq(&createReq);
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
||||
|
@ -424,18 +471,13 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
|||
SFuncObj *pFunc = NULL;
|
||||
SDropFuncReq dropReq = {0};
|
||||
|
||||
if (tDeserializeSDropFuncReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(tDeserializeSDropFuncReq(pReq->pCont, pReq->contLen, &dropReq), NULL, _OVER);
|
||||
|
||||
mInfo("func:%s, start to drop", dropReq.name);
|
||||
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_DROP_FUNC) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_DROP_FUNC), NULL, _OVER);
|
||||
|
||||
if (dropReq.name[0] == 0) {
|
||||
terrno = TSDB_CODE_MND_INVALID_FUNC_NAME;
|
||||
code = TSDB_CODE_MND_INVALID_FUNC_NAME;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -446,7 +488,7 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
|||
code = 0;
|
||||
goto _OVER;
|
||||
} else {
|
||||
terrno = TSDB_CODE_MND_FUNC_NOT_EXIST;
|
||||
code = TSDB_CODE_MND_FUNC_NOT_EXIST;
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
@ -456,11 +498,11 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
|||
|
||||
_OVER:
|
||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("func:%s, failed to drop since %s", dropReq.name, terrstr());
|
||||
mError("func:%s, failed to drop since %s", dropReq.name, tstrerror(code));
|
||||
}
|
||||
|
||||
mndReleaseFunc(pMnode, pFunc);
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) {
|
||||
|
@ -470,25 +512,25 @@ static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) {
|
|||
SRetrieveFuncRsp retrieveRsp = {0};
|
||||
|
||||
if (tDeserializeSRetrieveFuncReq(pReq->pCont, pReq->contLen, &retrieveReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
|
||||
if (retrieveReq.numOfFuncs <= 0 || retrieveReq.numOfFuncs > TSDB_FUNC_MAX_RETRIEVE) {
|
||||
terrno = TSDB_CODE_MND_INVALID_FUNC_RETRIEVE;
|
||||
code = TSDB_CODE_MND_INVALID_FUNC_RETRIEVE;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
|
||||
retrieveRsp.numOfFuncs = retrieveReq.numOfFuncs;
|
||||
retrieveRsp.pFuncInfos = taosArrayInit(retrieveReq.numOfFuncs, sizeof(SFuncInfo));
|
||||
if (retrieveRsp.pFuncInfos == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
|
||||
retrieveRsp.pFuncExtraInfos = taosArrayInit(retrieveReq.numOfFuncs, sizeof(SFuncExtraInfo));
|
||||
if (retrieveRsp.pFuncExtraInfos == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
|
||||
|
@ -497,6 +539,7 @@ static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) {
|
|||
|
||||
SFuncObj *pFunc = mndAcquireFunc(pMnode, funcName);
|
||||
if (pFunc == NULL) {
|
||||
if (terrno != 0) code = terrno;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
|
||||
|
@ -541,7 +584,7 @@ static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) {
|
|||
int32_t contLen = tSerializeSRetrieveFuncRsp(NULL, 0, &retrieveRsp);
|
||||
void *pRsp = rpcMallocCont(contLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
|
||||
|
@ -556,7 +599,7 @@ RETRIEVE_FUNC_OVER:
|
|||
tFreeSRetrieveFuncReq(&retrieveReq);
|
||||
tFreeSRetrieveFuncRsp(&retrieveRsp);
|
||||
|
||||
return code;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static void *mnodeGenTypeStr(char *buf, int32_t buflen, uint8_t type, int32_t len) {
|
||||
|
|
|
@ -19,21 +19,22 @@
|
|||
#include "query.h"
|
||||
#include "qworker.h"
|
||||
|
||||
SQnode *qndOpen(const SQnodeOpt *pOption) {
|
||||
SQnode *pQnode = taosMemoryCalloc(1, sizeof(SQnode));
|
||||
if (NULL == pQnode) {
|
||||
int32_t qndOpen(const SQnodeOpt *pOption, SQnode **pQnode) {
|
||||
*pQnode = taosMemoryCalloc(1, sizeof(SQnode));
|
||||
if (NULL == *pQnode) {
|
||||
qError("calloc SQnode failed");
|
||||
return NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pQnode->qndId = QNODE_HANDLE;
|
||||
(*pQnode)->qndId = QNODE_HANDLE;
|
||||
|
||||
if (qWorkerInit(NODE_TYPE_QNODE, pQnode->qndId, (void **)&pQnode->pQuery, &pOption->msgCb)) {
|
||||
int32_t code = qWorkerInit(NODE_TYPE_QNODE, (*pQnode)->qndId, (void **)&(*pQnode)->pQuery, &pOption->msgCb);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosMemoryFreeClear(pQnode);
|
||||
return NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
pQnode->msgCb = pOption->msgCb;
|
||||
return pQnode;
|
||||
(*pQnode)->msgCb = pOption->msgCb;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void qndClose(SQnode *pQnode) {
|
||||
|
|
|
@ -22,7 +22,6 @@ set(
|
|||
|
||||
# meta
|
||||
"src/meta/metaOpen.c"
|
||||
"src/meta/metaIdx.c"
|
||||
"src/meta/metaTable.c"
|
||||
"src/meta/metaSma.c"
|
||||
"src/meta/metaQuery.c"
|
||||
|
|
|
@ -318,7 +318,7 @@ void* tdUidStoreFree(STbUidStore* pStore);
|
|||
|
||||
// SMetaSnapReader ========================================
|
||||
int32_t metaSnapReaderOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapReader** ppReader);
|
||||
int32_t metaSnapReaderClose(SMetaSnapReader** ppReader);
|
||||
void metaSnapReaderClose(SMetaSnapReader** ppReader);
|
||||
int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData);
|
||||
// SMetaSnapWriter ========================================
|
||||
int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWriter** ppWriter);
|
||||
|
|
|
@ -118,90 +118,80 @@ static void freeCacheEntryFp(void* param) {
|
|||
|
||||
int32_t metaCacheOpen(SMeta* pMeta) {
|
||||
int32_t code = 0;
|
||||
SMetaCache* pCache = NULL;
|
||||
int32_t lino;
|
||||
|
||||
pCache = (SMetaCache*)taosMemoryMalloc(sizeof(SMetaCache));
|
||||
if (pCache == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
pMeta->pCache = (SMetaCache*)taosMemoryCalloc(1, sizeof(SMetaCache));
|
||||
if (pMeta->pCache == NULL) {
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
||||
}
|
||||
|
||||
// open entry cache
|
||||
pCache->sEntryCache.nEntry = 0;
|
||||
pCache->sEntryCache.nBucket = META_CACHE_BASE_BUCKET;
|
||||
pCache->sEntryCache.aBucket =
|
||||
(SMetaCacheEntry**)taosMemoryCalloc(pCache->sEntryCache.nBucket, sizeof(SMetaCacheEntry*));
|
||||
if (pCache->sEntryCache.aBucket == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
pMeta->pCache->sEntryCache.nEntry = 0;
|
||||
pMeta->pCache->sEntryCache.nBucket = META_CACHE_BASE_BUCKET;
|
||||
pMeta->pCache->sEntryCache.aBucket =
|
||||
(SMetaCacheEntry**)taosMemoryCalloc(pMeta->pCache->sEntryCache.nBucket, sizeof(SMetaCacheEntry*));
|
||||
if (pMeta->pCache->sEntryCache.aBucket == NULL) {
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
||||
}
|
||||
|
||||
// open stats cache
|
||||
pCache->sStbStatsCache.nEntry = 0;
|
||||
pCache->sStbStatsCache.nBucket = META_CACHE_STATS_BUCKET;
|
||||
pCache->sStbStatsCache.aBucket =
|
||||
(SMetaStbStatsEntry**)taosMemoryCalloc(pCache->sStbStatsCache.nBucket, sizeof(SMetaStbStatsEntry*));
|
||||
if (pCache->sStbStatsCache.aBucket == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err2;
|
||||
pMeta->pCache->sStbStatsCache.nEntry = 0;
|
||||
pMeta->pCache->sStbStatsCache.nBucket = META_CACHE_STATS_BUCKET;
|
||||
pMeta->pCache->sStbStatsCache.aBucket =
|
||||
(SMetaStbStatsEntry**)taosMemoryCalloc(pMeta->pCache->sStbStatsCache.nBucket, sizeof(SMetaStbStatsEntry*));
|
||||
if (pMeta->pCache->sStbStatsCache.aBucket == NULL) {
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
||||
}
|
||||
|
||||
pCache->sTagFilterResCache.pUidResCache = taosLRUCacheInit(5 * 1024 * 1024, -1, 0.5);
|
||||
if (pCache->sTagFilterResCache.pUidResCache == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err2;
|
||||
pMeta->pCache->sTagFilterResCache.pUidResCache = taosLRUCacheInit(5 * 1024 * 1024, -1, 0.5);
|
||||
if (pMeta->pCache->sTagFilterResCache.pUidResCache == NULL) {
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
pCache->sTagFilterResCache.accTimes = 0;
|
||||
pCache->sTagFilterResCache.pTableEntry =
|
||||
pMeta->pCache->sTagFilterResCache.accTimes = 0;
|
||||
pMeta->pCache->sTagFilterResCache.pTableEntry =
|
||||
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, HASH_NO_LOCK);
|
||||
if (pCache->sTagFilterResCache.pTableEntry == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err2;
|
||||
if (pMeta->pCache->sTagFilterResCache.pTableEntry == NULL) {
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
taosHashSetFreeFp(pCache->sTagFilterResCache.pTableEntry, freeCacheEntryFp);
|
||||
taosThreadMutexInit(&pCache->sTagFilterResCache.lock, NULL);
|
||||
taosHashSetFreeFp(pMeta->pCache->sTagFilterResCache.pTableEntry, freeCacheEntryFp);
|
||||
taosThreadMutexInit(&pMeta->pCache->sTagFilterResCache.lock, NULL);
|
||||
|
||||
pCache->STbGroupResCache.pResCache = taosLRUCacheInit(5 * 1024 * 1024, -1, 0.5);
|
||||
if (pCache->STbGroupResCache.pResCache == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err2;
|
||||
pMeta->pCache->STbGroupResCache.pResCache = taosLRUCacheInit(5 * 1024 * 1024, -1, 0.5);
|
||||
if (pMeta->pCache->STbGroupResCache.pResCache == NULL) {
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
pCache->STbGroupResCache.accTimes = 0;
|
||||
pCache->STbGroupResCache.pTableEntry =
|
||||
pMeta->pCache->STbGroupResCache.accTimes = 0;
|
||||
pMeta->pCache->STbGroupResCache.pTableEntry =
|
||||
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, HASH_NO_LOCK);
|
||||
if (pCache->STbGroupResCache.pTableEntry == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err2;
|
||||
if (pMeta->pCache->STbGroupResCache.pTableEntry == NULL) {
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
taosHashSetFreeFp(pCache->STbGroupResCache.pTableEntry, freeCacheEntryFp);
|
||||
taosThreadMutexInit(&pCache->STbGroupResCache.lock, NULL);
|
||||
taosHashSetFreeFp(pMeta->pCache->STbGroupResCache.pTableEntry, freeCacheEntryFp);
|
||||
taosThreadMutexInit(&pMeta->pCache->STbGroupResCache.lock, NULL);
|
||||
|
||||
pCache->STbFilterCache.pStb = taosHashInit(0, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (pCache->STbFilterCache.pStb == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err2;
|
||||
pMeta->pCache->STbFilterCache.pStb =
|
||||
taosHashInit(0, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (pMeta->pCache->STbFilterCache.pStb == NULL) {
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
pCache->STbFilterCache.pStbName =
|
||||
pMeta->pCache->STbFilterCache.pStbName =
|
||||
taosHashInit(0, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, HASH_NO_LOCK);
|
||||
if (pCache->STbFilterCache.pStbName == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err2;
|
||||
if (pMeta->pCache->STbFilterCache.pStbName == NULL) {
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
pMeta->pCache = pCache;
|
||||
return code;
|
||||
|
||||
_err2:
|
||||
entryCacheClose(pMeta);
|
||||
|
||||
_err:
|
||||
taosMemoryFree(pCache);
|
||||
metaError("vgId:%d, meta open cache failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
||||
_exit:
|
||||
if (code) {
|
||||
metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, lino, tstrerror(code));
|
||||
metaCacheClose(pMeta);
|
||||
} else {
|
||||
metaDebug("vgId:%d, %s success", TD_VID(pMeta->pVnode), __func__);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -289,8 +279,7 @@ int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) {
|
|||
}
|
||||
} else { // insert
|
||||
if (pCache->sEntryCache.nEntry >= pCache->sEntryCache.nBucket) {
|
||||
code = metaRehashCache(pCache, 1);
|
||||
if (code) goto _exit;
|
||||
TAOS_UNUSED(metaRehashCache(pCache, 1));
|
||||
|
||||
iBucket = TABS(pInfo->uid) % pCache->sEntryCache.nBucket;
|
||||
}
|
||||
|
@ -328,8 +317,7 @@ int32_t metaCacheDrop(SMeta* pMeta, int64_t uid) {
|
|||
pCache->sEntryCache.nEntry--;
|
||||
if (pCache->sEntryCache.nEntry < pCache->sEntryCache.nBucket / 4 &&
|
||||
pCache->sEntryCache.nBucket > META_CACHE_BASE_BUCKET) {
|
||||
code = metaRehashCache(pCache, 0);
|
||||
if (code) goto _exit;
|
||||
TAOS_UNUSED(metaRehashCache(pCache, 0));
|
||||
}
|
||||
} else {
|
||||
code = TSDB_CODE_NOT_FOUND;
|
||||
|
@ -351,7 +339,9 @@ int32_t metaCacheGet(SMeta* pMeta, int64_t uid, SMetaInfo* pInfo) {
|
|||
}
|
||||
|
||||
if (pEntry) {
|
||||
if (pInfo) {
|
||||
*pInfo = pEntry->info;
|
||||
}
|
||||
} else {
|
||||
code = TSDB_CODE_NOT_FOUND;
|
||||
}
|
||||
|
@ -415,9 +405,7 @@ int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo) {
|
|||
(*ppEntry)->info.ctbNum = pInfo->ctbNum;
|
||||
} else { // insert
|
||||
if (pCache->sStbStatsCache.nEntry >= pCache->sStbStatsCache.nBucket) {
|
||||
code = metaRehashStatsCache(pCache, 1);
|
||||
if (code) goto _exit;
|
||||
|
||||
TAOS_UNUSED(metaRehashStatsCache(pCache, 1));
|
||||
iBucket = TABS(pInfo->uid) % pCache->sStbStatsCache.nBucket;
|
||||
}
|
||||
|
||||
|
@ -454,8 +442,7 @@ int32_t metaStatsCacheDrop(SMeta* pMeta, int64_t uid) {
|
|||
pCache->sStbStatsCache.nEntry--;
|
||||
if (pCache->sStbStatsCache.nEntry < pCache->sStbStatsCache.nBucket / 4 &&
|
||||
pCache->sStbStatsCache.nBucket > META_CACHE_STATS_BUCKET) {
|
||||
code = metaRehashStatsCache(pCache, 0);
|
||||
if (code) goto _exit;
|
||||
TAOS_UNUSED(metaRehashStatsCache(pCache, 0));
|
||||
}
|
||||
} else {
|
||||
code = TSDB_CODE_NOT_FOUND;
|
||||
|
@ -477,7 +464,9 @@ int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo) {
|
|||
}
|
||||
|
||||
if (pEntry) {
|
||||
if (pInfo) {
|
||||
*pInfo = pEntry->info;
|
||||
}
|
||||
} else {
|
||||
code = TSDB_CODE_NOT_FOUND;
|
||||
}
|
||||
|
@ -502,7 +491,9 @@ static int checkAllEntriesInCache(const STagFilterResEntry* pEntry, SArray* pInv
|
|||
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
||||
LRUHandle* pRes = taosLRUCacheLookup(pCache, buf, len);
|
||||
if (pRes == NULL) { // remove the item in the linked list
|
||||
taosArrayPush(pInvalidRes, &pNode);
|
||||
if (taosArrayPush(pInvalidRes, &pNode) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
} else {
|
||||
taosLRUCacheRelease(pCache, pRes, false);
|
||||
}
|
||||
|
@ -626,7 +617,7 @@ static int32_t addNewEntry(SHashObj* pTableEntry, const void* pKey, int32_t keyL
|
|||
|
||||
p->hitTimes = 0;
|
||||
tdListInit(&p->list, keyLen);
|
||||
taosHashPut(pTableEntry, &suid, sizeof(uint64_t), &p, POINTER_BYTES);
|
||||
TAOS_CHECK_RETURN(taosHashPut(pTableEntry, &suid, sizeof(uint64_t), &p, POINTER_BYTES));
|
||||
tdListAppend(&p->list, pKey);
|
||||
return 0;
|
||||
}
|
||||
|
@ -956,9 +947,7 @@ int32_t metaInitTbFilterCache(SMeta* pMeta) {
|
|||
}
|
||||
if (tbNum && pTbArr) {
|
||||
for (int32_t i = 0; i < tbNum; ++i) {
|
||||
if (metaPutTbToFilterCache(pMeta, pTbArr[i], 1) != 0) {
|
||||
return terrno ? terrno : -1;
|
||||
}
|
||||
TAOS_CHECK_RETURN(metaPutTbToFilterCache(pMeta, pTbArr[i], 1));
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -21,7 +21,10 @@ static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) {
|
|||
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
||||
|
||||
// begin a meta txn
|
||||
int metaBegin(SMeta *pMeta, int8_t heap) {
|
||||
int32_t metaBegin(SMeta *pMeta, int8_t heap) {
|
||||
int32_t code = 0;
|
||||
int32_t lino;
|
||||
|
||||
void *(*xMalloc)(void *, size_t) = NULL;
|
||||
void (*xFree)(void *, void *) = NULL;
|
||||
void *xArg = NULL;
|
||||
|
@ -36,12 +39,19 @@ int metaBegin(SMeta *pMeta, int8_t heap) {
|
|||
xArg = pMeta->pVnode->inUse;
|
||||
}
|
||||
|
||||
if (tdbBegin(pMeta->pEnv, &pMeta->txn, xMalloc, xFree, xArg, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
||||
return -1;
|
||||
code = tdbBegin(pMeta->pEnv, &pMeta->txn, xMalloc, xFree, xArg, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
code = tdbCommit(pMeta->pEnv, pMeta->txn);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
metaError("vgId:%d %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, __LINE__,
|
||||
tstrerror(terrno));
|
||||
} else {
|
||||
metaDebug("vgId:%d %s success", TD_VID(pMeta->pVnode), __func__);
|
||||
}
|
||||
|
||||
tdbCommit(pMeta->pEnv, pMeta->txn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -49,20 +59,36 @@ int metaBegin(SMeta *pMeta, int8_t heap) {
|
|||
TXN *metaGetTxn(SMeta *pMeta) { return pMeta->txn; }
|
||||
int metaCommit(SMeta *pMeta, TXN *txn) { return tdbCommit(pMeta->pEnv, txn); }
|
||||
int metaFinishCommit(SMeta *pMeta, TXN *txn) { return tdbPostCommit(pMeta->pEnv, txn); }
|
||||
|
||||
int metaPrepareAsyncCommit(SMeta *pMeta) {
|
||||
// return tdbPrepareAsyncCommit(pMeta->pEnv, pMeta->txn);
|
||||
int code = 0;
|
||||
int32_t lino;
|
||||
|
||||
metaWLock(pMeta);
|
||||
code = ttlMgrFlush(pMeta->pTtlMgr, pMeta->txn);
|
||||
TAOS_UNUSED(ttlMgrFlush(pMeta->pTtlMgr, pMeta->txn));
|
||||
metaULock(pMeta);
|
||||
|
||||
code = tdbCommit(pMeta->pEnv, pMeta->txn);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
pMeta->changed = false;
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
metaError("vgId:%d %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, __LINE__,
|
||||
tstrerror(terrno));
|
||||
} else {
|
||||
metaDebug("vgId:%d %s success", TD_VID(pMeta->pVnode), __func__);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
// abort the meta txn
|
||||
int metaAbort(SMeta *pMeta) {
|
||||
if (!pMeta->txn) return 0;
|
||||
if (!pMeta->txn) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int code = tdbAbort(pMeta->pEnv, pMeta->txn);
|
||||
if (code) {
|
||||
metaError("vgId:%d, failed to abort meta since %s", TD_VID(pMeta->pVnode), tstrerror(terrno));
|
||||
|
|
|
@ -17,159 +17,166 @@
|
|||
|
||||
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
|
||||
const SColCmprWrapper *pw = &pME->colCmpr;
|
||||
if (tEncodeI32v(pCoder, pw->nCols) < 0) return -1;
|
||||
if (tEncodeI32v(pCoder, pw->version) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nCols));
|
||||
TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->version));
|
||||
uDebug("encode cols:%d", pw->nCols);
|
||||
|
||||
for (int32_t i = 0; i < pw->nCols; i++) {
|
||||
SColCmpr *p = &pw->pColCmpr[i];
|
||||
if (tEncodeI16v(pCoder, p->id) < 0) return -1;
|
||||
if (tEncodeU32(pCoder, p->alg) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
|
||||
TAOS_CHECK_RETURN(tEncodeU32(pCoder, p->alg));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
|
||||
SColCmprWrapper *pWrapper = &pME->colCmpr;
|
||||
if (tDecodeI32v(pDecoder, &pWrapper->nCols) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nCols));
|
||||
if (pWrapper->nCols == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tDecodeI32v(pDecoder, &pWrapper->version) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->version));
|
||||
uDebug("dencode cols:%d", pWrapper->nCols);
|
||||
pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
|
||||
if (pWrapper->pColCmpr == NULL) return -1;
|
||||
if (pWrapper->pColCmpr == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (int i = 0; i < pWrapper->nCols; i++) {
|
||||
SColCmpr *p = &pWrapper->pColCmpr[i];
|
||||
if (tDecodeI16v(pDecoder, &p->id) < 0) return -1;
|
||||
if (tDecodeU32(pDecoder, &p->alg) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
|
||||
TAOS_CHECK_RETURN(tDecodeU32(pDecoder, &p->alg));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static FORCE_INLINE void metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
|
||||
static FORCE_INLINE int32_t metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
|
||||
SSchemaWrapper *pSchema) {
|
||||
pCmpr->nCols = pSchema->nCols;
|
||||
pCmpr->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pCmpr->nCols * sizeof(SColCmpr));
|
||||
if ((pCmpr->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pCmpr->nCols * sizeof(SColCmpr))) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
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 = createDefaultColCmprByType(pColSchema->type);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
|
||||
if (tStartEncode(pCoder) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tStartEncode(pCoder));
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->version));
|
||||
TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->type));
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->uid));
|
||||
|
||||
if (tEncodeI64(pCoder, pME->version) < 0) return -1;
|
||||
if (tEncodeI8(pCoder, pME->type) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pME->uid) < 0) return -1;
|
||||
if (pME->name == NULL || tEncodeCStr(pCoder, pME->name) < 0) return -1;
|
||||
if (pME->name == NULL) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->name));
|
||||
|
||||
if (pME->type == TSDB_SUPER_TABLE) {
|
||||
if (tEncodeI8(pCoder, pME->flags) < 0) return -1; // TODO: need refactor?
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow) < 0) return -1;
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI8(pCoder, pME->flags));
|
||||
TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow));
|
||||
TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag));
|
||||
if (TABLE_IS_ROLLUP(pME->flags)) {
|
||||
if (tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
|
||||
}
|
||||
} else if (pME->type == TSDB_CHILD_TABLE) {
|
||||
if (tEncodeI64(pCoder, pME->ctbEntry.btime) < 0) return -1;
|
||||
if (tEncodeI32(pCoder, pME->ctbEntry.ttlDays) < 0) return -1;
|
||||
if (tEncodeI32v(pCoder, pME->ctbEntry.commentLen) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.btime));
|
||||
TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ctbEntry.ttlDays));
|
||||
TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ctbEntry.commentLen));
|
||||
if (pME->ctbEntry.commentLen > 0) {
|
||||
if (tEncodeCStr(pCoder, pME->ctbEntry.comment) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ctbEntry.comment));
|
||||
}
|
||||
if (tEncodeI64(pCoder, pME->ctbEntry.suid) < 0) return -1;
|
||||
if (tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ctbEntry.suid));
|
||||
TAOS_CHECK_RETURN(tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags));
|
||||
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
||||
if (tEncodeI64(pCoder, pME->ntbEntry.btime) < 0) return -1;
|
||||
if (tEncodeI32(pCoder, pME->ntbEntry.ttlDays) < 0) return -1;
|
||||
if (tEncodeI32v(pCoder, pME->ntbEntry.commentLen) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pCoder, pME->ntbEntry.btime));
|
||||
TAOS_CHECK_RETURN(tEncodeI32(pCoder, pME->ntbEntry.ttlDays));
|
||||
TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.commentLen));
|
||||
if (pME->ntbEntry.commentLen > 0) {
|
||||
if (tEncodeCStr(pCoder, pME->ntbEntry.comment) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pME->ntbEntry.comment));
|
||||
}
|
||||
if (tEncodeI32v(pCoder, pME->ntbEntry.ncid) < 0) return -1;
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pME->ntbEntry.ncid));
|
||||
TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schemaRow));
|
||||
} else if (pME->type == TSDB_TSMA_TABLE) {
|
||||
if (tEncodeTSma(pCoder, pME->smaEntry.tsma) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeTSma(pCoder, pME->smaEntry.tsma));
|
||||
} else {
|
||||
metaError("meta/entry: invalide table type: %" PRId8 " encode failed.", pME->type);
|
||||
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
if (meteEncodeColCmprEntry(pCoder, pME) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(meteEncodeColCmprEntry(pCoder, pME));
|
||||
|
||||
tEndEncode(pCoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
|
||||
if (tStartDecode(pCoder) < 0) return -1;
|
||||
|
||||
if (tDecodeI64(pCoder, &pME->version) < 0) return -1;
|
||||
if (tDecodeI8(pCoder, &pME->type) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pME->uid) < 0) return -1;
|
||||
if (tDecodeCStr(pCoder, &pME->name) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tStartDecode(pCoder));
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->version));
|
||||
TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->type));
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->uid));
|
||||
TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->name));
|
||||
|
||||
if (pME->type == TSDB_SUPER_TABLE) {
|
||||
if (tDecodeI8(pCoder, &pME->flags) < 0) return -1; // TODO: need refactor?
|
||||
if (tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow) < 0) return -1;
|
||||
if (tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pME->flags));
|
||||
TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow));
|
||||
TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag));
|
||||
if (TABLE_IS_ROLLUP(pME->flags)) {
|
||||
if (tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam));
|
||||
}
|
||||
} else if (pME->type == TSDB_CHILD_TABLE) {
|
||||
if (tDecodeI64(pCoder, &pME->ctbEntry.btime) < 0) return -1;
|
||||
if (tDecodeI32(pCoder, &pME->ctbEntry.ttlDays) < 0) return -1;
|
||||
if (tDecodeI32v(pCoder, &pME->ctbEntry.commentLen) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.btime));
|
||||
TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ctbEntry.ttlDays));
|
||||
TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ctbEntry.commentLen));
|
||||
if (pME->ctbEntry.commentLen > 0) {
|
||||
if (tDecodeCStr(pCoder, &pME->ctbEntry.comment) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ctbEntry.comment));
|
||||
}
|
||||
if (tDecodeI64(pCoder, &pME->ctbEntry.suid) < 0) return -1;
|
||||
if (tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags) < 0) return -1; // (TODO)
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ctbEntry.suid));
|
||||
TAOS_CHECK_RETURN(tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags));
|
||||
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
||||
if (tDecodeI64(pCoder, &pME->ntbEntry.btime) < 0) return -1;
|
||||
if (tDecodeI32(pCoder, &pME->ntbEntry.ttlDays) < 0) return -1;
|
||||
if (tDecodeI32v(pCoder, &pME->ntbEntry.commentLen) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pME->ntbEntry.btime));
|
||||
TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pME->ntbEntry.ttlDays));
|
||||
TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.commentLen));
|
||||
if (pME->ntbEntry.commentLen > 0) {
|
||||
if (tDecodeCStr(pCoder, &pME->ntbEntry.comment) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pME->ntbEntry.comment));
|
||||
}
|
||||
if (tDecodeI32v(pCoder, &pME->ntbEntry.ncid) < 0) return -1;
|
||||
if (tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pME->ntbEntry.ncid));
|
||||
TAOS_CHECK_RETURN(tDecodeSSchemaWrapperEx(pCoder, &pME->ntbEntry.schemaRow));
|
||||
} else if (pME->type == TSDB_TSMA_TABLE) {
|
||||
pME->smaEntry.tsma = tDecoderMalloc(pCoder, sizeof(STSma));
|
||||
if (!pME->smaEntry.tsma) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (tDecodeTSma(pCoder, pME->smaEntry.tsma, true) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeTSma(pCoder, pME->smaEntry.tsma, true));
|
||||
} else {
|
||||
metaError("meta/entry: invalide table type: %" PRId8 " decode failed.", pME->type);
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
if (pME->type == TSDB_SUPER_TABLE) {
|
||||
if (TABLE_IS_COL_COMPRESSED(pME->flags)) {
|
||||
if (meteDecodeColCmprEntry(pCoder, pME) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
|
||||
|
||||
if (pME->colCmpr.nCols == 0) {
|
||||
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow);
|
||||
TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow));
|
||||
}
|
||||
} else {
|
||||
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow);
|
||||
TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow));
|
||||
TABLE_SET_COL_COMPRESSED(pME->flags);
|
||||
}
|
||||
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
||||
if (!tDecodeIsEnd(pCoder)) {
|
||||
uDebug("set type: %d, tableName:%s", pME->type, pME->name);
|
||||
if (meteDecodeColCmprEntry(pCoder, pME) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(meteDecodeColCmprEntry(pCoder, pME));
|
||||
if (pME->colCmpr.nCols == 0) {
|
||||
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow);
|
||||
TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
|
||||
}
|
||||
} else {
|
||||
uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
|
||||
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow);
|
||||
TAOS_CHECK_RETURN(metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow));
|
||||
}
|
||||
TABLE_SET_COL_COMPRESSED(pME->flags);
|
||||
}
|
||||
|
|
|
@ -1,118 +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/>.
|
||||
*/
|
||||
|
||||
#ifdef USE_INVERTED_INDEX
|
||||
#include "index.h"
|
||||
#endif
|
||||
#include "meta.h"
|
||||
|
||||
struct SMetaIdx {
|
||||
#ifdef USE_INVERTED_INDEX
|
||||
SIndex *pIdx;
|
||||
#endif
|
||||
/* data */
|
||||
#ifdef WINDOWS
|
||||
size_t avoidCompilationErrors;
|
||||
#endif
|
||||
};
|
||||
|
||||
int metaOpenIdx(SMeta *pMeta) {
|
||||
#if 0
|
||||
char idxDir[128]; // TODO
|
||||
char * err = NULL;
|
||||
rocksdb_options_t *options = rocksdb_options_create();
|
||||
|
||||
// TODO
|
||||
sprintf(idxDir, "%s/index", pMeta->path);
|
||||
|
||||
if (pMeta->pCache) {
|
||||
rocksdb_options_set_row_cache(options, pMeta->pCache);
|
||||
}
|
||||
rocksdb_options_set_create_if_missing(options, 1);
|
||||
|
||||
pMeta->pIdx = rocksdb_open(options, idxDir, &err);
|
||||
if (pMeta->pIdx == NULL) {
|
||||
// TODO: handle error
|
||||
rocksdb_options_destroy(options);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rocksdb_options_destroy(options);
|
||||
#endif
|
||||
|
||||
#ifdef USE_INVERTED_INDEX
|
||||
// SIndexOpts opts;
|
||||
// if (indexOpen(&opts, pMeta->path, &pMeta->pIdx->pIdx) != 0) {
|
||||
// return -1;
|
||||
//}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef BUILD_NO_CALL
|
||||
void metaCloseIdx(SMeta *pMeta) { /* TODO */
|
||||
#if 0
|
||||
if (pMeta->pIdx) {
|
||||
rocksdb_close(pMeta->pIdx);
|
||||
pMeta->pIdx = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_INVERTED_INDEX
|
||||
// SIndexOpts opts;
|
||||
// if (indexClose(pMeta->pIdx->pIdx) != 0) {
|
||||
// return -1;
|
||||
//}
|
||||
// return 0;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
int metaSaveTableToIdx(SMeta *pMeta, const STbCfg *pTbCfg) {
|
||||
#ifdef USE_INVERTED_INDEX
|
||||
// if (pTbCfgs->type == META_CHILD_TABLE) {
|
||||
// char buf[8] = {0};
|
||||
// int16_t colId = (kvRowColIdx(pTbCfg->ctbCfg.pTag))[0].colId;
|
||||
// sprintf(buf, "%d", colId); // colname
|
||||
|
||||
// char *pTagVal = (char *)tdGetKVRowValOfCol(pTbCfg->ctbCfg.pTag, (kvRowColIdx(pTbCfg->ctbCfg.pTag))[0].colId);
|
||||
|
||||
// tb_uid_t suid = pTbCfg->ctbCfg.suid; // super id
|
||||
// tb_uid_t tuid = 0; // child table uid
|
||||
// SIndexMultiTerm *terms = indexMultiTermCreate();
|
||||
// SIndexTerm *term =
|
||||
// indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_BINARY, buf, strlen(buf), pTagVal, strlen(pTagVal), tuid);
|
||||
// indexMultiTermAdd(terms, term);
|
||||
|
||||
// int ret = indexPut(pMeta->pIdx->pIdx, terms);
|
||||
// indexMultiTermDestroy(terms);
|
||||
// return ret;
|
||||
//} else {
|
||||
// return DB_DONOTINDEX;
|
||||
//}
|
||||
#endif
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid) {
|
||||
#ifdef USE_INVERTED_INDEX
|
||||
|
||||
#endif
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -39,13 +39,13 @@ static int32_t metaDestroyLock(SMeta *pMeta) { return taosThreadRwlockDestroy(&p
|
|||
|
||||
static void metaCleanup(SMeta **ppMeta);
|
||||
|
||||
int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
||||
int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
||||
SMeta *pMeta = NULL;
|
||||
int ret;
|
||||
int offset;
|
||||
int32_t code = 0;
|
||||
int32_t lino;
|
||||
int32_t offset;
|
||||
char path[TSDB_FILENAME_LEN] = {0};
|
||||
|
||||
*ppMeta = NULL;
|
||||
char indexFullPath[128] = {0};
|
||||
|
||||
// create handle
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, path, TSDB_FILENAME_LEN);
|
||||
|
@ -53,8 +53,7 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
|||
snprintf(path + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VNODE_META_DIR);
|
||||
|
||||
if ((pMeta = taosMemoryCalloc(1, sizeof(*pMeta) + strlen(path) + 1)) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
||||
}
|
||||
|
||||
metaInitLock(pMeta);
|
||||
|
@ -69,163 +68,104 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
|||
taosMkDir(pMeta->path);
|
||||
|
||||
// open env
|
||||
ret = tdbOpen(pMeta->path, pVnode->config.szPage, pVnode->config.szCache, &pMeta->pEnv, rollback,
|
||||
code = tdbOpen(pMeta->path, pVnode->config.szPage, pVnode->config.szCache, &pMeta->pEnv, rollback,
|
||||
pVnode->config.tdbEncryptAlgorithm, pVnode->config.tdbEncryptKey);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta env since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// open pTbDb
|
||||
ret = tdbTbOpen("table.db", sizeof(STbDbKey), -1, tbDbKeyCmpr, pMeta->pEnv, &pMeta->pTbDb, 0);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta table db since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = tdbTbOpen("table.db", sizeof(STbDbKey), -1, tbDbKeyCmpr, pMeta->pEnv, &pMeta->pTbDb, 0);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// open pSkmDb
|
||||
ret = tdbTbOpen("schema.db", sizeof(SSkmDbKey), -1, skmDbKeyCmpr, pMeta->pEnv, &pMeta->pSkmDb, 0);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta schema db since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = tdbTbOpen("schema.db", sizeof(SSkmDbKey), -1, skmDbKeyCmpr, pMeta->pEnv, &pMeta->pSkmDb, 0);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// open pUidIdx
|
||||
ret = tdbTbOpen("uid.idx", sizeof(tb_uid_t), sizeof(SUidIdxVal), uidIdxKeyCmpr, pMeta->pEnv, &pMeta->pUidIdx, 0);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta uid idx since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = tdbTbOpen("uid.idx", sizeof(tb_uid_t), sizeof(SUidIdxVal), uidIdxKeyCmpr, pMeta->pEnv, &pMeta->pUidIdx, 0);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// open pNameIdx
|
||||
ret = tdbTbOpen("name.idx", -1, sizeof(tb_uid_t), NULL, pMeta->pEnv, &pMeta->pNameIdx, 0);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta name index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = tdbTbOpen("name.idx", -1, sizeof(tb_uid_t), NULL, pMeta->pEnv, &pMeta->pNameIdx, 0);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// open pCtbIdx
|
||||
ret = tdbTbOpen("ctb.idx", sizeof(SCtbIdxKey), -1, ctbIdxKeyCmpr, pMeta->pEnv, &pMeta->pCtbIdx, 0);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta child table index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = tdbTbOpen("ctb.idx", sizeof(SCtbIdxKey), -1, ctbIdxKeyCmpr, pMeta->pEnv, &pMeta->pCtbIdx, 0);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// open pSuidIdx
|
||||
ret = tdbTbOpen("suid.idx", sizeof(tb_uid_t), 0, uidIdxKeyCmpr, pMeta->pEnv, &pMeta->pSuidIdx, 0);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta super table index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = tdbTbOpen("suid.idx", sizeof(tb_uid_t), 0, uidIdxKeyCmpr, pMeta->pEnv, &pMeta->pSuidIdx, 0);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
char indexFullPath[128] = {0};
|
||||
sprintf(indexFullPath, "%s/%s", pMeta->path, "invert");
|
||||
taosMkDir(indexFullPath);
|
||||
TAOS_UNUSED(taosMkDir(indexFullPath));
|
||||
|
||||
SIndexOpts opts = {.cacheSize = 8 * 1024 * 1024};
|
||||
ret = indexOpen(&opts, indexFullPath, (SIndex **)&pMeta->pTagIvtIdx);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta tag index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = indexOpen(&opts, indexFullPath, (SIndex **)&pMeta->pTagIvtIdx);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
ret = tdbTbOpen("tag.idx", -1, 0, tagIdxKeyCmpr, pMeta->pEnv, &pMeta->pTagIdx, 0);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta tag index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = tdbTbOpen("tag.idx", -1, 0, tagIdxKeyCmpr, pMeta->pEnv, &pMeta->pTagIdx, 0);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// open pTtlMgr ("ttlv1.idx")
|
||||
char logPrefix[128] = {0};
|
||||
sprintf(logPrefix, "vgId:%d", TD_VID(pVnode));
|
||||
ret = ttlMgrOpen(&pMeta->pTtlMgr, pMeta->pEnv, 0, logPrefix, tsTtlFlushThreshold);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta ttl index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = ttlMgrOpen(&pMeta->pTtlMgr, pMeta->pEnv, 0, logPrefix, tsTtlFlushThreshold);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// open pSmaIdx
|
||||
ret = tdbTbOpen("sma.idx", sizeof(SSmaIdxKey), 0, smaIdxKeyCmpr, pMeta->pEnv, &pMeta->pSmaIdx, 0);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta sma index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = tdbTbOpen("sma.idx", sizeof(SSmaIdxKey), 0, smaIdxKeyCmpr, pMeta->pEnv, &pMeta->pSmaIdx, 0);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// idx table create time
|
||||
ret = tdbTbOpen("ctime.idx", sizeof(SBtimeIdxKey), 0, btimeIdxCmpr, pMeta->pEnv, &pMeta->pBtimeIdx, 0);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta ctime index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = tdbTbOpen("ctime.idx", sizeof(SBtimeIdxKey), 0, btimeIdxCmpr, pMeta->pEnv, &pMeta->pBtimeIdx, 0);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// idx num of col, normal table only
|
||||
ret = tdbTbOpen("ncol.idx", sizeof(SNcolIdxKey), 0, ncolIdxCmpr, pMeta->pEnv, &pMeta->pNcolIdx, 0);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta ncol index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = tdbTbOpen("ncol.idx", sizeof(SNcolIdxKey), 0, ncolIdxCmpr, pMeta->pEnv, &pMeta->pNcolIdx, 0);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
ret = tdbTbOpen("stream.task.db", sizeof(int64_t), -1, taskIdxKeyCmpr, pMeta->pEnv, &pMeta->pStreamDb, 0);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta stream task index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = tdbTbOpen("stream.task.db", sizeof(int64_t), -1, taskIdxKeyCmpr, pMeta->pEnv, &pMeta->pStreamDb, 0);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// open index
|
||||
if (metaOpenIdx(pMeta) < 0) {
|
||||
metaError("vgId:%d, failed to open meta index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
code = metaCacheOpen(pMeta);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
int32_t code = metaCacheOpen(pMeta);
|
||||
code = metaInitTbFilterCache(pMeta);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
terrno = code;
|
||||
metaError("vgId:%d, failed to open meta cache since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
|
||||
if (metaInitTbFilterCache(pMeta) != 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
metaDebug("vgId:%d, meta is opened", TD_VID(pVnode));
|
||||
|
||||
*ppMeta = pMeta;
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
metaError("vgId:%d %s failed at %s:%d since %s", TD_VID(pVnode), __func__, __FILE__, __LINE__, tstrerror(code));
|
||||
metaCleanup(&pMeta);
|
||||
return -1;
|
||||
*ppMeta = NULL;
|
||||
} else {
|
||||
metaDebug("vgId:%d %s success", TD_VID(pVnode), __func__);
|
||||
*ppMeta = pMeta;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int metaUpgrade(SVnode *pVnode, SMeta **ppMeta) {
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t metaUpgrade(SVnode *pVnode, SMeta **ppMeta) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino;
|
||||
SMeta *pMeta = *ppMeta;
|
||||
|
||||
if (ttlMgrNeedUpgrade(pMeta->pEnv)) {
|
||||
code = metaBegin(pMeta, META_BEGIN_HEAP_OS);
|
||||
if (code < 0) {
|
||||
metaError("vgId:%d, failed to upgrade meta, meta begin failed since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
code = ttlMgrUpgrade(pMeta->pTtlMgr, pMeta);
|
||||
if (code < 0) {
|
||||
metaError("vgId:%d, failed to upgrade meta ttl since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
code = metaCommit(pMeta, pMeta->txn);
|
||||
if (code < 0) {
|
||||
metaError("vgId:%d, failed to upgrade meta ttl, meta commit failed since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_err:
|
||||
_exit:
|
||||
if (code) {
|
||||
metaError("vgId:%d %s failed at %s:%d since %s", TD_VID(pVnode), __func__, __FILE__, __LINE__, tstrerror(code));
|
||||
metaCleanup(ppMeta);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -235,33 +175,42 @@ int metaClose(SMeta **ppMeta) {
|
|||
}
|
||||
|
||||
int metaAlterCache(SMeta *pMeta, int32_t nPage) {
|
||||
int32_t code = 0;
|
||||
metaWLock(pMeta);
|
||||
|
||||
if (tdbAlter(pMeta->pEnv, nPage) < 0) {
|
||||
code = tdbAlter(pMeta->pEnv, nPage);
|
||||
metaULock(pMeta);
|
||||
return -1;
|
||||
|
||||
if (code) {
|
||||
metaError("vgId:%d %s failed since %s", TD_VID(pMeta->pVnode), __func__, tstrerror(code));
|
||||
}
|
||||
|
||||
metaULock(pMeta);
|
||||
return 0;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t metaRLock(SMeta *pMeta) {
|
||||
metaTrace("meta rlock %p", &pMeta->lock);
|
||||
int32_t ret = taosThreadRwlockRdlock(&pMeta->lock);
|
||||
return ret;
|
||||
int32_t code = taosThreadRwlockRdlock(&pMeta->lock);
|
||||
if (code) {
|
||||
return TAOS_SYSTEM_ERROR(code);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t metaWLock(SMeta *pMeta) {
|
||||
metaTrace("meta wlock %p", &pMeta->lock);
|
||||
int32_t ret = taosThreadRwlockWrlock(&pMeta->lock);
|
||||
return ret;
|
||||
int32_t code = taosThreadRwlockWrlock(&pMeta->lock);
|
||||
if (code) {
|
||||
return TAOS_SYSTEM_ERROR(code);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t metaULock(SMeta *pMeta) {
|
||||
metaTrace("meta ulock %p", &pMeta->lock);
|
||||
int32_t ret = taosThreadRwlockUnlock(&pMeta->lock);
|
||||
return ret;
|
||||
int32_t code = taosThreadRwlockUnlock(&pMeta->lock);
|
||||
if (code) {
|
||||
return TAOS_SYSTEM_ERROR(code);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void metaCleanup(SMeta **ppMeta) {
|
||||
|
|
|
@ -1542,9 +1542,14 @@ int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables, int32_t
|
|||
// slow path: search TDB
|
||||
int64_t ctbNum = 0;
|
||||
int32_t colNum = 0;
|
||||
vnodeGetCtbNum(pVnode, uid, &ctbNum);
|
||||
vnodeGetStbColumnNum(pVnode, uid, &colNum);
|
||||
code = vnodeGetCtbNum(pVnode, uid, &ctbNum);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = vnodeGetStbColumnNum(pVnode, uid, &colNum);
|
||||
}
|
||||
metaULock(pVnodeObj->pMeta);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (numOfTables) *numOfTables = ctbNum;
|
||||
if (numOfCols) *numOfCols = colNum;
|
||||
|
|
|
@ -25,14 +25,14 @@ struct SMetaSnapReader {
|
|||
|
||||
int32_t metaSnapReaderOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapReader** ppReader) {
|
||||
int32_t code = 0;
|
||||
int32_t lino;
|
||||
int32_t c = 0;
|
||||
SMetaSnapReader* pReader = NULL;
|
||||
|
||||
// alloc
|
||||
pReader = (SMetaSnapReader*)taosMemoryCalloc(1, sizeof(*pReader));
|
||||
if (pReader == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
||||
}
|
||||
pReader->pMeta = pMeta;
|
||||
pReader->sver = sver;
|
||||
|
@ -40,36 +40,29 @@ int32_t metaSnapReaderOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapRe
|
|||
|
||||
// impl
|
||||
code = tdbTbcOpen(pMeta->pTbDb, &pReader->pTbc, NULL);
|
||||
if (code) {
|
||||
taosMemoryFree(pReader);
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
code = tdbTbcMoveTo(pReader->pTbc, &(STbDbKey){.version = sver, .uid = INT64_MIN}, sizeof(STbDbKey), &c);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
taosMemoryFree(pReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
metaInfo("vgId:%d, vnode snapshot meta reader opened", TD_VID(pMeta->pVnode));
|
||||
|
||||
*ppReader = pReader;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
metaError("vgId:%d, vnode snapshot meta reader open failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
||||
metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, lino, tstrerror(code));
|
||||
metaSnapReaderClose(&pReader);
|
||||
*ppReader = NULL;
|
||||
} else {
|
||||
metaInfo("vgId:%d, %s success", TD_VID(pMeta->pVnode), __func__);
|
||||
*ppReader = pReader;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t metaSnapReaderClose(SMetaSnapReader** ppReader) {
|
||||
int32_t code = 0;
|
||||
|
||||
void metaSnapReaderClose(SMetaSnapReader** ppReader) {
|
||||
if (ppReader && *ppReader) {
|
||||
tdbTbcClose((*ppReader)->pTbc);
|
||||
taosMemoryFree(*ppReader);
|
||||
*ppReader = NULL;
|
||||
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
||||
|
@ -106,7 +99,7 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
|||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + nData);
|
||||
if (*ppData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
|
||||
|
@ -122,10 +115,10 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
|||
}
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
|
||||
_err:
|
||||
metaError("vgId:%d, vnode snapshot meta read data failed since %s", TD_VID(pReader->pMeta->pVnode), tstrerror(code));
|
||||
if (code) {
|
||||
metaError("vgId:%d, vnode snapshot meta read data failed since %s", TD_VID(pReader->pMeta->pVnode),
|
||||
tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -138,26 +131,30 @@ struct SMetaSnapWriter {
|
|||
|
||||
int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWriter** ppWriter) {
|
||||
int32_t code = 0;
|
||||
int32_t lino;
|
||||
SMetaSnapWriter* pWriter;
|
||||
|
||||
// alloc
|
||||
pWriter = (SMetaSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||
if (pWriter == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
||||
}
|
||||
pWriter->pMeta = pMeta;
|
||||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
metaBegin(pMeta, META_BEGIN_HEAP_NIL);
|
||||
code = metaBegin(pMeta, META_BEGIN_HEAP_NIL);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
*ppWriter = pWriter;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
metaError("vgId:%d, meta snapshot writer open failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
||||
_exit:
|
||||
if (code) {
|
||||
metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, lino, tstrerror(code));
|
||||
taosMemoryFree(pWriter);
|
||||
*ppWriter = NULL;
|
||||
} else {
|
||||
metaDebug("vgId:%d, %s success", TD_VID(pMeta->pVnode), __func__);
|
||||
*ppWriter = pWriter;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -189,25 +186,24 @@ _err:
|
|||
|
||||
int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
int32_t code = 0;
|
||||
int32_t line = 0;
|
||||
int32_t lino = 0;
|
||||
SMeta* pMeta = pWriter->pMeta;
|
||||
SMetaEntry metaEntry = {0};
|
||||
SDecoder* pDecoder = &(SDecoder){0};
|
||||
|
||||
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||
code = metaDecodeEntry(pDecoder, &metaEntry);
|
||||
VND_CHECK_CODE(code, line, _err);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
code = metaHandleEntry(pMeta, &metaEntry);
|
||||
VND_CHECK_CODE(code, line, _err);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, lino, tstrerror(code));
|
||||
}
|
||||
tDecoderClear(pDecoder);
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tDecoderClear(pDecoder);
|
||||
metaError("vgId:%d, vnode snapshot meta write failed since %s at line:%d", TD_VID(pMeta->pVnode), terrstr(), line);
|
||||
return code;
|
||||
}
|
||||
|
||||
typedef struct STableInfoForChildTable {
|
||||
|
@ -478,9 +474,7 @@ void taosXSetTablePrimaryKey(SSnapContext* ctx, int64_t uid){
|
|||
ctx->hasPrimaryKey = ret;
|
||||
}
|
||||
|
||||
bool taosXGetTablePrimaryKey(SSnapContext* ctx){
|
||||
return ctx->hasPrimaryKey;
|
||||
}
|
||||
bool taosXGetTablePrimaryKey(SSnapContext* ctx) { return ctx->hasPrimaryKey; }
|
||||
|
||||
int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLen, int16_t* type, int64_t* uid) {
|
||||
int32_t ret = 0;
|
||||
|
|
|
@ -47,7 +47,7 @@ int32_t fillTableColCmpr(SMetaReader *reader, SSchemaExt *pExt, int32_t numOfCol
|
|||
return 0;
|
||||
}
|
||||
|
||||
int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||
int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||
STableInfoReq infoReq = {0};
|
||||
STableMetaRsp metaRsp = {0};
|
||||
SMetaReader mer1 = {0};
|
||||
|
@ -62,15 +62,15 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
|
||||
// decode req
|
||||
if (tDeserializeSTableInfoReq(pMsg->pCont, pMsg->contLen, &infoReq) != 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
code = terrno;
|
||||
goto _exit4;
|
||||
}
|
||||
|
||||
metaRsp.dbId = pVnode->config.dbId;
|
||||
strcpy(metaRsp.tbName, infoReq.tbName);
|
||||
memcpy(metaRsp.dbFName, infoReq.dbFName, sizeof(metaRsp.dbFName));
|
||||
(void)strcpy(metaRsp.tbName, infoReq.tbName);
|
||||
(void)memcpy(metaRsp.dbFName, infoReq.dbFName, sizeof(metaRsp.dbFName));
|
||||
|
||||
sprintf(tableFName, "%s.%s", infoReq.dbFName, infoReq.tbName);
|
||||
(void)sprintf(tableFName, "%s.%s", infoReq.dbFName, infoReq.tbName);
|
||||
code = vnodeValidateTableHash(pVnode, tableFName);
|
||||
if (code) {
|
||||
goto _exit4;
|
||||
|
@ -89,7 +89,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
metaRsp.tuid = mer1.me.uid;
|
||||
|
||||
if (mer1.me.type == TSDB_SUPER_TABLE) {
|
||||
strcpy(metaRsp.stbName, mer1.me.name);
|
||||
(void)strcpy(metaRsp.stbName, mer1.me.name);
|
||||
schema = mer1.me.stbEntry.schemaRow;
|
||||
schemaTag = mer1.me.stbEntry.schemaTag;
|
||||
metaRsp.suid = mer1.me.uid;
|
||||
|
@ -97,7 +97,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_NOLOCK);
|
||||
if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit2;
|
||||
|
||||
strcpy(metaRsp.stbName, mer2.me.name);
|
||||
(void)strcpy(metaRsp.stbName, mer2.me.name);
|
||||
metaRsp.suid = mer2.me.uid;
|
||||
schema = mer2.me.stbEntry.schemaRow;
|
||||
schemaTag = mer2.me.stbEntry.schemaTag;
|
||||
|
@ -114,10 +114,13 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
metaRsp.tversion = schemaTag.version;
|
||||
metaRsp.pSchemas = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * (metaRsp.numOfColumns + metaRsp.numOfTags));
|
||||
metaRsp.pSchemaExt = (SSchemaExt *)taosMemoryCalloc(metaRsp.numOfColumns, sizeof(SSchemaExt));
|
||||
|
||||
memcpy(metaRsp.pSchemas, schema.pSchema, sizeof(SSchema) * schema.nCols);
|
||||
if (NULL == metaRsp.pSchemas || NULL == metaRsp.pSchemaExt) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
(void)memcpy(metaRsp.pSchemas, schema.pSchema, sizeof(SSchema) * schema.nCols);
|
||||
if (schemaTag.nCols) {
|
||||
memcpy(metaRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
|
||||
(void)memcpy(metaRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
|
||||
}
|
||||
if (metaRsp.pSchemaExt) {
|
||||
SMetaReader *pReader = mer1.me.type == TSDB_CHILD_TABLE ? &mer2 : &mer1;
|
||||
|
@ -134,7 +137,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
// encode and send response
|
||||
rspLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp);
|
||||
if (rspLen < 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
@ -148,7 +151,12 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp);
|
||||
|
||||
rspLen = tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp);
|
||||
if (rspLen < 0) {
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
_exit:
|
||||
taosMemoryFree(metaRsp.pSchemas);
|
||||
|
@ -174,10 +182,10 @@ _exit4:
|
|||
*pMsg = rpcMsg;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||
int32_t vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||
STableCfgReq cfgReq = {0};
|
||||
STableCfgRsp cfgRsp = {0};
|
||||
SMetaReader mer1 = {0};
|
||||
|
@ -192,14 +200,14 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
|
||||
// decode req
|
||||
if (tDeserializeSTableCfgReq(pMsg->pCont, pMsg->contLen, &cfgReq) != 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
strcpy(cfgRsp.tbName, cfgReq.tbName);
|
||||
memcpy(cfgRsp.dbFName, cfgReq.dbFName, sizeof(cfgRsp.dbFName));
|
||||
(void)strcpy(cfgRsp.tbName, cfgReq.tbName);
|
||||
(void)memcpy(cfgRsp.dbFName, cfgReq.dbFName, sizeof(cfgRsp.dbFName));
|
||||
|
||||
sprintf(tableFName, "%s.%s", cfgReq.dbFName, cfgReq.tbName);
|
||||
(void)sprintf(tableFName, "%s.%s", cfgReq.dbFName, cfgReq.tbName);
|
||||
code = vnodeValidateTableHash(pVnode, tableFName);
|
||||
if (code) {
|
||||
goto _exit;
|
||||
|
@ -222,24 +230,36 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_LOCK);
|
||||
if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit;
|
||||
|
||||
strcpy(cfgRsp.stbName, mer2.me.name);
|
||||
(void)strcpy(cfgRsp.stbName, mer2.me.name);
|
||||
schema = mer2.me.stbEntry.schemaRow;
|
||||
schemaTag = mer2.me.stbEntry.schemaTag;
|
||||
cfgRsp.ttl = mer1.me.ctbEntry.ttlDays;
|
||||
cfgRsp.commentLen = mer1.me.ctbEntry.commentLen;
|
||||
if (mer1.me.ctbEntry.commentLen > 0) {
|
||||
cfgRsp.pComment = taosStrdup(mer1.me.ctbEntry.comment);
|
||||
if (NULL == cfgRsp.pComment) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
STag *pTag = (STag *)mer1.me.ctbEntry.pTags;
|
||||
cfgRsp.tagsLen = pTag->len;
|
||||
cfgRsp.pTags = taosMemoryMalloc(cfgRsp.tagsLen);
|
||||
memcpy(cfgRsp.pTags, pTag, cfgRsp.tagsLen);
|
||||
if (NULL == cfgRsp.pTags) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
(void)memcpy(cfgRsp.pTags, pTag, cfgRsp.tagsLen);
|
||||
} else if (mer1.me.type == TSDB_NORMAL_TABLE) {
|
||||
schema = mer1.me.ntbEntry.schemaRow;
|
||||
cfgRsp.ttl = mer1.me.ntbEntry.ttlDays;
|
||||
cfgRsp.commentLen = mer1.me.ntbEntry.commentLen;
|
||||
if (mer1.me.ntbEntry.commentLen > 0) {
|
||||
cfgRsp.pComment = taosStrdup(mer1.me.ntbEntry.comment);
|
||||
if (NULL == cfgRsp.pComment) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ASSERT(0);
|
||||
|
@ -250,9 +270,13 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
cfgRsp.pSchemas = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * (cfgRsp.numOfColumns + cfgRsp.numOfTags));
|
||||
cfgRsp.pSchemaExt = (SSchemaExt *)taosMemoryMalloc(cfgRsp.numOfColumns * sizeof(SSchemaExt));
|
||||
|
||||
memcpy(cfgRsp.pSchemas, schema.pSchema, sizeof(SSchema) * schema.nCols);
|
||||
if (NULL == cfgRsp.pSchemas || NULL == cfgRsp.pSchemaExt) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
(void)memcpy(cfgRsp.pSchemas, schema.pSchema, sizeof(SSchema) * schema.nCols);
|
||||
if (schemaTag.nCols) {
|
||||
memcpy(cfgRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
|
||||
(void)memcpy(cfgRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
|
||||
}
|
||||
|
||||
// if (useCompress(cfgRsp.tableType)) {
|
||||
|
@ -271,7 +295,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
// encode and send response
|
||||
rspLen = tSerializeSTableCfgRsp(NULL, 0, &cfgRsp);
|
||||
if (rspLen < 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
@ -285,7 +309,12 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
tSerializeSTableCfgRsp(pRsp, rspLen, &cfgRsp);
|
||||
|
||||
rspLen = tSerializeSTableCfgRsp(pRsp, rspLen, &cfgRsp);
|
||||
if (rspLen < 0) {
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
_exit:
|
||||
rpcMsg.info = pMsg->info;
|
||||
|
@ -307,7 +336,7 @@ _exit:
|
|||
tFreeSTableCfgRsp(&cfgRsp);
|
||||
metaReaderClear(&mer2);
|
||||
metaReaderClear(&mer1);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void vnodeFreeSBatchRspMsg(void *p) {
|
||||
|
@ -331,7 +360,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
void *pRsp = NULL;
|
||||
|
||||
if (tDeserializeSBatchReq(pMsg->pCont, pMsg->contLen, &batchReq)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
qError("tDeserializeSBatchReq failed");
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -352,6 +381,10 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
|
||||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
req = taosArrayGet(batchReq.pMsgs, i);
|
||||
if (req == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
reqMsg.msgType = req->msgType;
|
||||
reqMsg.pCont = req->msg;
|
||||
|
@ -359,13 +392,16 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
|
||||
switch (req->msgType) {
|
||||
case TDMT_VND_TABLE_META:
|
||||
vnodeGetTableMeta(pVnode, &reqMsg, false);
|
||||
// error code has been set into reqMsg, no need to handle it here.
|
||||
(void)vnodeGetTableMeta(pVnode, &reqMsg, false);
|
||||
break;
|
||||
case TDMT_VND_TABLE_CFG:
|
||||
vnodeGetTableCfg(pVnode, &reqMsg, false);
|
||||
// error code has been set into reqMsg, no need to handle it here.
|
||||
(void)vnodeGetTableCfg(pVnode, &reqMsg, false);
|
||||
break;
|
||||
case TDMT_VND_GET_STREAM_PROGRESS:
|
||||
vnodeGetStreamProgress(pVnode, &reqMsg, false);
|
||||
// error code has been set into reqMsg, no need to handle it here.
|
||||
(void)vnodeGetStreamProgress(pVnode, &reqMsg, false);
|
||||
break;
|
||||
default:
|
||||
qError("invalid req msgType %d", req->msgType);
|
||||
|
@ -381,24 +417,28 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
rsp.rspCode = reqMsg.code;
|
||||
rsp.msg = reqMsg.pCont;
|
||||
|
||||
taosArrayPush(batchRsp.pRsps, &rsp);
|
||||
if (NULL == taosArrayPush(batchRsp.pRsps, &rsp)) {
|
||||
qError("taosArrayPush failed");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
||||
rspSize = tSerializeSBatchRsp(NULL, 0, &batchRsp);
|
||||
if (rspSize < 0) {
|
||||
qError("tSerializeSBatchRsp failed");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
pRsp = rpcMallocCont(rspSize);
|
||||
if (pRsp == NULL) {
|
||||
qError("rpcMallocCont %d failed", rspSize);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
if (tSerializeSBatchRsp(pRsp, rspSize, &batchRsp) < 0) {
|
||||
qError("tSerializeSBatchRsp %d failed", rspSize);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
@ -501,7 +541,12 @@ int32_t vnodeGetTableList(void *pVnode, int8_t type, SArray *pList) {
|
|||
}
|
||||
|
||||
int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SMCtbCursor *pCur = metaOpenCtbCursor(pVnode, uid, 1);
|
||||
if (NULL == pCur) {
|
||||
qError("vnode get all table list failed");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
tb_uid_t id = metaCtbCursorNext(pCur);
|
||||
|
@ -510,11 +555,15 @@ int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list) {
|
|||
}
|
||||
|
||||
STableKeyInfo info = {uid = id};
|
||||
taosArrayPush(list, &info);
|
||||
if (NULL == taosArrayPush(list, &info)) {
|
||||
qError("taosArrayPush failed");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
}
|
||||
_exit:
|
||||
metaCloseCtbCursor(pCur);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeGetCtbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg), void *arg) {
|
||||
|
@ -522,8 +571,13 @@ int32_t vnodeGetCtbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bo
|
|||
}
|
||||
|
||||
int32_t vnodeGetCtbIdList(void *pVnode, int64_t suid, SArray *list) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SVnode *pVnodeObj = pVnode;
|
||||
SMCtbCursor *pCur = metaOpenCtbCursor(pVnodeObj, suid, 1);
|
||||
if (NULL == pCur) {
|
||||
qError("vnode get all table list failed");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
tb_uid_t id = metaCtbCursorNext(pCur);
|
||||
|
@ -531,14 +585,20 @@ int32_t vnodeGetCtbIdList(void *pVnode, int64_t suid, SArray *list) {
|
|||
break;
|
||||
}
|
||||
|
||||
taosArrayPush(list, &id);
|
||||
if (NULL == taosArrayPush(list, &id)) {
|
||||
qError("taosArrayPush failed");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
||||
_exit:
|
||||
metaCloseCtbCursor(pCur);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, suid);
|
||||
if (!pCur) {
|
||||
return TSDB_CODE_FAILED;
|
||||
|
@ -550,15 +610,21 @@ int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list) {
|
|||
break;
|
||||
}
|
||||
|
||||
taosArrayPush(list, &id);
|
||||
if (NULL == taosArrayPush(list, &id)) {
|
||||
qError("taosArrayPush failed");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
||||
_exit:
|
||||
metaCloseStbCursor(pCur);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeGetStbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg, void *arg1),
|
||||
void *arg) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, suid);
|
||||
if (!pCur) {
|
||||
return TSDB_CODE_FAILED;
|
||||
|
@ -574,11 +640,16 @@ int32_t vnodeGetStbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bo
|
|||
continue;
|
||||
}
|
||||
|
||||
taosArrayPush(list, &id);
|
||||
if (NULL == taosArrayPush(list, &id)) {
|
||||
qError("taosArrayPush failed");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
||||
_exit:
|
||||
metaCloseStbCursor(pCur);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeGetCtbNum(SVnode *pVnode, int64_t suid, int64_t *num) {
|
||||
|
@ -700,16 +771,20 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
|
|||
|
||||
*num = 0;
|
||||
int64_t arrSize = taosArrayGetSize(suidList);
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
for (int64_t i = 0; i < arrSize; ++i) {
|
||||
tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i);
|
||||
|
||||
int64_t ctbNum = 0;
|
||||
int32_t numOfCols = 0;
|
||||
metaGetStbStats(pVnode, suid, &ctbNum, &numOfCols);
|
||||
|
||||
code = metaGetStbStats(pVnode, suid, &ctbNum, &numOfCols);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _exit;
|
||||
}
|
||||
*num += ctbNum * (numOfCols - 1);
|
||||
}
|
||||
|
||||
_exit:
|
||||
taosArrayDestroy(suidList);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -728,7 +803,11 @@ int32_t vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num) {
|
|||
}
|
||||
|
||||
int64_t ctbNum = 0;
|
||||
vnodeGetCtbNum(pVnode, id, &ctbNum);
|
||||
int32_t code = vnodeGetCtbNum(pVnode, id, &ctbNum);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
metaCloseStbCursor(pCur);
|
||||
return code;
|
||||
}
|
||||
|
||||
*num += ctbNum;
|
||||
}
|
||||
|
@ -771,14 +850,17 @@ int32_t vnodeGetStreamProgress(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
rsp.vgId = req.vgId;
|
||||
rsp.streamId = req.streamId;
|
||||
rspLen = tSerializeStreamProgressRsp(0, 0, &rsp);
|
||||
if (rspLen < 0) {
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
if (direct) {
|
||||
buf = rpcMallocCont(rspLen);
|
||||
} else {
|
||||
buf = taosMemoryCalloc(1, rspLen);
|
||||
}
|
||||
if (!buf) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = -1;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
@ -787,7 +869,11 @@ int32_t vnodeGetStreamProgress(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
code = tqGetStreamExecInfo(pVnode, req.streamId, &rsp.progressDelay, &rsp.fillHisFinished);
|
||||
}
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
tSerializeStreamProgressRsp(buf, rspLen, &rsp);
|
||||
rspLen = tSerializeStreamProgressRsp(buf, rspLen, &rsp);
|
||||
if (rspLen < 0) {
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
rpcMsg.pCont = buf;
|
||||
buf = NULL;
|
||||
rpcMsg.contLen = rspLen;
|
||||
|
|
|
@ -312,8 +312,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
goto _exit;
|
||||
} else {
|
||||
pReader->metaDone = 1;
|
||||
code = metaSnapReaderClose(&pReader->pMetaReader);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
metaSnapReaderClose(&pReader->pMetaReader);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -521,8 +521,8 @@ int32_t setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t n
|
|||
|
||||
if (!pResInfo->initialized) {
|
||||
if (pCtx[i].functionId != -1) {
|
||||
bool ini = pCtx[i].fpSet.init(&pCtx[i], pResInfo);
|
||||
if (!ini && fmIsUserDefinedFunc(pCtx[i].functionId)) {
|
||||
int32_t code = pCtx[i].fpSet.init(&pCtx[i], pResInfo);
|
||||
if (code != TSDB_CODE_SUCCESS && fmIsUserDefinedFunc(pCtx[i].functionId)){
|
||||
pResInfo->initialized = false;
|
||||
return TSDB_CODE_UDF_FUNC_EXEC_FAILURE;
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ static int32_t doGenerateSourceData(SOperatorInfo* pOperator);
|
|||
static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator);
|
||||
static SSDataBlock* doApplyIndefinitFunction(SOperatorInfo* pOperator);
|
||||
static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols);
|
||||
static void setFunctionResultOutput(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t stage,
|
||||
int32_t numOfExprs);
|
||||
static int32_t setFunctionResultOutput(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, SAggSupporter* pSup,
|
||||
int32_t stage, int32_t numOfExprs);
|
||||
|
||||
static void destroyProjectOperatorInfo(void* param) {
|
||||
if (NULL == param) {
|
||||
|
@ -142,7 +142,10 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
|||
}
|
||||
|
||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||
setFunctionResultOutput(pOperator, &pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, numOfCols);
|
||||
code = setFunctionResultOutput(pOperator, &pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, numOfCols);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
code = filterInitFromNode((SNode*)pProjPhyNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -447,7 +450,11 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
|
|||
goto _error;
|
||||
}
|
||||
|
||||
setFunctionResultOutput(pOperator, &pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, numOfExpr);
|
||||
code = setFunctionResultOutput(pOperator, &pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, numOfExpr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
code = filterInitFromNode((SNode*)pPhyNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
|
@ -589,7 +596,8 @@ SSDataBlock* doApplyIndefinitFunction(SOperatorInfo* pOperator) {
|
|||
return (rows > 0) ? pInfo->pRes : NULL;
|
||||
}
|
||||
|
||||
void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size) {
|
||||
int32_t initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
for (int32_t j = 0; j < size; ++j) {
|
||||
struct SResultRowEntryInfo* pResInfo = GET_RES_INFO(&pCtx[j]);
|
||||
if (isRowEntryInitialized(pResInfo) || fmIsPseudoColumnFunc(pCtx[j].functionId) || pCtx[j].functionId == -1 ||
|
||||
|
@ -597,9 +605,13 @@ void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size) {
|
|||
continue;
|
||||
}
|
||||
|
||||
pCtx[j].fpSet.init(&pCtx[j], pCtx[j].resultInfo);
|
||||
code = pCtx[j].fpSet.init(&pCtx[j], pCtx[j].resultInfo);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
/*
|
||||
* The start of each column SResultRowEntryInfo is denote by RowCellInfoOffset.
|
||||
|
@ -610,7 +622,7 @@ void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size) {
|
|||
* offset[0] offset[1] offset[2]
|
||||
*/
|
||||
// TODO refactor: some function move away
|
||||
void setFunctionResultOutput(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t stage,
|
||||
int32_t setFunctionResultOutput(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t stage,
|
||||
int32_t numOfExprs) {
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx;
|
||||
|
@ -632,7 +644,7 @@ void setFunctionResultOutput(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, SA
|
|||
pCtx[i].scanFlag = stage;
|
||||
}
|
||||
|
||||
initCtxOutputBuffer(pCtx, numOfExprs);
|
||||
return initCtxOutputBuffer(pCtx, numOfExprs);
|
||||
}
|
||||
|
||||
SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols) {
|
||||
|
@ -841,7 +853,10 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
|
|||
// do nothing
|
||||
} else if (fmIsIndefiniteRowsFunc(pfCtx->functionId)) {
|
||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pfCtx);
|
||||
pfCtx->fpSet.init(pfCtx, pResInfo);
|
||||
code = pfCtx->fpSet.init(pfCtx, pResInfo);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
pfCtx->pOutput = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||
pfCtx->offset = createNewColModel ? 0 : pResult->info.rows; // set the start offset
|
||||
|
|
|
@ -207,8 +207,9 @@ static int32_t doDynamicPruneDataBlock(SOperatorInfo* pOperator, SDataBlockInfo*
|
|||
|
||||
SResultRowEntryInfo* pEntry = getResultEntryInfo(pRow, i, pTableScanInfo->base.pdInfo.pExprSup->rowEntryInfoOffset);
|
||||
|
||||
int32_t reqStatus = fmFuncDynDataRequired(functionId, pEntry, pBlockInfo);
|
||||
if (reqStatus != FUNC_DATA_REQUIRED_NOT_LOAD) {
|
||||
int32_t reqStatus;
|
||||
code = fmFuncDynDataRequired(functionId, pEntry, pBlockInfo, &reqStatus);
|
||||
if (code != TSDB_CODE_SUCCESS || reqStatus != FUNC_DATA_REQUIRED_NOT_LOAD) {
|
||||
notLoadBlock = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -49,9 +49,9 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
|
|||
|
||||
int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos);
|
||||
int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos);
|
||||
const char* loadTupleData(SqlFunctionCtx* pCtx, const STuplePos* pPos);
|
||||
int32_t loadTupleData(SqlFunctionCtx* pCtx, const STuplePos* pPos, char** value);
|
||||
|
||||
bool functionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t functionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t functionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
int32_t functionFinalizeWithResultBuf(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, char* finalResult);
|
||||
int32_t combineFunction(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||
|
@ -74,7 +74,7 @@ int32_t sumInvertFunction(SqlFunctionCtx* pCtx);
|
|||
|
||||
int32_t sumCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||
|
||||
bool minmaxFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t minmaxFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
bool getMinmaxFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
int32_t minFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t maxFunction(SqlFunctionCtx* pCtx);
|
||||
|
@ -83,7 +83,7 @@ int32_t minCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
|||
int32_t maxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||
|
||||
bool getAvgFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool avgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t avgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t avgFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t avgFunctionMerge(SqlFunctionCtx* pCtx);
|
||||
int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
@ -97,7 +97,7 @@ int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
|||
int32_t getAvgInfoSize();
|
||||
|
||||
bool getStddevFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool stddevFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t stddevFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t stddevFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx);
|
||||
int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
@ -111,18 +111,18 @@ int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
|||
int32_t getStddevInfoSize();
|
||||
|
||||
bool getLeastSQRFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool leastSQRFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t leastSQRFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t leastSQRFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
int32_t leastSQRCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||
|
||||
bool getPercentileFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool percentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t percentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t percentileFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
||||
bool getApercentileFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool apercentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t apercentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t apercentileFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx);
|
||||
int32_t apercentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
@ -131,16 +131,16 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx)
|
|||
int32_t getApercentileMaxSize();
|
||||
|
||||
bool getDiffFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo);
|
||||
int32_t diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo);
|
||||
int32_t diffFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t diffFunctionByRow(SArray* pCtx);
|
||||
|
||||
bool getDerivativeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool derivativeFuncSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo);
|
||||
int32_t derivativeFuncSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo);
|
||||
int32_t derivativeFunction(SqlFunctionCtx* pCtx);
|
||||
|
||||
bool getIrateFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool irateFuncSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo);
|
||||
int32_t irateFuncSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo);
|
||||
int32_t irateFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t irateFunctionMerge(SqlFunctionCtx* pCtx);
|
||||
int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
@ -165,7 +165,7 @@ EFuncDataRequired lastDynDataReq(void* pRes, SDataBlockInfo* pBlockInfo);
|
|||
int32_t lastRowFunction(SqlFunctionCtx* pCtx);
|
||||
|
||||
bool getTopBotFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv);
|
||||
bool topBotFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t topBotFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t topFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t bottomFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
@ -174,7 +174,7 @@ int32_t bottomCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
|||
int32_t getTopBotInfoSize(int64_t numOfItems);
|
||||
|
||||
bool getSpreadFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool spreadFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t spreadFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t spreadFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t spreadFunctionMerge(SqlFunctionCtx* pCtx);
|
||||
int32_t spreadFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
@ -183,7 +183,7 @@ int32_t getSpreadInfoSize();
|
|||
int32_t spreadCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||
|
||||
bool getElapsedFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool elapsedFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t elapsedFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t elapsedFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t elapsedFunctionMerge(SqlFunctionCtx* pCtx);
|
||||
int32_t elapsedFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
@ -192,7 +192,7 @@ int32_t getElapsedInfoSize();
|
|||
int32_t elapsedCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||
|
||||
bool getHistogramFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t histogramFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t histogramFunctionPartial(SqlFunctionCtx* pCtx);
|
||||
int32_t histogramFunctionMerge(SqlFunctionCtx* pCtx);
|
||||
|
@ -210,7 +210,7 @@ int32_t getHLLInfoSize();
|
|||
int32_t hllCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||
|
||||
bool getStateFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool stateFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t stateFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t stateCountFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t stateDurationFunction(SqlFunctionCtx* pCtx);
|
||||
|
||||
|
@ -218,35 +218,35 @@ bool getCsumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
|||
int32_t csumFunction(SqlFunctionCtx* pCtx);
|
||||
|
||||
bool getMavgFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool mavgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t mavgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t mavgFunction(SqlFunctionCtx* pCtx);
|
||||
|
||||
bool getSampleFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool sampleFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t sampleFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t sampleFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
||||
bool getTailFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool tailFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t tailFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t tailFunction(SqlFunctionCtx* pCtx);
|
||||
|
||||
bool getUniqueFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool uniqueFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t uniqueFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t uniqueFunction(SqlFunctionCtx* pCtx);
|
||||
|
||||
bool getModeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t modeFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
||||
bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool twaFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t twaFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t twaFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t twaFinalize(struct SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
||||
bool getSelectivityFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
|
||||
bool blockDistSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t blockDistSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t blockDistFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ static FORCE_INLINE void initResultRowEntry(SResultRowEntryInfo *pResInfo, int32
|
|||
|
||||
pResInfo->complete = false;
|
||||
pResInfo->numOfRes = 0;
|
||||
memset(GET_ROWCELL_INTERBUF(pResInfo), 0, bufLen);
|
||||
(void)memset(GET_ROWCELL_INTERBUF(pResInfo), 0, bufLen);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -55,14 +55,15 @@ typedef struct SHistogramInfo {
|
|||
#endif
|
||||
} SHistogramInfo;
|
||||
|
||||
SHistogramInfo* tHistogramCreate(int32_t numOfBins);
|
||||
int32_t tHistogramCreate(int32_t numOfEntries, SHistogramInfo** pHisto);
|
||||
SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins);
|
||||
|
||||
int32_t tHistogramAdd(SHistogramInfo** pHisto, double val);
|
||||
int64_t tHistogramSum(SHistogramInfo* pHisto, double v);
|
||||
|
||||
double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num);
|
||||
SHistogramInfo* tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2, int32_t numOfEntries);
|
||||
int32_t tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num, double** pVal);
|
||||
int32_t tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2, int32_t numOfEntries,
|
||||
SHistogramInfo** pResHistogram);
|
||||
void tHistogramDestroy(SHistogramInfo** pHisto);
|
||||
|
||||
void tHistogramPrint(SHistogramInfo* pHisto);
|
||||
|
|
|
@ -67,7 +67,8 @@ typedef struct tMemBucket {
|
|||
SHashObj *groupPagesMap; // disk page map for different groups;
|
||||
} tMemBucket;
|
||||
|
||||
tMemBucket *tMemBucketCreate(int32_t nElemSize, int16_t dataType, double minval, double maxval, bool hasWindowOrGroup);
|
||||
int32_t tMemBucketCreate(int32_t nElemSize, int16_t dataType, double minval, double maxval, bool hasWindowOrGroup,
|
||||
tMemBucket **pBucket);
|
||||
|
||||
void tMemBucketDestroy(tMemBucket *pBucket);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
static int32_t buildFuncErrMsg(char* pErrBuf, int32_t len, int32_t errCode, const char* pFormat, ...) {
|
||||
va_list vArgList;
|
||||
va_start(vArgList, pFormat);
|
||||
vsnprintf(pErrBuf, len, pFormat, vArgList);
|
||||
(void)vsnprintf(pErrBuf, len, pFormat, vArgList);
|
||||
va_end(vArgList);
|
||||
return errCode;
|
||||
}
|
||||
|
@ -42,27 +42,24 @@ static int32_t invaildFuncParaValueErrMsg(char* pErrBuf, int32_t len, const char
|
|||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_VALUE, "Invalid parameter value : %s", pFuncName);
|
||||
}
|
||||
|
||||
#define TIME_UNIT_INVALID 1
|
||||
#define TIME_UNIT_TOO_SMALL 2
|
||||
|
||||
static int32_t validateTimeUnitParam(uint8_t dbPrec, const SValueNode* pVal) {
|
||||
if (!IS_DURATION_VAL(pVal->flag)) {
|
||||
return TIME_UNIT_INVALID;
|
||||
return TSDB_CODE_FUNC_TIME_UNIT_INVALID;
|
||||
}
|
||||
|
||||
if (TSDB_TIME_PRECISION_MILLI == dbPrec &&
|
||||
(0 == strcasecmp(pVal->literal, "1u") || 0 == strcasecmp(pVal->literal, "1b"))) {
|
||||
return TIME_UNIT_TOO_SMALL;
|
||||
return TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL;
|
||||
}
|
||||
|
||||
if (TSDB_TIME_PRECISION_MICRO == dbPrec && 0 == strcasecmp(pVal->literal, "1b")) {
|
||||
return TIME_UNIT_TOO_SMALL;
|
||||
return TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL;
|
||||
}
|
||||
|
||||
if (pVal->literal[0] != '1' ||
|
||||
(pVal->literal[1] != 'u' && pVal->literal[1] != 'a' && pVal->literal[1] != 's' && pVal->literal[1] != 'm' &&
|
||||
pVal->literal[1] != 'h' && pVal->literal[1] != 'd' && pVal->literal[1] != 'w' && pVal->literal[1] != 'b')) {
|
||||
return TIME_UNIT_INVALID;
|
||||
return TSDB_CODE_FUNC_TIME_UNIT_INVALID;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -138,13 +135,13 @@ static bool validateTimezoneFormat(const SValueNode* pVal) {
|
|||
}
|
||||
|
||||
if (i == 2) {
|
||||
memcpy(buf, &tz[i - 1], 2);
|
||||
(void)memcpy(buf, &tz[i - 1], 2);
|
||||
hour = taosStr2Int8(buf, NULL, 10);
|
||||
if (!validateHourRange(hour)) {
|
||||
return false;
|
||||
}
|
||||
} else if (i == 4) {
|
||||
memcpy(buf, &tz[i - 1], 2);
|
||||
(void)memcpy(buf, &tz[i - 1], 2);
|
||||
minute = taosStr2Int8(buf, NULL, 10);
|
||||
if (!validateMinuteRange(hour, minute, tz[0])) {
|
||||
return false;
|
||||
|
@ -167,13 +164,13 @@ static bool validateTimezoneFormat(const SValueNode* pVal) {
|
|||
}
|
||||
|
||||
if (i == 2) {
|
||||
memcpy(buf, &tz[i - 1], 2);
|
||||
(void)memcpy(buf, &tz[i - 1], 2);
|
||||
hour = taosStr2Int8(buf, NULL, 10);
|
||||
if (!validateHourRange(hour)) {
|
||||
return false;
|
||||
}
|
||||
} else if (i == 5) {
|
||||
memcpy(buf, &tz[i - 1], 2);
|
||||
(void)memcpy(buf, &tz[i - 1], 2);
|
||||
minute = taosStr2Int8(buf, NULL, 10);
|
||||
if (!validateMinuteRange(hour, minute, tz[0])) {
|
||||
return false;
|
||||
|
@ -215,7 +212,7 @@ static int32_t addTimezoneParam(SNodeList* pList) {
|
|||
time_t t = taosTime(NULL);
|
||||
struct tm tmInfo;
|
||||
if (taosLocalTime(&t, &tmInfo, buf) != NULL) {
|
||||
strftime(buf, sizeof(buf), "%z", &tmInfo);
|
||||
(void)strftime(buf, sizeof(buf), "%z", &tmInfo);
|
||||
}
|
||||
int32_t len = (int32_t)strlen(buf);
|
||||
|
||||
|
@ -225,15 +222,27 @@ static int32_t addTimezoneParam(SNodeList* pList) {
|
|||
}
|
||||
|
||||
pVal->literal = strndup(buf, len);
|
||||
if (pVal->literal == NULL) {
|
||||
nodesDestroyNode((SNode*)pVal);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pVal->translate = true;
|
||||
pVal->node.resType.type = TSDB_DATA_TYPE_BINARY;
|
||||
pVal->node.resType.bytes = len + VARSTR_HEADER_SIZE;
|
||||
pVal->node.resType.precision = TSDB_TIME_PRECISION_MILLI;
|
||||
pVal->datum.p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE + 1);
|
||||
if (pVal->datum.p == NULL) {
|
||||
nodesDestroyNode((SNode*)pVal);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
varDataSetLen(pVal->datum.p, len);
|
||||
strncpy(varDataVal(pVal->datum.p), pVal->literal, len);
|
||||
(void)strncpy(varDataVal(pVal->datum.p), pVal->literal, len);
|
||||
|
||||
nodesListAppend(pList, (SNode*)pVal);
|
||||
int32_t code = nodesListAppend(pList, (SNode*)pVal);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode((SNode*)pVal);
|
||||
return code;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -252,7 +261,11 @@ static int32_t addDbPrecisonParam(SNodeList** pList, uint8_t precision) {
|
|||
pVal->datum.i = (int64_t)precision;
|
||||
pVal->typeData = (int64_t)precision;
|
||||
|
||||
nodesListMakeAppend(pList, (SNode*)pVal);
|
||||
int32_t code = nodesListMakeAppend(pList, (SNode*)pVal);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode((SNode*)pVal);
|
||||
return code;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -936,13 +949,13 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
|
|||
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
|
||||
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1));
|
||||
if (ret == TIME_UNIT_TOO_SMALL) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
int32_t code = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1));
|
||||
if (code == TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL) {
|
||||
return buildFuncErrMsg(pErrBuf, len, code,
|
||||
"ELAPSED function time unit parameter should be greater than db precision");
|
||||
} else if (ret == TIME_UNIT_INVALID) {
|
||||
} else if (code == TSDB_CODE_FUNC_TIME_UNIT_INVALID) {
|
||||
return buildFuncErrMsg(
|
||||
pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
pErrBuf, len, code,
|
||||
"ELAPSED function time unit parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
||||
}
|
||||
}
|
||||
|
@ -1062,7 +1075,7 @@ static int8_t validateHistogramBinType(char* binTypeStr) {
|
|||
return binType;
|
||||
}
|
||||
|
||||
static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* errMsg, int32_t msgLen) {
|
||||
static int32_t validateHistogramBinDesc(char* binDescStr, int8_t binType, char* errMsg, int32_t msgLen) {
|
||||
const char* msg1 = "HISTOGRAM function requires four parameters";
|
||||
const char* msg3 = "HISTOGRAM function invalid format for binDesc parameter";
|
||||
const char* msg4 = "HISTOGRAM function binDesc parameter \"count\" should be in range [1, 1000]";
|
||||
|
@ -1070,6 +1083,7 @@ static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* err
|
|||
const char* msg6 = "HISTOGRAM function binDesc parameter \"width\" cannot be 0";
|
||||
const char* msg7 = "HISTOGRAM function binDesc parameter \"start\" cannot be 0 with \"log_bin\" type";
|
||||
const char* msg8 = "HISTOGRAM function binDesc parameter \"factor\" cannot be negative or equal to 0/1";
|
||||
const char* msg9 = "HISTOGRAM function out of memory";
|
||||
|
||||
cJSON* binDesc = cJSON_Parse(binDescStr);
|
||||
int32_t numOfBins;
|
||||
|
@ -1078,9 +1092,9 @@ static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* err
|
|||
int32_t numOfParams = cJSON_GetArraySize(binDesc);
|
||||
int32_t startIndex;
|
||||
if (numOfParams != 4) {
|
||||
snprintf(errMsg, msgLen, "%s", msg1);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg1);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
cJSON* start = cJSON_GetObjectItem(binDesc, "start");
|
||||
|
@ -1090,22 +1104,22 @@ static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* err
|
|||
cJSON* infinity = cJSON_GetObjectItem(binDesc, "infinity");
|
||||
|
||||
if (!cJSON_IsNumber(start) || !cJSON_IsNumber(count) || !cJSON_IsBool(infinity)) {
|
||||
snprintf(errMsg, msgLen, "%s", msg3);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg3);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
if (count->valueint <= 0 || count->valueint > 1000) { // limit count to 1000
|
||||
snprintf(errMsg, msgLen, "%s", msg4);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg4);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
if (isinf(start->valuedouble) || (width != NULL && isinf(width->valuedouble)) ||
|
||||
(factor != NULL && isinf(factor->valuedouble)) || (count != NULL && isinf(count->valuedouble))) {
|
||||
snprintf(errMsg, msgLen, "%s", msg5);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg5);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
int32_t counter = (int32_t)count->valueint;
|
||||
|
@ -1118,53 +1132,58 @@ static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* err
|
|||
}
|
||||
|
||||
intervals = taosMemoryCalloc(numOfBins, sizeof(double));
|
||||
if (intervals == NULL) {
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg9);
|
||||
cJSON_Delete(binDesc);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (cJSON_IsNumber(width) && factor == NULL && binType == LINEAR_BIN) {
|
||||
// linear bin process
|
||||
if (width->valuedouble == 0) {
|
||||
snprintf(errMsg, msgLen, "%s", msg6);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg6);
|
||||
taosMemoryFree(intervals);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
for (int i = 0; i < counter + 1; ++i) {
|
||||
intervals[startIndex] = start->valuedouble + i * width->valuedouble;
|
||||
if (isinf(intervals[startIndex])) {
|
||||
snprintf(errMsg, msgLen, "%s", msg5);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg5);
|
||||
taosMemoryFree(intervals);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
startIndex++;
|
||||
}
|
||||
} else if (cJSON_IsNumber(factor) && width == NULL && binType == LOG_BIN) {
|
||||
// log bin process
|
||||
if (start->valuedouble == 0) {
|
||||
snprintf(errMsg, msgLen, "%s", msg7);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg7);
|
||||
taosMemoryFree(intervals);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (factor->valuedouble < 0 || factor->valuedouble == 0 || factor->valuedouble == 1) {
|
||||
snprintf(errMsg, msgLen, "%s", msg8);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg8);
|
||||
taosMemoryFree(intervals);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
for (int i = 0; i < counter + 1; ++i) {
|
||||
intervals[startIndex] = start->valuedouble * pow(factor->valuedouble, i * 1.0);
|
||||
if (isinf(intervals[startIndex])) {
|
||||
snprintf(errMsg, msgLen, "%s", msg5);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg5);
|
||||
taosMemoryFree(intervals);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
startIndex++;
|
||||
}
|
||||
} else {
|
||||
snprintf(errMsg, msgLen, "%s", msg3);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg3);
|
||||
taosMemoryFree(intervals);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
if (infinity->valueint == true) {
|
||||
|
@ -1172,7 +1191,7 @@ static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* err
|
|||
intervals[numOfBins - 1] = INFINITY;
|
||||
// in case of desc bin orders, -inf/inf should be swapped
|
||||
if (numOfBins < 4) {
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
if (intervals[1] > intervals[numOfBins - 2]) {
|
||||
|
@ -1181,46 +1200,51 @@ static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* err
|
|||
}
|
||||
} else if (cJSON_IsArray(binDesc)) { /* user input bins */
|
||||
if (binType != USER_INPUT_BIN) {
|
||||
snprintf(errMsg, msgLen, "%s", msg3);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg3);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
numOfBins = cJSON_GetArraySize(binDesc);
|
||||
intervals = taosMemoryCalloc(numOfBins, sizeof(double));
|
||||
if (intervals == NULL) {
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg9);
|
||||
cJSON_Delete(binDesc);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
cJSON* bin = binDesc->child;
|
||||
if (bin == NULL) {
|
||||
snprintf(errMsg, msgLen, "%s", msg3);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg3);
|
||||
taosMemoryFree(intervals);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
int i = 0;
|
||||
while (bin) {
|
||||
intervals[i] = bin->valuedouble;
|
||||
if (!cJSON_IsNumber(bin)) {
|
||||
snprintf(errMsg, msgLen, "%s", msg3);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg3);
|
||||
taosMemoryFree(intervals);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (i != 0 && intervals[i] <= intervals[i - 1]) {
|
||||
snprintf(errMsg, msgLen, "%s", msg3);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg3);
|
||||
taosMemoryFree(intervals);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
bin = bin->next;
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
snprintf(errMsg, msgLen, "%s", msg3);
|
||||
(void)snprintf(errMsg, msgLen, "%s", msg3);
|
||||
cJSON_Delete(binDesc);
|
||||
return false;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
cJSON_Delete(binDesc);
|
||||
taosMemoryFree(intervals);
|
||||
return true;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateHistogram(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
|
@ -1265,7 +1289,7 @@ static int32_t translateHistogram(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
|||
if (i == 2) {
|
||||
char errMsg[128] = {0};
|
||||
binDesc = varDataVal(pValue->datum.p);
|
||||
if (!validateHistogramBinDesc(binDesc, binType, errMsg, (int32_t)sizeof(errMsg))) {
|
||||
if (TSDB_CODE_SUCCESS != validateHistogramBinDesc(binDesc, binType, errMsg, (int32_t)sizeof(errMsg))) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, errMsg);
|
||||
}
|
||||
}
|
||||
|
@ -1323,7 +1347,7 @@ static int32_t translateHistogramImpl(SFunctionNode* pFunc, char* pErrBuf, int32
|
|||
if (i == 2) {
|
||||
char errMsg[128] = {0};
|
||||
binDesc = varDataVal(pValue->datum.p);
|
||||
if (!validateHistogramBinDesc(binDesc, binType, errMsg, (int32_t)sizeof(errMsg))) {
|
||||
if (TSDB_CODE_SUCCESS != validateHistogramBinDesc(binDesc, binType, errMsg, (int32_t)sizeof(errMsg))) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, errMsg);
|
||||
}
|
||||
}
|
||||
|
@ -1507,12 +1531,12 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
|
|||
if (numOfParams == 4) {
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
|
||||
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 3));
|
||||
if (ret == TIME_UNIT_TOO_SMALL) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
int32_t code = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 3));
|
||||
if (code == TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL) {
|
||||
return buildFuncErrMsg(pErrBuf, len, code,
|
||||
"STATEDURATION function time unit parameter should be greater than db precision");
|
||||
} else if (ret == TIME_UNIT_INVALID) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
} else if (code == TSDB_CODE_FUNC_TIME_UNIT_INVALID) {
|
||||
return buildFuncErrMsg(pErrBuf, len, code,
|
||||
"STATEDURATION function time unit parameter should be one of the following: [1b, 1u, 1a, "
|
||||
"1s, 1m, 1h, 1d, 1w]");
|
||||
}
|
||||
|
@ -2268,13 +2292,13 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
|
|||
}
|
||||
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1));
|
||||
if (ret == TIME_UNIT_TOO_SMALL) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
int32_t code = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1));
|
||||
if (code == TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL) {
|
||||
return buildFuncErrMsg(pErrBuf, len, code,
|
||||
"TIMETRUNCATE function time unit parameter should be greater than db precision");
|
||||
} else if (ret == TIME_UNIT_INVALID) {
|
||||
} else if (code == TSDB_CODE_FUNC_TIME_UNIT_INVALID) {
|
||||
return buildFuncErrMsg(
|
||||
pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
pErrBuf, len, code,
|
||||
"TIMETRUNCATE function time unit parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
||||
}
|
||||
|
||||
|
@ -2291,7 +2315,7 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
|
|||
|
||||
// add database precision as param
|
||||
|
||||
int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec);
|
||||
code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -2330,13 +2354,13 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
|||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
|
||||
if (3 == numOfParams) {
|
||||
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 2));
|
||||
if (ret == TIME_UNIT_TOO_SMALL) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
int32_t code = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 2));
|
||||
if (code == TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL) {
|
||||
return buildFuncErrMsg(pErrBuf, len, code,
|
||||
"TIMEDIFF function time unit parameter should be greater than db precision");
|
||||
} else if (ret == TIME_UNIT_INVALID) {
|
||||
} else if (code == TSDB_CODE_FUNC_TIME_UNIT_INVALID) {
|
||||
return buildFuncErrMsg(
|
||||
pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
pErrBuf, len, code,
|
||||
"TIMEDIFF function time unit parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -354,14 +354,17 @@ bool getAvgFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool avgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) {
|
||||
if (!functionSetup(pCtx, pResultInfo)) {
|
||||
return false;
|
||||
int32_t avgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) {
|
||||
if (pResultInfo->initialized) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != functionSetup(pCtx, pResultInfo)) {
|
||||
return TSDB_CODE_FUNC_SETUP_ERROR;
|
||||
}
|
||||
|
||||
SAvgRes* pRes = GET_ROWCELL_INTERBUF(pResultInfo);
|
||||
memset(pRes, 0, sizeof(SAvgRes));
|
||||
return true;
|
||||
(void)memset(pRes, 0, sizeof(SAvgRes));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t calculateAvgBySMAInfo(SAvgRes* pRes, int32_t numOfRows, int32_t type, const SColumnDataAgg* pAgg) {
|
||||
|
@ -849,15 +852,23 @@ int32_t avgPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
SAvgRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
int32_t resultBytes = getAvgInfoSize();
|
||||
char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char));
|
||||
|
||||
memcpy(varDataVal(res), pInfo, resultBytes);
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (NULL == res) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
(void)memcpy(varDataVal(res), pInfo, resultBytes);
|
||||
varDataSetLen(res, resultBytes);
|
||||
|
||||
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
||||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||
|
||||
colDataSetVal(pCol, pBlock->info.rows, res, false);
|
||||
|
||||
taosMemoryFree(res);
|
||||
return pResInfo->numOfRes;
|
||||
if(NULL == pCol) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
code = colDataSetVal(pCol, pBlock->info.rows, res, false);
|
||||
|
||||
_exit:
|
||||
taosMemoryFree(res);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "tglobal.h"
|
||||
|
||||
#define __COMPARE_ACQUIRED_MAX(i, end, bm, _data, ctx, val, pos) \
|
||||
int32_t code = TSDB_CODE_SUCCESS; \
|
||||
for (; i < (end); ++i) { \
|
||||
if (colDataIsNull_f(bm, i)) { \
|
||||
continue; \
|
||||
|
@ -28,12 +29,16 @@
|
|||
if ((val) < (_data)[i]) { \
|
||||
(val) = (_data)[i]; \
|
||||
if ((ctx)->subsidiaries.num > 0) { \
|
||||
updateTupleData((ctx), i, (ctx)->pSrcBlock, pos); \
|
||||
code = updateTupleData((ctx), i, (ctx)->pSrcBlock, pos); \
|
||||
if (TSDB_CODE_SUCCESS != code) { \
|
||||
return code; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define __COMPARE_ACQUIRED_MIN(i, end, bm, _data, ctx, val, pos) \
|
||||
int32_t code = TSDB_CODE_SUCCESS; \
|
||||
for (; i < (end); ++i) { \
|
||||
if (colDataIsNull_f(bm, i)) { \
|
||||
continue; \
|
||||
|
@ -42,7 +47,10 @@
|
|||
if ((val) > (_data)[i]) { \
|
||||
(val) = (_data)[i]; \
|
||||
if ((ctx)->subsidiaries.num > 0) { \
|
||||
updateTupleData((ctx), i, (ctx)->pSrcBlock, pos); \
|
||||
code = updateTupleData((ctx), i, (ctx)->pSrcBlock, pos); \
|
||||
if (TSDB_CODE_SUCCESS != code) { \
|
||||
return code; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
@ -571,7 +579,7 @@ static int32_t findRowIndex(int32_t start, int32_t num, SColumnInfoData* pCol, c
|
|||
return -1;
|
||||
}
|
||||
|
||||
static void doExtractVal(SColumnInfoData* pCol, int32_t i, int32_t end, SqlFunctionCtx* pCtx, SMinmaxResInfo* pBuf,
|
||||
static int32_t doExtractVal(SColumnInfoData* pCol, int32_t i, int32_t end, SqlFunctionCtx* pCtx, SMinmaxResInfo* pBuf,
|
||||
bool isMinFunc) {
|
||||
if (isMinFunc) {
|
||||
switch (pCol->info.type) {
|
||||
|
@ -700,6 +708,7 @@ static void doExtractVal(SColumnInfoData* pCol, int32_t i, int32_t end, SqlFunct
|
|||
}
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t saveRelatedTupleTag(SqlFunctionCtx* pCtx, SInputColumnInfoData* pInput, void* tval) {
|
||||
|
@ -840,7 +849,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
memcpy(&pBuf->v, p, pCol->info.bytes);
|
||||
(void)memcpy(&pBuf->v, p, pCol->info.bytes);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -858,7 +867,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
|
|||
goto _over;
|
||||
}
|
||||
|
||||
doExtractVal(pCol, i, end, pCtx, pBuf, isMinFunc);
|
||||
code = doExtractVal(pCol, i, end, pCtx, pBuf, isMinFunc);
|
||||
} else {
|
||||
numOfElems = numOfRows;
|
||||
|
||||
|
|
|
@ -35,14 +35,14 @@ static void doInitFunctionTable() {
|
|||
gFunMgtService.pFuncNameHashTable =
|
||||
taosHashInit(funcMgtBuiltinsNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
if (NULL == gFunMgtService.pFuncNameHashTable) {
|
||||
initFunctionCode = TSDB_CODE_FAILED;
|
||||
initFunctionCode = terrno;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < funcMgtBuiltinsNum; ++i) {
|
||||
if (TSDB_CODE_SUCCESS != taosHashPut(gFunMgtService.pFuncNameHashTable, funcMgtBuiltins[i].name,
|
||||
strlen(funcMgtBuiltins[i].name), &i, sizeof(int32_t))) {
|
||||
initFunctionCode = TSDB_CODE_FAILED;
|
||||
initFunctionCode = terrno;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ static bool isSpecificClassifyFunc(int32_t funcId, uint64_t classification) {
|
|||
}
|
||||
|
||||
int32_t fmFuncMgtInit() {
|
||||
taosThreadOnce(&functionHashTableInit, doInitFunctionTable);
|
||||
(void)taosThreadOnce(&functionHashTableInit, doInitFunctionTable);
|
||||
return initFunctionCode;
|
||||
}
|
||||
|
||||
|
@ -115,20 +115,24 @@ EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWin
|
|||
return funcMgtBuiltins[pFunc->funcId].dataRequiredFunc(pFunc, pTimeWindow);
|
||||
}
|
||||
|
||||
EFuncDataRequired fmFuncDynDataRequired(int32_t funcId, void* pRes, SDataBlockInfo* pBlockInfo) {
|
||||
int32_t fmFuncDynDataRequired(int32_t funcId, void* pRes, SDataBlockInfo* pBlockInfo, int32_t *reqStatus) {
|
||||
if (fmIsUserDefinedFunc(funcId) || funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
||||
*reqStatus = -1;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
const char* name = funcMgtBuiltins[funcId].name;
|
||||
if ((strcmp(name, "_group_key") == 0) || (strcmp(name, "_select_value") == 0)) {
|
||||
return FUNC_DATA_REQUIRED_NOT_LOAD;
|
||||
*reqStatus = FUNC_DATA_REQUIRED_NOT_LOAD;
|
||||
return TSDB_CODE_SUCCESS;;
|
||||
}
|
||||
|
||||
if (funcMgtBuiltins[funcId].dynDataRequiredFunc == NULL) {
|
||||
return FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||
*reqStatus = FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else {
|
||||
return funcMgtBuiltins[funcId].dynDataRequiredFunc(pRes, pBlockInfo);
|
||||
*reqStatus = funcMgtBuiltins[funcId].dynDataRequiredFunc(pRes, pBlockInfo);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -378,29 +382,30 @@ static int32_t getFuncInfo(SFunctionNode* pFunc) {
|
|||
return fmGetFuncInfo(pFunc, msg, sizeof(msg));
|
||||
}
|
||||
|
||||
SFunctionNode* createFunction(const char* pName, SNodeList* pParameterList) {
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pFunc) {
|
||||
return NULL;
|
||||
int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNode** pFunc) {
|
||||
*pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == *pFunc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
snprintf(pFunc->functionName, sizeof(pFunc->functionName), "%s", pName);
|
||||
pFunc->pParameterList = pParameterList;
|
||||
if (TSDB_CODE_SUCCESS != getFuncInfo(pFunc)) {
|
||||
pFunc->pParameterList = NULL;
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
return NULL;
|
||||
(void)snprintf((*pFunc)->functionName, sizeof((*pFunc)->functionName), "%s", pName);
|
||||
(*pFunc)->pParameterList = pParameterList;
|
||||
int32_t code = getFuncInfo((*pFunc));
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
(*pFunc)->pParameterList = NULL;
|
||||
nodesDestroyNode((SNode*)*pFunc);
|
||||
return code;
|
||||
}
|
||||
return pFunc;
|
||||
return code;
|
||||
}
|
||||
|
||||
static SNode* createColumnByFunc(const SFunctionNode* pFunc) {
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return NULL;
|
||||
static int32_t createColumnByFunc(const SFunctionNode* pFunc, SColumnNode** pCol) {
|
||||
*pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == *pCol) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(pCol->colName, pFunc->node.aliasName);
|
||||
pCol->node.resType = pFunc->node.resType;
|
||||
return (SNode*)pCol;
|
||||
(void)strcpy((*pCol)->colName, pFunc->node.aliasName);
|
||||
(*pCol)->node.resType = pFunc->node.resType;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
bool fmIsDistExecFunc(int32_t funcId) {
|
||||
|
@ -418,17 +423,17 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod
|
|||
if (NULL == pParameterList) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
*pPartialFunc = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pPartialFunc, pParameterList);
|
||||
if (NULL == *pPartialFunc) {
|
||||
int32_t code = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pPartialFunc, pParameterList,pPartialFunc );
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(pParameterList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
(*pPartialFunc)->hasOriginalFunc = true;
|
||||
(*pPartialFunc)->originalFuncId = pSrcFunc->hasOriginalFunc ? pSrcFunc->originalFuncId : pSrcFunc->funcId;
|
||||
char name[TSDB_FUNC_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_POINTER_PRINT_BYTES + 1] = {0};
|
||||
int32_t len = snprintf(name, sizeof(name) - 1, "%s.%p", (*pPartialFunc)->functionName, pSrcFunc);
|
||||
taosCreateMD5Hash(name, len);
|
||||
strncpy((*pPartialFunc)->node.aliasName, name, TSDB_COL_NAME_LEN - 1);
|
||||
(void)taosCreateMD5Hash(name, len);
|
||||
(void)strncpy((*pPartialFunc)->node.aliasName, name, TSDB_COL_NAME_LEN - 1);
|
||||
(*pPartialFunc)->hasPk = pSrcFunc->hasPk;
|
||||
(*pPartialFunc)->pkBytes = pSrcFunc->pkBytes;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -436,7 +441,11 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod
|
|||
|
||||
static int32_t createMergeFuncPara(const SFunctionNode* pSrcFunc, const SFunctionNode* pPartialFunc,
|
||||
SNodeList** pParameterList) {
|
||||
SNode* pRes = createColumnByFunc(pPartialFunc);
|
||||
SNode *pRes = NULL;
|
||||
int32_t code = createColumnByFunc(pPartialFunc, (SColumnNode**)&pRes);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
if (NULL != funcMgtBuiltins[pSrcFunc->funcId].createMergeParaFuc) {
|
||||
return funcMgtBuiltins[pSrcFunc->funcId].createMergeParaFuc(pSrcFunc->pParameterList, pRes, pParameterList);
|
||||
} else {
|
||||
|
@ -452,16 +461,13 @@ static int32_t createMidFunction(const SFunctionNode* pSrcFunc, const SFunctionN
|
|||
int32_t code = createMergeFuncPara(pSrcFunc, pPartialFunc, &pParameterList);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if(funcMgtBuiltins[pSrcFunc->funcId].pMiddleFunc != NULL){
|
||||
pFunc = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMiddleFunc, pParameterList);
|
||||
code = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMiddleFunc, pParameterList, &pFunc);
|
||||
}else{
|
||||
pFunc = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pParameterList);
|
||||
}
|
||||
if (NULL == pFunc) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pParameterList, &pFunc);
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
strcpy(pFunc->node.aliasName, pPartialFunc->node.aliasName);
|
||||
(void)strcpy(pFunc->node.aliasName, pPartialFunc->node.aliasName);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -481,10 +487,7 @@ static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctio
|
|||
|
||||
int32_t code = createMergeFuncPara(pSrcFunc, pPartialFunc, &pParameterList);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pFunc = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pParameterList);
|
||||
if (NULL == pFunc) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
code = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pParameterList, &pFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pFunc->hasOriginalFunc = true;
|
||||
|
@ -493,7 +496,7 @@ static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctio
|
|||
if (fmIsSameInOutType(pSrcFunc->funcId)) {
|
||||
pFunc->node.resType = pSrcFunc->node.resType;
|
||||
}
|
||||
strcpy(pFunc->node.aliasName, pSrcFunc->node.aliasName);
|
||||
(void)strcpy(pFunc->node.aliasName, pSrcFunc->node.aliasName);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -541,13 +544,13 @@ static int32_t fmCreateStateFunc(const SFunctionNode* pFunc, SFunctionNode** pSt
|
|||
if (funcMgtBuiltins[pFunc->funcId].pStateFunc) {
|
||||
SNodeList* pParams = nodesCloneList(pFunc->pParameterList);
|
||||
if (!pParams) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
*pStateFunc = createFunction(funcMgtBuiltins[pFunc->funcId].pStateFunc, pParams);
|
||||
if (!*pStateFunc) {
|
||||
int32_t code = createFunction(funcMgtBuiltins[pFunc->funcId].pStateFunc, pParams, pStateFunc);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(pParams);
|
||||
return TSDB_CODE_FUNC_FUNTION_ERROR;
|
||||
}
|
||||
strcpy((*pStateFunc)->node.aliasName, pFunc->node.aliasName);
|
||||
strcpy((*pStateFunc)->node.userAlias, pFunc->node.userAlias);
|
||||
(void)strcpy((*pStateFunc)->node.aliasName, pFunc->node.aliasName);
|
||||
(void)strcpy((*pStateFunc)->node.userAlias, pFunc->node.userAlias);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -587,13 +590,13 @@ static int32_t fmCreateStateMergeFunc(SFunctionNode* pFunc, SFunctionNode** pSta
|
|||
if (funcMgtBuiltins[pFunc->funcId].pMergeFunc) {
|
||||
SNodeList* pParams = nodesCloneList(pFunc->pParameterList);
|
||||
if (!pParams) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
*pStateMergeFunc = createFunction(funcMgtBuiltins[pFunc->funcId].pMergeFunc, pParams);
|
||||
if (!*pStateMergeFunc) {
|
||||
int32_t code = createFunction(funcMgtBuiltins[pFunc->funcId].pMergeFunc, pParams, pStateMergeFunc);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(pParams);
|
||||
return TSDB_CODE_FUNC_FUNTION_ERROR;
|
||||
return code;
|
||||
}
|
||||
strcpy((*pStateMergeFunc)->node.aliasName, pFunc->node.aliasName);
|
||||
strcpy((*pStateMergeFunc)->node.userAlias, pFunc->node.userAlias);
|
||||
(void)strcpy((*pStateMergeFunc)->node.aliasName, pFunc->node.aliasName);
|
||||
(void)strcpy((*pStateMergeFunc)->node.userAlias, pFunc->node.userAlias);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -646,6 +649,9 @@ bool fmIsMyStateFunc(int32_t funcId, int32_t stateFuncId) {
|
|||
}
|
||||
if (strcmp(pFunc->pStateFunc, pStateFunc->name) == 0) return true;
|
||||
int32_t stateMergeFuncId = fmGetFuncId(pFunc->pStateFunc);
|
||||
if (stateMergeFuncId == -1) {
|
||||
return false;
|
||||
}
|
||||
const SBuiltinFuncDefinition* pStateMergeFunc = &funcMgtBuiltins[stateMergeFuncId];
|
||||
return strcmp(pStateFunc->name, pStateMergeFunc->pMergeFunc) == 0;
|
||||
}
|
||||
|
|
|
@ -32,9 +32,12 @@
|
|||
*/
|
||||
static int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val);
|
||||
|
||||
SHistogramInfo* tHistogramCreate(int32_t numOfEntries) {
|
||||
int32_t tHistogramCreate(int32_t numOfEntries, SHistogramInfo** pHisto) {
|
||||
/* need one redundant slot */
|
||||
SHistogramInfo* pHisto = taosMemoryMalloc(sizeof(SHistogramInfo) + sizeof(SHistBin) * (numOfEntries + 1));
|
||||
*pHisto = taosMemoryMalloc(sizeof(SHistogramInfo) + sizeof(SHistBin) * (numOfEntries + 1));
|
||||
if (NULL == *pHisto) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
#if !defined(USE_ARRAYLIST)
|
||||
pHisto->pList = SSkipListCreate(MAX_SKIP_LIST_LEVEL, TSDB_DATA_TYPE_DOUBLE, sizeof(double));
|
||||
|
@ -46,11 +49,12 @@ SHistogramInfo* tHistogramCreate(int32_t numOfEntries) {
|
|||
pss->pTree = pHisto->pLoserTree;
|
||||
#endif
|
||||
|
||||
return tHistogramCreateFrom(pHisto, numOfEntries);
|
||||
*pHisto = tHistogramCreateFrom(*pHisto, numOfEntries);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins) {
|
||||
memset(pBuf, 0, sizeof(SHistogramInfo) + sizeof(SHistBin) * (numOfBins + 1));
|
||||
(void)memset(pBuf, 0, sizeof(SHistogramInfo) + sizeof(SHistBin) * (numOfBins + 1));
|
||||
|
||||
SHistogramInfo* pHisto = (SHistogramInfo*)pBuf;
|
||||
pHisto->elems = (SHistBin*)((char*)pBuf + sizeof(SHistogramInfo));
|
||||
|
@ -67,15 +71,19 @@ SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins) {
|
|||
}
|
||||
|
||||
int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (*pHisto == NULL) {
|
||||
*pHisto = tHistogramCreate(MAX_HISTOGRAM_BIN);
|
||||
code = tHistogramCreate(MAX_HISTOGRAM_BIN, pHisto);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(USE_ARRAYLIST)
|
||||
int32_t idx = histoBinarySearch((*pHisto)->elems, (*pHisto)->numOfEntries, val);
|
||||
if (ASSERTS(idx >= 0 && idx <= (*pHisto)->maxEntries && (*pHisto)->elems != NULL, "tHistogramAdd Error, idx:%d, maxEntries:%d, elems:%p",
|
||||
idx, (*pHisto)->maxEntries, (*pHisto)->elems)) {
|
||||
return -1;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
if ((*pHisto)->elems[idx].val == val && idx >= 0) {
|
||||
|
@ -89,23 +97,23 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
|
|||
if (idx > 0) {
|
||||
if (ASSERTS((*pHisto)->elems[idx - 1].val <= val, "tHistogramAdd Error, elems[%d].val:%lf, val:%lf",
|
||||
idx - 1, (*pHisto)->elems[idx - 1].val, val)) {
|
||||
return -1;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
if (ASSERTS((*pHisto)->elems[idx].val > val, "tHistogramAdd Error, elems[%d].val:%lf, val:%lf",
|
||||
idx, (*pHisto)->elems[idx].val, val)) {
|
||||
return -1;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
} else if ((*pHisto)->numOfElems > 0) {
|
||||
if (ASSERTS((*pHisto)->elems[(*pHisto)->numOfEntries].val <= val, "tHistogramAdd Error, elems[%d].val:%lf, val:%lf",
|
||||
(*pHisto)->numOfEntries, (*pHisto)->elems[idx].val, val)) {
|
||||
return -1;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t code = histogramCreateBin(*pHisto, idx, val);
|
||||
if (code != 0) {
|
||||
code = histogramCreateBin(*pHisto, idx, val);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +294,7 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
|
|||
}
|
||||
|
||||
(*pHisto)->numOfElems += 1;
|
||||
return 0;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t histoBinarySearch(SHistBin* pEntry, int32_t len, double val) {
|
||||
|
@ -335,7 +343,7 @@ static void histogramMergeImpl(SHistBin* pHistBin, int32_t* size) {
|
|||
s1->val = newVal;
|
||||
s1->num = s1->num + s2->num;
|
||||
|
||||
memmove(&pHistBin[index + 1], &pHistBin[index + 2], (oldSize - index - 2) * sizeof(SHistBin));
|
||||
(void)memmove(&pHistBin[index + 1], &pHistBin[index + 2], (oldSize - index - 2) * sizeof(SHistBin));
|
||||
(*size) -= 1;
|
||||
#endif
|
||||
}
|
||||
|
@ -345,12 +353,12 @@ int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val) {
|
|||
#if defined(USE_ARRAYLIST)
|
||||
int32_t remain = pHisto->numOfEntries - index;
|
||||
if (remain > 0) {
|
||||
memmove(&pHisto->elems[index + 1], &pHisto->elems[index], sizeof(SHistBin) * remain);
|
||||
(void)memmove(&pHisto->elems[index + 1], &pHisto->elems[index], sizeof(SHistBin) * remain);
|
||||
}
|
||||
|
||||
if (ASSERTS(index >= 0 && index <= pHisto->maxEntries, "histogramCreateBin Error, index:%d, maxEntries:%d",
|
||||
index, pHisto->maxEntries)) {
|
||||
return -1;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
pHisto->elems[index].num = 1;
|
||||
|
@ -367,10 +375,10 @@ int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val) {
|
|||
#endif
|
||||
if (ASSERTS(pHisto->numOfEntries <= pHisto->maxEntries, "histogramCreateBin Error, numOfEntries:%d, maxEntries:%d",
|
||||
pHisto->numOfEntries, pHisto->maxEntries)) {
|
||||
return -1;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void tHistogramDestroy(SHistogramInfo** pHisto) {
|
||||
|
@ -383,17 +391,17 @@ void tHistogramDestroy(SHistogramInfo** pHisto) {
|
|||
}
|
||||
|
||||
void tHistogramPrint(SHistogramInfo* pHisto) {
|
||||
printf("total entries: %d, elements: %" PRId64 "\n", pHisto->numOfEntries, pHisto->numOfElems);
|
||||
(void)printf("total entries: %d, elements: %" PRId64 "\n", pHisto->numOfEntries, pHisto->numOfElems);
|
||||
#if defined(USE_ARRAYLIST)
|
||||
for (int32_t i = 0; i < pHisto->numOfEntries; ++i) {
|
||||
printf("%d: (%f, %" PRId64 ")\n", i + 1, pHisto->elems[i].val, pHisto->elems[i].num);
|
||||
(void)printf("%d: (%f, %" PRId64 ")\n", i + 1, pHisto->elems[i].val, pHisto->elems[i].num);
|
||||
}
|
||||
#else
|
||||
tSkipListNode* pNode = pHisto->pList->pHead.pForward[0];
|
||||
|
||||
for (int32_t i = 0; i < pHisto->numOfEntries; ++i) {
|
||||
SHistBin* pEntry = (SHistBin*)pNode->pData;
|
||||
printf("%d: (%f, %" PRId64 ")\n", i + 1, pEntry->val, pEntry->num);
|
||||
(void)printf("%d: (%f, %" PRId64 ")\n", i + 1, pEntry->val, pEntry->num);
|
||||
pNode = pNode->pForward[0];
|
||||
}
|
||||
#endif
|
||||
|
@ -443,21 +451,24 @@ int64_t tHistogramSum(SHistogramInfo* pHisto, double v) {
|
|||
#endif
|
||||
}
|
||||
|
||||
double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num) {
|
||||
int32_t tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num, double** pVal) {
|
||||
#if defined(USE_ARRAYLIST)
|
||||
double* pVal = taosMemoryMalloc(num * sizeof(double));
|
||||
*pVal = taosMemoryMalloc(num * sizeof(double));
|
||||
if (NULL == *pVal) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
double numOfElem = (ratio[i] / 100) * pHisto->numOfElems;
|
||||
|
||||
if (numOfElem == 0) {
|
||||
pVal[i] = pHisto->min;
|
||||
(*pVal)[i] = pHisto->min;
|
||||
continue;
|
||||
} else if (numOfElem <= pHisto->elems[0].num) {
|
||||
pVal[i] = pHisto->elems[0].val;
|
||||
(*pVal)[i] = pHisto->elems[0].val;
|
||||
continue;
|
||||
} else if (numOfElem == pHisto->numOfElems) {
|
||||
pVal[i] = pHisto->max;
|
||||
(*pVal)[i] = pHisto->max;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -479,37 +490,39 @@ double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num) {
|
|||
|
||||
double delta = numOfElem - total;
|
||||
if (fabs(delta) < FLT_EPSILON) {
|
||||
pVal[i] = pHisto->elems[j].val;
|
||||
(*pVal)[i] = pHisto->elems[j].val;
|
||||
}
|
||||
|
||||
double start = (double)pHisto->elems[j].num;
|
||||
double range = pHisto->elems[j + 1].num - start;
|
||||
|
||||
if (range == 0) {
|
||||
pVal[i] = (pHisto->elems[j + 1].val - pHisto->elems[j].val) * delta / start + pHisto->elems[j].val;
|
||||
(*pVal)[i] = (pHisto->elems[j + 1].val - pHisto->elems[j].val) * delta / start + pHisto->elems[j].val;
|
||||
} else {
|
||||
double factor = (-2 * start + sqrt(4 * start * start - 4 * range * (-2 * delta))) / (2 * range);
|
||||
pVal[i] = pHisto->elems[j].val + (pHisto->elems[j + 1].val - pHisto->elems[j].val) * factor;
|
||||
(*pVal)[i] = pHisto->elems[j].val + (pHisto->elems[j + 1].val - pHisto->elems[j].val) * factor;
|
||||
}
|
||||
}
|
||||
#else
|
||||
double* pVal = taosMemoryMalloc(num * sizeof(double));
|
||||
|
||||
if (NULL == *pVal) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
double numOfElem = ratio[i] * pHisto->numOfElems;
|
||||
|
||||
tSkipListNode* pFirst = pHisto->pList->pHead.pForward[0];
|
||||
SHistBin* pEntry = (SHistBin*)pFirst->pData;
|
||||
if (numOfElem == 0) {
|
||||
pVal[i] = pHisto->min;
|
||||
(*pVal)[i] = pHisto->min;
|
||||
printf("i/numofSlot: %f, v:%f, %f\n", ratio[i], numOfElem, pVal[i]);
|
||||
continue;
|
||||
} else if (numOfElem <= pEntry->num) {
|
||||
pVal[i] = pEntry->val;
|
||||
(*pVal)[i] = pEntry->val;
|
||||
printf("i/numofSlot: %f, v:%f, %f\n", ratio[i], numOfElem, pVal[i]);
|
||||
continue;
|
||||
} else if (numOfElem == pHisto->numOfElems) {
|
||||
pVal[i] = pHisto->max;
|
||||
(*pVal)[i] = pHisto->max;
|
||||
printf("i/numofSlot: %f, v:%f, %f\n", ratio[i], numOfElem, pVal[i]);
|
||||
continue;
|
||||
}
|
||||
|
@ -540,34 +553,40 @@ double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num) {
|
|||
if (fabs(delta) < FLT_EPSILON) {
|
||||
// printf("i/numofSlot: %f, v:%f, %f\n",
|
||||
// (double)i/numOfSlots, numOfElem, pHisto->elems[j].val);
|
||||
pVal[i] = pPrev->val;
|
||||
(*pVal)[i] = pPrev->val;
|
||||
}
|
||||
|
||||
double start = pPrev->num;
|
||||
double range = pEntry->num - start;
|
||||
|
||||
if (range == 0) {
|
||||
pVal[i] = (pEntry->val - pPrev->val) * delta / start + pPrev->val;
|
||||
(*pVal)[i] = (pEntry->val - pPrev->val) * delta / start + pPrev->val;
|
||||
} else {
|
||||
double factor = (-2 * start + sqrt(4 * start * start - 4 * range * (-2 * delta))) / (2 * range);
|
||||
pVal[i] = pPrev->val + (pEntry->val - pPrev->val) * factor;
|
||||
(*pVal)[i] = pPrev->val + (pEntry->val - pPrev->val) * factor;
|
||||
}
|
||||
// printf("i/numofSlot: %f, v:%f, %f\n", (double)i/numOfSlots,
|
||||
// numOfElem, val);
|
||||
}
|
||||
#endif
|
||||
return pVal;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SHistogramInfo* tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2, int32_t numOfEntries) {
|
||||
SHistogramInfo* pResHistogram = tHistogramCreate(numOfEntries);
|
||||
int32_t tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2, int32_t numOfEntries, SHistogramInfo** pResHistogram) {
|
||||
int32_t code = tHistogramCreate(numOfEntries, pResHistogram);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
// error in histogram info
|
||||
if (pHisto1->numOfEntries > MAX_HISTOGRAM_BIN || pHisto2->numOfEntries > MAX_HISTOGRAM_BIN) {
|
||||
return pResHistogram;
|
||||
return code;
|
||||
}
|
||||
|
||||
SHistBin* pHistoBins = taosMemoryCalloc(1, sizeof(SHistBin) * (pHisto1->numOfEntries + pHisto2->numOfEntries));
|
||||
if (NULL == pHistoBins) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
int32_t i = 0, j = 0, k = 0;
|
||||
|
||||
while (i < pHisto1->numOfEntries && j < pHisto2->numOfEntries) {
|
||||
|
@ -583,28 +602,28 @@ SHistogramInfo* tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2
|
|||
|
||||
if (i < pHisto1->numOfEntries) {
|
||||
int32_t remain = pHisto1->numOfEntries - i;
|
||||
memcpy(&pHistoBins[k], &pHisto1->elems[i], sizeof(SHistBin) * remain);
|
||||
(void)memcpy(&pHistoBins[k], &pHisto1->elems[i], sizeof(SHistBin) * remain);
|
||||
k += remain;
|
||||
}
|
||||
|
||||
if (j < pHisto2->numOfEntries) {
|
||||
int32_t remain = pHisto2->numOfEntries - j;
|
||||
memcpy(&pHistoBins[k], &pHisto2->elems[j], sizeof(SHistBin) * remain);
|
||||
(void)memcpy(&pHistoBins[k], &pHisto2->elems[j], sizeof(SHistBin) * remain);
|
||||
k += remain;
|
||||
}
|
||||
|
||||
/* update other information */
|
||||
pResHistogram->numOfElems = pHisto1->numOfElems + pHisto2->numOfElems;
|
||||
pResHistogram->min = (pHisto1->min < pHisto2->min) ? pHisto1->min : pHisto2->min;
|
||||
pResHistogram->max = (pHisto1->max > pHisto2->max) ? pHisto1->max : pHisto2->max;
|
||||
(*pResHistogram)->numOfElems = pHisto1->numOfElems + pHisto2->numOfElems;
|
||||
(*pResHistogram)->min = (pHisto1->min < pHisto2->min) ? pHisto1->min : pHisto2->min;
|
||||
(*pResHistogram)->max = (pHisto1->max > pHisto2->max) ? pHisto1->max : pHisto2->max;
|
||||
|
||||
while (k > numOfEntries) {
|
||||
histogramMergeImpl(pHistoBins, &k);
|
||||
}
|
||||
|
||||
pResHistogram->numOfEntries = k;
|
||||
memcpy(pResHistogram->elems, pHistoBins, sizeof(SHistBin) * k);
|
||||
(*pResHistogram)->numOfEntries = k;
|
||||
(void)memcpy((*pResHistogram)->elems, pHistoBins, sizeof(SHistBin) * k);
|
||||
|
||||
taosMemoryFree(pHistoBins);
|
||||
return pResHistogram;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -28,9 +28,12 @@
|
|||
|
||||
int32_t getGroupId(int32_t numOfSlots, int32_t slotIndex, int32_t times) { return (times * numOfSlots) + slotIndex; }
|
||||
|
||||
static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx) {
|
||||
SFilePage *buffer =
|
||||
static int32_t loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx, SFilePage ** buffer) {
|
||||
*buffer =
|
||||
(SFilePage *)taosMemoryCalloc(1, pMemBucket->bytes * pMemBucket->pSlots[slotIdx].info.size + sizeof(SFilePage));
|
||||
if (NULL == *buffer) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t groupId = getGroupId(pMemBucket->numOfSlots, slotIdx, pMemBucket->times);
|
||||
|
||||
|
@ -39,26 +42,30 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx)
|
|||
if (p != NULL) {
|
||||
pIdList = *(SArray **)p;
|
||||
} else {
|
||||
taosMemoryFree(buffer);
|
||||
return NULL;
|
||||
taosMemoryFree(*buffer);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t offset = 0;
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pIdList); ++i) {
|
||||
int32_t *pageId = taosArrayGet(pIdList, i);
|
||||
if (pageId == NULL) {
|
||||
taosMemoryFree(*buffer);
|
||||
return TSDB_CODE_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
SFilePage *pg = getBufPage(pMemBucket->pBuffer, *pageId);
|
||||
if (pg == NULL) {
|
||||
taosMemoryFree(buffer);
|
||||
return NULL;
|
||||
taosMemoryFree(*buffer);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
memcpy(buffer->data + offset, pg->data, (size_t)(pg->num * pMemBucket->bytes));
|
||||
(void)memcpy((*buffer)->data + offset, pg->data, (size_t)(pg->num * pMemBucket->bytes));
|
||||
offset += (int32_t)(pg->num * pMemBucket->bytes);
|
||||
}
|
||||
|
||||
taosSort(buffer->data, pMemBucket->pSlots[slotIdx].info.size, pMemBucket->bytes, pMemBucket->comparFn);
|
||||
return buffer;
|
||||
taosSort((*buffer)->data, pMemBucket->pSlots[slotIdx].info.size, pMemBucket->bytes, pMemBucket->comparFn);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void resetBoundingBox(MinMaxEntry *range, int32_t type) {
|
||||
|
@ -116,6 +123,9 @@ int32_t findOnlyResult(tMemBucket *pMemBucket, double *result) {
|
|||
ASSERT(list->size == 1);
|
||||
|
||||
int32_t *pageId = taosArrayGet(list, 0);
|
||||
if (NULL == pageId) {
|
||||
return TSDB_CODE_OUT_OF_RANGE;
|
||||
}
|
||||
SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId);
|
||||
if (pPage == NULL) {
|
||||
return terrno;
|
||||
|
@ -238,67 +248,71 @@ static void resetSlotInfo(tMemBucket *pBucket) {
|
|||
}
|
||||
}
|
||||
|
||||
tMemBucket *tMemBucketCreate(int32_t nElemSize, int16_t dataType, double minval, double maxval, bool hasWindowOrGroup) {
|
||||
tMemBucket *pBucket = (tMemBucket *)taosMemoryCalloc(1, sizeof(tMemBucket));
|
||||
if (pBucket == NULL) {
|
||||
return NULL;
|
||||
int32_t tMemBucketCreate(int32_t nElemSize, int16_t dataType, double minval, double maxval, bool hasWindowOrGroup,
|
||||
tMemBucket **pBucket) {
|
||||
*pBucket = (tMemBucket *)taosMemoryCalloc(1, sizeof(tMemBucket));
|
||||
if (*pBucket == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (hasWindowOrGroup) {
|
||||
// With window or group by, we need to shrink page size and reduce page num to save memory.
|
||||
pBucket->numOfSlots = DEFAULT_NUM_OF_SLOT / 8 ; // 128 bucket
|
||||
pBucket->bufPageSize = 4096; // 4k per page
|
||||
(*pBucket)->numOfSlots = DEFAULT_NUM_OF_SLOT / 8 ; // 128 bucket
|
||||
(*pBucket)->bufPageSize = 4096; // 4k per page
|
||||
} else {
|
||||
pBucket->numOfSlots = DEFAULT_NUM_OF_SLOT;
|
||||
pBucket->bufPageSize = 16384 * 4; // 16k per page
|
||||
(*pBucket)->numOfSlots = DEFAULT_NUM_OF_SLOT;
|
||||
(*pBucket)->bufPageSize = 16384 * 4; // 16k per page
|
||||
}
|
||||
|
||||
pBucket->type = dataType;
|
||||
pBucket->bytes = nElemSize;
|
||||
pBucket->total = 0;
|
||||
pBucket->times = 1;
|
||||
(*pBucket)->type = dataType;
|
||||
(*pBucket)->bytes = nElemSize;
|
||||
(*pBucket)->total = 0;
|
||||
(*pBucket)->times = 1;
|
||||
|
||||
pBucket->maxCapacity = 200000;
|
||||
pBucket->groupPagesMap = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
if (setBoundingBox(&pBucket->range, pBucket->type, minval, maxval) != 0) {
|
||||
(*pBucket)->maxCapacity = 200000;
|
||||
(*pBucket)->groupPagesMap = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
if ((*pBucket)->groupPagesMap == NULL) {
|
||||
tMemBucketDestroy(*pBucket);
|
||||
return terrno;
|
||||
}
|
||||
if (setBoundingBox(&(*pBucket)->range, (*pBucket)->type, minval, maxval) != 0) {
|
||||
// qError("MemBucket:%p, invalid value range: %f-%f", pBucket, minval, maxval);
|
||||
taosMemoryFree(pBucket);
|
||||
return NULL;
|
||||
tMemBucketDestroy(*pBucket);
|
||||
return TSDB_CODE_FUNC_INVALID_VALUE_RANGE;
|
||||
}
|
||||
|
||||
pBucket->elemPerPage = (pBucket->bufPageSize - sizeof(SFilePage)) / pBucket->bytes;
|
||||
pBucket->comparFn = getKeyComparFunc(pBucket->type, TSDB_ORDER_ASC);
|
||||
(*pBucket)->elemPerPage = ((*pBucket)->bufPageSize - sizeof(SFilePage)) / (*pBucket)->bytes;
|
||||
(*pBucket)->comparFn = getKeyComparFunc((*pBucket)->type, TSDB_ORDER_ASC);
|
||||
|
||||
pBucket->hashFunc = getHashFunc(pBucket->type);
|
||||
if (pBucket->hashFunc == NULL) {
|
||||
(*pBucket)->hashFunc = getHashFunc((*pBucket)->type);
|
||||
if ((*pBucket)->hashFunc == NULL) {
|
||||
// qError("MemBucket:%p, not support data type %d, failed", pBucket, pBucket->type);
|
||||
taosMemoryFree(pBucket);
|
||||
return NULL;
|
||||
tMemBucketDestroy(*pBucket);
|
||||
return TSDB_CODE_FUNC_FUNTION_PARA_TYPE;
|
||||
}
|
||||
|
||||
pBucket->pSlots = (tMemBucketSlot *)taosMemoryCalloc(pBucket->numOfSlots, sizeof(tMemBucketSlot));
|
||||
if (pBucket->pSlots == NULL) {
|
||||
taosMemoryFree(pBucket);
|
||||
return NULL;
|
||||
(*pBucket)->pSlots = (tMemBucketSlot *)taosMemoryCalloc((*pBucket)->numOfSlots, sizeof(tMemBucketSlot));
|
||||
if ((*pBucket)->pSlots == NULL) {
|
||||
tMemBucketDestroy(*pBucket);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
resetSlotInfo(pBucket);
|
||||
resetSlotInfo((*pBucket));
|
||||
|
||||
if (!osTempSpaceAvailable()) {
|
||||
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||
// qError("MemBucket create disk based Buf failed since %s", terrstr(terrno));
|
||||
tMemBucketDestroy(pBucket);
|
||||
return NULL;
|
||||
tMemBucketDestroy(*pBucket);
|
||||
return TSDB_CODE_NO_DISKSPACE;
|
||||
}
|
||||
|
||||
int32_t ret = createDiskbasedBuf(&pBucket->pBuffer, pBucket->bufPageSize, pBucket->bufPageSize * 1024, "1", tsTempDir);
|
||||
int32_t ret = createDiskbasedBuf(&(*pBucket)->pBuffer, (*pBucket)->bufPageSize, (*pBucket)->bufPageSize * 1024, "1", tsTempDir);
|
||||
if (ret != 0) {
|
||||
tMemBucketDestroy(pBucket);
|
||||
return NULL;
|
||||
tMemBucketDestroy(*pBucket);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// qDebug("MemBucket:%p, elem size:%d", pBucket, pBucket->bytes);
|
||||
return pBucket;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void tMemBucketDestroy(tMemBucket *pBucket) {
|
||||
|
@ -394,7 +408,14 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
|
|||
void *p = taosHashGet(pBucket->groupPagesMap, &groupId, sizeof(groupId));
|
||||
if (p == NULL) {
|
||||
pPageIdList = taosArrayInit(4, sizeof(int32_t));
|
||||
taosHashPut(pBucket->groupPagesMap, &groupId, sizeof(groupId), &pPageIdList, POINTER_BYTES);
|
||||
if (NULL == pPageIdList) {
|
||||
return terrno;
|
||||
}
|
||||
int32_t code = taosHashPut(pBucket->groupPagesMap, &groupId, sizeof(groupId), &pPageIdList, POINTER_BYTES);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosArrayDestroy(pPageIdList);
|
||||
return code;
|
||||
}
|
||||
} else {
|
||||
pPageIdList = *(SArray **)p;
|
||||
}
|
||||
|
@ -404,10 +425,13 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
|
|||
return terrno;
|
||||
}
|
||||
pSlot->info.pageId = pageId;
|
||||
taosArrayPush(pPageIdList, &pageId);
|
||||
if (taosArrayPush(pPageIdList, &pageId) == NULL) {
|
||||
taosArrayDestroy(pPageIdList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(pSlot->info.data->data + pSlot->info.data->num * pBucket->bytes, d, pBucket->bytes);
|
||||
(void)memcpy(pSlot->info.data->data + pSlot->info.data->num * pBucket->bytes, d, pBucket->bytes);
|
||||
|
||||
pSlot->info.data->num += 1;
|
||||
pSlot->info.size += 1;
|
||||
|
@ -493,9 +517,10 @@ int32_t getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction
|
|||
|
||||
if (pSlot->info.size <= pMemBucket->maxCapacity) {
|
||||
// data in buffer and file are merged together to be processed.
|
||||
SFilePage *buffer = loadDataFromFilePage(pMemBucket, i);
|
||||
if (buffer == NULL) {
|
||||
return terrno;
|
||||
SFilePage *buffer = NULL;
|
||||
int32_t code = loadDataFromFilePage(pMemBucket, i, &buffer);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t currentIdx = count - num;
|
||||
|
@ -541,6 +566,9 @@ int32_t getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction
|
|||
|
||||
for (int32_t f = 0; f < list->size; ++f) {
|
||||
int32_t *pageId = taosArrayGet(list, f);
|
||||
if (NULL == pageId) {
|
||||
return TSDB_CODE_OUT_OF_RANGE;
|
||||
}
|
||||
SFilePage *pg = getBufPage(pMemBucket->pBuffer, *pageId);
|
||||
if (pg == NULL) {
|
||||
return terrno;
|
||||
|
|
|
@ -1011,7 +1011,7 @@ void releaseUdfFuncHandle(char *udfName, UdfcFuncHandle handle);
|
|||
int32_t cleanUpUdfs();
|
||||
|
||||
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);
|
||||
|
||||
|
@ -1196,15 +1196,18 @@ bool udfAggGetEnv(struct SFunctionNode *pFunc, SFuncExecEnv *pEnv) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo) {
|
||||
if (functionSetup(pCtx, pResultCellInfo) != true) {
|
||||
return false;
|
||||
int32_t udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo) {
|
||||
if (pResultCellInfo->initialized) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (functionSetup(pCtx, pResultCellInfo) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_FUNC_SETUP_ERROR;
|
||||
}
|
||||
UdfcFuncHandle handle;
|
||||
int32_t udfCode = 0;
|
||||
if ((udfCode = acquireUdfFuncHandle((char *)pCtx->udfName, &handle)) != 0) {
|
||||
fnError("udfAggInit error. step doSetupUdf. udf code: %d", udfCode);
|
||||
return false;
|
||||
return TSDB_CODE_FUNC_SETUP_ERROR;
|
||||
}
|
||||
SUdfcUvSession *session = (SUdfcUvSession *)handle;
|
||||
SUdfAggRes *udfRes = (SUdfAggRes *)GET_ROWCELL_INTERBUF(pResultCellInfo);
|
||||
|
@ -1218,7 +1221,7 @@ bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResult
|
|||
if ((udfCode = doCallUdfAggInit(handle, &buf)) != 0) {
|
||||
fnError("udfAggInit error. step doCallUdfAggInit. udf code: %d", udfCode);
|
||||
releaseUdfFuncHandle(pCtx->udfName, handle);
|
||||
return false;
|
||||
return TSDB_CODE_FUNC_SETUP_ERROR;
|
||||
}
|
||||
if (buf.bufLen <= session->bufSize) {
|
||||
memcpy(udfRes->interResBuf, buf.buf, buf.bufLen);
|
||||
|
@ -1227,11 +1230,11 @@ bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResult
|
|||
} else {
|
||||
fnError("udfc inter buf size %d is greater than function bufSize %d", buf.bufLen, session->bufSize);
|
||||
releaseUdfFuncHandle(pCtx->udfName, handle);
|
||||
return false;
|
||||
return TSDB_CODE_FUNC_SETUP_ERROR;
|
||||
}
|
||||
releaseUdfFuncHandle(pCtx->udfName, handle);
|
||||
freeUdfInterBuf(&buf);
|
||||
return true;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) {
|
||||
|
|
|
@ -10420,8 +10420,9 @@ static int32_t createLastTsSelectStmt(char* pDb, const char* pTable, const char*
|
|||
return code;
|
||||
}
|
||||
|
||||
SNode* pFunc = (SNode*)createFunction("last", pParameterList);
|
||||
if (NULL == pFunc) {
|
||||
SNode* pFunc = NULL;
|
||||
code = createFunction("last", pParameterList, (SFunctionNode**)&pFunc);
|
||||
if (code) {
|
||||
nodesDestroyList(pParameterList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -10438,8 +10439,9 @@ static int32_t createLastTsSelectStmt(char* pDb, const char* pTable, const char*
|
|||
return code;
|
||||
}
|
||||
|
||||
SFunctionNode* pFunc1 = createFunction("_vgid", NULL);
|
||||
if (NULL == pFunc1) {
|
||||
SFunctionNode* pFunc1 = NULL;
|
||||
code = createFunction("_vgid", NULL, &pFunc1);
|
||||
if (code) {
|
||||
nodesDestroyList(pProjectionList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -10451,8 +10453,9 @@ static int32_t createLastTsSelectStmt(char* pDb, const char* pTable, const char*
|
|||
return code;
|
||||
}
|
||||
|
||||
SFunctionNode* pFunc2 = createFunction("_vgver", NULL);
|
||||
if (NULL == pFunc2) {
|
||||
SFunctionNode* pFunc2 = NULL;
|
||||
code = createFunction("_vgver", NULL, &pFunc2);
|
||||
if (code) {
|
||||
nodesDestroyList(pProjectionList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ namespace ParserTest {
|
|||
class ParserEnv : public testing::Environment {
|
||||
public:
|
||||
virtual void SetUp() {
|
||||
fmFuncMgtInit();
|
||||
// TODO(smj) : How to handle return value of fmFuncMgtInit
|
||||
(void)fmFuncMgtInit();
|
||||
initMetaDataEnv();
|
||||
generateMetaData();
|
||||
initLog(TD_TMP_DIR_PATH "td");
|
||||
|
|
|
@ -5336,9 +5336,13 @@ static bool stbJoinOptShouldBeOptimized(SLogicNode* pNode) {
|
|||
}
|
||||
|
||||
int32_t stbJoinOptAddFuncToScanNode(char* funcName, SScanLogicNode* pScan) {
|
||||
SFunctionNode* pUidFunc = createFunction(funcName, NULL);
|
||||
SFunctionNode* pUidFunc = NULL;
|
||||
int32_t code = createFunction(funcName, NULL, &pUidFunc);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
snprintf(pUidFunc->node.aliasName, sizeof(pUidFunc->node.aliasName), "%s.%p", pUidFunc->functionName, pUidFunc);
|
||||
int32_t code = nodesListStrictAppend(pScan->pScanPseudoCols, (SNode*)pUidFunc);
|
||||
code = nodesListStrictAppend(pScan->pScanPseudoCols, (SNode*)pUidFunc);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createColumnByRewriteExpr((SNode*)pUidFunc, &pScan->node.pTargets);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
class PlannerEnv : public testing::Environment {
|
||||
public:
|
||||
virtual void SetUp() {
|
||||
fmFuncMgtInit();
|
||||
// TODO(smj) : How to handle return value of fmFuncMgtInit
|
||||
(void)fmFuncMgtInit();
|
||||
initMetaDataEnv();
|
||||
generateMetaData();
|
||||
initLog(TD_TMP_DIR_PATH "td");
|
||||
|
|
|
@ -997,9 +997,15 @@ int32_t filterDetachCnfGroups(SArray *group, SArray *left, SArray *right) {
|
|||
|
||||
for (int32_t l = 0; l < leftSize; ++l) {
|
||||
SFilterGroup *gp1 = taosArrayGet(left, l);
|
||||
if (NULL == gp1) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
for (int32_t r = 0; r < rightSize; ++r) {
|
||||
SFilterGroup *gp2 = taosArrayGet(right, r);
|
||||
if (NULL == gp2) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
FLT_ERR_RET(filterDetachCnfGroup(gp1, gp2, group));
|
||||
}
|
||||
|
@ -1212,7 +1218,7 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left,
|
|||
FLT_PACKAGE_UNIT_HASH_KEY(&v, optr, optr2, left->idx, (right ? right->idx : -1), (right2 ? right2->idx : -1));
|
||||
if (taosHashPut(info->pctx.unitHash, v, sizeof(v), uidx, sizeof(*uidx))) {
|
||||
fltError("taosHashPut to set failed");
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2157,7 +2163,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
|
|||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(fi->data), varDataLen(fi->data), varDataVal(newValData));
|
||||
if (len < 0) {
|
||||
qError("filterInitValFieldData taosUcs4ToMbs error 1");
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
return TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
}
|
||||
varDataSetLen(newValData, len);
|
||||
(void)varDataCopy(fi->data, newValData);
|
||||
|
@ -2307,6 +2313,9 @@ int32_t filterMergeUnits(SFilterInfo *info, SFilterGroupCtx *gRes, uint32_t colI
|
|||
|
||||
for (uint32_t i = 0; i < size; ++i) {
|
||||
SFilterUnit *u = taosArrayGetP(colArray, i);
|
||||
if (NULL == u) {
|
||||
FLT_ERR_JRET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
uint8_t optr = FILTER_UNIT_OPTR(u);
|
||||
|
||||
FLT_ERR_RET(filterAddRangeOptr(ctx, optr, LOGIC_COND_TYPE_AND, empty, NULL));
|
||||
|
@ -2637,6 +2646,9 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx **gRes1, SFilter
|
|||
|
||||
for (int32_t i = 0; i < ctxSize; ++i) {
|
||||
pctx = taosArrayGet(colCtxs, i);
|
||||
if (NULL == pctx) {
|
||||
FLT_ERR_JRET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
colInfo = &(*gRes1)->colInfo[pctx->colIdx];
|
||||
|
||||
filterFreeColInfo(colInfo);
|
||||
|
@ -2763,6 +2775,9 @@ int32_t filterConvertGroupFromArray(SFilterInfo *info, SArray *group) {
|
|||
|
||||
for (size_t i = 0; i < groupSize; ++i) {
|
||||
SFilterGroup *pg = taosArrayGet(group, i);
|
||||
if (NULL == pg) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
pg->unitFlags = taosMemoryCalloc(pg->unitNum, sizeof(*pg->unitFlags));
|
||||
if (pg->unitFlags == NULL) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
@ -2819,7 +2834,9 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t gResNum
|
|||
|
||||
for (int32_t n = 0; n < usize; ++n) {
|
||||
SFilterUnit *u = (SFilterUnit *)taosArrayGetP((SArray *)colInfo->info, n);
|
||||
|
||||
if (NULL == u) {
|
||||
FLT_ERR_JRET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
FLT_ERR_JRET(filterAddUnitFromUnit(info, &oinfo, u, &uidx));
|
||||
FLT_ERR_JRET(filterAddUnitToGroup(&ng, uidx));
|
||||
}
|
||||
|
@ -3425,7 +3442,7 @@ int32_t filterExecuteImplMisc(void *pinfo, int32_t numOfRows, SColumnInfoData *p
|
|||
if (len < 0) {
|
||||
qError("castConvert1 taosUcs4ToMbs error");
|
||||
taosMemoryFreeClear(newColData);
|
||||
FLT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
FLT_ERR_RET(TSDB_CODE_SCALAR_CONVERT_ERROR);
|
||||
} else {
|
||||
varDataSetLen(newColData, len);
|
||||
p[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData,
|
||||
|
@ -3500,7 +3517,7 @@ int32_t filterExecuteImpl(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes,
|
|||
if (len < 0) {
|
||||
qError("castConvert1 taosUcs4ToMbs error");
|
||||
taosMemoryFreeClear(newColData);
|
||||
FLT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
FLT_ERR_RET(TSDB_CODE_SCALAR_CONVERT_ERROR);
|
||||
} else {
|
||||
varDataSetLen(newColData, len);
|
||||
p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData);
|
||||
|
@ -3814,6 +3831,9 @@ int32_t fltSclMergeSort(SArray *pts1, SArray *pts2, SArray *result) {
|
|||
while (i < len1 && j < len2) {
|
||||
SFltSclPoint *pt1 = taosArrayGet(pts1, i);
|
||||
SFltSclPoint *pt2 = taosArrayGet(pts2, j);
|
||||
if (NULL == pt1 || NULL == pt2) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
bool less = fltSclLessPoint(pt1, pt2);
|
||||
if (less) {
|
||||
if (NULL == taosArrayPush(result, pt1)) {
|
||||
|
@ -3830,6 +3850,9 @@ int32_t fltSclMergeSort(SArray *pts1, SArray *pts2, SArray *result) {
|
|||
if (i < len1) {
|
||||
for (; i < len1; ++i) {
|
||||
SFltSclPoint *pt1 = taosArrayGet(pts1, i);
|
||||
if (NULL == pt1) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
if (NULL == taosArrayPush(result, pt1)) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -3838,6 +3861,9 @@ int32_t fltSclMergeSort(SArray *pts1, SArray *pts2, SArray *result) {
|
|||
if (j < len2) {
|
||||
for (; j < len2; ++j) {
|
||||
SFltSclPoint *pt2 = taosArrayGet(pts2, j);
|
||||
if (NULL == pt2) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
if (NULL == taosArrayPush(result, pt2)) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -3859,6 +3885,9 @@ int32_t fltSclMerge(SArray *pts1, SArray *pts2, bool isUnion, SArray *merged) {
|
|||
int32_t count = 0;
|
||||
for (int32_t i = 0; i < taosArrayGetSize(all); ++i) {
|
||||
SFltSclPoint *pt = taosArrayGet(all, i);
|
||||
if (NULL == pt) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
if (pt->start) {
|
||||
++count;
|
||||
if (count == countRequired) {
|
||||
|
@ -3893,6 +3922,9 @@ typedef struct {
|
|||
int32_t fltSclGetOrCreateColumnRange(SColumnNode *colNode, SArray *colRangeList, SFltSclColumnRange **colRange) {
|
||||
for (int32_t i = 0; i < taosArrayGetSize(colRangeList); ++i) {
|
||||
*colRange = taosArrayGet(colRangeList, i);
|
||||
if (NULL == colRange) {
|
||||
return TSDB_CODE_OUT_OF_RANGE;
|
||||
}
|
||||
if (nodesEqualNode((SNode *)(*colRange)->colNode, (SNode *)colNode)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -4044,6 +4076,9 @@ int32_t filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32
|
|||
SArray *colRanges = info->sclCtx.fltSclRange;
|
||||
for (int32_t i = 0; i < taosArrayGetSize(colRanges); ++i) {
|
||||
SFltSclColumnRange *colRange = taosArrayGet(colRanges, i);
|
||||
if (NULL == colRange) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
bool foundCol = false;
|
||||
int32_t j = 0;
|
||||
for (; j < numOfCols; ++j) {
|
||||
|
@ -4332,11 +4367,17 @@ int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict) {
|
|||
SArray *colRanges = info->sclCtx.fltSclRange;
|
||||
if (taosArrayGetSize(colRanges) == 1) {
|
||||
SFltSclColumnRange *colRange = taosArrayGet(colRanges, 0);
|
||||
if (NULL == colRange) {
|
||||
FLT_ERR_JRET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
SArray *points = colRange->points;
|
||||
if (taosArrayGetSize(points) == 2) {
|
||||
*win = TSWINDOW_DESC_INITIALIZER;
|
||||
SFltSclPoint *startPt = taosArrayGet(points, 0);
|
||||
SFltSclPoint *endPt = taosArrayGet(points, 1);
|
||||
if (NULL == startPt || NULL == endPt) {
|
||||
FLT_ERR_JRET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
SFltSclDatum start;
|
||||
SFltSclDatum end;
|
||||
FLT_ERR_JRET(fltSclGetTimeStampDatum(startPt, &start));
|
||||
|
@ -4398,7 +4439,7 @@ int32_t filterConverNcharColumns(SFilterInfo *info, int32_t rows, bool *gotNchar
|
|||
bool ret = taosMbsToUcs4(varDataVal(src), varDataLen(src), (TdUcs4 *)varDataVal(dst), bufSize, &len);
|
||||
if (!ret) {
|
||||
qError("filterConverNcharColumns taosMbsToUcs4 error");
|
||||
return TSDB_CODE_FAILED;
|
||||
return TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
}
|
||||
varDataLen(dst) = len;
|
||||
}
|
||||
|
@ -4432,7 +4473,7 @@ int32_t fltAddValueNodeToConverList(SFltTreeStat *stat, SValueNode *pNode) {
|
|||
if (NULL == stat->nodeList) {
|
||||
stat->nodeList = taosArrayInit(10, POINTER_BYTES);
|
||||
if (NULL == stat->nodeList) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4816,6 +4857,9 @@ int32_t fltSclProcessCNF(SArray *sclOpListCNF, SArray *colRangeList) {
|
|||
size_t sz = taosArrayGetSize(sclOpListCNF);
|
||||
for (int32_t i = 0; i < sz; ++i) {
|
||||
SFltSclOperator *sclOper = taosArrayGet(sclOpListCNF, i);
|
||||
if (NULL == sclOper) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
SFltSclColumnRange *colRange = NULL;
|
||||
FLT_ERR_RET(fltSclGetOrCreateColumnRange(sclOper->colNode, colRangeList, &colRange));
|
||||
SArray *points = taosArrayInit(4, sizeof(SFltSclPoint));
|
||||
|
@ -4920,22 +4964,27 @@ static int32_t fltSclCollectOperators(SNode *pNode, SArray *sclOpList) {
|
|||
|
||||
int32_t fltOptimizeNodes(SFilterInfo *pInfo, SNode **pNode, SFltTreeStat *pStat) {
|
||||
SArray *sclOpList = taosArrayInit(16, sizeof(SFltSclOperator));
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (NULL == sclOpList) {
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
FLT_ERR_RET(fltSclCollectOperators(*pNode, sclOpList));
|
||||
FLT_ERR_JRET(fltSclCollectOperators(*pNode, sclOpList));
|
||||
SArray *colRangeList = taosArrayInit(16, sizeof(SFltSclColumnRange));
|
||||
if (NULL == colRangeList) {
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
FLT_ERR_RET(fltSclProcessCNF(sclOpList, colRangeList));
|
||||
FLT_ERR_JRET(fltSclProcessCNF(sclOpList, colRangeList));
|
||||
pInfo->sclCtx.fltSclRange = colRangeList;
|
||||
|
||||
for (int32_t i = 0; i < taosArrayGetSize(sclOpList); ++i) {
|
||||
SFltSclOperator *sclOp = taosArrayGet(sclOpList, i);
|
||||
if (NULL == sclOp) {
|
||||
FLT_ERR_JRET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
nodesDestroyNode((SNode *)sclOp->colNode);
|
||||
nodesDestroyNode((SNode *)sclOp->valNode);
|
||||
}
|
||||
_return:
|
||||
taosArrayDestroy(sclOpList);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -4946,6 +4995,9 @@ int32_t fltGetDataFromColId(void *param, int32_t id, void **data) {
|
|||
|
||||
for (int32_t j = 0; j < numOfCols; ++j) {
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pDataBlock, j);
|
||||
if (NULL == pColInfo) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
if (id == pColInfo->info.colId) {
|
||||
*data = pColInfo;
|
||||
break;
|
||||
|
@ -4965,6 +5017,9 @@ int32_t fltGetDataFromSlotId(void *param, int32_t id, void **data) {
|
|||
}
|
||||
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pDataBlock, id);
|
||||
if (NULL == pColInfo) {
|
||||
return TSDB_CODE_OUT_OF_RANGE;
|
||||
}
|
||||
*data = pColInfo;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -90,6 +90,9 @@ int32_t sclConvertValueToSclParam(SValueNode *pValueNode, SScalarParam *out, int
|
|||
|
||||
int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockList) {
|
||||
SSDataBlock *pb = taosArrayGetP(pBlockList, 0);
|
||||
if (NULL == pb) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
SScalarParam *pLeft = taosMemoryCalloc(1, sizeof(SScalarParam));
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (NULL == pLeft) {
|
||||
|
@ -116,7 +119,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
|||
SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(type), true, false);
|
||||
if (NULL == pObj) {
|
||||
sclError("taosHashInit failed, size:%d", 256);
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
taosHashSetEqualFp(pObj, taosGetDefaultEqualFunction(type));
|
||||
|
@ -176,7 +179,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
|||
|
||||
if (taosHashPut(pObj, buf, (size_t)len, NULL, 0)) {
|
||||
sclError("taosHashPut to set failed");
|
||||
SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
colInfoDataCleanup(out.columnData, out.numOfRows);
|
||||
|
@ -336,6 +339,9 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
switch (nodeType(node)) {
|
||||
case QUERY_NODE_LEFT_VALUE: {
|
||||
SSDataBlock *pb = taosArrayGetP(ctx->pBlockList, 0);
|
||||
if (NULL == pb) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
param->numOfRows = pb->info.rows;
|
||||
break;
|
||||
}
|
||||
|
@ -347,10 +353,7 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
param->numOfRows = 1;
|
||||
int32_t code = sclCreateColumnInfoData(&valueNode->node.resType, 1, param);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SCL_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
SCL_ERR_RET(sclCreateColumnInfoData(&valueNode->node.resType, 1, param));
|
||||
if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type || valueNode->isNull) {
|
||||
colDataSetNULL(param->columnData, 0);
|
||||
} else {
|
||||
|
@ -377,7 +380,7 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
taosHashCleanup(param->pHashFilter);
|
||||
param->pHashFilter = NULL;
|
||||
sclError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
param->colAlloced = false;
|
||||
break;
|
||||
|
@ -393,6 +396,9 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
int32_t index = -1;
|
||||
for (int32_t i = 0; i < taosArrayGetSize(ctx->pBlockList); ++i) {
|
||||
SSDataBlock *pb = taosArrayGetP(ctx->pBlockList, i);
|
||||
if (NULL == pb) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
if (pb->info.id.blockId == ref->dataBlockId) {
|
||||
index = i;
|
||||
break;
|
||||
|
@ -461,6 +467,9 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList *pParamList, SScalarC
|
|||
if (NULL == pParamList) {
|
||||
if (ctx->pBlockList) {
|
||||
SSDataBlock *pBlock = taosArrayGetP(ctx->pBlockList, 0);
|
||||
if (NULL == pBlock) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
*rowNum = pBlock->info.rows;
|
||||
} else {
|
||||
*rowNum = 1;
|
||||
|
@ -919,6 +928,9 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
|
|||
|
||||
if (ctx->pBlockList) {
|
||||
SSDataBlock *pb = taosArrayGetP(ctx->pBlockList, 0);
|
||||
if (NULL == pb) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
rowNum = pb->info.rows;
|
||||
output->numOfRows = pb->info.rows;
|
||||
}
|
||||
|
@ -1532,6 +1544,10 @@ EDealRes sclWalkTarget(SNode *pNode, SScalarCtx *ctx) {
|
|||
int32_t index = -1;
|
||||
for (int32_t i = 0; i < taosArrayGetSize(ctx->pBlockList); ++i) {
|
||||
SSDataBlock *pb = taosArrayGetP(ctx->pBlockList, i);
|
||||
if (NULL == pb) {
|
||||
ctx->code = TSDB_CODE_OUT_OF_RANGE;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
if (pb->info.id.blockId == target->dataBlockId) {
|
||||
index = i;
|
||||
break;
|
||||
|
@ -1636,7 +1652,7 @@ int32_t sclCalcConstants(SNode *pNode, bool dual, SNode **pRes) {
|
|||
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (NULL == ctx.pRes) {
|
||||
sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM);
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
nodesRewriteExprPostOrder(&pNode, sclConstantsRewriter, (void *)&ctx);
|
||||
|
@ -1770,7 +1786,7 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
|||
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (NULL == ctx.pRes) {
|
||||
sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM);
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
nodesWalkExprPostOrder(pNode, sclCalcWalker, (void *)&ctx);
|
||||
|
@ -1784,6 +1800,9 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
|||
}
|
||||
|
||||
SSDataBlock *pb = taosArrayGetP(pBlockList, 0);
|
||||
if (NULL == pb) {
|
||||
SCL_ERR_JRET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
if (1 == res->numOfRows && pb->info.rows > 0) {
|
||||
SCL_ERR_JRET(sclExtendResRows(pDst, res, pBlockList));
|
||||
} else {
|
||||
|
|
|
@ -399,7 +399,7 @@ static int32_t concatCopyHelper(const char *input, char *output, bool hasNchar,
|
|||
bool ret = taosMbsToUcs4(varDataVal(input), len, newBuf, (varDataLen(input) + 1) * TSDB_NCHAR_SIZE, &len);
|
||||
if (!ret) {
|
||||
taosMemoryFree(newBuf);
|
||||
return TSDB_CODE_FAILED;
|
||||
return TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
}
|
||||
memcpy(varDataVal(output) + *dataLen, newBuf, varDataLen(input) * TSDB_NCHAR_SIZE);
|
||||
*dataLen += varDataLen(input) * TSDB_NCHAR_SIZE;
|
||||
|
@ -818,7 +818,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
|
@ -837,7 +837,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
convBuf[len] = 0;
|
||||
|
@ -855,7 +855,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
|
@ -874,7 +874,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
convBuf[len] = 0;
|
||||
|
@ -892,7 +892,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
convBuf[len] = 0;
|
||||
|
@ -910,7 +910,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
convBuf[len] = 0;
|
||||
|
@ -928,7 +928,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
convBuf[len] = 0;
|
||||
|
@ -946,7 +946,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
|
@ -965,7 +965,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
convBuf[len] = 0;
|
||||
|
@ -983,7 +983,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
convBuf[len] = 0;
|
||||
|
@ -1001,7 +1001,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
convBuf[len] = 0;
|
||||
|
@ -1041,7 +1041,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
|
||||
if (len < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
len = TMIN(len, outputLen - VARSTR_HEADER_SIZE);
|
||||
|
@ -1075,7 +1075,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
len = sprintf(tmp, "%.*s", outputCharLen, *(int8_t *)input ? "true" : "false");
|
||||
bool ret = taosMbsToUcs4(tmp, len, (TdUcs4 *)varDataVal(output), outputLen - VARSTR_HEADER_SIZE, &len);
|
||||
if (!ret) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
|
@ -1085,7 +1085,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
bool ret = taosMbsToUcs4(input + VARSTR_HEADER_SIZE, len, (TdUcs4 *)varDataVal(output),
|
||||
outputLen - VARSTR_HEADER_SIZE, &len);
|
||||
if (!ret) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
varDataSetLen(output, len);
|
||||
|
@ -1099,7 +1099,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
len = outputCharLen > len ? len : outputCharLen;
|
||||
bool ret = taosMbsToUcs4(buf, len, (TdUcs4 *)varDataVal(output), outputLen - VARSTR_HEADER_SIZE, &len);
|
||||
if (!ret) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
code = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _end;
|
||||
}
|
||||
varDataSetLen(output, len);
|
||||
|
|
|
@ -105,7 +105,7 @@ int32_t convertNcharToDouble(const void *inData, void *outData) {
|
|||
int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(inData), varDataLen(inData), tmp);
|
||||
if (len < 0) {
|
||||
sclError("castConvert taosUcs4ToMbs error 1");
|
||||
SCL_ERR_JRET(TSDB_CODE_FAILED);
|
||||
SCL_ERR_JRET(TSDB_CODE_SCALAR_CONVERT_ERROR);
|
||||
}
|
||||
|
||||
tmp[len] = 0;
|
||||
|
@ -596,7 +596,7 @@ int32_t ncharTobinary(void *buf, void **out) { // todo need to remove , if tobi
|
|||
sclError("charset:%s to %s. val:%s convert ncharTobinary failed.", DEFAULT_UNICODE_ENCODEC, tsCharset,
|
||||
(char *)varDataVal(buf));
|
||||
taosMemoryFree(*out);
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(TSDB_CODE_SCALAR_CONVERT_ERROR);
|
||||
}
|
||||
varDataSetLen(*out, len);
|
||||
SCL_RET(TSDB_CODE_SUCCESS);
|
||||
|
|
|
@ -549,7 +549,7 @@ int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
|||
if (tEncodeCStrWithLen(pEncoder, pTask->reserve, sizeof(pTask->reserve) - 1) < 0) return -1;
|
||||
|
||||
tEndEncode(pEncoder);
|
||||
return pEncoder->pos;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
||||
|
|
|
@ -707,6 +707,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED_FORMAT_ERR, "Func to_timest
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED_TS_ERR, "Func to_timestamp failed for wrong timestamp")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED_NOT_SUPPORTED, "Func to_timestamp failed for unsupported timestamp format")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_TO_CHAR_NOT_SUPPORTED, "Func to_char failed for unsupported format")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_TIME_UNIT_INVALID, "Invalid function time unit")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL, "Function time unit cannot be smaller than db precision")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_INVALID_VALUE_RANGE, "Function got invalid value range")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_SETUP_ERROR, "Function set up failed")
|
||||
|
||||
//udf
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_STOPPING, "udf is stopping")
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
/home/m.json
|
||||
/home/log_server.json
|
||||
/var/lib/jenkins/workspace/restore.sh
|
||||
/var/lib/jenkins/workspace/start_http.sh
|
||||
/var/lib/jenkins/workspace/TDinternal
|
||||
/var/lib/jenkins/workspace/remove_corefile.sh
|
||||
/var/lib/jenkins/workspace/CI_disk_Monitor.py
|
||||
/var/lib/jenkins/workspace/start_CI_Monitor.sh
|
|
@ -0,0 +1,88 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
function usage() {
|
||||
echo "$0"
|
||||
echo -e "\t -w work dir"
|
||||
echo -e "\t -e enterprise edition"
|
||||
echo -e "\t -t make thread count"
|
||||
echo -e "\t -h help"
|
||||
}
|
||||
|
||||
ent=0
|
||||
while getopts "w:t:eh" opt; do
|
||||
case $opt in
|
||||
w)
|
||||
WORKDIR=$OPTARG
|
||||
;;
|
||||
e)
|
||||
ent=1
|
||||
;;
|
||||
t)
|
||||
THREAD_COUNT=$OPTARG
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG"
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$WORKDIR" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
# if [ -z "$THREAD_COUNT" ]; then
|
||||
# THREAD_COUNT=1
|
||||
# fi
|
||||
|
||||
ulimit -c unlimited
|
||||
|
||||
if [ $ent -eq 0 ]; then
|
||||
REP_DIR=/home/TDengine
|
||||
REP_REAL_PATH=$WORKDIR/TDengine
|
||||
REP_MOUNT_PARAM=$REP_REAL_PATH:/home/TDengine
|
||||
else
|
||||
REP_DIR=/home/TDinternal
|
||||
REP_REAL_PATH=$WORKDIR/TDinternal
|
||||
REP_MOUNT_PARAM=$REP_REAL_PATH:/home/TDinternal
|
||||
|
||||
fi
|
||||
date
|
||||
docker run \
|
||||
-v $REP_MOUNT_PARAM \
|
||||
-v /root/.cargo/registry:/root/.cargo/registry \
|
||||
-v /root/.cargo/git:/root/.cargo/git \
|
||||
-v /root/go/pkg/mod:/root/go/pkg/mod \
|
||||
-v /root/.cache/go-build:/root/.cache/go-build \
|
||||
-v /root/.cos-local.1:/root/.cos-local.2 \
|
||||
--rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true $CMAKE_BUILD_TYPE -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=false -DJEMALLOC_ENABLED=0;make -j 10|| exit 1 "
|
||||
# -v ${REP_REAL_PATH}/community/contrib/jemalloc/:${REP_DIR}/community/contrib/jemalloc \
|
||||
|
||||
if [[ -d ${WORKDIR}/debugNoSan ]] ;then
|
||||
echo "delete ${WORKDIR}/debugNoSan"
|
||||
rm -rf ${WORKDIR}/debugNoSan
|
||||
fi
|
||||
if [[ -d ${WORKDIR}/debugSan ]] ;then
|
||||
echo "delete ${WORKDIR}/debugSan"
|
||||
rm -rf ${WORKDIR}/debugSan
|
||||
fi
|
||||
|
||||
if [ "$(uname -m)" = "aarch64" ] ;then
|
||||
CMAKE_BUILD_TYPE="-DCMAKE_BUILD_TYPE=Debug"
|
||||
else
|
||||
CMAKE_BUILD_TYPE="-DCMAKE_BUILD_TYPE=Release"
|
||||
fi
|
||||
|
||||
|
||||
mv ${REP_REAL_PATH}/debug ${WORKDIR}/debugSan
|
||||
date
|
||||
|
||||
ret=$?
|
||||
exit $ret
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
#!/bin/bash
|
||||
|
||||
function scp_file_from_host {
|
||||
# check at least three parameters
|
||||
if [ "$#" -lt 3 ]; then
|
||||
echo "Usage: $0 host passwd source_filename [dest_filename]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
host=$1
|
||||
passwd=$2
|
||||
source_filename=$3
|
||||
# If the fourth parameter is not provided, use the third parameter as the default value
|
||||
dest_filename=${4:-$3}
|
||||
|
||||
# use sshpass and scp for secure file transfer
|
||||
sshpass -p "$passwd" scp -o StrictHostKeyChecking=no -r "$host":"$source_filename" "$dest_filename"
|
||||
}
|
||||
|
||||
|
||||
# install docker and sshpass
|
||||
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
|
||||
sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce sshpass jq
|
||||
sudo systemctl enable docker
|
||||
sudo systemctl start docker
|
||||
|
||||
# create a log directory
|
||||
mkdir -p /var/lib/jenkins/workspace/log
|
||||
|
||||
# Assuming you have a file called 'file_list.txt' with one filename per line
|
||||
file_list="ci_deploy_dependency_file_list.txt"
|
||||
monitorip="192.168.1.59"
|
||||
passwd_all="abcdefg"
|
||||
|
||||
# Read the file list and call scp_file_from_host for each file
|
||||
while IFS= read -r source_filename; do
|
||||
scp_file_from_host "$monitorip" "$passwd_all" "$source_filename"
|
||||
done < "$file_list"
|
||||
|
||||
# modify the configuration file
|
||||
ip=$(ifconfig |grep inet|grep 192 |awk '{print $2}')
|
||||
sed -i "s/${monitorip}/$ip/" /home/log_server.json
|
||||
sed -i "s/${monitorip}/$ip/" /home/m.json
|
||||
|
||||
#mkdir corefile dir and configure the system to automatically set corefile dir at startup
|
||||
mkdir -p /home/coredump/ && echo "echo '/home/coredump/core_%e-%p' | sudo tee /proc/sys/kernel/core_pattern " >> /root/.bashrc
|
||||
|
||||
|
||||
# get image from 0.212
|
||||
image_ip="192.168.0.212"
|
||||
scp_file_from_host $image_ip $passwd_all "/home/tang/work/image/taos_image.tar " "/home/taos_image.tar"
|
||||
docker load -i /home/taos_image.tar
|
||||
|
||||
#start http server
|
||||
nohup /var/lib/jenkins/workspace/log/start_http.sh &
|
||||
|
||||
# start CI monitor and remove corefile in crontable
|
||||
(crontab -l;echo "0 1 * * * /usr/bin/bash /var/lib/jenkins/workspace/remove_corefile.sh") | crontab
|
||||
(crontab -l;echo "@reboot /usr/bin/bash /var/lib/jenkins/workspace/start_CI_Monitor.sh") | crontab
|
||||
|
||||
|
||||
# generate cache dir
|
||||
cd /var/lib/jenkins/workspace/TDinternal/community/tests/parallel_test || exit
|
||||
time ./container_build_newmachine.sh -w /var/lib/jenkins/workspace -e
|
||||
|
||||
# test if the CI machine compilation is successful
|
||||
time ./container_build.sh -w /var/lib/jenkins/workspace -e
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
date_str=$(date -d "4 day ago" +%Y%m%d)
|
||||
if [ ! -z "$1" ]; then
|
||||
date_str="$1"
|
||||
fi
|
||||
script_dir=$(dirname $0)
|
||||
cd "${script_dir}"/log || exit
|
||||
# date >>core.list
|
||||
# find . -name "core.*" | grep "$date_str" >>core.list
|
||||
# find . -name "core.*" | grep "$date_str" | xargs rm -rf
|
||||
# find . -name "build_*" | grep "$date_str" | xargs rm -rf
|
||||
for file in *; do
|
||||
if [[ $file == *"$date_str"* ]]; then
|
||||
rm -rf "$file"
|
||||
fi
|
||||
done
|
|
@ -0,0 +1,159 @@
|
|||
#!/bin/bash
|
||||
set -x
|
||||
JENKINS_LOG=jenkins.log
|
||||
# pr_num=14228
|
||||
# n=1
|
||||
function usage() {
|
||||
echo "$0"
|
||||
echo -e "\t -p PR number"
|
||||
echo -e "\t -n build number"
|
||||
echo -e "\t -c container name"
|
||||
echo -e "\t -h help"
|
||||
}
|
||||
while getopts "p:n:c:h" opt; do
|
||||
case $opt in
|
||||
p)
|
||||
pr_num=$OPTARG
|
||||
;;
|
||||
n)
|
||||
n=$OPTARG
|
||||
;;
|
||||
c)
|
||||
container_name=$OPTARG
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ -z "$container_name" ]; then
|
||||
echo "container name not specified"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$pr_num" ]; then
|
||||
echo "PR number not specified"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$n" ]; then
|
||||
echo "build number not specified"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
pr_num=`echo "$pr_num"|sed "s/PR-//"`
|
||||
container_count=`docker ps -a -f name=$container_name|wc -l`
|
||||
if [ $container_count -gt 1 ]; then
|
||||
docker ps -a -f name=$container_name
|
||||
echo "container $container_name exists"
|
||||
exit 1
|
||||
fi
|
||||
cd $(dirname $0)
|
||||
info=`grep -n "^[0-9]\{8\}-[0-9]\{6\}" jenkins.log | grep -A 1 "PR-${pr_num}:${n}:"`
|
||||
# 22131:20220625-113105 NewTest/PR-14228:PR-14228:1:3.0
|
||||
# 22270:20220625-121154 NewTest/PR-14221:PR-14221:2:3.0
|
||||
ci_hosts="\
|
||||
192.168.0.212 \
|
||||
192.168.0.215 \
|
||||
192.168.0.217 \
|
||||
192.168.0.219 \
|
||||
"
|
||||
if [ -z "$info" ]; then
|
||||
echo "PR-${pr_num}:${n} not found"
|
||||
for host in $ci_hosts; do
|
||||
ssh root@$host "sh -c \"grep -n \\\"^[0-9]\\\\\{8\\\\\}-[0-9]\\\\\{6\\\\\}\\\" /var/lib/jenkins/workspace/jenkins.log | grep \\\"PR-${pr_num}:${n}:\\\"\""
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "this PR is possibly on host $host"
|
||||
break
|
||||
fi
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
line_num=`echo "$info"|wc -l`
|
||||
curr=`echo "$info"|head -n1`
|
||||
if [ "$line_num" == "2" ]; then
|
||||
next=`echo "$info"|tail -n1`
|
||||
fi
|
||||
|
||||
# check if it is TDinternal CI
|
||||
internal=0
|
||||
commit_prefix=community
|
||||
echo "$curr"|grep -q TDinternalCI
|
||||
if [ $? -eq 0 ]; then
|
||||
internal=1
|
||||
commit_prefix=tdinternal
|
||||
fi
|
||||
|
||||
curr_line=`echo "$curr"|cut -d: -f1`
|
||||
next_line='$'
|
||||
if [ ! -z "$next" ]; then
|
||||
next_line=`echo "$next"|cut -d: -f1`
|
||||
next_line=$(( next_line - 1 ))
|
||||
fi
|
||||
# echo "$curr_line, $next_line"
|
||||
|
||||
details=`sed -n "${curr_line},${next_line}p" $JENKINS_LOG`
|
||||
merge_line=`echo "$details"|grep -A 10 "$commit_prefix log merged: "|grep "Merge .* into"|head -n1`
|
||||
if [ -z "$merge_line" ]; then
|
||||
echo "merge commit not found"
|
||||
exit 1
|
||||
fi
|
||||
echo "$merge_line"
|
||||
branch=`echo "$merge_line"|awk '{print $2}'`
|
||||
commit_id=`echo "$merge_line"|awk '{print $4}'`
|
||||
# echo "$details"
|
||||
community_id=`echo "$details"|grep "community log: commit"|awk '{print $NF}'`
|
||||
internal_id=`echo "$details"|grep "tdinternal log: commit"|awk '{print $NF}'`
|
||||
python_connector_id=`echo "$details"|grep "python connector log: commit"|awk '{print $NF}'`
|
||||
# change_branch=`echo "$details"|grep "CHANGE_BRANCH"|sed "s/CHANGE_BRANCH://"`
|
||||
|
||||
# if [ -z "${branch}" ]; then
|
||||
# branch="$change_branch"
|
||||
# fi
|
||||
|
||||
PWD=`pwd`
|
||||
log_dir=`ls log|grep "PR-${pr_num}_${n}_"`
|
||||
if [ -z "$log_dir" ]; then
|
||||
echo "no log dir found"
|
||||
else
|
||||
mount_dir="-v ${PWD}/log/$log_dir:/home/log"
|
||||
build_dir=`ls log/$log_dir | grep "build_"`
|
||||
if [ ! -z "$build_dir" ]; then
|
||||
mount_dir="$mount_dir -v ${PWD}/log/$log_dir/$build_dir:/home/TDinternal/debug/build"
|
||||
fi
|
||||
fi
|
||||
|
||||
docker run -d --privileged -it --name $container_name \
|
||||
$mount_dir \
|
||||
taos_test:v1.0 bash
|
||||
|
||||
if [ $internal -eq 0 ]; then
|
||||
docker exec $container_name /home/setup.sh -c $commit_id -m $branch -n
|
||||
echo "TDinternal checkout: $internal_id"
|
||||
docker exec $container_name sh -c "cd /home/TDinternal; git checkout $internal_id"
|
||||
else
|
||||
docker exec $container_name /home/setup.sh -e -c $commit_id -m $branch -n
|
||||
echo "community checkout: $community_id"
|
||||
docker exec $container_name sh -c "cd /home/TDinternal/community; git checkout $community_id"
|
||||
fi
|
||||
echo
|
||||
echo "* run the following command to enter the container:"
|
||||
echo " docker exec -it $container_name bash"
|
||||
if [ -z "$log_dir" ]; then
|
||||
echo "* no log dir found"
|
||||
else
|
||||
echo "* log and coredump files are located in /home/log"
|
||||
fi
|
||||
if [ -z "$build_dir" ]; then
|
||||
echo "* no build dir found"
|
||||
else
|
||||
echo "* build files are located in /home/TDinternal/debug/build"
|
||||
fi
|
||||
echo "* source files are located in /home/TDinternal"
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
script_dir=$(dirname $0)
|
||||
cd $script_dir || exit
|
||||
script_name=$(basename $0)
|
||||
ps -ef|grep -v grep|grep -v $$|grep -q "$script_name"
|
||||
if [ $? -eq 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
while [ 1 ]; do
|
||||
ps -ef|grep python|grep -q 8081
|
||||
if [ $? -ne 0 ]; then
|
||||
python3 -m http.server 8081
|
||||
fi
|
||||
sleep 60
|
||||
done
|
|
@ -61,14 +61,28 @@ docker run \
|
|||
-v /root/go/pkg/mod:/root/go/pkg/mod \
|
||||
-v /root/.cache/go-build:/root/.cache/go-build \
|
||||
-v /root/.cos-local.1:/root/.cos-local.2 \
|
||||
-v ${REP_REAL_PATH}/enterprise/src/plugins/taosx/target:${REP_DIR}/enterprise/src/plugins/taosx/target \
|
||||
-v ${REP_REAL_PATH}/community/tools/taosws-rs/target:${REP_DIR}/community/tools/taosws-rs/target \
|
||||
-v ${REP_REAL_PATH}/enterprise/contrib/grant-lib:${REP_DIR}/enterprise/contrib/grant-lib \
|
||||
-v ${REP_REAL_PATH}/community/tools/taosadapter:${REP_DIR}/community/tools/taosadapter \
|
||||
-v ${REP_REAL_PATH}/community/tools/taos-tools:${REP_DIR}/community/tools/taos-tools \
|
||||
-v ${REP_REAL_PATH}/community/tools/taosws-rs:${REP_DIR}/community/tools/taosws-rs \
|
||||
-v ${REP_REAL_PATH}/community/contrib/apr/:${REP_DIR}/community/contrib/apr \
|
||||
-v ${REP_REAL_PATH}/community/contrib/apr-util/:${REP_DIR}/community/contrib/apr-util \
|
||||
-v ${REP_REAL_PATH}/community/contrib/cJson/:${REP_DIR}/community/contrib/cJson \
|
||||
-v ${REP_REAL_PATH}/community/contrib/googletest/:${REP_DIR}/community/contrib/googletest \
|
||||
-v ${REP_REAL_PATH}/community/contrib/cpp-stub/:${REP_DIR}/community/contrib/cpp-stub \
|
||||
-v ${REP_REAL_PATH}/community/contrib/curl/:${REP_DIR}/community/contrib/curl \
|
||||
-v ${REP_REAL_PATH}/community/contrib/curl2/:${REP_DIR}/community/contrib/curl2 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/geos/:${REP_DIR}/community/contrib/geos \
|
||||
-v ${REP_REAL_PATH}/community/contrib/googletest/:${REP_DIR}/community/contrib/googletest \
|
||||
-v ${REP_REAL_PATH}/community/contrib/libs3/:${REP_DIR}/community/contrib/libs3 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/libuv/:${REP_DIR}/community/contrib/libuv \
|
||||
-v ${REP_REAL_PATH}/community/contrib/lz4/:${REP_DIR}/community/contrib/lz4 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/lzma2/:${REP_DIR}/community/contrib/lzma2 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/mxml/:${REP_DIR}/community/contrib/mxml \
|
||||
-v ${REP_REAL_PATH}/community/contrib/openssl/:${REP_DIR}/community/contrib/openssl \
|
||||
-v ${REP_REAL_PATH}/community/contrib/pcre2/:${REP_DIR}/community/contrib/pcre2 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/xml2/:${REP_DIR}/community/contrib/xml2 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/zlib/:${REP_DIR}/community/contrib/zlib \
|
||||
-v ${REP_REAL_PATH}/community/contrib/zstd/:${REP_DIR}/community/contrib/zstd \
|
||||
--rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_TAOSX=false -DJEMALLOC_ENABLED=0;make -j 10|| exit 1"
|
||||
# -v ${REP_REAL_PATH}/community/contrib/jemalloc/:${REP_DIR}/community/contrib/jemalloc \
|
||||
|
||||
|
@ -96,15 +110,29 @@ docker run \
|
|||
-v /root/go/pkg/mod:/root/go/pkg/mod \
|
||||
-v /root/.cache/go-build:/root/.cache/go-build \
|
||||
-v /root/.cos-local.1:/root/.cos-local.2 \
|
||||
-v ${REP_REAL_PATH}/enterprise/src/plugins/taosx/target:${REP_DIR}/enterprise/src/plugins/taosx/target \
|
||||
-v ${REP_REAL_PATH}/enterprise/contrib/grant-lib:${REP_DIR}/enterprise/contrib/grant-lib \
|
||||
-v ${REP_REAL_PATH}/community/tools/taosadapter:${REP_DIR}/community/tools/taosadapter \
|
||||
-v ${REP_REAL_PATH}/community/tools/taos-tools:${REP_DIR}/community/tools/taos-tools \
|
||||
-v ${REP_REAL_PATH}/community/tools/taosws-rs:${REP_DIR}/community/tools/taosws-rs \
|
||||
-v ${REP_REAL_PATH}/community/tools/taosws-rs/target:${REP_DIR}/community/tools/taosws-rs/target \
|
||||
-v ${REP_REAL_PATH}/community/contrib/apr/:${REP_DIR}/community/contrib/apr \
|
||||
-v ${REP_REAL_PATH}/community/contrib/apr-util/:${REP_DIR}/community/contrib/apr-util \
|
||||
-v ${REP_REAL_PATH}/community/contrib/cJson/:${REP_DIR}/community/contrib/cJson \
|
||||
-v ${REP_REAL_PATH}/community/contrib/googletest/:${REP_DIR}/community/contrib/googletest \
|
||||
-v ${REP_REAL_PATH}/community/contrib/cpp-stub/:${REP_DIR}/community/contrib/cpp-stub \
|
||||
-v ${REP_REAL_PATH}/community/contrib/curl/:${REP_DIR}/community/contrib/curl \
|
||||
-v ${REP_REAL_PATH}/community/contrib/curl2/:${REP_DIR}/community/contrib/curl2 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/geos/:${REP_DIR}/community/contrib/geos \
|
||||
-v ${REP_REAL_PATH}/community/contrib/googletest/:${REP_DIR}/community/contrib/googletest \
|
||||
-v ${REP_REAL_PATH}/community/contrib/libs3/:${REP_DIR}/community/contrib/libs3 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/libuv/:${REP_DIR}/community/contrib/libuv \
|
||||
-v ${REP_REAL_PATH}/community/contrib/lz4/:${REP_DIR}/community/contrib/lz4 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/lzma2/:${REP_DIR}/community/contrib/lzma2 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/mxml/:${REP_DIR}/community/contrib/mxml \
|
||||
-v ${REP_REAL_PATH}/community/contrib/openssl/:${REP_DIR}/community/contrib/openssl \
|
||||
-v ${REP_REAL_PATH}/community/contrib/pcre2/:${REP_DIR}/community/contrib/pcre2 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/xml2/:${REP_DIR}/community/contrib/xml2 \
|
||||
-v ${REP_REAL_PATH}/community/contrib/zlib/:${REP_DIR}/community/contrib/zlib \
|
||||
-v ${REP_REAL_PATH}/community/contrib/jemalloc/:${REP_DIR}/community/contrib/jemalloc \
|
||||
-v ${REP_REAL_PATH}/community/contrib/zstd/:${REP_DIR}/community/contrib/zstd \
|
||||
--rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=false -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true $CMAKE_BUILD_TYPE -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=false -DJEMALLOC_ENABLED=0;make -j 10|| exit 1 "
|
||||
|
||||
mv ${REP_REAL_PATH}/debug ${WORKDIR}/debugSan
|
||||
|
|
|
@ -93,9 +93,8 @@ class TDTestCase:
|
|||
tdSql.execute("create stream stream2 fill_history 1 into stb subtable(concat('new-', tname)) AS SELECT "
|
||||
"_wstart, count(*), avg(i) FROM st PARTITION BY tbname tname INTERVAL(1m)", show=True)
|
||||
|
||||
time.sleep(2)
|
||||
tdSql.query("select * from sta")
|
||||
tdSql.checkRows(3)
|
||||
sql= "select * from sta"
|
||||
tdSql.check_rows_loop(3, sql, loopCount=100, waitTime=0.5)
|
||||
tdSql.query("select tbname from sta order by tbname")
|
||||
if not tdSql.getData(0, 0).startswith('nee_w-t1_sta_'):
|
||||
tdLog.exit("error1")
|
||||
|
@ -106,8 +105,8 @@ class TDTestCase:
|
|||
if not tdSql.getData(2, 0).startswith('nee_w-t3_sta_'):
|
||||
tdLog.exit("error3")
|
||||
|
||||
tdSql.query("select * from stb")
|
||||
tdSql.checkRows(3)
|
||||
sql= "select * from stb"
|
||||
tdSql.check_rows_loop(3, sql, loopCount=100, waitTime=0.5)
|
||||
tdSql.query("select tbname from stb order by tbname")
|
||||
if not tdSql.getData(0, 0).startswith('new-t1_stb_'):
|
||||
tdLog.exit("error4")
|
||||
|
|
Loading…
Reference in New Issue