diff --git a/include/common/tmsg.h b/include/common/tmsg.h index cf3712b4447570e35e9d743e8b947358b90a672e..39f50e04967a2b7eb9fcf150866be2f0df9a1e4a 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -812,6 +812,7 @@ typedef struct { typedef struct { char tbFname[TSDB_TABLE_FNAME_LEN]; // table full name char stbFname[TSDB_TABLE_FNAME_LEN]; + char dbFname[TSDB_DB_FNAME_LEN]; int32_t numOfTags; int32_t numOfColumns; int8_t precision; diff --git a/source/dnode/vnode/impl/src/vnodeQuery.c b/source/dnode/vnode/impl/src/vnodeQuery.c index d869c245d91fa87de61967ab5b55bc2eac8e99a2..cbc4d75e8bd034e23f02221d41e6f0f4d543bf27 100644 --- a/source/dnode/vnode/impl/src/vnodeQuery.c +++ b/source/dnode/vnode/impl/src/vnodeQuery.c @@ -60,9 +60,11 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { int32_t nCols; int32_t nTagCols; SSchemaWrapper *pSW; - STableMetaMsg * pTbMetaMsg; + STableMetaMsg * pTbMetaMsg = NULL; SSchema * pTagSchema; SRpcMsg rpcMsg; + int msgLen = 0; + int32_t code = TSDB_CODE_VND_APP_ERROR; pTbCfg = metaGetTbInfoByName(pVnode->pMeta, pReq->tableFname, &uid); if (pTbCfg == NULL) { @@ -92,12 +94,13 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { pTagSchema = NULL; } - int msgLen = sizeof(STableMetaMsg) + sizeof(SSchema) * (nCols + nTagCols); + msgLen = sizeof(STableMetaMsg) + sizeof(SSchema) * (nCols + nTagCols); pTbMetaMsg = (STableMetaMsg *)rpcMallocCont(msgLen); if (pTbMetaMsg == NULL) { goto _exit; } + memcpy(pTbMetaMsg->dbFname, pReq->dbFname, sizeof(pTbMetaMsg->dbFname)); strcpy(pTbMetaMsg->tbFname, pTbCfg->name); if (pTbCfg->type == META_CHILD_TABLE) { strcpy(pTbMetaMsg->stbFname, pStbCfg->name); @@ -120,13 +123,15 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { pSch->bytes = htonl(pSch->bytes); } + code = 0; + _exit: - rpcMsg.handle = pMsg->handle; - rpcMsg.ahandle = pMsg->ahandle; - rpcMsg.pCont = pTbMetaMsg; - rpcMsg.contLen = msgLen; - rpcMsg.code = 0; + rpcMsg.handle = pMsg->handle; + rpcMsg.ahandle = pMsg->ahandle; + rpcMsg.pCont = pTbMetaMsg; + rpcMsg.contLen = msgLen; + rpcMsg.code = code; rpcSendResponse(&rpcMsg); diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index 1e27749a1ac576d4c0e3855e9ab80c270b31bf3e..29f84ddcd068b8e706442dbd9a02624b68692b0f 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -248,9 +248,14 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) { if (pMetaMsg->tableType == TSDB_CHILD_TABLE) { pOut->metaNum = 2; - - memcpy(pOut->ctbFname, pMetaMsg->tbFname, sizeof(pOut->ctbFname)); - memcpy(pOut->tbFname, pMetaMsg->stbFname, sizeof(pOut->tbFname)); + + if (pMetaMsg->dbFname[0]) { + snprintf(pOut->ctbFname, "%s.%s", pMetaMsg->dbFname, pMetaMsg->tbFname); + snprintf(pOut->tbFname, "%s.%s", pMetaMsg->dbFname, pMetaMsg->stbFname); + } else { + memcpy(pOut->ctbFname, pMetaMsg->tbFname, sizeof(pOut->ctbFname)); + memcpy(pOut->tbFname, pMetaMsg->stbFname, sizeof(pOut->tbFname)); + } pOut->ctbMeta.vgId = pMetaMsg->vgId; pOut->ctbMeta.tableType = pMetaMsg->tableType; @@ -261,7 +266,11 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) { } else { pOut->metaNum = 1; - memcpy(pOut->tbFname, pMetaMsg->tbFname, sizeof(pOut->tbFname)); + if (pMetaMsg->dbFname[0]) { + snprintf(pOut->tbFname, "%s.%s", pMetaMsg->dbFname, pMetaMsg->tbFname); + } else { + memcpy(pOut->tbFname, pMetaMsg->tbFname, sizeof(pOut->tbFname)); + } code = queryCreateTableMetaFromMsg(pMetaMsg, false, &pOut->tbMeta); }