Merge branch '3.0' into test/jcy
This commit is contained in:
commit
8209983cb7
|
@ -0,0 +1,2 @@
|
||||||
|
.vscode
|
||||||
|
*.lock
|
|
@ -135,6 +135,8 @@ typedef enum _mgmt_table {
|
||||||
#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x6
|
#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x6
|
||||||
#define TSDB_ALTER_USER_ADD_ALL_DB 0x7
|
#define TSDB_ALTER_USER_ADD_ALL_DB 0x7
|
||||||
#define TSDB_ALTER_USER_REMOVE_ALL_DB 0x8
|
#define TSDB_ALTER_USER_REMOVE_ALL_DB 0x8
|
||||||
|
#define TSDB_ALTER_USER_ENABLE 0x9
|
||||||
|
#define TSDB_ALTER_USER_SYSINFO 0xA
|
||||||
|
|
||||||
#define TSDB_ALTER_USER_PRIVILEGES 0x2
|
#define TSDB_ALTER_USER_PRIVILEGES 0x2
|
||||||
|
|
||||||
|
@ -534,6 +536,8 @@ int32_t tDeserializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t createType;
|
int8_t createType;
|
||||||
int8_t superUser; // denote if it is a super user or not
|
int8_t superUser; // denote if it is a super user or not
|
||||||
|
int8_t sysInfo;
|
||||||
|
int8_t enable;
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
char pass[TSDB_USET_PASSWORD_LEN];
|
char pass[TSDB_USET_PASSWORD_LEN];
|
||||||
} SCreateUserReq;
|
} SCreateUserReq;
|
||||||
|
@ -544,6 +548,8 @@ int32_t tDeserializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pR
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t alterType;
|
int8_t alterType;
|
||||||
int8_t superUser;
|
int8_t superUser;
|
||||||
|
int8_t sysInfo;
|
||||||
|
int8_t enable;
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
char pass[TSDB_USET_PASSWORD_LEN];
|
char pass[TSDB_USET_PASSWORD_LEN];
|
||||||
char dbname[TSDB_DB_FNAME_LEN];
|
char dbname[TSDB_DB_FNAME_LEN];
|
||||||
|
@ -563,6 +569,9 @@ typedef struct {
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
int32_t version;
|
int32_t version;
|
||||||
int8_t superAuth;
|
int8_t superAuth;
|
||||||
|
int8_t sysInfo;
|
||||||
|
int8_t enable;
|
||||||
|
int8_t reserve;
|
||||||
SHashObj* createdDbs;
|
SHashObj* createdDbs;
|
||||||
SHashObj* readDbs;
|
SHashObj* readDbs;
|
||||||
SHashObj* writeDbs;
|
SHashObj* writeDbs;
|
||||||
|
@ -2246,6 +2255,25 @@ typedef struct {
|
||||||
int8_t reserved;
|
int8_t reserved;
|
||||||
} SMqVDeleteRsp;
|
} SMqVDeleteRsp;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char name[TSDB_STREAM_FNAME_LEN];
|
||||||
|
int64_t streamId;
|
||||||
|
} SMDropStreamTaskReq;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t reserved;
|
||||||
|
} SMDropStreamTaskRsp;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SMsgHead head;
|
||||||
|
int64_t leftForVer;
|
||||||
|
int32_t taskId;
|
||||||
|
} SVDropStreamTaskReq;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t reserved;
|
||||||
|
} SVDropStreamTaskRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t leftForVer;
|
int64_t leftForVer;
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
|
|
|
@ -187,6 +187,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqPollReq, SMqDataBlkRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqPollReq, SMqDataBlkRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_DISPATCH_WRITE, "vnode-stream-task-dispatch-write", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_DISPATCH_WRITE, "vnode-stream-task-dispatch-write", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_DROP, "vnode-stream-task-drop", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
||||||
|
|
|
@ -132,7 +132,6 @@ typedef struct SqlFunctionCtx {
|
||||||
char *pOutput; // final result output buffer, point to sdata->data
|
char *pOutput; // final result output buffer, point to sdata->data
|
||||||
int32_t numOfParams;
|
int32_t numOfParams;
|
||||||
SFunctParam *param; // input parameter, e.g., top(k, 20), the number of results for top query is kept in param
|
SFunctParam *param; // input parameter, e.g., top(k, 20), the number of results for top query is kept in param
|
||||||
int64_t *ptsList; // corresponding timestamp array list, todo remove it
|
|
||||||
SColumnInfoData *pTsOutput; // corresponding output buffer for timestamp of each result, e.g., top/bottom*/
|
SColumnInfoData *pTsOutput; // corresponding output buffer for timestamp of each result, e.g., top/bottom*/
|
||||||
int32_t offset;
|
int32_t offset;
|
||||||
struct SResultRowEntryInfo *resultInfo;
|
struct SResultRowEntryInfo *resultInfo;
|
||||||
|
|
|
@ -134,6 +134,7 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_HYPERLOGLOG_MERGE,
|
FUNCTION_TYPE_HYPERLOGLOG_MERGE,
|
||||||
FUNCTION_TYPE_ELAPSED_PARTIAL,
|
FUNCTION_TYPE_ELAPSED_PARTIAL,
|
||||||
FUNCTION_TYPE_ELAPSED_MERGE,
|
FUNCTION_TYPE_ELAPSED_MERGE,
|
||||||
|
|
||||||
FUNCTION_TYPE_TOP_PARTIAL,
|
FUNCTION_TYPE_TOP_PARTIAL,
|
||||||
FUNCTION_TYPE_TOP_MERGE,
|
FUNCTION_TYPE_TOP_MERGE,
|
||||||
FUNCTION_TYPE_BOTTOM_PARTIAL,
|
FUNCTION_TYPE_BOTTOM_PARTIAL,
|
||||||
|
@ -184,6 +185,7 @@ bool fmIsUserDefinedFunc(int32_t funcId);
|
||||||
bool fmIsDistExecFunc(int32_t funcId);
|
bool fmIsDistExecFunc(int32_t funcId);
|
||||||
bool fmIsForbidFillFunc(int32_t funcId);
|
bool fmIsForbidFillFunc(int32_t funcId);
|
||||||
bool fmIsForbidStreamFunc(int32_t funcId);
|
bool fmIsForbidStreamFunc(int32_t funcId);
|
||||||
|
bool fmIsIntervalInterpoFunc(int32_t funcId);
|
||||||
|
|
||||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,8 @@ typedef enum ESubplanType {
|
||||||
SUBPLAN_TYPE_MERGE = 1,
|
SUBPLAN_TYPE_MERGE = 1,
|
||||||
SUBPLAN_TYPE_PARTIAL,
|
SUBPLAN_TYPE_PARTIAL,
|
||||||
SUBPLAN_TYPE_SCAN,
|
SUBPLAN_TYPE_SCAN,
|
||||||
SUBPLAN_TYPE_MODIFY
|
SUBPLAN_TYPE_MODIFY,
|
||||||
|
SUBPLAN_TYPE_COMPUTE
|
||||||
} ESubplanType;
|
} ESubplanType;
|
||||||
|
|
||||||
typedef struct SSubplanId {
|
typedef struct SSubplanId {
|
||||||
|
@ -196,6 +197,7 @@ typedef struct SLogicSubplan {
|
||||||
SVgroupsInfo* pVgroupList;
|
SVgroupsInfo* pVgroupList;
|
||||||
int32_t level;
|
int32_t level;
|
||||||
int32_t splitFlag;
|
int32_t splitFlag;
|
||||||
|
int32_t numOfComputeNodes;
|
||||||
} SLogicSubplan;
|
} SLogicSubplan;
|
||||||
|
|
||||||
typedef struct SQueryLogicPlan {
|
typedef struct SQueryLogicPlan {
|
||||||
|
|
|
@ -36,7 +36,7 @@ typedef struct SPlanContext {
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
char* pMsg;
|
char* pMsg;
|
||||||
int32_t msgLen;
|
int32_t msgLen;
|
||||||
double filesFactor;
|
// double filesFactor;
|
||||||
} SPlanContext;
|
} SPlanContext;
|
||||||
|
|
||||||
// Create the physical plan for the query, according to the AST.
|
// Create the physical plan for the query, according to the AST.
|
||||||
|
|
|
@ -132,7 +132,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0300)
|
#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0300)
|
||||||
#define TSDB_CODE_MND_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0301)
|
#define TSDB_CODE_MND_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0301)
|
||||||
#define TSDB_CODE_MND_NO_RIGHTS TAOS_DEF_ERROR_CODE(0, 0x0302)
|
#define TSDB_CODE_MND_NO_RIGHTS TAOS_DEF_ERROR_CODE(0, 0x0302)
|
||||||
#define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0303)
|
#define TSDB_CODE_MND_USER_DISABLED TAOS_DEF_ERROR_CODE(0, 0x0303)
|
||||||
|
#define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0304)
|
||||||
|
|
||||||
// mnode-show
|
// mnode-show
|
||||||
#define TSDB_CODE_MND_INVALID_SHOWOBJ TAOS_DEF_ERROR_CODE(0, 0x0310)
|
#define TSDB_CODE_MND_INVALID_SHOWOBJ TAOS_DEF_ERROR_CODE(0, 0x0310)
|
||||||
|
@ -436,6 +437,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_WAL_SIZE_LIMIT TAOS_DEF_ERROR_CODE(0, 0x1002)
|
#define TSDB_CODE_WAL_SIZE_LIMIT TAOS_DEF_ERROR_CODE(0, 0x1002)
|
||||||
#define TSDB_CODE_WAL_INVALID_VER TAOS_DEF_ERROR_CODE(0, 0x1003)
|
#define TSDB_CODE_WAL_INVALID_VER TAOS_DEF_ERROR_CODE(0, 0x1003)
|
||||||
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004)
|
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004)
|
||||||
|
#define TSDB_CODE_WAL_LOG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x1005)
|
||||||
|
|
||||||
// http
|
// http
|
||||||
#define TSDB_CODE_HTTP_SERVER_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x1100) //"http server is not online"
|
#define TSDB_CODE_HTTP_SERVER_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x1100) //"http server is not online"
|
||||||
|
|
|
@ -170,7 +170,9 @@ static const SSysDbTableSchema userTblDistSchema[] = {
|
||||||
|
|
||||||
static const SSysDbTableSchema userUsersSchema[] = {
|
static const SSysDbTableSchema userUsersSchema[] = {
|
||||||
{.name = "name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "privilege", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "super", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||||
|
{.name = "enable", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||||
|
{.name = "sysinfo", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1160,6 +1160,8 @@ int32_t tSerializeSCreateUserReq(void *buf, int32_t bufLen, SCreateUserReq *pReq
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->createType) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->createType) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->superUser) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->superUser) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->sysInfo) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->enable) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
@ -1176,6 +1178,8 @@ int32_t tDeserializeSCreateUserReq(void *buf, int32_t bufLen, SCreateUserReq *pR
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->createType) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->createType) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->superUser) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->superUser) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->sysInfo) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->enable) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
@ -1191,6 +1195,8 @@ int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq)
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->alterType) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->alterType) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->superUser) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->superUser) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->sysInfo) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->enable) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->dbname) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->dbname) < 0) return -1;
|
||||||
|
@ -1208,6 +1214,8 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->alterType) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->alterType) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->superUser) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->superUser) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->sysInfo) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->enable) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->dbname) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->dbname) < 0) return -1;
|
||||||
|
@ -1245,6 +1253,9 @@ int32_t tDeserializeSGetUserAuthReq(void *buf, int32_t bufLen, SGetUserAuthReq *
|
||||||
int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) {
|
int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) {
|
||||||
if (tEncodeCStr(pEncoder, pRsp->user) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pRsp->user) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pRsp->superAuth) < 0) return -1;
|
if (tEncodeI8(pEncoder, pRsp->superAuth) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pRsp->sysInfo) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pRsp->enable) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pRsp->reserve) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pRsp->version) < 0) return -1;
|
if (tEncodeI32(pEncoder, pRsp->version) < 0) return -1;
|
||||||
|
|
||||||
int32_t numOfCreatedDbs = taosHashGetSize(pRsp->createdDbs);
|
int32_t numOfCreatedDbs = taosHashGetSize(pRsp->createdDbs);
|
||||||
|
@ -1300,6 +1311,9 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
|
||||||
|
|
||||||
if (tDecodeCStrTo(pDecoder, pRsp->user) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, pRsp->user) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pRsp->superAuth) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pRsp->superAuth) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pRsp->sysInfo) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pRsp->enable) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pRsp->reserve) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pRsp->version) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pRsp->version) < 0) return -1;
|
||||||
|
|
||||||
int32_t numOfCreatedDbs = 0;
|
int32_t numOfCreatedDbs = 0;
|
||||||
|
|
|
@ -215,6 +215,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -350,6 +350,7 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TRIGGER, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TRIGGER, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_DROP, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -22,23 +22,42 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MND_OPER_CREATE_USER = 1,
|
||||||
|
MND_OPER_DROP_USER,
|
||||||
|
MND_OPER_ALTER_USER,
|
||||||
|
MND_OPER_CREATE_BNODE,
|
||||||
|
MND_OPER_DROP_BNODE,
|
||||||
|
MND_OPER_CREATE_DNODE,
|
||||||
|
MND_OPER_DROP_DNODE,
|
||||||
|
MND_OPER_CREATE_MNODE,
|
||||||
|
MND_OPER_DROP_MNODE,
|
||||||
|
MND_OPER_CREATE_QNODE,
|
||||||
|
MND_OPER_DROP_QNODE,
|
||||||
|
MND_OPER_CREATE_SNODE,
|
||||||
|
MND_OPER_DROP_SNODE,
|
||||||
|
MND_OPER_REDISTRIBUTE_VGROUP,
|
||||||
|
MND_OPER_SPLIT_VGROUP,
|
||||||
|
MND_OPER_BALANCE_VGROUP,
|
||||||
|
MND_OPER_CREATE_FUNC,
|
||||||
|
MND_OPER_DROP_FUNC,
|
||||||
|
MND_OPER_KILL_TRANS,
|
||||||
|
MND_OPER_CREATE_DB,
|
||||||
|
MND_OPER_ALTER_DB,
|
||||||
|
MND_OPER_DROP_DB,
|
||||||
|
MND_OPER_COMPACT_DB,
|
||||||
|
MND_OPER_USE_DB,
|
||||||
|
MND_OPER_WRITE_DB,
|
||||||
|
MND_OPER_READ_DB,
|
||||||
|
} EOperType;
|
||||||
|
|
||||||
int32_t mndInitAuth(SMnode *pMnode);
|
int32_t mndInitAuth(SMnode *pMnode);
|
||||||
void mndCleanupAuth(SMnode *pMnode);
|
void mndCleanupAuth(SMnode *pMnode);
|
||||||
|
|
||||||
int32_t mndCheckCreateUserAuth(SUserObj *pOperUser);
|
int32_t mndCheckOperAuth(SMnode *pMnode, const char *user, EOperType operType);
|
||||||
|
int32_t mndCheckDbAuth(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb);
|
||||||
|
int32_t mndCheckShowAuth(SMnode *pMnode, const char *user, int32_t showType);
|
||||||
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter);
|
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter);
|
||||||
int32_t mndCheckDropUserAuth(SUserObj *pOperUser);
|
|
||||||
|
|
||||||
int32_t mndCheckNodeAuth(SUserObj *pOperUser);
|
|
||||||
int32_t mndCheckFuncAuth(SUserObj *pOperUser);
|
|
||||||
int32_t mndCheckTransAuth(SUserObj *pOperUser);
|
|
||||||
|
|
||||||
int32_t mndCheckCreateDbAuth(SUserObj *pOperUser);
|
|
||||||
int32_t mndCheckAlterDropCompactDbAuth(SUserObj *pOperUser, SDbObj *pDb);
|
|
||||||
int32_t mndCheckUseDbAuth(SUserObj *pOperUser, SDbObj *pDb);
|
|
||||||
|
|
||||||
int32_t mndCheckWriteAuth(SUserObj *pOperUser, SDbObj *pDb);
|
|
||||||
int32_t mndCheckReadAuth(SUserObj *pOperUser, SDbObj *pDb);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,9 @@ typedef struct {
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
int8_t superUser;
|
int8_t superUser;
|
||||||
|
int8_t sysInfo;
|
||||||
|
int8_t enable;
|
||||||
|
int8_t reserve;
|
||||||
int32_t acctId;
|
int32_t acctId;
|
||||||
int32_t authVersion;
|
int32_t authVersion;
|
||||||
SHashObj* readDbs;
|
SHashObj* readDbs;
|
||||||
|
|
|
@ -73,29 +73,44 @@ static int32_t mndProcessAuthReq(SRpcMsg *pReq) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCheckCreateUserAuth(SUserObj *pOperUser) {
|
int32_t mndCheckOperAuth(SMnode *pMnode, const char *user, EOperType operType) {
|
||||||
if (pOperUser->superUser) return 0;
|
int32_t code = 0;
|
||||||
|
SUserObj *pUser = mndAcquireUser(pMnode, user);
|
||||||
|
|
||||||
|
if (pUser == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
code = -1;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pUser->superUser) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pUser->enable) {
|
||||||
|
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||||
|
code = -1;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
return -1;
|
code = -1;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter) {
|
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter) {
|
||||||
|
if (pOperUser->superUser) return 0;
|
||||||
|
if (!pOperUser->enable) {
|
||||||
|
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (pAlter->alterType == TSDB_ALTER_USER_PASSWD) {
|
if (pAlter->alterType == TSDB_ALTER_USER_PASSWD) {
|
||||||
if (pOperUser->superUser || strcmp(pUser->user, pOperUser->user) == 0) {
|
if (strcmp(pUser->user, pOperUser->user) == 0) {
|
||||||
return 0;
|
if (pOperUser->sysInfo) return 0;
|
||||||
}
|
|
||||||
} else if (pAlter->alterType == TSDB_ALTER_USER_SUPERUSER) {
|
|
||||||
if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pOperUser->superUser) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (pOperUser->superUser) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,65 +118,92 @@ int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserRe
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCheckDropUserAuth(SUserObj *pOperUser) {
|
int32_t mndCheckShowAuth(SMnode *pMnode, const char *user, int32_t showType) {
|
||||||
if (pOperUser->superUser) return 0;
|
int32_t code = 0;
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
SUserObj *pUser = mndAcquireUser(pMnode, user);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mndCheckNodeAuth(SUserObj *pOperUser) {
|
if (pUser == NULL) {
|
||||||
if (pOperUser->superUser) return 0;
|
code = -1;
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
goto _OVER;
|
||||||
return -1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mndCheckFuncAuth(SUserObj *pOperUser) {
|
if (pUser->superUser) {
|
||||||
if (pOperUser->superUser) return 0;
|
goto _OVER;
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
}
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mndCheckTransAuth(SUserObj *pOperUser) {
|
if (!pUser->enable) {
|
||||||
if (pOperUser->superUser) return 0;
|
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
code = -1;
|
||||||
return -1;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCheckCreateDbAuth(SUserObj *pOperUser) { return 0; }
|
if (!pUser->sysInfo) {
|
||||||
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
int32_t mndCheckAlterDropCompactDbAuth(SUserObj *pOperUser, SDbObj *pDb) {
|
code = -1;
|
||||||
if (pOperUser->superUser || strcmp(pOperUser->user, pDb->createUser) == 0) {
|
goto _OVER;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
return -1;
|
code = -1;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCheckUseDbAuth(SUserObj *pOperUser, SDbObj *pDb) { return 0; }
|
int32_t mndCheckDbAuth(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SUserObj *pUser = mndAcquireUser(pMnode, user);
|
||||||
|
|
||||||
int32_t mndCheckWriteAuth(SUserObj *pOperUser, SDbObj *pDb) {
|
if (pUser == NULL) {
|
||||||
if (pOperUser->superUser || strcmp(pOperUser->user, pDb->createUser) == 0) {
|
code = -1;
|
||||||
return 0;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashGet(pOperUser->writeDbs, pDb->name, strlen(pDb->name) + 1) != NULL) {
|
if (pUser->superUser) goto _OVER;
|
||||||
return 0;
|
|
||||||
|
if (!pUser->enable) {
|
||||||
|
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||||
|
code = -1;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_CREATE_DB) {
|
||||||
|
if (pUser->sysInfo) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_ALTER_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0 && pUser->sysInfo) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_DROP_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0 && pUser->sysInfo) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_COMPACT_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0 && pUser->sysInfo) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_USE_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER;
|
||||||
|
if (taosHashGet(pUser->readDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||||
|
if (taosHashGet(pUser->writeDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_WRITE_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER;
|
||||||
|
if (taosHashGet(pUser->writeDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_READ_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER;
|
||||||
|
if (taosHashGet(pUser->readDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
return -1;
|
code = -1;
|
||||||
}
|
|
||||||
|
_OVER:
|
||||||
int32_t mndCheckReadAuth(SUserObj *pOperUser, SDbObj *pDb) {
|
mndReleaseUser(pMnode, pUser);
|
||||||
if (pOperUser->superUser || strcmp(pOperUser->user, pDb->createUser) == 0) {
|
return code;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosHashGet(pOperUser->readDbs, pDb->name, strlen(pDb->name) + 1) != NULL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,6 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SBnodeObj *pObj = NULL;
|
SBnodeObj *pObj = NULL;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateBnodeReq createReq = {0};
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -293,13 +292,7 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_BNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +306,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseBnode(pMnode, pObj);
|
mndReleaseBnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +374,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SBnodeObj *pObj = NULL;
|
SBnodeObj *pObj = NULL;
|
||||||
SMDropBnodeReq dropReq = {0};
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
|
||||||
|
@ -403,13 +394,7 @@ static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_BNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,8 +407,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseBnode(pMnode, pObj);
|
mndReleaseBnode(pMnode, pObj);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckCreateDbAuth(pUser) != 0) {
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_DB, NULL) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,7 +684,6 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SAlterDbReq alterReq = {0};
|
SAlterDbReq alterReq = {0};
|
||||||
SDbObj dbObj = {0};
|
SDbObj dbObj = {0};
|
||||||
|
|
||||||
|
@ -701,12 +700,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_ALTER_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckAlterDropCompactDbAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,7 +727,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
taosArrayDestroy(dbObj.cfg.pRetensions);
|
taosArrayDestroy(dbObj.cfg.pRetensions);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -967,7 +960,6 @@ static int32_t mndProcessDropDbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDropDbReq dropReq = {0};
|
SDropDbReq dropReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSDropDbReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
if (tDeserializeSDropDbReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
||||||
|
@ -988,12 +980,7 @@ static int32_t mndProcessDropDbReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_DROP_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckAlterDropCompactDbAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,8 +993,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,7 +1088,6 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SUseDbReq usedbReq = {0};
|
SUseDbReq usedbReq = {0};
|
||||||
SUseDbRsp usedbRsp = {0};
|
SUseDbRsp usedbRsp = {0};
|
||||||
|
|
||||||
|
@ -1143,12 +1127,7 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
mError("db:%s, failed to process use db req since %s", usedbReq.db, terrstr());
|
mError("db:%s, failed to process use db req since %s", usedbReq.db, terrstr());
|
||||||
} else {
|
} else {
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_USE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckUseDbAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1179,7 +1158,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
tFreeSUsedbRsp(&usedbRsp);
|
tFreeSUsedbRsp(&usedbRsp);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1260,7 +1238,6 @@ static int32_t mndProcessCompactDbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SCompactDbReq compactReq = {0};
|
SCompactDbReq compactReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCompactDbReq(pReq->pCont, pReq->contLen, &compactReq) != 0) {
|
if (tDeserializeSCompactDbReq(pReq->pCont, pReq->contLen, &compactReq) != 0) {
|
||||||
|
@ -1275,12 +1252,7 @@ static int32_t mndProcessCompactDbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_COMPACT_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckAlterDropCompactDbAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1292,8 +1264,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -499,7 +499,6 @@ _OVER:
|
||||||
static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SCreateDnodeReq createReq = {0};
|
SCreateDnodeReq createReq = {0};
|
||||||
|
|
||||||
|
@ -522,13 +521,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_DNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,7 +534,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +578,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SMnodeObj *pMObj = NULL;
|
SMnodeObj *pMObj = NULL;
|
||||||
SMDropMnodeReq dropReq = {0};
|
SMDropMnodeReq dropReq = {0};
|
||||||
|
@ -631,13 +622,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_MNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,7 +635,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
mndReleaseMnode(pMnode, pMObj);
|
mndReleaseMnode(pMnode, pMObj);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,7 +274,6 @@ _OVER:
|
||||||
static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SFuncObj *pFunc = NULL;
|
SFuncObj *pFunc = NULL;
|
||||||
SCreateFuncReq createReq = {0};
|
SCreateFuncReq createReq = {0};
|
||||||
|
|
||||||
|
@ -309,23 +308,17 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createReq.codeLen <= 1) {
|
if (createReq.codeLen <= 1) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_FUNC_CODE;
|
terrno = TSDB_CODE_MND_INVALID_FUNC_CODE;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createReq.bufSize < 0 || createReq.bufSize > TSDB_FUNC_BUF_SIZE) {
|
if (createReq.bufSize < 0 || createReq.bufSize > TSDB_FUNC_BUF_SIZE) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_FUNC_BUFSIZE;
|
terrno = TSDB_CODE_MND_INVALID_FUNC_BUFSIZE;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_FUNC) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckFuncAuth(pUser)) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,16 +331,13 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseFunc(pMnode, pFunc);
|
mndReleaseFunc(pMnode, pFunc);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
tFreeSCreateFuncReq(&createReq);
|
tFreeSCreateFuncReq(&createReq);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SFuncObj *pFunc = NULL;
|
SFuncObj *pFunc = NULL;
|
||||||
SDropFuncReq dropReq = {0};
|
SDropFuncReq dropReq = {0};
|
||||||
|
|
||||||
|
@ -375,13 +365,7 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_FUNC) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckFuncAuth(pUser)) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,8 +378,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseFunc(pMnode, pFunc);
|
mndReleaseFunc(pMnode, pFunc);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,6 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SMnodeObj *pObj = NULL;
|
SMnodeObj *pObj = NULL;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateMnodeReq createReq = {0};
|
SMCreateMnodeReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -415,13 +414,7 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_MNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +428,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseMnode(pMnode, pObj);
|
mndReleaseMnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -594,7 +586,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMnodeObj *pObj = NULL;
|
SMnodeObj *pObj = NULL;
|
||||||
SMDropMnodeReq dropReq = {0};
|
SMDropMnodeReq dropReq = {0};
|
||||||
|
|
||||||
|
@ -630,13 +621,7 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_MNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,8 +634,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseMnode(pMnode, pObj);
|
mndReleaseMnode(pMnode, pObj);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,7 +271,6 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SQnodeObj *pObj = NULL;
|
SQnodeObj *pObj = NULL;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateQnodeReq createReq = {0};
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -295,13 +294,7 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_QNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +308,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseQnode(pMnode, pObj);
|
mndReleaseQnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +376,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SQnodeObj *pObj = NULL;
|
SQnodeObj *pObj = NULL;
|
||||||
SMDropQnodeReq dropReq = {0};
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
|
||||||
|
@ -405,13 +396,7 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_QNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,8 +409,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseQnode(pMnode, pObj);
|
mndReleaseQnode(pMnode, pObj);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,10 +63,11 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
|
||||||
.topicQuery = false,
|
.topicQuery = false,
|
||||||
.streamQuery = true,
|
.streamQuery = true,
|
||||||
.rSmaQuery = true,
|
.rSmaQuery = true,
|
||||||
.triggerType = triggerType,
|
.triggerType = STREAM_TRIGGER_AT_ONCE,
|
||||||
.watermark = watermark,
|
.watermark = watermark,
|
||||||
.filesFactor = filesFactor,
|
/*.filesFactor = filesFactor,*/
|
||||||
};
|
};
|
||||||
|
|
||||||
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
||||||
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
goto END;
|
goto END;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "systable.h"
|
#include "systable.h"
|
||||||
|
#include "mndAuth.h"
|
||||||
|
|
||||||
#define SHOW_STEP_SIZE 100
|
#define SHOW_STEP_SIZE 100
|
||||||
|
|
||||||
|
@ -228,6 +229,8 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
mDebug("show:0x%" PRIx64 ", start retrieve data, type:%d", pShow->id, pShow->type);
|
mDebug("show:0x%" PRIx64 ", start retrieve data, type:%d", pShow->id, pShow->type);
|
||||||
|
|
||||||
|
// if (mndCheckShowAuth(pMnode, pReq->conn.user, pShow->type) != 0) return -1;
|
||||||
|
|
||||||
int32_t numOfCols = pShow->pMeta->numOfColumns;
|
int32_t numOfCols = pShow->pMeta->numOfColumns;
|
||||||
SSDataBlock *pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
SSDataBlock *pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
||||||
|
|
|
@ -631,7 +631,6 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
|
||||||
SSmaObj *pSma = NULL;
|
SSmaObj *pSma = NULL;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateSmaReq createReq = {0};
|
SMCreateSmaReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSMCreateSmaReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSMCreateSmaReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -675,12 +674,7 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -696,7 +690,6 @@ _OVER:
|
||||||
mndReleaseSma(pMnode, pSma);
|
mndReleaseSma(pMnode, pSma);
|
||||||
mndReleaseStream(pMnode, pStream);
|
mndReleaseStream(pMnode, pStream);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
tFreeSMCreateSmaReq(&createReq);
|
tFreeSMCreateSmaReq(&createReq);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -913,7 +906,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SSmaObj *pSma = NULL;
|
SSmaObj *pSma = NULL;
|
||||||
SMDropSmaReq dropReq = {0};
|
SMDropSmaReq dropReq = {0};
|
||||||
|
@ -943,12 +935,7 @@ static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,9 +948,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseSma(pMnode, pSma);
|
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,6 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SSnodeObj *pObj = NULL;
|
SSnodeObj *pObj = NULL;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateSnodeReq createReq = {0};
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -301,13 +300,7 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_SNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +315,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseSnode(pMnode, pObj);
|
mndReleaseSnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +384,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SSnodeObj *pObj = NULL;
|
SSnodeObj *pObj = NULL;
|
||||||
SMDropSnodeReq dropReq = {0};
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
|
||||||
|
@ -413,13 +404,7 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_SNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,8 +417,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseSnode(pMnode, pObj);
|
mndReleaseSnode(pMnode, pObj);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -773,7 +773,6 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateStbReq createReq = {0};
|
SMCreateStbReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSMCreateStbReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSMCreateStbReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -807,12 +806,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,7 +830,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
tFreeSMCreateStbReq(&createReq);
|
tFreeSMCreateStbReq(&createReq);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1431,7 +1424,6 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMAlterStbReq alterReq = {0};
|
SMAlterStbReq alterReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSMAlterStbReq(pReq->pCont, pReq->contLen, &alterReq) != 0) {
|
if (tDeserializeSMAlterStbReq(pReq->pCont, pReq->contLen, &alterReq) != 0) {
|
||||||
|
@ -1462,12 +1454,7 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1481,7 +1468,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
taosArrayDestroy(alterReq.pFields);
|
taosArrayDestroy(alterReq.pFields);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1569,7 +1555,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SMDropStbReq dropReq = {0};
|
SMDropStbReq dropReq = {0};
|
||||||
|
@ -1599,12 +1584,7 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1618,8 +1598,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream);
|
||||||
static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream);
|
static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream);
|
||||||
static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pStream, SStreamObj *pNewStream);
|
static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pStream, SStreamObj *pNewStream);
|
||||||
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq);
|
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq);
|
||||||
/*static int32_t mndProcessDropStreamReq(SRpcMsg *pReq);*/
|
static int32_t mndProcessDropStreamReq(SRpcMsg *pReq);
|
||||||
/*static int32_t mndProcessDropStreamInRsp(SRpcMsg *pRsp);*/
|
/*static int32_t mndProcessDropStreamInRsp(SRpcMsg *pRsp);*/
|
||||||
static int32_t mndProcessStreamMetaReq(SRpcMsg *pReq);
|
static int32_t mndProcessStreamMetaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndGetStreamMeta(SRpcMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta);
|
static int32_t mndGetStreamMeta(SRpcMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta);
|
||||||
|
@ -55,9 +55,8 @@ int32_t mndInitStream(SMnode *pMnode) {
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STREAM, mndProcessCreateStreamReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STREAM, mndProcessCreateStreamReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_DEPLOY_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_DEPLOY_RSP, mndTransProcessRsp);
|
||||||
/*mndSetMsgHandle(pMnode, TDMT_SND_TASK_DEPLOY_RSP, mndTransProcessRsp);*/
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);
|
||||||
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);*/
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndTransProcessRsp);
|
||||||
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/
|
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndRetrieveStream);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndRetrieveStream);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndCancelGetNextStream);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndCancelGetNextStream);
|
||||||
|
@ -196,16 +195,6 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream) {
|
||||||
sdbRelease(pSdb, pStream);
|
sdbRelease(pSdb, pStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDbObj *mndAcquireDbByStream(SMnode *pMnode, char *streamName) {
|
|
||||||
SName name = {0};
|
|
||||||
tNameFromString(&name, streamName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
|
||||||
|
|
||||||
char db[TSDB_STREAM_FNAME_LEN] = {0};
|
|
||||||
tNameGetFullDbName(&name, db);
|
|
||||||
|
|
||||||
return mndAcquireDb(pMnode, db);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
|
static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
|
||||||
if (pCreate->name[0] == 0 || pCreate->sql == NULL || pCreate->sql[0] == 0) {
|
if (pCreate->name[0] == 0 || pCreate->sql == NULL || pCreate->sql[0] == 0) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_STREAM_OPTION;
|
terrno = TSDB_CODE_MND_INVALID_STREAM_OPTION;
|
||||||
|
@ -291,7 +280,6 @@ int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast
|
||||||
static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStreamObj *pStream, const char *user) {
|
static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStreamObj *pStream, const char *user) {
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
|
|
||||||
SMCreateStbReq createReq = {0};
|
SMCreateStbReq createReq = {0};
|
||||||
tstrncpy(createReq.name, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
tstrncpy(createReq.name, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
||||||
|
@ -333,12 +321,8 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, user);
|
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
if (mndCheckDbAuth(pMnode, user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,10 +350,50 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
|
||||||
_OVER:
|
_OVER:
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndPersistTaskDropReq(STrans *pTrans, SStreamTask *pTask) {
|
||||||
|
ASSERT(pTask->nodeId != 0);
|
||||||
|
|
||||||
|
// vnode
|
||||||
|
if (pTask->nodeId > 0) {
|
||||||
|
SVDropStreamTaskReq *pReq = taosMemoryCalloc(1, sizeof(SVDropStreamTaskReq));
|
||||||
|
if (pReq == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pReq->head.vgId = htonl(pTask->nodeId);
|
||||||
|
pReq->taskId = pTask->taskId;
|
||||||
|
STransAction action = {0};
|
||||||
|
memcpy(&action.epSet, &pTask->epSet, sizeof(SEpSet));
|
||||||
|
action.pCont = pReq;
|
||||||
|
action.contLen = sizeof(SVDropStreamTaskReq);
|
||||||
|
action.msgType = TDMT_VND_STREAM_TASK_DROP;
|
||||||
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
|
taosMemoryFree(pReq);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndDropStreamTasks(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
||||||
|
int32_t lv = taosArrayGetSize(pStream->tasks);
|
||||||
|
for (int32_t i = 0; i < lv; i++) {
|
||||||
|
SArray *pTasks = taosArrayGetP(pStream->tasks, i);
|
||||||
|
int32_t sz = taosArrayGetSize(pTasks);
|
||||||
|
for (int32_t j = 0; j < sz; j++) {
|
||||||
|
SStreamTask *pTask = taosArrayGetP(pTasks, j);
|
||||||
|
if (mndPersistTaskDropReq(pTrans, pTask) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndCreateStream(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq *pCreate, SDbObj *pDb) {
|
static int32_t mndCreateStream(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq *pCreate, SDbObj *pDb) {
|
||||||
mDebug("stream:%s to create", pCreate->name);
|
mDebug("stream:%s to create", pCreate->name);
|
||||||
SStreamObj streamObj = {0};
|
SStreamObj streamObj = {0};
|
||||||
|
@ -435,19 +459,18 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SCMCreateStreamReq createStreamReq = {0};
|
SCMCreateStreamReq createStreamReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, &createStreamReq) != 0) {
|
if (tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, &createStreamReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("stream:%s, start to create, sql:%s", createStreamReq.name, createStreamReq.sql);
|
mDebug("stream:%s, start to create, sql:%s", createStreamReq.name, createStreamReq.sql);
|
||||||
|
|
||||||
if (mndCheckCreateStreamReq(&createStreamReq) != 0) {
|
if (mndCheckCreateStreamReq(&createStreamReq) != 0) {
|
||||||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pStream = mndAcquireStream(pMnode, createStreamReq.name);
|
pStream = mndAcquireStream(pMnode, createStreamReq.name);
|
||||||
|
@ -455,46 +478,82 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
if (createStreamReq.igExists) {
|
if (createStreamReq.igExists) {
|
||||||
mDebug("stream:%s, already exist, ignore exist is set", createStreamReq.name);
|
mDebug("stream:%s, already exist, ignore exist is set", createStreamReq.name);
|
||||||
code = 0;
|
code = 0;
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
} else if (terrno != TSDB_CODE_MND_STREAM_NOT_EXIST) {
|
} else if (terrno != TSDB_CODE_MND_STREAM_NOT_EXIST) {
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO check auth
|
||||||
pDb = mndAcquireDb(pMnode, createStreamReq.sourceDB);
|
pDb = mndAcquireDb(pMnode, createStreamReq.sourceDB);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
goto _OVER;
|
||||||
goto CREATE_STREAM_OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto CREATE_STREAM_OVER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndCreateStream(pMnode, pReq, &createStreamReq, pDb);
|
code = mndCreateStream(pMnode, pReq, &createStreamReq, pDb);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
CREATE_STREAM_OVER:
|
_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseStream(pMnode, pStream);
|
mndReleaseStream(pMnode, pStream);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
tFreeSCMCreateStreamReq(&createStreamReq);
|
tFreeSCMCreateStreamReq(&createStreamReq);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
int32_t code = -1;
|
||||||
|
SStreamObj *pStream = NULL;
|
||||||
|
/*SDbObj *pDb = NULL;*/
|
||||||
|
/*SUserObj *pUser = NULL;*/
|
||||||
|
|
||||||
|
SMDropStreamTaskReq dropStreamReq = *(SMDropStreamTaskReq *)pReq->pCont;
|
||||||
|
|
||||||
|
pStream = mndAcquireStream(pMnode, dropStreamReq.name);
|
||||||
|
|
||||||
|
if (pStream == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// todo check auth
|
||||||
|
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
goto DROP_STREAM_OVER;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq);
|
||||||
|
if (pTrans == NULL) {
|
||||||
|
mError("stream:%s, failed to drop since %s", dropStreamReq.name, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
mDebug("trans:%d, used to drop stream:%s", pTrans->id, dropStreamReq.name);
|
||||||
|
|
||||||
|
// drop all tasks
|
||||||
|
if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) {
|
||||||
|
mError("stream:%s, failed to drop task since %s", dropStreamReq.name, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DROP_STREAM_OVER:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams) {
|
static int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SDbObj *pDb = mndAcquireDb(pMnode, dbName);
|
SDbObj *pDb = mndAcquireDb(pMnode, dbName);
|
||||||
|
|
|
@ -387,7 +387,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodesNodeToString((SNode*)pPlan, false, &topicObj.physicalPlan, NULL) != 0) {
|
if (nodesNodeToString((SNode *)pPlan, false, &topicObj.physicalPlan, NULL) != 0) {
|
||||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||||
taosMemoryFree(topicObj.ast);
|
taosMemoryFree(topicObj.ast);
|
||||||
taosMemoryFree(topicObj.sql);
|
taosMemoryFree(topicObj.sql);
|
||||||
|
@ -440,19 +440,18 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SMqTopicObj *pTopic = NULL;
|
SMqTopicObj *pTopic = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SCMCreateTopicReq createTopicReq = {0};
|
SCMCreateTopicReq createTopicReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCMCreateTopicReq(pReq->pCont, pReq->contLen, &createTopicReq) != 0) {
|
if (tDeserializeSCMCreateTopicReq(pReq->pCont, pReq->contLen, &createTopicReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("topic:%s, start to create, sql:%s", createTopicReq.name, createTopicReq.sql);
|
mDebug("topic:%s, start to create, sql:%s", createTopicReq.name, createTopicReq.sql);
|
||||||
|
|
||||||
if (mndCheckCreateTopicReq(&createTopicReq) != 0) {
|
if (mndCheckCreateTopicReq(&createTopicReq) != 0) {
|
||||||
mError("topic:%s, failed to create since %s", createTopicReq.name, terrstr());
|
mError("topic:%s, failed to create since %s", createTopicReq.name, terrstr());
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTopic = mndAcquireTopic(pMnode, createTopicReq.name);
|
pTopic = mndAcquireTopic(pMnode, createTopicReq.name);
|
||||||
|
@ -460,41 +459,35 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
|
||||||
if (createTopicReq.igExists) {
|
if (createTopicReq.igExists) {
|
||||||
mDebug("topic:%s, already exist, ignore exist is set", createTopicReq.name);
|
mDebug("topic:%s, already exist, ignore exist is set", createTopicReq.name);
|
||||||
code = 0;
|
code = 0;
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_MND_TOPIC_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_TOPIC_ALREADY_EXIST;
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
} else if (terrno != TSDB_CODE_MND_TOPIC_NOT_EXIST) {
|
} else if (terrno != TSDB_CODE_MND_TOPIC_NOT_EXIST) {
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDb = mndAcquireDb(pMnode, createTopicReq.subDbName);
|
pDb = mndAcquireDb(pMnode, createTopicReq.subDbName);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
goto _OVER;
|
||||||
goto CREATE_TOPIC_OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto CREATE_TOPIC_OVER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndCreateTopic(pMnode, pReq, &createTopicReq, pDb);
|
code = mndCreateTopic(pMnode, pReq, &createTopicReq, pDb);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
CREATE_TOPIC_OVER:
|
_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("topic:%s, failed to create since %s", createTopicReq.name, terrstr());
|
mError("topic:%s, failed to create since %s", createTopicReq.name, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseTopic(pMnode, pTopic);
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
tFreeSCMCreateTopicReq(&createTopicReq);
|
tFreeSCMCreateTopicReq(&createTopicReq);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -1362,7 +1362,6 @@ static int32_t mndProcessKillTransReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SKillTransReq killReq = {0};
|
SKillTransReq killReq = {0};
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
|
|
||||||
if (tDeserializeSKillTransReq(pReq->pCont, pReq->contLen, &killReq) != 0) {
|
if (tDeserializeSKillTransReq(pReq->pCont, pReq->contLen, &killReq) != 0) {
|
||||||
|
@ -1372,12 +1371,7 @@ static int32_t mndProcessKillTransReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
mInfo("trans:%d, start to kill", killReq.transId);
|
mInfo("trans:%d, start to kill", killReq.transId);
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_KILL_TRANS) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckTransAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1393,7 +1387,6 @@ _OVER:
|
||||||
mError("trans:%d, failed to kill since %s", killReq.transId, terrstr());
|
mError("trans:%d, failed to kill since %s", killReq.transId, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
mndReleaseTrans(pMnode, pTrans);
|
mndReleaseTrans(pMnode, pTrans);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,8 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char
|
||||||
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
||||||
userObj.createdTime = taosGetTimestampMs();
|
userObj.createdTime = taosGetTimestampMs();
|
||||||
userObj.updateTime = userObj.createdTime;
|
userObj.updateTime = userObj.createdTime;
|
||||||
|
userObj.sysInfo = 1;
|
||||||
|
userObj.enable = 1;
|
||||||
|
|
||||||
if (strcmp(user, TSDB_DEFAULT_USER) == 0) {
|
if (strcmp(user, TSDB_DEFAULT_USER) == 0) {
|
||||||
userObj.superUser = 1;
|
userObj.superUser = 1;
|
||||||
|
@ -128,6 +130,9 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
|
||||||
SDB_SET_INT64(pRaw, dataPos, pUser->createdTime, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pUser->createdTime, _OVER)
|
||||||
SDB_SET_INT64(pRaw, dataPos, pUser->updateTime, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pUser->updateTime, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pUser->superUser, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pUser->superUser, _OVER)
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pUser->sysInfo, _OVER)
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pUser->enable, _OVER)
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pUser->reserve, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pUser->authVersion, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pUser->authVersion, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, numOfReadDbs, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, numOfReadDbs, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, numOfWriteDbs, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, numOfWriteDbs, _OVER)
|
||||||
|
@ -184,6 +189,9 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pUser->createdTime, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pUser->createdTime, _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pUser->updateTime, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pUser->updateTime, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pUser->superUser, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pUser->superUser, _OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &pUser->sysInfo, _OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &pUser->enable, _OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &pUser->reserve, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pUser->authVersion, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pUser->authVersion, _OVER)
|
||||||
|
|
||||||
int32_t numOfReadDbs = 0;
|
int32_t numOfReadDbs = 0;
|
||||||
|
@ -256,6 +264,8 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) {
|
||||||
taosWLockLatch(&pOld->lock);
|
taosWLockLatch(&pOld->lock);
|
||||||
pOld->updateTime = pNew->updateTime;
|
pOld->updateTime = pNew->updateTime;
|
||||||
pOld->authVersion = pNew->authVersion;
|
pOld->authVersion = pNew->authVersion;
|
||||||
|
pOld->sysInfo = pNew->sysInfo;
|
||||||
|
pOld->enable = pNew->enable;
|
||||||
memcpy(pOld->pass, pNew->pass, TSDB_PASSWORD_LEN);
|
memcpy(pOld->pass, pNew->pass, TSDB_PASSWORD_LEN);
|
||||||
TSWAP(pOld->readDbs, pNew->readDbs);
|
TSWAP(pOld->readDbs, pNew->readDbs);
|
||||||
TSWAP(pOld->writeDbs, pNew->writeDbs);
|
TSWAP(pOld->writeDbs, pNew->writeDbs);
|
||||||
|
@ -286,6 +296,8 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
||||||
userObj.createdTime = taosGetTimestampMs();
|
userObj.createdTime = taosGetTimestampMs();
|
||||||
userObj.updateTime = userObj.createdTime;
|
userObj.updateTime = userObj.createdTime;
|
||||||
userObj.superUser = pCreate->superUser;
|
userObj.superUser = pCreate->superUser;
|
||||||
|
userObj.sysInfo = pCreate->sysInfo;
|
||||||
|
userObj.enable = pCreate->enable;
|
||||||
|
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
|
@ -348,7 +360,7 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckCreateUserAuth(pOperUser) != 0) {
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_USER) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,6 +493,14 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
||||||
newUser.superUser = alterReq.superUser;
|
newUser.superUser = alterReq.superUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alterReq.alterType == TSDB_ALTER_USER_ENABLE) {
|
||||||
|
newUser.enable = alterReq.enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alterReq.alterType == TSDB_ALTER_USER_SYSINFO) {
|
||||||
|
newUser.sysInfo = alterReq.sysInfo;
|
||||||
|
}
|
||||||
|
|
||||||
if (alterReq.alterType == TSDB_ALTER_USER_ADD_READ_DB || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB) {
|
if (alterReq.alterType == TSDB_ALTER_USER_ADD_READ_DB || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB) {
|
||||||
if (strcmp(alterReq.dbname, "1.*") != 0) {
|
if (strcmp(alterReq.dbname, "1.*") != 0) {
|
||||||
int32_t len = strlen(alterReq.dbname) + 1;
|
int32_t len = strlen(alterReq.dbname) + 1;
|
||||||
|
@ -603,7 +623,6 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
SUserObj *pUser = NULL;
|
||||||
SUserObj *pOperUser = NULL;
|
|
||||||
SDropUserReq dropReq = {0};
|
SDropUserReq dropReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSDropUserReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
if (tDeserializeSDropUserReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
||||||
|
@ -624,13 +643,7 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_USER) != 0) {
|
||||||
if (pOperUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckDropUserAuth(pOperUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,9 +655,7 @@ _OVER:
|
||||||
mError("user:%s, failed to drop since %s", dropReq.user, terrstr());
|
mError("user:%s, failed to drop since %s", dropReq.user, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseUser(pMnode, pOperUser);
|
|
||||||
mndReleaseUser(pMnode, pUser);
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,19 +751,21 @@ static int32_t mndRetrieveUsers(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
|
|
||||||
cols = 0;
|
cols = 0;
|
||||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
|
char name[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
char name[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(name, pUser->user, pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(name, pUser->user, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)name, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)name, false);
|
||||||
|
|
||||||
cols++;
|
cols++;
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)&pUser->superUser, false);
|
||||||
|
|
||||||
const char *src = pUser->superUser ? "super" : "normal";
|
cols++;
|
||||||
char b[10 + VARSTR_HEADER_SIZE] = {0};
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
STR_WITH_SIZE_TO_VARSTR(b, src, strlen(src));
|
colDataAppend(pColInfo, numOfRows, (const char *)&pUser->enable, false);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)b, false);
|
|
||||||
|
cols++;
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)&pUser->sysInfo, false);
|
||||||
|
|
||||||
cols++;
|
cols++;
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
|
|
|
@ -1177,7 +1177,6 @@ _OVER:
|
||||||
|
|
||||||
static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) {
|
static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDnodeObj *pNew1 = NULL;
|
SDnodeObj *pNew1 = NULL;
|
||||||
SDnodeObj *pNew2 = NULL;
|
SDnodeObj *pNew2 = NULL;
|
||||||
SDnodeObj *pNew3 = NULL;
|
SDnodeObj *pNew3 = NULL;
|
||||||
|
@ -1200,13 +1199,8 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("vgId:%d, start to redistribute to dnode %d:%d:%d", req.vgId, req.dnodeId1, req.dnodeId2, req.dnodeId3);
|
mInfo("vgId:%d, start to redistribute to dnode %d:%d:%d", req.vgId, req.dnodeId1, req.dnodeId2, req.dnodeId3);
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) goto _OVER;
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_REDISTRIBUTE_VGROUP) != 0) goto _OVER;
|
||||||
|
|
||||||
pVgroup = mndAcquireVgroup(pMnode, req.vgId);
|
pVgroup = mndAcquireVgroup(pMnode, req.vgId);
|
||||||
if (pVgroup == NULL) goto _OVER;
|
if (pVgroup == NULL) goto _OVER;
|
||||||
|
@ -1368,7 +1362,6 @@ _OVER:
|
||||||
mndReleaseDnode(pMnode, pOld1);
|
mndReleaseDnode(pMnode, pOld1);
|
||||||
mndReleaseDnode(pMnode, pOld2);
|
mndReleaseDnode(pMnode, pOld2);
|
||||||
mndReleaseDnode(pMnode, pOld3);
|
mndReleaseDnode(pMnode, pOld3);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
mndReleaseVgroup(pMnode, pVgroup);
|
mndReleaseVgroup(pMnode, pVgroup);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
|
|
||||||
|
@ -1493,12 +1486,11 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
|
static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
int32_t vgId = 2;
|
int32_t vgId = 2;
|
||||||
SUserObj *pUser = NULL;
|
SVgObj *pVgroup = NULL;
|
||||||
SVgObj *pVgroup = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SDbObj *pDb = NULL;
|
|
||||||
|
|
||||||
mDebug("vgId:%d, start to split", vgId);
|
mDebug("vgId:%d, start to split", vgId);
|
||||||
|
|
||||||
|
@ -1508,19 +1500,12 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
|
||||||
pDb = mndAcquireDb(pMnode, pVgroup->dbName);
|
pDb = mndAcquireDb(pMnode, pVgroup->dbName);
|
||||||
if (pDb == NULL) goto _OVER;
|
if (pDb == NULL) goto _OVER;
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_SPLIT_VGROUP) != 0) goto _OVER;
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) goto _OVER;
|
|
||||||
|
|
||||||
code = mndSplitVgroup(pMnode, pReq, pDb, pVgroup);
|
code = mndSplitVgroup(pMnode, pReq, pDb, pVgroup);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
mndReleaseVgroup(pMnode, pVgroup);
|
mndReleaseVgroup(pMnode, pVgroup);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
return code;
|
return code;
|
||||||
|
@ -1631,21 +1616,15 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq) {
|
static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
SArray *pArray = NULL;
|
||||||
SArray *pArray = NULL;
|
void *pIter = NULL;
|
||||||
void *pIter = NULL;
|
int64_t curMs = taosGetTimestampMs();
|
||||||
int64_t curMs = taosGetTimestampMs();
|
|
||||||
|
|
||||||
mDebug("start to balance vgroup");
|
mDebug("start to balance vgroup");
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) goto _OVER;
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_BALANCE_VGROUP) != 0) goto _OVER;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
|
@ -1676,7 +1655,6 @@ _OVER:
|
||||||
mError("failed to balance vgroup since %s", terrstr());
|
mError("failed to balance vgroup since %s", terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
|
@ -140,6 +140,7 @@ int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen);
|
int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId);
|
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId);
|
||||||
int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen);
|
int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen);
|
||||||
|
int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* data);
|
int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* data);
|
||||||
int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg);
|
||||||
|
|
|
@ -510,3 +510,13 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
streamProcessRecoverRsp(pTask, pRsp);
|
streamProcessRecoverRsp(pTask, pRsp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
|
SVDropStreamTaskReq* pReq = (SVDropStreamTaskReq*)msg;
|
||||||
|
int32_t code = taosHashRemove(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
|
||||||
|
if (code == 0) {
|
||||||
|
// sendrsp
|
||||||
|
}
|
||||||
|
ASSERT(code == 0);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
|
@ -168,6 +168,11 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case TDMT_VND_STREAM_TASK_DROP: {
|
||||||
|
if (tqProcessTaskDropReq(pVnode->pTq, pMsg->pCont, pMsg->contLen) < 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
case TDMT_VND_ALTER_CONFIRM:
|
case TDMT_VND_ALTER_CONFIRM:
|
||||||
vnodeProcessAlterConfirmReq(pVnode, version, pReq, len, pRsp);
|
vnodeProcessAlterConfirmReq(pVnode, version, pReq, len, pRsp);
|
||||||
break;
|
break;
|
||||||
|
@ -375,8 +380,9 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
ret = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
ret = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
||||||
syncAppendEntriesReplyDestroy(pSyncMsg);
|
syncAppendEntriesReplyDestroy(pSyncMsg);
|
||||||
|
|
||||||
} else if (pRpcMsg->msgType == TDMT_SYNC_SET_MNODE_STANDBY) {
|
} else if (pRpcMsg->msgType == TDMT_SYNC_SET_VNODE_STANDBY) {
|
||||||
ret = syncSetStandby(pVnode->sync);
|
ret = syncSetStandby(pVnode->sync);
|
||||||
|
vInfo("vgId:%d, set standby result:0x%x rid:%" PRId64, pVnode->config.vgId, ret, pVnode->sync);
|
||||||
SRpcMsg rsp = {.code = ret, .info = pMsg->info};
|
SRpcMsg rsp = {.code = ret, .info = pMsg->info};
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
typedef struct SGroupResInfo {
|
typedef struct SGroupResInfo {
|
||||||
int32_t index;
|
int32_t index;
|
||||||
SArray* pRows; // SArray<SResKeyPos>
|
SArray* pRows; // SArray<SResKeyPos>
|
||||||
int32_t position;
|
|
||||||
} SGroupResInfo;
|
} SGroupResInfo;
|
||||||
|
|
||||||
typedef struct SResultRow {
|
typedef struct SResultRow {
|
||||||
|
@ -56,7 +55,7 @@ typedef struct SResultRow {
|
||||||
uint32_t numOfRows; // number of rows of current time window
|
uint32_t numOfRows; // number of rows of current time window
|
||||||
STimeWindow win;
|
STimeWindow win;
|
||||||
struct SResultRowEntryInfo pEntryInfo[]; // For each result column, there is a resultInfo
|
struct SResultRowEntryInfo pEntryInfo[]; // For each result column, there is a resultInfo
|
||||||
// char *key; // start key of current result row
|
// char *key; // start key of current result row
|
||||||
} SResultRow;
|
} SResultRow;
|
||||||
|
|
||||||
typedef struct SResultRowPosition {
|
typedef struct SResultRowPosition {
|
||||||
|
@ -71,9 +70,7 @@ typedef struct SResKeyPos {
|
||||||
} SResKeyPos;
|
} SResKeyPos;
|
||||||
|
|
||||||
typedef struct SResultRowInfo {
|
typedef struct SResultRowInfo {
|
||||||
SResultRowPosition *pPosition; // todo remove this
|
|
||||||
int32_t size; // number of result set
|
int32_t size; // number of result set
|
||||||
int32_t capacity; // max capacity
|
|
||||||
SResultRowPosition cur;
|
SResultRowPosition cur;
|
||||||
SList* openWindow;
|
SList* openWindow;
|
||||||
} SResultRowInfo;
|
} SResultRowInfo;
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern int32_t exchangeObjRefPool;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* pData;
|
char* pData;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
|
|
|
@ -181,7 +181,6 @@ typedef struct SExecTaskInfo {
|
||||||
STaskCostInfo cost;
|
STaskCostInfo cost;
|
||||||
int64_t owner; // if it is in execution
|
int64_t owner; // if it is in execution
|
||||||
int32_t code;
|
int32_t code;
|
||||||
// uint64_t totalRows; // total number of rows
|
|
||||||
struct {
|
struct {
|
||||||
char *tablename;
|
char *tablename;
|
||||||
char *dbname;
|
char *dbname;
|
||||||
|
@ -222,10 +221,10 @@ typedef struct STaskRuntimeEnv {
|
||||||
} STaskRuntimeEnv;
|
} STaskRuntimeEnv;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
OP_NOT_OPENED = 0x0,
|
OP_NOT_OPENED = 0x0,
|
||||||
OP_OPENED = 0x1,
|
OP_OPENED = 0x1,
|
||||||
OP_RES_TO_RETURN = 0x5,
|
OP_RES_TO_RETURN = 0x5,
|
||||||
OP_EXEC_DONE = 0x9,
|
OP_EXEC_DONE = 0x9,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct SOperatorFpSet {
|
typedef struct SOperatorFpSet {
|
||||||
|
@ -262,12 +261,12 @@ typedef enum {
|
||||||
} EX_SOURCE_STATUS;
|
} EX_SOURCE_STATUS;
|
||||||
|
|
||||||
typedef struct SSourceDataInfo {
|
typedef struct SSourceDataInfo {
|
||||||
struct SExchangeInfo* pEx;
|
|
||||||
int32_t index;
|
int32_t index;
|
||||||
SRetrieveTableRsp* pRsp;
|
SRetrieveTableRsp* pRsp;
|
||||||
uint64_t totalRows;
|
uint64_t totalRows;
|
||||||
int32_t code;
|
int32_t code;
|
||||||
EX_SOURCE_STATUS status;
|
EX_SOURCE_STATUS status;
|
||||||
|
const char* taskId;
|
||||||
} SSourceDataInfo;
|
} SSourceDataInfo;
|
||||||
|
|
||||||
typedef struct SLoadRemoteDataInfo {
|
typedef struct SLoadRemoteDataInfo {
|
||||||
|
@ -285,6 +284,7 @@ typedef struct SExchangeInfo {
|
||||||
bool seqLoadData; // sequential load data or not, false by default
|
bool seqLoadData; // sequential load data or not, false by default
|
||||||
int32_t current;
|
int32_t current;
|
||||||
SLoadRemoteDataInfo loadInfo;
|
SLoadRemoteDataInfo loadInfo;
|
||||||
|
uint64_t self;
|
||||||
} SExchangeInfo;
|
} SExchangeInfo;
|
||||||
|
|
||||||
#define COL_MATCH_FROM_COL_ID 0x1
|
#define COL_MATCH_FROM_COL_ID 0x1
|
||||||
|
@ -470,10 +470,8 @@ typedef struct SIntervalAggOperatorInfo {
|
||||||
bool timeWindowInterpo; // interpolation needed or not
|
bool timeWindowInterpo; // interpolation needed or not
|
||||||
char** pRow; // previous row/tuple of already processed datablock
|
char** pRow; // previous row/tuple of already processed datablock
|
||||||
SArray* pInterpCols; // interpolation columns
|
SArray* pInterpCols; // interpolation columns
|
||||||
STableQueryInfo* pCurrent; // current tableQueryInfo struct
|
|
||||||
int32_t order; // current SSDataBlock scan order
|
int32_t order; // current SSDataBlock scan order
|
||||||
EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model]
|
EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model]
|
||||||
SArray* pUpdatedWindow; // updated time window due to the input data block from the downstream operator.
|
|
||||||
STimeWindowAggSupp twAggSup;
|
STimeWindowAggSupp twAggSup;
|
||||||
bool invertible;
|
bool invertible;
|
||||||
SArray* pPrevValues; // SArray<SGroupKeys> used to keep the previous not null value for interpolation.
|
SArray* pPrevValues; // SArray<SGroupKeys> used to keep the previous not null value for interpolation.
|
||||||
|
@ -502,8 +500,6 @@ typedef struct SAggOperatorInfo {
|
||||||
STableQueryInfo *current;
|
STableQueryInfo *current;
|
||||||
uint64_t groupId;
|
uint64_t groupId;
|
||||||
SGroupResInfo groupResInfo;
|
SGroupResInfo groupResInfo;
|
||||||
STableQueryInfo *pTableQueryInfo;
|
|
||||||
|
|
||||||
SExprInfo *pScalarExprInfo;
|
SExprInfo *pScalarExprInfo;
|
||||||
int32_t numOfScalarExpr; // the number of scalar expression before the aggregate function can be applied
|
int32_t numOfScalarExpr; // the number of scalar expression before the aggregate function can be applied
|
||||||
SqlFunctionCtx *pScalarCtx; // scalar function requried sql function struct.
|
SqlFunctionCtx *pScalarCtx; // scalar function requried sql function struct.
|
||||||
|
@ -639,8 +635,13 @@ typedef struct SStreamSessionAggOperatorInfo {
|
||||||
|
|
||||||
typedef struct STimeSliceOperatorInfo {
|
typedef struct STimeSliceOperatorInfo {
|
||||||
SOptrBasicInfo binfo;
|
SOptrBasicInfo binfo;
|
||||||
|
STimeWindow win;
|
||||||
SInterval interval;
|
SInterval interval;
|
||||||
SGroupResInfo groupResInfo; // multiple results build supporter
|
int64_t current;
|
||||||
|
SArray* pPrevRow; // SArray<SGroupValue>
|
||||||
|
SArray* pCols; // SArray<SColumn>
|
||||||
|
int32_t fillType; // fill type
|
||||||
|
struct SFillColInfo* pFillColInfo; // fill column info
|
||||||
} STimeSliceOperatorInfo;
|
} STimeSliceOperatorInfo;
|
||||||
|
|
||||||
typedef struct SStateWindowOperatorInfo {
|
typedef struct SStateWindowOperatorInfo {
|
||||||
|
@ -733,6 +734,8 @@ typedef struct SJoinOperatorInfo {
|
||||||
#define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED)
|
#define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED)
|
||||||
#define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED)
|
#define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED)
|
||||||
|
|
||||||
|
void doDestroyExchangeOperatorInfo(void* param);
|
||||||
|
|
||||||
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn,
|
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn,
|
||||||
__optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode,
|
__optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode,
|
||||||
__optr_decode_fn_t decode, __optr_explain_fn_t explain);
|
__optr_decode_fn_t decode, __optr_explain_fn_t explain);
|
||||||
|
@ -840,7 +843,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
||||||
SSDataBlock* pResultBlock, SArray* pGroupColList, SExecTaskInfo* pTaskInfo);
|
SSDataBlock* pResultBlock, SArray* pGroupColList, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo);
|
SSDataBlock* pResultBlock, const SNodeListNode* pValNode, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SNode* pOnCondition, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SNode* pOnCondition, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
|
@ -912,6 +915,15 @@ int32_t compareTimeWindow(const void* p1, const void* p2, const void* param);
|
||||||
int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition,
|
int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition,
|
||||||
SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, int32_t numOfExprs, const int32_t* rowCellOffset,
|
SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, int32_t numOfExprs, const int32_t* rowCellOffset,
|
||||||
SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
|
int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STableListInfo* pListInfo,
|
||||||
|
SNode* pTagCond);
|
||||||
|
int32_t createMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle,
|
||||||
|
STableListInfo* pTableListInfo, SArray* arrayReader, uint64_t queryId,
|
||||||
|
uint64_t taskId, SNode* pTagCond);
|
||||||
|
SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SArray* dataReaders,
|
||||||
|
SReadHandle* readHandle, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex);
|
void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -28,8 +28,6 @@ struct SSDataBlock;
|
||||||
|
|
||||||
typedef struct SFillColInfo {
|
typedef struct SFillColInfo {
|
||||||
SExprInfo *pExpr;
|
SExprInfo *pExpr;
|
||||||
// SResSchema schema;
|
|
||||||
// int16_t functionId; // sql function id
|
|
||||||
int16_t flag; // column flag: TAG COLUMN|NORMAL COLUMN
|
int16_t flag; // column flag: TAG COLUMN|NORMAL COLUMN
|
||||||
int16_t tagIndex; // index of current tag in SFillTagColInfo array list
|
int16_t tagIndex; // index of current tag in SFillTagColInfo array list
|
||||||
SVariant fillVal;
|
SVariant fillVal;
|
||||||
|
|
|
@ -41,13 +41,7 @@ int32_t getOutputInterResultBufSize(STaskAttr* pQueryAttr) {
|
||||||
|
|
||||||
int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) {
|
int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) {
|
||||||
pResultRowInfo->size = 0;
|
pResultRowInfo->size = 0;
|
||||||
pResultRowInfo->capacity = size;
|
|
||||||
pResultRowInfo->cur.pageId = -1;
|
pResultRowInfo->cur.pageId = -1;
|
||||||
|
|
||||||
pResultRowInfo->pPosition = taosMemoryCalloc(pResultRowInfo->capacity, sizeof(SResultRowPosition));
|
|
||||||
if (pResultRowInfo->pPosition == NULL) {
|
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,25 +50,14 @@ void cleanupResultRowInfo(SResultRowInfo *pResultRowInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pResultRowInfo->capacity == 0) {
|
|
||||||
// assert(pResultRowInfo->pResult == NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int32_t i = 0; i < pResultRowInfo->size; ++i) {
|
for(int32_t i = 0; i < pResultRowInfo->size; ++i) {
|
||||||
// if (pResultRowInfo->pResult[i]) {
|
// if (pResultRowInfo->pResult[i]) {
|
||||||
// taosMemoryFreeClear(pResultRowInfo->pResult[i]->key);
|
// taosMemoryFreeClear(pResultRowInfo->pResult[i]->key);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pResultRowInfo->pPosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetResultRowInfo(STaskRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo) {
|
void resetResultRowInfo(STaskRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo) {
|
||||||
if (pResultRowInfo == NULL || pResultRowInfo->capacity == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pResultRowInfo->size; ++i) {
|
for (int32_t i = 0; i < pResultRowInfo->size; ++i) {
|
||||||
// SResultRow *pWindowRes = pResultRowInfo->pResult[i];
|
// SResultRow *pWindowRes = pResultRowInfo->pResult[i];
|
||||||
// clearResultRow(pRuntimeEnv, pWindowRes);
|
// clearResultRow(pRuntimeEnv, pWindowRes);
|
||||||
|
@ -288,232 +271,3 @@ void orderTheResultRows(STaskRuntimeEnv* pRuntimeEnv) {
|
||||||
|
|
||||||
taosArraySort(pRuntimeEnv->pResultRowArrayList, fn);
|
taosArraySort(pRuntimeEnv->pResultRowArrayList, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mergeIntoGroupResultImplRv(STaskRuntimeEnv *pRuntimeEnv, SGroupResInfo* pGroupResInfo, uint64_t groupId, int32_t* rowCellInfoOffset) {
|
|
||||||
if (pGroupResInfo->pRows == NULL) {
|
|
||||||
pGroupResInfo->pRows = taosArrayInit(100, POINTER_BYTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t len = taosArrayGetSize(pRuntimeEnv->pResultRowArrayList);
|
|
||||||
for(; pGroupResInfo->position < len; ++pGroupResInfo->position) {
|
|
||||||
SResultRowCell* pResultRowCell = taosArrayGet(pRuntimeEnv->pResultRowArrayList, pGroupResInfo->position);
|
|
||||||
if (pResultRowCell->groupId != groupId) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int64_t num = 0;//getNumOfResultWindowRes(pRuntimeEnv, &pResultRowCell->pos, rowCellInfoOffset);
|
|
||||||
if (num <= 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayPush(pGroupResInfo->pRows, &pResultRowCell->pos);
|
|
||||||
// pResultRowCell->pRow->numOfRows = (uint32_t) num;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv, SGroupResInfo* pGroupResInfo, SArray *pTableList,
|
|
||||||
int32_t* rowCellInfoOffset) {
|
|
||||||
bool ascQuery = true;
|
|
||||||
#if 0
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
|
||||||
|
|
||||||
int32_t *posList = NULL;
|
|
||||||
SMultiwayMergeTreeInfo *pTree = NULL;
|
|
||||||
STableQueryInfo **pTableQueryInfoList = NULL;
|
|
||||||
|
|
||||||
size_t size = taosArrayGetSize(pTableList);
|
|
||||||
if (pGroupResInfo->pRows == NULL) {
|
|
||||||
pGroupResInfo->pRows = taosArrayInit(100, POINTER_BYTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
posList = taosMemoryCalloc(size, sizeof(int32_t));
|
|
||||||
pTableQueryInfoList = taosMemoryMalloc(POINTER_BYTES * size);
|
|
||||||
|
|
||||||
if (pTableQueryInfoList == NULL || posList == NULL || pGroupResInfo->pRows == NULL || pGroupResInfo->pRows == NULL) {
|
|
||||||
// qError("QInfo:%"PRIu64" failed alloc memory", GET_TASKID(pRuntimeEnv));
|
|
||||||
code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
|
||||||
goto _end;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t numOfTables = 0;
|
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
|
||||||
STableQueryInfo *item = taosArrayGetP(pTableList, i);
|
|
||||||
// if (item->resInfo.size > 0) {
|
|
||||||
// pTableQueryInfoList[numOfTables++] = item;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// there is no data in current group
|
|
||||||
// no need to merge results since only one table in each group
|
|
||||||
// if (numOfTables == 0) {
|
|
||||||
// goto _end;
|
|
||||||
// }
|
|
||||||
|
|
||||||
int32_t order = TSDB_ORDER_ASC;
|
|
||||||
SCompSupporter cs = {pTableQueryInfoList, posList, order};
|
|
||||||
|
|
||||||
int32_t ret = tMergeTreeCreate(&pTree, numOfTables, &cs, tableResultComparFn);
|
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
|
||||||
code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
|
||||||
goto _end;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t lastTimestamp = ascQuery? INT64_MIN:INT64_MAX;
|
|
||||||
int64_t startt = taosGetTimestampMs();
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
int32_t tableIndex = tMergeTreeGetChosenIndex(pTree);
|
|
||||||
|
|
||||||
SResultRowInfo *pWindowResInfo = &pTableQueryInfoList[tableIndex]->resInfo;
|
|
||||||
ASSERT(0);
|
|
||||||
SResultRow *pWindowRes = NULL;//getResultRow(pBuf, pWindowResInfo, cs.rowIndex[tableIndex]);
|
|
||||||
|
|
||||||
int64_t num = 0;//getNumOfResultWindowRes(pRuntimeEnv, pWindowRes, rowCellInfoOffset);
|
|
||||||
if (num <= 0) {
|
|
||||||
cs.rowIndex[tableIndex] += 1;
|
|
||||||
|
|
||||||
if (cs.rowIndex[tableIndex] >= pWindowResInfo->size) {
|
|
||||||
cs.rowIndex[tableIndex] = -1;
|
|
||||||
if (--numOfTables == 0) { // all input sources are exhausted
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
assert((pWindowRes->win.skey >= lastTimestamp && ascQuery) || (pWindowRes->win.skey <= lastTimestamp && !ascQuery));
|
|
||||||
|
|
||||||
if (pWindowRes->win.skey != lastTimestamp) {
|
|
||||||
taosArrayPush(pGroupResInfo->pRows, &pWindowRes);
|
|
||||||
pWindowRes->numOfRows = (uint32_t) num;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastTimestamp = pWindowRes->win.skey;
|
|
||||||
|
|
||||||
// move to the next row of current entry
|
|
||||||
if ((++cs.rowIndex[tableIndex]) >= pWindowResInfo->size) {
|
|
||||||
cs.rowIndex[tableIndex] = -1;
|
|
||||||
|
|
||||||
// all input sources are exhausted
|
|
||||||
if ((--numOfTables) == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tMergeTreeAdjust(pTree, tMergeTreeGetAdjustIndex(pTree));
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t endt = taosGetTimestampMs();
|
|
||||||
|
|
||||||
// qDebug("QInfo:%"PRIx64" result merge completed for group:%d, elapsed time:%" PRId64 " ms", GET_TASKID(pRuntimeEnv),
|
|
||||||
// pGroupResInfo->currentGroup, endt - startt);
|
|
||||||
|
|
||||||
_end:
|
|
||||||
taosMemoryFreeClear(pTableQueryInfoList);
|
|
||||||
taosMemoryFreeClear(posList);
|
|
||||||
taosMemoryFreeClear(pTree);
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mergeIntoGroupResult(SGroupResInfo* pGroupResInfo, STaskRuntimeEnv* pRuntimeEnv, int32_t* offset) {
|
|
||||||
int64_t st = taosGetTimestampUs();
|
|
||||||
|
|
||||||
while (pGroupResInfo->currentGroup < pGroupResInfo->totalGroup) {
|
|
||||||
mergeIntoGroupResultImplRv(pRuntimeEnv, pGroupResInfo, pGroupResInfo->currentGroup, offset);
|
|
||||||
|
|
||||||
// this group generates at least one result, return results
|
|
||||||
if (taosArrayGetSize(pGroupResInfo->pRows) > 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// qDebug("QInfo:%"PRIu64" no result in group %d, continue", GET_TASKID(pRuntimeEnv), pGroupResInfo->currentGroup);
|
|
||||||
cleanupGroupResInfo(pGroupResInfo);
|
|
||||||
incNextGroup(pGroupResInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int64_t elapsedTime = taosGetTimestampUs() - st;
|
|
||||||
// qDebug("QInfo:%"PRIu64" merge res data into group, index:%d, total group:%d, elapsed time:%" PRId64 "us", GET_TASKID(pRuntimeEnv),
|
|
||||||
// pGroupResInfo->currentGroup, pGroupResInfo->totalGroup, elapsedTime);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
//void blockDistInfoToBinary(STableBlockDist* pDist, struct SBufferWriter* bw) {
|
|
||||||
// tbufWriteUint32(bw, pDist->numOfTables);
|
|
||||||
// tbufWriteUint16(bw, pDist->numOfFiles);
|
|
||||||
// tbufWriteUint64(bw, pDist->totalSize);
|
|
||||||
// tbufWriteUint64(bw, pDist->totalRows);
|
|
||||||
// tbufWriteInt32(bw, pDist->maxRows);
|
|
||||||
// tbufWriteInt32(bw, pDist->minRows);
|
|
||||||
// tbufWriteUint32(bw, pDist->numOfInmemRows);
|
|
||||||
// tbufWriteUint32(bw, pDist->numOfSmallBlocks);
|
|
||||||
// tbufWriteUint64(bw, taosArrayGetSize(pDist->dataBlockInfos));
|
|
||||||
//
|
|
||||||
// // compress the binary string
|
|
||||||
// char* p = TARRAY_GET_START(pDist->dataBlockInfos);
|
|
||||||
//
|
|
||||||
// // compress extra bytes
|
|
||||||
// size_t x = taosArrayGetSize(pDist->dataBlockInfos) * pDist->dataBlockInfos->elemSize;
|
|
||||||
// char* tmp = taosMemoryMalloc(x + 2);
|
|
||||||
//
|
|
||||||
// bool comp = false;
|
|
||||||
// int32_t len = tsCompressString(p, (int32_t)x, 1, tmp, (int32_t)x, ONE_STAGE_COMP, NULL, 0);
|
|
||||||
// if (len == -1 || len >= x) { // compress failed, do not compress this binary data
|
|
||||||
// comp = false;
|
|
||||||
// len = (int32_t)x;
|
|
||||||
// } else {
|
|
||||||
// comp = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// tbufWriteUint8(bw, comp);
|
|
||||||
// tbufWriteUint32(bw, len);
|
|
||||||
// if (comp) {
|
|
||||||
// tbufWriteBinary(bw, tmp, len);
|
|
||||||
// } else {
|
|
||||||
// tbufWriteBinary(bw, p, len);
|
|
||||||
// }
|
|
||||||
// taosMemoryFreeClear(tmp);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//void blockDistInfoFromBinary(const char* data, int32_t len, STableBlockDist* pDist) {
|
|
||||||
// SBufferReader br = tbufInitReader(data, len, false);
|
|
||||||
//
|
|
||||||
// pDist->numOfTables = tbufReadUint32(&br);
|
|
||||||
// pDist->numOfFiles = tbufReadUint16(&br);
|
|
||||||
// pDist->totalSize = tbufReadUint64(&br);
|
|
||||||
// pDist->totalRows = tbufReadUint64(&br);
|
|
||||||
// pDist->maxRows = tbufReadInt32(&br);
|
|
||||||
// pDist->minRows = tbufReadInt32(&br);
|
|
||||||
// pDist->numOfInmemRows = tbufReadUint32(&br);
|
|
||||||
// pDist->numOfSmallBlocks = tbufReadUint32(&br);
|
|
||||||
// int64_t numSteps = tbufReadUint64(&br);
|
|
||||||
//
|
|
||||||
// bool comp = tbufReadUint8(&br);
|
|
||||||
// uint32_t compLen = tbufReadUint32(&br);
|
|
||||||
//
|
|
||||||
// size_t originalLen = (size_t) (numSteps *sizeof(SFileBlockInfo));
|
|
||||||
//
|
|
||||||
// char* outputBuf = NULL;
|
|
||||||
// if (comp) {
|
|
||||||
// outputBuf = taosMemoryMalloc(originalLen);
|
|
||||||
//
|
|
||||||
// size_t actualLen = compLen;
|
|
||||||
// const char* compStr = tbufReadBinary(&br, &actualLen);
|
|
||||||
//
|
|
||||||
// int32_t orignalLen = tsDecompressString(compStr, compLen, 1, outputBuf,
|
|
||||||
// (int32_t)originalLen , ONE_STAGE_COMP, NULL, 0);
|
|
||||||
// assert(orignalLen == numSteps *sizeof(SFileBlockInfo));
|
|
||||||
// } else {
|
|
||||||
// outputBuf = (char*) tbufReadBinary(&br, &originalLen);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pDist->dataBlockInfos = taosArrayFromList(outputBuf, (uint32_t)numSteps, sizeof(SFileBlockInfo));
|
|
||||||
// if (comp) {
|
|
||||||
// taosMemoryFreeClear(outputBuf);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
|
@ -13,28 +13,30 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <vnode.h>
|
|
||||||
#include "dataSinkMgt.h"
|
|
||||||
#include "texception.h"
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tarray.h"
|
#include "tref.h"
|
||||||
#include "tcache.h"
|
#include "dataSinkMgt.h"
|
||||||
#include "tglobal.h"
|
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tudf.h"
|
#include "tudf.h"
|
||||||
|
|
||||||
#include "executor.h"
|
#include "executor.h"
|
||||||
#include "executorimpl.h"
|
#include "executorimpl.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "thash.h"
|
|
||||||
#include "tlosertree.h"
|
static TdThreadOnce initPoolOnce = PTHREAD_ONCE_INIT;
|
||||||
#include "ttypes.h"
|
int32_t exchangeObjRefPool = -1;
|
||||||
|
|
||||||
|
static void initRefPool() {
|
||||||
|
exchangeObjRefPool = taosOpenRef(1024, doDestroyExchangeOperatorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan,
|
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan,
|
||||||
qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, EOPTR_EXEC_MODEL model) {
|
qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, EOPTR_EXEC_MODEL model) {
|
||||||
assert(readHandle != NULL && pSubplan != NULL);
|
assert(readHandle != NULL && pSubplan != NULL);
|
||||||
SExecTaskInfo** pTask = (SExecTaskInfo**)pTaskInfo;
|
SExecTaskInfo** pTask = (SExecTaskInfo**)pTaskInfo;
|
||||||
|
|
||||||
|
taosThreadOnce(&initPoolOnce, initRefPool);
|
||||||
|
|
||||||
int32_t code = createExecTaskInfoImpl(pSubplan, pTask, readHandle, taskId, model);
|
int32_t code = createExecTaskInfoImpl(pSubplan, pTask, readHandle, taskId, model);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "tref.h"
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
@ -37,9 +38,6 @@
|
||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
|
|
||||||
#define IS_MAIN_SCAN(runtime) ((runtime)->scanFlag == MAIN_SCAN)
|
#define IS_MAIN_SCAN(runtime) ((runtime)->scanFlag == MAIN_SCAN)
|
||||||
#define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == REVERSE_SCAN)
|
|
||||||
#define IS_REPEAT_SCAN(runtime) ((runtime)->scanFlag == REPEAT_SCAN)
|
|
||||||
#define SET_MAIN_SCAN_FLAG(runtime) ((runtime)->scanFlag = MAIN_SCAN)
|
|
||||||
#define SET_REVERSE_SCAN_FLAG(runtime) ((runtime)->scanFlag = REVERSE_SCAN)
|
#define SET_REVERSE_SCAN_FLAG(runtime) ((runtime)->scanFlag = REVERSE_SCAN)
|
||||||
|
|
||||||
#define SDATA_BLOCK_INITIALIZER \
|
#define SDATA_BLOCK_INITIALIZER \
|
||||||
|
@ -47,12 +45,6 @@
|
||||||
|
|
||||||
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
|
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
|
||||||
|
|
||||||
enum {
|
|
||||||
TS_JOIN_TS_EQUAL = 0,
|
|
||||||
TS_JOIN_TS_NOT_EQUALS = 1,
|
|
||||||
TS_JOIN_TAG_NOT_EQUALS = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static UNUSED_FUNC void *u_malloc (size_t __size) {
|
static UNUSED_FUNC void *u_malloc (size_t __size) {
|
||||||
uint32_t v = taosRand();
|
uint32_t v = taosRand();
|
||||||
|
@ -88,7 +80,6 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st)))
|
#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st)))
|
||||||
//#define GET_NUM_OF_TABLEGROUP(q) taosArrayGetSize((q)->tableqinfoGroupInfo.pGroupList)
|
|
||||||
#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->interval.interval > 0)
|
#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->interval.interval > 0)
|
||||||
|
|
||||||
int32_t getMaximumIdleDurationSec() { return tsShellActivityTimer * 2; }
|
int32_t getMaximumIdleDurationSec() { return tsShellActivityTimer * 2; }
|
||||||
|
@ -110,7 +101,6 @@ static void releaseQueryBuf(size_t numOfTables);
|
||||||
|
|
||||||
static void destroySFillOperatorInfo(void* param, int32_t numOfOutput);
|
static void destroySFillOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput);
|
static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
static void destroyTagScanOperatorInfo(void* param, int32_t numOfOutput);
|
|
||||||
static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput);
|
static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
static void destroyAggOperatorInfo(void* param, int32_t numOfOutput);
|
static void destroyAggOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
|
|
||||||
|
@ -118,7 +108,6 @@ static void destroyIntervalOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
static void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput);
|
static void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
|
|
||||||
static void destroyOperatorInfo(SOperatorInfo* pOperator);
|
static void destroyOperatorInfo(SOperatorInfo* pOperator);
|
||||||
static void destroySysTableScannerOperatorInfo(void* param, int32_t numOfOutput);
|
|
||||||
|
|
||||||
void doSetOperatorCompleted(SOperatorInfo* pOperator) {
|
void doSetOperatorCompleted(SOperatorInfo* pOperator) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
|
@ -562,10 +551,6 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWindow
|
||||||
pCtx[k].input.startRowIndex = offset;
|
pCtx[k].input.startRowIndex = offset;
|
||||||
pCtx[k].input.numOfRows = forwardStep;
|
pCtx[k].input.numOfRows = forwardStep;
|
||||||
|
|
||||||
if (tsCol != NULL) {
|
|
||||||
pCtx[k].ptsList = tsCol;
|
|
||||||
}
|
|
||||||
|
|
||||||
// not a whole block involved in query processing, statistics data can not be used
|
// not a whole block involved in query processing, statistics data can not be used
|
||||||
// NOTE: the original value of isSet have been changed here
|
// NOTE: the original value of isSet have been changed here
|
||||||
if (pCtx[k].input.colDataAggIsSet && forwardStep < numOfTotal) {
|
if (pCtx[k].input.colDataAggIsSet && forwardStep < numOfTotal) {
|
||||||
|
@ -1133,40 +1118,6 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
||||||
pCtx->increase = false;
|
pCtx->increase = false;
|
||||||
|
|
||||||
pCtx->param = pFunct->pParam;
|
pCtx->param = pFunct->pParam;
|
||||||
// for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
|
|
||||||
// // set the order information for top/bottom query
|
|
||||||
// int32_t functionId = pCtx->functionId;
|
|
||||||
// if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) {
|
|
||||||
// int32_t f = getExprFunctionId(&pExpr[0]);
|
|
||||||
// assert(f == FUNCTION_TS || f == FUNCTION_TS_DUMMY);
|
|
||||||
//
|
|
||||||
// // pCtx->param[2].i = pQueryAttr->order.order;
|
|
||||||
// // pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
|
|
||||||
// // pCtx->param[3].i = functionId;
|
|
||||||
// // pCtx->param[3].nType = TSDB_DATA_TYPE_BIGINT;
|
|
||||||
//
|
|
||||||
// // pCtx->param[1].i = pQueryAttr->order.col.info.colId;
|
|
||||||
// } else if (functionId == FUNCTION_INTERP) {
|
|
||||||
// // pCtx->param[2].i = (int8_t)pQueryAttr->fillType;
|
|
||||||
// // if (pQueryAttr->fillVal != NULL) {
|
|
||||||
// // if (isNull((const char *)&pQueryAttr->fillVal[i], pCtx->inputType)) {
|
|
||||||
// // pCtx->param[1].nType = TSDB_DATA_TYPE_NULL;
|
|
||||||
// // } else { // todo refactor, taosVariantCreateFromBinary should handle the NULL value
|
|
||||||
// // if (pCtx->inputType != TSDB_DATA_TYPE_BINARY && pCtx->inputType != TSDB_DATA_TYPE_NCHAR) {
|
|
||||||
// // taosVariantCreateFromBinary(&pCtx->param[1], (char *)&pQueryAttr->fillVal[i],
|
|
||||||
// pCtx->inputBytes, pCtx->inputType);
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// } else if (functionId == FUNCTION_TWA) {
|
|
||||||
// // pCtx->param[1].i = pQueryAttr->window.skey;
|
|
||||||
// // pCtx->param[1].nType = TSDB_DATA_TYPE_BIGINT;
|
|
||||||
// // pCtx->param[2].i = pQueryAttr->window.ekey;
|
|
||||||
// // pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
|
|
||||||
// } else if (functionId == FUNCTION_ARITHM) {
|
|
||||||
// // pCtx->param[1].pz = (char*) getScalarFuncSupport(pRuntimeEnv->scalarSup, i);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 1; i < numOfOutput; ++i) {
|
for (int32_t i = 1; i < numOfOutput; ++i) {
|
||||||
|
@ -2438,44 +2389,44 @@ static void doTableQueryInfoTimeWindowCheck(SExecTaskInfo* pTaskInfo, STableQuer
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// static void updateTableIdInfo(STableQueryInfo* pTableQueryInfo, SSDataBlock* pBlock, SHashObj* pTableIdInfo, int32_t
|
typedef struct SFetchRspHandleWrapper {
|
||||||
// order) {
|
uint32_t exchangeId;
|
||||||
// int32_t step = GET_FORWARD_DIRECTION_FACTOR(order);
|
int32_t sourceIndex;
|
||||||
// pTableQueryInfo->lastKey = ((order == TSDB_ORDER_ASC)? pBlock->info.window.ekey:pBlock->info.window.skey) + step;
|
} SFetchRspHandleWrapper;
|
||||||
//
|
|
||||||
// if (pTableQueryInfo->pTable == NULL) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// STableIdInfo tidInfo = createTableIdInfo(pTableQueryInfo);
|
|
||||||
// STableIdInfo *idinfo = taosHashGet(pTableIdInfo, &tidInfo.tid, sizeof(tidInfo.tid));
|
|
||||||
// if (idinfo != NULL) {
|
|
||||||
// assert(idinfo->tid == tidInfo.tid && idinfo->uid == tidInfo.uid);
|
|
||||||
// idinfo->key = tidInfo.key;
|
|
||||||
// } else {
|
|
||||||
// taosHashPut(pTableIdInfo, &tidInfo.tid, sizeof(tidInfo.tid), &tidInfo, sizeof(STableIdInfo));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
SSourceDataInfo* pSourceDataInfo = (SSourceDataInfo*)param;
|
SFetchRspHandleWrapper* pWrapper = (SFetchRspHandleWrapper*) param;
|
||||||
|
|
||||||
|
SExchangeInfo* pExchangeInfo = taosAcquireRef(exchangeObjRefPool, pWrapper->exchangeId);
|
||||||
|
if (pExchangeInfo == NULL) {
|
||||||
|
qWarn("failed to acquire exchange operator, since it may have been released");
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t index = pWrapper->sourceIndex;
|
||||||
|
SSourceDataInfo* pSourceDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, index);
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
pSourceDataInfo->pRsp = pMsg->pData;
|
pSourceDataInfo->pRsp = pMsg->pData;
|
||||||
|
|
||||||
SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp;
|
SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp;
|
||||||
pRsp->numOfRows = htonl(pRsp->numOfRows);
|
pRsp->numOfRows = htonl(pRsp->numOfRows);
|
||||||
pRsp->compLen = htonl(pRsp->compLen);
|
pRsp->compLen = htonl(pRsp->compLen);
|
||||||
pRsp->numOfCols = htonl(pRsp->numOfCols);
|
pRsp->numOfCols = htonl(pRsp->numOfCols);
|
||||||
pRsp->useconds = htobe64(pRsp->useconds);
|
pRsp->useconds = htobe64(pRsp->useconds);
|
||||||
|
|
||||||
ASSERT(pSourceDataInfo->pRsp != NULL);
|
ASSERT(pRsp != NULL);
|
||||||
qDebug("fetch rsp received, index:%d, rows:%d", pSourceDataInfo->index, pRsp->numOfRows);
|
qDebug("%s fetch rsp received, index:%d, rows:%d", pSourceDataInfo->taskId, index, pRsp->numOfRows);
|
||||||
} else {
|
} else {
|
||||||
pSourceDataInfo->code = code;
|
pSourceDataInfo->code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
pSourceDataInfo->status = EX_SOURCE_DATA_READY;
|
pSourceDataInfo->status = EX_SOURCE_DATA_READY;
|
||||||
tsem_post(&pSourceDataInfo->pEx->ready);
|
|
||||||
|
tsem_post(&pExchangeInfo->ready);
|
||||||
|
taosReleaseRef(exchangeObjRefPool, pWrapper->exchangeId);
|
||||||
|
|
||||||
|
taosMemoryFree(pWrapper);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2524,9 +2475,9 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
||||||
pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, sourceIndex, totalSources);
|
pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, sourceIndex, totalSources);
|
||||||
|
|
||||||
pMsg->header.vgId = htonl(pSource->addr.nodeId);
|
pMsg->header.vgId = htonl(pSource->addr.nodeId);
|
||||||
pMsg->sId = htobe64(pSource->schedId);
|
pMsg->sId = htobe64(pSource->schedId);
|
||||||
pMsg->taskId = htobe64(pSource->taskId);
|
pMsg->taskId = htobe64(pSource->taskId);
|
||||||
pMsg->queryId = htobe64(pTaskInfo->id.queryId);
|
pMsg->queryId = htobe64(pTaskInfo->id.queryId);
|
||||||
|
|
||||||
// send the fetch remote task result reques
|
// send the fetch remote task result reques
|
||||||
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
|
@ -2537,11 +2488,15 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
||||||
return pTaskInfo->code;
|
return pTaskInfo->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
pMsgSendInfo->param = pDataInfo;
|
SFetchRspHandleWrapper* pWrapper = taosMemoryCalloc(1, sizeof(SFetchRspHandleWrapper));
|
||||||
|
pWrapper->exchangeId = pExchangeInfo->self;
|
||||||
|
pWrapper->sourceIndex = sourceIndex;
|
||||||
|
|
||||||
|
pMsgSendInfo->param = pWrapper;
|
||||||
pMsgSendInfo->msgInfo.pData = pMsg;
|
pMsgSendInfo->msgInfo.pData = pMsg;
|
||||||
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
||||||
pMsgSendInfo->msgType = TDMT_VND_FETCH;
|
pMsgSendInfo->msgType = TDMT_VND_FETCH;
|
||||||
pMsgSendInfo->fp = loadRemoteDataCallback;
|
pMsgSendInfo->fp = loadRemoteDataCallback;
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
int64_t transporterId = 0;
|
||||||
int32_t code = asyncSendMsgToServer(pExchangeInfo->pTransporter, &pSource->addr.epSet, &transporterId, pMsgSendInfo);
|
int32_t code = asyncSendMsgToServer(pExchangeInfo->pTransporter, &pSource->addr.epSet, &transporterId, pMsgSendInfo);
|
||||||
|
@ -2689,10 +2644,10 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
SSDataBlock* pRes = pExchangeInfo->pResult;
|
SSDataBlock* pRes = pExchangeInfo->pResult;
|
||||||
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
||||||
if (pRsp->numOfRows == 0) {
|
if (pRsp->numOfRows == 0) {
|
||||||
qDebug("%s vgId:%d, taskID:0x%" PRIx64 " index:%d completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
qDebug("%s vgId:%d, taskId:0x%" PRIx64 " index:%d completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
||||||
" try next",
|
", completed:%d try next %d/%"PRIzu,
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i + 1, pDataInfo->totalRows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i, pDataInfo->totalRows,
|
||||||
pExchangeInfo->loadInfo.totalRows);
|
pExchangeInfo->loadInfo.totalRows, completed + 1, i + 1, totalSources);
|
||||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
completed += 1;
|
completed += 1;
|
||||||
taosMemoryFreeClear(pDataInfo->pRsp);
|
taosMemoryFreeClear(pDataInfo->pRsp);
|
||||||
|
@ -2708,10 +2663,11 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRsp->completed == 1) {
|
if (pRsp->completed == 1) {
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, rowsOfSource:%" PRIu64
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " index:%d completed, numOfRows:%d, rowsOfSource:%" PRIu64
|
||||||
", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 " try next %d/%" PRIzu,
|
", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 ", completed:%d try next %d/%" PRIzu,
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pDataInfo->totalRows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i, pRes->info.rows, pDataInfo->totalRows,
|
||||||
pLoadInfo->totalRows, pLoadInfo->totalSize, i + 1, totalSources);
|
pLoadInfo->totalRows, pLoadInfo->totalSize, completed + 1, i + 1, totalSources);
|
||||||
|
completed += 1;
|
||||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
} else {
|
} else {
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64
|
||||||
|
@ -2761,13 +2717,13 @@ static int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t endTs = taosGetTimestampUs();
|
int64_t endTs = taosGetTimestampUs();
|
||||||
qDebug("%s send all fetch requests to %" PRIzu " sources completed, elapsed:%" PRId64, GET_TASKID(pTaskInfo),
|
qDebug("%s send all fetch requests to %" PRIzu " sources completed, elapsed:%.2fms", GET_TASKID(pTaskInfo),
|
||||||
totalSources, endTs - startTs);
|
totalSources, (endTs - startTs)/1000.0);
|
||||||
|
|
||||||
tsem_wait(&pExchangeInfo->ready);
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
pOperator->cost.openCost = taosGetTimestampUs() - startTs;
|
pOperator->cost.openCost = taosGetTimestampUs() - startTs;
|
||||||
|
|
||||||
|
tsem_wait(&pExchangeInfo->ready);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2883,7 +2839,7 @@ static SSDataBlock* doLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo) {
|
static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo, const char* id) {
|
||||||
pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo));
|
pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo));
|
||||||
if (pInfo->pSourceDataInfo == NULL) {
|
if (pInfo->pSourceDataInfo == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -2892,11 +2848,10 @@ static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo) {
|
||||||
for (int32_t i = 0; i < numOfSources; ++i) {
|
for (int32_t i = 0; i < numOfSources; ++i) {
|
||||||
SSourceDataInfo dataInfo = {0};
|
SSourceDataInfo dataInfo = {0};
|
||||||
dataInfo.status = EX_SOURCE_DATA_NOT_READY;
|
dataInfo.status = EX_SOURCE_DATA_NOT_READY;
|
||||||
dataInfo.pEx = pInfo;
|
dataInfo.taskId = id;
|
||||||
dataInfo.index = i;
|
dataInfo.index = i;
|
||||||
|
SSourceDataInfo *pDs = taosArrayPush(pInfo->pSourceDataInfo, &dataInfo);
|
||||||
void* ret = taosArrayPush(pInfo->pSourceDataInfo, &dataInfo);
|
if (pDs == NULL) {
|
||||||
if (ret == NULL) {
|
|
||||||
taosArrayDestroy(pInfo->pSourceDataInfo);
|
taosArrayDestroy(pInfo->pSourceDataInfo);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -2924,7 +2879,9 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo*
|
||||||
taosArrayPush(pInfo->pSources, pNode);
|
taosArrayPush(pInfo->pSources, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return initDataSource(numOfSources, pInfo);
|
pInfo->self = taosAddRef(exchangeObjRefPool, pInfo);
|
||||||
|
|
||||||
|
return initDataSource(numOfSources, pInfo, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo) {
|
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo) {
|
||||||
|
@ -2939,18 +2896,18 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->seqLoadData = false;
|
|
||||||
pInfo->pTransporter = pTransporter;
|
|
||||||
pInfo->pResult = createResDataBlock(pExNode->node.pOutputDataBlockDesc);
|
|
||||||
tsem_init(&pInfo->ready, 0, 0);
|
tsem_init(&pInfo->ready, 0, 0);
|
||||||
|
|
||||||
pOperator->name = "ExchangeOperator";
|
pInfo->seqLoadData = false;
|
||||||
|
pInfo->pTransporter = pTransporter;
|
||||||
|
pInfo->pResult = createResDataBlock(pExNode->node.pOutputDataBlockDesc);
|
||||||
|
pOperator->name = "ExchangeOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_EXCHANGE;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_EXCHANGE;
|
||||||
pOperator->blocking = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfExprs = pInfo->pResult->info.numOfCols;
|
pOperator->numOfExprs = pInfo->pResult->info.numOfCols;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL,
|
pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL,
|
||||||
destroyExchangeOperatorInfo, NULL, NULL, NULL);
|
destroyExchangeOperatorInfo, NULL, NULL, NULL);
|
||||||
|
@ -2958,7 +2915,7 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
if (pInfo != NULL) {
|
if (pInfo != NULL) {
|
||||||
destroyExchangeOperatorInfo(pInfo, LIST_LENGTH(pExNode->pSrcEndPoints));
|
doDestroyExchangeOperatorInfo(pInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pInfo);
|
taosMemoryFreeClear(pInfo);
|
||||||
|
@ -4105,6 +4062,12 @@ static void destroyIndefinitOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
|
|
||||||
void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) {
|
void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
SExchangeInfo* pExInfo = (SExchangeInfo*)param;
|
SExchangeInfo* pExInfo = (SExchangeInfo*)param;
|
||||||
|
taosRemoveRef(exchangeObjRefPool, pExInfo->self);
|
||||||
|
}
|
||||||
|
|
||||||
|
void doDestroyExchangeOperatorInfo(void* param) {
|
||||||
|
SExchangeInfo* pExInfo = (SExchangeInfo*) param;
|
||||||
|
|
||||||
taosArrayDestroy(pExInfo->pSources);
|
taosArrayDestroy(pExInfo->pSources);
|
||||||
taosArrayDestroy(pExInfo->pSourceDataInfo);
|
taosArrayDestroy(pExInfo->pSourceDataInfo);
|
||||||
if (pExInfo->pResult != NULL) {
|
if (pExInfo->pResult != NULL) {
|
||||||
|
@ -4322,6 +4285,8 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
|
||||||
|
|
||||||
pInfo->p = taosMemoryCalloc(numOfCols, POINTER_BYTES);
|
pInfo->p = taosMemoryCalloc(numOfCols, POINTER_BYTES);
|
||||||
if (pInfo->pFillInfo == NULL || pInfo->p == NULL) {
|
if (pInfo->pFillInfo == NULL || pInfo->p == NULL) {
|
||||||
|
taosMemoryFree(pInfo->pFillInfo);
|
||||||
|
taosMemoryFree(pInfo->p);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
} else {
|
} else {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -4556,8 +4521,6 @@ static tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SRead
|
||||||
STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId,
|
STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId,
|
||||||
SNode* pTagCond);
|
SNode* pTagCond);
|
||||||
|
|
||||||
static int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STableListInfo* pListInfo,
|
|
||||||
SNode* pTagCond);
|
|
||||||
static SArray* extractColumnInfo(SNodeList* pNodeList);
|
static SArray* extractColumnInfo(SNodeList* pNodeList);
|
||||||
|
|
||||||
static SArray* createSortInfo(SNodeList* pNodeList);
|
static SArray* createSortInfo(SNodeList* pNodeList);
|
||||||
|
@ -4691,19 +4654,30 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionKeys);
|
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionKeys);
|
||||||
code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); //todo for json
|
code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json
|
||||||
taosArrayDestroy(groupKeys);
|
taosArrayDestroy(groupKeys);
|
||||||
if (code){
|
if (code) {
|
||||||
tsdbCleanupReadHandle(pDataReader);
|
tsdbCleanupReadHandle(pDataReader);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* pOperator =
|
SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
||||||
createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
|
||||||
|
|
||||||
STableScanInfo* pScanInfo = pOperator->info;
|
STableScanInfo* pScanInfo = pOperator->info;
|
||||||
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
||||||
|
return pOperator;
|
||||||
|
} else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) {
|
||||||
|
STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode;
|
||||||
|
|
||||||
|
SArray* dataReaders = taosArrayInit(8, POINTER_BYTES);
|
||||||
|
createMultipleDataReaders(pTableScanNode, pHandle, pTableListInfo, dataReaders, queryId, taskId, pTagCond);
|
||||||
|
extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
||||||
|
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionKeys);
|
||||||
|
generateGroupIdMap(pTableListInfo, pHandle, groupKeys); //todo for json
|
||||||
|
taosArrayDestroy(groupKeys);
|
||||||
|
SOperatorInfo* pOperator =
|
||||||
|
createTableMergeScanOperatorInfo(pTableScanNode, dataReaders, pHandle, pTaskInfo);
|
||||||
|
STableScanInfo* pScanInfo = pOperator->info;
|
||||||
|
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
||||||
return pOperator;
|
return pOperator;
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
||||||
return createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, (SExchangePhysiNode*)pPhyNode, pTaskInfo);
|
return createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, (SExchangePhysiNode*)pPhyNode, pTaskInfo);
|
||||||
|
@ -4837,11 +4811,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
int32_t tsSlotId = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
int32_t tsSlotId = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
||||||
pOptr = createMergeIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, pTaskInfo);
|
pOptr = createMergeIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, pTaskInfo);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL == type) {
|
||||||
qDebug("[******]create Semi");
|
|
||||||
int32_t children = 0;
|
int32_t children = 0;
|
||||||
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL == type) {
|
||||||
qDebug("[******]create Final");
|
|
||||||
int32_t children = 1;
|
int32_t children = 1;
|
||||||
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) {
|
||||||
|
|
|
@ -332,12 +332,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
closeAllResultRows(&pInfo->binfo.resultRowInfo);
|
closeAllResultRows(&pInfo->binfo.resultRowInfo);
|
||||||
// if (!stableQuery) { // finalize include the update of result rows
|
|
||||||
// finalizeQueryResult(pInfo->binfo.pCtx, pOperator->numOfExprs);
|
|
||||||
// } else {
|
|
||||||
// updateNumOfRowsInResultRows(pInfo->binfo.pCtx, pOperator->numOfExprs, &pInfo->binfo.resultRowInfo,
|
|
||||||
// pInfo->binfo.rowCellInfoOffset);
|
|
||||||
// }
|
|
||||||
#if 0
|
#if 0
|
||||||
if(pOperator->fpSet.encodeResultRow){
|
if(pOperator->fpSet.encodeResultRow){
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
@ -378,8 +373,9 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
||||||
return (rows == 0)? NULL:pRes;
|
return (rows == 0)? NULL:pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList,
|
SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SNode* pCondition, SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo) {
|
SSDataBlock* pResultBlock, SArray* pGroupColList, SNode* pCondition,
|
||||||
|
SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo) {
|
||||||
SGroupbyOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SGroupbyOperatorInfo));
|
SGroupbyOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SGroupbyOperatorInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
|
@ -407,7 +403,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
// pOperator->operatorType = OP_Groupby;
|
// pOperator->operatorType = OP_Groupby;
|
||||||
pOperator->pExpr = pExprInfo;
|
pOperator->pExpr = pExprInfo;
|
||||||
pOperator->numOfExprs = numOfCols;
|
pOperator->numOfExprs = numOfCols;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
|
@ -669,8 +665,8 @@ static void destroyPartitionOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
taosMemoryFree(pInfo->columnOffset);
|
taosMemoryFree(pInfo->columnOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList,
|
SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SExecTaskInfo* pTaskInfo) {
|
SSDataBlock* pResultBlock, SArray* pGroupColList, SExecTaskInfo* pTaskInfo) {
|
||||||
SPartitionOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SPartitionOperatorInfo));
|
SPartitionOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SPartitionOperatorInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
|
|
|
@ -630,7 +630,7 @@ static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator) {
|
||||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
|
||||||
int32_t len = tSerializeBlockDistInfo(NULL, 0, &blockDistInfo);
|
int32_t len = tSerializeBlockDistInfo(NULL, 0, &blockDistInfo);
|
||||||
char* p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE);
|
char* p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE);
|
||||||
tSerializeBlockDistInfo(varDataVal(p), len, &blockDistInfo);
|
tSerializeBlockDistInfo(varDataVal(p), len, &blockDistInfo);
|
||||||
varDataSetLen(p, len);
|
varDataSetLen(p, len);
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyBlockDistScanOperatorInfo(void* param, int32_t numOfOutput) {
|
static void destroyBlockDistScanOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
SBlockDistInfo* pDistInfo = (SBlockDistInfo*) param;
|
SBlockDistInfo* pDistInfo = (SBlockDistInfo*)param;
|
||||||
blockDataDestroy(pDistInfo->pResBlock);
|
blockDataDestroy(pDistInfo->pResBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,24 +654,25 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo*
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pHandle = dataReader;
|
pInfo->pHandle = dataReader;
|
||||||
|
|
||||||
pInfo->pResBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
pInfo->pResBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
|
|
||||||
SColumnInfoData infoData = {0};
|
SColumnInfoData infoData = {0};
|
||||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
infoData.info.bytes = 1024;
|
infoData.info.bytes = 1024;
|
||||||
|
|
||||||
taosArrayPush(pInfo->pResBlock->pDataBlock, &infoData);
|
taosArrayPush(pInfo->pResBlock->pDataBlock, &infoData);
|
||||||
|
|
||||||
pOperator->name = "DataBlockInfoScanOperator";
|
pOperator->name = "DataBlockInfoScanOperator";
|
||||||
// pOperator->operatorType = OP_TableBlockInfoScan;
|
// pOperator->operatorType = OP_TableBlockInfoScan;
|
||||||
pOperator->blocking = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doBlockInfoScan, NULL, NULL, destroyBlockDistScanOperatorInfo, NULL, NULL, NULL);
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doBlockInfoScan, NULL, NULL,
|
||||||
|
destroyBlockDistScanOperatorInfo, NULL, NULL, NULL);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
|
@ -890,7 +891,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t current = pInfo->validBlockIndex++;
|
int32_t current = pInfo->validBlockIndex++;
|
||||||
SSDataBlock* pBlock = taosArrayGetP(pInfo->pBlockLists, current);
|
SSDataBlock* pBlock = taosArrayGetP(pInfo->pBlockLists, current);
|
||||||
blockDataUpdateTsWindow(pBlock, 0);
|
blockDataUpdateTsWindow(pBlock, 0);
|
||||||
return pBlock;
|
return pBlock;
|
||||||
|
@ -1058,7 +1059,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
|
||||||
SScanPhysiNode* pScanPhyNode = &pTableScanNode->scan;
|
SScanPhysiNode* pScanPhyNode = &pTableScanNode->scan;
|
||||||
|
|
||||||
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
||||||
SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
||||||
|
|
||||||
STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanDummy->info;
|
STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanDummy->info;
|
||||||
|
|
||||||
|
@ -1512,7 +1513,6 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
|
||||||
pRsp->numOfRows, pInfo->loadInfo.totalRows);
|
pRsp->numOfRows, pInfo->loadInfo.totalRows);
|
||||||
|
|
||||||
if (pRsp->numOfRows == 0) {
|
if (pRsp->numOfRows == 0) {
|
||||||
|
|
||||||
taosMemoryFree(pRsp);
|
taosMemoryFree(pRsp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1849,3 +1849,498 @@ _error:
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct STableMergeScanInfo {
|
||||||
|
SArray* dataReaders; // array of tsdbReaderT*
|
||||||
|
SReadHandle readHandle;
|
||||||
|
|
||||||
|
int32_t bufPageSize;
|
||||||
|
uint32_t sortBufSize; // max buffer size for in-memory sort
|
||||||
|
|
||||||
|
SArray* pSortInfo;
|
||||||
|
SSortHandle* pSortHandle;
|
||||||
|
|
||||||
|
SSDataBlock* pSortInputBlock;
|
||||||
|
int64_t startTs; // sort start time
|
||||||
|
|
||||||
|
bool hasGroupId;
|
||||||
|
uint64_t groupId;
|
||||||
|
STupleHandle* prefetchedTuple;
|
||||||
|
|
||||||
|
SArray* sortSourceParams;
|
||||||
|
|
||||||
|
SFileBlockLoadRecorder readRecorder;
|
||||||
|
int64_t numOfRows;
|
||||||
|
// int32_t prevGroupId; // previous table group id
|
||||||
|
SScanInfo scanInfo;
|
||||||
|
int32_t scanTimes;
|
||||||
|
SNode* pFilterNode; // filter info, which is push down by optimizer
|
||||||
|
SqlFunctionCtx* pCtx; // which belongs to the direct upstream operator operator query context
|
||||||
|
SResultRowInfo* pResultRowInfo;
|
||||||
|
int32_t* rowCellInfoOffset;
|
||||||
|
SExprInfo* pExpr;
|
||||||
|
SSDataBlock* pResBlock;
|
||||||
|
SArray* pColMatchInfo;
|
||||||
|
int32_t numOfOutput;
|
||||||
|
|
||||||
|
SExprInfo* pPseudoExpr;
|
||||||
|
int32_t numOfPseudoExpr;
|
||||||
|
SqlFunctionCtx* pPseudoCtx;
|
||||||
|
// int32_t* rowCellInfoOffset;
|
||||||
|
|
||||||
|
SQueryTableDataCond cond;
|
||||||
|
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
||||||
|
int32_t dataBlockLoadFlag;
|
||||||
|
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time
|
||||||
|
// window to check if current data block needs to be loaded.
|
||||||
|
|
||||||
|
SSampleExecInfo sample; // sample execution info
|
||||||
|
int32_t curTWinIdx;
|
||||||
|
|
||||||
|
} STableMergeScanInfo;
|
||||||
|
|
||||||
|
int32_t createMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle,
|
||||||
|
STableListInfo* pTableListInfo, SArray* arrayReader, uint64_t queryId,
|
||||||
|
uint64_t taskId, SNode* pTagCond) {
|
||||||
|
int32_t code =
|
||||||
|
getTableList(pHandle->meta, pTableScanNode->scan.tableType, pTableScanNode->scan.uid, pTableListInfo, pTagCond);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosArrayGetSize(pTableListInfo->pTableList) == 0) {
|
||||||
|
qDebug("no table qualified for query, TID:0x%" PRIx64 ", QID:0x%" PRIx64, taskId, queryId);
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
SQueryTableDataCond cond = {0};
|
||||||
|
code = initQueryTableDataCond(&cond, pTableScanNode);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
// TODO: free the sublist info and the table list in it
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); ++i) {
|
||||||
|
STableListInfo* subListInfo = taosMemoryCalloc(1, sizeof(subListInfo));
|
||||||
|
subListInfo->pTableList = taosArrayInit(1, sizeof(STableKeyInfo));
|
||||||
|
taosArrayPush(subListInfo->pTableList, taosArrayGet(pTableListInfo->pTableList, i));
|
||||||
|
|
||||||
|
tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, &cond, subListInfo, queryId, taskId);
|
||||||
|
taosArrayPush(arrayReader, &pReader);
|
||||||
|
|
||||||
|
taosArrayDestroy(subListInfo->pTableList);
|
||||||
|
taosMemoryFree(subListInfo);
|
||||||
|
}
|
||||||
|
clearupQueryTableDataCond(&cond);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeScanInfo* pTableScanInfo,
|
||||||
|
int32_t readerIdx, SSDataBlock* pBlock, uint32_t* status) {
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
STableMergeScanInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
|
SFileBlockLoadRecorder* pCost = &pTableScanInfo->readRecorder;
|
||||||
|
|
||||||
|
pCost->totalBlocks += 1;
|
||||||
|
pCost->totalRows += pBlock->info.rows;
|
||||||
|
|
||||||
|
*status = pInfo->dataBlockLoadFlag;
|
||||||
|
if (pTableScanInfo->pFilterNode != NULL ||
|
||||||
|
overlapWithTimeWindow(&pTableScanInfo->interval, &pBlock->info, pTableScanInfo->cond.order)) {
|
||||||
|
(*status) = FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDataBlockInfo* pBlockInfo = &pBlock->info;
|
||||||
|
taosMemoryFreeClear(pBlock->pBlockAgg);
|
||||||
|
|
||||||
|
if (*status == FUNC_DATA_REQUIRED_FILTEROUT) {
|
||||||
|
qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo),
|
||||||
|
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
|
pCost->filterOutBlocks += 1;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
} else if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) {
|
||||||
|
qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo),
|
||||||
|
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
|
pCost->skipBlocks += 1;
|
||||||
|
|
||||||
|
// clear all data in pBlock that are set when handing the previous block
|
||||||
|
for (int32_t i = 0; i < pBlockInfo->numOfCols; ++i) {
|
||||||
|
SColumnInfoData* pcol = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
pcol->pData = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
} else if (*status == FUNC_DATA_REQUIRED_STATIS_LOAD) {
|
||||||
|
pCost->loadBlockStatis += 1;
|
||||||
|
|
||||||
|
bool allColumnsHaveAgg = true;
|
||||||
|
SColumnDataAgg** pColAgg = NULL;
|
||||||
|
tsdbReaderT* reader = taosArrayGetP(pTableScanInfo->dataReaders, readerIdx);
|
||||||
|
tsdbRetrieveDataBlockStatisInfo(reader, &pColAgg, &allColumnsHaveAgg);
|
||||||
|
|
||||||
|
if (allColumnsHaveAgg == true) {
|
||||||
|
int32_t numOfCols = pBlock->info.numOfCols;
|
||||||
|
|
||||||
|
// todo create this buffer during creating operator
|
||||||
|
if (pBlock->pBlockAgg == NULL) {
|
||||||
|
pBlock->pBlockAgg = taosMemoryCalloc(numOfCols, POINTER_BYTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SColMatchInfo* pColMatchInfo = taosArrayGet(pTableScanInfo->pColMatchInfo, i);
|
||||||
|
if (!pColMatchInfo->output) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pBlock->pBlockAgg[pColMatchInfo->targetSlotId] = pColAgg[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
} else { // failed to load the block sma data, data block statistics does not exist, load data block instead
|
||||||
|
*status = FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(*status == FUNC_DATA_REQUIRED_DATA_LOAD);
|
||||||
|
|
||||||
|
// todo filter data block according to the block sma data firstly
|
||||||
|
#if 0
|
||||||
|
if (!doFilterByBlockStatistics(pBlock->pBlockStatis, pTableScanInfo->pCtx, pBlockInfo->rows)) {
|
||||||
|
pCost->filterOutBlocks += 1;
|
||||||
|
qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), pBlockInfo->window.skey,
|
||||||
|
pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
|
(*status) = FUNC_DATA_REQUIRED_FILTEROUT;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pCost->totalCheckedRows += pBlock->info.rows;
|
||||||
|
pCost->loadBlocks += 1;
|
||||||
|
|
||||||
|
tsdbReaderT* reader = taosArrayGetP(pTableScanInfo->dataReaders, readerIdx);
|
||||||
|
SArray* pCols = tsdbRetrieveDataBlock(reader, NULL);
|
||||||
|
if (pCols == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
relocateColumnData(pBlock, pTableScanInfo->pColMatchInfo, pCols);
|
||||||
|
|
||||||
|
// currently only the tbname pseudo column
|
||||||
|
if (pTableScanInfo->numOfPseudoExpr > 0) {
|
||||||
|
addTagPseudoColumnData(&pTableScanInfo->readHandle, pTableScanInfo->pPseudoExpr, pTableScanInfo->numOfPseudoExpr,
|
||||||
|
pBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t st = taosGetTimestampMs();
|
||||||
|
doFilter(pTableScanInfo->pFilterNode, pBlock);
|
||||||
|
|
||||||
|
int64_t et = taosGetTimestampMs();
|
||||||
|
pTableScanInfo->readRecorder.filterTime += (et - st);
|
||||||
|
|
||||||
|
if (pBlock->info.rows == 0) {
|
||||||
|
pCost->filterOutBlocks += 1;
|
||||||
|
qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo),
|
||||||
|
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct STableMergeScanSortSourceParam {
|
||||||
|
SOperatorInfo* pOperator;
|
||||||
|
int32_t readerIdx;
|
||||||
|
SSDataBlock* inputBlock;
|
||||||
|
} STableMergeScanSortSourceParam;
|
||||||
|
|
||||||
|
static SSDataBlock* getTableDataBlock(void* param) {
|
||||||
|
STableMergeScanSortSourceParam* source = param;
|
||||||
|
SOperatorInfo* pOperator = source->pOperator;
|
||||||
|
int32_t readerIdx = source->readerIdx;
|
||||||
|
SSDataBlock* pBlock = source->inputBlock;
|
||||||
|
STableMergeScanInfo* pTableScanInfo = pOperator->info;
|
||||||
|
|
||||||
|
int64_t st = taosGetTimestampUs();
|
||||||
|
|
||||||
|
blockDataCleanup(pBlock);
|
||||||
|
|
||||||
|
tsdbReaderT* reader = taosArrayGetP(pTableScanInfo->dataReaders, readerIdx);
|
||||||
|
while (tsdbNextDataBlock(reader)) {
|
||||||
|
if (isTaskKilled(pOperator->pTaskInfo)) {
|
||||||
|
longjmp(pOperator->pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// process this data block based on the probabilities
|
||||||
|
bool processThisBlock = processBlockWithProbability(&pTableScanInfo->sample);
|
||||||
|
if (!processThisBlock) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbRetrieveDataBlockInfo(reader, &pBlock->info);
|
||||||
|
|
||||||
|
uint32_t status = 0;
|
||||||
|
int32_t code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, readerIdx, pBlock, &status);
|
||||||
|
// int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
longjmp(pOperator->pTaskInfo->env, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
// current block is filter out according to filter condition, continue load the next block
|
||||||
|
if (status == FUNC_DATA_REQUIRED_FILTEROUT || pBlock->info.rows == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t* groupId = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t));
|
||||||
|
if (groupId) {
|
||||||
|
pBlock->info.groupId = *groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
pOperator->resultInfo.totalRows = pTableScanInfo->readRecorder.totalRows;
|
||||||
|
pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
||||||
|
|
||||||
|
return pBlock;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SArray* generateSortByTsInfo(int32_t order) {
|
||||||
|
SArray* pList = taosArrayInit(1, sizeof(SBlockOrderInfo));
|
||||||
|
SBlockOrderInfo bi = {0};
|
||||||
|
bi.order = order;
|
||||||
|
bi.slotId = 0;
|
||||||
|
bi.nullFirst = NULL_ORDER_FIRST;
|
||||||
|
|
||||||
|
taosArrayPush(pList, &bi);
|
||||||
|
|
||||||
|
return pList;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t doOpenTableMergeScanOperator(SOperatorInfo* pOperator) {
|
||||||
|
STableMergeScanInfo* pInfo = pOperator->info;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
if (OPTR_IS_OPENED(pOperator)) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t numOfBufPage = pInfo->sortBufSize / pInfo->bufPageSize;
|
||||||
|
|
||||||
|
pInfo->pSortHandle =
|
||||||
|
tsortCreateSortHandle(pInfo->pSortInfo, pInfo->pColMatchInfo, SORT_MULTISOURCE_MERGE, pInfo->bufPageSize,
|
||||||
|
numOfBufPage, pInfo->pSortInputBlock, pTaskInfo->id.str);
|
||||||
|
|
||||||
|
tsortSetFetchRawDataFp(pInfo->pSortHandle, getTableDataBlock, NULL, NULL);
|
||||||
|
|
||||||
|
size_t numReaders = taosArrayGetSize(pInfo->dataReaders);
|
||||||
|
for (int32_t i = 0; i < numReaders; ++i) {
|
||||||
|
SSortSource* ps = taosMemoryCalloc(1, sizeof(SSortSource));
|
||||||
|
STableMergeScanSortSourceParam* param = taosArrayGet(pInfo->sortSourceParams, i);
|
||||||
|
ps->param = param;
|
||||||
|
tsortAddSource(pInfo->pSortHandle, ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code = tsortOpen(pInfo->pSortHandle);
|
||||||
|
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
longjmp(pTaskInfo->env, terrno);
|
||||||
|
}
|
||||||
|
|
||||||
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
|
|
||||||
|
OPTR_SET_OPENED(pOperator);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, int32_t capacity, SOperatorInfo* pOperator) {
|
||||||
|
STableMergeScanInfo* pInfo = pOperator->info;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
SSDataBlock* p = tsortGetSortedDataBlock(pHandle);
|
||||||
|
if (p == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDataEnsureCapacity(p, capacity);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
STupleHandle* pTupleHandle = NULL;
|
||||||
|
if (pInfo->prefetchedTuple == NULL) {
|
||||||
|
pTupleHandle = tsortNextTuple(pHandle);
|
||||||
|
} else {
|
||||||
|
pTupleHandle = pInfo->prefetchedTuple;
|
||||||
|
pInfo->groupId = tsortGetGroupId(pTupleHandle);
|
||||||
|
pInfo->prefetchedTuple = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTupleHandle == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t tupleGroupId = tsortGetGroupId(pTupleHandle);
|
||||||
|
if (!pInfo->hasGroupId) {
|
||||||
|
pInfo->groupId = tupleGroupId;
|
||||||
|
pInfo->hasGroupId = true;
|
||||||
|
appendOneRowToDataBlock(p, pTupleHandle);
|
||||||
|
} else if (pInfo->groupId == tupleGroupId) {
|
||||||
|
appendOneRowToDataBlock(p, pTupleHandle);
|
||||||
|
} else {
|
||||||
|
pInfo->prefetchedTuple = pTupleHandle;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->info.rows >= capacity) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
qDebug("%s get sorted row blocks, rows:%d", GET_TASKID(pTaskInfo), p->info.rows);
|
||||||
|
return (p->info.rows > 0) ? p : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) {
|
||||||
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
STableMergeScanInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
|
int32_t code = pOperator->fpSet._openFn(pOperator);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
longjmp(pTaskInfo->env, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSDataBlock* pBlock =
|
||||||
|
getSortedTableMergeScanBlockData(pInfo->pSortHandle, pOperator->resultInfo.capacity, pOperator);
|
||||||
|
|
||||||
|
if (pBlock != NULL) {
|
||||||
|
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
||||||
|
} else {
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
|
}
|
||||||
|
return pBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroyTableMergeScanOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
|
STableMergeScanInfo* pTableScanInfo = (STableMergeScanInfo*)param;
|
||||||
|
clearupQueryTableDataCond(&pTableScanInfo->cond);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pTableScanInfo->dataReaders); ++i) {
|
||||||
|
tsdbReaderT* reader = taosArrayGetP(pTableScanInfo->dataReaders, i);
|
||||||
|
tsdbCleanupReadHandle(reader);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(pTableScanInfo->dataReaders);
|
||||||
|
|
||||||
|
if (pTableScanInfo->pColMatchInfo != NULL) {
|
||||||
|
taosArrayDestroy(pTableScanInfo->pColMatchInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pTableScanInfo->sortSourceParams);
|
||||||
|
pTableScanInfo->pResBlock = blockDataDestroy(pTableScanInfo->pResBlock);
|
||||||
|
pTableScanInfo->pSortInputBlock = blockDataDestroy(pTableScanInfo->pSortInputBlock);
|
||||||
|
|
||||||
|
taosArrayDestroy(pTableScanInfo->pSortInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct STableMergeScanExecInfo {
|
||||||
|
SFileBlockLoadRecorder blockRecorder;
|
||||||
|
SSortExecInfo sortExecInfo;
|
||||||
|
} STableMergeScanExecInfo;
|
||||||
|
|
||||||
|
int32_t getTableMergeScanExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) {
|
||||||
|
ASSERT(pOptr != NULL);
|
||||||
|
// TODO: merge these two info into one struct
|
||||||
|
STableMergeScanExecInfo* execInfo = taosMemoryCalloc(1, sizeof(STableMergeScanExecInfo));
|
||||||
|
STableMergeScanInfo* pInfo = pOptr->info;
|
||||||
|
execInfo->blockRecorder = pInfo->readRecorder;
|
||||||
|
execInfo->sortExecInfo = tsortGetSortExecInfo(pInfo->pSortHandle);
|
||||||
|
|
||||||
|
*pOptrExplain = execInfo;
|
||||||
|
*len = sizeof(STableMergeScanExecInfo);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SArray* dataReaders,
|
||||||
|
SReadHandle* readHandle, SExecTaskInfo* pTaskInfo) {
|
||||||
|
STableMergeScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableMergeScanInfo));
|
||||||
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
|
|
||||||
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
|
int32_t numOfCols = 0;
|
||||||
|
SArray* pColList =
|
||||||
|
extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, pTaskInfo, COL_MATCH_FROM_COL_ID);
|
||||||
|
|
||||||
|
int32_t code = initQueryTableDataCond(&pInfo->cond, pTableScanNode);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTableScanNode->scan.pScanPseudoCols != NULL) {
|
||||||
|
pInfo->pPseudoExpr = createExprInfo(pTableScanNode->scan.pScanPseudoCols, NULL, &pInfo->numOfPseudoExpr);
|
||||||
|
pInfo->pPseudoCtx = createSqlFunctionCtx(pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, &pInfo->rowCellInfoOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
pInfo->scanInfo = (SScanInfo){.numOfAsc = pTableScanNode->scanSeq[0], .numOfDesc = pTableScanNode->scanSeq[1]};
|
||||||
|
|
||||||
|
pInfo->readHandle = *readHandle;
|
||||||
|
pInfo->interval = extractIntervalInfo(pTableScanNode);
|
||||||
|
pInfo->sample.sampleRatio = pTableScanNode->ratio;
|
||||||
|
pInfo->sample.seed = taosGetTimestampSec();
|
||||||
|
|
||||||
|
pInfo->dataBlockLoadFlag = pTableScanNode->dataRequired;
|
||||||
|
pInfo->pFilterNode = pTableScanNode->scan.node.pConditions;
|
||||||
|
pInfo->dataReaders = dataReaders;
|
||||||
|
pInfo->scanFlag = MAIN_SCAN;
|
||||||
|
pInfo->pColMatchInfo = pColList;
|
||||||
|
pInfo->curTWinIdx = 0;
|
||||||
|
|
||||||
|
pInfo->pResBlock = createResDataBlock(pDescNode);
|
||||||
|
|
||||||
|
pInfo->sortSourceParams = taosArrayInit(taosArrayGetSize(dataReaders), sizeof(STableMergeScanSortSourceParam));
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(dataReaders); ++i) {
|
||||||
|
STableMergeScanSortSourceParam* param = taosMemoryCalloc(1, sizeof(STableMergeScanSortSourceParam));
|
||||||
|
param->readerIdx = i;
|
||||||
|
param->pOperator = pOperator;
|
||||||
|
param->inputBlock = createOneDataBlock(pInfo->pResBlock, false);
|
||||||
|
taosArrayPush(pInfo->sortSourceParams, param);
|
||||||
|
taosMemoryFree(param);
|
||||||
|
}
|
||||||
|
pInfo->pSortInfo = generateSortByTsInfo(pInfo->cond.order);
|
||||||
|
pInfo->pSortInputBlock = createOneDataBlock(pInfo->pResBlock, false);
|
||||||
|
int32_t rowSize = pInfo->pResBlock->info.rowSize;
|
||||||
|
pInfo->bufPageSize = rowSize < 1024 ? 1024 : rowSize * 2;
|
||||||
|
pInfo->sortBufSize = pInfo->bufPageSize * 16;
|
||||||
|
pInfo->hasGroupId = false;
|
||||||
|
pInfo->prefetchedTuple = NULL;
|
||||||
|
|
||||||
|
pOperator->name = "TableMergeScanOperator";
|
||||||
|
// TODO : change it
|
||||||
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
|
||||||
|
pOperator->blocking = false;
|
||||||
|
pOperator->status = OP_NOT_OPENED;
|
||||||
|
pOperator->info = pInfo;
|
||||||
|
pOperator->numOfExprs = numOfCols;
|
||||||
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
initResultSizeInfo(pOperator, 1024);
|
||||||
|
|
||||||
|
pOperator->fpSet =
|
||||||
|
createOperatorFpSet(doOpenTableMergeScanOperator, doTableMergeScan, NULL, NULL, destroyTableMergeScanOperatorInfo,
|
||||||
|
NULL, NULL, getTableMergeScanExplainExecInfo);
|
||||||
|
pOperator->cost.openCost = 0;
|
||||||
|
return pOperator;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
taosMemoryFree(pInfo);
|
||||||
|
taosMemoryFree(pOperator);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -76,7 +76,9 @@ void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle) {
|
||||||
colDataAppendNULL(pColInfo, pBlock->info.rows);
|
colDataAppendNULL(pColInfo, pBlock->info.rows);
|
||||||
} else {
|
} else {
|
||||||
char* pData = tsortGetValue(pTupleHandle, i);
|
char* pData = tsortGetValue(pTupleHandle, i);
|
||||||
colDataAppend(pColInfo, pBlock->info.rows, pData, false);
|
if (pData != NULL) {
|
||||||
|
colDataAppend(pColInfo, pBlock->info.rows, pData, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +429,7 @@ SOperatorInfo* createMultiwaySortMergeOperatorInfo(SOperatorInfo** downStreams,
|
||||||
pInfo->pInputBlock = pInputBlock;
|
pInfo->pInputBlock = pInputBlock;
|
||||||
pOperator->name = "MultiwaySortMerge";
|
pOperator->name = "MultiwaySortMerge";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE;
|
||||||
pOperator->blocking = true;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
#include "tfill.h"
|
||||||
|
|
||||||
typedef enum SResultTsInterpType {
|
typedef enum SResultTsInterpType {
|
||||||
RESULT_ROW_START_INTERP = 1,
|
RESULT_ROW_START_INTERP = 1,
|
||||||
|
@ -30,18 +31,18 @@ static int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo
|
||||||
static SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SResultRow* pResult);
|
static SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SResultRow* pResult);
|
||||||
static void doCloseWindow(SResultRowInfo* pResultRowInfo, const SIntervalAggOperatorInfo* pInfo, SResultRow* pResult);
|
static void doCloseWindow(SResultRowInfo* pResultRowInfo, const SIntervalAggOperatorInfo* pInfo, SResultRow* pResult);
|
||||||
|
|
||||||
/*
|
///*
|
||||||
* There are two cases to handle:
|
// * There are two cases to handle:
|
||||||
*
|
// *
|
||||||
* 1. Query range is not set yet (queryRangeSet = 0). we need to set the query range info, including
|
// * 1. Query range is not set yet (queryRangeSet = 0). we need to set the query range info, including
|
||||||
* pQueryAttr->lastKey, pQueryAttr->window.skey, and pQueryAttr->eKey.
|
// * pQueryAttr->lastKey, pQueryAttr->window.skey, and pQueryAttr->eKey.
|
||||||
* 2. Query range is set and query is in progress. There may be another result with the same query ranges to be
|
// * 2. Query range is set and query is in progress. There may be another result with the same query ranges to be
|
||||||
* merged during merge stage. In this case, we need the pTableQueryInfo->lastResRows to decide if there
|
// * merged during merge stage. In this case, we need the pTableQueryInfo->lastResRows to decide if there
|
||||||
* is a previous result generated or not.
|
// * is a previous result generated or not.
|
||||||
*/
|
// */
|
||||||
static void setIntervalQueryRange(STableQueryInfo* pTableQueryInfo, TSKEY key, STimeWindow* pQRange) {
|
//static void setIntervalQueryRange(STableQueryInfo* pTableQueryInfo, TSKEY key, STimeWindow* pQRange) {
|
||||||
// do nothing
|
// // do nothing
|
||||||
}
|
//}
|
||||||
|
|
||||||
static TSKEY getStartTsKey(STimeWindow* win, const TSKEY* tsCols) { return tsCols == NULL ? win->skey : tsCols[0]; }
|
static TSKEY getStartTsKey(STimeWindow* win, const TSKEY* tsCols) { return tsCols == NULL ? win->skey : tsCols[0]; }
|
||||||
|
|
||||||
|
@ -327,8 +328,7 @@ void doTimeWindowInterpolation(SIntervalAggOperatorInfo* pInfo, int32_t numOfExp
|
||||||
|
|
||||||
int32_t index = 1;
|
int32_t index = 1;
|
||||||
for (int32_t k = 0; k < numOfExprs; ++k) {
|
for (int32_t k = 0; k < numOfExprs; ++k) {
|
||||||
// todo use flag instead of function name
|
if (!fmIsIntervalInterpoFunc(pCtx[k].functionId)) {
|
||||||
if (strcmp(pCtx[k].pExpr->pExpr->_function.functionName, "twa") != 0) {
|
|
||||||
pCtx[k].start.key = INT64_MIN;
|
pCtx[k].start.key = INT64_MIN;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,7 @@ void doTimeWindowInterpolation(SIntervalAggOperatorInfo* pInfo, int32_t numOfExp
|
||||||
SFunctParam* pParam = &pCtx[k].param[0];
|
SFunctParam* pParam = &pCtx[k].param[0];
|
||||||
SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, pParam->pCol->slotId);
|
SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, pParam->pCol->slotId);
|
||||||
|
|
||||||
ASSERT(pColInfo->info.colId == pParam->pCol->colId && curTs != windowKey);
|
ASSERT(pColInfo->info.type == pParam->pCol->type && curTs != windowKey);
|
||||||
|
|
||||||
double v1 = 0, v2 = 0, v = 0;
|
double v1 = 0, v2 = 0, v = 0;
|
||||||
if (prevRowIndex == -1) {
|
if (prevRowIndex == -1) {
|
||||||
|
@ -958,9 +958,6 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, pInfo->order, scanFlag, true);
|
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, pInfo->order, scanFlag, true);
|
||||||
STableQueryInfo* pTableQueryInfo = pInfo->pCurrent;
|
|
||||||
|
|
||||||
setIntervalQueryRange(pTableQueryInfo, pBlock->info.window.skey, &pTaskInfo->window);
|
|
||||||
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag, NULL);
|
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag, NULL);
|
||||||
|
|
||||||
#if 0 // test for encode/decode result info
|
#if 0 // test for encode/decode result info
|
||||||
|
@ -1414,7 +1411,7 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SExprInfo* pExpr = pCtx[i].pExpr;
|
SExprInfo* pExpr = pCtx[i].pExpr;
|
||||||
|
|
||||||
if (strcmp(pExpr->pExpr->_function.functionName, "twa") == 0) {
|
if (fmIsIntervalInterpoFunc(pCtx[i].functionId)) {
|
||||||
SFunctParam* pParam = &pExpr->base.pParam[0];
|
SFunctParam* pParam = &pExpr->base.pParam[0];
|
||||||
|
|
||||||
SColumn c = *pParam->pCol;
|
SColumn c = *pParam->pCol;
|
||||||
|
@ -1475,11 +1472,9 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
||||||
pInfo->timeWindowInterpo = timeWindowinterpNeeded(pInfo->binfo.pCtx, numOfCols, pInfo);
|
pInfo->timeWindowInterpo = timeWindowinterpNeeded(pInfo->binfo.pCtx, numOfCols, pInfo);
|
||||||
if (pInfo->timeWindowInterpo) {
|
if (pInfo->timeWindowInterpo) {
|
||||||
pInfo->binfo.resultRowInfo.openWindow = tdListNew(sizeof(SResultRowPosition));
|
pInfo->binfo.resultRowInfo.openWindow = tdListNew(sizeof(SResultRowPosition));
|
||||||
}
|
if (pInfo->binfo.resultRowInfo.openWindow == NULL) {
|
||||||
|
goto _error;
|
||||||
// pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo);
|
}
|
||||||
if (code != TSDB_CODE_SUCCESS /* || pInfo->pTableQueryInfo == NULL*/) {
|
|
||||||
goto _error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)1);
|
initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)1);
|
||||||
|
@ -1694,24 +1689,44 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
||||||
return (rows == 0) ? NULL : pBInfo->pRes;
|
return (rows == 0) ? NULL : pBInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doAllIntervalAgg(SOperatorInfo* pOperator) {
|
static void doKeepPrevRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock* pBlock) {
|
||||||
|
int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
||||||
|
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
|
||||||
|
// null data should not be kept since it can not be used to perform interpolation
|
||||||
|
if (!colDataIsNull_s(pColInfoData, i)) {
|
||||||
|
SGroupKeys* pkey = taosArrayGet(pSliceInfo->pPrevRow, i);
|
||||||
|
|
||||||
|
pkey->isNull = false;
|
||||||
|
char* val = colDataGetData(pColInfoData, i);
|
||||||
|
memcpy(pkey->pData, val, pkey->bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STimeSliceOperatorInfo* pSliceInfo = pOperator->info;
|
STimeSliceOperatorInfo* pSliceInfo = pOperator->info;
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
SSDataBlock* pResBlock = pSliceInfo->binfo.pRes;
|
||||||
// doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes);
|
|
||||||
if (pSliceInfo->binfo.pRes->info.rows == 0 || !hashRemainDataInGroupInfo(&pSliceInfo->groupResInfo)) {
|
|
||||||
doSetOperatorCompleted(pOperator);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pSliceInfo->binfo.pRes;
|
// if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
}
|
// // doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes);
|
||||||
|
// if (pResBlock->info.rows == 0 || !hashRemainDataInGroupInfo(&pSliceInfo->groupResInfo)) {
|
||||||
|
// doSetOperatorCompleted(pOperator);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return pResBlock;
|
||||||
|
// }
|
||||||
|
|
||||||
int32_t order = TSDB_ORDER_ASC;
|
int32_t order = TSDB_ORDER_ASC;
|
||||||
|
SInterval* pInterval = &pSliceInfo->interval;
|
||||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||||
|
|
||||||
|
int32_t numOfRows = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -1720,48 +1735,198 @@ static SSDataBlock* doAllIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pSliceInfo->binfo.pCtx, pBlock, order, MAIN_SCAN, true);
|
setInputDataBlock(pOperator, pSliceInfo->binfo.pCtx, pBlock, order, MAIN_SCAN, true);
|
||||||
// hashAllIntervalAgg(pOperator, &pSliceInfo->binfo.resultRowInfo, pBlock, 0);
|
|
||||||
|
SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
for(int32_t i = 0; i < pBlock->info.rows; ++i) {
|
||||||
|
int64_t ts = *(int64_t*) colDataGetData(pTsCol, i);
|
||||||
|
|
||||||
|
if (ts == pSliceInfo->current) {
|
||||||
|
for(int32_t j = 0; j < pOperator->numOfExprs; ++j) {
|
||||||
|
SExprInfo* pExprInfo = &pOperator->pExpr[j];
|
||||||
|
int32_t dstSlot = pExprInfo->base.resSchema.slotId;
|
||||||
|
int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId;
|
||||||
|
|
||||||
|
SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, srcSlot);
|
||||||
|
SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, dstSlot);
|
||||||
|
|
||||||
|
char* v = colDataGetData(pSrc, i);
|
||||||
|
colDataAppend(pDst, numOfRows, v, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
numOfRows += 1;
|
||||||
|
|
||||||
|
pSliceInfo->current += taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
|
||||||
|
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (ts < pSliceInfo->current) {
|
||||||
|
if (i != pBlock->info.window.ekey) {
|
||||||
|
int64_t nextTs = *(int64_t*) colDataGetData(pTsCol, i + 1);
|
||||||
|
if (nextTs > pSliceInfo->current) {
|
||||||
|
// output the result
|
||||||
|
for (int32_t j = 0; j < pOperator->numOfExprs; ++j) {
|
||||||
|
SExprInfo* pExprInfo = &pOperator->pExpr[j];
|
||||||
|
int32_t dstSlot = pExprInfo->base.resSchema.slotId;
|
||||||
|
int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId;
|
||||||
|
|
||||||
|
SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, srcSlot);
|
||||||
|
SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, dstSlot);
|
||||||
|
|
||||||
|
switch (pSliceInfo->fillType) {
|
||||||
|
case TSDB_FILL_NULL:
|
||||||
|
colDataAppendNULL(pDst, numOfRows);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TSDB_FILL_SET_VALUE: {
|
||||||
|
SVariant* pVar = &pSliceInfo->pFillColInfo[i].fillVal;
|
||||||
|
|
||||||
|
if (pDst->info.type == TSDB_DATA_TYPE_FLOAT) {
|
||||||
|
float v = 0;
|
||||||
|
GET_TYPED_DATA(v, float, pVar->nType, &pVar->i);
|
||||||
|
colDataAppend(pDst, numOfRows, (char*)&v, false);
|
||||||
|
} else if (pDst->info.type == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
|
double v = 0;
|
||||||
|
GET_TYPED_DATA(v, double, pVar->nType, &pVar->i);
|
||||||
|
colDataAppend(pDst, numOfRows, (char*)&v, false);
|
||||||
|
} else if (IS_SIGNED_NUMERIC_TYPE(pDst->info.type)) {
|
||||||
|
int64_t v = 0;
|
||||||
|
GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i);
|
||||||
|
colDataAppend(pDst, numOfRows, (char*)&v, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TSDB_FILL_LINEAR:
|
||||||
|
#if 0
|
||||||
|
if (pCtx->start.key == INT64_MIN || pCtx->start.key > pCtx->startTs
|
||||||
|
|| pCtx->end.key == INT64_MIN || pCtx->end.key < pCtx->startTs) {
|
||||||
|
// goto interp_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
double v1 = -1, v2 = -1;
|
||||||
|
GET_TYPED_DATA(v1, double, pCtx->inputType, &pCtx->start.val);
|
||||||
|
GET_TYPED_DATA(v2, double, pCtx->inputType, &pCtx->end.val);
|
||||||
|
|
||||||
|
SPoint point1 = {.key = ts, .val = &v1};
|
||||||
|
SPoint point2 = {.key = nextTs, .val = &v2};
|
||||||
|
SPoint point = {.key = pCtx->startTs, .val = pCtx->pOutput};
|
||||||
|
|
||||||
|
int32_t srcType = pCtx->inputType;
|
||||||
|
if (isNull((char *)&pCtx->start.val, srcType) || isNull((char *)&pCtx->end.val, srcType)) {
|
||||||
|
setNull(pCtx->pOutput, srcType, pCtx->inputBytes);
|
||||||
|
} else {
|
||||||
|
bool exceedMax = false, exceedMin = false;
|
||||||
|
taosGetLinearInterpolationVal(&point, pCtx->outputType, &point1, &point2, TSDB_DATA_TYPE_DOUBLE, &exceedMax, &exceedMin);
|
||||||
|
if (exceedMax || exceedMin) {
|
||||||
|
__compar_fn_t func = getComparFunc((int32_t)pCtx->inputType, 0);
|
||||||
|
if (func(&pCtx->start.val, &pCtx->end.val) <= 0) {
|
||||||
|
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->start.val : &pCtx->end.val);
|
||||||
|
} else {
|
||||||
|
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->end.val : &pCtx->start.val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TSDB_FILL_PREV: {
|
||||||
|
SGroupKeys* pkey = taosArrayGet(pSliceInfo->pPrevRow, srcSlot);
|
||||||
|
colDataAppend(pDst, numOfRows, pkey->pData, false);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case TSDB_FILL_NEXT: {
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case TSDB_FILL_NONE:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
pSliceInfo->current +=
|
||||||
|
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
|
||||||
|
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// ignore current row, and do nothing
|
||||||
|
}
|
||||||
|
} else { // it is the last row of current block
|
||||||
|
doKeepPrevRows(pSliceInfo, pBlock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore the value
|
// restore the value
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
|
||||||
closeAllResultRows(&pSliceInfo->binfo.resultRowInfo);
|
|
||||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||||
// finalizeQueryResult(pSliceInfo->binfo.pCtx, pOperator->numOfExprs);
|
if (pResBlock->info.rows == 0) {
|
||||||
|
|
||||||
// initGroupedResultInfo(&pSliceInfo->groupResInfo, &pSliceInfo->binfo.resultRowInfo);
|
|
||||||
// doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pSliceInfo->pRes);
|
|
||||||
|
|
||||||
if (pSliceInfo->binfo.pRes->info.rows == 0 || !hashRemainDataInGroupInfo(&pSliceInfo->groupResInfo)) {
|
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pSliceInfo->binfo.pRes->info.rows == 0 ? NULL : pSliceInfo->binfo.pRes;
|
return pResBlock->info.rows == 0 ? NULL : pResBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t initTimesliceInfo(STimeSliceOperatorInfo* pInfo, SqlFunctionCtx* pCtx, int32_t numOfCols) {
|
||||||
|
pInfo->pPrevRow = taosArrayInit(4, sizeof(SGroupKeys));
|
||||||
|
pInfo->pCols = taosArrayInit(4, sizeof(SColumn));
|
||||||
|
|
||||||
|
if (pInfo->pPrevRow == NULL || pInfo->pCols == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SExprInfo* pExpr = pCtx[i].pExpr;
|
||||||
|
|
||||||
|
SFunctParam* pParam = &pExpr->base.pParam[0];
|
||||||
|
|
||||||
|
SColumn c = *pParam->pCol;
|
||||||
|
taosArrayPush(pInfo->pCols, &c);
|
||||||
|
|
||||||
|
SGroupKeys key = {0};
|
||||||
|
key.bytes = c.bytes;
|
||||||
|
key.type = c.type;
|
||||||
|
key.isNull = false;
|
||||||
|
key.pData = taosMemoryCalloc(1, c.bytes);
|
||||||
|
taosArrayPush(pInfo->pPrevRow, &key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo) {
|
SSDataBlock* pResultBlock, const SNodeListNode* pValNode, SExecTaskInfo* pTaskInfo) {
|
||||||
STimeSliceOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STimeSliceOperatorInfo));
|
STimeSliceOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STimeSliceOperatorInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pOperator == NULL || pInfo == NULL) {
|
if (pOperator == NULL || pInfo == NULL) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t code = initTimesliceInfo(pInfo, pInfo->binfo.pCtx, numOfCols);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
|
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
|
||||||
|
pInfo->pFillColInfo = createFillColInfo(pExprInfo, numOfCols, pValNode);
|
||||||
|
|
||||||
pOperator->name = "TimeSliceOperator";
|
pInfo->binfo.pRes = pResultBlock;
|
||||||
|
|
||||||
|
pOperator->name = "TimeSliceOperator";
|
||||||
// pOperator->operatorType = OP_AllTimeWindow;
|
// pOperator->operatorType = OP_AllTimeWindow;
|
||||||
pOperator->blocking = true;
|
pOperator->blocking = true;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->pExpr = pExprInfo;
|
pOperator->pExpr = pExprInfo;
|
||||||
pOperator->numOfExprs = numOfCols;
|
pOperator->numOfExprs = numOfCols;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doAllIntervalAgg, NULL, NULL, destroyBasicOperatorInfo,
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTimeslice, NULL, NULL, destroyBasicOperatorInfo,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
|
@ -3344,9 +3509,6 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
getTableScanInfo(pOperator, &iaInfo->order, &scanFlag);
|
getTableScanInfo(pOperator, &iaInfo->order, &scanFlag);
|
||||||
setInputDataBlock(pOperator, iaInfo->binfo.pCtx, pBlock, iaInfo->order, scanFlag, true);
|
setInputDataBlock(pOperator, iaInfo->binfo.pCtx, pBlock, iaInfo->order, scanFlag, true);
|
||||||
STableQueryInfo* pTableQueryInfo = iaInfo->pCurrent;
|
|
||||||
|
|
||||||
setIntervalQueryRange(pTableQueryInfo, pBlock->info.window.skey, &pTaskInfo->window);
|
|
||||||
doMergeIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes);
|
doMergeIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes);
|
||||||
|
|
||||||
if (pRes->info.rows >= pOperator->resultInfo.threshold) {
|
if (pRes->info.rows >= pOperator->resultInfo.threshold) {
|
||||||
|
|
|
@ -738,7 +738,11 @@ bool tsortIsNullVal(STupleHandle* pVHandle, int32_t colIndex) {
|
||||||
|
|
||||||
void* tsortGetValue(STupleHandle* pVHandle, int32_t colIndex) {
|
void* tsortGetValue(STupleHandle* pVHandle, int32_t colIndex) {
|
||||||
SColumnInfoData* pColInfo = TARRAY_GET_ELEM(pVHandle->pBlock->pDataBlock, colIndex);
|
SColumnInfoData* pColInfo = TARRAY_GET_ELEM(pVHandle->pBlock->pDataBlock, colIndex);
|
||||||
return colDataGetData(pColInfo, pVHandle->rowIndex);
|
if (pColInfo->pData == NULL) {
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
return colDataGetData(pColInfo, pVHandle->rowIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t tsortGetGroupId(STupleHandle* pVHandle) {
|
uint64_t tsortGetGroupId(STupleHandle* pVHandle) {
|
||||||
|
|
|
@ -97,6 +97,10 @@ bool getDiffFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
bool diffFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResInfo);
|
bool diffFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResInfo);
|
||||||
int32_t diffFunction(SqlFunctionCtx *pCtx);
|
int32_t diffFunction(SqlFunctionCtx *pCtx);
|
||||||
|
|
||||||
|
bool getDerivativeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
|
bool derivativeFuncSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResInfo);
|
||||||
|
int32_t derivativeFunction(SqlFunctionCtx *pCtx);
|
||||||
|
|
||||||
bool getFirstLastFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getFirstLastFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
int32_t firstFunction(SqlFunctionCtx *pCtx);
|
int32_t firstFunction(SqlFunctionCtx *pCtx);
|
||||||
int32_t firstFunctionMerge(SqlFunctionCtx *pCtx);
|
int32_t firstFunctionMerge(SqlFunctionCtx *pCtx);
|
||||||
|
|
|
@ -42,7 +42,8 @@ extern "C" {
|
||||||
#define FUNC_MGT_SELECT_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(13)
|
#define FUNC_MGT_SELECT_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(13)
|
||||||
#define FUNC_MGT_REPEAT_SCAN_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(14)
|
#define FUNC_MGT_REPEAT_SCAN_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(14)
|
||||||
#define FUNC_MGT_FORBID_FILL_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(15)
|
#define FUNC_MGT_FORBID_FILL_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(15)
|
||||||
#define FUNC_MGT_FORBID_STREAM_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(16)
|
#define FUNC_MGT_INTERVAL_INTERPO_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(16)
|
||||||
|
#define FUNC_MGT_FORBID_STREAM_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(17)
|
||||||
|
|
||||||
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
||||||
|
|
||||||
|
|
|
@ -60,12 +60,6 @@ typedef struct SExprTraverseSupp {
|
||||||
void *pExtInfo;
|
void *pExtInfo;
|
||||||
} SExprTraverseSupp;
|
} SExprTraverseSupp;
|
||||||
|
|
||||||
tExprNode* exprTreeFromTableName(const char* tbnameCond);
|
|
||||||
|
|
||||||
bool exprTreeApplyFilter(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *param);
|
|
||||||
|
|
||||||
void buildFilterSetFromBinary(void **q, const char *buf, int32_t len);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TD_COMMON_UNARY_SCALAR_OPERATOR_H_
|
|
||||||
#define _TD_COMMON_UNARY_SCALAR_OPERATOR_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#include "tscalarfunction.h"
|
|
||||||
|
|
||||||
//typedef void (*_unary_scalar_fn_t)(SScalarParam *pLeft, SScalarParam* pOutput);
|
|
||||||
//_unary_scalar_fn_t getUnaryScalarOperatorFn(int32_t binOperator);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TD_COMMON_BIN_SCALAR_OPERATOR_H_*/
|
|
|
@ -997,6 +997,38 @@ static int32_t translateLastRow(SFunctionNode* pFunc, char* pErrBuf, int32_t len
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateDerivative(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
if (3 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||||
|
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t colType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||||
|
|
||||||
|
// param1
|
||||||
|
SNode* pParamNode1 = nodesListGetNode(pFunc->pParameterList, 1);
|
||||||
|
if (QUERY_NODE_VALUE != nodeType(pParamNode1)) {
|
||||||
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
SValueNode* pValue = (SValueNode*)pParamNode1;
|
||||||
|
pValue->notReserved = true;
|
||||||
|
|
||||||
|
if (!IS_NUMERIC_TYPE(colType)) {
|
||||||
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
SNode* pParamNode2 = nodesListGetNode(pFunc->pParameterList, 2);
|
||||||
|
SValueNode* pValue2 = (SValueNode*)pParamNode2;
|
||||||
|
pValue2->notReserved = true;
|
||||||
|
|
||||||
|
if (pValue2->datum.i != 0 && pValue2->datum.i != 1) {
|
||||||
|
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE};
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
// first(col_list) will be rewritten as first(col)
|
// first(col_list) will be rewritten as first(col)
|
||||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||||
|
@ -1596,6 +1628,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.type = FUNCTION_TYPE_AVG,
|
.type = FUNCTION_TYPE_AVG,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC,
|
||||||
.translateFunc = translateInNumOutDou,
|
.translateFunc = translateInNumOutDou,
|
||||||
|
.dataRequiredFunc = statisDataRequired,
|
||||||
.getEnvFunc = getAvgFuncEnv,
|
.getEnvFunc = getAvgFuncEnv,
|
||||||
.initFunc = avgFunctionSetup,
|
.initFunc = avgFunctionSetup,
|
||||||
.processFunc = avgFunction,
|
.processFunc = avgFunction,
|
||||||
|
@ -1793,7 +1826,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "elapsed",
|
.name = "elapsed",
|
||||||
.type = FUNCTION_TYPE_ELAPSED,
|
.type = FUNCTION_TYPE_ELAPSED,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||||
.dataRequiredFunc = statisDataRequired,
|
.dataRequiredFunc = statisDataRequired,
|
||||||
.translateFunc = translateElapsed,
|
.translateFunc = translateElapsed,
|
||||||
.getEnvFunc = getElapsedFuncEnv,
|
.getEnvFunc = getElapsedFuncEnv,
|
||||||
|
@ -1831,6 +1864,26 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.invertFunc = NULL,
|
.invertFunc = NULL,
|
||||||
.combineFunc = elapsedCombine,
|
.combineFunc = elapsedCombine,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "interp",
|
||||||
|
.type = FUNCTION_TYPE_INTERP,
|
||||||
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC,
|
||||||
|
.translateFunc = translateFirstLast,
|
||||||
|
.getEnvFunc = getSelectivityFuncEnv,
|
||||||
|
.initFunc = functionSetup,
|
||||||
|
.processFunc = NULL,
|
||||||
|
.finalizeFunc = NULL
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "derivative",
|
||||||
|
.type = FUNCTION_TYPE_DERIVATIVE,
|
||||||
|
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC,
|
||||||
|
.translateFunc = translateDerivative,
|
||||||
|
.getEnvFunc = getDerivativeFuncEnv,
|
||||||
|
.initFunc = derivativeFuncSetup,
|
||||||
|
.processFunc = derivativeFunction,
|
||||||
|
.finalizeFunc = functionFinalize
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "last_row",
|
.name = "last_row",
|
||||||
.type = FUNCTION_TYPE_LAST_ROW,
|
.type = FUNCTION_TYPE_LAST_ROW,
|
||||||
|
@ -1914,8 +1967,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "twa",
|
.name = "twa",
|
||||||
.type = FUNCTION_TYPE_TWA,
|
.type = FUNCTION_TYPE_TWA,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||||
.translateFunc = translateInNumOutDou,
|
.translateFunc = translateInNumOutDou,
|
||||||
|
.dataRequiredFunc = statisDataRequired,
|
||||||
.getEnvFunc = getTwaFuncEnv,
|
.getEnvFunc = getTwaFuncEnv,
|
||||||
.initFunc = twaFunctionSetup,
|
.initFunc = twaFunctionSetup,
|
||||||
.processFunc = twaFunction,
|
.processFunc = twaFunction,
|
||||||
|
|
|
@ -990,9 +990,6 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
index = pInput->pColumnDataAgg[0]->maxIndex;
|
index = pInput->pColumnDataAgg[0]->maxIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the index is the original position, not the relative position
|
|
||||||
TSKEY key = (pCtx->ptsList != NULL) ? pCtx->ptsList[index] : TSKEY_INITIAL_VAL;
|
|
||||||
|
|
||||||
if (!pBuf->assign) {
|
if (!pBuf->assign) {
|
||||||
pBuf->v = *(int64_t*)tval;
|
pBuf->v = *(int64_t*)tval;
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
@ -3424,7 +3421,7 @@ bool elapsedFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo
|
||||||
pInfo->min = MAX_TS_KEY;
|
pInfo->min = MAX_TS_KEY;
|
||||||
pInfo->max = 0;
|
pInfo->max = 0;
|
||||||
|
|
||||||
if (pCtx->numOfParams == 2) {
|
if (pCtx->numOfParams > 2) {
|
||||||
pInfo->timeUnit = pCtx->param[1].param.i;
|
pInfo->timeUnit = pCtx->param[1].param.i;
|
||||||
} else {
|
} else {
|
||||||
pInfo->timeUnit = 1;
|
pInfo->timeUnit = 1;
|
||||||
|
@ -3474,8 +3471,8 @@ int32_t elapsedFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
SColumnInfoData* pCol = pInput->pData[0];
|
SColumnInfoData* pCol = pInput->pData[0];
|
||||||
|
|
||||||
int32_t start = pInput->startRowIndex;
|
int32_t start = pInput->startRowIndex;
|
||||||
TSKEY* ptsList = (int64_t*)colDataGetData(pCol, start);
|
TSKEY* ptsList = (int64_t*)colDataGetData(pCol, 0);
|
||||||
if (pCtx->order == TSDB_ORDER_DESC) {
|
if (pCtx->order == TSDB_ORDER_DESC) {
|
||||||
if (pCtx->start.key == INT64_MIN) {
|
if (pCtx->start.key == INT64_MIN) {
|
||||||
pInfo->max =
|
pInfo->max =
|
||||||
|
@ -5166,3 +5163,198 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct SDerivInfo {
|
||||||
|
double prevValue; // previous value
|
||||||
|
TSKEY prevTs; // previous timestamp
|
||||||
|
bool ignoreNegative;// ignore the negative value
|
||||||
|
int64_t tsWindow; // time window for derivative
|
||||||
|
bool valueSet; // the value has been set already
|
||||||
|
} SDerivInfo;
|
||||||
|
|
||||||
|
bool getDerivativeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
||||||
|
pEnv->calcMemSize = sizeof(SDerivInfo);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool derivativeFuncSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResInfo) {
|
||||||
|
if (!functionSetup(pCtx, pResInfo)) {
|
||||||
|
return false; // not initialized since it has been initialized
|
||||||
|
}
|
||||||
|
|
||||||
|
SDerivInfo* pDerivInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
|
pDerivInfo->ignoreNegative = pCtx->param[2].param.i;
|
||||||
|
pDerivInfo->prevTs = -1;
|
||||||
|
pDerivInfo->tsWindow = pCtx->param[1].param.i;
|
||||||
|
pDerivInfo->valueSet = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t derivativeFunction(SqlFunctionCtx *pCtx) {
|
||||||
|
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
SDerivInfo* pDerivInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
|
|
||||||
|
int32_t numOfElems = 0;
|
||||||
|
SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput;
|
||||||
|
SColumnInfoData* pTsOutput = pCtx->pTsOutput;
|
||||||
|
|
||||||
|
int32_t i = pInput->startRowIndex;
|
||||||
|
TSKEY* tsList = (int64_t*)pInput->pPTS->pData;
|
||||||
|
|
||||||
|
double v = 0;
|
||||||
|
|
||||||
|
if (pCtx->order == TSDB_ORDER_ASC) {
|
||||||
|
for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) {
|
||||||
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* d = (char*)pInputCol->pData + pInputCol->info.bytes * i;
|
||||||
|
GET_TYPED_DATA(v, double, pInputCol->info.type, d);
|
||||||
|
|
||||||
|
int32_t pos = pCtx->offset + numOfElems;
|
||||||
|
if (!pDerivInfo->valueSet) { // initial value is not set yet
|
||||||
|
pDerivInfo->valueSet = true;
|
||||||
|
} else {
|
||||||
|
double r = ((v - pDerivInfo->prevValue) * pDerivInfo->tsWindow) / (tsList[i] - pDerivInfo->prevTs);
|
||||||
|
if (pDerivInfo->ignoreNegative && r < 0) {
|
||||||
|
} else {
|
||||||
|
colDataAppend(pOutput, pos, (const char*)&r, false);
|
||||||
|
if (pTsOutput != NULL) {
|
||||||
|
colDataAppendInt64(pTsOutput, pos, &tsList[i]);
|
||||||
|
}
|
||||||
|
numOfElems++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pDerivInfo->prevValue = v;
|
||||||
|
pDerivInfo->prevTs = tsList[i];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) {
|
||||||
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* d = (char*)pInputCol->pData + pInputCol->info.bytes * i;
|
||||||
|
GET_TYPED_DATA(v, double, pInputCol->info.type, d);
|
||||||
|
|
||||||
|
int32_t pos = pCtx->offset + numOfElems;
|
||||||
|
if (!pDerivInfo->valueSet) { // initial value is not set yet
|
||||||
|
pDerivInfo->valueSet = true;
|
||||||
|
} else {
|
||||||
|
double r = ((pDerivInfo->prevValue - v) * pDerivInfo->tsWindow) / (pDerivInfo->prevTs - tsList[i]);
|
||||||
|
if (pDerivInfo->ignoreNegative && r < 0) {
|
||||||
|
} else {
|
||||||
|
colDataAppend(pOutput, pos, (const char*)&r, false);
|
||||||
|
if (pTsOutput != NULL) {
|
||||||
|
colDataAppendInt64(pTsOutput, pos, &pDerivInfo->prevTs);
|
||||||
|
}
|
||||||
|
numOfElems++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pDerivInfo->prevValue = v;
|
||||||
|
pDerivInfo->prevTs = tsList[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return numOfElems;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t interpFunction(SqlFunctionCtx *pCtx) {
|
||||||
|
#if 0
|
||||||
|
int32_t fillType = (int32_t) pCtx->param[2].i64;
|
||||||
|
//bool ascQuery = (pCtx->order == TSDB_ORDER_ASC);
|
||||||
|
|
||||||
|
if (pCtx->start.key == pCtx->startTs) {
|
||||||
|
assert(pCtx->start.key != INT64_MIN);
|
||||||
|
|
||||||
|
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, &pCtx->start.val);
|
||||||
|
|
||||||
|
goto interp_success_exit;
|
||||||
|
} else if (pCtx->end.key == pCtx->startTs && pCtx->end.key != INT64_MIN && fillType == TSDB_FILL_NEXT) {
|
||||||
|
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, &pCtx->end.val);
|
||||||
|
|
||||||
|
goto interp_success_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (fillType) {
|
||||||
|
case TSDB_FILL_NULL:
|
||||||
|
setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TSDB_FILL_SET_VALUE:
|
||||||
|
tVariantDump(&pCtx->param[1], pCtx->pOutput, pCtx->inputType, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TSDB_FILL_LINEAR:
|
||||||
|
if (pCtx->start.key == INT64_MIN || pCtx->start.key > pCtx->startTs
|
||||||
|
|| pCtx->end.key == INT64_MIN || pCtx->end.key < pCtx->startTs) {
|
||||||
|
goto interp_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
double v1 = -1, v2 = -1;
|
||||||
|
GET_TYPED_DATA(v1, double, pCtx->inputType, &pCtx->start.val);
|
||||||
|
GET_TYPED_DATA(v2, double, pCtx->inputType, &pCtx->end.val);
|
||||||
|
|
||||||
|
SPoint point1 = {.key = pCtx->start.key, .val = &v1};
|
||||||
|
SPoint point2 = {.key = pCtx->end.key, .val = &v2};
|
||||||
|
SPoint point = {.key = pCtx->startTs, .val = pCtx->pOutput};
|
||||||
|
|
||||||
|
int32_t srcType = pCtx->inputType;
|
||||||
|
if (isNull((char *)&pCtx->start.val, srcType) || isNull((char *)&pCtx->end.val, srcType)) {
|
||||||
|
setNull(pCtx->pOutput, srcType, pCtx->inputBytes);
|
||||||
|
} else {
|
||||||
|
bool exceedMax = false, exceedMin = false;
|
||||||
|
taosGetLinearInterpolationVal(&point, pCtx->outputType, &point1, &point2, TSDB_DATA_TYPE_DOUBLE, &exceedMax, &exceedMin);
|
||||||
|
if (exceedMax || exceedMin) {
|
||||||
|
__compar_fn_t func = getComparFunc((int32_t)pCtx->inputType, 0);
|
||||||
|
if (func(&pCtx->start.val, &pCtx->end.val) <= 0) {
|
||||||
|
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->start.val : &pCtx->end.val);
|
||||||
|
} else {
|
||||||
|
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->end.val : &pCtx->start.val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TSDB_FILL_PREV:
|
||||||
|
if (pCtx->start.key == INT64_MIN || pCtx->start.key > pCtx->startTs) {
|
||||||
|
goto interp_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, &pCtx->start.val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TSDB_FILL_NEXT:
|
||||||
|
if (pCtx->end.key == INT64_MIN || pCtx->end.key < pCtx->startTs) {
|
||||||
|
goto interp_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, &pCtx->end.val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TSDB_FILL_NONE:
|
||||||
|
// do nothing
|
||||||
|
default:
|
||||||
|
goto interp_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interp_success_exit:
|
||||||
|
*(TSKEY*)pCtx->ptsOutputBuf = pCtx->startTs;
|
||||||
|
INC_INIT_VAL(pCtx, 1);
|
||||||
|
|
||||||
|
interp_exit:
|
||||||
|
pCtx->start.key = INT64_MIN;
|
||||||
|
pCtx->end.key = INT64_MIN;
|
||||||
|
pCtx->endTs = pCtx->startTs;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
|
@ -161,6 +161,8 @@ bool fmIsUserDefinedFunc(int32_t funcId) { return funcId > FUNC_UDF_ID_START; }
|
||||||
|
|
||||||
bool fmIsForbidFillFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_FORBID_FILL_FUNC); }
|
bool fmIsForbidFillFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_FORBID_FILL_FUNC); }
|
||||||
|
|
||||||
|
bool fmIsIntervalInterpoFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_INTERVAL_INTERPO_FUNC); }
|
||||||
|
|
||||||
bool fmIsForbidStreamFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_FORBID_STREAM_FUNC); }
|
bool fmIsForbidStreamFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_FORBID_STREAM_FUNC); }
|
||||||
|
|
||||||
void fmFuncMgtDestroy() {
|
void fmFuncMgtDestroy() {
|
||||||
|
|
|
@ -161,13 +161,13 @@ typedef struct SRateInfo {
|
||||||
bool isIRate; // true for IRate functions, false for Rate functions
|
bool isIRate; // true for IRate functions, false for Rate functions
|
||||||
} SRateInfo;
|
} SRateInfo;
|
||||||
|
|
||||||
typedef struct SDerivInfo {
|
//typedef struct SDerivInfo {
|
||||||
double prevValue; // previous value
|
// double prevValue; // previous value
|
||||||
TSKEY prevTs; // previous timestamp
|
// TSKEY prevTs; // previous timestamp
|
||||||
bool ignoreNegative;// ignore the negative value
|
// bool ignoreNegative;// ignore the negative value
|
||||||
int64_t tsWindow; // time window for derivative
|
// int64_t tsWindow; // time window for derivative
|
||||||
bool valueSet; // the value has been set already
|
// bool valueSet; // the value has been set already
|
||||||
} SDerivInfo;
|
//} SDerivInfo;
|
||||||
|
|
||||||
typedef struct SResPair {
|
typedef struct SResPair {
|
||||||
TSKEY key;
|
TSKEY key;
|
||||||
|
|
|
@ -48,34 +48,6 @@ static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) {
|
||||||
*pExpr = NULL;
|
*pExpr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exprTreeApplyFilter(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *param) {
|
|
||||||
#if 0
|
|
||||||
//non-leaf nodes, recursively traverse the expression tree in the post-root order
|
|
||||||
if (pLeft->nodeType == TEXPR_BINARYEXPR_NODE && pRight->nodeType == TEXPR_BINARYEXPR_NODE) {
|
|
||||||
if (pExpr->_node.optr == LOGIC_COND_TYPE_OR) { // or
|
|
||||||
if (exprTreeApplyFilter(pLeft, pItem, param)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// left child does not satisfy the query condition, try right child
|
|
||||||
return exprTreeApplyFilter(pRight, pItem, param);
|
|
||||||
} else { // and
|
|
||||||
if (!exprTreeApplyFilter(pLeft, pItem, param)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return exprTreeApplyFilter(pRight, pItem, param);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle the leaf node
|
|
||||||
param->setupInfoFn(pExpr, param->pExtInfo);
|
|
||||||
return param->nodeFilterFn(pItem, pExpr->_node.info);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: these three functions should be made global
|
// TODO: these three functions should be made global
|
||||||
static void* exception_calloc(size_t nmemb, size_t size) {
|
static void* exception_calloc(size_t nmemb, size_t size) {
|
||||||
void* p = taosMemoryCalloc(nmemb, size);
|
void* p = taosMemoryCalloc(nmemb, size);
|
||||||
|
@ -101,214 +73,3 @@ static UNUSED_FUNC char* exception_strdup(const char* str) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildFilterSetFromBinary(void **q, const char *buf, int32_t len) {
|
|
||||||
SBufferReader br = tbufInitReader(buf, len, false);
|
|
||||||
uint32_t type = tbufReadUint32(&br);
|
|
||||||
SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(type), true, false);
|
|
||||||
|
|
||||||
// taosHashSetEqualFp(pObj, taosGetDefaultEqualFunction(type));
|
|
||||||
|
|
||||||
int dummy = -1;
|
|
||||||
int32_t sz = tbufReadInt32(&br);
|
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
|
||||||
if (type == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(type)) {
|
|
||||||
int64_t val = tbufReadInt64(&br);
|
|
||||||
taosHashPut(pObj, (char *)&val, sizeof(val), &dummy, sizeof(dummy));
|
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
|
||||||
uint64_t val = tbufReadUint64(&br);
|
|
||||||
taosHashPut(pObj, (char *)&val, sizeof(val), &dummy, sizeof(dummy));
|
|
||||||
}
|
|
||||||
else if (type == TSDB_DATA_TYPE_TIMESTAMP) {
|
|
||||||
int64_t val = tbufReadInt64(&br);
|
|
||||||
taosHashPut(pObj, (char *)&val, sizeof(val), &dummy, sizeof(dummy));
|
|
||||||
} else if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_FLOAT) {
|
|
||||||
double val = tbufReadDouble(&br);
|
|
||||||
taosHashPut(pObj, (char *)&val, sizeof(val), &dummy, sizeof(dummy));
|
|
||||||
} else if (type == TSDB_DATA_TYPE_BINARY) {
|
|
||||||
size_t t = 0;
|
|
||||||
const char *val = tbufReadBinary(&br, &t);
|
|
||||||
taosHashPut(pObj, (char *)val, t, &dummy, sizeof(dummy));
|
|
||||||
} else if (type == TSDB_DATA_TYPE_NCHAR) {
|
|
||||||
size_t t = 0;
|
|
||||||
const char *val = tbufReadBinary(&br, &t);
|
|
||||||
taosHashPut(pObj, (char *)val, t, &dummy, sizeof(dummy));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*q = (void *)pObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t tType) {
|
|
||||||
SBufferReader br = tbufInitReader(buf, len, false);
|
|
||||||
uint32_t sType = tbufReadUint32(&br);
|
|
||||||
SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(tType), true, false);
|
|
||||||
|
|
||||||
// taosHashSetEqualFp(pObj, taosGetDefaultEqualFunction(tType));
|
|
||||||
|
|
||||||
int dummy = -1;
|
|
||||||
SVariant tmpVar = {0};
|
|
||||||
size_t t = 0;
|
|
||||||
int32_t sz = tbufReadInt32(&br);
|
|
||||||
void *pvar = NULL;
|
|
||||||
int64_t val = 0;
|
|
||||||
int32_t bufLen = 0;
|
|
||||||
if (IS_NUMERIC_TYPE(sType)) {
|
|
||||||
bufLen = 60; // The maximum length of string that a number is converted to.
|
|
||||||
} else {
|
|
||||||
bufLen = 128;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *tmp = taosMemoryCalloc(1, bufLen * TSDB_NCHAR_SIZE);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
|
||||||
switch (sType) {
|
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
|
||||||
case TSDB_DATA_TYPE_UTINYINT:
|
|
||||||
case TSDB_DATA_TYPE_TINYINT: {
|
|
||||||
*(uint8_t *)&val = (uint8_t)tbufReadInt64(&br);
|
|
||||||
t = sizeof(val);
|
|
||||||
pvar = &val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_USMALLINT:
|
|
||||||
case TSDB_DATA_TYPE_SMALLINT: {
|
|
||||||
*(uint16_t *)&val = (uint16_t)tbufReadInt64(&br);
|
|
||||||
t = sizeof(val);
|
|
||||||
pvar = &val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_UINT:
|
|
||||||
case TSDB_DATA_TYPE_INT: {
|
|
||||||
*(uint32_t *)&val = (uint32_t)tbufReadInt64(&br);
|
|
||||||
t = sizeof(val);
|
|
||||||
pvar = &val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
|
||||||
case TSDB_DATA_TYPE_UBIGINT:
|
|
||||||
case TSDB_DATA_TYPE_BIGINT: {
|
|
||||||
*(uint64_t *)&val = (uint64_t)tbufReadInt64(&br);
|
|
||||||
t = sizeof(val);
|
|
||||||
pvar = &val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
|
||||||
*(double *)&val = tbufReadDouble(&br);
|
|
||||||
t = sizeof(val);
|
|
||||||
pvar = &val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
|
||||||
*(float *)&val = (float)tbufReadDouble(&br);
|
|
||||||
t = sizeof(val);
|
|
||||||
pvar = &val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_BINARY: {
|
|
||||||
pvar = (char *)tbufReadBinary(&br, &t);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
|
||||||
pvar = (char *)tbufReadBinary(&br, &t);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
taosHashCleanup(pObj);
|
|
||||||
*q = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosVariantCreateFromBinary(&tmpVar, (char *)pvar, t, sType);
|
|
||||||
|
|
||||||
if (bufLen < t) {
|
|
||||||
tmp = taosMemoryRealloc(tmp, t * TSDB_NCHAR_SIZE);
|
|
||||||
bufLen = (int32_t)t;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (tType) {
|
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
|
||||||
case TSDB_DATA_TYPE_UTINYINT:
|
|
||||||
case TSDB_DATA_TYPE_TINYINT: {
|
|
||||||
if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) {
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
pvar = &val;
|
|
||||||
t = sizeof(val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_USMALLINT:
|
|
||||||
case TSDB_DATA_TYPE_SMALLINT: {
|
|
||||||
if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) {
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
pvar = &val;
|
|
||||||
t = sizeof(val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_UINT:
|
|
||||||
case TSDB_DATA_TYPE_INT: {
|
|
||||||
if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) {
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
pvar = &val;
|
|
||||||
t = sizeof(val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
|
||||||
case TSDB_DATA_TYPE_UBIGINT:
|
|
||||||
case TSDB_DATA_TYPE_BIGINT: {
|
|
||||||
if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) {
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
pvar = &val;
|
|
||||||
t = sizeof(val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
|
||||||
if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) {
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
pvar = &val;
|
|
||||||
t = sizeof(val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
|
||||||
if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) {
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
pvar = &val;
|
|
||||||
t = sizeof(val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_BINARY: {
|
|
||||||
if (taosVariantDump(&tmpVar, tmp, tType, true)) {
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
t = varDataLen(tmp);
|
|
||||||
pvar = varDataVal(tmp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
|
||||||
if (taosVariantDump(&tmpVar, tmp, tType, true)) {
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
t = varDataLen(tmp);
|
|
||||||
pvar = varDataVal(tmp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
goto err_ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosHashPut(pObj, (char *)pvar, t, &dummy, sizeof(dummy));
|
|
||||||
taosVariantDestroy(&tmpVar);
|
|
||||||
memset(&tmpVar, 0, sizeof(tmpVar));
|
|
||||||
}
|
|
||||||
|
|
||||||
*q = (void *)pObj;
|
|
||||||
pObj = NULL;
|
|
||||||
|
|
||||||
err_ret:
|
|
||||||
taosVariantDestroy(&tmpVar);
|
|
||||||
taosHashCleanup(pObj);
|
|
||||||
taosMemoryFreeClear(tmp);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1117,6 +1117,7 @@ static const char* jkLogicSubplanVgroupsSize = "VgroupsSize";
|
||||||
static const char* jkLogicSubplanVgroups = "Vgroups";
|
static const char* jkLogicSubplanVgroups = "Vgroups";
|
||||||
static const char* jkLogicSubplanLevel = "Level";
|
static const char* jkLogicSubplanLevel = "Level";
|
||||||
static const char* jkLogicSubplanSplitFlag = "SplitFlag";
|
static const char* jkLogicSubplanSplitFlag = "SplitFlag";
|
||||||
|
static const char* jkLogicSubplanNumOfComputeNodes = "NumOfComputeNodes";
|
||||||
|
|
||||||
static int32_t logicSubplanToJson(const void* pObj, SJson* pJson) {
|
static int32_t logicSubplanToJson(const void* pObj, SJson* pJson) {
|
||||||
const SLogicSubplan* pNode = (const SLogicSubplan*)pObj;
|
const SLogicSubplan* pNode = (const SLogicSubplan*)pObj;
|
||||||
|
@ -1143,6 +1144,9 @@ static int32_t logicSubplanToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkLogicSubplanSplitFlag, pNode->splitFlag);
|
code = tjsonAddIntegerToObject(pJson, jkLogicSubplanSplitFlag, pNode->splitFlag);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkLogicSubplanNumOfComputeNodes, pNode->numOfComputeNodes);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1159,7 +1163,6 @@ static int32_t jsonToLogicSubplan(const SJson* pJson, void* pObj) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkLogicSubplanType, pNode->subplanType, code);
|
tjsonGetNumberValue(pJson, jkLogicSubplanType, pNode->subplanType, code);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
int32_t objSize = 0;
|
int32_t objSize = 0;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -1174,6 +1177,9 @@ static int32_t jsonToLogicSubplan(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetIntValue(pJson, jkLogicSubplanSplitFlag, &pNode->splitFlag);
|
code = tjsonGetIntValue(pJson, jkLogicSubplanSplitFlag, &pNode->splitFlag);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetIntValue(pJson, jkLogicSubplanNumOfComputeNodes, &pNode->numOfComputeNodes);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3257,6 +3257,8 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt
|
||||||
strcpy(createReq.user, pStmt->useName);
|
strcpy(createReq.user, pStmt->useName);
|
||||||
createReq.createType = 0;
|
createReq.createType = 0;
|
||||||
createReq.superUser = 0;
|
createReq.superUser = 0;
|
||||||
|
createReq.sysInfo = 1;
|
||||||
|
createReq.enable = 1;
|
||||||
strcpy(createReq.pass, pStmt->password);
|
strcpy(createReq.pass, pStmt->password);
|
||||||
|
|
||||||
return buildCmdMsg(pCxt, TDMT_MND_CREATE_USER, (FSerializeFunc)tSerializeSCreateUserReq, &createReq);
|
return buildCmdMsg(pCxt, TDMT_MND_CREATE_USER, (FSerializeFunc)tSerializeSCreateUserReq, &createReq);
|
||||||
|
|
|
@ -498,7 +498,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCxt->pPlanCxt->rSmaQuery) {
|
if (pCxt->pPlanCxt->rSmaQuery) {
|
||||||
pWindow->filesFactor = pCxt->pPlanCxt->filesFactor;
|
/*pWindow->filesFactor = pCxt->pPlanCxt->filesFactor;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
|
|
@ -470,8 +470,8 @@ static ENodeType getScanOperatorType(EScanType scanType) {
|
||||||
case SCAN_TYPE_STREAM:
|
case SCAN_TYPE_STREAM:
|
||||||
return QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
return QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
||||||
case SCAN_TYPE_TABLE_MERGE:
|
case SCAN_TYPE_TABLE_MERGE:
|
||||||
return QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
|
// return QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
|
||||||
// return QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN;
|
return QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,45 @@ static int32_t scaleOutForScan(SScaleOutContext* pCxt, SLogicSubplan* pSubplan,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t pushHierarchicalPlan(SNodeList* pParentsGroup, SNodeList* pCurrentGroup) {
|
static int32_t scaleOutForCompute(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
for (int32_t i = 0; i < pSubplan->numOfComputeNodes; ++i) {
|
||||||
|
SLogicSubplan* pNewSubplan = singleCloneSubLogicPlan(pCxt, pSubplan, level);
|
||||||
|
if (NULL == pNewSubplan) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
code = nodesListStrictAppend(pGroup, (SNode*)pNewSubplan);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t pushHierarchicalPlanForCompute(SNodeList* pParentsGroup, SNodeList* pCurrentGroup) {
|
||||||
|
SNode* pChild = NULL;
|
||||||
|
SNode* pParent = NULL;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
FORBOTH(pChild, pCurrentGroup, pParent, pParentsGroup) {
|
||||||
|
code = nodesListMakeAppend(&(((SLogicSubplan*)pParent)->pChildren), pChild);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodesListMakeAppend(&(((SLogicSubplan*)pChild)->pParents), pParent);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isComputeGroup(SNodeList* pGroup) {
|
||||||
|
if (0 == LIST_LENGTH(pGroup)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return SUBPLAN_TYPE_COMPUTE == ((SLogicSubplan*)nodesListGetNode(pGroup, 0))->subplanType;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t pushHierarchicalPlanForNormal(SNodeList* pParentsGroup, SNodeList* pCurrentGroup) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
bool topLevel = (0 == LIST_LENGTH(pParentsGroup));
|
bool topLevel = (0 == LIST_LENGTH(pParentsGroup));
|
||||||
SNode* pChild = NULL;
|
SNode* pChild = NULL;
|
||||||
|
@ -138,6 +176,13 @@ static int32_t pushHierarchicalPlan(SNodeList* pParentsGroup, SNodeList* pCurren
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t pushHierarchicalPlan(SNodeList* pParentsGroup, SNodeList* pCurrentGroup) {
|
||||||
|
if (isComputeGroup(pParentsGroup)) {
|
||||||
|
return pushHierarchicalPlanForCompute(pParentsGroup, pCurrentGroup);
|
||||||
|
}
|
||||||
|
return pushHierarchicalPlanForNormal(pParentsGroup, pCurrentGroup);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pParentsGroup) {
|
static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pParentsGroup) {
|
||||||
SNodeList* pCurrentGroup = nodesMakeList();
|
SNodeList* pCurrentGroup = nodesMakeList();
|
||||||
if (NULL == pCurrentGroup) {
|
if (NULL == pCurrentGroup) {
|
||||||
|
@ -155,6 +200,9 @@ static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32
|
||||||
case SUBPLAN_TYPE_MODIFY:
|
case SUBPLAN_TYPE_MODIFY:
|
||||||
code = scaleOutForModify(pCxt, pSubplan, level, pCurrentGroup);
|
code = scaleOutForModify(pCxt, pSubplan, level, pCurrentGroup);
|
||||||
break;
|
break;
|
||||||
|
case SUBPLAN_TYPE_COMPUTE:
|
||||||
|
code = scaleOutForCompute(pCxt, pSubplan, level, pCurrentGroup);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -994,8 +994,20 @@ static int32_t qnodeSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
||||||
}
|
}
|
||||||
int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pSplitNode, info.pSubplan->subplanType);
|
int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pSplitNode, info.pSubplan->subplanType);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)splCreateScanSubplan(pCxt, info.pSplitNode, 0));
|
SLogicSubplan* pScanSubplan = splCreateScanSubplan(pCxt, info.pSplitNode, 0);
|
||||||
|
if (NULL != pScanSubplan) {
|
||||||
|
if (NULL != info.pSubplan->pVgroupList) {
|
||||||
|
info.pSubplan->numOfComputeNodes = info.pSubplan->pVgroupList->numOfVgroups;
|
||||||
|
TSWAP(pScanSubplan->pVgroupList, info.pSubplan->pVgroupList);
|
||||||
|
} else {
|
||||||
|
info.pSubplan->numOfComputeNodes = 1;
|
||||||
|
}
|
||||||
|
code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)pScanSubplan);
|
||||||
|
} else {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
info.pSubplan->subplanType = SUBPLAN_TYPE_COMPUTE;
|
||||||
++(pCxt->groupId);
|
++(pCxt->groupId);
|
||||||
pCxt->split = true;
|
pCxt->split = true;
|
||||||
return code;
|
return code;
|
||||||
|
@ -1007,8 +1019,7 @@ static const SSplitRule splitRuleSet[] = {
|
||||||
{.pName = "SingleTableJoinSplit", .splitFunc = singleTableJoinSplit},
|
{.pName = "SingleTableJoinSplit", .splitFunc = singleTableJoinSplit},
|
||||||
{.pName = "UnionAllSplit", .splitFunc = unionAllSplit},
|
{.pName = "UnionAllSplit", .splitFunc = unionAllSplit},
|
||||||
{.pName = "UnionDistinctSplit", .splitFunc = unionDistinctSplit},
|
{.pName = "UnionDistinctSplit", .splitFunc = unionDistinctSplit},
|
||||||
{.pName = "SmaIndexSplit", .splitFunc = smaIndexSplit},
|
{.pName = "SmaIndexSplit", .splitFunc = smaIndexSplit}
|
||||||
{.pName = "QnodeSplit", .splitFunc = qnodeSplit}
|
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -1039,7 +1050,7 @@ static int32_t applySplitRule(SPlanContext* pCxt, SLogicSubplan* pSubplan) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (split);
|
} while (split);
|
||||||
return TSDB_CODE_SUCCESS;
|
return qnodeSplit(&cxt, pSubplan);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setVgroupsInfo(SLogicNode* pNode, SLogicSubplan* pSubplan) {
|
static void setVgroupsInfo(SLogicNode* pNode, SLogicSubplan* pSubplan) {
|
||||||
|
|
|
@ -150,12 +150,14 @@ int32_t syncSetStandby(int64_t rid) {
|
||||||
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
sError("failed to set standby since accquire ref error, rid:%" PRId64, rid);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
||||||
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
||||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
sError("failed to set standby since it is leader, rid:%" PRId64, rid);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1808,37 +1810,39 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
|
||||||
|
|
||||||
static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
||||||
SSyncNode* pSyncNode = (SSyncNode*)param;
|
SSyncNode* pSyncNode = (SSyncNode*)param;
|
||||||
if (atomic_load_64(&pSyncNode->heartbeatTimerLogicClockUser) <=
|
if (pSyncNode->replicaNum > 1) {
|
||||||
atomic_load_64(&pSyncNode->heartbeatTimerLogicClock)) {
|
if (atomic_load_64(&pSyncNode->heartbeatTimerLogicClockUser) <=
|
||||||
SyncTimeout* pSyncMsg =
|
atomic_load_64(&pSyncNode->heartbeatTimerLogicClock)) {
|
||||||
syncTimeoutBuild2(SYNC_TIMEOUT_HEARTBEAT, atomic_load_64(&pSyncNode->heartbeatTimerLogicClock),
|
SyncTimeout* pSyncMsg =
|
||||||
pSyncNode->heartbeatTimerMS, pSyncNode->vgId, pSyncNode);
|
syncTimeoutBuild2(SYNC_TIMEOUT_HEARTBEAT, atomic_load_64(&pSyncNode->heartbeatTimerLogicClock),
|
||||||
SRpcMsg rpcMsg;
|
pSyncNode->heartbeatTimerMS, pSyncNode->vgId, pSyncNode);
|
||||||
syncTimeout2RpcMsg(pSyncMsg, &rpcMsg);
|
SRpcMsg rpcMsg;
|
||||||
syncRpcMsgLog2((char*)"==syncNodeEqHeartbeatTimer==", &rpcMsg);
|
syncTimeout2RpcMsg(pSyncMsg, &rpcMsg);
|
||||||
if (pSyncNode->FpEqMsg != NULL) {
|
syncRpcMsgLog2((char*)"==syncNodeEqHeartbeatTimer==", &rpcMsg);
|
||||||
int32_t code = pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg);
|
if (pSyncNode->FpEqMsg != NULL) {
|
||||||
if (code != 0) {
|
int32_t code = pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg);
|
||||||
sError("vgId:%d sync enqueue timer msg error, code:%d", pSyncNode->vgId, code);
|
if (code != 0) {
|
||||||
rpcFreeCont(rpcMsg.pCont);
|
sError("vgId:%d sync enqueue timer msg error, code:%d", pSyncNode->vgId, code);
|
||||||
syncTimeoutDestroy(pSyncMsg);
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
return;
|
syncTimeoutDestroy(pSyncMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sError("syncNodeEqHeartbeatTimer FpEqMsg is NULL");
|
||||||
|
}
|
||||||
|
syncTimeoutDestroy(pSyncMsg);
|
||||||
|
|
||||||
|
if (syncEnvIsStart()) {
|
||||||
|
taosTmrReset(syncNodeEqHeartbeatTimer, pSyncNode->heartbeatTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
||||||
|
&pSyncNode->pHeartbeatTimer);
|
||||||
|
} else {
|
||||||
|
sError("sync env is stop, syncNodeEqHeartbeatTimer");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sError("syncNodeEqHeartbeatTimer FpEqMsg is NULL");
|
sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%" PRIu64 ", heartbeatTimerLogicClockUser:%" PRIu64
|
||||||
|
"",
|
||||||
|
pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser);
|
||||||
}
|
}
|
||||||
syncTimeoutDestroy(pSyncMsg);
|
|
||||||
|
|
||||||
if (syncEnvIsStart()) {
|
|
||||||
taosTmrReset(syncNodeEqHeartbeatTimer, pSyncNode->heartbeatTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
|
||||||
&pSyncNode->pHeartbeatTimer);
|
|
||||||
} else {
|
|
||||||
sError("sync env is stop, syncNodeEqHeartbeatTimer");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%" PRIu64 ", heartbeatTimerLogicClockUser:%" PRIu64
|
|
||||||
"",
|
|
||||||
pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2184,7 +2188,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
|
||||||
ths->pFsm->FpRestoreFinishCb(ths->pFsm);
|
ths->pFsm->FpRestoreFinishCb(ths->pFsm);
|
||||||
}
|
}
|
||||||
ths->restoreFinish = true;
|
ths->restoreFinish = true;
|
||||||
sDebug("vgId:%d sync event restore finish", ths->vgId);
|
sDebug("vgId:%d sync event restore finish, index:%ld", ths->vgId, pEntry->index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ static int32_t walReadSeekVer(SWalReadHandle *pRead, int64_t ver) {
|
||||||
}
|
}
|
||||||
if (ver > pWal->vers.lastVer || ver < pWal->vers.firstVer) {
|
if (ver > pWal->vers.lastVer || ver < pWal->vers.firstVer) {
|
||||||
wError("invalid version: % " PRId64 ", first ver %ld, last ver %ld", ver, pWal->vers.firstVer, pWal->vers.lastVer);
|
wError("invalid version: % " PRId64 ", first ver %ld, last ver %ld", ver, pWal->vers.firstVer, pWal->vers.lastVer);
|
||||||
terrno = TSDB_CODE_WAL_INVALID_VER;
|
terrno = TSDB_CODE_WAL_LOG_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (ver < pWal->vers.snapshotVer) {
|
if (ver < pWal->vers.snapshotVer) {
|
||||||
|
|
|
@ -64,7 +64,10 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
|
||||||
int32_t walCommit(SWal *pWal, int64_t ver) {
|
int32_t walCommit(SWal *pWal, int64_t ver) {
|
||||||
ASSERT(pWal->vers.commitVer >= pWal->vers.snapshotVer);
|
ASSERT(pWal->vers.commitVer >= pWal->vers.snapshotVer);
|
||||||
ASSERT(pWal->vers.commitVer <= pWal->vers.lastVer);
|
ASSERT(pWal->vers.commitVer <= pWal->vers.lastVer);
|
||||||
if (ver < pWal->vers.commitVer || ver > pWal->vers.lastVer) {
|
if (ver < pWal->vers.commitVer) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (ver > pWal->vers.lastVer) {
|
||||||
terrno = TSDB_CODE_WAL_INVALID_VER;
|
terrno = TSDB_CODE_WAL_INVALID_VER;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,19 +53,19 @@ typedef struct SCacheEntry {
|
||||||
SCacheNode *next;
|
SCacheNode *next;
|
||||||
} SCacheEntry;
|
} SCacheEntry;
|
||||||
|
|
||||||
typedef struct STrashElem {
|
struct STrashElem {
|
||||||
struct STrashElem *prev;
|
struct STrashElem *prev;
|
||||||
struct STrashElem *next;
|
struct STrashElem *next;
|
||||||
SCacheNode *pData;
|
SCacheNode *pData;
|
||||||
} STrashElem;
|
};
|
||||||
|
|
||||||
typedef struct SCacheIter {
|
struct SCacheIter {
|
||||||
SCacheObj *pCacheObj;
|
SCacheObj *pCacheObj;
|
||||||
SCacheNode **pCurrent;
|
SCacheNode **pCurrent;
|
||||||
int32_t entryIndex;
|
int32_t entryIndex;
|
||||||
int32_t index;
|
int32_t index;
|
||||||
int32_t numOfObj;
|
int32_t numOfObj;
|
||||||
} SCacheIter;
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* to accommodate the old data which has the same key value of new one in hashList
|
* to accommodate the old data which has the same key value of new one in hashList
|
||||||
|
|
|
@ -137,6 +137,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_STMT_CLAUSE_ERROR, "not supported stmt cl
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_APP_ERROR, "Mnode internal error")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_APP_ERROR, "Mnode internal error")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_READY, "Mnode not ready")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_READY, "Mnode not ready")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_RIGHTS, "Insufficient privilege for operation")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_RIGHTS, "Insufficient privilege for operation")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_USER_DISABLED, "User is disabled")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CONNECTION, "Invalid message connection")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CONNECTION, "Invalid message connection")
|
||||||
|
|
||||||
// mnode-show
|
// mnode-show
|
||||||
|
@ -422,6 +423,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_WAL_APP_ERROR, "Unexpected generic er
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_FILE_CORRUPTED, "WAL file is corrupted")
|
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_FILE_CORRUPTED, "WAL file is corrupted")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_SIZE_LIMIT, "WAL size exceeds limit")
|
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_SIZE_LIMIT, "WAL size exceeds limit")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_INVALID_VER, "WAL use invalid version")
|
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_INVALID_VER, "WAL use invalid version")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_LOG_NOT_EXIST, "WAL log not exist")
|
||||||
|
|
||||||
// tfs
|
// tfs
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_FS_APP_ERROR, "tfs out of memory")
|
TAOS_DEFINE_ERROR(TSDB_CODE_FS_APP_ERROR, "tfs out of memory")
|
||||||
|
|
|
@ -334,22 +334,22 @@ class TDDnode:
|
||||||
bkey2 = bytes(key2, encoding="utf8")
|
bkey2 = bytes(key2, encoding="utf8")
|
||||||
logFile = self.logDir + "/taosdlog.0"
|
logFile = self.logDir + "/taosdlog.0"
|
||||||
i = 0
|
i = 0
|
||||||
while not os.path.exists(logFile):
|
# while not os.path.exists(logFile):
|
||||||
sleep(0.1)
|
# sleep(0.1)
|
||||||
i += 1
|
# i += 1
|
||||||
if i > 10:
|
# if i > 10:
|
||||||
break
|
# break
|
||||||
tailCmdStr = 'tail -f '
|
# tailCmdStr = 'tail -f '
|
||||||
if platform.system().lower() == 'windows':
|
# if platform.system().lower() == 'windows':
|
||||||
tailCmdStr = 'tail -n +0 -f '
|
# tailCmdStr = 'tail -n +0 -f '
|
||||||
popen = subprocess.Popen(
|
# popen = subprocess.Popen(
|
||||||
tailCmdStr + logFile,
|
# tailCmdStr + logFile,
|
||||||
stdout=subprocess.PIPE,
|
# stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
# stderr=subprocess.PIPE,
|
||||||
shell=True)
|
# shell=True)
|
||||||
pid = popen.pid
|
# pid = popen.pid
|
||||||
# print('Popen.pid:' + str(pid))
|
# # print('Popen.pid:' + str(pid))
|
||||||
timeout = time.time() + 60 * 2
|
# timeout = time.time() + 60 * 2
|
||||||
# while True:
|
# while True:
|
||||||
# line = popen.stdout.readline().strip()
|
# line = popen.stdout.readline().strip()
|
||||||
# print(line)
|
# print(line)
|
||||||
|
|
|
@ -156,6 +156,7 @@ class TDSql:
|
||||||
def checkRows(self, expectRows):
|
def checkRows(self, expectRows):
|
||||||
if self.queryRows == expectRows:
|
if self.queryRows == expectRows:
|
||||||
tdLog.info("sql:%s, queryRows:%d == expect:%d" % (self.sql, self.queryRows, expectRows))
|
tdLog.info("sql:%s, queryRows:%d == expect:%d" % (self.sql, self.queryRows, expectRows))
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
args = (caller.filename, caller.lineno, self.sql, self.queryRows, expectRows)
|
args = (caller.filename, caller.lineno, self.sql, self.queryRows, expectRows)
|
||||||
|
|
|
@ -246,20 +246,26 @@ class TDTestCase:
|
||||||
user = self.root_user
|
user = self.root_user
|
||||||
with taos_connect(user=user.name, passwd=user.passwd) as use:
|
with taos_connect(user=user.name, passwd=user.passwd) as use:
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
use.query("use db")
|
|
||||||
use.query("show tables")
|
|
||||||
if check_priv == PRIVILEGES_ALL:
|
if check_priv == PRIVILEGES_ALL:
|
||||||
|
use.query("use db")
|
||||||
|
use.query("show tables")
|
||||||
use.query("select * from ct1")
|
use.query("select * from ct1")
|
||||||
use.query("insert into t1 (ts) values (now())")
|
use.query("insert into t1 (ts) values (now())")
|
||||||
elif check_priv == PRIVILEGES_READ:
|
elif check_priv == PRIVILEGES_READ:
|
||||||
|
use.query("use db")
|
||||||
|
use.query("show tables")
|
||||||
use.query("select * from ct1")
|
use.query("select * from ct1")
|
||||||
use.error("insert into t1 (ts) values (now())")
|
use.error("insert into t1 (ts) values (now())")
|
||||||
elif check_priv == PRIVILEGES_WRITE:
|
elif check_priv == PRIVILEGES_WRITE:
|
||||||
|
use.query("use db")
|
||||||
|
use.query("show tables")
|
||||||
use.error("select * from ct1")
|
use.error("select * from ct1")
|
||||||
use.query("insert into t1 (ts) values (now())")
|
use.query("insert into t1 (ts) values (now())")
|
||||||
elif check_priv is None:
|
elif check_priv is None:
|
||||||
use.error("select * from ct1")
|
use.error("use db")
|
||||||
use.error("insert into t1 (ts) values (now())")
|
use.error("show tables")
|
||||||
|
use.error("select * from db.ct1")
|
||||||
|
use.error("insert into db.t1 (ts) values (now())")
|
||||||
|
|
||||||
def __change_user_priv(self, user: User, pre_priv, invoke=False):
|
def __change_user_priv(self, user: User, pre_priv, invoke=False):
|
||||||
if user.priv == pre_priv and invoke :
|
if user.priv == pre_priv and invoke :
|
||||||
|
@ -610,7 +616,7 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========step0: init, user list only has root account")
|
tdLog.printNoPrefix("==========step0: init, user list only has root account")
|
||||||
tdSql.query("show users")
|
tdSql.query("show users")
|
||||||
tdSql.checkData(0, 0, "root")
|
tdSql.checkData(0, 0, "root")
|
||||||
tdSql.checkData(0, 1, "super")
|
tdSql.checkData(0, 1, "1")
|
||||||
|
|
||||||
# root用户权限
|
# root用户权限
|
||||||
# 创建用户测试
|
# 创建用户测试
|
||||||
|
@ -676,7 +682,7 @@ class TDTestCase:
|
||||||
tdSql.query("show users")
|
tdSql.query("show users")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0, 0, "root")
|
tdSql.checkData(0, 0, "root")
|
||||||
tdSql.checkData(0, 1, "super")
|
tdSql.checkData(0, 1, "1")
|
||||||
|
|
||||||
tdDnodes.stop(1)
|
tdDnodes.stop(1)
|
||||||
tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
|
@ -690,7 +696,7 @@ class TDTestCase:
|
||||||
tdSql.query("show users")
|
tdSql.query("show users")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0, 0, "root")
|
tdSql.checkData(0, 0, "root")
|
||||||
tdSql.checkData(0, 1, "super")
|
tdSql.checkData(0, 1, "1")
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|
|
@ -543,7 +543,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(0, 0, 1.5)
|
tdSql.checkData(0, 0, 1.5)
|
||||||
#tdSql.query("select last_row(dataint) from jsons1 where jtag->'tag1'>1")
|
#tdSql.query("select last_row(dataint) from jsons1 where jtag->'tag1'>1")
|
||||||
#tdSql.checkData(0, 0, 11)
|
#tdSql.checkData(0, 0, 11)
|
||||||
tdSql.error("select interp(dataint) from jsons1 where ts = '2020-06-02 09:17:08.000' and jtag->'tag1'>1")
|
#tdSql.error("select interp(dataint) from jsons1 where ts = '2020-06-02 09:17:08.000' and jtag->'tag1'>1")
|
||||||
#
|
#
|
||||||
# #test calculation function:diff/derivative/spread/ceil/floor/round/
|
# #test calculation function:diff/derivative/spread/ceil/floor/round/
|
||||||
#tdSql.error("select diff(dataint) from jsons1 where jtag->'tag1'>1")
|
#tdSql.error("select diff(dataint) from jsons1 where jtag->'tag1'>1")
|
||||||
|
|
|
@ -54,7 +54,9 @@ class TDTestCase:
|
||||||
valgrind = 0
|
valgrind = 0
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
dnodes = []
|
dnodes = []
|
||||||
start_port = 6030
|
start_port = 6030
|
||||||
|
start_port_sec = 6130
|
||||||
|
|
||||||
for num in range(1, dnodes_nums+1):
|
for num in range(1, dnodes_nums+1):
|
||||||
dnode = TDDnode(num)
|
dnode = TDDnode(num)
|
||||||
dnode.addExtraCfg("firstEp", f"{hostname}:{start_port}")
|
dnode.addExtraCfg("firstEp", f"{hostname}:{start_port}")
|
||||||
|
@ -62,6 +64,8 @@ class TDTestCase:
|
||||||
dnode.addExtraCfg("serverPort", f"{start_port + (num-1)*100}")
|
dnode.addExtraCfg("serverPort", f"{start_port + (num-1)*100}")
|
||||||
dnode.addExtraCfg("monitorFqdn", hostname)
|
dnode.addExtraCfg("monitorFqdn", hostname)
|
||||||
dnode.addExtraCfg("monitorPort", 7043)
|
dnode.addExtraCfg("monitorPort", 7043)
|
||||||
|
dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}")
|
||||||
|
|
||||||
dnodes.append(dnode)
|
dnodes.append(dnode)
|
||||||
|
|
||||||
self.TDDnodes = MyDnodes(dnodes)
|
self.TDDnodes = MyDnodes(dnodes)
|
||||||
|
|
|
@ -78,6 +78,7 @@ class TDTestCase:
|
||||||
print(hostname)
|
print(hostname)
|
||||||
dnodes = []
|
dnodes = []
|
||||||
start_port = 6030
|
start_port = 6030
|
||||||
|
start_port_sec = 6130
|
||||||
for num in range(1, dnodes_nums+1):
|
for num in range(1, dnodes_nums+1):
|
||||||
dnode = TDDnode(num)
|
dnode = TDDnode(num)
|
||||||
dnode.addExtraCfg("firstEp", f"{hostname}:{start_port}")
|
dnode.addExtraCfg("firstEp", f"{hostname}:{start_port}")
|
||||||
|
@ -85,6 +86,7 @@ class TDTestCase:
|
||||||
dnode.addExtraCfg("serverPort", f"{start_port + (num-1)*100}")
|
dnode.addExtraCfg("serverPort", f"{start_port + (num-1)*100}")
|
||||||
dnode.addExtraCfg("monitorFqdn", hostname)
|
dnode.addExtraCfg("monitorFqdn", hostname)
|
||||||
dnode.addExtraCfg("monitorPort", 7043)
|
dnode.addExtraCfg("monitorPort", 7043)
|
||||||
|
dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}")
|
||||||
dnodes.append(dnode)
|
dnodes.append(dnode)
|
||||||
|
|
||||||
self.TDDnodes = MyDnodes(dnodes)
|
self.TDDnodes = MyDnodes(dnodes)
|
||||||
|
@ -116,25 +118,28 @@ class TDTestCase:
|
||||||
while count < 10:
|
while count < 10:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='leader' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[1][2]=='follower':
|
if tdSql.queryResult[0][2]=='leader' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='follower':
|
||||||
print("three mnodes is ready in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("three mnodes is ready in 10s")
|
||||||
elif tdSql.queryResult[0][2]=='follower' :
|
break
|
||||||
if tdSql.queryResult[1][2]=='leader':
|
elif tdSql.queryResult[0][2]=='follower' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='leader':
|
||||||
print("three mnodes is ready in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("three mnodes is ready in 10s")
|
||||||
elif tdSql.queryResult[0][2]=='follower' :
|
break
|
||||||
if tdSql.queryResult[1][2]=='follower':
|
elif tdSql.queryResult[0][2]=='follower' :
|
||||||
if tdSql.queryResult[2][2]=='leader':
|
if tdSql.queryResult[1][2]=='follower':
|
||||||
print("three mnodes is ready in 10s")
|
if tdSql.queryResult[2][2]=='leader':
|
||||||
break
|
print("three mnodes is ready in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
|
print(tdSql.queryResult)
|
||||||
print("three mnodes is not ready in 10s ")
|
print("three mnodes is not ready in 10s ")
|
||||||
|
return -1
|
||||||
|
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
|
@ -151,18 +156,21 @@ class TDTestCase:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='offline' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[1][2]=='leader':
|
if tdSql.queryResult[0][2]=='offline' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='leader':
|
||||||
print("stop mnodes on dnode 2 successfully in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("stop mnodes on dnode 2 successfully in 10s")
|
||||||
elif tdSql.queryResult[1][2]=='follower':
|
break
|
||||||
if tdSql.queryResult[2][2]=='leader':
|
elif tdSql.queryResult[1][2]=='follower':
|
||||||
print("stop mnodes on dnode 2 successfully in 10s")
|
if tdSql.queryResult[2][2]=='leader':
|
||||||
break
|
print("stop mnodes on dnode 2 successfully in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
print("stop mnodes on dnode 2 failed in 10s ")
|
print("stop mnodes on dnode 2 failed in 10s ")
|
||||||
|
return -1
|
||||||
|
tdSql.error("drop mnode on dnode 1;")
|
||||||
|
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
|
@ -174,20 +182,23 @@ class TDTestCase:
|
||||||
tdSql.checkData(2,1,'%s:6230'%self.host)
|
tdSql.checkData(2,1,'%s:6230'%self.host)
|
||||||
tdSql.checkData(2,3,'ready')
|
tdSql.checkData(2,3,'ready')
|
||||||
|
|
||||||
def check3mnode2drop(self):
|
def check3mnode2off(self):
|
||||||
count=0
|
count=0
|
||||||
while count < 10:
|
while count < 40:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='leader' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[1][2]=='offline':
|
if tdSql.queryResult[0][2]=='leader' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='offline':
|
||||||
print("stop mnodes on dnode 2 successfully in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("stop mnodes on dnode 2 successfully in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
print("stop mnodes on dnode 2 failed in 10s ")
|
print("stop mnodes on dnode 2 failed in 10s ")
|
||||||
|
return -1
|
||||||
|
tdSql.error("drop mnode on dnode 2;")
|
||||||
|
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
|
@ -197,7 +208,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(1,1,'%s:6130'%self.host)
|
tdSql.checkData(1,1,'%s:6130'%self.host)
|
||||||
tdSql.checkData(1,2,'offline')
|
tdSql.checkData(1,2,'offline')
|
||||||
tdSql.checkData(1,3,'ready')
|
tdSql.checkData(1,3,'ready')
|
||||||
tdSql.checkData(2,1,'%s:6230')
|
tdSql.checkData(2,1,'%s:6230'%self.host)
|
||||||
tdSql.checkData(2,2,'follower')
|
tdSql.checkData(2,2,'follower')
|
||||||
tdSql.checkData(2,3,'ready')
|
tdSql.checkData(2,3,'ready')
|
||||||
|
|
||||||
|
@ -207,15 +218,17 @@ class TDTestCase:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='leader' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[2][2]=='offline':
|
if tdSql.queryResult[0][2]=='leader' :
|
||||||
if tdSql.queryResult[1][2]=='follower':
|
if tdSql.queryResult[2][2]=='offline':
|
||||||
print("stop mnodes on dnode 3 successfully in 10s")
|
if tdSql.queryResult[1][2]=='follower':
|
||||||
break
|
print("stop mnodes on dnode 3 successfully in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
print("stop mnodes on dnode 3 failed in 10s")
|
print("stop mnodes on dnode 3 failed in 10s")
|
||||||
|
return -1
|
||||||
|
tdSql.error("drop mnode on dnode 3;")
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||||
|
@ -262,8 +275,25 @@ class TDTestCase:
|
||||||
for i in range(1,3):
|
for i in range(1,3):
|
||||||
tdLog.debug("drop mnode on dnode %d"%(i+1))
|
tdLog.debug("drop mnode on dnode %d"%(i+1))
|
||||||
tdSql.execute("drop mnode on dnode %d"%(i+1))
|
tdSql.execute("drop mnode on dnode %d"%(i+1))
|
||||||
|
tdSql.query("show mnodes;")
|
||||||
|
count=0
|
||||||
|
while count<10:
|
||||||
|
time.sleep(1)
|
||||||
|
tdSql.query("show mnodes;")
|
||||||
|
if tdSql.checkRows(2):
|
||||||
|
print("drop mnode %d successfully"%(i+1))
|
||||||
|
break
|
||||||
|
count+=1
|
||||||
tdLog.debug("create mnode on dnode %d"%(i+1))
|
tdLog.debug("create mnode on dnode %d"%(i+1))
|
||||||
tdSql.execute("create mnode on dnode %d"%(i+1))
|
tdSql.execute("create mnode on dnode %d"%(i+1))
|
||||||
|
count=0
|
||||||
|
while count<10:
|
||||||
|
time.sleep(1)
|
||||||
|
tdSql.query("show mnodes;")
|
||||||
|
if tdSql.checkRows(3):
|
||||||
|
print("drop mnode %d successfully"%(i+1))
|
||||||
|
break
|
||||||
|
count+=1
|
||||||
dropcount+=1
|
dropcount+=1
|
||||||
self.check3mnode()
|
self.check3mnode()
|
||||||
|
|
||||||
|
|
|
@ -115,25 +115,27 @@ class TDTestCase:
|
||||||
while count < 10:
|
while count < 10:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='leader' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[1][2]=='follower':
|
if tdSql.queryResult[0][2]=='leader' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='follower':
|
||||||
print("three mnodes is ready in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("three mnodes is ready in 10s")
|
||||||
elif tdSql.queryResult[0][2]=='follower' :
|
break
|
||||||
if tdSql.queryResult[1][2]=='leader':
|
elif tdSql.queryResult[0][2]=='follower' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='leader':
|
||||||
print("three mnodes is ready in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("three mnodes is ready in 10s")
|
||||||
elif tdSql.queryResult[0][2]=='follower' :
|
break
|
||||||
if tdSql.queryResult[1][2]=='follower':
|
elif tdSql.queryResult[0][2]=='follower' :
|
||||||
if tdSql.queryResult[2][2]=='leader':
|
if tdSql.queryResult[1][2]=='follower':
|
||||||
print("three mnodes is ready in 10s")
|
if tdSql.queryResult[2][2]=='leader':
|
||||||
break
|
print("three mnodes is ready in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
print("three mnodes is not ready in 10s ")
|
print("three mnodes is not ready in 10s ")
|
||||||
|
return -1
|
||||||
|
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
|
@ -145,24 +147,26 @@ class TDTestCase:
|
||||||
tdSql.checkData(2,3,'ready')
|
tdSql.checkData(2,3,'ready')
|
||||||
|
|
||||||
def check3mnode1off(self):
|
def check3mnode1off(self):
|
||||||
tdSql.error("drop mnode on dnode 1;")
|
|
||||||
count=0
|
count=0
|
||||||
while count < 10:
|
while count < 10:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='offline' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[1][2]=='leader':
|
if tdSql.queryResult[0][2]=='offline' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='leader':
|
||||||
print("stop mnodes on dnode 2 successfully in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("stop mnodes on dnode 2 successfully in 10s")
|
||||||
elif tdSql.queryResult[1][2]=='follower':
|
break
|
||||||
if tdSql.queryResult[2][2]=='leader':
|
elif tdSql.queryResult[1][2]=='follower':
|
||||||
print("stop mnodes on dnode 2 successfully in 10s")
|
if tdSql.queryResult[2][2]=='leader':
|
||||||
break
|
print("stop mnodes on dnode 2 successfully in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
print("stop mnodes on dnode 2 failed in 10s ")
|
print("stop mnodes on dnode 2 failed in 10s ")
|
||||||
|
return -1
|
||||||
|
tdSql.error("drop mnode on dnode 1;")
|
||||||
|
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
|
@ -175,20 +179,22 @@ class TDTestCase:
|
||||||
tdSql.checkData(2,3,'ready')
|
tdSql.checkData(2,3,'ready')
|
||||||
|
|
||||||
def check3mnode2off(self):
|
def check3mnode2off(self):
|
||||||
tdSql.error("drop mnode on dnode 2;")
|
|
||||||
count=0
|
count=0
|
||||||
while count < 10:
|
while count < 40:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='leader' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[1][2]=='offline':
|
if tdSql.queryResult[0][2]=='leader' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='offline':
|
||||||
print("stop mnodes on dnode 2 successfully in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("stop mnodes on dnode 2 successfully in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
print("stop mnodes on dnode 2 failed in 10s ")
|
print("stop mnodes on dnode 2 failed in 10s ")
|
||||||
|
return -1
|
||||||
|
tdSql.error("drop mnode on dnode 2;")
|
||||||
|
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
|
@ -203,21 +209,22 @@ class TDTestCase:
|
||||||
tdSql.checkData(2,3,'ready')
|
tdSql.checkData(2,3,'ready')
|
||||||
|
|
||||||
def check3mnode3off(self):
|
def check3mnode3off(self):
|
||||||
tdSql.error("drop mnode on dnode 3;")
|
|
||||||
count=0
|
count=0
|
||||||
while count < 10:
|
while count < 10:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='leader' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[2][2]=='offline':
|
if tdSql.queryResult[0][2]=='leader' :
|
||||||
if tdSql.queryResult[1][2]=='follower':
|
if tdSql.queryResult[2][2]=='offline':
|
||||||
print("stop mnodes on dnode 3 successfully in 10s")
|
if tdSql.queryResult[1][2]=='follower':
|
||||||
break
|
print("stop mnodes on dnode 3 successfully in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
print("stop mnodes on dnode 3 failed in 10s")
|
print("stop mnodes on dnode 3 failed in 10s")
|
||||||
|
return -1
|
||||||
|
tdSql.error("drop mnode on dnode 3;")
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||||
|
@ -264,13 +271,13 @@ class TDTestCase:
|
||||||
|
|
||||||
self.TDDnodes.stoptaosd(3)
|
self.TDDnodes.stoptaosd(3)
|
||||||
self.check3mnode3off()
|
self.check3mnode3off()
|
||||||
self.TDDnodes.starttaosd(2)
|
self.TDDnodes.starttaosd(3)
|
||||||
|
|
||||||
self.TDDnodes.stoptaosd(1)
|
self.TDDnodes.stoptaosd(1)
|
||||||
self.check3mnode1off()
|
self.check3mnode1off()
|
||||||
self.TDDnodes.starttaosd(1)
|
self.TDDnodes.starttaosd(1)
|
||||||
|
|
||||||
# self.check3mnode()
|
self.check3mnode()
|
||||||
stopcount =0
|
stopcount =0
|
||||||
while stopcount <= 2:
|
while stopcount <= 2:
|
||||||
for i in range(dnodenumber):
|
for i in range(dnodenumber):
|
||||||
|
|
|
@ -13,13 +13,17 @@ import time
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
from multiprocessing import Process
|
from multiprocessing import Process
|
||||||
import threading as thd
|
import threading
|
||||||
|
import time
|
||||||
|
import inspect
|
||||||
|
import ctypes
|
||||||
class MyDnodes(TDDnodes):
|
class MyDnodes(TDDnodes):
|
||||||
def __init__(self ,dnodes_lists):
|
def __init__(self ,dnodes_lists):
|
||||||
super(MyDnodes,self).__init__()
|
super(MyDnodes,self).__init__()
|
||||||
self.dnodes = dnodes_lists # dnode must be TDDnode instance
|
self.dnodes = dnodes_lists # dnode must be TDDnode instance
|
||||||
self.simDeployed = False
|
self.simDeployed = False
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
|
|
||||||
def init(self,conn ,logSql):
|
def init(self,conn ,logSql):
|
||||||
|
@ -49,11 +53,31 @@ class TDTestCase:
|
||||||
buildPath = root[:len(root) - len("/build/bin")]
|
buildPath = root[:len(root) - len("/build/bin")]
|
||||||
break
|
break
|
||||||
return buildPath
|
return buildPath
|
||||||
|
|
||||||
|
def _async_raise(self, tid, exctype):
|
||||||
|
"""raises the exception, performs cleanup if needed"""
|
||||||
|
if not inspect.isclass(exctype):
|
||||||
|
exctype = type(exctype)
|
||||||
|
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
|
||||||
|
if res == 0:
|
||||||
|
raise ValueError("invalid thread id")
|
||||||
|
elif res != 1:
|
||||||
|
# """if it returns a number greater than one, you're in trouble,
|
||||||
|
# and you should call it again with exc=NULL to revert the effect"""
|
||||||
|
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
|
||||||
|
raise SystemError("PyThreadState_SetAsyncExc failed")
|
||||||
|
|
||||||
|
def stop_thread(self,thread):
|
||||||
|
self._async_raise(thread.ident, SystemExit)
|
||||||
|
|
||||||
|
|
||||||
def insert_data(self,countstart,countstop):
|
def insert_data(self,countstart,countstop):
|
||||||
# fisrt add data : db\stable\childtable\general table
|
# fisrt add data : db\stable\childtable\general table
|
||||||
|
|
||||||
for couti in range(countstart,countstop):
|
for couti in range(countstart,countstop):
|
||||||
|
tdLog.debug("drop database if exists db%d" %couti)
|
||||||
tdSql.execute("drop database if exists db%d" %couti)
|
tdSql.execute("drop database if exists db%d" %couti)
|
||||||
|
print("create database if not exists db%d replica 1 duration 300" %couti)
|
||||||
tdSql.execute("create database if not exists db%d replica 1 duration 300" %couti)
|
tdSql.execute("create database if not exists db%d replica 1 duration 300" %couti)
|
||||||
tdSql.execute("use db%d" %couti)
|
tdSql.execute("use db%d" %couti)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
@ -78,6 +102,7 @@ class TDTestCase:
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
dnodes = []
|
dnodes = []
|
||||||
start_port = 6030
|
start_port = 6030
|
||||||
|
start_port_sec = 6130
|
||||||
for num in range(1, dnodes_nums+1):
|
for num in range(1, dnodes_nums+1):
|
||||||
dnode = TDDnode(num)
|
dnode = TDDnode(num)
|
||||||
dnode.addExtraCfg("firstEp", f"{hostname}:{start_port}")
|
dnode.addExtraCfg("firstEp", f"{hostname}:{start_port}")
|
||||||
|
@ -85,6 +110,7 @@ class TDTestCase:
|
||||||
dnode.addExtraCfg("serverPort", f"{start_port + (num-1)*100}")
|
dnode.addExtraCfg("serverPort", f"{start_port + (num-1)*100}")
|
||||||
dnode.addExtraCfg("monitorFqdn", hostname)
|
dnode.addExtraCfg("monitorFqdn", hostname)
|
||||||
dnode.addExtraCfg("monitorPort", 7043)
|
dnode.addExtraCfg("monitorPort", 7043)
|
||||||
|
dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}")
|
||||||
dnodes.append(dnode)
|
dnodes.append(dnode)
|
||||||
|
|
||||||
self.TDDnodes = MyDnodes(dnodes)
|
self.TDDnodes = MyDnodes(dnodes)
|
||||||
|
@ -111,30 +137,58 @@ class TDTestCase:
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
tdLog.info(" create cluster with %d dnode done! " %dnodes_nums)
|
tdLog.info(" create cluster with %d dnode done! " %dnodes_nums)
|
||||||
|
|
||||||
|
def checkdnodes(self,dnodenumber):
|
||||||
|
count=0
|
||||||
|
while count < 10:
|
||||||
|
time.sleep(1)
|
||||||
|
statusReadyBumber=0
|
||||||
|
tdSql.query("show dnodes;")
|
||||||
|
if tdSql.checkRows(dnodenumber) :
|
||||||
|
print("dnode is %d nodes"%dnodenumber)
|
||||||
|
for i in range(dnodenumber):
|
||||||
|
if tdSql.queryResult[i][4] !='ready' :
|
||||||
|
status=tdSql.queryResult[i][4]
|
||||||
|
print("dnode:%d status is %s "%(i,status))
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
statusReadyBumber+=1
|
||||||
|
print(statusReadyBumber)
|
||||||
|
if statusReadyBumber == dnodenumber :
|
||||||
|
print("all of %d mnodes is ready in 10s "%dnodenumber)
|
||||||
|
return True
|
||||||
|
break
|
||||||
|
count+=1
|
||||||
|
else:
|
||||||
|
print("%d mnodes is not ready in 10s "%dnodenumber)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def check3mnode(self):
|
def check3mnode(self):
|
||||||
count=0
|
count=0
|
||||||
while count < 10:
|
while count < 10:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='leader' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[1][2]=='follower':
|
if tdSql.queryResult[0][2]=='leader' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='follower':
|
||||||
print("three mnodes is ready in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("three mnodes is ready in 10s")
|
||||||
elif tdSql.queryResult[0][2]=='follower' :
|
break
|
||||||
if tdSql.queryResult[1][2]=='leader':
|
elif tdSql.queryResult[0][2]=='follower' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='leader':
|
||||||
print("three mnodes is ready in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("three mnodes is ready in 10s")
|
||||||
elif tdSql.queryResult[0][2]=='follower' :
|
break
|
||||||
if tdSql.queryResult[1][2]=='follower':
|
elif tdSql.queryResult[0][2]=='follower' :
|
||||||
if tdSql.queryResult[2][2]=='leader':
|
if tdSql.queryResult[1][2]=='follower':
|
||||||
print("three mnodes is ready in 10s")
|
if tdSql.queryResult[2][2]=='leader':
|
||||||
break
|
print("three mnodes is ready in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
print("three mnodes is not ready in 10s ")
|
print("three mnodes is not ready in 10s ")
|
||||||
|
return -1
|
||||||
|
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
|
@ -146,24 +200,26 @@ class TDTestCase:
|
||||||
tdSql.checkData(2,3,'ready')
|
tdSql.checkData(2,3,'ready')
|
||||||
|
|
||||||
def check3mnode1off(self):
|
def check3mnode1off(self):
|
||||||
tdSql.error("drop mnode on dnode 1;")
|
|
||||||
count=0
|
count=0
|
||||||
while count < 10:
|
while count < 10:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='offline' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[1][2]=='leader':
|
if tdSql.queryResult[0][2]=='offline' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='leader':
|
||||||
print("stop mnodes on dnode 2 successfully in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("stop mnodes on dnode 2 successfully in 10s")
|
||||||
elif tdSql.queryResult[1][2]=='follower':
|
break
|
||||||
if tdSql.queryResult[2][2]=='leader':
|
elif tdSql.queryResult[1][2]=='follower':
|
||||||
print("stop mnodes on dnode 2 successfully in 10s")
|
if tdSql.queryResult[2][2]=='leader':
|
||||||
break
|
print("stop mnodes on dnode 2 successfully in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
print("stop mnodes on dnode 2 failed in 10s ")
|
print("stop mnodes on dnode 2 failed in 10s ")
|
||||||
|
return -1
|
||||||
|
tdSql.error("drop mnode on dnode 1;")
|
||||||
|
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
|
@ -176,20 +232,22 @@ class TDTestCase:
|
||||||
tdSql.checkData(2,3,'ready')
|
tdSql.checkData(2,3,'ready')
|
||||||
|
|
||||||
def check3mnode2off(self):
|
def check3mnode2off(self):
|
||||||
tdSql.error("drop mnode on dnode 2;")
|
|
||||||
count=0
|
count=0
|
||||||
while count < 40:
|
while count < 40:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='leader' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[1][2]=='offline':
|
if tdSql.queryResult[0][2]=='leader' :
|
||||||
if tdSql.queryResult[2][2]=='follower':
|
if tdSql.queryResult[1][2]=='offline':
|
||||||
print("stop mnodes on dnode 2 successfully in 10s")
|
if tdSql.queryResult[2][2]=='follower':
|
||||||
break
|
print("stop mnodes on dnode 2 successfully in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
print("stop mnodes on dnode 2 failed in 10s ")
|
print("stop mnodes on dnode 2 failed in 10s ")
|
||||||
|
return -1
|
||||||
|
tdSql.error("drop mnode on dnode 2;")
|
||||||
|
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
|
@ -204,21 +262,22 @@ class TDTestCase:
|
||||||
tdSql.checkData(2,3,'ready')
|
tdSql.checkData(2,3,'ready')
|
||||||
|
|
||||||
def check3mnode3off(self):
|
def check3mnode3off(self):
|
||||||
tdSql.error("drop mnode on dnode 3;")
|
|
||||||
count=0
|
count=0
|
||||||
while count < 10:
|
while count < 10:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
if tdSql.checkRows(3) :
|
if tdSql.checkRows(3) :
|
||||||
if tdSql.queryResult[0][2]=='leader' :
|
print("mnode is three nodes")
|
||||||
if tdSql.queryResult[2][2]=='offline':
|
if tdSql.queryResult[0][2]=='leader' :
|
||||||
if tdSql.queryResult[1][2]=='follower':
|
if tdSql.queryResult[2][2]=='offline':
|
||||||
print("stop mnodes on dnode 3 successfully in 10s")
|
if tdSql.queryResult[1][2]=='follower':
|
||||||
break
|
print("stop mnodes on dnode 3 successfully in 10s")
|
||||||
|
break
|
||||||
count+=1
|
count+=1
|
||||||
else:
|
else:
|
||||||
print("stop mnodes on dnode 3 failed in 10s")
|
print("stop mnodes on dnode 3 failed in 10s")
|
||||||
|
return -1
|
||||||
|
tdSql.error("drop mnode on dnode 3;")
|
||||||
tdSql.query("show mnodes;")
|
tdSql.query("show mnodes;")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||||
|
@ -231,8 +290,6 @@ class TDTestCase:
|
||||||
tdSql.checkData(2,2,'offline')
|
tdSql.checkData(2,2,'offline')
|
||||||
tdSql.checkData(2,3,'ready')
|
tdSql.checkData(2,3,'ready')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def five_dnode_three_mnode(self,dnodenumber):
|
def five_dnode_three_mnode(self,dnodenumber):
|
||||||
tdSql.query("show dnodes;")
|
tdSql.query("show dnodes;")
|
||||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||||
|
@ -252,43 +309,29 @@ class TDTestCase:
|
||||||
# fisrt check statut ready
|
# fisrt check statut ready
|
||||||
self.check3mnode()
|
self.check3mnode()
|
||||||
|
|
||||||
|
|
||||||
tdSql.error("create mnode on dnode 2")
|
tdSql.error("create mnode on dnode 2")
|
||||||
|
|
||||||
tdSql.query("show dnodes;")
|
tdSql.query("show dnodes;")
|
||||||
print(tdSql.queryResult)
|
print(tdSql.queryResult)
|
||||||
|
tdLog.debug("stop all of mnode ")
|
||||||
|
|
||||||
tdLog.debug("stop and follower of mnode")
|
|
||||||
self.TDDnodes.stoptaosd(2)
|
|
||||||
self.check3mnode2off()
|
|
||||||
self.TDDnodes.starttaosd(2)
|
|
||||||
|
|
||||||
self.TDDnodes.stoptaosd(3)
|
|
||||||
self.check3mnode3off()
|
|
||||||
self.TDDnodes.starttaosd(3)
|
|
||||||
|
|
||||||
self.TDDnodes.stoptaosd(1)
|
|
||||||
self.check3mnode1off()
|
|
||||||
self.TDDnodes.starttaosd(1)
|
|
||||||
|
|
||||||
# self.check3mnode()
|
|
||||||
stopcount =0
|
stopcount =0
|
||||||
while stopcount <= 2:
|
while stopcount <= 2:
|
||||||
for i in range(dnodenumber):
|
for i in range(dnodenumber):
|
||||||
threads = []
|
# threads=[]
|
||||||
threads.append(thd.Thread(target=self.insert_data, args=(i*2,i*2+2)))
|
# threads = MyThreadFunc(self.insert_data(i*2,i*2+2))
|
||||||
threads[0].start()
|
threads=threading.Thread(target=self.insert_data, args=((stopcount+i)*2,(i+stopcount)*2+2))
|
||||||
|
threads.start()
|
||||||
self.TDDnodes.stoptaosd(i+1)
|
self.TDDnodes.stoptaosd(i+1)
|
||||||
# if i == 1 :
|
|
||||||
# self.check3mnode2off()
|
|
||||||
# elif i == 2 :
|
|
||||||
# self.check3mnode3off()
|
|
||||||
# elif i == 0:
|
|
||||||
# self.check3mnode1off()
|
|
||||||
|
|
||||||
self.TDDnodes.starttaosd(i+1)
|
self.TDDnodes.starttaosd(i+1)
|
||||||
threads[0].join()
|
|
||||||
|
|
||||||
|
if self.checkdnodes(5):
|
||||||
|
print("123")
|
||||||
|
threads.join()
|
||||||
|
else:
|
||||||
|
print("456")
|
||||||
|
self.stop_thread(threads)
|
||||||
|
assert 1 == 2 ,"some dnode started failed"
|
||||||
|
return False
|
||||||
# self.check3mnode()
|
# self.check3mnode()
|
||||||
stopcount+=1
|
stopcount+=1
|
||||||
self.check3mnode()
|
self.check3mnode()
|
||||||
|
|
|
@ -59,8 +59,8 @@ class TDTestCase:
|
||||||
def initConsumerTable(self,cdbName='cdb'):
|
def initConsumerTable(self,cdbName='cdb'):
|
||||||
tdLog.info("create consume database, and consume info table, and consume result table")
|
tdLog.info("create consume database, and consume info table, and consume result table")
|
||||||
tdSql.query("create database if not exists %s vgroups 1"%(cdbName))
|
tdSql.query("create database if not exists %s vgroups 1"%(cdbName))
|
||||||
# tdSql.query("drop table if exists %s.consumeinfo "%(cdbName))
|
tdSql.query("drop table if exists %s.consumeinfo "%(cdbName))
|
||||||
# tdSql.query("drop table if exists %s.consumeresult "%(cdbName))
|
tdSql.query("drop table if exists %s.consumeresult "%(cdbName))
|
||||||
|
|
||||||
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName)
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName)
|
||||||
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
|
@ -101,7 +101,7 @@ python3 ./test.py -f 2-query/tail.py
|
||||||
|
|
||||||
python3 ./test.py -f 6-cluster/5dnode1mnode.py
|
python3 ./test.py -f 6-cluster/5dnode1mnode.py
|
||||||
python3 ./test.py -f 6-cluster/5dnode2mnode.py
|
python3 ./test.py -f 6-cluster/5dnode2mnode.py
|
||||||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py
|
python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py
|
||||||
python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py
|
python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py
|
||||||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
|
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 9ce3f5c98ef95d9c7c596c4ed7302b0ed69a92b2
|
|
Loading…
Reference in New Issue