From e3a1f7be632475b3ce1a967fca9b3a56b49ae277 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 16 Mar 2022 17:52:44 +0800 Subject: [PATCH 1/4] [td-13039] add the show command. --- include/common/tmsg.h | 1 + source/common/src/tmsg.c | 5 +- source/dnode/mnode/impl/src/mndDnode.c | 2 +- source/dnode/mnode/impl/src/mndInfoSchema.c | 58 +++++++++++---------- source/dnode/mnode/impl/src/mndMnode.c | 4 +- source/dnode/mnode/impl/src/mndShow.c | 14 ++--- source/dnode/mnode/impl/src/mndStb.c | 34 ++++++++++-- source/libs/executor/inc/executorimpl.h | 3 +- source/libs/executor/src/executorimpl.c | 43 +++++++++++++-- 9 files changed, 117 insertions(+), 47 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index c27af5bb0e..05aa88e68f 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -862,6 +862,7 @@ void tFreeSShowRsp(SShowRsp* pRsp); typedef struct { int32_t type; char db[TSDB_DB_FNAME_LEN]; + char tb[TSDB_TABLE_NAME_LEN]; int64_t showId; int8_t free; } SRetrieveTableReq; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 1be028116f..383f30c26f 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1734,6 +1734,8 @@ int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq if (tEncodeI64(&encoder, pReq->showId) < 0) return -1; if (tEncodeI32(&encoder, pReq->type) < 0) return -1; if (tEncodeI8(&encoder, pReq->free) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->db) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->tb) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1749,7 +1751,8 @@ int32_t tDeserializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableR if (tDecodeI64(&decoder, &pReq->showId) < 0) return -1; if (tDecodeI32(&decoder, &pReq->type) < 0) return -1; if (tDecodeI8(&decoder, &pReq->free) < 0) return -1; - + if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->tb) < 0) return -1; tEndDecode(&decoder); tCoderClear(&decoder); return 0; diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index e231717e61..c274f65b24 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -752,7 +752,7 @@ static int32_t mndGetDnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp * pSchema[cols].bytes = pShow->bytes[cols]; cols++; - pShow->bytes[cols] = 24 + VARSTR_HEADER_SIZE; + pShow->bytes[cols] = 256 + VARSTR_HEADER_SIZE; pSchema[cols].type = TSDB_DATA_TYPE_BINARY; strcpy(pSchema[cols].name, "offline_reason"); pSchema[cols].bytes = pShow->bytes[cols]; diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index 06dd66074c..dafdb0fb00 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -16,31 +16,30 @@ #define _DEFAULT_SOURCE #include "mndInfoSchema.h" -static const SInfosTableSchema dnodesSchema[] = {{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "end_point", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "vnodes", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "cores", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "role", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY}, +static const SInfosTableSchema dnodesSchema[] = {{.name = "id", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, + {.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, + {.name = "max_vnodes",.bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, + {.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, - {.name = "offline_reason", .bytes = 256, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "note", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, }; static const SInfosTableSchema mnodesSchema[] = {{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "end_point", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "role", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "role", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, {.name = "role_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, }; static const SInfosTableSchema modulesSchema[] = {{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "end_point", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "endpoint", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY}, {.name = "module", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY}, }; static const SInfosTableSchema qnodesSchema[] = {{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "end_point", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "endpoint", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, }; static const SInfosTableSchema userDBSchema[] = {{.name = "name", .bytes = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "vgroups", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, {.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, {.name = "replica", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, @@ -56,10 +55,10 @@ static const SInfosTableSchema userDBSchema[] = {{.name = "name", .b {.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "cachelast", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "precision", .bytes = 3 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, +// {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update }; static const SInfosTableSchema userFuncSchema[] = {{.name = "name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "ntables", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "precision", .bytes = 2, .type = TSDB_DATA_TYPE_BINARY}, {.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY}, @@ -72,26 +71,30 @@ static const SInfosTableSchema userIdxSchema[] = {{.name = "db_name", . {.name = "index_type", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY}, {.name = "index_extensions", .bytes = 256, .type = TSDB_DATA_TYPE_BINARY}, }; -static const SInfosTableSchema userStbsSchema[] = {{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "stable_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, +static const SInfosTableSchema userStbsSchema[] = {{.name = "db_name", .bytes = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "stable_name", .bytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "tags", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "last_update", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "table_comment", .bytes = 1024 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_INT}, }; static const SInfosTableSchema userStreamsSchema[] = {{.name = "stream_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY}, {.name = "user_name", .bytes = 23, .type = TSDB_DATA_TYPE_BINARY}, {.name = "dest_table", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "sql", .bytes = 1024, .type = TSDB_DATA_TYPE_BINARY}, }; static const SInfosTableSchema userTblsSchema[] = {{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY}, {.name = "table_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "stable_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "tid", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, - {.name = "vg_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "uid", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, + {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "ttl", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "table_comment", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, }; static const SInfosTableSchema userTblDistSchema[] = {{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY}, {.name = "table_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY}, @@ -107,11 +110,12 @@ static const SInfosTableSchema userTblDistSchema[] = {{.name = "db_name", {.name = "rows_in_mem", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "seek_header_time", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, }; -static const SInfosTableSchema userUsersSchema[] = {{.name = "user_name", .bytes = 23, .type = TSDB_DATA_TYPE_BINARY}, - {.name = "privilege", .bytes = 256, .type = TSDB_DATA_TYPE_BINARY}, +static const SInfosTableSchema userUsersSchema[] = {{.name = "name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "privilege", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "account", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, }; -static const SInfosTableSchema vgroupsSchema[] = {{.name = "vg_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, +static const SInfosTableSchema vgroupsSchema[] = {{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY}, {.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY}, @@ -123,6 +127,8 @@ static const SInfosTableSchema vgroupsSchema[] = {{.name = "vg_id", . {.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "v3_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY}, {.name = "compacting", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "nfiles", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "file_size", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, }; static const SInfosTableMeta infosMeta[] = {{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema)}, @@ -140,7 +146,7 @@ static const SInfosTableMeta infosMeta[] = {{TSDB_INS_TABLE_DNODES, dnodesSchema {TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)}, }; - +//connection/application/ int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) { SSchema *schema = calloc(colNum, sizeof(SSchema)); if (NULL == schema) { @@ -148,7 +154,6 @@ int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, S return -1; } - for (int32_t i = 0; i < colNum; ++i) { strcpy(schema[i].name, pSrc[i].name); @@ -158,7 +163,6 @@ int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, S } *pDst = schema; - return TSDB_CODE_SUCCESS; } diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index 9a6297a0f4..01627f5557 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -692,11 +692,11 @@ static int32_t mndRetrieveMnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, i cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int64_t *)pWrite = pObj->createdTime; + *(int64_t *)pWrite = pObj->roleTime; cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int64_t *)pWrite = pObj->roleTime; + *(int64_t *)pWrite = pObj->createdTime; cols++; numOfRows++; diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 83b0a0669f..ae2cf23b29 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -284,7 +284,13 @@ static int32_t mndProcessRetrieveSysTableReq(SMnodeMsg *pReq) { strncpy(req.db, retrieveReq.db, tListLen(req.db)); pShow = mndCreateShowObj(pMnode, &req); - STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, TSDB_INS_TABLE_USER_DATABASES, strlen(TSDB_INS_TABLE_USER_DATABASES)); + if (pShow == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + mError("failed to process show-meta req since %s", terrstr()); + return -1; + } + + STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb)); pShow->numOfRows = 100; int32_t offset = 0; @@ -297,12 +303,6 @@ static int32_t mndProcessRetrieveSysTableReq(SMnodeMsg *pReq) { pShow->bytes[i] = bytes; offset += bytes; } - - if (pShow == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - mError("failed to process show-meta req since %s", terrstr()); - return -1; - } } else { pShow = mndAcquireShowObj(pMnode, retrieveReq.showId); if (pShow == NULL) { diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index d8091dfa76..8e9ce1d738 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1490,7 +1490,7 @@ static void mndExtractTableName(char *tableId, char *name) { int32_t pos = -1; int32_t num = 0; for (pos = 0; tableId[pos] != 0; ++pos) { - if (tableId[pos] == '.') num++; + if (tableId[pos] == TS_PATH_DELIMITER[0]) num++; if (num == 2) break; } @@ -1508,8 +1508,11 @@ static int32_t mndRetrieveStb(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3 char *pWrite; char prefix[TSDB_DB_FNAME_LEN] = {0}; - SDbObj *pDb = mndAcquireDb(pMnode, pShow->db); - if (pDb == NULL) return 0; + SDbObj* pDb = NULL; + if (strlen(pShow->db) > 0) { + pDb = mndAcquireDb(pMnode, pShow->db); + if (pDb == NULL) return 0; + } tstrncpy(prefix, pShow->db, TSDB_DB_FNAME_LEN); strcat(prefix, TS_PATH_DELIMITER); @@ -1519,7 +1522,7 @@ static int32_t mndRetrieveStb(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3 pShow->pIter = sdbFetch(pSdb, SDB_STB, pShow->pIter, (void **)&pStb); if (pShow->pIter == NULL) break; - if (pStb->dbUid != pDb->uid) { + if (pDb != NULL && pStb->dbUid != pDb->uid) { if (strncmp(pStb->db, pDb->name, prefixLen) == 0) { mError("Inconsistent table data, name:%s, db:%s, dbUid:%" PRIu64, pStb->name, pDb->name, pDb->uid); } @@ -1530,8 +1533,17 @@ static int32_t mndRetrieveStb(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3 cols = 0; + SName name = {0}; + char db[TSDB_DB_NAME_LEN] = {0}; + tNameFromString(&name, pStb->db, T_NAME_ACCT|T_NAME_DB); + tNameGetDbName(&name, db); + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_TO_VARSTR(pWrite, db); + cols++; + char stbName[TSDB_TABLE_NAME_LEN] = {0}; - tstrncpy(stbName, pStb->name + prefixLen, TSDB_TABLE_NAME_LEN); + mndExtractTableName(pStb->name, stbName); pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; STR_TO_VARSTR(pWrite, stbName); cols++; @@ -1548,6 +1560,18 @@ static int32_t mndRetrieveStb(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3 *(int32_t *)pWrite = pStb->numOfTags; cols++; + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t *)pWrite = 0; // number of tables + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int64_t *)pWrite = pStb->updateTime; // number of tables + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_TO_VARSTR(pWrite, pStb->comment); + cols++; + numOfRows++; sdbRelease(pSdb, pStb); } diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index cdaabe46a7..1e65578c36 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -433,6 +433,7 @@ typedef struct SSysTableScanInfo { SRetrieveTableReq req; SEpSet epSet; int32_t type; // show type + SName name; tsem_t ready; SSchema* pSchema; SSDataBlock* pRes; @@ -619,7 +620,7 @@ SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntim SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataBlock* pResBlock, int32_t tableType, SEpSet epset, +SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataBlock* pResBlock, const SName* pName, SEpSet epset, SExecTaskInfo* pTaskInfo); SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 6780e6d14d..710f7e3d6e 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -5460,6 +5460,9 @@ static SSDataBlock* doSysTableScan(void* param, bool* newgroup) { int64_t startTs = taosGetTimestampUs(); pInfo->req.type = pInfo->type; +// tNameGetFullDbName(&pInfo->name, pInfo->req.db); + strncpy(pInfo->req.tb, tNameGetTableName(&pInfo->name), tListLen(pInfo->req.tb)); + int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &pInfo->req); char* buf1 = calloc(1, contLen); tSerializeSRetrieveTableReq(buf1, contLen, &pInfo->req); @@ -5502,7 +5505,7 @@ static SSDataBlock* doSysTableScan(void* param, bool* newgroup) { return NULL; } -SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataBlock* pResBlock, int32_t tableType, +SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataBlock* pResBlock, const SName* pName, SEpSet epset, SExecTaskInfo* pTaskInfo) { SSysTableScanInfo* pInfo = calloc(1, sizeof(SSysTableScanInfo)); SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); @@ -5515,7 +5518,41 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB pInfo->pRes = pResBlock; pInfo->capacity = 4096; - pInfo->type = tableType; + + int32_t tableType = 0; + const char* name = tNameGetTableName(pName); + if (strncasecmp(name, TSDB_INS_TABLE_USER_DATABASES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_DB; + } else if (strncasecmp(name, TSDB_INS_TABLE_USER_USERS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_USER; + } else if (strncasecmp(name, TSDB_INS_TABLE_DNODES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_DNODE; + } else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_MNODE; + } else if (strncasecmp(name, TSDB_INS_TABLE_MODULES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_MODULE; + } else if (strncasecmp(name, TSDB_INS_TABLE_QNODES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_QNODE; + } else if (strncasecmp(name, TSDB_INS_TABLE_USER_FUNCTIONS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_FUNC; + } else if (strncasecmp(name, TSDB_INS_TABLE_USER_INDEXES, tListLen(pName->tname)) == 0) { +// tableType = TSDB_MGMT_TABLE_INDEX; + } else if (strncasecmp(name, TSDB_INS_TABLE_USER_STABLES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_STB; + } else if (strncasecmp(name, TSDB_INS_TABLE_USER_STREAMS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_STREAMS; + } else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_TABLE; + } else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_VGROUP; + } else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, tListLen(pName->tname)) == 0) { +// tableType = TSDB_MGMT_TABLE_DIST; + } else { + ASSERT(0); + } + + tNameAssign(&pInfo->name, pName); + pInfo->type = tableType; if (pInfo->type == TSDB_MGMT_TABLE_TABLE) { pInfo->readHandle = pSysTableReadHandle; blockDataEnsureCapacity(pInfo->pRes, pInfo->capacity); @@ -8092,7 +8129,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa SSystemTableScanPhysiNode * pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode; SSDataBlock* pResBlock = createOutputBuf_rv1(pSysScanPhyNode->scan.node.pOutputDataBlockDesc); - SOperatorInfo* pOperator = createSysTableScanOperatorInfo(NULL, pResBlock, TSDB_MGMT_TABLE_DB, pSysScanPhyNode->mgmtEpSet, pTaskInfo); + SOperatorInfo* pOperator = createSysTableScanOperatorInfo(NULL, pResBlock, &pSysScanPhyNode->scan.tableName, pSysScanPhyNode->mgmtEpSet, pTaskInfo); return pOperator; } else { ASSERT(0); From 93c680580ea3966a52ded220d68614cc3494fdcb Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 16 Mar 2022 18:24:11 +0800 Subject: [PATCH 2/4] [td-13039] add the show command. --- source/dnode/mnode/impl/src/mndInfoSchema.c | 2 +- source/dnode/mnode/impl/src/mndStb.c | 5 +- source/dnode/mnode/impl/src/mndVgroup.c | 81 ++++++++++++++------- 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index dafdb0fb00..b076cf0eb0 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -116,7 +116,7 @@ static const SInfosTableSchema userUsersSchema[] = {{.name = "name", . {.name = "account", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, }; static const SInfosTableSchema vgroupsSchema[] = {{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "db_name", .bytes = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, {.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY}, {.name = "onlines", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 8e9ce1d738..35d1cf4515 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1576,7 +1576,10 @@ static int32_t mndRetrieveStb(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3 sdbRelease(pSdb, pStb); } - mndReleaseDb(pMnode, pDb); + if (pDb != NULL) { + mndReleaseDb(pMnode, pDb); + } + pShow->numOfReads += numOfRows; mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); return numOfRows; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index f7b177f170..4f67d3b776 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -559,41 +559,72 @@ static int32_t mndRetrieveVgroups(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t cols = 0; char *pWrite; - SDbObj *pDb = mndAcquireDb(pMnode, pShow->db); - if (pDb == NULL) return 0; + SDbObj *pDb = NULL; + if (strlen(pShow->db) > 0) { + pDb = mndAcquireDb(pMnode, pShow->db); + if (pDb == NULL) { + return 0; + } + } while (numOfRows < rows) { pShow->pIter = sdbFetch(pSdb, SDB_VGROUP, pShow->pIter, (void **)&pVgroup); if (pShow->pIter == NULL) break; - if (pVgroup->dbUid == pDb->uid) { - cols = 0; - - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = pVgroup->vgId; - cols++; - - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = pVgroup->numOfTables; - cols++; - - for (int32_t i = 0; i < pShow->replica; ++i) { - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int16_t *)pWrite = pVgroup->vnodeGid[i].dnodeId; - cols++; - - const char *role = mndGetRoleStr(pVgroup->vnodeGid[i].role); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_WITH_MAXSIZE_TO_VARSTR(pWrite, role, pShow->bytes[cols]); - cols++; - } - numOfRows++; + if (pDb != NULL && pVgroup->dbUid != pDb->uid) { + continue; } + cols = 0; + +// mndGetVgroupMaxReplica(pMnode, pShow->db, &pShow->replica, &pShow->numOfRows); + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t *)pWrite = pVgroup->vgId; + cols++; + + SName name = {0}; + char db[TSDB_DB_NAME_LEN] = {0}; + tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT|T_NAME_DB); + tNameGetDbName(&name, db); + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_TO_VARSTR(pWrite, db); + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t *)pWrite = pVgroup->numOfTables; + cols++; + + //status + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_TO_VARSTR(pWrite, "ready"); // TODO + cols++; + + //onlines + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t *)pWrite = pVgroup->replica; + cols++; + + + for (int32_t i = 0; i < pVgroup->replica; ++i) { + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int16_t *)pWrite = pVgroup->vnodeGid[i].dnodeId; + cols++; + + const char *role = mndGetRoleStr(pVgroup->vnodeGid[i].role); + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_WITH_MAXSIZE_TO_VARSTR(pWrite, role, pShow->bytes[cols]); + cols++; + } + + numOfRows++; sdbRelease(pSdb, pVgroup); } - mndReleaseDb(pMnode, pDb); + if (pDb != NULL) { + mndReleaseDb(pMnode, pDb); + } + mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; return numOfRows; From ee7f8bd84c4635de9062cb595e6f43ffc9b735cd Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 16 Mar 2022 18:25:10 +0800 Subject: [PATCH 3/4] [td-13039] add the show command. --- source/dnode/mnode/impl/src/mndVgroup.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 4f67d3b776..bfe6f94c2a 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -577,7 +577,6 @@ static int32_t mndRetrieveVgroups(SMnodeMsg *pReq, SShowObj *pShow, char *data, cols = 0; -// mndGetVgroupMaxReplica(pMnode, pShow->db, &pShow->replica, &pShow->numOfRows); pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int32_t *)pWrite = pVgroup->vgId; cols++; From 0f6573d537f03252700a452f44263c99b365d88b Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 16 Mar 2022 22:33:44 -0400 Subject: [PATCH 4/4] TD-14043 show statement bugfix --- source/libs/nodes/src/nodesCodeFuncs.c | 13 +++++++++--- source/libs/parser/inc/parAst.h | 1 + source/libs/parser/inc/sql.y | 4 ++-- source/libs/parser/src/parAstCreater.c | 18 +++++++++++++++- source/libs/parser/src/parTranslater.c | 25 ++++------------------- source/libs/parser/src/sql.c | 12 ++++++----- source/libs/parser/test/parserAstTest.cpp | 8 ++++---- 7 files changed, 45 insertions(+), 36 deletions(-) diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 5d007db29b..1c72a90c13 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -1040,7 +1040,7 @@ static int32_t datumToJson(const void* pObj, SJson* pJson) { case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: - code = tjsonAddStringToObject(pJson, jkValueDatum, pNode->datum.p); + code = tjsonAddStringToObject(pJson, jkValueDatum, varDataVal(pNode->datum.p)); break; case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_DECIMAL: @@ -1103,9 +1103,16 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) { case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_VARCHAR: - case TSDB_DATA_TYPE_VARBINARY: - code = tjsonDupStringValue(pJson, jkValueDatum, &pNode->datum.p); + case TSDB_DATA_TYPE_VARBINARY: { + pNode->datum.p = calloc(1, pNode->node.resType.bytes); + if (NULL == pNode->datum.p) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + varDataSetLen(pNode->datum.p, pNode->node.resType.bytes); + code = tjsonGetStringValue(pJson, jkValueDatum, varDataVal(pNode->datum.p)); break; + } case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_DECIMAL: case TSDB_DATA_TYPE_BLOB: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 5470c67235..7ecfe626ce 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -80,6 +80,7 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode SNode* createColumnNode(SAstCreateContext* pCxt, const SToken* pTableAlias, const SToken* pColumnName); SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral); SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral); +SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt); SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* pAlias); SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType type, SNode* pParam1, SNode* pParam2); SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 2074c18533..c49ffd6d90 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -203,7 +203,7 @@ cmd ::= SHOW FUNCTIONS. cmd ::= SHOW INDEXES FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, A, B); } cmd ::= SHOW STREAMS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } -db_name_cond_opt(A) ::= . { A = NULL; } +db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); } db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } like_pattern_opt(A) ::= . { A = NULL; } @@ -211,7 +211,7 @@ like_pattern_opt(A) ::= LIKE NK_STRING(B). table_name_cond(A) ::= table_name(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } -from_db_opt(A) ::= . { A = NULL; } +from_db_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); } from_db_opt(A) ::= FROM db_name(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } /************************************************ select **************************************************************/ diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index f8086e8a63..4ba989ca3e 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -489,9 +489,12 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); CHECK_OUT_OF_MEM(val); val->literal = strndup(pLiteral->z, pLiteral->n); + if (IS_VAR_DATA_TYPE(dataType) || TSDB_DATA_TYPE_TIMESTAMP == dataType) { + trimString(pLiteral->z, pLiteral->n, val->literal, pLiteral->n); + } CHECK_OUT_OF_MEM(val->literal); val->node.resType.type = dataType; - val->node.resType.bytes = tDataTypes[dataType].bytes; + val->node.resType.bytes = IS_VAR_DATA_TYPE(dataType) ? strlen(val->literal) : tDataTypes[dataType].bytes; if (TSDB_DATA_TYPE_TIMESTAMP == dataType) { val->node.resType.precision = TSDB_TIME_PRECISION_MILLI; } @@ -513,6 +516,19 @@ SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral) return (SNode*)val; } +SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) { + SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + CHECK_OUT_OF_MEM(val); + val->literal = strdup(pCxt->pQueryCxt->db); + CHECK_OUT_OF_MEM(val->literal); + val->isDuration = false; + val->translate = false; + val->node.resType.type = TSDB_DATA_TYPE_BINARY; + val->node.resType.bytes = strlen(val->literal); + val->node.resType.precision = TSDB_TIME_PRECISION_MILLI; + return (SNode*)val; +} + SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType type, SNode* pParam1, SNode* pParam2) { SLogicConditionNode* cond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); CHECK_OUT_OF_MEM(cond); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 8eb79fe8aa..9efc88d11b 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -307,15 +307,6 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) { return found ? DEAL_RES_CONTINUE : translateColumnWithoutPrefix(pCxt, pCol); } -static int32_t trimStringWithVarFormat(const char* src, int32_t len, bool format, char* dst) { - char* dstVal = dst; - if (format) { - varDataSetLen(dst, len); - dstVal = varDataVal(dst); - } - return trimString(src, len, dstVal, len); -} - static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { if (pVal->isDuration) { char unit = 0; @@ -355,26 +346,18 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: { - int32_t n = strlen(pVal->literal); - pVal->datum.p = calloc(1, n + VARSTR_HEADER_SIZE); + pVal->datum.p = calloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE); if (NULL == pVal->datum.p) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY); } - trimStringWithVarFormat(pVal->literal, n, true, pVal->datum.p); + varDataSetLen(pVal->datum.p, pVal->node.resType.bytes); + strcpy(varDataVal(pVal->datum.p), pVal->literal); break; } case TSDB_DATA_TYPE_TIMESTAMP: { - int32_t n = strlen(pVal->literal); - char* tmp = calloc(1, n); - if (NULL == tmp) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY); - } - int32_t len = trimStringWithVarFormat(pVal->literal, n, false, tmp); - if (taosParseTime(tmp, &pVal->datum.i, len, pVal->node.resType.precision, tsDaylight) != TSDB_CODE_SUCCESS) { - tfree(tmp); + if (taosParseTime(pVal->literal, &pVal->datum.i, pVal->node.resType.bytes, pVal->node.resType.precision, tsDaylight) != TSDB_CODE_SUCCESS) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); } - tfree(tmp); break; } case TSDB_DATA_TYPE_JSON: diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 9312537c49..806e7efc77 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -2284,8 +2284,14 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } break; case 101: /* db_name_cond_opt ::= */ - case 103: /* like_pattern_opt ::= */ yytestcase(yyruleno==103); case 106: /* from_db_opt ::= */ yytestcase(yyruleno==106); +{ yymsp[1].minor.yy68 = createDefaultDatabaseCondValue(pCxt); } + break; + case 102: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy68 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy5); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; + break; + case 103: /* like_pattern_opt ::= */ case 198: /* where_clause_opt ::= */ yytestcase(yyruleno==198); case 202: /* twindow_clause_opt ::= */ yytestcase(yyruleno==202); case 207: /* sliding_opt ::= */ yytestcase(yyruleno==207); @@ -2295,10 +2301,6 @@ static YYACTIONTYPE yy_reduce( case 233: /* limit_clause_opt ::= */ yytestcase(yyruleno==233); { yymsp[1].minor.yy68 = NULL; } break; - case 102: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy68 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy5); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; - break; case 104: /* like_pattern_opt ::= LIKE NK_STRING */ { yymsp[-1].minor.yy68 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index 732e8ec0a7..20dcc3251d 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -409,11 +409,11 @@ TEST_F(ParserTest, createTable) { TEST_F(ParserTest, showTables) { setDatabase("root", "test"); - // bind("show tables"); - // ASSERT_TRUE(run()); + bind("show tables"); + ASSERT_TRUE(run()); - // bind("show test.tables"); - // ASSERT_TRUE(run()); + bind("show test.tables"); + ASSERT_TRUE(run()); bind("show tables like 'c%'"); ASSERT_TRUE(run());