Merge remote-tracking branch 'origin/3.0_query_integrate' into feature/scheduler
This commit is contained in:
commit
f17d4fb94e
|
@ -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;
|
||||
|
|
|
@ -53,7 +53,6 @@ TEST(testCase, driverInit_Test) {
|
|||
// taos_init();
|
||||
}
|
||||
|
||||
#if 0
|
||||
TEST(testCase, connect_Test) {
|
||||
// taos_options(TSDB_OPTION_CONFIGDIR, "/home/ubuntu/first/cfg");
|
||||
|
||||
|
@ -564,8 +563,6 @@ TEST(testCase, insert_test) {
|
|||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
TEST(testCase, projection_query_tables) {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
|
@ -579,7 +576,7 @@ TEST(testCase, projection_query_tables) {
|
|||
|
||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||
taos_free_result(pRes);
|
||||
#if 0
|
||||
|
||||
pRes = taos_query(pConn, "create stable st1 (ts timestamp, k int) tags(a int)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
|
||||
|
@ -602,9 +599,8 @@ TEST(testCase, projection_query_tables) {
|
|||
|
||||
taos_free_result(p);
|
||||
}
|
||||
#endif
|
||||
|
||||
pRes = taos_query(pConn, "select count(ts) from tu");
|
||||
pRes = taos_query(pConn, "select * from tu");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
|
@ -625,7 +621,6 @@ TEST(testCase, projection_query_tables) {
|
|||
taos_close(pConn);
|
||||
}
|
||||
|
||||
#if 0
|
||||
TEST(testCase, projection_query_stables) {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
@ -687,6 +682,5 @@ TEST(testCase, agg_query_tables) {
|
|||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -8186,9 +8186,9 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
|
|||
static tsdbReaderT createDataReaderImpl(STableScanPhysiNode* pTableScanNode, STableGroupInfo* pGroupInfo, void* readHandle, uint64_t queryId, uint64_t taskId) {
|
||||
STsdbQueryCond cond = {.loadExternalRows = false};
|
||||
|
||||
cond.order = pTableScanNode->scan.order;
|
||||
cond.order = pTableScanNode->scan.order;
|
||||
cond.numOfCols = LIST_LENGTH(pTableScanNode->scan.pScanCols);
|
||||
cond.colList = calloc(cond.numOfCols, sizeof(SColumnInfo));
|
||||
cond.colList = calloc(cond.numOfCols, sizeof(SColumnInfo));
|
||||
if (cond.colList == NULL) {
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
|
@ -8198,15 +8198,21 @@ static tsdbReaderT createDataReaderImpl(STableScanPhysiNode* pTableScanNode, STa
|
|||
cond.type = BLOCK_LOAD_OFFSET_SEQ_ORDER;
|
||||
// cond.type = pTableScanNode->scanFlag;
|
||||
|
||||
int32_t j = 0;
|
||||
for (int32_t i = 0; i < cond.numOfCols; ++i) {
|
||||
STargetNode* pNode = (STargetNode*)nodesListGetNode(pTableScanNode->scan.pScanCols, i);
|
||||
|
||||
SColumnNode* pColNode = (SColumnNode*)pNode->pExpr;
|
||||
cond.colList[i].type = pColNode->node.resType.type;
|
||||
cond.colList[i].bytes = pColNode->node.resType.bytes;
|
||||
cond.colList[i].colId = pColNode->colId;
|
||||
if (pColNode->colType == COLUMN_TYPE_TAG) {
|
||||
continue;
|
||||
}
|
||||
|
||||
cond.colList[j].type = pColNode->node.resType.type;
|
||||
cond.colList[j].bytes = pColNode->node.resType.bytes;
|
||||
cond.colList[j].colId = pColNode->colId;
|
||||
j += 1;
|
||||
}
|
||||
|
||||
cond.numOfCols = j;
|
||||
return tsdbQueryTables(readHandle, &cond, pGroupInfo, queryId, taskId);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,54 @@ 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_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 +342,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;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ static int32_t createColumnNodeByTable(STranslateContext* pCxt, const STableNode
|
|||
if (NULL == pCol) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, (i < pMeta->tableInfo.numOfTags), pCol);
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, (i >= pMeta->tableInfo.numOfColumns), pCol);
|
||||
nodesListAppend(pList, (SNode*)pCol);
|
||||
}
|
||||
} else {
|
||||
|
@ -156,7 +156,7 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) {
|
|||
int32_t nums = pMeta->tableInfo.numOfTags + pMeta->tableInfo.numOfColumns;
|
||||
for (int32_t i = 0; i < nums; ++i) {
|
||||
if (0 == strcmp(pCol->colName, pMeta->schema[i].name)) {
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, (i < pMeta->tableInfo.numOfTags), pCol);
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, (i >= pMeta->tableInfo.numOfColumns), pCol);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1090,6 +1093,10 @@ static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) {
|
|||
static int32_t translateShowTables(STranslateContext* pCxt) {
|
||||
SName name = {0};
|
||||
SVShowTablesReq* pShowReq = calloc(1, sizeof(SVShowTablesReq));
|
||||
if (pCxt->pParseCxt->db == NULL || strlen(pCxt->pParseCxt->db) == 0) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_TSC_INVALID_OPERATION, "db not specified");
|
||||
}
|
||||
|
||||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, strlen(pCxt->pParseCxt->db));
|
||||
char dbFname[TSDB_DB_FNAME_LEN] = {0};
|
||||
tNameGetFullDbName(&name, dbFname);
|
||||
|
@ -1206,7 +1213,13 @@ 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);
|
||||
|
||||
if (NULL != pCxt->pCmdMsg) {
|
||||
tfree(pCxt->pCmdMsg->pMsg);
|
||||
tfree(pCxt->pCmdMsg);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue