Merge branch '3.0' into feature/3.0_glzhao
This commit is contained in:
commit
db87cabd15
|
@ -113,6 +113,20 @@ static FORCE_INLINE void colDataAppendNULL(SColumnInfoData* pColumnInfoData, uin
|
||||||
pColumnInfoData->hasNull = true;
|
pColumnInfoData->hasNull = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void colDataAppendNNULL(SColumnInfoData* pColumnInfoData, uint32_t start, size_t nRows) {
|
||||||
|
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||||
|
for(int32_t i = start; i < start + nRows; ++i) {
|
||||||
|
pColumnInfoData->varmeta.offset[i] = -1; // it is a null value of VAR type.
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(int32_t i = start; i < start + nRows; ++i) {
|
||||||
|
colDataSetNull_f(pColumnInfoData->nullbitmap, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pColumnInfoData->hasNull = true;
|
||||||
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t colDataAppendInt8(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int8_t* v) {
|
static FORCE_INLINE int32_t colDataAppendInt8(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int8_t* v) {
|
||||||
ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_TINYINT ||
|
ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_TINYINT ||
|
||||||
pColumnInfoData->info.type == TSDB_DATA_TYPE_UTINYINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_BOOL);
|
pColumnInfoData->info.type == TSDB_DATA_TYPE_UTINYINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_BOOL);
|
||||||
|
|
|
@ -1395,11 +1395,10 @@ typedef struct {
|
||||||
} SDDropTopicReq;
|
} SDDropTopicReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float xFilesFactor;
|
float xFilesFactor;
|
||||||
int8_t delayUnit;
|
int32_t delay;
|
||||||
int8_t nFuncIds;
|
int8_t nFuncIds;
|
||||||
int32_t* pFuncIds;
|
func_id_t* pFuncIds;
|
||||||
int64_t delay;
|
|
||||||
} SRSmaParam;
|
} SRSmaParam;
|
||||||
|
|
||||||
typedef struct SVCreateTbReq {
|
typedef struct SVCreateTbReq {
|
||||||
|
|
|
@ -50,7 +50,6 @@ typedef struct {
|
||||||
PutToQueueFp queueFps[QUEUE_MAX];
|
PutToQueueFp queueFps[QUEUE_MAX];
|
||||||
GetQueueSizeFp qsizeFp;
|
GetQueueSizeFp qsizeFp;
|
||||||
SendReqFp sendReqFp;
|
SendReqFp sendReqFp;
|
||||||
SendMnodeReqFp sendMnodeReqFp;
|
|
||||||
SendRspFp sendRspFp;
|
SendRspFp sendRspFp;
|
||||||
RegisterBrokenLinkArgFp registerBrokenLinkArgFp;
|
RegisterBrokenLinkArgFp registerBrokenLinkArgFp;
|
||||||
ReleaseHandleFp releaseHandleFp;
|
ReleaseHandleFp releaseHandleFp;
|
||||||
|
@ -60,7 +59,6 @@ void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb);
|
||||||
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pReq);
|
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pReq);
|
||||||
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype);
|
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype);
|
||||||
int32_t tmsgSendReq(const SMsgCb* pMsgCb, const SEpSet* epSet, SRpcMsg* pReq);
|
int32_t tmsgSendReq(const SMsgCb* pMsgCb, const SEpSet* epSet, SRpcMsg* pReq);
|
||||||
int32_t tmsgSendMnodeReq(const SMsgCb* pMsgCb, SRpcMsg* pReq);
|
|
||||||
void tmsgSendRsp(const SRpcMsg* pRsp);
|
void tmsgSendRsp(const SRpcMsg* pRsp);
|
||||||
void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg);
|
void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg);
|
||||||
void tmsgReleaseHandle(void* handle, int8_t type);
|
void tmsgReleaseHandle(void* handle, int8_t type);
|
||||||
|
|
|
@ -172,7 +172,7 @@
|
||||||
#define TK_SYNCDB 154
|
#define TK_SYNCDB 154
|
||||||
#define TK_NULL 155
|
#define TK_NULL 155
|
||||||
#define TK_NK_VARIABLE 156
|
#define TK_NK_VARIABLE 156
|
||||||
#define TK_NK_UNDERLINE 157
|
#define TK_NOW 157
|
||||||
#define TK_ROWTS 158
|
#define TK_ROWTS 158
|
||||||
#define TK_TBNAME 159
|
#define TK_TBNAME 159
|
||||||
#define TK_QSTARTTS 160
|
#define TK_QSTARTTS 160
|
||||||
|
@ -229,7 +229,6 @@
|
||||||
#define TK_NK_COLON 500
|
#define TK_NK_COLON 500
|
||||||
#define TK_NK_BITNOT 501
|
#define TK_NK_BITNOT 501
|
||||||
#define TK_INSERT 502
|
#define TK_INSERT 502
|
||||||
#define TK_NOW 504
|
|
||||||
#define TK_VALUES 507
|
#define TK_VALUES 507
|
||||||
#define TK_IMPORT 509
|
#define TK_IMPORT 509
|
||||||
#define TK_NK_SEMI 508
|
#define TK_NK_SEMI 508
|
||||||
|
|
|
@ -31,6 +31,7 @@ typedef int16_t col_id_t;
|
||||||
typedef int8_t col_type_t;
|
typedef int8_t col_type_t;
|
||||||
typedef int32_t col_bytes_t;
|
typedef int32_t col_bytes_t;
|
||||||
typedef uint16_t schema_ver_t;
|
typedef uint16_t schema_ver_t;
|
||||||
|
typedef int32_t func_id_t;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -29,8 +29,7 @@ extern "C" {
|
||||||
typedef struct SMnode SMnode;
|
typedef struct SMnode SMnode;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
bool deploy;
|
||||||
int64_t clusterId;
|
|
||||||
int8_t replica;
|
int8_t replica;
|
||||||
int8_t selfIndex;
|
int8_t selfIndex;
|
||||||
SReplica replicas[TSDB_MAX_REPLICA];
|
SReplica replicas[TSDB_MAX_REPLICA];
|
||||||
|
|
|
@ -306,6 +306,7 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNod
|
||||||
|
|
||||||
bool nodesIsExprNode(const SNode* pNode);
|
bool nodesIsExprNode(const SNode* pNode);
|
||||||
|
|
||||||
|
bool nodesIsUnaryOp(const SOperatorNode* pOp);
|
||||||
bool nodesIsArithmeticOp(const SOperatorNode* pOp);
|
bool nodesIsArithmeticOp(const SOperatorNode* pOp);
|
||||||
bool nodesIsComparisonOp(const SOperatorNode* pOp);
|
bool nodesIsComparisonOp(const SOperatorNode* pOp);
|
||||||
bool nodesIsJsonOp(const SOperatorNode* pOp);
|
bool nodesIsJsonOp(const SOperatorNode* pOp);
|
||||||
|
|
|
@ -26,7 +26,7 @@ typedef struct {
|
||||||
void* ptr;
|
void* ptr;
|
||||||
} SShm;
|
} SShm;
|
||||||
|
|
||||||
int32_t taosCreateShm(SShm *pShm, int32_t shmsize) ;
|
int32_t taosCreateShm(SShm *pShm, int32_t key, int32_t shmsize) ;
|
||||||
void taosDropShm(SShm *pShm);
|
void taosDropShm(SShm *pShm);
|
||||||
int32_t taosAttachShm(SShm *pShm);
|
int32_t taosAttachShm(SShm *pShm);
|
||||||
|
|
||||||
|
|
|
@ -128,18 +128,20 @@ extern const int32_t TYPE_BYTES[15];
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
typedef enum EOperatorType {
|
typedef enum EOperatorType {
|
||||||
// arithmetic operator
|
// binary arithmetic operator
|
||||||
OP_TYPE_ADD = 1,
|
OP_TYPE_ADD = 1,
|
||||||
OP_TYPE_SUB,
|
OP_TYPE_SUB,
|
||||||
OP_TYPE_MULTI,
|
OP_TYPE_MULTI,
|
||||||
OP_TYPE_DIV,
|
OP_TYPE_DIV,
|
||||||
OP_TYPE_MOD,
|
OP_TYPE_MOD,
|
||||||
|
// unary arithmetic operator
|
||||||
|
OP_TYPE_MINUS,
|
||||||
|
|
||||||
// bit operator
|
// bit operator
|
||||||
OP_TYPE_BIT_AND,
|
OP_TYPE_BIT_AND,
|
||||||
OP_TYPE_BIT_OR,
|
OP_TYPE_BIT_OR,
|
||||||
|
|
||||||
// comparison operator
|
// binary comparison operator
|
||||||
OP_TYPE_GREATER_THAN,
|
OP_TYPE_GREATER_THAN,
|
||||||
OP_TYPE_GREATER_EQUAL,
|
OP_TYPE_GREATER_EQUAL,
|
||||||
OP_TYPE_LOWER_THAN,
|
OP_TYPE_LOWER_THAN,
|
||||||
|
@ -152,6 +154,7 @@ typedef enum EOperatorType {
|
||||||
OP_TYPE_NOT_LIKE,
|
OP_TYPE_NOT_LIKE,
|
||||||
OP_TYPE_MATCH,
|
OP_TYPE_MATCH,
|
||||||
OP_TYPE_NMATCH,
|
OP_TYPE_NMATCH,
|
||||||
|
// unary comparison operator
|
||||||
OP_TYPE_IS_NULL,
|
OP_TYPE_IS_NULL,
|
||||||
OP_TYPE_IS_NOT_NULL,
|
OP_TYPE_IS_NOT_NULL,
|
||||||
OP_TYPE_IS_TRUE,
|
OP_TYPE_IS_TRUE,
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum { PROC_REQ, PROC_RSP, PROC_REG, PROC_RELEASE } ProcFuncType;
|
typedef enum { PROC_QUEUE, PROC_REQ, PROC_RSP, PROC_REGIST, PROC_RELEASE } ProcFuncType;
|
||||||
|
|
||||||
typedef struct SProcQueue SProcQueue;
|
typedef struct SProcQueue SProcQueue;
|
||||||
typedef struct SProcObj SProcObj;
|
typedef struct SProcObj SProcObj;
|
||||||
|
@ -53,7 +53,7 @@ void taosProcCleanup(SProcObj *pProc);
|
||||||
int32_t taosProcRun(SProcObj *pProc);
|
int32_t taosProcRun(SProcObj *pProc);
|
||||||
int32_t taosProcPutToChildQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
int32_t taosProcPutToChildQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
||||||
ProcFuncType ftype);
|
ProcFuncType ftype);
|
||||||
int32_t taosProcPutToParentQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
void taosProcPutToParentQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
||||||
ProcFuncType ftype);
|
ProcFuncType ftype);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -753,6 +753,7 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
||||||
pStart += colLength[i];
|
pStart += colLength[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert UCS4-LE encoded character to native multi-bytes character in current data block.
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
int32_t type = pResultInfo->fields[i].type;
|
int32_t type = pResultInfo->fields[i].type;
|
||||||
int32_t bytes = pResultInfo->fields[i].bytes;
|
int32_t bytes = pResultInfo->fields[i].bytes;
|
||||||
|
@ -779,6 +780,7 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
||||||
}
|
}
|
||||||
|
|
||||||
pResultInfo->pCol[i].pData = pResultInfo->convertBuf[i];
|
pResultInfo->pCol[i].pData = pResultInfo->convertBuf[i];
|
||||||
|
pResultInfo->row[i] = pResultInfo->pCol[i].pData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -314,13 +314,12 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
|
||||||
}
|
}
|
||||||
if (pReq->rollup && pReq->stbCfg.pRSmaParam) {
|
if (pReq->rollup && pReq->stbCfg.pRSmaParam) {
|
||||||
SRSmaParam *param = pReq->stbCfg.pRSmaParam;
|
SRSmaParam *param = pReq->stbCfg.pRSmaParam;
|
||||||
tlen += taosEncodeFixedU32(buf, (uint32_t)param->xFilesFactor);
|
tlen += taosEncodeBinary(buf, (const void *)¶m->xFilesFactor, sizeof(param->xFilesFactor));
|
||||||
tlen += taosEncodeFixedI8(buf, param->delayUnit);
|
tlen += taosEncodeFixedI32(buf, param->delay);
|
||||||
tlen += taosEncodeFixedI8(buf, param->nFuncIds);
|
tlen += taosEncodeFixedI8(buf, param->nFuncIds);
|
||||||
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
||||||
tlen += taosEncodeFixedI32(buf, param->pFuncIds[i]);
|
tlen += taosEncodeFixedI32(buf, param->pFuncIds[i]);
|
||||||
}
|
}
|
||||||
tlen += taosEncodeFixedI64(buf, param->delay);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TD_CHILD_TABLE:
|
case TD_CHILD_TABLE:
|
||||||
|
@ -339,13 +338,12 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
|
||||||
}
|
}
|
||||||
if (pReq->rollup && pReq->ntbCfg.pRSmaParam) {
|
if (pReq->rollup && pReq->ntbCfg.pRSmaParam) {
|
||||||
SRSmaParam *param = pReq->ntbCfg.pRSmaParam;
|
SRSmaParam *param = pReq->ntbCfg.pRSmaParam;
|
||||||
tlen += taosEncodeFixedU32(buf, (uint32_t)param->xFilesFactor);
|
tlen += taosEncodeBinary(buf, (const void *)¶m->xFilesFactor, sizeof(param->xFilesFactor));
|
||||||
tlen += taosEncodeFixedI8(buf, param->delayUnit);
|
tlen += taosEncodeFixedI32(buf, param->delay);
|
||||||
tlen += taosEncodeFixedI8(buf, param->nFuncIds);
|
tlen += taosEncodeFixedI8(buf, param->nFuncIds);
|
||||||
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
||||||
tlen += taosEncodeFixedI32(buf, param->pFuncIds[i]);
|
tlen += taosEncodeFixedI32(buf, param->pFuncIds[i]);
|
||||||
}
|
}
|
||||||
tlen += taosEncodeFixedI64(buf, param->delay);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -387,17 +385,17 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
||||||
if (pReq->rollup) {
|
if (pReq->rollup) {
|
||||||
pReq->stbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam));
|
pReq->stbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam));
|
||||||
SRSmaParam *param = pReq->stbCfg.pRSmaParam;
|
SRSmaParam *param = pReq->stbCfg.pRSmaParam;
|
||||||
buf = taosDecodeFixedU32(buf, (uint32_t *)¶m->xFilesFactor);
|
buf = taosDecodeBinaryTo(buf, (void*)¶m->xFilesFactor, sizeof(param->xFilesFactor));
|
||||||
buf = taosDecodeFixedI8(buf, ¶m->delayUnit);
|
buf = taosDecodeFixedI32(buf, ¶m->delay);
|
||||||
buf = taosDecodeFixedI8(buf, ¶m->nFuncIds);
|
buf = taosDecodeFixedI8(buf, ¶m->nFuncIds);
|
||||||
if (param->nFuncIds > 0) {
|
if (param->nFuncIds > 0) {
|
||||||
|
param->pFuncIds = (func_id_t *)taosMemoryMalloc(param->nFuncIds * sizeof(func_id_t));
|
||||||
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
||||||
buf = taosDecodeFixedI32(buf, param->pFuncIds + i);
|
buf = taosDecodeFixedI32(buf, param->pFuncIds + i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
param->pFuncIds = NULL;
|
param->pFuncIds = NULL;
|
||||||
}
|
}
|
||||||
buf = taosDecodeFixedI64(buf, ¶m->delay);
|
|
||||||
} else {
|
} else {
|
||||||
pReq->stbCfg.pRSmaParam = NULL;
|
pReq->stbCfg.pRSmaParam = NULL;
|
||||||
}
|
}
|
||||||
|
@ -420,17 +418,17 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
||||||
if (pReq->rollup) {
|
if (pReq->rollup) {
|
||||||
pReq->ntbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam));
|
pReq->ntbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam));
|
||||||
SRSmaParam *param = pReq->ntbCfg.pRSmaParam;
|
SRSmaParam *param = pReq->ntbCfg.pRSmaParam;
|
||||||
buf = taosDecodeFixedU32(buf, (uint32_t *)¶m->xFilesFactor);
|
buf = taosDecodeBinaryTo(buf, (void*)¶m->xFilesFactor, sizeof(param->xFilesFactor));
|
||||||
buf = taosDecodeFixedI8(buf, ¶m->delayUnit);
|
buf = taosDecodeFixedI32(buf, ¶m->delay);
|
||||||
buf = taosDecodeFixedI8(buf, ¶m->nFuncIds);
|
buf = taosDecodeFixedI8(buf, ¶m->nFuncIds);
|
||||||
if (param->nFuncIds > 0) {
|
if (param->nFuncIds > 0) {
|
||||||
|
param->pFuncIds = (func_id_t *)taosMemoryMalloc(param->nFuncIds * sizeof(func_id_t));
|
||||||
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
||||||
buf = taosDecodeFixedI32(buf, param->pFuncIds + i);
|
buf = taosDecodeFixedI32(buf, param->pFuncIds + i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
param->pFuncIds = NULL;
|
param->pFuncIds = NULL;
|
||||||
}
|
}
|
||||||
buf = taosDecodeFixedI64(buf, ¶m->delay);
|
|
||||||
} else {
|
} else {
|
||||||
pReq->ntbCfg.pRSmaParam = NULL;
|
pReq->ntbCfg.pRSmaParam = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,6 @@ int32_t tmsgSendReq(const SMsgCb* pMsgCb, const SEpSet* epSet, SRpcMsg* pReq) {
|
||||||
return (*pMsgCb->sendReqFp)(pMsgCb->pWrapper, epSet, pReq);
|
return (*pMsgCb->sendReqFp)(pMsgCb->pWrapper, epSet, pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tmsgSendMnodeReq(const SMsgCb* pMsgCb, SRpcMsg* pReq) {
|
|
||||||
return (*pMsgCb->sendMnodeReqFp)(pMsgCb->pWrapper, pReq);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tmsgSendRsp(const SRpcMsg* pRsp) { return (*tsDefaultMsgCb.sendRspFp)(tsDefaultMsgCb.pWrapper, pRsp); }
|
void tmsgSendRsp(const SRpcMsg* pRsp) { return (*tsDefaultMsgCb.sendRspFp)(tsDefaultMsgCb.pWrapper, pRsp); }
|
||||||
|
|
||||||
void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg) {
|
void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg) {
|
||||||
|
|
|
@ -19,12 +19,7 @@
|
||||||
static int32_t bmRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
|
static int32_t bmRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
|
||||||
|
|
||||||
static void bmInitOption(SBnodeMgmt *pMgmt, SBnodeOpt *pOption) {
|
static void bmInitOption(SBnodeMgmt *pMgmt, SBnodeOpt *pOption) {
|
||||||
SMsgCb msgCb = {0};
|
SMsgCb msgCb = dndCreateMsgcb(pMgmt->pWrapper);
|
||||||
msgCb.pWrapper = pMgmt->pWrapper;
|
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
|
||||||
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
|
||||||
pOption->msgCb = msgCb;
|
pOption->msgCb = msgCb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ static struct {
|
||||||
} global = {0};
|
} global = {0};
|
||||||
|
|
||||||
static void dndStopDnode(int signum, void *info, void *ctx) {
|
static void dndStopDnode(int signum, void *info, void *ctx) {
|
||||||
dInfo("system signal:%d received", signum);
|
|
||||||
SDnode *pDnode = atomic_val_compare_exchange_ptr(&global.pDnode, 0, global.pDnode);
|
SDnode *pDnode = atomic_val_compare_exchange_ptr(&global.pDnode, 0, global.pDnode);
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
dndHandleEvent(pDnode, DND_EVENT_STOP);
|
dndHandleEvent(pDnode, DND_EVENT_STOP);
|
||||||
|
@ -41,8 +40,10 @@ static void dndSetSignalHandle() {
|
||||||
taosSetSignal(SIGTERM, dndStopDnode);
|
taosSetSignal(SIGTERM, dndStopDnode);
|
||||||
taosSetSignal(SIGHUP, dndStopDnode);
|
taosSetSignal(SIGHUP, dndStopDnode);
|
||||||
taosSetSignal(SIGINT, dndStopDnode);
|
taosSetSignal(SIGINT, dndStopDnode);
|
||||||
|
taosSetSignal(SIGTSTP, dndStopDnode);
|
||||||
taosSetSignal(SIGABRT, dndStopDnode);
|
taosSetSignal(SIGABRT, dndStopDnode);
|
||||||
taosSetSignal(SIGBREAK, dndStopDnode);
|
taosSetSignal(SIGBREAK, dndStopDnode);
|
||||||
|
taosSetSignal(SIGQUIT, dndStopDnode);
|
||||||
|
|
||||||
if (!tsMultiProcess) {
|
if (!tsMultiProcess) {
|
||||||
} else if (global.ntype == DNODE || global.ntype == NODE_MAX) {
|
} else if (global.ntype == DNODE || global.ntype == NODE_MAX) {
|
||||||
|
@ -72,7 +73,7 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
|
||||||
} else if (strcmp(argv[i], "-n") == 0) {
|
} else if (strcmp(argv[i], "-n") == 0) {
|
||||||
global.ntype = atoi(argv[++i]);
|
global.ntype = atoi(argv[++i]);
|
||||||
if (global.ntype <= DNODE || global.ntype > NODE_MAX) {
|
if (global.ntype <= DNODE || global.ntype > NODE_MAX) {
|
||||||
printf("'-n' range is [1-5], default is 0\n");
|
printf("'-n' range is [1 - %d], default is 0\n", NODE_MAX - 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-k") == 0) {
|
} else if (strcmp(argv[i], "-k") == 0) {
|
||||||
|
|
|
@ -149,7 +149,7 @@ int32_t dndInitClient(SDnode *pDnode);
|
||||||
void dndCleanupClient(SDnode *pDnode);
|
void dndCleanupClient(SDnode *pDnode);
|
||||||
int32_t dndProcessNodeMsg(SDnode *pDnode, SNodeMsg *pMsg);
|
int32_t dndProcessNodeMsg(SDnode *pDnode, SNodeMsg *pMsg);
|
||||||
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||||
int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pMsg);
|
int32_t dndSendReq(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pMsg);
|
||||||
void dndSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp);
|
void dndSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp);
|
||||||
void dndRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
void dndRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||||
SMsgCb dndCreateMsgcb(SMgmtWrapper *pWrapper);
|
SMsgCb dndCreateMsgcb(SMgmtWrapper *pWrapper);
|
||||||
|
|
|
@ -45,7 +45,7 @@ int32_t dndOpenNode(SMgmtWrapper *pWrapper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndCloseNode(SMgmtWrapper *pWrapper) {
|
void dndCloseNode(SMgmtWrapper *pWrapper) {
|
||||||
dDebug("node:%s, start to close", pWrapper->name);
|
dDebug("node:%s, mgmt start to close", pWrapper->name);
|
||||||
pWrapper->required = false;
|
pWrapper->required = false;
|
||||||
taosWLockLatch(&pWrapper->latch);
|
taosWLockLatch(&pWrapper->latch);
|
||||||
if (pWrapper->deployed) {
|
if (pWrapper->deployed) {
|
||||||
|
@ -62,7 +62,7 @@ void dndCloseNode(SMgmtWrapper *pWrapper) {
|
||||||
taosProcCleanup(pWrapper->pProc);
|
taosProcCleanup(pWrapper->pProc);
|
||||||
pWrapper->pProc = NULL;
|
pWrapper->pProc = NULL;
|
||||||
}
|
}
|
||||||
dDebug("node:%s, has been closed", pWrapper->name);
|
dDebug("node:%s, mgmt has been closed", pWrapper->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
||||||
|
@ -90,10 +90,10 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t
|
||||||
static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
||||||
ProcFuncType ftype) {
|
ProcFuncType ftype) {
|
||||||
pMsg->pCont = pCont;
|
pMsg->pCont = pCont;
|
||||||
dTrace("msg:%p, get from parent queue, handle:%p app:%p", pMsg, pMsg->handle, pMsg->ahandle);
|
dTrace("msg:%p, get from parent queue, ftype:%d handle:%p, app:%p", pMsg, ftype, pMsg->handle, pMsg->ahandle);
|
||||||
|
|
||||||
switch (ftype) {
|
switch (ftype) {
|
||||||
case PROC_REG:
|
case PROC_REGIST:
|
||||||
rpcRegisterBrokenLinkArg(pMsg);
|
rpcRegisterBrokenLinkArg(pMsg);
|
||||||
break;
|
break;
|
||||||
case PROC_RELEASE:
|
case PROC_RELEASE:
|
||||||
|
@ -101,11 +101,14 @@ static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t
|
||||||
rpcFreeCont(pCont);
|
rpcFreeCont(pCont);
|
||||||
break;
|
break;
|
||||||
case PROC_REQ:
|
case PROC_REQ:
|
||||||
// todo send to dnode
|
|
||||||
dndSendReqToMnode(pWrapper, pMsg);
|
dndSendReqToMnode(pWrapper, pMsg);
|
||||||
default:
|
// dndSendReq(pWrapper, (const SEpSet *)((char *)pMsg + sizeof(SRpcMsg)), pMsg);
|
||||||
|
break;
|
||||||
|
case PROC_RSP:
|
||||||
dndSendRpcRsp(pWrapper, pMsg);
|
dndSendRpcRsp(pWrapper, pMsg);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
taosMemoryFree(pMsg);
|
taosMemoryFree(pMsg);
|
||||||
}
|
}
|
||||||
|
@ -180,6 +183,7 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pDnode->event == DND_EVENT_STOP) {
|
if (pDnode->event == DND_EVENT_STOP) {
|
||||||
dInfo("dnode is about to stop");
|
dInfo("dnode is about to stop");
|
||||||
|
dndSetStatus(pDnode, DND_STAT_STOPPED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
taosMsleep(100);
|
taosMsleep(100);
|
||||||
|
@ -202,7 +206,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
if (!pWrapper->required) continue;
|
if (!pWrapper->required) continue;
|
||||||
|
|
||||||
int32_t shmsize = 1024 * 1024 * 2; // size will be a configuration item
|
int32_t shmsize = 1024 * 1024 * 2; // size will be a configuration item
|
||||||
if (taosCreateShm(&pWrapper->shm, shmsize) != 0) {
|
if (taosCreateShm(&pWrapper->shm, n, shmsize) != 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(terrno);
|
terrno = TAOS_SYSTEM_ERROR(terrno);
|
||||||
dError("node:%s, failed to create shm size:%d since %s", pWrapper->name, shmsize, terrstr());
|
dError("node:%s, failed to create shm size:%d since %s", pWrapper->name, shmsize, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -255,6 +259,8 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pDnode->event == DND_EVENT_STOP) {
|
if (pDnode->event == DND_EVENT_STOP) {
|
||||||
dInfo("dnode is about to stop");
|
dInfo("dnode is about to stop");
|
||||||
|
dndSetStatus(pDnode, DND_STAT_STOPPED);
|
||||||
|
|
||||||
for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) {
|
for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
if (!pWrapper->required) continue;
|
if (!pWrapper->required) continue;
|
||||||
|
@ -263,15 +269,6 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) {
|
if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) {
|
||||||
dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pWrapper->procId);
|
dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pWrapper->procId);
|
||||||
taosKillProc(pWrapper->procId);
|
taosKillProc(pWrapper->procId);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) {
|
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
|
||||||
if (!pWrapper->required) continue;
|
|
||||||
if (pDnode->ntype == NODE_MAX) continue;
|
|
||||||
|
|
||||||
if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) {
|
|
||||||
dInfo("node:%s, wait for child process:%d to stop", pWrapper->name, pWrapper->procId);
|
dInfo("node:%s, wait for child process:%d to stop", pWrapper->name, pWrapper->procId);
|
||||||
taosWaitProc(pWrapper->procId);
|
taosWaitProc(pWrapper->procId);
|
||||||
dInfo("node:%s, child process:%d is stopped", pWrapper->name, pWrapper->procId);
|
dInfo("node:%s, child process:%d is stopped", pWrapper->name, pWrapper->procId);
|
||||||
|
@ -331,6 +328,8 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dndSetStatus(pDnode, DND_STAT_RUNNING);
|
||||||
|
|
||||||
if (taosProcRun(pWrapper->pProc) != 0) {
|
if (taosProcRun(pWrapper->pProc) != 0) {
|
||||||
dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr());
|
dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -340,11 +339,14 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) {
|
||||||
dndReportStartup(pDnode, "TDengine", "initialized successfully");
|
dndReportStartup(pDnode, "TDengine", "initialized successfully");
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pDnode->event == DND_EVENT_STOP) {
|
if (pDnode->event == DND_EVENT_STOP) {
|
||||||
dInfo("dnode is about to stop");
|
dInfo("%s is about to stop", pWrapper->name);
|
||||||
|
dndSetStatus(pDnode, DND_STAT_STOPPED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
taosMsleep(100);
|
taosMsleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndRun(SDnode *pDnode) {
|
int32_t dndRun(SDnode *pDnode) {
|
||||||
|
|
|
@ -133,14 +133,6 @@ _OVER:
|
||||||
void dndClose(SDnode *pDnode) {
|
void dndClose(SDnode *pDnode) {
|
||||||
if (pDnode == NULL) return;
|
if (pDnode == NULL) return;
|
||||||
|
|
||||||
if (dndGetStatus(pDnode) == DND_STAT_STOPPED) {
|
|
||||||
dError("dnode is shutting down, data:%p", pDnode);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dInfo("start to close dnode, data:%p", pDnode);
|
|
||||||
dndSetStatus(pDnode, DND_STAT_STOPPED);
|
|
||||||
|
|
||||||
for (ENodeType n = 0; n < NODE_MAX; ++n) {
|
for (ENodeType n = 0; n < NODE_MAX; ++n) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
dndCloseNode(pWrapper);
|
dndCloseNode(pWrapper);
|
||||||
|
@ -151,7 +143,6 @@ void dndClose(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndHandleEvent(SDnode *pDnode, EDndEvent event) {
|
void dndHandleEvent(SDnode *pDnode, EDndEvent event) {
|
||||||
dInfo("dnode receive %s event, data:%p", dndEventStr(event), pDnode);
|
|
||||||
if (event == DND_EVENT_STOP) {
|
if (event == DND_EVENT_STOP) {
|
||||||
pDnode->event = event;
|
pDnode->event = event;
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,22 +319,6 @@ static int32_t dndSendRpcReq(STransMgmt *pMgmt, const SEpSet *pEpSet, SRpcMsg *p
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pReq) {
|
|
||||||
if (pWrapper->procType != PROC_CHILD) {
|
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
|
||||||
if (dndGetStatus(pDnode) != DND_STAT_RUNNING) {
|
|
||||||
terrno = TSDB_CODE_DND_OFFLINE;
|
|
||||||
dError("failed to send rpc msg since %s, handle:%p", terrstr(), pReq->handle);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return dndSendRpcReq(&pDnode->trans, pEpSet, pReq);
|
|
||||||
} else {
|
|
||||||
while (taosProcPutToParentQ(pWrapper->pProc, pReq, sizeof(SRpcMsg), pReq->pCont, pReq->contLen, PROC_REQ) != 0) {
|
|
||||||
taosMsleep(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
|
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
STransMgmt *pTrans = &pDnode->trans;
|
STransMgmt *pTrans = &pDnode->trans;
|
||||||
|
@ -362,13 +346,37 @@ void dndSendRpcRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t dndSendReq(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pReq) {
|
||||||
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
|
if (dndGetStatus(pDnode) != DND_STAT_RUNNING) {
|
||||||
|
terrno = TSDB_CODE_DND_OFFLINE;
|
||||||
|
dError("failed to send rpc msg since %s, handle:%p", terrstr(), pReq->handle);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pWrapper->procType != PROC_CHILD) {
|
||||||
|
return dndSendRpcReq(&pDnode->trans, pEpSet, pReq);
|
||||||
|
} else {
|
||||||
|
int32_t headLen = sizeof(SRpcMsg) + sizeof(SEpSet);
|
||||||
|
char *pHead = taosMemoryMalloc(headLen);
|
||||||
|
if (pHead == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memcpy(pHead, pReq, sizeof(SRpcMsg));
|
||||||
|
memcpy(pHead + sizeof(SRpcMsg), pEpSet, sizeof(SEpSet));
|
||||||
|
|
||||||
|
taosProcPutToParentQ(pWrapper->pProc, pReq, headLen, pReq->pCont, pReq->contLen, PROC_REQ);
|
||||||
|
taosMemoryFree(pHead);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dndSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) {
|
void dndSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) {
|
||||||
if (pWrapper->procType != PROC_CHILD) {
|
if (pWrapper->procType != PROC_CHILD) {
|
||||||
dndSendRpcRsp(pWrapper, pRsp);
|
dndSendRpcRsp(pWrapper, pRsp);
|
||||||
} else {
|
} else {
|
||||||
while (taosProcPutToParentQ(pWrapper->pProc, pRsp, sizeof(SRpcMsg), pRsp->pCont, pRsp->contLen, PROC_RSP) != 0) {
|
taosProcPutToParentQ(pWrapper->pProc, pRsp, sizeof(SRpcMsg), pRsp->pCont, pRsp->contLen, PROC_RSP);
|
||||||
taosMsleep(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,9 +384,7 @@ void dndRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
||||||
if (pWrapper->procType != PROC_CHILD) {
|
if (pWrapper->procType != PROC_CHILD) {
|
||||||
rpcRegisterBrokenLinkArg(pMsg);
|
rpcRegisterBrokenLinkArg(pMsg);
|
||||||
} else {
|
} else {
|
||||||
while (taosProcPutToParentQ(pWrapper->pProc, pMsg, sizeof(SRpcMsg), pMsg->pCont, pMsg->contLen, PROC_REG) != 0) {
|
taosProcPutToParentQ(pWrapper->pProc, pMsg, sizeof(SRpcMsg), pMsg->pCont, pMsg->contLen, PROC_REGIST);
|
||||||
taosMsleep(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,20 +393,17 @@ static void dndReleaseHandle(SMgmtWrapper *pWrapper, void *handle, int8_t type)
|
||||||
rpcReleaseHandle(handle, type);
|
rpcReleaseHandle(handle, type);
|
||||||
} else {
|
} else {
|
||||||
SRpcMsg msg = {.handle = handle, .code = type};
|
SRpcMsg msg = {.handle = handle, .code = type};
|
||||||
while (taosProcPutToParentQ(pWrapper->pProc, &msg, sizeof(SRpcMsg), NULL, 0, PROC_RELEASE) != 0) {
|
taosProcPutToParentQ(pWrapper->pProc, &msg, sizeof(SRpcMsg), NULL, 0, PROC_RELEASE);
|
||||||
taosMsleep(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SMsgCb dndCreateMsgcb(SMgmtWrapper *pWrapper) {
|
SMsgCb dndCreateMsgcb(SMgmtWrapper *pWrapper) {
|
||||||
SMsgCb msgCb = {
|
SMsgCb msgCb = {
|
||||||
.pWrapper = pWrapper,
|
.pWrapper = pWrapper,
|
||||||
|
.sendReqFp = dndSendReq,
|
||||||
|
.sendRspFp = dndSendRsp,
|
||||||
.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg,
|
.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg,
|
||||||
.releaseHandleFp = dndReleaseHandle,
|
.releaseHandleFp = dndReleaseHandle,
|
||||||
.sendMnodeReqFp = dndSendReqToMnode,
|
|
||||||
.sendReqFp = dndSendReqToDnode,
|
|
||||||
.sendRspFp = dndSendRsp,
|
|
||||||
};
|
};
|
||||||
return msgCb;
|
return msgCb;
|
||||||
}
|
}
|
|
@ -111,7 +111,7 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, bool deployed) {
|
||||||
|
|
||||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);;
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
dError("failed to write %s since %s", file, terrstr());
|
dError("failed to write %s since %s", file, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, bool deployed) {
|
||||||
snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP);
|
snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP);
|
||||||
|
|
||||||
if (taosRenameFile(file, realfile) != 0) {
|
if (taosRenameFile(file, realfile) != 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);;
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
dError("failed to rename %s since %s", file, terrstr());
|
dError("failed to rename %s since %s", file, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,20 +39,11 @@ static int32_t mmRequire(SMgmtWrapper *pWrapper, bool *required) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mmInitOption(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) {
|
static void mmInitOption(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) {
|
||||||
SDnode *pDnode = pMgmt->pDnode;
|
SMsgCb msgCb = dndCreateMsgcb(pMgmt->pWrapper);
|
||||||
pOption->dnodeId = pDnode->dnodeId;
|
|
||||||
pOption->clusterId = pDnode->clusterId;
|
|
||||||
|
|
||||||
SMsgCb msgCb = {0};
|
|
||||||
msgCb.pWrapper = pMgmt->pWrapper;
|
|
||||||
msgCb.queueFps[QUERY_QUEUE] = mmPutMsgToQueryQueue;
|
msgCb.queueFps[QUERY_QUEUE] = mmPutMsgToQueryQueue;
|
||||||
msgCb.queueFps[READ_QUEUE] = mmPutMsgToReadQueue;
|
msgCb.queueFps[READ_QUEUE] = mmPutMsgToReadQueue;
|
||||||
msgCb.queueFps[WRITE_QUEUE] = mmPutMsgToWriteQueue;
|
msgCb.queueFps[WRITE_QUEUE] = mmPutMsgToWriteQueue;
|
||||||
msgCb.queueFps[SYNC_QUEUE] = mmPutMsgToWriteQueue;
|
msgCb.queueFps[SYNC_QUEUE] = mmPutMsgToWriteQueue;
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
|
||||||
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
|
||||||
pOption->msgCb = msgCb;
|
pOption->msgCb = msgCb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +57,7 @@ static void mmBuildOptionForDeploy(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) {
|
||||||
pReplica->id = 1;
|
pReplica->id = 1;
|
||||||
pReplica->port = pDnode->serverPort;
|
pReplica->port = pDnode->serverPort;
|
||||||
tstrncpy(pReplica->fqdn, pDnode->localFqdn, TSDB_FQDN_LEN);
|
tstrncpy(pReplica->fqdn, pDnode->localFqdn, TSDB_FQDN_LEN);
|
||||||
|
pOption->deploy = true;
|
||||||
|
|
||||||
pMgmt->selfIndex = pOption->selfIndex;
|
pMgmt->selfIndex = pOption->selfIndex;
|
||||||
pMgmt->replica = pOption->replica;
|
pMgmt->replica = pOption->replica;
|
||||||
|
@ -77,6 +69,7 @@ static void mmBuildOptionForOpen(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) {
|
||||||
pOption->selfIndex = pMgmt->selfIndex;
|
pOption->selfIndex = pMgmt->selfIndex;
|
||||||
pOption->replica = pMgmt->replica;
|
pOption->replica = pMgmt->replica;
|
||||||
memcpy(&pOption->replicas, pMgmt->replicas, sizeof(SReplica) * TSDB_MAX_REPLICA);
|
memcpy(&pOption->replicas, pMgmt->replicas, sizeof(SReplica) * TSDB_MAX_REPLICA);
|
||||||
|
pOption->deploy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mmBuildOptionFromReq(SMnodeMgmt *pMgmt, SMnodeOpt *pOption, SDCreateMnodeReq *pCreate) {
|
static int32_t mmBuildOptionFromReq(SMnodeMgmt *pMgmt, SMnodeOpt *pOption, SDCreateMnodeReq *pCreate) {
|
||||||
|
@ -89,7 +82,7 @@ static int32_t mmBuildOptionFromReq(SMnodeMgmt *pMgmt, SMnodeOpt *pOption, SDCre
|
||||||
pReplica->id = pCreate->replicas[i].id;
|
pReplica->id = pCreate->replicas[i].id;
|
||||||
pReplica->port = pCreate->replicas[i].port;
|
pReplica->port = pCreate->replicas[i].port;
|
||||||
memcpy(pReplica->fqdn, pCreate->replicas[i].fqdn, TSDB_FQDN_LEN);
|
memcpy(pReplica->fqdn, pCreate->replicas[i].fqdn, TSDB_FQDN_LEN);
|
||||||
if (pReplica->id == pOption->dnodeId) {
|
if (pReplica->id == pMgmt->pDnode->dnodeId) {
|
||||||
pOption->selfIndex = i;
|
pOption->selfIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,6 +91,7 @@ static int32_t mmBuildOptionFromReq(SMnodeMgmt *pMgmt, SMnodeOpt *pOption, SDCre
|
||||||
dError("failed to build mnode options since %s", terrstr());
|
dError("failed to build mnode options since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
pOption->deploy = true;
|
||||||
|
|
||||||
pMgmt->selfIndex = pOption->selfIndex;
|
pMgmt->selfIndex = pOption->selfIndex;
|
||||||
pMgmt->replica = pOption->replica;
|
pMgmt->replica = pOption->replica;
|
||||||
|
@ -225,9 +219,7 @@ int32_t mmOpenFromMsg(SMgmtWrapper *pWrapper, SDCreateMnodeReq *pReq) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mmOpen(SMgmtWrapper *pWrapper) {
|
static int32_t mmOpen(SMgmtWrapper *pWrapper) { return mmOpenFromMsg(pWrapper, NULL); }
|
||||||
return mmOpenFromMsg(pWrapper, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mmStart(SMgmtWrapper *pWrapper) {
|
static int32_t mmStart(SMgmtWrapper *pWrapper) {
|
||||||
dDebug("mnode-mgmt start to run");
|
dDebug("mnode-mgmt start to run");
|
||||||
|
@ -258,7 +250,7 @@ int32_t mmGetUserAuth(SMgmtWrapper *pWrapper, char *user, char *spi, char *encry
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmMonitorMnodeInfo(SMgmtWrapper *pWrapper, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo,
|
int32_t mmMonitorMnodeInfo(SMgmtWrapper *pWrapper, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo,
|
||||||
SMonGrantInfo *pGrantInfo) {
|
SMonGrantInfo *pGrantInfo) {
|
||||||
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
return mndGetMonitorInfo(pMgmt->pMnode, pClusterInfo, pVgroupInfo, pGrantInfo);
|
return mndGetMonitorInfo(pMgmt->pMnode, pClusterInfo, pVgroupInfo, pGrantInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,15 +19,10 @@
|
||||||
static int32_t qmRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
|
static int32_t qmRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
|
||||||
|
|
||||||
static void qmInitOption(SQnodeMgmt *pMgmt, SQnodeOpt *pOption) {
|
static void qmInitOption(SQnodeMgmt *pMgmt, SQnodeOpt *pOption) {
|
||||||
SMsgCb msgCb = {0};
|
SMsgCb msgCb = dndCreateMsgcb(pMgmt->pWrapper);
|
||||||
msgCb.pWrapper = pMgmt->pWrapper;
|
|
||||||
msgCb.queueFps[QUERY_QUEUE] = qmPutMsgToQueryQueue;
|
msgCb.queueFps[QUERY_QUEUE] = qmPutMsgToQueryQueue;
|
||||||
msgCb.queueFps[FETCH_QUEUE] = qmPutMsgToFetchQueue;
|
msgCb.queueFps[FETCH_QUEUE] = qmPutMsgToFetchQueue;
|
||||||
msgCb.qsizeFp = qmGetQueueSize;
|
msgCb.qsizeFp = qmGetQueueSize;
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
|
||||||
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
|
||||||
pOption->msgCb = msgCb;
|
pOption->msgCb = msgCb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,7 @@
|
||||||
static int32_t smRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
|
static int32_t smRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
|
||||||
|
|
||||||
static void smInitOption(SSnodeMgmt *pMgmt, SSnodeOpt *pOption) {
|
static void smInitOption(SSnodeMgmt *pMgmt, SSnodeOpt *pOption) {
|
||||||
SMsgCb msgCb = {0};
|
SMsgCb msgCb = dndCreateMsgcb(pMgmt->pWrapper);
|
||||||
msgCb.pWrapper = pMgmt->pWrapper;
|
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
|
||||||
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
|
||||||
pOption->msgCb = msgCb;
|
pOption->msgCb = msgCb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,46 +70,6 @@ TEST_F(DndTestVnode, 01_Create_Vnode) {
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
SCreateVnodeReq createReq = {0};
|
|
||||||
createReq.vgId = 2;
|
|
||||||
createReq.dnodeId = 3;
|
|
||||||
strcpy(createReq.db, "1.d1");
|
|
||||||
createReq.dbUid = 9527;
|
|
||||||
createReq.vgVersion = 1;
|
|
||||||
createReq.cacheBlockSize = 16;
|
|
||||||
createReq.totalBlocks = 10;
|
|
||||||
createReq.daysPerFile = 10;
|
|
||||||
createReq.daysToKeep0 = 3650;
|
|
||||||
createReq.daysToKeep1 = 3650;
|
|
||||||
createReq.daysToKeep2 = 3650;
|
|
||||||
createReq.minRows = 100;
|
|
||||||
createReq.minRows = 4096;
|
|
||||||
createReq.commitTime = 3600;
|
|
||||||
createReq.fsyncPeriod = 3000;
|
|
||||||
createReq.walLevel = 1;
|
|
||||||
createReq.precision = 0;
|
|
||||||
createReq.compression = 2;
|
|
||||||
createReq.replica = 1;
|
|
||||||
createReq.quorum = 1;
|
|
||||||
createReq.update = 0;
|
|
||||||
createReq.cacheLastRow = 0;
|
|
||||||
createReq.selfIndex = 0;
|
|
||||||
for (int r = 0; r < createReq.replica; ++r) {
|
|
||||||
SReplica* pReplica = &createReq.replicas[r];
|
|
||||||
pReplica->id = 1;
|
|
||||||
pReplica->port = 9527;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateVnodeReq(NULL, 0, &createReq);
|
|
||||||
void* pReq = rpcMallocCont(contLen);
|
|
||||||
tSerializeSCreateVnodeReq(pReq, contLen, &createReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_VNODE, pReq, contLen);
|
|
||||||
ASSERT_NE(pRsp, nullptr);
|
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_VNODE_INVALID_OPTION);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DndTestVnode, 02_Alter_Vnode) {
|
TEST_F(DndTestVnode, 02_Alter_Vnode) {
|
||||||
|
|
|
@ -128,16 +128,12 @@ static void *vmOpenVnodeFunc(void *param) {
|
||||||
pMgmt->state.openVnodes, pMgmt->state.totalVnodes);
|
pMgmt->state.openVnodes, pMgmt->state.totalVnodes);
|
||||||
dndReportStartup(pDnode, "open-vnodes", stepDesc);
|
dndReportStartup(pDnode, "open-vnodes", stepDesc);
|
||||||
|
|
||||||
SMsgCb msgCb = {0};
|
SMsgCb msgCb = dndCreateMsgcb(pMgmt->pWrapper);
|
||||||
msgCb.pWrapper = pMgmt->pWrapper;
|
msgCb.pWrapper = pMgmt->pWrapper;
|
||||||
msgCb.queueFps[QUERY_QUEUE] = vmPutMsgToQueryQueue;
|
msgCb.queueFps[QUERY_QUEUE] = vmPutMsgToQueryQueue;
|
||||||
msgCb.queueFps[FETCH_QUEUE] = vmPutMsgToFetchQueue;
|
msgCb.queueFps[FETCH_QUEUE] = vmPutMsgToFetchQueue;
|
||||||
msgCb.queueFps[APPLY_QUEUE] = vmPutMsgToApplyQueue;
|
msgCb.queueFps[APPLY_QUEUE] = vmPutMsgToApplyQueue;
|
||||||
msgCb.qsizeFp = vmGetQueueSize;
|
msgCb.qsizeFp = vmGetQueueSize;
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
|
||||||
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
|
||||||
SVnodeCfg cfg = {.msgCb = msgCb, .pTfs = pMgmt->pTfs, .vgId = pCfg->vgId, .dbId = pCfg->dbUid};
|
SVnodeCfg cfg = {.msgCb = msgCb, .pTfs = pMgmt->pTfs, .vgId = pCfg->vgId, .dbId = pCfg->dbUid};
|
||||||
SVnode *pImpl = vnodeOpen(pCfg->path, &cfg);
|
SVnode *pImpl = vnodeOpen(pCfg->path, &cfg);
|
||||||
if (pImpl == NULL) {
|
if (pImpl == NULL) {
|
||||||
|
|
|
@ -68,12 +68,6 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
SWrapperCfg wrapperCfg = {0};
|
SWrapperCfg wrapperCfg = {0};
|
||||||
vmGenerateWrapperCfg(pMgmt, &createReq, &wrapperCfg);
|
vmGenerateWrapperCfg(pMgmt, &createReq, &wrapperCfg);
|
||||||
|
|
||||||
if (createReq.dnodeId != pMgmt->pDnode->dnodeId) {
|
|
||||||
terrno = TSDB_CODE_DND_VNODE_INVALID_OPTION;
|
|
||||||
dDebug("vgId:%d, failed to create vnode since %s", createReq.vgId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, createReq.vgId);
|
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, createReq.vgId);
|
||||||
if (pVnode != NULL) {
|
if (pVnode != NULL) {
|
||||||
dDebug("vgId:%d, already exist", createReq.vgId);
|
dDebug("vgId:%d, already exist", createReq.vgId);
|
||||||
|
@ -82,16 +76,12 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMsgCb msgCb = {0};
|
SMsgCb msgCb = dndCreateMsgcb(pMgmt->pWrapper);
|
||||||
msgCb.pWrapper = pMgmt->pWrapper;
|
msgCb.pWrapper = pMgmt->pWrapper;
|
||||||
msgCb.queueFps[QUERY_QUEUE] = vmPutMsgToQueryQueue;
|
msgCb.queueFps[QUERY_QUEUE] = vmPutMsgToQueryQueue;
|
||||||
msgCb.queueFps[FETCH_QUEUE] = vmPutMsgToFetchQueue;
|
msgCb.queueFps[FETCH_QUEUE] = vmPutMsgToFetchQueue;
|
||||||
msgCb.queueFps[APPLY_QUEUE] = vmPutMsgToApplyQueue;
|
msgCb.queueFps[APPLY_QUEUE] = vmPutMsgToApplyQueue;
|
||||||
msgCb.qsizeFp = vmGetQueueSize;
|
msgCb.qsizeFp = vmGetQueueSize;
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
|
||||||
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
|
||||||
|
|
||||||
vnodeCfg.msgCb = msgCb;
|
vnodeCfg.msgCb = msgCb;
|
||||||
vnodeCfg.pTfs = pMgmt->pTfs;
|
vnodeCfg.pTfs = pMgmt->pTfs;
|
||||||
|
|
|
@ -25,6 +25,7 @@ extern "C" {
|
||||||
int32_t mndInitCluster(SMnode *pMnode);
|
int32_t mndInitCluster(SMnode *pMnode);
|
||||||
void mndCleanupCluster(SMnode *pMnode);
|
void mndCleanupCluster(SMnode *pMnode);
|
||||||
int32_t mndGetClusterName(SMnode *pMnode, char *clusterName, int32_t len);
|
int32_t mndGetClusterName(SMnode *pMnode, char *clusterName, int32_t len);
|
||||||
|
int64_t mndGetClusterId(SMnode *pMnode);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,6 @@ typedef struct {
|
||||||
} SGrantInfo;
|
} SGrantInfo;
|
||||||
|
|
||||||
typedef struct SMnode {
|
typedef struct SMnode {
|
||||||
int32_t dnodeId;
|
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
int8_t replica;
|
int8_t replica;
|
||||||
int8_t selfIndex;
|
int8_t selfIndex;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "mndCluster.h"
|
#include "mndCluster.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
|
|
||||||
#define TSDB_CLUSTER_VER_NUMBE 1
|
#define TSDB_CLUSTER_VER_NUMBE 1
|
||||||
#define TSDB_CLUSTER_RESERVE_SIZE 64
|
#define TSDB_CLUSTER_RESERVE_SIZE 64
|
||||||
|
|
||||||
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster);
|
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster);
|
||||||
|
@ -61,6 +61,23 @@ int32_t mndGetClusterName(SMnode *pMnode, char *clusterName, int32_t len) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t mndGetClusterId(SMnode *pMnode) {
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
void *pIter = NULL;
|
||||||
|
int64_t clusterId = -1;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
SClusterObj *pCluster = NULL;
|
||||||
|
pIter = sdbFetch(pSdb, SDB_CLUSTER, pIter, (void **)&pCluster);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
clusterId = pCluster->id;
|
||||||
|
sdbRelease(pSdb, pCluster);
|
||||||
|
}
|
||||||
|
|
||||||
|
return clusterId;
|
||||||
|
}
|
||||||
|
|
||||||
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster) {
|
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
|
|
@ -433,12 +433,6 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
|
||||||
pHeartbeat->connId = htonl(pHeartbeat->connId);
|
pHeartbeat->connId = htonl(pHeartbeat->connId);
|
||||||
pHeartbeat->pid = htonl(pHeartbeat->pid);
|
pHeartbeat->pid = htonl(pHeartbeat->pid);
|
||||||
|
|
||||||
SRpcConnInfo info = {0};
|
|
||||||
if (rpcGetConnInfo(pReq->rpcMsg.handle, &info) != 0) {
|
|
||||||
mError("user:%s, connId:%d failed to process hb since %s", pReq->user, pHeartbeat->connId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SConnObj *pConn = mndAcquireConn(pMnode, pHeartbeat->connId);
|
SConnObj *pConn = mndAcquireConn(pMnode, pHeartbeat->connId);
|
||||||
if (pConn == NULL) {
|
if (pConn == NULL) {
|
||||||
pConn = mndCreateConn(pMnode, &info, pHeartbeat->pid, pHeartbeat->app, 0);
|
pConn = mndCreateConn(pMnode, &info, pHeartbeat->pid, pHeartbeat->app, 0);
|
||||||
|
|
|
@ -423,7 +423,7 @@ static int32_t mndProcessDropQnodeReq(SNodeMsg *pReq) {
|
||||||
|
|
||||||
DROP_QNODE_OVER:
|
DROP_QNODE_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mError("qnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
mError("qnode:%d, failed to drop since %s", dropReq.dnodeId, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseQnode(pMnode, pObj);
|
mndReleaseQnode(pMnode, pObj);
|
||||||
|
|
|
@ -433,7 +433,7 @@ static int32_t mndProcessDropSnodeReq(SNodeMsg *pReq) {
|
||||||
|
|
||||||
DROP_SNODE_OVER:
|
DROP_SNODE_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mError("snode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
mError("snode:%d, failed to drop since %s", dropReq.dnodeId, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseSnode(pMnode, pObj);
|
mndReleaseSnode(pMnode, pObj);
|
||||||
|
|
|
@ -354,6 +354,7 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
||||||
req.name = (char *)tNameGetTableName(&name);
|
req.name = (char *)tNameGetTableName(&name);
|
||||||
req.ttl = 0;
|
req.ttl = 0;
|
||||||
req.keep = 0;
|
req.keep = 0;
|
||||||
|
req.rollup = pStb->aggregationMethod > -1 ? 1 : 0;
|
||||||
req.type = TD_SUPER_TABLE;
|
req.type = TD_SUPER_TABLE;
|
||||||
req.stbCfg.suid = pStb->uid;
|
req.stbCfg.suid = pStb->uid;
|
||||||
req.stbCfg.nCols = pStb->numOfColumns;
|
req.stbCfg.nCols = pStb->numOfColumns;
|
||||||
|
@ -365,7 +366,7 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bSmaStat = 0; // no column has bsma
|
int bSmaStat = 0; // no column has bsma
|
||||||
if (pStb->numOfSmas == pStb->numOfColumns) { // assume pColumns > 0
|
if (pStb->numOfSmas == pStb->numOfColumns) { // assume pColumns > 0
|
||||||
bSmaStat = 1; // all columns have bsma
|
bSmaStat = 1; // all columns have bsma
|
||||||
|
@ -405,9 +406,38 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SRSmaParam *pRSmaParam = NULL;
|
||||||
|
if (req.rollup) {
|
||||||
|
pRSmaParam = (SRSmaParam *)taosMemoryCalloc(1, sizeof(SRSmaParam));
|
||||||
|
if (pRSmaParam == NULL) {
|
||||||
|
taosMemoryFreeClear(req.stbCfg.pSchema);
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pRSmaParam->xFilesFactor = pStb->xFilesFactor;
|
||||||
|
pRSmaParam->delay = pStb->delay;
|
||||||
|
pRSmaParam->nFuncIds = 1; // only 1 aggregation method supported currently
|
||||||
|
pRSmaParam->pFuncIds = (func_id_t *)taosMemoryCalloc(pRSmaParam->nFuncIds, sizeof(func_id_t));
|
||||||
|
if (pRSmaParam->pFuncIds == NULL) {
|
||||||
|
taosMemoryFreeClear(req.stbCfg.pRSmaParam);
|
||||||
|
taosMemoryFreeClear(req.stbCfg.pSchema);
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
for (int32_t f = 0; f < pRSmaParam->nFuncIds; ++f) {
|
||||||
|
*(pRSmaParam->pFuncIds + f) = pStb->aggregationMethod;
|
||||||
|
}
|
||||||
|
req.stbCfg.pRSmaParam = pRSmaParam;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t contLen = tSerializeSVCreateTbReq(NULL, &req) + sizeof(SMsgHead);
|
int32_t contLen = tSerializeSVCreateTbReq(NULL, &req) + sizeof(SMsgHead);
|
||||||
SMsgHead *pHead = taosMemoryMalloc(contLen);
|
SMsgHead *pHead = taosMemoryMalloc(contLen);
|
||||||
if (pHead == NULL) {
|
if (pHead == NULL) {
|
||||||
|
if (pRSmaParam) {
|
||||||
|
taosMemoryFreeClear(pRSmaParam->pFuncIds);
|
||||||
|
taosMemoryFreeClear(pRSmaParam);
|
||||||
|
}
|
||||||
taosMemoryFreeClear(req.stbCfg.pSchema);
|
taosMemoryFreeClear(req.stbCfg.pSchema);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -420,6 +450,10 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
||||||
tSerializeSVCreateTbReq(&pBuf, &req);
|
tSerializeSVCreateTbReq(&pBuf, &req);
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
|
if (pRSmaParam) {
|
||||||
|
taosMemoryFreeClear(pRSmaParam->pFuncIds);
|
||||||
|
taosMemoryFreeClear(pRSmaParam);
|
||||||
|
}
|
||||||
taosMemoryFreeClear(req.stbCfg.pSchema);
|
taosMemoryFreeClear(req.stbCfg.pSchema);
|
||||||
return pHead;
|
return pHead;
|
||||||
}
|
}
|
||||||
|
@ -632,6 +666,9 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
|
||||||
stbObj.dbUid = pDb->uid;
|
stbObj.dbUid = pDb->uid;
|
||||||
stbObj.version = 1;
|
stbObj.version = 1;
|
||||||
stbObj.nextColId = 1;
|
stbObj.nextColId = 1;
|
||||||
|
stbObj.xFilesFactor = pCreate->xFilesFactor;
|
||||||
|
stbObj.aggregationMethod = pCreate->aggregationMethod;
|
||||||
|
stbObj.delay = pCreate->delay;
|
||||||
stbObj.ttl = pCreate->ttl;
|
stbObj.ttl = pCreate->ttl;
|
||||||
stbObj.numOfColumns = pCreate->numOfColumns;
|
stbObj.numOfColumns = pCreate->numOfColumns;
|
||||||
stbObj.numOfTags = pCreate->numOfTags;
|
stbObj.numOfTags = pCreate->numOfTags;
|
||||||
|
|
|
@ -187,7 +187,7 @@ static int32_t mndAllocStep(SMnode *pMnode, char *name, MndInitFp initFp, MndCle
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndInitSteps(SMnode *pMnode) {
|
static int32_t mndInitSteps(SMnode *pMnode, bool deploy) {
|
||||||
if (mndAllocStep(pMnode, "mnode-sdb", mndInitSdb, mndCleanupSdb) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-sdb", mndInitSdb, mndCleanupSdb) != 0) return -1;
|
||||||
if (mndAllocStep(pMnode, "mnode-trans", mndInitTrans, mndCleanupTrans) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-trans", mndInitTrans, mndCleanupTrans) != 0) return -1;
|
||||||
if (mndAllocStep(pMnode, "mnode-cluster", mndInitCluster, mndCleanupCluster) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-cluster", mndInitCluster, mndCleanupCluster) != 0) return -1;
|
||||||
|
@ -210,7 +210,7 @@ static int32_t mndInitSteps(SMnode *pMnode) {
|
||||||
if (mndAllocStep(pMnode, "mnode-infos", mndInitInfos, mndCleanupInfos) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-infos", mndInitInfos, mndCleanupInfos) != 0) return -1;
|
||||||
if (mndAllocStep(pMnode, "mnode-db", mndInitDb, mndCleanupDb) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-db", mndInitDb, mndCleanupDb) != 0) return -1;
|
||||||
if (mndAllocStep(pMnode, "mnode-func", mndInitFunc, mndCleanupFunc) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-func", mndInitFunc, mndCleanupFunc) != 0) return -1;
|
||||||
if (pMnode->clusterId <= 0) {
|
if (deploy) {
|
||||||
if (mndAllocStep(pMnode, "mnode-sdb-deploy", mndDeploySdb, NULL) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-sdb-deploy", mndDeploySdb, NULL) != 0) return -1;
|
||||||
} else {
|
} else {
|
||||||
if (mndAllocStep(pMnode, "mnode-sdb-read", mndReadSdb, NULL) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-sdb-read", mndReadSdb, NULL) != 0) return -1;
|
||||||
|
@ -263,23 +263,15 @@ static int32_t mndExecSteps(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pMnode->clusterId = mndGetClusterId(pMnode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
|
static void mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
|
||||||
pMnode->dnodeId = pOption->dnodeId;
|
|
||||||
pMnode->clusterId = pOption->clusterId;
|
|
||||||
pMnode->replica = pOption->replica;
|
pMnode->replica = pOption->replica;
|
||||||
pMnode->selfIndex = pOption->selfIndex;
|
pMnode->selfIndex = pOption->selfIndex;
|
||||||
memcpy(&pMnode->replicas, pOption->replicas, sizeof(SReplica) * TSDB_MAX_REPLICA);
|
memcpy(&pMnode->replicas, pOption->replicas, sizeof(SReplica) * TSDB_MAX_REPLICA);
|
||||||
pMnode->msgCb = pOption->msgCb;
|
pMnode->msgCb = pOption->msgCb;
|
||||||
|
|
||||||
if (pMnode->dnodeId < 0 || pMnode->clusterId < 0) {
|
|
||||||
terrno = TSDB_CODE_MND_INVALID_OPTIONS;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
|
SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
|
||||||
|
@ -294,6 +286,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
|
||||||
|
|
||||||
char timestr[24] = "1970-01-01 00:00:00.00";
|
char timestr[24] = "1970-01-01 00:00:00.00";
|
||||||
(void)taosParseTime(timestr, &pMnode->checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
(void)taosParseTime(timestr, &pMnode->checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
||||||
|
mndSetOptions(pMnode, pOption);
|
||||||
|
|
||||||
pMnode->pSteps = taosArrayInit(24, sizeof(SMnodeStep));
|
pMnode->pSteps = taosArrayInit(24, sizeof(SMnodeStep));
|
||||||
if (pMnode->pSteps == NULL) {
|
if (pMnode->pSteps == NULL) {
|
||||||
|
@ -312,16 +305,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndSetOptions(pMnode, pOption);
|
code = mndInitSteps(pMnode, pOption->deploy);
|
||||||
if (code != 0) {
|
|
||||||
code = terrno;
|
|
||||||
mError("failed to open mnode since %s", terrstr());
|
|
||||||
mndClose(pMnode);
|
|
||||||
terrno = code;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndInitSteps(pMnode);
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
mError("failed to open mnode since %s", terrstr());
|
mError("failed to open mnode since %s", terrstr());
|
||||||
|
|
|
@ -78,10 +78,13 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: maybe need to clear the request struct
|
// TODO: to encapsule a free API
|
||||||
taosMemoryFree(vCreateTbReq.stbCfg.pSchema);
|
taosMemoryFree(vCreateTbReq.stbCfg.pSchema);
|
||||||
taosMemoryFree(vCreateTbReq.stbCfg.pTagSchema);
|
taosMemoryFree(vCreateTbReq.stbCfg.pTagSchema);
|
||||||
taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam);
|
if(vCreateTbReq.stbCfg.pRSmaParam) {
|
||||||
|
taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam->pFuncIds);
|
||||||
|
taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam);
|
||||||
|
}
|
||||||
taosMemoryFree(vCreateTbReq.dbFName);
|
taosMemoryFree(vCreateTbReq.dbFName);
|
||||||
taosMemoryFree(vCreateTbReq.name);
|
taosMemoryFree(vCreateTbReq.name);
|
||||||
break;
|
break;
|
||||||
|
@ -110,17 +113,24 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
vError("vgId:%d, failed to create table: %s", pVnode->vgId, pCreateTbReq->name);
|
vError("vgId:%d, failed to create table: %s", pVnode->vgId, pCreateTbReq->name);
|
||||||
}
|
}
|
||||||
|
// TODO: to encapsule a free API
|
||||||
taosMemoryFree(pCreateTbReq->name);
|
taosMemoryFree(pCreateTbReq->name);
|
||||||
taosMemoryFree(pCreateTbReq->dbFName);
|
taosMemoryFree(pCreateTbReq->dbFName);
|
||||||
if (pCreateTbReq->type == TD_SUPER_TABLE) {
|
if (pCreateTbReq->type == TD_SUPER_TABLE) {
|
||||||
taosMemoryFree(pCreateTbReq->stbCfg.pSchema);
|
taosMemoryFree(pCreateTbReq->stbCfg.pSchema);
|
||||||
taosMemoryFree(pCreateTbReq->stbCfg.pTagSchema);
|
taosMemoryFree(pCreateTbReq->stbCfg.pTagSchema);
|
||||||
taosMemoryFree(pCreateTbReq->stbCfg.pRSmaParam);
|
if (pCreateTbReq->stbCfg.pRSmaParam) {
|
||||||
|
taosMemoryFree(pCreateTbReq->stbCfg.pRSmaParam->pFuncIds);
|
||||||
|
taosMemoryFree(pCreateTbReq->stbCfg.pRSmaParam);
|
||||||
|
}
|
||||||
} else if (pCreateTbReq->type == TD_CHILD_TABLE) {
|
} else if (pCreateTbReq->type == TD_CHILD_TABLE) {
|
||||||
taosMemoryFree(pCreateTbReq->ctbCfg.pTag);
|
taosMemoryFree(pCreateTbReq->ctbCfg.pTag);
|
||||||
} else {
|
} else {
|
||||||
taosMemoryFree(pCreateTbReq->ntbCfg.pSchema);
|
taosMemoryFree(pCreateTbReq->ntbCfg.pSchema);
|
||||||
taosMemoryFree(pCreateTbReq->ntbCfg.pRSmaParam);
|
if (pCreateTbReq->ntbCfg.pRSmaParam) {
|
||||||
|
taosMemoryFree(pCreateTbReq->ntbCfg.pRSmaParam->pFuncIds);
|
||||||
|
taosMemoryFree(pCreateTbReq->ntbCfg.pRSmaParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,9 +155,13 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
SVCreateTbReq vAlterTbReq = {0};
|
SVCreateTbReq vAlterTbReq = {0};
|
||||||
vTrace("vgId:%d, process alter stb req", pVnode->vgId);
|
vTrace("vgId:%d, process alter stb req", pVnode->vgId);
|
||||||
tDeserializeSVCreateTbReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vAlterTbReq);
|
tDeserializeSVCreateTbReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vAlterTbReq);
|
||||||
|
// TODO: to encapsule a free API
|
||||||
taosMemoryFree(vAlterTbReq.stbCfg.pSchema);
|
taosMemoryFree(vAlterTbReq.stbCfg.pSchema);
|
||||||
taosMemoryFree(vAlterTbReq.stbCfg.pTagSchema);
|
taosMemoryFree(vAlterTbReq.stbCfg.pTagSchema);
|
||||||
taosMemoryFree(vAlterTbReq.stbCfg.pRSmaParam);
|
if (vAlterTbReq.stbCfg.pRSmaParam) {
|
||||||
|
taosMemoryFree(vAlterTbReq.stbCfg.pRSmaParam->pFuncIds);
|
||||||
|
taosMemoryFree(vAlterTbReq.stbCfg.pRSmaParam);
|
||||||
|
}
|
||||||
taosMemoryFree(vAlterTbReq.dbFName);
|
taosMemoryFree(vAlterTbReq.dbFName);
|
||||||
taosMemoryFree(vAlterTbReq.name);
|
taosMemoryFree(vAlterTbReq.name);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3026,11 +3026,27 @@ int32_t loadDataBlock(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo,
|
||||||
int8_t* rowRes = NULL;
|
int8_t* rowRes = NULL;
|
||||||
bool keep = filterExecute(filter, pBlock, &rowRes, NULL, param1.numOfCols);
|
bool keep = filterExecute(filter, pBlock, &rowRes, NULL, param1.numOfCols);
|
||||||
|
|
||||||
// filterSetColFieldData(pQueryAttr->pFilters, pBlock->info.numOfCols, pBlock->pDataBlock);
|
SSDataBlock* px = createOneDataBlock(pBlock);
|
||||||
|
blockDataEnsureCapacity(px, pBlock->info.rows);
|
||||||
|
|
||||||
// if (pQueryAttr->pFilters != NULL) {
|
int32_t numOfRow = 0;
|
||||||
// filterColRowsInDataBlock(pRuntimeEnv, pBlock, ascQuery);
|
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
|
||||||
// }
|
SColumnInfoData* pDst = taosArrayGet(px->pDataBlock, i);
|
||||||
|
SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
|
||||||
|
numOfRow = 0;
|
||||||
|
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
|
||||||
|
if (rowRes[j] == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
colDataAppend(pDst, numOfRow, colDataGetData(pSrc, j), false);
|
||||||
|
numOfRow += 1;
|
||||||
|
}
|
||||||
|
*pSrc = *pDst;
|
||||||
|
}
|
||||||
|
|
||||||
|
pBlock->info.rows = numOfRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -441,6 +441,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = winDurFunction,
|
.sprocessFunc = winDurFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "now",
|
||||||
|
.type = FUNCTION_TYPE_NOW,
|
||||||
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
||||||
|
.checkFunc = stubCheckAndGetResultType,
|
||||||
|
.getEnvFunc = getTimePseudoFuncEnv,
|
||||||
|
.initFunc = NULL,
|
||||||
|
.sprocessFunc = winDurFunction,
|
||||||
|
.finalizeFunc = NULL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -568,6 +578,9 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case FUNCTION_TYPE_NOW:
|
||||||
|
// todo
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(0); // to found the fault ASAP.
|
ASSERT(0); // to found the fault ASAP.
|
||||||
}
|
}
|
||||||
|
|
|
@ -860,6 +860,24 @@ bool nodesIsExprNode(const SNode* pNode) {
|
||||||
return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type || QUERY_NODE_FUNCTION == type);
|
return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type || QUERY_NODE_FUNCTION == type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool nodesIsUnaryOp(const SOperatorNode* pOp) {
|
||||||
|
switch (pOp->opType) {
|
||||||
|
case OP_TYPE_MINUS:
|
||||||
|
case OP_TYPE_IS_NULL:
|
||||||
|
case OP_TYPE_IS_NOT_NULL:
|
||||||
|
case OP_TYPE_IS_TRUE:
|
||||||
|
case OP_TYPE_IS_FALSE:
|
||||||
|
case OP_TYPE_IS_UNKNOWN:
|
||||||
|
case OP_TYPE_IS_NOT_TRUE:
|
||||||
|
case OP_TYPE_IS_NOT_FALSE:
|
||||||
|
case OP_TYPE_IS_NOT_UNKNOWN:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool nodesIsArithmeticOp(const SOperatorNode* pOp) {
|
bool nodesIsArithmeticOp(const SOperatorNode* pOp) {
|
||||||
switch (pOp->opType) {
|
switch (pOp->opType) {
|
||||||
case OP_TYPE_ADD:
|
case OP_TYPE_ADD:
|
||||||
|
|
|
@ -77,7 +77,6 @@ typedef struct STableDataBlocks {
|
||||||
STableMeta *pTableMeta; // the tableMeta of current table, the table meta will be used during submit, keep a ref to avoid to be removed from cache
|
STableMeta *pTableMeta; // the tableMeta of current table, the table meta will be used during submit, keep a ref to avoid to be removed from cache
|
||||||
char *pData;
|
char *pData;
|
||||||
bool cloned;
|
bool cloned;
|
||||||
STagData tagData;
|
|
||||||
|
|
||||||
SParsedDataColInfo boundColumnInfo;
|
SParsedDataColInfo boundColumnInfo;
|
||||||
SRowBuilder rowBuilder;
|
SRowBuilder rowBuilder;
|
||||||
|
|
|
@ -513,7 +513,7 @@ expression(A) ::= NK_PLUS(B) expression(C).
|
||||||
}
|
}
|
||||||
expression(A) ::= NK_MINUS(B) expression(C). {
|
expression(A) ::= NK_MINUS(B) expression(C). {
|
||||||
SToken t = getTokenFromRawExprNode(pCxt, C);
|
SToken t = getTokenFromRawExprNode(pCxt, C);
|
||||||
A = createRawExprNodeExt(pCxt, &B, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, C), NULL));
|
A = createRawExprNodeExt(pCxt, &B, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, C), NULL));
|
||||||
}
|
}
|
||||||
expression(A) ::= expression(B) NK_PLUS expression(C). {
|
expression(A) ::= expression(B) NK_PLUS expression(C). {
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||||
|
@ -549,38 +549,14 @@ expression_list(A) ::= expression_list(B) NK_COMMA expression(C).
|
||||||
column_reference(A) ::= column_name(B). { A = createRawExprNode(pCxt, &B, createColumnNode(pCxt, NULL, &B)); }
|
column_reference(A) ::= column_name(B). { A = createRawExprNode(pCxt, &B, createColumnNode(pCxt, NULL, &B)); }
|
||||||
column_reference(A) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); }
|
column_reference(A) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); }
|
||||||
|
|
||||||
//pseudo_column(A) ::= NK_NOW. { A = createFunctionNode(pCxt, NULL, NULL); }
|
pseudo_column(A) ::= NOW(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= NK_UNDERLINE(B) ROWTS(C). {
|
pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
SToken t = B;
|
|
||||||
t.n = (C.z + C.n) - B.z;
|
|
||||||
A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
|
|
||||||
}
|
|
||||||
pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= NK_UNDERLINE(B) QSTARTTS(C). {
|
pseudo_column(A) ::= QSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
SToken t = B;
|
pseudo_column(A) ::= QENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
t.n = (C.z + C.n) - B.z;
|
pseudo_column(A) ::= WSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
|
pseudo_column(A) ::= WENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
}
|
pseudo_column(A) ::= WDURATION(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= NK_UNDERLINE(B) QENDTS(C). {
|
|
||||||
SToken t = B;
|
|
||||||
t.n = (C.z + C.n) - B.z;
|
|
||||||
A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
|
|
||||||
}
|
|
||||||
pseudo_column(A) ::= NK_UNDERLINE(B) WSTARTTS(C). {
|
|
||||||
SToken t = B;
|
|
||||||
t.n = (C.z + C.n) - B.z;
|
|
||||||
A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
|
|
||||||
}
|
|
||||||
pseudo_column(A) ::= NK_UNDERLINE(B) WENDTS(C). {
|
|
||||||
SToken t = B;
|
|
||||||
t.n = (C.z + C.n) - B.z;
|
|
||||||
A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
|
|
||||||
}
|
|
||||||
pseudo_column(A) ::= NK_UNDERLINE(B) WDURATION(C). {
|
|
||||||
SToken t = B;
|
|
||||||
t.n = (C.z + C.n) - B.z;
|
|
||||||
A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************ predicate ***********************************************************/
|
/************************************************ predicate ***********************************************************/
|
||||||
predicate(A) ::= expression(B) compare_op(C) expression(D). {
|
predicate(A) ::= expression(B) compare_op(C) expression(D). {
|
||||||
|
|
|
@ -55,8 +55,10 @@ typedef struct SInsertParseContext {
|
||||||
STableMeta* pTableMeta; // each table
|
STableMeta* pTableMeta; // each table
|
||||||
SParsedDataColInfo tags; // each table
|
SParsedDataColInfo tags; // each table
|
||||||
SKVRowBuilder tagsBuilder; // each table
|
SKVRowBuilder tagsBuilder; // each table
|
||||||
|
SVCreateTbReq createTblReq; // each table
|
||||||
SHashObj* pVgroupsHashObj; // global
|
SHashObj* pVgroupsHashObj; // global
|
||||||
SHashObj* pTableBlockHashObj; // global
|
SHashObj* pTableBlockHashObj; // global
|
||||||
|
SHashObj* pSubTableHashObj; // global
|
||||||
SArray* pTableDataBlocks; // global
|
SArray* pTableDataBlocks; // global
|
||||||
SArray* pVgDataBlocks; // global
|
SArray* pVgDataBlocks; // global
|
||||||
int32_t totalNum;
|
int32_t totalNum;
|
||||||
|
@ -738,8 +740,20 @@ static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void *value, int32_t len, voi
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t buildCreateTbReq(SInsertParseContext* pCxt, const SName* pName, SKVRow row) {
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||||
|
tNameGetFullDbName(pName, dbFName);
|
||||||
|
pCxt->createTblReq.type = TD_CHILD_TABLE;
|
||||||
|
pCxt->createTblReq.dbFName = strdup(dbFName);
|
||||||
|
pCxt->createTblReq.name = strdup(pName->tname);
|
||||||
|
pCxt->createTblReq.ctbCfg.suid = pCxt->pTableMeta->suid;
|
||||||
|
pCxt->createTblReq.ctbCfg.pTag = row;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
// pSql -> tag1_value, ...)
|
// pSql -> tag1_value, ...)
|
||||||
static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema, uint8_t precision) {
|
static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema, uint8_t precision, const SName* pName) {
|
||||||
if (tdInitKVRowBuilder(&pCxt->tagsBuilder) < 0) {
|
if (tdInitKVRowBuilder(&pCxt->tagsBuilder) < 0) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -760,23 +774,46 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema,
|
||||||
}
|
}
|
||||||
tdSortKVRowByColIdx(row);
|
tdSortKVRowByColIdx(row);
|
||||||
|
|
||||||
// todo construct payload
|
return buildCreateTbReq(pCxt, pName, row);
|
||||||
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(row);
|
static int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst) {
|
||||||
|
*pDst = taosMemoryMalloc(TABLE_META_SIZE(pSrc));
|
||||||
|
if (NULL == *pDst) {
|
||||||
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
memcpy(*pDst, pSrc, TABLE_META_SIZE(pSrc));
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
static int32_t storeTableMeta(SHashObj* pHash, const char* pName, int32_t len, STableMeta* pMeta) {
|
||||||
|
STableMeta* pBackup = NULL;
|
||||||
|
if (TSDB_CODE_SUCCESS != cloneTableMeta(pMeta, &pBackup)) {
|
||||||
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
return taosHashPut(pHash, pName, len, &pBackup, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
|
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
|
||||||
static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken) {
|
static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken) {
|
||||||
SToken sToken;
|
SName name;
|
||||||
|
createSName(&name, pTbnameToken, pCxt->pComCxt, &pCxt->msg);
|
||||||
|
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
tNameExtractFullName(&name, tbFName);
|
||||||
|
int32_t len = strlen(tbFName);
|
||||||
|
STableMeta** pMeta = taosHashGet(pCxt->pSubTableHashObj, tbFName, len);
|
||||||
|
if (NULL != pMeta) {
|
||||||
|
return cloneTableMeta(*pMeta, &pCxt->pTableMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
SToken sToken;
|
||||||
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
|
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
|
||||||
NEXT_TOKEN(pCxt->pSql, sToken);
|
NEXT_TOKEN(pCxt->pSql, sToken);
|
||||||
CHECK_CODE(getTableMeta(pCxt, &sToken));
|
CHECK_CODE(getTableMeta(pCxt, &sToken));
|
||||||
if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) {
|
if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) {
|
||||||
return buildInvalidOperationMsg(&pCxt->msg, "create table only from super table is allowed");
|
return buildInvalidOperationMsg(&pCxt->msg, "create table only from super table is allowed");
|
||||||
}
|
}
|
||||||
|
CHECK_CODE(storeTableMeta(pCxt->pSubTableHashObj, tbFName, len, pCxt->pTableMeta));
|
||||||
|
|
||||||
SSchema* pTagsSchema = getTableTagSchema(pCxt->pTableMeta);
|
SSchema* pTagsSchema = getTableTagSchema(pCxt->pTableMeta);
|
||||||
setBoundColumnInfo(&pCxt->tags, pTagsSchema, getNumOfTags(pCxt->pTableMeta));
|
setBoundColumnInfo(&pCxt->tags, pTagsSchema, getNumOfTags(pCxt->pTableMeta));
|
||||||
|
@ -796,7 +833,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken)
|
||||||
if (TK_NK_LP != sToken.type) {
|
if (TK_NK_LP != sToken.type) {
|
||||||
return buildSyntaxErrMsg(&pCxt->msg, "( is expected", sToken.z);
|
return buildSyntaxErrMsg(&pCxt->msg, "( is expected", sToken.z);
|
||||||
}
|
}
|
||||||
CHECK_CODE(parseTagsClause(pCxt, pTagsSchema, getTableInfo(pCxt->pTableMeta).precision));
|
CHECK_CODE(parseTagsClause(pCxt, pTagsSchema, getTableInfo(pCxt->pTableMeta).precision, &name));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -904,10 +941,17 @@ static int32_t parseValuesClause(SInsertParseContext* pCxt, STableDataBlocks* da
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void destroyCreateSubTbReq(SVCreateTbReq* pReq) {
|
||||||
|
taosMemoryFreeClear(pReq->dbFName);
|
||||||
|
taosMemoryFreeClear(pReq->name);
|
||||||
|
taosMemoryFreeClear(pReq->ctbCfg.pTag);
|
||||||
|
}
|
||||||
|
|
||||||
static void destroyInsertParseContextForTable(SInsertParseContext* pCxt) {
|
static void destroyInsertParseContextForTable(SInsertParseContext* pCxt) {
|
||||||
taosMemoryFreeClear(pCxt->pTableMeta);
|
taosMemoryFreeClear(pCxt->pTableMeta);
|
||||||
destroyBoundColumnInfo(&pCxt->tags);
|
destroyBoundColumnInfo(&pCxt->tags);
|
||||||
tdDestroyKVRowBuilder(&pCxt->tagsBuilder);
|
tdDestroyKVRowBuilder(&pCxt->tagsBuilder);
|
||||||
|
destroyCreateSubTbReq(&pCxt->createTblReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyDataBlock(STableDataBlocks* pDataBlock) {
|
static void destroyDataBlock(STableDataBlocks* pDataBlock) {
|
||||||
|
@ -972,7 +1016,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
STableDataBlocks *dataBuf = NULL;
|
STableDataBlocks *dataBuf = NULL;
|
||||||
CHECK_CODE(getDataBlockFromList(pCxt->pTableBlockHashObj, pCxt->pTableMeta->uid, TSDB_DEFAULT_PAYLOAD_SIZE,
|
CHECK_CODE(getDataBlockFromList(pCxt->pTableBlockHashObj, pCxt->pTableMeta->uid, TSDB_DEFAULT_PAYLOAD_SIZE,
|
||||||
sizeof(SSubmitBlk), getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta, &dataBuf, NULL));
|
sizeof(SSubmitBlk), getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta, &dataBuf, NULL));
|
||||||
|
|
||||||
if (TK_NK_LP == sToken.type) {
|
if (TK_NK_LP == sToken.type) {
|
||||||
// pSql -> field1_name, ...)
|
// pSql -> field1_name, ...)
|
||||||
CHECK_CODE(parseBoundColumns(pCxt, &dataBuf->boundColumnInfo, getTableColumnSchema(pCxt->pTableMeta)));
|
CHECK_CODE(parseBoundColumns(pCxt, &dataBuf->boundColumnInfo, getTableColumnSchema(pCxt->pTableMeta)));
|
||||||
|
@ -1021,11 +1065,13 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
|
||||||
.pTableMeta = NULL,
|
.pTableMeta = NULL,
|
||||||
.pVgroupsHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, false),
|
.pVgroupsHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, false),
|
||||||
.pTableBlockHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false),
|
.pTableBlockHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false),
|
||||||
|
.pSubTableHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, false),
|
||||||
.totalNum = 0,
|
.totalNum = 0,
|
||||||
.pOutput = (SVnodeModifOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT)
|
.pOutput = (SVnodeModifOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (NULL == context.pVgroupsHashObj || NULL == context.pTableBlockHashObj || NULL == context.pOutput) {
|
if (NULL == context.pVgroupsHashObj || NULL == context.pTableBlockHashObj ||
|
||||||
|
NULL == context.pSubTableHashObj || NULL == context.pOutput) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,10 +125,10 @@ static SKeyword keywordTable[] = {
|
||||||
{"PRECISION", TK_PRECISION},
|
{"PRECISION", TK_PRECISION},
|
||||||
{"PRIVILEGE", TK_PRIVILEGE},
|
{"PRIVILEGE", TK_PRIVILEGE},
|
||||||
{"PREV", TK_PREV},
|
{"PREV", TK_PREV},
|
||||||
{"QENDTS", TK_QENDTS},
|
{"_QENDTS", TK_QENDTS},
|
||||||
{"QNODE", TK_QNODE},
|
{"QNODE", TK_QNODE},
|
||||||
{"QNODES", TK_QNODES},
|
{"QNODES", TK_QNODES},
|
||||||
{"QSTARTTS", TK_QSTARTTS},
|
{"_QSTARTTS", TK_QSTARTTS},
|
||||||
{"QTIME", TK_QTIME},
|
{"QTIME", TK_QTIME},
|
||||||
{"QUERIES", TK_QUERIES},
|
{"QUERIES", TK_QUERIES},
|
||||||
{"QUERY", TK_QUERY},
|
{"QUERY", TK_QUERY},
|
||||||
|
@ -138,7 +138,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"RESET", TK_RESET},
|
{"RESET", TK_RESET},
|
||||||
{"RETENTIONS", TK_RETENTIONS},
|
{"RETENTIONS", TK_RETENTIONS},
|
||||||
{"ROLLUP", TK_ROLLUP},
|
{"ROLLUP", TK_ROLLUP},
|
||||||
{"ROWTS", TK_ROWTS},
|
{"_ROWTS", TK_ROWTS},
|
||||||
{"SCORES", TK_SCORES},
|
{"SCORES", TK_SCORES},
|
||||||
{"SELECT", TK_SELECT},
|
{"SELECT", TK_SELECT},
|
||||||
{"SESSION", TK_SESSION},
|
{"SESSION", TK_SESSION},
|
||||||
|
@ -184,10 +184,10 @@ static SKeyword keywordTable[] = {
|
||||||
{"VGROUPS", TK_VGROUPS},
|
{"VGROUPS", TK_VGROUPS},
|
||||||
{"VNODES", TK_VNODES},
|
{"VNODES", TK_VNODES},
|
||||||
{"WAL", TK_WAL},
|
{"WAL", TK_WAL},
|
||||||
{"WDURATION", TK_WDURATION},
|
{"_WDURATION", TK_WDURATION},
|
||||||
{"WENDTS", TK_WENDTS},
|
{"_WENDTS", TK_WENDTS},
|
||||||
{"WHERE", TK_WHERE},
|
{"WHERE", TK_WHERE},
|
||||||
{"WSTARTTS", TK_WSTARTTS},
|
{"_WSTARTTS", TK_WSTARTTS},
|
||||||
// {"ID", TK_ID},
|
// {"ID", TK_ID},
|
||||||
// {"STRING", TK_STRING},
|
// {"STRING", TK_STRING},
|
||||||
// {"EQ", TK_EQ},
|
// {"EQ", TK_EQ},
|
||||||
|
@ -440,10 +440,6 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
|
||||||
*tokenId = TK_NK_QUESTION;
|
*tokenId = TK_NK_QUESTION;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
case '_': {
|
|
||||||
*tokenId = TK_NK_UNDERLINE;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
case '`':
|
case '`':
|
||||||
case '\'':
|
case '\'':
|
||||||
case '"': {
|
case '"': {
|
||||||
|
|
|
@ -439,6 +439,9 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
||||||
|
if (nodesIsUnaryOp(pOp)) {
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
||||||
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
|
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
|
||||||
if (nodesIsArithmeticOp(pOp)) {
|
if (nodesIsArithmeticOp(pOp)) {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -190,14 +190,14 @@ TEST_F(PlannerTest, subquery) {
|
||||||
TEST_F(PlannerTest, interval) {
|
TEST_F(PlannerTest, interval) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
// bind("SELECT count(*) FROM t1 interval(10s)");
|
bind("SELECT count(*) FROM t1 interval(10s)");
|
||||||
// ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
// bind("SELECT _wstartts, _wduration, _wendts, count(*) FROM t1 interval(10s)");
|
bind("SELECT _wstartts, _wduration, _wendts, count(*) FROM t1 interval(10s)");
|
||||||
// ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
// bind("SELECT count(*) FROM t1 interval(10s) fill(linear)");
|
bind("SELECT count(*) FROM t1 interval(10s) fill(linear)");
|
||||||
// ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("SELECT count(*), sum(c1) FROM t1 interval(10s) fill(value, 10, 20)");
|
bind("SELECT count(*), sum(c1) FROM t1 interval(10s) fill(value, 10, 20)");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
|
@ -229,7 +229,7 @@ typedef struct SFltBuildGroupCtx {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
} SFltBuildGroupCtx;
|
} SFltBuildGroupCtx;
|
||||||
|
|
||||||
typedef struct SFilterInfo {
|
struct SFilterInfo {
|
||||||
bool scalarMode;
|
bool scalarMode;
|
||||||
SFltScalarCtx sclCtx;
|
SFltScalarCtx sclCtx;
|
||||||
uint32_t options;
|
uint32_t options;
|
||||||
|
@ -254,7 +254,7 @@ typedef struct SFilterInfo {
|
||||||
SArray *blkList;
|
SArray *blkList;
|
||||||
|
|
||||||
SFilterPCtx pctx;
|
SFilterPCtx pctx;
|
||||||
} SFilterInfo;
|
};
|
||||||
|
|
||||||
#define FILTER_NO_MERGE_DATA_TYPE(t) ((t) == TSDB_DATA_TYPE_BINARY || (t) == TSDB_DATA_TYPE_NCHAR || (t) == TSDB_DATA_TYPE_JSON)
|
#define FILTER_NO_MERGE_DATA_TYPE(t) ((t) == TSDB_DATA_TYPE_BINARY || (t) == TSDB_DATA_TYPE_NCHAR || (t) == TSDB_DATA_TYPE_JSON)
|
||||||
#define FILTER_NO_MERGE_OPTR(o) ((o) == OP_TYPE_IS_NULL || (o) == OP_TYPE_IS_NOT_NULL || (o) == FILTER_DUMMY_EMPTY_OPTR)
|
#define FILTER_NO_MERGE_OPTR(o) ((o) == OP_TYPE_IS_NULL || (o) == OP_TYPE_IS_NOT_NULL || (o) == FILTER_DUMMY_EMPTY_OPTR)
|
||||||
|
|
|
@ -3638,16 +3638,16 @@ int32_t filterInitFromNode(SNode* pNode, SFilterInfo **pInfo, uint32_t options)
|
||||||
info = *pInfo;
|
info = *pInfo;
|
||||||
info->options = options;
|
info->options = options;
|
||||||
|
|
||||||
SFltTreeStat stat = {0};
|
SFltTreeStat stat1 = {0};
|
||||||
FLT_ERR_JRET(fltReviseNodes(info, &pNode, &stat));
|
FLT_ERR_JRET(fltReviseNodes(info, &pNode, &stat1));
|
||||||
|
|
||||||
info->scalarMode = stat.scalarMode;
|
info->scalarMode = stat1.scalarMode;
|
||||||
|
|
||||||
if (!info->scalarMode) {
|
if (!info->scalarMode) {
|
||||||
FLT_ERR_JRET(fltInitFromNode(pNode, info, options));
|
FLT_ERR_JRET(fltInitFromNode(pNode, info, options));
|
||||||
} else {
|
} else {
|
||||||
info->sclCtx.node = pNode;
|
info->sclCtx.node = pNode;
|
||||||
FLT_ERR_JRET(fltOptimizeNodes(info, &info->sclCtx.node, &stat));
|
FLT_ERR_JRET(fltOptimizeNodes(info, &info->sclCtx.node, &stat1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -3664,24 +3664,16 @@ _return:
|
||||||
bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) {
|
bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||||
if (info->scalarMode) {
|
if (info->scalarMode) {
|
||||||
SScalarParam output = {0};
|
SScalarParam output = {0};
|
||||||
|
|
||||||
|
SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
|
||||||
|
output.columnData = createColumnInfoData(&type, pSrc->info.rows);
|
||||||
|
|
||||||
|
*p = (int8_t *)output.columnData->pData;
|
||||||
SArray *pList = taosArrayInit(1, POINTER_BYTES);
|
SArray *pList = taosArrayInit(1, POINTER_BYTES);
|
||||||
taosArrayPush(pList, &pSrc);
|
taosArrayPush(pList, &pSrc);
|
||||||
|
|
||||||
FLT_ERR_RET(scalarCalculate(info->sclCtx.node, pList, &output));
|
FLT_ERR_RET(scalarCalculate(info->sclCtx.node, pList, &output));
|
||||||
taosArrayDestroy(pList);
|
taosArrayDestroy(pList);
|
||||||
// TODO Fix it
|
|
||||||
// *p = output.orig.data;
|
|
||||||
// output.orig.data = NULL;
|
|
||||||
//
|
|
||||||
// sclFreeParam(&output);
|
|
||||||
//
|
|
||||||
// int8_t *r = output.data;
|
|
||||||
// for (int32_t i = 0; i < output.num; ++i) {
|
|
||||||
// if (0 == *(r+i)) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
||||||
param->numOfRows = 1;
|
param->numOfRows = 1;
|
||||||
param->columnData = createColumnInfoData(&valueNode->node.resType, 1);
|
param->columnData = createColumnInfoData(&valueNode->node.resType, 1);
|
||||||
if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type) {
|
if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type) {
|
||||||
colDataAppend(param->columnData, 0, NULL, true);
|
colDataAppendNULL(param->columnData, 0);
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(param->columnData, 0, nodesGetValueFromNode(valueNode), false);
|
colDataAppend(param->columnData, 0, nodesGetValueFromNode(valueNode), false);
|
||||||
}
|
}
|
||||||
|
@ -311,12 +311,10 @@ int32_t sclExecFunction(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *outp
|
||||||
SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (int32_t i = 0; i < rowNum; ++i) {
|
code = (*ffpSet.process)(params, node->pParameterList->length, output);
|
||||||
code = (*ffpSet.process)(params, node->pParameterList->length, output);
|
if (code) {
|
||||||
if (code) {
|
sclError("scalar function exec failed, funcId:%d, code:%s", node->funcId, tstrerror(code));
|
||||||
sclError("scalar function exec failed, funcId:%d, code:%s", node->funcId, tstrerror(code));
|
SCL_ERR_JRET(code);
|
||||||
SCL_ERR_JRET(code);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
@ -447,7 +445,6 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
|
||||||
*pNode = (SNode*)res;
|
*pNode = (SNode*)res;
|
||||||
|
|
||||||
sclFreeParam(&output);
|
sclFreeParam(&output);
|
||||||
|
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -689,8 +686,9 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SScalarCtx ctx = {.code = 0, .pBlockList = pBlockList};
|
SScalarCtx ctx = {.code = 0, .pBlockList = pBlockList};
|
||||||
|
|
||||||
// TODO: OPT performance
|
// TODO: OPT performance
|
||||||
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
if (NULL == ctx.pRes) {
|
if (NULL == ctx.pRes) {
|
||||||
sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM);
|
sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM);
|
||||||
SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
|
|
@ -158,23 +158,23 @@ _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) {
|
||||||
|
|
||||||
static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t rowIndex) {
|
static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t rowIndex) {
|
||||||
int64_t value = strtoll(buf, NULL, 10);
|
int64_t value = strtoll(buf, NULL, 10);
|
||||||
colDataAppend(pOut->columnData, rowIndex, (char*) &value, false);
|
colDataAppendInt64(pOut->columnData, rowIndex, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t rowIndex) {
|
static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t rowIndex) {
|
||||||
uint64_t value = strtoull(buf, NULL, 10);
|
uint64_t value = strtoull(buf, NULL, 10);
|
||||||
colDataAppend(pOut->columnData, rowIndex, (char*) &value, false);
|
colDataAppendInt64(pOut->columnData, rowIndex, (int64_t*) &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void varToFloat(char *buf, SScalarParam* pOut, int32_t rowIndex) {
|
static FORCE_INLINE void varToFloat(char *buf, SScalarParam* pOut, int32_t rowIndex) {
|
||||||
double value = strtod(buf, NULL);
|
double value = strtod(buf, NULL);
|
||||||
colDataAppend(pOut->columnData, rowIndex, (char*) &value, false);
|
colDataAppendDouble(pOut->columnData, rowIndex, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void varToBool(char *buf, SScalarParam* pOut, int32_t rowIndex) {
|
static FORCE_INLINE void varToBool(char *buf, SScalarParam* pOut, int32_t rowIndex) {
|
||||||
int64_t value = strtoll(buf, NULL, 10);
|
int64_t value = strtoll(buf, NULL, 10);
|
||||||
bool v = (value != 0)? true:false;
|
bool v = (value != 0)? true:false;
|
||||||
colDataAppend(pOut->columnData, rowIndex, (char*) &v, false);
|
colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*) &v);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, int32_t inType, int32_t outType) {
|
int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, int32_t inType, int32_t outType) {
|
||||||
|
@ -198,7 +198,7 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in
|
||||||
pOut->numOfRows = pIn->numOfRows;
|
pOut->numOfRows = pIn->numOfRows;
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
||||||
if (colDataIsNull(pIn->columnData, pIn->numOfRows, i, NULL)) {
|
if (colDataIsNull(pIn->columnData, pIn->numOfRows, i, NULL)) {
|
||||||
colDataAppend(pOut->columnData, i, NULL, true);
|
colDataAppendNULL(pOut->columnData, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,13 +242,13 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut) {
|
||||||
case TSDB_DATA_TYPE_BOOL: {
|
case TSDB_DATA_TYPE_BOOL: {
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppend(pOutputCol, i, NULL, true);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool value = 0;
|
bool value = 0;
|
||||||
GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppend(pOutputCol, i, (char*) &value, false);
|
colDataAppendInt8(pOutputCol, i, (int8_t*) &value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -259,13 +259,13 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut) {
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP: {
|
case TSDB_DATA_TYPE_TIMESTAMP: {
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppend(pOutputCol, i, NULL, true);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t value = 0;
|
int64_t value = 0;
|
||||||
GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppend(pOutputCol, i, (char *)&value, false);
|
colDataAppendInt64(pOutputCol, i, &value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -275,26 +275,26 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut) {
|
||||||
case TSDB_DATA_TYPE_UBIGINT:
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppend(pOutputCol, i, NULL, true);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t value = 0;
|
uint64_t value = 0;
|
||||||
GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppend(pOutputCol, i, (char*) &value, false);
|
colDataAppendInt64(pOutputCol, i, (int64_t*)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppend(pOutputCol, i, NULL, true);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppend(pOutputCol, i, (char*) &value, false);
|
colDataAppendDouble(pOutputCol, i, &value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -445,7 +445,7 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
|
||||||
double *output = (double *)pOutputCol->pData;
|
double *output = (double *)pOutputCol->pData;
|
||||||
|
|
||||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||||
// TODO set numOfRows NULL value
|
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||||
} else {
|
} else {
|
||||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||||
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) + getVectorDoubleValueFnRight(pRightCol->pData, 0);
|
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) + getVectorDoubleValueFnRight(pRightCol->pData, 0);
|
||||||
|
@ -527,7 +527,7 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
|
||||||
double *output = (double *)pOutputCol->pData;
|
double *output = (double *)pOutputCol->pData;
|
||||||
|
|
||||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||||
// TODO set numOfRows NULL value
|
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||||
} else {
|
} else {
|
||||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||||
*output = (getVectorDoubleValueFnLeft(pLeftCol->pData, i) - getVectorDoubleValueFnRight(pRightCol->pData, 0)) * factor;
|
*output = (getVectorDoubleValueFnLeft(pLeftCol->pData, i) - getVectorDoubleValueFnRight(pRightCol->pData, 0)) * factor;
|
||||||
|
@ -586,7 +586,7 @@ static void vectorMathMultiplyHelper(SColumnInfoData* pLeftCol, SColumnInfoData*
|
||||||
double *output = (double *)pOutputCol->pData;
|
double *output = (double *)pOutputCol->pData;
|
||||||
|
|
||||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||||
// TODO set numOfRows NULL value
|
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||||
} else {
|
} else {
|
||||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||||
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) * getVectorDoubleValueFnRight(pRightCol->pData, 0);
|
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) * getVectorDoubleValueFnRight(pRightCol->pData, 0);
|
||||||
|
@ -666,7 +666,7 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
|
||||||
|
|
||||||
} else if (pLeft->numOfRows == 1) {
|
} else if (pLeft->numOfRows == 1) {
|
||||||
if (colDataIsNull_f(pLeftCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
if (colDataIsNull_f(pLeftCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||||
// TODO set numOfRows NULL value
|
colDataAppendNNULL(pOutputCol, 0, pRight->numOfRows);
|
||||||
} else {
|
} else {
|
||||||
for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) {
|
for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) {
|
||||||
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, 0) / getVectorDoubleValueFnRight(pRightCol->pData, i);
|
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, 0) / getVectorDoubleValueFnRight(pRightCol->pData, i);
|
||||||
|
@ -678,7 +678,7 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
|
||||||
}
|
}
|
||||||
} else if (pRight->numOfRows == 1) {
|
} else if (pRight->numOfRows == 1) {
|
||||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||||
// TODO set numOfRows NULL value
|
colDataAppendNNULL(pOutputCol, 0, pLeft->numOfRows);
|
||||||
} else {
|
} else {
|
||||||
for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) {
|
for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) {
|
||||||
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) / getVectorDoubleValueFnRight(pRightCol->pData, 0);
|
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) / getVectorDoubleValueFnRight(pRightCol->pData, 0);
|
||||||
|
@ -714,14 +714,14 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
|
||||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||||
if (colDataIsNull_f(pLeftCol->nullbitmap, i) || colDataIsNull_f(pRightCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pLeftCol->nullbitmap, i) || colDataIsNull_f(pRightCol->nullbitmap, i)) {
|
||||||
colDataAppend(pOutputCol, i, NULL, true);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, i);
|
double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, i);
|
||||||
double rx = getVectorDoubleValueFnRight(pRightCol->pData, i);
|
double rx = getVectorDoubleValueFnRight(pRightCol->pData, i);
|
||||||
if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx)) {
|
if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx)) {
|
||||||
colDataAppend(pOutputCol, i, NULL, true);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,17 +730,17 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
|
||||||
} else if (pLeft->numOfRows == 1) {
|
} else if (pLeft->numOfRows == 1) {
|
||||||
double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, 0);
|
double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, 0);
|
||||||
if (colDataIsNull_f(pLeftCol->nullbitmap, 0) || isnan(lx) || isinf(lx)) { // Set pLeft->numOfRows NULL value
|
if (colDataIsNull_f(pLeftCol->nullbitmap, 0) || isnan(lx) || isinf(lx)) { // Set pLeft->numOfRows NULL value
|
||||||
// TODO set numOfRows NULL value
|
colDataAppendNNULL(pOutputCol, 0, pRight->numOfRows);
|
||||||
} else {
|
} else {
|
||||||
for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) {
|
for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) {
|
||||||
if (colDataIsNull_f(pRightCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pRightCol->nullbitmap, i)) {
|
||||||
colDataAppend(pOutputCol, i, NULL, true);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double rx = getVectorDoubleValueFnRight(pRightCol->pData, i);
|
double rx = getVectorDoubleValueFnRight(pRightCol->pData, i);
|
||||||
if (isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) {
|
if (isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) {
|
||||||
colDataAppend(pOutputCol, i, NULL, true);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,17 +750,17 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
|
||||||
} else if (pRight->numOfRows == 1) {
|
} else if (pRight->numOfRows == 1) {
|
||||||
double rx = getVectorDoubleValueFnRight(pRightCol->pData, 0);
|
double rx = getVectorDoubleValueFnRight(pRightCol->pData, 0);
|
||||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0) || FLT_EQUAL(rx, 0)) { // Set pLeft->numOfRows NULL value
|
if (colDataIsNull_f(pRightCol->nullbitmap, 0) || FLT_EQUAL(rx, 0)) { // Set pLeft->numOfRows NULL value
|
||||||
// TODO set numOfRows NULL value
|
colDataAppendNNULL(pOutputCol, 0, pLeft->numOfRows);
|
||||||
} else {
|
} else {
|
||||||
for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) {
|
for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) {
|
||||||
if (colDataIsNull_f(pLeftCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pLeftCol->nullbitmap, i)) {
|
||||||
colDataAppend(pOutputCol, i, NULL, true);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, i);
|
double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, i);
|
||||||
if (isnan(lx) || isinf(lx)) {
|
if (isnan(lx) || isinf(lx)) {
|
||||||
colDataAppend(pOutputCol, i, NULL, true);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -831,7 +831,7 @@ static void vectorBitAndHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRigh
|
||||||
double *output = (double *)pOutputCol->pData;
|
double *output = (double *)pOutputCol->pData;
|
||||||
|
|
||||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||||
// TODO set numOfRows NULL value
|
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||||
} else {
|
} else {
|
||||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||||
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) & getVectorBigintValueFnRight(pRightCol->pData, 0);
|
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) & getVectorBigintValueFnRight(pRightCol->pData, 0);
|
||||||
|
@ -888,7 +888,7 @@ static void vectorBitOrHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRight
|
||||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||||
|
|
||||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||||
// TODO set numOfRows NULL value
|
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||||
} else {
|
} else {
|
||||||
int64_t rx = getVectorBigintValueFnRight(pRightCol->pData, 0);
|
int64_t rx = getVectorBigintValueFnRight(pRightCol->pData, 0);
|
||||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||||
|
@ -947,56 +947,51 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
|
||||||
|
|
||||||
if (pRight->pHashFilter != NULL) {
|
if (pRight->pHashFilter != NULL) {
|
||||||
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
||||||
if (colDataIsNull(pLeft->columnData, pLeft->numOfRows, i, NULL) /*||
|
if (colDataIsNull_s(pLeft->columnData, i)) {
|
||||||
colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL)*/) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pLeftData = colDataGetData(pLeft->columnData, i);
|
char *pLeftData = colDataGetData(pLeft->columnData, i);
|
||||||
bool res = filterDoCompare(fp, optr, pLeftData, pRight->pHashFilter);
|
bool res = filterDoCompare(fp, optr, pLeftData, pRight->pHashFilter);
|
||||||
colDataAppend(pOut->columnData, i, (char *)&res, false);
|
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||||
for (; i < pRight->numOfRows && i >= 0; i += step) {
|
for (; i < pRight->numOfRows && i >= 0; i += step) {
|
||||||
if (colDataIsNull(pLeft->columnData, pLeft->numOfRows, i, NULL) ||
|
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i)) {
|
||||||
colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL)) {
|
|
||||||
continue; // TODO set null or ignore
|
continue; // TODO set null or ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pLeftData = colDataGetData(pLeft->columnData, i);
|
char *pLeftData = colDataGetData(pLeft->columnData, i);
|
||||||
char *pRightData = colDataGetData(pRight->columnData, i);
|
char *pRightData = colDataGetData(pRight->columnData, i);
|
||||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||||
colDataAppend(pOut->columnData, i, (char *)&res, false);
|
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||||
}
|
}
|
||||||
} else if (pRight->numOfRows == 1) {
|
} else if (pRight->numOfRows == 1) {
|
||||||
char *pRightData = colDataGetData(pRight->columnData, 0);
|
char *pRightData = colDataGetData(pRight->columnData, 0);
|
||||||
ASSERT(pLeft->pHashFilter == NULL);
|
ASSERT(pLeft->pHashFilter == NULL);
|
||||||
|
|
||||||
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
||||||
if (colDataIsNull(pLeft->columnData, pLeft->numOfRows, i, NULL) /*||
|
if (colDataIsNull_s(pLeft->columnData, i)) {
|
||||||
colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL)*/) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pLeftData = colDataGetData(pLeft->columnData, i);
|
char *pLeftData = colDataGetData(pLeft->columnData, i);
|
||||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||||
colDataAppend(pOut->columnData, i, (char *)&res, false);
|
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||||
}
|
}
|
||||||
} else if (pLeft->numOfRows == 1) {
|
} else if (pLeft->numOfRows == 1) {
|
||||||
char *pLeftData = colDataGetData(pLeft->columnData, 0);
|
char *pLeftData = colDataGetData(pLeft->columnData, 0);
|
||||||
|
|
||||||
for (; i >= 0 && i < pRight->numOfRows; i += step) {
|
for (; i >= 0 && i < pRight->numOfRows; i += step) {
|
||||||
if (colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL) /*||
|
if (colDataIsNull_s(pRight->columnData, i)) {
|
||||||
colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL)*/) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pRightData = colDataGetData(pLeft->columnData, i);
|
char *pRightData = colDataGetData(pLeft->columnData, i);
|
||||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||||
colDataAppend(pOut->columnData, i, (char *)&res, false);
|
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1077,23 +1072,16 @@ void vectorNotMatch(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOu
|
||||||
|
|
||||||
void vectorIsNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
void vectorIsNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
||||||
for(int32_t i = 0; i < pLeft->numOfRows; ++i) {
|
for(int32_t i = 0; i < pLeft->numOfRows; ++i) {
|
||||||
int8_t v = 0;
|
int8_t v = colDataIsNull_s(pLeft->columnData, i)? 1:0;
|
||||||
if (colDataIsNull(pLeft->columnData, pLeft->numOfRows, i, NULL)) {
|
colDataAppendInt8(pOut->columnData, i, &v);
|
||||||
v = 1;
|
|
||||||
}
|
|
||||||
colDataAppend(pOut->columnData, i, (char*) &v, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pOut->numOfRows = pLeft->numOfRows;
|
pOut->numOfRows = pLeft->numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vectorNotNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
void vectorNotNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
||||||
for(int32_t i = 0; i < pLeft->numOfRows; ++i) {
|
for(int32_t i = 0; i < pLeft->numOfRows; ++i) {
|
||||||
int8_t v = 1;
|
int8_t v = colDataIsNull_s(pLeft->columnData, i)? 0:1;
|
||||||
if (colDataIsNull(pLeft->columnData, pLeft->numOfRows, i, NULL)) {
|
colDataAppendInt8(pOut->columnData, i, &v);
|
||||||
v = 0;
|
|
||||||
}
|
|
||||||
colDataAppend(pOut->columnData, i, (char*) &v, false);
|
|
||||||
}
|
}
|
||||||
pOut->numOfRows = pLeft->numOfRows;
|
pOut->numOfRows = pLeft->numOfRows;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@ int32_t taosNewProc(char **args) {
|
||||||
int32_t pid = fork();
|
int32_t pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
args[0] = tsProcPath;
|
args[0] = tsProcPath;
|
||||||
close(STDIN_FILENO);
|
// close(STDIN_FILENO);
|
||||||
close(STDOUT_FILENO);
|
close(STDOUT_FILENO);
|
||||||
close(STDERR_FILENO);
|
// close(STDERR_FILENO);
|
||||||
return execvp(tsProcPath, args);
|
return execvp(tsProcPath, args);
|
||||||
} else {
|
} else {
|
||||||
return pid;
|
return pid;
|
||||||
|
@ -33,7 +33,7 @@ int32_t taosNewProc(char **args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosWaitProc(int32_t pid) {
|
void taosWaitProc(int32_t pid) {
|
||||||
int32_t status = 0;
|
int32_t status = -1;
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
int32_t taosCreateShm(SShm* pShm, int32_t shmsize) {
|
int32_t taosCreateShm(SShm* pShm, int32_t key, int32_t shmsize) {
|
||||||
pShm->id = -1;
|
pShm->id = -1;
|
||||||
|
|
||||||
int32_t shmid = shmget(0X95279527, shmsize, IPC_CREAT | 0600);
|
int32_t shmid = shmget(0X95270000 + key, shmsize, IPC_CREAT | 0600);
|
||||||
if (shmid < 0) {
|
if (shmid < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ void taosSetSignal(int32_t signum, FSignalHandler sigfp) {
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
memset(&act, 0, sizeof(act));
|
memset(&act, 0, sizeof(act));
|
||||||
#if 1
|
#if 1
|
||||||
act.sa_flags = SA_SIGINFO;
|
act.sa_flags = SA_SIGINFO | SA_RESTART;
|
||||||
act.sa_sigaction = (FLinuxSignalHandler)sigfp;
|
act.sa_sigaction = (FLinuxSignalHandler)sigfp;
|
||||||
#else
|
#else
|
||||||
act.sa_handler = sigfp;
|
act.sa_handler = sigfp;
|
||||||
|
|
|
@ -347,12 +347,16 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
|
||||||
taosThreadMutexInit(&tsLogObj.logMutex, NULL);
|
taosThreadMutexInit(&tsLogObj.logMutex, NULL);
|
||||||
|
|
||||||
taosUmaskFile(0);
|
taosUmaskFile(0);
|
||||||
tsLogObj.logHandle->pFile = taosOpenFile(fileName, TD_FILE_CTEATE | TD_FILE_WRITE);
|
TdFilePtr pFile = taosOpenFile(fileName, TD_FILE_CTEATE | TD_FILE_WRITE);
|
||||||
|
|
||||||
if (tsLogObj.logHandle->pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
printf("\nfailed to open log file:%s, reason:%s\n", fileName, strerror(errno));
|
printf("\nfailed to open log file:%s, reason:%s\n", fileName, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
TdFilePtr pOldFile = tsLogObj.logHandle->pFile;
|
||||||
|
tsLogObj.logHandle->pFile = pFile;
|
||||||
|
taosUnLockLogFile(pOldFile);
|
||||||
|
taosCloseFile(&pOldFile);
|
||||||
taosLockLogFile(tsLogObj.logHandle->pFile);
|
taosLockLogFile(tsLogObj.logHandle->pFile);
|
||||||
|
|
||||||
// only an estimate for number of lines
|
// only an estimate for number of lines
|
||||||
|
|
|
@ -434,7 +434,9 @@ int32_t taosProcPutToChildQ(SProcObj *pProc, const void *pHead, int16_t headLen,
|
||||||
return taosProcQueuePush(pProc->pChildQueue, pHead, headLen, pBody, bodyLen, ftype);
|
return taosProcQueuePush(pProc->pChildQueue, pHead, headLen, pBody, bodyLen, ftype);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosProcPutToParentQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
void taosProcPutToParentQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
||||||
ProcFuncType ftype) {
|
ProcFuncType ftype) {
|
||||||
return taosProcQueuePush(pProc->pParentQueue, pHead, headLen, pBody, bodyLen, ftype);
|
while (taosProcQueuePush(pProc->pParentQueue, pHead, headLen, pBody, bodyLen, ftype) != 0) {
|
||||||
|
taosMsleep(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,4 +52,10 @@
|
||||||
./test.sh -f tsim/stable/values.sim
|
./test.sh -f tsim/stable/values.sim
|
||||||
./test.sh -f tsim/stable/vnode3.sim
|
./test.sh -f tsim/stable/vnode3.sim
|
||||||
|
|
||||||
|
|
||||||
|
# --- for multi process mode
|
||||||
|
./test.sh -f tsim/user/basic1.sim -m
|
||||||
|
./test.sh -f tsim/stable/vnode3.sim -m
|
||||||
|
./test.sh -f tsim/tmq/basic.sim -m
|
||||||
|
|
||||||
#======================b1-end===============
|
#======================b1-end===============
|
||||||
|
|
|
@ -5,18 +5,12 @@ set +e
|
||||||
|
|
||||||
echo "Executing deploy.sh"
|
echo "Executing deploy.sh"
|
||||||
|
|
||||||
if [ $# != 4 ]; then
|
|
||||||
echo "argument list need input : "
|
|
||||||
echo " -n nodeName"
|
|
||||||
echo " -i nodePort"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
UNAME_BIN=`which uname`
|
UNAME_BIN=`which uname`
|
||||||
OS_TYPE=`$UNAME_BIN`
|
OS_TYPE=`$UNAME_BIN`
|
||||||
NODE_NAME=
|
NODE_NAME=
|
||||||
NODE=
|
NODE=
|
||||||
while getopts "n:i:" arg
|
MULTIPROCESS=0
|
||||||
|
while getopts "n:i:m" arg
|
||||||
do
|
do
|
||||||
case $arg in
|
case $arg in
|
||||||
n)
|
n)
|
||||||
|
@ -25,6 +19,9 @@ do
|
||||||
i)
|
i)
|
||||||
NODE=$OPTARG
|
NODE=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
m)
|
||||||
|
MULTIPROCESS=1
|
||||||
|
;;
|
||||||
?)
|
?)
|
||||||
echo "unkonw argument"
|
echo "unkonw argument"
|
||||||
;;
|
;;
|
||||||
|
@ -145,5 +142,5 @@ echo "statusInterval 1" >> $TAOS_CFG
|
||||||
echo "asyncLog 0" >> $TAOS_CFG
|
echo "asyncLog 0" >> $TAOS_CFG
|
||||||
echo "locale en_US.UTF-8" >> $TAOS_CFG
|
echo "locale en_US.UTF-8" >> $TAOS_CFG
|
||||||
echo "telemetryReporting 0" >> $TAOS_CFG
|
echo "telemetryReporting 0" >> $TAOS_CFG
|
||||||
echo "multiProcess 0" >> $TAOS_CFG
|
echo "multiProcess ${MULTIPROCESS}" >> $TAOS_CFG
|
||||||
echo " " >> $TAOS_CFG
|
echo " " >> $TAOS_CFG
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
##################################################
|
##################################################
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
#set -x
|
|
||||||
|
|
||||||
FILE_NAME=
|
FILE_NAME=
|
||||||
RELEASE=0
|
RELEASE=0
|
||||||
|
@ -16,7 +15,8 @@ VALGRIND=0
|
||||||
UNIQUE=0
|
UNIQUE=0
|
||||||
UNAME_BIN=`which uname`
|
UNAME_BIN=`which uname`
|
||||||
OS_TYPE=`$UNAME_BIN`
|
OS_TYPE=`$UNAME_BIN`
|
||||||
while getopts "f:avu" arg
|
MULTIPROCESS=0
|
||||||
|
while getopts "f:avum" arg
|
||||||
do
|
do
|
||||||
case $arg in
|
case $arg in
|
||||||
f)
|
f)
|
||||||
|
@ -28,6 +28,9 @@ do
|
||||||
u)
|
u)
|
||||||
UNIQUE=1
|
UNIQUE=1
|
||||||
;;
|
;;
|
||||||
|
m)
|
||||||
|
MULTIPROCESS=1
|
||||||
|
;;
|
||||||
?)
|
?)
|
||||||
echo "unknow argument"
|
echo "unknow argument"
|
||||||
;;
|
;;
|
||||||
|
@ -125,8 +128,13 @@ if [ -n "$FILE_NAME" ]; then
|
||||||
echo valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME
|
echo valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME
|
||||||
valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME
|
valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME
|
||||||
else
|
else
|
||||||
echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f $FILE_NAME
|
if [[ $MULTIPROCESS -eq 1 ]];then
|
||||||
$PROGRAM -c $CFG_DIR -f $FILE_NAME
|
echo "ExcuteCmd(multiprocess):" $PROGRAM -m -c $CFG_DIR -f $FILE_NAME
|
||||||
|
$PROGRAM -m -c $CFG_DIR -f $FILE_NAME
|
||||||
|
else
|
||||||
|
echo "ExcuteCmd(singleprocess):" $PROGRAM -c $CFG_DIR -f $FILE_NAME
|
||||||
|
$PROGRAM -c $CFG_DIR -f $FILE_NAME
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f basicSuite.sim
|
echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f basicSuite.sim
|
||||||
|
|
|
@ -27,7 +27,15 @@ sql connect
|
||||||
$vgroups = 4
|
$vgroups = 4
|
||||||
$dbNamme = d0
|
$dbNamme = d0
|
||||||
|
|
||||||
print =============== create database $dbNamme vgroups $vgroups
|
print ====> create database d1 precision 'us'
|
||||||
|
sql create database d1 precision 'us'
|
||||||
|
sql use d1
|
||||||
|
sql create table dev_001 (ts timestamp ,i timestamp ,j int)
|
||||||
|
sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4)
|
||||||
|
sql create table secondts(ts timestamp,t2 timestamp,i int)
|
||||||
|
sql insert into secondts values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4)
|
||||||
|
|
||||||
|
print ====> create database $dbNamme vgroups $vgroups
|
||||||
sql create database $dbNamme vgroups $vgroups
|
sql create database $dbNamme vgroups $vgroups
|
||||||
sql show databases
|
sql show databases
|
||||||
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
@ -41,17 +49,33 @@ sql create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50)
|
||||||
sql create table if not exists dev_001 using st tags("dev_01", "tag_01")
|
sql create table if not exists dev_001 using st tags("dev_01", "tag_01")
|
||||||
sql create table if not exists dev_002 using st tags("dev_02", "tag_02")
|
sql create table if not exists dev_002 using st tags("dev_02", "tag_02")
|
||||||
|
|
||||||
sql INSERT INTO dev_001 VALUES('2020-05-13 10:00:00.000', 1)('2020-05-13 10:00:00.005', 2)('2020-05-13 10:00:00.011', 3)
|
sql INSERT INTO dev_001 VALUES('2020-05-13 10:00:00.000', 1)
|
||||||
sql INSERT INTO dev_001 VALUES('2020-05-13 10:00:01.011', 4)('2020-05-13 10:00:01.611', 5)('2020-05-13 10:00:02.612', 6)
|
sql INSERT INTO dev_001 VALUES('2020-05-13 10:00:00.005', 2)
|
||||||
sql INSERT INTO dev_001 VALUES('2020-05-13 10:01:02.612', 7)('2020-05-13 10:02:02.612', 8)('2020-05-13 10:03:02.613', 9)
|
sql INSERT INTO dev_001 VALUES('2020-05-13 10:00:00.011', 3)
|
||||||
sql INSERT INTO dev_001 VALUES('2020-05-13 11:00:00.000', 10)('2020-05-13 12:00:00.000', 11)('2020-05-13 13:00:00.001', 12)
|
sql INSERT INTO dev_001 VALUES('2020-05-13 10:00:01.011', 4)
|
||||||
sql INSERT INTO dev_001 VALUES('2020-05-14 13:00:00.001', 13)('2020-05-15 14:00:00.000', 14)('2020-05-20 10:00:00.000', 15)
|
sql INSERT INTO dev_001 VALUES('2020-05-13 10:00:01.611', 5)
|
||||||
|
sql INSERT INTO dev_001 VALUES('2020-05-13 10:00:02.612', 6)
|
||||||
|
sql INSERT INTO dev_001 VALUES('2020-05-13 10:01:02.612', 7)
|
||||||
|
sql INSERT INTO dev_001 VALUES('2020-05-13 10:02:02.612', 8)
|
||||||
|
sql INSERT INTO dev_001 VALUES('2020-05-13 10:03:02.613', 9)
|
||||||
|
sql INSERT INTO dev_001 VALUES('2020-05-13 11:00:00.000', 10)
|
||||||
|
sql INSERT INTO dev_001 VALUES('2020-05-13 12:00:00.000', 11)
|
||||||
|
sql INSERT INTO dev_001 VALUES('2020-05-13 13:00:00.001', 12)
|
||||||
|
sql INSERT INTO dev_001 VALUES('2020-05-14 13:00:00.001', 13)
|
||||||
|
sql INSERT INTO dev_001 VALUES('2020-05-15 14:00:00.000', 14)
|
||||||
|
sql INSERT INTO dev_001 VALUES('2020-05-20 10:00:00.000', 15)
|
||||||
sql INSERT INTO dev_001 VALUES('2020-05-27 10:00:00.001', 16)
|
sql INSERT INTO dev_001 VALUES('2020-05-27 10:00:00.001', 16)
|
||||||
|
|
||||||
sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.000', 1)('2020-05-13 10:00:00.005', 2)('2020-05-13 10:00:00.009', 3)
|
sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.000', 1)
|
||||||
sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.0021', 4)('2020-05-13 10:00:00.031', 5)('2020-05-13 10:00:00.036', 6)('2020-05-13 10:00:00.51', 7)
|
sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.005', 2)
|
||||||
|
sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.009', 3)
|
||||||
|
sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.0021', 4)
|
||||||
|
sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.031', 5)
|
||||||
|
sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.036', 6)
|
||||||
|
sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.51', 7)
|
||||||
|
|
||||||
|
$loop_test = 0
|
||||||
|
loop_test_pos:
|
||||||
|
|
||||||
# session(ts,5a)
|
# session(ts,5a)
|
||||||
print ====> select count(*) from dev_001 session(ts,5a)
|
print ====> select count(*) from dev_001 session(ts,5a)
|
||||||
|
@ -74,156 +98,241 @@ if $data01 != 2 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
#
|
print ====> select count(*) from (select * from dev_001) session(ts,5a)
|
||||||
# # session(ts,5a) main query
|
sql select count(*) from (select * from dev_001) session(ts,5a)
|
||||||
# tdSql.query("select count(*) from (select * from dev_001) session(ts,5a)")
|
if $rows != 15 then
|
||||||
# tdSql.checkRows(15)
|
return -1
|
||||||
# tdSql.checkData(0, 1, 2)
|
endi
|
||||||
#
|
if $data01 != 2 then
|
||||||
#
|
return -1
|
||||||
# # session(ts,1s)
|
endi
|
||||||
# tdSql.query("select count(*) from dev_001 session(ts,1s)")
|
|
||||||
# tdSql.checkRows(12)
|
print ====> select count(*) from dev_001 session(ts,1s)
|
||||||
# tdSql.checkData(0, 1, 5)
|
sql select count(*) from dev_001 session(ts,1s)
|
||||||
#
|
if $rows != 12 then
|
||||||
# # session(ts,1s) main query
|
return -1
|
||||||
# tdSql.query("select count(*) from (select * from dev_001) session(ts,1s)")
|
endi
|
||||||
# tdSql.checkRows(12)
|
if $data01 != 5 then
|
||||||
# tdSql.checkData(0, 1, 5)
|
return -1
|
||||||
#
|
endi
|
||||||
# tdSql.query("select count(*) from dev_001 session(ts,1000a)")
|
|
||||||
# tdSql.checkRows(12)
|
print ====> select count(*) from (select * from dev_001) session(ts,1s)
|
||||||
# tdSql.checkData(0, 1, 5)
|
sql select count(*) from (select * from dev_001) session(ts,1s)
|
||||||
#
|
if $rows != 12 then
|
||||||
# tdSql.query("select count(*) from (select * from dev_001) session(ts,1000a)")
|
return -1
|
||||||
# tdSql.checkRows(12)
|
endi
|
||||||
# tdSql.checkData(0, 1, 5)
|
if $data01 != 5 then
|
||||||
#
|
return -1
|
||||||
# # session(ts,1m)
|
endi
|
||||||
# tdSql.query("select count(*) from dev_001 session(ts,1m)")
|
|
||||||
# tdSql.checkRows(9)
|
print ====> select count(*) from dev_001 session(ts,1000a)
|
||||||
# tdSql.checkData(0, 1, 8)
|
sql select count(*) from dev_001 session(ts,1000a)
|
||||||
#
|
if $rows != 12 then
|
||||||
# # session(ts,1m)
|
return -1
|
||||||
# tdSql.query("select count(*) from (select * from dev_001) session(ts,1m)")
|
endi
|
||||||
# tdSql.checkRows(9)
|
if $data01 != 5 then
|
||||||
# tdSql.checkData(0, 1, 8)
|
return -1
|
||||||
#
|
endi
|
||||||
# # session(ts,1h)
|
|
||||||
# tdSql.query("select count(*) from dev_001 session(ts,1h)")
|
print ====> select count(*) from (select * from dev_001) session(ts,1000a)
|
||||||
# tdSql.checkRows(6)
|
sql select count(*) from (select * from dev_001) session(ts,1000a)
|
||||||
# tdSql.checkData(0, 1, 11)
|
if $rows != 12 then
|
||||||
#
|
return -1
|
||||||
# # session(ts,1h)
|
endi
|
||||||
# tdSql.query("select count(*) from (select * from dev_001) session(ts,1h)")
|
if $data01 != 5 then
|
||||||
# tdSql.checkRows(6)
|
return -1
|
||||||
# tdSql.checkData(0, 1, 11)
|
endi
|
||||||
#
|
|
||||||
# # session(ts,1d)
|
print ====> select count(*) from dev_001 session(ts,1m)
|
||||||
# tdSql.query("select count(*) from dev_001 session(ts,1d)")
|
sql select count(*) from dev_001 session(ts,1m)
|
||||||
# tdSql.checkRows(4)
|
if $rows != 9 then
|
||||||
# tdSql.checkData(0, 1, 13)
|
return -1
|
||||||
#
|
endi
|
||||||
# # session(ts,1d)
|
if $data01 != 8 then
|
||||||
# tdSql.query("select count(*) from (select * from dev_001) session(ts,1d)")
|
return -1
|
||||||
# tdSql.checkRows(4)
|
endi
|
||||||
# tdSql.checkData(0, 1, 13)
|
|
||||||
#
|
print ====> select count(*) from (select * from dev_001) session(ts,1m)
|
||||||
# # session(ts,1w)
|
sql select count(*) from (select * from dev_001) session(ts,1m)
|
||||||
# tdSql.query("select count(*) from dev_001 session(ts,1w)")
|
if $rows != 9 then
|
||||||
# tdSql.checkRows(2)
|
return -1
|
||||||
# tdSql.checkData(0, 1, 15)
|
endi
|
||||||
#
|
if $data01 != 8 then
|
||||||
# # session(ts,1w)
|
return -1
|
||||||
# tdSql.query("select count(*) from (select * from dev_001) session(ts,1w)")
|
endi
|
||||||
# tdSql.checkRows(2)
|
|
||||||
# tdSql.checkData(0, 1, 15)
|
print ====> select count(*) from dev_001 session(ts,1h)
|
||||||
#
|
sql select count(*) from dev_001 session(ts,1h)
|
||||||
# # session with where
|
if $rows != 6 then
|
||||||
# tdSql.query("select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d)")
|
return -1
|
||||||
#
|
endi
|
||||||
# tdSql.checkRows(2)
|
if $data01 != 11 then
|
||||||
# tdSql.checkData(0, 1, 13)
|
return -1
|
||||||
# tdSql.checkData(0, 2, 1)
|
endi
|
||||||
# tdSql.checkData(0, 3, 13)
|
|
||||||
# tdSql.checkData(0, 4, 7)
|
print ====> select count(*) from (select * from dev_001) session(ts,1h)
|
||||||
# tdSql.checkData(0, 5, 91)
|
sql select count(*) from (select * from dev_001) session(ts,1h)
|
||||||
# tdSql.checkData(0, 6, 1)
|
if $rows != 6 then
|
||||||
# tdSql.checkData(0, 7, 13)
|
return -1
|
||||||
# tdSql.checkData(0, 8, '{slop:1.000000, intercept:0.000000}')
|
endi
|
||||||
# tdSql.checkData(0, 9, 12)
|
if $data01 != 11 then
|
||||||
# tdSql.checkData(0, 10, 3.741657387)
|
return -1
|
||||||
# tdSql.checkData(0, 11, 1)
|
endi
|
||||||
# tdSql.checkData(1, 11, 14)
|
|
||||||
#
|
print ====> select count(*) from dev_001 session(ts,1d)
|
||||||
# # session with where main
|
sql select count(*) from dev_001 session(ts,1d)
|
||||||
#
|
if $rows != 4 then
|
||||||
# tdSql.query("select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1) from (select * from dev_001 where ts <'2020-05-20 0:0:0') session(ts,1d)")
|
return -1
|
||||||
#
|
endi
|
||||||
# tdSql.checkRows(2)
|
if $data01 != 13 then
|
||||||
# tdSql.checkData(0, 1, 13)
|
return -1
|
||||||
# tdSql.checkData(0, 2, 1)
|
endi
|
||||||
# tdSql.checkData(0, 3, 13)
|
|
||||||
# tdSql.checkData(0, 4, 7)
|
print ====> select count(*) from (select * from dev_001) session(ts,1d)
|
||||||
# tdSql.checkData(0, 5, 91)
|
sql select count(*) from (select * from dev_001) session(ts,1d)
|
||||||
# tdSql.checkData(0, 6, 1)
|
if $rows != 4 then
|
||||||
# tdSql.checkData(0, 7, 13)
|
return -1
|
||||||
# tdSql.checkData(0, 8, '{slop:1.000000, intercept:0.000000}')
|
endi
|
||||||
#
|
if $data01 != 13 then
|
||||||
# # tdsql err
|
return -1
|
||||||
# tdSql.error("select * from dev_001 session(ts,1w)")
|
endi
|
||||||
# tdSql.error("select count(*) from st session(ts,1w)")
|
|
||||||
# tdSql.error("select count(*) from dev_001 group by tagtype session(ts,1w) ")
|
print ====> select count(*) from dev_001 session(ts,1w)
|
||||||
# tdSql.error("select count(*) from dev_001 session(ts,1n)")
|
sql select count(*) from dev_001 session(ts,1w)
|
||||||
# tdSql.error("select count(*) from dev_001 session(ts,1y)")
|
if $rows != 2 then
|
||||||
# tdSql.error("select count(*) from dev_001 session(ts,0s)")
|
return -1
|
||||||
# tdSql.error("select count(*) from dev_001 session(i,1y)")
|
endi
|
||||||
# tdSql.error("select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0'")
|
if $data01 != 15 then
|
||||||
#
|
return -1
|
||||||
# #test precision us
|
endi
|
||||||
# tdSql.execute("create database test precision 'us'")
|
|
||||||
# tdSql.execute("use test")
|
print ====> select count(*) from (select * from dev_001) session(ts,1w)
|
||||||
# tdSql.execute("create table dev_001 (ts timestamp ,i timestamp ,j int)")
|
sql select count(*) from (select * from dev_001) session(ts,1w)
|
||||||
# tdSql.execute("insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4)")
|
if $rows != 2 then
|
||||||
#
|
return -1
|
||||||
# # session(ts,1u)
|
endi
|
||||||
# tdSql.query("select count(*) from dev_001 session(ts,1u)")
|
if $data01 != 15 then
|
||||||
# tdSql.checkRows(2)
|
return -1
|
||||||
# tdSql.checkData(0, 1, 3)
|
endi
|
||||||
# tdSql.error("select count(*) from dev_001 session(i,1s)")
|
|
||||||
# # test second timestamp fileds
|
print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d)
|
||||||
# tdSql.execute("create table secondts(ts timestamp,t2 timestamp,i int)")
|
sql select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d)
|
||||||
# tdSql.error("select count(*) from secondts session(t2,2s)")
|
if $rows != 2 then
|
||||||
#
|
return -1
|
||||||
#
|
endi
|
||||||
|
if $data01 != 13 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data02 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data03 != 13 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data04 != 7 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data05 != 91 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data06 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data07 != 13 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data08 != @{slop:1.000000, intercept:0.000000}@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data09 != 12 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
# $data0-10 != 3.741657387
|
||||||
|
# $data0-11 != 1
|
||||||
|
# $data1-11 != 14
|
||||||
|
|
||||||
|
print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1) from (select * from dev_001 where ts <'2020-05-20 0:0:0') session(ts,1d)
|
||||||
|
sql select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1) from (select * from dev_001 where ts <'2020-05-20 0:0:0') session(ts,1d)
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data01 != 13 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data02 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data03 != 13 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data04 != 7 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data05 != 91 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data06 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data07 != 13 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data08 != @{slop:1.000000, intercept:0.000000}@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql_error select * from dev_001 session(ts,1w)
|
||||||
|
sql_error select count(*) from st session(ts,1w)
|
||||||
|
sql_error select count(*) from dev_001 group by tagtype session(ts,1w)
|
||||||
|
sql_error select count(*) from dev_001 session(ts,1n)
|
||||||
|
sql_error select count(*) from dev_001 session(ts,1y)
|
||||||
|
sql_error select count(*) from dev_001 session(ts,0s)
|
||||||
|
sql_error select count(*) from dev_001 session(i,1y)
|
||||||
|
sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0'
|
||||||
|
|
||||||
|
print ====> create database d1 precision 'us'
|
||||||
|
sql create database d1 precision 'us'
|
||||||
|
sql use d1
|
||||||
|
sql create table dev_001 (ts timestamp ,i timestamp ,j int)
|
||||||
|
sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4)
|
||||||
|
print ====> select count(*) from dev_001 session(ts,1u)
|
||||||
|
sql select count(*) from dev_001 session(ts,1u)
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data01 != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql_error select count(*) from dev_001 session(i,1s)
|
||||||
|
sql create table secondts(ts timestamp,t2 timestamp,i int)
|
||||||
|
sql_error select count(*) from secondts session(t2,2s)
|
||||||
|
|
||||||
|
|
||||||
#if $loop_test == 0 then
|
if $loop_test == 0 then
|
||||||
# print =============== stop and restart taosd
|
print =============== stop and restart taosd
|
||||||
# system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
# system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
#
|
|
||||||
# $loop_cnt = 0
|
$loop_cnt = 0
|
||||||
# check_dnode_ready_0:
|
check_dnode_ready_0:
|
||||||
# $loop_cnt = $loop_cnt + 1
|
$loop_cnt = $loop_cnt + 1
|
||||||
# sleep 200
|
sleep 200
|
||||||
# if $loop_cnt == 10 then
|
if $loop_cnt == 10 then
|
||||||
# print ====> dnode not ready!
|
print ====> dnode not ready!
|
||||||
# return -1
|
return -1
|
||||||
# endi
|
endi
|
||||||
# sql show dnodes
|
sql show dnodes
|
||||||
# print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
|
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
# if $data00 != 1 then
|
if $data00 != 1 then
|
||||||
# return -1
|
return -1
|
||||||
# endi
|
endi
|
||||||
# if $data04 != ready then
|
if $data04 != ready then
|
||||||
# goto check_dnode_ready_0
|
goto check_dnode_ready_0
|
||||||
# endi
|
endi
|
||||||
#
|
|
||||||
# $loop_test = 1
|
$loop_test = 1
|
||||||
# goto loop_test_pos
|
goto loop_test_pos
|
||||||
#endi
|
endi
|
||||||
#
|
|
||||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
|
|
@ -91,20 +91,23 @@ function runSimCaseOneByOnefq {
|
||||||
for ((i=$start;i<=$end;i++)) ; do
|
for ((i=$start;i<=$end;i++)) ; do
|
||||||
line=`sed -n "$i"p jenkins/basic.txt`
|
line=`sed -n "$i"p jenkins/basic.txt`
|
||||||
if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then
|
if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then
|
||||||
case=`echo $line | grep sim$ |awk '{print $NF}'`
|
#case=`echo $line | grep sim$ |awk '{print $NF}'`
|
||||||
|
case=`echo $line | grep -o ".*\.sim" |awk '{print $NF}'`
|
||||||
|
|
||||||
start_time=`date +%s`
|
start_time=`date +%s`
|
||||||
date +%F\ %T | tee -a out.log
|
date +%F\ %T | tee -a out.log
|
||||||
if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
|
if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
|
||||||
echo -n $case
|
#echo -n $case
|
||||||
./test.sh -f $case > case.log 2>&1 \
|
echo -n $line
|
||||||
|
$line > case.log 2>&1 \
|
||||||
&& \
|
&& \
|
||||||
([ -f ../../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
|
([ -f ../../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
|
||||||
([ -f ../../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \
|
([ -f ../../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \
|
||||||
( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && cat case.log )
|
( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && cat case.log )
|
||||||
else
|
else
|
||||||
echo -n $case
|
#echo -n $case
|
||||||
./test.sh -f $case > ../../sim/case.log 2>&1 && \
|
echo -n $line
|
||||||
|
$line > ../../sim/case.log 2>&1 && \
|
||||||
([ -f ../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
|
([ -f ../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
|
||||||
([ -f ../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \
|
([ -f ../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \
|
||||||
( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && pwd && cat ../../sim/case.log )
|
( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && pwd && cat ../../sim/case.log )
|
||||||
|
|
|
@ -155,6 +155,7 @@ extern int32_t simScriptSucced;
|
||||||
extern int32_t simDebugFlag;
|
extern int32_t simDebugFlag;
|
||||||
extern char simScriptDir[];
|
extern char simScriptDir[];
|
||||||
extern bool abortExecution;
|
extern bool abortExecution;
|
||||||
|
extern bool useMultiProcess;
|
||||||
|
|
||||||
SScript *simParseScript(char *fileName);
|
SScript *simParseScript(char *fileName);
|
||||||
SScript *simProcessCallOver(SScript *script);
|
SScript *simProcessCallOver(SScript *script);
|
||||||
|
|
|
@ -305,25 +305,24 @@ bool simExecuteRunBackCmd(SScript *script, char *option) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void simReplaceShToBat(char *dst) {
|
void simReplaceStr(char *buf, char *src, char *dst) {
|
||||||
char *sh = strstr(dst, ".sh");
|
char *begin = strstr(buf, src);
|
||||||
if (sh != NULL) {
|
if (begin != NULL) {
|
||||||
|
int32_t srcLen = (int32_t)strlen(src);
|
||||||
int32_t dstLen = (int32_t)strlen(dst);
|
int32_t dstLen = (int32_t)strlen(dst);
|
||||||
char *end = dst + dstLen;
|
int32_t interval = (dstLen - srcLen);
|
||||||
*(end + 1) = 0;
|
int32_t remainLen = (int32_t)strlen(buf);
|
||||||
|
char *end = buf + remainLen;
|
||||||
|
*(end + interval) = 0;
|
||||||
|
|
||||||
for (char *p = end; p >= sh; p--) {
|
for (char *p = end; p >= begin; p--) {
|
||||||
*(p + 1) = *p;
|
*(p + interval) = *p;
|
||||||
}
|
}
|
||||||
|
|
||||||
sh[0] = '.';
|
memcpy(begin, dst, dstLen);
|
||||||
sh[1] = 'b';
|
|
||||||
sh[2] = 'a';
|
|
||||||
sh[3] = 't';
|
|
||||||
sh[4] = ' ';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
simDebug("system cmd is %s", dst);
|
simInfo("system cmd is %s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool simExecuteSystemCmd(SScript *script, char *option) {
|
bool simExecuteSystemCmd(SScript *script, char *option) {
|
||||||
|
@ -334,9 +333,13 @@ bool simExecuteSystemCmd(SScript *script, char *option) {
|
||||||
simVisuallizeOption(script, option, buf + strlen(buf));
|
simVisuallizeOption(script, option, buf + strlen(buf));
|
||||||
#else
|
#else
|
||||||
sprintf(buf, "%s%s", simScriptDir, option);
|
sprintf(buf, "%s%s", simScriptDir, option);
|
||||||
simReplaceShToBat(buf);
|
simReplaceStr(buf, ".sh", ".bat");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (useMultiProcess) {
|
||||||
|
simReplaceStr(buf, "deploy.sh", "deploy.sh -m");
|
||||||
|
}
|
||||||
|
|
||||||
simLogSql(buf, true);
|
simLogSql(buf, true);
|
||||||
int32_t code = system(buf);
|
int32_t code = system(buf);
|
||||||
int32_t repeatTimes = 0;
|
int32_t repeatTimes = 0;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
bool simExecSuccess = false;
|
bool simExecSuccess = false;
|
||||||
bool abortExecution = false;
|
bool abortExecution = false;
|
||||||
|
bool useMultiProcess = false;
|
||||||
|
|
||||||
void simHandleSignal(int32_t signo, void *sigInfo, void *context) {
|
void simHandleSignal(int32_t signo, void *sigInfo, void *context) {
|
||||||
simSystemCleanUp();
|
simSystemCleanUp();
|
||||||
|
@ -32,6 +33,8 @@ int32_t main(int32_t argc, char *argv[]) {
|
||||||
tstrncpy(configDir, argv[++i], 128);
|
tstrncpy(configDir, argv[++i], 128);
|
||||||
} else if (strcmp(argv[i], "-f") == 0 && i < argc - 1) {
|
} else if (strcmp(argv[i], "-f") == 0 && i < argc - 1) {
|
||||||
strcpy(scriptFile, argv[++i]);
|
strcpy(scriptFile, argv[++i]);
|
||||||
|
} else if (strcmp(argv[i], "-m") == 0) {
|
||||||
|
useMultiProcess = true;
|
||||||
} else {
|
} else {
|
||||||
printf("usage: %s [options] \n", argv[0]);
|
printf("usage: %s [options] \n", argv[0]);
|
||||||
printf(" [-c config]: config directory, default is: %s\n", configDir);
|
printf(" [-c config]: config directory, default is: %s\n", configDir);
|
||||||
|
|
Loading…
Reference in New Issue