Merge branch '3.0' of https://github.com/taosdata/TDengine into feat/TS-4994-3.0
This commit is contained in:
commit
25b9de5d51
|
@ -108,7 +108,7 @@ typedef struct TAOS_FIELD_STB {
|
||||||
uint8_t precision;
|
uint8_t precision;
|
||||||
uint8_t scale;
|
uint8_t scale;
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
TAOS_FIELD_T field_type;
|
uint8_t field_type;
|
||||||
} TAOS_FIELD_STB;
|
} TAOS_FIELD_STB;
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
|
|
@ -61,6 +61,7 @@ extern "C" {
|
||||||
#define TSDB_INS_TABLE_MACHINES "ins_machines"
|
#define TSDB_INS_TABLE_MACHINES "ins_machines"
|
||||||
#define TSDB_INS_TABLE_ENCRYPTIONS "ins_encryptions"
|
#define TSDB_INS_TABLE_ENCRYPTIONS "ins_encryptions"
|
||||||
#define TSDB_INS_TABLE_TSMAS "ins_tsmas"
|
#define TSDB_INS_TABLE_TSMAS "ins_tsmas"
|
||||||
|
#define TSDB_INS_DISK_USAGE "ins_disk_usage"
|
||||||
#define TSDB_INS_TABLE_FILESETS "ins_filesets"
|
#define TSDB_INS_TABLE_FILESETS "ins_filesets"
|
||||||
|
|
||||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||||
|
|
|
@ -218,9 +218,9 @@ typedef struct SDataBlockInfo {
|
||||||
} SDataBlockInfo;
|
} SDataBlockInfo;
|
||||||
|
|
||||||
typedef struct SSDataBlock {
|
typedef struct SSDataBlock {
|
||||||
SColumnDataAgg* pBlockAgg;
|
SColumnDataAgg* pBlockAgg;
|
||||||
SArray* pDataBlock; // SArray<SColumnInfoData>
|
SArray* pDataBlock; // SArray<SColumnInfoData>
|
||||||
SDataBlockInfo info;
|
SDataBlockInfo info;
|
||||||
} SSDataBlock;
|
} SSDataBlock;
|
||||||
|
|
||||||
typedef struct SVarColAttr {
|
typedef struct SVarColAttr {
|
||||||
|
@ -302,6 +302,15 @@ typedef struct STableBlockDistInfo {
|
||||||
int32_t tSerializeBlockDistInfo(void* buf, int32_t bufLen, const STableBlockDistInfo* pInfo);
|
int32_t tSerializeBlockDistInfo(void* buf, int32_t bufLen, const STableBlockDistInfo* pInfo);
|
||||||
int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo* pInfo);
|
int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo* pInfo);
|
||||||
|
|
||||||
|
typedef struct SDBBlockUsageInfo {
|
||||||
|
uint64_t dataInDiskSize;
|
||||||
|
uint64_t walInDiskSize;
|
||||||
|
uint64_t rawDataSize;
|
||||||
|
} SDBBlockUsageInfo;
|
||||||
|
|
||||||
|
int32_t tSerializeBlockDbUsage(void* buf, int32_t bufLen, const SDBBlockUsageInfo* pInfo);
|
||||||
|
int32_t tDeserializeBlockDbUsage(void* buf, int32_t bufLen, SDBBlockUsageInfo* pInfo);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
FUNC_PARAM_TYPE_VALUE = 0x1,
|
FUNC_PARAM_TYPE_VALUE = 0x1,
|
||||||
FUNC_PARAM_TYPE_COLUMN = 0x2,
|
FUNC_PARAM_TYPE_COLUMN = 0x2,
|
||||||
|
@ -398,9 +407,9 @@ typedef struct STUidTagInfo {
|
||||||
int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t startTime);
|
int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t startTime);
|
||||||
int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol);
|
int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol);
|
||||||
|
|
||||||
#define TSMA_RES_STB_POSTFIX "_tsma_res_stb_"
|
#define TSMA_RES_STB_POSTFIX "_tsma_res_stb_"
|
||||||
#define MD5_OUTPUT_LEN 32
|
#define MD5_OUTPUT_LEN 32
|
||||||
#define TSMA_RES_STB_EXTRA_COLUMN_NUM 4 // 3 columns: _wstart, _wend, _wduration, 1 tag: tbname
|
#define TSMA_RES_STB_EXTRA_COLUMN_NUM 4 // 3 columns: _wstart, _wend, _wduration, 1 tag: tbname
|
||||||
|
|
||||||
static inline bool isTsmaResSTb(const char* stbName) {
|
static inline bool isTsmaResSTb(const char* stbName) {
|
||||||
static bool showTsmaTables = false;
|
static bool showTsmaTables = false;
|
||||||
|
|
|
@ -161,6 +161,7 @@ typedef enum _mgmt_table {
|
||||||
TSDB_MGMT_TABLE_USER_FULL,
|
TSDB_MGMT_TABLE_USER_FULL,
|
||||||
TSDB_MGMT_TABLE_ANODE,
|
TSDB_MGMT_TABLE_ANODE,
|
||||||
TSDB_MGMT_TABLE_ANODE_FULL,
|
TSDB_MGMT_TABLE_ANODE_FULL,
|
||||||
|
TSDB_MGMT_TABLE_USAGE,
|
||||||
TSDB_MGMT_TABLE_FILESETS,
|
TSDB_MGMT_TABLE_FILESETS,
|
||||||
TSDB_MGMT_TABLE_MAX,
|
TSDB_MGMT_TABLE_MAX,
|
||||||
} EShowType;
|
} EShowType;
|
||||||
|
@ -399,6 +400,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_SHOW_TSMAS_STMT,
|
QUERY_NODE_SHOW_TSMAS_STMT,
|
||||||
QUERY_NODE_SHOW_ANODES_STMT,
|
QUERY_NODE_SHOW_ANODES_STMT,
|
||||||
QUERY_NODE_SHOW_ANODES_FULL_STMT,
|
QUERY_NODE_SHOW_ANODES_FULL_STMT,
|
||||||
|
QUERY_NODE_SHOW_USAGE_STMT,
|
||||||
QUERY_NODE_CREATE_TSMA_STMT,
|
QUERY_NODE_CREATE_TSMA_STMT,
|
||||||
QUERY_NODE_SHOW_CREATE_TSMA_STMT,
|
QUERY_NODE_SHOW_CREATE_TSMA_STMT,
|
||||||
QUERY_NODE_DROP_TSMA_STMT,
|
QUERY_NODE_DROP_TSMA_STMT,
|
||||||
|
@ -682,7 +684,7 @@ typedef struct {
|
||||||
int32_t tsSlowLogThreshold;
|
int32_t tsSlowLogThreshold;
|
||||||
int32_t tsSlowLogMaxLen;
|
int32_t tsSlowLogMaxLen;
|
||||||
int32_t tsSlowLogScope;
|
int32_t tsSlowLogScope;
|
||||||
int32_t tsSlowLogThresholdTest; //Obsolete
|
int32_t tsSlowLogThresholdTest; // Obsolete
|
||||||
char tsSlowLogExceptDb[TSDB_DB_NAME_LEN];
|
char tsSlowLogExceptDb[TSDB_DB_NAME_LEN];
|
||||||
} SMonitorParas;
|
} SMonitorParas;
|
||||||
|
|
||||||
|
@ -1758,6 +1760,21 @@ typedef struct {
|
||||||
int32_t learnerProgress; // use one reservered
|
int32_t learnerProgress; // use one reservered
|
||||||
} SVnodeLoad;
|
} SVnodeLoad;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t vgId;
|
||||||
|
int64_t numOfTables;
|
||||||
|
int64_t memSize;
|
||||||
|
int64_t l1Size;
|
||||||
|
int64_t l2Size;
|
||||||
|
int64_t l3Size;
|
||||||
|
int64_t cacheSize;
|
||||||
|
int64_t walSize;
|
||||||
|
int64_t metaSize;
|
||||||
|
int64_t rawDataSize;
|
||||||
|
int64_t s3Size;
|
||||||
|
const char* dbname;
|
||||||
|
} SDbSizeStatisInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int64_t nTimeSeries;
|
int64_t nTimeSeries;
|
||||||
|
|
|
@ -290,6 +290,7 @@ typedef struct SStoreMeta {
|
||||||
int32_t (*getNumOfChildTables)(void* pVnode, int64_t uid, int64_t* numOfTables, int32_t* numOfCols);
|
int32_t (*getNumOfChildTables)(void* pVnode, int64_t uid, int64_t* numOfTables, int32_t* numOfCols);
|
||||||
void (*getBasicInfo)(void* pVnode, const char** dbname, int32_t* vgId, int64_t* numOfTables,
|
void (*getBasicInfo)(void* pVnode, const char** dbname, int32_t* vgId, int64_t* numOfTables,
|
||||||
int64_t* numOfNormalTables);
|
int64_t* numOfNormalTables);
|
||||||
|
int32_t (*getDBSize)(void* pVnode, SDbSizeStatisInfo* pInfo);
|
||||||
|
|
||||||
SMCtbCursor* (*openCtbCursor)(void* pVnode, tb_uid_t uid, int lock);
|
SMCtbCursor* (*openCtbCursor)(void* pVnode, tb_uid_t uid, int lock);
|
||||||
int32_t (*resumeCtbCursor)(SMCtbCursor* pCtbCur, int8_t first);
|
int32_t (*resumeCtbCursor)(SMCtbCursor* pCtbCur, int8_t first);
|
||||||
|
|
|
@ -219,6 +219,9 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_CONTAINS,
|
FUNCTION_TYPE_CONTAINS,
|
||||||
FUNCTION_TYPE_CONTAINS_PROPERLY,
|
FUNCTION_TYPE_CONTAINS_PROPERLY,
|
||||||
|
|
||||||
|
FUNCTION_TYPE_DB_USAGE = 4300,
|
||||||
|
FUNCTION_TYPE_DB_USAGE_INFO,
|
||||||
|
|
||||||
// user defined funcion
|
// user defined funcion
|
||||||
FUNCTION_TYPE_UDF = 10000
|
FUNCTION_TYPE_UDF = 10000
|
||||||
} EFunctionType;
|
} EFunctionType;
|
||||||
|
@ -290,13 +293,15 @@ bool fmIsPrimaryKeyFunc(int32_t funcId);
|
||||||
bool fmIsProcessByRowFunc(int32_t funcId);
|
bool fmIsProcessByRowFunc(int32_t funcId);
|
||||||
bool fmisSelectGroupConstValueFunc(int32_t funcId);
|
bool fmisSelectGroupConstValueFunc(int32_t funcId);
|
||||||
bool fmIsElapsedFunc(int32_t funcId);
|
bool fmIsElapsedFunc(int32_t funcId);
|
||||||
|
bool fmIsDBUsageFunc(int32_t funcId);
|
||||||
bool fmIsRowTsOriginFunc(int32_t funcId);
|
bool fmIsRowTsOriginFunc(int32_t funcId);
|
||||||
|
|
||||||
void getLastCacheDataType(SDataType* pType, int32_t pkBytes);
|
void getLastCacheDataType(SDataType* pType, int32_t pkBytes);
|
||||||
int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNode** pFunc);
|
int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNode** pFunc);
|
||||||
int32_t createFunctionWithSrcFunc(const char* pName, const SFunctionNode* pSrcFunc, SNodeList* pParameterList, SFunctionNode** pFunc);
|
int32_t createFunctionWithSrcFunc(const char* pName, const SFunctionNode* pSrcFunc, SNodeList* pParameterList, SFunctionNode** pFunc);
|
||||||
|
|
||||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMidFunc, SFunctionNode** pMergeFunc);
|
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMidFunc,
|
||||||
|
SFunctionNode** pMergeFunc);
|
||||||
|
|
||||||
typedef enum EFuncDataRequired {
|
typedef enum EFuncDataRequired {
|
||||||
FUNC_DATA_REQUIRED_DATA_LOAD = 1,
|
FUNC_DATA_REQUIRED_DATA_LOAD = 1,
|
||||||
|
@ -319,7 +324,7 @@ int32_t fmSetNormalFunc(int32_t funcId, SFuncExecFuncs* pFpSet);
|
||||||
bool fmIsInvertible(int32_t funcId);
|
bool fmIsInvertible(int32_t funcId);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char* fmGetFuncName(int32_t funcId);
|
char* fmGetFuncName(int32_t funcId);
|
||||||
|
|
||||||
bool fmIsTSMASupportedFunc(func_id_t funcId);
|
bool fmIsTSMASupportedFunc(func_id_t funcId);
|
||||||
int32_t fmCreateStateFuncs(SNodeList* pFuncs);
|
int32_t fmCreateStateFuncs(SNodeList* pFuncs);
|
||||||
|
|
|
@ -395,6 +395,11 @@ typedef struct SShowTableDistributedStmt {
|
||||||
char tableName[TSDB_TABLE_NAME_LEN];
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
} SShowTableDistributedStmt;
|
} SShowTableDistributedStmt;
|
||||||
|
|
||||||
|
typedef struct SShowDBUsageStmt {
|
||||||
|
ENodeType type;
|
||||||
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
|
} SShowDBUsageStmt;
|
||||||
|
|
||||||
typedef struct SShowDnodeVariablesStmt {
|
typedef struct SShowDnodeVariablesStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
SNode* pDnodeId;
|
SNode* pDnodeId;
|
||||||
|
|
|
@ -77,7 +77,7 @@ typedef enum EScanType {
|
||||||
SCAN_TYPE_TABLE_MERGE,
|
SCAN_TYPE_TABLE_MERGE,
|
||||||
SCAN_TYPE_BLOCK_INFO,
|
SCAN_TYPE_BLOCK_INFO,
|
||||||
SCAN_TYPE_LAST_ROW,
|
SCAN_TYPE_LAST_ROW,
|
||||||
SCAN_TYPE_TABLE_COUNT
|
SCAN_TYPE_TABLE_COUNT,
|
||||||
} EScanType;
|
} EScanType;
|
||||||
|
|
||||||
typedef struct SScanLogicNode {
|
typedef struct SScanLogicNode {
|
||||||
|
@ -121,12 +121,12 @@ typedef struct SScanLogicNode {
|
||||||
bool sortPrimaryKey;
|
bool sortPrimaryKey;
|
||||||
bool igLastNull;
|
bool igLastNull;
|
||||||
bool groupOrderScan;
|
bool groupOrderScan;
|
||||||
bool onlyMetaCtbIdx; // for tag scan with no tbname
|
bool onlyMetaCtbIdx; // for tag scan with no tbname
|
||||||
bool filesetDelimited; // returned blocks delimited by fileset
|
bool filesetDelimited; // returned blocks delimited by fileset
|
||||||
bool isCountByTag; // true if selectstmt hasCountFunc & part by tag/tbname
|
bool isCountByTag; // true if selectstmt hasCountFunc & part by tag/tbname
|
||||||
SArray* pFuncTypes; // for last, last_row
|
SArray* pFuncTypes; // for last, last_row
|
||||||
bool paraTablesSort; // for table merge scan
|
bool paraTablesSort; // for table merge scan
|
||||||
bool smallDataTsSort; // disable row id sort for table merge scan
|
bool smallDataTsSort; // disable row id sort for table merge scan
|
||||||
bool needSplit;
|
bool needSplit;
|
||||||
} SScanLogicNode;
|
} SScanLogicNode;
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ typedef struct SJoinLogicNode {
|
||||||
SNode* pColOnCond;
|
SNode* pColOnCond;
|
||||||
SNode* pTagEqCond;
|
SNode* pTagEqCond;
|
||||||
SNode* pTagOnCond;
|
SNode* pTagOnCond;
|
||||||
SNode* pFullOnCond; // except prim eq cond
|
SNode* pFullOnCond; // except prim eq cond
|
||||||
SNodeList* pLeftEqNodes;
|
SNodeList* pLeftEqNodes;
|
||||||
SNodeList* pRightEqNodes;
|
SNodeList* pRightEqNodes;
|
||||||
bool allEqTags;
|
bool allEqTags;
|
||||||
|
@ -156,10 +156,10 @@ typedef struct SJoinLogicNode {
|
||||||
bool batchScanHint;
|
bool batchScanHint;
|
||||||
|
|
||||||
// FOR HASH JOIN
|
// FOR HASH JOIN
|
||||||
int32_t timeRangeTarget; //table onCond filter
|
int32_t timeRangeTarget; // table onCond filter
|
||||||
STimeWindow timeRange; //table onCond filter
|
STimeWindow timeRange; // table onCond filter
|
||||||
SNode* pLeftOnCond; //table onCond filter
|
SNode* pLeftOnCond; // table onCond filter
|
||||||
SNode* pRightOnCond; //table onCond filter
|
SNode* pRightOnCond; // table onCond filter
|
||||||
} SJoinLogicNode;
|
} SJoinLogicNode;
|
||||||
|
|
||||||
typedef struct SAggLogicNode {
|
typedef struct SAggLogicNode {
|
||||||
|
@ -174,7 +174,7 @@ typedef struct SAggLogicNode {
|
||||||
bool isGroupTb;
|
bool isGroupTb;
|
||||||
bool isPartTb; // true if partition keys has tbname
|
bool isPartTb; // true if partition keys has tbname
|
||||||
bool hasGroup;
|
bool hasGroup;
|
||||||
SNodeList *pTsmaSubplans;
|
SNodeList* pTsmaSubplans;
|
||||||
} SAggLogicNode;
|
} SAggLogicNode;
|
||||||
|
|
||||||
typedef struct SProjectLogicNode {
|
typedef struct SProjectLogicNode {
|
||||||
|
@ -224,19 +224,19 @@ typedef struct SForecastFuncLogicNode {
|
||||||
} SForecastFuncLogicNode;
|
} SForecastFuncLogicNode;
|
||||||
|
|
||||||
typedef struct SGroupCacheLogicNode {
|
typedef struct SGroupCacheLogicNode {
|
||||||
SLogicNode node;
|
SLogicNode node;
|
||||||
bool grpColsMayBeNull;
|
bool grpColsMayBeNull;
|
||||||
bool grpByUid;
|
bool grpByUid;
|
||||||
bool globalGrp;
|
bool globalGrp;
|
||||||
bool batchFetch;
|
bool batchFetch;
|
||||||
SNodeList* pGroupCols;
|
SNodeList* pGroupCols;
|
||||||
} SGroupCacheLogicNode;
|
} SGroupCacheLogicNode;
|
||||||
|
|
||||||
typedef struct SDynQueryCtrlStbJoin {
|
typedef struct SDynQueryCtrlStbJoin {
|
||||||
bool batchFetch;
|
bool batchFetch;
|
||||||
SNodeList* pVgList;
|
SNodeList* pVgList;
|
||||||
SNodeList* pUidList;
|
SNodeList* pUidList;
|
||||||
bool srcScan[2];
|
bool srcScan[2];
|
||||||
} SDynQueryCtrlStbJoin;
|
} SDynQueryCtrlStbJoin;
|
||||||
|
|
||||||
typedef struct SDynQueryCtrlLogicNode {
|
typedef struct SDynQueryCtrlLogicNode {
|
||||||
|
@ -356,7 +356,7 @@ typedef struct SSortLogicNode {
|
||||||
bool groupSort;
|
bool groupSort;
|
||||||
bool skipPKSortOpt;
|
bool skipPKSortOpt;
|
||||||
bool calcGroupId;
|
bool calcGroupId;
|
||||||
bool excludePkCol; // exclude PK ts col when calc group id
|
bool excludePkCol; // exclude PK ts col when calc group id
|
||||||
} SSortLogicNode;
|
} SSortLogicNode;
|
||||||
|
|
||||||
typedef struct SPartitionLogicNode {
|
typedef struct SPartitionLogicNode {
|
||||||
|
@ -366,8 +366,8 @@ typedef struct SPartitionLogicNode {
|
||||||
SNode* pSubtable;
|
SNode* pSubtable;
|
||||||
SNodeList* pAggFuncs;
|
SNodeList* pAggFuncs;
|
||||||
|
|
||||||
bool needBlockOutputTsOrder; // if true, partition output block will have ts order maintained
|
bool needBlockOutputTsOrder; // if true, partition output block will have ts order maintained
|
||||||
int32_t pkTsColId;
|
int32_t pkTsColId;
|
||||||
uint64_t pkTsColTbId;
|
uint64_t pkTsColTbId;
|
||||||
} SPartitionLogicNode;
|
} SPartitionLogicNode;
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ typedef struct SScanPhysiNode {
|
||||||
|
|
||||||
typedef struct STagScanPhysiNode {
|
typedef struct STagScanPhysiNode {
|
||||||
SScanPhysiNode scan;
|
SScanPhysiNode scan;
|
||||||
bool onlyMetaCtbIdx; //no tbname, tag index not used.
|
bool onlyMetaCtbIdx; // no tbname, tag index not used.
|
||||||
} STagScanPhysiNode;
|
} STagScanPhysiNode;
|
||||||
|
|
||||||
typedef SScanPhysiNode SBlockDistScanPhysiNode;
|
typedef SScanPhysiNode SBlockDistScanPhysiNode;
|
||||||
|
@ -519,16 +519,16 @@ typedef struct SIndefRowsFuncPhysiNode {
|
||||||
} SIndefRowsFuncPhysiNode;
|
} SIndefRowsFuncPhysiNode;
|
||||||
|
|
||||||
typedef struct SInterpFuncPhysiNode {
|
typedef struct SInterpFuncPhysiNode {
|
||||||
SPhysiNode node;
|
SPhysiNode node;
|
||||||
SNodeList* pExprs;
|
SNodeList* pExprs;
|
||||||
SNodeList* pFuncs;
|
SNodeList* pFuncs;
|
||||||
STimeWindow timeRange;
|
STimeWindow timeRange;
|
||||||
int64_t interval;
|
int64_t interval;
|
||||||
int8_t intervalUnit;
|
int8_t intervalUnit;
|
||||||
int8_t precision;
|
int8_t precision;
|
||||||
EFillMode fillMode;
|
EFillMode fillMode;
|
||||||
SNode* pFillValues; // SNodeListNode
|
SNode* pFillValues; // SNodeListNode
|
||||||
SNode* pTimeSeries; // SColumnNode
|
SNode* pTimeSeries; // SColumnNode
|
||||||
SStreamNodeOption streamNodeOption;
|
SStreamNodeOption streamNodeOption;
|
||||||
int64_t rangeInterval;
|
int64_t rangeInterval;
|
||||||
int8_t rangeIntervalUnit;
|
int8_t rangeIntervalUnit;
|
||||||
|
@ -555,12 +555,12 @@ typedef struct SSortMergeJoinPhysiNode {
|
||||||
int32_t rightPrimSlotId;
|
int32_t rightPrimSlotId;
|
||||||
SNodeList* pEqLeft;
|
SNodeList* pEqLeft;
|
||||||
SNodeList* pEqRight;
|
SNodeList* pEqRight;
|
||||||
SNode* pPrimKeyCond; //remove
|
SNode* pPrimKeyCond; // remove
|
||||||
SNode* pColEqCond; //remove
|
SNode* pColEqCond; // remove
|
||||||
SNode* pColOnCond;
|
SNode* pColOnCond;
|
||||||
SNode* pFullOnCond;
|
SNode* pFullOnCond;
|
||||||
SNodeList* pTargets;
|
SNodeList* pTargets;
|
||||||
SQueryStat inputStat[2];
|
SQueryStat inputStat[2];
|
||||||
bool seqWinGroup;
|
bool seqWinGroup;
|
||||||
bool grpJoin;
|
bool grpJoin;
|
||||||
} SSortMergeJoinPhysiNode;
|
} SSortMergeJoinPhysiNode;
|
||||||
|
@ -570,25 +570,25 @@ typedef struct SHashJoinPhysiNode {
|
||||||
EJoinType joinType;
|
EJoinType joinType;
|
||||||
EJoinSubType subType;
|
EJoinSubType subType;
|
||||||
SNode* pWindowOffset;
|
SNode* pWindowOffset;
|
||||||
SNode* pJLimit;
|
SNode* pJLimit;
|
||||||
SNodeList* pOnLeft;
|
SNodeList* pOnLeft;
|
||||||
SNodeList* pOnRight;
|
SNodeList* pOnRight;
|
||||||
SNode* leftPrimExpr;
|
SNode* leftPrimExpr;
|
||||||
SNode* rightPrimExpr;
|
SNode* rightPrimExpr;
|
||||||
int32_t leftPrimSlotId;
|
int32_t leftPrimSlotId;
|
||||||
int32_t rightPrimSlotId;
|
int32_t rightPrimSlotId;
|
||||||
int32_t timeRangeTarget; //table onCond filter
|
int32_t timeRangeTarget; // table onCond filter
|
||||||
STimeWindow timeRange; //table onCond filter
|
STimeWindow timeRange; // table onCond filter
|
||||||
SNode* pLeftOnCond; //table onCond filter
|
SNode* pLeftOnCond; // table onCond filter
|
||||||
SNode* pRightOnCond; //table onCond filter
|
SNode* pRightOnCond; // table onCond filter
|
||||||
SNode* pFullOnCond; //preFilter
|
SNode* pFullOnCond; // preFilter
|
||||||
SNodeList* pTargets;
|
SNodeList* pTargets;
|
||||||
SQueryStat inputStat[2];
|
SQueryStat inputStat[2];
|
||||||
|
|
||||||
// only in planner internal
|
// only in planner internal
|
||||||
SNode* pPrimKeyCond;
|
SNode* pPrimKeyCond;
|
||||||
SNode* pColEqCond;
|
SNode* pColEqCond;
|
||||||
SNode* pTagEqCond;
|
SNode* pTagEqCond;
|
||||||
} SHashJoinPhysiNode;
|
} SHashJoinPhysiNode;
|
||||||
|
|
||||||
typedef struct SGroupCachePhysiNode {
|
typedef struct SGroupCachePhysiNode {
|
||||||
|
@ -601,10 +601,10 @@ typedef struct SGroupCachePhysiNode {
|
||||||
} SGroupCachePhysiNode;
|
} SGroupCachePhysiNode;
|
||||||
|
|
||||||
typedef struct SStbJoinDynCtrlBasic {
|
typedef struct SStbJoinDynCtrlBasic {
|
||||||
bool batchFetch;
|
bool batchFetch;
|
||||||
int32_t vgSlot[2];
|
int32_t vgSlot[2];
|
||||||
int32_t uidSlot[2];
|
int32_t uidSlot[2];
|
||||||
bool srcScan[2];
|
bool srcScan[2];
|
||||||
} SStbJoinDynCtrlBasic;
|
} SStbJoinDynCtrlBasic;
|
||||||
|
|
||||||
typedef struct SDynQueryCtrlPhysiNode {
|
typedef struct SDynQueryCtrlPhysiNode {
|
||||||
|
@ -699,7 +699,7 @@ typedef struct SFillPhysiNode {
|
||||||
SNode* pWStartTs; // SColumnNode
|
SNode* pWStartTs; // SColumnNode
|
||||||
SNode* pValues; // SNodeListNode
|
SNode* pValues; // SNodeListNode
|
||||||
STimeWindow timeRange;
|
STimeWindow timeRange;
|
||||||
SNodeList* pFillNullExprs;
|
SNodeList* pFillNullExprs;
|
||||||
} SFillPhysiNode;
|
} SFillPhysiNode;
|
||||||
|
|
||||||
typedef SFillPhysiNode SStreamFillPhysiNode;
|
typedef SFillPhysiNode SStreamFillPhysiNode;
|
||||||
|
@ -809,9 +809,9 @@ typedef struct SDataDeleterNode {
|
||||||
char tableFName[TSDB_TABLE_NAME_LEN];
|
char tableFName[TSDB_TABLE_NAME_LEN];
|
||||||
char tsColName[TSDB_COL_NAME_LEN];
|
char tsColName[TSDB_COL_NAME_LEN];
|
||||||
STimeWindow deleteTimeRange;
|
STimeWindow deleteTimeRange;
|
||||||
SNode* pAffectedRows; // usless
|
SNode* pAffectedRows; // usless
|
||||||
SNode* pStartTs; // usless
|
SNode* pStartTs; // usless
|
||||||
SNode* pEndTs; // usless
|
SNode* pEndTs; // usless
|
||||||
} SDataDeleterNode;
|
} SDataDeleterNode;
|
||||||
|
|
||||||
typedef struct SSubplan {
|
typedef struct SSubplan {
|
||||||
|
|
|
@ -22,8 +22,8 @@ extern "C" {
|
||||||
|
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tvariant.h"
|
|
||||||
#include "tsimplehash.h"
|
#include "tsimplehash.h"
|
||||||
|
#include "tvariant.h"
|
||||||
|
|
||||||
#define TABLE_TOTAL_COL_NUM(pMeta) ((pMeta)->tableInfo.numOfColumns + (pMeta)->tableInfo.numOfTags)
|
#define TABLE_TOTAL_COL_NUM(pMeta) ((pMeta)->tableInfo.numOfColumns + (pMeta)->tableInfo.numOfTags)
|
||||||
#define TABLE_META_SIZE(pMeta) \
|
#define TABLE_META_SIZE(pMeta) \
|
||||||
|
@ -41,7 +41,7 @@ typedef struct SRawExprNode {
|
||||||
char* p;
|
char* p;
|
||||||
uint32_t n;
|
uint32_t n;
|
||||||
SNode* pNode;
|
SNode* pNode;
|
||||||
bool isPseudoColumn;
|
bool isPseudoColumn;
|
||||||
} SRawExprNode;
|
} SRawExprNode;
|
||||||
|
|
||||||
typedef struct SDataType {
|
typedef struct SDataType {
|
||||||
|
@ -111,8 +111,8 @@ typedef struct STargetNode {
|
||||||
#define VALUE_FLAG_IS_DURATION (1 << 0)
|
#define VALUE_FLAG_IS_DURATION (1 << 0)
|
||||||
#define VALUE_FLAG_IS_TIME_OFFSET (1 << 1)
|
#define VALUE_FLAG_IS_TIME_OFFSET (1 << 1)
|
||||||
|
|
||||||
#define IS_DURATION_VAL(_flag) ((_flag) & VALUE_FLAG_IS_DURATION)
|
#define IS_DURATION_VAL(_flag) ((_flag)&VALUE_FLAG_IS_DURATION)
|
||||||
#define IS_TIME_OFFSET_VAL(_flag) ((_flag) & VALUE_FLAG_IS_TIME_OFFSET)
|
#define IS_TIME_OFFSET_VAL(_flag) ((_flag)&VALUE_FLAG_IS_TIME_OFFSET)
|
||||||
|
|
||||||
typedef struct SValueNode {
|
typedef struct SValueNode {
|
||||||
SExprNode node; // QUERY_NODE_VALUE
|
SExprNode node; // QUERY_NODE_VALUE
|
||||||
|
@ -190,7 +190,7 @@ typedef struct SFunctionNode {
|
||||||
bool hasOriginalFunc;
|
bool hasOriginalFunc;
|
||||||
int32_t originalFuncId;
|
int32_t originalFuncId;
|
||||||
ETrimType trimType;
|
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;
|
} SFunctionNode;
|
||||||
|
|
||||||
typedef struct STableNode {
|
typedef struct STableNode {
|
||||||
|
@ -205,7 +205,7 @@ typedef struct STableNode {
|
||||||
struct STableMeta;
|
struct STableMeta;
|
||||||
|
|
||||||
typedef struct STsmaTargetCTbInfo {
|
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;
|
uint64_t uid;
|
||||||
} STsmaTargetTbInfo;
|
} STsmaTargetTbInfo;
|
||||||
|
|
||||||
|
@ -219,8 +219,8 @@ typedef struct SRealTableNode {
|
||||||
int8_t cacheLastMode;
|
int8_t cacheLastMode;
|
||||||
int8_t stbRewrite;
|
int8_t stbRewrite;
|
||||||
SArray* pTsmas;
|
SArray* pTsmas;
|
||||||
SArray* tsmaTargetTbVgInfo; // SArray<SVgroupsInfo*>, 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
|
SArray* tsmaTargetTbInfo; // SArray<STsmaTargetTbInfo>, used for child table or normal table only
|
||||||
} SRealTableNode;
|
} SRealTableNode;
|
||||||
|
|
||||||
typedef struct STempTableNode {
|
typedef struct STempTableNode {
|
||||||
|
@ -238,12 +238,12 @@ typedef struct SViewNode {
|
||||||
int8_t cacheLastMode;
|
int8_t cacheLastMode;
|
||||||
} SViewNode;
|
} 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_INNER_NONE_JOIN(_type, _stype) ((_type) == JOIN_TYPE_INNER && (_stype) == JOIN_STYPE_NONE)
|
||||||
#define IS_SEMI_JOIN(_stype) ((_stype) == JOIN_STYPE_SEMI)
|
#define IS_SEMI_JOIN(_stype) ((_stype) == JOIN_STYPE_SEMI)
|
||||||
#define IS_WINDOW_JOIN(_stype) ((_stype) == JOIN_STYPE_WIN)
|
#define IS_WINDOW_JOIN(_stype) ((_stype) == JOIN_STYPE_WIN)
|
||||||
#define IS_ASOF_JOIN(_stype) ((_stype) == JOIN_STYPE_ASOF)
|
#define IS_ASOF_JOIN(_stype) ((_stype) == JOIN_STYPE_ASOF)
|
||||||
|
|
||||||
typedef enum EJoinType {
|
typedef enum EJoinType {
|
||||||
JOIN_TYPE_INNER = 0,
|
JOIN_TYPE_INNER = 0,
|
||||||
|
@ -469,6 +469,7 @@ typedef struct SSelectStmt {
|
||||||
bool groupSort;
|
bool groupSort;
|
||||||
bool tagScan;
|
bool tagScan;
|
||||||
bool joinContains;
|
bool joinContains;
|
||||||
|
bool mixSysTableAndActualTable;
|
||||||
} SSelectStmt;
|
} SSelectStmt;
|
||||||
|
|
||||||
typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType;
|
typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType;
|
||||||
|
@ -638,13 +639,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;
|
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,
|
int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char* pTableAlias, ECollectColType type,
|
||||||
SNodeList** pCols);
|
SNodeList** pCols);
|
||||||
int32_t nodesCollectColumnsExt(SSelectStmt* pSelect, ESqlClause clause, SSHashObj* pMultiTableAlias, ECollectColType type,
|
int32_t nodesCollectColumnsExt(SSelectStmt* pSelect, ESqlClause clause, SSHashObj* pMultiTableAlias,
|
||||||
SNodeList** pCols);
|
ECollectColType type, SNodeList** pCols);
|
||||||
int32_t nodesCollectColumnsFromNode(SNode* node, const char* pTableAlias, ECollectColType type, SNodeList** pCols);
|
int32_t nodesCollectColumnsFromNode(SNode* node, const char* pTableAlias, ECollectColType type, SNodeList** pCols);
|
||||||
|
|
||||||
typedef bool (*FFuncClassifier)(int32_t funcId);
|
typedef bool (*FFuncClassifier)(int32_t funcId);
|
||||||
int32_t nodesCollectFuncs(SSelectStmt* pSelect, ESqlClause clause, char* tableAlias, FFuncClassifier classifier, SNodeList** pFuncs);
|
int32_t nodesCollectFuncs(SSelectStmt* pSelect, ESqlClause clause, char* tableAlias, FFuncClassifier classifier,
|
||||||
int32_t nodesCollectSelectFuncs(SSelectStmt* pSelect, ESqlClause clause, char* tableAlias, FFuncClassifier classifier, SNodeList* pFuncs);
|
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);
|
int32_t nodesCollectSpecialNodes(SSelectStmt* pSelect, ESqlClause clause, ENodeType type, SNodeList** pNodes);
|
||||||
|
|
||||||
|
@ -678,12 +681,11 @@ const char* logicConditionTypeStr(ELogicConditionType type);
|
||||||
bool nodesIsStar(SNode* pNode);
|
bool nodesIsStar(SNode* pNode);
|
||||||
bool nodesIsTableStar(SNode* pNode);
|
bool nodesIsTableStar(SNode* pNode);
|
||||||
|
|
||||||
char* getJoinTypeString(EJoinType type);
|
char* getJoinTypeString(EJoinType type);
|
||||||
char* getJoinSTypeString(EJoinSubType type);
|
char* getJoinSTypeString(EJoinSubType type);
|
||||||
char* getFullJoinTypeString(EJoinType type, EJoinSubType stype);
|
char* getFullJoinTypeString(EJoinType type, EJoinSubType stype);
|
||||||
int32_t mergeJoinConds(SNode** ppDst, SNode** ppSrc);
|
int32_t mergeJoinConds(SNode** ppDst, SNode** ppSrc);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -37,11 +37,11 @@ extern "C" {
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
|
||||||
#define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\"
|
#define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\"
|
||||||
#ifdef CUS_NAME
|
#ifdef CUS_NAME
|
||||||
#define TD_CFG_DIR_PATH "C:\\"CUS_NAME"\\cfg\\"
|
#define TD_CFG_DIR_PATH "C:\\" CUS_NAME "\\cfg\\"
|
||||||
#define TD_DATA_DIR_PATH "C:\\"CUS_NAME"\\data\\"
|
#define TD_DATA_DIR_PATH "C:\\" CUS_NAME "\\data\\"
|
||||||
#define TD_LOG_DIR_PATH "C:\\"CUS_NAME"\\log\\"
|
#define TD_LOG_DIR_PATH "C:\\" CUS_NAME "\\log\\"
|
||||||
#else
|
#else
|
||||||
#define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\"
|
#define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\"
|
||||||
#define TD_DATA_DIR_PATH "C:\\TDengine\\data\\"
|
#define TD_DATA_DIR_PATH "C:\\TDengine\\data\\"
|
||||||
|
@ -51,10 +51,10 @@ extern "C" {
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
|
|
||||||
#ifdef CUS_PROMPT
|
#ifdef CUS_PROMPT
|
||||||
#define TD_TMP_DIR_PATH "/tmp/"CUS_PROMPT"d/"
|
#define TD_TMP_DIR_PATH "/tmp/" CUS_PROMPT "d/"
|
||||||
#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/"
|
#define TD_CFG_DIR_PATH "/etc/" CUS_PROMPT "/"
|
||||||
#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/"
|
#define TD_DATA_DIR_PATH "/var/lib/" CUS_PROMPT "/"
|
||||||
#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/"
|
#define TD_LOG_DIR_PATH "/var/log/" CUS_PROMPT "/"
|
||||||
#else
|
#else
|
||||||
#define TD_TMP_DIR_PATH "/tmp/taosd/"
|
#define TD_TMP_DIR_PATH "/tmp/taosd/"
|
||||||
#define TD_CFG_DIR_PATH "/etc/taos/"
|
#define TD_CFG_DIR_PATH "/etc/taos/"
|
||||||
|
@ -64,16 +64,16 @@ extern "C" {
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define TD_TMP_DIR_PATH "/tmp/"
|
#define TD_TMP_DIR_PATH "/tmp/"
|
||||||
#ifdef CUS_PROMPT
|
#ifdef CUS_PROMPT
|
||||||
#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/"
|
#define TD_CFG_DIR_PATH "/etc/" CUS_PROMPT "/"
|
||||||
#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/"
|
#define TD_DATA_DIR_PATH "/var/lib/" CUS_PROMPT "/"
|
||||||
#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/"
|
#define TD_LOG_DIR_PATH "/var/log/" CUS_PROMPT "/"
|
||||||
#else
|
#else
|
||||||
#define TD_CFG_DIR_PATH "/etc/taos/"
|
#define TD_CFG_DIR_PATH "/etc/taos/"
|
||||||
#define TD_DATA_DIR_PATH "/var/lib/taos/"
|
#define TD_DATA_DIR_PATH "/var/lib/taos/"
|
||||||
#define TD_LOG_DIR_PATH "/var/log/taos/"
|
#define TD_LOG_DIR_PATH "/var/log/taos/"
|
||||||
#endif // CUS_PROMPT
|
#endif // CUS_PROMPT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct TdDir *TdDirPtr;
|
typedef struct TdDir *TdDirPtr;
|
||||||
|
@ -100,6 +100,7 @@ bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry);
|
||||||
char *taosGetDirEntryName(TdDirEntryPtr pDirEntry);
|
char *taosGetDirEntryName(TdDirEntryPtr pDirEntry);
|
||||||
int32_t taosCloseDir(TdDirPtr *ppDir);
|
int32_t taosCloseDir(TdDirPtr *ppDir);
|
||||||
|
|
||||||
|
int taosGetDirSize(const char *path, int64_t *size);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -97,6 +97,7 @@ int32_t taosGetErrSize();
|
||||||
#define TSDB_CODE_RPC_ASYNC_IN_PROCESS TAOS_DEF_ERROR_CODE(0, 0x0028)
|
#define TSDB_CODE_RPC_ASYNC_IN_PROCESS TAOS_DEF_ERROR_CODE(0, 0x0028)
|
||||||
#define TSDB_CODE_RPC_NO_STATE TAOS_DEF_ERROR_CODE(0, 0x0029)
|
#define TSDB_CODE_RPC_NO_STATE TAOS_DEF_ERROR_CODE(0, 0x0029)
|
||||||
#define TSDB_CODE_RPC_STATE_DROPED TAOS_DEF_ERROR_CODE(0, 0x002A)
|
#define TSDB_CODE_RPC_STATE_DROPED TAOS_DEF_ERROR_CODE(0, 0x002A)
|
||||||
|
#define TSDB_CODE_RPC_MSG_EXCCED_LIMIT TAOS_DEF_ERROR_CODE(0, 0x002B)
|
||||||
|
|
||||||
//common & util
|
//common & util
|
||||||
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) //
|
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) //
|
||||||
|
|
|
@ -467,6 +467,19 @@ static const SSysDbTableSchema encryptionsSchema[] = {
|
||||||
{.name = "key_status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "key_status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const SSysDbTableSchema diskUsageSchema[] = {
|
||||||
|
{.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", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||||
|
{.name = "data1", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||||
|
{.name = "data2", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||||
|
{.name = "data3", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||||
|
{.name = "cache_rdb", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||||
|
{.name = "table_meta", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||||
|
{.name = "s3",.bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||||
|
{.name = "raw_data", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||||
|
};
|
||||||
|
|
||||||
static const SSysTableMeta infosMeta[] = {
|
static const SSysTableMeta infosMeta[] = {
|
||||||
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true},
|
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true},
|
||||||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
||||||
|
@ -505,6 +518,7 @@ static const SSysTableMeta infosMeta[] = {
|
||||||
{TSDB_INS_TABLE_TSMAS, tsmaSchema, tListLen(tsmaSchema), false},
|
{TSDB_INS_TABLE_TSMAS, tsmaSchema, tListLen(tsmaSchema), false},
|
||||||
{TSDB_INS_TABLE_ANODES, anodesSchema, tListLen(anodesSchema), true},
|
{TSDB_INS_TABLE_ANODES, anodesSchema, tListLen(anodesSchema), true},
|
||||||
{TSDB_INS_TABLE_ANODES_FULL, anodesFullSchema, tListLen(anodesFullSchema), true},
|
{TSDB_INS_TABLE_ANODES_FULL, anodesFullSchema, tListLen(anodesFullSchema), true},
|
||||||
|
{TSDB_INS_DISK_USAGE, diskUsageSchema, tListLen(diskUsageSchema), false},
|
||||||
{TSDB_INS_TABLE_FILESETS, filesetsFullSchema, tListLen(filesetsFullSchema), false},
|
{TSDB_INS_TABLE_FILESETS, filesetsFullSchema, tListLen(filesetsFullSchema), false},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndPrivilege.h"
|
#include "mndPrivilege.h"
|
||||||
#include "systable.h"
|
|
||||||
#include "mndUser.h"
|
#include "mndUser.h"
|
||||||
|
#include "systable.h"
|
||||||
|
|
||||||
#define SHOW_STEP_SIZE 100
|
#define SHOW_STEP_SIZE 100
|
||||||
#define SHOW_COLS_STEP_SIZE 4096
|
#define SHOW_COLS_STEP_SIZE 4096
|
||||||
|
@ -60,10 +60,10 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
||||||
type = TSDB_MGMT_TABLE_DNODE;
|
type = TSDB_MGMT_TABLE_DNODE;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_MNODE;
|
type = TSDB_MGMT_TABLE_MNODE;
|
||||||
/*
|
/*
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_MODULES, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_MODULES, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_MODULE;
|
type = TSDB_MGMT_TABLE_MODULE;
|
||||||
*/
|
*/
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_QNODES, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_QNODES, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_QNODE;
|
type = TSDB_MGMT_TABLE_QNODE;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
|
||||||
|
@ -142,6 +142,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
||||||
type = TSDB_MGMT_TABLE_ENCRYPTIONS;
|
type = TSDB_MGMT_TABLE_ENCRYPTIONS;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_TSMAS;
|
type = TSDB_MGMT_TABLE_TSMAS;
|
||||||
|
} else if (strncasecmp(name, TSDB_INS_DISK_USAGE, len) == 0) {
|
||||||
|
type = TSDB_MGMT_TABLE_USAGE;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_FILESETS, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_FILESETS, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_FILESETS;
|
type = TSDB_MGMT_TABLE_FILESETS;
|
||||||
} else {
|
} else {
|
||||||
|
@ -265,7 +267,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pShow->type == TSDB_MGMT_TABLE_COL){ // expend capacity for ins_columns
|
if (pShow->type == TSDB_MGMT_TABLE_COL) { // expend capacity for ins_columns
|
||||||
rowsToRead = SHOW_COLS_STEP_SIZE;
|
rowsToRead = SHOW_COLS_STEP_SIZE;
|
||||||
} else if (pShow->type == TSDB_MGMT_TABLE_PRIVILEGES) {
|
} else if (pShow->type == TSDB_MGMT_TABLE_PRIVILEGES) {
|
||||||
rowsToRead = SHOW_PRIVILEGES_STEP_SIZE;
|
rowsToRead = SHOW_PRIVILEGES_STEP_SIZE;
|
||||||
|
@ -290,7 +292,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
if (pShow->type == TSDB_MGMT_TABLE_USER_FULL) {
|
if (pShow->type == TSDB_MGMT_TABLE_USER_FULL) {
|
||||||
if(strcmp(pReq->info.conn.user, "root") != 0){
|
if (strcmp(pReq->info.conn.user, "root") != 0) {
|
||||||
mError("The operation is not permitted, user:%s, pShow->type:%d", pReq->info.conn.user, pShow->type);
|
mError("The operation is not permitted, user:%s, pShow->type:%d", pReq->info.conn.user, pShow->type);
|
||||||
code = TSDB_CODE_MND_NO_RIGHTS;
|
code = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
|
@ -336,7 +338,8 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t dataEncodeBufSize = blockGetEncodeSize(pBlock);
|
size_t dataEncodeBufSize = blockGetEncodeSize(pBlock);
|
||||||
size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns + dataEncodeBufSize;
|
size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns +
|
||||||
|
dataEncodeBufSize;
|
||||||
|
|
||||||
SRetrieveMetaTableRsp *pRsp = rpcMallocCont(size);
|
SRetrieveMetaTableRsp *pRsp = rpcMallocCont(size);
|
||||||
if (pRsp == NULL) {
|
if (pRsp == NULL) {
|
||||||
|
@ -364,9 +367,9 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = blockEncode(pBlock, pStart, dataEncodeBufSize, pShow->pMeta->numOfColumns);
|
int32_t len = blockEncode(pBlock, pStart, dataEncodeBufSize, pShow->pMeta->numOfColumns);
|
||||||
if(len < 0){
|
if (len < 0) {
|
||||||
mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(code));
|
mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(code));
|
||||||
code = terrno;
|
code = terrno;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -390,7 +393,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
||||||
_exit:
|
_exit:
|
||||||
mndReleaseShowObj(pShow, false);
|
mndReleaseShowObj(pShow, false);
|
||||||
blockDataDestroy(pBlock);
|
blockDataDestroy(pBlock);
|
||||||
if(pRsp) {
|
if (pRsp) {
|
||||||
rpcFreeCont(pRsp);
|
rpcFreeCont(pRsp);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -80,6 +80,7 @@ int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list);
|
||||||
int32_t vnodeIsCatchUp(SVnode *pVnode);
|
int32_t vnodeIsCatchUp(SVnode *pVnode);
|
||||||
ESyncRole vnodeGetRole(SVnode *pVnode);
|
ESyncRole vnodeGetRole(SVnode *pVnode);
|
||||||
int32_t vnodeGetArbToken(SVnode *pVnode, char *outToken);
|
int32_t vnodeGetArbToken(SVnode *pVnode, char *outToken);
|
||||||
|
int32_t vnodeGetDBSize(void *pVnode, SDbSizeStatisInfo *pInfo);
|
||||||
|
|
||||||
int32_t vnodeUpdateArbTerm(SVnode *pVnode, int64_t arbTerm);
|
int32_t vnodeUpdateArbTerm(SVnode *pVnode, int64_t arbTerm);
|
||||||
|
|
||||||
|
@ -108,7 +109,7 @@ int32_t vnodePreprocessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||||
|
|
||||||
int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp);
|
int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp);
|
||||||
int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||||
int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo* pInfo);
|
int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
||||||
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
||||||
int32_t vnodeProcessStreamMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
int32_t vnodeProcessStreamMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
||||||
void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs);
|
void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs);
|
||||||
|
@ -224,10 +225,10 @@ void tqReaderClose(STqReader *);
|
||||||
bool tqGetTablePrimaryKey(STqReader *pReader);
|
bool tqGetTablePrimaryKey(STqReader *pReader);
|
||||||
void tqSetTablePrimaryKey(STqReader *pReader, int64_t uid);
|
void tqSetTablePrimaryKey(STqReader *pReader, int64_t uid);
|
||||||
|
|
||||||
void tqReaderSetColIdList(STqReader *pReader, SArray *pColIdList);
|
void tqReaderSetColIdList(STqReader *pReader, SArray *pColIdList);
|
||||||
void tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList, const char *id);
|
void tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList, const char *id);
|
||||||
void tqReaderAddTbUidList(STqReader *pReader, const SArray *pTableUidList);
|
void tqReaderAddTbUidList(STqReader *pReader, const SArray *pTableUidList);
|
||||||
void tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList);
|
void tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList);
|
||||||
|
|
||||||
bool tqReaderIsQueriedTable(STqReader *pReader, uint64_t uid);
|
bool tqReaderIsQueriedTable(STqReader *pReader, uint64_t uid);
|
||||||
bool tqCurrentBlockConsumed(const STqReader *pReader);
|
bool tqCurrentBlockConsumed(const STqReader *pReader);
|
||||||
|
@ -243,7 +244,8 @@ int32_t extractMsgFromWal(SWalReader *pReader, void **pItem, int64_t maxVer, con
|
||||||
int32_t tqReaderSetSubmitMsg(STqReader *pReader, void *msgStr, int32_t msgLen, int64_t ver);
|
int32_t tqReaderSetSubmitMsg(STqReader *pReader, void *msgStr, int32_t msgLen, int64_t ver);
|
||||||
bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids);
|
bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids);
|
||||||
int32_t tqRetrieveDataBlock(STqReader *pReader, SSDataBlock **pRes, const char *idstr);
|
int32_t tqRetrieveDataBlock(STqReader *pReader, SSDataBlock **pRes, const char *idstr);
|
||||||
int32_t tqRetrieveTaosxBlock(STqReader *pReader, SArray *blocks, SArray *schemas, SSubmitTbData **pSubmitTbDataRet, int64_t *createTime);
|
int32_t tqRetrieveTaosxBlock(STqReader *pReader, SArray *blocks, SArray *schemas, SSubmitTbData **pSubmitTbDataRet,
|
||||||
|
int64_t *createTime);
|
||||||
int32_t tqGetStreamExecInfo(SVnode *pVnode, int64_t streamId, int64_t *pDelay, bool *fhFinished);
|
int32_t tqGetStreamExecInfo(SVnode *pVnode, int64_t streamId, int64_t *pDelay, bool *fhFinished);
|
||||||
|
|
||||||
// sma
|
// sma
|
||||||
|
@ -258,14 +260,14 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, SSnapshotParam *pParam, SVSnapWriter
|
||||||
int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *pSnapshot);
|
int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *pSnapshot);
|
||||||
int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData);
|
int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData);
|
||||||
|
|
||||||
bool taosXGetTablePrimaryKey(SSnapContext *ctx);
|
bool taosXGetTablePrimaryKey(SSnapContext *ctx);
|
||||||
void taosXSetTablePrimaryKey(SSnapContext *ctx, int64_t uid);
|
void taosXSetTablePrimaryKey(SSnapContext *ctx, int64_t uid);
|
||||||
int32_t buildSnapContext(SVnode *pVnode, int64_t snapVersion, int64_t suid, int8_t subType, int8_t withMeta,
|
int32_t buildSnapContext(SVnode *pVnode, int64_t snapVersion, int64_t suid, int8_t subType, int8_t withMeta,
|
||||||
SSnapContext **ctxRet);
|
SSnapContext **ctxRet);
|
||||||
int32_t getTableInfoFromSnapshot(SSnapContext *ctx, void **pBuf, int32_t *contLen, int16_t *type, int64_t *uid);
|
int32_t getTableInfoFromSnapshot(SSnapContext *ctx, void **pBuf, int32_t *contLen, int16_t *type, int64_t *uid);
|
||||||
int32_t getMetaTableInfoFromSnapshot(SSnapContext *ctx, SMetaTableInfo* info);
|
int32_t getMetaTableInfoFromSnapshot(SSnapContext *ctx, SMetaTableInfo *info);
|
||||||
int32_t setForSnapShot(SSnapContext *ctx, int64_t uid);
|
int32_t setForSnapShot(SSnapContext *ctx, int64_t uid);
|
||||||
void destroySnapContext(SSnapContext *ctx);
|
void destroySnapContext(SSnapContext *ctx);
|
||||||
|
|
||||||
// structs
|
// structs
|
||||||
struct STsdbCfg {
|
struct STsdbCfg {
|
||||||
|
|
|
@ -959,6 +959,8 @@ int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
|
||||||
int32_t tsdbCacheDeleteLast(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
|
int32_t tsdbCacheDeleteLast(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
|
||||||
int32_t tsdbCacheDelete(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
|
int32_t tsdbCacheDelete(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
|
||||||
|
|
||||||
|
int32_t tsdbGetS3Size(STsdb *tsdb, int64_t *size);
|
||||||
|
|
||||||
// ========== inline functions ==========
|
// ========== inline functions ==========
|
||||||
static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
|
static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
|
||||||
TSDBKEY *pKey1 = (TSDBKEY *)p1;
|
TSDBKEY *pKey1 = (TSDBKEY *)p1;
|
||||||
|
|
|
@ -84,16 +84,18 @@ typedef struct SQueryNode SQueryNode;
|
||||||
#define VNODE_META_TMP_DIR "meta.tmp"
|
#define VNODE_META_TMP_DIR "meta.tmp"
|
||||||
#define VNODE_META_BACKUP_DIR "meta.backup"
|
#define VNODE_META_BACKUP_DIR "meta.backup"
|
||||||
|
|
||||||
#define VNODE_META_DIR "meta"
|
#define VNODE_META_DIR "meta"
|
||||||
#define VNODE_TSDB_DIR "tsdb"
|
#define VNODE_TSDB_DIR "tsdb"
|
||||||
#define VNODE_TQ_DIR "tq"
|
#define VNODE_TQ_DIR "tq"
|
||||||
#define VNODE_WAL_DIR "wal"
|
#define VNODE_WAL_DIR "wal"
|
||||||
#define VNODE_TSMA_DIR "tsma"
|
#define VNODE_TSMA_DIR "tsma"
|
||||||
#define VNODE_RSMA_DIR "rsma"
|
#define VNODE_RSMA_DIR "rsma"
|
||||||
#define VNODE_RSMA0_DIR "tsdb"
|
#define VNODE_RSMA0_DIR "tsdb"
|
||||||
#define VNODE_RSMA1_DIR "rsma1"
|
#define VNODE_RSMA1_DIR "rsma1"
|
||||||
#define VNODE_RSMA2_DIR "rsma2"
|
#define VNODE_RSMA2_DIR "rsma2"
|
||||||
#define VNODE_TQ_STREAM "stream"
|
#define VNODE_TQ_STREAM "stream"
|
||||||
|
#define VNODE_CACHE_DIR "cache.rdb"
|
||||||
|
#define VNODE_TSDB_CACHE_DIR VNODE_TSDB_DIR TD_DIRSEP VNODE_CACHE_DIR
|
||||||
|
|
||||||
#if SUSPEND_RESUME_TEST // only for test purpose
|
#if SUSPEND_RESUME_TEST // only for test purpose
|
||||||
#define VNODE_BUFPOOL_SEGMENTS 1
|
#define VNODE_BUFPOOL_SEGMENTS 1
|
||||||
|
@ -163,7 +165,7 @@ int32_t metaDropTables(SMeta* pMeta, SArray* tbUids);
|
||||||
int metaTtlFindExpired(SMeta* pMeta, int64_t timePointMs, SArray* tbUids, int32_t ttlDropMaxCount);
|
int metaTtlFindExpired(SMeta* pMeta, int64_t timePointMs, SArray* tbUids, int32_t ttlDropMaxCount);
|
||||||
int metaAlterTable(SMeta* pMeta, int64_t version, SVAlterTbReq* pReq, STableMetaRsp* pMetaRsp);
|
int metaAlterTable(SMeta* pMeta, int64_t version, SVAlterTbReq* pReq, STableMetaRsp* pMetaRsp);
|
||||||
int metaUpdateChangeTimeWithLock(SMeta* pMeta, tb_uid_t uid, int64_t changeTimeMs);
|
int metaUpdateChangeTimeWithLock(SMeta* pMeta, tb_uid_t uid, int64_t changeTimeMs);
|
||||||
SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, int lock, int64_t *createTime);
|
SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, int lock, int64_t* createTime);
|
||||||
int32_t metaGetTbTSchemaNotNull(SMeta* pMeta, tb_uid_t uid, int32_t sver, int lock, STSchema** ppTSchema);
|
int32_t metaGetTbTSchemaNotNull(SMeta* pMeta, tb_uid_t uid, int32_t sver, int lock, STSchema** ppTSchema);
|
||||||
int32_t metaGetTbTSchemaMaybeNull(SMeta* pMeta, tb_uid_t uid, int32_t sver, int lock, STSchema** ppTSchema);
|
int32_t metaGetTbTSchemaMaybeNull(SMeta* pMeta, tb_uid_t uid, int32_t sver, int lock, STSchema** ppTSchema);
|
||||||
STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, int lock);
|
STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, int lock);
|
||||||
|
|
|
@ -733,3 +733,30 @@ int32_t tsdbAsyncS3Migrate(STsdb *tsdb, int64_t now) {
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbGetS3SizeImpl(STsdb *tsdb, int64_t *size) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
SVnodeCfg *pCfg = &tsdb->pVnode->config;
|
||||||
|
int64_t chunksize = (int64_t)pCfg->tsdbPageSize * pCfg->s3ChunkSize;
|
||||||
|
|
||||||
|
STFileSet *fset;
|
||||||
|
TARRAY2_FOREACH(tsdb->pFS->fSetArr, fset) {
|
||||||
|
STFileObj *fobj = fset->farr[TSDB_FTYPE_DATA];
|
||||||
|
if (fobj) {
|
||||||
|
int32_t lcn = fobj->f->lcn;
|
||||||
|
if (lcn > 1) {
|
||||||
|
*size += ((lcn - 1) * chunksize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
int32_t tsdbGetS3Size(STsdb *tsdb, int64_t *size) {
|
||||||
|
int32_t code = 0;
|
||||||
|
(void)taosThreadMutexLock(&tsdb->mutex);
|
||||||
|
code = tsdbGetS3SizeImpl(tsdb, size);
|
||||||
|
(void)taosThreadMutexUnlock(&tsdb->mutex);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ void initMetadataAPI(SStoreMeta* pMeta) {
|
||||||
pMeta->pauseCtbCursor = metaPauseCtbCursor;
|
pMeta->pauseCtbCursor = metaPauseCtbCursor;
|
||||||
pMeta->closeCtbCursor = metaCloseCtbCursor;
|
pMeta->closeCtbCursor = metaCloseCtbCursor;
|
||||||
pMeta->ctbCursorNext = metaCtbCursorNext;
|
pMeta->ctbCursorNext = metaCtbCursorNext;
|
||||||
|
pMeta->getDBSize = vnodeGetDBSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTqAPI(SStoreTqReader* pTq) {
|
void initTqAPI(SStoreTqReader* pTq) {
|
||||||
|
|
|
@ -870,6 +870,41 @@ int32_t vnodeGetTableSchema(void *pVnode, int64_t uid, STSchema **pSchema, int64
|
||||||
return tsdbGetTableSchema(((SVnode *)pVnode)->pMeta, uid, pSchema, suid);
|
return tsdbGetTableSchema(((SVnode *)pVnode)->pMeta, uid, pSchema, suid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t vnodeGetDBSize(void *pVnode, SDbSizeStatisInfo *pInfo) {
|
||||||
|
SVnode *pVnodeObj = pVnode;
|
||||||
|
if (pVnodeObj == NULL) {
|
||||||
|
return TSDB_CODE_VND_NOT_EXIST;
|
||||||
|
}
|
||||||
|
int32_t code = 0;
|
||||||
|
char path[TSDB_FILENAME_LEN] = {0};
|
||||||
|
|
||||||
|
char *dirName[] = {VNODE_TSDB_DIR, VNODE_WAL_DIR, VNODE_META_DIR, VNODE_TSDB_CACHE_DIR};
|
||||||
|
int64_t dirSize[4];
|
||||||
|
|
||||||
|
vnodeGetPrimaryDir(pVnodeObj->path, pVnodeObj->diskPrimary, pVnodeObj->pTfs, path, TSDB_FILENAME_LEN);
|
||||||
|
int32_t offset = strlen(path);
|
||||||
|
|
||||||
|
for (int i = 0; i < sizeof(dirName) / sizeof(dirName[0]); i++) {
|
||||||
|
int64_t size = {0};
|
||||||
|
(void)snprintf(path + offset, TSDB_FILENAME_LEN, "%s%s", TD_DIRSEP, dirName[i]);
|
||||||
|
code = taosGetDirSize(path, &size);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
path[offset] = 0;
|
||||||
|
dirSize[i] = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
pInfo->l1Size = dirSize[0] - dirSize[3];
|
||||||
|
pInfo->walSize = dirSize[1];
|
||||||
|
pInfo->metaSize = dirSize[2];
|
||||||
|
pInfo->cacheSize = dirSize[3];
|
||||||
|
|
||||||
|
code = tsdbGetS3Size(pVnodeObj->pTsdb, &pInfo->s3Size);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t vnodeGetStreamProgress(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
int32_t vnodeGetStreamProgress(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SStreamProgressReq req;
|
SStreamProgressReq req;
|
||||||
|
|
|
@ -29,10 +29,9 @@
|
||||||
#include "storageapi.h"
|
#include "storageapi.h"
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
|
|
||||||
|
|
||||||
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t cleanup,
|
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t cleanup,
|
||||||
__optr_close_fn_t closeFn, __optr_reqBuf_fn_t reqBufFn,
|
__optr_close_fn_t closeFn, __optr_reqBuf_fn_t reqBufFn, __optr_explain_fn_t explain,
|
||||||
__optr_explain_fn_t explain, __optr_get_ext_fn_t nextExtFn, __optr_notify_fn_t notifyFn) {
|
__optr_get_ext_fn_t nextExtFn, __optr_notify_fn_t notifyFn) {
|
||||||
SOperatorFpSet fpSet = {
|
SOperatorFpSet fpSet = {
|
||||||
._openFn = openFn,
|
._openFn = openFn,
|
||||||
.getNextFn = nextFn,
|
.getNextFn = nextFn,
|
||||||
|
@ -133,7 +132,7 @@ void releaseQueryBuf(size_t numOfTables) {
|
||||||
int64_t t = getQuerySupportBufSize(numOfTables);
|
int64_t t = getQuerySupportBufSize(numOfTables);
|
||||||
|
|
||||||
// restore value is not enough buffer available
|
// restore value is not enough buffer available
|
||||||
(void) atomic_add_fetch_64(&tsQueryBufferSizeBytes, t);
|
(void)atomic_add_fetch_64(&tsQueryBufferSizeBytes, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -148,7 +147,7 @@ typedef struct STraverParam {
|
||||||
} STraverParam;
|
} STraverParam;
|
||||||
|
|
||||||
// iterate the operator tree helper
|
// iterate the operator tree helper
|
||||||
typedef ERetType (*optr_fn_t)(SOperatorInfo *pOperator, STraverParam *pParam, const char* pIdstr);
|
typedef ERetType (*optr_fn_t)(SOperatorInfo* pOperator, STraverParam* pParam, const char* pIdstr);
|
||||||
|
|
||||||
void traverseOperatorTree(SOperatorInfo* pOperator, optr_fn_t fn, STraverParam* pParam, const char* id) {
|
void traverseOperatorTree(SOperatorInfo* pOperator, optr_fn_t fn, STraverParam* pParam, const char* id) {
|
||||||
if (pOperator == NULL) {
|
if (pOperator == NULL) {
|
||||||
|
@ -202,30 +201,30 @@ typedef struct SExtScanInfo {
|
||||||
} SExtScanInfo;
|
} SExtScanInfo;
|
||||||
|
|
||||||
static ERetType extractScanInfo(SOperatorInfo* pOperator, STraverParam* pParam, const char* pIdStr) {
|
static ERetType extractScanInfo(SOperatorInfo* pOperator, STraverParam* pParam, const char* pIdStr) {
|
||||||
int32_t type = pOperator->operatorType;
|
int32_t type = pOperator->operatorType;
|
||||||
SExtScanInfo* pInfo = pParam->pParam;
|
SExtScanInfo* pInfo = pParam->pParam;
|
||||||
|
|
||||||
if (type == QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN || type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN ||
|
if (type == QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN || type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN ||
|
||||||
type == QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN || type == QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN ||
|
type == QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN || type == QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN ||
|
||||||
type == QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN || type == QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN) {
|
type == QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN || type == QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN) {
|
||||||
pInfo->order = TSDB_ORDER_ASC;
|
pInfo->order = TSDB_ORDER_ASC;
|
||||||
pInfo->scanFlag= MAIN_SCAN;
|
pInfo->scanFlag = MAIN_SCAN;
|
||||||
return OPTR_FN_RET_ABORT;
|
return OPTR_FN_RET_ABORT;
|
||||||
} else if (type == QUERY_NODE_PHYSICAL_PLAN_EXCHANGE) {
|
} else if (type == QUERY_NODE_PHYSICAL_PLAN_EXCHANGE) {
|
||||||
if (!pInfo->inheritUsOrder) {
|
if (!pInfo->inheritUsOrder) {
|
||||||
pInfo->order = TSDB_ORDER_ASC;
|
pInfo->order = TSDB_ORDER_ASC;
|
||||||
}
|
}
|
||||||
pInfo->scanFlag= MAIN_SCAN;
|
pInfo->scanFlag = MAIN_SCAN;
|
||||||
return OPTR_FN_RET_ABORT;
|
return OPTR_FN_RET_ABORT;
|
||||||
} else if (type == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) {
|
} else if (type == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) {
|
||||||
STableScanInfo* pTableScanInfo = pOperator->info;
|
STableScanInfo* pTableScanInfo = pOperator->info;
|
||||||
pInfo->order = pTableScanInfo->base.cond.order;
|
pInfo->order = pTableScanInfo->base.cond.order;
|
||||||
pInfo->scanFlag= pTableScanInfo->base.scanFlag;
|
pInfo->scanFlag = pTableScanInfo->base.scanFlag;
|
||||||
return OPTR_FN_RET_ABORT;
|
return OPTR_FN_RET_ABORT;
|
||||||
} else if (type == QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN) {
|
} else if (type == QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN) {
|
||||||
STableMergeScanInfo* pTableScanInfo = pOperator->info;
|
STableMergeScanInfo* pTableScanInfo = pOperator->info;
|
||||||
pInfo->order = pTableScanInfo->base.cond.order;
|
pInfo->order = pTableScanInfo->base.cond.order;
|
||||||
pInfo->scanFlag= pTableScanInfo->base.scanFlag;
|
pInfo->scanFlag = pTableScanInfo->base.scanFlag;
|
||||||
return OPTR_FN_RET_ABORT;
|
return OPTR_FN_RET_ABORT;
|
||||||
} else {
|
} else {
|
||||||
return OPTR_FN_RET_CONTINUE;
|
return OPTR_FN_RET_CONTINUE;
|
||||||
|
@ -281,14 +280,13 @@ int32_t stopTableScanOperator(SOperatorInfo* pOperator, const char* pIdStr, SSto
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t createOperator(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, SNode* pTagCond,
|
int32_t createOperator(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, SNode* pTagCond,
|
||||||
SNode* pTagIndexCond, const char* pUser, const char* dbname, SOperatorInfo** pOptrInfo) {
|
SNode* pTagIndexCond, const char* pUser, const char* dbname, SOperatorInfo** pOptrInfo) {
|
||||||
QRY_PARAM_CHECK(pOptrInfo);
|
QRY_PARAM_CHECK(pOptrInfo);
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t type = nodeType(pPhyNode);
|
int32_t type = nodeType(pPhyNode);
|
||||||
const char* idstr = GET_TASKID(pTaskInfo);
|
const char* idstr = GET_TASKID(pTaskInfo);
|
||||||
|
|
||||||
|
|
||||||
if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) {
|
if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) {
|
||||||
SOperatorInfo* pOperator = NULL;
|
SOperatorInfo* pOperator = NULL;
|
||||||
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) {
|
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) {
|
||||||
|
@ -318,8 +316,8 @@ int32_t createOperator(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHand
|
||||||
pTableListInfo->idInfo.suid = pTableScanNode->scan.suid;
|
pTableListInfo->idInfo.suid = pTableScanNode->scan.suid;
|
||||||
pTableListInfo->idInfo.tableType = pTableScanNode->scan.tableType;
|
pTableListInfo->idInfo.tableType = pTableScanNode->scan.tableType;
|
||||||
} else {
|
} else {
|
||||||
code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, pTableScanNode->groupSort, pHandle,
|
code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, pTableScanNode->groupSort,
|
||||||
pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo);
|
pHandle, pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo);
|
||||||
if (code) {
|
if (code) {
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
tableListDestroy(pTableListInfo);
|
tableListDestroy(pTableListInfo);
|
||||||
|
@ -346,8 +344,8 @@ int32_t createOperator(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHand
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, true, pHandle,
|
code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, true, pHandle, pTableListInfo,
|
||||||
pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo);
|
pTagCond, pTagIndexCond, pTaskInfo);
|
||||||
if (code) {
|
if (code) {
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
tableListDestroy(pTableListInfo);
|
tableListDestroy(pTableListInfo);
|
||||||
|
@ -373,7 +371,7 @@ int32_t createOperator(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHand
|
||||||
pTaskInfo->cost.pRecoder = &pScanInfo->base.readRecorder;
|
pTaskInfo->cost.pRecoder = &pScanInfo->base.readRecorder;
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
||||||
code = createExchangeOperatorInfo(pHandle ? pHandle->pMsgCb->clientRpc : NULL, (SExchangePhysiNode*)pPhyNode,
|
code = createExchangeOperatorInfo(pHandle ? pHandle->pMsgCb->clientRpc : NULL, (SExchangePhysiNode*)pPhyNode,
|
||||||
pTaskInfo, &pOperator);
|
pTaskInfo, &pOperator);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
||||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
||||||
STableListInfo* pTableListInfo = tableListCreate();
|
STableListInfo* pTableListInfo = tableListCreate();
|
||||||
|
@ -416,7 +414,7 @@ int32_t createOperator(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHand
|
||||||
}
|
}
|
||||||
if (!pTagScanPhyNode->onlyMetaCtbIdx) {
|
if (!pTagScanPhyNode->onlyMetaCtbIdx) {
|
||||||
code = createScanTableListInfo((SScanPhysiNode*)pTagScanPhyNode, NULL, false, pHandle, pTableListInfo, pTagCond,
|
code = createScanTableListInfo((SScanPhysiNode*)pTagScanPhyNode, NULL, false, pHandle, pTableListInfo, pTagCond,
|
||||||
pTagIndexCond, pTaskInfo);
|
pTagIndexCond, pTaskInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
qError("failed to getTableList, code: %s", tstrerror(code));
|
qError("failed to getTableList, code: %s", tstrerror(code));
|
||||||
|
@ -655,7 +653,6 @@ int32_t createOperator(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHand
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void destroyOperator(SOperatorInfo* pOperator) {
|
void destroyOperator(SOperatorInfo* pOperator) {
|
||||||
if (pOperator == NULL) {
|
if (pOperator == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -737,7 +734,7 @@ int32_t mergeOperatorParams(SOperatorParam* pDst, SOperatorParam* pSrc) {
|
||||||
qError("different optype %d:%d for merge operator params", pDst->opType, pSrc->opType);
|
qError("different optype %d:%d for merge operator params", pDst->opType, pSrc->opType);
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pDst->opType) {
|
switch (pDst->opType) {
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE: {
|
case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE: {
|
||||||
SExchangeOperatorParam* pDExc = pDst->value;
|
SExchangeOperatorParam* pDExc = pDst->value;
|
||||||
|
@ -757,17 +754,19 @@ int32_t mergeOperatorParams(SOperatorParam* pDst, SOperatorParam* pSrc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tSimpleHashSetFreeFp(pBatch->pBatchs, freeExchangeGetBasicOperatorParam);
|
tSimpleHashSetFreeFp(pBatch->pBatchs, freeExchangeGetBasicOperatorParam);
|
||||||
|
|
||||||
int32_t code = tSimpleHashPut(pBatch->pBatchs, &pDExc->basic.vgId, sizeof(pDExc->basic.vgId), &pDExc->basic, sizeof(pDExc->basic));
|
int32_t code = tSimpleHashPut(pBatch->pBatchs, &pDExc->basic.vgId, sizeof(pDExc->basic.vgId), &pDExc->basic,
|
||||||
|
sizeof(pDExc->basic));
|
||||||
if (code) {
|
if (code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tSimpleHashPut(pBatch->pBatchs, &pSExc->basic.vgId, sizeof(pSExc->basic.vgId), &pSExc->basic, sizeof(pSExc->basic));
|
code = tSimpleHashPut(pBatch->pBatchs, &pSExc->basic.vgId, sizeof(pSExc->basic.vgId), &pSExc->basic,
|
||||||
|
sizeof(pSExc->basic));
|
||||||
if (code) {
|
if (code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(pDst->value);
|
taosMemoryFree(pDst->value);
|
||||||
pDst->value = pBatch;
|
pDst->value = pBatch;
|
||||||
} else {
|
} else {
|
||||||
|
@ -778,14 +777,16 @@ int32_t mergeOperatorParams(SOperatorParam* pDst, SOperatorParam* pSrc) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SExchangeOperatorBatchParam* pBatch = pDst->value;
|
SExchangeOperatorBatchParam* pBatch = pDst->value;
|
||||||
SExchangeOperatorBasicParam* pBasic = tSimpleHashGet(pBatch->pBatchs, &pSExc->basic.vgId, sizeof(pSExc->basic.vgId));
|
SExchangeOperatorBasicParam* pBasic =
|
||||||
|
tSimpleHashGet(pBatch->pBatchs, &pSExc->basic.vgId, sizeof(pSExc->basic.vgId));
|
||||||
if (pBasic) {
|
if (pBasic) {
|
||||||
void* p = taosArrayAddAll(pBasic->uidList, pSExc->basic.uidList);
|
void* p = taosArrayAddAll(pBasic->uidList, pSExc->basic.uidList);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int32_t code = tSimpleHashPut(pBatch->pBatchs, &pSExc->basic.vgId, sizeof(pSExc->basic.vgId), &pSExc->basic, sizeof(pSExc->basic));
|
int32_t code = tSimpleHashPut(pBatch->pBatchs, &pSExc->basic.vgId, sizeof(pSExc->basic.vgId), &pSExc->basic,
|
||||||
|
sizeof(pSExc->basic));
|
||||||
if (code) {
|
if (code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -801,9 +802,8 @@ int32_t mergeOperatorParams(SOperatorParam* pDst, SOperatorParam* pSrc) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t setOperatorParams(struct SOperatorInfo* pOperator, SOperatorParam* pInput, SOperatorParamType type) {
|
int32_t setOperatorParams(struct SOperatorInfo* pOperator, SOperatorParam* pInput, SOperatorParamType type) {
|
||||||
SOperatorParam** ppParam = NULL;
|
SOperatorParam** ppParam = NULL;
|
||||||
SOperatorParam*** pppDownstramParam = NULL;
|
SOperatorParam*** pppDownstramParam = NULL;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OP_GET_PARAM:
|
case OP_GET_PARAM:
|
||||||
|
@ -819,13 +819,13 @@ int32_t setOperatorParams(struct SOperatorInfo* pOperator, SOperatorParam* pInpu
|
||||||
}
|
}
|
||||||
|
|
||||||
freeResetOperatorParams(pOperator, type, false);
|
freeResetOperatorParams(pOperator, type, false);
|
||||||
|
|
||||||
if (NULL == pInput) {
|
if (NULL == pInput) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppParam = (pInput->opType == pOperator->operatorType) ? pInput : NULL;
|
*ppParam = (pInput->opType == pOperator->operatorType) ? pInput : NULL;
|
||||||
|
|
||||||
if (NULL == *pppDownstramParam) {
|
if (NULL == *pppDownstramParam) {
|
||||||
*pppDownstramParam = taosMemoryCalloc(pOperator->numOfDownstream, POINTER_BYTES);
|
*pppDownstramParam = taosMemoryCalloc(pOperator->numOfDownstream, POINTER_BYTES);
|
||||||
if (NULL == *pppDownstramParam) {
|
if (NULL == *pppDownstramParam) {
|
||||||
|
@ -846,7 +846,7 @@ int32_t setOperatorParams(struct SOperatorInfo* pOperator, SOperatorParam* pInpu
|
||||||
if (childrenNum <= 0) {
|
if (childrenNum <= 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < childrenNum; ++i) {
|
for (int32_t i = 0; i < childrenNum; ++i) {
|
||||||
SOperatorParam* pChild = *(SOperatorParam**)taosArrayGet((*ppParam)->pChildren, i);
|
SOperatorParam* pChild = *(SOperatorParam**)taosArrayGet((*ppParam)->pChildren, i);
|
||||||
if (pChild == NULL) {
|
if (pChild == NULL) {
|
||||||
|
@ -869,7 +869,6 @@ int32_t setOperatorParams(struct SOperatorInfo* pOperator, SOperatorParam* pInpu
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SSDataBlock* getNextBlockFromDownstream(struct SOperatorInfo* pOperator, int32_t idx) {
|
SSDataBlock* getNextBlockFromDownstream(struct SOperatorInfo* pOperator, int32_t idx) {
|
||||||
SSDataBlock* p = NULL;
|
SSDataBlock* p = NULL;
|
||||||
int32_t code = getNextBlockFromDownstreamImpl(pOperator, idx, true, &p);
|
int32_t code = getNextBlockFromDownstreamImpl(pOperator, idx, true, &p);
|
||||||
|
@ -933,7 +932,7 @@ int32_t optrDefaultNotifyFn(struct SOperatorInfo* pOperator, SOperatorParam* pPa
|
||||||
pOperator->pTaskInfo->code = code;
|
pOperator->pTaskInfo->code = code;
|
||||||
T_LONG_JMP(pOperator->pTaskInfo->env, pOperator->pTaskInfo->code);
|
T_LONG_JMP(pOperator->pTaskInfo->env, pOperator->pTaskInfo->code);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,5 +942,3 @@ int16_t getOperatorResultBlockId(struct SOperatorInfo* pOperator, int32_t idx) {
|
||||||
}
|
}
|
||||||
return pOperator->resultDataBlockId;
|
return pOperator->resultDataBlockId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ typedef struct SSysTableScanInfo {
|
||||||
bool sysInfo;
|
bool sysInfo;
|
||||||
bool showRewrite;
|
bool showRewrite;
|
||||||
bool restore;
|
bool restore;
|
||||||
|
bool skipFilterTable;
|
||||||
SNode* pCondition; // db_name filter condition, to discard data that are not in current database
|
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.
|
SMTbCursor* pCur; // cursor for iterate the local table meta store.
|
||||||
SSysTableIndex* pIdx; // idx for local table meta
|
SSysTableIndex* pIdx; // idx for local table meta
|
||||||
|
@ -72,6 +73,8 @@ typedef struct SSysTableScanInfo {
|
||||||
SLoadRemoteDataInfo loadInfo;
|
SLoadRemoteDataInfo loadInfo;
|
||||||
SLimitInfo limitInfo;
|
SLimitInfo limitInfo;
|
||||||
int32_t tbnameSlotId;
|
int32_t tbnameSlotId;
|
||||||
|
STableListInfo* pTableListInfo;
|
||||||
|
SReadHandle* pHandle;
|
||||||
SStorageAPI* pAPI;
|
SStorageAPI* pAPI;
|
||||||
|
|
||||||
// file set iterate
|
// file set iterate
|
||||||
|
@ -97,6 +100,11 @@ typedef struct SBlockDistInfo {
|
||||||
uint64_t uid; // table uid
|
uint64_t uid; // table uid
|
||||||
} SBlockDistInfo;
|
} SBlockDistInfo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t type;
|
||||||
|
tb_uid_t uid;
|
||||||
|
} STableId;
|
||||||
|
|
||||||
static int32_t sysChkFilter__Comm(SNode* pNode);
|
static int32_t sysChkFilter__Comm(SNode* pNode);
|
||||||
static int32_t sysChkFilter__DBName(SNode* pNode);
|
static int32_t sysChkFilter__DBName(SNode* pNode);
|
||||||
static int32_t sysChkFilter__VgroupId(SNode* pNode);
|
static int32_t sysChkFilter__VgroupId(SNode* pNode);
|
||||||
|
@ -153,6 +161,8 @@ static int32_t sysTableUserColsFillOneTableCols(const SSysTableScanInfo* pInfo,
|
||||||
static void relocateAndFilterSysTagsScanResult(SSysTableScanInfo* pInfo, int32_t numOfRows, SSDataBlock* dataBlock,
|
static void relocateAndFilterSysTagsScanResult(SSysTableScanInfo* pInfo, int32_t numOfRows, SSDataBlock* dataBlock,
|
||||||
SFilterInfo* pFilterInfo, SExecTaskInfo* pTaskInfo);
|
SFilterInfo* pFilterInfo, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
|
static int32_t vnodeEstimateRawDataSize(SOperatorInfo* pOperator, SDbSizeStatisInfo* pStatisInfo);
|
||||||
|
|
||||||
int32_t sysFilte__DbName(void* arg, SNode* pNode, SArray* result) {
|
int32_t sysFilte__DbName(void* arg, SNode* pNode, SArray* result) {
|
||||||
SSTabFltArg* pArg = arg;
|
SSTabFltArg* pArg = arg;
|
||||||
void* pVnode = pArg->pVnode;
|
void* pVnode = pArg->pVnode;
|
||||||
|
@ -851,9 +861,11 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if pInfo->pRes->info.rows == 0, also need to add this meta into datablock.
|
|
||||||
|
// if pInfo->pRes->info.rows == 0, also need to add the meta to pDataBlock
|
||||||
code = sysTableUserTagsFillOneTableTags(pInfo, &smrSuperTable, &pInfo->pCur->mr, dbname, tableName, &numOfRows,
|
code = sysTableUserTagsFillOneTableTags(pInfo, &smrSuperTable, &pInfo->pCur->mr, dbname, tableName, &numOfRows,
|
||||||
dataBlock);
|
dataBlock);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||||
pAPI->metaReaderFn.clearReader(&smrSuperTable);
|
pAPI->metaReaderFn.clearReader(&smrSuperTable);
|
||||||
|
@ -1915,6 +1927,194 @@ _end:
|
||||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t buildVgDiskUsage(SOperatorInfo* pOperator, SDbSizeStatisInfo* pStaticsInfo) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||||
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
int32_t vgId = 0;
|
||||||
|
const char* db = NULL;
|
||||||
|
pAPI->metaFn.getBasicInfo(pInfo->readHandle.vnode, &pStaticsInfo->dbname, &vgId, NULL, NULL);
|
||||||
|
|
||||||
|
pStaticsInfo->vgId = vgId;
|
||||||
|
|
||||||
|
code = pAPI->metaFn.getDBSize(pInfo->readHandle.vnode, pStaticsInfo);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
static SSDataBlock* sysTableBuildVgUsage(SOperatorInfo* pOperator) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||||
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
SDbSizeStatisInfo staticsInfo = {0};
|
||||||
|
|
||||||
|
char* buf = NULL;
|
||||||
|
SSDataBlock* p = NULL;
|
||||||
|
|
||||||
|
const char* db = NULL;
|
||||||
|
int32_t numOfCols = 0;
|
||||||
|
int32_t numOfRows = 0;
|
||||||
|
|
||||||
|
// the retrieve is executed on the mnode, so return tables that belongs to the information schema database.
|
||||||
|
if (pInfo->readHandle.mnd != NULL) {
|
||||||
|
setOperatorCompleted(pOperator);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (pInfo->pCur == NULL) {
|
||||||
|
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
|
||||||
|
if (pInfo->pCur == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SSDataBlock* pBlock = pInfo->pRes;
|
||||||
|
|
||||||
|
code = buildVgDiskUsage(pOperator, &staticsInfo);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
if (pInfo->showRewrite) {
|
||||||
|
SSDataBlock* pBlock = pInfo->pRes;
|
||||||
|
SDBBlockUsageInfo usageInfo = {0};
|
||||||
|
int32_t len = tSerializeBlockDbUsage(NULL, 0, &usageInfo);
|
||||||
|
|
||||||
|
usageInfo.dataInDiskSize = staticsInfo.l1Size + staticsInfo.l2Size + staticsInfo.l3Size;
|
||||||
|
usageInfo.walInDiskSize = staticsInfo.walSize;
|
||||||
|
usageInfo.rawDataSize = staticsInfo.rawDataSize;
|
||||||
|
|
||||||
|
buf = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE);
|
||||||
|
QUERY_CHECK_NULL(buf, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
int32_t tempRes = tSerializeBlockDbUsage(varDataVal(buf), len, &usageInfo);
|
||||||
|
if (tempRes != len) {
|
||||||
|
QUERY_CHECK_CODE(TSDB_CODE_INVALID_MSG, lino, _end);
|
||||||
|
}
|
||||||
|
|
||||||
|
varDataSetLen(buf, len);
|
||||||
|
|
||||||
|
int32_t slotId = 1;
|
||||||
|
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, 1);
|
||||||
|
QUERY_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
code = colDataSetVal(pColInfo, 0, buf, false);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
taosMemoryFreeClear(buf);
|
||||||
|
if (slotId != 0) {
|
||||||
|
SColumnInfoData* p1 = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
QUERY_CHECK_NULL(p1, code, lino, _end, terrno);
|
||||||
|
}
|
||||||
|
|
||||||
|
pBlock->info.rows = 1;
|
||||||
|
pOperator->status = OP_EXEC_DONE;
|
||||||
|
pInfo->pRes->info.rows = pBlock->info.rows;
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
} else {
|
||||||
|
SName sn = {0};
|
||||||
|
char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
code = tNameFromString(&sn, staticsInfo.dbname, T_NAME_ACCT | T_NAME_DB);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
code = tNameGetDbName(&sn, varDataVal(dbname));
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
||||||
|
|
||||||
|
p = buildInfoSchemaTableMetaBlock(TSDB_INS_DISK_USAGE);
|
||||||
|
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = blockDataEnsureCapacity(p, pOperator->resultInfo.capacity);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||||
|
code = colDataSetVal(pColInfoData, numOfRows, dbname, false);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||||
|
code = colDataSetVal(pColInfoData, numOfRows, (char*)&staticsInfo.vgId, false);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||||
|
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.l1Size, false); // l1_size
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||||
|
code = colDataSetVal(pColInfoData, numOfRows, (char*)&staticsInfo.l2Size, false); // l2_size
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||||
|
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);
|
||||||
|
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||||
|
code = colDataSetVal(pColInfoData, numOfRows, (char*)&staticsInfo.rawDataSize, false); // estimate_size
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
numOfRows += 1;
|
||||||
|
|
||||||
|
if (numOfRows > 0) {
|
||||||
|
p->info.rows = numOfRows;
|
||||||
|
pInfo->pRes->info.rows = numOfRows;
|
||||||
|
|
||||||
|
code = relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
code = doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDataDestroy(p);
|
||||||
|
p = NULL;
|
||||||
|
|
||||||
|
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||||
|
setOperatorCompleted(pOperator);
|
||||||
|
}
|
||||||
|
_end:
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
if (pInfo->pCur) {
|
||||||
|
pAPI->metaFn.closeTableMetaCursor(pInfo->pCur);
|
||||||
|
pInfo->pCur = NULL;
|
||||||
|
}
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
blockDataDestroy(p);
|
||||||
|
pTaskInfo->code = code;
|
||||||
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
|
}
|
||||||
|
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
|
static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
@ -1969,6 +2169,26 @@ static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
|
||||||
return sysTableBuildUserTables(pOperator);
|
return sysTableBuildUserTables(pOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
pTaskInfo->code = code;
|
||||||
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
static SSDataBlock* sysTableScanUsage(SOperatorInfo* pOperator) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
|
SNode* pCondition = pInfo->pCondition;
|
||||||
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return sysTableBuildVgUsage(pOperator);
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
@ -2330,7 +2550,7 @@ static int32_t doSysTableScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes)
|
||||||
if (dbName[0]) TAOS_UNUSED(tsnprintf(pInfo->req.db, sizeof(pInfo->req.db), "%d.%s", pInfo->accountId, dbName));
|
if (dbName[0]) TAOS_UNUSED(tsnprintf(pInfo->req.db, sizeof(pInfo->req.db), "%d.%s", pInfo->accountId, dbName));
|
||||||
(void)sysTableIsCondOnOneTable(pInfo->pCondition, pInfo->req.filterTb);
|
(void)sysTableIsCondOnOneTable(pInfo->pCondition, pInfo->req.filterTb);
|
||||||
}
|
}
|
||||||
|
bool filter = true;
|
||||||
SSDataBlock* pBlock = NULL;
|
SSDataBlock* pBlock = NULL;
|
||||||
if (strncasecmp(name, TSDB_INS_TABLE_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
if (strncasecmp(name, TSDB_INS_TABLE_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
pBlock = sysTableScanUserTables(pOperator);
|
pBlock = sysTableScanUserTables(pOperator);
|
||||||
|
@ -2341,13 +2561,15 @@ static int32_t doSysTableScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes)
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, TSDB_TABLE_FNAME_LEN) == 0 && pInfo->showRewrite &&
|
} else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, TSDB_TABLE_FNAME_LEN) == 0 && pInfo->showRewrite &&
|
||||||
IS_SYS_DBNAME(dbName)) {
|
IS_SYS_DBNAME(dbName)) {
|
||||||
pBlock = sysTableScanUserSTables(pOperator);
|
pBlock = sysTableScanUserSTables(pOperator);
|
||||||
|
} else if (strncasecmp(name, TSDB_INS_DISK_USAGE, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
|
pBlock = sysTableScanUsage(pOperator);
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_FILESETS, TSDB_TABLE_FNAME_LEN) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_FILESETS, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
pBlock = sysTableScanUserFileSets(pOperator);
|
pBlock = sysTableScanUserFileSets(pOperator);
|
||||||
} else { // load the meta from mnode of the given epset
|
} else { // load the meta from mnode of the given epset
|
||||||
pBlock = sysTableScanFromMNode(pOperator, pInfo, name, pTaskInfo);
|
pBlock = sysTableScanFromMNode(pOperator, pInfo, name, pTaskInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
sysTableScanFillTbName(pOperator, pInfo, name, pBlock);
|
if (!pInfo->skipFilterTable) sysTableScanFillTbName(pOperator, pInfo, name, pBlock);
|
||||||
if (pBlock != NULL) {
|
if (pBlock != NULL) {
|
||||||
bool limitReached = applyLimitOffset(&pInfo->limitInfo, pBlock, pTaskInfo);
|
bool limitReached = applyLimitOffset(&pInfo->limitInfo, pBlock, pTaskInfo);
|
||||||
if (limitReached) {
|
if (limitReached) {
|
||||||
|
@ -2523,6 +2745,7 @@ int32_t createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNo
|
||||||
|
|
||||||
SScanPhysiNode* pScanNode = &pScanPhyNode->scan;
|
SScanPhysiNode* pScanNode = &pScanPhyNode->scan;
|
||||||
SDataBlockDescNode* pDescNode = pScanNode->node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pScanNode->node.pOutputDataBlockDesc;
|
||||||
|
QUERY_CHECK_CODE(code, lino, _error);
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
code = extractColMatchInfo(pScanNode->pScanCols, pDescNode, &num, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo);
|
code = extractColMatchInfo(pScanNode->pScanCols, pDescNode, &num, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo);
|
||||||
|
@ -2539,8 +2762,21 @@ int32_t createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNo
|
||||||
pInfo->showRewrite = pScanPhyNode->showRewrite;
|
pInfo->showRewrite = pScanPhyNode->showRewrite;
|
||||||
pInfo->pRes = createDataBlockFromDescNode(pDescNode);
|
pInfo->pRes = createDataBlockFromDescNode(pDescNode);
|
||||||
QUERY_CHECK_NULL(pInfo->pRes, code, lino, _error, terrno);
|
QUERY_CHECK_NULL(pInfo->pRes, code, lino, _error, terrno);
|
||||||
|
|
||||||
pInfo->pCondition = pScanNode->node.pConditions;
|
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);
|
||||||
|
} else {
|
||||||
|
code = filterInitFromNode(pScanNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
QUERY_CHECK_CODE(code, lino, _error);
|
QUERY_CHECK_CODE(code, lino, _error);
|
||||||
|
|
||||||
initLimitInfo(pScanPhyNode->scan.node.pLimit, pScanPhyNode->scan.node.pSlimit, &pInfo->limitInfo);
|
initLimitInfo(pScanPhyNode->scan.node.pLimit, pScanPhyNode->scan.node.pSlimit, &pInfo->limitInfo);
|
||||||
|
@ -2548,9 +2784,6 @@ int32_t createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNo
|
||||||
code = blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
code = blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
QUERY_CHECK_CODE(code, lino, _error);
|
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 ||
|
if (strncasecmp(name, TSDB_INS_TABLE_TABLES, TSDB_TABLE_FNAME_LEN) == 0 ||
|
||||||
strncasecmp(name, TSDB_INS_TABLE_TAGS, TSDB_TABLE_FNAME_LEN) == 0 ||
|
strncasecmp(name, TSDB_INS_TABLE_TAGS, TSDB_TABLE_FNAME_LEN) == 0 ||
|
||||||
strncasecmp(name, TSDB_INS_TABLE_FILESETS, TSDB_TABLE_FNAME_LEN) == 0) {
|
strncasecmp(name, TSDB_INS_TABLE_FILESETS, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
|
@ -3050,8 +3283,7 @@ static int32_t doBlockInfoScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes
|
||||||
code = pAPI->tsdReader.tsdReaderGetDataBlockDistInfo(pBlockScanInfo->pHandle, &blockDistInfo);
|
code = pAPI->tsdReader.tsdReaderGetDataBlockDistInfo(pBlockScanInfo->pHandle, &blockDistInfo);
|
||||||
QUERY_CHECK_CODE(code, lino, _end);
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
blockDistInfo.numOfInmemRows = 0;
|
code = (int32_t)pAPI->tsdReader.tsdReaderGetNumOfInMemRows(pBlockScanInfo->pHandle, &blockDistInfo.numOfInmemRows);
|
||||||
code = pAPI->tsdReader.tsdReaderGetNumOfInMemRows(pBlockScanInfo->pHandle, &blockDistInfo.numOfInmemRows);
|
|
||||||
QUERY_CHECK_CODE(code, lino, _end);
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
SSDataBlock* pBlock = pBlockScanInfo->pResBlock;
|
SSDataBlock* pBlock = pBlockScanInfo->pResBlock;
|
||||||
|
@ -3202,3 +3434,195 @@ _error:
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t buildTableListInfo(SOperatorInfo* pOperator, STableId* id, STableListInfo** ppTableListInfo) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t line = 0;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||||
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
SReadHandle* pReadHandle = &pInfo->readHandle;
|
||||||
|
SArray* pList = NULL;
|
||||||
|
|
||||||
|
STableListInfo* pTableListInfo = tableListCreate();
|
||||||
|
QUERY_CHECK_NULL(ppTableListInfo, code, line, _end, terrno);
|
||||||
|
|
||||||
|
if (id->type == TSDB_SUPER_TABLE) {
|
||||||
|
pList = taosArrayInit(4, sizeof(uint64_t));
|
||||||
|
QUERY_CHECK_NULL(pList, code, line, _end, terrno);
|
||||||
|
|
||||||
|
code = pReadHandle->api.metaFn.getChildTableList(pReadHandle->vnode, id->uid, pList);
|
||||||
|
QUERY_CHECK_CODE(code, line, _end);
|
||||||
|
|
||||||
|
size_t num = taosArrayGetSize(pList);
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
uint64_t* id = taosArrayGet(pList, i);
|
||||||
|
if (id == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
code = tableListAddTableInfo(pTableListInfo, *id, 0);
|
||||||
|
QUERY_CHECK_CODE(code, line, _end);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(pList);
|
||||||
|
pList = NULL;
|
||||||
|
|
||||||
|
} else if (id->type == TSDB_NORMAL_TABLE) {
|
||||||
|
code = tableListAddTableInfo(pTableListInfo, id->uid, 0);
|
||||||
|
QUERY_CHECK_CODE(code, line, _end);
|
||||||
|
}
|
||||||
|
*ppTableListInfo = pTableListInfo;
|
||||||
|
return code;
|
||||||
|
_end:
|
||||||
|
taosArrayDestroy(pList);
|
||||||
|
tableListDestroy(pTableListInfo);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
static int32_t vnodeEstimateDataSizeByUid(SOperatorInfo* pOperator, STableId* id, SDbSizeStatisInfo* pStaticInfo) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t line = 0;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||||
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
SQueryTableDataCond cond = {0};
|
||||||
|
|
||||||
|
SReadHandle* pReadHandle = &pInfo->readHandle;
|
||||||
|
|
||||||
|
STableListInfo* pTableListInfo = NULL;
|
||||||
|
code = buildTableListInfo(pOperator, id, &pTableListInfo);
|
||||||
|
QUERY_CHECK_CODE(code, line, _end);
|
||||||
|
|
||||||
|
tb_uid_t tbId = id->type == TSDB_SUPER_TABLE ? id->uid : 0;
|
||||||
|
|
||||||
|
code = initTableblockDistQueryCond(tbId, &cond);
|
||||||
|
QUERY_CHECK_CODE(code, line, _end);
|
||||||
|
|
||||||
|
pInfo->pTableListInfo = pTableListInfo;
|
||||||
|
|
||||||
|
int32_t num = 0;
|
||||||
|
code = tableListGetSize(pTableListInfo, &num);
|
||||||
|
QUERY_CHECK_CODE(code, line, _end);
|
||||||
|
|
||||||
|
void* pList = tableListGetInfo(pTableListInfo, 0);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
STableBlockDistInfo blockDistInfo = {.minRows = INT_MAX, .maxRows = INT_MIN};
|
||||||
|
code = doGetTableRowSize(pReadHandle, id->uid, (int32_t*)&blockDistInfo.rowSize, GET_TASKID(pTaskInfo));
|
||||||
|
QUERY_CHECK_CODE(code, line, _end);
|
||||||
|
|
||||||
|
code = pAPI->tsdReader.tsdReaderGetDataBlockDistInfo(pInfo->pHandle, &blockDistInfo);
|
||||||
|
QUERY_CHECK_CODE(code, line, _end);
|
||||||
|
|
||||||
|
code = pAPI->tsdReader.tsdReaderGetNumOfInMemRows(pInfo->pHandle, &blockDistInfo.numOfInmemRows);
|
||||||
|
QUERY_CHECK_CODE(code, line, _end);
|
||||||
|
|
||||||
|
int64_t rawDiskSize = 0, rawCacheSize = 0;
|
||||||
|
rawDiskSize = (blockDistInfo.totalRows + blockDistInfo.numOfSttRows) * blockDistInfo.rowSize;
|
||||||
|
rawCacheSize = blockDistInfo.numOfInmemRows * blockDistInfo.rowSize;
|
||||||
|
pStaticInfo->rawDataSize += rawDiskSize;
|
||||||
|
pStaticInfo->cacheSize += rawCacheSize;
|
||||||
|
|
||||||
|
if (pInfo->pHandle != NULL) {
|
||||||
|
pReadHandle->api.tsdReader.tsdReaderClose(pInfo->pHandle);
|
||||||
|
pInfo->pHandle = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tableListDestroy(pInfo->pTableListInfo);
|
||||||
|
pInfo->pTableListInfo = NULL;
|
||||||
|
return code;
|
||||||
|
_end:
|
||||||
|
|
||||||
|
if (pInfo->pHandle != NULL) {
|
||||||
|
pReadHandle->api.tsdReader.tsdReaderClose(pInfo->pHandle);
|
||||||
|
pInfo->pHandle = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tableListDestroy(pInfo->pTableListInfo);
|
||||||
|
pInfo->pTableListInfo = NULL;
|
||||||
|
if (code) {
|
||||||
|
pTaskInfo->code = code;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
cleanupQueryTableDataCond(&cond);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t vnodeEstimateRawDataSizeImpl(SOperatorInfo* pOperator, SArray* pTableList,
|
||||||
|
SDbSizeStatisInfo* pStaticInfo) {
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||||
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
|
int32_t rowLen = 0;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
for (int i = 0; i < taosArrayGetSize(pTableList); i++) {
|
||||||
|
STableId* id = (STableId*)taosArrayGet(pTableList, i);
|
||||||
|
code = vnodeEstimateDataSizeByUid(pOperator, id, pStaticInfo);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t vnodeEstimateRawDataSize(SOperatorInfo* pOperator, SDbSizeStatisInfo* pStaticInfo) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
int32_t line = 0;
|
||||||
|
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||||
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
int32_t numOfRows = 0;
|
||||||
|
int32_t ret = 0;
|
||||||
|
|
||||||
|
if (pInfo->pCur == NULL) {
|
||||||
|
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
|
||||||
|
if (pInfo->pCur == NULL) {
|
||||||
|
TAOS_CHECK_GOTO(terrno, &line, _exit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SArray* pIdList = taosArrayInit(16, sizeof(STableId));
|
||||||
|
if (pIdList == NULL) {
|
||||||
|
TAOS_CHECK_GOTO(terrno, &line, _exit);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (((ret = pAPI->metaFn.cursorNext(pInfo->pCur, TSDB_CHILD_TABLE)) == 0)) {
|
||||||
|
if (pInfo->pCur->mr.me.type == TSDB_SUPER_TABLE) {
|
||||||
|
STableId id = {.type = TSDB_SUPER_TABLE, .uid = pInfo->pCur->mr.me.uid};
|
||||||
|
if (taosArrayPush(pIdList, &id) == NULL) {
|
||||||
|
TAOS_CHECK_GOTO(terrno, &line, _exit);
|
||||||
|
}
|
||||||
|
} else if (pInfo->pCur->mr.me.type == TSDB_CHILD_TABLE) {
|
||||||
|
continue;
|
||||||
|
} else if (pInfo->pCur->mr.me.type == TSDB_NORMAL_TABLE) {
|
||||||
|
STableId id = {.type = TSDB_NORMAL_TABLE, .uid = pInfo->pCur->mr.me.uid};
|
||||||
|
if (taosArrayPush(pIdList, &id) == NULL) {
|
||||||
|
TAOS_CHECK_GOTO(terrno, &line, _exit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pInfo->pCur) {
|
||||||
|
pAPI->metaFn.closeTableMetaCursor(pInfo->pCur);
|
||||||
|
pInfo->pCur = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = vnodeEstimateRawDataSizeImpl(pOperator, pIdList, pStaticInfo);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (pInfo->pCur) {
|
||||||
|
pAPI->metaFn.closeTableMetaCursor(pInfo->pCur);
|
||||||
|
pInfo->pCur = NULL;
|
||||||
|
}
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
qError("%s failed at line %d since %s", __func__, line, tstrerror(code));
|
||||||
|
pTaskInfo->code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pIdList);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ int32_t i32VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, b
|
||||||
int32_t floatVectorCmpAVX2(const float* pData, int32_t numOfRows, bool isMinFunc, float* res);
|
int32_t floatVectorCmpAVX2(const float* pData, int32_t numOfRows, bool isMinFunc, float* res);
|
||||||
int32_t doubleVectorCmpAVX2(const double* pData, int32_t numOfRows, bool isMinFunc, double* res);
|
int32_t doubleVectorCmpAVX2(const double* pData, int32_t numOfRows, bool isMinFunc, double* res);
|
||||||
|
|
||||||
int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos);
|
int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos);
|
||||||
int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos);
|
int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos);
|
||||||
int32_t loadTupleData(SqlFunctionCtx* pCtx, const STuplePos* pPos, char** value);
|
int32_t loadTupleData(SqlFunctionCtx* pCtx, const STuplePos* pPos, char** value);
|
||||||
|
|
||||||
int32_t functionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
int32_t functionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
int32_t functionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
int32_t functionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
@ -45,7 +45,7 @@ bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEn
|
||||||
int32_t countFunction(SqlFunctionCtx* pCtx);
|
int32_t countFunction(SqlFunctionCtx* pCtx);
|
||||||
|
|
||||||
#ifdef BUILD_NO_CALL
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t countInvertFunction(SqlFunctionCtx* pCtx);
|
int32_t countInvertFunction(SqlFunctionCtx* pCtx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EFuncDataRequired statisDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
EFuncDataRequired statisDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||||
|
@ -53,10 +53,10 @@ bool getSumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv)
|
||||||
int32_t sumFunction(SqlFunctionCtx* pCtx);
|
int32_t sumFunction(SqlFunctionCtx* pCtx);
|
||||||
|
|
||||||
#ifdef BUILD_NO_CALL
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t sumInvertFunction(SqlFunctionCtx* pCtx);
|
int32_t sumInvertFunction(SqlFunctionCtx* pCtx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t sumCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
int32_t sumCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||||
|
|
||||||
int32_t minmaxFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
int32_t minmaxFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
bool getMinmaxFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getMinmaxFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
|
@ -102,7 +102,7 @@ int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
int32_t leastSQRCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
int32_t leastSQRCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||||
|
|
||||||
bool getPercentileFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getPercentileFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
int32_t percentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
int32_t percentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
int32_t percentileFunction(SqlFunctionCtx* pCtx);
|
int32_t percentileFunction(SqlFunctionCtx* pCtx);
|
||||||
int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
void percentileFunctionCleanupExt(SqlFunctionCtx* pCtx);
|
void percentileFunctionCleanupExt(SqlFunctionCtx* pCtx);
|
||||||
|
@ -211,7 +211,7 @@ int32_t mavgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo
|
||||||
int32_t mavgFunction(SqlFunctionCtx* pCtx);
|
int32_t mavgFunction(SqlFunctionCtx* pCtx);
|
||||||
|
|
||||||
bool getSampleFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getSampleFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
int32_t sampleFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
int32_t sampleFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
int32_t sampleFunction(SqlFunctionCtx* pCtx);
|
int32_t sampleFunction(SqlFunctionCtx* pCtx);
|
||||||
int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
void modeFunctionCleanupExt(SqlFunctionCtx* pCtx);
|
void modeFunctionCleanupExt(SqlFunctionCtx* pCtx);
|
||||||
|
|
||||||
bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
int32_t twaFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
int32_t twaFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
int32_t twaFunction(SqlFunctionCtx* pCtx);
|
int32_t twaFunction(SqlFunctionCtx* pCtx);
|
||||||
int32_t twaFinalize(struct SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
int32_t twaFinalize(struct SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
|
||||||
|
@ -247,6 +247,10 @@ int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||||
int32_t groupConstValueFunction(SqlFunctionCtx* pCtx);
|
int32_t groupConstValueFunction(SqlFunctionCtx* pCtx);
|
||||||
int32_t groupConstValueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
int32_t groupConstValueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
|
||||||
|
int32_t blockDBUsageSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
|
int32_t blockDBUsageFunction(SqlFunctionCtx* pCtx);
|
||||||
|
int32_t blockDBUsageFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -187,8 +187,8 @@ static int32_t countTrailingSpaces(const SValueNode* pVal, bool isLtrim) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t addTimezoneParam(SNodeList* pList) {
|
static int32_t addTimezoneParam(SNodeList* pList) {
|
||||||
char buf[TD_TIME_STR_LEN] = {0};
|
char buf[TD_TIME_STR_LEN] = {0};
|
||||||
time_t t;
|
time_t t;
|
||||||
int32_t code = taosTime(&t);
|
int32_t code = taosTime(&t);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -232,7 +232,7 @@ static int32_t addTimezoneParam(SNodeList* pList) {
|
||||||
|
|
||||||
static int32_t addUint8Param(SNodeList** pList, uint8_t param) {
|
static int32_t addUint8Param(SNodeList** pList, uint8_t param) {
|
||||||
SValueNode* pVal = NULL;
|
SValueNode* pVal = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
||||||
if (pVal == NULL) {
|
if (pVal == NULL) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ static int32_t addUint8Param(SNodeList** pList, uint8_t param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t addPseudoParam(SNodeList** pList) {
|
static int32_t addPseudoParam(SNodeList** pList) {
|
||||||
SNode *pseudoNode = NULL;
|
SNode* pseudoNode = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_LEFT_VALUE, &pseudoNode);
|
int32_t code = nodesMakeNode(QUERY_NODE_LEFT_VALUE, &pseudoNode);
|
||||||
if (pseudoNode == NULL) {
|
if (pseudoNode == NULL) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -693,19 +693,17 @@ static int32_t validateHistogramBinDesc(char* binDescStr, int8_t binType, char*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkRangeValue(SNode *pNode, SParamRange range, bool *isMatch) {
|
static int32_t checkRangeValue(SNode* pNode, SParamRange range, bool* isMatch) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (pNode->type == QUERY_NODE_VALUE) {
|
if (pNode->type == QUERY_NODE_VALUE) {
|
||||||
SValueNode* pVal = (SValueNode*)pNode;
|
SValueNode* pVal = (SValueNode*)pNode;
|
||||||
if (IS_INTEGER_TYPE(getSDataTypeFromNode(pNode)->type)) {
|
if (IS_INTEGER_TYPE(getSDataTypeFromNode(pNode)->type)) {
|
||||||
if (pVal->datum.i < range.iMinVal ||
|
if (pVal->datum.i < range.iMinVal || pVal->datum.i > range.iMaxVal) {
|
||||||
pVal->datum.i > range.iMaxVal) {
|
|
||||||
code = TSDB_CODE_FUNC_FUNTION_PARA_RANGE;
|
code = TSDB_CODE_FUNC_FUNTION_PARA_RANGE;
|
||||||
*isMatch = false;
|
*isMatch = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((int64_t)pVal->datum.d < range.iMinVal ||
|
if ((int64_t)pVal->datum.d < range.iMinVal || (int64_t)pVal->datum.d > range.iMaxVal) {
|
||||||
(int64_t)pVal->datum.d > range.iMaxVal) {
|
|
||||||
code = TSDB_CODE_FUNC_FUNTION_PARA_RANGE;
|
code = TSDB_CODE_FUNC_FUNTION_PARA_RANGE;
|
||||||
*isMatch = false;
|
*isMatch = false;
|
||||||
}
|
}
|
||||||
|
@ -716,11 +714,10 @@ static int32_t checkRangeValue(SNode *pNode, SParamRange range, bool *isMatch) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkFixedValue(SNode *pNode, const SParamInfo *paramPattern, int32_t paramIdx, bool *isMatch) {
|
static int32_t checkFixedValue(SNode* pNode, const SParamInfo* paramPattern, int32_t paramIdx, bool* isMatch) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
bool checkStr = paramSupportVarBinary(paramPattern->validDataType) ||
|
bool checkStr = paramSupportVarBinary(paramPattern->validDataType) ||
|
||||||
paramSupportVarchar(paramPattern->validDataType) ||
|
paramSupportVarchar(paramPattern->validDataType) || paramSupportNchar(paramPattern->validDataType);
|
||||||
paramSupportNchar(paramPattern->validDataType);
|
|
||||||
if (pNode->type == QUERY_NODE_VALUE) {
|
if (pNode->type == QUERY_NODE_VALUE) {
|
||||||
SValueNode* pVal = (SValueNode*)pNode;
|
SValueNode* pVal = (SValueNode*)pNode;
|
||||||
if (!checkStr) {
|
if (!checkStr) {
|
||||||
|
@ -752,7 +749,7 @@ static int32_t checkFixedValue(SNode *pNode, const SParamInfo *paramPattern, int
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkPrimTS(SNode *pNode, bool *isMatch) {
|
static int32_t checkPrimTS(SNode* pNode, bool* isMatch) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (nodeType(pNode) != QUERY_NODE_COLUMN || !IS_TIMESTAMP_TYPE(getSDataTypeFromNode(pNode)->type) ||
|
if (nodeType(pNode) != QUERY_NODE_COLUMN || !IS_TIMESTAMP_TYPE(getSDataTypeFromNode(pNode)->type) ||
|
||||||
!((SColumnNode*)pNode)->isPrimTs) {
|
!((SColumnNode*)pNode)->isPrimTs) {
|
||||||
|
@ -762,7 +759,7 @@ static int32_t checkPrimTS(SNode *pNode, bool *isMatch) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkPrimaryKey(SNode *pNode, bool *isMatch) {
|
static int32_t checkPrimaryKey(SNode* pNode, bool* isMatch) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (nodeType(pNode) != QUERY_NODE_COLUMN || !IS_INTEGER_TYPE(getSDataTypeFromNode(pNode)->type) ||
|
if (nodeType(pNode) != QUERY_NODE_COLUMN || !IS_INTEGER_TYPE(getSDataTypeFromNode(pNode)->type) ||
|
||||||
!((SColumnNode*)pNode)->isPk) {
|
!((SColumnNode*)pNode)->isPk) {
|
||||||
|
@ -772,7 +769,7 @@ static int32_t checkPrimaryKey(SNode *pNode, bool *isMatch) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkHasColumn(SNode *pNode, bool *isMatch) {
|
static int32_t checkHasColumn(SNode* pNode, bool* isMatch) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (!nodesExprHasColumn(pNode)) {
|
if (!nodesExprHasColumn(pNode)) {
|
||||||
code = TSDB_CODE_FUNC_FUNTION_PARA_HAS_COL;
|
code = TSDB_CODE_FUNC_FUNTION_PARA_HAS_COL;
|
||||||
|
@ -781,7 +778,7 @@ static int32_t checkHasColumn(SNode *pNode, bool *isMatch) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkValueNodeNotNull(SNode *pNode, bool *isMatch) {
|
static int32_t checkValueNodeNotNull(SNode* pNode, bool* isMatch) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (IS_NULL_TYPE(getSDataTypeFromNode(pNode)->type) && QUERY_NODE_VALUE == nodeType(pNode)) {
|
if (IS_NULL_TYPE(getSDataTypeFromNode(pNode)->type) && QUERY_NODE_VALUE == nodeType(pNode)) {
|
||||||
code = TSDB_CODE_FUNC_FUNTION_PARA_TYPE;
|
code = TSDB_CODE_FUNC_FUNTION_PARA_TYPE;
|
||||||
|
@ -790,7 +787,7 @@ static int32_t checkValueNodeNotNull(SNode *pNode, bool *isMatch) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkTimeUnit(SNode *pNode, int32_t precision, bool *isMatch) {
|
static int32_t checkTimeUnit(SNode* pNode, int32_t precision, bool* isMatch) {
|
||||||
if (nodeType(pNode) != QUERY_NODE_VALUE || !IS_INTEGER_TYPE(getSDataTypeFromNode(pNode)->type)) {
|
if (nodeType(pNode) != QUERY_NODE_VALUE || !IS_INTEGER_TYPE(getSDataTypeFromNode(pNode)->type)) {
|
||||||
*isMatch = false;
|
*isMatch = false;
|
||||||
return TSDB_CODE_FUNC_FUNTION_PARA_TYPE;
|
return TSDB_CODE_FUNC_FUNTION_PARA_TYPE;
|
||||||
|
@ -808,15 +805,15 @@ static int32_t checkTimeUnit(SNode *pNode, int32_t precision, bool *isMatch) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
static int32_t validateParam(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t validateParam(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SNodeList* paramList = pFunc->pParameterList;
|
SNodeList* paramList = pFunc->pParameterList;
|
||||||
char errMsg[128] = {0};
|
char errMsg[128] = {0};
|
||||||
|
|
||||||
// no need to check
|
// no need to check
|
||||||
if (funcMgtBuiltins[pFunc->funcId].parameters.paramInfoPattern == 0) {
|
if (funcMgtBuiltins[pFunc->funcId].parameters.paramInfoPattern == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check param num
|
// check param num
|
||||||
if ((funcMgtBuiltins[pFunc->funcId].parameters.maxParamNum != -1 &&
|
if ((funcMgtBuiltins[pFunc->funcId].parameters.maxParamNum != -1 &&
|
||||||
LIST_LENGTH(paramList) > funcMgtBuiltins[pFunc->funcId].parameters.maxParamNum) ||
|
LIST_LENGTH(paramList) > funcMgtBuiltins[pFunc->funcId].parameters.maxParamNum) ||
|
||||||
|
@ -831,7 +828,8 @@ static int32_t validateParam(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
const SParamInfo* paramPattern = funcMgtBuiltins[pFunc->funcId].parameters.inputParaInfo[i];
|
const SParamInfo* paramPattern = funcMgtBuiltins[pFunc->funcId].parameters.inputParaInfo[i];
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
for (int8_t j = paramPattern[paramIdx].startParam; j <= (paramPattern[paramIdx].endParam == -1 ? INT8_MAX : paramPattern[paramIdx].endParam); j++) {
|
for (int8_t j = paramPattern[paramIdx].startParam;
|
||||||
|
j <= (paramPattern[paramIdx].endParam == -1 ? INT8_MAX : paramPattern[paramIdx].endParam); j++) {
|
||||||
if (j > LIST_LENGTH(paramList)) {
|
if (j > LIST_LENGTH(paramList)) {
|
||||||
code = TSDB_CODE_SUCCESS;
|
code = TSDB_CODE_SUCCESS;
|
||||||
isMatch = true;
|
isMatch = true;
|
||||||
|
@ -915,8 +913,8 @@ static int32_t validateParam(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_RANGE, "Invalid parameter range : %s",
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_RANGE, "Invalid parameter range : %s",
|
||||||
pFunc->functionName);
|
pFunc->functionName);
|
||||||
case TSDB_CODE_FUNC_FUNTION_PARA_PRIMTS:
|
case TSDB_CODE_FUNC_FUNTION_PARA_PRIMTS:
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_PRIMTS, "Parameter should be primary timestamp : %s",
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_PRIMTS,
|
||||||
pFunc->functionName);
|
"Parameter should be primary timestamp : %s", pFunc->functionName);
|
||||||
case TSDB_CODE_FUNC_FUNTION_PARA_PK:
|
case TSDB_CODE_FUNC_FUNTION_PARA_PK:
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_PK, "Parameter should be primary key : %s",
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_PK, "Parameter should be primary key : %s",
|
||||||
pFunc->functionName);
|
pFunc->functionName);
|
||||||
|
@ -928,7 +926,7 @@ static int32_t validateParam(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
pFunc->functionName);
|
pFunc->functionName);
|
||||||
case TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL:
|
case TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL:
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL, "Time unit is too small : %s",
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL, "Time unit is too small : %s",
|
||||||
pFunc->functionName);
|
pFunc->functionName);
|
||||||
case TSDB_CODE_FUNC_FUNCTION_HISTO_TYPE:
|
case TSDB_CODE_FUNC_FUNCTION_HISTO_TYPE:
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNCTION_HISTO_TYPE, "Invalid histogram bin type : %s",
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNCTION_HISTO_TYPE, "Invalid histogram bin type : %s",
|
||||||
pFunc->functionName);
|
pFunc->functionName);
|
||||||
|
@ -956,8 +954,8 @@ static int32_t translateMinMax(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
||||||
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
||||||
|
|
||||||
SDataType* dataType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0));
|
SDataType* dataType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0));
|
||||||
uint8_t paraType = IS_NULL_TYPE(dataType->type) ? TSDB_DATA_TYPE_BIGINT : dataType->type;
|
uint8_t paraType = IS_NULL_TYPE(dataType->type) ? TSDB_DATA_TYPE_BIGINT : dataType->type;
|
||||||
int32_t bytes = IS_STR_DATA_TYPE(paraType) ? dataType->bytes : tDataTypes[paraType].bytes;
|
int32_t bytes = IS_STR_DATA_TYPE(paraType) ? dataType->bytes : tDataTypes[paraType].bytes;
|
||||||
pFunc->node.resType = (SDataType){.bytes = bytes, .type = paraType};
|
pFunc->node.resType = (SDataType){.bytes = bytes, .type = paraType};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -969,7 +967,6 @@ static int32_t translateOutDouble(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t translateTrimStr(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isLtrim) {
|
static int32_t translateTrimStr(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isLtrim) {
|
||||||
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
||||||
|
|
||||||
|
@ -1024,7 +1021,8 @@ static int32_t translateSum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
|
||||||
static int32_t translateWduration(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateWduration(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
// pseudo column do not need to check parameters
|
// pseudo column do not need to check parameters
|
||||||
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT,
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes,
|
||||||
|
.type = TSDB_DATA_TYPE_BIGINT,
|
||||||
.precision = pFunc->node.resType.precision};
|
.precision = pFunc->node.resType.precision};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1054,8 +1052,7 @@ static int32_t translateRand(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType =
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE};
|
||||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE};
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1069,9 +1066,9 @@ static int32_t translateOutFirstIn(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
||||||
static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
// pseudo column do not need to check parameters
|
// pseudo column do not need to check parameters
|
||||||
|
|
||||||
pFunc->node.resType =
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes,
|
||||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP,
|
.type = TSDB_DATA_TYPE_TIMESTAMP,
|
||||||
.precision = pFunc->node.resType.precision};
|
.precision = pFunc->node.resType.precision};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1101,7 +1098,6 @@ static int32_t translateVgIdColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t reserveFirstMergeParam(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters) {
|
static int32_t reserveFirstMergeParam(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters) {
|
||||||
int32_t code = nodesListMakeAppend(pParameters, pPartialRes);
|
int32_t code = nodesListMakeAppend(pParameters, pPartialRes);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -1130,13 +1126,9 @@ int32_t apercentileCreateMergeParam(SNodeList* pRawParameters, SNode* pPartialRe
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateElapsedPartial(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateElapsedPartial(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t translateElapsedMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateElapsedMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t translateCsum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateCsum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
||||||
|
@ -1164,8 +1156,8 @@ static int32_t translateSampleTail(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
||||||
uint8_t colType = pSDataType->type;
|
uint8_t colType = pSDataType->type;
|
||||||
|
|
||||||
// set result type
|
// set result type
|
||||||
pFunc->node.resType = (SDataType){.bytes = IS_STR_DATA_TYPE(colType) ? pSDataType->bytes : tDataTypes[colType].bytes,
|
pFunc->node.resType =
|
||||||
.type = colType};
|
(SDataType){.bytes = IS_STR_DATA_TYPE(colType) ? pSDataType->bytes : tDataTypes[colType].bytes, .type = colType};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1264,7 +1256,7 @@ static EFuncReturnRows diffEstReturnRows(SFunctionNode* pFunc) {
|
||||||
return FUNC_RETURN_ROWS_N_MINUS_1;
|
return FUNC_RETURN_ROWS_N_MINUS_1;
|
||||||
}
|
}
|
||||||
return 1 < ((SValueNode*)nodesListGetNode(pFunc->pParameterList, 1))->datum.i ? FUNC_RETURN_ROWS_INDEFINITE
|
return 1 < ((SValueNode*)nodesListGetNode(pFunc->pParameterList, 1))->datum.i ? FUNC_RETURN_ROWS_INDEFINITE
|
||||||
: FUNC_RETURN_ROWS_N_MINUS_1;
|
: FUNC_RETURN_ROWS_N_MINUS_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, int32_t minParaNum,
|
static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, int32_t minParaNum,
|
||||||
|
@ -1331,14 +1323,14 @@ static int32_t translateChar(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
|
||||||
static int32_t translateAscii(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateAscii(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
||||||
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_UTINYINT].bytes, .type = TSDB_DATA_TYPE_UTINYINT};
|
pFunc->node.resType =
|
||||||
|
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_UTINYINT].bytes, .type = TSDB_DATA_TYPE_UTINYINT};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateTrim(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateTrim(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
||||||
|
|
||||||
|
|
||||||
uint8_t para0Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
uint8_t para0Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||||
int32_t resLen = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->bytes;
|
int32_t resLen = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->bytes;
|
||||||
uint8_t type = para0Type;
|
uint8_t type = para0Type;
|
||||||
|
@ -1408,7 +1400,7 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
// The number of parameters has been limited by the syntax definition
|
// The number of parameters has been limited by the syntax definition
|
||||||
|
|
||||||
SExprNode* pPara0 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
SExprNode* pPara0 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
uint8_t para0Type = pPara0->resType.type;
|
uint8_t para0Type = pPara0->resType.type;
|
||||||
if (TSDB_DATA_TYPE_VARBINARY == para0Type) {
|
if (TSDB_DATA_TYPE_VARBINARY == para0Type) {
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
@ -1425,7 +1417,7 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
if (TSDB_DATA_TYPE_NCHAR == para2Type) {
|
if (TSDB_DATA_TYPE_NCHAR == para2Type) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"CAST function converted length should be in range (0, %d] NCHARS",
|
"CAST function converted length should be in range (0, %d] NCHARS",
|
||||||
(TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE);
|
(TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE);
|
||||||
} else {
|
} else {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"CAST function converted length should be in range (0, %d] bytes",
|
"CAST function converted length should be in range (0, %d] bytes",
|
||||||
|
@ -1529,8 +1521,7 @@ static int32_t translateAddPrecOutBigint(SFunctionNode* pFunc, char* pErrBuf, in
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType =
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1582,6 +1573,10 @@ static bool getBlockDistFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv
|
||||||
pEnv->calcMemSize = sizeof(STableBlockDistInfo);
|
pEnv->calcMemSize = sizeof(STableBlockDistInfo);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
static bool getBlockDBUsageFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
||||||
|
pEnv->calcMemSize = sizeof(SDBBlockUsageInfo);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateGroupKey(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateGroupKey(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||||
|
@ -1591,7 +1586,6 @@ static int32_t translateGroupKey(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t translateServerStatusFunc(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateServerStatusFunc(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes, .type = TSDB_DATA_TYPE_INT};
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes, .type = TSDB_DATA_TYPE_INT};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1674,12 +1668,17 @@ static int32_t translateOutVarchar(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
||||||
case FUNCTION_TYPE_FIRST_STATE:
|
case FUNCTION_TYPE_FIRST_STATE:
|
||||||
case FUNCTION_TYPE_LAST_STATE:
|
case FUNCTION_TYPE_LAST_STATE:
|
||||||
bytes = getFirstLastInfoSize(getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->bytes,
|
bytes = getFirstLastInfoSize(getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->bytes,
|
||||||
(pFunc->hasPk) ? pFunc->pkBytes : 0) + VARSTR_HEADER_SIZE;
|
(pFunc->hasPk) ? pFunc->pkBytes : 0) +
|
||||||
|
VARSTR_HEADER_SIZE;
|
||||||
break;
|
break;
|
||||||
case FUNCTION_TYPE_FIRST_STATE_MERGE:
|
case FUNCTION_TYPE_FIRST_STATE_MERGE:
|
||||||
case FUNCTION_TYPE_LAST_STATE_MERGE:
|
case FUNCTION_TYPE_LAST_STATE_MERGE:
|
||||||
bytes = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->bytes;
|
bytes = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->bytes;
|
||||||
break;
|
break;
|
||||||
|
case FUNCTION_TYPE_DB_USAGE:
|
||||||
|
case FUNCTION_TYPE_DB_USAGE_INFO:
|
||||||
|
bytes = 128;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -1691,8 +1690,8 @@ static int32_t translateOutVarchar(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
||||||
static int32_t translateHistogramImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateHistogramImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len));
|
||||||
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
|
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
|
||||||
int8_t binType;
|
int8_t binType;
|
||||||
char* binDesc;
|
char* binDesc;
|
||||||
for (int32_t i = 1; i < numOfParams; ++i) {
|
for (int32_t i = 1; i < numOfParams; ++i) {
|
||||||
SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, i);
|
SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, i);
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
|
@ -5610,6 +5609,30 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.sprocessFunc = NULL,
|
.sprocessFunc = NULL,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "_db_usage",
|
||||||
|
.type = FUNCTION_TYPE_DB_USAGE,
|
||||||
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||||
|
.parameters = {.minParamNum = 0,
|
||||||
|
.maxParamNum = 0,
|
||||||
|
.paramInfoPattern = 0,
|
||||||
|
.outputParaInfo = {.validDataType = FUNC_PARAM_SUPPORT_VARCHAR_TYPE}},
|
||||||
|
.translateFunc = translateOutVarchar,
|
||||||
|
.getEnvFunc = getBlockDBUsageFuncEnv,
|
||||||
|
.initFunc = blockDBUsageSetup,
|
||||||
|
.processFunc = blockDBUsageFunction,
|
||||||
|
.finalizeFunc = blockDBUsageFinalize
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "_db_usage_info",
|
||||||
|
.type = FUNCTION_TYPE_DB_USAGE_INFO,
|
||||||
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_SCAN_PC_FUNC,
|
||||||
|
.parameters = {.minParamNum = 0,
|
||||||
|
.maxParamNum = 0,
|
||||||
|
.paramInfoPattern = 0,
|
||||||
|
.outputParaInfo = {.validDataType = FUNC_PARAM_SUPPORT_VARCHAR_TYPE}},
|
||||||
|
.translateFunc = translateOutVarchar,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,8 @@
|
||||||
#include "thistogram.h"
|
#include "thistogram.h"
|
||||||
#include "tpercentile.h"
|
#include "tpercentile.h"
|
||||||
|
|
||||||
bool ignoreNegative(int8_t ignoreOption){
|
bool ignoreNegative(int8_t ignoreOption) { return (ignoreOption & 0x1) == 0x1; }
|
||||||
return (ignoreOption & 0x1) == 0x1;
|
bool ignoreNull(int8_t ignoreOption) { return (ignoreOption & 0x2) == 0x2; }
|
||||||
}
|
|
||||||
bool ignoreNull(int8_t ignoreOption){
|
|
||||||
return (ignoreOption & 0x2) == 0x2;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
APERCT_ALGO_UNKNOWN = 0,
|
APERCT_ALGO_UNKNOWN = 0,
|
||||||
|
@ -215,7 +211,7 @@ void funcInputUpdate(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t funcInputGetNextRowDescPk(SFuncInputRowIter* pIter, SFuncInputRow* pRow, bool *res) {
|
int32_t funcInputGetNextRowDescPk(SFuncInputRowIter* pIter, SFuncInputRow* pRow, bool* res) {
|
||||||
if (pIter->finalRow) {
|
if (pIter->finalRow) {
|
||||||
if (pIter->hasPrev) {
|
if (pIter->hasPrev) {
|
||||||
pRow->ts = pIter->prevBlockTsEnd;
|
pRow->ts = pIter->prevBlockTsEnd;
|
||||||
|
@ -223,7 +219,7 @@ int32_t funcInputGetNextRowDescPk(SFuncInputRowIter* pIter, SFuncInputRow* pRow,
|
||||||
pRow->pData = pIter->pPrevData;
|
pRow->pData = pIter->pPrevData;
|
||||||
pRow->block = pIter->pPrevRowBlock;
|
pRow->block = pIter->pPrevRowBlock;
|
||||||
pRow->rowIndex = 0;
|
pRow->rowIndex = 0;
|
||||||
|
|
||||||
pIter->hasPrev = false;
|
pIter->hasPrev = false;
|
||||||
*res = true;
|
*res = true;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -312,7 +308,8 @@ int32_t funcInputGetNextRowDescPk(SFuncInputRowIter* pIter, SFuncInputRow* pRow,
|
||||||
qError("out of memory when function get input row.");
|
qError("out of memory when function get input row.");
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
(void)memcpy(pIter->pPrevData, colDataGetData(pIter->pDataCol, pIter->inputEndIndex), pIter->pDataCol->info.bytes);
|
(void)memcpy(pIter->pPrevData, colDataGetData(pIter->pDataCol, pIter->inputEndIndex),
|
||||||
|
pIter->pDataCol->info.bytes);
|
||||||
pIter->pPrevPk = taosMemoryMalloc(pIter->pPkCol->info.bytes);
|
pIter->pPrevPk = taosMemoryMalloc(pIter->pPkCol->info.bytes);
|
||||||
if (NULL == pIter->pPrevPk) {
|
if (NULL == pIter->pPrevPk) {
|
||||||
qError("out of memory when function get input row.");
|
qError("out of memory when function get input row.");
|
||||||
|
@ -341,12 +338,12 @@ static void setInputRowInfo(SFuncInputRow* pRow, SFuncInputRowIter* pIter, int32
|
||||||
pRow->ts = pIter->tsList[rowIndex];
|
pRow->ts = pIter->tsList[rowIndex];
|
||||||
pRow->isDataNull = colDataIsNull_f(pIter->pDataCol->nullbitmap, rowIndex);
|
pRow->isDataNull = colDataIsNull_f(pIter->pDataCol->nullbitmap, rowIndex);
|
||||||
pRow->pData = colDataGetData(pIter->pDataCol, rowIndex);
|
pRow->pData = colDataGetData(pIter->pDataCol, rowIndex);
|
||||||
pRow->pPk = setPk? colDataGetData(pIter->pPkCol, rowIndex):NULL;
|
pRow->pPk = setPk ? colDataGetData(pIter->pPkCol, rowIndex) : NULL;
|
||||||
pRow->block = pIter->pSrcBlock;
|
pRow->block = pIter->pSrcBlock;
|
||||||
pRow->rowIndex = rowIndex;
|
pRow->rowIndex = rowIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool funcInputGetNextRowAscPk(SFuncInputRowIter *pIter, SFuncInputRow* pRow) {
|
bool funcInputGetNextRowAscPk(SFuncInputRowIter* pIter, SFuncInputRow* pRow) {
|
||||||
if (pIter->hasPrev) {
|
if (pIter->hasPrev) {
|
||||||
if (pIter->prevBlockTsEnd == pIter->tsList[pIter->inputEndIndex]) {
|
if (pIter->prevBlockTsEnd == pIter->tsList[pIter->inputEndIndex]) {
|
||||||
pIter->hasPrev = true;
|
pIter->hasPrev = true;
|
||||||
|
@ -363,7 +360,7 @@ bool funcInputGetNextRowAscPk(SFuncInputRowIter *pIter, SFuncInputRow* pRow) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pIter->rowIndex <= pIter->inputEndIndex) {
|
if (pIter->rowIndex <= pIter->inputEndIndex) {
|
||||||
setInputRowInfo(pRow, pIter, pIter->rowIndex, true);
|
setInputRowInfo(pRow, pIter, pIter->rowIndex, true);
|
||||||
|
|
||||||
TSKEY tsEnd = pIter->tsList[pIter->inputEndIndex];
|
TSKEY tsEnd = pIter->tsList[pIter->inputEndIndex];
|
||||||
|
@ -382,17 +379,17 @@ bool funcInputGetNextRowAscPk(SFuncInputRowIter *pIter, SFuncInputRow* pRow) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool funcInputGetNextRowNoPk(SFuncInputRowIter *pIter, SFuncInputRow* pRow) {
|
bool funcInputGetNextRowNoPk(SFuncInputRowIter* pIter, SFuncInputRow* pRow) {
|
||||||
if (pIter->rowIndex <= pIter->inputEndIndex) {
|
if (pIter->rowIndex <= pIter->inputEndIndex) {
|
||||||
setInputRowInfo(pRow, pIter, pIter->rowIndex, false);
|
setInputRowInfo(pRow, pIter, pIter->rowIndex, false);
|
||||||
++pIter->rowIndex;
|
++pIter->rowIndex;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t funcInputGetNextRow(SqlFunctionCtx* pCtx, SFuncInputRow* pRow, bool *res) {
|
int32_t funcInputGetNextRow(SqlFunctionCtx* pCtx, SFuncInputRow* pRow, bool* res) {
|
||||||
SFuncInputRowIter* pIter = &pCtx->rowIter;
|
SFuncInputRowIter* pIter = &pCtx->rowIter;
|
||||||
if (pCtx->hasPrimaryKey) {
|
if (pCtx->hasPrimaryKey) {
|
||||||
if (pCtx->order == TSDB_ORDER_ASC) {
|
if (pCtx->order == TSDB_ORDER_ASC) {
|
||||||
|
@ -448,7 +445,8 @@ int32_t appendSelectivityCols(SqlFunctionCtx* pCtx, SSDataBlock* pSrcBlock, int3
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool funcInputGetNextRowIndex(SInputColumnInfoData* pInput, int32_t from, bool firstOccur, int32_t* pRowIndex, int32_t* nextFrom);
|
bool funcInputGetNextRowIndex(SInputColumnInfoData* pInput, int32_t from, bool firstOccur, int32_t* pRowIndex,
|
||||||
|
int32_t* nextFrom);
|
||||||
|
|
||||||
static bool firstLastTransferInfoImpl(SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst);
|
static bool firstLastTransferInfoImpl(SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst);
|
||||||
|
|
||||||
|
@ -505,7 +503,7 @@ int32_t functionFinalizeWithResultBuf(SqlFunctionCtx* pCtx, SSDataBlock* pBlock,
|
||||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
pResInfo->isNullRes = (pResInfo->numOfRes == 0) ? 1 : 0;
|
pResInfo->isNullRes = (pResInfo->numOfRes == 0) ? 1 : 0;
|
||||||
|
|
||||||
char* in = finalResult;
|
char* in = finalResult;
|
||||||
int32_t code = colDataSetVal(pCol, pBlock->info.rows, in, pResInfo->isNullRes);
|
int32_t code = colDataSetVal(pCol, pBlock->info.rows, in, pResInfo->isNullRes);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -534,7 +532,7 @@ static int64_t getNumOfElems(SqlFunctionCtx* pCtx) {
|
||||||
*/
|
*/
|
||||||
SInputColumnInfoData* pInput = &pCtx->input;
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
if(1 == pInput->numOfRows && pInput->blankFill) {
|
if (1 == pInput->numOfRows && pInput->blankFill) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (pInput->colDataSMAIsSet && pInput->totalRows == pInput->numOfRows) {
|
if (pInput->colDataSMAIsSet && pInput->totalRows == pInput->numOfRows) {
|
||||||
|
@ -918,8 +916,8 @@ int32_t setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STu
|
||||||
|
|
||||||
if ((pCtx->saveHandle.pBuf != NULL && pTuplePos->pageId != -1) ||
|
if ((pCtx->saveHandle.pBuf != NULL && pTuplePos->pageId != -1) ||
|
||||||
(pCtx->saveHandle.pState && pTuplePos->streamTupleKey.ts > 0)) {
|
(pCtx->saveHandle.pState && pTuplePos->streamTupleKey.ts > 0)) {
|
||||||
int32_t numOfCols = pCtx->subsidiaries.num;
|
int32_t numOfCols = pCtx->subsidiaries.num;
|
||||||
char* p = NULL;
|
char* p = NULL;
|
||||||
int32_t code = loadTupleData(pCtx, pTuplePos, &p);
|
int32_t code = loadTupleData(pCtx, pTuplePos, &p);
|
||||||
if (p == NULL || TSDB_CODE_SUCCESS != code) {
|
if (p == NULL || TSDB_CODE_SUCCESS != code) {
|
||||||
qError("Load tuple data failed since %s, groupId:%" PRIu64 ", ts:%" PRId64, terrstr(),
|
qError("Load tuple data failed since %s, groupId:%" PRIu64 ", ts:%" PRId64, terrstr(),
|
||||||
|
@ -1004,7 +1002,7 @@ int32_t appendSelectivityValue(SqlFunctionCtx* pCtx, int32_t rowIndex, int32_t p
|
||||||
|
|
||||||
void replaceTupleData(STuplePos* pDestPos, STuplePos* pSourcePos) { *pDestPos = *pSourcePos; }
|
void replaceTupleData(STuplePos* pDestPos, STuplePos* pSourcePos) { *pDestPos = *pSourcePos; }
|
||||||
|
|
||||||
#define COMPARE_MINMAX_DATA(type) (( (*(type*)&pDBuf->v) < (*(type*)&pSBuf->v) ) ^ isMinFunc)
|
#define COMPARE_MINMAX_DATA(type) (((*(type*)&pDBuf->v) < (*(type*)&pSBuf->v)) ^ isMinFunc)
|
||||||
int32_t minMaxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int32_t isMinFunc) {
|
int32_t minMaxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int32_t isMinFunc) {
|
||||||
SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx);
|
SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx);
|
||||||
SMinmaxResInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo);
|
SMinmaxResInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo);
|
||||||
|
@ -1318,8 +1316,8 @@ int32_t stdFunctionMerge(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) {
|
||||||
if (colDataIsNull_s(pCol, i)) continue;
|
if (colDataIsNull_s(pCol, i)) continue;
|
||||||
char* data = colDataGetData(pCol, i);
|
char* data = colDataGetData(pCol, i);
|
||||||
SStdRes* pInputInfo = (SStdRes*)varDataVal(data);
|
SStdRes* pInputInfo = (SStdRes*)varDataVal(data);
|
||||||
stdTransferInfo(pInputInfo, pInfo);
|
stdTransferInfo(pInputInfo, pInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1805,7 +1803,8 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) {
|
||||||
pResInfo->complete = true;
|
pResInfo->complete = true;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
code = tMemBucketCreate(pCol->info.bytes, type, pInfo->minval, pInfo->maxval, pCtx->hasWindowOrGroup, &pInfo->pMemBucket, pInfo->numOfElems);
|
code = tMemBucketCreate(pCol->info.bytes, type, pInfo->minval, pInfo->maxval, pCtx->hasWindowOrGroup,
|
||||||
|
&pInfo->pMemBucket, pInfo->numOfElems);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1893,8 +1892,9 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
tMemBucket** pMemBucket = &ppInfo->pMemBucket;
|
tMemBucket** pMemBucket = &ppInfo->pMemBucket;
|
||||||
if ((*pMemBucket) != NULL && (*pMemBucket)->total > 0) { // check for null
|
if ((*pMemBucket) != NULL && (*pMemBucket)->total > 0) { // check for null
|
||||||
if (pCtx->numOfParams > 2) {
|
if (pCtx->numOfParams > 2) {
|
||||||
char buf[3200] = {0};
|
char buf[3200] = {0};
|
||||||
// max length of double num is 317, e.g. use %.6lf to print -1.0e+308, consider the comma and bracket, 3200 is enough.
|
// max length of double num is 317, e.g. use %.6lf to print -1.0e+308, consider the comma and bracket, 3200 is
|
||||||
|
// enough.
|
||||||
size_t len = 1;
|
size_t len = 1;
|
||||||
|
|
||||||
varDataVal(buf)[0] = '[';
|
varDataVal(buf)[0] = '[';
|
||||||
|
@ -2139,7 +2139,7 @@ static int32_t apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInf
|
||||||
pHisto->numOfEntries, pInput->pHisto);
|
pHisto->numOfEntries, pInput->pHisto);
|
||||||
|
|
||||||
SHistogramInfo* pRes = NULL;
|
SHistogramInfo* pRes = NULL;
|
||||||
int32_t code = tHistogramMerge(pHisto, pInput->pHisto, MAX_HISTOGRAM_BIN, &pRes);
|
int32_t code = tHistogramMerge(pHisto, pInput->pHisto, MAX_HISTOGRAM_BIN, &pRes);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
tHistogramDestroy(&pRes);
|
tHistogramDestroy(&pRes);
|
||||||
return code;
|
return code;
|
||||||
|
@ -2169,13 +2169,13 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
qDebug("%s total %" PRId64 " rows will merge, %p", __FUNCTION__, pInput->numOfRows, pInfo->pHisto);
|
qDebug("%s total %" PRId64 " rows will merge, %p", __FUNCTION__, pInput->numOfRows, pInfo->pHisto);
|
||||||
|
|
||||||
bool hasRes = false;
|
bool hasRes = false;
|
||||||
int32_t start = pInput->startRowIndex;
|
int32_t start = pInput->startRowIndex;
|
||||||
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
||||||
char* data = colDataGetData(pCol, i);
|
char* data = colDataGetData(pCol, i);
|
||||||
|
|
||||||
SAPercentileInfo* pInputInfo = (SAPercentileInfo*)varDataVal(data);
|
SAPercentileInfo* pInputInfo = (SAPercentileInfo*)varDataVal(data);
|
||||||
int32_t code = apercentileTransferInfo(pInputInfo, pInfo, &hasRes);
|
int32_t code = apercentileTransferInfo(pInputInfo, pInfo, &hasRes);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2299,7 +2299,7 @@ static int32_t comparePkDataWithSValue(int8_t pkType, char* pkData, SValue* pVal
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
char* blockData = (IS_NUMERIC_TYPE(pkType)) ? (char*) numVal : (char*)pVal->pData;
|
char* blockData = (IS_NUMERIC_TYPE(pkType)) ? (char*)numVal : (char*)pVal->pData;
|
||||||
__compar_fn_t fn = getKeyComparFunc(pkType, order);
|
__compar_fn_t fn = getKeyComparFunc(pkType, order);
|
||||||
return fn(pkData, blockData);
|
return fn(pkData, blockData);
|
||||||
}
|
}
|
||||||
|
@ -2318,7 +2318,7 @@ EFuncDataRequired firstDynDataReq(void* pRes, SDataBlockInfo* pBlockInfo) {
|
||||||
pResult->pkData = pResult->buf + pResult->bytes;
|
pResult->pkData = pResult->buf + pResult->bytes;
|
||||||
} else {
|
} else {
|
||||||
pResult->pkData = NULL;
|
pResult->pkData = NULL;
|
||||||
}
|
}
|
||||||
if (pResult->ts < pBlockInfo->window.skey) {
|
if (pResult->ts < pBlockInfo->window.skey) {
|
||||||
return FUNC_DATA_REQUIRED_NOT_LOAD;
|
return FUNC_DATA_REQUIRED_NOT_LOAD;
|
||||||
} else if (pResult->ts == pBlockInfo->window.skey) {
|
} else if (pResult->ts == pBlockInfo->window.skey) {
|
||||||
|
@ -2363,12 +2363,12 @@ EFuncDataRequired lastDynDataReq(void* pRes, SDataBlockInfo* pBlockInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO modify it to include primary key bytes
|
// TODO modify it to include primary key bytes
|
||||||
int32_t getFirstLastInfoSize(int32_t resBytes, int32_t pkBytes) { return sizeof(SFirstLastRes) + resBytes + pkBytes; }
|
int32_t getFirstLastInfoSize(int32_t resBytes, int32_t pkBytes) { return sizeof(SFirstLastRes) + resBytes + pkBytes; }
|
||||||
|
|
||||||
bool getFirstLastFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
bool getFirstLastFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
||||||
SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
//TODO: change SFunctionNode to add pk info
|
// TODO: change SFunctionNode to add pk info
|
||||||
int32_t pkBytes = (pFunc->hasPk) ? pFunc->pkBytes : 0;
|
int32_t pkBytes = (pFunc->hasPk) ? pFunc->pkBytes : 0;
|
||||||
pEnv->calcMemSize = getFirstLastInfoSize(pNode->node.resType.bytes, pkBytes);
|
pEnv->calcMemSize = getFirstLastInfoSize(pNode->node.resType.bytes, pkBytes);
|
||||||
return true;
|
return true;
|
||||||
|
@ -2402,7 +2402,7 @@ int32_t firstLastFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResIn
|
||||||
return TSDB_CODE_FUNC_SETUP_ERROR;
|
return TSDB_CODE_FUNC_SETUP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
SFirstLastRes * pRes = GET_ROWCELL_INTERBUF(pResInfo);
|
SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
SInputColumnInfoData* pInput = &pCtx->input;
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
|
|
||||||
pRes->nullTupleSaved = false;
|
pRes->nullTupleSaved = false;
|
||||||
|
@ -2444,7 +2444,8 @@ static int32_t firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowI
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doSaveCurrentVal(SqlFunctionCtx* pCtx, int32_t rowIndex, int64_t currentTs, char* pkData, int32_t type, char* pData) {
|
static int32_t doSaveCurrentVal(SqlFunctionCtx* pCtx, int32_t rowIndex, int64_t currentTs, char* pkData, int32_t type,
|
||||||
|
char* pData) {
|
||||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
SFirstLastRes* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
SFirstLastRes* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
|
@ -2490,7 +2491,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
||||||
pInfo->pkType = -1;
|
pInfo->pkType = -1;
|
||||||
__compar_fn_t pkCompareFn = NULL;
|
__compar_fn_t pkCompareFn = NULL;
|
||||||
if (pCtx->hasPrimaryKey) {
|
if (pCtx->hasPrimaryKey) {
|
||||||
pInfo->pkType = pkCol->info.type;
|
pInfo->pkType = pkCol->info.type;
|
||||||
pInfo->pkBytes = pkCol->info.bytes;
|
pInfo->pkBytes = pkCol->info.bytes;
|
||||||
|
@ -2569,7 +2570,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
||||||
#else
|
#else
|
||||||
int64_t* pts = (int64_t*)pInput->pPTS->pData;
|
int64_t* pts = (int64_t*)pInput->pPTS->pData;
|
||||||
|
|
||||||
int from = -1;
|
int from = -1;
|
||||||
int32_t i = -1;
|
int32_t i = -1;
|
||||||
while (funcInputGetNextRowIndex(pInput, from, true, &i, &from)) {
|
while (funcInputGetNextRowIndex(pInput, from, true, &i, &from)) {
|
||||||
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
||||||
|
@ -2583,8 +2584,8 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
||||||
pkData = colDataGetData(pkCol, i);
|
pkData = colDataGetData(pkCol, i);
|
||||||
}
|
}
|
||||||
TSKEY cts = pts[i];
|
TSKEY cts = pts[i];
|
||||||
if (pResInfo->numOfRes == 0 || pInfo->ts > cts ||
|
if (pResInfo->numOfRes == 0 || pInfo->ts > cts ||
|
||||||
(pInfo->ts == cts && pkCompareFn && pkCompareFn(pkData, pInfo->pkData) < 0)) {
|
(pInfo->ts == cts && pkCompareFn && pkCompareFn(pkData, pInfo->pkData) < 0)) {
|
||||||
int32_t code = doSaveCurrentVal(pCtx, i, cts, pkData, pInputCol->info.type, data);
|
int32_t code = doSaveCurrentVal(pCtx, i, cts, pkData, pInputCol->info.type, data);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -2625,7 +2626,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
||||||
pInfo->pkType = -1;
|
pInfo->pkType = -1;
|
||||||
__compar_fn_t pkCompareFn = NULL;
|
__compar_fn_t pkCompareFn = NULL;
|
||||||
if (pCtx->hasPrimaryKey) {
|
if (pCtx->hasPrimaryKey) {
|
||||||
pInfo->pkType = pkCol->info.type;
|
pInfo->pkType = pkCol->info.type;
|
||||||
pInfo->pkBytes = pkCol->info.bytes;
|
pInfo->pkBytes = pkCol->info.bytes;
|
||||||
|
@ -2703,7 +2704,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// todo refactor
|
// todo refactor
|
||||||
if (!pInputCol->hasNull && !pCtx->hasPrimaryKey) {
|
if (!pInputCol->hasNull && !pCtx->hasPrimaryKey) {
|
||||||
numOfElems = 1;
|
numOfElems = 1;
|
||||||
|
|
||||||
|
@ -2750,7 +2751,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int from = -1;
|
int from = -1;
|
||||||
int32_t i = -1;
|
int32_t i = -1;
|
||||||
while (funcInputGetNextRowIndex(pInput, from, false, &i, &from)) {
|
while (funcInputGetNextRowIndex(pInput, from, false, &i, &from)) {
|
||||||
if (colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
if (colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
||||||
|
@ -2976,8 +2977,7 @@ int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
||||||
static int32_t doSaveLastrow(SqlFunctionCtx* pCtx, char* pData, int32_t rowIndex, int64_t cts, SFirstLastRes* pInfo) {
|
static int32_t doSaveLastrow(SqlFunctionCtx* pCtx, char* pData, int32_t rowIndex, int64_t cts, SFirstLastRes* pInfo) {
|
||||||
SInputColumnInfoData* pInput = &pCtx->input;
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
||||||
|
|
||||||
|
|
||||||
if (colDataIsNull_s(pInputCol, rowIndex)) {
|
if (colDataIsNull_s(pInputCol, rowIndex)) {
|
||||||
pInfo->isNull = true;
|
pInfo->isNull = true;
|
||||||
|
@ -3028,7 +3028,7 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
||||||
pInfo->pkType = -1;
|
pInfo->pkType = -1;
|
||||||
__compar_fn_t pkCompareFn = NULL;
|
__compar_fn_t pkCompareFn = NULL;
|
||||||
if (pCtx->hasPrimaryKey) {
|
if (pCtx->hasPrimaryKey) {
|
||||||
pInfo->pkType = pkCol->info.type;
|
pInfo->pkType = pkCol->info.type;
|
||||||
pInfo->pkBytes = pkCol->info.bytes;
|
pInfo->pkBytes = pkCol->info.bytes;
|
||||||
|
@ -3068,8 +3068,8 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int64_t* pts = (int64_t*)pInput->pPTS->pData;
|
int64_t* pts = (int64_t*)pInput->pPTS->pData;
|
||||||
int from = -1;
|
int from = -1;
|
||||||
int32_t i = -1;
|
int32_t i = -1;
|
||||||
while (funcInputGetNextRowIndex(pInput, from, false, &i, &from)) {
|
while (funcInputGetNextRowIndex(pInput, from, false, &i, &from)) {
|
||||||
bool isNull = colDataIsNull(pInputCol, pInput->numOfRows, i, NULL);
|
bool isNull = colDataIsNull(pInputCol, pInput->numOfRows, i, NULL);
|
||||||
char* data = isNull ? NULL : colDataGetData(pInputCol, i);
|
char* data = isNull ? NULL : colDataGetData(pInputCol, i);
|
||||||
|
@ -3089,7 +3089,6 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
|
||||||
pResInfo->numOfRes = 1;
|
pResInfo->numOfRes = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_VAL(pResInfo, numOfElems, 1);
|
SET_VAL(pResInfo, numOfElems, 1);
|
||||||
|
@ -3187,7 +3186,7 @@ static bool diffIsNegtive(SDiffInfo* pDiffInfo, int32_t type, const char* pv) {
|
||||||
int64_t v = *(int16_t*)pv;
|
int64_t v = *(int16_t*)pv;
|
||||||
return v < pDiffInfo->prev.i64;
|
return v < pDiffInfo->prev.i64;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UBIGINT:{
|
case TSDB_DATA_TYPE_UBIGINT: {
|
||||||
uint64_t v = *(uint64_t*)pv;
|
uint64_t v = *(uint64_t*)pv;
|
||||||
return v < (uint64_t)pDiffInfo->prev.i64;
|
return v < (uint64_t)pDiffInfo->prev.i64;
|
||||||
}
|
}
|
||||||
|
@ -3213,7 +3212,7 @@ static bool diffIsNegtive(SDiffInfo* pDiffInfo, int32_t type, const char* pv) {
|
||||||
|
|
||||||
static void tryToSetInt64(SDiffInfo* pDiffInfo, int32_t type, SColumnInfoData* pOutput, int64_t v, int32_t pos) {
|
static void tryToSetInt64(SDiffInfo* pDiffInfo, int32_t type, SColumnInfoData* pOutput, int64_t v, int32_t pos) {
|
||||||
bool isNegative = v < pDiffInfo->prev.i64;
|
bool isNegative = v < pDiffInfo->prev.i64;
|
||||||
if(type == TSDB_DATA_TYPE_UBIGINT){
|
if (type == TSDB_DATA_TYPE_UBIGINT) {
|
||||||
isNegative = (uint64_t)v < (uint64_t)pDiffInfo->prev.i64;
|
isNegative = (uint64_t)v < (uint64_t)pDiffInfo->prev.i64;
|
||||||
}
|
}
|
||||||
int64_t delta = v - pDiffInfo->prev.i64;
|
int64_t delta = v - pDiffInfo->prev.i64;
|
||||||
|
@ -3269,7 +3268,7 @@ static int32_t doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv,
|
||||||
tryToSetInt64(pDiffInfo, type, pOutput, v, pos);
|
tryToSetInt64(pDiffInfo, type, pOutput, v, pos);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_USMALLINT:{
|
case TSDB_DATA_TYPE_USMALLINT: {
|
||||||
int64_t v = *(uint16_t*)pv;
|
int64_t v = *(uint16_t*)pv;
|
||||||
tryToSetInt64(pDiffInfo, type, pOutput, v, pos);
|
tryToSetInt64(pDiffInfo, type, pOutput, v, pos);
|
||||||
break;
|
break;
|
||||||
|
@ -3303,9 +3302,10 @@ static int32_t doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv,
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: the primary key compare can be skipped for ordered pk if knonwn before
|
// TODO: the primary key compare can be skipped for ordered pk if knonwn before
|
||||||
//TODO: for desc ordered, pk shall select the smallest one for one ts. if across block boundaries.
|
// TODO: for desc ordered, pk shall select the smallest one for one ts. if across block boundaries.
|
||||||
bool funcInputGetNextRowIndex(SInputColumnInfoData* pInput, int32_t from, bool firstOccur, int32_t* pRowIndex, int32_t* nextFrom) {
|
bool funcInputGetNextRowIndex(SInputColumnInfoData* pInput, int32_t from, bool firstOccur, int32_t* pRowIndex,
|
||||||
|
int32_t* nextFrom) {
|
||||||
if (pInput->pPrimaryKey == NULL) {
|
if (pInput->pPrimaryKey == NULL) {
|
||||||
if (from == -1) {
|
if (from == -1) {
|
||||||
from = pInput->startRowIndex;
|
from = pInput->startRowIndex;
|
||||||
|
@ -3321,16 +3321,16 @@ bool funcInputGetNextRowIndex(SInputColumnInfoData* pInput, int32_t from, bool f
|
||||||
} else if (from >= pInput->numOfRows + pInput->startRowIndex) {
|
} else if (from >= pInput->numOfRows + pInput->startRowIndex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TSKEY* tsList = (int64_t*)pInput->pPTS->pData;
|
TSKEY* tsList = (int64_t*)pInput->pPTS->pData;
|
||||||
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
||||||
int8_t pkType = pkCol->info.type;
|
int8_t pkType = pkCol->info.type;
|
||||||
int32_t order = (firstOccur) ? TSDB_ORDER_ASC: TSDB_ORDER_DESC;
|
int32_t order = (firstOccur) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||||
__compar_fn_t compareFunc = getKeyComparFunc(pkType, order);
|
__compar_fn_t compareFunc = getKeyComparFunc(pkType, order);
|
||||||
int32_t select = from;
|
int32_t select = from;
|
||||||
char* val = colDataGetData(pkCol, select);
|
char* val = colDataGetData(pkCol, select);
|
||||||
while (from < pInput->numOfRows + pInput->startRowIndex - 1 && tsList[from + 1] == tsList[from]) {
|
while (from < pInput->numOfRows + pInput->startRowIndex - 1 && tsList[from + 1] == tsList[from]) {
|
||||||
char* val1 = colDataGetData(pkCol, from + 1);
|
char* val1 = colDataGetData(pkCol, from + 1);
|
||||||
if (compareFunc(val1, val) < 0) {
|
if (compareFunc(val1, val) < 0) {
|
||||||
select = from + 1;
|
select = from + 1;
|
||||||
val = val1;
|
val = val1;
|
||||||
}
|
}
|
||||||
|
@ -3347,13 +3347,13 @@ bool getForecastConfEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t diffResultIsNull(SqlFunctionCtx* pCtx, SFuncInputRow* pRow){
|
int32_t diffResultIsNull(SqlFunctionCtx* pCtx, SFuncInputRow* pRow) {
|
||||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
SDiffInfo* pDiffInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
SDiffInfo* pDiffInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
if (pRow->isDataNull || !pDiffInfo->hasPrev ) {
|
if (pRow->isDataNull || !pDiffInfo->hasPrev) {
|
||||||
return true;
|
return true;
|
||||||
} else if (ignoreNegative(pDiffInfo->ignoreOption)){
|
} else if (ignoreNegative(pDiffInfo->ignoreOption)) {
|
||||||
return diffIsNegtive(pDiffInfo, pCtx->input.pData[0]->info.type, pRow->pData);
|
return diffIsNegtive(pDiffInfo, pCtx->input.pData[0]->info.type, pRow->pData);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -3377,7 +3377,7 @@ int32_t trySetPreVal(SqlFunctionCtx* pCtx, SFuncInputRow* pRow) {
|
||||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
int8_t inputType = pInputCol->info.type;
|
int8_t inputType = pInputCol->info.type;
|
||||||
|
|
||||||
char* pv = pRow->pData;
|
char* pv = pRow->pData;
|
||||||
return doSetPrevVal(pDiffInfo, inputType, pv, pRow->ts);
|
return doSetPrevVal(pDiffInfo, inputType, pv, pRow->ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3424,19 +3424,17 @@ int32_t setDoDiffResult(SqlFunctionCtx* pCtx, SFuncInputRow* pRow, int32_t pos)
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t diffFunction(SqlFunctionCtx* pCtx) {
|
int32_t diffFunction(SqlFunctionCtx* pCtx) { return TSDB_CODE_SUCCESS; }
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t diffFunctionByRow(SArray* pCtxArray) {
|
int32_t diffFunctionByRow(SArray* pCtxArray) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int diffColNum = pCtxArray->size;
|
int diffColNum = pCtxArray->size;
|
||||||
if(diffColNum == 0) {
|
if (diffColNum == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
int32_t numOfElems = 0;
|
int32_t numOfElems = 0;
|
||||||
|
|
||||||
SArray* pRows = taosArrayInit_s(sizeof(SFuncInputRow), diffColNum);
|
SArray* pRows = taosArrayInit_s(sizeof(SFuncInputRow), diffColNum);
|
||||||
if (NULL == pRows) {
|
if (NULL == pRows) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -3457,7 +3455,7 @@ int32_t diffFunctionByRow(SArray* pCtxArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SqlFunctionCtx* pCtx0 = *(SqlFunctionCtx**)taosArrayGet(pCtxArray, 0);
|
SqlFunctionCtx* pCtx0 = *(SqlFunctionCtx**)taosArrayGet(pCtxArray, 0);
|
||||||
SFuncInputRow* pRow0 = (SFuncInputRow*)taosArrayGet(pRows, 0);
|
SFuncInputRow* pRow0 = (SFuncInputRow*)taosArrayGet(pRows, 0);
|
||||||
if (NULL == pCtx0 || NULL == pRow0) {
|
if (NULL == pCtx0 || NULL == pRow0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -3475,7 +3473,7 @@ int32_t diffFunctionByRow(SArray* pCtxArray) {
|
||||||
bool hasNotNullValue = !diffResultIsNull(pCtx0, pRow0);
|
bool hasNotNullValue = !diffResultIsNull(pCtx0, pRow0);
|
||||||
for (int i = 1; i < diffColNum; ++i) {
|
for (int i = 1; i < diffColNum; ++i) {
|
||||||
SqlFunctionCtx* pCtx = *(SqlFunctionCtx**)taosArrayGet(pCtxArray, i);
|
SqlFunctionCtx* pCtx = *(SqlFunctionCtx**)taosArrayGet(pCtxArray, i);
|
||||||
SFuncInputRow* pRow = (SFuncInputRow*)taosArrayGet(pRows, i);
|
SFuncInputRow* pRow = (SFuncInputRow*)taosArrayGet(pRows, i);
|
||||||
if (NULL == pCtx || NULL == pRow) {
|
if (NULL == pCtx || NULL == pRow) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -3503,7 +3501,7 @@ int32_t diffFunctionByRow(SArray* pCtxArray) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
if ((keepNull || hasNotNullValue) && !isFirstRow(pCtx, pRow)){
|
if ((keepNull || hasNotNullValue) && !isFirstRow(pCtx, pRow)) {
|
||||||
code = setDoDiffResult(pCtx, pRow, pos);
|
code = setDoDiffResult(pCtx, pRow, pos);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -3513,14 +3511,14 @@ int32_t diffFunctionByRow(SArray* pCtxArray) {
|
||||||
code = trySetPreVal(pCtx, pRow);
|
code = trySetPreVal(pCtx, pRow);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newRow) ++numOfElems;
|
if (newRow) ++numOfElems;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < diffColNum; ++i) {
|
for (int i = 0; i < diffColNum; ++i) {
|
||||||
SqlFunctionCtx* pCtx = *(SqlFunctionCtx**)taosArrayGet(pCtxArray, i);
|
SqlFunctionCtx* pCtx = *(SqlFunctionCtx**)taosArrayGet(pCtxArray, i);
|
||||||
if (NULL == pCtx) {
|
if (NULL == pCtx) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -3737,7 +3735,7 @@ int32_t doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSD
|
||||||
qDebug("page_copyTuple pageId:%d, offset:%d", pItem->tuplePos.pageId, pItem->tuplePos.offset);
|
qDebug("page_copyTuple pageId:%d, offset:%d", pItem->tuplePos.pageId, pItem->tuplePos.offset);
|
||||||
#endif
|
#endif
|
||||||
code = taosheapadjust((void*)pItems, sizeof(STopBotResItem), 0, pEntryInfo->numOfRes - 1, (const void*)&type,
|
code = taosheapadjust((void*)pItems, sizeof(STopBotResItem), 0, pEntryInfo->numOfRes - 1, (const void*)&type,
|
||||||
topBotResComparFn, NULL, !isTopQuery);
|
topBotResComparFn, NULL, !isTopQuery);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -3754,7 +3752,7 @@ int32_t doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSD
|
||||||
* +------------------------------------+--------------+--------------+
|
* +------------------------------------+--------------+--------------+
|
||||||
*/
|
*/
|
||||||
int32_t serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsidiaryResInfo* pSubsidiaryies,
|
int32_t serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsidiaryResInfo* pSubsidiaryies,
|
||||||
char* buf, char** res) {
|
char* buf, char** res) {
|
||||||
char* nullList = buf;
|
char* nullList = buf;
|
||||||
char* pStart = (char*)(nullList + sizeof(bool) * pSubsidiaryies->num);
|
char* pStart = (char*)(nullList + sizeof(bool) * pSubsidiaryies->num);
|
||||||
|
|
||||||
|
@ -3828,7 +3826,7 @@ static int32_t doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf,
|
||||||
pPage->num += length;
|
pPage->num += length;
|
||||||
setBufPageDirty(pPage, true);
|
setBufPageDirty(pPage, true);
|
||||||
releaseBufPage(pHandle->pBuf, pPage);
|
releaseBufPage(pHandle->pBuf, pPage);
|
||||||
} else { // other tuple save policy
|
} else { // other tuple save policy
|
||||||
if (pStore->streamStateFuncPut(pHandle->pState, key, pBuf, length) >= 0) {
|
if (pStore->streamStateFuncPut(pHandle->pState, key, pBuf, length) >= 0) {
|
||||||
p.streamTupleKey = *key;
|
p.streamTupleKey = *key;
|
||||||
}
|
}
|
||||||
|
@ -3865,7 +3863,8 @@ int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock*
|
||||||
return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, &key, pPos, pCtx->pStore);
|
return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, &key, pPos, pCtx->pStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doUpdateTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STuplePos* pPos, SFunctionStateStore* pStore) {
|
static int32_t doUpdateTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STuplePos* pPos,
|
||||||
|
SFunctionStateStore* pStore) {
|
||||||
if (pHandle->pBuf != NULL) {
|
if (pHandle->pBuf != NULL) {
|
||||||
SFilePage* pPage = getBufPage(pHandle->pBuf, pPos->pageId);
|
SFilePage* pPage = getBufPage(pHandle->pBuf, pPos->pageId);
|
||||||
if (pPage == NULL) {
|
if (pPage == NULL) {
|
||||||
|
@ -3898,7 +3897,8 @@ int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBloc
|
||||||
return doUpdateTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pPos, pCtx->pStore);
|
return doUpdateTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pPos, pCtx->pStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doLoadTupleData(SSerializeDataHandle* pHandle, const STuplePos* pPos, SFunctionStateStore* pStore, char** value) {
|
static int32_t doLoadTupleData(SSerializeDataHandle* pHandle, const STuplePos* pPos, SFunctionStateStore* pStore,
|
||||||
|
char** value) {
|
||||||
if (pHandle->pBuf != NULL) {
|
if (pHandle->pBuf != NULL) {
|
||||||
SFilePage* pPage = getBufPage(pHandle->pBuf, pPos->pageId);
|
SFilePage* pPage = getBufPage(pHandle->pBuf, pPos->pageId);
|
||||||
if (pPage == NULL) {
|
if (pPage == NULL) {
|
||||||
|
@ -3911,7 +3911,7 @@ static int32_t doLoadTupleData(SSerializeDataHandle* pHandle, const STuplePos* p
|
||||||
} else {
|
} else {
|
||||||
*value = NULL;
|
*value = NULL;
|
||||||
int32_t vLen;
|
int32_t vLen;
|
||||||
int32_t code = pStore->streamStateFuncGet(pHandle->pState, &pPos->streamTupleKey, (void **)(value), &vLen);
|
int32_t code = pStore->streamStateFuncGet(pHandle->pState, &pPos->streamTupleKey, (void**)(value), &vLen);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -3978,11 +3978,11 @@ int32_t addResult(SqlFunctionCtx* pCtx, STopBotResItem* pSourceItem, int16_t typ
|
||||||
pItem->tuplePos.pageId = -1;
|
pItem->tuplePos.pageId = -1;
|
||||||
replaceTupleData(&pItem->tuplePos, &pSourceItem->tuplePos);
|
replaceTupleData(&pItem->tuplePos, &pSourceItem->tuplePos);
|
||||||
pEntryInfo->numOfRes++;
|
pEntryInfo->numOfRes++;
|
||||||
code = taosheapsort((void*)pItems, sizeof(STopBotResItem), pEntryInfo->numOfRes, (const void*)&type,
|
code = taosheapsort((void*)pItems, sizeof(STopBotResItem), pEntryInfo->numOfRes, (const void*)&type,
|
||||||
topBotResComparFn, !isTopQuery);
|
topBotResComparFn, !isTopQuery);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
} else { // replace the minimum value in the result
|
} else { // replace the minimum value in the result
|
||||||
if ((isTopQuery && ((IS_SIGNED_NUMERIC_TYPE(type) && pSourceItem->v.i > pItems[0].v.i) ||
|
if ((isTopQuery && ((IS_SIGNED_NUMERIC_TYPE(type) && pSourceItem->v.i > pItems[0].v.i) ||
|
||||||
(IS_UNSIGNED_NUMERIC_TYPE(type) && pSourceItem->v.u > pItems[0].v.u) ||
|
(IS_UNSIGNED_NUMERIC_TYPE(type) && pSourceItem->v.u > pItems[0].v.u) ||
|
||||||
|
@ -4158,7 +4158,7 @@ int32_t spreadFunctionMerge(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
int32_t start = pInput->startRowIndex;
|
int32_t start = pInput->startRowIndex;
|
||||||
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
||||||
if(colDataIsNull_s(pCol, i)) continue;
|
if (colDataIsNull_s(pCol, i)) continue;
|
||||||
char* data = colDataGetData(pCol, i);
|
char* data = colDataGetData(pCol, i);
|
||||||
SSpreadInfo* pInputInfo = (SSpreadInfo*)varDataVal(data);
|
SSpreadInfo* pInputInfo = (SSpreadInfo*)varDataVal(data);
|
||||||
if (pInputInfo->hasResult) {
|
if (pInputInfo->hasResult) {
|
||||||
|
@ -4612,7 +4612,7 @@ int32_t histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResul
|
||||||
pInfo->totalCount = 0;
|
pInfo->totalCount = 0;
|
||||||
pInfo->normalized = 0;
|
pInfo->normalized = 0;
|
||||||
|
|
||||||
char* binTypeStr = taosStrndup(varDataVal(pCtx->param[1].param.pz), varDataLen(pCtx->param[1].param.pz));
|
char* binTypeStr = taosStrndup(varDataVal(pCtx->param[1].param.pz), varDataLen(pCtx->param[1].param.pz));
|
||||||
if (binTypeStr == NULL) {
|
if (binTypeStr == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -4622,7 +4622,7 @@ int32_t histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResul
|
||||||
if (binType == UNKNOWN_BIN) {
|
if (binType == UNKNOWN_BIN) {
|
||||||
return TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
return TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
||||||
}
|
}
|
||||||
char* binDesc = taosStrndup(varDataVal(pCtx->param[2].param.pz), varDataLen(pCtx->param[2].param.pz));
|
char* binDesc = taosStrndup(varDataVal(pCtx->param[2].param.pz), varDataLen(pCtx->param[2].param.pz));
|
||||||
if (binDesc == NULL) {
|
if (binDesc == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -4743,11 +4743,13 @@ int32_t histogramFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
int32_t len;
|
int32_t len;
|
||||||
char buf[512] = {0};
|
char buf[512] = {0};
|
||||||
if (!pInfo->normalized) {
|
if (!pInfo->normalized) {
|
||||||
len = tsnprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%" PRId64 "}",
|
len = tsnprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE,
|
||||||
pInfo->bins[i].lower, pInfo->bins[i].upper, pInfo->bins[i].count);
|
"{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%" PRId64 "}", pInfo->bins[i].lower,
|
||||||
|
pInfo->bins[i].upper, pInfo->bins[i].count);
|
||||||
} else {
|
} else {
|
||||||
len = tsnprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%lf}", pInfo->bins[i].lower,
|
len = tsnprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE,
|
||||||
pInfo->bins[i].upper, pInfo->bins[i].percentage);
|
"{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%lf}", pInfo->bins[i].lower, pInfo->bins[i].upper,
|
||||||
|
pInfo->bins[i].percentage);
|
||||||
}
|
}
|
||||||
varDataSetLen(buf, len);
|
varDataSetLen(buf, len);
|
||||||
code = colDataSetVal(pCol, currentRow, buf, false);
|
code = colDataSetVal(pCol, currentRow, buf, false);
|
||||||
|
@ -5857,7 +5859,7 @@ int32_t modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void modeFunctionCleanup(SModeInfo * pInfo) {
|
static void modeFunctionCleanup(SModeInfo* pInfo) {
|
||||||
taosHashCleanup(pInfo->pHash);
|
taosHashCleanup(pInfo->pHash);
|
||||||
pInfo->pHash = NULL;
|
pInfo->pHash = NULL;
|
||||||
taosMemoryFreeClear(pInfo->buf);
|
taosMemoryFreeClear(pInfo->buf);
|
||||||
|
@ -5870,7 +5872,7 @@ void modeFunctionCleanupExt(SqlFunctionCtx* pCtx) {
|
||||||
modeFunctionCleanup(GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)));
|
modeFunctionCleanup(GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t saveModeTupleData(SqlFunctionCtx* pCtx, char* data, SModeInfo *pInfo, STuplePos* pPos) {
|
static int32_t saveModeTupleData(SqlFunctionCtx* pCtx, char* data, SModeInfo* pInfo, STuplePos* pPos) {
|
||||||
if (IS_VAR_DATA_TYPE(pInfo->colType)) {
|
if (IS_VAR_DATA_TYPE(pInfo->colType)) {
|
||||||
(void)memcpy(pInfo->buf, data, varDataTLen(data));
|
(void)memcpy(pInfo->buf, data, varDataTLen(data));
|
||||||
} else {
|
} else {
|
||||||
|
@ -5884,10 +5886,10 @@ static int32_t doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCt
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t hashKeyBytes = IS_STR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes;
|
int32_t hashKeyBytes = IS_STR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes;
|
||||||
|
|
||||||
SModeItem* pHashItem = (SModeItem *)taosHashGet(pInfo->pHash, data, hashKeyBytes);
|
SModeItem* pHashItem = (SModeItem*)taosHashGet(pInfo->pHash, data, hashKeyBytes);
|
||||||
if (pHashItem == NULL) {
|
if (pHashItem == NULL) {
|
||||||
int32_t size = sizeof(SModeItem);
|
int32_t size = sizeof(SModeItem);
|
||||||
SModeItem item = {0};
|
SModeItem item = {0};
|
||||||
|
|
||||||
item.count += 1;
|
item.count += 1;
|
||||||
code = saveModeTupleData(pCtx, data, pInfo, &item.dataPos);
|
code = saveModeTupleData(pCtx, data, pInfo, &item.dataPos);
|
||||||
|
@ -5971,11 +5973,11 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STuplePos resDataPos, resTuplePos;
|
STuplePos resDataPos, resTuplePos;
|
||||||
int32_t maxCount = 0;
|
int32_t maxCount = 0;
|
||||||
|
|
||||||
void *pIter = taosHashIterate(pInfo->pHash, NULL);
|
void* pIter = taosHashIterate(pInfo->pHash, NULL);
|
||||||
while (pIter != NULL) {
|
while (pIter != NULL) {
|
||||||
SModeItem *pItem = (SModeItem *)pIter;
|
SModeItem* pItem = (SModeItem*)pIter;
|
||||||
if (pItem->count >= maxCount) {
|
if (pItem->count >= maxCount) {
|
||||||
maxCount = pItem->count;
|
maxCount = pItem->count;
|
||||||
resDataPos = pItem->dataPos;
|
resDataPos = pItem->dataPos;
|
||||||
|
@ -5999,7 +6001,7 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
code = colDataSetVal(pCol, currentRow, pData, false);
|
code = colDataSetVal(pCol, currentRow, pData, false);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
modeFunctionCleanup(pInfo);
|
modeFunctionCleanup(pInfo);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
code = setSelectivityValue(pCtx, pBlock, &resTuplePos, currentRow);
|
code = setSelectivityValue(pCtx, pBlock, &resTuplePos, currentRow);
|
||||||
} else {
|
} else {
|
||||||
|
@ -6375,8 +6377,8 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE,
|
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]",
|
"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, '%');
|
pData->numOfBlocks, pData->totalSize / 1024.0, averageSize / 1024.0, compRatio, '%');
|
||||||
|
|
||||||
varDataSetLen(st, len);
|
varDataSetLen(st, len);
|
||||||
int32_t code = colDataSetVal(pColInfo, row++, st, false);
|
int32_t code = colDataSetVal(pColInfo, row++, st, false);
|
||||||
|
@ -6389,23 +6391,26 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
avgRows = pData->totalRows / pData->numOfBlocks;
|
avgRows = pData->totalRows / pData->numOfBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE, "Block_Rows=[%" PRId64 "] MinRows=[%d] MaxRows=[%d] AvgRows=[%" PRId64 "]",
|
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE,
|
||||||
pData->totalRows, pData->minRows, pData->maxRows, avgRows);
|
"Block_Rows=[%" PRId64 "] MinRows=[%d] MaxRows=[%d] AvgRows=[%" PRId64 "]", pData->totalRows,
|
||||||
|
pData->minRows, pData->maxRows, avgRows);
|
||||||
varDataSetLen(st, len);
|
varDataSetLen(st, len);
|
||||||
code = colDataSetVal(pColInfo, row++, st, false);
|
code = colDataSetVal(pColInfo, row++, st, false);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE, "Inmem_Rows=[%d] Stt_Rows=[%d] ", pData->numOfInmemRows, pData->numOfSttRows);
|
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE, "Inmem_Rows=[%d] Stt_Rows=[%d] ",
|
||||||
|
pData->numOfInmemRows, pData->numOfSttRows);
|
||||||
varDataSetLen(st, len);
|
varDataSetLen(st, len);
|
||||||
code = colDataSetVal(pColInfo, row++, st, false);
|
code = colDataSetVal(pColInfo, row++, st, false);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE, "Total_Tables=[%d] Total_Filesets=[%d] Total_Vgroups=[%d]", pData->numOfTables,
|
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE,
|
||||||
pData->numOfFiles, pData->numOfVgroups);
|
"Total_Tables=[%d] Total_Filesets=[%d] Total_Vgroups=[%d]", pData->numOfTables, pData->numOfFiles,
|
||||||
|
pData->numOfVgroups);
|
||||||
|
|
||||||
varDataSetLen(st, len);
|
varDataSetLen(st, len);
|
||||||
code = colDataSetVal(pColInfo, row++, st, false);
|
code = colDataSetVal(pColInfo, row++, st, false);
|
||||||
|
@ -6414,7 +6419,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE,
|
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE,
|
||||||
"--------------------------------------------------------------------------------");
|
"--------------------------------------------------------------------------------");
|
||||||
varDataSetLen(st, len);
|
varDataSetLen(st, len);
|
||||||
code = colDataSetVal(pColInfo, row++, st, false);
|
code = colDataSetVal(pColInfo, row++, st, false);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
@ -6437,10 +6442,11 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
double factor = pData->numOfBlocks / 80.0;
|
double factor = pData->numOfBlocks / 80.0;
|
||||||
|
|
||||||
int32_t numOfBuckets = sizeof(pData->blockRowsHisto) / sizeof(pData->blockRowsHisto[0]);
|
int32_t numOfBuckets = sizeof(pData->blockRowsHisto) / sizeof(pData->blockRowsHisto[0]);
|
||||||
int32_t bucketRange = ceil(((double) (pData->defMaxRows - pData->defMinRows)) / numOfBuckets);
|
int32_t bucketRange = ceil(((double)(pData->defMaxRows - pData->defMinRows)) / numOfBuckets);
|
||||||
|
|
||||||
for (int32_t i = 0; i < tListLen(pData->blockRowsHisto); ++i) {
|
for (int32_t i = 0; i < tListLen(pData->blockRowsHisto); ++i) {
|
||||||
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE, "%04d |", pData->defMinRows + bucketRange * (i + 1));
|
len =
|
||||||
|
tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE, "%04d |", pData->defMinRows + bucketRange * (i + 1));
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
if (pData->blockRowsHisto[i] > 0) {
|
if (pData->blockRowsHisto[i] > 0) {
|
||||||
|
@ -6454,7 +6460,8 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
|
||||||
if (pData->blockRowsHisto[i] > 0) {
|
if (pData->blockRowsHisto[i] > 0) {
|
||||||
double v = pData->blockRowsHisto[i] * 100.0 / pData->numOfBlocks;
|
double v = pData->blockRowsHisto[i] * 100.0 / pData->numOfBlocks;
|
||||||
len += tsnprintf(varDataVal(st) + len, sizeof(st) - VARSTR_HEADER_SIZE - len, " %d (%.2f%c)", pData->blockRowsHisto[i], v, '%');
|
len += tsnprintf(varDataVal(st) + len, sizeof(st) - VARSTR_HEADER_SIZE - len, " %d (%.2f%c)",
|
||||||
|
pData->blockRowsHisto[i], v, '%');
|
||||||
}
|
}
|
||||||
|
|
||||||
varDataSetLen(st, len);
|
varDataSetLen(st, len);
|
||||||
|
@ -6466,6 +6473,114 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
int32_t blockDBUsageSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) {
|
||||||
|
if (pResultInfo->initialized) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS != functionSetup(pCtx, pResultInfo)) {
|
||||||
|
return TSDB_CODE_FUNC_SETUP_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDBBlockUsageInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
int32_t blockDBUsageFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
const int32_t BLOCK_DISK_USAGE_RESULT_ROWS = 2;
|
||||||
|
|
||||||
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
SDBBlockUsageInfo* pDistInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
|
SDBBlockUsageInfo p1 = {0};
|
||||||
|
if (tDeserializeBlockDbUsage(varDataVal(pInputCol->pData), varDataLen(pInputCol->pData), &p1) < 0) {
|
||||||
|
qError("failed to deserialize block dist info");
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeBlockDbUsage(void* buf, int32_t bufLen, const SDBBlockUsageInfo* pInfo) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
int32_t tlen;
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tEncodeU64(&encoder, pInfo->dataInDiskSize));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeU64(&encoder, pInfo->walInDiskSize));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeU64(&encoder, pInfo->rawDataSize));
|
||||||
|
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
tlen = code;
|
||||||
|
} else {
|
||||||
|
tlen = encoder.pos;
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
int32_t tDeserializeBlockDbUsage(void* buf, int32_t bufLen, SDBBlockUsageInfo* pInfo) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pInfo->dataInDiskSize));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pInfo->walInDiskSize));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pInfo->rawDataSize));
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
int32_t blockDBUsageFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
SDBBlockUsageInfo* pData = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
|
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
if (NULL == pColInfo) {
|
||||||
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
|
}
|
||||||
|
int32_t len = 0;
|
||||||
|
int32_t row = 0;
|
||||||
|
char st[256] = {0};
|
||||||
|
|
||||||
|
uint64_t totalDiskSize = pData->dataInDiskSize;
|
||||||
|
uint64_t rawDataSize = pData->rawDataSize;
|
||||||
|
double compressRadio = 0;
|
||||||
|
if (rawDataSize != 0) {
|
||||||
|
compressRadio = totalDiskSize * 100 / (double)rawDataSize;
|
||||||
|
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE, "Compress_radio=[%.2f]", compressRadio);
|
||||||
|
} else {
|
||||||
|
len = tsnprintf(varDataVal(st), sizeof(st) - VARSTR_HEADER_SIZE, "Compress_radio=[NULL]");
|
||||||
|
}
|
||||||
|
|
||||||
|
varDataSetLen(st, len);
|
||||||
|
int32_t code = colDataSetVal(pColInfo, row++, st, false);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
bool getDerivativeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
bool getDerivativeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
||||||
pEnv->calcMemSize = sizeof(SDerivInfo);
|
pEnv->calcMemSize = sizeof(SDerivInfo);
|
||||||
|
@ -6506,7 +6621,7 @@ int32_t derivativeFunction(SqlFunctionCtx* pCtx) {
|
||||||
double v = 0;
|
double v = 0;
|
||||||
if (pCtx->order == TSDB_ORDER_ASC) {
|
if (pCtx->order == TSDB_ORDER_ASC) {
|
||||||
SFuncInputRow row = {0};
|
SFuncInputRow row = {0};
|
||||||
bool result = false;
|
bool result = false;
|
||||||
while (1) {
|
while (1) {
|
||||||
code = funcInputGetNextRow(pCtx, &row, &result);
|
code = funcInputGetNextRow(pCtx, &row, &result);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
@ -6681,7 +6796,7 @@ static void initializeRateInfo(SqlFunctionCtx* pCtx, SRateInfo* pRateInfo, bool
|
||||||
} else {
|
} else {
|
||||||
pRateInfo->firstPk = NULL;
|
pRateInfo->firstPk = NULL;
|
||||||
pRateInfo->lastPk = NULL;
|
pRateInfo->lastPk = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t irateFunction(SqlFunctionCtx* pCtx) {
|
int32_t irateFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
@ -6695,14 +6810,14 @@ int32_t irateFunction(SqlFunctionCtx* pCtx) {
|
||||||
SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput;
|
SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput;
|
||||||
|
|
||||||
funcInputUpdate(pCtx);
|
funcInputUpdate(pCtx);
|
||||||
|
|
||||||
initializeRateInfo(pCtx, pRateInfo, false);
|
initializeRateInfo(pCtx, pRateInfo, false);
|
||||||
|
|
||||||
int32_t numOfElems = 0;
|
int32_t numOfElems = 0;
|
||||||
int32_t type = pInputCol->info.type;
|
int32_t type = pInputCol->info.type;
|
||||||
SFuncInputRow row = {0};
|
SFuncInputRow row = {0};
|
||||||
bool result = false;
|
bool result = false;
|
||||||
while (1) {
|
while (1) {
|
||||||
code = funcInputGetNextRow(pCtx, &row, &result);
|
code = funcInputGetNextRow(pCtx, &row, &result);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -6731,19 +6846,18 @@ int32_t irateFunction(SqlFunctionCtx* pCtx) {
|
||||||
doSaveRateInfo(pRateInfo, false, row.ts, row.pPk, v);
|
doSaveRateInfo(pRateInfo, false, row.ts, row.pPk, v);
|
||||||
continue;
|
continue;
|
||||||
} else if (row.ts == pRateInfo->lastKey) {
|
} else if (row.ts == pRateInfo->lastKey) {
|
||||||
return TSDB_CODE_FUNC_DUP_TIMESTAMP;
|
return TSDB_CODE_FUNC_DUP_TIMESTAMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((INT64_MIN == pRateInfo->firstKey) || row.ts > pRateInfo->firstKey) {
|
if ((INT64_MIN == pRateInfo->firstKey) || row.ts > pRateInfo->firstKey) {
|
||||||
doSaveRateInfo(pRateInfo, true, row.ts, row.pPk, v);
|
doSaveRateInfo(pRateInfo, true, row.ts, row.pPk, v);
|
||||||
} else if (row.ts == pRateInfo->firstKey) {
|
} else if (row.ts == pRateInfo->firstKey) {
|
||||||
return TSDB_CODE_FUNC_DUP_TIMESTAMP;
|
return TSDB_CODE_FUNC_DUP_TIMESTAMP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfElems++;
|
numOfElems++;
|
||||||
|
|
||||||
SET_VAL(pResInfo, numOfElems, 1);
|
SET_VAL(pResInfo, numOfElems, 1);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -6795,8 +6909,9 @@ static void irateCopyInfo(SRateInfo* pInput, SRateInfo* pOutput) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t irateTransferInfo(SRateInfo* pInput, SRateInfo* pOutput) {
|
static int32_t irateTransferInfo(SRateInfo* pInput, SRateInfo* pOutput) {
|
||||||
if ((pInput->firstKey != INT64_MIN && (pInput->firstKey == pOutput->firstKey || pInput->firstKey == pOutput->lastKey)) ||
|
if ((pInput->firstKey != INT64_MIN &&
|
||||||
(pInput->lastKey != INT64_MIN && (pInput->lastKey == pOutput->firstKey || pInput->lastKey == pOutput->lastKey))) {
|
(pInput->firstKey == pOutput->firstKey || pInput->firstKey == pOutput->lastKey)) ||
|
||||||
|
(pInput->lastKey != INT64_MIN && (pInput->lastKey == pOutput->firstKey || pInput->lastKey == pOutput->lastKey))) {
|
||||||
return TSDB_CODE_FUNC_DUP_TIMESTAMP;
|
return TSDB_CODE_FUNC_DUP_TIMESTAMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6830,8 +6945,8 @@ int32_t irateFunctionMerge(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
int32_t start = pInput->startRowIndex;
|
int32_t start = pInput->startRowIndex;
|
||||||
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
||||||
char* data = colDataGetData(pCol, i);
|
char* data = colDataGetData(pCol, i);
|
||||||
SRateInfo* pInputInfo = (SRateInfo*)varDataVal(data);
|
SRateInfo* pInputInfo = (SRateInfo*)varDataVal(data);
|
||||||
initializeRateInfo(pCtx, pInfo, true);
|
initializeRateInfo(pCtx, pInfo, true);
|
||||||
if (pInputInfo->hasResult) {
|
if (pInputInfo->hasResult) {
|
||||||
int32_t code = irateTransferInfo(pInputInfo, pInfo);
|
int32_t code = irateTransferInfo(pInputInfo, pInfo);
|
||||||
|
@ -6863,8 +6978,8 @@ int32_t iratePartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
||||||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
if (NULL == pCol) {
|
if (NULL == pCol) {
|
||||||
taosMemoryFree(res);
|
taosMemoryFree(res);
|
||||||
return TSDB_CODE_OUT_OF_RANGE;
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = colDataSetVal(pCol, pBlock->info.rows, res, false);
|
int32_t code = colDataSetVal(pCol, pBlock->info.rows, res, false);
|
||||||
|
@ -6885,7 +7000,7 @@ int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
|
||||||
SRateInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
SRateInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
double result = doCalcRate(pInfo, (double)TSDB_TICK_PER_SECOND(pCtx->param[1].param.i));
|
double result = doCalcRate(pInfo, (double)TSDB_TICK_PER_SECOND(pCtx->param[1].param.i));
|
||||||
int32_t code = colDataSetVal(pCol, pBlock->info.rows, (const char*)&result, pResInfo->isNullRes);
|
int32_t code = colDataSetVal(pCol, pBlock->info.rows, (const char*)&result, pResInfo->isNullRes);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -6925,9 +7040,7 @@ _group_value_over:
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
|
int32_t groupKeyFunction(SqlFunctionCtx* pCtx) { return groupConstValueFunction(pCtx); }
|
||||||
return groupConstValueFunction(pCtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t groupConstValueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
int32_t groupConstValueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
||||||
|
@ -6956,9 +7069,7 @@ int32_t groupConstValueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock){
|
int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return groupConstValueFinalize(pCtx, pBlock); }
|
||||||
return groupConstValueFinalize(pCtx, pBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
||||||
SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx);
|
SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx);
|
||||||
|
@ -6980,7 +7091,8 @@ int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pSourceCtx->resDataInfo.type)) {
|
if (IS_VAR_DATA_TYPE(pSourceCtx->resDataInfo.type)) {
|
||||||
(void)memcpy(pDBuf->data, pSBuf->data,
|
(void)memcpy(pDBuf->data, pSBuf->data,
|
||||||
(pSourceCtx->resDataInfo.type == TSDB_DATA_TYPE_JSON) ? getJsonValueLen(pSBuf->data) : varDataTLen(pSBuf->data));
|
(pSourceCtx->resDataInfo.type == TSDB_DATA_TYPE_JSON) ? getJsonValueLen(pSBuf->data)
|
||||||
|
: varDataTLen(pSBuf->data));
|
||||||
} else {
|
} else {
|
||||||
(void)memcpy(pDBuf->data, pSBuf->data, pSourceCtx->resDataInfo.bytes);
|
(void)memcpy(pDBuf->data, pSBuf->data, pSourceCtx->resDataInfo.bytes);
|
||||||
}
|
}
|
||||||
|
@ -7007,7 +7119,7 @@ int32_t cachedLastRowFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
SColumnInfoData* pkCol = pInput->pPrimaryKey;
|
||||||
pInfo->pkType = -1;
|
pInfo->pkType = -1;
|
||||||
__compar_fn_t pkCompareFn = NULL;
|
__compar_fn_t pkCompareFn = NULL;
|
||||||
if (pCtx->hasPrimaryKey) {
|
if (pCtx->hasPrimaryKey) {
|
||||||
pInfo->pkType = pkCol->info.type;
|
pInfo->pkType = pkCol->info.type;
|
||||||
pInfo->pkBytes = pkCol->info.bytes;
|
pInfo->pkBytes = pkCol->info.bytes;
|
||||||
|
|
|
@ -122,7 +122,8 @@ EFuncDataRequired fmFuncDynDataRequired(int32_t funcId, void* pRes, SDataBlockIn
|
||||||
|
|
||||||
const char* name = funcMgtBuiltins[funcId].name;
|
const char* name = funcMgtBuiltins[funcId].name;
|
||||||
if ((strcmp(name, "_group_key") == 0) || (strcmp(name, "_select_value") == 0)) {
|
if ((strcmp(name, "_group_key") == 0) || (strcmp(name, "_select_value") == 0)) {
|
||||||
return FUNC_DATA_REQUIRED_NOT_LOAD;;
|
return FUNC_DATA_REQUIRED_NOT_LOAD;
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (funcMgtBuiltins[funcId].dynDataRequiredFunc == NULL) {
|
if (funcMgtBuiltins[funcId].dynDataRequiredFunc == NULL) {
|
||||||
|
@ -188,7 +189,6 @@ bool fmIsWindowClauseFunc(int32_t funcId) { return fmIsAggFunc(funcId) || fmIsWi
|
||||||
|
|
||||||
bool fmIsIndefiniteRowsFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_INDEFINITE_ROWS_FUNC); }
|
bool fmIsIndefiniteRowsFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_INDEFINITE_ROWS_FUNC); }
|
||||||
|
|
||||||
|
|
||||||
bool fmIsSpecialDataRequiredFunc(int32_t funcId) {
|
bool fmIsSpecialDataRequiredFunc(int32_t funcId) {
|
||||||
return isSpecificClassifyFunc(funcId, FUNC_MGT_SPECIAL_DATA_REQUIRED);
|
return isSpecificClassifyFunc(funcId, FUNC_MGT_SPECIAL_DATA_REQUIRED);
|
||||||
}
|
}
|
||||||
|
@ -299,6 +299,13 @@ bool fmIsBlockDistFunc(int32_t funcId) {
|
||||||
return FUNCTION_TYPE_BLOCK_DIST == funcMgtBuiltins[funcId].type;
|
return FUNCTION_TYPE_BLOCK_DIST == funcMgtBuiltins[funcId].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fmIsDBUsageFunc(int32_t funcId) {
|
||||||
|
if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return FUNCTION_TYPE_DB_USAGE == funcMgtBuiltins[funcId].type;
|
||||||
|
}
|
||||||
|
|
||||||
bool fmIsProcessByRowFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_PROCESS_BY_ROW); }
|
bool fmIsProcessByRowFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_PROCESS_BY_ROW); }
|
||||||
|
|
||||||
bool fmIsIgnoreNullFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_IGNORE_NULL_FUNC); }
|
bool fmIsIgnoreNullFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_IGNORE_NULL_FUNC); }
|
||||||
|
@ -377,15 +384,11 @@ bool fmIsConstantResFunc(SFunctionNode* pFunc) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fmIsSkipScanCheckFunc(int32_t funcId) {
|
bool fmIsSkipScanCheckFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_SKIP_SCAN_CHECK_FUNC); }
|
||||||
return isSpecificClassifyFunc(funcId, FUNC_MGT_SKIP_SCAN_CHECK_FUNC);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool fmIsPrimaryKeyFunc(int32_t funcId) {
|
bool fmIsPrimaryKeyFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_PRIMARY_KEY_FUNC); }
|
||||||
return isSpecificClassifyFunc(funcId, FUNC_MGT_PRIMARY_KEY_FUNC);
|
|
||||||
}
|
|
||||||
void getLastCacheDataType(SDataType* pType, int32_t pkBytes) {
|
void getLastCacheDataType(SDataType* pType, int32_t pkBytes) {
|
||||||
//TODO: do it later.
|
// TODO: do it later.
|
||||||
pType->bytes = getFirstLastInfoSize(pType->bytes, pkBytes) + VARSTR_HEADER_SIZE;
|
pType->bytes = getFirstLastInfoSize(pType->bytes, pkBytes) + VARSTR_HEADER_SIZE;
|
||||||
pType->type = TSDB_DATA_TYPE_BINARY;
|
pType->type = TSDB_DATA_TYPE_BINARY;
|
||||||
}
|
}
|
||||||
|
@ -463,7 +466,7 @@ bool fmIsDistExecFunc(int32_t funcId) {
|
||||||
|
|
||||||
static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNode** pPartialFunc) {
|
static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNode** pPartialFunc) {
|
||||||
SNodeList* pParameterList = NULL;
|
SNodeList* pParameterList = NULL;
|
||||||
int32_t code = nodesCloneList(pSrcFunc->pParameterList, &pParameterList);
|
int32_t code = nodesCloneList(pSrcFunc->pParameterList, &pParameterList);
|
||||||
if (NULL == pParameterList) {
|
if (NULL == pParameterList) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -476,7 +479,7 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod
|
||||||
(*pPartialFunc)->hasOriginalFunc = true;
|
(*pPartialFunc)->hasOriginalFunc = true;
|
||||||
(*pPartialFunc)->originalFuncId = pSrcFunc->hasOriginalFunc ? pSrcFunc->originalFuncId : pSrcFunc->funcId;
|
(*pPartialFunc)->originalFuncId = pSrcFunc->hasOriginalFunc ? pSrcFunc->originalFuncId : pSrcFunc->funcId;
|
||||||
char name[TSDB_FUNC_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_POINTER_PRINT_BYTES + 1] = {0};
|
char name[TSDB_FUNC_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_POINTER_PRINT_BYTES + 1] = {0};
|
||||||
|
|
||||||
int32_t len = tsnprintf(name, sizeof(name), "%s.%p", (*pPartialFunc)->functionName, pSrcFunc);
|
int32_t len = tsnprintf(name, sizeof(name), "%s.%p", (*pPartialFunc)->functionName, pSrcFunc);
|
||||||
if (taosHashBinary(name, len) < 0) {
|
if (taosHashBinary(name, len) < 0) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
|
@ -487,7 +490,7 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod
|
||||||
|
|
||||||
static int32_t createMergeFuncPara(const SFunctionNode* pSrcFunc, const SFunctionNode* pPartialFunc,
|
static int32_t createMergeFuncPara(const SFunctionNode* pSrcFunc, const SFunctionNode* pPartialFunc,
|
||||||
SNodeList** pParameterList) {
|
SNodeList** pParameterList) {
|
||||||
SNode *pRes = NULL;
|
SNode* pRes = NULL;
|
||||||
int32_t code = createColumnByFunc(pPartialFunc, (SColumnNode**)&pRes);
|
int32_t code = createColumnByFunc(pPartialFunc, (SColumnNode**)&pRes);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -500,7 +503,7 @@ static int32_t createMergeFuncPara(const SFunctionNode* pSrcFunc, const SFunctio
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createMidFunction(const SFunctionNode* pSrcFunc, const SFunctionNode* pPartialFunc,
|
static int32_t createMidFunction(const SFunctionNode* pSrcFunc, const SFunctionNode* pPartialFunc,
|
||||||
SFunctionNode** pMidFunc) {
|
SFunctionNode** pMidFunc) {
|
||||||
SNodeList* pParameterList = NULL;
|
SNodeList* pParameterList = NULL;
|
||||||
SFunctionNode* pFunc = NULL;
|
SFunctionNode* pFunc = NULL;
|
||||||
|
|
||||||
|
@ -551,7 +554,8 @@ static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctio
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMidFunc, SFunctionNode** pMergeFunc) {
|
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMidFunc,
|
||||||
|
SFunctionNode** pMergeFunc) {
|
||||||
if (!fmIsDistExecFunc(pFunc->funcId)) {
|
if (!fmIsDistExecFunc(pFunc->funcId)) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -577,7 +581,7 @@ char* fmGetFuncName(int32_t funcId) {
|
||||||
if (fmIsUserDefinedFunc(funcId) || funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
if (fmIsUserDefinedFunc(funcId) || funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
||||||
return taosStrdup("invalid function");
|
return taosStrdup("invalid function");
|
||||||
}
|
}
|
||||||
return taosStrdup(funcMgtBuiltins[funcId].name);
|
return taosStrdup(funcMgtBuiltins[funcId].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param [out] pStateFunc, not changed if error occured or no need to create state func
|
/// @param [out] pStateFunc, not changed if error occured or no need to create state func
|
||||||
|
@ -585,7 +589,7 @@ char* fmGetFuncName(int32_t funcId) {
|
||||||
static int32_t fmCreateStateFunc(const SFunctionNode* pFunc, SFunctionNode** pStateFunc) {
|
static int32_t fmCreateStateFunc(const SFunctionNode* pFunc, SFunctionNode** pStateFunc) {
|
||||||
if (funcMgtBuiltins[pFunc->funcId].pStateFunc) {
|
if (funcMgtBuiltins[pFunc->funcId].pStateFunc) {
|
||||||
SNodeList* pParams = NULL;
|
SNodeList* pParams = NULL;
|
||||||
int32_t code = nodesCloneList(pFunc->pParameterList, &pParams);
|
int32_t code = nodesCloneList(pFunc->pParameterList, &pParams);
|
||||||
if (!pParams) return code;
|
if (!pParams) return code;
|
||||||
code = createFunction(funcMgtBuiltins[pFunc->funcId].pStateFunc, pParams, pStateFunc);
|
code = createFunction(funcMgtBuiltins[pFunc->funcId].pStateFunc, pParams, pStateFunc);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
@ -632,7 +636,7 @@ int32_t fmCreateStateFuncs(SNodeList* pFuncs) {
|
||||||
static int32_t fmCreateStateMergeFunc(SFunctionNode* pFunc, SFunctionNode** pStateMergeFunc) {
|
static int32_t fmCreateStateMergeFunc(SFunctionNode* pFunc, SFunctionNode** pStateMergeFunc) {
|
||||||
if (funcMgtBuiltins[pFunc->funcId].pMergeFunc) {
|
if (funcMgtBuiltins[pFunc->funcId].pMergeFunc) {
|
||||||
SNodeList* pParams = NULL;
|
SNodeList* pParams = NULL;
|
||||||
int32_t code = nodesCloneList(pFunc->pParameterList, &pParams);
|
int32_t code = nodesCloneList(pFunc->pParameterList, &pParams);
|
||||||
if (!pParams) return code;
|
if (!pParams) return code;
|
||||||
code = createFunction(funcMgtBuiltins[pFunc->funcId].pMergeFunc, pParams, pStateMergeFunc);
|
code = createFunction(funcMgtBuiltins[pFunc->funcId].pMergeFunc, pParams, pStateMergeFunc);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
|
|
@ -300,6 +300,8 @@ const char* nodesNodeName(ENodeType type) {
|
||||||
return "ShowClusterMachinesStmt";
|
return "ShowClusterMachinesStmt";
|
||||||
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
||||||
return "ShowEncryptionsStmt";
|
return "ShowEncryptionsStmt";
|
||||||
|
case QUERY_NODE_SHOW_USAGE_STMT:
|
||||||
|
return "ShowUsageStmt";
|
||||||
case QUERY_NODE_DELETE_STMT:
|
case QUERY_NODE_DELETE_STMT:
|
||||||
return "DeleteStmt";
|
return "DeleteStmt";
|
||||||
case QUERY_NODE_INSERT_STMT:
|
case QUERY_NODE_INSERT_STMT:
|
||||||
|
@ -2377,7 +2379,7 @@ static int32_t physiMergeJoinNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanAsofOp, pNode->asofOpType);
|
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanAsofOp, pNode->asofOpType);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddObject(pJson, jkJoinPhysiPlanLeftPrimExpr, nodeToJson, pNode->leftPrimExpr);
|
code = tjsonAddObject(pJson, jkJoinPhysiPlanLeftPrimExpr, nodeToJson, pNode->leftPrimExpr);
|
||||||
}
|
}
|
||||||
|
@ -2386,10 +2388,10 @@ static int32_t physiMergeJoinNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanLeftPrimSlotId, pNode->leftPrimSlotId);
|
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanLeftPrimSlotId, pNode->leftPrimSlotId);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanRightPrimSlotId, pNode->rightPrimSlotId);
|
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanRightPrimSlotId, pNode->rightPrimSlotId);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodeListToJson(pJson, jkJoinPhysiPlanLeftEqCols, pNode->pEqLeft);
|
code = nodeListToJson(pJson, jkJoinPhysiPlanLeftEqCols, pNode->pEqLeft);
|
||||||
}
|
}
|
||||||
|
@ -2491,7 +2493,7 @@ static int32_t jsonToPhysiMergeJoinNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBoolValue(pJson, jkJoinPhysiPlanGroupJoin, &pNode->grpJoin);
|
code = tjsonGetBoolValue(pJson, jkJoinPhysiPlanGroupJoin, &pNode->grpJoin);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2504,7 +2506,7 @@ static int32_t physiHashJoinNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanSubType, pNode->subType);
|
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanSubType, pNode->subType);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodeListToJson(pJson, jkJoinPhysiPlanOnLeftCols, pNode->pOnLeft);
|
code = nodeListToJson(pJson, jkJoinPhysiPlanOnLeftCols, pNode->pOnLeft);
|
||||||
}
|
}
|
||||||
|
@ -2519,10 +2521,10 @@ static int32_t physiHashJoinNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanLeftPrimSlotId, pNode->leftPrimSlotId);
|
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanLeftPrimSlotId, pNode->leftPrimSlotId);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanRightPrimSlotId, pNode->rightPrimSlotId);
|
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanRightPrimSlotId, pNode->rightPrimSlotId);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddObject(pJson, jkJoinPhysiPlanOnConditions, nodeToJson, pNode->pFullOnCond);
|
code = tjsonAddObject(pJson, jkJoinPhysiPlanOnConditions, nodeToJson, pNode->pFullOnCond);
|
||||||
}
|
}
|
||||||
|
@ -2569,7 +2571,7 @@ static int32_t jsonToPhysiHashJoinNode(const SJson* pJson, void* pObj) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkJoinPhysiPlanSubType, pNode->subType, code);
|
tjsonGetNumberValue(pJson, jkJoinPhysiPlanSubType, pNode->subType, code);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkJoinPhysiPlanOnLeftCols, &pNode->pOnLeft);
|
code = jsonToNodeList(pJson, jkJoinPhysiPlanOnLeftCols, &pNode->pOnLeft);
|
||||||
}
|
}
|
||||||
|
@ -2587,7 +2589,7 @@ static int32_t jsonToPhysiHashJoinNode(const SJson* pJson, void* pObj) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkJoinPhysiPlanRightPrimSlotId, pNode->rightPrimSlotId, code);
|
tjsonGetNumberValue(pJson, jkJoinPhysiPlanRightPrimSlotId, pNode->rightPrimSlotId, code);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeObject(pJson, jkJoinPhysiPlanOnConditions, &pNode->pFullOnCond);
|
code = jsonToNodeObject(pJson, jkJoinPhysiPlanOnConditions, &pNode->pFullOnCond);
|
||||||
}
|
}
|
||||||
|
@ -2614,7 +2616,7 @@ static int32_t jsonToPhysiHashJoinNode(const SJson* pJson, void* pObj) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkJoinPhysiPlanTimeRangeTarget, pNode->timeRangeTarget, code);
|
tjsonGetNumberValue(pJson, jkJoinPhysiPlanTimeRangeTarget, pNode->timeRangeTarget, code);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBigIntValue(pJson, jkJoinPhysiPlanTimeRangeSKey, &pNode->timeRange.skey);
|
code = tjsonGetBigIntValue(pJson, jkJoinPhysiPlanTimeRangeSKey, &pNode->timeRange.skey);
|
||||||
}
|
}
|
||||||
|
@ -4117,7 +4119,7 @@ static int32_t columnNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddBoolToObject(pJson, jkColumnIsPk, pNode->isPk);
|
code = tjsonAddBoolToObject(pJson, jkColumnIsPk, pNode->isPk);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkColumnNumOfPKs, pNode->numOfPKs);
|
code = tjsonAddIntegerToObject(pJson, jkColumnNumOfPKs, pNode->numOfPKs);
|
||||||
}
|
}
|
||||||
|
@ -4166,10 +4168,10 @@ static int32_t jsonToColumnNode(const SJson* pJson, void* pObj) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBoolValue(pJson, jkColumnIsPk, &pNode->isPk);
|
code = tjsonGetBoolValue(pJson, jkColumnIsPk, &pNode->isPk);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetSmallIntValue(pJson, jkColumnNumOfPKs, &pNode->numOfPKs);
|
code = tjsonGetSmallIntValue(pJson, jkColumnNumOfPKs, &pNode->numOfPKs);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4579,7 +4581,7 @@ static int32_t jsonToFunctionNode(const SJson* pJson, void* pObj) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetIntValue(pJson, jkFunctionPkBytes, &pNode->pkBytes);
|
code = tjsonGetIntValue(pJson, jkFunctionPkBytes, &pNode->pkBytes);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBoolValue(pJson, jkFunctionIsMergeFunc, &pNode->hasOriginalFunc);
|
code = tjsonGetBoolValue(pJson, jkFunctionIsMergeFunc, &pNode->hasOriginalFunc);
|
||||||
}
|
}
|
||||||
|
@ -5283,7 +5285,7 @@ static int32_t jsonToColumnDefNode(const SJson* pJson, void* pObj) {
|
||||||
code = tjsonGetBoolValue(pJson, jkColumnDefSma, &pNode->sma);
|
code = tjsonGetBoolValue(pJson, jkColumnDefSma, &pNode->sma);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeObject(pJson, jkColumnDefOptions, (SNode**)&pNode->pOptions);
|
code = jsonToNodeObject(pJson, jkColumnDefOptions, (SNode**)&pNode->pOptions);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -5343,14 +5345,14 @@ static int32_t jsonToDownstreamSourceNode(const SJson* pJson, void* pObj) {
|
||||||
|
|
||||||
static const char* jkWindowOffsetStartOffset = "StartOffset";
|
static const char* jkWindowOffsetStartOffset = "StartOffset";
|
||||||
static const char* jkWindowOffsetEndOffset = "EndOffset";
|
static const char* jkWindowOffsetEndOffset = "EndOffset";
|
||||||
static int32_t windowOffsetNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t windowOffsetNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SWindowOffsetNode* pNode = (const SWindowOffsetNode*)pObj;
|
const SWindowOffsetNode* pNode = (const SWindowOffsetNode*)pObj;
|
||||||
|
|
||||||
int32_t code = tjsonAddObject(pJson, jkWindowOffsetStartOffset, nodeToJson, pNode->pStartOffset);
|
int32_t code = tjsonAddObject(pJson, jkWindowOffsetStartOffset, nodeToJson, pNode->pStartOffset);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddObject(pJson, jkWindowOffsetEndOffset, nodeToJson, pNode->pEndOffset);
|
code = tjsonAddObject(pJson, jkWindowOffsetEndOffset, nodeToJson, pNode->pEndOffset);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t jsonToWindowOffsetNode(const SJson* pJson, void* pObj) {
|
static int32_t jsonToWindowOffsetNode(const SJson* pJson, void* pObj) {
|
||||||
|
@ -5363,7 +5365,6 @@ static int32_t jsonToWindowOffsetNode(const SJson* pJson, void* pObj) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char* jkDatabaseOptionsBuffer = "Buffer";
|
static const char* jkDatabaseOptionsBuffer = "Buffer";
|
||||||
static const char* jkDatabaseOptionsCacheModel = "CacheModel";
|
static const char* jkDatabaseOptionsCacheModel = "CacheModel";
|
||||||
static const char* jkDatabaseOptionsCompressionLevel = "CompressionLevel";
|
static const char* jkDatabaseOptionsCompressionLevel = "CompressionLevel";
|
||||||
|
@ -5600,11 +5601,11 @@ static const char* jkColumnOptionsEncode = "encode";
|
||||||
static const char* jkColumnOptionsCompress = "compress";
|
static const char* jkColumnOptionsCompress = "compress";
|
||||||
static const char* jkColumnOptionsLevel = "level";
|
static const char* jkColumnOptionsLevel = "level";
|
||||||
static int32_t columnOptionsToJson(const void* pObj, SJson* pJson) {
|
static int32_t columnOptionsToJson(const void* pObj, SJson* pJson) {
|
||||||
const SColumnOptions* pNode = (const SColumnOptions*)pObj;
|
const SColumnOptions* pNode = (const SColumnOptions*)pObj;
|
||||||
int32_t code = tjsonAddStringToObject(pJson, jkColumnOptionsEncode, pNode->encode);
|
int32_t code = tjsonAddStringToObject(pJson, jkColumnOptionsEncode, pNode->encode);
|
||||||
code = tjsonAddStringToObject(pJson, jkColumnOptionsCompress, pNode->compress);
|
code = tjsonAddStringToObject(pJson, jkColumnOptionsCompress, pNode->compress);
|
||||||
code = tjsonAddStringToObject(pJson, jkColumnOptionsLevel, pNode->compressLevel);
|
code = tjsonAddStringToObject(pJson, jkColumnOptionsLevel, pNode->compressLevel);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t jsonToColumnOptions(const SJson* pJson, void* pObj) {
|
static int32_t jsonToColumnOptions(const SJson* pJson, void* pObj) {
|
||||||
|
@ -7463,6 +7464,9 @@ static int32_t jsonToShowClusterMachinesStmt(const SJson* pJson, void* pObj) { r
|
||||||
|
|
||||||
static int32_t jsonToShowEncryptionsStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
static int32_t jsonToShowEncryptionsStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||||
|
|
||||||
|
static int32_t showUsageStmtStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
|
||||||
|
static int32_t jsonToShowUsageStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||||
|
|
||||||
static const char* jkShowDnodeVariablesStmtDnodeId = "DnodeId";
|
static const char* jkShowDnodeVariablesStmtDnodeId = "DnodeId";
|
||||||
static const char* jkShowDnodeVariablesStmtLikePattern = "LikePattern";
|
static const char* jkShowDnodeVariablesStmtLikePattern = "LikePattern";
|
||||||
|
|
||||||
|
@ -7769,7 +7773,7 @@ static const char* jkTSMAOptionTsPrecision = "Precision";
|
||||||
|
|
||||||
static int32_t tsmaOptionToJson(const void* pObj, SJson* pJson) {
|
static int32_t tsmaOptionToJson(const void* pObj, SJson* pJson) {
|
||||||
const STSMAOptions* pNode = (const STSMAOptions*)pObj;
|
const STSMAOptions* pNode = (const STSMAOptions*)pObj;
|
||||||
int32_t code = nodeListToJson(pJson, jkTSMAOptionFuncs, pNode->pFuncs);
|
int32_t code = nodeListToJson(pJson, jkTSMAOptionFuncs, pNode->pFuncs);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddObject(pJson, jkTSMAOptionInterval, nodeToJson, pNode->pInterval);
|
code = tjsonAddObject(pJson, jkTSMAOptionInterval, nodeToJson, pNode->pInterval);
|
||||||
}
|
}
|
||||||
|
@ -7781,7 +7785,7 @@ static int32_t tsmaOptionToJson(const void* pObj, SJson* pJson) {
|
||||||
|
|
||||||
static int32_t jsonToTSMAOption(const SJson* pJson, void* pObj) {
|
static int32_t jsonToTSMAOption(const SJson* pJson, void* pObj) {
|
||||||
STSMAOptions* pNode = (STSMAOptions*)pObj;
|
STSMAOptions* pNode = (STSMAOptions*)pObj;
|
||||||
int32_t code = jsonToNodeList(pJson, jkTSMAOptionFuncs, &pNode->pFuncs);
|
int32_t code = jsonToNodeList(pJson, jkTSMAOptionFuncs, &pNode->pFuncs);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeObject(pJson, jkTSMAOptionInterval, &pNode->pInterval);
|
code = jsonToNodeObject(pJson, jkTSMAOptionInterval, &pNode->pInterval);
|
||||||
}
|
}
|
||||||
|
@ -7799,7 +7803,7 @@ static const char* jkCreateTSMAStmtpOptions = "Options";
|
||||||
|
|
||||||
static int32_t createTSMAStmtToJson(const void* pObj, SJson* pJson) {
|
static int32_t createTSMAStmtToJson(const void* pObj, SJson* pJson) {
|
||||||
const SCreateTSMAStmt* pNode = (const SCreateTSMAStmt*)pObj;
|
const SCreateTSMAStmt* pNode = (const SCreateTSMAStmt*)pObj;
|
||||||
int32_t code = tjsonAddBoolToObject(pJson, jkCreateTSMAStmtIgnoreExists, pNode->ignoreExists);
|
int32_t code = tjsonAddBoolToObject(pJson, jkCreateTSMAStmtIgnoreExists, pNode->ignoreExists);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddStringToObject(pJson, jkCreateTSMAStmtTsmaName, pNode->tsmaName);
|
code = tjsonAddStringToObject(pJson, jkCreateTSMAStmtTsmaName, pNode->tsmaName);
|
||||||
}
|
}
|
||||||
|
@ -7817,7 +7821,7 @@ static int32_t createTSMAStmtToJson(const void* pObj, SJson* pJson) {
|
||||||
|
|
||||||
static int32_t jsonToCreateTSMAStmt(const SJson* pJson, void* pObj) {
|
static int32_t jsonToCreateTSMAStmt(const SJson* pJson, void* pObj) {
|
||||||
SCreateTSMAStmt* pNode = (SCreateTSMAStmt*)pObj;
|
SCreateTSMAStmt* pNode = (SCreateTSMAStmt*)pObj;
|
||||||
int32_t code = tjsonGetBoolValue(pJson, jkCreateTSMAStmtIgnoreExists, &pNode->ignoreExists);
|
int32_t code = tjsonGetBoolValue(pJson, jkCreateTSMAStmtIgnoreExists, &pNode->ignoreExists);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetStringValue(pJson, jkCreateTSMAStmtTsmaName, pNode->tsmaName);
|
code = tjsonGetStringValue(pJson, jkCreateTSMAStmtTsmaName, pNode->tsmaName);
|
||||||
}
|
}
|
||||||
|
@ -7839,7 +7843,7 @@ static const char* jkDropTSMAStmtTsmaName = "TSMAName";
|
||||||
|
|
||||||
static int32_t dropTSMAStmtToJson(const void* pObj, SJson* pJson) {
|
static int32_t dropTSMAStmtToJson(const void* pObj, SJson* pJson) {
|
||||||
const SDropTSMAStmt* pNode = (const SDropTSMAStmt*)pObj;
|
const SDropTSMAStmt* pNode = (const SDropTSMAStmt*)pObj;
|
||||||
int32_t code = tjsonAddBoolToObject(pJson, jkDropTSMAStmtIgnoreNotExists, pNode->ignoreNotExists);
|
int32_t code = tjsonAddBoolToObject(pJson, jkDropTSMAStmtIgnoreNotExists, pNode->ignoreNotExists);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddStringToObject(pJson, jkDropTSMAStmtDbName, pNode->dbName);
|
code = tjsonAddStringToObject(pJson, jkDropTSMAStmtDbName, pNode->dbName);
|
||||||
}
|
}
|
||||||
|
@ -7851,7 +7855,7 @@ static int32_t dropTSMAStmtToJson(const void* pObj, SJson* pJson) {
|
||||||
|
|
||||||
static int32_t jsonToDropTSMAStmt(const SJson* pJson, void* pObj) {
|
static int32_t jsonToDropTSMAStmt(const SJson* pJson, void* pObj) {
|
||||||
SDropTSMAStmt* pNode = (SDropTSMAStmt*)pObj;
|
SDropTSMAStmt* pNode = (SDropTSMAStmt*)pObj;
|
||||||
int32_t code = tjsonGetBoolValue(pJson, jkDropTSMAStmtIgnoreNotExists, &pNode->ignoreNotExists);
|
int32_t code = tjsonGetBoolValue(pJson, jkDropTSMAStmtIgnoreNotExists, &pNode->ignoreNotExists);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetStringValue(pJson, jkDropTSMAStmtDbName, pNode->dbName);
|
code = tjsonGetStringValue(pJson, jkDropTSMAStmtDbName, pNode->dbName);
|
||||||
}
|
}
|
||||||
|
@ -8106,6 +8110,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
return showLocalVariablesStmtToJson(pObj, pJson);
|
return showLocalVariablesStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
||||||
return showTableTagsStmtToJson(pObj, pJson);
|
return showTableTagsStmtToJson(pObj, pJson);
|
||||||
|
case QUERY_NODE_SHOW_USAGE_STMT:
|
||||||
|
return showUsageStmtStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_DELETE_STMT:
|
case QUERY_NODE_DELETE_STMT:
|
||||||
return deleteStmtToJson(pObj, pJson);
|
return deleteStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_INSERT_STMT:
|
case QUERY_NODE_INSERT_STMT:
|
||||||
|
@ -8389,7 +8395,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT:
|
||||||
return TSDB_CODE_SUCCESS; // SBalanceVgroupLeaderStmt has no fields to deserialize.
|
return TSDB_CODE_SUCCESS; // SBalanceVgroupLeaderStmt has no fields to deserialize.
|
||||||
case QUERY_NODE_MERGE_VGROUP_STMT:
|
case QUERY_NODE_MERGE_VGROUP_STMT:
|
||||||
return jsonToMergeVgroupStmt(pJson, pObj);
|
return jsonToMergeVgroupStmt(pJson, pObj);
|
||||||
case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT:
|
case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT:
|
||||||
|
@ -8471,6 +8477,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToShowLocalVariablesStmt(pJson, pObj);
|
return jsonToShowLocalVariablesStmt(pJson, pObj);
|
||||||
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
||||||
return jsonToShowTableTagsStmt(pJson, pObj);
|
return jsonToShowTableTagsStmt(pJson, pObj);
|
||||||
|
case QUERY_NODE_SHOW_USAGE_STMT:
|
||||||
|
return jsonToShowUsageStmt(pJson, pObj);
|
||||||
case QUERY_NODE_DELETE_STMT:
|
case QUERY_NODE_DELETE_STMT:
|
||||||
return jsonToDeleteStmt(pJson, pObj);
|
return jsonToDeleteStmt(pJson, pObj);
|
||||||
case QUERY_NODE_INSERT_STMT:
|
case QUERY_NODE_INSERT_STMT:
|
||||||
|
|
|
@ -682,6 +682,7 @@ int32_t nodesMakeNode(ENodeType type, SNode** ppNodeOut) {
|
||||||
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_TSMAS_STMT:
|
case QUERY_NODE_SHOW_TSMAS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_USAGE_STMT:
|
||||||
code = makeNode(type, sizeof(SShowStmt), &pNode);
|
code = makeNode(type, sizeof(SShowStmt), &pNode);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
||||||
|
@ -1526,7 +1527,8 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_TSMAS_STMT: {
|
case QUERY_NODE_SHOW_TSMAS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_USAGE_STMT: {
|
||||||
SShowStmt* pStmt = (SShowStmt*)pNode;
|
SShowStmt* pStmt = (SShowStmt*)pNode;
|
||||||
nodesDestroyNode(pStmt->pDbName);
|
nodesDestroyNode(pStmt->pDbName);
|
||||||
nodesDestroyNode(pStmt->pTbName);
|
nodesDestroyNode(pStmt->pTbName);
|
||||||
|
|
|
@ -325,6 +325,7 @@ SNode* createDefaultTSMAOptions(SAstCreateContext* pCxt);
|
||||||
SNode* createDropTSMAStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable);
|
SNode* createDropTSMAStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable);
|
||||||
SNode* createShowCreateTSMAStmt(SAstCreateContext* pCxt, SNode* pRealTable);
|
SNode* createShowCreateTSMAStmt(SAstCreateContext* pCxt, SNode* pRealTable);
|
||||||
SNode* createShowTSMASStmt(SAstCreateContext* pCxt, SNode* dbName);
|
SNode* createShowTSMASStmt(SAstCreateContext* pCxt, SNode* dbName);
|
||||||
|
SNode* createShowDiskUsageStmt(SAstCreateContext* pCxt, SNode* dbName, ENodeType type);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "cmdnodes.h"
|
||||||
#include "parToken.h"
|
#include "parToken.h"
|
||||||
#include "parUtil.h"
|
#include "parUtil.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "cmdnodes.h"
|
|
||||||
|
|
||||||
typedef struct STranslateContext {
|
typedef struct STranslateContext {
|
||||||
SParseContext* pParseCxt;
|
SParseContext* pParseCxt;
|
||||||
|
@ -46,14 +46,16 @@ typedef struct STranslateContext {
|
||||||
bool withOpt;
|
bool withOpt;
|
||||||
SNode* pPrevRoot;
|
SNode* pPrevRoot;
|
||||||
SNode* pPostRoot;
|
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;
|
} STranslateContext;
|
||||||
|
|
||||||
int32_t biRewriteToTbnameFunc(STranslateContext* pCxt, SNode** ppNode, bool* pRet);
|
int32_t biRewriteToTbnameFunc(STranslateContext* pCxt, SNode** ppNode, bool* pRet);
|
||||||
int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect);
|
int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect);
|
||||||
int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SCreateTableStmt* pStmt);
|
int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SCreateTableStmt* pStmt);
|
||||||
int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STableNode** pOutput);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -588,6 +588,7 @@ cmd ::= SHOW db_name_cond_opt(A) VIEWS like_pattern_opt(B).
|
||||||
cmd ::= SHOW CREATE VIEW full_table_name(A). { pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, A); }
|
cmd ::= SHOW CREATE VIEW full_table_name(A). { pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, A); }
|
||||||
cmd ::= SHOW COMPACTS. { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); }
|
cmd ::= SHOW COMPACTS. { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); }
|
||||||
cmd ::= SHOW COMPACT NK_INTEGER(A). { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &A)); }
|
cmd ::= SHOW COMPACT NK_INTEGER(A). { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &A)); }
|
||||||
|
cmd ::= SHOW db_name_cond_opt(A) DISK_INFO. { pCxt->pRootNode = createShowDiskUsageStmt(pCxt, A, QUERY_NODE_SHOW_USAGE_STMT); }
|
||||||
|
|
||||||
%type table_kind_db_name_cond_opt { SShowTablesOption }
|
%type table_kind_db_name_cond_opt { SShowTablesOption }
|
||||||
%destructor table_kind_db_name_cond_opt { }
|
%destructor table_kind_db_name_cond_opt { }
|
||||||
|
|
|
@ -2654,7 +2654,7 @@ static bool needDbShowStmt(ENodeType type) {
|
||||||
return QUERY_NODE_SHOW_TABLES_STMT == type || QUERY_NODE_SHOW_STABLES_STMT == type ||
|
return QUERY_NODE_SHOW_TABLES_STMT == type || QUERY_NODE_SHOW_STABLES_STMT == type ||
|
||||||
QUERY_NODE_SHOW_VGROUPS_STMT == type || QUERY_NODE_SHOW_INDEXES_STMT == type ||
|
QUERY_NODE_SHOW_VGROUPS_STMT == type || QUERY_NODE_SHOW_INDEXES_STMT == type ||
|
||||||
QUERY_NODE_SHOW_TAGS_STMT == type || QUERY_NODE_SHOW_TABLE_TAGS_STMT == type ||
|
QUERY_NODE_SHOW_TAGS_STMT == type || QUERY_NODE_SHOW_TABLE_TAGS_STMT == type ||
|
||||||
QUERY_NODE_SHOW_VIEWS_STMT == type || QUERY_NODE_SHOW_TSMAS_STMT == type;
|
QUERY_NODE_SHOW_VIEWS_STMT == type || QUERY_NODE_SHOW_TSMAS_STMT == type || QUERY_NODE_SHOW_USAGE_STMT == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) {
|
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) {
|
||||||
|
@ -3963,3 +3963,21 @@ _err:
|
||||||
nodesDestroyNode(dbName);
|
nodesDestroyNode(dbName);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
SNode* createShowDiskUsageStmt(SAstCreateContext* pCxt, SNode* dbName, ENodeType type) {
|
||||||
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
if (NULL == dbName) {
|
||||||
|
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "database not specified");
|
||||||
|
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||||
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
}
|
||||||
|
|
||||||
|
SShowStmt* pStmt = NULL;
|
||||||
|
pCxt->errCode = nodesMakeNode(type, (SNode**)&pStmt);
|
||||||
|
CHECK_MAKE_NODE(pStmt);
|
||||||
|
|
||||||
|
pStmt->pDbName = dbName;
|
||||||
|
return (SNode*)pStmt;
|
||||||
|
_err:
|
||||||
|
nodesDestroyNode(dbName);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -184,7 +184,8 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code &&
|
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_TAGS) || 0 == strcmp(pTable, TSDB_INS_TABLE_TABLES) ||
|
||||||
0 == strcmp(pTable, TSDB_INS_TABLE_FILESETS) || 0 == strcmp(pTable, TSDB_INS_TABLE_COLS)) &&
|
0 == strcmp(pTable, TSDB_INS_TABLE_COLS) || 0 == strcmp(pTable, TSDB_INS_DISK_USAGE) ||
|
||||||
|
0 == strcmp(pTable, TSDB_INS_TABLE_FILESETS)) &&
|
||||||
QUERY_NODE_SELECT_STMT == nodeType(pCxt->pStmt)) {
|
QUERY_NODE_SELECT_STMT == nodeType(pCxt->pStmt)) {
|
||||||
code = collectMetaKeyFromInsTags(pCxt);
|
code = collectMetaKeyFromInsTags(pCxt);
|
||||||
}
|
}
|
||||||
|
@ -951,6 +952,20 @@ static int32_t collectMetaKeyFromDropTSMAStmt(SCollectMetaKeyCxt* pCxt, SDropTSM
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowUsage(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code =
|
||||||
|
reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, ((SValueNode*)pStmt->pDbName)->literal,
|
||||||
|
NULL, AUTH_TYPE_READ_OR_WRITE, pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowTSMASStmt(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowTSMASStmt(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TSMAS,
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TSMAS,
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
|
@ -1098,6 +1113,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
return collectMetaKeyFromShowApps(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowApps(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
return collectMetaKeyFromShowTransactions(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowTransactions(pCxt, (SShowStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_USAGE_STMT:
|
||||||
|
return collectMetaKeyFromShowUsage(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_DELETE_STMT:
|
case QUERY_NODE_DELETE_STMT:
|
||||||
return collectMetaKeyFromDelete(pCxt, (SDeleteStmt*)pStmt);
|
return collectMetaKeyFromDelete(pCxt, (SDeleteStmt*)pStmt);
|
||||||
case QUERY_NODE_INSERT_STMT:
|
case QUERY_NODE_INSERT_STMT:
|
||||||
|
|
|
@ -29,13 +29,13 @@ typedef struct SSelectAuthCxt {
|
||||||
} SSelectAuthCxt;
|
} SSelectAuthCxt;
|
||||||
|
|
||||||
typedef struct SAuthRewriteCxt {
|
typedef struct SAuthRewriteCxt {
|
||||||
STableNode* pTarget;
|
STableNode* pTarget;
|
||||||
} SAuthRewriteCxt;
|
} SAuthRewriteCxt;
|
||||||
|
|
||||||
static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt);
|
static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt);
|
||||||
|
|
||||||
static int32_t setUserAuthInfo(SParseContext* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type,
|
static int32_t setUserAuthInfo(SParseContext* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type,
|
||||||
bool isView, bool effective, SUserAuthInfo* pAuth) {
|
bool isView, bool effective, SUserAuthInfo* pAuth) {
|
||||||
if (effective) {
|
if (effective) {
|
||||||
snprintf(pAuth->user, sizeof(pAuth->user), "%s", pCxt->pEffectiveUser ? pCxt->pEffectiveUser : "");
|
snprintf(pAuth->user, sizeof(pAuth->user), "%s", pCxt->pEffectiveUser ? pCxt->pEffectiveUser : "");
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,7 +53,8 @@ static int32_t setUserAuthInfo(SParseContext* pCxt, const char* pDbName, const c
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkAuthImpl(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond, bool isView, bool effective) {
|
static int32_t checkAuthImpl(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond,
|
||||||
|
bool isView, bool effective) {
|
||||||
SParseContext* pParseCxt = pCxt->pParseCxt;
|
SParseContext* pParseCxt = pCxt->pParseCxt;
|
||||||
if (pParseCxt->isSuperUser) {
|
if (pParseCxt->isSuperUser) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -61,7 +62,7 @@ static int32_t checkAuthImpl(SAuthCxt* pCxt, const char* pDbName, const char* pT
|
||||||
|
|
||||||
AUTH_RES_TYPE auth_res_type = isView ? AUTH_RES_VIEW : AUTH_RES_BASIC;
|
AUTH_RES_TYPE auth_res_type = isView ? AUTH_RES_VIEW : AUTH_RES_BASIC;
|
||||||
SUserAuthInfo authInfo = {0};
|
SUserAuthInfo authInfo = {0};
|
||||||
int32_t code = setUserAuthInfo(pCxt->pParseCxt, pDbName, pTabName, type, isView, effective, &authInfo);
|
int32_t code = setUserAuthInfo(pCxt->pParseCxt, pDbName, pTabName, type, isView, effective, &authInfo);
|
||||||
if (TSDB_CODE_SUCCESS != code) return code;
|
if (TSDB_CODE_SUCCESS != code) return code;
|
||||||
SUserAuthRes authRes = {0};
|
SUserAuthRes authRes = {0};
|
||||||
if (NULL != pCxt->pMetaCache) {
|
if (NULL != pCxt->pMetaCache) {
|
||||||
|
@ -82,15 +83,16 @@ static int32_t checkAuthImpl(SAuthCxt* pCxt, const char* pDbName, const char* pT
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pCond) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pCond) {
|
||||||
*pCond = authRes.pCond[auth_res_type];
|
*pCond = authRes.pCond[auth_res_type];
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS == code ? (authRes.pass[auth_res_type] ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED) : code;
|
return TSDB_CODE_SUCCESS == code ? (authRes.pass[auth_res_type] ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED)
|
||||||
|
: code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t checkAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond) {
|
static int32_t checkAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond) {
|
||||||
return checkAuthImpl(pCxt, pDbName, pTabName, type, pCond, false, false);
|
return checkAuthImpl(pCxt, pDbName, pTabName, type, pCond, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkEffectiveAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond) {
|
static int32_t checkEffectiveAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type,
|
||||||
|
SNode** pCond) {
|
||||||
return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, false, true);
|
return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +100,8 @@ static int32_t checkViewAuth(SAuthCxt* pCxt, const char* pDbName, const char* pT
|
||||||
return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, true, false);
|
return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkViewEffectiveAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond) {
|
static int32_t checkViewEffectiveAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type,
|
||||||
|
SNode** pCond) {
|
||||||
return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, true, true);
|
return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +111,7 @@ static EDealRes authSubquery(SAuthCxt* pCxt, SNode* pStmt) {
|
||||||
|
|
||||||
static int32_t mergeStableTagCond(SNode** pWhere, SNode* pTagCond) {
|
static int32_t mergeStableTagCond(SNode** pWhere, SNode* pTagCond) {
|
||||||
SLogicConditionNode* pLogicCond = NULL;
|
SLogicConditionNode* pLogicCond = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogicCond);
|
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogicCond);
|
||||||
if (NULL == pLogicCond) {
|
if (NULL == pLogicCond) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +132,7 @@ static int32_t mergeStableTagCond(SNode** pWhere, SNode* pTagCond) {
|
||||||
|
|
||||||
EDealRes rewriteAuthTable(SNode* pNode, void* pContext) {
|
EDealRes rewriteAuthTable(SNode* pNode, void* pContext) {
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
SAuthRewriteCxt* pCxt = (SAuthRewriteCxt*)pContext;
|
SAuthRewriteCxt* pCxt = (SAuthRewriteCxt*)pContext;
|
||||||
strcpy(pCol->tableName, pCxt->pTarget->tableName);
|
strcpy(pCol->tableName, pCxt->pTarget->tableName);
|
||||||
strcpy(pCol->tableAlias, pCxt->pTarget->tableAlias);
|
strcpy(pCol->tableAlias, pCxt->pTarget->tableAlias);
|
||||||
|
@ -139,7 +142,7 @@ EDealRes rewriteAuthTable(SNode* pNode, void* pContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewriteAppendStableTagCond(SNode** pWhere, SNode* pTagCond, STableNode* pTable) {
|
static int32_t rewriteAppendStableTagCond(SNode** pWhere, SNode* pTagCond, STableNode* pTable) {
|
||||||
SNode* pTagCondCopy = NULL;
|
SNode* pTagCondCopy = NULL;
|
||||||
int32_t code = nodesCloneNode(pTagCond, &pTagCondCopy);
|
int32_t code = nodesCloneNode(pTagCond, &pTagCondCopy);
|
||||||
if (NULL == pTagCondCopy) {
|
if (NULL == pTagCondCopy) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -247,6 +250,10 @@ static int32_t authShowTables(SAuthCxt* pCxt, SShowStmt* pStmt) {
|
||||||
return checkAuth(pCxt, ((SValueNode*)pStmt->pDbName)->literal, NULL, AUTH_TYPE_READ_OR_WRITE, NULL);
|
return checkAuth(pCxt, ((SValueNode*)pStmt->pDbName)->literal, NULL, AUTH_TYPE_READ_OR_WRITE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t authShowUsage(SAuthCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
return checkAuth(pCxt, ((SValueNode*)pStmt->pDbName)->literal, NULL, AUTH_TYPE_READ_OR_WRITE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t authShowCreateTable(SAuthCxt* pCxt, SShowCreateTableStmt* pStmt) {
|
static int32_t authShowCreateTable(SAuthCxt* pCxt, SShowCreateTableStmt* pStmt) {
|
||||||
SNode* pTagCond = NULL;
|
SNode* pTagCond = NULL;
|
||||||
// todo check tag condition for subtable
|
// todo check tag condition for subtable
|
||||||
|
@ -380,6 +387,7 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
|
||||||
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
case QUERY_NODE_SHOW_ARBGROUPS_STMT:
|
case QUERY_NODE_SHOW_ARBGROUPS_STMT:
|
||||||
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_USAGE_STMT:
|
||||||
return !pCxt->pParseCxt->enableSysInfo ? TSDB_CODE_PAR_PERMISSION_DENIED : TSDB_CODE_SUCCESS;
|
return !pCxt->pParseCxt->enableSysInfo ? TSDB_CODE_PAR_PERMISSION_DENIED : TSDB_CODE_SUCCESS;
|
||||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||||
|
@ -387,8 +395,8 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
|
||||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
return authShowCreateTable(pCxt, (SShowCreateTableStmt*)pStmt);
|
return authShowCreateTable(pCxt, (SShowCreateTableStmt*)pStmt);
|
||||||
// case QUERY_NODE_SHOW_CREATE_VIEW_STMT:
|
// case QUERY_NODE_SHOW_CREATE_VIEW_STMT:
|
||||||
// return authShowCreateView(pCxt, (SShowCreateViewStmt*)pStmt);
|
// return authShowCreateView(pCxt, (SShowCreateViewStmt*)pStmt);
|
||||||
case QUERY_NODE_CREATE_VIEW_STMT:
|
case QUERY_NODE_CREATE_VIEW_STMT:
|
||||||
return authCreateView(pCxt, (SCreateViewStmt*)pStmt);
|
return authCreateView(pCxt, (SCreateViewStmt*)pStmt);
|
||||||
case QUERY_NODE_DROP_VIEW_STMT:
|
case QUERY_NODE_DROP_VIEW_STMT:
|
||||||
|
|
|
@ -25,10 +25,10 @@ typedef struct SNodeReplaceContext {
|
||||||
} SNodeReplaceContext;
|
} SNodeReplaceContext;
|
||||||
|
|
||||||
typedef struct SCalcConstContext {
|
typedef struct SCalcConstContext {
|
||||||
SParseContext* pParseCxt;
|
SParseContext* pParseCxt;
|
||||||
SNodeReplaceContext replaceCxt;
|
SNodeReplaceContext replaceCxt;
|
||||||
SMsgBuf msgBuf;
|
SMsgBuf msgBuf;
|
||||||
int32_t code;
|
int32_t code;
|
||||||
} SCalcConstContext;
|
} SCalcConstContext;
|
||||||
|
|
||||||
static int32_t calcConstQuery(SCalcConstContext* pCxt, SNode* pStmt, bool subquery);
|
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) {
|
static int32_t rewriteIsTrue(SNode* pSrc, SNode** pIsTrue) {
|
||||||
SOperatorNode* pOp = NULL;
|
SOperatorNode* pOp = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOp);
|
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOp);
|
||||||
if (NULL == pOp) {
|
if (NULL == pOp) {
|
||||||
return code;
|
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) {
|
static int32_t findAndReplaceNode(SCalcConstContext* pCxt, SNode** pRoot, SNode* pTarget, SNode* pNew, bool strict) {
|
||||||
pCxt->replaceCxt.pNew = pNew;
|
pCxt->replaceCxt.pNew = pNew;
|
||||||
pCxt->replaceCxt.pTarget = pTarget;
|
pCxt->replaceCxt.pTarget = pTarget;
|
||||||
|
|
||||||
nodesRewriteExprPostOrder(pRoot, doFindAndReplaceNode, pCxt);
|
nodesRewriteExprPostOrder(pRoot, doFindAndReplaceNode, pCxt);
|
||||||
if (TSDB_CODE_SUCCESS == pCxt->code && strict && !pCxt->replaceCxt.replaced) {
|
if (TSDB_CODE_SUCCESS == pCxt->code && strict && !pCxt->replaceCxt.replaced) {
|
||||||
parserError("target replace node not found, %p", pTarget);
|
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;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (dual) {
|
if (dual) {
|
||||||
code = scalarCalculateConstantsFromDual(pProject, pNew);
|
code = scalarCalculateConstantsFromDual(pProject, pNew);
|
||||||
|
@ -226,7 +226,7 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d
|
||||||
int32_t size = taosArrayGetSize(pAssociation);
|
int32_t size = taosArrayGetSize(pAssociation);
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
SAssociationNode* pAssNode = taosArrayGet(pAssociation, i);
|
SAssociationNode* pAssNode = taosArrayGet(pAssociation, i);
|
||||||
SNode** pCol = pAssNode->pPlace;
|
SNode** pCol = pAssNode->pPlace;
|
||||||
if (*pCol == pAssNode->pAssociationNode) {
|
if (*pCol == pAssNode->pAssociationNode) {
|
||||||
strcpy(aliasName, ((SExprNode*)*pCol)->aliasName);
|
strcpy(aliasName, ((SExprNode*)*pCol)->aliasName);
|
||||||
SArray* pOrigAss = NULL;
|
SArray* pOrigAss = NULL;
|
||||||
|
@ -255,15 +255,15 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct SIsUselessColCtx {
|
typedef struct SIsUselessColCtx {
|
||||||
bool isUseless;
|
bool isUseless;
|
||||||
} SIsUselessColCtx ;
|
} SIsUselessColCtx;
|
||||||
|
|
||||||
EDealRes checkUselessCol(SNode *pNode, void *pContext) {
|
EDealRes checkUselessCol(SNode* pNode, void* pContext) {
|
||||||
SIsUselessColCtx *ctx = (SIsUselessColCtx *)pContext;
|
SIsUselessColCtx* ctx = (SIsUselessColCtx*)pContext;
|
||||||
if (QUERY_NODE_FUNCTION == nodeType(pNode) && !fmIsScalarFunc(((SFunctionNode*)pNode)->funcId) &&
|
if (QUERY_NODE_FUNCTION == nodeType(pNode) && !fmIsScalarFunc(((SFunctionNode*)pNode)->funcId) &&
|
||||||
!fmIsPseudoColumnFunc(((SFunctionNode*)pNode)->funcId)) {
|
!fmIsPseudoColumnFunc(((SFunctionNode*)pNode)->funcId)) {
|
||||||
ctx->isUseless = false;
|
ctx->isUseless = false;
|
||||||
return DEAL_RES_END;
|
return DEAL_RES_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ EDealRes checkUselessCol(SNode *pNode, void *pContext) {
|
||||||
|
|
||||||
static bool isUselessCol(SExprNode* pProj) {
|
static bool isUselessCol(SExprNode* pProj) {
|
||||||
SIsUselessColCtx ctx = {.isUseless = true};
|
SIsUselessColCtx ctx = {.isUseless = true};
|
||||||
nodesWalkExpr((SNode*)pProj, checkUselessCol, (void *)&ctx);
|
nodesWalkExpr((SNode*)pProj, checkUselessCol, (void*)&ctx);
|
||||||
if (!ctx.isUseless) {
|
if (!ctx.isUseless) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ static bool isUselessCol(SExprNode* pProj) {
|
||||||
|
|
||||||
static int32_t createConstantValue(SValueNode** ppNode) {
|
static int32_t createConstantValue(SValueNode** ppNode) {
|
||||||
SValueNode* pVal = NULL;
|
SValueNode* pVal = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
||||||
if (NULL == pVal) {
|
if (NULL == pVal) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec
|
||||||
}
|
}
|
||||||
if (0 == LIST_LENGTH(pSelect->pProjectionList)) {
|
if (0 == LIST_LENGTH(pSelect->pProjectionList)) {
|
||||||
SValueNode* pVal = NULL;
|
SValueNode* pVal = NULL;
|
||||||
int32_t code = createConstantValue(&pVal);
|
int32_t code = createConstantValue(&pVal);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
return nodesListStrictAppend(pSelect->pProjectionList, (SNode*)pVal);
|
return nodesListStrictAppend(pSelect->pProjectionList, (SNode*)pVal);
|
||||||
}
|
}
|
||||||
|
@ -359,10 +359,13 @@ static int32_t calcConstSelectFrom(SCalcConstContext* pCxt, SSelectStmt* pSelect
|
||||||
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) &&
|
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) &&
|
||||||
((STempTableNode*)pSelect->pFromTable)->pSubquery != NULL &&
|
((STempTableNode*)pSelect->pFromTable)->pSubquery != NULL &&
|
||||||
QUERY_NODE_SELECT_STMT == nodeType(((STempTableNode*)pSelect->pFromTable)->pSubquery) &&
|
QUERY_NODE_SELECT_STMT == nodeType(((STempTableNode*)pSelect->pFromTable)->pSubquery) &&
|
||||||
((SSelectStmt*)((STempTableNode*)pSelect->pFromTable)->pSubquery)->isEmptyResult){
|
((SSelectStmt*)((STempTableNode*)pSelect->pFromTable)->pSubquery)->isEmptyResult) {
|
||||||
pSelect->isEmptyResult = true;
|
pSelect->isEmptyResult = true;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
if (pSelect->mixSysTableAndActualTable) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = calcConstProjections(pCxt, pSelect, subquery);
|
code = calcConstProjections(pCxt, pSelect, subquery);
|
||||||
}
|
}
|
||||||
|
@ -518,7 +521,7 @@ static int32_t calcConstSetOpProjections(SCalcConstContext* pCxt, SSetOperator*
|
||||||
}
|
}
|
||||||
if (0 == LIST_LENGTH(pSetOp->pProjectionList)) {
|
if (0 == LIST_LENGTH(pSetOp->pProjectionList)) {
|
||||||
SValueNode* pVal = NULL;
|
SValueNode* pVal = NULL;
|
||||||
int32_t code = createConstantValue(&pVal);
|
int32_t code = createConstantValue(&pVal);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
return nodesListStrictAppend(pSetOp->pProjectionList, (SNode*)pVal);
|
return nodesListStrictAppend(pSetOp->pProjectionList, (SNode*)pVal);
|
||||||
}
|
}
|
||||||
|
@ -621,7 +624,8 @@ int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery) {
|
||||||
.msgBuf.buf = pParseCxt->pMsg,
|
.msgBuf.buf = pParseCxt->pMsg,
|
||||||
.msgBuf.len = pParseCxt->msgLen,
|
.msgBuf.len = pParseCxt->msgLen,
|
||||||
.code = TSDB_CODE_SUCCESS};
|
.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) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
resetProjectNullType(pQuery->pRoot);
|
resetProjectNullType(pQuery->pRoot);
|
||||||
if (isEmptyResultQuery(pQuery->pRoot)) {
|
if (isEmptyResultQuery(pQuery->pRoot)) {
|
||||||
|
|
|
@ -2555,6 +2555,9 @@ static int32_t checkTableClauseFirstToken(SInsertParseContext* pCxt, SVnodeModif
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pTbName->z = tbName;
|
pTbName->z = tbName;
|
||||||
pTbName->n = strlen(tbName);
|
pTbName->n = strlen(tbName);
|
||||||
|
} else if (code == TSDB_CODE_TSC_STMT_TBNAME_ERROR) {
|
||||||
|
pCxt->preCtbname = true;
|
||||||
|
code = TSDB_CODE_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -952,7 +952,7 @@ int32_t buildStbBoundFields(SBoundColInfo boundColsInfo, SSchema* pSchema, int32
|
||||||
if (preCtbname && numOfBound != boundColsInfo.numOfBound) {
|
if (preCtbname && numOfBound != boundColsInfo.numOfBound) {
|
||||||
(*fields)[idx].field_type = TAOS_FIELD_TBNAME;
|
(*fields)[idx].field_type = TAOS_FIELD_TBNAME;
|
||||||
tstrncpy((*fields)[idx].name, "tbname", sizeof((*fields)[idx].name));
|
tstrncpy((*fields)[idx].name, "tbname", sizeof((*fields)[idx].name));
|
||||||
(*fields)[idx].type = TSDB_DATA_TYPE_VARCHAR;
|
(*fields)[idx].type = TSDB_DATA_TYPE_BINARY;
|
||||||
(*fields)[idx].bytes = TSDB_TABLE_FNAME_LEN;
|
(*fields)[idx].bytes = TSDB_TABLE_FNAME_LEN;
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
@ -988,6 +988,9 @@ int32_t buildStbBoundFields(SBoundColInfo boundColsInfo, SSchema* pSchema, int32
|
||||||
if (idxCol == pMeta->tableInfo.numOfColumns + pMeta->tableInfo.numOfTags) {
|
if (idxCol == pMeta->tableInfo.numOfColumns + pMeta->tableInfo.numOfTags) {
|
||||||
(*fields)[idx].field_type = TAOS_FIELD_TBNAME;
|
(*fields)[idx].field_type = TAOS_FIELD_TBNAME;
|
||||||
tstrncpy((*fields)[i].name, "tbname", sizeof((*fields)[idx].name));
|
tstrncpy((*fields)[i].name, "tbname", sizeof((*fields)[idx].name));
|
||||||
|
(*fields)[idx].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
(*fields)[idx].bytes = TSDB_TABLE_FNAME_LEN;
|
||||||
|
idx++;
|
||||||
continue;
|
continue;
|
||||||
} else if (idxCol < pMeta->tableInfo.numOfColumns) {
|
} else if (idxCol < pMeta->tableInfo.numOfColumns) {
|
||||||
(*fields)[idx].field_type = TAOS_FIELD_COL;
|
(*fields)[idx].field_type = TAOS_FIELD_COL;
|
||||||
|
|
|
@ -350,6 +350,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"ARBGROUPS", TK_ARBGROUPS},
|
{"ARBGROUPS", TK_ARBGROUPS},
|
||||||
{"IS_IMPORT", TK_IS_IMPORT},
|
{"IS_IMPORT", TK_IS_IMPORT},
|
||||||
{"FORCE_WINDOW_CLOSE", TK_FORCE_WINDOW_CLOSE},
|
{"FORCE_WINDOW_CLOSE", TK_FORCE_WINDOW_CLOSE},
|
||||||
|
{"DISK_INFO", TK_DISK_INFO},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
|
@ -350,8 +350,7 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
||||||
.numOfShowCols = 1,
|
.numOfShowCols = 1,
|
||||||
.pShowCols = {"*"}
|
.pShowCols = {"*"}
|
||||||
},
|
},
|
||||||
{
|
{ .showType = QUERY_NODE_SHOW_ANODES_STMT,
|
||||||
.showType = QUERY_NODE_SHOW_ANODES_STMT,
|
|
||||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||||
.pTableName = TSDB_INS_TABLE_ANODES,
|
.pTableName = TSDB_INS_TABLE_ANODES,
|
||||||
.numOfShowCols = 1,
|
.numOfShowCols = 1,
|
||||||
|
@ -364,6 +363,13 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
||||||
.numOfShowCols = 1,
|
.numOfShowCols = 1,
|
||||||
.pShowCols = {"*"}
|
.pShowCols = {"*"}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.showType = QUERY_NODE_SHOW_USAGE_STMT,
|
||||||
|
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||||
|
.pTableName = TSDB_INS_DISK_USAGE,
|
||||||
|
.numOfShowCols = 1,
|
||||||
|
.pShowCols = {"*"}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.showType = QUERY_NODE_SHOW_FILESETS_STMT,
|
.showType = QUERY_NODE_SHOW_FILESETS_STMT,
|
||||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||||
|
@ -1508,6 +1514,17 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef,
|
||||||
break;
|
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 {
|
} else {
|
||||||
STempTableNode* pTempTable = (STempTableNode*)pTable;
|
STempTableNode* pTempTable = (STempTableNode*)pTable;
|
||||||
SNodeList* pProjectList = getProjectList(pTempTable->pSubquery);
|
SNodeList* pProjectList = getProjectList(pTempTable->pSubquery);
|
||||||
|
@ -2788,6 +2805,26 @@ static int32_t translateBlockDistFunc(STranslateContext* pCtx, SFunctionNode* pF
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
static int32_t translateDBUsageFunc(STranslateContext* pCtx, SFunctionNode* pFunc) {
|
||||||
|
if (!fmIsDBUsageFunc(pFunc->funcId)) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
if (!isSelectStmt(pCtx->pCurrStmt)) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCtx->msgBuf, TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE,
|
||||||
|
"%s is only supported in single table query", pFunc->functionName);
|
||||||
|
}
|
||||||
|
SSelectStmt* pSelect = (SSelectStmt*)pCtx->pCurrStmt;
|
||||||
|
SNode* pTable = pSelect->pFromTable;
|
||||||
|
// if (NULL != pTable && (QUERY_NODE_REAL_TABLE != nodeType(pTable) ||
|
||||||
|
// (TSDB_SUPER_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType &&
|
||||||
|
// TSDB_CHILD_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType &&
|
||||||
|
// TSDB_NORMAL_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType))) {
|
||||||
|
// return generateSyntaxErrMsgExt(&pCtx->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
|
||||||
|
// "%s is only supported on super table, child table or normal table",
|
||||||
|
// pFunc->functionName);
|
||||||
|
// }
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static bool isStarParam(SNode* pNode) { return nodesIsStar(pNode) || nodesIsTableStar(pNode); }
|
static bool isStarParam(SNode* pNode) { return nodesIsStar(pNode) || nodesIsTableStar(pNode); }
|
||||||
|
|
||||||
|
@ -3145,6 +3182,10 @@ static int32_t translateNormalFunction(STranslateContext* pCxt, SNode** ppNode)
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateBlockDistFunc(pCxt, pFunc);
|
code = translateBlockDistFunc(pCxt, pFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = translateDBUsageFunc(pCxt, pFunc);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
setFuncClassification(pCxt, pFunc);
|
setFuncClassification(pCxt, pFunc);
|
||||||
}
|
}
|
||||||
|
@ -3771,7 +3812,8 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList);
|
bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList);
|
||||||
FOREACH(pPartKey, pSelect->pPartitionByList) {
|
FOREACH(pPartKey, pSelect->pPartitionByList) {
|
||||||
if (nodesEqualNode(pPartKey, *pNode)) {
|
if (nodesEqualNode(pPartKey, *pNode)) {
|
||||||
return (pSelect->hasAggFuncs || pSelect->pWindow) ? rewriteExprToGroupKeyFunc(pCxt, pNode) : DEAL_RES_IGNORE_CHILD;
|
return (pSelect->hasAggFuncs || pSelect->pWindow) ? rewriteExprToGroupKeyFunc(pCxt, pNode)
|
||||||
|
: DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
if ((partionByTbname) && QUERY_NODE_COLUMN == nodeType(*pNode) &&
|
if ((partionByTbname) && QUERY_NODE_COLUMN == nodeType(*pNode) &&
|
||||||
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
||||||
|
@ -4084,7 +4126,8 @@ static int32_t dnodeToVgroupsInfo(SArray* pDnodes, SVgroupsInfo** pVgsInfo) {
|
||||||
|
|
||||||
static bool sysTableFromVnode(const char* pTable) {
|
static bool sysTableFromVnode(const char* pTable) {
|
||||||
return ((0 == strcmp(pTable, TSDB_INS_TABLE_TABLES)) || (0 == strcmp(pTable, TSDB_INS_TABLE_TAGS)) ||
|
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_FILESETS)));
|
(0 == strcmp(pTable, TSDB_INS_TABLE_COLS)) || 0 == strcmp(pTable, TSDB_INS_DISK_USAGE) ||
|
||||||
|
(0 == strcmp(pTable, TSDB_INS_TABLE_FILESETS)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool sysTableFromDnode(const char* pTable) { return 0 == strcmp(pTable, TSDB_INS_TABLE_DNODE_VARIABLES); }
|
static bool sysTableFromDnode(const char* pTable) { return 0 == strcmp(pTable, TSDB_INS_TABLE_DNODE_VARIABLES); }
|
||||||
|
@ -4155,9 +4198,10 @@ static int32_t setVnodeSysTableVgroupList(STranslateContext* pCxt, SName* pName,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code &&
|
if (TSDB_CODE_SUCCESS == code &&
|
||||||
(0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TABLES) && !hasUserDbCond) ||
|
((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_COLS) ||
|
||||||
0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_FILESETS)) {
|
(0 == strcmp(pRealTable->table.tableName, TSDB_INS_DISK_USAGE) && !hasUserDbCond) ||
|
||||||
|
0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_FILESETS))) {
|
||||||
code = addMnodeToVgroupList(&pCxt->pParseCxt->mgmtEpSet, &pVgs);
|
code = addMnodeToVgroupList(&pCxt->pParseCxt->mgmtEpSet, &pVgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4256,8 +4300,9 @@ static bool isSingleTable(SRealTableNode* pRealTable) {
|
||||||
if (TSDB_SYSTEM_TABLE == tableType) {
|
if (TSDB_SYSTEM_TABLE == tableType) {
|
||||||
return 0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TABLES) &&
|
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_TAGS) &&
|
||||||
0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_FILESETS) &&
|
0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_COLS) &&
|
||||||
0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_COLS);
|
0 != strcmp(pRealTable->table.tableName, TSDB_INS_DISK_USAGE) &&
|
||||||
|
0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_FILESETS);
|
||||||
}
|
}
|
||||||
return (TSDB_CHILD_TABLE == tableType || TSDB_NORMAL_TABLE == tableType);
|
return (TSDB_CHILD_TABLE == tableType || TSDB_NORMAL_TABLE == tableType);
|
||||||
}
|
}
|
||||||
|
@ -5402,7 +5447,8 @@ static int32_t doCheckFillValues(STranslateContext* pCxt, SFillNode* pFill, SNod
|
||||||
int32_t fillNo = 0;
|
int32_t fillNo = 0;
|
||||||
SNodeListNode* pFillValues = (SNodeListNode*)pFill->pValues;
|
SNodeListNode* pFillValues = (SNodeListNode*)pFill->pValues;
|
||||||
SNode* pProject = NULL;
|
SNode* pProject = NULL;
|
||||||
if (!pFillValues) return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Filled values number mismatch");
|
if (!pFillValues)
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Filled values number mismatch");
|
||||||
FOREACH(pProject, pProjectionList) {
|
FOREACH(pProject, pProjectionList) {
|
||||||
if (needFill(pProject)) {
|
if (needFill(pProject)) {
|
||||||
if (fillNo >= LIST_LENGTH(pFillValues->pNodeList)) {
|
if (fillNo >= LIST_LENGTH(pFillValues->pNodeList)) {
|
||||||
|
@ -6201,7 +6247,7 @@ static int32_t translateInterpEvery(STranslateContext* pCxt, SNode** pEvery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes hasRowTsOriginFuncWalkNode(SNode* pNode, void* ctx) {
|
static EDealRes hasRowTsOriginFuncWalkNode(SNode* pNode, void* ctx) {
|
||||||
bool *hasRowTsOriginFunc = ctx;
|
bool* hasRowTsOriginFunc = ctx;
|
||||||
if (nodeType(pNode) == QUERY_NODE_FUNCTION) {
|
if (nodeType(pNode) == QUERY_NODE_FUNCTION) {
|
||||||
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
||||||
if (fmIsRowTsOriginFunc(pFunc->funcId)) {
|
if (fmIsRowTsOriginFunc(pFunc->funcId)) {
|
||||||
|
@ -6216,10 +6262,12 @@ static int32_t checkInterpForStream(STranslateContext* pCxt, SSelectStmt* pSelec
|
||||||
if (pCxt->createStream) {
|
if (pCxt->createStream) {
|
||||||
SFillNode* pFill = (SFillNode*)pSelect->pFill;
|
SFillNode* pFill = (SFillNode*)pSelect->pFill;
|
||||||
if (pFill->mode == FILL_MODE_NEAR) {
|
if (pFill->mode == FILL_MODE_NEAR) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "FILL NEAR is not supported by stream");
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
|
"FILL NEAR is not supported by stream");
|
||||||
}
|
}
|
||||||
if (pSelect->pRangeAround) {
|
if (pSelect->pRangeAround) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "RANGE with around is not supported by stream");
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
|
"RANGE with around is not supported by stream");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -6244,24 +6292,25 @@ static int32_t translateInterpFill(STranslateContext* pCxt, SSelectStmt* pSelect
|
||||||
nodesWalkExprs(pSelect->pProjectionList, hasRowTsOriginFuncWalkNode, &hasRowTsOriginFunc);
|
nodesWalkExprs(pSelect->pProjectionList, hasRowTsOriginFuncWalkNode, &hasRowTsOriginFunc);
|
||||||
if (hasRowTsOriginFunc && pCxt->createStream) {
|
if (hasRowTsOriginFunc && pCxt->createStream) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
"_irowts_origin is not supported by stream");
|
"_irowts_origin is not supported by stream");
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SFillNode* pFill = (SFillNode*)pSelect->pFill;
|
SFillNode* pFill = (SFillNode*)pSelect->pFill;
|
||||||
if (pSelect->pRangeAround) {
|
if (pSelect->pRangeAround) {
|
||||||
if (pFill->mode != FILL_MODE_PREV && pFill->mode != FILL_MODE_NEXT && pFill->mode != FILL_MODE_NEAR) {
|
if (pFill->mode != FILL_MODE_PREV && pFill->mode != FILL_MODE_NEXT && pFill->mode != FILL_MODE_NEAR) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE,
|
||||||
"Range with interval can only used with fill PREV/NEXT/NEAR");
|
"Range with interval can only used with fill PREV/NEXT/NEAR");
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code)
|
if (TSDB_CODE_SUCCESS == code) code = doCheckFillValues(pCxt, pFill, pSelect->pProjectionList);
|
||||||
code = doCheckFillValues(pCxt, pFill, pSelect->pProjectionList);
|
|
||||||
} else {
|
} else {
|
||||||
if (FILL_MODE_PREV == pFill->mode || FILL_MODE_NEXT == pFill->mode || FILL_MODE_NEAR == pFill->mode) {
|
if (FILL_MODE_PREV == pFill->mode || FILL_MODE_NEXT == pFill->mode || FILL_MODE_NEAR == pFill->mode) {
|
||||||
if (pFill->pValues) {
|
if (pFill->pValues) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Can't specify fill values");
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Can't specify fill values");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hasRowTsOriginFunc) return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC, "_irowts_origin can only be used with FILL PREV/NEXT/NEAR");
|
if (hasRowTsOriginFunc)
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC,
|
||||||
|
"_irowts_origin can only be used with FILL PREV/NEXT/NEAR");
|
||||||
}
|
}
|
||||||
code = checkFillValues(pCxt, pFill, pSelect->pProjectionList);
|
code = checkFillValues(pCxt, pFill, pSelect->pProjectionList);
|
||||||
}
|
}
|
||||||
|
@ -6279,7 +6328,8 @@ static int32_t translateInterpAround(STranslateContext* pCxt, SSelectStmt* pSele
|
||||||
if (nodeType(pAround->pInterval) == QUERY_NODE_VALUE) {
|
if (nodeType(pAround->pInterval) == QUERY_NODE_VALUE) {
|
||||||
SValueNode* pVal = (SValueNode*)pAround->pInterval;
|
SValueNode* pVal = (SValueNode*)pAround->pInterval;
|
||||||
if (pVal->datum.i == 0) {
|
if (pVal->datum.i == 0) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE, "Range interval cannot be 0");
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE,
|
||||||
|
"Range interval cannot be 0");
|
||||||
}
|
}
|
||||||
int8_t unit = pVal->unit;
|
int8_t unit = pVal->unit;
|
||||||
if (unit == TIME_UNIT_YEAR || unit == TIME_UNIT_MONTH) {
|
if (unit == TIME_UNIT_YEAR || unit == TIME_UNIT_MONTH) {
|
||||||
|
@ -6332,7 +6382,7 @@ static int32_t translateInterp(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
// single point interp every can be omitted
|
// single point interp every can be omitted
|
||||||
} else {
|
} else {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_INTERP_CLAUSE,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_INTERP_CLAUSE,
|
||||||
"Missing RANGE clause, EVERY clause or FILL clause");
|
"Missing RANGE clause, EVERY clause or FILL clause");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -6341,8 +6391,7 @@ static int32_t translateInterp(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
"Range clause with around interval can't be used with EVERY clause");
|
"Range clause with around interval can't be used with EVERY clause");
|
||||||
}
|
}
|
||||||
if (!pSelect->pFill) {
|
if (!pSelect->pFill) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_INTERP_CLAUSE,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_INTERP_CLAUSE, "Missing FILL clause");
|
||||||
"Missing FILL clause");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13530,6 +13579,12 @@ static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt)
|
||||||
static int32_t createSelectStmtForShowTableDist(SShowTableDistributedStmt* pStmt, SSelectStmt** pOutput) {
|
static int32_t createSelectStmtForShowTableDist(SShowTableDistributedStmt* pStmt, SSelectStmt** pOutput) {
|
||||||
return createSimpleSelectStmtFromCols(pStmt->dbName, pStmt->tableName, 0, NULL, pOutput);
|
return createSimpleSelectStmtFromCols(pStmt->dbName, pStmt->tableName, 0, NULL, pOutput);
|
||||||
}
|
}
|
||||||
|
static int32_t createSelectStmtForShowDBUsage(SShowStmt* pStmt, SSelectStmt** pOutput) {
|
||||||
|
int32_t type = nodeType(pStmt);
|
||||||
|
const SSysTableShowAdapter* pShow = &sysTableShowAdapter[type - SYSTABLE_SHOW_TYPE_OFFSET];
|
||||||
|
return createSimpleSelectStmtFromCols(pShow->pDbName, pShow->pTableName, pShow->numOfShowCols, pShow->pShowCols,
|
||||||
|
pOutput);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t createOperatorNode(EOperatorType opType, const char* pColName, const SNode* pRight, SNode** pOp) {
|
static int32_t createOperatorNode(EOperatorType opType, const char* pColName, const SNode* pRight, SNode** pOp) {
|
||||||
if (NULL == pRight) {
|
if (NULL == pRight) {
|
||||||
|
@ -14061,6 +14116,62 @@ static int32_t rewriteShowTableDist(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
return code;
|
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);
|
||||||
|
if (NULL == pFunc) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(pFunc->functionName, "_db_usage");
|
||||||
|
strcpy(pFunc->node.aliasName, "_db_usage");
|
||||||
|
SFunctionNode* pFuncNew = NULL;
|
||||||
|
code = createBlockDBUsageInfoFunc(&pFuncNew);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodesListMakeStrictAppend(&pFunc->pParameterList, (SNode*)pFuncNew);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
nodesDestroyNode((SNode*)pFunc);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
*ppNode = pFunc;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
static int32_t rewriteShowDBUsage(STranslateContext* pCtx, SQuery* pQuery) {
|
||||||
|
SSelectStmt* pStmt = NULL;
|
||||||
|
int32_t code = createSelectStmtForShowDBUsage((SShowStmt*)pQuery->pRoot, &pStmt);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
NODES_DESTORY_LIST(pStmt->pProjectionList);
|
||||||
|
SFunctionNode* pFuncNew = NULL;
|
||||||
|
code = createDBUsageFunc(&pFuncNew);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) code = nodesListMakeStrictAppend(&pStmt->pProjectionList, (SNode*)pFuncNew);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = createShowCondition((SShowStmt*)pQuery->pRoot, pStmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
pCtx->showRewrite = true;
|
||||||
|
pQuery->showRewrite = true;
|
||||||
|
nodesDestroyNode(pQuery->pRoot);
|
||||||
|
pQuery->pRoot = (SNode*)pStmt;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct SVgroupCreateTableBatch {
|
typedef struct SVgroupCreateTableBatch {
|
||||||
SVCreateTbBatchReq req;
|
SVCreateTbBatchReq req;
|
||||||
SVgroupInfo info;
|
SVgroupInfo info;
|
||||||
|
@ -16583,6 +16694,9 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
case QUERY_NODE_SHOW_TSMAS_STMT:
|
case QUERY_NODE_SHOW_TSMAS_STMT:
|
||||||
code = rewriteShow(pCxt, pQuery);
|
code = rewriteShow(pCxt, pQuery);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_SHOW_USAGE_STMT:
|
||||||
|
code = rewriteShowDBUsage(pCxt, pQuery);
|
||||||
|
break;
|
||||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
code = rewriteShowTags(pCxt, pQuery);
|
code = rewriteShowTags(pCxt, pQuery);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "planInt.h"
|
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
#include "tglobal.h"
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
#include "planInt.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
|
||||||
// primary key column always the second column if exists
|
// primary key column always the second column if exists
|
||||||
#define PRIMARY_COLUMN_SLOT 1
|
#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) {
|
static int32_t rewriteExprForSelect(SNode* pExpr, SSelectStmt* pSelect, ESqlClause clause) {
|
||||||
nodesWalkExpr(pExpr, doNameExpr, NULL);
|
nodesWalkExpr(pExpr, doNameExpr, NULL);
|
||||||
bool isPartitionBy = (pSelect->pPartitionByList && pSelect->pPartitionByList->length > 0) ? true : false;
|
bool isPartitionBy = (pSelect->pPartitionByList && pSelect->pPartitionByList->length > 0) ? true : false;
|
||||||
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = NULL, .pOutputs = NULL, .isPartitionBy = isPartitionBy};
|
SRewriteExprCxt cxt = {
|
||||||
|
.errCode = TSDB_CODE_SUCCESS, .pExprs = NULL, .pOutputs = NULL, .isPartitionBy = isPartitionBy};
|
||||||
cxt.errCode = nodesListMakeAppend(&cxt.pExprs, pExpr);
|
cxt.errCode = nodesListMakeAppend(&cxt.pExprs, pExpr);
|
||||||
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
||||||
nodesRewriteSelectStmt(pSelect, clause, doRewriteExpr, &cxt);
|
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,
|
static int32_t rewriteExprsForSelect(SNodeList* pExprs, SSelectStmt* pSelect, ESqlClause clause,
|
||||||
SNodeList** pRewriteExprs) {
|
SNodeList** pRewriteExprs) {
|
||||||
nodesWalkExprs(pExprs, doNameExpr, NULL);
|
nodesWalkExprs(pExprs, doNameExpr, NULL);
|
||||||
bool isPartitionBy = (pSelect->pPartitionByList && pSelect->pPartitionByList->length > 0) ? true : false;
|
bool isPartitionBy = (pSelect->pPartitionByList && pSelect->pPartitionByList->length > 0) ? true : false;
|
||||||
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs, .pOutputs = NULL, .isPartitionBy = isPartitionBy};
|
SRewriteExprCxt cxt = {
|
||||||
|
.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs, .pOutputs = NULL, .isPartitionBy = isPartitionBy};
|
||||||
if (NULL != pRewriteExprs) {
|
if (NULL != pRewriteExprs) {
|
||||||
cxt.pOutputs = taosMemoryCalloc(LIST_LENGTH(pExprs), sizeof(bool));
|
cxt.pOutputs = taosMemoryCalloc(LIST_LENGTH(pExprs), sizeof(bool));
|
||||||
if (NULL == cxt.pOutputs) {
|
if (NULL == cxt.pOutputs) {
|
||||||
|
@ -271,6 +273,10 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_SYSTEM_TABLE == tableType) {
|
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;
|
return SCAN_TYPE_SYSTEM_TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +297,7 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasPkInTable(const STableMeta* pTableMeta) {
|
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) {
|
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) {
|
static int32_t addPrimaryKeyCol(SRealTableNode* pTable, SNodeList** pCols) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
SNode* pCol = NULL;
|
SNode* pCol = NULL;
|
||||||
SSchema* pSchema = &pTable->pMeta->schema[PRIMARY_COLUMN_SLOT];
|
SSchema* pSchema = &pTable->pMeta->schema[PRIMARY_COLUMN_SLOT];
|
||||||
FOREACH(pCol, *pCols) {
|
FOREACH(pCol, *pCols) {
|
||||||
if (pSchema->colId == ((SColumnNode*)pCol)->colId) {
|
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,
|
static int32_t makeScanLogicNode(SLogicPlanContext* pCxt, SRealTableNode* pRealTable, bool hasRepeatScanFuncs,
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
SScanLogicNode* pScan = NULL;
|
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) {
|
if (NULL == pScan) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -427,7 +433,8 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
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);
|
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) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SNodeList* pNewScanPseudoCols = NULL;
|
SNodeList* pNewScanPseudoCols = NULL;
|
||||||
code = rewriteExprsForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM, NULL);
|
code = rewriteExprsForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM, NULL);
|
||||||
/*
|
/*
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pScan->pScanPseudoCols) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pScan->pScanPseudoCols) {
|
||||||
code = createColumnByRewriteExprs(pScan->pScanPseudoCols, &pNewScanPseudoCols);
|
code = createColumnByRewriteExprs(pScan->pScanPseudoCols, &pNewScanPseudoCols);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
nodesDestroyList(pScan->pScanPseudoCols);
|
nodesDestroyList(pScan->pScanPseudoCols);
|
||||||
pScan->pScanPseudoCols = pNewScanPseudoCols;
|
pScan->pScanPseudoCols = pNewScanPseudoCols;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != pScan->pScanCols) {
|
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) {
|
int32_t collectJoinResColumns(SSelectStmt* pSelect, SJoinLogicNode* pJoin, SNodeList** pCols) {
|
||||||
SSHashObj* pTables = NULL;
|
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) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return 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,
|
static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SJoinTableNode* pJoinTable,
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SJoinLogicNode* pJoin = NULL;
|
SJoinLogicNode* pJoin = NULL;
|
||||||
code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_JOIN, (SNode**)&pJoin);
|
code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_JOIN, (SNode**)&pJoin);
|
||||||
if (NULL == pJoin) {
|
if (NULL == pJoin) {
|
||||||
|
@ -555,7 +562,8 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesMakeList(&pJoin->node.pChildren);
|
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;
|
SLogicNode* pLeft = NULL;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -638,7 +646,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
}
|
}
|
||||||
nodesDestroyList(pColList);
|
nodesDestroyList(pColList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
rewriteTargetsWithResId(pJoin->node.pTargets);
|
rewriteTargetsWithResId(pJoin->node.pTargets);
|
||||||
}
|
}
|
||||||
|
@ -649,7 +657,6 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
*pLogicNode = (SLogicNode*)pJoin;
|
*pLogicNode = (SLogicNode*)pJoin;
|
||||||
} else {
|
} else {
|
||||||
|
@ -708,7 +715,7 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr)
|
||||||
|
|
||||||
static int32_t createGroupingSetNode(SNode* pExpr, SNode** ppNode) {
|
static int32_t createGroupingSetNode(SNode* pExpr, SNode** ppNode) {
|
||||||
SGroupingSetNode* pGroupingSet = NULL;
|
SGroupingSetNode* pGroupingSet = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
*ppNode = NULL;
|
*ppNode = NULL;
|
||||||
code = nodesMakeNode(QUERY_NODE_GROUPING_SET, (SNode**)&pGroupingSet);
|
code = nodesMakeNode(QUERY_NODE_GROUPING_SET, (SNode**)&pGroupingSet);
|
||||||
if (NULL == pGroupingSet) {
|
if (NULL == pGroupingSet) {
|
||||||
|
@ -731,13 +738,15 @@ static EGroupAction getDistinctGroupAction(SLogicPlanContext* pCxt, SSelectStmt*
|
||||||
: GROUP_ACTION_NONE;
|
: GROUP_ACTION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isWindowJoinStmt(SSelectStmt * pSelect) {
|
static bool isWindowJoinStmt(SSelectStmt* pSelect) {
|
||||||
return (QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) && IS_WINDOW_JOIN(((SJoinTableNode*)pSelect->pFromTable)->subType));
|
return (QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) &&
|
||||||
|
IS_WINDOW_JOIN(((SJoinTableNode*)pSelect->pFromTable)->subType));
|
||||||
}
|
}
|
||||||
|
|
||||||
static EGroupAction getGroupAction(SLogicPlanContext* pCxt, SSelectStmt* pSelect) {
|
static EGroupAction getGroupAction(SLogicPlanContext* pCxt, SSelectStmt* pSelect) {
|
||||||
return ((pCxt->pPlanCxt->streamQuery || NULL != pSelect->pLimit || NULL != pSelect->pSlimit) && !pSelect->isDistinct) ? GROUP_ACTION_KEEP
|
return ((pCxt->pPlanCxt->streamQuery || NULL != pSelect->pLimit || NULL != pSelect->pSlimit) && !pSelect->isDistinct)
|
||||||
: GROUP_ACTION_NONE;
|
? GROUP_ACTION_KEEP
|
||||||
|
: GROUP_ACTION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDataOrderLevel getRequireDataOrder(bool needTimeline, SSelectStmt* pSelect) {
|
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) {
|
static int32_t addWinJoinPrimKeyToAggFuncs(SSelectStmt* pSelect, SNodeList** pList) {
|
||||||
SNodeList* pTargets = *pList;
|
SNodeList* pTargets = *pList;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (pTargets) {
|
if (pTargets) {
|
||||||
code = nodesMakeList(&pTargets);
|
code = nodesMakeList(&pTargets);
|
||||||
}
|
}
|
||||||
|
@ -811,7 +820,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
|
||||||
}
|
}
|
||||||
|
|
||||||
SAggLogicNode* pAgg = NULL;
|
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) {
|
if (NULL == pAgg) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -890,7 +899,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
|
||||||
}
|
}
|
||||||
|
|
||||||
SIndefRowsFuncLogicNode* pIdfRowsFunc = NULL;
|
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) {
|
if (NULL == pIdfRowsFunc) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -923,7 +932,8 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isInterpFunc(int32_t funcId) {
|
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 void initStreamOption(SLogicPlanContext* pCxt, SStreamNodeOption* pOption) {
|
static void initStreamOption(SLogicPlanContext* pCxt, SStreamNodeOption* pOption) {
|
||||||
|
@ -941,7 +951,7 @@ static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
|
||||||
}
|
}
|
||||||
|
|
||||||
SInterpFuncLogicNode* pInterpFunc = NULL;
|
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) {
|
if (NULL == pInterpFunc) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1002,7 +1012,8 @@ static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isForecastFunc(int32_t funcId) {
|
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) {
|
static int32_t createForecastFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||||
|
@ -1011,7 +1022,7 @@ static int32_t createForecastFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt*
|
||||||
}
|
}
|
||||||
|
|
||||||
SForecastFuncLogicNode* pForecastFunc = NULL;
|
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) {
|
if (NULL == pForecastFunc) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1079,7 +1090,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
|
||||||
static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindowNode* pState, SSelectStmt* pSelect,
|
static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindowNode* pState, SSelectStmt* pSelect,
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
SWindowLogicNode* pWindow = NULL;
|
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) {
|
if (NULL == pWindow) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1115,7 +1126,7 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo
|
||||||
static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionWindowNode* pSession,
|
static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionWindowNode* pSession,
|
||||||
SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||||
SWindowLogicNode* pWindow = NULL;
|
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) {
|
if (NULL == pWindow) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1148,7 +1159,7 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW
|
||||||
static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SIntervalWindowNode* pInterval,
|
static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SIntervalWindowNode* pInterval,
|
||||||
SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||||
SWindowLogicNode* pWindow = NULL;
|
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) {
|
if (NULL == pWindow) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1182,7 +1193,7 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
|
||||||
static int32_t createWindowLogicNodeByEvent(SLogicPlanContext* pCxt, SEventWindowNode* pEvent, SSelectStmt* pSelect,
|
static int32_t createWindowLogicNodeByEvent(SLogicPlanContext* pCxt, SEventWindowNode* pEvent, SSelectStmt* pSelect,
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
SWindowLogicNode* pWindow = NULL;
|
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) {
|
if (NULL == pWindow) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1219,7 +1230,7 @@ static int32_t createWindowLogicNodeByEvent(SLogicPlanContext* pCxt, SEventWindo
|
||||||
static int32_t createWindowLogicNodeByCount(SLogicPlanContext* pCxt, SCountWindowNode* pCount, SSelectStmt* pSelect,
|
static int32_t createWindowLogicNodeByCount(SLogicPlanContext* pCxt, SCountWindowNode* pCount, SSelectStmt* pSelect,
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
SWindowLogicNode* pWindow = NULL;
|
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) {
|
if (NULL == pWindow) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1308,11 +1319,11 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct SCollectFillExprsCtx {
|
typedef struct SCollectFillExprsCtx {
|
||||||
SHashObj* pPseudoCols;
|
SHashObj* pPseudoCols;
|
||||||
SNodeList* pFillExprs;
|
SNodeList* pFillExprs;
|
||||||
SNodeList* pNotFillExprs;
|
SNodeList* pNotFillExprs;
|
||||||
bool collectAggFuncs;
|
bool collectAggFuncs;
|
||||||
SNodeList* pAggFuncCols;
|
SNodeList* pAggFuncCols;
|
||||||
} SCollectFillExprsCtx;
|
} SCollectFillExprsCtx;
|
||||||
|
|
||||||
typedef struct SWalkFillSubExprCtx {
|
typedef struct SWalkFillSubExprCtx {
|
||||||
|
@ -1334,8 +1345,8 @@ static bool nodeAlreadyContained(SNodeList* pList, SNode* pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes needFillValueImpl(SNode* pNode, void* pContext) {
|
static EDealRes needFillValueImpl(SNode* pNode, void* pContext) {
|
||||||
SWalkFillSubExprCtx *pCtx = pContext;
|
SWalkFillSubExprCtx* pCtx = pContext;
|
||||||
EDealRes res = DEAL_RES_CONTINUE;
|
EDealRes res = DEAL_RES_CONTINUE;
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
if (COLUMN_TYPE_WINDOW_START == pCol->colType || COLUMN_TYPE_WINDOW_END == pCol->colType ||
|
if (COLUMN_TYPE_WINDOW_START == pCol->colType || COLUMN_TYPE_WINDOW_END == pCol->colType ||
|
||||||
|
@ -1365,14 +1376,12 @@ static EDealRes needFillValueImpl(SNode* pNode, void* pContext) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void needFillValue(SNode* pNode, SWalkFillSubExprCtx* pCtx) {
|
static void needFillValue(SNode* pNode, SWalkFillSubExprCtx* pCtx) { nodesWalkExpr(pNode, needFillValueImpl, pCtx); }
|
||||||
nodesWalkExpr(pNode, needFillValueImpl, pCtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t collectFillExpr(SNode* pNode, SCollectFillExprsCtx* pCollectFillCtx) {
|
static int32_t collectFillExpr(SNode* pNode, SCollectFillExprsCtx* pCollectFillCtx) {
|
||||||
SNode* pNew = NULL;
|
SNode* pNew = NULL;
|
||||||
SWalkFillSubExprCtx collectFillSubExprCtx = {
|
SWalkFillSubExprCtx collectFillSubExprCtx = {
|
||||||
.hasFillCol = false, .hasPseudoWinCol = false, .hasGroupKeyCol = false, .pCollectFillCtx = pCollectFillCtx};
|
.hasFillCol = false, .hasPseudoWinCol = false, .hasGroupKeyCol = false, .pCollectFillCtx = pCollectFillCtx};
|
||||||
needFillValue(pNode, &collectFillSubExprCtx);
|
needFillValue(pNode, &collectFillSubExprCtx);
|
||||||
if (collectFillSubExprCtx.code != TSDB_CODE_SUCCESS) {
|
if (collectFillSubExprCtx.code != TSDB_CODE_SUCCESS) {
|
||||||
return collectFillSubExprCtx.code;
|
return collectFillSubExprCtx.code;
|
||||||
|
@ -1416,7 +1425,7 @@ static int32_t collectFillExprs(SSelectStmt* pSelect, SNodeList** pFillExprs, SN
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
void* pIter = taosHashIterate(collectFillCtx.pPseudoCols, 0);
|
void* pIter = taosHashIterate(collectFillCtx.pPseudoCols, 0);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SNode* pNode = *(SNode**)pIter, *pNew = NULL;
|
SNode *pNode = *(SNode**)pIter, *pNew = NULL;
|
||||||
code = nodesCloneNode(pNode, &pNew);
|
code = nodesCloneNode(pNode, &pNew);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
code = nodesListMakeStrictAppend(&collectFillCtx.pNotFillExprs, pNew);
|
code = nodesListMakeStrictAppend(&collectFillCtx.pNotFillExprs, pNew);
|
||||||
|
@ -1455,7 +1464,7 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
}
|
}
|
||||||
|
|
||||||
SFillLogicNode* pFill = NULL;
|
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) {
|
if (NULL == pFill) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1521,7 +1530,7 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
}
|
}
|
||||||
|
|
||||||
SSortLogicNode* pSort = NULL;
|
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) {
|
if (NULL == pSort) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1577,12 +1586,12 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
static int32_t createColumnByProjections(SLogicPlanContext* pCxt, const char* pStmtName, SNodeList* pExprs,
|
static int32_t createColumnByProjections(SLogicPlanContext* pCxt, const char* pStmtName, SNodeList* pExprs,
|
||||||
SNodeList** pCols) {
|
SNodeList** pCols) {
|
||||||
SNodeList* pList = NULL;
|
SNodeList* pList = NULL;
|
||||||
int32_t code = nodesMakeList(&pList);
|
int32_t code = nodesMakeList(&pList);
|
||||||
if (NULL == pList) {
|
if (NULL == pList) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* pNode;
|
SNode* pNode;
|
||||||
int32_t projIdx = 1;
|
int32_t projIdx = 1;
|
||||||
FOREACH(pNode, pExprs) {
|
FOREACH(pNode, pExprs) {
|
||||||
SColumnNode* pCol = createColumnByExpr(pStmtName, (SExprNode*)pNode);
|
SColumnNode* pCol = createColumnByExpr(pStmtName, (SExprNode*)pNode);
|
||||||
|
@ -1599,7 +1608,7 @@ static int32_t createColumnByProjections(SLogicPlanContext* pCxt, const char* pS
|
||||||
|
|
||||||
static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||||
SProjectLogicNode* pProject = NULL;
|
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) {
|
if (NULL == pProject) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1638,7 +1647,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
|
||||||
}
|
}
|
||||||
|
|
||||||
SPartitionLogicNode* pPartition = NULL;
|
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) {
|
if (NULL == pPartition) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1660,7 +1669,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
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);
|
code = nodesCollectFuncs(pSelect, SQL_CLAUSE_PARTITION_BY, NULL, fmIsAggFunc, &pPartition->pAggFuncs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1673,7 +1682,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
|
||||||
nodeType(pSelect->pWindow) == QUERY_NODE_INTERVAL_WINDOW) {
|
nodeType(pSelect->pWindow) == QUERY_NODE_INTERVAL_WINDOW) {
|
||||||
pPartition->needBlockOutputTsOrder = true;
|
pPartition->needBlockOutputTsOrder = true;
|
||||||
SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pSelect->pWindow;
|
SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pSelect->pWindow;
|
||||||
SColumnNode* pTsCol = (SColumnNode*)pInterval->pCol;
|
SColumnNode* pTsCol = (SColumnNode*)pInterval->pCol;
|
||||||
pPartition->pkTsColId = pTsCol->colId;
|
pPartition->pkTsColId = pTsCol->colId;
|
||||||
pPartition->pkTsColTbId = pTsCol->tableId;
|
pPartition->pkTsColTbId = pTsCol->tableId;
|
||||||
}
|
}
|
||||||
|
@ -1709,12 +1718,12 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
|
||||||
}
|
}
|
||||||
|
|
||||||
SAggLogicNode* pAgg = NULL;
|
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) {
|
if (NULL == pAgg) {
|
||||||
return code;
|
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.requireDataOrder = DATA_ORDER_LEVEL_NONE;
|
||||||
pAgg->node.resultDataOrder = DATA_ORDER_LEVEL_NONE;
|
pAgg->node.resultDataOrder = DATA_ORDER_LEVEL_NONE;
|
||||||
|
|
||||||
|
@ -1828,7 +1837,7 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p
|
||||||
}
|
}
|
||||||
|
|
||||||
SSortLogicNode* pSort = NULL;
|
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) {
|
if (NULL == pSort) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1855,7 +1864,7 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p
|
||||||
static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator,
|
static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator,
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
SProjectLogicNode* pProject = NULL;
|
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) {
|
if (NULL == pProject) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1885,7 +1894,7 @@ static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator
|
||||||
|
|
||||||
static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator, SLogicNode** pLogicNode) {
|
static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator, SLogicNode** pLogicNode) {
|
||||||
SAggLogicNode* pAgg = NULL;
|
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) {
|
if (NULL == pAgg) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1993,7 +2002,7 @@ static int32_t getMsgType(ENodeType sqlType) {
|
||||||
|
|
||||||
static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifyOpStmt* pStmt, SLogicNode** pLogicNode) {
|
static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifyOpStmt* pStmt, SLogicNode** pLogicNode) {
|
||||||
SVnodeModifyLogicNode* pModif = NULL;
|
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) {
|
if (NULL == pModif) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2011,7 +2020,7 @@ static int32_t createDeleteRootLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
|
||||||
|
|
||||||
static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
||||||
SScanLogicNode* pScan = NULL;
|
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
|
// set columns to scan
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -2046,7 +2055,7 @@ static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
|
||||||
|
|
||||||
static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
||||||
SAggLogicNode* pAgg = NULL;
|
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) {
|
if (NULL == pAgg) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2096,7 +2105,7 @@ static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pD
|
||||||
static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDeleteStmt* pDelete,
|
static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDeleteStmt* pDelete,
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
SVnodeModifyLogicNode* pModify = NULL;
|
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) {
|
if (NULL == pModify) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2157,7 +2166,7 @@ static int32_t creatInsertRootLogicNode(SLogicPlanContext* pCxt, SInsertStmt* pI
|
||||||
static int32_t createVnodeModifLogicNodeByInsert(SLogicPlanContext* pCxt, SInsertStmt* pInsert,
|
static int32_t createVnodeModifLogicNodeByInsert(SLogicPlanContext* pCxt, SInsertStmt* pInsert,
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
SVnodeModifyLogicNode* pModify = NULL;
|
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) {
|
if (NULL == pModify) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2240,7 +2249,7 @@ int32_t createLogicPlan(SPlanContext* pCxt, SLogicSubplan** pLogicSubplan) {
|
||||||
SLogicPlanContext cxt = {.pPlanCxt = pCxt, .pCurrRoot = NULL, .hasScan = false};
|
SLogicPlanContext cxt = {.pPlanCxt = pCxt, .pCurrRoot = NULL, .hasScan = false};
|
||||||
|
|
||||||
SLogicSubplan* pSubplan = NULL;
|
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) {
|
if (NULL == pSubplan) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,8 +30,7 @@ typedef struct SSlotIndex {
|
||||||
SArray* pSlotIdsInfo; // duplicate name slot
|
SArray* pSlotIdsInfo; // duplicate name slot
|
||||||
} SSlotIndex;
|
} SSlotIndex;
|
||||||
|
|
||||||
|
static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char** ppKey, int32_t* pLen, uint16_t extraBufLen) {
|
||||||
static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char** ppKey, int32_t *pLen, uint16_t extraBufLen) {
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
|
@ -125,11 +124,10 @@ static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char** ppKey, int
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static SNode* createSlotDesc(SPhysiPlanContext* pCxt, const char* pName, const SNode* pNode, int16_t slotId,
|
static SNode* createSlotDesc(SPhysiPlanContext* pCxt, const char* pName, const SNode* pNode, int16_t slotId,
|
||||||
bool output, bool reserve) {
|
bool output, bool reserve) {
|
||||||
SSlotDescNode* pSlot = NULL;
|
SSlotDescNode* pSlot = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_SLOT_DESC, (SNode**)&pSlot);
|
int32_t code = nodesMakeNode(QUERY_NODE_SLOT_DESC, (SNode**)&pSlot);
|
||||||
if (NULL == pSlot) {
|
if (NULL == pSlot) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -144,7 +142,7 @@ static SNode* createSlotDesc(SPhysiPlanContext* pCxt, const char* pName, const S
|
||||||
|
|
||||||
static int32_t createTarget(SNode* pNode, int16_t dataBlockId, int16_t slotId, SNode** pOutput) {
|
static int32_t createTarget(SNode* pNode, int16_t dataBlockId, int16_t slotId, SNode** pOutput) {
|
||||||
STargetNode* pTarget = NULL;
|
STargetNode* pTarget = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_TARGET, (SNode**)&pTarget);
|
int32_t code = nodesMakeNode(QUERY_NODE_TARGET, (SNode**)&pTarget);
|
||||||
if (NULL == pTarget) {
|
if (NULL == pTarget) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +176,8 @@ static int32_t putSlotToHashImpl(int16_t dataBlockId, int16_t slotId, const char
|
||||||
return taosHashPut(pHash, pName, len, &index, sizeof(SSlotIndex));
|
return taosHashPut(pHash, pName, len, &index, sizeof(SSlotIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t putSlotToHash(const char* pName, int32_t len, int16_t dataBlockId, int16_t slotId, SNode* pNode, SHashObj* pHash) {
|
static int32_t putSlotToHash(const char* pName, int32_t len, int16_t dataBlockId, int16_t slotId, SNode* pNode,
|
||||||
|
SHashObj* pHash) {
|
||||||
return putSlotToHashImpl(dataBlockId, slotId, pName, len, pHash);
|
return putSlotToHashImpl(dataBlockId, slotId, pName, len, pHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +219,7 @@ static int32_t buildDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SD
|
||||||
int16_t slotId = 0;
|
int16_t slotId = 0;
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pList) {
|
FOREACH(pNode, pList) {
|
||||||
char* name = NULL;
|
char* name = NULL;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
code = getSlotKey(pNode, NULL, &name, &len, 16);
|
code = getSlotKey(pNode, NULL, &name, &len, 16);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -247,7 +246,7 @@ static int32_t buildDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SD
|
||||||
|
|
||||||
static int32_t createDataBlockDesc(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode** pDataBlockDesc) {
|
static int32_t createDataBlockDesc(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode** pDataBlockDesc) {
|
||||||
SDataBlockDescNode* pDesc = NULL;
|
SDataBlockDescNode* pDesc = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_DATABLOCK_DESC, (SNode**)&pDesc);
|
int32_t code = nodesMakeNode(QUERY_NODE_DATABLOCK_DESC, (SNode**)&pDesc);
|
||||||
if (NULL == pDesc) {
|
if (NULL == pDesc) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -292,15 +291,15 @@ static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList,
|
||||||
int16_t nextSlotId = LIST_LENGTH(pDataBlockDesc->pSlots), slotId = 0;
|
int16_t nextSlotId = LIST_LENGTH(pDataBlockDesc->pSlots), slotId = 0;
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pList) {
|
FOREACH(pNode, pList) {
|
||||||
SNode* pExpr = QUERY_NODE_ORDER_BY_EXPR == nodeType(pNode) ? ((SOrderByExprNode*)pNode)->pExpr : pNode;
|
SNode* pExpr = QUERY_NODE_ORDER_BY_EXPR == nodeType(pNode) ? ((SOrderByExprNode*)pNode)->pExpr : pNode;
|
||||||
char *name = NULL;
|
char* name = NULL;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
code = getSlotKey(pExpr, pStmtName, &name, &len, 0);
|
code = getSlotKey(pExpr, pStmtName, &name, &len, 0);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SSlotIndex* pIndex = taosHashGet(pHash, name, len);
|
SSlotIndex* pIndex = taosHashGet(pHash, name, len);
|
||||||
if (NULL == pIndex) {
|
if (NULL == pIndex) {
|
||||||
code =
|
code = nodesListStrictAppend(pDataBlockDesc->pSlots,
|
||||||
nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, name, pExpr, nextSlotId, output, reserve));
|
createSlotDesc(pCxt, name, pExpr, nextSlotId, output, reserve));
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = putSlotToHashImpl(pDataBlockDesc->dataBlockId, nextSlotId, name, len, pHash);
|
code = putSlotToHashImpl(pDataBlockDesc->dataBlockId, nextSlotId, name, len, pHash);
|
||||||
}
|
}
|
||||||
|
@ -315,7 +314,7 @@ static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(name);
|
taosMemoryFree(name);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SNode* pTarget = NULL;
|
SNode* pTarget = NULL;
|
||||||
code = createTarget(pNode, pDataBlockDesc->dataBlockId, slotId, &pTarget);
|
code = createTarget(pNode, pDataBlockDesc->dataBlockId, slotId, &pTarget);
|
||||||
|
@ -388,13 +387,13 @@ static void dumpSlots(const char* pName, SHashObj* pHash) {
|
||||||
static EDealRes doSetSlotId(SNode* pNode, void* pContext) {
|
static EDealRes doSetSlotId(SNode* pNode, void* pContext) {
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode) && 0 != strcmp(((SColumnNode*)pNode)->colName, "*")) {
|
if (QUERY_NODE_COLUMN == nodeType(pNode) && 0 != strcmp(((SColumnNode*)pNode)->colName, "*")) {
|
||||||
SSetSlotIdCxt* pCxt = (SSetSlotIdCxt*)pContext;
|
SSetSlotIdCxt* pCxt = (SSetSlotIdCxt*)pContext;
|
||||||
char *name = NULL;
|
char* name = NULL;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
pCxt->errCode = getSlotKey(pNode, NULL, &name, &len, 16);
|
pCxt->errCode = getSlotKey(pNode, NULL, &name, &len, 16);
|
||||||
if (TSDB_CODE_SUCCESS != pCxt->errCode) {
|
if (TSDB_CODE_SUCCESS != pCxt->errCode) {
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
SSlotIndex *pIndex = NULL;
|
SSlotIndex* pIndex = NULL;
|
||||||
if (((SColumnNode*)pNode)->projRefIdx > 0) {
|
if (((SColumnNode*)pNode)->projRefIdx > 0) {
|
||||||
sprintf(name + strlen(name), "_%d", ((SColumnNode*)pNode)->projRefIdx);
|
sprintf(name + strlen(name), "_%d", ((SColumnNode*)pNode)->projRefIdx);
|
||||||
pIndex = taosHashGet(pCxt->pLeftProjIdxHash, name, strlen(name));
|
pIndex = taosHashGet(pCxt->pLeftProjIdxHash, name, strlen(name));
|
||||||
|
@ -430,7 +429,7 @@ static int32_t setNodeSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, i
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* pRes = NULL;
|
SNode* pRes = NULL;
|
||||||
int32_t code = nodesCloneNode(pNode, &pRes);
|
int32_t code = nodesCloneNode(pNode, &pRes);
|
||||||
if (NULL == pRes) {
|
if (NULL == pRes) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -459,7 +458,7 @@ static int32_t setListSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, i
|
||||||
}
|
}
|
||||||
|
|
||||||
SNodeList* pRes = NULL;
|
SNodeList* pRes = NULL;
|
||||||
int32_t code = nodesCloneList(pList, &pRes);
|
int32_t code = nodesCloneList(pList, &pRes);
|
||||||
if (NULL == pRes) {
|
if (NULL == pRes) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -481,7 +480,7 @@ static int32_t setListSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, i
|
||||||
|
|
||||||
static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, ENodeType type) {
|
static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, ENodeType type) {
|
||||||
SPhysiNode* pPhysiNode = NULL;
|
SPhysiNode* pPhysiNode = NULL;
|
||||||
int32_t code = nodesMakeNode(type, (SNode**)&pPhysiNode);
|
int32_t code = nodesMakeNode(type, (SNode**)&pPhysiNode);
|
||||||
if (NULL == pPhysiNode) {
|
if (NULL == pPhysiNode) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -524,7 +523,7 @@ static int32_t sortScanCols(SNodeList* pScanCols) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SNode* pCol = NULL;
|
SNode* pCol = NULL;
|
||||||
FOREACH(pCol, pScanCols) {
|
FOREACH(pCol, pScanCols) {
|
||||||
if (NULL == taosArrayPush(pArray, &pCol)) {
|
if (NULL == taosArrayPush(pArray, &pCol)) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
@ -654,7 +653,7 @@ static int32_t createSimpleScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSub
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
|
static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
STagScanPhysiNode* pScan =
|
STagScanPhysiNode* pScan =
|
||||||
(STagScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN);
|
(STagScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN);
|
||||||
if (NULL == pScan) {
|
if (NULL == pScan) {
|
||||||
|
@ -677,7 +676,7 @@ static int32_t createLastRowScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSu
|
||||||
}
|
}
|
||||||
pScan->pTargets = NULL;
|
pScan->pTargets = NULL;
|
||||||
int32_t code = nodesCloneList(pScanLogicNode->node.pTargets, &pScan->pTargets);
|
int32_t code = nodesCloneList(pScanLogicNode->node.pTargets, &pScan->pTargets);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
nodesDestroyNode((SNode*)pScan);
|
nodesDestroyNode((SNode*)pScan);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -703,7 +702,7 @@ static int32_t createLastRowScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSu
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* pTargetNode = NULL;
|
SNode* pTargetNode = NULL;
|
||||||
int funcTypeIndex = 0;
|
int funcTypeIndex = 0;
|
||||||
FOREACH(pTargetNode, ((SScanPhysiNode*)pScan)->pScanCols) {
|
FOREACH(pTargetNode, ((SScanPhysiNode*)pScan)->pScanCols) {
|
||||||
if (((STargetNode*)pTargetNode)->pExpr->type != QUERY_NODE_COLUMN) {
|
if (((STargetNode*)pTargetNode)->pExpr->type != QUERY_NODE_COLUMN) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -713,7 +712,7 @@ static int32_t createLastRowScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSu
|
||||||
for (int i = 0; i < TARRAY_SIZE(pScanLogicNode->pFuncTypes); ++i) {
|
for (int i = 0; i < TARRAY_SIZE(pScanLogicNode->pFuncTypes); ++i) {
|
||||||
SFunctParam* pFunctParam = taosArrayGet(pScanLogicNode->pFuncTypes, i);
|
SFunctParam* pFunctParam = taosArrayGet(pScanLogicNode->pFuncTypes, i);
|
||||||
if (pColNode->colId == pFunctParam->pCol->colId &&
|
if (pColNode->colId == pFunctParam->pCol->colId &&
|
||||||
0 == strncmp(pColNode->colName, pFunctParam->pCol->name, strlen(pColNode->colName))) {
|
0 == strncmp(pColNode->colName, pFunctParam->pCol->name, strlen(pColNode->colName))) {
|
||||||
if (NULL == taosArrayInsert(pScan->pFuncTypes, funcTypeIndex, &pFunctParam->type)) {
|
if (NULL == taosArrayInsert(pScan->pFuncTypes, funcTypeIndex, &pFunctParam->type)) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
}
|
}
|
||||||
|
@ -767,13 +766,13 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
|
||||||
pTableScan->dataRequired = pScanLogicNode->dataRequired;
|
pTableScan->dataRequired = pScanLogicNode->dataRequired;
|
||||||
pTableScan->pDynamicScanFuncs = NULL;
|
pTableScan->pDynamicScanFuncs = NULL;
|
||||||
int32_t code = nodesCloneList(pScanLogicNode->pDynamicScanFuncs, &pTableScan->pDynamicScanFuncs);
|
int32_t code = nodesCloneList(pScanLogicNode->pDynamicScanFuncs, &pTableScan->pDynamicScanFuncs);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
nodesDestroyNode((SNode*)pTableScan);
|
nodesDestroyNode((SNode*)pTableScan);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
pTableScan->pGroupTags = NULL;
|
pTableScan->pGroupTags = NULL;
|
||||||
code = nodesCloneList(pScanLogicNode->pGroupTags, &pTableScan->pGroupTags);
|
code = nodesCloneList(pScanLogicNode->pGroupTags, &pTableScan->pGroupTags);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
nodesDestroyNode((SNode*)pTableScan);
|
nodesDestroyNode((SNode*)pTableScan);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -820,6 +819,7 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
|
||||||
if (0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_TABLES) ||
|
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_TAGS) ||
|
||||||
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_COLS) ||
|
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_COLS) ||
|
||||||
|
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_DISK_USAGE) ||
|
||||||
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_FILESETS)) {
|
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_FILESETS)) {
|
||||||
if (pScanLogicNode->pVgroupList) {
|
if (pScanLogicNode->pVgroupList) {
|
||||||
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
|
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
|
||||||
|
@ -878,22 +878,25 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
|
||||||
static int32_t getJoinDataBlockDescNode(SNodeList* pChildren, int32_t idx, SDataBlockDescNode** ppDesc) {
|
static int32_t getJoinDataBlockDescNode(SNodeList* pChildren, int32_t idx, SDataBlockDescNode** ppDesc) {
|
||||||
if (2 == pChildren->length) {
|
if (2 == pChildren->length) {
|
||||||
*ppDesc = ((SPhysiNode*)nodesListGetNode(pChildren, idx))->pOutputDataBlockDesc;
|
*ppDesc = ((SPhysiNode*)nodesListGetNode(pChildren, idx))->pOutputDataBlockDesc;
|
||||||
} else if (1 == pChildren->length && nodeType(nodesListGetNode(pChildren, 0)) == QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE) {
|
} else if (1 == pChildren->length &&
|
||||||
|
nodeType(nodesListGetNode(pChildren, 0)) == QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE) {
|
||||||
SGroupCachePhysiNode* pGrpCache = (SGroupCachePhysiNode*)nodesListGetNode(pChildren, 0);
|
SGroupCachePhysiNode* pGrpCache = (SGroupCachePhysiNode*)nodesListGetNode(pChildren, 0);
|
||||||
*ppDesc = ((SPhysiNode*)nodesListGetNode(pGrpCache->node.pChildren, idx))->pOutputDataBlockDesc;
|
*ppDesc = ((SPhysiNode*)nodesListGetNode(pGrpCache->node.pChildren, idx))->pOutputDataBlockDesc;
|
||||||
} else {
|
} else {
|
||||||
planError("Invalid join children num:%d or child type:%d", pChildren->length, nodeType(nodesListGetNode(pChildren, 0)));
|
planError("Invalid join children num:%d or child type:%d", pChildren->length,
|
||||||
|
nodeType(nodesListGetNode(pChildren, 0)));
|
||||||
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setColEqList(SNode* pEqCond, int16_t leftBlkId, int16_t rightBlkId, SNodeList** ppLeft, SNodeList** ppRight) {
|
static int32_t setColEqList(SNode* pEqCond, int16_t leftBlkId, int16_t rightBlkId, SNodeList** ppLeft,
|
||||||
|
SNodeList** ppRight) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (QUERY_NODE_OPERATOR == nodeType(pEqCond) && ((SOperatorNode*)pEqCond)->opType == OP_TYPE_EQUAL) {
|
if (QUERY_NODE_OPERATOR == nodeType(pEqCond) && ((SOperatorNode*)pEqCond)->opType == OP_TYPE_EQUAL) {
|
||||||
SOperatorNode* pOp = (SOperatorNode*)pEqCond;
|
SOperatorNode* pOp = (SOperatorNode*)pEqCond;
|
||||||
SNode* pNew = NULL;
|
SNode* pNew = NULL;
|
||||||
if (leftBlkId == ((SColumnNode*)pOp->pLeft)->dataBlockId) {
|
if (leftBlkId == ((SColumnNode*)pOp->pLeft)->dataBlockId) {
|
||||||
code = nodesCloneNode(pOp->pLeft, &pNew);
|
code = nodesCloneNode(pOp->pLeft, &pNew);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -908,7 +911,7 @@ static int32_t setColEqList(SNode* pEqCond, int16_t leftBlkId, int16_t rightBlkI
|
||||||
planError("invalid col equal list, leftBlockId:%d", ((SColumnNode*)pOp->pLeft)->dataBlockId);
|
planError("invalid col equal list, leftBlockId:%d", ((SColumnNode*)pOp->pLeft)->dataBlockId);
|
||||||
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pNew = NULL;
|
pNew = NULL;
|
||||||
if (leftBlkId == ((SColumnNode*)pOp->pRight)->dataBlockId) {
|
if (leftBlkId == ((SColumnNode*)pOp->pRight)->dataBlockId) {
|
||||||
code = nodesCloneNode(pOp->pRight, &pNew);
|
code = nodesCloneNode(pOp->pRight, &pNew);
|
||||||
|
@ -925,9 +928,10 @@ static int32_t setColEqList(SNode* pEqCond, int16_t leftBlkId, int16_t rightBlkI
|
||||||
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (QUERY_NODE_LOGIC_CONDITION == nodeType(pEqCond) && ((SLogicConditionNode*)pEqCond)->condType == LOGIC_COND_TYPE_AND) {
|
} else if (QUERY_NODE_LOGIC_CONDITION == nodeType(pEqCond) &&
|
||||||
|
((SLogicConditionNode*)pEqCond)->condType == LOGIC_COND_TYPE_AND) {
|
||||||
SLogicConditionNode* pLogic = (SLogicConditionNode*)pEqCond;
|
SLogicConditionNode* pLogic = (SLogicConditionNode*)pEqCond;
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pLogic->pParameterList) {
|
FOREACH(pNode, pLogic->pParameterList) {
|
||||||
int32_t code = setColEqList(pNode, leftBlkId, rightBlkId, ppLeft, ppRight);
|
int32_t code = setColEqList(pNode, leftBlkId, rightBlkId, ppLeft, ppRight);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -942,7 +946,8 @@ static int32_t setColEqList(SNode* pEqCond, int16_t leftBlkId, int16_t rightBlkI
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_t leftBlkId, int16_t rightBlkId, SSortMergeJoinPhysiNode* pJoin) {
|
static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_t leftBlkId, int16_t rightBlkId,
|
||||||
|
SSortMergeJoinPhysiNode* pJoin) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (QUERY_NODE_OPERATOR == nodeType(pEqCond)) {
|
if (QUERY_NODE_OPERATOR == nodeType(pEqCond)) {
|
||||||
SOperatorNode* pOp = (SOperatorNode*)pEqCond;
|
SOperatorNode* pOp = (SOperatorNode*)pEqCond;
|
||||||
|
@ -996,7 +1001,7 @@ static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_
|
||||||
planError("invalid primary cond left node type, leftNodeType:%d", nodeType(pOp->pLeft));
|
planError("invalid primary cond left node type, leftNodeType:%d", nodeType(pOp->pLeft));
|
||||||
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
switch (nodeType(pOp->pRight)) {
|
switch (nodeType(pOp->pRight)) {
|
||||||
|
@ -1053,7 +1058,7 @@ static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode,
|
static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
SSortMergeJoinPhysiNode* pJoin =
|
SSortMergeJoinPhysiNode* pJoin =
|
||||||
(SSortMergeJoinPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN);
|
(SSortMergeJoinPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN);
|
||||||
if (NULL == pJoin) {
|
if (NULL == pJoin) {
|
||||||
|
@ -1066,7 +1071,7 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi
|
||||||
pJoin->subType = pJoinLogicNode->subType;
|
pJoin->subType = pJoinLogicNode->subType;
|
||||||
pJoin->pWindowOffset = NULL;
|
pJoin->pWindowOffset = NULL;
|
||||||
int32_t code = nodesCloneNode(pJoinLogicNode->pWindowOffset, &pJoin->pWindowOffset);
|
int32_t code = nodesCloneNode(pJoinLogicNode->pWindowOffset, &pJoin->pWindowOffset);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pJoin->pJLimit = NULL;
|
pJoin->pJLimit = NULL;
|
||||||
code = nodesCloneNode(pJoinLogicNode->pJLimit, (SNode**)&pJoin->pJLimit);
|
code = nodesCloneNode(pJoinLogicNode->pJLimit, (SNode**)&pJoin->pJLimit);
|
||||||
}
|
}
|
||||||
|
@ -1083,9 +1088,10 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pPrimKeyEqCond) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pPrimKeyEqCond) {
|
||||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pPrimKeyEqCond,
|
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pPrimKeyEqCond,
|
||||||
&pJoin->pPrimKeyCond);
|
&pJoin->pPrimKeyCond);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setMergeJoinPrimColEqCond(pJoin->pPrimKeyCond, pJoin->subType, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoin);
|
code = setMergeJoinPrimColEqCond(pJoin->pPrimKeyCond, pJoin->subType, pLeftDesc->dataBlockId,
|
||||||
|
pRightDesc->dataBlockId, pJoin);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoin->leftPrimExpr) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoin->leftPrimExpr) {
|
||||||
code = addDataBlockSlot(pCxt, &pJoin->leftPrimExpr, pLeftDesc);
|
code = addDataBlockSlot(pCxt, &pJoin->leftPrimExpr, pLeftDesc);
|
||||||
|
@ -1098,9 +1104,10 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->addPrimEqCond) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->addPrimEqCond) {
|
||||||
SNode* pPrimKeyCond = NULL;
|
SNode* pPrimKeyCond = NULL;
|
||||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->addPrimEqCond,
|
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->addPrimEqCond,
|
||||||
&pPrimKeyCond);
|
&pPrimKeyCond);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setMergeJoinPrimColEqCond(pPrimKeyCond, pJoin->subType, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoin);
|
code = setMergeJoinPrimColEqCond(pPrimKeyCond, pJoin->subType, pLeftDesc->dataBlockId, pRightDesc->dataBlockId,
|
||||||
|
pJoin);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoin->leftPrimExpr) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoin->leftPrimExpr) {
|
||||||
code = addDataBlockSlot(pCxt, &pJoin->leftPrimExpr, pLeftDesc);
|
code = addDataBlockSlot(pCxt, &pJoin->leftPrimExpr, pLeftDesc);
|
||||||
|
@ -1117,42 +1124,44 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pFullOnCond) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pFullOnCond) {
|
||||||
code = setNodeSlotId(pCxt, ((SPhysiNode*)pJoin)->pOutputDataBlockDesc->dataBlockId, -1,
|
code = setNodeSlotId(pCxt, ((SPhysiNode*)pJoin)->pOutputDataBlockDesc->dataBlockId, -1, pJoinLogicNode->pFullOnCond,
|
||||||
pJoinLogicNode->pFullOnCond, &pJoin->pFullOnCond);
|
&pJoin->pFullOnCond);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && ((NULL != pJoinLogicNode->pColEqCond) || (NULL != pJoinLogicNode->pTagEqCond))) {
|
if (TSDB_CODE_SUCCESS == code && ((NULL != pJoinLogicNode->pColEqCond) || (NULL != pJoinLogicNode->pTagEqCond))) {
|
||||||
code = mergeJoinConds(&pJoinLogicNode->pColEqCond, &pJoinLogicNode->pTagEqCond);
|
code = mergeJoinConds(&pJoinLogicNode->pColEqCond, &pJoinLogicNode->pTagEqCond);
|
||||||
}
|
}
|
||||||
//TODO set from input blocks for group algo
|
// TODO set from input blocks for group algo
|
||||||
/*
|
/*
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pColEqCond) {
|
||||||
|
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pColEqCond,
|
||||||
|
&pJoin->pColEqCond);
|
||||||
|
}
|
||||||
|
*/
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pColEqCond) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pColEqCond) {
|
||||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pColEqCond, &pJoin->pColEqCond);
|
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pColEqCond,
|
||||||
}
|
&pJoin->pColEqCond);
|
||||||
*/
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pColEqCond) {
|
code = setColEqList(pJoin->pColEqCond, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, &pJoin->pEqLeft,
|
||||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId,
|
&pJoin->pEqRight);
|
||||||
pJoinLogicNode->pColEqCond, &pJoin->pColEqCond);
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = setColEqList(pJoin->pColEqCond, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, &pJoin->pEqLeft, &pJoin->pEqRight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && ((NULL != pJoinLogicNode->pColOnCond) || (NULL != pJoinLogicNode->pTagOnCond))) {
|
if (TSDB_CODE_SUCCESS == code && ((NULL != pJoinLogicNode->pColOnCond) || (NULL != pJoinLogicNode->pTagOnCond))) {
|
||||||
code = mergeJoinConds(&pJoinLogicNode->pColOnCond, &pJoinLogicNode->pTagOnCond);
|
code = mergeJoinConds(&pJoinLogicNode->pColOnCond, &pJoinLogicNode->pTagOnCond);
|
||||||
}
|
}
|
||||||
//TODO set from input blocks for group algo
|
// TODO set from input blocks for group algo
|
||||||
/*
|
/*
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pColOnCond) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pColOnCond) {
|
||||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pColOnCond, &pJoin->pColOnCond);
|
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pColOnCond,
|
||||||
|
&pJoin->pColOnCond);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pColOnCond) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pColOnCond) {
|
||||||
code = setNodeSlotId(pCxt, ((SPhysiNode*)pJoin)->pOutputDataBlockDesc->dataBlockId, -1,
|
code = setNodeSlotId(pCxt, ((SPhysiNode*)pJoin)->pOutputDataBlockDesc->dataBlockId, -1, pJoinLogicNode->pColOnCond,
|
||||||
pJoinLogicNode->pColOnCond, &pJoin->pColOnCond);
|
&pJoin->pColOnCond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setConditionsSlotId(pCxt, (const SLogicNode*)pJoinLogicNode, (SPhysiNode*)pJoin);
|
code = setConditionsSlotId(pCxt, (const SLogicNode*)pJoinLogicNode, (SPhysiNode*)pJoin);
|
||||||
}
|
}
|
||||||
|
@ -1174,34 +1183,35 @@ static int32_t extractHashJoinOpCols(int16_t lBlkId, int16_t rBlkId, SNode* pEq,
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (QUERY_NODE_OPERATOR == nodeType(pEq)) {
|
if (QUERY_NODE_OPERATOR == nodeType(pEq)) {
|
||||||
SOperatorNode* pOp = (SOperatorNode*)pEq;
|
SOperatorNode* pOp = (SOperatorNode*)pEq;
|
||||||
SColumnNode* pLeft = (SColumnNode*)pOp->pLeft;
|
SColumnNode* pLeft = (SColumnNode*)pOp->pLeft;
|
||||||
SColumnNode* pRight = (SColumnNode*)pOp->pRight;
|
SColumnNode* pRight = (SColumnNode*)pOp->pRight;
|
||||||
if (lBlkId == pLeft->dataBlockId && rBlkId == pRight->dataBlockId) {
|
if (lBlkId == pLeft->dataBlockId && rBlkId == pRight->dataBlockId) {
|
||||||
SNode* pL = NULL, *pR = NULL;
|
SNode *pL = NULL, *pR = NULL;
|
||||||
code = nodesCloneNode(pOp->pLeft, &pL);
|
code = nodesCloneNode(pOp->pLeft, &pL);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListStrictAppend(pJoin->pOnLeft, pL);
|
code = nodesListStrictAppend(pJoin->pOnLeft, pL);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesCloneNode(pOp->pRight, &pR);
|
code = nodesCloneNode(pOp->pRight, &pR);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListStrictAppend(pJoin->pOnRight, pR);
|
code = nodesListStrictAppend(pJoin->pOnRight, pR);
|
||||||
}
|
}
|
||||||
} else if (rBlkId == pLeft->dataBlockId && lBlkId == pRight->dataBlockId) {
|
} else if (rBlkId == pLeft->dataBlockId && lBlkId == pRight->dataBlockId) {
|
||||||
SNode* pL = NULL, *pR = NULL;
|
SNode *pL = NULL, *pR = NULL;
|
||||||
code = nodesCloneNode(pOp->pRight, &pR);
|
code = nodesCloneNode(pOp->pRight, &pR);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListStrictAppend(pJoin->pOnLeft, pR);
|
code = nodesListStrictAppend(pJoin->pOnLeft, pR);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesCloneNode(pOp->pLeft, &pL);
|
code = nodesCloneNode(pOp->pLeft, &pL);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListStrictAppend(pJoin->pOnRight, pL);
|
code = nodesListStrictAppend(pJoin->pOnRight, pL);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
planError("Invalid join equal cond, lbid:%d, rbid:%d, oplid:%d, oprid:%d", lBlkId, rBlkId, pLeft->dataBlockId, pRight->dataBlockId);
|
planError("Invalid join equal cond, lbid:%d, rbid:%d, oplid:%d, oprid:%d", lBlkId, rBlkId, pLeft->dataBlockId,
|
||||||
|
pRight->dataBlockId);
|
||||||
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1222,7 +1232,7 @@ static int32_t extractHashJoinOnCols(int16_t lBlkId, int16_t rBlkId, SNode* pEq,
|
||||||
code = extractHashJoinOpCols(lBlkId, rBlkId, pEq, pJoin);
|
code = extractHashJoinOpCols(lBlkId, rBlkId, pEq, pJoin);
|
||||||
} else if (QUERY_NODE_LOGIC_CONDITION == nodeType(pEq)) {
|
} else if (QUERY_NODE_LOGIC_CONDITION == nodeType(pEq)) {
|
||||||
SLogicConditionNode* pLogic = (SLogicConditionNode*)pEq;
|
SLogicConditionNode* pLogic = (SLogicConditionNode*)pEq;
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pLogic->pParameterList) {
|
FOREACH(pNode, pLogic->pParameterList) {
|
||||||
code = extractHashJoinOpCols(lBlkId, rBlkId, pNode, pJoin);
|
code = extractHashJoinOpCols(lBlkId, rBlkId, pNode, pJoin);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -1237,16 +1247,17 @@ static int32_t extractHashJoinOnCols(int16_t lBlkId, int16_t rBlkId, SNode* pEq,
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createHashJoinColList(int16_t lBlkId, int16_t rBlkId, SNode* pEq1, SNode* pEq2, SNode* pEq3, SHashJoinPhysiNode* pJoin) {
|
static int32_t createHashJoinColList(int16_t lBlkId, int16_t rBlkId, SNode* pEq1, SNode* pEq2, SNode* pEq3,
|
||||||
|
SHashJoinPhysiNode* pJoin) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
pJoin->pOnLeft = NULL;
|
pJoin->pOnLeft = NULL;
|
||||||
code = nodesMakeList(&pJoin->pOnLeft);
|
code = nodesMakeList(&pJoin->pOnLeft);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
pJoin->pOnRight = NULL;
|
pJoin->pOnRight = NULL;
|
||||||
code = nodesMakeList(&pJoin->pOnRight);
|
code = nodesMakeList(&pJoin->pOnRight);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1266,25 +1277,25 @@ static int32_t createHashJoinColList(int16_t lBlkId, int16_t rBlkId, SNode* pEq1
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sortHashJoinTargets(int16_t lBlkId, int16_t rBlkId, SHashJoinPhysiNode* pJoin) {
|
static int32_t sortHashJoinTargets(int16_t lBlkId, int16_t rBlkId, SHashJoinPhysiNode* pJoin) {
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
SSHashObj* pHash = tSimpleHashInit(pJoin->pTargets->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY));
|
SSHashObj* pHash = tSimpleHashInit(pJoin->pTargets->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY));
|
||||||
if (NULL == pHash) {
|
if (NULL == pHash) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
SNodeList* pNew = NULL;
|
SNodeList* pNew = NULL;
|
||||||
int32_t code = nodesMakeList(&pNew);
|
int32_t code = nodesMakeList(&pNew);
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
FOREACH(pNode, pJoin->pTargets) {
|
FOREACH(pNode, pJoin->pTargets) {
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
char *pName = NULL;
|
char* pName = NULL;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
code = getSlotKey(pNode, NULL, &pName, &len, 0);
|
code = getSlotKey(pNode, NULL, &pName, &len, 0);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tSimpleHashPut(pHash, pName, len, &pCol, POINTER_BYTES);
|
code = tSimpleHashPut(pHash, pName, len, &pCol, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
taosMemoryFree(pName);
|
taosMemoryFree(pName);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1294,9 +1305,9 @@ static int32_t sortHashJoinTargets(int16_t lBlkId, int16_t rBlkId, SHashJoinPhys
|
||||||
pJoin->pTargets = pNew;
|
pJoin->pTargets = pNew;
|
||||||
|
|
||||||
FOREACH(pNode, pJoin->pOnLeft) {
|
FOREACH(pNode, pJoin->pOnLeft) {
|
||||||
char* pName = NULL;
|
char* pName = NULL;
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
code = getSlotKey(pNode, NULL, &pName, &len, 0);
|
code = getSlotKey(pNode, NULL, &pName, &len, 0);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SNode** p = tSimpleHashGet(pHash, pName, len);
|
SNode** p = tSimpleHashGet(pHash, pName, len);
|
||||||
|
@ -1315,9 +1326,9 @@ static int32_t sortHashJoinTargets(int16_t lBlkId, int16_t rBlkId, SHashJoinPhys
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
FOREACH(pNode, pJoin->pOnRight) {
|
FOREACH(pNode, pJoin->pOnRight) {
|
||||||
char* pName = NULL;
|
char* pName = NULL;
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
code = getSlotKey(pNode, NULL, &pName, &len, 0);
|
code = getSlotKey(pNode, NULL, &pName, &len, 0);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SNode** p = tSimpleHashGet(pHash, pName, len);
|
SNode** p = tSimpleHashGet(pHash, pName, len);
|
||||||
|
@ -1357,8 +1368,8 @@ static int32_t sortHashJoinTargets(int16_t lBlkId, int16_t rBlkId, SHashJoinPhys
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t setHashJoinPrimColEqCond(SNode* pEqCond, int16_t leftBlkId, int16_t rightBlkId,
|
||||||
static int32_t setHashJoinPrimColEqCond(SNode* pEqCond, int16_t leftBlkId, int16_t rightBlkId, SHashJoinPhysiNode* pJoin) {
|
SHashJoinPhysiNode* pJoin) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (QUERY_NODE_OPERATOR == nodeType(pEqCond)) {
|
if (QUERY_NODE_OPERATOR == nodeType(pEqCond)) {
|
||||||
SOperatorNode* pOp = (SOperatorNode*)pEqCond;
|
SOperatorNode* pOp = (SOperatorNode*)pEqCond;
|
||||||
|
@ -1464,11 +1475,10 @@ static int32_t setHashJoinPrimColEqCond(SNode* pEqCond, int16_t leftBlkId, int16
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t createHashJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode,
|
static int32_t createHashJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
SHashJoinPhysiNode* pJoin =
|
SHashJoinPhysiNode* pJoin =
|
||||||
(SHashJoinPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_HASH_JOIN);
|
(SHashJoinPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_HASH_JOIN);
|
||||||
if (NULL == pJoin) {
|
if (NULL == pJoin) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -1498,22 +1508,24 @@ static int32_t createHashJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
|
||||||
|
|
||||||
if (NULL != pJoinLogicNode->pPrimKeyEqCond) {
|
if (NULL != pJoinLogicNode->pPrimKeyEqCond) {
|
||||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pPrimKeyEqCond,
|
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pPrimKeyEqCond,
|
||||||
&pJoin->pPrimKeyCond);
|
&pJoin->pPrimKeyCond);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setHashJoinPrimColEqCond(pJoin->pPrimKeyCond, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoin);
|
code = setHashJoinPrimColEqCond(pJoin->pPrimKeyCond, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoin);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoin->leftPrimExpr) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoin->leftPrimExpr) {
|
||||||
code = addDataBlockSlot(pCxt, &pJoin->leftPrimExpr, pLeftDesc);
|
code = addDataBlockSlot(pCxt, &pJoin->leftPrimExpr, pLeftDesc);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoin->rightPrimExpr) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoin->rightPrimExpr) {
|
||||||
code = addDataBlockSlot(pCxt, &pJoin->rightPrimExpr, pRightDesc);
|
code = addDataBlockSlot(pCxt, &pJoin->rightPrimExpr, pRightDesc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pColEqCond, &pJoin->pColEqCond);
|
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pColEqCond,
|
||||||
|
&pJoin->pColEqCond);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pTagEqCond, &pJoin->pTagEqCond);
|
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pTagEqCond,
|
||||||
|
&pJoin->pTagEqCond);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, -1, pJoinLogicNode->pLeftOnCond, &pJoin->pLeftOnCond);
|
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, -1, pJoinLogicNode->pLeftOnCond, &pJoin->pLeftOnCond);
|
||||||
|
@ -1523,19 +1535,22 @@ static int32_t createHashJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && ((NULL != pJoinLogicNode->pColOnCond) || (NULL != pJoinLogicNode->pTagOnCond))) {
|
if (TSDB_CODE_SUCCESS == code && ((NULL != pJoinLogicNode->pColOnCond) || (NULL != pJoinLogicNode->pTagOnCond))) {
|
||||||
code = mergeJoinConds(&pJoinLogicNode->pColOnCond, &pJoinLogicNode->pTagOnCond);
|
code = mergeJoinConds(&pJoinLogicNode->pColOnCond, &pJoinLogicNode->pTagOnCond);
|
||||||
}
|
}
|
||||||
SNode* pOnCond = (NULL != pJoinLogicNode->pColOnCond) ? pJoinLogicNode->pColOnCond : pJoinLogicNode->pTagOnCond;
|
SNode* pOnCond = (NULL != pJoinLogicNode->pColOnCond) ? pJoinLogicNode->pColOnCond : pJoinLogicNode->pTagOnCond;
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pOnCond) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pOnCond) {
|
||||||
code = setNodeSlotId(pCxt, ((SPhysiNode*)pJoin)->pOutputDataBlockDesc->dataBlockId, -1, pOnCond, &pJoin->pFullOnCond);
|
code =
|
||||||
|
setNodeSlotId(pCxt, ((SPhysiNode*)pJoin)->pOutputDataBlockDesc->dataBlockId, -1, pOnCond, &pJoin->pFullOnCond);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setListSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->node.pTargets, &pJoin->pTargets);
|
code = setListSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->node.pTargets,
|
||||||
|
&pJoin->pTargets);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setConditionsSlotId(pCxt, (const SLogicNode*)pJoinLogicNode, (SPhysiNode*)pJoin);
|
code = setConditionsSlotId(pCxt, (const SLogicNode*)pJoinLogicNode, (SPhysiNode*)pJoin);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = createHashJoinColList(pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoin->pPrimKeyCond, pJoin->pColEqCond, pJoin->pTagEqCond, pJoin);
|
code = createHashJoinColList(pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoin->pPrimKeyCond,
|
||||||
|
pJoin->pColEqCond, pJoin->pTagEqCond, pJoin);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = sortHashJoinTargets(pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoin);
|
code = sortHashJoinTargets(pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoin);
|
||||||
|
@ -1568,10 +1583,10 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createGroupCachePhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SGroupCacheLogicNode* pLogicNode,
|
static int32_t createGroupCachePhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SPhysiNode** pPhyNode) {
|
SGroupCacheLogicNode* pLogicNode, SPhysiNode** pPhyNode) {
|
||||||
SGroupCachePhysiNode* pGrpCache =
|
SGroupCachePhysiNode* pGrpCache =
|
||||||
(SGroupCachePhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pLogicNode, QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE);
|
(SGroupCachePhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pLogicNode, QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE);
|
||||||
if (NULL == pGrpCache) {
|
if (NULL == pGrpCache) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -1582,30 +1597,30 @@ static int32_t createGroupCachePhysiNode(SPhysiPlanContext* pCxt, SNodeList* pCh
|
||||||
pGrpCache->batchFetch = pLogicNode->batchFetch;
|
pGrpCache->batchFetch = pLogicNode->batchFetch;
|
||||||
SDataBlockDescNode* pChildDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
SDataBlockDescNode* pChildDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
/*
|
/*
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setListSlotId(pCxt, pChildDesc->dataBlockId, -1, pLogicNode->pGroupCols, &pGrpCache->pGroupCols);
|
code = setListSlotId(pCxt, pChildDesc->dataBlockId, -1, pLogicNode->pGroupCols, &pGrpCache->pGroupCols);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
*pPhyNode = (SPhysiNode*)pGrpCache;
|
*pPhyNode = (SPhysiNode*)pGrpCache;
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t updateDynQueryCtrlStbJoinInfo(SPhysiPlanContext* pCxt, SNodeList* pChildren, SDynQueryCtrlLogicNode* pLogicNode,
|
static int32_t updateDynQueryCtrlStbJoinInfo(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SDynQueryCtrlPhysiNode* pDynCtrl) {
|
SDynQueryCtrlLogicNode* pLogicNode, SDynQueryCtrlPhysiNode* pDynCtrl) {
|
||||||
SDataBlockDescNode* pPrevDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
SDataBlockDescNode* pPrevDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
||||||
SNodeList* pVgList = NULL;
|
SNodeList* pVgList = NULL;
|
||||||
SNodeList* pUidList = NULL;
|
SNodeList* pUidList = NULL;
|
||||||
int32_t code = setListSlotId(pCxt, pPrevDesc->dataBlockId, -1, pLogicNode->stbJoin.pVgList, &pVgList);
|
int32_t code = setListSlotId(pCxt, pPrevDesc->dataBlockId, -1, pLogicNode->stbJoin.pVgList, &pVgList);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setListSlotId(pCxt, pPrevDesc->dataBlockId, -1, pLogicNode->stbJoin.pUidList, &pUidList);
|
code = setListSlotId(pCxt, pPrevDesc->dataBlockId, -1, pLogicNode->stbJoin.pUidList, &pUidList);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
memcpy(pDynCtrl->stbJoin.srcScan, pLogicNode->stbJoin.srcScan, sizeof(pDynCtrl->stbJoin.srcScan));
|
memcpy(pDynCtrl->stbJoin.srcScan, pLogicNode->stbJoin.srcScan, sizeof(pDynCtrl->stbJoin.srcScan));
|
||||||
|
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
FOREACH(pNode, pVgList) {
|
FOREACH(pNode, pVgList) {
|
||||||
pDynCtrl->stbJoin.vgSlot[i] = ((SColumnNode*)pNode)->slotId;
|
pDynCtrl->stbJoin.vgSlot[i] = ((SColumnNode*)pNode)->slotId;
|
||||||
|
@ -1624,11 +1639,11 @@ static int32_t updateDynQueryCtrlStbJoinInfo(SPhysiPlanContext* pCxt, SNodeList*
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createDynQueryCtrlPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SDynQueryCtrlLogicNode* pLogicNode,
|
static int32_t createDynQueryCtrlPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SPhysiNode** pPhyNode) {
|
SDynQueryCtrlLogicNode* pLogicNode, SPhysiNode** pPhyNode) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SDynQueryCtrlPhysiNode* pDynCtrl =
|
SDynQueryCtrlPhysiNode* pDynCtrl =
|
||||||
(SDynQueryCtrlPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pLogicNode, QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL);
|
(SDynQueryCtrlPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pLogicNode, QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL);
|
||||||
if (NULL == pDynCtrl) {
|
if (NULL == pDynCtrl) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -1689,7 +1704,7 @@ static EDealRes collectAndRewrite(SRewritePrecalcExprsCxt* pCxt, SNode** pNode)
|
||||||
|
|
||||||
static int32_t rewriteValueToOperator(SRewritePrecalcExprsCxt* pCxt, SNode** pNode) {
|
static int32_t rewriteValueToOperator(SRewritePrecalcExprsCxt* pCxt, SNode** pNode) {
|
||||||
SOperatorNode* pOper = NULL;
|
SOperatorNode* pOper = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOper);
|
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOper);
|
||||||
if (NULL == pOper) {
|
if (NULL == pOper) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2360,7 +2375,7 @@ static int32_t createCountWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pC
|
||||||
pCount->windowCount = pWindowLogicNode->windowCount;
|
pCount->windowCount = pWindowLogicNode->windowCount;
|
||||||
pCount->windowSliding = pWindowLogicNode->windowSliding;
|
pCount->windowSliding = pWindowLogicNode->windowSliding;
|
||||||
|
|
||||||
int32_t code = createWindowPhysiNodeFinalize(pCxt, pChildren, &pCount->window, pWindowLogicNode);
|
int32_t code = createWindowPhysiNodeFinalize(pCxt, pChildren, &pCount->window, pWindowLogicNode);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
*pPhyNode = (SPhysiNode*)pCount;
|
*pPhyNode = (SPhysiNode*)pCount;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2524,7 +2539,7 @@ static int32_t createPartitionPhysiNodeImpl(SPhysiPlanContext* pCxt, SNodeList*
|
||||||
|
|
||||||
if (pPart->needBlockOutputTsOrder) {
|
if (pPart->needBlockOutputTsOrder) {
|
||||||
SNode* node;
|
SNode* node;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
FOREACH(node, pPartLogicNode->node.pTargets) {
|
FOREACH(node, pPartLogicNode->node.pTargets) {
|
||||||
if (nodeType(node) == QUERY_NODE_COLUMN) {
|
if (nodeType(node) == QUERY_NODE_COLUMN) {
|
||||||
SColumnNode* pCol = (SColumnNode*)node;
|
SColumnNode* pCol = (SColumnNode*)node;
|
||||||
|
@ -2608,7 +2623,7 @@ static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && LIST_LENGTH(pFillNode->pFillNullExprs) > 0) {
|
if (TSDB_CODE_SUCCESS == code && LIST_LENGTH(pFillNode->pFillNullExprs) > 0) {
|
||||||
code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pFillNode->pFillNullExprs, &pFill->pFillNullExprs);
|
code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pFillNode->pFillNullExprs, &pFill->pFillNullExprs);
|
||||||
if (TSDB_CODE_SUCCESS == code ) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addDataBlockSlots(pCxt, pFill->pFillNullExprs, pFill->node.pOutputDataBlockDesc);
|
code = addDataBlockSlots(pCxt, pFill->pFillNullExprs, pFill->node.pOutputDataBlockDesc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2639,7 +2654,7 @@ static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
||||||
|
|
||||||
static int32_t createExchangePhysiNodeByMerge(SMergePhysiNode* pMerge, int32_t idx) {
|
static int32_t createExchangePhysiNodeByMerge(SMergePhysiNode* pMerge, int32_t idx) {
|
||||||
SExchangePhysiNode* pExchange = NULL;
|
SExchangePhysiNode* pExchange = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_EXCHANGE, (SNode**)&pExchange);
|
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_EXCHANGE, (SNode**)&pExchange);
|
||||||
if (NULL == pExchange) {
|
if (NULL == pExchange) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2658,8 +2673,9 @@ static int32_t createExchangePhysiNodeByMerge(SMergePhysiNode* pMerge, int32_t i
|
||||||
return nodesListMakeStrictAppend(&pMerge->node.pChildren, (SNode*)pExchange);
|
return nodesListMakeStrictAppend(&pMerge->node.pChildren, (SNode*)pExchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SMergeLogicNode* pMergeLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SMergeLogicNode* pMergeLogicNode,
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
SPhysiNode** pPhyNode) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SMergePhysiNode* pMerge =
|
SMergePhysiNode* pMerge =
|
||||||
(SMergePhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pMergeLogicNode, QUERY_NODE_PHYSICAL_PLAN_MERGE);
|
(SMergePhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pMergeLogicNode, QUERY_NODE_PHYSICAL_PLAN_MERGE);
|
||||||
if (NULL == pMerge) {
|
if (NULL == pMerge) {
|
||||||
|
@ -2673,7 +2689,7 @@ static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildre
|
||||||
} else {
|
} else {
|
||||||
pMerge->type = MERGE_TYPE_NON_SORT;
|
pMerge->type = MERGE_TYPE_NON_SORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
pMerge->numOfChannels = pMergeLogicNode->numOfChannels;
|
pMerge->numOfChannels = pMergeLogicNode->numOfChannels;
|
||||||
pMerge->srcGroupId = pMergeLogicNode->srcGroupId;
|
pMerge->srcGroupId = pMergeLogicNode->srcGroupId;
|
||||||
pMerge->srcEndGroupId = pMergeLogicNode->srcEndGroupId;
|
pMerge->srcEndGroupId = pMergeLogicNode->srcEndGroupId;
|
||||||
|
@ -2712,7 +2728,8 @@ static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildre
|
||||||
SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
||||||
SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc;
|
SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc;
|
||||||
|
|
||||||
code = setListSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pMergeLogicNode->node.pTargets, &pMerge->pTargets);
|
code = setListSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pMergeLogicNode->node.pTargets,
|
||||||
|
&pMerge->pTargets);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addDataBlockSlots(pCxt, pMerge->pTargets, pMerge->node.pOutputDataBlockDesc);
|
code = addDataBlockSlots(pCxt, pMerge->pTargets, pMerge->node.pOutputDataBlockDesc);
|
||||||
}
|
}
|
||||||
|
@ -2770,7 +2787,7 @@ static int32_t doCreatePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode
|
||||||
static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, SSubplan* pSubplan,
|
static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, SSubplan* pSubplan,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
SNodeList* pChildren = NULL;
|
SNodeList* pChildren = NULL;
|
||||||
int32_t code = nodesMakeList(&pChildren);
|
int32_t code = nodesMakeList(&pChildren);
|
||||||
if (NULL == pChildren) {
|
if (NULL == pChildren) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2808,7 +2825,7 @@ static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode,
|
||||||
|
|
||||||
static int32_t createDataInserter(SPhysiPlanContext* pCxt, SVgDataBlocks* pBlocks, SDataSinkNode** pSink) {
|
static int32_t createDataInserter(SPhysiPlanContext* pCxt, SVgDataBlocks* pBlocks, SDataSinkNode** pSink) {
|
||||||
SDataInserterNode* pInserter = NULL;
|
SDataInserterNode* pInserter = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT, (SNode**)&pInserter);
|
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT, (SNode**)&pInserter);
|
||||||
if (NULL == pInserter) {
|
if (NULL == pInserter) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2823,7 +2840,7 @@ static int32_t createDataInserter(SPhysiPlanContext* pCxt, SVgDataBlocks* pBlock
|
||||||
|
|
||||||
static int32_t createDataDispatcher(SPhysiPlanContext* pCxt, const SPhysiNode* pRoot, SDataSinkNode** pSink) {
|
static int32_t createDataDispatcher(SPhysiPlanContext* pCxt, const SPhysiNode* pRoot, SDataSinkNode** pSink) {
|
||||||
SDataDispatcherNode* pDispatcher = NULL;
|
SDataDispatcherNode* pDispatcher = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH, (SNode**)&pDispatcher);
|
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH, (SNode**)&pDispatcher);
|
||||||
if (NULL == pDispatcher) {
|
if (NULL == pDispatcher) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2841,7 +2858,7 @@ static int32_t createDataDispatcher(SPhysiPlanContext* pCxt, const SPhysiNode* p
|
||||||
|
|
||||||
static int32_t makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan** ppSubplan) {
|
static int32_t makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan** ppSubplan) {
|
||||||
SSubplan* pSubplan = NULL;
|
SSubplan* pSubplan = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN, (SNode**)&pSubplan);
|
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN, (SNode**)&pSubplan);
|
||||||
if (NULL == pSubplan) {
|
if (NULL == pSubplan) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2869,7 +2886,7 @@ static int32_t buildInsertValuesSubplan(SPhysiPlanContext* pCxt, SVnodeModifyLog
|
||||||
static int32_t createQueryInserter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pModify, SSubplan* pSubplan,
|
static int32_t createQueryInserter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pModify, SSubplan* pSubplan,
|
||||||
SDataSinkNode** pSink) {
|
SDataSinkNode** pSink) {
|
||||||
SQueryInserterNode* pInserter = NULL;
|
SQueryInserterNode* pInserter = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT, (SNode**)&pInserter);
|
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT, (SNode**)&pInserter);
|
||||||
if (NULL == pInserter) {
|
if (NULL == pInserter) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2885,7 +2902,7 @@ static int32_t createQueryInserter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNod
|
||||||
vgroupInfoToNodeAddr(pModify->pVgroupList->vgroups, &pSubplan->execNode);
|
vgroupInfoToNodeAddr(pModify->pVgroupList->vgroups, &pSubplan->execNode);
|
||||||
}
|
}
|
||||||
code = setListSlotId(pCxt, pSubplan->pNode->pOutputDataBlockDesc->dataBlockId, -1, pModify->pInsertCols,
|
code = setListSlotId(pCxt, pSubplan->pNode->pOutputDataBlockDesc->dataBlockId, -1, pModify->pInsertCols,
|
||||||
&pInserter->pCols);
|
&pInserter->pCols);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pInserter->sink.pInputDataBlockDesc = NULL;
|
pInserter->sink.pInputDataBlockDesc = NULL;
|
||||||
code = nodesCloneNode((SNode*)pSubplan->pNode->pOutputDataBlockDesc, (SNode**)&pInserter->sink.pInputDataBlockDesc);
|
code = nodesCloneNode((SNode*)pSubplan->pNode->pOutputDataBlockDesc, (SNode**)&pInserter->sink.pInputDataBlockDesc);
|
||||||
|
@ -2923,7 +2940,7 @@ static int32_t buildInsertSubplan(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode
|
||||||
static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pModify, const SPhysiNode* pRoot,
|
static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pModify, const SPhysiNode* pRoot,
|
||||||
SDataSinkNode** pSink) {
|
SDataSinkNode** pSink) {
|
||||||
SDataDeleterNode* pDeleter = NULL;
|
SDataDeleterNode* pDeleter = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DELETE, (SNode**)&pDeleter);
|
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DELETE, (SNode**)&pDeleter);
|
||||||
if (NULL == pDeleter) {
|
if (NULL == pDeleter) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2935,7 +2952,7 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode*
|
||||||
pDeleter->deleteTimeRange = pModify->deleteTimeRange;
|
pDeleter->deleteTimeRange = pModify->deleteTimeRange;
|
||||||
|
|
||||||
code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pAffectedRows,
|
code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pAffectedRows,
|
||||||
&pDeleter->pAffectedRows);
|
&pDeleter->pAffectedRows);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pStartTs, &pDeleter->pStartTs);
|
code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pStartTs, &pDeleter->pStartTs);
|
||||||
}
|
}
|
||||||
|
@ -2988,7 +3005,7 @@ static int32_t buildVnodeModifySubplan(SPhysiPlanContext* pCxt, SLogicSubplan* p
|
||||||
|
|
||||||
static int32_t createPhysiSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan** pPhysiSubplan) {
|
static int32_t createPhysiSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan** pPhysiSubplan) {
|
||||||
SSubplan* pSubplan = NULL;
|
SSubplan* pSubplan = NULL;
|
||||||
int32_t code = makeSubplan(pCxt, pLogicSubplan, &pSubplan);
|
int32_t code = makeSubplan(pCxt, pLogicSubplan, &pSubplan);
|
||||||
if (NULL == pSubplan) {
|
if (NULL == pSubplan) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -3018,7 +3035,7 @@ static int32_t createPhysiSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogic
|
||||||
|
|
||||||
static int32_t makeQueryPhysiPlan(SPhysiPlanContext* pCxt, SQueryPlan** ppQueryPlan) {
|
static int32_t makeQueryPhysiPlan(SPhysiPlanContext* pCxt, SQueryPlan** ppQueryPlan) {
|
||||||
SQueryPlan* pPlan = NULL;
|
SQueryPlan* pPlan = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN, (SNode**)&pPlan);
|
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN, (SNode**)&pPlan);
|
||||||
if (NULL == pPlan) {
|
if (NULL == pPlan) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -3093,7 +3110,7 @@ static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubp
|
||||||
|
|
||||||
static int32_t doCreatePhysiPlan(SPhysiPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPhysiPlan) {
|
static int32_t doCreatePhysiPlan(SPhysiPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPhysiPlan) {
|
||||||
SQueryPlan* pPlan = NULL;
|
SQueryPlan* pPlan = NULL;
|
||||||
int32_t code = makeQueryPhysiPlan(pCxt, &pPlan);
|
int32_t code = makeQueryPhysiPlan(pCxt, &pPlan);
|
||||||
if (NULL == pPlan) {
|
if (NULL == pPlan) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -3148,8 +3165,7 @@ static int32_t setExecNodeList(SPhysiPlanContext* pCxt, SArray* pExecNodeList) {
|
||||||
}
|
}
|
||||||
if (pCxt->hasSysScan || !pCxt->hasScan) {
|
if (pCxt->hasSysScan || !pCxt->hasScan) {
|
||||||
SQueryNodeLoad node = {.addr = {.nodeId = MNODE_HANDLE, .epSet = pCxt->pPlanCxt->mgmtEpSet}, .load = 0};
|
SQueryNodeLoad node = {.addr = {.nodeId = MNODE_HANDLE, .epSet = pCxt->pPlanCxt->mgmtEpSet}, .load = 0};
|
||||||
if (NULL == taosArrayPush(pExecNodeList, &node))
|
if (NULL == taosArrayPush(pExecNodeList, &node)) code = terrno;
|
||||||
code = terrno;
|
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,7 @@ typedef void* queue[2];
|
||||||
#define TRANS_CONN_TIMEOUT 5000 // connect timeout (ms)
|
#define TRANS_CONN_TIMEOUT 5000 // connect timeout (ms)
|
||||||
#define TRANS_READ_TIMEOUT 3000 // read timeout (ms)
|
#define TRANS_READ_TIMEOUT 3000 // read timeout (ms)
|
||||||
#define TRANS_PACKET_LIMIT 1024 * 1024 * 512
|
#define TRANS_PACKET_LIMIT 1024 * 1024 * 512
|
||||||
|
#define TRANS_MSG_LIMIT (TRANS_PACKET_LIMIT - sizeof(STransMsgHead))
|
||||||
|
|
||||||
#define TRANS_MAGIC_NUM 0x5f375a86
|
#define TRANS_MAGIC_NUM 0x5f375a86
|
||||||
#define TRANS_NOVALID_PACKET(src) ((src) != TRANS_MAGIC_NUM ? 1 : 0)
|
#define TRANS_NOVALID_PACKET(src) ((src) != TRANS_MAGIC_NUM ? 1 : 0)
|
||||||
|
|
|
@ -377,6 +377,12 @@ static FORCE_INLINE void logConnMissHit(SCliConn* pConn);
|
||||||
|
|
||||||
static void* cliWorkThread(void* arg);
|
static void* cliWorkThread(void* arg);
|
||||||
|
|
||||||
|
static bool isReqExceedLimit(STransMsg* pMsg) {
|
||||||
|
if (pMsg != NULL && pMsg->contLen >= TRANS_MSG_LIMIT) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
int32_t cliGetConnTimer(SCliThrd* pThrd, SCliConn* pConn) {
|
int32_t cliGetConnTimer(SCliThrd* pThrd, SCliConn* pConn) {
|
||||||
uv_timer_t* timer = taosArrayGetSize(pThrd->timerList) > 0 ? *(uv_timer_t**)taosArrayPop(pThrd->timerList) : NULL;
|
uv_timer_t* timer = taosArrayGetSize(pThrd->timerList) > 0 ? *(uv_timer_t**)taosArrayPop(pThrd->timerList) : NULL;
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
|
@ -3209,6 +3215,10 @@ _exception:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t transSendRequest(void* pInstRef, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* ctx) {
|
int32_t transSendRequest(void* pInstRef, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* ctx) {
|
||||||
|
if (isReqExceedLimit(pReq)) {
|
||||||
|
return TSDB_CODE_RPC_MSG_EXCCED_LIMIT;
|
||||||
|
}
|
||||||
|
|
||||||
STrans* pInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)pInstRef);
|
STrans* pInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)pInstRef);
|
||||||
if (pInst == NULL) {
|
if (pInst == NULL) {
|
||||||
transFreeMsg(pReq->pCont);
|
transFreeMsg(pReq->pCont);
|
||||||
|
@ -3236,9 +3246,6 @@ int32_t transSendRequest(void* pInstRef, const SEpSet* pEpSet, STransMsg* pReq,
|
||||||
return (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code);
|
return (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (pReq->msgType == TDMT_SCH_DROP_TASK) {
|
|
||||||
// TAOS_UNUSED(transReleaseCliHandle(pReq->info.handle));
|
|
||||||
// }
|
|
||||||
transReleaseExHandle(transGetInstMgt(), (int64_t)pInstRef);
|
transReleaseExHandle(transGetInstMgt(), (int64_t)pInstRef);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -3255,6 +3262,9 @@ int32_t transSendRequestWithId(void* pInstRef, const SEpSet* pEpSet, STransMsg*
|
||||||
if (transpointId == NULL) {
|
if (transpointId == NULL) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
if (isReqExceedLimit(pReq)) {
|
||||||
|
return TSDB_CODE_RPC_MSG_EXCCED_LIMIT;
|
||||||
|
}
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int8_t transIdInited = 0;
|
int8_t transIdInited = 0;
|
||||||
|
|
||||||
|
@ -3306,6 +3316,9 @@ _exception:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t transSendRecv(void* pInstRef, const SEpSet* pEpSet, STransMsg* pReq, STransMsg* pRsp) {
|
int32_t transSendRecv(void* pInstRef, const SEpSet* pEpSet, STransMsg* pReq, STransMsg* pRsp) {
|
||||||
|
if (isReqExceedLimit(pReq)) {
|
||||||
|
return TSDB_CODE_RPC_MSG_EXCCED_LIMIT;
|
||||||
|
}
|
||||||
STrans* pInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)pInstRef);
|
STrans* pInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)pInstRef);
|
||||||
if (pInst == NULL) {
|
if (pInst == NULL) {
|
||||||
transFreeMsg(pReq->pCont);
|
transFreeMsg(pReq->pCont);
|
||||||
|
|
|
@ -149,7 +149,7 @@ int32_t taosMulMkDir(const char *dirname) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
code = taosRealPath(dirname, temp, sizeof(temp));
|
code = taosRealPath(dirname, temp, sizeof(temp));
|
||||||
if(code != 0) {
|
if (code != 0) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
if (temp[1] == ':') pos += 3;
|
if (temp[1] == ':') pos += 3;
|
||||||
|
@ -192,7 +192,7 @@ int32_t taosMulMkDir(const char *dirname) {
|
||||||
code = mkdir(temp, 0755);
|
code = mkdir(temp, 0755);
|
||||||
#endif
|
#endif
|
||||||
if (code < 0 && errno != EEXIST) {
|
if (code < 0 && errno != EEXIST) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ int32_t taosMulModeMkDir(const char *dirname, int mode, bool checkAccess) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
code = taosRealPath(dirname, temp, sizeof(temp));
|
code = taosRealPath(dirname, temp, sizeof(temp));
|
||||||
if(code != 0) {
|
if (code != 0) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
if (temp[1] == ':') pos += 3;
|
if (temp[1] == ':') pos += 3;
|
||||||
|
@ -223,7 +223,8 @@ int32_t taosMulModeMkDir(const char *dirname, int mode, bool checkAccess) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (taosDirExist(temp)) {
|
if (taosDirExist(temp)) {
|
||||||
if (checkAccess && taosCheckAccessFile(temp, TD_FILE_ACCESS_EXIST_OK | TD_FILE_ACCESS_READ_OK | TD_FILE_ACCESS_WRITE_OK)) {
|
if (checkAccess &&
|
||||||
|
taosCheckAccessFile(temp, TD_FILE_ACCESS_EXIST_OK | TD_FILE_ACCESS_READ_OK | TD_FILE_ACCESS_WRITE_OK)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +278,8 @@ int32_t taosMulModeMkDir(const char *dirname, int mode, bool checkAccess) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code < 0 && errno == EEXIST) {
|
if (code < 0 && errno == EEXIST) {
|
||||||
if (checkAccess && taosCheckAccessFile(temp, TD_FILE_ACCESS_EXIST_OK | TD_FILE_ACCESS_READ_OK | TD_FILE_ACCESS_WRITE_OK)) {
|
if (checkAccess &&
|
||||||
|
taosCheckAccessFile(temp, TD_FILE_ACCESS_EXIST_OK | TD_FILE_ACCESS_READ_OK | TD_FILE_ACCESS_WRITE_OK)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,7 +310,7 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
||||||
int32_t len = (int32_t)strlen(filename);
|
int32_t len = (int32_t)strlen(filename);
|
||||||
if (len > 3 && strcmp(filename + len - 3, ".gz") == 0) {
|
if (len > 3 && strcmp(filename + len - 3, ".gz") == 0) {
|
||||||
len -= 3;
|
len -= 3;
|
||||||
}else{
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +326,7 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
||||||
int32_t days = (int32_t)(TABS(sec - fileSec) / 86400 + 1);
|
int32_t days = (int32_t)(TABS(sec - fileSec) / 86400 + 1);
|
||||||
if (days > keepDays) {
|
if (days > keepDays) {
|
||||||
TAOS_UNUSED(taosRemoveFile(filename));
|
TAOS_UNUSED(taosRemoveFile(filename));
|
||||||
uInfo("file:%s is removed, days:%d keepDays:%d, sed:%"PRId64, filename, days, keepDays, fileSec);
|
uInfo("file:%s is removed, days:%d keepDays:%d, sed:%" PRId64, filename, days, keepDays, fileSec);
|
||||||
} else {
|
} else {
|
||||||
// printf("file:%s won't be removed, days:%d keepDays:%d", filename, days, keepDays);
|
// printf("file:%s won't be removed, days:%d keepDays:%d", filename, days, keepDays);
|
||||||
}
|
}
|
||||||
|
@ -339,7 +341,7 @@ int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) {
|
||||||
OS_PARAM_CHECK(dirname);
|
OS_PARAM_CHECK(dirname);
|
||||||
OS_PARAM_CHECK(outname);
|
OS_PARAM_CHECK(outname);
|
||||||
wordexp_t full_path;
|
wordexp_t full_path;
|
||||||
int32_t code = wordexp(dirname, &full_path, 0);
|
int32_t code = wordexp(dirname, &full_path, 0);
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
@ -393,7 +395,7 @@ bool taosIsDir(const char *dirname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *taosDirName(char *name) {
|
char *taosDirName(char *name) {
|
||||||
if(name == NULL) {
|
if (name == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -423,7 +425,7 @@ char *taosDirName(char *name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *taosDirEntryBaseName(char *name) {
|
char *taosDirEntryBaseName(char *name) {
|
||||||
if(name == NULL) {
|
if (name == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -456,7 +458,7 @@ TdDirPtr taosOpenDir(const char *dirname) {
|
||||||
HANDLE hFind;
|
HANDLE hFind;
|
||||||
|
|
||||||
TdDirPtr pDir = taosMemoryMalloc(sizeof(TdDir));
|
TdDirPtr pDir = taosMemoryMalloc(sizeof(TdDir));
|
||||||
if(pDir == NULL) {
|
if (pDir == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +495,7 @@ TdDirPtr taosOpenDir(const char *dirname) {
|
||||||
|
|
||||||
TdDirEntryPtr taosReadDir(TdDirPtr pDir) {
|
TdDirEntryPtr taosReadDir(TdDirPtr pDir) {
|
||||||
if (pDir == NULL) {
|
if (pDir == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
@ -541,13 +543,13 @@ char *taosGetDirEntryName(TdDirEntryPtr pDirEntry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosCloseDir(TdDirPtr *ppDir) {
|
int32_t taosCloseDir(TdDirPtr *ppDir) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (ppDir == NULL || *ppDir == NULL) {
|
if (ppDir == NULL || *ppDir == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
if(!FindClose((*ppDir)->hFind)) {
|
if (!FindClose((*ppDir)->hFind)) {
|
||||||
terrno = TAOS_SYSTEM_WINAPI_ERROR(GetLastError());
|
terrno = TAOS_SYSTEM_WINAPI_ERROR(GetLastError());
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -582,3 +584,48 @@ void taosGetCwd(char *buf, int32_t len) {
|
||||||
tstrncpy(buf, "not implemented on windows", len);
|
tstrncpy(buf, "not implemented on windows", len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int taosGetDirSize(const char *path, int64_t *size) {
|
||||||
|
int32_t code;
|
||||||
|
TdDirPtr pDir = taosOpenDir(path);
|
||||||
|
if (pDir == NULL) {
|
||||||
|
return code = terrno;
|
||||||
|
}
|
||||||
|
int32_t nBytes = 0;
|
||||||
|
char fullPath[1024] = {0};
|
||||||
|
|
||||||
|
int64_t totalSize = 0;
|
||||||
|
TdDirEntryPtr de = NULL;
|
||||||
|
while ((de = taosReadDir(pDir)) != NULL) {
|
||||||
|
char *name = taosGetDirEntryName(de);
|
||||||
|
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
nBytes = snprintf(fullPath, sizeof(fullPath), "%s%s%s", path, TD_DIRSEP, name);
|
||||||
|
if (nBytes <= 0 || nBytes >= sizeof(fullPath)) {
|
||||||
|
TAOS_UNUSED(taosCloseDir(&pDir));
|
||||||
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t subSize = 0;
|
||||||
|
if (taosIsDir(fullPath)) {
|
||||||
|
code = taosGetDirSize(fullPath, &subSize);
|
||||||
|
if (code != 0) {
|
||||||
|
TAOS_UNUSED(taosCloseDir(&pDir));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
code = taosStatFile(fullPath, &subSize, NULL, NULL);
|
||||||
|
if (code != 0) {
|
||||||
|
TAOS_UNUSED(taosCloseDir(&pDir));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
totalSize += subSize;
|
||||||
|
fullPath[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*size = totalSize;
|
||||||
|
TAOS_UNUSED(taosCloseDir(&pDir));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -445,7 +445,7 @@ int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t res = 0;
|
int64_t res = 0;
|
||||||
DWORD bytesRead;
|
DWORD bytesRead;
|
||||||
if (!ReadFile(pFile->hFile, buf, count, &bytesRead, NULL)) {
|
if (!ReadFile(pFile->hFile, buf, count, &bytesRead, NULL)) {
|
||||||
DWORD errCode = GetLastError();
|
DWORD errCode = GetLastError();
|
||||||
terrno = TAOS_SYSTEM_WINAPI_ERROR(errCode);
|
terrno = TAOS_SYSTEM_WINAPI_ERROR(errCode);
|
||||||
|
@ -1620,4 +1620,4 @@ int taosSetAutoDelFile(char *path) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ASYNC_MODULE_QUIT, "rpc async module alre
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ASYNC_IN_PROCESS, "rpc async in process")
|
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ASYNC_IN_PROCESS, "rpc async in process")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NO_STATE, "rpc no state")
|
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NO_STATE, "rpc no state")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_STATE_DROPED, "rpc state already dropped")
|
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_STATE_DROPED, "rpc state already dropped")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MSG_EXCCED_LIMIT, "rpc msg exceed limit")
|
||||||
|
|
||||||
//common & util
|
//common & util
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TIME_UNSYNCED, "Client and server's time is not synchronized")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TIME_UNSYNCED, "Client and server's time is not synchronized")
|
||||||
|
|
|
@ -236,6 +236,7 @@
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 2
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 2
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 3
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 3
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 4
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 4
|
||||||
|
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/td-32548.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/td-32548.py
|
||||||
|
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stddev_test.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stddev_test.py
|
||||||
|
@ -374,6 +375,7 @@
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/compress_tsz2.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/compress_tsz2.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/view/non_marterial_view/test_view.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/view/non_marterial_view/test_view.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/test_show_table_distributed.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/test_show_table_distributed.py
|
||||||
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/test_show_disk_usage.py
|
||||||
,,n,system-test,python3 ./test.py -f 0-others/compatibility.py
|
,,n,system-test,python3 ./test.py -f 0-others/compatibility.py
|
||||||
,,n,system-test,python3 ./test.py -f 0-others/tag_index_basic.py
|
,,n,system-test,python3 ./test.py -f 0-others/tag_index_basic.py
|
||||||
,,n,system-test,python3 ./test.py -f 0-others/udfpy_main.py
|
,,n,system-test,python3 ./test.py -f 0-others/udfpy_main.py
|
||||||
|
@ -1539,6 +1541,7 @@
|
||||||
,,y,script,./test.sh -f tsim/compute/stddev.sim
|
,,y,script,./test.sh -f tsim/compute/stddev.sim
|
||||||
,,y,script,./test.sh -f tsim/compute/sum.sim
|
,,y,script,./test.sh -f tsim/compute/sum.sim
|
||||||
,,y,script,./test.sh -f tsim/compute/top.sim
|
,,y,script,./test.sh -f tsim/compute/top.sim
|
||||||
|
,,y,script,./test.sh -f tsim/compute/disk_usage.sim
|
||||||
,,y,script,./test.sh -f tsim/field/2.sim
|
,,y,script,./test.sh -f tsim/field/2.sim
|
||||||
,,y,script,./test.sh -f tsim/field/3.sim
|
,,y,script,./test.sh -f tsim/field/3.sim
|
||||||
,,y,script,./test.sh -f tsim/field/4.sim
|
,,y,script,./test.sh -f tsim/field/4.sim
|
||||||
|
|
|
@ -46,18 +46,26 @@ void do_query(TAOS *taos, const char *sql) {
|
||||||
void do_stmt(TAOS *taos) {
|
void do_stmt(TAOS *taos) {
|
||||||
do_query(taos, "drop database if exists db");
|
do_query(taos, "drop database if exists db");
|
||||||
do_query(taos, "create database db");
|
do_query(taos, "create database db");
|
||||||
|
do_query(taos, "use db");
|
||||||
do_query(taos,
|
do_query(taos,
|
||||||
"create table db.stb (ts timestamp, b binary(10)) tags(t1 "
|
"create table db.stb (ts timestamp, b binary(10)) tags(t1 "
|
||||||
"int, t2 binary(10))");
|
"int, t2 binary(10))");
|
||||||
do_query(taos, "CREATE TABLE db.d0 USING db.stb (t1,t2) TAGS (7,'Cali');");
|
do_query(taos, "CREATE TABLE db.d0 USING db.stb (t1,t2) TAGS (7,'Cali');");
|
||||||
do_query(taos, "CREATE TABLE db.ntb(nts timestamp, nb binary(10),nvc varchar(16),ni int);");
|
do_query(taos, "CREATE TABLE db.ntb(nts timestamp, nb binary(10),nvc varchar(16),ni int);");
|
||||||
|
do_query(
|
||||||
|
taos,
|
||||||
|
"create table if not exists all_stb(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 "
|
||||||
|
"tinyint unsigned, v7 smallint unsigned, v8 int unsigned, v9 bigint unsigned, v10 float, v11 double, v12 "
|
||||||
|
"binary(20), v13 varbinary(20), v14 geometry(100), v15 nchar(20))tags(tts timestamp, tv1 bool, tv2 tinyint, tv3 "
|
||||||
|
"smallint, tv4 int, tv5 bigint, tv6 tinyint unsigned, tv7 smallint unsigned, tv8 int unsigned, tv9 bigint "
|
||||||
|
"unsigned, tv10 float, tv11 double, tv12 binary(20), tv13 varbinary(20), tv14 geometry(100), tv15 nchar(20));");
|
||||||
|
|
||||||
printf("field_type: TAOS_FIELD_COL = 1, TAOS_FIELD_TAG=2, TAOS_FIELD_QUERY=3, TAOS_FIELD_TBNAME=4\n");
|
printf("field_type: TAOS_FIELD_COL = 1, TAOS_FIELD_TAG=2, TAOS_FIELD_QUERY=3, TAOS_FIELD_TBNAME=4\n");
|
||||||
|
|
||||||
// case 1 : INSERT INTO db.stb(t1,t2,ts,b,tbname) values(?,?,?,?,?)
|
// case 1 : INSERT INTO db.stb(t1,t2,ts,b,tbname) values(?,?,?,?,?)
|
||||||
// test super table
|
// test super table
|
||||||
const char *sql = "insert into db.stb(t1,t2,ts,b,tbname) values(?,?,?,?,?)";
|
const char *sql = "insert into db.stb(t1,t2,ts,b,tbname) values(?,?,?,?,?)";
|
||||||
printf("====================================\n");
|
printf("=================normal test===================\n");
|
||||||
printf("case 1 : %s\n", sql);
|
printf("case 1 : %s\n", sql);
|
||||||
getFields(taos, sql);
|
getFields(taos, sql);
|
||||||
|
|
||||||
|
@ -73,76 +81,123 @@ void do_stmt(TAOS *taos) {
|
||||||
printf("case 3 : %s\n", sql);
|
printf("case 3 : %s\n", sql);
|
||||||
getFields(taos, sql);
|
getFields(taos, sql);
|
||||||
|
|
||||||
// case 4 : INSERT INTO db.? using db.stb TAGS(?,?) VALUES(?,?)
|
// case 4 : INSERT INTO db.ntb VALUES(?,?,?,?)
|
||||||
// not support this clause
|
// test random order
|
||||||
sql = "insert into db.? using db.stb tags(?, ?) values(?,?)";
|
sql = "insert into db.stb(t1,tbname,ts,t2,b) values(?,?,?,?,?)";
|
||||||
printf("case 4 : %s\n", sql);
|
printf("case 4 : %s\n", sql);
|
||||||
getFields(taos, sql);
|
getFields(taos, sql);
|
||||||
|
|
||||||
// case 5 : INSERT INTO db.stb(t1,t2,ts,b) values(?,?,?,?)
|
// case 5 : insert into db.stb(ts,b,tbname) values(?,?,?)
|
||||||
// no tbname error
|
|
||||||
sql = "INSERT INTO db.stb(t1,t2,ts,b) values(?,?,?,?)";
|
|
||||||
printf("case 5 (no tbname error): %s\n", sql);
|
|
||||||
getFields(taos, sql);
|
|
||||||
|
|
||||||
// case 6 : INSERT INTO db.d0 using db.stb values(?,?)
|
|
||||||
// none para for ctbname
|
|
||||||
sql = "INSERT INTO db.d0 using db.stb values(?,?)";
|
|
||||||
printf("case 6 (no tags error): %s\n", sql);
|
|
||||||
getFields(taos, sql);
|
|
||||||
|
|
||||||
// case 7 : insert into db.stb(t1,t2,tbname) values(?,?,?)
|
|
||||||
// no value
|
|
||||||
sql = "insert into db.stb(t1,t2,tbname) values(?,?,?)";
|
|
||||||
printf("case 7 (no PK error): %s\n", sql);
|
|
||||||
getFields(taos, sql);
|
|
||||||
|
|
||||||
// case 8 : insert into db.stb(ts,b,tbname) values(?,?,?)
|
|
||||||
// no tag
|
// no tag
|
||||||
sql = "insert into db.stb(ts,b,tbname) values(?,?,?)";
|
sql = "insert into db.stb(ts,b,tbname) values(?,?,?)";
|
||||||
|
printf("case 5 : %s\n", sql);
|
||||||
|
getFields(taos, sql);
|
||||||
|
|
||||||
|
// case 6 : INSERT INTO db.? using db.stb TAGS(?,?) VALUES(?,?)
|
||||||
|
// normal insert clause
|
||||||
|
sql = "insert into ? using db.stb tags(?, ?) values(?,?)";
|
||||||
|
printf("case 6 : %s\n", sql);
|
||||||
|
getFields(taos, sql);
|
||||||
|
|
||||||
|
// case 7 : insert into db.? using db.stb(t2,t1) tags(?, ?) (b,ts)values(?,?)
|
||||||
|
// disordered
|
||||||
|
sql = "insert into db.? using db.stb(t2,t1) tags(?, ?) (b,ts)values(?,?)";
|
||||||
|
printf("case 7 : %s\n", sql);
|
||||||
|
getFields(taos, sql);
|
||||||
|
|
||||||
|
// case 8 : insert into db.? using db.stb tags(?, ?) values(?,?)
|
||||||
|
// no field name
|
||||||
|
sql = "insert into db.? using db.stb tags(?, ?) values(?,?)";
|
||||||
printf("case 8 : %s\n", sql);
|
printf("case 8 : %s\n", sql);
|
||||||
getFields(taos, sql);
|
getFields(taos, sql);
|
||||||
|
|
||||||
// case 9 : insert into db.stb(ts,b,tbname) values(?,?,?,?,?)
|
// case 9 : insert into db.? using db.stb tags(?, ?) values(?,?)
|
||||||
// wrong para nums
|
// less para
|
||||||
sql = "insert into db.stb(ts,b,tbname) values(?,?,?,?,?)";
|
sql = "insert into db.? using db.stb (t2)tags(?) (ts)values(?)";
|
||||||
printf("case 9 (wrong para nums): %s\n", sql);
|
printf("case 9 : %s\n", sql);
|
||||||
getFields(taos, sql);
|
getFields(taos, sql);
|
||||||
|
|
||||||
// case 10 : insert into db.ntb(nts,ni) values(?,?,?,?,?)
|
// case 10 : insert into db.? using db.stb tags(?, ?) values(?,?)
|
||||||
// wrong para nums
|
// less para
|
||||||
sql = "insert into db.ntb(nts,ni) values(?,?)";
|
sql = "insert into db.d0 (ts)values(?)";
|
||||||
printf("case 10 : %s\n", sql);
|
printf("case 10 : %s\n", sql);
|
||||||
getFields(taos, sql);
|
getFields(taos, sql);
|
||||||
|
|
||||||
// case 11 : insert into db.? values(?,?)
|
// case 11 : insert into abc using stb tags(?, ?) values(?,?)
|
||||||
// normal table must have tbnam
|
// insert create table
|
||||||
sql = "insert into db.? values(?,?)";
|
sql = "insert into abc using stb tags(?, ?) values(?,?)";
|
||||||
printf("case 11 (normal table must have tbname): %s\n", sql);
|
printf("case 11 : %s\n", sql);
|
||||||
getFields(taos, sql);
|
getFields(taos, sql);
|
||||||
|
|
||||||
// case 12 : insert into db.? using db.stb(t2,t1) tags(?, ?) (b,ts)values(?,?)
|
// case 12 : insert into ? using all_stb tags(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||||
// disordered
|
// test all types
|
||||||
sql = "insert into db.? using db.stb(t2,t1) tags(?, ?) (b,ts)values(?,?)";
|
sql = "insert into ? using all_stb tags(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||||
printf("case 12 : %s\n", sql);
|
printf("case 12 : %s\n", sql);
|
||||||
getFields(taos, sql);
|
getFields(taos, sql);
|
||||||
|
|
||||||
// case 13 : insert into db.? using db.stb tags(?, ?) values(?,?)
|
// case 13 : insert into ? using all_stb tags(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||||
// no field name
|
// test all types
|
||||||
sql = "insert into db.? using db.stb tags(?, ?) values(?,?)";
|
sql =
|
||||||
|
"insert into all_stb "
|
||||||
|
"(tbname,tts,tv1,tv2,tv3,tv4,tv5,tv6,tv7,tv8,tv9,tv10,tv11,tv12,tv13,tv14,tv15,ts,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,"
|
||||||
|
"v11,v12,v13,v14,v15) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||||
printf("case 13 : %s\n", sql);
|
printf("case 13 : %s\n", sql);
|
||||||
getFields(taos, sql);
|
getFields(taos, sql);
|
||||||
|
printf("=================error test===================\n");
|
||||||
|
|
||||||
// case 14 : insert into db.? using db.stb tags(?, ?) values(?,?)
|
// case 14 : INSERT INTO db.d0 using db.stb values(?,?)
|
||||||
// less para
|
// none para for ctbname
|
||||||
sql = "insert into db.? using db.stb (t2)tags(?) (ts)values(?)";
|
sql = "INSERT INTO db.d0 using db.stb values(?,?)";
|
||||||
printf("case 14 : %s\n", sql);
|
printf("case 14 (no tags error): %s\n", sql);
|
||||||
getFields(taos, sql);
|
getFields(taos, sql);
|
||||||
|
|
||||||
// case 15 : insert into db.? using db.stb tags(?, ?) values(?,?)
|
// case 15 : insert into db.stb(t1,t2,tbname) values(?,?,?)
|
||||||
// less para
|
// no value
|
||||||
sql = "insert into db.d0 (ts)values(?)";
|
sql = "insert into db.stb(t1,t2,tbname) values(?,?,?)";
|
||||||
printf("case 15 : %s\n", sql);
|
printf("case 15 (no PK error): %s\n", sql);
|
||||||
|
getFields(taos, sql);
|
||||||
|
|
||||||
|
// case 16 : insert into db.stb(ts,b,tbname) values(?,?,?,?,?)
|
||||||
|
// wrong para nums
|
||||||
|
sql = "insert into db.stb(ts,b,tbname) values(?,?,?,?,?)";
|
||||||
|
printf("case 16 (wrong para nums): %s\n", sql);
|
||||||
|
getFields(taos, sql);
|
||||||
|
|
||||||
|
// case 17 : insert into db.? values(?,?)
|
||||||
|
// normal table must have tbnam
|
||||||
|
sql = "insert into db.? values(?,?)";
|
||||||
|
printf("case 17 (normal table must have tbname): %s\n", sql);
|
||||||
|
getFields(taos, sql);
|
||||||
|
|
||||||
|
// case 18 : INSERT INTO db.stb(t1,t2,ts,b) values(?,?,?,?)
|
||||||
|
// no tbname error
|
||||||
|
sql = "INSERT INTO db.stb(t1,t2,ts,b) values(?,?,?,?)";
|
||||||
|
printf("case 18 (no tbname error): %s\n", sql);
|
||||||
|
getFields(taos, sql);
|
||||||
|
|
||||||
|
// case 19 : insert into db.ntb(nts,ni) values(?,?,?,?,?)
|
||||||
|
// wrong para nums
|
||||||
|
sql = "insert into ntb(nts,ni) values(?,?,?,?,?)";
|
||||||
|
printf("case 19 : %s\n", sql);
|
||||||
|
getFields(taos, sql);
|
||||||
|
|
||||||
|
// case 20 : insert into db.stb(t1,t2,ts,b,tbname) values(*,*,*,*,*)
|
||||||
|
// wrong simbol
|
||||||
|
sql = "insert into db.stb(t1,t2,ts,b,tbname) values(*,*,*,*,*)";
|
||||||
|
printf("=================normal test===================\n");
|
||||||
|
printf("case 20 : %s\n", sql);
|
||||||
|
getFields(taos, sql);
|
||||||
|
|
||||||
|
// case 21 : INSERT INTO ! using db.stb TAGS(?,?) VALUES(?,?)
|
||||||
|
// wrong simbol
|
||||||
|
sql = "insert into ! using db.stb tags(?, ?) values(?,?)";
|
||||||
|
printf("case 21 : %s\n", sql);
|
||||||
|
getFields(taos, sql);
|
||||||
|
|
||||||
|
// case 22 : INSERT INTO ! using db.stb TAGS(?,?) VALUES(?,?)
|
||||||
|
// wrong tbname
|
||||||
|
sql = "insert into db.stb values(?,?)";
|
||||||
|
printf("case 22 : %s\n", sql);
|
||||||
getFields(taos, sql);
|
getFields(taos, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/cfg.sh -n dnode1 -c debugflag -v 131
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
$dbPrefix = m_di_db
|
||||||
|
$tbPrefix = m_di_tb
|
||||||
|
$mtPrefix = m_di_mt
|
||||||
|
$ntPrefix = m_di_nt
|
||||||
|
$tbNum = 1
|
||||||
|
$rowNum = 2000
|
||||||
|
|
||||||
|
print =============== step1
|
||||||
|
$i = 0
|
||||||
|
$db = $dbPrefix . $i
|
||||||
|
$mt = $mtPrefix . $i
|
||||||
|
$nt = $ntPrefix . $i
|
||||||
|
|
||||||
|
sql drop database $db -x step1
|
||||||
|
step1:
|
||||||
|
sql create database $db
|
||||||
|
sql use $db
|
||||||
|
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||||
|
|
||||||
|
$i = 0
|
||||||
|
while $i < $tbNum
|
||||||
|
$tb = $tbPrefix . $i
|
||||||
|
sql create table $tb using $mt tags( $i )
|
||||||
|
|
||||||
|
$x = 0
|
||||||
|
while $x < $rowNum
|
||||||
|
$cc = $x * 60000
|
||||||
|
$ms = 1601481600000 + $cc
|
||||||
|
sql insert into $tb values ($ms , $x )
|
||||||
|
$x = $x + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
$i = $i + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
sql create table $nt (ts timestamp, tbcol int)
|
||||||
|
$x = 0
|
||||||
|
while $x < $rowNum
|
||||||
|
$cc = $x * 60000
|
||||||
|
$ms = 1601481600000 + $cc
|
||||||
|
sql insert into $nt values ($ms , $x )
|
||||||
|
$x = $x + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
sql flush database $db
|
||||||
|
|
||||||
|
|
||||||
|
sql select * from information_schema.ins_disk_usage
|
||||||
|
sql select sum(vgroup_id) from information_schema.ins_disk_usage
|
||||||
|
sql select sum(wal) from information_schema.ins_disk_usage
|
||||||
|
sql select sum(data1) from information_schema.ins_disk_usage
|
||||||
|
sql select sum(data2) from information_schema.ins_disk_usage
|
||||||
|
sql select sum(data3) from information_schema.ins_disk_usage
|
||||||
|
sql select sum(cache_rdb) from information_schema.ins_disk_usage
|
||||||
|
sql select sum(table_meta) from information_schema.ins_disk_usage
|
||||||
|
sql select sum(s3) from information_schema.ins_disk_usage
|
||||||
|
sql select sum(raw_data) from information_schema.ins_disk_usage
|
||||||
|
|
||||||
|
print $data00
|
||||||
|
print $rawDataSize
|
||||||
|
print $rows
|
||||||
|
|
||||||
|
sql use $db
|
||||||
|
sql show disk_info
|
||||||
|
|
||||||
|
#sql drop database $db
|
||||||
|
#sql select * from information_schema.ins_disk_usage
|
||||||
|
#if $rows != 0 then
|
||||||
|
# return -1
|
||||||
|
#endi
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -61,7 +61,7 @@ class TDTestCase:
|
||||||
self.ins_list = ['ins_dnodes','ins_mnodes','ins_qnodes','ins_snodes','ins_cluster','ins_databases','ins_functions',\
|
self.ins_list = ['ins_dnodes','ins_mnodes','ins_qnodes','ins_snodes','ins_cluster','ins_databases','ins_functions',\
|
||||||
'ins_indexes','ins_stables','ins_tables','ins_tags','ins_columns','ins_users','ins_grants','ins_vgroups','ins_configs','ins_dnode_variables',\
|
'ins_indexes','ins_stables','ins_tables','ins_tags','ins_columns','ins_users','ins_grants','ins_vgroups','ins_configs','ins_dnode_variables',\
|
||||||
'ins_topics','ins_subscriptions','ins_streams','ins_stream_tasks','ins_vnodes','ins_user_privileges','ins_views',
|
'ins_topics','ins_subscriptions','ins_streams','ins_stream_tasks','ins_vnodes','ins_user_privileges','ins_views',
|
||||||
'ins_compacts', 'ins_compact_details', 'ins_grants_full','ins_grants_logs', 'ins_machines', 'ins_arbgroups', 'ins_tsmas', "ins_encryptions", "ins_anodes", "ins_anodes_full", "ins_filesets"]
|
'ins_compacts', 'ins_compact_details', 'ins_grants_full','ins_grants_logs', 'ins_machines', 'ins_arbgroups', 'ins_tsmas', "ins_encryptions", "ins_anodes", "ins_anodes_full", "ins_disk_usagea", "ins_filesets"]
|
||||||
self.perf_list = ['perf_connections','perf_queries','perf_consumers','perf_trans','perf_apps']
|
self.perf_list = ['perf_connections','perf_queries','perf_consumers','perf_trans','perf_apps']
|
||||||
def insert_data(self,column_dict,tbname,row_num):
|
def insert_data(self,column_dict,tbname,row_num):
|
||||||
insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str)
|
insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str)
|
||||||
|
|
|
@ -0,0 +1,217 @@
|
||||||
|
from itertools import product
|
||||||
|
import taos
|
||||||
|
import random
|
||||||
|
import time
|
||||||
|
from taos.tmq import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.common import *
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.sqlset import *
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
def get_disk_usage(path):
|
||||||
|
try:
|
||||||
|
result = subprocess.run(['du', '-sb', path], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||||
|
if result.returncode == 0:
|
||||||
|
# The output is in the format "size\tpath"
|
||||||
|
size = int(result.stdout.split()[0])
|
||||||
|
return size
|
||||||
|
else:
|
||||||
|
print(f"Error: {result.stderr}")
|
||||||
|
return None
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Exception occurred: {e}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
def list_directories_with_keyword(base_path, keyword):
|
||||||
|
matching_dirs = []
|
||||||
|
for dirpath, dirnames, filenames in os.walk(base_path):
|
||||||
|
for dirname in dirnames:
|
||||||
|
if keyword in dirname:
|
||||||
|
full_path = os.path.join(dirpath, dirname)
|
||||||
|
matching_dirs.append(full_path)
|
||||||
|
return matching_dirs
|
||||||
|
|
||||||
|
def calculate_directories_size(base_path, keyword):
|
||||||
|
matching_dirs = list_directories_with_keyword(base_path, keyword)
|
||||||
|
total_size = 0
|
||||||
|
for directory in matching_dirs:
|
||||||
|
printf("directory: %s" % directory)
|
||||||
|
size = get_disk_usage(directory)
|
||||||
|
if size is not None:
|
||||||
|
total_size += size
|
||||||
|
return int(total_size/1024)
|
||||||
|
class TDTestCase:
|
||||||
|
"""This test case is used to veirfy show db disk usage"""
|
||||||
|
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
# init the tdsql
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
self.dbname = "db_disk_usage"
|
||||||
|
self.stname = "st"
|
||||||
|
self.ctnum = 100
|
||||||
|
self.row_num = 1000
|
||||||
|
self.row_data_size = self.ctnum * self.row_num * (8 + 4 + 4) # timestamp + int + float
|
||||||
|
self.other_dbname = "db_disk_usage_other"
|
||||||
|
self.other_stname = "st_other"
|
||||||
|
self.data_path = tdCom.getTaosdPath()
|
||||||
|
tdLog.debug("data_path: %s" % self.data_path)
|
||||||
|
# create database
|
||||||
|
tdSql.execute(f'create database if not exists {self.dbname};')
|
||||||
|
tdSql.execute(f'create database if not exists {self.other_dbname};')
|
||||||
|
tdSql.execute(f'create table {self.other_dbname}.{self.other_stname} (ts timestamp, id int, temperature float) tags (name binary(20));')
|
||||||
|
tdSql.execute(f'create database if not exists {self.other_dbname};')
|
||||||
|
|
||||||
|
tdSql.execute(f'use {self.dbname};')
|
||||||
|
# create super table
|
||||||
|
tdSql.execute(f'create table {self.dbname}.{self.stname} (ts timestamp, id int, temperature float) tags (name binary(20));')
|
||||||
|
# create child table
|
||||||
|
for i in range(self.ctnum):
|
||||||
|
tdSql.execute(f'create table ct_{str(i+1)} using {self.stname} tags ("name{str(i+1)}");')
|
||||||
|
# insert data
|
||||||
|
sql = f"insert into ct_{str(i+1)} values "
|
||||||
|
for j in range(self.row_num):
|
||||||
|
sql += f"(now+{j+1}s, {j+1}, {random.uniform(15, 30)}) "
|
||||||
|
sql += ";"
|
||||||
|
tdSql.execute(sql)
|
||||||
|
|
||||||
|
|
||||||
|
tdSql.execute(f"flush database {self.dbname};")
|
||||||
|
tdLog.debug("init finished")
|
||||||
|
def getWALSize(self):
|
||||||
|
return calculate_directories_size(self.data_path, "wal")
|
||||||
|
def getTSDBSize(self):
|
||||||
|
tsdbDirSize = calculate_directories_size(self.data_path, "tsdb")
|
||||||
|
cacheRdbSize = calculate_directories_size(self.data_path, "cache.rdb")
|
||||||
|
return tsdbDirSize - cacheRdbSize
|
||||||
|
def getTableMetaSize(self):
|
||||||
|
return calculate_directories_size(self.data_path, "meta")
|
||||||
|
def getCacheRDBSize(self):
|
||||||
|
return calculate_directories_size(self.data_path, "cache.rdb")
|
||||||
|
def checkRes(self, queryRes):
|
||||||
|
disk_occupied = 0
|
||||||
|
compress_radio = 0
|
||||||
|
for item in queryRes:
|
||||||
|
if "Disk_occupied=" in item[0]:
|
||||||
|
disk_occupied= int(item[0].split("=")[1].split(" ")[0].replace("[", "").replace("k]", ""))
|
||||||
|
#tdLog.debug("disk_occupied: %s" % disk_occupied)
|
||||||
|
elif "Compress_radio=" in item[0]:
|
||||||
|
value = item[0].split("=")[1].split(" ")[0].replace("[", "").replace("]", "")
|
||||||
|
if value != 'NULL':
|
||||||
|
compress_radio = float(value)
|
||||||
|
#tdLog.debug("compress_occupied: %s" % compress_radio)
|
||||||
|
return disk_occupied, compress_radio
|
||||||
|
|
||||||
|
def insertData(self):
|
||||||
|
tdSql.execute(f'use {self.other_dbname};')
|
||||||
|
# create super table
|
||||||
|
tdSql.execute(f'create table {self.other_dbname}.{self.stname} (ts timestamp, id int, temperature float) tags (name binary(20));')
|
||||||
|
# create child table
|
||||||
|
for i in range(self.ctnum):
|
||||||
|
tdSql.execute(f'create table ct_{str(i+1)} using {self.stname} tags ("name{str(i+1)}");')
|
||||||
|
sql = f"insert into ct_{str(i+1)} values "
|
||||||
|
for j in range(self.row_num):
|
||||||
|
sql += f"(now+{j+1}s, {j+1}, {random.uniform(15, 30)}) "
|
||||||
|
sql += ";"
|
||||||
|
tdSql.execute(sql)
|
||||||
|
|
||||||
|
tdSql.execute(f"flush database {self.other_dbname};")
|
||||||
|
tdLog.debug("init finished")
|
||||||
|
def value_check(self,base_value,check_value, threshold):
|
||||||
|
if abs(base_value-check_value) < threshold:
|
||||||
|
tdLog.info(f"checkEqual success, base_value={base_value},check_value={check_value}")
|
||||||
|
else :
|
||||||
|
tdLog.exit(f"checkEqual error, base_value=={base_value},check_value={check_value}")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
|
||||||
|
tdSql.execute(f"flush database {self.dbname};")
|
||||||
|
tdSql.query(f"show disk_info")
|
||||||
|
tdLog.debug(tdSql.queryResult)
|
||||||
|
disk_occupied,compress_radio = self.checkRes(tdSql.queryResult)
|
||||||
|
tdLog.debug("disk_occupied: %s, compress_radio: %s" % (disk_occupied, compress_radio))
|
||||||
|
|
||||||
|
|
||||||
|
#mem_rows_num, stt_rows_num = self.checkRes(tdSql.queryResult)
|
||||||
|
#tdLog.debug("mem_rows_num: %s, stt_rows_num: %s" % (mem_rows_num, stt_rows_num))
|
||||||
|
|
||||||
|
tdSql.query(f"select sum(data1+data2+data3) from information_schema.ins_disk_usage where db_name='{self.dbname}';")
|
||||||
|
tdSql.checkData(0,0,disk_occupied)
|
||||||
|
tdSql.query(f"select sum(data1+data2+data3)/sum(raw_data) from information_schema.ins_disk_usage where db_name='{self.dbname}';")
|
||||||
|
#tdSql.checkData(0,0,compress_radio/100)
|
||||||
|
tdSql.query(f"select sum(wal) from information_schema.ins_disk_usage where db_name='{self.dbname}';")
|
||||||
|
tdSql.query(f"select sum(table_meta) from information_schema.ins_disk_usage where db_name='{self.dbname}';")
|
||||||
|
tdSql.query(f"select sum(cache_rdb) from information_schema.ins_disk_usage where db_name='{self.dbname}';")
|
||||||
|
|
||||||
|
tdSql.execute(f"use {self.other_dbname};")
|
||||||
|
tdSql.query(f"select sum(data1+data2+data3) from information_schema.ins_disk_usage where db_name='{self.other_dbname}';")
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query(f"select sum(wal) from information_schema.ins_disk_usage where db_name='{self.other_dbname}';")
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query(f"select sum(cache_rdb) from information_schema.ins_disk_usage where db_name='{self.other_dbname}';")
|
||||||
|
tdSql.checkData(0,0,12)
|
||||||
|
tdSql.query(f"select sum(table_meta) from information_schema.ins_disk_usage where db_name='{self.other_dbname}';")
|
||||||
|
tdSql.checkData(0,0,152)
|
||||||
|
tdSql.query(f"select sum(s3) from information_schema.ins_disk_usage where db_name='{self.other_dbname}';")
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.error(f"select sum(s3) from information_schema.ins_disk_usage where db='{self.other_dbname}';")
|
||||||
|
tdSql.error(f"select sum(s3) from information_schema.ins_disk_usage where db1='{self.other_dbname}';")
|
||||||
|
|
||||||
|
|
||||||
|
self.insertData()
|
||||||
|
tdSql.execute(f"flush database {self.other_dbname};")
|
||||||
|
tdSql.query(f"show {self.other_dbname}.disk_info;")
|
||||||
|
disk_occupied,compress_radio = self.checkRes(tdSql.queryResult)
|
||||||
|
tdLog.debug("database: %s, disk_occupied: %s, compress_radio: %s" % (self.other_dbname,disk_occupied, compress_radio))
|
||||||
|
|
||||||
|
tdSql.query(f"select sum(data1+data2+data3) from information_schema.ins_disk_usage where db_name='{self.other_dbname}';")
|
||||||
|
tdSql.checkData(0,0,disk_occupied)
|
||||||
|
|
||||||
|
|
||||||
|
tdSql.query(f"select sum(wal) from information_schema.ins_disk_usage where db_name='{self.other_dbname}' or db_name='{self.dbname}';")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
iwal = tdSql.queryResult[0][0]
|
||||||
|
tdSql.query(f"select sum(table_meta) from information_schema.ins_disk_usage where db_name='{self.other_dbname}' or db_name='{self.dbname}';")
|
||||||
|
itableMeta = tdSql.queryResult[0][0]
|
||||||
|
tdSql.query(f"select sum(data1+data2+data3) from information_schema.ins_disk_usage where db_name='{self.other_dbname}' or db_name='{self.dbname}';")
|
||||||
|
itsdbSize = int(tdSql.queryResult[0][0])
|
||||||
|
tdSql.query(f"select sum(cache_rdb) from information_schema.ins_disk_usage where db_name='{self.other_dbname}' or db_name='{self.dbname}';")
|
||||||
|
icache = tdSql.queryResult[0][0]
|
||||||
|
walSize = self.getWALSize()
|
||||||
|
tableMetaSize = self.getTableMetaSize()
|
||||||
|
tsdbSize = self.getTSDBSize()
|
||||||
|
cacheRdbSize = self.getCacheRDBSize()
|
||||||
|
tdLog.debug("calc: walSize: %s, tableMetaSize: %s, tsdbSize: %s, cacheRdbSize: %s" % (iwal, itableMeta, itsdbSize, icache))
|
||||||
|
tdLog.debug("du: walSize: %s, tableMetaSize: %s, tsdbSize: %s, cacheRdbSize: %s" % (walSize, tableMetaSize, tsdbSize, cacheRdbSize))
|
||||||
|
|
||||||
|
self.value_check(icache, cacheRdbSize, 64)
|
||||||
|
self.value_check(itableMeta,tableMetaSize, 64)
|
||||||
|
self.value_check(itsdbSize, tsdbSize, 64)
|
||||||
|
self.value_check(iwal, walSize, 128)
|
||||||
|
#if abs(icache - cacheRdbSize) > 12:
|
||||||
|
# tdLog.error("cache_rdb size is not equal")
|
||||||
|
|
||||||
|
#if abs(walSize - iwal) > 12:
|
||||||
|
# tdLog.error("wal size is not equal")
|
||||||
|
|
||||||
|
#if abs(tableMetaSize - itableMeta) > 12k'k'k
|
||||||
|
# tdLog.error("table_meta size is not equal")
|
||||||
|
|
||||||
|
#if abs(tsdbSize - itsdbSize) > 12:
|
||||||
|
# tdLog.error("tsdb size is not equal")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
# remove the user
|
||||||
|
tdSql.execute(f'drop database {self.dbname};')
|
||||||
|
# close the connection
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
Loading…
Reference in New Issue