Merge pull request #11942 from taosdata/feature/3.0_liaohj
enh(query): add more information for the result of show tables.
This commit is contained in:
commit
576c4fa07a
|
@ -32,6 +32,7 @@ typedef struct SReadHandle {
|
||||||
void* reader;
|
void* reader;
|
||||||
void* meta;
|
void* meta;
|
||||||
void* config;
|
void* config;
|
||||||
|
void* vnode;
|
||||||
} SReadHandle;
|
} SReadHandle;
|
||||||
|
|
||||||
#define STREAM_DATA_TYPE_SUBMIT_BLOCK 0x1
|
#define STREAM_DATA_TYPE_SUBMIT_BLOCK 0x1
|
||||||
|
|
|
@ -142,6 +142,7 @@ static const SInfosTableSchema userTblsSchema[] = {
|
||||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "ttl", .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},
|
{.name = "table_comment", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
|
{.name = "type", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SInfosTableSchema userTblDistSchema[] = {
|
static const SInfosTableSchema userTblDistSchema[] = {
|
||||||
|
|
|
@ -68,6 +68,7 @@ void vnodeStop(SVnode *pVnode);
|
||||||
|
|
||||||
int64_t vnodeGetSyncHandle(SVnode *pVnode);
|
int64_t vnodeGetSyncHandle(SVnode *pVnode);
|
||||||
void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot);
|
void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot);
|
||||||
|
void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId);
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
typedef struct SMeta SMeta; // todo: remove
|
typedef struct SMeta SMeta; // todo: remove
|
||||||
|
|
|
@ -88,7 +88,7 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
|
||||||
|
|
||||||
// preprocess req
|
// preprocess req
|
||||||
pReq->uid = tGenIdPI64();
|
pReq->uid = tGenIdPI64();
|
||||||
pReq->ctime = taosGetTimestampSec();
|
pReq->ctime = taosGetTimestampMs();
|
||||||
|
|
||||||
// validate req
|
// validate req
|
||||||
metaReaderInit(&mr, pMeta, 0);
|
metaReaderInit(&mr, pMeta, 0);
|
||||||
|
|
|
@ -138,3 +138,13 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
||||||
pLoad->numOfBatchInsertSuccessReqs = 4;
|
pLoad->numOfBatchInsertSuccessReqs = 4;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId) {
|
||||||
|
if (dbname) {
|
||||||
|
*dbname = pVnode->config.dbname;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vgId) {
|
||||||
|
*vgId = TD_VID(pVnode);
|
||||||
|
}
|
||||||
|
}
|
|
@ -142,7 +142,7 @@ _err:
|
||||||
|
|
||||||
int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
vTrace("message in vnode query queue is processing");
|
vTrace("message in vnode query queue is processing");
|
||||||
SReadHandle handle = {.reader = pVnode->pTsdb, .meta = pVnode->pMeta, .config = &pVnode->config};
|
SReadHandle handle = {.reader = pVnode->pTsdb, .meta = pVnode->pMeta, .config = &pVnode->config, .vnode = pVnode};
|
||||||
|
|
||||||
switch (pMsg->msgType) {
|
switch (pMsg->msgType) {
|
||||||
case TDMT_VND_QUERY:
|
case TDMT_VND_QUERY:
|
||||||
|
|
|
@ -380,7 +380,7 @@ typedef struct SStreamBlockScanInfo {
|
||||||
typedef struct SSysTableScanInfo {
|
typedef struct SSysTableScanInfo {
|
||||||
union {
|
union {
|
||||||
void* pTransporter;
|
void* pTransporter;
|
||||||
void* readHandle;
|
SReadHandle readHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
SRetrieveMetaTableRsp* pRsp;
|
SRetrieveMetaTableRsp* pRsp;
|
||||||
|
|
|
@ -3738,7 +3738,32 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO if only one or two columns required, how to extract data?
|
// NOTE: sources columns are more than the destination SSDatablock columns.
|
||||||
|
static void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols) {
|
||||||
|
size_t numOfSrcCols = taosArrayGetSize(pCols);
|
||||||
|
ASSERT(numOfSrcCols >= pBlock->info.numOfCols);
|
||||||
|
|
||||||
|
int32_t i = 0, j = 0;
|
||||||
|
while(i < numOfSrcCols && j < taosArrayGetSize(pColMatchInfo)) {
|
||||||
|
SColumnInfoData* p = taosArrayGet(pCols, i);
|
||||||
|
SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, j);
|
||||||
|
if (!pmInfo->output) {
|
||||||
|
j++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->info.colId == pmInfo->colId) {
|
||||||
|
taosArraySet(pBlock->pDataBlock, pmInfo->targetSlotId, p);
|
||||||
|
i++;
|
||||||
|
j++;
|
||||||
|
} else if (p->info.colId < pmInfo->colId) {
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
|
int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
|
||||||
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
|
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
|
||||||
SArray* pColList) {
|
SArray* pColList) {
|
||||||
|
@ -3756,7 +3781,7 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
||||||
char* pStart = pData + sizeof(int32_t) * numOfOutput;
|
char* pStart = pData + sizeof(int32_t) * numOfOutput;
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
colLen[i] = htonl(colLen[i]);
|
colLen[i] = htonl(colLen[i]);
|
||||||
ASSERT(colLen[i] > 0);
|
ASSERT(colLen[i] >= 0);
|
||||||
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pRes->pDataBlock, i);
|
SColumnInfoData* pColInfoData = taosArrayGet(pRes->pDataBlock, i);
|
||||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||||
|
@ -3766,13 +3791,18 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
||||||
memcpy(pColInfoData->varmeta.offset, pStart, sizeof(int32_t) * numOfRows);
|
memcpy(pColInfoData->varmeta.offset, pStart, sizeof(int32_t) * numOfRows);
|
||||||
pStart += sizeof(int32_t) * numOfRows;
|
pStart += sizeof(int32_t) * numOfRows;
|
||||||
|
|
||||||
pColInfoData->pData = taosMemoryMalloc(colLen[i]);
|
if (colLen[i] > 0) {
|
||||||
|
pColInfoData->pData = taosMemoryMalloc(colLen[i]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
memcpy(pColInfoData->nullbitmap, pStart, BitmapLen(numOfRows));
|
memcpy(pColInfoData->nullbitmap, pStart, BitmapLen(numOfRows));
|
||||||
pStart += BitmapLen(numOfRows);
|
pStart += BitmapLen(numOfRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pColInfoData->pData, pStart, colLen[i]);
|
if (colLen[i] > 0) {
|
||||||
|
memcpy(pColInfoData->pData, pStart, colLen[i]);
|
||||||
|
}
|
||||||
|
|
||||||
//TODO setting this flag to true temporarily so aggregate function on stable will
|
//TODO setting this flag to true temporarily so aggregate function on stable will
|
||||||
//examine NULL value for non-primary key column
|
//examine NULL value for non-primary key column
|
||||||
pColInfoData->hasNull = true;
|
pColInfoData->hasNull = true;
|
||||||
|
@ -3785,6 +3815,7 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
||||||
int32_t numOfCols = htonl(*(int32_t*)pStart);
|
int32_t numOfCols = htonl(*(int32_t*)pStart);
|
||||||
pStart += sizeof(int32_t);
|
pStart += sizeof(int32_t);
|
||||||
|
|
||||||
|
// todo refactor:extract method
|
||||||
SSysTableSchema* pSchema = (SSysTableSchema*)pStart;
|
SSysTableSchema* pSchema = (SSysTableSchema*)pStart;
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SSysTableSchema* p = (SSysTableSchema*)pStart;
|
SSysTableSchema* p = (SSysTableSchema*)pStart;
|
||||||
|
@ -3839,19 +3870,7 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
||||||
}
|
}
|
||||||
|
|
||||||
// data from mnode
|
// data from mnode
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
relocateColumnData(pRes, pColList, block.pDataBlock);
|
||||||
SColumnInfoData* pSrc = taosArrayGet(block.pDataBlock, i);
|
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfOutput; ++j) {
|
|
||||||
int16_t colIndex = *(int16_t*)taosArrayGet(pColList, j);
|
|
||||||
|
|
||||||
if (colIndex - 1 == i) {
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pRes->pDataBlock, j);
|
|
||||||
colDataAssign(pColInfoData, pSrc, numOfRows);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pRes->info.rows = numOfRows;
|
pRes->info.rows = numOfRows;
|
||||||
|
@ -6423,7 +6442,6 @@ static tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SRead
|
||||||
static int32_t doCreateTableGroup(void* metaHandle, int32_t tableType, uint64_t tableUid, STableGroupInfo* pGroupInfo,
|
static int32_t doCreateTableGroup(void* metaHandle, int32_t tableType, uint64_t tableUid, STableGroupInfo* pGroupInfo,
|
||||||
uint64_t queryId, uint64_t taskId);
|
uint64_t queryId, uint64_t taskId);
|
||||||
static SArray* extractTableIdList(const STableGroupInfo* pTableGroupInfo);
|
static SArray* extractTableIdList(const STableGroupInfo* pTableGroupInfo);
|
||||||
static SArray* extractScanColumnId(SNodeList* pNodeList);
|
|
||||||
static SArray* extractColumnInfo(SNodeList* pNodeList);
|
static SArray* extractColumnInfo(SNodeList* pNodeList);
|
||||||
static SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols);
|
static SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols);
|
||||||
|
|
||||||
|
@ -6494,10 +6512,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan;
|
SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan;
|
||||||
|
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pScanNode->node.pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createResDataBlock(pScanNode->node.pOutputDataBlockDesc);
|
||||||
SArray* colList = extractScanColumnId(pScanNode->pScanCols);
|
|
||||||
|
|
||||||
|
int32_t numOfOutputCols = 0;
|
||||||
|
SArray* colList = extractColMatchInfo(pScanNode->pScanCols, pScanNode->node.pOutputDataBlockDesc, &numOfOutputCols);
|
||||||
SOperatorInfo* pOperator = createSysTableScanOperatorInfo(
|
SOperatorInfo* pOperator = createSysTableScanOperatorInfo(
|
||||||
pHandle->meta, pResBlock, &pScanNode->tableName, pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet,
|
pHandle, pResBlock, &pScanNode->tableName, pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet,
|
||||||
colList, pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId);
|
colList, pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
} else {
|
} else {
|
||||||
|
@ -6658,28 +6677,6 @@ static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableS
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* extractScanColumnId(SNodeList* pNodeList) {
|
|
||||||
size_t numOfCols = LIST_LENGTH(pNodeList);
|
|
||||||
SArray* pList = taosArrayInit(numOfCols, sizeof(int16_t));
|
|
||||||
if (pList == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
|
||||||
for (int32_t j = 0; j < numOfCols; ++j) {
|
|
||||||
STargetNode* pNode = (STargetNode*)nodesListGetNode(pNodeList, j);
|
|
||||||
if (pNode->slotId == i) {
|
|
||||||
SColumnNode* pColNode = (SColumnNode*)pNode->pExpr;
|
|
||||||
taosArrayPush(pList, &pColNode->colId);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pList;
|
|
||||||
}
|
|
||||||
|
|
||||||
SArray* extractColumnInfo(SNodeList* pNodeList) {
|
SArray* extractColumnInfo(SNodeList* pNodeList) {
|
||||||
size_t numOfCols = LIST_LENGTH(pNodeList);
|
size_t numOfCols = LIST_LENGTH(pNodeList);
|
||||||
SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn));
|
SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn));
|
||||||
|
@ -6815,9 +6812,9 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
|
||||||
SColumnNode* pColNode = (SColumnNode*)pNode->pExpr;
|
SColumnNode* pColNode = (SColumnNode*)pNode->pExpr;
|
||||||
|
|
||||||
SColMatchInfo c = {0};
|
SColMatchInfo c = {0};
|
||||||
|
c.output = true;
|
||||||
c.colId = pColNode->colId;
|
c.colId = pColNode->colId;
|
||||||
c.targetSlotId = pNode->slotId;
|
c.targetSlotId = pNode->slotId;
|
||||||
c.output = true;
|
|
||||||
taosArrayPush(pList, &c);
|
taosArrayPush(pList, &c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6825,8 +6822,10 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
|
||||||
int32_t num = LIST_LENGTH(pOutputNodeList->pSlots);
|
int32_t num = LIST_LENGTH(pOutputNodeList->pSlots);
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SSlotDescNode* pNode = (SSlotDescNode*)nodesListGetNode(pOutputNodeList->pSlots, i);
|
SSlotDescNode* pNode = (SSlotDescNode*)nodesListGetNode(pOutputNodeList->pSlots, i);
|
||||||
|
|
||||||
// todo: add reserve flag check
|
// todo: add reserve flag check
|
||||||
if (pNode->slotId >= numOfCols) { // it is a column reserved for the arithmetic expression calculation
|
// it is a column reserved for the arithmetic expression calculation
|
||||||
|
if (pNode->slotId >= numOfCols) {
|
||||||
(*numOfOutputCols) += 1;
|
(*numOfOutputCols) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -811,7 +811,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
const char* name = tNameGetTableName(&pInfo->name);
|
const char* name = tNameGetTableName(&pInfo->name);
|
||||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
if (pInfo->pCur == NULL) {
|
if (pInfo->pCur == NULL) {
|
||||||
pInfo->pCur = metaOpenTbCursor(pInfo->readHandle);
|
pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDataCleanup(pInfo->pRes);
|
blockDataCleanup(pInfo->pRes);
|
||||||
|
@ -819,32 +819,97 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
int32_t tableNameSlotId = 1;
|
int32_t tableNameSlotId = 1;
|
||||||
SColumnInfoData* pTableNameCol = taosArrayGet(pInfo->pRes->pDataBlock, tableNameSlotId);
|
SColumnInfoData* pTableNameCol = taosArrayGet(pInfo->pRes->pDataBlock, tableNameSlotId);
|
||||||
|
|
||||||
char* tb = NULL;
|
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
|
|
||||||
|
const char* db = NULL;
|
||||||
|
int32_t vgId = 0;
|
||||||
|
vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId);
|
||||||
|
|
||||||
|
SName sn = {0};
|
||||||
|
char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
tNameFromString(&sn, db, T_NAME_ACCT|T_NAME_DB);
|
||||||
|
|
||||||
|
tNameGetDbName(&sn, varDataVal(dbname));
|
||||||
|
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
||||||
|
|
||||||
char n[TSDB_TABLE_NAME_LEN] = {0};
|
char n[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
while (metaTbCursorNext(pInfo->pCur) == 0) {
|
while (metaTbCursorNext(pInfo->pCur) == 0) {
|
||||||
STR_TO_VARSTR(n, pInfo->pCur->mr.me.name);
|
STR_TO_VARSTR(n, pInfo->pCur->mr.me.name);
|
||||||
colDataAppend(pTableNameCol, numOfRows, n, false);
|
colDataAppend(pTableNameCol, numOfRows, n, false);
|
||||||
numOfRows += 1;
|
|
||||||
if (numOfRows >= pInfo->capacity) {
|
int32_t tableType = pInfo->pCur->mr.me.type;
|
||||||
break;
|
|
||||||
|
// database name
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 0);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, dbname, false);
|
||||||
|
|
||||||
|
// vgId
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 6);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*) &vgId, false);
|
||||||
|
|
||||||
|
// table comment
|
||||||
|
// todo: set the correct comment
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 8);
|
||||||
|
colDataAppendNULL(pColInfoData, numOfRows);
|
||||||
|
|
||||||
|
char str[256] = {0};
|
||||||
|
if (tableType == TSDB_CHILD_TABLE) {
|
||||||
|
SMetaReader mr = {0};
|
||||||
|
metaReaderInit(&mr, pInfo->readHandle.meta, 0);
|
||||||
|
metaGetTableEntryByUid(&mr, pInfo->pCur->mr.me.ctbEntry.suid);
|
||||||
|
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 3);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*) &mr.me.stbEntry.schema.nCols, false);
|
||||||
|
|
||||||
|
// create time
|
||||||
|
int64_t ts = pInfo->pCur->mr.me.ctbEntry.ctime;
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 2);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*) &ts, false);
|
||||||
|
|
||||||
|
// super table name
|
||||||
|
STR_TO_VARSTR(str, mr.me.name);
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 4);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, str, false);
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
|
||||||
|
// uid
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 5);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.uid, false);
|
||||||
|
|
||||||
|
// ttl
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 7);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.ctbEntry.ttlDays, false);
|
||||||
|
|
||||||
|
STR_TO_VARSTR(str, "CHILD_TABLE");
|
||||||
|
} else if (tableType == TSDB_NORMAL_TABLE) {
|
||||||
|
// create time
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 2);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.ntbEntry.ctime, false);
|
||||||
|
|
||||||
|
// number of columns
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 3);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.ntbEntry.schema.nCols, false);
|
||||||
|
|
||||||
|
// super table name
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 4);
|
||||||
|
colDataAppendNULL(pColInfoData, numOfRows);
|
||||||
|
|
||||||
|
// uid
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 5);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.uid, false);
|
||||||
|
|
||||||
|
// ttl
|
||||||
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 7);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.ntbEntry.ttlDays, false);
|
||||||
|
|
||||||
|
STR_TO_VARSTR(str, "NORMAL_TABLE");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < pInfo->pRes->info.numOfCols; ++i) {
|
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 9);
|
||||||
if (i == tableNameSlotId) {
|
colDataAppend(pColInfoData, numOfRows, str, false);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, i);
|
if (++numOfRows >= pInfo->capacity) {
|
||||||
int64_t tmp = 0;
|
break;
|
||||||
char t[10] = {0};
|
|
||||||
STR_TO_VARSTR(t, "_"); // TODO
|
|
||||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
|
||||||
colDataAppend(pColInfoData, numOfRows, t, false);
|
|
||||||
} else {
|
|
||||||
colDataAppend(pColInfoData, numOfRows, (char*)&tmp, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,7 +988,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataBlock* pResBlock, const SName* pName,
|
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSDataBlock* pResBlock, const SName* pName,
|
||||||
SNode* pCondition, SEpSet epset, SArray* colList,
|
SNode* pCondition, SEpSet epset, SArray* colList,
|
||||||
SExecTaskInfo* pTaskInfo, bool showRewrite, int32_t accountId) {
|
SExecTaskInfo* pTaskInfo, bool showRewrite, int32_t accountId) {
|
||||||
SSysTableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SSysTableScanInfo));
|
SSysTableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SSysTableScanInfo));
|
||||||
|
@ -945,7 +1010,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
|
||||||
tNameAssign(&pInfo->name, pName);
|
tNameAssign(&pInfo->name, pName);
|
||||||
const char* name = tNameGetTableName(&pInfo->name);
|
const char* name = tNameGetTableName(&pInfo->name);
|
||||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
pInfo->readHandle = pSysTableReadHandle;
|
pInfo->readHandle = *(SReadHandle*) readHandle;
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pInfo->capacity);
|
blockDataEnsureCapacity(pInfo->pRes, pInfo->capacity);
|
||||||
} else {
|
} else {
|
||||||
tsem_init(&pInfo->ready, 0, 0);
|
tsem_init(&pInfo->ready, 0, 0);
|
||||||
|
|
Loading…
Reference in New Issue