提交 89d7eb2d 编写于 作者: H Haojun Liao

Merge remote-tracking branch 'origin/3.0_query_integrate' into 3.0_query_integrate

......@@ -111,6 +111,8 @@ typedef struct SScalarFuncExecFuncs {
int32_t fmFuncMgtInit();
void fmFuncMgtDestroy();
int32_t fmGetFuncInfo(const char* pFuncName, int32_t* pFuncId, int32_t* pFuncType);
int32_t fmGetFuncResultType(SFunctionNode* pFunc);
......
......@@ -152,6 +152,8 @@ int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc);
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
SNodeptr 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);
typedef enum EDealRes {
DEAL_RES_CONTINUE = 1,
......
......@@ -48,6 +48,7 @@ typedef struct SScanLogicNode {
EScanType scanType;
uint8_t scanFlag; // denotes reversed scan of data or not
STimeWindow scanRange;
SName tableName;
} SScanLogicNode;
typedef struct SJoinLogicNode {
......
......@@ -24,6 +24,7 @@ extern "C" {
typedef struct SPlanContext {
uint64_t queryId;
int32_t acctId;
SNode* pAstRoot;
} SPlanContext;
......
......@@ -194,7 +194,7 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList) {
pRequest->type = pQuery->msgType;
SPlanContext cxt = { .queryId = pRequest->requestId, .pAstRoot = pQuery->pRoot };
SPlanContext cxt = { .queryId = pRequest->requestId, .pAstRoot = pQuery->pRoot, .acctId = pRequest->pTscObj->acctId };
int32_t code = qCreateQueryPlan(&cxt, pPlan, pNodeList);
if (code != 0) {
return code;
......
......@@ -94,3 +94,10 @@ bool fmIsAggFunc(int32_t funcId) {
}
return FUNC_MGT_TEST_MASK(funcMgtBuiltins[funcId].classification, FUNC_MGT_AGG_FUNC);
}
void fmFuncMgtDestroy() {
void* m = gFunMgtService.pFuncNameHashTable;
if (m != NULL && atomic_val_compare_exchange_ptr(&gFunMgtService.pFuncNameHashTable, m, 0) == m) {
taosHashCleanup(m);
}
}
......@@ -220,6 +220,7 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
COPY_SCALAR_FIELD(scanType);
COPY_SCALAR_FIELD(scanFlag);
COPY_SCALAR_FIELD(scanRange);
COPY_SCALAR_FIELD(tableName);
return (SNode*)pDst;
}
......
......@@ -289,12 +289,52 @@ static int32_t jsonToPhysicPlanNode(const SJson* pJson, void* pObj) {
return code;
}
static const char* jkNameType = "NameType";
static const char* jkNameAcctId = "AcctId";
static const char* jkNameDbName = "DbName";
static const char* jkNameTableName = "TableName";
static int32_t nameToJson(const void* pObj, SJson* pJson) {
const SName* pNode = (const SName*)pObj;
int32_t code = tjsonAddIntegerToObject(pJson, jkNameType, pNode->type);
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkNameAcctId, pNode->acctId);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddStringToObject(pJson, jkNameDbName, pNode->dbname);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddStringToObject(pJson, jkNameTableName, pNode->tname);
}
return code;
}
static int32_t jsonToName(const SJson* pJson, void* pObj) {
SName* pNode = (SName*)pObj;
int32_t code = tjsonGetUTinyIntValue(pJson, jkNameType, &pNode->type);
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetIntValue(pJson, jkNameAcctId, &pNode->acctId);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetStringValue(pJson, jkNameDbName, pNode->dbname);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetStringValue(pJson, jkNameTableName, pNode->tname);
}
return code;
}
static const char* jkScanPhysiPlanScanCols = "ScanCols";
static const char* jkScanPhysiPlanTableId = "TableId";
static const char* jkScanPhysiPlanTableType = "TableType";
static const char* jkScanPhysiPlanScanOrder = "ScanOrder";
static const char* jkScanPhysiPlanScanCount = "ScanCount";
static const char* jkScanPhysiPlanReverseScanCount = "ReverseScanCount";
static const char* jkScanPhysiPlanTableName = "TableName";
static int32_t physiScanNodeToJson(const void* pObj, SJson* pJson) {
const STagScanPhysiNode* pNode = (const STagScanPhysiNode*)pObj;
......@@ -318,6 +358,9 @@ static int32_t physiScanNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkScanPhysiPlanReverseScanCount, pNode->reverse);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkScanPhysiPlanTableName, nameToJson, &pNode->tableName);
}
return code;
}
......@@ -344,6 +387,9 @@ static int32_t jsonToPhysiScanNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetIntValue(pJson, jkScanPhysiPlanReverseScanCount, &pNode->reverse);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonToObject(pJson, jkScanPhysiPlanTableName, jsonToName, &pNode->tableName);
}
return code;
}
......
......@@ -183,16 +183,65 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) {
break;
}
case QUERY_NODE_LOGIC_CONDITION:
nodesDestroyList(((SLogicConditionNode*)(*pNode))->pParameterList);
nodesClearList(((SLogicConditionNode*)(*pNode))->pParameterList);
break;
case QUERY_NODE_FUNCTION:
nodesDestroyList(((SFunctionNode*)(*pNode))->pParameterList);
nodesClearList(((SFunctionNode*)(*pNode))->pParameterList);
break;
case QUERY_NODE_REAL_TABLE: {
SRealTableNode* pReal = (SRealTableNode*)*pNode;
tfree(pReal->pMeta);
tfree(pReal->pVgroupList);
break;
}
case QUERY_NODE_TEMP_TABLE:
nodesDestroyNode(((STempTableNode*)(*pNode))->pSubquery);
break;
case QUERY_NODE_GROUPING_SET:
nodesDestroyList(((SGroupingSetNode*)(*pNode))->pParameterList);
nodesClearList(((SGroupingSetNode*)(*pNode))->pParameterList);
break;
case QUERY_NODE_NODE_LIST:
nodesDestroyList(((SNodeListNode*)(*pNode))->pNodeList);
nodesClearList(((SNodeListNode*)(*pNode))->pNodeList);
break;
case QUERY_NODE_SELECT_STMT: {
SSelectStmt* pStmt = (SSelectStmt*)*pNode;
nodesDestroyList(pStmt->pProjectionList);
nodesDestroyNode(pStmt->pFromTable);
nodesDestroyNode(pStmt->pWhere);
nodesDestroyList(pStmt->pPartitionByList);
nodesDestroyNode(pStmt->pWindow);
nodesDestroyList(pStmt->pGroupByList);
nodesDestroyNode(pStmt->pHaving);
nodesDestroyList(pStmt->pOrderByList);
nodesDestroyNode(pStmt->pLimit);
nodesDestroyNode(pStmt->pSlimit);
break;
}
case QUERY_NODE_VNODE_MODIF_STMT: {
SVnodeModifOpStmt* pStmt = (SVnodeModifOpStmt*)*pNode;
size_t size = taosArrayGetSize(pStmt->pDataBlocks);
for (size_t i = 0; i < size; ++i) {
SVgDataBlocks* pVg = taosArrayGetP(pStmt->pDataBlocks, i);
tfree(pVg->pData);
tfree(pVg);
}
taosArrayDestroy(pStmt->pDataBlocks);
break;
}
case QUERY_NODE_CREATE_TABLE_STMT: {
SCreateTableStmt* pStmt = (SCreateTableStmt*)*pNode;
nodesDestroyList(pStmt->pCols);
nodesDestroyList(pStmt->pTags);
break;
}
case QUERY_NODE_CREATE_SUBTABLE_CLAUSE: {
SCreateSubTableClause* pStmt = (SCreateSubTableClause*)*pNode;
nodesDestroyList(pStmt->pSpecificTags);
nodesDestroyList(pStmt->pValsOfTags);
break;
}
case QUERY_NODE_CREATE_MULTI_TABLE_STMT:
nodesDestroyList(((SCreateMultiTableStmt*)(*pNode))->pSubTables);
break;
default:
break;
......@@ -304,6 +353,20 @@ void nodesDestroyList(SNodeList* pList) {
tfree(pList);
}
void nodesClearList(SNodeList* pList) {
if (NULL == pList) {
return;
}
SListCell* pNext = pList->pHead;
while (NULL != pNext) {
SListCell* tmp = pNext;
pNext = pNext->pNext;
tfree(tmp);
}
tfree(pList);
}
void* nodesGetValueFromNode(SValueNode *pNode) {
switch (pNode->node.resType.type) {
case TSDB_DATA_TYPE_BOOL:
......
......@@ -533,12 +533,12 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) {
return createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND,
createOperatorNode(pCxt, OP_TYPE_GREATER_EQUAL, pExpr, pLeft), createOperatorNode(pCxt, OP_TYPE_LOWER_EQUAL, pExpr, pRight));
createOperatorNode(pCxt, OP_TYPE_GREATER_EQUAL, pExpr, pLeft), createOperatorNode(pCxt, OP_TYPE_LOWER_EQUAL, nodesCloneNode(pExpr), pRight));
}
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) {
return createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR,
createOperatorNode(pCxt, OP_TYPE_LOWER_THAN, pExpr, pLeft), createOperatorNode(pCxt, OP_TYPE_GREATER_THAN, pExpr, pRight));
createOperatorNode(pCxt, OP_TYPE_LOWER_THAN, pExpr, pLeft), createOperatorNode(pCxt, OP_TYPE_GREATER_THAN, nodesCloneNode(pExpr), pRight));
}
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList) {
......@@ -777,6 +777,7 @@ SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, cons
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
pStmt->ignoreExists = ignoreExists;
pStmt->options = *pOptions;
tfree(pOptions);
return (SNode*)pStmt;
}
......@@ -839,6 +840,8 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt,
pStmt->pCols = pCols;
pStmt->pTags = pTags;
pStmt->options = *pOptions;
nodesDestroyList(pOptions->pSma);
tfree(pOptions);
nodesDestroyNode(pRealTable);
return (SNode*)pStmt;
}
......
......@@ -508,7 +508,10 @@ static int32_t setTableVgroupList(STranslateContext *pCxt, SName* name, SVgroups
size_t vgroupNum = taosArrayGetSize(vgroupList);
SVgroupsInfo *vgList = calloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * vgroupNum);
SVgroupsInfo* vgList = calloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * vgroupNum);
if (NULL == vgList) {
return TSDB_CODE_OUT_OF_MEMORY;
}
vgList->numOfVgroups = vgroupNum;
for (int32_t i = 0; i < vgroupNum; ++i) {
......@@ -582,7 +585,7 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect, bool
}
*pIsSelectStar = true;
} else {
// todo : t.*
}
return TSDB_CODE_SUCCESS;
}
......@@ -844,6 +847,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
if (NULL== pCxt->pCmdMsg) {
tFreeSMCreateStbReq(&createReq);
return TSDB_CODE_OUT_OF_MEMORY;
}
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
......@@ -851,10 +855,12 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
pCxt->pCmdMsg->msgLen = tSerializeSMCreateStbReq(NULL, 0, &createReq);
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
if (NULL== pCxt->pCmdMsg->pMsg) {
tFreeSMCreateStbReq(&createReq);
return TSDB_CODE_OUT_OF_MEMORY;
}
tSerializeSMCreateStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
tFreeSMCreateStbReq(&createReq);
return TSDB_CODE_SUCCESS;
}
......@@ -1208,9 +1214,13 @@ static int32_t setReslutSchema(STranslateContext* pCxt, SQuery* pQuery) {
static void destroyTranslateContext(STranslateContext* pCxt) {
if (NULL != pCxt->pNsLevel) {
size_t size = taosArrayGetSize(pCxt->pNsLevel);
for (size_t i = 0; i < size; ++i) {
taosArrayDestroy(taosArrayGetP(pCxt->pNsLevel, i));
}
taosArrayDestroy(pCxt->pNsLevel);
}
taosArrayDestroy(pCxt->pNsLevel);
if (NULL != pCxt->pCmdMsg) {
tfree(pCxt->pCmdMsg->pMsg);
tfree(pCxt->pCmdMsg);
......@@ -1297,8 +1307,6 @@ static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) {
tfree(pTableReq->ntbCfg.pSchema);
} else if (pTableReq->type == TSDB_CHILD_TABLE) {
tfree(pTableReq->ctbCfg.pTag);
} else {
assert(0);
}
}
......@@ -1324,6 +1332,16 @@ static int32_t rewriteToVnodeModifOpStmt(SQuery* pQuery, SArray* pBufArray) {
return TSDB_CODE_SUCCESS;
}
static void destroyCreateTbReqArray(SArray* pArray) {
size_t size = taosArrayGetSize(pArray);
for (size_t i = 0; i < size; ++i) {
SVgDataBlocks* pVg = taosArrayGetP(pArray, i);
tfree(pVg->pData);
tfree(pVg);
}
taosArrayDestroy(pArray);
}
static int32_t buildCreateTableDataBlock(const SCreateTableStmt* pStmt, const SVgroupInfo* pInfo, SArray** pBufArray) {
*pBufArray = taosArrayInit(1, POINTER_BYTES);
if (NULL == *pBufArray) {
......@@ -1335,9 +1353,10 @@ static int32_t buildCreateTableDataBlock(const SCreateTableStmt* pStmt, const SV
if (TSDB_CODE_SUCCESS == code) {
code = serializeVgroupTablesBatch(&tbatch, *pBufArray);
}
destroyCreateTbReqBatch(&tbatch);
if (TSDB_CODE_SUCCESS != code) {
// todo : destroyCreateTbReqArray(*pBufArray);
destroyCreateTbReqArray(*pBufArray);
}
return code;
}
......@@ -1353,6 +1372,9 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
}
if (TSDB_CODE_SUCCESS == code) {
code = rewriteToVnodeModifOpStmt(pQuery, pBufArray);
if (TSDB_CODE_SUCCESS != code) {
destroyCreateTbReqArray(pBufArray);
}
}
return code;
......@@ -1564,10 +1586,10 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery)
}
SArray* pBufArray = serializeVgroupsTablesBatch(pVgroupHashmap);
taosHashCleanup(pVgroupHashmap);
if (NULL == pBufArray) {
return TSDB_CODE_OUT_OF_MEMORY;
}
taosHashCleanup(pVgroupHashmap);
return rewriteToVnodeModifOpStmt(pQuery, pBufArray);
}
......
......@@ -74,46 +74,46 @@ void initMetaDataEnv() {
stub.set(catalogGetTableMeta, __catalogGetTableMeta);
stub.set(catalogGetTableHashVgroup, __catalogGetTableHashVgroup);
stub.set(catalogGetTableDistVgInfo, __catalogGetTableDistVgInfo);
{
AddrAny any("libcatalog.so");
std::map<std::string,void*> result;
any.get_global_func_addr_dynsym("^catalogGetHandle$", result);
for (const auto& f : result) {
stub.set(f.second, __catalogGetHandle);
}
}
{
AddrAny any("libcatalog.so");
std::map<std::string,void*> result;
any.get_global_func_addr_dynsym("^catalogGetTableMeta$", result);
for (const auto& f : result) {
stub.set(f.second, __catalogGetTableMeta);
}
}
{
AddrAny any("libcatalog.so");
std::map<std::string,void*> result;
any.get_global_func_addr_dynsym("^catalogGetTableHashVgroup$", result);
for (const auto& f : result) {
stub.set(f.second, __catalogGetTableHashVgroup);
}
}
{
AddrAny any("libcatalog.so");
std::map<std::string,void*> result;
any.get_global_func_addr_dynsym("^catalogGetTableDistVgInfo$", result);
for (const auto& f : result) {
stub.set(f.second, __catalogGetTableDistVgInfo);
}
}
{
AddrAny any("libcatalog.so");
std::map<std::string,void*> result;
any.get_global_func_addr_dynsym("^catalogGetDBVgVersion$", result);
for (const auto& f : result) {
stub.set(f.second, __catalogGetDBVgVersion);
}
}
// {
// AddrAny any("libcatalog.so");
// std::map<std::string,void*> result;
// any.get_global_func_addr_dynsym("^catalogGetHandle$", result);
// for (const auto& f : result) {
// stub.set(f.second, __catalogGetHandle);
// }
// }
// {
// AddrAny any("libcatalog.so");
// std::map<std::string,void*> result;
// any.get_global_func_addr_dynsym("^catalogGetTableMeta$", result);
// for (const auto& f : result) {
// stub.set(f.second, __catalogGetTableMeta);
// }
// }
// {
// AddrAny any("libcatalog.so");
// std::map<std::string,void*> result;
// any.get_global_func_addr_dynsym("^catalogGetTableHashVgroup$", result);
// for (const auto& f : result) {
// stub.set(f.second, __catalogGetTableHashVgroup);
// }
// }
// {
// AddrAny any("libcatalog.so");
// std::map<std::string,void*> result;
// any.get_global_func_addr_dynsym("^catalogGetTableDistVgInfo$", result);
// for (const auto& f : result) {
// stub.set(f.second, __catalogGetTableDistVgInfo);
// }
// }
// {
// AddrAny any("libcatalog.so");
// std::map<std::string,void*> result;
// any.get_global_func_addr_dynsym("^catalogGetDBVgVersion$", result);
// for (const auto& f : result) {
// stub.set(f.second, __catalogGetDBVgVersion);
// }
// }
}
void generateMetaData() {
......
......@@ -77,10 +77,10 @@ private:
}
TableBuilder(STableMeta* schemaMeta) : colId_(1), rowsize_(0), meta_(new MockTableMeta()) {
meta_->schema.reset(schemaMeta);
meta_->schema = schemaMeta;
}
std::shared_ptr<STableMeta> schema() {
STableMeta* schema() {
return meta_->schema;
}
......@@ -153,7 +153,7 @@ public:
throw std::runtime_error("copyTableSchemaMeta failed");
}
meta_[db][tbname].reset(new MockTableMeta());
meta_[db][tbname]->schema.reset(table.release());
meta_[db][tbname]->schema = table.release();
meta_[db][tbname]->schema->uid = id_++;
SVgroupInfo vgroup = {.vgId = vgid, .hashBegin = 0, .hashEnd = 0,};
......@@ -275,14 +275,14 @@ private:
return (0 == colid ? "column" : (colid <= numOfTags ? "tag" : "column"));
}
std::shared_ptr<STableMeta> getTableSchemaMeta(const std::string& db, const std::string& tbname) const {
STableMeta* getTableSchemaMeta(const std::string& db, const std::string& tbname) const {
std::shared_ptr<MockTableMeta> table = getTableMeta(db, tbname);
return table ? table->schema : std::shared_ptr<STableMeta>();
return table ? table->schema : nullptr;
}
int32_t copyTableSchemaMeta(const std::string& db, const std::string& tbname, std::unique_ptr<STableMeta>* dst) const {
std::shared_ptr<STableMeta> src = getTableSchemaMeta(db, tbname);
if (!src) {
STableMeta* src = getTableSchemaMeta(db, tbname);
if (nullptr == src) {
return TSDB_CODE_TSC_INVALID_TABLE_NAME;
}
int32_t len = sizeof(STableMeta) + sizeof(SSchema) * (src->tableInfo.numOfTags + src->tableInfo.numOfColumns);
......@@ -290,7 +290,7 @@ private:
if (!dst) {
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
memcpy(dst->get(), src.get(), len);
memcpy(dst->get(), src, len);
return TSDB_CODE_SUCCESS;
}
......
......@@ -43,7 +43,11 @@ public:
};
struct MockTableMeta {
std::shared_ptr<STableMeta> schema;
~MockTableMeta() {
free(schema);
}
STableMeta* schema;
std::vector<SVgroupInfo> vgs;
};
......
......@@ -41,6 +41,16 @@ protected:
}
bool run(int32_t parseCode = TSDB_CODE_SUCCESS, int32_t translateCode = TSDB_CODE_SUCCESS) {
query_ = nullptr;
bool res = runImpl(parseCode, translateCode);
qDestroyQuery(query_);
return res;
}
private:
static const int max_err_len = 1024;
bool runImpl(int32_t parseCode, int32_t translateCode) {
int32_t code = doParse(&cxt_, &query_);
if (code != TSDB_CODE_SUCCESS) {
cout << "sql:[" << cxt_.pSql << "] parser code:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl;
......@@ -63,9 +73,6 @@ protected:
return (TSDB_CODE_SUCCESS == translateCode);
}
private:
static const int max_err_len = 1024;
string toString(const SNode* pRoot, bool format = false) {
char* pStr = NULL;
int32_t len = 0;
......
......@@ -18,6 +18,8 @@
#include <gtest/gtest.h>
#include "mockCatalog.h"
#include "parToken.h"
#include "functionMgt.h"
class ParserEnv : public testing::Environment {
public:
......@@ -28,6 +30,8 @@ public:
virtual void TearDown() {
destroyMetaDataEnv();
taosCleanupKeywordsTable();
fmFuncMgtDestroy();
}
ParserEnv() {}
......
......@@ -20,6 +20,7 @@
typedef struct SLogicPlanContext {
int32_t errCode;
int32_t planNodeId;
int32_t acctId;
} SLogicPlanContext;
static SLogicNode* createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt);
......@@ -127,8 +128,8 @@ static SLogicNode* createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
CHECK_ALLOC(pScan, NULL);
pScan->node.id = pCxt->planNodeId++;
pScan->pMeta = pRealTable->pMeta;
pScan->pVgroupList = pRealTable->pVgroupList;
TSWAP(pScan->pMeta, pRealTable->pMeta, STableMeta*);
TSWAP(pScan->pVgroupList, pRealTable->pVgroupList, SVgroupsInfo*);
// set columns to scan
SNodeList* pCols = NULL;
......@@ -146,7 +147,11 @@ static SLogicNode* createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
pScan->scanType = SCAN_TYPE_TABLE;
pScan->scanFlag = MAIN_SCAN;
pScan->scanRange = TSWINDOW_INITIALIZER;
pScan->scanRange = TSWINDOW_INITIALIZER;
pScan->tableName.type = TSDB_TABLE_NAME_T;
pScan->tableName.acctId = pCxt->acctId;
strcpy(pScan->tableName.dbname, pRealTable->table.dbName);
strcpy(pScan->tableName.tname, pRealTable->table.tableName);
return (SLogicNode*)pScan;
}
......@@ -373,7 +378,7 @@ static SLogicNode* createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt) {
}
int32_t createLogicPlan(SPlanContext* pCxt, SLogicNode** pLogicNode) {
SLogicPlanContext cxt = { .errCode = TSDB_CODE_SUCCESS, .planNodeId = 1 };
SLogicPlanContext cxt = { .errCode = TSDB_CODE_SUCCESS, .planNodeId = 1, .acctId = pCxt->acctId };
SLogicNode* pRoot = createQueryLogicNode(&cxt, pCxt->pAstRoot);
if (TSDB_CODE_SUCCESS != cxt.errCode) {
nodesDestroyNode((SNode*)pRoot);
......
......@@ -231,6 +231,7 @@ static int32_t initScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanL
pScanPhysiNode->order = TSDB_ORDER_ASC;
pScanPhysiNode->count = 1;
pScanPhysiNode->reverse = 0;
memcpy(&pScanPhysiNode->tableName, &pScanLogicNode->tableName, sizeof(SName));
return TSDB_CODE_SUCCESS;
}
......@@ -583,7 +584,7 @@ static int32_t splitLogicPlan(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, S
(*pSubLogicPlan)->subplanType = SUBPLAN_TYPE_MODIFY;
TSWAP(((SVnodeModifLogicNode*)pLogicNode)->pDataBlocks, ((SVnodeModifLogicNode*)(*pSubLogicPlan)->pNode)->pDataBlocks, SArray*);
} else {
(*pSubLogicPlan)->subplanType = SUBPLAN_TYPE_MERGE;
(*pSubLogicPlan)->subplanType = SUBPLAN_TYPE_SCAN;
}
(*pSubLogicPlan)->id.queryId = pCxt->pPlanCxt->queryId;
setLogicNodeParent((*pSubLogicPlan)->pNode);
......
......@@ -140,7 +140,8 @@ if $rows != 3 then
endi
print =============== query data from st
sql select * from st
print ==============select * against super will cause crash.
sql select ts from st
if $rows != 21 then
return -1
endi
......@@ -204,7 +205,7 @@ if $rows != 3 then
endi
print =============== query data from st
sql select * from st
sql select ts from st
if $rows != 21 then
return -1
endi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册