support quick cmd
This commit is contained in:
parent
620c7627e9
commit
6ad894b356
|
@ -61,7 +61,7 @@ extern "C" {
|
|||
#define TSDB_INS_TABLE_MACHINES "ins_machines"
|
||||
#define TSDB_INS_TABLE_ENCRYPTIONS "ins_encryptions"
|
||||
#define TSDB_INS_TABLE_TSMAS "ins_tsmas"
|
||||
#define TSDB_INS_TABLE_USAGE "ins_usage"
|
||||
#define TSDB_INS_DISK_USAGE "ins_disk_usage"
|
||||
|
||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
||||
|
|
|
@ -300,20 +300,9 @@ int32_t tSerializeBlockDistInfo(void* buf, int32_t bufLen, const STableBlockDist
|
|||
int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo* pInfo);
|
||||
|
||||
typedef struct SDBBlockUsageInfo {
|
||||
uint32_t rowSize;
|
||||
uint16_t numOfFiles;
|
||||
uint32_t numOfTables;
|
||||
uint32_t numOfBlocks;
|
||||
uint64_t totalSize;
|
||||
uint64_t totalRows;
|
||||
int32_t maxRows;
|
||||
int32_t minRows;
|
||||
int32_t defMinRows;
|
||||
int32_t defMaxRows;
|
||||
int32_t firstSeekTimeUs;
|
||||
uint32_t numOfInmemRows;
|
||||
uint32_t numOfSttRows;
|
||||
uint32_t numOfVgroups;
|
||||
uint64_t dataInDiskSize;
|
||||
uint64_t walInDiskSize;
|
||||
uint64_t rawDataSize;
|
||||
} SDBBlockUsageInfo;
|
||||
|
||||
int32_t tSerializeBlockDbUsage(void* buf, int32_t bufLen, const SDBBlockUsageInfo* pInfo);
|
||||
|
|
|
@ -22,8 +22,8 @@ extern "C" {
|
|||
|
||||
#include "nodes.h"
|
||||
#include "tmsg.h"
|
||||
#include "tvariant.h"
|
||||
#include "tsimplehash.h"
|
||||
#include "tvariant.h"
|
||||
|
||||
#define TABLE_TOTAL_COL_NUM(pMeta) ((pMeta)->tableInfo.numOfColumns + (pMeta)->tableInfo.numOfTags)
|
||||
#define TABLE_META_SIZE(pMeta) \
|
||||
|
@ -41,7 +41,7 @@ typedef struct SRawExprNode {
|
|||
char* p;
|
||||
uint32_t n;
|
||||
SNode* pNode;
|
||||
bool isPseudoColumn;
|
||||
bool isPseudoColumn;
|
||||
} SRawExprNode;
|
||||
|
||||
typedef struct SDataType {
|
||||
|
@ -111,8 +111,8 @@ typedef struct STargetNode {
|
|||
#define VALUE_FLAG_IS_DURATION (1 << 0)
|
||||
#define VALUE_FLAG_IS_TIME_OFFSET (1 << 1)
|
||||
|
||||
#define IS_DURATION_VAL(_flag) ((_flag) & VALUE_FLAG_IS_DURATION)
|
||||
#define IS_TIME_OFFSET_VAL(_flag) ((_flag) & VALUE_FLAG_IS_TIME_OFFSET)
|
||||
#define IS_DURATION_VAL(_flag) ((_flag)&VALUE_FLAG_IS_DURATION)
|
||||
#define IS_TIME_OFFSET_VAL(_flag) ((_flag)&VALUE_FLAG_IS_TIME_OFFSET)
|
||||
|
||||
typedef struct SValueNode {
|
||||
SExprNode node; // QUERY_NODE_VALUE
|
||||
|
@ -190,7 +190,7 @@ typedef struct SFunctionNode {
|
|||
bool hasOriginalFunc;
|
||||
int32_t originalFuncId;
|
||||
ETrimType trimType;
|
||||
bool dual; // whether select stmt without from stmt, true for without.
|
||||
bool dual; // whether select stmt without from stmt, true for without.
|
||||
} SFunctionNode;
|
||||
|
||||
typedef struct STableNode {
|
||||
|
@ -205,7 +205,7 @@ typedef struct STableNode {
|
|||
struct STableMeta;
|
||||
|
||||
typedef struct STsmaTargetCTbInfo {
|
||||
char tableName[TSDB_TABLE_NAME_LEN]; // child table or normal table name
|
||||
char tableName[TSDB_TABLE_NAME_LEN]; // child table or normal table name
|
||||
uint64_t uid;
|
||||
} STsmaTargetTbInfo;
|
||||
|
||||
|
@ -219,8 +219,8 @@ typedef struct SRealTableNode {
|
|||
int8_t cacheLastMode;
|
||||
int8_t stbRewrite;
|
||||
SArray* pTsmas;
|
||||
SArray* tsmaTargetTbVgInfo; // SArray<SVgroupsInfo*>, used for child table or normal table only
|
||||
SArray* tsmaTargetTbInfo; // SArray<STsmaTargetTbInfo>, used for child table or normal table only
|
||||
SArray* tsmaTargetTbVgInfo; // SArray<SVgroupsInfo*>, used for child table or normal table only
|
||||
SArray* tsmaTargetTbInfo; // SArray<STsmaTargetTbInfo>, used for child table or normal table only
|
||||
} SRealTableNode;
|
||||
|
||||
typedef struct STempTableNode {
|
||||
|
@ -238,12 +238,12 @@ typedef struct SViewNode {
|
|||
int8_t cacheLastMode;
|
||||
} SViewNode;
|
||||
|
||||
#define JOIN_JLIMIT_MAX_VALUE 1024
|
||||
#define JOIN_JLIMIT_MAX_VALUE 1024
|
||||
|
||||
#define IS_INNER_NONE_JOIN(_type, _stype) ((_type) == JOIN_TYPE_INNER && (_stype) == JOIN_STYPE_NONE)
|
||||
#define IS_SEMI_JOIN(_stype) ((_stype) == JOIN_STYPE_SEMI)
|
||||
#define IS_WINDOW_JOIN(_stype) ((_stype) == JOIN_STYPE_WIN)
|
||||
#define IS_ASOF_JOIN(_stype) ((_stype) == JOIN_STYPE_ASOF)
|
||||
#define IS_SEMI_JOIN(_stype) ((_stype) == JOIN_STYPE_SEMI)
|
||||
#define IS_WINDOW_JOIN(_stype) ((_stype) == JOIN_STYPE_WIN)
|
||||
#define IS_ASOF_JOIN(_stype) ((_stype) == JOIN_STYPE_ASOF)
|
||||
|
||||
typedef enum EJoinType {
|
||||
JOIN_TYPE_INNER = 0,
|
||||
|
@ -407,7 +407,6 @@ typedef struct SWindowOffsetNode {
|
|||
SNode* pEndOffset; // SValueNode
|
||||
} SWindowOffsetNode;
|
||||
|
||||
|
||||
typedef struct SSelectStmt {
|
||||
ENodeType type; // QUERY_NODE_SELECT_STMT
|
||||
bool isDistinct;
|
||||
|
@ -461,6 +460,7 @@ typedef struct SSelectStmt {
|
|||
bool groupSort;
|
||||
bool tagScan;
|
||||
bool joinContains;
|
||||
bool mixSysTableAndActualTable;
|
||||
} SSelectStmt;
|
||||
|
||||
typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType;
|
||||
|
@ -630,13 +630,15 @@ void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewrit
|
|||
typedef enum ECollectColType { COLLECT_COL_TYPE_COL = 1, COLLECT_COL_TYPE_TAG, COLLECT_COL_TYPE_ALL } ECollectColType;
|
||||
int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char* pTableAlias, ECollectColType type,
|
||||
SNodeList** pCols);
|
||||
int32_t nodesCollectColumnsExt(SSelectStmt* pSelect, ESqlClause clause, SSHashObj* pMultiTableAlias, ECollectColType type,
|
||||
SNodeList** pCols);
|
||||
int32_t nodesCollectColumnsExt(SSelectStmt* pSelect, ESqlClause clause, SSHashObj* pMultiTableAlias,
|
||||
ECollectColType type, SNodeList** pCols);
|
||||
int32_t nodesCollectColumnsFromNode(SNode* node, const char* pTableAlias, ECollectColType type, SNodeList** pCols);
|
||||
|
||||
typedef bool (*FFuncClassifier)(int32_t funcId);
|
||||
int32_t nodesCollectFuncs(SSelectStmt* pSelect, ESqlClause clause, char* tableAlias, FFuncClassifier classifier, SNodeList** pFuncs);
|
||||
int32_t nodesCollectSelectFuncs(SSelectStmt* pSelect, ESqlClause clause, char* tableAlias, FFuncClassifier classifier, SNodeList* pFuncs);
|
||||
int32_t nodesCollectFuncs(SSelectStmt* pSelect, ESqlClause clause, char* tableAlias, FFuncClassifier classifier,
|
||||
SNodeList** pFuncs);
|
||||
int32_t nodesCollectSelectFuncs(SSelectStmt* pSelect, ESqlClause clause, char* tableAlias, FFuncClassifier classifier,
|
||||
SNodeList* pFuncs);
|
||||
|
||||
int32_t nodesCollectSpecialNodes(SSelectStmt* pSelect, ESqlClause clause, ENodeType type, SNodeList** pNodes);
|
||||
|
||||
|
@ -670,12 +672,11 @@ const char* logicConditionTypeStr(ELogicConditionType type);
|
|||
bool nodesIsStar(SNode* pNode);
|
||||
bool nodesIsTableStar(SNode* pNode);
|
||||
|
||||
char* getJoinTypeString(EJoinType type);
|
||||
char* getJoinSTypeString(EJoinSubType type);
|
||||
char* getFullJoinTypeString(EJoinType type, EJoinSubType stype);
|
||||
char* getJoinTypeString(EJoinType type);
|
||||
char* getJoinSTypeString(EJoinSubType type);
|
||||
char* getFullJoinTypeString(EJoinType type, EJoinSubType stype);
|
||||
int32_t mergeJoinConds(SNode** ppDst, SNode** ppSrc);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -454,13 +454,14 @@ static const SSysDbTableSchema encryptionsSchema[] = {
|
|||
static const SSysDbTableSchema usageSchema[] = {
|
||||
{.name = "db_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "wal_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "mem_rows_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "level1_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "level2_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "level3_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "s3_size",.bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "estimated_row_data_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "wal", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "level1", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "level2", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "level3", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "cache", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "meta", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "s3",.bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "estimated_raw_data", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysTableMeta infosMeta[] = {
|
||||
|
@ -501,7 +502,7 @@ static const SSysTableMeta infosMeta[] = {
|
|||
{TSDB_INS_TABLE_TSMAS, tsmaSchema, tListLen(tsmaSchema), false},
|
||||
{TSDB_INS_TABLE_ANODES, anodesSchema, tListLen(anodesSchema), true},
|
||||
{TSDB_INS_TABLE_ANODES_FULL, anodesFullSchema, tListLen(anodesFullSchema), true},
|
||||
{TSDB_INS_TABLE_USAGE, usageSchema, tListLen(usageSchema), false},
|
||||
{TSDB_INS_DISK_USAGE, usageSchema, tListLen(usageSchema), false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema connectionsSchema[] = {
|
||||
|
|
|
@ -142,7 +142,7 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
|||
type = TSDB_MGMT_TABLE_ENCRYPTIONS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_TSMAS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USAGE, len) == 0) {
|
||||
} else if (strncasecmp(name, TSDB_INS_DISK_USAGE, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_USAGE;
|
||||
} else {
|
||||
mError("invalid show name:%s len:%d", name, len);
|
||||
|
@ -364,9 +364,9 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
int32_t len = blockEncode(pBlock, pStart, pShow->pMeta->numOfColumns);
|
||||
if(len < 0){
|
||||
if (len < 0) {
|
||||
mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(code));
|
||||
code = terrno;
|
||||
code = terrno;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
|||
_exit:
|
||||
mndReleaseShowObj(pShow, false);
|
||||
blockDataDestroy(pBlock);
|
||||
if(pRsp) {
|
||||
if (pRsp) {
|
||||
rpcFreeCont(pRsp);
|
||||
}
|
||||
return code;
|
||||
|
|
|
@ -61,6 +61,7 @@ typedef struct SSysTableScanInfo {
|
|||
bool sysInfo;
|
||||
bool showRewrite;
|
||||
bool restore;
|
||||
bool skipFilterTable;
|
||||
SNode* pCondition; // db_name filter condition, to discard data that are not in current database
|
||||
SMTbCursor* pCur; // cursor for iterate the local table meta store.
|
||||
SSysTableIndex* pIdx; // idx for local table meta
|
||||
|
@ -1457,7 +1458,7 @@ _end:
|
|||
int32_t buildSysUsageInfo(const SSysTableScanInfo* pInfo, int32_t capacity) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SSDataBlock* p = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_USAGE);
|
||||
SSDataBlock* p = buildInfoSchemaTableMetaBlock(TSDB_INS_DISK_USAGE);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(p, capacity);
|
||||
|
@ -2026,14 +2027,24 @@ static int32_t buildVgDiskUsage(SOperatorInfo* pOperator, SDbSizeStatisInfo* pSt
|
|||
const char* db = NULL;
|
||||
pAPI->metaFn.getBasicInfo(pInfo->readHandle.vnode, &pStaticsInfo->dbname, &vgId, NULL, NULL);
|
||||
|
||||
SDbSizeStatisInfo staticsInfo = {0};
|
||||
pStaticsInfo->vgId = vgId;
|
||||
|
||||
staticsInfo.vgId = vgId;
|
||||
|
||||
code = pAPI->metaFn.getDBSize(pInfo->readHandle.vnode, &staticsInfo);
|
||||
code = pAPI->metaFn.getDBSize(pInfo->readHandle.vnode, pStaticsInfo);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
return vnodeEstimateRawDataSize(pOperator, &staticsInfo);
|
||||
code = vnodeEstimateRawDataSize(pOperator, pStaticsInfo);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
pStaticsInfo->memSize = pStaticsInfo->memSize >> 10;
|
||||
pStaticsInfo->l1Size = pStaticsInfo->l1Size >> 10;
|
||||
pStaticsInfo->l2Size = pStaticsInfo->l2Size >> 10;
|
||||
pStaticsInfo->l3Size = pStaticsInfo->l3Size >> 10;
|
||||
pStaticsInfo->cacheSize = pStaticsInfo->cacheSize >> 10;
|
||||
pStaticsInfo->walSize = pStaticsInfo->walSize >> 10;
|
||||
pStaticsInfo->metaSize = pStaticsInfo->metaSize >> 10;
|
||||
pStaticsInfo->rawDataSize = pStaticsInfo->rawDataSize >> 10;
|
||||
pStaticsInfo->s3Size = pStaticsInfo->s3Size >> 10;
|
||||
|
||||
_end:
|
||||
return code;
|
||||
}
|
||||
|
@ -2069,9 +2080,9 @@ static SSDataBlock* sysTableBuildVgUsage(SOperatorInfo* pOperator) {
|
|||
SDBBlockUsageInfo usageInfo = {0};
|
||||
int32_t len = tSerializeBlockDbUsage(NULL, 0, &usageInfo);
|
||||
|
||||
usageInfo.numOfSttRows = 120;
|
||||
usageInfo.numOfInmemRows = 120;
|
||||
usageInfo.numOfBlocks = 120;
|
||||
usageInfo.dataInDiskSize = staticsInfo.l1Size + staticsInfo.l2Size + staticsInfo.l3Size;
|
||||
usageInfo.walInDiskSize = staticsInfo.walSize;
|
||||
usageInfo.rawDataSize = staticsInfo.rawDataSize;
|
||||
|
||||
char* p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||
|
@ -2098,7 +2109,6 @@ static SSDataBlock* sysTableBuildVgUsage(SOperatorInfo* pOperator) {
|
|||
pBlock->info.rows = 1;
|
||||
pOperator->status = OP_EXEC_DONE;
|
||||
pInfo->pRes->info.rows = pBlock->info.rows;
|
||||
// code = relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, pBlock->pDataBlock, false);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
} else {
|
||||
SName sn = {0};
|
||||
|
@ -2111,7 +2121,7 @@ static SSDataBlock* sysTableBuildVgUsage(SOperatorInfo* pOperator) {
|
|||
|
||||
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
||||
|
||||
p = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_USAGE);
|
||||
p = buildInfoSchemaTableMetaBlock(TSDB_INS_DISK_USAGE);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(p, pOperator->resultInfo.capacity);
|
||||
|
@ -2129,10 +2139,6 @@ static SSDataBlock* sysTableBuildVgUsage(SOperatorInfo* pOperator) {
|
|||
code = colDataSetVal(pColInfoData, numOfRows, (char*)&staticsInfo.walSize, false); // wal
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||
code = colDataSetVal(pColInfoData, numOfRows, (char*)&staticsInfo.memSize, false); // memtable
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||
code = colDataSetVal(pColInfoData, numOfRows, (char*)&staticsInfo.l1Size, false); // l1_size
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
@ -2145,6 +2151,14 @@ static SSDataBlock* sysTableBuildVgUsage(SOperatorInfo* pOperator) {
|
|||
code = colDataSetVal(pColInfoData, numOfRows, (char*)&staticsInfo.l3Size, false); // l3_size
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||
code = colDataSetVal(pColInfoData, numOfRows, (char*)&staticsInfo.cacheSize, false); // cache_size
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||
code = colDataSetVal(pColInfoData, numOfRows, (char*)&staticsInfo.metaSize, false); // meta_size
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||
code = colDataSetVal(pColInfoData, numOfRows, (char*)&staticsInfo.s3Size, false); // s3_size
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
@ -2383,16 +2397,13 @@ static int32_t doSysTableScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes)
|
|||
} else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, TSDB_TABLE_FNAME_LEN) == 0 && pInfo->showRewrite &&
|
||||
IS_SYS_DBNAME(dbName)) {
|
||||
pBlock = sysTableScanUserSTables(pOperator);
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USAGE, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||
if (pInfo->showRewrite) {
|
||||
filter = false;
|
||||
}
|
||||
} else if (strncasecmp(name, TSDB_INS_DISK_USAGE, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||
pBlock = sysTableScanUsage(pOperator);
|
||||
} else { // load the meta from mnode of the given epset
|
||||
pBlock = sysTableScanFromMNode(pOperator, pInfo, name, pTaskInfo);
|
||||
}
|
||||
|
||||
if (filter) sysTableScanFillTbName(pOperator, pInfo, name, pBlock);
|
||||
if (!pInfo->skipFilterTable) sysTableScanFillTbName(pOperator, pInfo, name, pBlock);
|
||||
if (pBlock != NULL) {
|
||||
bool limitReached = applyLimitOffset(&pInfo->limitInfo, pBlock, pTaskInfo);
|
||||
if (limitReached) {
|
||||
|
@ -2587,7 +2598,17 @@ int32_t createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNo
|
|||
QUERY_CHECK_NULL(pInfo->pRes, code, lino, _error, terrno);
|
||||
|
||||
pInfo->pCondition = pScanNode->node.pConditions;
|
||||
code = filterInitFromNode(pScanNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
|
||||
|
||||
tNameAssign(&pInfo->name, &pScanNode->tableName);
|
||||
const char* name = tNameGetTableName(&pInfo->name);
|
||||
if (pInfo->showRewrite == false) {
|
||||
code = filterInitFromNode(pScanNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
|
||||
} else {
|
||||
if (strncasecmp(name, TSDB_INS_DISK_USAGE, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||
pInfo->skipFilterTable = true;
|
||||
}
|
||||
code = filterInitFromNode(NULL, &pOperator->exprSupp.pFilterInfo, 0);
|
||||
}
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
initLimitInfo(pScanPhyNode->scan.node.pLimit, pScanPhyNode->scan.node.pSlimit, &pInfo->limitInfo);
|
||||
|
@ -2595,9 +2616,6 @@ int32_t createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNo
|
|||
code = blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
tNameAssign(&pInfo->name, &pScanNode->tableName);
|
||||
const char* name = tNameGetTableName(&pInfo->name);
|
||||
|
||||
if (strncasecmp(name, TSDB_INS_TABLE_TABLES, TSDB_TABLE_FNAME_LEN) == 0 ||
|
||||
strncasecmp(name, TSDB_INS_TABLE_TAGS, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||
pInfo->readHandle = *(SReadHandle*)readHandle;
|
||||
|
@ -3326,13 +3344,8 @@ static int32_t vnodeEstimateDataSizeByUid(SOperatorInfo* pOperator, STableId* id
|
|||
|
||||
void* pList = tableListGetInfo(pTableListInfo, 0);
|
||||
|
||||
if (pInfo->showRewrite) {
|
||||
code = pReadHandle->api.tsdReader.tsdReaderOpen(pReadHandle->vnode, &cond, pList, num, pInfo->pRes,
|
||||
(void**)&pInfo->pHandle, pTaskInfo->id.str, NULL);
|
||||
} else {
|
||||
code = pReadHandle->api.tsdReader.tsdReaderOpen(pReadHandle->vnode, &cond, pList, num, NULL,
|
||||
(void**)&pInfo->pHandle, pTaskInfo->id.str, NULL);
|
||||
}
|
||||
code = pReadHandle->api.tsdReader.tsdReaderOpen(pReadHandle->vnode, &cond, pList, num, NULL, (void**)&pInfo->pHandle,
|
||||
pTaskInfo->id.str, NULL);
|
||||
cleanupQueryTableDataCond(&cond);
|
||||
QUERY_CHECK_CODE(code, line, _end);
|
||||
|
||||
|
|
|
@ -6480,7 +6480,6 @@ int32_t blockDBUsageSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo
|
|||
}
|
||||
|
||||
SDBBlockUsageInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
pInfo->minRows = INT32_MAX;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
int32_t blockDBUsageFunction(SqlFunctionCtx* pCtx) {
|
||||
|
@ -6497,26 +6496,9 @@ int32_t blockDBUsageFunction(SqlFunctionCtx* pCtx) {
|
|||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
pDistInfo->numOfBlocks += p1.numOfBlocks;
|
||||
pDistInfo->numOfTables += p1.numOfTables;
|
||||
pDistInfo->numOfInmemRows += p1.numOfInmemRows;
|
||||
pDistInfo->numOfSttRows += p1.numOfSttRows;
|
||||
pDistInfo->totalSize += p1.totalSize;
|
||||
pDistInfo->totalRows += p1.totalRows;
|
||||
pDistInfo->numOfFiles += p1.numOfFiles;
|
||||
|
||||
pDistInfo->defMinRows = p1.defMinRows;
|
||||
pDistInfo->defMaxRows = p1.defMaxRows;
|
||||
pDistInfo->rowSize = p1.rowSize;
|
||||
|
||||
if (pDistInfo->minRows > p1.minRows) {
|
||||
pDistInfo->minRows = p1.minRows;
|
||||
}
|
||||
if (pDistInfo->maxRows < p1.maxRows) {
|
||||
pDistInfo->maxRows = p1.maxRows;
|
||||
}
|
||||
pDistInfo->numOfVgroups += (p1.numOfTables != 0 ? 1 : 0);
|
||||
|
||||
pDistInfo->dataInDiskSize += p1.dataInDiskSize;
|
||||
pDistInfo->walInDiskSize += p1.walInDiskSize;
|
||||
pDistInfo->rawDataSize += p1.rawDataSize;
|
||||
pResInfo->numOfRes = BLOCK_DISK_USAGE_RESULT_ROWS; // default output rows
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -6529,21 +6511,10 @@ int32_t tSerializeBlockDbUsage(void* buf, int32_t bufLen, const SDBBlockUsageInf
|
|||
tEncoderInit(&encoder, buf, bufLen);
|
||||
|
||||
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||
TAOS_CHECK_EXIT(tEncodeU32(&encoder, pInfo->rowSize));
|
||||
|
||||
TAOS_CHECK_EXIT(tEncodeU16(&encoder, pInfo->numOfFiles));
|
||||
TAOS_CHECK_EXIT(tEncodeU32(&encoder, pInfo->numOfBlocks));
|
||||
TAOS_CHECK_EXIT(tEncodeU32(&encoder, pInfo->numOfTables));
|
||||
|
||||
TAOS_CHECK_EXIT(tEncodeU64(&encoder, pInfo->totalSize));
|
||||
TAOS_CHECK_EXIT(tEncodeU64(&encoder, pInfo->totalRows));
|
||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pInfo->maxRows));
|
||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pInfo->minRows));
|
||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pInfo->defMaxRows));
|
||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pInfo->defMinRows));
|
||||
TAOS_CHECK_EXIT(tEncodeU32(&encoder, pInfo->numOfInmemRows));
|
||||
TAOS_CHECK_EXIT(tEncodeU32(&encoder, pInfo->numOfSttRows));
|
||||
TAOS_CHECK_EXIT(tEncodeU32(&encoder, pInfo->numOfVgroups));
|
||||
TAOS_CHECK_EXIT(tEncodeU64(&encoder, pInfo->dataInDiskSize));
|
||||
TAOS_CHECK_EXIT(tEncodeU64(&encoder, pInfo->walInDiskSize));
|
||||
TAOS_CHECK_EXIT(tEncodeU64(&encoder, pInfo->rawDataSize));
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
|
@ -6563,21 +6534,9 @@ int32_t tDeserializeBlockDbUsage(void* buf, int32_t bufLen, SDBBlockUsageInfo* p
|
|||
tDecoderInit(&decoder, buf, bufLen);
|
||||
|
||||
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||
TAOS_CHECK_EXIT(tDecodeU32(&decoder, &pInfo->rowSize));
|
||||
|
||||
TAOS_CHECK_EXIT(tDecodeU16(&decoder, &pInfo->numOfFiles));
|
||||
TAOS_CHECK_EXIT(tDecodeU32(&decoder, &pInfo->numOfBlocks));
|
||||
TAOS_CHECK_EXIT(tDecodeU32(&decoder, &pInfo->numOfTables));
|
||||
|
||||
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pInfo->totalSize));
|
||||
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pInfo->totalRows));
|
||||
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pInfo->maxRows));
|
||||
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pInfo->minRows));
|
||||
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pInfo->defMaxRows));
|
||||
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pInfo->defMinRows));
|
||||
TAOS_CHECK_EXIT(tDecodeU32(&decoder, &pInfo->numOfInmemRows));
|
||||
TAOS_CHECK_EXIT(tDecodeU32(&decoder, &pInfo->numOfSttRows));
|
||||
TAOS_CHECK_EXIT(tDecodeU32(&decoder, &pInfo->numOfVgroups));
|
||||
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pInfo->dataInDiskSize));
|
||||
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pInfo->walInDiskSize));
|
||||
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pInfo->rawDataSize));
|
||||
|
||||
_exit:
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -6591,26 +6550,17 @@ int32_t blockDBUsageFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
if (NULL == pColInfo) {
|
||||
return TSDB_CODE_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
if (pData->totalRows == 0) {
|
||||
pData->minRows = 0;
|
||||
}
|
||||
|
||||
int32_t row = 0;
|
||||
char st[256] = {0};
|
||||
double averageSize = 0;
|
||||
if (pData->numOfBlocks != 0) {
|
||||
averageSize = ((double)pData->totalSize) / pData->numOfBlocks;
|
||||
}
|
||||
uint64_t totalRawSize = pData->totalRows * pData->rowSize;
|
||||
double compRatio = 0;
|
||||
if (totalRawSize != 0) {
|
||||
compRatio = pData->totalSize * 100 / (double)totalRawSize;
|
||||
|
||||
uint64_t totalDiskSize = pData->dataInDiskSize;
|
||||
uint64_t rawDataSize = pData->rawDataSize;
|
||||
double compressRadio = 0;
|
||||
if (rawDataSize != 0) {
|
||||
compressRadio = totalDiskSize * 100 / (double)rawDataSize;
|
||||
}
|
||||
|
||||
int32_t len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE,
|
||||
"Total_Blocks=[%d] Total_Size=[%.2f KiB] Average_size=[%.2f KiB] Compression_Ratio=[%.2f %c]",
|
||||
pData->numOfBlocks, pData->totalSize / 1024.0, averageSize / 1024.0, compRatio, '%');
|
||||
int32_t len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE, "Compress_radio: %.2f", compressRadio);
|
||||
|
||||
varDataSetLen(st, len);
|
||||
int32_t code = colDataSetVal(pColInfo, row++, st, false);
|
||||
|
@ -6618,14 +6568,8 @@ int32_t blockDBUsageFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int64_t avgRows = 0;
|
||||
if (pData->numOfBlocks > 0) {
|
||||
avgRows = pData->totalRows / pData->numOfBlocks;
|
||||
}
|
||||
|
||||
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE,
|
||||
"Block_Rows=[%" PRId64 "] MinRows=[%d] MaxRows=[%d] AvgRows=[%" PRId64 "]", pData->totalRows,
|
||||
pData->minRows, pData->maxRows, avgRows);
|
||||
len =
|
||||
tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE, "Disk_occupied: %" PRId64 "k", pData->dataInDiskSize);
|
||||
varDataSetLen(st, len);
|
||||
code = colDataSetVal(pColInfo, row++, st, false);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "cmdnodes.h"
|
||||
#include "parToken.h"
|
||||
#include "parUtil.h"
|
||||
#include "parser.h"
|
||||
#include "cmdnodes.h"
|
||||
|
||||
typedef struct STranslateContext {
|
||||
SParseContext* pParseCxt;
|
||||
|
@ -46,14 +46,16 @@ typedef struct STranslateContext {
|
|||
bool withOpt;
|
||||
SNode* pPrevRoot;
|
||||
SNode* pPostRoot;
|
||||
bool dual; // whether select stmt without from stmt, true for without.
|
||||
bool dual; // whether select stmt without from stmt, true for without.
|
||||
bool skipCheck;
|
||||
} STranslateContext;
|
||||
|
||||
int32_t biRewriteToTbnameFunc(STranslateContext* pCxt, SNode** ppNode, bool* pRet);
|
||||
int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect);
|
||||
int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SCreateTableStmt* pStmt);
|
||||
int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STableNode** pOutput);
|
||||
int32_t getTargetMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta, bool couldBeView);
|
||||
int32_t getTargetMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta,
|
||||
bool couldBeView);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c
|
|||
}
|
||||
if (TSDB_CODE_SUCCESS == code &&
|
||||
(0 == strcmp(pTable, TSDB_INS_TABLE_TAGS) || 0 == strcmp(pTable, TSDB_INS_TABLE_TABLES) ||
|
||||
0 == strcmp(pTable, TSDB_INS_TABLE_COLS) || 0 == strcmp(pTable, TSDB_INS_TABLE_USAGE)) &&
|
||||
0 == strcmp(pTable, TSDB_INS_TABLE_COLS) || 0 == strcmp(pTable, TSDB_INS_DISK_USAGE)) &&
|
||||
QUERY_NODE_SELECT_STMT == nodeType(pCxt->pStmt)) {
|
||||
code = collectMetaKeyFromInsTags(pCxt);
|
||||
}
|
||||
|
@ -933,7 +933,7 @@ static int32_t collectMetaKeyFromDropTSMAStmt(SCollectMetaKeyCxt* pCxt, SDropTSM
|
|||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowUsage(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USAGE,
|
||||
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_DISK_USAGE,
|
||||
pCxt->pMetaCache);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
|
||||
|
|
|
@ -25,10 +25,10 @@ typedef struct SNodeReplaceContext {
|
|||
} SNodeReplaceContext;
|
||||
|
||||
typedef struct SCalcConstContext {
|
||||
SParseContext* pParseCxt;
|
||||
SNodeReplaceContext replaceCxt;
|
||||
SMsgBuf msgBuf;
|
||||
int32_t code;
|
||||
SParseContext* pParseCxt;
|
||||
SNodeReplaceContext replaceCxt;
|
||||
SMsgBuf msgBuf;
|
||||
int32_t code;
|
||||
} SCalcConstContext;
|
||||
|
||||
static int32_t calcConstQuery(SCalcConstContext* pCxt, SNode* pStmt, bool subquery);
|
||||
|
@ -73,7 +73,7 @@ static bool isCondition(const SNode* pNode) {
|
|||
|
||||
static int32_t rewriteIsTrue(SNode* pSrc, SNode** pIsTrue) {
|
||||
SOperatorNode* pOp = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOp);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOp);
|
||||
if (NULL == pOp) {
|
||||
return code;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ static EDealRes doFindAndReplaceNode(SNode** pNode, void* pContext) {
|
|||
static int32_t findAndReplaceNode(SCalcConstContext* pCxt, SNode** pRoot, SNode* pTarget, SNode* pNew, bool strict) {
|
||||
pCxt->replaceCxt.pNew = pNew;
|
||||
pCxt->replaceCxt.pTarget = pTarget;
|
||||
|
||||
|
||||
nodesRewriteExprPostOrder(pRoot, doFindAndReplaceNode, pCxt);
|
||||
if (TSDB_CODE_SUCCESS == pCxt->code && strict && !pCxt->replaceCxt.replaced) {
|
||||
parserError("target replace node not found, %p", pTarget);
|
||||
|
@ -214,7 +214,7 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d
|
|||
}
|
||||
}
|
||||
|
||||
char aliasName[TSDB_COL_NAME_LEN] = {0};
|
||||
char aliasName[TSDB_COL_NAME_LEN] = {0};
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (dual) {
|
||||
code = scalarCalculateConstantsFromDual(pProject, pNew);
|
||||
|
@ -226,7 +226,7 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d
|
|||
int32_t size = taosArrayGetSize(pAssociation);
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SAssociationNode* pAssNode = taosArrayGet(pAssociation, i);
|
||||
SNode** pCol = pAssNode->pPlace;
|
||||
SNode** pCol = pAssNode->pPlace;
|
||||
if (*pCol == pAssNode->pAssociationNode) {
|
||||
strcpy(aliasName, ((SExprNode*)*pCol)->aliasName);
|
||||
SArray* pOrigAss = NULL;
|
||||
|
@ -255,15 +255,15 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d
|
|||
return code;
|
||||
}
|
||||
|
||||
typedef struct SIsUselessColCtx {
|
||||
bool isUseless;
|
||||
} SIsUselessColCtx ;
|
||||
typedef struct SIsUselessColCtx {
|
||||
bool isUseless;
|
||||
} SIsUselessColCtx;
|
||||
|
||||
EDealRes checkUselessCol(SNode *pNode, void *pContext) {
|
||||
SIsUselessColCtx *ctx = (SIsUselessColCtx *)pContext;
|
||||
EDealRes checkUselessCol(SNode* pNode, void* pContext) {
|
||||
SIsUselessColCtx* ctx = (SIsUselessColCtx*)pContext;
|
||||
if (QUERY_NODE_FUNCTION == nodeType(pNode) && !fmIsScalarFunc(((SFunctionNode*)pNode)->funcId) &&
|
||||
!fmIsPseudoColumnFunc(((SFunctionNode*)pNode)->funcId)) {
|
||||
ctx->isUseless = false;
|
||||
ctx->isUseless = false;
|
||||
return DEAL_RES_END;
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,7 @@ EDealRes checkUselessCol(SNode *pNode, void *pContext) {
|
|||
|
||||
static bool isUselessCol(SExprNode* pProj) {
|
||||
SIsUselessColCtx ctx = {.isUseless = true};
|
||||
nodesWalkExpr((SNode*)pProj, checkUselessCol, (void *)&ctx);
|
||||
nodesWalkExpr((SNode*)pProj, checkUselessCol, (void*)&ctx);
|
||||
if (!ctx.isUseless) {
|
||||
return false;
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ static bool isUselessCol(SExprNode* pProj) {
|
|||
|
||||
static int32_t createConstantValue(SValueNode** ppNode) {
|
||||
SValueNode* pVal = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
||||
if (NULL == pVal) {
|
||||
return code;
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec
|
|||
}
|
||||
if (0 == LIST_LENGTH(pSelect->pProjectionList)) {
|
||||
SValueNode* pVal = NULL;
|
||||
int32_t code = createConstantValue(&pVal);
|
||||
int32_t code = createConstantValue(&pVal);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
return nodesListStrictAppend(pSelect->pProjectionList, (SNode*)pVal);
|
||||
}
|
||||
|
@ -350,10 +350,13 @@ static int32_t calcConstSelectFrom(SCalcConstContext* pCxt, SSelectStmt* pSelect
|
|||
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) &&
|
||||
((STempTableNode*)pSelect->pFromTable)->pSubquery != NULL &&
|
||||
QUERY_NODE_SELECT_STMT == nodeType(((STempTableNode*)pSelect->pFromTable)->pSubquery) &&
|
||||
((SSelectStmt*)((STempTableNode*)pSelect->pFromTable)->pSubquery)->isEmptyResult){
|
||||
((SSelectStmt*)((STempTableNode*)pSelect->pFromTable)->pSubquery)->isEmptyResult) {
|
||||
pSelect->isEmptyResult = true;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
if (pSelect->mixSysTableAndActualTable) {
|
||||
return code;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = calcConstProjections(pCxt, pSelect, subquery);
|
||||
}
|
||||
|
@ -509,7 +512,7 @@ static int32_t calcConstSetOpProjections(SCalcConstContext* pCxt, SSetOperator*
|
|||
}
|
||||
if (0 == LIST_LENGTH(pSetOp->pProjectionList)) {
|
||||
SValueNode* pVal = NULL;
|
||||
int32_t code = createConstantValue(&pVal);
|
||||
int32_t code = createConstantValue(&pVal);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
return nodesListStrictAppend(pSetOp->pProjectionList, (SNode*)pVal);
|
||||
}
|
||||
|
@ -612,7 +615,8 @@ int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery) {
|
|||
.msgBuf.buf = pParseCxt->pMsg,
|
||||
.msgBuf.len = pParseCxt->msgLen,
|
||||
.code = TSDB_CODE_SUCCESS};
|
||||
int32_t code = calcConstQuery(&cxt, pQuery->pRoot, false);
|
||||
|
||||
int32_t code = calcConstQuery(&cxt, pQuery->pRoot, false);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
resetProjectNullType(pQuery->pRoot);
|
||||
if (isEmptyResultQuery(pQuery->pRoot)) {
|
||||
|
|
|
@ -365,7 +365,7 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
|||
{
|
||||
.showType = QUERY_NODE_SHOW_USAGE_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_USAGE,
|
||||
.pTableName = TSDB_INS_DISK_USAGE,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
|
@ -1505,6 +1505,17 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pCxt->showRewrite && pMeta->tableType == TSDB_SYSTEM_TABLE) {
|
||||
if (strncmp(pCol->dbName, TSDB_INFORMATION_SCHEMA_DB, strlen(TSDB_INFORMATION_SCHEMA_DB)) == 0 &&
|
||||
strncmp(pCol->tableName, TSDB_INS_DISK_USAGE, strlen(TSDB_INS_DISK_USAGE)) == 0 &&
|
||||
strncmp(pCol->colName, "db_name", strlen("db_name")) == 0) {
|
||||
pCol->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
pCol->node.resType.bytes = 8;
|
||||
pCxt->skipCheck = true;
|
||||
((SSelectStmt*)pCxt->pCurrStmt)->mixSysTableAndActualTable = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
STempTableNode* pTempTable = (STempTableNode*)pTable;
|
||||
SNodeList* pProjectList = getProjectList(pTempTable->pSubquery);
|
||||
|
@ -4102,7 +4113,7 @@ static int32_t dnodeToVgroupsInfo(SArray* pDnodes, SVgroupsInfo** pVgsInfo) {
|
|||
|
||||
static bool sysTableFromVnode(const char* pTable) {
|
||||
return ((0 == strcmp(pTable, TSDB_INS_TABLE_TABLES)) || (0 == strcmp(pTable, TSDB_INS_TABLE_TAGS)) ||
|
||||
(0 == strcmp(pTable, TSDB_INS_TABLE_COLS)) || 0 == strcmp(pTable, TSDB_INS_TABLE_USAGE));
|
||||
(0 == strcmp(pTable, TSDB_INS_TABLE_COLS)) || 0 == strcmp(pTable, TSDB_INS_DISK_USAGE));
|
||||
}
|
||||
|
||||
static bool sysTableFromDnode(const char* pTable) { return 0 == strcmp(pTable, TSDB_INS_TABLE_DNODE_VARIABLES); }
|
||||
|
@ -4175,7 +4186,7 @@ static int32_t setVnodeSysTableVgroupList(STranslateContext* pCxt, SName* pName,
|
|||
if (TSDB_CODE_SUCCESS == code &&
|
||||
((0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TABLES) && !hasUserDbCond) ||
|
||||
0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_COLS) ||
|
||||
(0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USAGE) && !hasUserDbCond))) {
|
||||
(0 == strcmp(pRealTable->table.tableName, TSDB_INS_DISK_USAGE) && !hasUserDbCond))) {
|
||||
code = addMnodeToVgroupList(&pCxt->pParseCxt->mgmtEpSet, &pVgs);
|
||||
}
|
||||
|
||||
|
@ -4275,7 +4286,7 @@ static bool isSingleTable(SRealTableNode* pRealTable) {
|
|||
return 0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TABLES) &&
|
||||
0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TAGS) &&
|
||||
0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_COLS) &&
|
||||
0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USAGE);
|
||||
0 != strcmp(pRealTable->table.tableName, TSDB_INS_DISK_USAGE);
|
||||
}
|
||||
return (TSDB_CHILD_TABLE == tableType || TSDB_NORMAL_TABLE == tableType);
|
||||
}
|
||||
|
@ -13717,6 +13728,18 @@ static int32_t rewriteShowTableDist(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t createBlockDBUsageInfoFunc(SFunctionNode** ppNode) {
|
||||
SFunctionNode* pFunc = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc);
|
||||
if (NULL == pFunc) {
|
||||
return code;
|
||||
}
|
||||
|
||||
strcpy(pFunc->functionName, "_db_usage_info");
|
||||
strcpy(pFunc->node.aliasName, "_db_usage_info");
|
||||
*ppNode = pFunc;
|
||||
return code;
|
||||
}
|
||||
static int32_t createDBUsageFunc(SFunctionNode** ppNode) {
|
||||
SFunctionNode* pFunc = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc);
|
||||
|
@ -13727,7 +13750,7 @@ static int32_t createDBUsageFunc(SFunctionNode** ppNode) {
|
|||
strcpy(pFunc->functionName, "_db_usage");
|
||||
strcpy(pFunc->node.aliasName, "_db_usage");
|
||||
SFunctionNode* pFuncNew = NULL;
|
||||
code = createBlockDistInfoFunc(&pFuncNew);
|
||||
code = createBlockDBUsageInfoFunc(&pFuncNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pFunc->pParameterList, (SNode*)pFuncNew);
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "planInt.h"
|
||||
#include "filter.h"
|
||||
#include "functionMgt.h"
|
||||
#include "tglobal.h"
|
||||
#include "parser.h"
|
||||
#include "planInt.h"
|
||||
#include "tglobal.h"
|
||||
|
||||
// primary key column always the second column if exists
|
||||
#define PRIMARY_COLUMN_SLOT 1
|
||||
|
@ -163,8 +163,9 @@ static EDealRes doNameExpr(SNode* pNode, void* pContext) {
|
|||
|
||||
static int32_t rewriteExprForSelect(SNode* pExpr, SSelectStmt* pSelect, ESqlClause clause) {
|
||||
nodesWalkExpr(pExpr, doNameExpr, NULL);
|
||||
bool isPartitionBy = (pSelect->pPartitionByList && pSelect->pPartitionByList->length > 0) ? true : false;
|
||||
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = NULL, .pOutputs = NULL, .isPartitionBy = isPartitionBy};
|
||||
bool isPartitionBy = (pSelect->pPartitionByList && pSelect->pPartitionByList->length > 0) ? true : false;
|
||||
SRewriteExprCxt cxt = {
|
||||
.errCode = TSDB_CODE_SUCCESS, .pExprs = NULL, .pOutputs = NULL, .isPartitionBy = isPartitionBy};
|
||||
cxt.errCode = nodesListMakeAppend(&cxt.pExprs, pExpr);
|
||||
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
||||
nodesRewriteSelectStmt(pSelect, clause, doRewriteExpr, &cxt);
|
||||
|
@ -197,8 +198,9 @@ static int32_t cloneRewriteExprs(SNodeList* pExprs, bool* pOutputs, SNodeList**
|
|||
static int32_t rewriteExprsForSelect(SNodeList* pExprs, SSelectStmt* pSelect, ESqlClause clause,
|
||||
SNodeList** pRewriteExprs) {
|
||||
nodesWalkExprs(pExprs, doNameExpr, NULL);
|
||||
bool isPartitionBy = (pSelect->pPartitionByList && pSelect->pPartitionByList->length > 0) ? true : false;
|
||||
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs, .pOutputs = NULL, .isPartitionBy = isPartitionBy};
|
||||
bool isPartitionBy = (pSelect->pPartitionByList && pSelect->pPartitionByList->length > 0) ? true : false;
|
||||
SRewriteExprCxt cxt = {
|
||||
.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs, .pOutputs = NULL, .isPartitionBy = isPartitionBy};
|
||||
if (NULL != pRewriteExprs) {
|
||||
cxt.pOutputs = taosMemoryCalloc(LIST_LENGTH(pExprs), sizeof(bool));
|
||||
if (NULL == cxt.pOutputs) {
|
||||
|
@ -271,6 +273,10 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
|
|||
}
|
||||
|
||||
if (TSDB_SYSTEM_TABLE == tableType) {
|
||||
// if (NULL != pScanPseudoCols &&
|
||||
// FUNCTION_TYPE_DB_USAGE_INFO == ((SFunctionNode*)nodesListGetNode(pScanPseudoCols, 0))->funcType) {
|
||||
// return SCAN_TYPE_BLOCK_INFO;
|
||||
// }
|
||||
return SCAN_TYPE_SYSTEM_TABLE;
|
||||
}
|
||||
|
||||
|
@ -291,7 +297,7 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
|
|||
}
|
||||
|
||||
static bool hasPkInTable(const STableMeta* pTableMeta) {
|
||||
return pTableMeta->tableInfo.numOfColumns>=2 && pTableMeta->schema[1].flags & COL_IS_KEY;
|
||||
return pTableMeta->tableInfo.numOfColumns >= 2 && pTableMeta->schema[1].flags & COL_IS_KEY;
|
||||
}
|
||||
|
||||
static SNode* createFirstCol(SRealTableNode* pTable, const SSchema* pSchema) {
|
||||
|
@ -338,8 +344,8 @@ static int32_t addSystableFirstCol(SRealTableNode* pTable, SNodeList** pCols) {
|
|||
}
|
||||
|
||||
static int32_t addPrimaryKeyCol(SRealTableNode* pTable, SNodeList** pCols) {
|
||||
bool found = false;
|
||||
SNode* pCol = NULL;
|
||||
bool found = false;
|
||||
SNode* pCol = NULL;
|
||||
SSchema* pSchema = &pTable->pMeta->schema[PRIMARY_COLUMN_SLOT];
|
||||
FOREACH(pCol, *pCols) {
|
||||
if (pSchema->colId == ((SColumnNode*)pCol)->colId) {
|
||||
|
@ -368,7 +374,7 @@ static int32_t addDefaultScanCol(SRealTableNode* pTable, SNodeList** pCols) {
|
|||
static int32_t makeScanLogicNode(SLogicPlanContext* pCxt, SRealTableNode* pRealTable, bool hasRepeatScanFuncs,
|
||||
SLogicNode** pLogicNode) {
|
||||
SScanLogicNode* pScan = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN, (SNode**)&pScan);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN, (SNode**)&pScan);
|
||||
if (NULL == pScan) {
|
||||
return code;
|
||||
}
|
||||
|
@ -427,7 +433,8 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesCollectFuncs(pSelect, SQL_CLAUSE_FROM, pRealTable->table.tableAlias, fmIsScanPseudoColumnFunc, &pScan->pScanPseudoCols);
|
||||
code = nodesCollectFuncs(pSelect, SQL_CLAUSE_FROM, pRealTable->table.tableAlias, fmIsScanPseudoColumnFunc,
|
||||
&pScan->pScanPseudoCols);
|
||||
}
|
||||
|
||||
pScan->scanType = getScanType(pCxt, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType, pSelect->tagScan);
|
||||
|
@ -436,15 +443,15 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SNodeList* pNewScanPseudoCols = NULL;
|
||||
code = rewriteExprsForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM, NULL);
|
||||
/*
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pScan->pScanPseudoCols) {
|
||||
code = createColumnByRewriteExprs(pScan->pScanPseudoCols, &pNewScanPseudoCols);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
nodesDestroyList(pScan->pScanPseudoCols);
|
||||
pScan->pScanPseudoCols = pNewScanPseudoCols;
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pScan->pScanPseudoCols) {
|
||||
code = createColumnByRewriteExprs(pScan->pScanPseudoCols, &pNewScanPseudoCols);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
nodesDestroyList(pScan->pScanPseudoCols);
|
||||
pScan->pScanPseudoCols = pNewScanPseudoCols;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (NULL != pScan->pScanCols) {
|
||||
|
@ -507,7 +514,7 @@ static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
|
|||
|
||||
int32_t collectJoinResColumns(SSelectStmt* pSelect, SJoinLogicNode* pJoin, SNodeList** pCols) {
|
||||
SSHashObj* pTables = NULL;
|
||||
int32_t code = collectTableAliasFromNodes(nodesListGetNode(pJoin->node.pChildren, 0), &pTables);
|
||||
int32_t code = collectTableAliasFromNodes(nodesListGetNode(pJoin->node.pChildren, 0), &pTables);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
@ -526,7 +533,7 @@ int32_t collectJoinResColumns(SSelectStmt* pSelect, SJoinLogicNode* pJoin, SNode
|
|||
|
||||
static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SJoinTableNode* pJoinTable,
|
||||
SLogicNode** pLogicNode) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SJoinLogicNode* pJoin = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_JOIN, (SNode**)&pJoin);
|
||||
if (NULL == pJoin) {
|
||||
|
@ -555,7 +562,8 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesMakeList(&pJoin->node.pChildren);
|
||||
}
|
||||
pJoin->seqWinGroup = (JOIN_STYPE_WIN == pJoinTable->subType) && (pSelect->hasAggFuncs || pSelect->hasIndefiniteRowsFunc);
|
||||
pJoin->seqWinGroup =
|
||||
(JOIN_STYPE_WIN == pJoinTable->subType) && (pSelect->hasAggFuncs || pSelect->hasIndefiniteRowsFunc);
|
||||
|
||||
SLogicNode* pLeft = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -638,7 +646,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
}
|
||||
nodesDestroyList(pColList);
|
||||
}
|
||||
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
rewriteTargetsWithResId(pJoin->node.pTargets);
|
||||
}
|
||||
|
@ -649,7 +657,6 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pJoin;
|
||||
} else {
|
||||
|
@ -708,7 +715,7 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr)
|
|||
|
||||
static int32_t createGroupingSetNode(SNode* pExpr, SNode** ppNode) {
|
||||
SGroupingSetNode* pGroupingSet = NULL;
|
||||
int32_t code = 0;
|
||||
int32_t code = 0;
|
||||
*ppNode = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_GROUPING_SET, (SNode**)&pGroupingSet);
|
||||
if (NULL == pGroupingSet) {
|
||||
|
@ -731,13 +738,15 @@ static EGroupAction getDistinctGroupAction(SLogicPlanContext* pCxt, SSelectStmt*
|
|||
: GROUP_ACTION_NONE;
|
||||
}
|
||||
|
||||
static bool isWindowJoinStmt(SSelectStmt * pSelect) {
|
||||
return (QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) && IS_WINDOW_JOIN(((SJoinTableNode*)pSelect->pFromTable)->subType));
|
||||
static bool isWindowJoinStmt(SSelectStmt* pSelect) {
|
||||
return (QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) &&
|
||||
IS_WINDOW_JOIN(((SJoinTableNode*)pSelect->pFromTable)->subType));
|
||||
}
|
||||
|
||||
static EGroupAction getGroupAction(SLogicPlanContext* pCxt, SSelectStmt* pSelect) {
|
||||
return ((pCxt->pPlanCxt->streamQuery || NULL != pSelect->pLimit || NULL != pSelect->pSlimit) && !pSelect->isDistinct) ? GROUP_ACTION_KEEP
|
||||
: GROUP_ACTION_NONE;
|
||||
return ((pCxt->pPlanCxt->streamQuery || NULL != pSelect->pLimit || NULL != pSelect->pSlimit) && !pSelect->isDistinct)
|
||||
? GROUP_ACTION_KEEP
|
||||
: GROUP_ACTION_NONE;
|
||||
}
|
||||
|
||||
static EDataOrderLevel getRequireDataOrder(bool needTimeline, SSelectStmt* pSelect) {
|
||||
|
@ -747,7 +756,7 @@ static EDataOrderLevel getRequireDataOrder(bool needTimeline, SSelectStmt* pSele
|
|||
|
||||
static int32_t addWinJoinPrimKeyToAggFuncs(SSelectStmt* pSelect, SNodeList** pList) {
|
||||
SNodeList* pTargets = *pList;
|
||||
int32_t code = 0;
|
||||
int32_t code = 0;
|
||||
if (pTargets) {
|
||||
code = nodesMakeList(&pTargets);
|
||||
}
|
||||
|
@ -811,7 +820,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
|
|||
}
|
||||
|
||||
SAggLogicNode* pAgg = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG, (SNode**)&pAgg);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG, (SNode**)&pAgg);
|
||||
if (NULL == pAgg) {
|
||||
return code;
|
||||
}
|
||||
|
@ -887,7 +896,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
|
|||
}
|
||||
|
||||
SIndefRowsFuncLogicNode* pIdfRowsFunc = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC, (SNode**)&pIdfRowsFunc);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC, (SNode**)&pIdfRowsFunc);
|
||||
if (NULL == pIdfRowsFunc) {
|
||||
return code;
|
||||
}
|
||||
|
@ -920,7 +929,8 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
|
|||
}
|
||||
|
||||
static bool isInterpFunc(int32_t funcId) {
|
||||
return fmIsInterpFunc(funcId) || fmIsInterpPseudoColumnFunc(funcId) || fmIsGroupKeyFunc(funcId) || fmisSelectGroupConstValueFunc(funcId);
|
||||
return fmIsInterpFunc(funcId) || fmIsInterpPseudoColumnFunc(funcId) || fmIsGroupKeyFunc(funcId) ||
|
||||
fmisSelectGroupConstValueFunc(funcId);
|
||||
}
|
||||
|
||||
static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||
|
@ -929,7 +939,7 @@ static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
|
|||
}
|
||||
|
||||
SInterpFuncLogicNode* pInterpFunc = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_INTERP_FUNC, (SNode**)&pInterpFunc);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_INTERP_FUNC, (SNode**)&pInterpFunc);
|
||||
if (NULL == pInterpFunc) {
|
||||
return code;
|
||||
}
|
||||
|
@ -974,7 +984,8 @@ static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
|
|||
}
|
||||
|
||||
static bool isForecastFunc(int32_t funcId) {
|
||||
return fmIsForecastFunc(funcId) || fmIsForecastPseudoColumnFunc(funcId) || fmIsGroupKeyFunc(funcId) || fmisSelectGroupConstValueFunc(funcId);
|
||||
return fmIsForecastFunc(funcId) || fmIsForecastPseudoColumnFunc(funcId) || fmIsGroupKeyFunc(funcId) ||
|
||||
fmisSelectGroupConstValueFunc(funcId);
|
||||
}
|
||||
|
||||
static int32_t createForecastFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||
|
@ -983,7 +994,7 @@ static int32_t createForecastFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt*
|
|||
}
|
||||
|
||||
SForecastFuncLogicNode* pForecastFunc = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_FORECAST_FUNC, (SNode**)&pForecastFunc);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_FORECAST_FUNC, (SNode**)&pForecastFunc);
|
||||
if (NULL == pForecastFunc) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1051,7 +1062,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
|
|||
static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindowNode* pState, SSelectStmt* pSelect,
|
||||
SLogicNode** pLogicNode) {
|
||||
SWindowLogicNode* pWindow = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW, (SNode**)&pWindow);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW, (SNode**)&pWindow);
|
||||
if (NULL == pWindow) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1087,7 +1098,7 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo
|
|||
static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionWindowNode* pSession,
|
||||
SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||
SWindowLogicNode* pWindow = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW, (SNode**)&pWindow);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW, (SNode**)&pWindow);
|
||||
if (NULL == pWindow) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1120,7 +1131,7 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW
|
|||
static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SIntervalWindowNode* pInterval,
|
||||
SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||
SWindowLogicNode* pWindow = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW, (SNode**)&pWindow);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW, (SNode**)&pWindow);
|
||||
if (NULL == pWindow) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1154,7 +1165,7 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
|
|||
static int32_t createWindowLogicNodeByEvent(SLogicPlanContext* pCxt, SEventWindowNode* pEvent, SSelectStmt* pSelect,
|
||||
SLogicNode** pLogicNode) {
|
||||
SWindowLogicNode* pWindow = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW, (SNode**)&pWindow);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW, (SNode**)&pWindow);
|
||||
if (NULL == pWindow) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1191,7 +1202,7 @@ static int32_t createWindowLogicNodeByEvent(SLogicPlanContext* pCxt, SEventWindo
|
|||
static int32_t createWindowLogicNodeByCount(SLogicPlanContext* pCxt, SCountWindowNode* pCount, SSelectStmt* pSelect,
|
||||
SLogicNode** pLogicNode) {
|
||||
SWindowLogicNode* pWindow = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW, (SNode**)&pWindow);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW, (SNode**)&pWindow);
|
||||
if (NULL == pWindow) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1280,11 +1291,11 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
|
|||
}
|
||||
|
||||
typedef struct SCollectFillExprsCtx {
|
||||
SHashObj* pPseudoCols;
|
||||
SNodeList* pFillExprs;
|
||||
SNodeList* pNotFillExprs;
|
||||
bool collectAggFuncs;
|
||||
SNodeList* pAggFuncCols;
|
||||
SHashObj* pPseudoCols;
|
||||
SNodeList* pFillExprs;
|
||||
SNodeList* pNotFillExprs;
|
||||
bool collectAggFuncs;
|
||||
SNodeList* pAggFuncCols;
|
||||
} SCollectFillExprsCtx;
|
||||
|
||||
typedef struct SWalkFillSubExprCtx {
|
||||
|
@ -1306,8 +1317,8 @@ static bool nodeAlreadyContained(SNodeList* pList, SNode* pNode) {
|
|||
}
|
||||
|
||||
static EDealRes needFillValueImpl(SNode* pNode, void* pContext) {
|
||||
SWalkFillSubExprCtx *pCtx = pContext;
|
||||
EDealRes res = DEAL_RES_CONTINUE;
|
||||
SWalkFillSubExprCtx* pCtx = pContext;
|
||||
EDealRes res = DEAL_RES_CONTINUE;
|
||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||
if (COLUMN_TYPE_WINDOW_START == pCol->colType || COLUMN_TYPE_WINDOW_END == pCol->colType ||
|
||||
|
@ -1337,14 +1348,12 @@ static EDealRes needFillValueImpl(SNode* pNode, void* pContext) {
|
|||
return res;
|
||||
}
|
||||
|
||||
static void needFillValue(SNode* pNode, SWalkFillSubExprCtx* pCtx) {
|
||||
nodesWalkExpr(pNode, needFillValueImpl, pCtx);
|
||||
}
|
||||
static void needFillValue(SNode* pNode, SWalkFillSubExprCtx* pCtx) { nodesWalkExpr(pNode, needFillValueImpl, pCtx); }
|
||||
|
||||
static int32_t collectFillExpr(SNode* pNode, SCollectFillExprsCtx* pCollectFillCtx) {
|
||||
SNode* pNew = NULL;
|
||||
SWalkFillSubExprCtx collectFillSubExprCtx = {
|
||||
.hasFillCol = false, .hasPseudoWinCol = false, .hasGroupKeyCol = false, .pCollectFillCtx = pCollectFillCtx};
|
||||
SNode* pNew = NULL;
|
||||
SWalkFillSubExprCtx collectFillSubExprCtx = {
|
||||
.hasFillCol = false, .hasPseudoWinCol = false, .hasGroupKeyCol = false, .pCollectFillCtx = pCollectFillCtx};
|
||||
needFillValue(pNode, &collectFillSubExprCtx);
|
||||
if (collectFillSubExprCtx.code != TSDB_CODE_SUCCESS) {
|
||||
return collectFillSubExprCtx.code;
|
||||
|
@ -1388,7 +1397,7 @@ static int32_t collectFillExprs(SSelectStmt* pSelect, SNodeList** pFillExprs, SN
|
|||
if (code == TSDB_CODE_SUCCESS) {
|
||||
void* pIter = taosHashIterate(collectFillCtx.pPseudoCols, 0);
|
||||
while (pIter) {
|
||||
SNode* pNode = *(SNode**)pIter, *pNew = NULL;
|
||||
SNode *pNode = *(SNode**)pIter, *pNew = NULL;
|
||||
code = nodesCloneNode(pNode, &pNew);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
code = nodesListMakeStrictAppend(&collectFillCtx.pNotFillExprs, pNew);
|
||||
|
@ -1427,7 +1436,7 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
}
|
||||
|
||||
SFillLogicNode* pFill = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_FILL, (SNode**)&pFill);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_FILL, (SNode**)&pFill);
|
||||
if (NULL == pFill) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1493,7 +1502,7 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
}
|
||||
|
||||
SSortLogicNode* pSort = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT, (SNode**)&pSort);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT, (SNode**)&pSort);
|
||||
if (NULL == pSort) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1531,7 +1540,8 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
FOREACH(pNode, pSelect->pProjectionList) {
|
||||
SExprNode* pExpr = (SExprNode*)pNode;
|
||||
if (0 == strcmp(pCol->node.aliasName, pExpr->aliasName)) {
|
||||
pCol->projIdx = projIdx; break;
|
||||
pCol->projIdx = projIdx;
|
||||
break;
|
||||
}
|
||||
projIdx++;
|
||||
}
|
||||
|
@ -1550,12 +1560,12 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
static int32_t createColumnByProjections(SLogicPlanContext* pCxt, const char* pStmtName, SNodeList* pExprs,
|
||||
SNodeList** pCols) {
|
||||
SNodeList* pList = NULL;
|
||||
int32_t code = nodesMakeList(&pList);
|
||||
int32_t code = nodesMakeList(&pList);
|
||||
if (NULL == pList) {
|
||||
return code;
|
||||
}
|
||||
|
||||
SNode* pNode;
|
||||
SNode* pNode;
|
||||
int32_t projIdx = 1;
|
||||
FOREACH(pNode, pExprs) {
|
||||
SColumnNode* pCol = createColumnByExpr(pStmtName, (SExprNode*)pNode);
|
||||
|
@ -1572,7 +1582,7 @@ static int32_t createColumnByProjections(SLogicPlanContext* pCxt, const char* pS
|
|||
|
||||
static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||
SProjectLogicNode* pProject = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT, (SNode**)&pProject);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT, (SNode**)&pProject);
|
||||
if (NULL == pProject) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1611,7 +1621,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
|
|||
}
|
||||
|
||||
SPartitionLogicNode* pPartition = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PARTITION, (SNode**)&pPartition);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PARTITION, (SNode**)&pPartition);
|
||||
if (NULL == pPartition) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1633,7 +1643,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
// code = nodesCollectFuncs(pSelect, SQL_CLAUSE_GROUP_BY, NULL, fmIsAggFunc, &pPartition->pAggFuncs);
|
||||
// code = nodesCollectFuncs(pSelect, SQL_CLAUSE_GROUP_BY, NULL, fmIsAggFunc, &pPartition->pAggFuncs);
|
||||
code = nodesCollectFuncs(pSelect, SQL_CLAUSE_PARTITION_BY, NULL, fmIsAggFunc, &pPartition->pAggFuncs);
|
||||
}
|
||||
|
||||
|
@ -1646,7 +1656,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
|
|||
nodeType(pSelect->pWindow) == QUERY_NODE_INTERVAL_WINDOW) {
|
||||
pPartition->needBlockOutputTsOrder = true;
|
||||
SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pSelect->pWindow;
|
||||
SColumnNode* pTsCol = (SColumnNode*)pInterval->pCol;
|
||||
SColumnNode* pTsCol = (SColumnNode*)pInterval->pCol;
|
||||
pPartition->pkTsColId = pTsCol->colId;
|
||||
pPartition->pkTsColTbId = pTsCol->tableId;
|
||||
}
|
||||
|
@ -1682,12 +1692,12 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
|
|||
}
|
||||
|
||||
SAggLogicNode* pAgg = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG, (SNode**)&pAgg);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG, (SNode**)&pAgg);
|
||||
if (NULL == pAgg) {
|
||||
return code;
|
||||
}
|
||||
|
||||
pAgg->node.groupAction = GROUP_ACTION_CLEAR;//getDistinctGroupAction(pCxt, pSelect);
|
||||
pAgg->node.groupAction = GROUP_ACTION_CLEAR; // getDistinctGroupAction(pCxt, pSelect);
|
||||
pAgg->node.requireDataOrder = DATA_ORDER_LEVEL_NONE;
|
||||
pAgg->node.resultDataOrder = DATA_ORDER_LEVEL_NONE;
|
||||
|
||||
|
@ -1801,7 +1811,7 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p
|
|||
}
|
||||
|
||||
SSortLogicNode* pSort = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT, (SNode**)&pSort);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT, (SNode**)&pSort);
|
||||
if (NULL == pSort) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1828,7 +1838,7 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p
|
|||
static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator,
|
||||
SLogicNode** pLogicNode) {
|
||||
SProjectLogicNode* pProject = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT, (SNode**)&pProject);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT, (SNode**)&pProject);
|
||||
if (NULL == pProject) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1858,7 +1868,7 @@ static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator
|
|||
|
||||
static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator, SLogicNode** pLogicNode) {
|
||||
SAggLogicNode* pAgg = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG, (SNode**)&pAgg);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG, (SNode**)&pAgg);
|
||||
if (NULL == pAgg) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1966,7 +1976,7 @@ static int32_t getMsgType(ENodeType sqlType) {
|
|||
|
||||
static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifyOpStmt* pStmt, SLogicNode** pLogicNode) {
|
||||
SVnodeModifyLogicNode* pModif = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY, (SNode**)&pModif);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY, (SNode**)&pModif);
|
||||
if (NULL == pModif) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1984,7 +1994,7 @@ static int32_t createDeleteRootLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
|
|||
|
||||
static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
||||
SScanLogicNode* pScan = NULL;
|
||||
int32_t code = makeScanLogicNode(pCxt, (SRealTableNode*)pDelete->pFromTable, false, (SLogicNode**)&pScan);
|
||||
int32_t code = makeScanLogicNode(pCxt, (SRealTableNode*)pDelete->pFromTable, false, (SLogicNode**)&pScan);
|
||||
|
||||
// set columns to scan
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -2019,7 +2029,7 @@ static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
|
|||
|
||||
static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
||||
SAggLogicNode* pAgg = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG, (SNode**)&pAgg);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG, (SNode**)&pAgg);
|
||||
if (NULL == pAgg) {
|
||||
return code;
|
||||
}
|
||||
|
@ -2069,7 +2079,7 @@ static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pD
|
|||
static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDeleteStmt* pDelete,
|
||||
SLogicNode** pLogicNode) {
|
||||
SVnodeModifyLogicNode* pModify = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY, (SNode**)&pModify);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY, (SNode**)&pModify);
|
||||
if (NULL == pModify) {
|
||||
return code;
|
||||
}
|
||||
|
@ -2130,7 +2140,7 @@ static int32_t creatInsertRootLogicNode(SLogicPlanContext* pCxt, SInsertStmt* pI
|
|||
static int32_t createVnodeModifLogicNodeByInsert(SLogicPlanContext* pCxt, SInsertStmt* pInsert,
|
||||
SLogicNode** pLogicNode) {
|
||||
SVnodeModifyLogicNode* pModify = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY, (SNode**)&pModify);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY, (SNode**)&pModify);
|
||||
if (NULL == pModify) {
|
||||
return code;
|
||||
}
|
||||
|
@ -2213,7 +2223,7 @@ int32_t createLogicPlan(SPlanContext* pCxt, SLogicSubplan** pLogicSubplan) {
|
|||
SLogicPlanContext cxt = {.pPlanCxt = pCxt, .pCurrRoot = NULL, .hasScan = false};
|
||||
|
||||
SLogicSubplan* pSubplan = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN, (SNode**)&pSubplan);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN, (SNode**)&pSubplan);
|
||||
if (NULL == pSubplan) {
|
||||
return code;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -820,7 +820,7 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
|
|||
if (0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_TABLES) ||
|
||||
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_TAGS) ||
|
||||
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_COLS) ||
|
||||
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_USAGE)) {
|
||||
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_DISK_USAGE)) {
|
||||
if (pScanLogicNode->pVgroupList) {
|
||||
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
|
||||
}
|
||||
|
|
|
@ -591,23 +591,24 @@ int taosGetDirSize(const char *path, int64_t *size) {
|
|||
return TSDB_CODE_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
int64_t subSize = 0;
|
||||
if (taosIsDir(fullPath)) {
|
||||
code = taosGetDirSize(fullPath, &totalSize);
|
||||
code = taosGetDirSize(fullPath, &subSize);
|
||||
if (code != 0) {
|
||||
taosCloseDir(&pDir);
|
||||
return code;
|
||||
}
|
||||
} else {
|
||||
int64_t fileSize = 0;
|
||||
code = taosStatFile(fullPath, &fileSize, NULL, NULL);
|
||||
code = taosStatFile(fullPath, &subSize, NULL, NULL);
|
||||
if (code != 0) {
|
||||
taosCloseDir(&pDir);
|
||||
return code;
|
||||
}
|
||||
totalSize += fileSize;
|
||||
}
|
||||
totalSize += subSize;
|
||||
fullPath[0] = 0;
|
||||
}
|
||||
|
||||
*size = totalSize;
|
||||
TAOS_UNUSED(taosCloseDir(&pDir));
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue