diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 286cb99cb9..1a155beb90 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -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 diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index bc257f797a..7bf3371006 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -8140,11 +8140,9 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa idList = taosArrayInit(4, sizeof(uint64_t)); } - // SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle->reader, pScanPhyNode->pScanCols, idList, pTaskInfo); - // taosArrayDestroy(idList); - - // //TODO destroy groupInfo - // return pOperator; +// SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle->reader, pScanPhyNode->pScanCols, idList, pTaskInfo); + taosArrayDestroy(idList); +// return pOperator; } } @@ -8175,9 +8173,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; @@ -8187,15 +8185,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); } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 0ed73ea1f6..e97ff91c16 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -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; } @@ -1090,6 +1090,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);