Merge branch '3.0' of https://github.com/taosdata/TDengine into feat/tsdb_refact
This commit is contained in:
commit
c67e572266
|
@ -1494,9 +1494,9 @@ typedef struct {
|
|||
int32_t code;
|
||||
} STaskDropRsp;
|
||||
|
||||
#define STREAM_TRIGGER_AT_ONCE 1
|
||||
#define STREAM_TRIGGER_WINDOW_CLOSE 2
|
||||
#define STREAM_TRIGGER_MAX_DELAY 3
|
||||
#define STREAM_TRIGGER_AT_ONCE 1
|
||||
#define STREAM_TRIGGER_WINDOW_CLOSE 2
|
||||
#define STREAM_TRIGGER_MAX_DELAY 3
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_TABLE_FNAME_LEN];
|
||||
|
@ -1506,6 +1506,7 @@ typedef struct {
|
|||
char* sql;
|
||||
char* ast;
|
||||
int8_t triggerType;
|
||||
int64_t maxDelay;
|
||||
int64_t watermark;
|
||||
} SCMCreateStreamReq;
|
||||
|
||||
|
|
|
@ -184,76 +184,77 @@
|
|||
#define TK_TRIGGER 166
|
||||
#define TK_AT_ONCE 167
|
||||
#define TK_WINDOW_CLOSE 168
|
||||
#define TK_WATERMARK 169
|
||||
#define TK_KILL 170
|
||||
#define TK_CONNECTION 171
|
||||
#define TK_TRANSACTION 172
|
||||
#define TK_BALANCE 173
|
||||
#define TK_VGROUP 174
|
||||
#define TK_MERGE 175
|
||||
#define TK_REDISTRIBUTE 176
|
||||
#define TK_SPLIT 177
|
||||
#define TK_SYNCDB 178
|
||||
#define TK_DELETE 179
|
||||
#define TK_NULL 180
|
||||
#define TK_NK_QUESTION 181
|
||||
#define TK_NK_ARROW 182
|
||||
#define TK_ROWTS 183
|
||||
#define TK_TBNAME 184
|
||||
#define TK_QSTARTTS 185
|
||||
#define TK_QENDTS 186
|
||||
#define TK_WSTARTTS 187
|
||||
#define TK_WENDTS 188
|
||||
#define TK_WDURATION 189
|
||||
#define TK_CAST 190
|
||||
#define TK_NOW 191
|
||||
#define TK_TODAY 192
|
||||
#define TK_TIMEZONE 193
|
||||
#define TK_COUNT 194
|
||||
#define TK_FIRST 195
|
||||
#define TK_LAST 196
|
||||
#define TK_LAST_ROW 197
|
||||
#define TK_BETWEEN 198
|
||||
#define TK_IS 199
|
||||
#define TK_NK_LT 200
|
||||
#define TK_NK_GT 201
|
||||
#define TK_NK_LE 202
|
||||
#define TK_NK_GE 203
|
||||
#define TK_NK_NE 204
|
||||
#define TK_MATCH 205
|
||||
#define TK_NMATCH 206
|
||||
#define TK_CONTAINS 207
|
||||
#define TK_JOIN 208
|
||||
#define TK_INNER 209
|
||||
#define TK_SELECT 210
|
||||
#define TK_DISTINCT 211
|
||||
#define TK_WHERE 212
|
||||
#define TK_PARTITION 213
|
||||
#define TK_BY 214
|
||||
#define TK_SESSION 215
|
||||
#define TK_STATE_WINDOW 216
|
||||
#define TK_SLIDING 217
|
||||
#define TK_FILL 218
|
||||
#define TK_VALUE 219
|
||||
#define TK_NONE 220
|
||||
#define TK_PREV 221
|
||||
#define TK_LINEAR 222
|
||||
#define TK_NEXT 223
|
||||
#define TK_HAVING 224
|
||||
#define TK_ORDER 225
|
||||
#define TK_SLIMIT 226
|
||||
#define TK_SOFFSET 227
|
||||
#define TK_LIMIT 228
|
||||
#define TK_OFFSET 229
|
||||
#define TK_ASC 230
|
||||
#define TK_NULLS 231
|
||||
#define TK_ID 232
|
||||
#define TK_NK_BITNOT 233
|
||||
#define TK_INSERT 234
|
||||
#define TK_VALUES 235
|
||||
#define TK_IMPORT 236
|
||||
#define TK_NK_SEMI 237
|
||||
#define TK_FILE 238
|
||||
#define TK_MAX_DELAY 169
|
||||
#define TK_WATERMARK 170
|
||||
#define TK_KILL 171
|
||||
#define TK_CONNECTION 172
|
||||
#define TK_TRANSACTION 173
|
||||
#define TK_BALANCE 174
|
||||
#define TK_VGROUP 175
|
||||
#define TK_MERGE 176
|
||||
#define TK_REDISTRIBUTE 177
|
||||
#define TK_SPLIT 178
|
||||
#define TK_SYNCDB 179
|
||||
#define TK_DELETE 180
|
||||
#define TK_NULL 181
|
||||
#define TK_NK_QUESTION 182
|
||||
#define TK_NK_ARROW 183
|
||||
#define TK_ROWTS 184
|
||||
#define TK_TBNAME 185
|
||||
#define TK_QSTARTTS 186
|
||||
#define TK_QENDTS 187
|
||||
#define TK_WSTARTTS 188
|
||||
#define TK_WENDTS 189
|
||||
#define TK_WDURATION 190
|
||||
#define TK_CAST 191
|
||||
#define TK_NOW 192
|
||||
#define TK_TODAY 193
|
||||
#define TK_TIMEZONE 194
|
||||
#define TK_COUNT 195
|
||||
#define TK_FIRST 196
|
||||
#define TK_LAST 197
|
||||
#define TK_LAST_ROW 198
|
||||
#define TK_BETWEEN 199
|
||||
#define TK_IS 200
|
||||
#define TK_NK_LT 201
|
||||
#define TK_NK_GT 202
|
||||
#define TK_NK_LE 203
|
||||
#define TK_NK_GE 204
|
||||
#define TK_NK_NE 205
|
||||
#define TK_MATCH 206
|
||||
#define TK_NMATCH 207
|
||||
#define TK_CONTAINS 208
|
||||
#define TK_JOIN 209
|
||||
#define TK_INNER 210
|
||||
#define TK_SELECT 211
|
||||
#define TK_DISTINCT 212
|
||||
#define TK_WHERE 213
|
||||
#define TK_PARTITION 214
|
||||
#define TK_BY 215
|
||||
#define TK_SESSION 216
|
||||
#define TK_STATE_WINDOW 217
|
||||
#define TK_SLIDING 218
|
||||
#define TK_FILL 219
|
||||
#define TK_VALUE 220
|
||||
#define TK_NONE 221
|
||||
#define TK_PREV 222
|
||||
#define TK_LINEAR 223
|
||||
#define TK_NEXT 224
|
||||
#define TK_HAVING 225
|
||||
#define TK_ORDER 226
|
||||
#define TK_SLIMIT 227
|
||||
#define TK_SOFFSET 228
|
||||
#define TK_LIMIT 229
|
||||
#define TK_OFFSET 230
|
||||
#define TK_ASC 231
|
||||
#define TK_NULLS 232
|
||||
#define TK_ID 233
|
||||
#define TK_NK_BITNOT 234
|
||||
#define TK_INSERT 235
|
||||
#define TK_VALUES 236
|
||||
#define TK_IMPORT 237
|
||||
#define TK_NK_SEMI 238
|
||||
#define TK_FILE 239
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -175,6 +175,7 @@ bool fmIsRepeatScanFunc(int32_t funcId);
|
|||
bool fmIsUserDefinedFunc(int32_t funcId);
|
||||
bool fmIsDistExecFunc(int32_t funcId);
|
||||
bool fmIsForbidFillFunc(int32_t funcId);
|
||||
bool fmIsForbidStreamFunc(int32_t funcId);
|
||||
|
||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
||||
|
||||
|
|
|
@ -289,6 +289,7 @@ typedef struct SKillStmt {
|
|||
typedef struct SStreamOptions {
|
||||
ENodeType type;
|
||||
int8_t triggerType;
|
||||
SNode* pDelay;
|
||||
SNode* pWatermark;
|
||||
} SStreamOptions;
|
||||
|
||||
|
|
|
@ -252,22 +252,20 @@ typedef struct SNodeList {
|
|||
SListCell* pTail;
|
||||
} SNodeList;
|
||||
|
||||
#define SNodeptr void*
|
||||
|
||||
SNodeptr nodesMakeNode(ENodeType type);
|
||||
void nodesDestroyNode(SNodeptr pNode);
|
||||
SNode* nodesMakeNode(ENodeType type);
|
||||
void nodesDestroyNode(SNode* pNode);
|
||||
|
||||
SNodeList* nodesMakeList();
|
||||
int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode);
|
||||
int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode);
|
||||
int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode);
|
||||
int32_t nodesListMakeStrictAppend(SNodeList** pList, SNodeptr pNode);
|
||||
int32_t nodesListAppend(SNodeList* pList, SNode* pNode);
|
||||
int32_t nodesListStrictAppend(SNodeList* pList, SNode* pNode);
|
||||
int32_t nodesListMakeAppend(SNodeList** pList, SNode* pNode);
|
||||
int32_t nodesListMakeStrictAppend(SNodeList** pList, SNode* pNode);
|
||||
int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||
int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||
int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode);
|
||||
int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
|
||||
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
||||
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||
SNodeptr nodesListGetNode(SNodeList* pList, int32_t index);
|
||||
SNode* nodesListGetNode(SNodeList* pList, int32_t index);
|
||||
void nodesDestroyList(SNodeList* pList);
|
||||
// Only clear the linked list structure, without releasing the elements inside
|
||||
void nodesClearList(SNodeList* pList);
|
||||
|
@ -275,9 +273,9 @@ void nodesClearList(SNodeList* pList);
|
|||
typedef enum EDealRes { DEAL_RES_CONTINUE = 1, DEAL_RES_IGNORE_CHILD, DEAL_RES_ERROR, DEAL_RES_END } EDealRes;
|
||||
|
||||
typedef EDealRes (*FNodeWalker)(SNode* pNode, void* pContext);
|
||||
void nodesWalkExpr(SNodeptr pNode, FNodeWalker walker, void* pContext);
|
||||
void nodesWalkExpr(SNode* pNode, FNodeWalker walker, void* pContext);
|
||||
void nodesWalkExprs(SNodeList* pList, FNodeWalker walker, void* pContext);
|
||||
void nodesWalkExprPostOrder(SNodeptr pNode, FNodeWalker walker, void* pContext);
|
||||
void nodesWalkExprPostOrder(SNode* pNode, FNodeWalker walker, void* pContext);
|
||||
void nodesWalkExprsPostOrder(SNodeList* pList, FNodeWalker walker, void* pContext);
|
||||
|
||||
typedef EDealRes (*FNodeRewriter)(SNode** pNode, void* pContext);
|
||||
|
@ -286,13 +284,13 @@ void nodesRewriteExprs(SNodeList* pList, FNodeRewriter rewriter, void* pContext)
|
|||
void nodesRewriteExprPostOrder(SNode** pNode, FNodeRewriter rewriter, void* pContext);
|
||||
void nodesRewriteExprsPostOrder(SNodeList* pList, FNodeRewriter rewriter, void* pContext);
|
||||
|
||||
bool nodesEqualNode(const SNodeptr a, const SNodeptr b);
|
||||
bool nodesEqualNode(const SNode* a, const SNode* b);
|
||||
|
||||
SNodeptr nodesCloneNode(const SNodeptr pNode);
|
||||
SNode* nodesCloneNode(const SNode* pNode);
|
||||
SNodeList* nodesCloneList(const SNodeList* pList);
|
||||
|
||||
const char* nodesNodeName(ENodeType type);
|
||||
int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen);
|
||||
int32_t nodesNodeToString(const SNode* pNode, bool format, char** pStr, int32_t* pLen);
|
||||
int32_t nodesStringToNode(const char* pStr, SNode** pNode);
|
||||
|
||||
int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen);
|
||||
|
|
|
@ -336,22 +336,21 @@ typedef enum EQueryExecMode {
|
|||
} EQueryExecMode;
|
||||
|
||||
typedef struct SQuery {
|
||||
ENodeType type;
|
||||
EQueryExecMode execMode;
|
||||
bool haveResultSet;
|
||||
SNode* pRoot;
|
||||
int32_t numOfResCols;
|
||||
SSchema* pResSchema;
|
||||
int8_t precision;
|
||||
SCmdMsgInfo* pCmdMsg;
|
||||
int32_t msgType;
|
||||
SArray* pTableList;
|
||||
SArray* pDbList;
|
||||
bool showRewrite;
|
||||
int32_t placeholderNum;
|
||||
SArray* pPlaceholderValues;
|
||||
SNode* pPrepareRoot;
|
||||
struct SParseMetaCache* pMetaCache;
|
||||
ENodeType type;
|
||||
EQueryExecMode execMode;
|
||||
bool haveResultSet;
|
||||
SNode* pRoot;
|
||||
int32_t numOfResCols;
|
||||
SSchema* pResSchema;
|
||||
int8_t precision;
|
||||
SCmdMsgInfo* pCmdMsg;
|
||||
int32_t msgType;
|
||||
SArray* pTableList;
|
||||
SArray* pDbList;
|
||||
bool showRewrite;
|
||||
int32_t placeholderNum;
|
||||
SArray* pPlaceholderValues;
|
||||
SNode* pPrepareRoot;
|
||||
} SQuery;
|
||||
|
||||
void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext);
|
||||
|
|
|
@ -698,7 +698,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
taosHashSetFreeFp(pAppHbMgr->activeInfo, tFreeClientHbReq);
|
||||
// taosHashSetFreeFp(pAppHbMgr->activeInfo, tFreeClientHbReq);
|
||||
|
||||
taosThreadMutexLock(&clientHbMgr.lock);
|
||||
taosArrayPush(clientHbMgr.appHbMgrs, &pAppHbMgr);
|
||||
|
|
|
@ -233,9 +233,7 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SAppInstInfo* getAppInfo(SRequestObj* pRequest) {
|
||||
return pRequest->pTscObj->pAppInfo;
|
||||
}
|
||||
static SAppInstInfo* getAppInfo(SRequestObj* pRequest) { return pRequest->pTscObj->pAppInfo; }
|
||||
|
||||
void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
||||
SRetrieveTableRsp* pRsp = NULL;
|
||||
|
@ -259,7 +257,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
|||
}
|
||||
|
||||
pRequest->body.queryFp(pRequest->body.param, pRequest, 0);
|
||||
// pRequest->body.fetchFp(pRequest->body.param, pRequest, pResultInfo->numOfRows);
|
||||
// pRequest->body.fetchFp(pRequest->body.param, pRequest, pResultInfo->numOfRows);
|
||||
}
|
||||
|
||||
int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
||||
|
@ -323,7 +321,7 @@ int32_t getQnodeList(SRequestObj* pRequest, SArray** pNodeList) {
|
|||
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pNodeList = taosArrayInit(5, sizeof(SQueryNodeLoad));
|
||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)};
|
||||
|
@ -401,21 +399,19 @@ void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) {
|
|||
int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
||||
tsem_init(&schdRspSem, 0, 0);
|
||||
|
||||
SQueryResult res = {.code = 0, .numOfRows = 0};
|
||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||
SQueryResult res = {.code = 0, .numOfRows = 0};
|
||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self
|
||||
};
|
||||
SSchedulerReq req = {.pConn = &conn,
|
||||
.pNodeList = pNodeList,
|
||||
.pDag = pDag,
|
||||
.sql = pRequest->sqlstr,
|
||||
.startTs = pRequest->metric.start,
|
||||
.fp = schdExecCallback,
|
||||
.cbParam = &res
|
||||
};
|
||||
|
||||
int32_t code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob);
|
||||
.requestObjRefId = pRequest->self};
|
||||
SSchedulerReq req = {.pConn = &conn,
|
||||
.pNodeList = pNodeList,
|
||||
.pDag = pDag,
|
||||
.sql = pRequest->sqlstr,
|
||||
.startTs = pRequest->metric.start,
|
||||
.fp = schdExecCallback,
|
||||
.cbParam = &res};
|
||||
|
||||
int32_t code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob);
|
||||
|
||||
pRequest->body.resInfo.execRes = res.res;
|
||||
|
||||
|
@ -455,21 +451,19 @@ int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNod
|
|||
int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
||||
void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter;
|
||||
|
||||
SQueryResult res = {0};
|
||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||
SQueryResult res = {0};
|
||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self
|
||||
};
|
||||
SSchedulerReq req = {.pConn = &conn,
|
||||
.pNodeList = pNodeList,
|
||||
.pDag = pDag,
|
||||
.sql = pRequest->sqlstr,
|
||||
.startTs = pRequest->metric.start,
|
||||
.fp = NULL,
|
||||
.cbParam = NULL
|
||||
};
|
||||
|
||||
int32_t code = schedulerExecJob(&req,&pRequest->body.queryJob, &res);
|
||||
.requestObjRefId = pRequest->self};
|
||||
SSchedulerReq req = {.pConn = &conn,
|
||||
.pNodeList = pNodeList,
|
||||
.pDag = pDag,
|
||||
.sql = pRequest->sqlstr,
|
||||
.startTs = pRequest->metric.start,
|
||||
.fp = NULL,
|
||||
.cbParam = NULL};
|
||||
|
||||
int32_t code = schedulerExecJob(&req, &pRequest->body.queryJob, &res);
|
||||
pRequest->body.resInfo.execRes = res.res;
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -482,7 +476,8 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
|||
return pRequest->code;
|
||||
}
|
||||
|
||||
if (TDMT_VND_SUBMIT == pRequest->type || TDMT_VND_DELETE == pRequest->type || TDMT_VND_CREATE_TABLE == pRequest->type) {
|
||||
if (TDMT_VND_SUBMIT == pRequest->type || TDMT_VND_DELETE == pRequest->type ||
|
||||
TDMT_VND_CREATE_TABLE == pRequest->type) {
|
||||
pRequest->body.resInfo.numOfRows = res.numOfRows;
|
||||
|
||||
if (pRequest->body.queryJob != 0) {
|
||||
|
@ -495,9 +490,9 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
|||
return pRequest->code;
|
||||
}
|
||||
|
||||
int32_t handleSubmitExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet *epset) {
|
||||
int32_t code = 0;
|
||||
SArray* pArray = NULL;
|
||||
int32_t handleSubmitExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet* epset) {
|
||||
int32_t code = 0;
|
||||
SArray* pArray = NULL;
|
||||
SSubmitRsp* pRsp = (SSubmitRsp*)res;
|
||||
if (pRsp->nBlocks <= 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -519,7 +514,7 @@ int32_t handleSubmitExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog
|
|||
taosArrayPush(pArray, &tbSver);
|
||||
}
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = *epset};
|
||||
|
@ -532,7 +527,7 @@ _return:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet *epset) {
|
||||
int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet* epset) {
|
||||
int32_t code = 0;
|
||||
SArray* pArray = NULL;
|
||||
SArray* pTbArray = (SArray*)res;
|
||||
|
@ -553,7 +548,7 @@ int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog,
|
|||
taosArrayPush(pArray, &tbSver);
|
||||
}
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = *epset};
|
||||
|
@ -575,15 +570,15 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCatalog* pCatalog = NULL;
|
||||
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
||||
SCatalog* pCatalog = NULL;
|
||||
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
||||
|
||||
int32_t code = catalogGetHandle(pAppInfo->clusterId, &pCatalog);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
SEpSet epset = getEpSet_s(&pAppInfo->mgmtEp);
|
||||
SEpSet epset = getEpSet_s(&pAppInfo->mgmtEp);
|
||||
SQueryExecRes* pRes = &pRequest->body.resInfo.execRes;
|
||||
|
||||
switch (pRes->msgType) {
|
||||
|
@ -601,8 +596,8 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) {
|
|||
break;
|
||||
}
|
||||
default:
|
||||
tscError("0x%"PRIx64", invalid exec result for request type %d, reqId:0x%"PRIx64, pRequest->self,
|
||||
pRequest->type, pRequest->requestId);
|
||||
tscError("0x%" PRIx64 ", invalid exec result for request type %d, reqId:0x%" PRIx64, pRequest->self,
|
||||
pRequest->type, pRequest->requestId);
|
||||
code = TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
|
@ -610,13 +605,13 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) {
|
|||
}
|
||||
|
||||
void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) {
|
||||
SRequestObj* pRequest = (SRequestObj*) param;
|
||||
SRequestObj* pRequest = (SRequestObj*)param;
|
||||
pRequest->code = code;
|
||||
|
||||
STscObj* pTscObj = pRequest->pTscObj;
|
||||
if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||
tscDebug("0x%"PRIx64" client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code),
|
||||
pRequest->retry, pRequest->requestId);
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64,
|
||||
pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||
pRequest->prevCode = code;
|
||||
doAsyncQuery(pRequest, true);
|
||||
return;
|
||||
|
@ -624,7 +619,7 @@ void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) {
|
|||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
code = handleQueryExecRsp(pRequest);
|
||||
ASSERT(pRequest->code == TSDB_CODE_SUCCESS);
|
||||
ASSERT(pRequest->code == TSDB_CODE_SUCCESS);
|
||||
pRequest->code = code;
|
||||
}
|
||||
|
||||
|
@ -727,35 +722,34 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = qCreateQueryPlan(&cxt, &pRequest->body.pDag, pNodeList);
|
||||
if (code) {
|
||||
tscError("0x%"PRIx64" failed to create query plan, code:%s 0x%"PRIx64, pRequest->self, tstrerror(code), pRequest->requestId);
|
||||
tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
}
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SRequestConnInfo conn = {.pTrans = pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self
|
||||
};
|
||||
SRequestConnInfo conn = {
|
||||
.pTrans = pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self};
|
||||
SSchedulerReq req = {.pConn = &conn,
|
||||
.pNodeList = pNodeList,
|
||||
.pDag = pRequest->body.pDag,
|
||||
.sql = pRequest->sqlstr,
|
||||
.startTs = pRequest->metric.start,
|
||||
.fp = schedulerExecCb,
|
||||
.cbParam = pRequest
|
||||
};
|
||||
.cbParam = pRequest};
|
||||
code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob);
|
||||
} else {
|
||||
tscError("0x%"PRIx64" failed to create query plan, code:%s 0x%"PRIx64, pRequest->self, tstrerror(code), pRequest->requestId);
|
||||
tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||
}
|
||||
|
||||
//todo not to be released here
|
||||
// todo not to be released here
|
||||
taosArrayDestroy(pNodeList);
|
||||
break;
|
||||
}
|
||||
case QUERY_EXEC_MODE_EMPTY_RESULT:
|
||||
pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
|
||||
pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
|
||||
pRequest->body.queryFp(pRequest->body.param, pRequest, 0);
|
||||
break;
|
||||
default:
|
||||
|
@ -786,7 +780,7 @@ int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest) {
|
|||
return code;
|
||||
}
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
|
@ -989,23 +983,22 @@ void updateTargetEpSet(SMsgSendInfo* pSendInfo, STscObj* pTscObj, SRpcMsg* pMsg,
|
|||
switch (pSendInfo->target.type) {
|
||||
case TARGET_TYPE_MNODE:
|
||||
if (NULL == pTscObj) {
|
||||
tscError("mnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64,
|
||||
TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId);
|
||||
tscError("mnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64,
|
||||
TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId);
|
||||
return;
|
||||
}
|
||||
|
||||
SEpSet* pOrig = &pTscObj->pAppInfo->mgmtEp.epSet;
|
||||
SEp* pOrigEp = &pOrig->eps[pOrig->inUse];
|
||||
SEp* pNewEp = &pEpSet->eps[pEpSet->inUse];
|
||||
tscDebug("mnode epset updated from %d/%d=>%s:%d to %d/%d=>%s:%d in client",
|
||||
pOrig->inUse, pOrig->numOfEps, pOrigEp->fqdn, pOrigEp->port,
|
||||
pEpSet->inUse, pEpSet->numOfEps, pNewEp->fqdn, pNewEp->port);
|
||||
SEp* pOrigEp = &pOrig->eps[pOrig->inUse];
|
||||
SEp* pNewEp = &pEpSet->eps[pEpSet->inUse];
|
||||
tscDebug("mnode epset updated from %d/%d=>%s:%d to %d/%d=>%s:%d in client", pOrig->inUse, pOrig->numOfEps,
|
||||
pOrigEp->fqdn, pOrigEp->port, pEpSet->inUse, pEpSet->numOfEps, pNewEp->fqdn, pNewEp->port);
|
||||
updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, pEpSet);
|
||||
break;
|
||||
case TARGET_TYPE_VNODE: {
|
||||
if (NULL == pTscObj) {
|
||||
tscError("vnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64,
|
||||
TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId);
|
||||
tscError("vnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64,
|
||||
TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1415,14 +1408,14 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
|||
p += sizeof(uint64_t);
|
||||
|
||||
// check fields
|
||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||
int16_t type = *(int16_t*) p;
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
int16_t type = *(int16_t*)p;
|
||||
p += sizeof(int16_t);
|
||||
|
||||
int32_t bytes = *(int32_t*) p;
|
||||
int32_t bytes = *(int32_t*)p;
|
||||
p += sizeof(int32_t);
|
||||
|
||||
// ASSERT(type == pFields[i].type && bytes == pFields[i].bytes);
|
||||
// ASSERT(type == pFields[i].type && bytes == pFields[i].bytes);
|
||||
}
|
||||
|
||||
int32_t* colLength = (int32_t*)p;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#define TSC_VAR_RELEASED 0
|
||||
|
||||
static int32_t sentinel = TSC_VAR_NOT_RELEASE;
|
||||
static int32_t createParseContext(const SRequestObj *pRequest, SParseContext** pCxt);
|
||||
static int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt);
|
||||
|
||||
int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
||||
static int32_t lock = 0;
|
||||
|
@ -177,8 +177,8 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
|||
return pResInfo->userFields;
|
||||
}
|
||||
|
||||
static void syncQueryFn(void* param, void* res, int32_t code) {
|
||||
SSyncQueryParam* pParam = param;
|
||||
static void syncQueryFn(void *param, void *res, int32_t code) {
|
||||
SSyncQueryParam *pParam = param;
|
||||
pParam->pRequest = res;
|
||||
pParam->pRequest->code = code;
|
||||
|
||||
|
@ -190,10 +190,10 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
STscObj* pTscObj = (STscObj*)taos;
|
||||
STscObj *pTscObj = (STscObj *)taos;
|
||||
|
||||
#if SYNC_ON_TOP_OF_ASYNC
|
||||
SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
||||
SSyncQueryParam *param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
||||
tsem_init(¶m->sem, 0, 0);
|
||||
|
||||
taos_query_a(pTscObj, sql, syncQueryFn, param);
|
||||
|
@ -606,16 +606,30 @@ const char *taos_get_server_info(TAOS *taos) {
|
|||
}
|
||||
|
||||
typedef struct SqlParseWrapper {
|
||||
SParseContext* pCtx;
|
||||
SParseContext *pCtx;
|
||||
SCatalogReq catalogReq;
|
||||
SRequestObj* pRequest;
|
||||
SQuery* pQuery;
|
||||
SRequestObj *pRequest;
|
||||
SQuery *pQuery;
|
||||
} SqlParseWrapper;
|
||||
|
||||
void retrieveMetaCallback(SMetaData* pResultMeta, void* param, int32_t code) {
|
||||
SqlParseWrapper *pWrapper = (SqlParseWrapper*) param;
|
||||
SQuery* pQuery = pWrapper->pQuery;
|
||||
SRequestObj* pRequest = pWrapper->pRequest;
|
||||
static void destorySqlParseWrapper(SqlParseWrapper *pWrapper) {
|
||||
taosArrayDestroy(pWrapper->catalogReq.pDbVgroup);
|
||||
taosArrayDestroy(pWrapper->catalogReq.pDbCfg);
|
||||
taosArrayDestroy(pWrapper->catalogReq.pDbInfo);
|
||||
taosArrayDestroy(pWrapper->catalogReq.pTableMeta);
|
||||
taosArrayDestroy(pWrapper->catalogReq.pTableHash);
|
||||
taosArrayDestroy(pWrapper->catalogReq.pUdf);
|
||||
taosArrayDestroy(pWrapper->catalogReq.pIndex);
|
||||
taosArrayDestroy(pWrapper->catalogReq.pUser);
|
||||
taosArrayDestroy(pWrapper->catalogReq.pTableIndex);
|
||||
taosMemoryFree(pWrapper->pCtx);
|
||||
taosMemoryFree(pWrapper);
|
||||
}
|
||||
|
||||
void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
|
||||
SqlParseWrapper *pWrapper = (SqlParseWrapper *)param;
|
||||
SQuery *pQuery = pWrapper->pQuery;
|
||||
SRequestObj *pRequest = pWrapper->pRequest;
|
||||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
code = qAnalyseSqlSemantic(pWrapper->pCtx, &pWrapper->catalogReq, pResultMeta, pQuery);
|
||||
|
@ -630,22 +644,22 @@ void retrieveMetaCallback(SMetaData* pResultMeta, void* param, int32_t code) {
|
|||
TSWAP(pRequest->dbList, (pQuery)->pDbList);
|
||||
TSWAP(pRequest->tableList, (pQuery)->pTableList);
|
||||
|
||||
taosMemoryFree(pWrapper);
|
||||
destorySqlParseWrapper(pWrapper);
|
||||
launchAsyncQuery(pRequest, pQuery);
|
||||
} else {
|
||||
destorySqlParseWrapper(pWrapper);
|
||||
tscDebug("error happens, code:%d", code);
|
||||
if (NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||
tscDebug("0x%"PRIx64" client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code),
|
||||
pRequest->retry, pRequest->requestId);
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64,
|
||||
pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||
pRequest->prevCode = code;
|
||||
doAsyncQuery(pRequest, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// return to app directly
|
||||
taosMemoryFree(pWrapper);
|
||||
tscError("0x%" PRIx64 " error occurs, code:%s, return to user app, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
tscError("0x%" PRIx64 " error occurs, code:%s, return to user app, reqId:0x%" PRIx64, pRequest->self,
|
||||
tstrerror(code), pRequest->requestId);
|
||||
pRequest->code = code;
|
||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||
}
|
||||
|
@ -670,7 +684,7 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
|
|||
}
|
||||
|
||||
SRequestObj *pRequest = NULL;
|
||||
int32_t code = buildRequest(taos, sql, sqlLen, &pRequest);
|
||||
int32_t code = buildRequest(taos, sql, sqlLen, &pRequest);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
terrno = code;
|
||||
fp(param, NULL, terrno);
|
||||
|
@ -678,11 +692,11 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
|
|||
}
|
||||
|
||||
pRequest->body.queryFp = fp;
|
||||
pRequest->body.param = param;
|
||||
pRequest->body.param = param;
|
||||
doAsyncQuery(pRequest, false);
|
||||
}
|
||||
|
||||
int32_t createParseContext(const SRequestObj *pRequest, SParseContext** pCxt) {
|
||||
int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) {
|
||||
const STscObj *pTscObj = pRequest->pTscObj;
|
||||
|
||||
*pCxt = taosMemoryCalloc(1, sizeof(SParseContext));
|
||||
|
@ -690,28 +704,30 @@ int32_t createParseContext(const SRequestObj *pRequest, SParseContext** pCxt) {
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
**pCxt = (SParseContext){.requestId = pRequest->requestId,
|
||||
.requestRid = pRequest->self,
|
||||
.acctId = pTscObj->acctId,
|
||||
.db = pRequest->pDb,
|
||||
.topicQuery = false,
|
||||
.pSql = pRequest->sqlstr,
|
||||
.sqlLen = pRequest->sqlLen,
|
||||
.pMsg = pRequest->msgBuf,
|
||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||
.pTransporter = pTscObj->pAppInfo->pTransporter,
|
||||
.pStmtCb = NULL,
|
||||
.pUser = pTscObj->user,
|
||||
.schemalessType = pTscObj->schemalessType,
|
||||
.isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)),
|
||||
.async = true,};
|
||||
**pCxt = (SParseContext){
|
||||
.requestId = pRequest->requestId,
|
||||
.requestRid = pRequest->self,
|
||||
.acctId = pTscObj->acctId,
|
||||
.db = pRequest->pDb,
|
||||
.topicQuery = false,
|
||||
.pSql = pRequest->sqlstr,
|
||||
.sqlLen = pRequest->sqlLen,
|
||||
.pMsg = pRequest->msgBuf,
|
||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||
.pTransporter = pTscObj->pAppInfo->pTransporter,
|
||||
.pStmtCb = NULL,
|
||||
.pUser = pTscObj->user,
|
||||
.schemalessType = pTscObj->schemalessType,
|
||||
.isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)),
|
||||
.async = true,
|
||||
};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void doAsyncQuery(SRequestObj* pRequest, bool updateMetaForce) {
|
||||
SParseContext* pCxt = NULL;
|
||||
STscObj *pTscObj = pRequest->pTscObj;
|
||||
int32_t code = 0;
|
||||
void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
||||
SParseContext *pCxt = NULL;
|
||||
STscObj *pTscObj = pRequest->pTscObj;
|
||||
int32_t code = 0;
|
||||
|
||||
if (pRequest->retry++ > REQUEST_TOTAL_EXEC_TIMES) {
|
||||
code = pRequest->prevCode;
|
||||
|
@ -748,28 +764,29 @@ void doAsyncQuery(SRequestObj* pRequest, bool updateMetaForce) {
|
|||
pWrapper->pRequest = pRequest;
|
||||
pWrapper->catalogReq = catalogReq;
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = pCxt->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pCxt->pTransporter,
|
||||
.requestId = pCxt->requestId,
|
||||
.requestObjRefId = pCxt->requestRid,
|
||||
.mgmtEps = pCxt->mgmtEpSet};
|
||||
|
||||
code = catalogAsyncGetAllMeta(pCxt->pCatalog, &conn, pRequest->requestId,
|
||||
&catalogReq, retrieveMetaCallback, pWrapper, &pRequest->body.queryJob);
|
||||
code = catalogAsyncGetAllMeta(pCxt->pCatalog, &conn, pRequest->requestId, &catalogReq, retrieveMetaCallback, pWrapper,
|
||||
&pRequest->body.queryJob);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
_error:
|
||||
tscError("0x%"PRIx64" error happens, code:%d - %s, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code), pRequest->requestId);
|
||||
_error:
|
||||
tscError("0x%" PRIx64 " error happens, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
terrno = code;
|
||||
pRequest->code = code;
|
||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||
}
|
||||
|
||||
static void fetchCallback(void* pResult, void* param, int32_t code) {
|
||||
SRequestObj* pRequest = (SRequestObj*) param;
|
||||
static void fetchCallback(void *pResult, void *param, int32_t code) {
|
||||
SRequestObj *pRequest = (SRequestObj *)param;
|
||||
|
||||
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
||||
SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
|
||||
|
||||
pResultInfo->pData = pResult;
|
||||
pResultInfo->numOfRows = 0;
|
||||
|
@ -785,7 +802,8 @@ static void fetchCallback(void* pResult, void* param, int32_t code) {
|
|||
return;
|
||||
}
|
||||
|
||||
pRequest->code = setQueryResultFromRsp(pResultInfo, (SRetrieveTableRsp*)pResultInfo->pData, pResultInfo->convertUcs4, false);
|
||||
pRequest->code =
|
||||
setQueryResultFromRsp(pResultInfo, (SRetrieveTableRsp *)pResultInfo->pData, pResultInfo->convertUcs4, false);
|
||||
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
||||
pResultInfo->numOfRows = 0;
|
||||
pRequest->code = code;
|
||||
|
@ -801,7 +819,7 @@ static void fetchCallback(void* pResult, void* param, int32_t code) {
|
|||
}
|
||||
|
||||
void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||
ASSERT (res != NULL && fp != NULL);
|
||||
ASSERT(res != NULL && fp != NULL);
|
||||
|
||||
SRequestObj *pRequest = res;
|
||||
pRequest->body.fetchFp = fp;
|
||||
|
@ -825,7 +843,7 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
|||
schedulerAsyncFetchRows(pRequest->body.queryJob, fetchCallback, pRequest);
|
||||
}
|
||||
|
||||
void taos_fetch_raw_block_a(TAOS_RES* res, __taos_async_fn_t fp, void* param) {
|
||||
void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||
ASSERT(res != NULL && fp != NULL);
|
||||
SRequestObj *pRequest = res;
|
||||
|
||||
|
@ -838,9 +856,9 @@ void taos_fetch_raw_block_a(TAOS_RES* res, __taos_async_fn_t fp, void* param) {
|
|||
taos_fetch_rows_a(res, fp, param);
|
||||
}
|
||||
|
||||
const void* taos_get_raw_block(TAOS_RES* res) {
|
||||
const void *taos_get_raw_block(TAOS_RES *res) {
|
||||
ASSERT(res != NULL);
|
||||
SRequestObj* pRequest = res;
|
||||
SRequestObj *pRequest = res;
|
||||
|
||||
return pRequest->body.resInfo.pData;
|
||||
}
|
||||
|
@ -924,26 +942,25 @@ int taos_stmt_set_tags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags) {
|
|||
return stmtSetTbTags(stmt, tags);
|
||||
}
|
||||
|
||||
|
||||
int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name) { return taos_stmt_set_tbname(stmt, name); }
|
||||
|
||||
int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int* fieldNum, TAOS_FIELD_E** fields) {
|
||||
int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields) {
|
||||
if (stmt == NULL || NULL == fieldNum) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
||||
return stmtGetTagFields(stmt, fieldNum, fields);
|
||||
}
|
||||
|
||||
int taos_stmt_get_col_fields(TAOS_STMT *stmt, int* fieldNum, TAOS_FIELD_E** fields) {
|
||||
int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields) {
|
||||
if (stmt == NULL || NULL == fieldNum) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
||||
return stmtGetColFields(stmt, fieldNum, fields);
|
||||
}
|
||||
|
||||
|
@ -1102,4 +1119,3 @@ int taos_stmt_close(TAOS_STMT *stmt) {
|
|||
|
||||
return stmtClose(stmt);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -692,6 +692,7 @@ int32_t tDeserializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq
|
|||
void tFreeSMAltertbReq(SMAlterStbReq *pReq) {
|
||||
taosArrayDestroy(pReq->pFields);
|
||||
pReq->pFields = NULL;
|
||||
taosMemoryFreeClear(pReq->comment);
|
||||
}
|
||||
|
||||
int32_t tSerializeSEpSet(void *buf, int32_t bufLen, const SEpSet *pEpset) {
|
||||
|
@ -4064,6 +4065,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
|||
if (tEncodeI32(&encoder, sqlLen) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, astLen) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->triggerType) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->maxDelay) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1;
|
||||
if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
||||
if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1;
|
||||
|
@ -4090,6 +4092,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
|
|||
if (tDecodeI32(&decoder, &sqlLen) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &astLen) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->triggerType) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->maxDelay) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1;
|
||||
|
||||
if (sqlLen > 0) {
|
||||
|
|
|
@ -77,7 +77,7 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
|
|||
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
||||
goto END;
|
||||
}
|
||||
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0);
|
||||
SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0);
|
||||
|
||||
int32_t opNum = LIST_LENGTH(inner->pNodeList);
|
||||
if (opNum != 1) {
|
||||
|
@ -85,7 +85,7 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
|
|||
goto END;
|
||||
}
|
||||
|
||||
SSubplan* plan = nodesListGetNode(inner->pNodeList, 0);
|
||||
SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0);
|
||||
if (qSubPlanToString(plan, pDst, pDstLen) < 0) {
|
||||
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
||||
goto END;
|
||||
|
@ -93,7 +93,7 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
|
|||
|
||||
END:
|
||||
if (pAst) nodesDestroyNode(pAst);
|
||||
if (pPlan) nodesDestroyNode(pPlan);
|
||||
if (pPlan) nodesDestroyNode((SNode*)pPlan);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
@ -378,8 +378,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
|||
SArray* taskInnerLevel = taosArrayInit(0, sizeof(void*));
|
||||
taosArrayPush(pStream->tasks, &taskInnerLevel);
|
||||
|
||||
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0);
|
||||
SSubplan* plan = nodesListGetNode(inner->pNodeList, 0);
|
||||
SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0);
|
||||
SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0);
|
||||
ASSERT(plan->subplanType == SUBPLAN_TYPE_MERGE);
|
||||
|
||||
pFinalTask = tNewSStreamTask(pStream->uid);
|
||||
|
@ -407,8 +407,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
|||
SArray* taskSourceLevel = taosArrayInit(0, sizeof(void*));
|
||||
taosArrayPush(pStream->tasks, &taskSourceLevel);
|
||||
|
||||
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 1);
|
||||
SSubplan* plan = nodesListGetNode(inner->pNodeList, 0);
|
||||
SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 1);
|
||||
SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0);
|
||||
ASSERT(plan->subplanType == SUBPLAN_TYPE_SCAN);
|
||||
|
||||
void* pIter = NULL;
|
||||
|
@ -449,9 +449,9 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
|||
SArray* taskOneLevel = taosArrayInit(0, sizeof(void*));
|
||||
taosArrayPush(pStream->tasks, &taskOneLevel);
|
||||
|
||||
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0);
|
||||
SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0);
|
||||
ASSERT(LIST_LENGTH(inner->pNodeList) == 1);
|
||||
SSubplan* plan = nodesListGetNode(inner->pNodeList, 0);
|
||||
SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0);
|
||||
ASSERT(plan->subplanType == SUBPLAN_TYPE_SCAN);
|
||||
|
||||
void* pIter = NULL;
|
||||
|
@ -509,7 +509,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
|
|||
return -1;
|
||||
}
|
||||
|
||||
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0);
|
||||
SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0);
|
||||
|
||||
int32_t opNum = LIST_LENGTH(inner->pNodeList);
|
||||
if (opNum != 1) {
|
||||
|
@ -517,7 +517,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
|
|||
terrno = TSDB_CODE_MND_INVALID_TOPIC_QUERY;
|
||||
return -1;
|
||||
}
|
||||
plan = nodesListGetNode(inner->pNodeList, 0);
|
||||
plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0);
|
||||
}
|
||||
|
||||
ASSERT(pSub->unassignedVgs);
|
||||
|
|
|
@ -235,10 +235,10 @@ static int32_t mndStreamGetPlanString(const char *ast, int8_t triggerType, int64
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesNodeToString(pPlan, false, pStr, NULL);
|
||||
code = nodesNodeToString((SNode*)pPlan, false, pStr, NULL);
|
||||
}
|
||||
nodesDestroyNode(pAst);
|
||||
nodesDestroyNode(pPlan);
|
||||
nodesDestroyNode((SNode*)pPlan);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -387,7 +387,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (nodesNodeToString(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());
|
||||
taosMemoryFree(topicObj.ast);
|
||||
taosMemoryFree(topicObj.sql);
|
||||
|
|
|
@ -211,7 +211,7 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo
|
|||
SExplainResNode *pResNode = NULL;
|
||||
FOREACH(node, pPhysiChildren) {
|
||||
QRY_ERR_RET(qExplainGenerateResNode((SPhysiNode *)node, group, &pResNode));
|
||||
QRY_ERR_RET(nodesListAppend(*pChildren, pResNode));
|
||||
QRY_ERR_RET(nodesListAppend(*pChildren, (SNode*)pResNode));
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -715,7 +715,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
EXPLAIN_ROW_NEW(level + 1, "Sort Key: ");
|
||||
if (pResNode->pExecInfo) {
|
||||
for (int32_t i = 0; i < LIST_LENGTH(pSortNode->pSortKeys); ++i) {
|
||||
SOrderByExprNode *ptn = nodesListGetNode(pSortNode->pSortKeys, i);
|
||||
SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pSortNode->pSortKeys, i);
|
||||
EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr));
|
||||
}
|
||||
}
|
||||
|
@ -1039,7 +1039,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
EXPLAIN_ROW_NEW(level + 1, "Merge Key: ");
|
||||
if (pResNode->pExecInfo) {
|
||||
for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) {
|
||||
SOrderByExprNode *ptn = nodesListGetNode(pMergeNode->pMergeKeys, i);
|
||||
SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pMergeNode->pMergeKeys, i);
|
||||
EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr));
|
||||
}
|
||||
}
|
||||
|
@ -1078,7 +1078,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
|
||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_MERGE_KEYS_FORMAT);
|
||||
for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) {
|
||||
SOrderByExprNode *ptn = nodesListGetNode(pMergeNode->pMergeKeys, i);
|
||||
SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pMergeNode->pMergeKeys, i);
|
||||
EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr));
|
||||
}
|
||||
EXPLAIN_ROW_END();
|
||||
|
|
|
@ -202,7 +202,7 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) {
|
|||
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData idata = {{0}};
|
||||
SSlotDescNode* pDescNode = nodesListGetNode(pNode->pSlots, i);
|
||||
SSlotDescNode* pDescNode = (SSlotDescNode*)nodesListGetNode(pNode->pSlots, i);
|
||||
// if (!pDescNode->output) { // todo disable it temporarily
|
||||
// continue;
|
||||
// }
|
||||
|
@ -2920,7 +2920,7 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo*
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < numOfSources; ++i) {
|
||||
SNodeListNode* pNode = nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i);
|
||||
SNodeListNode* pNode = (SNodeListNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i);
|
||||
taosArrayPush(pInfo->pSources, pNode);
|
||||
}
|
||||
|
||||
|
@ -4494,7 +4494,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
if (NULL == res) { // todo handle error
|
||||
} else {
|
||||
res->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT};
|
||||
nodesListAppend(pFuncNode->pParameterList, res);
|
||||
nodesListAppend(pFuncNode->pParameterList, (SNode*)res);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1378,7 +1378,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param, int32_t numOfOutput) {
|
|||
taosMemoryFreeClear(pChildOp);
|
||||
}
|
||||
}
|
||||
nodesDestroyNode(pInfo->pPhyNode);
|
||||
nodesDestroyNode((SNode*)pInfo->pPhyNode);
|
||||
}
|
||||
|
||||
static bool allInvertible(SqlFunctionCtx* pFCtx, int32_t numOfCols) {
|
||||
|
@ -2157,7 +2157,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
|||
pInfo->pUpdateRes = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
pInfo->pUpdateRes->info.type = STREAM_REPROCESS;
|
||||
blockDataEnsureCapacity(pInfo->pUpdateRes, 128);
|
||||
pInfo->pPhyNode = nodesCloneNode(pPhyNode);
|
||||
pInfo->pPhyNode = (SPhysiNode*)nodesCloneNode((SNode*)pPhyNode);
|
||||
|
||||
pOperator->name = "StreamFinalIntervalOperator";
|
||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL;
|
||||
|
|
|
@ -42,6 +42,7 @@ extern "C" {
|
|||
#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_FORBID_FILL_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(15)
|
||||
#define FUNC_MGT_FORBID_STREAM_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(16)
|
||||
|
||||
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
||||
|
||||
|
|
|
@ -1274,7 +1274,7 @@ void static addTimezoneParam(SNodeList* pList) {
|
|||
varDataSetLen(pVal->datum.p, len);
|
||||
strncpy(varDataVal(pVal->datum.p), pVal->literal, len);
|
||||
|
||||
nodesListAppend(pList, pVal);
|
||||
nodesListAppend(pList, (SNode*)pVal);
|
||||
}
|
||||
|
||||
static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
|
@ -1363,7 +1363,7 @@ static int32_t translateToJson(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
SExprNode* pPara = nodesListGetNode(pFunc->pParameterList, 0);
|
||||
SExprNode* pPara = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||
if (QUERY_NODE_VALUE != nodeType(pPara) || (!IS_VAR_DATA_TYPE(pPara->resType.type))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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 fmIsForbidStreamFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_FORBID_STREAM_FUNC); }
|
||||
|
||||
void fmFuncMgtDestroy() {
|
||||
void* m = gFunMgtService.pFuncNameHashTable;
|
||||
if (m != NULL && atomic_val_compare_exchange_ptr((void**)&gFunMgtService.pFuncNameHashTable, m, 0) == m) {
|
||||
|
@ -239,7 +241,7 @@ static int32_t getFuncInfo(SFunctionNode* pFunc) {
|
|||
}
|
||||
|
||||
static SFunctionNode* createFunction(const char* pName, SNodeList* pParameterList) {
|
||||
SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pFunc) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -247,14 +249,14 @@ static SFunctionNode* createFunction(const char* pName, SNodeList* pParameterLis
|
|||
pFunc->pParameterList = pParameterList;
|
||||
if (TSDB_CODE_SUCCESS != getFuncInfo(pFunc)) {
|
||||
pFunc->pParameterList = NULL;
|
||||
nodesDestroyNode(pFunc);
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
return NULL;
|
||||
}
|
||||
return pFunc;
|
||||
}
|
||||
|
||||
static SColumnNode* createColumnByFunc(const SFunctionNode* pFunc) {
|
||||
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -291,7 +293,7 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod
|
|||
static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctionNode* pPartialFunc,
|
||||
SFunctionNode** pMergeFunc) {
|
||||
SNodeList* pParameterList = NULL;
|
||||
nodesListMakeStrictAppend(&pParameterList, createColumnByFunc(pPartialFunc));
|
||||
nodesListMakeStrictAppend(&pParameterList, (SNode*)createColumnByFunc(pPartialFunc));
|
||||
*pMergeFunc = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pParameterList);
|
||||
if (NULL == *pMergeFunc) {
|
||||
nodesDestroyList(pParameterList);
|
||||
|
@ -316,8 +318,8 @@ int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode(*pPartialFunc);
|
||||
nodesDestroyNode(*pMergeFunc);
|
||||
nodesDestroyNode((SNode*)*pPartialFunc);
|
||||
nodesDestroyNode((SNode*)*pMergeFunc);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
break; \
|
||||
} \
|
||||
(pDst)->fldname = strdup((pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CLONE_NODE_FIELD(fldname) \
|
||||
|
@ -49,11 +53,23 @@
|
|||
} \
|
||||
(pDst)->fldname = nodesCloneNode((pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
nodesDestroyNode((SNode*)(pDst)); \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CLONE_NODE_FIELD_EX(fldname, nodePtrType) \
|
||||
do { \
|
||||
if (NULL == (pSrc)->fldname) { \
|
||||
break; \
|
||||
} \
|
||||
(pDst)->fldname = (nodePtrType)nodesCloneNode((SNode*)(pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CLONE_NODE_LIST_FIELD(fldname) \
|
||||
do { \
|
||||
if (NULL == (pSrc)->fldname) { \
|
||||
|
@ -61,7 +77,7 @@
|
|||
} \
|
||||
(pDst)->fldname = nodesCloneList((pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
nodesDestroyNode((SNode*)(pDst)); \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -73,7 +89,7 @@
|
|||
} \
|
||||
(pDst)->fldname = cloneFunc((pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
nodesDestroyNode((SNode*)(pDst)); \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -81,6 +97,7 @@
|
|||
#define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \
|
||||
do { \
|
||||
if (NULL == copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \
|
||||
nodesDestroyNode((SNode*)pDst); \
|
||||
return NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -147,7 +164,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
|||
int32_t len = varDataTLen(pSrc->datum.p) + 1;
|
||||
pDst->datum.p = taosMemoryCalloc(1, len);
|
||||
if (NULL == pDst->datum.p) {
|
||||
nodesDestroyNode(pDst);
|
||||
nodesDestroyNode((SNode*)pDst);
|
||||
return NULL;
|
||||
}
|
||||
memcpy(pDst->datum.p, pSrc->datum.p, len);
|
||||
|
@ -275,8 +292,8 @@ static SNode* stateWindowNodeCopy(const SStateWindowNode* pSrc, SStateWindowNode
|
|||
}
|
||||
|
||||
static SNode* sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) {
|
||||
CLONE_NODE_FIELD(pCol);
|
||||
CLONE_NODE_FIELD(pGap);
|
||||
CLONE_NODE_FIELD_EX(pCol, SColumnNode*);
|
||||
CLONE_NODE_FIELD_EX(pGap, SValueNode*);
|
||||
return (SNode*)pDst;
|
||||
}
|
||||
|
||||
|
@ -442,7 +459,7 @@ static SNode* logicIndefRowsFuncCopy(const SIndefRowsFuncLogicNode* pSrc, SIndef
|
|||
|
||||
static SNode* logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) {
|
||||
COPY_OBJECT_FIELD(id, sizeof(SSubplanId));
|
||||
CLONE_NODE_FIELD(pNode);
|
||||
CLONE_NODE_FIELD_EX(pNode, SLogicNode*);
|
||||
COPY_SCALAR_FIELD(subplanType);
|
||||
COPY_SCALAR_FIELD(level);
|
||||
COPY_SCALAR_FIELD(splitFlag);
|
||||
|
@ -450,7 +467,7 @@ static SNode* logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) {
|
|||
}
|
||||
|
||||
static SNode* physiNodeCopy(const SPhysiNode* pSrc, SPhysiNode* pDst) {
|
||||
CLONE_NODE_FIELD(pOutputDataBlockDesc);
|
||||
CLONE_NODE_FIELD_EX(pOutputDataBlockDesc, SDataBlockDescNode*);
|
||||
CLONE_NODE_FIELD(pConditions);
|
||||
CLONE_NODE_LIST_FIELD(pChildren);
|
||||
return (SNode*)pDst;
|
||||
|
@ -555,8 +572,8 @@ static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) {
|
|||
CLONE_NODE_LIST_FIELD(pGroupByList);
|
||||
CLONE_NODE_FIELD(pHaving);
|
||||
CLONE_NODE_LIST_FIELD(pOrderByList);
|
||||
CLONE_NODE_FIELD(pLimit);
|
||||
CLONE_NODE_FIELD(pLimit);
|
||||
CLONE_NODE_FIELD_EX(pLimit, SLimitNode*);
|
||||
CLONE_NODE_FIELD_EX(pLimit, SLimitNode*);
|
||||
COPY_CHAR_ARRAY_FIELD(stmtName);
|
||||
COPY_SCALAR_FIELD(precision);
|
||||
COPY_SCALAR_FIELD(isEmptyResult);
|
||||
|
@ -566,7 +583,7 @@ static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) {
|
|||
return (SNode*)pDst;
|
||||
}
|
||||
|
||||
SNodeptr nodesCloneNode(const SNodeptr pNode) {
|
||||
SNode* nodesCloneNode(const SNode* pNode) {
|
||||
if (NULL == pNode) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -4205,7 +4205,7 @@ static int32_t jsonToNodeObject(const SJson* pJson, const char* pName, SNode** p
|
|||
return makeNodeByJson(pJsonNode, pNode);
|
||||
}
|
||||
|
||||
int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen) {
|
||||
int32_t nodesNodeToString(const SNode* pNode, bool format, char** pStr, int32_t* pLen) {
|
||||
if (NULL == pNode || NULL == pStr) {
|
||||
terrno = TSDB_CODE_FAILED;
|
||||
return TSDB_CODE_FAILED;
|
||||
|
|
|
@ -137,7 +137,7 @@ static bool functionNodeEqual(const SFunctionNode* a, const SFunctionNode* b) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool nodesEqualNode(const SNodeptr a, const SNodeptr b) {
|
||||
bool nodesEqualNode(const SNode* a, const SNode* b) {
|
||||
if (a == b) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ static EDealRes walkExprs(SNodeList* pNodeList, ETraversalOrder order, FNodeWalk
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
void nodesWalkExpr(SNodeptr pNode, FNodeWalker walker, void* pContext) {
|
||||
void nodesWalkExpr(SNode* pNode, FNodeWalker walker, void* pContext) {
|
||||
(void)walkExpr(pNode, TRAVERSAL_PREORDER, walker, pContext);
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ void nodesWalkExprs(SNodeList* pNodeList, FNodeWalker walker, void* pContext) {
|
|||
(void)walkExprs(pNodeList, TRAVERSAL_PREORDER, walker, pContext);
|
||||
}
|
||||
|
||||
void nodesWalkExprPostOrder(SNodeptr pNode, FNodeWalker walker, void* pContext) {
|
||||
void nodesWalkExprPostOrder(SNode* pNode, FNodeWalker walker, void* pContext) {
|
||||
(void)walkExpr(pNode, TRAVERSAL_POSTORDER, walker, pContext);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ static SNode* makeNode(ENodeType type, size_t size) {
|
|||
return p;
|
||||
}
|
||||
|
||||
SNodeptr nodesMakeNode(ENodeType type) {
|
||||
SNode* nodesMakeNode(ENodeType type) {
|
||||
switch (type) {
|
||||
case QUERY_NODE_COLUMN:
|
||||
return makeNode(type, sizeof(SColumnNode));
|
||||
|
@ -215,6 +215,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
return makeNode(type, sizeof(SKillStmt));
|
||||
case QUERY_NODE_DELETE_STMT:
|
||||
return makeNode(type, sizeof(SDeleteStmt));
|
||||
case QUERY_NODE_QUERY:
|
||||
return makeNode(type, sizeof(SQuery));
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
return makeNode(type, sizeof(SScanLogicNode));
|
||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||
|
@ -325,7 +327,7 @@ static void destroyLogicNode(SLogicNode* pNode) {
|
|||
static void destroyPhysiNode(SPhysiNode* pNode) {
|
||||
nodesDestroyList(pNode->pChildren);
|
||||
nodesDestroyNode(pNode->pConditions);
|
||||
nodesDestroyNode(pNode->pOutputDataBlockDesc);
|
||||
nodesDestroyNode((SNode*)pNode->pOutputDataBlockDesc);
|
||||
}
|
||||
|
||||
static void destroyWinodwPhysiNode(SWinodwPhysiNode* pNode) {
|
||||
|
@ -340,9 +342,9 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) {
|
|||
nodesDestroyList(pNode->pScanCols);
|
||||
}
|
||||
|
||||
static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode(pNode->pInputDataBlockDesc); }
|
||||
static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode((SNode*)pNode->pInputDataBlockDesc); }
|
||||
|
||||
void nodesDestroyNode(SNodeptr pNode) {
|
||||
void nodesDestroyNode(SNode* pNode) {
|
||||
if (NULL == pNode) {
|
||||
return;
|
||||
}
|
||||
|
@ -399,8 +401,8 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
break;
|
||||
case QUERY_NODE_SESSION_WINDOW: {
|
||||
SSessionWindowNode* pSession = (SSessionWindowNode*)pNode;
|
||||
nodesDestroyNode(pSession->pCol);
|
||||
nodesDestroyNode(pSession->pGap);
|
||||
nodesDestroyNode((SNode*)pSession->pCol);
|
||||
nodesDestroyNode((SNode*)pSession->pGap);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_INTERVAL_WINDOW: {
|
||||
|
@ -436,7 +438,7 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
break;
|
||||
case QUERY_NODE_DATABASE_OPTIONS: {
|
||||
SDatabaseOptions* pOptions = (SDatabaseOptions*)pNode;
|
||||
nodesDestroyNode(pOptions->pDaysPerFile);
|
||||
nodesDestroyNode((SNode*)pOptions->pDaysPerFile);
|
||||
nodesDestroyList(pOptions->pKeep);
|
||||
nodesDestroyList(pOptions->pRetentions);
|
||||
break;
|
||||
|
@ -455,6 +457,13 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
nodesDestroyNode(pOptions->pSliding);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_EXPLAIN_OPTIONS: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_STREAM_OPTIONS:
|
||||
nodesDestroyNode(((SStreamOptions*)pNode)->pWatermark);
|
||||
break;
|
||||
case QUERY_NODE_LEFT_VALUE: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_SET_OPERATOR: {
|
||||
SSetOperator* pStmt = (SSetOperator*)pNode;
|
||||
nodesDestroyNode(pStmt->pLeft);
|
||||
|
@ -473,26 +482,26 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
nodesDestroyList(pStmt->pGroupByList);
|
||||
nodesDestroyNode(pStmt->pHaving);
|
||||
nodesDestroyList(pStmt->pOrderByList);
|
||||
nodesDestroyNode(pStmt->pLimit);
|
||||
nodesDestroyNode(pStmt->pSlimit);
|
||||
nodesDestroyNode((SNode*)pStmt->pLimit);
|
||||
nodesDestroyNode((SNode*)pStmt->pSlimit);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_VNODE_MODIF_STMT:
|
||||
destroyVgDataBlockArray(((SVnodeModifOpStmt*)pNode)->pDataBlocks);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_DATABASE_STMT:
|
||||
nodesDestroyNode(((SCreateDatabaseStmt*)pNode)->pOptions);
|
||||
nodesDestroyNode((SNode*)((SCreateDatabaseStmt*)pNode)->pOptions);
|
||||
break;
|
||||
case QUERY_NODE_DROP_DATABASE_STMT: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_ALTER_DATABASE_STMT:
|
||||
nodesDestroyNode(((SAlterDatabaseStmt*)pNode)->pOptions);
|
||||
nodesDestroyNode((SNode*)((SAlterDatabaseStmt*)pNode)->pOptions);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_TABLE_STMT: {
|
||||
SCreateTableStmt* pStmt = (SCreateTableStmt*)pNode;
|
||||
nodesDestroyList(pStmt->pCols);
|
||||
nodesDestroyList(pStmt->pTags);
|
||||
nodesDestroyNode(pStmt->pOptions);
|
||||
nodesDestroyNode((SNode*)pStmt->pOptions);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_CREATE_SUBTABLE_CLAUSE: {
|
||||
|
@ -507,14 +516,14 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
case QUERY_NODE_DROP_TABLE_CLAUSE: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_DROP_TABLE_STMT:
|
||||
nodesDestroyNode(((SDropTableStmt*)pNode)->pTables);
|
||||
nodesDestroyList(((SDropTableStmt*)pNode)->pTables);
|
||||
break;
|
||||
case QUERY_NODE_DROP_SUPER_TABLE_STMT: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_ALTER_TABLE_STMT: {
|
||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)pNode;
|
||||
nodesDestroyNode(pStmt->pOptions);
|
||||
nodesDestroyNode(pStmt->pVal);
|
||||
nodesDestroyNode((SNode*)pStmt->pOptions);
|
||||
nodesDestroyNode((SNode*)pStmt->pVal);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_CREATE_USER_STMT: // no pointer field
|
||||
|
@ -527,37 +536,107 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
break;
|
||||
case QUERY_NODE_CREATE_INDEX_STMT: {
|
||||
SCreateIndexStmt* pStmt = (SCreateIndexStmt*)pNode;
|
||||
nodesDestroyNode(pStmt->pOptions);
|
||||
nodesDestroyNode((SNode*)pStmt->pOptions);
|
||||
nodesDestroyList(pStmt->pCols);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_DROP_INDEX_STMT: // no pointer field
|
||||
case QUERY_NODE_CREATE_QNODE_STMT: // no pointer field
|
||||
case QUERY_NODE_DROP_QNODE_STMT: // no pointer field
|
||||
case QUERY_NODE_CREATE_BNODE_STMT: // no pointer field
|
||||
case QUERY_NODE_DROP_BNODE_STMT: // no pointer field
|
||||
case QUERY_NODE_CREATE_SNODE_STMT: // no pointer field
|
||||
case QUERY_NODE_DROP_SNODE_STMT: // no pointer field
|
||||
case QUERY_NODE_CREATE_MNODE_STMT: // no pointer field
|
||||
case QUERY_NODE_DROP_MNODE_STMT: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_CREATE_TOPIC_STMT:
|
||||
nodesDestroyNode(((SCreateTopicStmt*)pNode)->pQuery);
|
||||
break;
|
||||
case QUERY_NODE_DROP_TOPIC_STMT: // no pointer field
|
||||
case QUERY_NODE_DROP_CGROUP_STMT: // no pointer field
|
||||
case QUERY_NODE_ALTER_LOCAL_STMT: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
case QUERY_NODE_EXPLAIN_STMT: {
|
||||
SExplainStmt* pStmt = (SExplainStmt*)pNode;
|
||||
nodesDestroyNode((SNode*)pStmt->pOptions);
|
||||
nodesDestroyNode(pStmt->pQuery);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_DESCRIBE_STMT:
|
||||
taosMemoryFree(((SDescribeStmt*)pNode)->pMeta);
|
||||
break;
|
||||
case QUERY_NODE_RESET_QUERY_CACHE_STMT: // no pointer field
|
||||
case QUERY_NODE_COMPACT_STMT: // no pointer field
|
||||
case QUERY_NODE_CREATE_FUNCTION_STMT: // no pointer field
|
||||
case QUERY_NODE_DROP_FUNCTION_STMT: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_CREATE_STREAM_STMT: {
|
||||
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pNode;
|
||||
nodesDestroyNode((SNode*)pStmt->pOptions);
|
||||
nodesDestroyNode(pStmt->pQuery);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_DROP_STREAM_STMT: // no pointer field
|
||||
case QUERY_NODE_BALANCE_VGROUP_STMT: // no pointer field
|
||||
case QUERY_NODE_MERGE_VGROUP_STMT: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT:
|
||||
nodesDestroyList(((SRedistributeVgroupStmt*)pNode)->pDnodes);
|
||||
break;
|
||||
case QUERY_NODE_SPLIT_VGROUP_STMT: // no pointer field
|
||||
case QUERY_NODE_SYNCDB_STMT: // no pointer field
|
||||
case QUERY_NODE_GRANT_STMT: // no pointer field
|
||||
case QUERY_NODE_REVOKE_STMT: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
case QUERY_NODE_SHOW_FUNCTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_INDEXES_STMT:
|
||||
case QUERY_NODE_SHOW_STREAMS_STMT: {
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIBES_STMT:
|
||||
case QUERY_NODE_SHOW_SMAS_STMT:
|
||||
case QUERY_NODE_SHOW_CONFIGS_STMT:
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||
case QUERY_NODE_SHOW_APPS_STMT:
|
||||
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT: {
|
||||
SShowStmt* pStmt = (SShowStmt*)pNode;
|
||||
nodesDestroyNode(pStmt->pDbName);
|
||||
nodesDestroyNode(pStmt->pTbNamePattern);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_KILL_CONNECTION_STMT: // no pointer field
|
||||
case QUERY_NODE_KILL_QUERY_STMT: // no pointer field
|
||||
case QUERY_NODE_KILL_TRANSACTION_STMT: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_DELETE_STMT: {
|
||||
SDeleteStmt* pStmt = (SDeleteStmt*)pNode;
|
||||
nodesDestroyNode(pStmt->pFromTable);
|
||||
nodesDestroyNode(pStmt->pWhere);
|
||||
nodesDestroyNode(pStmt->pCountFunc);
|
||||
nodesDestroyNode(pStmt->pTagIndexCond);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_QUERY: {
|
||||
SQuery* pQuery = (SQuery*)pNode;
|
||||
nodesDestroyNode(pQuery->pRoot);
|
||||
|
@ -606,6 +685,13 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||
destroyLogicNode((SLogicNode*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_MERGE: {
|
||||
SMergeLogicNode* pLogicNode = (SMergeLogicNode*)pNode;
|
||||
destroyLogicNode((SLogicNode*)pLogicNode);
|
||||
nodesDestroyList(pLogicNode->pMergeKeys);
|
||||
nodesDestroyList(pLogicNode->pInputs);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_LOGIC_PLAN_WINDOW: {
|
||||
SWindowLogicNode* pLogicNode = (SWindowLogicNode*)pNode;
|
||||
destroyLogicNode((SLogicNode*)pLogicNode);
|
||||
|
@ -613,6 +699,13 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
nodesDestroyNode(pLogicNode->pTspk);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_LOGIC_PLAN_FILL: {
|
||||
SFillLogicNode* pLogicNode = (SFillLogicNode*)pNode;
|
||||
destroyLogicNode((SLogicNode*)pLogicNode);
|
||||
nodesDestroyNode(pLogicNode->pWStartTs);
|
||||
nodesDestroyNode(pLogicNode->pValues);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_LOGIC_PLAN_SORT: {
|
||||
SSortLogicNode* pLogicNode = (SSortLogicNode*)pNode;
|
||||
destroyLogicNode((SLogicNode*)pLogicNode);
|
||||
|
@ -625,10 +718,16 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
nodesDestroyList(pLogicNode->pPartitionKeys);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC: {
|
||||
SIndefRowsFuncLogicNode* pLogicNode = (SIndefRowsFuncLogicNode*)pNode;
|
||||
destroyLogicNode((SLogicNode*)pLogicNode);
|
||||
nodesDestroyList(pLogicNode->pVectorFuncs);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_LOGIC_SUBPLAN: {
|
||||
SLogicSubplan* pSubplan = (SLogicSubplan*)pNode;
|
||||
nodesDestroyList(pSubplan->pChildren);
|
||||
nodesDestroyNode(pSubplan->pNode);
|
||||
nodesDestroyNode((SNode*)pSubplan->pNode);
|
||||
nodesClearList(pSubplan->pParents);
|
||||
taosMemoryFreeClear(pSubplan->pVgroupList);
|
||||
break;
|
||||
|
@ -637,17 +736,9 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
nodesDestroyList(((SQueryLogicPlan*)pNode)->pTopSubplans);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
||||
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
|
||||
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
|
||||
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
|
||||
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
||||
break;
|
||||
|
@ -678,21 +769,62 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
nodesDestroyList(pPhyNode->pSrcEndPoints);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE: {
|
||||
SMergePhysiNode* pPhyNode = (SMergePhysiNode*)pNode;
|
||||
destroyPhysiNode((SPhysiNode*)pPhyNode);
|
||||
nodesDestroyList(pPhyNode->pMergeKeys);
|
||||
nodesDestroyList(pPhyNode->pTargets);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_SORT: {
|
||||
SSortPhysiNode* pPhyNode = (SSortPhysiNode*)pNode;
|
||||
destroyPhysiNode((SPhysiNode*)pPhyNode);
|
||||
nodesDestroyNode(pPhyNode->pExprs);
|
||||
nodesDestroyNode(pPhyNode->pSortKeys);
|
||||
nodesDestroyList(pPhyNode->pExprs);
|
||||
nodesDestroyList(pPhyNode->pSortKeys);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL:
|
||||
destroyWinodwPhysiNode((SWinodwPhysiNode*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_FILL: {
|
||||
SFillPhysiNode* pPhyNode = (SFillPhysiNode*)pNode;
|
||||
destroyPhysiNode((SPhysiNode*)pPhyNode);
|
||||
nodesDestroyNode(pPhyNode->pWStartTs);
|
||||
nodesDestroyNode(pPhyNode->pValues);
|
||||
nodesDestroyList(pPhyNode->pTargets);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION:
|
||||
destroyWinodwPhysiNode((SWinodwPhysiNode*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE: {
|
||||
SStateWinodwPhysiNode* pPhyNode = (SStateWinodwPhysiNode*)pNode;
|
||||
destroyWinodwPhysiNode((SWinodwPhysiNode*)pPhyNode);
|
||||
nodesDestroyNode(pPhyNode->pStateKey);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION: {
|
||||
SPartitionPhysiNode* pPhyNode = (SPartitionPhysiNode*)pNode;
|
||||
destroyPhysiNode((SPhysiNode*)pPhyNode);
|
||||
nodesDestroyList(pPhyNode->pExprs);
|
||||
nodesDestroyList(pPhyNode->pPartitionKeys);
|
||||
nodesDestroyList(pPhyNode->pTargets);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: {
|
||||
SIndefRowsFuncPhysiNode* pPhyNode = (SIndefRowsFuncPhysiNode*)pNode;
|
||||
destroyPhysiNode((SPhysiNode*)pPhyNode);
|
||||
nodesDestroyList(pPhyNode->pExprs);
|
||||
nodesDestroyList(pPhyNode->pVectorFuncs);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||
destroyDataSinkNode((SDataSinkNode*)pNode);
|
||||
break;
|
||||
|
@ -702,11 +834,17 @@ void nodesDestroyNode(SNodeptr pNode) {
|
|||
taosMemoryFreeClear(pSink->pData);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_DELETE: {
|
||||
SDataDeleterNode* pSink = (SDataDeleterNode*)pNode;
|
||||
destroyDataSinkNode((SDataSinkNode*)pSink);
|
||||
nodesDestroyNode(pSink->pAffectedRows);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_SUBPLAN: {
|
||||
SSubplan* pSubplan = (SSubplan*)pNode;
|
||||
nodesDestroyList(pSubplan->pChildren);
|
||||
nodesDestroyNode(pSubplan->pNode);
|
||||
nodesDestroyNode(pSubplan->pDataSink);
|
||||
nodesDestroyNode((SNode*)pSubplan->pNode);
|
||||
nodesDestroyNode((SNode*)pSubplan->pDataSink);
|
||||
nodesClearList(pSubplan->pParents);
|
||||
break;
|
||||
}
|
||||
|
@ -744,7 +882,7 @@ SNodeList* nodesMakeList() {
|
|||
return p;
|
||||
}
|
||||
|
||||
int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) {
|
||||
int32_t nodesListAppend(SNodeList* pList, SNode* pNode) {
|
||||
if (NULL == pList || NULL == pNode) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -766,7 +904,7 @@ int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode) {
|
||||
int32_t nodesListStrictAppend(SNodeList* pList, SNode* pNode) {
|
||||
if (NULL == pNode) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -778,7 +916,7 @@ int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode) {
|
||||
int32_t nodesListMakeAppend(SNodeList** pList, SNode* pNode) {
|
||||
if (NULL == *pList) {
|
||||
*pList = nodesMakeList();
|
||||
if (NULL == *pList) {
|
||||
|
@ -789,7 +927,7 @@ int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode) {
|
|||
return nodesListAppend(*pList, pNode);
|
||||
}
|
||||
|
||||
int32_t nodesListMakeStrictAppend(SNodeList** pList, SNodeptr pNode) {
|
||||
int32_t nodesListMakeStrictAppend(SNodeList** pList, SNode* pNode) {
|
||||
if (NULL == *pList) {
|
||||
*pList = nodesMakeList();
|
||||
if (NULL == *pList) {
|
||||
|
@ -831,7 +969,7 @@ int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode) {
|
||||
int32_t nodesListPushFront(SNodeList* pList, SNode* pNode) {
|
||||
if (NULL == pList || NULL == pNode) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -886,7 +1024,7 @@ void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc) {
|
|||
taosMemoryFreeClear(pSrc);
|
||||
}
|
||||
|
||||
SNodeptr nodesListGetNode(SNodeList* pList, int32_t index) {
|
||||
SNode* nodesListGetNode(SNodeList* pList, int32_t index) {
|
||||
SNode* node;
|
||||
FOREACH(node, pList) {
|
||||
if (0 == index--) {
|
||||
|
@ -1420,7 +1558,7 @@ int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc) {
|
|||
*pDst = nodesListGetNode(*pSrc, 0);
|
||||
nodesClearList(*pSrc);
|
||||
} else {
|
||||
SLogicConditionNode* pLogicCond = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SLogicConditionNode* pLogicCond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
if (NULL == pLogicCond) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -27,12 +27,12 @@ extern "C" {
|
|||
#define QUERY_SMA_OPTIMIZE_DISABLE 0
|
||||
#define QUERY_SMA_OPTIMIZE_ENABLE 1
|
||||
|
||||
int32_t parseInsertSyntax(SParseContext* pContext, SQuery** pQuery);
|
||||
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery);
|
||||
int32_t parseInsertSyntax(SParseContext* pContext, SQuery** pQuery, SParseMetaCache* pMetaCache);
|
||||
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache* pMetaCache);
|
||||
int32_t parse(SParseContext* pParseCxt, SQuery** pQuery);
|
||||
int32_t collectMetaKey(SParseContext* pParseCxt, SQuery* pQuery);
|
||||
int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery);
|
||||
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery);
|
||||
int32_t collectMetaKey(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache);
|
||||
int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache);
|
||||
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache);
|
||||
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
||||
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery);
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con
|
|||
bool* pPass);
|
||||
int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFuncInfo* pInfo);
|
||||
int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes);
|
||||
void destoryParseMetaCache(SParseMetaCache* pMetaCache);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -461,6 +461,7 @@ into_opt(A) ::= INTO full_table_name(B).
|
|||
stream_options(A) ::= . { A = createStreamOptions(pCxt); }
|
||||
stream_options(A) ::= stream_options(B) TRIGGER AT_ONCE. { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_AT_ONCE; A = B; }
|
||||
stream_options(A) ::= stream_options(B) TRIGGER WINDOW_CLOSE. { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; A = B; }
|
||||
stream_options(A) ::= stream_options(B) TRIGGER MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; }
|
||||
stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; }
|
||||
|
||||
/************************************************ kill connection/query ***********************************************/
|
||||
|
|
|
@ -338,7 +338,7 @@ SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLitera
|
|||
if (NULL == pCxt->pPlaceholderValues) {
|
||||
pCxt->pPlaceholderValues = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES);
|
||||
if (NULL == pCxt->pPlaceholderValues) {
|
||||
nodesDestroyNode(val);
|
||||
nodesDestroyNode((SNode*)val);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType typ
|
|||
code = addParamToLogicConditionNode(cond, pParam2);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode(cond);
|
||||
nodesDestroyNode((SNode*)cond);
|
||||
return NULL;
|
||||
}
|
||||
return (SNode*)cond;
|
||||
|
@ -399,7 +399,7 @@ SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft,
|
|||
|
||||
static SNode* createPrimaryKeyCol(SAstCreateContext* pCxt) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
CHECK_OUT_OF_MEM(pCol);
|
||||
pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
strcpy(pCol->colName, PK_TS_COL_INTERNAL_NAME);
|
||||
|
@ -541,7 +541,7 @@ SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) {
|
|||
CHECK_OUT_OF_MEM(state);
|
||||
state->pCol = createPrimaryKeyCol(pCxt);
|
||||
if (NULL == state->pCol) {
|
||||
nodesDestroyNode(state);
|
||||
nodesDestroyNode((SNode*)state);
|
||||
CHECK_OUT_OF_MEM(state->pCol);
|
||||
}
|
||||
state->pExpr = pExpr;
|
||||
|
@ -555,7 +555,7 @@ SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode
|
|||
CHECK_OUT_OF_MEM(interval);
|
||||
interval->pCol = createPrimaryKeyCol(pCxt);
|
||||
if (NULL == interval->pCol) {
|
||||
nodesDestroyNode(interval);
|
||||
nodesDestroyNode((SNode*)interval);
|
||||
CHECK_OUT_OF_MEM(interval->pCol);
|
||||
}
|
||||
interval->pInterval = pInterval;
|
||||
|
@ -573,7 +573,7 @@ SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues) {
|
|||
fill->pValues = pValues;
|
||||
fill->pWStartTs = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == fill->pWStartTs) {
|
||||
nodesDestroyNode(fill);
|
||||
nodesDestroyNode((SNode*)fill);
|
||||
CHECK_OUT_OF_MEM(fill->pWStartTs);
|
||||
}
|
||||
strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstartts");
|
||||
|
@ -689,7 +689,7 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode*
|
|||
|
||||
SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS);
|
||||
SDatabaseOptions* pOptions = (SDatabaseOptions*)nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->buffer = TSDB_DEFAULT_BUFFER_PER_VNODE;
|
||||
pOptions->cachelast = TSDB_DEFAULT_CACHE_LAST_ROW;
|
||||
|
@ -715,7 +715,7 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
|
|||
|
||||
SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS);
|
||||
SDatabaseOptions* pOptions = (SDatabaseOptions*)nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->buffer = -1;
|
||||
pOptions->cachelast = -1;
|
||||
|
@ -852,7 +852,7 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode*
|
|||
if (!checkDbName(pCxt, pDbName, false)) {
|
||||
return NULL;
|
||||
}
|
||||
SAlterDatabaseStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT);
|
||||
SAlterDatabaseStmt* pStmt = (SAlterDatabaseStmt*)nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
||||
pStmt->pOptions = (SDatabaseOptions*)pOptions;
|
||||
|
@ -861,7 +861,7 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode*
|
|||
|
||||
SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
|
||||
STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->filesFactor = TSDB_DEFAULT_ROLLUP_FILE_FACTOR;
|
||||
pOptions->ttl = TSDB_DEFAULT_TABLE_TTL;
|
||||
|
@ -870,7 +870,7 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
|
|||
|
||||
SNode* createAlterTableOptions(SAstCreateContext* pCxt) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
|
||||
STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->filesFactor = -1;
|
||||
pOptions->ttl = -1;
|
||||
|
@ -948,7 +948,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode*
|
|||
SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable,
|
||||
SNodeList* pSpecificTags, SNodeList* pValsOfTags, SNode* pOptions) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SCreateSubTableClause* pStmt = nodesMakeNode(QUERY_NODE_CREATE_SUBTABLE_CLAUSE);
|
||||
SCreateSubTableClause* pStmt = (SCreateSubTableClause*)nodesMakeNode(QUERY_NODE_CREATE_SUBTABLE_CLAUSE);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
|
@ -959,12 +959,13 @@ SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SN
|
|||
pStmt->pValsOfTags = pValsOfTags;
|
||||
nodesDestroyNode(pRealTable);
|
||||
nodesDestroyNode(pUseRealTable);
|
||||
nodesDestroyNode(pOptions);
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SCreateMultiTableStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_MULTI_TABLE_STMT);
|
||||
SCreateMultiTableStmt* pStmt = (SCreateMultiTableStmt*)nodesMakeNode(QUERY_NODE_CREATE_MULTI_TABLE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->pSubTables = pSubTables;
|
||||
return (SNode*)pStmt;
|
||||
|
@ -972,7 +973,7 @@ SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables
|
|||
|
||||
SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDropTableClause* pStmt = nodesMakeNode(QUERY_NODE_DROP_TABLE_CLAUSE);
|
||||
SDropTableClause* pStmt = (SDropTableClause*)nodesMakeNode(QUERY_NODE_DROP_TABLE_CLAUSE);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
|
@ -983,7 +984,7 @@ SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNod
|
|||
|
||||
SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDropTableStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT);
|
||||
SDropTableStmt* pStmt = (SDropTableStmt*)nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->pTables = pTables;
|
||||
return (SNode*)pStmt;
|
||||
|
@ -991,7 +992,7 @@ SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables) {
|
|||
|
||||
SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDropSuperTableStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_SUPER_TABLE_STMT);
|
||||
SDropSuperTableStmt* pStmt = (SDropSuperTableStmt*)nodesMakeNode(QUERY_NODE_DROP_SUPER_TABLE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
|
@ -1009,7 +1010,7 @@ static SNode* createAlterTableStmtFinalize(SNode* pRealTable, SAlterTableStmt* p
|
|||
|
||||
SNode* createAlterTableModifyOptions(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_OPTIONS;
|
||||
pStmt->pOptions = (STableOptions*)pOptions;
|
||||
|
@ -1022,7 +1023,7 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable,
|
|||
if (!checkColumnName(pCxt, pColName)) {
|
||||
return NULL;
|
||||
}
|
||||
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->alterType = alterType;
|
||||
strncpy(pStmt->colName, pColName->z, pColName->n);
|
||||
|
@ -1035,7 +1036,7 @@ SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_
|
|||
if (!checkColumnName(pCxt, pColName)) {
|
||||
return NULL;
|
||||
}
|
||||
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->alterType = alterType;
|
||||
strncpy(pStmt->colName, pColName->z, pColName->n);
|
||||
|
@ -1048,7 +1049,7 @@ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int
|
|||
if (!checkColumnName(pCxt, pOldColName) || !checkColumnName(pCxt, pNewColName)) {
|
||||
return NULL;
|
||||
}
|
||||
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->alterType = alterType;
|
||||
strncpy(pStmt->colName, pOldColName->z, pOldColName->n);
|
||||
|
@ -1061,7 +1062,7 @@ SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken
|
|||
if (!checkColumnName(pCxt, pTagName)) {
|
||||
return NULL;
|
||||
}
|
||||
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_VAL;
|
||||
strncpy(pStmt->colName, pTagName->z, pTagName->n);
|
||||
|
@ -1092,7 +1093,7 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, S
|
|||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
SShowStmt* pStmt = nodesMakeNode(type);
|
||||
SShowStmt* pStmt = (SShowStmt*)nodesMakeNode(type);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->pDbName = pDbName;
|
||||
pStmt->pTbNamePattern = pTbNamePattern;
|
||||
|
@ -1137,7 +1138,7 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t al
|
|||
if (TSDB_ALTER_USER_PASSWD == alterType) {
|
||||
char password[TSDB_USET_PASSWORD_LEN] = {0};
|
||||
if (!checkPassword(pCxt, pVal, password)) {
|
||||
nodesDestroyNode(pStmt);
|
||||
nodesDestroyNode((SNode*)pStmt);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(pStmt->password, password);
|
||||
|
@ -1187,7 +1188,7 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) {
|
|||
pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10);
|
||||
} else {
|
||||
if (!checkAndSplitEndpoint(pCxt, pDnode, pStmt->fqdn, &pStmt->port)) {
|
||||
nodesDestroyNode(pStmt);
|
||||
nodesDestroyNode((SNode*)pStmt);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1197,7 +1198,7 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) {
|
|||
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig,
|
||||
const SToken* pValue) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SAlterDnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT);
|
||||
SAlterDnodeStmt* pStmt = (SAlterDnodeStmt*)nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10);
|
||||
trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config));
|
||||
|
@ -1213,7 +1214,7 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno
|
|||
if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName) || !checkDbName(pCxt, NULL, true)) {
|
||||
return NULL;
|
||||
}
|
||||
SCreateIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT);
|
||||
SCreateIndexStmt* pStmt = (SCreateIndexStmt*)nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->indexType = type;
|
||||
pStmt->ignoreExists = ignoreExists;
|
||||
|
@ -1227,7 +1228,7 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno
|
|||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset,
|
||||
SNode* pSliding) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SIndexOptions* pOptions = nodesMakeNode(QUERY_NODE_INDEX_OPTIONS);
|
||||
SIndexOptions* pOptions = (SIndexOptions*)nodesMakeNode(QUERY_NODE_INDEX_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->pFuncs = pFuncs;
|
||||
pOptions->pInterval = pInterval;
|
||||
|
@ -1241,7 +1242,7 @@ SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken
|
|||
if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) {
|
||||
return NULL;
|
||||
}
|
||||
SDropIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT);
|
||||
SDropIndexStmt* pStmt = (SDropIndexStmt*)nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->ignoreNotExists = ignoreNotExists;
|
||||
strncpy(pStmt->indexName, pIndexName->z, pIndexName->n);
|
||||
|
@ -1251,26 +1252,24 @@ SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken
|
|||
|
||||
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SCreateComponentNodeStmt* pStmt = nodesMakeNode(type);
|
||||
SCreateComponentNodeStmt* pStmt = (SCreateComponentNodeStmt*)nodesMakeNode(type);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->dnodeId = taosStr2Int32(pDnodeId->z, NULL, 10);
|
||||
;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDropComponentNodeStmt* pStmt = nodesMakeNode(type);
|
||||
SDropComponentNodeStmt* pStmt = (SDropComponentNodeStmt*)nodesMakeNode(type);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->dnodeId = taosStr2Int32(pDnodeId->z, NULL, 10);
|
||||
;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery,
|
||||
const SToken* pSubDbName, SNode* pRealTable) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SCreateTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
||||
SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strncpy(pStmt->topicName, pTopicName->z, pTopicName->n);
|
||||
pStmt->ignoreExists = ignoreExists;
|
||||
|
@ -1288,7 +1287,7 @@ SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const S
|
|||
|
||||
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDropTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT);
|
||||
SDropTopicStmt* pStmt = (SDropTopicStmt*)nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strncpy(pStmt->topicName, pTopicName->z, pTopicName->n);
|
||||
pStmt->ignoreNotExists = ignoreNotExists;
|
||||
|
@ -1298,7 +1297,7 @@ SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const
|
|||
SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId,
|
||||
const SToken* pTopicName) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDropCGroupStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT);
|
||||
SDropCGroupStmt* pStmt = (SDropCGroupStmt*)nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->ignoreNotExists = ignoreNotExists;
|
||||
strncpy(pStmt->topicName, pTopicName->z, pTopicName->n);
|
||||
|
@ -1308,7 +1307,7 @@ SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const
|
|||
|
||||
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SAlterLocalStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_LOCAL_STMT);
|
||||
SAlterLocalStmt* pStmt = (SAlterLocalStmt*)nodesMakeNode(QUERY_NODE_ALTER_LOCAL_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config));
|
||||
if (NULL != pValue) {
|
||||
|
@ -1319,7 +1318,7 @@ SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, cons
|
|||
|
||||
SNode* createDefaultExplainOptions(SAstCreateContext* pCxt) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SExplainOptions* pOptions = nodesMakeNode(QUERY_NODE_EXPLAIN_OPTIONS);
|
||||
SExplainOptions* pOptions = (SExplainOptions*)nodesMakeNode(QUERY_NODE_EXPLAIN_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->verbose = TSDB_DEFAULT_EXPLAIN_VERBOSE;
|
||||
pOptions->ratio = TSDB_DEFAULT_EXPLAIN_RATIO;
|
||||
|
@ -1340,7 +1339,7 @@ SNode* setExplainRatio(SAstCreateContext* pCxt, SNode* pOptions, const SToken* p
|
|||
|
||||
SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* pQuery) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SExplainStmt* pStmt = nodesMakeNode(QUERY_NODE_EXPLAIN_STMT);
|
||||
SExplainStmt* pStmt = (SExplainStmt*)nodesMakeNode(QUERY_NODE_EXPLAIN_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->analyze = analyze;
|
||||
pStmt->pOptions = (SExplainOptions*)pOptions;
|
||||
|
@ -1350,7 +1349,7 @@ SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions,
|
|||
|
||||
SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDescribeStmt* pStmt = nodesMakeNode(QUERY_NODE_DESCRIBE_STMT);
|
||||
SDescribeStmt* pStmt = (SDescribeStmt*)nodesMakeNode(QUERY_NODE_DESCRIBE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||
|
@ -1379,7 +1378,7 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool
|
|||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
SCreateFunctionStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_FUNCTION_STMT);
|
||||
SCreateFunctionStmt* pStmt = (SCreateFunctionStmt*)nodesMakeNode(QUERY_NODE_CREATE_FUNCTION_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->ignoreExists = ignoreExists;
|
||||
strncpy(pStmt->funcName, pFuncName->z, pFuncName->n);
|
||||
|
@ -1392,7 +1391,7 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool
|
|||
|
||||
SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDropFunctionStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT);
|
||||
SDropFunctionStmt* pStmt = (SDropFunctionStmt*)nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->ignoreNotExists = ignoreNotExists;
|
||||
strncpy(pStmt->funcName, pFuncName->z, pFuncName->n);
|
||||
|
@ -1401,7 +1400,7 @@ SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con
|
|||
|
||||
SNode* createStreamOptions(SAstCreateContext* pCxt) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SStreamOptions* pOptions = nodesMakeNode(QUERY_NODE_STREAM_OPTIONS);
|
||||
SStreamOptions* pOptions = (SStreamOptions*)nodesMakeNode(QUERY_NODE_STREAM_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->triggerType = STREAM_TRIGGER_AT_ONCE;
|
||||
return (SNode*)pOptions;
|
||||
|
@ -1410,7 +1409,7 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) {
|
|||
SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable,
|
||||
SNode* pOptions, SNode* pQuery) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SCreateStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT);
|
||||
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strncpy(pStmt->streamName, pStreamName->z, pStreamName->n);
|
||||
if (NULL != pRealTable) {
|
||||
|
@ -1426,7 +1425,7 @@ SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const
|
|||
|
||||
SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDropStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT);
|
||||
SDropStreamStmt* pStmt = (SDropStreamStmt*)nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strncpy(pStmt->streamName, pStreamName->z, pStreamName->n);
|
||||
pStmt->ignoreNotExists = ignoreNotExists;
|
||||
|
@ -1435,7 +1434,7 @@ SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const
|
|||
|
||||
SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SKillStmt* pStmt = nodesMakeNode(type);
|
||||
SKillStmt* pStmt = (SKillStmt*)nodesMakeNode(type);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->targetId = taosStr2Int32(pId->z, NULL, 10);
|
||||
return (SNode*)pStmt;
|
||||
|
@ -1443,14 +1442,14 @@ SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId
|
|||
|
||||
SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SBalanceVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_STMT);
|
||||
SBalanceVgroupStmt* pStmt = (SBalanceVgroupStmt*)nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SMergeVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_MERGE_VGROUP_STMT);
|
||||
SMergeVgroupStmt* pStmt = (SMergeVgroupStmt*)nodesMakeNode(QUERY_NODE_MERGE_VGROUP_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->vgId1 = taosStr2Int32(pVgId1->z, NULL, 10);
|
||||
pStmt->vgId2 = taosStr2Int32(pVgId2->z, NULL, 10);
|
||||
|
@ -1459,7 +1458,7 @@ SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, cons
|
|||
|
||||
SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SRedistributeVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_REDISTRIBUTE_VGROUP_STMT);
|
||||
SRedistributeVgroupStmt* pStmt = (SRedistributeVgroupStmt*)nodesMakeNode(QUERY_NODE_REDISTRIBUTE_VGROUP_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->vgId = taosStr2Int32(pVgId->z, NULL, 10);
|
||||
pStmt->pDnodes = pDnodes;
|
||||
|
@ -1468,7 +1467,7 @@ SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId
|
|||
|
||||
SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SSplitVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_SPLIT_VGROUP_STMT);
|
||||
SSplitVgroupStmt* pStmt = (SSplitVgroupStmt*)nodesMakeNode(QUERY_NODE_SPLIT_VGROUP_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->vgId = taosStr2Int32(pVgId->z, NULL, 10);
|
||||
return (SNode*)pStmt;
|
||||
|
@ -1486,7 +1485,7 @@ SNode* createGrantStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbN
|
|||
if (!checkDbName(pCxt, pDbName, false) || !checkUserName(pCxt, pUserName)) {
|
||||
return NULL;
|
||||
}
|
||||
SGrantStmt* pStmt = nodesMakeNode(QUERY_NODE_GRANT_STMT);
|
||||
SGrantStmt* pStmt = (SGrantStmt*)nodesMakeNode(QUERY_NODE_GRANT_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->privileges = privileges;
|
||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
||||
|
@ -1499,7 +1498,7 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb
|
|||
if (!checkDbName(pCxt, pDbName, false) || !checkUserName(pCxt, pUserName)) {
|
||||
return NULL;
|
||||
}
|
||||
SRevokeStmt* pStmt = nodesMakeNode(QUERY_NODE_REVOKE_STMT);
|
||||
SRevokeStmt* pStmt = (SRevokeStmt*)nodesMakeNode(QUERY_NODE_REVOKE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->privileges = privileges;
|
||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
||||
|
@ -1508,11 +1507,11 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb
|
|||
}
|
||||
|
||||
SNode* createCountFuncForDelete(SAstCreateContext* pCxt) {
|
||||
SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
CHECK_OUT_OF_MEM(pFunc);
|
||||
strcpy(pFunc->functionName, "count");
|
||||
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pFunc->pParameterList, createPrimaryKeyCol(pCxt))) {
|
||||
nodesDestroyNode(pFunc);
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
CHECK_OUT_OF_MEM(NULL);
|
||||
}
|
||||
return (SNode*)pFunc;
|
||||
|
@ -1520,13 +1519,13 @@ SNode* createCountFuncForDelete(SAstCreateContext* pCxt) {
|
|||
|
||||
SNode* createDeleteStmt(SAstCreateContext* pCxt, SNode* pTable, SNode* pWhere) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SDeleteStmt* pStmt = nodesMakeNode(QUERY_NODE_DELETE_STMT);
|
||||
SDeleteStmt* pStmt = (SDeleteStmt*)nodesMakeNode(QUERY_NODE_DELETE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->pFromTable = pTable;
|
||||
pStmt->pWhere = pWhere;
|
||||
pStmt->pCountFunc = createCountFuncForDelete(pCxt);
|
||||
if (NULL == pStmt->pCountFunc) {
|
||||
nodesDestroyNode(pStmt);
|
||||
nodesDestroyNode((SNode*)pStmt);
|
||||
CHECK_OUT_OF_MEM(NULL);
|
||||
}
|
||||
return (SNode*)pStmt;
|
||||
|
|
|
@ -77,7 +77,7 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
|
|||
abort_parse:
|
||||
ParseFree(pParser, (FFree)taosMemoryFree);
|
||||
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
||||
*pQuery = taosMemoryCalloc(1, sizeof(SQuery));
|
||||
*pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
if (NULL == *pQuery) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -95,12 +95,6 @@ typedef struct SCollectMetaKeyCxt {
|
|||
SNode* pStmt;
|
||||
} SCollectMetaKeyCxt;
|
||||
|
||||
static void destroyCollectMetaKeyCxt(SCollectMetaKeyCxt* pCxt) {
|
||||
if (NULL != pCxt->pMetaCache) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct SCollectMetaKeyFromExprCxt {
|
||||
SCollectMetaKeyCxt* pComCxt;
|
||||
int32_t errCode;
|
||||
|
@ -463,16 +457,7 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t collectMetaKey(SParseContext* pParseCxt, SQuery* pQuery) {
|
||||
SCollectMetaKeyCxt cxt = {
|
||||
.pParseCxt = pParseCxt, .pMetaCache = taosMemoryCalloc(1, sizeof(SParseMetaCache)), .pStmt = pQuery->pRoot};
|
||||
if (NULL == cxt.pMetaCache) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
int32_t code = collectMetaKeyFromQuery(&cxt, pQuery->pRoot);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
TSWAP(pQuery->pMetaCache, cxt.pMetaCache);
|
||||
}
|
||||
destroyCollectMetaKeyCxt(&cxt);
|
||||
return code;
|
||||
int32_t collectMetaKey(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
|
||||
SCollectMetaKeyCxt cxt = {.pParseCxt = pParseCxt, .pMetaCache = pMetaCache, .pStmt = pQuery->pRoot};
|
||||
return collectMetaKeyFromQuery(&cxt, pQuery->pRoot);
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery) {
|
||||
SAuthCxt cxt = {.pParseCxt = pParseCxt, .pMetaCache = pQuery->pMetaCache, .errCode = TSDB_CODE_SUCCESS};
|
||||
int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
|
||||
SAuthCxt cxt = {.pParseCxt = pParseCxt, .pMetaCache = pMetaCache, .errCode = TSDB_CODE_SUCCESS};
|
||||
return authQuery(&cxt, pQuery->pRoot);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ static bool isCondition(const SNode* pNode) {
|
|||
}
|
||||
|
||||
static int32_t rewriteIsTrue(SNode* pSrc, SNode** pIsTrue) {
|
||||
SOperatorNode* pOp = nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SOperatorNode* pOp = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
if (NULL == pOp) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -1301,6 +1301,8 @@ static void destroyInsertParseContextForTable(SInsertParseContext* pCxt) {
|
|||
destroyCreateSubTbReq(&pCxt->createTblReq);
|
||||
}
|
||||
|
||||
static void destroySubTableHashElem(void* p) { taosMemoryFree(*(STableMeta**)p); }
|
||||
|
||||
static void destroyInsertParseContext(SInsertParseContext* pCxt) {
|
||||
destroyInsertParseContextForTable(pCxt);
|
||||
taosHashCleanup(pCxt->pVgroupsHashObj);
|
||||
|
@ -1458,7 +1460,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
|||
// [(field1_name, ...)]
|
||||
// VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path
|
||||
// [...];
|
||||
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
|
||||
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache* pMetaCache) {
|
||||
SInsertParseContext context = {
|
||||
.pComCxt = pContext,
|
||||
.pSql = (char*)pContext->pSql,
|
||||
|
@ -1469,7 +1471,8 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
|
|||
.pDbFNameHashObj = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK),
|
||||
.totalNum = 0,
|
||||
.pOutput = (SVnodeModifOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT),
|
||||
.pStmtCb = pContext->pStmtCb};
|
||||
.pStmtCb = pContext->pStmtCb,
|
||||
.pMetaCache = pMetaCache};
|
||||
|
||||
if (pContext->pStmtCb && *pQuery) {
|
||||
(*pContext->pStmtCb->getExecInfoFn)(pContext->pStmtCb->pStmt, &context.pVgroupsHashObj,
|
||||
|
@ -1484,18 +1487,17 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
|
|||
NULL == context.pTableNameHashObj || NULL == context.pDbFNameHashObj || NULL == context.pOutput) {
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
}
|
||||
taosHashSetFreeFp(context.pSubTableHashObj, destroySubTableHashElem);
|
||||
|
||||
if (pContext->pStmtCb) {
|
||||
TSDB_QUERY_SET_TYPE(context.pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT);
|
||||
}
|
||||
|
||||
if (NULL == *pQuery) {
|
||||
*pQuery = taosMemoryCalloc(1, sizeof(SQuery));
|
||||
*pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
if (NULL == *pQuery) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
} else {
|
||||
context.pMetaCache = (*pQuery)->pMetaCache;
|
||||
}
|
||||
(*pQuery)->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
(*pQuery)->haveResultSet = false;
|
||||
|
@ -1694,24 +1696,20 @@ static int32_t parseInsertBodySyntax(SInsertParseSyntaxCxt* pCxt) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t parseInsertSyntax(SParseContext* pContext, SQuery** pQuery) {
|
||||
int32_t parseInsertSyntax(SParseContext* pContext, SQuery** pQuery, SParseMetaCache* pMetaCache) {
|
||||
SInsertParseSyntaxCxt context = {.pComCxt = pContext,
|
||||
.pSql = (char*)pContext->pSql,
|
||||
.msg = {.buf = pContext->pMsg, .len = pContext->msgLen},
|
||||
.pMetaCache = taosMemoryCalloc(1, sizeof(SParseMetaCache))};
|
||||
if (NULL == context.pMetaCache) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
int32_t code = skipInsertInto(&context.pSql, &context.msg);
|
||||
.pMetaCache = pMetaCache};
|
||||
int32_t code = skipInsertInto(&context.pSql, &context.msg);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = parseInsertBodySyntax(&context);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pQuery = taosMemoryCalloc(1, sizeof(SQuery));
|
||||
*pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
if (NULL == *pQuery) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
TSWAP((*pQuery)->pMetaCache, context.pMetaCache);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -117,6 +117,7 @@ static SKeyword keywordTable[] = {
|
|||
{"LOCAL", TK_LOCAL},
|
||||
{"MATCH", TK_MATCH},
|
||||
{"MAXROWS", TK_MAXROWS},
|
||||
{"MAX_DELAY", TK_MAX_DELAY},
|
||||
{"MERGE", TK_MERGE},
|
||||
{"MINROWS", TK_MINROWS},
|
||||
{"MINUS", TK_MINUS},
|
||||
|
|
|
@ -112,7 +112,7 @@ static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STa
|
|||
if (pParCxt->async) {
|
||||
code = getTableMetaFromCache(pCxt->pMetaCache, pName, pMeta);
|
||||
} else {
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
.requestId = pParCxt->requestId,
|
||||
.requestObjRefId = pParCxt->requestRid,
|
||||
.mgmtEps = pParCxt->mgmtEpSet};
|
||||
|
@ -140,13 +140,12 @@ static int32_t refreshGetTableMeta(STranslateContext* pCxt, const char* pDbName,
|
|||
if (pParCxt->async) {
|
||||
code = getTableMetaFromCache(pCxt->pMetaCache, &name, pMeta);
|
||||
} else {
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
.requestId = pParCxt->requestId,
|
||||
.requestObjRefId = pParCxt->requestRid,
|
||||
.mgmtEps = pParCxt->mgmtEpSet};
|
||||
|
||||
code =
|
||||
catalogRefreshGetTableMeta(pParCxt->pCatalog, &conn, &name, pMeta, false);
|
||||
|
||||
code = catalogRefreshGetTableMeta(pParCxt->pCatalog, &conn, &name, pMeta, false);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
parserError("catalogRefreshGetTableMeta error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pDbName,
|
||||
|
@ -164,7 +163,7 @@ static int32_t getDBVgInfoImpl(STranslateContext* pCxt, const SName* pName, SArr
|
|||
if (pParCxt->async) {
|
||||
code = getDbVgInfoFromCache(pCxt->pMetaCache, fullDbName, pVgInfo);
|
||||
} else {
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
.requestId = pParCxt->requestId,
|
||||
.requestObjRefId = pParCxt->requestRid,
|
||||
.mgmtEps = pParCxt->mgmtEpSet};
|
||||
|
@ -195,7 +194,7 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam
|
|||
if (pParCxt->async) {
|
||||
code = getTableVgroupFromCache(pCxt->pMetaCache, pName, pInfo);
|
||||
} else {
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
.requestId = pParCxt->requestId,
|
||||
.requestObjRefId = pParCxt->requestRid,
|
||||
.mgmtEps = pParCxt->mgmtEpSet};
|
||||
|
@ -243,7 +242,7 @@ static int32_t getDBCfg(STranslateContext* pCxt, const char* pDbName, SDbCfgInfo
|
|||
if (pParCxt->async) {
|
||||
code = getDbCfgFromCache(pCxt->pMetaCache, dbFname, pInfo);
|
||||
} else {
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
.requestId = pParCxt->requestId,
|
||||
.requestObjRefId = pParCxt->requestRid,
|
||||
.mgmtEps = pParCxt->mgmtEpSet};
|
||||
|
@ -264,13 +263,12 @@ static int32_t getUdfInfo(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
|||
if (pParCxt->async) {
|
||||
code = getUdfInfoFromCache(pCxt->pMetaCache, pFunc->functionName, &funcInfo);
|
||||
} else {
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
.requestId = pParCxt->requestId,
|
||||
.requestObjRefId = pParCxt->requestRid,
|
||||
.mgmtEps = pParCxt->mgmtEpSet};
|
||||
|
||||
code = catalogGetUdfInfo(pParCxt->pCatalog, &conn, pFunc->functionName,
|
||||
&funcInfo);
|
||||
code = catalogGetUdfInfo(pParCxt->pCatalog, &conn, pFunc->functionName, &funcInfo);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pFunc->funcType = FUNCTION_TYPE_UDF;
|
||||
|
@ -292,11 +290,11 @@ static int32_t getTableIndex(STranslateContext* pCxt, const SName* pName, SArray
|
|||
if (pParCxt->async) {
|
||||
code = getTableIndexFromCache(pCxt->pMetaCache, pName, pIndexes);
|
||||
} else {
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||
.requestId = pParCxt->requestId,
|
||||
.requestObjRefId = pParCxt->requestRid,
|
||||
.mgmtEps = pParCxt->mgmtEpSet};
|
||||
|
||||
|
||||
code = catalogGetTableIndex(pParCxt->pCatalog, &conn, pName, pIndexes);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
|
@ -982,7 +980,7 @@ static bool isCountStar(SFunctionNode* pFunc) {
|
|||
|
||||
// count(*) is rewritten as count(ts) for scannning optimization
|
||||
static int32_t rewriteCountStar(STranslateContext* pCxt, SFunctionNode* pCount) {
|
||||
SColumnNode* pCol = nodesListGetNode(pCount->pParameterList, 0);
|
||||
SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pCount->pParameterList, 0);
|
||||
STableNode* pTable = NULL;
|
||||
int32_t code = findTable(pCxt, ('\0' == pCol->tableAlias[0] ? NULL : pCol->tableAlias), &pTable);
|
||||
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
|
||||
|
@ -1034,7 +1032,7 @@ static int32_t translateScanPseudoColumnFunc(STranslateContext* pCxt, SFunctionN
|
|||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TBNAME);
|
||||
}
|
||||
} else {
|
||||
SValueNode* pVal = nodesListGetNode(pFunc->pParameterList, 0);
|
||||
SValueNode* pVal = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||
STableNode* pTable = NULL;
|
||||
pCxt->errCode = findTable(pCxt, pVal->literal, &pTable);
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode && (NULL == pTable || QUERY_NODE_REAL_TABLE != nodeType(pTable))) {
|
||||
|
@ -1175,7 +1173,7 @@ typedef struct SCheckExprForGroupByCxt {
|
|||
} SCheckExprForGroupByCxt;
|
||||
|
||||
static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||
SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pFunc) {
|
||||
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
|
@ -1190,7 +1188,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode
|
|||
*pNode = (SNode*)pFunc;
|
||||
pCxt->pCurrSelectStmt->hasSelectValFunc = true;
|
||||
} else {
|
||||
nodesDestroyNode(pFunc);
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -1527,14 +1525,14 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) {
|
|||
}
|
||||
|
||||
static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
|
||||
SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pFunc) {
|
||||
return NULL;
|
||||
}
|
||||
pFunc->pParameterList = nodesMakeList();
|
||||
if (NULL == pFunc->pParameterList ||
|
||||
TSDB_CODE_SUCCESS != nodesListStrictAppend(pFunc->pParameterList, nodesCloneNode(pExpr))) {
|
||||
nodesDestroyNode(pFunc);
|
||||
TSDB_CODE_SUCCESS != nodesListStrictAppend(pFunc->pParameterList, nodesCloneNode((SNode*)pExpr))) {
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2039,7 +2037,7 @@ static int32_t checkLimit(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
}
|
||||
|
||||
static int32_t createPrimaryKeyColByTable(STranslateContext* pCxt, STableNode* pTable, SNode** pPrimaryKey) {
|
||||
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -2120,7 +2118,7 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
}
|
||||
|
||||
static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) {
|
||||
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2132,20 +2130,20 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) {
|
|||
}
|
||||
|
||||
static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType dt, SNode** pCast) {
|
||||
SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pFunc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(pFunc->functionName, "cast");
|
||||
pFunc->node.resType = dt;
|
||||
if (TSDB_CODE_SUCCESS != nodesListMakeAppend(&pFunc->pParameterList, pExpr)) {
|
||||
nodesDestroyNode(pFunc);
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != getFuncInfo(pCxt, pFunc)) {
|
||||
nodesClearList(pFunc->pParameterList);
|
||||
pFunc->pParameterList = NULL;
|
||||
nodesDestroyNode(pFunc);
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pExpr)->aliasName);
|
||||
}
|
||||
*pCast = (SNode*)pFunc;
|
||||
|
@ -2449,11 +2447,11 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
|
|||
|
||||
static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions) {
|
||||
int32_t daysPerFile = pOptions->daysPerFile;
|
||||
int32_t daysToKeep0 = pOptions->keep[0];
|
||||
int64_t daysToKeep0 = pOptions->keep[0];
|
||||
if (-1 == daysPerFile && -1 == daysToKeep0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else if (-1 == daysPerFile || -1 == daysToKeep0) {
|
||||
SDbCfgInfo dbCfg;
|
||||
SDbCfgInfo dbCfg = {0};
|
||||
int32_t code = getDBCfg(pCxt, pDbName, &dbCfg);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
|
@ -2557,16 +2555,14 @@ static int32_t buildCmdMsg(STranslateContext* pCxt, int16_t msgType, FSerializeF
|
|||
|
||||
static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt) {
|
||||
SCreateDbReq createReq = {0};
|
||||
|
||||
int32_t code = checkCreateDatabase(pCxt, pStmt);
|
||||
int32_t code = checkCreateDatabase(pCxt, pStmt);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCreateDbReq(pCxt, pStmt, &createReq);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCmdMsg(pCxt, TDMT_MND_CREATE_DB, (FSerializeFunc)tSerializeSCreateDbReq, &createReq);
|
||||
}
|
||||
|
||||
tFreeSCreateDbReq(&createReq);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -2794,15 +2790,15 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt
|
|||
}
|
||||
|
||||
static int32_t checkSchemalessDb(STranslateContext* pCxt, const char* pDbName) {
|
||||
// if (0 != pCxt->pParseCxt->schemalessType) {
|
||||
// return TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
// SDbCfgInfo info = {0};
|
||||
// int32_t code = getDBCfg(pCxt, pDbName, &info);
|
||||
// if (TSDB_CODE_SUCCESS == code) {
|
||||
// code = info.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
// return code;
|
||||
// if (0 != pCxt->pParseCxt->schemalessType) {
|
||||
// return TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
// SDbCfgInfo info = {0};
|
||||
// int32_t code = getDBCfg(pCxt, pDbName, &info);
|
||||
// if (TSDB_CODE_SUCCESS == code) {
|
||||
// code = info.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
// return code;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2850,15 +2846,15 @@ typedef struct SSampleAstInfo {
|
|||
|
||||
static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, char** pAst, int32_t* pLen, char** pExpr,
|
||||
int32_t* pExprLen) {
|
||||
SSelectStmt* pSelect = nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
||||
SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
||||
if (NULL == pSelect) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
sprintf(pSelect->stmtName, "%p", pSelect);
|
||||
|
||||
SRealTableNode* pTable = nodesMakeNode(QUERY_NODE_REAL_TABLE);
|
||||
SRealTableNode* pTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE);
|
||||
if (NULL == pTable) {
|
||||
nodesDestroyNode(pSelect);
|
||||
nodesDestroyNode((SNode*)pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(pTable->table.dbName, pInfo->pDbName);
|
||||
|
@ -2867,19 +2863,19 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch
|
|||
pSelect->pFromTable = (SNode*)pTable;
|
||||
|
||||
TSWAP(pSelect->pProjectionList, pInfo->pFuncs);
|
||||
SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pSelect->pProjectionList || NULL == pFunc) {
|
||||
nodesDestroyNode(pSelect);
|
||||
nodesDestroyNode((SNode*)pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(pFunc->functionName, "_wstartts");
|
||||
nodesListPushFront(pSelect->pProjectionList, pFunc);
|
||||
nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
|
||||
SNode* pProject = NULL;
|
||||
FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); }
|
||||
|
||||
SIntervalWindowNode* pInterval = nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW);
|
||||
SIntervalWindowNode* pInterval = (SIntervalWindowNode*)nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW);
|
||||
if (NULL == pInterval) {
|
||||
nodesDestroyNode(pSelect);
|
||||
nodesDestroyNode((SNode*)pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pSelect->pWindow = (SNode*)pInterval;
|
||||
|
@ -2888,7 +2884,7 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch
|
|||
TSWAP(pInterval->pSliding, pInfo->pSliding);
|
||||
pInterval->pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pInterval->pCol) {
|
||||
nodesDestroyNode(pSelect);
|
||||
nodesDestroyNode((SNode*)pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
((SColumnNode*)pInterval->pCol)->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
|
@ -2897,12 +2893,12 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch
|
|||
pCxt->createStream = true;
|
||||
int32_t code = translateQuery(pCxt, (SNode*)pSelect);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesNodeToString(pSelect, false, pAst, pLen);
|
||||
code = nodesNodeToString((SNode*)pSelect, false, pAst, pLen);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pExpr) {
|
||||
code = nodesListToString(pSelect->pProjectionList, false, pExpr, pExprLen);
|
||||
}
|
||||
nodesDestroyNode(pSelect);
|
||||
nodesDestroyNode((SNode*)pSelect);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -2914,7 +2910,7 @@ static void clearSampleAstInfo(SSampleAstInfo* pInfo) {
|
|||
}
|
||||
|
||||
static SNode* makeIntervalVal(SRetention* pRetension, int8_t precision) {
|
||||
SValueNode* pVal = nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
if (NULL == pVal) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2923,7 +2919,7 @@ static SNode* makeIntervalVal(SRetention* pRetension, int8_t precision) {
|
|||
int32_t len = snprintf(buf, sizeof(buf), "%" PRId64 "%c", timeVal, pRetension->freqUnit);
|
||||
pVal->literal = strndup(buf, len);
|
||||
if (NULL == pVal->literal) {
|
||||
nodesDestroyNode(pVal);
|
||||
nodesDestroyNode((SNode*)pVal);
|
||||
return NULL;
|
||||
}
|
||||
pVal->isDuration = true;
|
||||
|
@ -2934,7 +2930,7 @@ static SNode* makeIntervalVal(SRetention* pRetension, int8_t precision) {
|
|||
}
|
||||
|
||||
static SNode* createColumnFromDef(SColumnDefNode* pDef) {
|
||||
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2943,12 +2939,12 @@ static SNode* createColumnFromDef(SColumnDefNode* pDef) {
|
|||
}
|
||||
|
||||
static SNode* createRollupFunc(SNode* pSrcFunc, SColumnDefNode* pColDef) {
|
||||
SFunctionNode* pFunc = nodesCloneNode(pSrcFunc);
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesCloneNode(pSrcFunc);
|
||||
if (NULL == pFunc) {
|
||||
return NULL;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pFunc->pParameterList, createColumnFromDef(pColDef))) {
|
||||
nodesDestroyNode(pFunc);
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
return NULL;
|
||||
}
|
||||
return (SNode*)pFunc;
|
||||
|
@ -3098,7 +3094,7 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p
|
|||
}
|
||||
|
||||
static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt) {
|
||||
SDropTableClause* pClause = nodesListGetNode(pStmt->pTables, 0);
|
||||
SDropTableClause* pClause = (SDropTableClause*)nodesListGetNode(pStmt->pTables, 0);
|
||||
SName tableName;
|
||||
return doTranslateDropSuperTable(
|
||||
pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), pClause->ignoreNotExists);
|
||||
|
@ -3170,6 +3166,7 @@ static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pSt
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCmdMsg(pCxt, TDMT_MND_ALTER_STB, (FSerializeFunc)tSerializeSMAlterStbReq, &alterReq);
|
||||
}
|
||||
tFreeSMAltertbReq(&alterReq);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -3576,6 +3573,16 @@ static int32_t translateKillTransaction(STranslateContext* pCxt, SKillStmt* pStm
|
|||
}
|
||||
|
||||
static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) {
|
||||
if (NULL != pStmt->pOptions->pWatermark &&
|
||||
(DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pWatermark))) {
|
||||
return pCxt->errCode;
|
||||
}
|
||||
|
||||
if (NULL != pStmt->pOptions->pDelay &&
|
||||
(DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pDelay))) {
|
||||
return pCxt->errCode;
|
||||
}
|
||||
|
||||
if (NULL == pStmt->pQuery) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -3623,12 +3630,9 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
|
|||
}
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pWatermark) {
|
||||
code = (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pWatermark)) ? pCxt->errCode
|
||||
: TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pReq->triggerType = pStmt->pOptions->triggerType;
|
||||
pReq->maxDelay = (NULL != pStmt->pOptions->pDelay ? ((SValueNode*)pStmt->pOptions->pDelay)->datum.i : 0);
|
||||
pReq->watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0);
|
||||
}
|
||||
|
||||
|
@ -4116,15 +4120,15 @@ static const char* getSysTableName(ENodeType type) {
|
|||
}
|
||||
|
||||
static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt) {
|
||||
SSelectStmt* pSelect = nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
||||
SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
||||
if (NULL == pSelect) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
sprintf(pSelect->stmtName, "%p", pSelect);
|
||||
|
||||
SRealTableNode* pTable = nodesMakeNode(QUERY_NODE_REAL_TABLE);
|
||||
SRealTableNode* pTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE);
|
||||
if (NULL == pTable) {
|
||||
nodesDestroyNode(pSelect);
|
||||
nodesDestroyNode((SNode*)pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(pTable->table.dbName, getSysDbName(showType));
|
||||
|
@ -4142,7 +4146,7 @@ static int32_t createOperatorNode(EOperatorType opType, const char* pColName, SN
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SOperatorNode* pOper = nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SOperatorNode* pOper = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
if (NULL == pOper) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -4151,7 +4155,7 @@ static int32_t createOperatorNode(EOperatorType opType, const char* pColName, SN
|
|||
pOper->pLeft = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
pOper->pRight = nodesCloneNode(pRight);
|
||||
if (NULL == pOper->pLeft || NULL == pOper->pRight) {
|
||||
nodesDestroyNode(pOper);
|
||||
nodesDestroyNode((SNode*)pOper);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(((SColumnNode*)pOper->pLeft)->colName, pColName);
|
||||
|
@ -4165,19 +4169,19 @@ static const char* getTbNameColName(ENodeType type) {
|
|||
}
|
||||
|
||||
static int32_t createLogicCondNode(SNode* pCond1, SNode* pCond2, SNode** pCond) {
|
||||
SLogicConditionNode* pCondition = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SLogicConditionNode* pCondition = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
if (NULL == pCondition) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCondition->condType = LOGIC_COND_TYPE_AND;
|
||||
pCondition->pParameterList = nodesMakeList();
|
||||
if (NULL == pCondition->pParameterList) {
|
||||
nodesDestroyNode(pCondition);
|
||||
nodesDestroyNode((SNode*)pCondition);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != nodesListAppend(pCondition->pParameterList, pCond1) ||
|
||||
TSDB_CODE_SUCCESS != nodesListAppend(pCondition->pParameterList, pCond2)) {
|
||||
nodesDestroyNode(pCondition);
|
||||
nodesDestroyNode((SNode*)pCondition);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -4325,7 +4329,7 @@ static void destroyCreateTbReqBatch(SVgroupCreateTableBatch* pTbBatch) {
|
|||
}
|
||||
|
||||
static int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray) {
|
||||
SVnodeModifOpStmt* pNewStmt = nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT);
|
||||
SVnodeModifOpStmt* pNewStmt = (SVnodeModifOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT);
|
||||
if (pNewStmt == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -5078,29 +5082,18 @@ static int32_t buildModifyVnodeArray(STranslateContext* pCxt, SAlterTableStmt* p
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) {
|
||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)pQuery->pRoot;
|
||||
int32_t code = checkSchemalessDb(pCxt, pStmt->dbName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
STableMeta* pTableMeta = NULL;
|
||||
code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_TAG) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG);
|
||||
}
|
||||
|
||||
if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_COLUMN) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COL_JSON);
|
||||
}
|
||||
static void destoryAlterTbReq(SVAlterTbReq* pReq) {
|
||||
taosMemoryFree(pReq->tbName);
|
||||
taosMemoryFree(pReq->colName);
|
||||
taosMemoryFree(pReq->colNewName);
|
||||
taosMemoryFree(pReq->tagName);
|
||||
taosMemoryFree(pReq->newComment);
|
||||
}
|
||||
|
||||
static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
|
||||
SQuery* pQuery) {
|
||||
if (getNumOfTags(pTableMeta) == 1 && pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE,
|
||||
"can not drop tag if there is only one tag");
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
||||
}
|
||||
|
||||
if (TSDB_SUPER_TABLE == pTableMeta->tableType) {
|
||||
|
@ -5116,7 +5109,7 @@ static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
}
|
||||
|
||||
SVAlterTbReq req = {0};
|
||||
code = buildAlterTbReq(pCxt, pStmt, pTableMeta, &req);
|
||||
int32_t code = buildAlterTbReq(pCxt, pStmt, pTableMeta, &req);
|
||||
|
||||
SArray* pArray = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -5125,7 +5118,27 @@ static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = rewriteToVnodeModifyOpStmt(pQuery, pArray);
|
||||
}
|
||||
destoryAlterTbReq(&req);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) {
|
||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)pQuery->pRoot;
|
||||
|
||||
if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_TAG) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG);
|
||||
}
|
||||
|
||||
if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_COLUMN) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COL_JSON);
|
||||
}
|
||||
|
||||
STableMeta* pTableMeta = NULL;
|
||||
int32_t code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = rewriteAlterTableImpl(pCxt, pStmt, pTableMeta, pQuery);
|
||||
}
|
||||
taosMemoryFree(pTableMeta);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -5261,10 +5274,10 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery) {
|
||||
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
|
||||
STranslateContext cxt = {0};
|
||||
|
||||
int32_t code = initTranslateContext(pParseCxt, pQuery->pMetaCache, &cxt);
|
||||
int32_t code = initTranslateContext(pParseCxt, pMetaCache, &cxt);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = rewriteQuery(&cxt, pQuery);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
#define USER_AUTH_KEY_MAX_LEN TSDB_USER_LEN + TSDB_DB_FNAME_LEN + 2
|
||||
|
||||
const void* nullPointer = NULL;
|
||||
|
||||
static char* getSyntaxErrFormat(int32_t errCode) {
|
||||
switch (errCode) {
|
||||
case TSDB_CODE_PAR_SYNTAX_ERROR:
|
||||
|
@ -550,9 +552,15 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pData, int32_t index, SHashObj* pHash) {
|
||||
static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pData, int32_t index, SHashObj** pHash) {
|
||||
if (NULL == *pHash) {
|
||||
*pHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
if (NULL == *pHash) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
SMetaRes* pRes = taosArrayGet(pData, index);
|
||||
return taosHashPut(pHash, pKey, len, &pRes, POINTER_BYTES);
|
||||
return taosHashPut(*pHash, pKey, len, &pRes, POINTER_BYTES);
|
||||
}
|
||||
|
||||
static int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput) {
|
||||
|
@ -566,7 +574,7 @@ static int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHas
|
|||
return (*pRes)->code;
|
||||
}
|
||||
|
||||
static int32_t putTableDataToCache(const SArray* pTableReq, const SArray* pTableData, SHashObj* pTable) {
|
||||
static int32_t putTableDataToCache(const SArray* pTableReq, const SArray* pTableData, SHashObj** pTable) {
|
||||
int32_t ntables = taosArrayGetSize(pTableReq);
|
||||
for (int32_t i = 0; i < ntables; ++i) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
|
@ -578,7 +586,7 @@ static int32_t putTableDataToCache(const SArray* pTableReq, const SArray* pTable
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHashObj* pDb) {
|
||||
static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHashObj** pDb) {
|
||||
int32_t nvgs = taosArrayGetSize(pDbReq);
|
||||
for (int32_t i = 0; i < nvgs; ++i) {
|
||||
char* pDbFName = taosArrayGet(pDbReq, i);
|
||||
|
@ -589,7 +597,7 @@ static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHa
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUserAuthData, SHashObj* pUserAuth) {
|
||||
static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUserAuthData, SHashObj** pUserAuth) {
|
||||
int32_t nvgs = taosArrayGetSize(pUserAuthReq);
|
||||
for (int32_t i = 0; i < nvgs; ++i) {
|
||||
SUserAuthInfo* pUser = taosArrayGet(pUserAuthReq, i);
|
||||
|
@ -602,7 +610,7 @@ static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUse
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHashObj* pUdf) {
|
||||
static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHashObj** pUdf) {
|
||||
int32_t num = taosArrayGetSize(pUdfReq);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
char* pFunc = taosArrayGet(pUdfReq, i);
|
||||
|
@ -614,27 +622,27 @@ static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHas
|
|||
}
|
||||
|
||||
int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache) {
|
||||
int32_t code = putTableDataToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, pMetaCache->pTableMeta);
|
||||
int32_t code = putTableDataToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, &pMetaCache->pTableMeta);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putDbDataToCache(pCatalogReq->pDbVgroup, pMetaData->pDbVgroup, pMetaCache->pDbVgroup);
|
||||
code = putDbDataToCache(pCatalogReq->pDbVgroup, pMetaData->pDbVgroup, &pMetaCache->pDbVgroup);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putTableDataToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, pMetaCache->pTableVgroup);
|
||||
code = putTableDataToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, &pMetaCache->pTableVgroup);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putDbDataToCache(pCatalogReq->pDbCfg, pMetaData->pDbCfg, pMetaCache->pDbCfg);
|
||||
code = putDbDataToCache(pCatalogReq->pDbCfg, pMetaData->pDbCfg, &pMetaCache->pDbCfg);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putDbDataToCache(pCatalogReq->pDbInfo, pMetaData->pDbInfo, pMetaCache->pDbInfo);
|
||||
code = putDbDataToCache(pCatalogReq->pDbInfo, pMetaData->pDbInfo, &pMetaCache->pDbInfo);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putUserAuthToCache(pCatalogReq->pUser, pMetaData->pUser, pMetaCache->pUserAuth);
|
||||
code = putUserAuthToCache(pCatalogReq->pUser, pMetaData->pUser, &pMetaCache->pUserAuth);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putUdfToCache(pCatalogReq->pUdf, pMetaData->pUdfList, pMetaCache->pUdf);
|
||||
code = putUdfToCache(pCatalogReq->pUdf, pMetaData->pUdfList, &pMetaCache->pUdf);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putTableDataToCache(pCatalogReq->pTableIndex, pMetaData->pTableIndex, pMetaCache->pTableIndex);
|
||||
code = putTableDataToCache(pCatalogReq->pTableIndex, pMetaData->pTableIndex, &pMetaCache->pTableIndex);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -646,7 +654,7 @@ static int32_t reserveTableReqInCacheImpl(const char* pTbFName, int32_t len, SHa
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
return taosHashPut(*pTables, pTbFName, len, &pTables, POINTER_BYTES);
|
||||
return taosHashPut(*pTables, pTbFName, len, &nullPointer, POINTER_BYTES);
|
||||
}
|
||||
|
||||
static int32_t reserveTableReqInCache(int32_t acctId, const char* pDb, const char* pTable, SHashObj** pTables) {
|
||||
|
@ -688,7 +696,7 @@ static int32_t reserveDbReqInCache(int32_t acctId, const char* pDb, SHashObj** p
|
|||
}
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
int32_t len = snprintf(fullName, sizeof(fullName), "%d.%s", acctId, pDb);
|
||||
return taosHashPut(*pDbs, fullName, len, &pDbs, POINTER_BYTES);
|
||||
return taosHashPut(*pDbs, fullName, len, &nullPointer, POINTER_BYTES);
|
||||
}
|
||||
|
||||
int32_t reserveDbVgInfoInCache(int32_t acctId, const char* pDb, SParseMetaCache* pMetaCache) {
|
||||
|
@ -803,7 +811,7 @@ int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache) {
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
return taosHashPut(pMetaCache->pUdf, pFunc, strlen(pFunc), &pMetaCache, POINTER_BYTES);
|
||||
return taosHashPut(pMetaCache->pUdf, pFunc, strlen(pFunc), &nullPointer, POINTER_BYTES);
|
||||
}
|
||||
|
||||
int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFuncInfo* pInfo) {
|
||||
|
@ -854,3 +862,14 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName,
|
|||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
void destoryParseMetaCache(SParseMetaCache* pMetaCache) {
|
||||
taosHashCleanup(pMetaCache->pTableMeta);
|
||||
taosHashCleanup(pMetaCache->pDbVgroup);
|
||||
taosHashCleanup(pMetaCache->pTableVgroup);
|
||||
taosHashCleanup(pMetaCache->pDbCfg);
|
||||
taosHashCleanup(pMetaCache->pDbInfo);
|
||||
taosHashCleanup(pMetaCache->pUserAuth);
|
||||
taosHashCleanup(pMetaCache->pUdf);
|
||||
taosHashCleanup(pMetaCache->pTableIndex);
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ bool qIsInsertSql(const char* pStr, size_t length) {
|
|||
} while (1);
|
||||
}
|
||||
|
||||
static int32_t analyseSemantic(SParseContext* pCxt, SQuery* pQuery) {
|
||||
int32_t code = authenticate(pCxt, pQuery);
|
||||
static int32_t analyseSemantic(SParseContext* pCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
|
||||
int32_t code = authenticate(pCxt, pQuery, pMetaCache);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code && pQuery->placeholderNum > 0) {
|
||||
TSWAP(pQuery->pPrepareRoot, pQuery->pRoot);
|
||||
|
@ -43,7 +43,7 @@ static int32_t analyseSemantic(SParseContext* pCxt, SQuery* pQuery) {
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translate(pCxt, pQuery);
|
||||
code = translate(pCxt, pQuery, pMetaCache);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = calculateConstant(pCxt, pQuery);
|
||||
|
@ -54,15 +54,15 @@ static int32_t analyseSemantic(SParseContext* pCxt, SQuery* pQuery) {
|
|||
static int32_t parseSqlIntoAst(SParseContext* pCxt, SQuery** pQuery) {
|
||||
int32_t code = parse(pCxt, pQuery);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = analyseSemantic(pCxt, *pQuery);
|
||||
code = analyseSemantic(pCxt, *pQuery, NULL);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t parseSqlSyntax(SParseContext* pCxt, SQuery** pQuery) {
|
||||
static int32_t parseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, SParseMetaCache* pMetaCache) {
|
||||
int32_t code = parse(pCxt, pQuery);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = collectMetaKey(pCxt, *pQuery);
|
||||
code = collectMetaKey(pCxt, *pQuery, pMetaCache);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ static void rewriteExprAlias(SNode* pRoot) {
|
|||
int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (qIsInsertSql(pCxt->pSql, pCxt->sqlLen)) {
|
||||
code = parseInsertSql(pCxt, pQuery);
|
||||
code = parseInsertSql(pCxt, pQuery, NULL);
|
||||
} else {
|
||||
code = parseSqlIntoAst(pCxt, pQuery);
|
||||
}
|
||||
|
@ -158,29 +158,38 @@ int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery) {
|
|||
}
|
||||
|
||||
int32_t qParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, struct SCatalogReq* pCatalogReq) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SParseMetaCache metaCache = {0};
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (qIsInsertSql(pCxt->pSql, pCxt->sqlLen)) {
|
||||
code = parseInsertSyntax(pCxt, pQuery);
|
||||
code = parseInsertSyntax(pCxt, pQuery, &metaCache);
|
||||
} else {
|
||||
code = parseSqlSyntax(pCxt, pQuery);
|
||||
code = parseSqlSyntax(pCxt, pQuery, &metaCache);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCatalogReq((*pQuery)->pMetaCache, pCatalogReq);
|
||||
code = buildCatalogReq(&metaCache, pCatalogReq);
|
||||
}
|
||||
destoryParseMetaCache(&metaCache);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCatalogReq,
|
||||
const struct SMetaData* pMetaData, SQuery* pQuery) {
|
||||
int32_t code = putMetaDataToCache(pCatalogReq, pMetaData, pQuery->pMetaCache);
|
||||
if (NULL == pQuery->pRoot) {
|
||||
return parseInsertSql(pCxt, &pQuery);
|
||||
SParseMetaCache metaCache = {0};
|
||||
int32_t code = putMetaDataToCache(pCatalogReq, pMetaData, &metaCache);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL == pQuery->pRoot) {
|
||||
code = parseInsertSql(pCxt, &pQuery, &metaCache);
|
||||
} else {
|
||||
code = analyseSemantic(pCxt, pQuery, &metaCache);
|
||||
}
|
||||
}
|
||||
return analyseSemantic(pCxt, pQuery);
|
||||
destoryParseMetaCache(&metaCache);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
||||
void qDestroyQuery(SQuery* pQueryNode) { nodesDestroyNode(pQueryNode); }
|
||||
void qDestroyQuery(SQuery* pQueryNode) { nodesDestroyNode((SNode*)pQueryNode); }
|
||||
|
||||
int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) {
|
||||
return extractResultSchema(pRoot, numOfCols, pSchema);
|
||||
|
@ -226,10 +235,9 @@ int32_t qStmtBindParams(SQuery* pQuery, TAOS_MULTI_BIND* pParams, int32_t colIdx
|
|||
}
|
||||
|
||||
int32_t qStmtParseQuerySql(SParseContext* pCxt, SQuery* pQuery) {
|
||||
int32_t code = translate(pCxt, pQuery);
|
||||
int32_t code = translate(pCxt, pQuery, NULL);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = calculateConstant(pCxt, pQuery);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -157,6 +157,28 @@ void generateTestST1(MockCatalogService* mcs) {
|
|||
mcs->createSubTable("test", "st1", "st1s3", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Super Table: st2
|
||||
* Field | Type | DataType | Bytes |
|
||||
* ==========================================================================
|
||||
* ts | column | TIMESTAMP | 8 |
|
||||
* c1 | column | INT | 4 |
|
||||
* c2 | column | VARCHAR | 20 |
|
||||
* jtag | tag | json | -- |
|
||||
* Child Table: st2s1, st2s2
|
||||
*/
|
||||
void generateTestST2(MockCatalogService* mcs) {
|
||||
ITableBuilder& builder = mcs->createTableBuilder("test", "st2", TSDB_SUPER_TABLE, 3, 1)
|
||||
.setPrecision(TSDB_TIME_PRECISION_MILLI)
|
||||
.addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP)
|
||||
.addColumn("c1", TSDB_DATA_TYPE_INT)
|
||||
.addColumn("c2", TSDB_DATA_TYPE_BINARY, 20)
|
||||
.addTag("jtag", TSDB_DATA_TYPE_JSON);
|
||||
builder.done();
|
||||
mcs->createSubTable("test", "st2", "st2s1", 1);
|
||||
mcs->createSubTable("test", "st2", "st2s2", 2);
|
||||
}
|
||||
|
||||
void generateFunctions(MockCatalogService* mcs) {
|
||||
mcs->createFunction("udf1", TSDB_FUNC_TYPE_SCALAR, TSDB_DATA_TYPE_INT, tDataTypes[TSDB_DATA_TYPE_INT].bytes, 0);
|
||||
mcs->createFunction("udf2", TSDB_FUNC_TYPE_AGGREGATE, TSDB_DATA_TYPE_DOUBLE, tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes,
|
||||
|
@ -283,6 +305,7 @@ void generateMetaData() {
|
|||
generatePerformanceSchema(g_mockCatalogService.get());
|
||||
generateTestT1(g_mockCatalogService.get());
|
||||
generateTestST1(g_mockCatalogService.get());
|
||||
generateTestST2(g_mockCatalogService.get());
|
||||
generateFunctions(g_mockCatalogService.get());
|
||||
g_mockCatalogService->showTables();
|
||||
}
|
||||
|
|
|
@ -584,3 +584,35 @@ int32_t MockCatalogService::catalogGetTableIndex(const SName* pTableName, SArray
|
|||
int32_t MockCatalogService::catalogGetAllMeta(const SCatalogReq* pCatalogReq, SMetaData* pMetaData) const {
|
||||
return impl_->catalogGetAllMeta(pCatalogReq, pMetaData);
|
||||
}
|
||||
|
||||
void MockCatalogService::destoryCatalogReq(SCatalogReq* pReq) {
|
||||
taosArrayDestroy(pReq->pDbVgroup);
|
||||
taosArrayDestroy(pReq->pDbCfg);
|
||||
taosArrayDestroy(pReq->pDbInfo);
|
||||
taosArrayDestroy(pReq->pTableMeta);
|
||||
taosArrayDestroy(pReq->pTableHash);
|
||||
taosArrayDestroy(pReq->pUdf);
|
||||
taosArrayDestroy(pReq->pIndex);
|
||||
taosArrayDestroy(pReq->pUser);
|
||||
taosArrayDestroy(pReq->pTableIndex);
|
||||
delete pReq;
|
||||
}
|
||||
|
||||
void MockCatalogService::destoryMetaRes(void* p) {
|
||||
SMetaRes* pRes = (SMetaRes*)p;
|
||||
taosMemoryFree(pRes->pRes);
|
||||
}
|
||||
|
||||
void MockCatalogService::destoryMetaData(SMetaData* pData) {
|
||||
taosArrayDestroyEx(pData->pDbVgroup, destoryMetaRes);
|
||||
taosArrayDestroyEx(pData->pDbCfg, destoryMetaRes);
|
||||
taosArrayDestroyEx(pData->pDbInfo, destoryMetaRes);
|
||||
taosArrayDestroyEx(pData->pTableMeta, destoryMetaRes);
|
||||
taosArrayDestroyEx(pData->pTableHash, destoryMetaRes);
|
||||
taosArrayDestroyEx(pData->pTableIndex, destoryMetaRes);
|
||||
taosArrayDestroyEx(pData->pUdfList, destoryMetaRes);
|
||||
taosArrayDestroyEx(pData->pIndex, destoryMetaRes);
|
||||
taosArrayDestroyEx(pData->pUser, destoryMetaRes);
|
||||
taosArrayDestroyEx(pData->pQnodeList, destoryMetaRes);
|
||||
delete pData;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,10 @@ struct MockTableMeta {
|
|||
class MockCatalogServiceImpl;
|
||||
class MockCatalogService {
|
||||
public:
|
||||
static void destoryCatalogReq(SCatalogReq* pReq);
|
||||
static void destoryMetaRes(void* p);
|
||||
static void destoryMetaData(SMetaData* pData);
|
||||
|
||||
MockCatalogService();
|
||||
~MockCatalogService();
|
||||
ITableBuilder& createTableBuilder(const std::string& db, const std::string& tbname, int8_t tableType,
|
||||
|
|
|
@ -76,6 +76,11 @@ TEST_F(ParserInitialATest, alterSTable) {
|
|||
|
||||
SMAlterStbReq expect = {0};
|
||||
|
||||
auto clearAlterStbReq = [&]() {
|
||||
tFreeSMAltertbReq(&expect);
|
||||
memset(&expect, 0, sizeof(SMAlterStbReq));
|
||||
};
|
||||
|
||||
auto setAlterStbReqFunc = [&](const char* pTbname, int8_t alterType, int32_t numOfFields = 0,
|
||||
const char* pField1Name = nullptr, int8_t field1Type = 0, int32_t field1Bytes = 0,
|
||||
const char* pField2Name = nullptr, const char* pComment = nullptr,
|
||||
|
@ -139,39 +144,49 @@ TEST_F(ParserInitialATest, alterSTable) {
|
|||
ASSERT_EQ(pField->type, pExpectField->type);
|
||||
ASSERT_EQ(pField->bytes, pExpectField->bytes);
|
||||
}
|
||||
tFreeSMAltertbReq(&req);
|
||||
});
|
||||
|
||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, nullptr, 10);
|
||||
run("ALTER TABLE st1 TTL 10");
|
||||
clearAlterStbReq();
|
||||
|
||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, "test");
|
||||
run("ALTER TABLE st1 COMMENT 'test'");
|
||||
clearAlterStbReq();
|
||||
|
||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_ADD_COLUMN, 1, "cc1", TSDB_DATA_TYPE_BIGINT);
|
||||
run("ALTER TABLE st1 ADD COLUMN cc1 BIGINT");
|
||||
clearAlterStbReq();
|
||||
|
||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_DROP_COLUMN, 1, "c1");
|
||||
run("ALTER TABLE st1 DROP COLUMN c1");
|
||||
clearAlterStbReq();
|
||||
|
||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, 1, "c1", TSDB_DATA_TYPE_VARCHAR,
|
||||
20 + VARSTR_HEADER_SIZE);
|
||||
run("ALTER TABLE st1 MODIFY COLUMN c1 VARCHAR(20)");
|
||||
clearAlterStbReq();
|
||||
|
||||
// setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, 2, "c1", 0, 0, "cc1");
|
||||
// run("ALTER TABLE st1 RENAME COLUMN c1 cc1");
|
||||
|
||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_ADD_TAG, 1, "tag11", TSDB_DATA_TYPE_BIGINT);
|
||||
run("ALTER TABLE st1 ADD TAG tag11 BIGINT");
|
||||
clearAlterStbReq();
|
||||
|
||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_DROP_TAG, 1, "tag1");
|
||||
run("ALTER TABLE st1 DROP TAG tag1");
|
||||
clearAlterStbReq();
|
||||
|
||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, 1, "tag1", TSDB_DATA_TYPE_VARCHAR,
|
||||
20 + VARSTR_HEADER_SIZE);
|
||||
run("ALTER TABLE st1 MODIFY TAG tag1 VARCHAR(20)");
|
||||
clearAlterStbReq();
|
||||
|
||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_TAG_NAME, 2, "tag1", 0, 0, "tag11");
|
||||
run("ALTER TABLE st1 RENAME TAG tag1 tag11");
|
||||
clearAlterStbReq();
|
||||
|
||||
// todo
|
||||
// ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option]
|
||||
|
@ -188,9 +203,16 @@ TEST_F(ParserInitialATest, alterTable) {
|
|||
|
||||
SVAlterTbReq expect = {0};
|
||||
|
||||
auto clearAlterTbReq = [&]() {
|
||||
free(expect.tbName);
|
||||
free(expect.colName);
|
||||
free(expect.colNewName);
|
||||
free(expect.tagName);
|
||||
memset(&expect, 0, sizeof(SVAlterTbReq));
|
||||
};
|
||||
|
||||
auto setAlterColFunc = [&](const char* pTbname, int8_t alterType, const char* pColName, int8_t dataType = 0,
|
||||
int32_t dataBytes = 0, const char* pNewColName = nullptr) {
|
||||
memset(&expect, 0, sizeof(SVAlterTbReq));
|
||||
expect.tbName = strdup(pTbname);
|
||||
expect.action = alterType;
|
||||
expect.colName = strdup(pColName);
|
||||
|
@ -213,7 +235,6 @@ TEST_F(ParserInitialATest, alterTable) {
|
|||
};
|
||||
|
||||
auto setAlterTagFunc = [&](const char* pTbname, const char* pTagName, uint8_t* pNewVal, uint32_t bytes) {
|
||||
memset(&expect, 0, sizeof(SVAlterTbReq));
|
||||
expect.tbName = strdup(pTbname);
|
||||
expect.action = TSDB_ALTER_TABLE_UPDATE_TAG_VAL;
|
||||
expect.tagName = strdup(pTagName);
|
||||
|
@ -224,7 +245,6 @@ TEST_F(ParserInitialATest, alterTable) {
|
|||
};
|
||||
|
||||
auto setAlterOptionsFunc = [&](const char* pTbname, int32_t ttl, char* pComment = nullptr) {
|
||||
memset(&expect, 0, sizeof(SVAlterTbReq));
|
||||
expect.tbName = strdup(pTbname);
|
||||
expect.action = TSDB_ALTER_TABLE_UPDATE_OPTIONS;
|
||||
if (-1 != ttl) {
|
||||
|
@ -281,25 +301,32 @@ TEST_F(ParserInitialATest, alterTable) {
|
|||
|
||||
setAlterOptionsFunc("t1", 10, nullptr);
|
||||
run("ALTER TABLE t1 TTL 10");
|
||||
clearAlterTbReq();
|
||||
|
||||
setAlterOptionsFunc("t1", -1, (char*)"test");
|
||||
run("ALTER TABLE t1 COMMENT 'test'");
|
||||
clearAlterTbReq();
|
||||
|
||||
setAlterColFunc("t1", TSDB_ALTER_TABLE_ADD_COLUMN, "cc1", TSDB_DATA_TYPE_BIGINT);
|
||||
run("ALTER TABLE t1 ADD COLUMN cc1 BIGINT");
|
||||
clearAlterTbReq();
|
||||
|
||||
setAlterColFunc("t1", TSDB_ALTER_TABLE_DROP_COLUMN, "c1");
|
||||
run("ALTER TABLE t1 DROP COLUMN c1");
|
||||
clearAlterTbReq();
|
||||
|
||||
setAlterColFunc("t1", TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, "c2", TSDB_DATA_TYPE_VARCHAR, 30 + VARSTR_HEADER_SIZE);
|
||||
run("ALTER TABLE t1 MODIFY COLUMN c2 VARCHAR(30)");
|
||||
clearAlterTbReq();
|
||||
|
||||
setAlterColFunc("t1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, "c1", 0, 0, "cc1");
|
||||
run("ALTER TABLE t1 RENAME COLUMN c1 cc1");
|
||||
clearAlterTbReq();
|
||||
|
||||
int32_t val = 10;
|
||||
setAlterTagFunc("st1s1", "tag1", (uint8_t*)&val, sizeof(val));
|
||||
run("ALTER TABLE st1s1 SET TAG tag1=10");
|
||||
clearAlterTbReq();
|
||||
|
||||
// todo
|
||||
// ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option]
|
||||
|
|
|
@ -67,8 +67,12 @@ TEST_F(ParserInitialCTest, createDatabase) {
|
|||
|
||||
SCreateDbReq expect = {0};
|
||||
|
||||
auto setCreateDbReqFunc = [&](const char* pDbname, int8_t igExists = 0) {
|
||||
auto clearCreateDbReq = [&]() {
|
||||
tFreeSCreateDbReq(&expect);
|
||||
memset(&expect, 0, sizeof(SCreateDbReq));
|
||||
};
|
||||
|
||||
auto setCreateDbReqFunc = [&](const char* pDbname, int8_t igExists = 0) {
|
||||
int32_t len = snprintf(expect.db, sizeof(expect.db), "0.%s", pDbname);
|
||||
expect.db[len] = '\0';
|
||||
expect.ignoreExist = igExists;
|
||||
|
@ -166,10 +170,12 @@ TEST_F(ParserInitialCTest, createDatabase) {
|
|||
ASSERT_EQ(pReten->keepUnit, pExpectReten->keepUnit);
|
||||
}
|
||||
}
|
||||
tFreeSCreateDbReq(&req);
|
||||
});
|
||||
|
||||
setCreateDbReqFunc("wxy_db");
|
||||
run("CREATE DATABASE wxy_db");
|
||||
clearCreateDbReq();
|
||||
|
||||
setCreateDbReqFunc("wxy_db", 1);
|
||||
setDbBufferFunc(64);
|
||||
|
@ -211,6 +217,7 @@ TEST_F(ParserInitialCTest, createDatabase) {
|
|||
"VGROUPS 100 "
|
||||
"SINGLE_STABLE 1 "
|
||||
"SCHEMALESS 1");
|
||||
clearCreateDbReq();
|
||||
|
||||
setCreateDbReqFunc("wxy_db", 1);
|
||||
setDbDaysFunc(100);
|
||||
|
@ -218,6 +225,7 @@ TEST_F(ParserInitialCTest, createDatabase) {
|
|||
run("CREATE DATABASE IF NOT EXISTS wxy_db "
|
||||
"DAYS 100m "
|
||||
"KEEP 1440m,300h,400d ");
|
||||
clearCreateDbReq();
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createDatabaseSemanticCheck) {
|
||||
|
@ -309,10 +317,14 @@ TEST_F(ParserInitialCTest, createStable) {
|
|||
|
||||
SMCreateStbReq expect = {0};
|
||||
|
||||
auto clearCreateStbReq = [&]() {
|
||||
tFreeSMCreateStbReq(&expect);
|
||||
memset(&expect, 0, sizeof(SMCreateStbReq));
|
||||
};
|
||||
|
||||
auto setCreateStbReqFunc = [&](const char* pTbname, int8_t igExists = 0,
|
||||
float xFilesFactor = TSDB_DEFAULT_ROLLUP_FILE_FACTOR,
|
||||
int32_t ttl = TSDB_DEFAULT_TABLE_TTL, const char* pComment = nullptr) {
|
||||
memset(&expect, 0, sizeof(SMCreateStbReq));
|
||||
int32_t len = snprintf(expect.name, sizeof(expect.name), "0.test.%s", pTbname);
|
||||
expect.name[len] = '\0';
|
||||
expect.igExists = igExists;
|
||||
|
@ -396,6 +408,7 @@ TEST_F(ParserInitialCTest, createStable) {
|
|||
if (expect.ast2Len > 0) {
|
||||
ASSERT_EQ(std::string(req.pAst2), std::string(expect.pAst2));
|
||||
}
|
||||
tFreeSMCreateStbReq(&req);
|
||||
});
|
||||
|
||||
setCreateStbReqFunc("t1");
|
||||
|
@ -403,6 +416,7 @@ TEST_F(ParserInitialCTest, createStable) {
|
|||
addFieldToCreateStbReqFunc(true, "c1", TSDB_DATA_TYPE_INT);
|
||||
addFieldToCreateStbReqFunc(false, "id", TSDB_DATA_TYPE_INT);
|
||||
run("CREATE STABLE t1(ts TIMESTAMP, c1 INT) TAGS(id INT)");
|
||||
clearCreateStbReq();
|
||||
|
||||
setCreateStbReqFunc("t1", 1, 0.1, 100, "test create table");
|
||||
addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP, 0, 0);
|
||||
|
@ -443,6 +457,7 @@ TEST_F(ParserInitialCTest, createStable) {
|
|||
"a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, "
|
||||
"a12 TINYINT UNSIGNED, a13 BOOL, a14 NCHAR(30), a15 VARCHAR(50)) "
|
||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1");
|
||||
clearCreateStbReq();
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createStableSemanticCheck) {
|
||||
|
@ -455,13 +470,62 @@ TEST_F(ParserInitialCTest, createStableSemanticCheck) {
|
|||
TEST_F(ParserInitialCTest, createStream) {
|
||||
useDb("root", "test");
|
||||
|
||||
SCMCreateStreamReq expect = {0};
|
||||
|
||||
auto clearCreateStreamReq = [&]() {
|
||||
tFreeSCMCreateStreamReq(&expect);
|
||||
memset(&expect, 0, sizeof(SCMCreateStreamReq));
|
||||
};
|
||||
|
||||
auto setCreateStbReqFunc =
|
||||
[&](const char* pStream, const char* pSrcDb, const char* pSql, const char* pDstStb = nullptr, int8_t igExists = 0,
|
||||
int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0, int64_t watermark = 0) {
|
||||
snprintf(expect.name, sizeof(expect.name), "0.%s", pStream);
|
||||
snprintf(expect.sourceDB, sizeof(expect.sourceDB), "0.%s", pSrcDb);
|
||||
if (NULL != pDstStb) {
|
||||
snprintf(expect.targetStbFullName, sizeof(expect.targetStbFullName), "0.test.%s", pDstStb);
|
||||
}
|
||||
expect.igExists = igExists;
|
||||
expect.sql = strdup(pSql);
|
||||
expect.triggerType = triggerType;
|
||||
expect.maxDelay = maxDelay;
|
||||
expect.watermark = watermark;
|
||||
};
|
||||
|
||||
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_STREAM_STMT);
|
||||
SCMCreateStreamReq req = {0};
|
||||
ASSERT_TRUE(TSDB_CODE_SUCCESS ==
|
||||
tDeserializeSCMCreateStreamReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
||||
|
||||
ASSERT_EQ(std::string(req.name), std::string(expect.name));
|
||||
ASSERT_EQ(std::string(req.sourceDB), std::string(expect.sourceDB));
|
||||
ASSERT_EQ(std::string(req.targetStbFullName), std::string(expect.targetStbFullName));
|
||||
ASSERT_EQ(req.igExists, expect.igExists);
|
||||
ASSERT_EQ(std::string(req.sql), std::string(expect.sql));
|
||||
ASSERT_EQ(req.triggerType, expect.triggerType);
|
||||
ASSERT_EQ(req.maxDelay, expect.maxDelay);
|
||||
ASSERT_EQ(req.watermark, expect.watermark);
|
||||
tFreeSCMCreateStreamReq(&req);
|
||||
});
|
||||
|
||||
setCreateStbReqFunc("s1", "test", "create stream s1 as select * from t1");
|
||||
run("CREATE STREAM s1 AS SELECT * FROM t1");
|
||||
clearCreateStreamReq();
|
||||
|
||||
setCreateStbReqFunc("s1", "test", "create stream if not exists s1 as select * from t1", nullptr, 1);
|
||||
run("CREATE STREAM IF NOT EXISTS s1 AS SELECT * FROM t1");
|
||||
clearCreateStreamReq();
|
||||
|
||||
setCreateStbReqFunc("s1", "test", "create stream s1 into st1 as select * from t1", "st1");
|
||||
run("CREATE STREAM s1 INTO st1 AS SELECT * FROM t1");
|
||||
clearCreateStreamReq();
|
||||
|
||||
run("CREATE STREAM IF NOT EXISTS s1 TRIGGER WINDOW_CLOSE WATERMARK 10s INTO st1 AS SELECT * FROM t1");
|
||||
setCreateStbReqFunc("s1", "test",
|
||||
"create stream if not exists s1 trigger max_delay 20s watermark 10s into st1 as select * from t1",
|
||||
"st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND);
|
||||
run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s INTO st1 AS SELECT * FROM t1");
|
||||
clearCreateStreamReq();
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createTable) {
|
||||
|
@ -497,9 +561,10 @@ TEST_F(ParserInitialCTest, createTopic) {
|
|||
|
||||
SCMCreateTopicReq expect = {0};
|
||||
|
||||
auto clearCreateTopicReq = [&]() { memset(&expect, 0, sizeof(SCMCreateTopicReq)); };
|
||||
|
||||
auto setCreateTopicReqFunc = [&](const char* pTopicName, int8_t igExists, const char* pSql, const char* pAst,
|
||||
const char* pDbName = nullptr, const char* pTbname = nullptr) {
|
||||
memset(&expect, 0, sizeof(SMCreateStbReq));
|
||||
snprintf(expect.name, sizeof(expect.name), "0.%s", pTopicName);
|
||||
expect.igExists = igExists;
|
||||
expect.sql = (char*)pSql;
|
||||
|
@ -538,19 +603,24 @@ TEST_F(ParserInitialCTest, createTopic) {
|
|||
default:
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
tFreeSCMCreateTopicReq(&req);
|
||||
});
|
||||
|
||||
setCreateTopicReqFunc("tp1", 0, "create topic tp1 as select * from t1", "ast");
|
||||
run("CREATE TOPIC tp1 AS SELECT * FROM t1");
|
||||
clearCreateTopicReq();
|
||||
|
||||
setCreateTopicReqFunc("tp1", 1, "create topic if not exists tp1 as select ts, ceil(c1) from t1", "ast");
|
||||
run("CREATE TOPIC IF NOT EXISTS tp1 AS SELECT ts, CEIL(c1) FROM t1");
|
||||
clearCreateTopicReq();
|
||||
|
||||
setCreateTopicReqFunc("tp1", 0, "create topic tp1 as database test", nullptr, "test");
|
||||
run("CREATE TOPIC tp1 AS DATABASE test");
|
||||
clearCreateTopicReq();
|
||||
|
||||
setCreateTopicReqFunc("tp1", 1, "create topic if not exists tp1 as stable st1", nullptr, "test", "st1");
|
||||
run("CREATE TOPIC IF NOT EXISTS tp1 AS STABLE st1");
|
||||
clearCreateTopicReq();
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createUser) {
|
||||
|
|
|
@ -35,6 +35,9 @@ string toString(int32_t code) { return tstrerror(code); }
|
|||
// [...];
|
||||
class InsertTest : public Test {
|
||||
protected:
|
||||
InsertTest() : res_(nullptr) {}
|
||||
~InsertTest() { reset(); }
|
||||
|
||||
void setDatabase(const string& acctId, const string& db) {
|
||||
acctId_ = acctId;
|
||||
db_ = db;
|
||||
|
@ -51,7 +54,7 @@ class InsertTest : public Test {
|
|||
}
|
||||
|
||||
int32_t run() {
|
||||
code_ = parseInsertSql(&cxt_, &res_);
|
||||
code_ = parseInsertSql(&cxt_, &res_, nullptr);
|
||||
if (code_ != TSDB_CODE_SUCCESS) {
|
||||
cout << "code:" << toString(code_) << ", msg:" << errMagBuf_ << endl;
|
||||
}
|
||||
|
@ -60,29 +63,31 @@ class InsertTest : public Test {
|
|||
|
||||
int32_t runAsync() {
|
||||
cxt_.async = true;
|
||||
code_ = parseInsertSyntax(&cxt_, &res_);
|
||||
unique_ptr<SParseMetaCache, void (*)(SParseMetaCache*)> metaCache(new SParseMetaCache(), _destoryParseMetaCache);
|
||||
code_ = parseInsertSyntax(&cxt_, &res_, metaCache.get());
|
||||
if (code_ != TSDB_CODE_SUCCESS) {
|
||||
cout << "parseInsertSyntax code:" << toString(code_) << ", msg:" << errMagBuf_ << endl;
|
||||
return code_;
|
||||
}
|
||||
|
||||
SCatalogReq catalogReq = {0};
|
||||
code_ = buildCatalogReq(res_->pMetaCache, &catalogReq);
|
||||
unique_ptr<SCatalogReq, void (*)(SCatalogReq*)> catalogReq(new SCatalogReq(),
|
||||
MockCatalogService::destoryCatalogReq);
|
||||
code_ = buildCatalogReq(metaCache.get(), catalogReq.get());
|
||||
if (code_ != TSDB_CODE_SUCCESS) {
|
||||
cout << "buildCatalogReq code:" << toString(code_) << ", msg:" << errMagBuf_ << endl;
|
||||
return code_;
|
||||
}
|
||||
|
||||
SMetaData metaData = {0};
|
||||
g_mockCatalogService->catalogGetAllMeta(&catalogReq, &metaData);
|
||||
unique_ptr<SMetaData, void (*)(SMetaData*)> metaData(new SMetaData(), MockCatalogService::destoryMetaData);
|
||||
g_mockCatalogService->catalogGetAllMeta(catalogReq.get(), metaData.get());
|
||||
|
||||
code_ = putMetaDataToCache(&catalogReq, &metaData, res_->pMetaCache);
|
||||
code_ = putMetaDataToCache(catalogReq.get(), metaData.get(), metaCache.get());
|
||||
if (code_ != TSDB_CODE_SUCCESS) {
|
||||
cout << "putMetaDataToCache code:" << toString(code_) << ", msg:" << errMagBuf_ << endl;
|
||||
return code_;
|
||||
}
|
||||
|
||||
code_ = parseInsertSql(&cxt_, &res_);
|
||||
code_ = parseInsertSql(&cxt_, &res_, metaCache.get());
|
||||
if (code_ != TSDB_CODE_SUCCESS) {
|
||||
cout << "parseInsertSql code:" << toString(code_) << ", msg:" << errMagBuf_ << endl;
|
||||
return code_;
|
||||
|
@ -139,12 +144,18 @@ class InsertTest : public Test {
|
|||
static const int max_err_len = 1024;
|
||||
static const int max_sql_len = 1024 * 1024;
|
||||
|
||||
static void _destoryParseMetaCache(SParseMetaCache* pMetaCache) {
|
||||
destoryParseMetaCache(pMetaCache);
|
||||
delete pMetaCache;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
memset(&cxt_, 0, sizeof(cxt_));
|
||||
memset(errMagBuf_, 0, max_err_len);
|
||||
cxt_.pMsg = errMagBuf_;
|
||||
cxt_.msgLen = max_err_len;
|
||||
code_ = TSDB_CODE_SUCCESS;
|
||||
qDestroyQuery(res_);
|
||||
res_ = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ class ParserEnv : public testing::Environment {
|
|||
destroyMetaDataEnv();
|
||||
taosCleanupKeywordsTable();
|
||||
fmFuncMgtDestroy();
|
||||
taosCloseLog();
|
||||
}
|
||||
|
||||
ParserEnv() {}
|
||||
|
|
|
@ -78,33 +78,12 @@ class ParserTestBaseImpl {
|
|||
return;
|
||||
}
|
||||
|
||||
reset(expect, checkStage);
|
||||
try {
|
||||
SParseContext cxt = {0};
|
||||
setParseContext(sql, &cxt);
|
||||
|
||||
SQuery* pQuery = nullptr;
|
||||
doParse(&cxt, &pQuery);
|
||||
|
||||
doAuthenticate(&cxt, pQuery);
|
||||
|
||||
doTranslate(&cxt, pQuery);
|
||||
|
||||
doCalculateConstant(&cxt, pQuery);
|
||||
|
||||
if (g_dump) {
|
||||
dump();
|
||||
}
|
||||
} catch (const TerminateFlag& e) {
|
||||
// success and terminate
|
||||
return;
|
||||
} catch (...) {
|
||||
dump();
|
||||
throw;
|
||||
}
|
||||
runInternalFuncs(sql, expect, checkStage);
|
||||
runApis(sql, expect, checkStage);
|
||||
|
||||
if (g_testAsyncApis) {
|
||||
runAsync(sql, expect, checkStage);
|
||||
runAsyncInternalFuncs(sql, expect, checkStage);
|
||||
runAsyncApis(sql, expect, checkStage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,34 +110,63 @@ class ParserTestBaseImpl {
|
|||
string calcConstAst_;
|
||||
};
|
||||
|
||||
enum TestInterfaceType {
|
||||
TEST_INTERFACE_INTERNAL = 1,
|
||||
TEST_INTERFACE_API,
|
||||
TEST_INTERFACE_ASYNC_INTERNAL,
|
||||
TEST_INTERFACE_ASYNC_API
|
||||
};
|
||||
|
||||
static void _destoryParseMetaCache(SParseMetaCache* pMetaCache) {
|
||||
destoryParseMetaCache(pMetaCache);
|
||||
delete pMetaCache;
|
||||
}
|
||||
|
||||
bool checkResultCode(const string& pFunc, int32_t resultCode) {
|
||||
return !(stmtEnv_.checkFunc_.empty())
|
||||
? (("*" == stmtEnv_.checkFunc_ || stmtEnv_.checkFunc_ == pFunc) ? stmtEnv_.expect_ == resultCode
|
||||
: TSDB_CODE_SUCCESS == resultCode)
|
||||
? ((stmtEnv_.checkFunc_ == pFunc) ? stmtEnv_.expect_ == resultCode : TSDB_CODE_SUCCESS == resultCode)
|
||||
: true;
|
||||
}
|
||||
|
||||
string stageFunc(ParserStage stage) {
|
||||
switch (stage) {
|
||||
case PARSER_STAGE_PARSE:
|
||||
return "parse";
|
||||
case PARSER_STAGE_TRANSLATE:
|
||||
return "translate";
|
||||
case PARSER_STAGE_CALC_CONST:
|
||||
return "calculateConstant";
|
||||
case PARSER_STAGE_ALL:
|
||||
return "*";
|
||||
string stageFunc(ParserStage stage, TestInterfaceType type) {
|
||||
switch (type) {
|
||||
case TEST_INTERFACE_INTERNAL:
|
||||
case TEST_INTERFACE_ASYNC_INTERNAL:
|
||||
switch (stage) {
|
||||
case PARSER_STAGE_PARSE:
|
||||
return "parse";
|
||||
case PARSER_STAGE_TRANSLATE:
|
||||
return "translate";
|
||||
case PARSER_STAGE_CALC_CONST:
|
||||
return "calculateConstant";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TEST_INTERFACE_API:
|
||||
return "qParseSql";
|
||||
case TEST_INTERFACE_ASYNC_API:
|
||||
switch (stage) {
|
||||
case PARSER_STAGE_PARSE:
|
||||
return "qParseSqlSyntax";
|
||||
case PARSER_STAGE_TRANSLATE:
|
||||
case PARSER_STAGE_CALC_CONST:
|
||||
return "qAnalyseSqlSemantic";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
void reset(int32_t expect, ParserStage checkStage) {
|
||||
void reset(int32_t expect, ParserStage checkStage, TestInterfaceType type) {
|
||||
stmtEnv_.sql_.clear();
|
||||
stmtEnv_.msgBuf_.fill(0);
|
||||
stmtEnv_.expect_ = expect;
|
||||
stmtEnv_.checkFunc_ = stageFunc(checkStage);
|
||||
stmtEnv_.checkFunc_ = stageFunc(checkStage, type);
|
||||
|
||||
res_.parsedAst_.clear();
|
||||
res_.translatedAst_.clear();
|
||||
|
@ -167,12 +175,18 @@ class ParserTestBaseImpl {
|
|||
|
||||
void dump() {
|
||||
cout << "==========================================sql : [" << stmtEnv_.sql_ << "]" << endl;
|
||||
cout << "raw syntax tree : " << endl;
|
||||
cout << res_.parsedAst_ << endl;
|
||||
cout << "translated syntax tree : " << endl;
|
||||
cout << res_.translatedAst_ << endl;
|
||||
cout << "optimized syntax tree : " << endl;
|
||||
cout << res_.calcConstAst_ << endl;
|
||||
if (!res_.parsedAst_.empty()) {
|
||||
cout << "raw syntax tree : " << endl;
|
||||
cout << res_.parsedAst_ << endl;
|
||||
}
|
||||
if (!res_.translatedAst_.empty()) {
|
||||
cout << "translated syntax tree : " << endl;
|
||||
cout << res_.translatedAst_ << endl;
|
||||
}
|
||||
if (!res_.calcConstAst_.empty()) {
|
||||
cout << "optimized syntax tree : " << endl;
|
||||
cout << res_.calcConstAst_ << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void setParseContext(const string& sql, SParseContext* pCxt, bool async = false) {
|
||||
|
@ -196,9 +210,8 @@ class ParserTestBaseImpl {
|
|||
res_.parsedAst_ = toString((*pQuery)->pRoot);
|
||||
}
|
||||
|
||||
void doCollectMetaKey(SParseContext* pCxt, SQuery* pQuery) {
|
||||
DO_WITH_THROW(collectMetaKey, pCxt, pQuery);
|
||||
ASSERT_NE(pQuery->pMetaCache, nullptr);
|
||||
void doCollectMetaKey(SParseContext* pCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
|
||||
DO_WITH_THROW(collectMetaKey, pCxt, pQuery, pMetaCache);
|
||||
}
|
||||
|
||||
void doBuildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalogReq) {
|
||||
|
@ -213,10 +226,12 @@ class ParserTestBaseImpl {
|
|||
DO_WITH_THROW(putMetaDataToCache, pCatalogReq, pMetaData, pMetaCache);
|
||||
}
|
||||
|
||||
void doAuthenticate(SParseContext* pCxt, SQuery* pQuery) { DO_WITH_THROW(authenticate, pCxt, pQuery); }
|
||||
void doAuthenticate(SParseContext* pCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
|
||||
DO_WITH_THROW(authenticate, pCxt, pQuery, pMetaCache);
|
||||
}
|
||||
|
||||
void doTranslate(SParseContext* pCxt, SQuery* pQuery) {
|
||||
DO_WITH_THROW(translate, pCxt, pQuery);
|
||||
void doTranslate(SParseContext* pCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
|
||||
DO_WITH_THROW(translate, pCxt, pQuery, pMetaCache);
|
||||
checkQuery(pQuery, PARSER_STAGE_TRANSLATE);
|
||||
res_.translatedAst_ = toString(pQuery->pRoot);
|
||||
}
|
||||
|
@ -226,6 +241,24 @@ class ParserTestBaseImpl {
|
|||
res_.calcConstAst_ = toString(pQuery->pRoot);
|
||||
}
|
||||
|
||||
void doParseSql(SParseContext* pCxt, SQuery** pQuery) {
|
||||
DO_WITH_THROW(qParseSql, pCxt, pQuery);
|
||||
ASSERT_NE(*pQuery, nullptr);
|
||||
res_.calcConstAst_ = toString((*pQuery)->pRoot);
|
||||
}
|
||||
|
||||
void doParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatalogReq) {
|
||||
DO_WITH_THROW(qParseSqlSyntax, pCxt, pQuery, pCatalogReq);
|
||||
ASSERT_NE(*pQuery, nullptr);
|
||||
res_.parsedAst_ = toString((*pQuery)->pRoot);
|
||||
}
|
||||
|
||||
void doAnalyseSqlSemantic(SParseContext* pCxt, const SCatalogReq* pCatalogReq, const SMetaData* pMetaData,
|
||||
SQuery* pQuery) {
|
||||
DO_WITH_THROW(qAnalyseSqlSemantic, pCxt, pCatalogReq, pMetaData, pQuery);
|
||||
res_.calcConstAst_ = toString(pQuery->pRoot);
|
||||
}
|
||||
|
||||
string toString(const SNode* pRoot) {
|
||||
char* pStr = NULL;
|
||||
int32_t len = 0;
|
||||
|
@ -237,31 +270,84 @@ class ParserTestBaseImpl {
|
|||
|
||||
void checkQuery(const SQuery* pQuery, ParserStage stage) { pBase_->checkDdl(pQuery, stage); }
|
||||
|
||||
void runAsync(const string& sql, int32_t expect, ParserStage checkStage) {
|
||||
reset(expect, checkStage);
|
||||
void runInternalFuncs(const string& sql, int32_t expect, ParserStage checkStage) {
|
||||
reset(expect, checkStage, TEST_INTERFACE_INTERNAL);
|
||||
try {
|
||||
SParseContext cxt = {0};
|
||||
setParseContext(sql, &cxt);
|
||||
|
||||
SQuery* pQuery = nullptr;
|
||||
doParse(&cxt, &pQuery);
|
||||
unique_ptr<SQuery, void (*)(SQuery*)> query(pQuery, qDestroyQuery);
|
||||
|
||||
doAuthenticate(&cxt, pQuery, nullptr);
|
||||
|
||||
doTranslate(&cxt, pQuery, nullptr);
|
||||
|
||||
doCalculateConstant(&cxt, pQuery);
|
||||
|
||||
if (g_dump) {
|
||||
dump();
|
||||
}
|
||||
} catch (const TerminateFlag& e) {
|
||||
// success and terminate
|
||||
return;
|
||||
} catch (...) {
|
||||
dump();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void runApis(const string& sql, int32_t expect, ParserStage checkStage) {
|
||||
reset(expect, checkStage, TEST_INTERFACE_API);
|
||||
try {
|
||||
SParseContext cxt = {0};
|
||||
setParseContext(sql, &cxt);
|
||||
|
||||
SQuery* pQuery = nullptr;
|
||||
doParseSql(&cxt, &pQuery);
|
||||
unique_ptr<SQuery, void (*)(SQuery*)> query(pQuery, qDestroyQuery);
|
||||
|
||||
if (g_dump) {
|
||||
dump();
|
||||
}
|
||||
} catch (const TerminateFlag& e) {
|
||||
// success and terminate
|
||||
return;
|
||||
} catch (...) {
|
||||
dump();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void runAsyncInternalFuncs(const string& sql, int32_t expect, ParserStage checkStage) {
|
||||
reset(expect, checkStage, TEST_INTERFACE_ASYNC_INTERNAL);
|
||||
try {
|
||||
SParseContext cxt = {0};
|
||||
setParseContext(sql, &cxt, true);
|
||||
|
||||
SQuery* pQuery = nullptr;
|
||||
doParse(&cxt, &pQuery);
|
||||
unique_ptr<SQuery, void (*)(SQuery*)> query(pQuery, qDestroyQuery);
|
||||
|
||||
doCollectMetaKey(&cxt, pQuery);
|
||||
unique_ptr<SParseMetaCache, void (*)(SParseMetaCache*)> metaCache(new SParseMetaCache(), _destoryParseMetaCache);
|
||||
doCollectMetaKey(&cxt, pQuery, metaCache.get());
|
||||
|
||||
SCatalogReq catalogReq = {0};
|
||||
doBuildCatalogReq(pQuery->pMetaCache, &catalogReq);
|
||||
unique_ptr<SCatalogReq, void (*)(SCatalogReq*)> catalogReq(new SCatalogReq(),
|
||||
MockCatalogService::destoryCatalogReq);
|
||||
doBuildCatalogReq(metaCache.get(), catalogReq.get());
|
||||
|
||||
string err;
|
||||
thread t1([&]() {
|
||||
try {
|
||||
SMetaData metaData = {0};
|
||||
doGetAllMeta(&catalogReq, &metaData);
|
||||
unique_ptr<SMetaData, void (*)(SMetaData*)> metaData(new SMetaData(), MockCatalogService::destoryMetaData);
|
||||
doGetAllMeta(catalogReq.get(), metaData.get());
|
||||
|
||||
doPutMetaDataToCache(&catalogReq, &metaData, pQuery->pMetaCache);
|
||||
doPutMetaDataToCache(catalogReq.get(), metaData.get(), metaCache.get());
|
||||
|
||||
doAuthenticate(&cxt, pQuery);
|
||||
doAuthenticate(&cxt, pQuery, metaCache.get());
|
||||
|
||||
doTranslate(&cxt, pQuery);
|
||||
doTranslate(&cxt, pQuery, metaCache.get());
|
||||
|
||||
doCalculateConstant(&cxt, pQuery);
|
||||
} catch (const TerminateFlag& e) {
|
||||
|
@ -290,6 +376,51 @@ class ParserTestBaseImpl {
|
|||
}
|
||||
}
|
||||
|
||||
void runAsyncApis(const string& sql, int32_t expect, ParserStage checkStage) {
|
||||
reset(expect, checkStage, TEST_INTERFACE_ASYNC_API);
|
||||
try {
|
||||
SParseContext cxt = {0};
|
||||
setParseContext(sql, &cxt);
|
||||
|
||||
unique_ptr<SCatalogReq, void (*)(SCatalogReq*)> catalogReq(new SCatalogReq(),
|
||||
MockCatalogService::destoryCatalogReq);
|
||||
SQuery* pQuery = nullptr;
|
||||
doParseSqlSyntax(&cxt, &pQuery, catalogReq.get());
|
||||
unique_ptr<SQuery, void (*)(SQuery*)> query(pQuery, qDestroyQuery);
|
||||
|
||||
string err;
|
||||
thread t1([&]() {
|
||||
try {
|
||||
unique_ptr<SMetaData, void (*)(SMetaData*)> metaData(new SMetaData(), MockCatalogService::destoryMetaData);
|
||||
doGetAllMeta(catalogReq.get(), metaData.get());
|
||||
|
||||
doAnalyseSqlSemantic(&cxt, catalogReq.get(), metaData.get(), pQuery);
|
||||
} catch (const TerminateFlag& e) {
|
||||
// success and terminate
|
||||
} catch (const runtime_error& e) {
|
||||
err = e.what();
|
||||
} catch (...) {
|
||||
err = "unknown error";
|
||||
}
|
||||
});
|
||||
|
||||
t1.join();
|
||||
if (!err.empty()) {
|
||||
throw runtime_error(err);
|
||||
}
|
||||
|
||||
if (g_dump) {
|
||||
dump();
|
||||
}
|
||||
} catch (const TerminateFlag& e) {
|
||||
// success and terminate
|
||||
return;
|
||||
} catch (...) {
|
||||
dump();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
caseEnv caseEnv_;
|
||||
stmtEnv stmtEnv_;
|
||||
stmtRes res_;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace ParserTest {
|
|||
|
||||
class ParserTestBaseImpl;
|
||||
|
||||
enum ParserStage { PARSER_STAGE_PARSE, PARSER_STAGE_TRANSLATE, PARSER_STAGE_CALC_CONST, PARSER_STAGE_ALL };
|
||||
enum ParserStage { PARSER_STAGE_PARSE = 1, PARSER_STAGE_TRANSLATE, PARSER_STAGE_CALC_CONST };
|
||||
|
||||
class ParserTestBase : public testing::Test {
|
||||
public:
|
||||
|
|
|
@ -138,7 +138,7 @@ static int32_t createRootLogicNode(SLogicPlanContext* pCxt, void* pStmt, uint8_t
|
|||
code = pushLogicNode(pCxt, pRoot, pNode);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode(pNode);
|
||||
nodesDestroyNode((SNode*)pNode);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -173,8 +173,8 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
|
|||
return SCAN_TYPE_TAG;
|
||||
}
|
||||
|
||||
static SNodeptr createPrimaryKeyCol(uint64_t tableId) {
|
||||
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
static SNode* createPrimaryKeyCol(uint64_t tableId) {
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ static SNodeptr createPrimaryKeyCol(uint64_t tableId) {
|
|||
pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
pCol->colType = COLUMN_TYPE_COLUMN;
|
||||
strcpy(pCol->colName, "#primarykey");
|
||||
return pCol;
|
||||
return (SNode*)pCol;
|
||||
}
|
||||
|
||||
static int32_t addPrimaryKeyCol(uint64_t tableId, SNodeList** pCols) {
|
||||
|
@ -282,7 +282,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pScan;
|
||||
} else {
|
||||
nodesDestroyNode(pScan);
|
||||
nodesDestroyNode((SNode*)pScan);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -349,7 +349,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pJoin;
|
||||
} else {
|
||||
nodesDestroyNode(pJoin);
|
||||
nodesDestroyNode((SNode*)pJoin);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -377,7 +377,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pNode->pConditions = nodesCloneNode(pSelect->pWhere);
|
||||
if (NULL != pSelect->pWhere && NULL == pNode->pConditions) {
|
||||
nodesDestroyNode(pNode);
|
||||
nodesDestroyNode((SNode*)pNode);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pNode->precision = pSelect->precision;
|
||||
|
@ -387,7 +387,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel
|
|||
}
|
||||
|
||||
static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr) {
|
||||
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pAgg;
|
||||
} else {
|
||||
nodesDestroyNode(pAgg);
|
||||
nodesDestroyNode((SNode*)pAgg);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -482,7 +482,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pIdfRowsFunc;
|
||||
} else {
|
||||
nodesDestroyNode(pIdfRowsFunc);
|
||||
nodesDestroyNode((SNode*)pIdfRowsFunc);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -514,7 +514,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pWindow;
|
||||
} else {
|
||||
nodesDestroyNode(pWindow);
|
||||
nodesDestroyNode((SNode*)pWindow);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -522,7 +522,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
|
|||
|
||||
static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindowNode* pState, SSelectStmt* pSelect,
|
||||
SLogicNode** pLogicNode) {
|
||||
SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
||||
SWindowLogicNode* pWindow = (SWindowLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
||||
if (NULL == pWindow) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -532,7 +532,7 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo
|
|||
|
||||
pWindow->pTspk = nodesCloneNode(pState->pCol);
|
||||
if (NULL == pWindow->pTspk) {
|
||||
nodesDestroyNode(pWindow);
|
||||
nodesDestroyNode((SNode*)pWindow);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -541,7 +541,7 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo
|
|||
|
||||
static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionWindowNode* pSession,
|
||||
SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||
SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
||||
SWindowLogicNode* pWindow = (SWindowLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
||||
if (NULL == pWindow) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -549,9 +549,9 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW
|
|||
pWindow->winType = WINDOW_TYPE_SESSION;
|
||||
pWindow->sessionGap = ((SValueNode*)pSession->pGap)->datum.i;
|
||||
|
||||
pWindow->pTspk = nodesCloneNode(pSession->pCol);
|
||||
pWindow->pTspk = nodesCloneNode((SNode*)pSession->pCol);
|
||||
if (NULL == pWindow->pTspk) {
|
||||
nodesDestroyNode(pWindow);
|
||||
nodesDestroyNode((SNode*)pWindow);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -560,7 +560,7 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW
|
|||
|
||||
static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SIntervalWindowNode* pInterval,
|
||||
SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||
SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
||||
SWindowLogicNode* pWindow = (SWindowLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
||||
if (NULL == pWindow) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
|
|||
|
||||
pWindow->pTspk = nodesCloneNode(pInterval->pCol);
|
||||
if (NULL == pWindow->pTspk) {
|
||||
nodesDestroyNode(pWindow);
|
||||
nodesDestroyNode((SNode*)pWindow);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -610,7 +610,7 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
|
||||
SFillNode* pFillNode = (SFillNode*)(((SIntervalWindowNode*)pSelect->pWindow)->pFill);
|
||||
|
||||
SFillLogicNode* pFill = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_FILL);
|
||||
SFillLogicNode* pFill = (SFillLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_FILL);
|
||||
if (NULL == pFill) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -628,7 +628,7 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pFill;
|
||||
} else {
|
||||
nodesDestroyNode(pFill);
|
||||
nodesDestroyNode((SNode*)pFill);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -639,7 +639,7 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SSortLogicNode* pSort = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT);
|
||||
SSortLogicNode* pSort = (SSortLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT);
|
||||
if (NULL == pSort) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -656,7 +656,7 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pSort;
|
||||
} else {
|
||||
nodesDestroyNode(pSort);
|
||||
nodesDestroyNode((SNode*)pSort);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -671,7 +671,7 @@ static int32_t createColumnByProjections(SLogicPlanContext* pCxt, const char* pS
|
|||
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pExprs) {
|
||||
if (TSDB_CODE_SUCCESS != nodesListAppend(pList, createColumnByExpr(pStmtName, (SExprNode*)pNode))) {
|
||||
if (TSDB_CODE_SUCCESS != nodesListAppend(pList, (SNode*)createColumnByExpr(pStmtName, (SExprNode*)pNode))) {
|
||||
nodesDestroyList(pList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pProject;
|
||||
} else {
|
||||
nodesDestroyNode(pProject);
|
||||
nodesDestroyNode((SNode*)pProject);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -729,7 +729,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SPartitionLogicNode* pPartition = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PARTITION);
|
||||
SPartitionLogicNode* pPartition = (SPartitionLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PARTITION);
|
||||
if (NULL == pPartition) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pPartition;
|
||||
} else {
|
||||
nodesDestroyNode(pPartition);
|
||||
nodesDestroyNode((SNode*)pPartition);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -783,7 +783,7 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pAgg;
|
||||
} else {
|
||||
nodesDestroyNode(pAgg);
|
||||
nodesDestroyNode((SNode*)pAgg);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -820,7 +820,7 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = pRoot;
|
||||
} else {
|
||||
nodesDestroyNode(pRoot);
|
||||
nodesDestroyNode((SNode*)pRoot);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -836,7 +836,7 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SSortLogicNode* pSort = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT);
|
||||
SSortLogicNode* pSort = (SSortLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT);
|
||||
if (NULL == pSort) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -858,7 +858,7 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pSort;
|
||||
} else {
|
||||
nodesDestroyNode(pSort);
|
||||
nodesDestroyNode((SNode*)pSort);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -894,7 +894,7 @@ static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pProject;
|
||||
} else {
|
||||
nodesDestroyNode(pProject);
|
||||
nodesDestroyNode((SNode*)pProject);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -925,7 +925,7 @@ static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pS
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pAgg;
|
||||
} else {
|
||||
nodesDestroyNode(pAgg);
|
||||
nodesDestroyNode((SNode*)pAgg);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -964,7 +964,7 @@ static int32_t createSetOpLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetO
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pSetOp;
|
||||
} else {
|
||||
nodesDestroyNode(pSetOp);
|
||||
nodesDestroyNode((SNode*)pSetOp);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -981,7 +981,7 @@ static int32_t createSetOperatorLogicNode(SLogicPlanContext* pCxt, SSetOperator*
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = pRoot;
|
||||
} else {
|
||||
nodesDestroyNode(pRoot);
|
||||
nodesDestroyNode((SNode*)pRoot);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1003,7 +1003,7 @@ static int32_t getMsgType(ENodeType sqlType) {
|
|||
}
|
||||
|
||||
static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpStmt* pStmt, SLogicNode** pLogicNode) {
|
||||
SVnodeModifyLogicNode* pModif = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY);
|
||||
SVnodeModifyLogicNode* pModif = (SVnodeModifyLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY);
|
||||
if (NULL == pModif) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1047,7 +1047,7 @@ static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pScan;
|
||||
} else {
|
||||
nodesDestroyNode(pScan);
|
||||
nodesDestroyNode((SNode*)pScan);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1071,7 +1071,7 @@ static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pD
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pAgg;
|
||||
} else {
|
||||
nodesDestroyNode(pAgg);
|
||||
nodesDestroyNode((SNode*)pAgg);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1094,7 +1094,7 @@ static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDelet
|
|||
pModify->deleteTimeRange = pDelete->timeRange;
|
||||
pModify->pAffectedRows = nodesCloneNode(pDelete->pCountFunc);
|
||||
if (NULL == pModify->pAffectedRows) {
|
||||
nodesDestroyNode(pModify);
|
||||
nodesDestroyNode((SNode*)pModify);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -1115,7 +1115,7 @@ static int32_t createDeleteLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDele
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = pRoot;
|
||||
} else {
|
||||
nodesDestroyNode(pRoot);
|
||||
nodesDestroyNode((SNode*)pRoot);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1171,7 +1171,7 @@ int32_t createLogicPlan(SPlanContext* pCxt, SLogicSubplan** pLogicSubplan) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicSubplan = pSubplan;
|
||||
} else {
|
||||
nodesDestroyNode(pSubplan);
|
||||
nodesDestroyNode((SNode*)pSubplan);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
|
@ -247,7 +247,7 @@ static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan)
|
|||
}
|
||||
|
||||
static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) {
|
||||
SLogicConditionNode* pLogicCond = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SLogicConditionNode* pLogicCond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
if (NULL == pLogicCond) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pDst = (SNode*)pLogicCond;
|
||||
} else {
|
||||
nodesDestroyNode(pLogicCond);
|
||||
nodesDestroyNode((SNode*)pLogicCond);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -662,13 +662,13 @@ static int32_t opkGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeL
|
|||
switch (nodeType(pNode)) {
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
if (TSDB_SUPER_TABLE != ((SScanLogicNode*)pNode)->tableType) {
|
||||
return nodesListMakeAppend(pScanNodes, pNode);
|
||||
return nodesListMakeAppend(pScanNodes, (SNode*)pNode);
|
||||
}
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||
code = opkGetScanNodesImpl(nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes);
|
||||
code = opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = opkGetScanNodesImpl(nodesListGetNode(pNode->pChildren, 1), pNotOptimize, pScanNodes);
|
||||
code = opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 1), pNotOptimize, pScanNodes);
|
||||
}
|
||||
return code;
|
||||
case QUERY_NODE_LOGIC_PLAN_AGG:
|
||||
|
@ -683,7 +683,7 @@ static int32_t opkGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeL
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
return opkGetScanNodesImpl(nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes);
|
||||
return opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes);
|
||||
}
|
||||
|
||||
static int32_t opkGetScanNodes(SLogicNode* pNode, SNodeList** pScanNodes) {
|
||||
|
@ -721,12 +721,12 @@ static int32_t opkDoOptimized(SOptimizeContext* pCxt, SSortLogicNode* pSort, SNo
|
|||
SNode* pDownNode = opkRewriteDownNode(pSort);
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pSort->node.pParent->pChildren) {
|
||||
if (nodesEqualNode(pNode, pSort)) {
|
||||
if (nodesEqualNode(pNode, (SNode*)pSort)) {
|
||||
REPLACE_NODE(pDownNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
nodesDestroyNode(pSort);
|
||||
nodesDestroyNode((SNode*)pSort);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -736,7 +736,7 @@ static int32_t opkOptimizeImpl(SOptimizeContext* pCxt, SSortLogicNode* pSort) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
SNodeList* pScanNodes = NULL;
|
||||
int32_t code = opkGetScanNodes(nodesListGetNode(pSort->node.pChildren, 0), &pScanNodes);
|
||||
int32_t code = opkGetScanNodes((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0), &pScanNodes);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pScanNodes) {
|
||||
code = opkDoOptimized(pCxt, pSort, pScanNodes);
|
||||
}
|
||||
|
@ -768,7 +768,7 @@ static bool smaOptMayBeOptimized(SLogicNode* pNode) {
|
|||
}
|
||||
|
||||
static int32_t smaOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNodeList* pTargets, SLogicNode** pOutput) {
|
||||
SMergeLogicNode* pMerge = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE);
|
||||
SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE);
|
||||
if (NULL == pMerge) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -778,7 +778,7 @@ static int32_t smaOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNod
|
|||
pMerge->node.pTargets = pTargets;
|
||||
pMerge->pInputs = nodesCloneList(pChild->pTargets);
|
||||
if (NULL == pMerge->pInputs) {
|
||||
nodesDestroyNode(pMerge);
|
||||
nodesDestroyNode((SNode*)pMerge);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -788,9 +788,9 @@ static int32_t smaOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNod
|
|||
|
||||
static int32_t smaOptRecombinationNode(SLogicSubplan* pLogicSubplan, SLogicNode* pInterval, SLogicNode* pMerge,
|
||||
SLogicNode* pSmaScan) {
|
||||
int32_t code = nodesListMakeAppend(&pMerge->pChildren, pInterval);
|
||||
int32_t code = nodesListMakeAppend(&pMerge->pChildren, (SNode*)pInterval);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pMerge->pChildren, pSmaScan);
|
||||
code = nodesListMakeAppend(&pMerge->pChildren, (SNode*)pSmaScan);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = replaceLogicNode(pLogicSubplan, pInterval, pMerge);
|
||||
|
@ -802,7 +802,7 @@ static int32_t smaOptRecombinationNode(SLogicSubplan* pLogicSubplan, SLogicNode*
|
|||
|
||||
static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pIndex, SNodeList* pCols,
|
||||
SLogicNode** pOutput) {
|
||||
SScanLogicNode* pSmaScan = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN);
|
||||
SScanLogicNode* pSmaScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN);
|
||||
if (NULL == pSmaScan) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -819,7 +819,7 @@ static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pInde
|
|||
pSmaScan->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo));
|
||||
pSmaScan->node.pTargets = nodesCloneList(pCols);
|
||||
if (NULL == pSmaScan->pVgroupList || NULL == pSmaScan->node.pTargets) {
|
||||
nodesDestroyNode(pSmaScan);
|
||||
nodesDestroyNode((SNode*)pSmaScan);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pSmaScan->pVgroupList->numOfVgroups = 1;
|
||||
|
@ -851,7 +851,7 @@ static bool smaOptEqualInterval(SScanLogicNode* pScan, SWindowLogicNode* pWindow
|
|||
}
|
||||
|
||||
static SNode* smaOptCreateSmaCol(SNode* pFunc, uint64_t tableId, int32_t colId) {
|
||||
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -926,32 +926,32 @@ static int32_t smaOptCouldApplyIndex(SScanLogicNode* pScan, STableIndexInfo* pIn
|
|||
}
|
||||
|
||||
static SNode* smaOptCreateWStartTs() {
|
||||
SFunctionNode* pWStart = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pWStart = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pWStart) {
|
||||
return NULL;
|
||||
}
|
||||
strcpy(pWStart->functionName, "_wstartts");
|
||||
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart);
|
||||
if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pWStart, NULL, 0)) {
|
||||
nodesDestroyNode(pWStart);
|
||||
nodesDestroyNode((SNode*)pWStart);
|
||||
return NULL;
|
||||
}
|
||||
return (SNode*)pWStart;
|
||||
}
|
||||
|
||||
static int32_t smaOptCreateMergeKey(SNode* pCol, SNodeList** pMergeKeys) {
|
||||
SOrderByExprNode* pMergeKey = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
|
||||
SOrderByExprNode* pMergeKey = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
|
||||
if (NULL == pMergeKey) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pMergeKey->pExpr = nodesCloneNode(pCol);
|
||||
if (NULL == pMergeKey->pExpr) {
|
||||
nodesDestroyNode(pMergeKey);
|
||||
nodesDestroyNode((SNode*)pMergeKey);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pMergeKey->order = ORDER_ASC;
|
||||
pMergeKey->nullOrder = NULL_ORDER_FIRST;
|
||||
return nodesListMakeStrictAppend(pMergeKeys, pMergeKey);
|
||||
return nodesListMakeStrictAppend(pMergeKeys, (SNode*)pMergeKey);
|
||||
}
|
||||
|
||||
static int32_t smaOptRewriteInterval(SWindowLogicNode* pInterval, int32_t wstrartIndex, SNodeList** pMergeKeys) {
|
||||
|
|
|
@ -56,14 +56,14 @@ static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char* pKey) {
|
|||
return sprintf(pKey, "%s", ((SExprNode*)pNode)->aliasName);
|
||||
}
|
||||
|
||||
static SNode* createSlotDesc(SPhysiPlanContext* pCxt, const SNode* pNode, int16_t slotId, bool output) {
|
||||
static SNode* createSlotDesc(SPhysiPlanContext* pCxt, const SNode* pNode, int16_t slotId, bool output, bool reserve) {
|
||||
SSlotDescNode* pSlot = (SSlotDescNode*)nodesMakeNode(QUERY_NODE_SLOT_DESC);
|
||||
if (NULL == pSlot) {
|
||||
return NULL;
|
||||
}
|
||||
pSlot->slotId = slotId;
|
||||
pSlot->dataType = ((SExprNode*)pNode)->resType;
|
||||
pSlot->reserve = false;
|
||||
pSlot->reserve = reserve;
|
||||
pSlot->output = output;
|
||||
return (SNode*)pSlot;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ static int32_t buildDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SD
|
|||
int16_t slotId = 0;
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, pList) {
|
||||
code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pNode, slotId, true));
|
||||
code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pNode, slotId, true, false));
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putSlotToHash(pDataBlockDesc->dataBlockId, slotId, pNode, pHash);
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ static int32_t buildDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SD
|
|||
}
|
||||
|
||||
static int32_t createDataBlockDesc(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode** pDataBlockDesc) {
|
||||
SDataBlockDescNode* pDesc = nodesMakeNode(QUERY_NODE_DATABLOCK_DESC);
|
||||
SDataBlockDescNode* pDesc = (SDataBlockDescNode*)nodesMakeNode(QUERY_NODE_DATABLOCK_DESC);
|
||||
if (NULL == pDesc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ static int32_t createDataBlockDesc(SPhysiPlanContext* pCxt, SNodeList* pList, SD
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pDataBlockDesc = pDesc;
|
||||
} else {
|
||||
nodesDestroyNode(pDesc);
|
||||
nodesDestroyNode((SNode*)pDesc);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -181,7 +181,7 @@ static int16_t getUnsetSlotId(const SArray* pSlotIdsInfo) {
|
|||
}
|
||||
|
||||
static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc,
|
||||
const char* pStmtName, bool output) {
|
||||
const char* pStmtName, bool output, bool reserve) {
|
||||
if (NULL == pList) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList,
|
|||
int32_t len = getSlotKey(pExpr, pStmtName, name);
|
||||
SSlotIndex* pIndex = taosHashGet(pHash, name, len);
|
||||
if (NULL == pIndex) {
|
||||
code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pExpr, nextSlotId, output));
|
||||
code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pExpr, nextSlotId, output, reserve));
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putSlotToHashImpl(pDataBlockDesc->dataBlockId, nextSlotId, name, len, pHash);
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList,
|
|||
}
|
||||
|
||||
static int32_t addDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc) {
|
||||
return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, NULL, false);
|
||||
return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, NULL, false, false);
|
||||
}
|
||||
|
||||
static int32_t addDataBlockSlot(SPhysiPlanContext* pCxt, SNode** pNode, SDataBlockDescNode* pDataBlockDesc) {
|
||||
|
@ -248,11 +248,11 @@ static int32_t addDataBlockSlot(SPhysiPlanContext* pCxt, SNode** pNode, SDataBlo
|
|||
|
||||
static int32_t addDataBlockSlotsForProject(SPhysiPlanContext* pCxt, const char* pStmtName, SNodeList* pList,
|
||||
SDataBlockDescNode* pDataBlockDesc) {
|
||||
return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, pStmtName, true);
|
||||
return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, pStmtName, true, false);
|
||||
}
|
||||
|
||||
static int32_t pushdownDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc) {
|
||||
return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, NULL, true);
|
||||
return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, NULL, true, true);
|
||||
}
|
||||
|
||||
typedef struct SSetSlotIdCxt {
|
||||
|
@ -350,7 +350,7 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode
|
|||
|
||||
int32_t code = createDataBlockDesc(pCxt, pLogicNode->pTargets, &pPhysiNode->pOutputDataBlockDesc);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode(pPhysiNode);
|
||||
nodesDestroyNode((SNode*)pPhysiNode);
|
||||
return NULL;
|
||||
}
|
||||
pPhysiNode->pOutputDataBlockDesc->precision = pLogicNode->precision;
|
||||
|
@ -439,7 +439,7 @@ static int32_t createScanPhysiNodeFinalize(SPhysiPlanContext* pCxt, SSubplan* pS
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhyNode = (SPhysiNode*)pScanPhysiNode;
|
||||
} else {
|
||||
nodesDestroyNode(pScanPhysiNode);
|
||||
nodesDestroyNode((SNode*)pScanPhysiNode);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -486,7 +486,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
|
|||
pTableScan->dataRequired = pScanLogicNode->dataRequired;
|
||||
pTableScan->pDynamicScanFuncs = nodesCloneList(pScanLogicNode->pDynamicScanFuncs);
|
||||
if (NULL != pScanLogicNode->pDynamicScanFuncs && NULL == pTableScan->pDynamicScanFuncs) {
|
||||
nodesDestroyNode(pTableScan);
|
||||
nodesDestroyNode((SNode*)pTableScan);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pTableScan->interval = pScanLogicNode->interval;
|
||||
|
@ -584,7 +584,7 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhyNode = (SPhysiNode*)pJoin;
|
||||
} else {
|
||||
nodesDestroyNode(pJoin);
|
||||
nodesDestroyNode((SNode*)pJoin);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -635,7 +635,7 @@ static int32_t rewriteValueToOperator(SRewritePrecalcExprsCxt* pCxt, SNode** pNo
|
|||
}
|
||||
pOper->pLeft = nodesMakeNode(QUERY_NODE_LEFT_VALUE);
|
||||
if (NULL == pOper->pLeft) {
|
||||
nodesDestroyNode(pOper);
|
||||
nodesDestroyNode((SNode*)pOper);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
SValueNode* pVal = (SValueNode*)*pNode;
|
||||
|
@ -782,7 +782,7 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhyNode = (SPhysiNode*)pAgg;
|
||||
} else {
|
||||
nodesDestroyNode(pAgg);
|
||||
nodesDestroyNode((SNode*)pAgg);
|
||||
}
|
||||
|
||||
nodesDestroyList(pPrecalcExprs);
|
||||
|
@ -823,7 +823,7 @@ static int32_t createIndefRowsFuncPhysiNode(SPhysiPlanContext* pCxt, SNodeList*
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhyNode = (SPhysiNode*)pIdfRowsFunc;
|
||||
} else {
|
||||
nodesDestroyNode(pIdfRowsFunc);
|
||||
nodesDestroyNode((SNode*)pIdfRowsFunc);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -855,7 +855,7 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhyNode = (SPhysiNode*)pProject;
|
||||
} else {
|
||||
nodesDestroyNode(pProject);
|
||||
nodesDestroyNode((SNode*)pProject);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -904,7 +904,7 @@ static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExc
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhyNode = (SPhysiNode*)pScan;
|
||||
} else {
|
||||
nodesDestroyNode(pScan);
|
||||
nodesDestroyNode((SNode*)pScan);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -952,7 +952,7 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList*
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhyNode = (SPhysiNode*)pWindow;
|
||||
} else {
|
||||
nodesDestroyNode(pWindow);
|
||||
nodesDestroyNode((SNode*)pWindow);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1037,7 +1037,7 @@ static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pC
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode(pState);
|
||||
nodesDestroyNode((SNode*)pState);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1094,7 +1094,7 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhyNode = (SPhysiNode*)pSort;
|
||||
} else {
|
||||
nodesDestroyNode(pSort);
|
||||
nodesDestroyNode((SNode*)pSort);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1117,7 +1117,7 @@ static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi
|
|||
if (TSDB_CODE_SUCCESS == code && NULL != pPrecalcExprs) {
|
||||
code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pPrecalcExprs, &pPart->pExprs);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = addDataBlockSlots(pCxt, pPart->pExprs, pChildTupe);
|
||||
code = pushdownDataBlockSlots(pCxt, pPart->pExprs, pChildTupe);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhyNode = (SPhysiNode*)pPart;
|
||||
} else {
|
||||
nodesDestroyNode(pPart);
|
||||
nodesDestroyNode((SNode*)pPart);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1174,28 +1174,28 @@ static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhyNode = (SPhysiNode*)pFill;
|
||||
} else {
|
||||
nodesDestroyNode(pFill);
|
||||
nodesDestroyNode((SNode*)pFill);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t createExchangePhysiNodeByMerge(SMergePhysiNode* pMerge) {
|
||||
SExchangePhysiNode* pExchange = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_EXCHANGE);
|
||||
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_EXCHANGE);
|
||||
if (NULL == pExchange) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pExchange->srcGroupId = pMerge->srcGroupId;
|
||||
pExchange->singleChannel = true;
|
||||
pExchange->node.pParent = (SPhysiNode*)pMerge;
|
||||
pExchange->node.pOutputDataBlockDesc = nodesCloneNode(pMerge->node.pOutputDataBlockDesc);
|
||||
pExchange->node.pOutputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pMerge->node.pOutputDataBlockDesc);
|
||||
if (NULL == pExchange->node.pOutputDataBlockDesc) {
|
||||
nodesDestroyNode(pExchange);
|
||||
nodesDestroyNode((SNode*)pExchange);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
SNode* pSlot = NULL;
|
||||
FOREACH(pSlot, pExchange->node.pOutputDataBlockDesc->pSlots) { ((SSlotDescNode*)pSlot)->output = true; }
|
||||
return nodesListMakeStrictAppend(&pMerge->node.pChildren, pExchange);
|
||||
return nodesListMakeStrictAppend(&pMerge->node.pChildren, (SNode*)pExchange);
|
||||
}
|
||||
|
||||
static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SMergeLogicNode* pMergeLogicNode, SPhysiNode** pPhyNode) {
|
||||
|
@ -1235,7 +1235,7 @@ static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SMergeLogicNode* pM
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhyNode = (SPhysiNode*)pMerge;
|
||||
} else {
|
||||
nodesDestroyNode(pMerge);
|
||||
nodesDestroyNode((SNode*)pMerge);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1287,7 +1287,7 @@ static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode,
|
|||
SPhysiNode* pChild = NULL;
|
||||
code = createPhysiNode(pCxt, (SLogicNode*)pLogicChild, pSubplan, &pChild);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(pChildren, pChild);
|
||||
code = nodesListStrictAppend(pChildren, (SNode*)pChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1311,7 +1311,7 @@ static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode,
|
|||
}
|
||||
|
||||
static int32_t createDataInserter(SPhysiPlanContext* pCxt, SVgDataBlocks* pBlocks, SDataSinkNode** pSink) {
|
||||
SDataInserterNode* pInserter = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT);
|
||||
SDataInserterNode* pInserter = (SDataInserterNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT);
|
||||
if (NULL == pInserter) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1325,14 +1325,14 @@ static int32_t createDataInserter(SPhysiPlanContext* pCxt, SVgDataBlocks* pBlock
|
|||
}
|
||||
|
||||
static int32_t createDataDispatcher(SPhysiPlanContext* pCxt, const SPhysiNode* pRoot, SDataSinkNode** pSink) {
|
||||
SDataDispatcherNode* pDispatcher = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH);
|
||||
SDataDispatcherNode* pDispatcher = (SDataDispatcherNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH);
|
||||
if (NULL == pDispatcher) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pDispatcher->sink.pInputDataBlockDesc = nodesCloneNode(pRoot->pOutputDataBlockDesc);
|
||||
pDispatcher->sink.pInputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pRoot->pOutputDataBlockDesc);
|
||||
if (NULL == pDispatcher->sink.pInputDataBlockDesc) {
|
||||
nodesDestroyNode(pDispatcher);
|
||||
nodesDestroyNode((SNode*)pDispatcher);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -1341,7 +1341,7 @@ static int32_t createDataDispatcher(SPhysiPlanContext* pCxt, const SPhysiNode* p
|
|||
}
|
||||
|
||||
static SSubplan* makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan) {
|
||||
SSubplan* pSubplan = nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN);
|
||||
SSubplan* pSubplan = (SSubplan*)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN);
|
||||
if (NULL == pSubplan) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1361,7 +1361,7 @@ static int32_t buildInsertSubplan(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode
|
|||
|
||||
static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pModify, const SPhysiNode* pRoot,
|
||||
SDataSinkNode** pSink) {
|
||||
SDataDeleterNode* pDeleter = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DELETE);
|
||||
SDataDeleterNode* pDeleter = (SDataDeleterNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DELETE);
|
||||
if (NULL == pDeleter) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1374,7 +1374,7 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode*
|
|||
int32_t code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pAffectedRows,
|
||||
&pDeleter->pAffectedRows);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pDeleter->sink.pInputDataBlockDesc = nodesCloneNode(pRoot->pOutputDataBlockDesc);
|
||||
pDeleter->sink.pInputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pRoot->pOutputDataBlockDesc);
|
||||
if (NULL == pDeleter->sink.pInputDataBlockDesc) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1383,7 +1383,7 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode*
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pSink = (SDataSinkNode*)pDeleter;
|
||||
} else {
|
||||
nodesDestroyNode(pDeleter);
|
||||
nodesDestroyNode((SNode*)pDeleter);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1437,38 +1437,38 @@ static int32_t createPhysiSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogic
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhysiSubplan = pSubplan;
|
||||
} else {
|
||||
nodesDestroyNode(pSubplan);
|
||||
nodesDestroyNode((SNode*)pSubplan);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static SQueryPlan* makeQueryPhysiPlan(SPhysiPlanContext* pCxt) {
|
||||
SQueryPlan* pPlan = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN);
|
||||
SQueryPlan* pPlan = (SQueryPlan*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN);
|
||||
if (NULL == pPlan) {
|
||||
return NULL;
|
||||
}
|
||||
pPlan->pSubplans = nodesMakeList();
|
||||
if (NULL == pPlan->pSubplans) {
|
||||
nodesDestroyNode(pPlan);
|
||||
nodesDestroyNode((SNode*)pPlan);
|
||||
return NULL;
|
||||
}
|
||||
pPlan->queryId = pCxt->pPlanCxt->queryId;
|
||||
return pPlan;
|
||||
}
|
||||
|
||||
static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNodeptr pSubplan, int32_t level, SNodeList* pSubplans) {
|
||||
SNodeListNode* pGroup;
|
||||
static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNode* pSubplan, int32_t level, SNodeList* pSubplans) {
|
||||
SNodeListNode* pGroup = NULL;
|
||||
if (level >= LIST_LENGTH(pSubplans)) {
|
||||
pGroup = nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
pGroup = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
if (NULL == pGroup) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pSubplans, pGroup)) {
|
||||
if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pSubplans, (SNode*)pGroup)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
} else {
|
||||
pGroup = nodesListGetNode(pSubplans, level);
|
||||
pGroup = (SNodeListNode*)nodesListGetNode(pSubplans, level);
|
||||
}
|
||||
if (NULL == pGroup->pNodeList) {
|
||||
pGroup->pNodeList = nodesMakeList();
|
||||
|
@ -1476,7 +1476,7 @@ static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNodeptr pSubplan, int32_t l
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
return nodesListStrictAppend(pGroup->pNodeList, pSubplan);
|
||||
return nodesListStrictAppend(pGroup->pNodeList, (SNode*)pSubplan);
|
||||
}
|
||||
|
||||
static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan* pParent,
|
||||
|
@ -1485,19 +1485,19 @@ static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubp
|
|||
int32_t code = createPhysiSubplan(pCxt, pLogicSubplan, &pSubplan);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = pushSubplan(pCxt, pSubplan, pLogicSubplan->level, pQueryPlan->pSubplans);
|
||||
code = pushSubplan(pCxt, (SNode*)pSubplan, pLogicSubplan->level, pQueryPlan->pSubplans);
|
||||
++(pQueryPlan->numOfSubplans);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode(pSubplan);
|
||||
nodesDestroyNode((SNode*)pSubplan);
|
||||
return code;
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pParent) {
|
||||
code = nodesListMakeAppend(&pParent->pChildren, pSubplan);
|
||||
code = nodesListMakeAppend(&pParent->pChildren, (SNode*)pSubplan);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pSubplan->pParents, pParent);
|
||||
code = nodesListMakeAppend(&pSubplan->pParents, (SNode*)pParent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1515,7 +1515,7 @@ static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubp
|
|||
}
|
||||
|
||||
static int32_t doCreatePhysiPlan(SPhysiPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPhysiPlan) {
|
||||
SQueryPlan* pPlan = makeQueryPhysiPlan(pCxt);
|
||||
SQueryPlan* pPlan = (SQueryPlan*)makeQueryPhysiPlan(pCxt);
|
||||
if (NULL == pPlan) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1533,7 +1533,7 @@ static int32_t doCreatePhysiPlan(SPhysiPlanContext* pCxt, SQueryLogicPlan* pLogi
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPhysiPlan = pPlan;
|
||||
} else {
|
||||
nodesDestroyNode(pPlan);
|
||||
nodesDestroyNode((SNode*)pPlan);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
|
@ -21,13 +21,13 @@ typedef struct SScaleOutContext {
|
|||
} SScaleOutContext;
|
||||
|
||||
static SLogicSubplan* singleCloneSubLogicPlan(SScaleOutContext* pCxt, SLogicSubplan* pSrc, int32_t level) {
|
||||
SLogicSubplan* pDst = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
||||
SLogicSubplan* pDst = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
||||
if (NULL == pDst) {
|
||||
return NULL;
|
||||
}
|
||||
pDst->pNode = nodesCloneNode(pSrc->pNode);
|
||||
pDst->pNode = (SLogicNode*)nodesCloneNode((SNode*)pSrc->pNode);
|
||||
if (NULL == pDst->pNode) {
|
||||
nodesDestroyNode(pDst);
|
||||
nodesDestroyNode((SNode*)pDst);
|
||||
return NULL;
|
||||
}
|
||||
pDst->subplanType = pSrc->subplanType;
|
||||
|
@ -73,7 +73,7 @@ static int32_t scaleOutByVgroups(SScaleOutContext* pCxt, SLogicSubplan* pSubplan
|
|||
}
|
||||
code = setScanVgroup(pNewSubplan->pNode, pSubplan->pVgroupList->vgroups + i);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(pGroup, pNewSubplan);
|
||||
code = nodesListStrictAppend(pGroup, (SNode*)pNewSubplan);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
break;
|
||||
|
@ -95,7 +95,7 @@ static int32_t scaleOutForModify(SScaleOutContext* pCxt, SLogicSubplan* pSubplan
|
|||
}
|
||||
((SVnodeModifyLogicNode*)pNewSubplan->pNode)->pVgDataBlocks =
|
||||
(SVgDataBlocks*)taosArrayGetP(pNode->pDataBlocks, i);
|
||||
if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pGroup, pNewSubplan)) {
|
||||
if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pGroup, (SNode*)pNewSubplan)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ static int32_t scaleOutForModify(SScaleOutContext* pCxt, SLogicSubplan* pSubplan
|
|||
}
|
||||
|
||||
static int32_t scaleOutForMerge(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) {
|
||||
return nodesListStrictAppend(pGroup, singleCloneSubLogicPlan(pCxt, pSubplan, level));
|
||||
return nodesListStrictAppend(pGroup, (SNode*)singleCloneSubLogicPlan(pCxt, pSubplan, level));
|
||||
}
|
||||
|
||||
static int32_t scaleOutForScan(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) {
|
||||
|
@ -189,7 +189,7 @@ static SQueryLogicPlan* makeQueryLogicPlan() {
|
|||
}
|
||||
pLogicPlan->pTopSubplans = nodesMakeList();
|
||||
if (NULL == pLogicPlan->pTopSubplans) {
|
||||
nodesDestroyNode(pLogicPlan);
|
||||
nodesDestroyNode((SNode*)pLogicPlan);
|
||||
return NULL;
|
||||
}
|
||||
return pLogicPlan;
|
||||
|
@ -206,7 +206,7 @@ int32_t scaleOutLogicPlan(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SQue
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicPlan = pPlan;
|
||||
} else {
|
||||
nodesDestroyNode(pPlan);
|
||||
nodesDestroyNode((SNode*)pPlan);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
|
@ -50,7 +50,7 @@ static void splSetSubplanVgroups(SLogicSubplan* pSubplan, SLogicNode* pNode) {
|
|||
}
|
||||
|
||||
static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SLogicNode* pNode, int32_t flag) {
|
||||
SLogicSubplan* pSubplan = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
||||
SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
||||
if (NULL == pSubplan) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SLogicNode* pNod
|
|||
}
|
||||
|
||||
static int32_t splCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pChild, SExchangeLogicNode** pOutput) {
|
||||
SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||
SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||
if (NULL == pExchange) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ static int32_t splCreateExchangeNodeForSubplan(SSplitContext* pCxt, SLogicSubpla
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pSubplan->subplanType = subplanType;
|
||||
} else {
|
||||
nodesDestroyNode(pExchange);
|
||||
nodesDestroyNode((SNode*)pExchange);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -191,21 +191,21 @@ static int32_t stbSplRewriteFuns(const SNodeList* pFuncs, SNodeList** pPartialFu
|
|||
SFunctionNode* pMergeFunc = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (fmIsWindowPseudoColumnFunc(pFunc->funcId)) {
|
||||
pPartFunc = nodesCloneNode(pFunc);
|
||||
pMergeFunc = nodesCloneNode(pFunc);
|
||||
pPartFunc = (SFunctionNode*)nodesCloneNode(pNode);
|
||||
pMergeFunc = (SFunctionNode*)nodesCloneNode(pNode);
|
||||
if (NULL == pPartFunc || NULL == pMergeFunc) {
|
||||
nodesDestroyNode(pPartFunc);
|
||||
nodesDestroyNode(pMergeFunc);
|
||||
nodesDestroyNode((SNode*)pPartFunc);
|
||||
nodesDestroyNode((SNode*)pMergeFunc);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
} else {
|
||||
code = fmGetDistMethod(pFunc, &pPartFunc, &pMergeFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(pPartialFuncs, pPartFunc);
|
||||
code = nodesListMakeStrictAppend(pPartialFuncs, (SNode*)pPartFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(pMergeFuncs, pMergeFunc);
|
||||
code = nodesListMakeStrictAppend(pMergeFuncs, (SNode*)pMergeFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(*pPartialFuncs);
|
||||
|
@ -227,7 +227,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) {
|
|||
++index;
|
||||
}
|
||||
|
||||
SFunctionNode* pWStart = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pWStart = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pWStart) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) {
|
|||
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart);
|
||||
int32_t code = fmGetFuncInfo(pWStart, NULL, 0);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(pFuncs, pWStart);
|
||||
code = nodesListStrictAppend(pFuncs, (SNode*)pWStart);
|
||||
}
|
||||
*pIndex = index;
|
||||
return code;
|
||||
|
@ -250,7 +250,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
|
|||
pMergeWindow->node.pChildren = NULL;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SWindowLogicNode* pPartWin = nodesCloneNode(pMergeWindow);
|
||||
SWindowLogicNode* pPartWin = (SWindowLogicNode*)nodesCloneNode((SNode*)pMergeWindow);
|
||||
if (NULL == pPartWin) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pPartWindow = (SLogicNode*)pPartWin;
|
||||
} else {
|
||||
nodesDestroyNode(pPartWin);
|
||||
nodesDestroyNode((SNode*)pPartWin);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -287,7 +287,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
|
|||
|
||||
static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pSplitNode,
|
||||
SNodeList* pMergeKeys, SLogicNode* pPartChild) {
|
||||
SMergeLogicNode* pMerge = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE);
|
||||
SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE);
|
||||
if (NULL == pMerge) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -309,13 +309,13 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla
|
|||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL == pSubplan) {
|
||||
code = nodesListMakeAppend(&pSplitNode->pChildren, pMerge);
|
||||
code = nodesListMakeAppend(&pSplitNode->pChildren, (SNode*)pMerge);
|
||||
} else {
|
||||
code = replaceLogicNode(pSubplan, pSplitNode, (SLogicNode*)pMerge);
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode(pMerge);
|
||||
nodesDestroyNode((SNode*)pMerge);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -324,24 +324,24 @@ static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent
|
|||
SExchangeLogicNode* pExchange = NULL;
|
||||
int32_t code = splCreateExchangeNode(pCxt, pPartChild, &pExchange);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pParent->pChildren, pExchange);
|
||||
code = nodesListMakeAppend(&pParent->pChildren, (SNode*)pExchange);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t stbSplCreateMergeKeysForInterval(SNode* pWStartTs, SNodeList** pMergeKeys) {
|
||||
SOrderByExprNode* pMergeKey = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
|
||||
SOrderByExprNode* pMergeKey = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
|
||||
if (NULL == pMergeKey) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pMergeKey->pExpr = nodesCloneNode(pWStartTs);
|
||||
if (NULL == pMergeKey->pExpr) {
|
||||
nodesDestroyNode(pMergeKey);
|
||||
nodesDestroyNode((SNode*)pMergeKey);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pMergeKey->order = ORDER_ASC;
|
||||
pMergeKey->nullOrder = NULL_ORDER_FIRST;
|
||||
return nodesListMakeStrictAppend(pMergeKeys, pMergeKey);
|
||||
return nodesListMakeStrictAppend(pMergeKeys, (SNode*)pMergeKey);
|
||||
}
|
||||
|
||||
static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
|
||||
|
@ -361,7 +361,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo
|
|||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
|
||||
splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT));
|
||||
(SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT));
|
||||
}
|
||||
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
||||
return code;
|
||||
|
@ -377,7 +377,7 @@ static int32_t stbSplSplitIntervalForStream(SSplitContext* pCxt, SStableSplitInf
|
|||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
|
||||
splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT));
|
||||
(SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT));
|
||||
}
|
||||
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
||||
return code;
|
||||
|
@ -418,7 +418,7 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO
|
|||
pMergeAgg->node.pChildren = NULL;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SAggLogicNode* pPartAgg = nodesCloneNode(pMergeAgg);
|
||||
SAggLogicNode* pPartAgg = (SAggLogicNode*)nodesCloneNode((SNode*)pMergeAgg);
|
||||
if (NULL == pPartAgg) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pOutput = (SLogicNode*)pPartAgg;
|
||||
} else {
|
||||
nodesDestroyNode(pPartAgg);
|
||||
nodesDestroyNode((SNode*)pPartAgg);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -461,14 +461,14 @@ static int32_t stbSplSplitAggNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
|
|||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
|
||||
splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT));
|
||||
(SNode*)splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT));
|
||||
}
|
||||
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
||||
return code;
|
||||
}
|
||||
|
||||
static SNode* stbSplCreateColumnNode(SExprNode* pExpr) {
|
||||
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -482,13 +482,13 @@ static SNode* stbSplCreateColumnNode(SExprNode* pExpr) {
|
|||
}
|
||||
|
||||
static SNode* stbSplCreateOrderByExpr(SOrderByExprNode* pSortKey, SNode* pCol) {
|
||||
SOrderByExprNode* pOutput = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
|
||||
SOrderByExprNode* pOutput = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
|
||||
if (NULL == pOutput) {
|
||||
return NULL;
|
||||
}
|
||||
pOutput->pExpr = nodesCloneNode(pCol);
|
||||
if (NULL == pOutput->pExpr) {
|
||||
nodesDestroyNode(pOutput);
|
||||
nodesDestroyNode((SNode*)pOutput);
|
||||
return NULL;
|
||||
}
|
||||
pOutput->order = pSortKey->order;
|
||||
|
@ -542,7 +542,7 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut
|
|||
pSort->node.pChildren = NULL;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SSortLogicNode* pPartSort = nodesCloneNode(pSort);
|
||||
SSortLogicNode* pPartSort = (SSortLogicNode*)nodesCloneNode((SNode*)pSort);
|
||||
if (NULL == pPartSort) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -558,7 +558,7 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut
|
|||
*pOutputPartSort = (SLogicNode*)pPartSort;
|
||||
*pOutputMergeKeys = pMergeKeys;
|
||||
} else {
|
||||
nodesDestroyNode(pPartSort);
|
||||
nodesDestroyNode((SNode*)pPartSort);
|
||||
nodesDestroyList(pMergeKeys);
|
||||
}
|
||||
|
||||
|
@ -574,7 +574,7 @@ static int32_t stbSplSplitSortNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
|
|||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
|
||||
splCreateScanSubplan(pCxt, pPartSort, SPLIT_FLAG_STABLE_SPLIT));
|
||||
(SNode*)splCreateScanSubplan(pCxt, pPartSort, SPLIT_FLAG_STABLE_SPLIT));
|
||||
}
|
||||
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
||||
return code;
|
||||
|
@ -584,7 +584,7 @@ static int32_t stbSplSplitScanNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
|
|||
int32_t code = splCreateExchangeNodeForSubplan(pCxt, pInfo->pSubplan, pInfo->pSplitNode, SUBPLAN_TYPE_MERGE);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
|
||||
splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT));
|
||||
(SNode*)splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ static bool sigTbJoinSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubpl
|
|||
SJoinLogicNode* pJoin = sigTbJoinSplMatchByNode(pSubplan->pNode);
|
||||
if (NULL != pJoin) {
|
||||
pInfo->pJoin = pJoin;
|
||||
pInfo->pSplitNode = nodesListGetNode(pJoin->node.pChildren, 1);
|
||||
pInfo->pSplitNode = (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1);
|
||||
pInfo->pSubplan = pSubplan;
|
||||
}
|
||||
return NULL != pJoin;
|
||||
|
@ -667,7 +667,7 @@ static int32_t singleTableJoinSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan
|
|||
}
|
||||
int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pSplitNode, info.pSubplan->subplanType);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, splCreateScanSubplan(pCxt, info.pSplitNode, 0));
|
||||
code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)splCreateScanSubplan(pCxt, info.pSplitNode, 0));
|
||||
}
|
||||
++(pCxt->groupId);
|
||||
pCxt->split = true;
|
||||
|
@ -708,7 +708,7 @@ static int32_t unionMountSubplan(SLogicSubplan* pParent, SNodeList* pChildren) {
|
|||
}
|
||||
|
||||
static SLogicSubplan* unionCreateSubplan(SSplitContext* pCxt, SLogicNode* pNode) {
|
||||
SLogicSubplan* pSubplan = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
||||
SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
||||
if (NULL == pSubplan) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubpl
|
|||
SNode* pChild = NULL;
|
||||
FOREACH(pChild, pSplitNode->pChildren) {
|
||||
SLogicSubplan* pNewSubplan = unionCreateSubplan(pCxt, (SLogicNode*)pChild);
|
||||
code = nodesListMakeStrictAppend(&pUnionSubplan->pChildren, pNewSubplan);
|
||||
code = nodesListMakeStrictAppend(&pUnionSubplan->pChildren, (SNode*)pNewSubplan);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
REPLACE_NODE(NULL);
|
||||
code = unionMountSubplan(pNewSubplan, pSubplanChildren);
|
||||
|
@ -774,7 +774,7 @@ static bool unAllSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan,
|
|||
}
|
||||
|
||||
static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SProjectLogicNode* pProject) {
|
||||
SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||
SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||
if (NULL == pExchange) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -789,20 +789,20 @@ static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pS
|
|||
|
||||
if (NULL == pProject->node.pParent) {
|
||||
pSubplan->pNode = (SLogicNode*)pExchange;
|
||||
nodesDestroyNode(pProject);
|
||||
nodesDestroyNode((SNode*)pProject);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pProject->node.pParent->pChildren) {
|
||||
if (nodesEqualNode(pNode, pProject)) {
|
||||
if (nodesEqualNode(pNode, (SNode*)pProject)) {
|
||||
REPLACE_NODE(pExchange);
|
||||
nodesDestroyNode(pNode);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
nodesDestroyNode(pExchange);
|
||||
return TSDB_CODE_FAILED;
|
||||
nodesDestroyNode((SNode*)pExchange);
|
||||
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
static int32_t unionAllSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
||||
|
@ -840,7 +840,7 @@ static SLogicNode* unDistSplMatchByNode(SLogicNode* pNode) {
|
|||
}
|
||||
|
||||
static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SAggLogicNode* pAgg) {
|
||||
SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||
SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||
if (NULL == pExchange) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -853,7 +853,7 @@ static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* p
|
|||
|
||||
pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
||||
|
||||
return nodesListMakeAppend(&pAgg->node.pChildren, pExchange);
|
||||
return nodesListMakeAppend(&pAgg->node.pChildren, (SNode*)pExchange);
|
||||
}
|
||||
|
||||
static bool unDistSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SUnionDistinctSplitInfo* pInfo) {
|
||||
|
@ -937,7 +937,7 @@ static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule));
|
|||
|
||||
static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) {
|
||||
char* pStr = NULL;
|
||||
nodesNodeToString(pSubplan, false, &pStr, NULL);
|
||||
nodesNodeToString((SNode*)pSubplan, false, &pStr, NULL);
|
||||
qDebugL("apply %s rule: %s", pRuleName, pStr);
|
||||
taosMemoryFree(pStr);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,8 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
|
|||
}
|
||||
pCol->node.resType = pExpr->resType;
|
||||
strcpy(pCol->colName, pExpr->aliasName);
|
||||
return (TSDB_CODE_SUCCESS == nodesListAppend(pCxt->pList, pCol) ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
||||
return (TSDB_CODE_SUCCESS == nodesListStrictAppend(pCxt->pList, (SNode*)pCol) ? DEAL_RES_IGNORE_CHILD
|
||||
: DEAL_RES_ERROR);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -111,7 +112,7 @@ int32_t replaceLogicNode(SLogicSubplan* pSubplan, SLogicNode* pOld, SLogicNode*
|
|||
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pOld->pParent->pChildren) {
|
||||
if (nodesEqualNode(pNode, pOld)) {
|
||||
if (nodesEqualNode(pNode, (SNode*)pOld)) {
|
||||
REPLACE_NODE(pNew);
|
||||
pNew->pParent = pOld->pParent;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
static void dumpQueryPlan(SQueryPlan* pPlan) {
|
||||
char* pStr = NULL;
|
||||
nodesNodeToString(pPlan, false, &pStr, NULL);
|
||||
nodesNodeToString((SNode*)pPlan, false, &pStr, NULL);
|
||||
planDebugL("Query Plan: %s", pStr);
|
||||
taosMemoryFree(pStr);
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
|
|||
dumpQueryPlan(*pPlan);
|
||||
}
|
||||
|
||||
nodesDestroyNode(pLogicSubplan);
|
||||
nodesDestroyNode(pLogicPlan);
|
||||
nodesDestroyNode((SNode*)pLogicSubplan);
|
||||
nodesDestroyNode((SNode*)pLogicPlan);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDown
|
|||
if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == nodeType(pNode)) {
|
||||
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pNode;
|
||||
if (pExchange->srcGroupId == groupId) {
|
||||
return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode(pSource));
|
||||
return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode((SNode*)pSource));
|
||||
}
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_MERGE == nodeType(pNode)) {
|
||||
SMergePhysiNode* pMerge = (SMergePhysiNode*)pNode;
|
||||
|
@ -68,7 +68,7 @@ static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDown
|
|||
} else {
|
||||
--(pMerge->numOfChannels);
|
||||
}
|
||||
return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode(pSource));
|
||||
return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode((SNode*)pSource));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan) { return nodesSt
|
|||
char* qQueryPlanToString(const SQueryPlan* pPlan) {
|
||||
char* pStr = NULL;
|
||||
int32_t len = 0;
|
||||
if (TSDB_CODE_SUCCESS != nodesNodeToString(pPlan, false, &pStr, &len)) {
|
||||
if (TSDB_CODE_SUCCESS != nodesNodeToString((SNode*)pPlan, false, &pStr, &len)) {
|
||||
return NULL;
|
||||
}
|
||||
return pStr;
|
||||
|
@ -115,4 +115,4 @@ SQueryPlan* qStringToQueryPlan(const char* pStr) {
|
|||
return pPlan;
|
||||
}
|
||||
|
||||
void qDestroyQueryPlan(SQueryPlan* pPlan) { nodesDestroyNode(pPlan); }
|
||||
void qDestroyQueryPlan(SQueryPlan* pPlan) { nodesDestroyNode((SNode*)pPlan); }
|
||||
|
|
|
@ -53,6 +53,14 @@ TEST_F(PlanGroupByTest, aggFunc) {
|
|||
run("SELECT SUM(10), COUNT(c1) FROM t1 GROUP BY c2");
|
||||
}
|
||||
|
||||
TEST_F(PlanGroupByTest, rewriteFunc) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT AVG(c1) FROM t1");
|
||||
|
||||
run("SELECT AVG(c1) FROM t1 GROUP BY c2");
|
||||
}
|
||||
|
||||
TEST_F(PlanGroupByTest, selectFunc) {
|
||||
useDb("root", "test");
|
||||
|
||||
|
|
|
@ -24,6 +24,10 @@ TEST_F(PlanPartitionByTest, basic) {
|
|||
useDb("root", "test");
|
||||
|
||||
run("select * from t1 partition by c1");
|
||||
|
||||
run("select ts, c1 + 1 from st1 partition by c1 + 1");
|
||||
|
||||
run("select ts, jtag->'tag1' from st2 partition by jtag->'tag1'");
|
||||
}
|
||||
|
||||
TEST_F(PlanPartitionByTest, withAggFunc) {
|
||||
|
|
|
@ -308,7 +308,7 @@ void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
|||
}
|
||||
|
||||
if (ctx->plan) {
|
||||
nodesDestroyNode(ctx->plan);
|
||||
nodesDestroyNode((SNode*)ctx->plan);
|
||||
ctx->plan = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1244,7 +1244,7 @@ void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) {
|
|||
|
||||
void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) {
|
||||
sDebug("vgId:%d sync event become follower, isStandBy:%d, %s", pSyncNode->vgId, pSyncNode->pRaftCfg->isStandBy,
|
||||
debugStr);
|
||||
debugStr);
|
||||
|
||||
// maybe clear leader cache
|
||||
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
||||
|
@ -1279,7 +1279,7 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) {
|
|||
//
|
||||
void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) {
|
||||
sDebug("vgId:%d sync event become leader, isStandBy:%d, %s", pSyncNode->vgId, pSyncNode->pRaftCfg->isStandBy,
|
||||
debugStr);
|
||||
debugStr);
|
||||
|
||||
// state change
|
||||
pSyncNode->state = TAOS_SYNC_STATE_LEADER;
|
||||
|
@ -1888,7 +1888,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
|
|||
int32_t code = 0;
|
||||
ESyncState state = flag;
|
||||
sDebug("vgId:%d sync event commit by wal from index:%" PRId64 " to index:%" PRId64 ", %s", ths->vgId, beginIndex,
|
||||
endIndex, syncUtilState2String(state));
|
||||
endIndex, syncUtilState2String(state));
|
||||
|
||||
// execute fsm
|
||||
if (ths->pFsm != NULL) {
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
|
||||
#define FREE_HASH_NODE(_fp, _n) \
|
||||
do { \
|
||||
/* if (_fp != NULL) { \
|
||||
(_fp)(_n); \
|
||||
}*/ \
|
||||
if (_fp != NULL) { \
|
||||
(_fp)(_n); \
|
||||
} \
|
||||
taosMemoryFreeClear(_n); \
|
||||
} while (0);
|
||||
|
||||
|
|
|
@ -163,9 +163,12 @@ endi
|
|||
print =============== step32: move follower2
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
||||
=======
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
||||
sql show d1.tables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
|
@ -174,9 +177,12 @@ endi
|
|||
print =============== step33: move follower1
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
||||
=======
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
||||
sql show d1.tables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
|
@ -185,9 +191,12 @@ endi
|
|||
print =============== step34: move follower2
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
||||
=======
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
||||
sql show d1.tables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
|
@ -196,8 +205,15 @@ endi
|
|||
print =============== step35: move follower1
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
||||
sql show d1.tables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
=======
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
||||
|
||||
sql show d1.tables
|
||||
if $rows != 1 then
|
||||
|
@ -226,6 +242,8 @@ if $rows != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
||||
=======
|
||||
print =============== step38: move follower2
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||
|
@ -236,6 +254,7 @@ sql show d1.tables
|
|||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
||||
|
||||
print =============== step39: move follower1
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
||||
|
|
|
@ -160,53 +160,110 @@ if $rows != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
<<<<<<< HEAD
|
||||
print =============== step32: move follower2
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
||||
=======
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
||||
=======
|
||||
print =============== step32: move leader
|
||||
print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
||||
sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
>>>>>>> origin/3.0
|
||||
sql show d1.tables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
<<<<<<< HEAD
|
||||
print =============== step33: move follower1
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
||||
=======
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
||||
=======
|
||||
print =============== step33: move follower2
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
>>>>>>> origin/3.0
|
||||
sql show d1.tables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
<<<<<<< HEAD
|
||||
print =============== step34: move follower2
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
||||
=======
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
||||
=======
|
||||
print =============== step34: move follower1
|
||||
print redistribute vgroup 2 dnode $follower2 dnode 5 dnode $leaderVnode
|
||||
sql redistribute vgroup 2 dnode $follower2 dnode 5 dnode $leaderVnode
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
>>>>>>> origin/3.0
|
||||
sql show d1.tables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
<<<<<<< HEAD
|
||||
print =============== step35: move follower1
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
||||
sql show d1.tables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
=======
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
||||
=======
|
||||
print =============== step35: move 5
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode $follower2
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode $follower2
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
>>>>>>> origin/3.0
|
||||
|
||||
sql show d1.tables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
<<<<<<< HEAD
|
||||
print =============== step36: move follower2
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||
=======
|
||||
print =============== step36: move follower1
|
||||
print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
||||
sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
||||
>>>>>>> origin/3.0
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
|
@ -215,7 +272,11 @@ if $rows != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
<<<<<<< HEAD
|
||||
print =============== step37: move follower1
|
||||
=======
|
||||
print =============== step37: move follower2
|
||||
>>>>>>> origin/3.0
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||
sql show d1.vgroups
|
||||
|
@ -226,9 +287,17 @@ if $rows != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
||||
=======
|
||||
print =============== step38: move follower2
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||
=======
|
||||
print =============== step38: move leader
|
||||
print redistribute vgroup 2 dnode $follower1 dnode 5 dnode $follower2
|
||||
sql redistribute vgroup 2 dnode $follower1 dnode 5 dnode $follower2
|
||||
>>>>>>> origin/3.0
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
|
@ -236,10 +305,18 @@ sql show d1.tables
|
|||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
||||
|
||||
print =============== step39: move follower1
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
||||
=======
|
||||
|
||||
print =============== step39: move 5
|
||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1
|
||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1
|
||||
>>>>>>> origin/3.0
|
||||
sql show d1.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
|
||||
|
|
Loading…
Reference in New Issue