From 0fd55077f504874a6c7076c2db065bdcd1324f4c Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Fri, 8 Jul 2022 09:33:28 +0800 Subject: [PATCH] feat: sql command 'insert ... select' --- source/libs/parser/src/parTranslater.c | 2 +- source/libs/planner/src/planSpliter.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 0fbeac47e6..97a263f86f 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -6384,7 +6384,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { break; case QUERY_NODE_INSERT_STMT: pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; - pQuery->msgType = TDMT_VND_SUBMIT; + pQuery->msgType = TDMT_SCH_QUERY; break; case QUERY_NODE_VNODE_MODIF_STMT: pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 0863b5f21f..1dfdaf5f21 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -1219,14 +1219,27 @@ static int32_t insertSelectSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { return TSDB_CODE_SUCCESS; } + SLogicSubplan* pNewSubplan = NULL; + SNodeList* pSubplanChildren = info.pSubplan->pChildren; int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pQueryRoot, info.pSubplan->subplanType); if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)splCreateScanSubplan(pCxt, info.pQueryRoot, 0)); + pNewSubplan = splCreateScanSubplan(pCxt, info.pQueryRoot, 0); + if (NULL == pNewSubplan) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)pNewSubplan); } + if (TSDB_CODE_SUCCESS == code) { + code = unionMountSubplan(pNewSubplan, pSubplanChildren); + } + if (TSDB_CODE_SUCCESS == code) { info.pSubplan->subplanType = SUBPLAN_TYPE_MODIFY; SPLIT_FLAG_SET_MASK(info.pSubplan->splitFlag, SPLIT_FLAG_INSERT_SPLIT); } + ++(pCxt->groupId); pCxt->split = true; return code; -- GitLab