[td-2859]
This commit is contained in:
parent
4a0bc100b9
commit
b6aa9da938
|
@ -88,7 +88,7 @@ typedef struct SVgroupTableInfo {
|
|||
SArray* itemList; //SArray<STableIdInfo>
|
||||
} SVgroupTableInfo;
|
||||
|
||||
static FORCE_INLINE SQueryInfo* tscGetQueryInfo(SSqlCmd* pCmd, int32_t subClauseIndex) {
|
||||
static FORCE_INLINE SQueryNodeInfo* tscGetQueryInfo(SSqlCmd* pCmd, int32_t subClauseIndex) {
|
||||
assert(pCmd != NULL && subClauseIndex >= 0);
|
||||
if (pCmd->pQueryInfo == NULL || subClauseIndex >= pCmd->numOfClause) {
|
||||
return NULL;
|
||||
|
@ -97,7 +97,7 @@ static FORCE_INLINE SQueryInfo* tscGetQueryInfo(SSqlCmd* pCmd, int32_t subClause
|
|||
return pCmd->pQueryInfo[subClauseIndex];
|
||||
}
|
||||
|
||||
SQueryInfo* tscGetActiveQueryInfo(SSqlCmd* pCmd);
|
||||
SQueryNodeInfo* tscGetActiveQueryInfo(SSqlCmd* pCmd);
|
||||
|
||||
int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOffset, SName* name, STableMeta* pTableMeta, STableDataBlocks** dataBlocks);
|
||||
void tscDestroyDataBlock(STableDataBlocks* pDataBlock, bool removeMeta);
|
||||
|
@ -121,27 +121,33 @@ int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, i
|
|||
* @param pSql sql object
|
||||
* @return
|
||||
*/
|
||||
bool tscIsPointInterpQuery(SQueryInfo* pQueryInfo);
|
||||
bool tscIsTWAQuery(SQueryInfo* pQueryInfo);
|
||||
bool tscIsSecondStageQuery(SQueryInfo* pQueryInfo);
|
||||
bool tscGroupbyColumn(SQueryInfo* pQueryInfo);
|
||||
bool tscIsPointInterpQuery(SQueryNodeInfo* pQueryInfo);
|
||||
bool tscIsTWAQuery(SQueryNodeInfo* pQueryInfo);
|
||||
bool tscIsSecondStageQuery(SQueryNodeInfo* pQueryInfo);
|
||||
bool tscGroupbyColumn(SQueryNodeInfo* pQueryInfo);
|
||||
bool tscIsTopBotQuery(SQueryNodeInfo* pQueryInfo);
|
||||
bool hasTagValOutput(SQueryNodeInfo* pQueryInfo);
|
||||
bool timeWindowInterpoRequired(SQueryNodeInfo *pQueryNodeInfo);
|
||||
bool isStabledev(SQueryNodeInfo* pQueryInfo);
|
||||
bool isTsCompQuery(SQueryNodeInfo* pQueryNodeInfo);
|
||||
bool isSimpleAggregate(SQueryNodeInfo* pQueryNodeInfo);
|
||||
|
||||
bool tscNonOrderedProjectionQueryOnSTable(SQueryInfo *pQueryInfo, int32_t tableIndex);
|
||||
bool tscOrderedProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex);
|
||||
bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex);
|
||||
bool tscNonOrderedProjectionQueryOnSTable(SQueryNodeInfo *pQueryInfo, int32_t tableIndex);
|
||||
bool tscOrderedProjectionQueryOnSTable(SQueryNodeInfo* pQueryInfo, int32_t tableIndex);
|
||||
bool tscIsProjectionQueryOnSTable(SQueryNodeInfo* pQueryInfo, int32_t tableIndex);
|
||||
|
||||
bool tscIsProjectionQuery(SQueryInfo* pQueryInfo);
|
||||
bool tscIsProjectionQuery(SQueryNodeInfo* pQueryInfo);
|
||||
|
||||
bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex);
|
||||
bool tscQueryTags(SQueryInfo* pQueryInfo);
|
||||
bool tscMultiRoundQuery(SQueryInfo* pQueryInfo, int32_t tableIndex);
|
||||
bool tscQueryBlockInfo(SQueryInfo* pQueryInfo);
|
||||
bool tscIsTwoStageSTableQuery(SQueryNodeInfo* pQueryInfo, int32_t tableIndex);
|
||||
bool tscQueryTags(SQueryNodeInfo* pQueryInfo);
|
||||
bool tscMultiRoundQuery(SQueryNodeInfo* pQueryInfo, int32_t tableIndex);
|
||||
bool tscQueryBlockInfo(SQueryNodeInfo* pQueryInfo);
|
||||
|
||||
SSqlExpr* tscAddFuncInSelectClause(SQueryInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId,
|
||||
SExprInfo* tscAddFuncInSelectClause(SQueryNodeInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId,
|
||||
SColumnIndex* pIndex, SSchema* pColSchema, int16_t colType);
|
||||
|
||||
int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql);
|
||||
void tscClearInterpInfo(SQueryInfo* pQueryInfo);
|
||||
void tscClearInterpInfo(SQueryNodeInfo* pQueryInfo);
|
||||
|
||||
bool tscIsInsertData(char* sqlstr);
|
||||
|
||||
|
@ -155,12 +161,12 @@ SInternalField* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_F
|
|||
SInternalField* tscFieldInfoGetInternalField(SFieldInfo* pFieldInfo, int32_t index);
|
||||
TAOS_FIELD* tscFieldInfoGetField(SFieldInfo* pFieldInfo, int32_t index);
|
||||
|
||||
void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo);
|
||||
void tscFieldInfoUpdateOffset(SQueryNodeInfo* pQueryInfo);
|
||||
|
||||
int16_t tscFieldInfoGetOffset(SQueryInfo* pQueryInfo, int32_t index);
|
||||
int16_t tscFieldInfoGetOffset(SQueryNodeInfo* pQueryInfo, int32_t index);
|
||||
void tscFieldInfoClear(SFieldInfo* pFieldInfo);
|
||||
|
||||
static FORCE_INLINE int32_t tscNumOfFields(SQueryInfo* pQueryInfo) { return pQueryInfo->fieldsInfo.numOfOutput; }
|
||||
static FORCE_INLINE int32_t tscNumOfFields(SQueryNodeInfo* pQueryInfo) { return pQueryInfo->fieldsInfo.numOfOutput; }
|
||||
|
||||
int32_t tscFieldInfoCompare(const SFieldInfo* pFieldInfo1, const SFieldInfo* pFieldInfo2);
|
||||
|
||||
|
@ -168,24 +174,24 @@ void addExprParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t bytes)
|
|||
|
||||
int32_t tscGetResRowLength(SArray* pExprList);
|
||||
|
||||
SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
|
||||
SExprInfo* tscSqlExprInsert(SQueryNodeInfo* pQueryInfo, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
|
||||
int16_t size, int16_t resColId, int16_t interSize, bool isTagCol);
|
||||
|
||||
SSqlExpr* tscSqlExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
|
||||
SExprInfo* tscSqlExprAppend(SQueryNodeInfo* pQueryInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
|
||||
int16_t size, int16_t resColId, int16_t interSize, bool isTagCol);
|
||||
|
||||
SSqlExpr* tscSqlExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type,
|
||||
SExprInfo* tscSqlExprUpdate(SQueryNodeInfo* pQueryInfo, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type,
|
||||
int16_t size);
|
||||
size_t tscSqlExprNumOfExprs(SQueryInfo* pQueryInfo);
|
||||
void tscInsertPrimaryTsSourceColumn(SQueryInfo* pQueryInfo, SColumnIndex* pIndex);
|
||||
size_t tscSqlExprNumOfExprs(SQueryNodeInfo* pQueryInfo);
|
||||
void tscInsertPrimaryTsSourceColumn(SQueryNodeInfo* pQueryInfo, SColumnIndex* pIndex);
|
||||
|
||||
SSqlExpr* tscSqlExprGet(SQueryInfo* pQueryInfo, int32_t index);
|
||||
SExprInfo* tscSqlExprGet(SQueryNodeInfo* pQueryInfo, int32_t index);
|
||||
int32_t tscSqlExprCopy(SArray* dst, const SArray* src, uint64_t uid, bool deepcopy);
|
||||
void tscSqlExprAssign(SExprInfo* dst, const SExprInfo* src);
|
||||
void tscSqlExprInfoDestroy(SArray* pExprInfo);
|
||||
|
||||
SColumn* tscColumnClone(const SColumn* src);
|
||||
SColumn* tscColumnListInsert(SArray* pColList, SColumnIndex* colIndex);
|
||||
SArray* tscColumnListClone(const SArray* src, int16_t tableIndex);
|
||||
SColumn* tscColumnListInsert(SArray* pColList, SColumnIndex* colIndex, SSchema* pSchema);
|
||||
void tscColumnListDestroy(SArray* pColList);
|
||||
|
||||
void tscDequoteAndTrimToken(SStrToken* pToken);
|
||||
|
@ -202,25 +208,25 @@ void tsSetSTableQueryCond(STagCond* pTagCond, uint64_t uid, SBufferWriter* bw)
|
|||
int32_t tscTagCondCopy(STagCond* dest, const STagCond* src);
|
||||
void tscTagCondRelease(STagCond* pCond);
|
||||
|
||||
void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo);
|
||||
void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryNodeInfo* pQueryInfo);
|
||||
|
||||
bool tscShouldBeFreed(SSqlObj* pSql);
|
||||
|
||||
STableMetaInfo* tscGetTableMetaInfoFromCmd(SSqlCmd *pCmd, int32_t subClauseIndex, int32_t tableIndex);
|
||||
STableMetaInfo* tscGetMetaInfo(SQueryInfo *pQueryInfo, int32_t tableIndex);
|
||||
STableMetaInfo* tscGetMetaInfo(SQueryNodeInfo *pQueryInfo, int32_t tableIndex);
|
||||
|
||||
void tscInitQueryInfo(SQueryInfo* pQueryInfo);
|
||||
void tscInitQueryInfo(SQueryNodeInfo* pQueryInfo);
|
||||
void tscClearSubqueryInfo(SSqlCmd* pCmd);
|
||||
int32_t tscAddQueryInfo(SSqlCmd *pCmd);
|
||||
SQueryInfo *tscGetQueryInfo(SSqlCmd* pCmd, int32_t subClauseIndex);
|
||||
SQueryInfo *tscGetQueryInfoS(SSqlCmd *pCmd, int32_t subClauseIndex);
|
||||
SQueryNodeInfo *tscGetQueryInfo(SSqlCmd* pCmd, int32_t subClauseIndex);
|
||||
SQueryNodeInfo *tscGetQueryInfoS(SSqlCmd *pCmd, int32_t subClauseIndex);
|
||||
|
||||
void tscClearTableMetaInfo(STableMetaInfo* pTableMetaInfo);
|
||||
|
||||
STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, SName* name, STableMeta* pTableMeta,
|
||||
STableMetaInfo* tscAddTableMetaInfo(SQueryNodeInfo* pQueryInfo, SName* name, STableMeta* pTableMeta,
|
||||
SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables);
|
||||
|
||||
STableMetaInfo* tscAddEmptyMetaInfo(SQueryInfo *pQueryInfo);
|
||||
STableMetaInfo* tscAddEmptyMetaInfo(SQueryNodeInfo *pQueryInfo);
|
||||
|
||||
void tscFreeVgroupTableInfo(SArray* pVgroupTables);
|
||||
SArray* tscVgroupTableInfoDup(SArray* pVgroupTables);
|
||||
|
@ -233,8 +239,8 @@ int tscGetTableMetaEx(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, bool creat
|
|||
|
||||
void tscResetForNextRetrieve(SSqlRes* pRes);
|
||||
void tscDoQuery(SSqlObj* pSql);
|
||||
void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo);
|
||||
void doExecuteQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo);
|
||||
void executeQuery(SSqlObj* pSql, SQueryNodeInfo* pQueryInfo);
|
||||
void doExecuteQuery(SSqlObj* pSql, SQueryNodeInfo* pQueryInfo);
|
||||
|
||||
SVgroupsInfo* tscVgroupInfoClone(SVgroupsInfo *pInfo);
|
||||
void* tscVgroupInfoClear(SVgroupsInfo *pInfo);
|
||||
|
@ -263,7 +269,7 @@ void registerSqlObj(SSqlObj* pSql);
|
|||
SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t fp, void* param, int32_t cmd, SSqlObj* pPrevSql);
|
||||
void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClauseIndex, int32_t tableIndex);
|
||||
|
||||
void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex);
|
||||
void doAddGroupColumnForSubquery(SQueryNodeInfo* pQueryInfo, int32_t tagIndex);
|
||||
|
||||
int16_t tscGetJoinTagColIdByUid(STagCond* pTagCond, uint64_t uid);
|
||||
int16_t tscGetTagColIndexById(STableMeta* pTableMeta, int16_t colId);
|
||||
|
@ -282,7 +288,7 @@ int tscSetMgmtEpSetFromCfg(const char *first, const char *second, SRpcCorEpSet
|
|||
|
||||
bool tscSetSqlOwner(SSqlObj* pSql);
|
||||
void tscClearSqlOwner(SSqlObj* pSql);
|
||||
int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize);
|
||||
int32_t doArithmeticCalculate(SQueryNodeInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize);
|
||||
|
||||
char* serializeTagData(STagData* pTagData, char* pMsg);
|
||||
int32_t copyTagData(STagData* dst, const STagData* src);
|
||||
|
@ -294,8 +300,9 @@ uint32_t tscGetTableMetaMaxSize();
|
|||
int32_t tscCreateTableMetaFromCChildMeta(STableMeta* pChild, const char* name);
|
||||
STableMeta* tscTableMetaDup(STableMeta* pTableMeta);
|
||||
|
||||
void tsCreateSQLFunctionCtx(SQueryInfo* pQueryInfo, SQLFunctionCtx* pCtx);
|
||||
|
||||
void tsCreateSQLFunctionCtx(SQueryNodeInfo* pQueryInfo, SQLFunctionCtx* pCtx);
|
||||
void* createQueryInfoFromQueryNode(SQueryNodeInfo* pQueryNodeInfo, SExprInfo* pExprs, STableGroupInfo* pTableGroupInfo,
|
||||
uint64_t* qId, char* sql);
|
||||
|
||||
void* malloc_throw(size_t size);
|
||||
void* calloc_throw(size_t nmemb, size_t size);
|
||||
|
|
|
@ -105,8 +105,7 @@ typedef struct SColumnIndex {
|
|||
typedef struct SInternalField {
|
||||
TAOS_FIELD field;
|
||||
bool visible;
|
||||
SExprInfo *pArithExprInfo;
|
||||
SSqlExpr *pSqlExpr;
|
||||
SExprInfo *pExpr;
|
||||
} SInternalField;
|
||||
|
||||
typedef struct SFieldInfo {
|
||||
|
@ -117,8 +116,7 @@ typedef struct SFieldInfo {
|
|||
|
||||
typedef struct SColumn {
|
||||
SColumnIndex colIndex;
|
||||
int32_t numOfFilters;
|
||||
SColumnFilterInfo *filterInfo;
|
||||
SColumnInfo info;
|
||||
} SColumn;
|
||||
|
||||
typedef struct SCond {
|
||||
|
@ -181,7 +179,7 @@ typedef struct STableDataBlocks {
|
|||
SParamInfo *params;
|
||||
} STableDataBlocks;
|
||||
|
||||
typedef struct SQueryInfo {
|
||||
typedef struct SQueryNodeInfo {
|
||||
int16_t command; // the command may be different for each subclause, so keep it seperately.
|
||||
uint32_t type; // query/insert type
|
||||
STimeWindow window; // the whole query time window
|
||||
|
@ -196,6 +194,7 @@ typedef struct SQueryInfo {
|
|||
SLimitVal limit;
|
||||
SLimitVal slimit;
|
||||
STagCond tagCond;
|
||||
|
||||
SOrderVal order;
|
||||
int16_t fillType; // final result fill type
|
||||
int16_t numOfTables;
|
||||
|
@ -215,10 +214,13 @@ typedef struct SQueryInfo {
|
|||
int32_t bufLen;
|
||||
char* buf;
|
||||
|
||||
struct SQueryInfo *sibling; // sibling
|
||||
SArray *pUpstream; // SArray<struct SQueryInfo>
|
||||
SArray *pDownstream; // SArray<struct SQueryInfo>
|
||||
} SQueryInfo;
|
||||
SArray* pDSOperator;
|
||||
SArray* pPhyOperator;
|
||||
|
||||
struct SQueryNodeInfo *sibling; // sibling
|
||||
SArray *pUpstream; // SArray<struct SQueryNodeInfo>
|
||||
SArray *pDownstream; // SArray<struct SQueryNodeInfo>
|
||||
} SQueryNodeInfo;
|
||||
|
||||
typedef struct {
|
||||
int command;
|
||||
|
@ -242,10 +244,10 @@ typedef struct {
|
|||
char * payload;
|
||||
int32_t payloadLen;
|
||||
|
||||
SQueryInfo **pQueryInfo;
|
||||
SQueryNodeInfo **pQueryInfo;
|
||||
int32_t numOfClause;
|
||||
int32_t clauseIndex; // index of multiple subclause query
|
||||
SQueryInfo *active; // current active query info
|
||||
SQueryNodeInfo *active; // current active query info
|
||||
|
||||
int32_t batchSize; // for parameter ('?') binding and batch processing
|
||||
int32_t numOfParams;
|
||||
|
@ -402,7 +404,7 @@ void tscInitMsgsFp();
|
|||
int tsParseSql(SSqlObj *pSql, bool initial);
|
||||
|
||||
void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet);
|
||||
int tscProcessSql(SSqlObj *pSql, SQueryInfo* pQueryInfo);
|
||||
int tscProcessSql(SSqlObj *pSql, SQueryNodeInfo* pQueryInfo);
|
||||
|
||||
int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex);
|
||||
void tscAsyncResultOnError(SSqlObj *pSql);
|
||||
|
@ -412,12 +414,12 @@ void tscQueueAsyncError(void(*fp), void *param, int32_t code);
|
|||
int tscProcessLocalCmd(SSqlObj *pSql);
|
||||
int tscCfgDynamicOptions(char *msg);
|
||||
|
||||
int32_t tscTansformFuncForSTableQuery(SQueryInfo *pQueryInfo);
|
||||
void tscRestoreFuncForSTableQuery(SQueryInfo *pQueryInfo);
|
||||
int32_t tscTansformFuncForSTableQuery(SQueryNodeInfo *pQueryInfo);
|
||||
void tscRestoreFuncForSTableQuery(SQueryNodeInfo *pQueryInfo);
|
||||
|
||||
int32_t tscCreateResPointerInfo(SSqlRes *pRes, SQueryInfo *pQueryInfo);
|
||||
void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo);
|
||||
void prepareInputDataFromUpstream(SSqlRes* pRes, SQueryInfo* pQueryInfo);
|
||||
int32_t tscCreateResPointerInfo(SSqlRes *pRes, SQueryNodeInfo *pQueryInfo);
|
||||
void tscSetResRawPtr(SSqlRes* pRes, SQueryNodeInfo* pQueryInfo);
|
||||
void prepareInputDataFromUpstream(SSqlRes* pRes, SQueryNodeInfo* pQueryInfo);
|
||||
|
||||
void tscResetSqlCmd(SSqlCmd *pCmd, bool removeMeta);
|
||||
|
||||
|
@ -452,7 +454,7 @@ bool tscIsUpdateQuery(SSqlObj* pSql);
|
|||
char* tscGetSqlStr(SSqlObj* pSql);
|
||||
bool tscIsQueryWithLimit(SSqlObj* pSql);
|
||||
|
||||
bool tscHasReachLimitation(SQueryInfo *pQueryInfo, SSqlRes *pRes);
|
||||
bool tscHasReachLimitation(SQueryNodeInfo *pQueryInfo, SSqlRes *pRes);
|
||||
|
||||
char *tscGetErrorMsgPayload(SSqlCmd *pCmd);
|
||||
|
||||
|
@ -471,15 +473,15 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
|
|||
UNUSED(pData);
|
||||
|
||||
// user defined constant value output columns
|
||||
if (pInfo->pSqlExpr != NULL && TSDB_COL_IS_UD_COL(pInfo->pSqlExpr->colInfo.flag)) {
|
||||
if (pInfo->pExpr != NULL && TSDB_COL_IS_UD_COL(pInfo->pExpr->base.colInfo.flag)) {
|
||||
if (type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BINARY) {
|
||||
pData = pInfo->pSqlExpr->param[1].pz;
|
||||
pRes->length[columnIndex] = pInfo->pSqlExpr->param[1].nLen;
|
||||
pRes->tsrow[columnIndex] = (pInfo->pSqlExpr->param[1].nType == TSDB_DATA_TYPE_NULL) ? NULL : (unsigned char*)pData;
|
||||
pData = pInfo->pExpr->base.param[1].pz;
|
||||
pRes->length[columnIndex] = pInfo->pExpr->base.param[1].nLen;
|
||||
pRes->tsrow[columnIndex] = (pInfo->pExpr->base.param[1].nType == TSDB_DATA_TYPE_NULL) ? NULL : (unsigned char*)pData;
|
||||
} else {
|
||||
assert(bytes == tDataTypes[type].bytes);
|
||||
|
||||
pRes->tsrow[columnIndex] = isNull(pData, type) ? NULL : (unsigned char*)&pInfo->pSqlExpr->param[1].i64;
|
||||
pRes->tsrow[columnIndex] = isNull(pData, type) ? NULL : (unsigned char*)&pInfo->pExpr->base.param[1].i64;
|
||||
pRes->length[columnIndex] = bytes;
|
||||
}
|
||||
} else {
|
||||
|
@ -488,7 +490,7 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
|
|||
assert(realLen <= bytes - VARSTR_HEADER_SIZE);
|
||||
|
||||
pRes->tsrow[columnIndex] = (isNull(pData, type)) ? NULL : (unsigned char*)((tstr *)pData)->data;
|
||||
if (realLen < pInfo->pSqlExpr->resBytes - VARSTR_HEADER_SIZE) { // todo refactor
|
||||
if (realLen < pInfo->pExpr->base.resBytes - VARSTR_HEADER_SIZE) { // todo refactor
|
||||
*(pData + realLen + VARSTR_HEADER_SIZE) = 0;
|
||||
}
|
||||
|
||||
|
@ -516,7 +518,7 @@ extern int tscNumOfObj; // number of existed sqlObj in current process.
|
|||
extern int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo);
|
||||
|
||||
void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArray* tables);
|
||||
int16_t getNewResColId(SQueryInfo* pQueryInfo);
|
||||
int16_t getNewResColId(SQueryNodeInfo* pQueryInfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* para
|
|||
return;
|
||||
}
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
executeQuery(pSql, pQueryInfo);
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ void taos_fetch_rows_a(TAOS_RES *tres, __async_cb_func_t fp, void *param) {
|
|||
pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
|
||||
}
|
||||
|
||||
SQueryInfo* pQueryInfo1 = tscGetActiveQueryInfo(&pSql->cmd);
|
||||
SQueryNodeInfo* pQueryInfo1 = tscGetActiveQueryInfo(&pSql->cmd);
|
||||
tscProcessSql(pSql, pQueryInfo1);
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
|
|||
|
||||
tscDebug("%p get %s successfully", pSql, msg);
|
||||
if (pSql->pStream == NULL) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
// check if it is a sub-query of super table query first, if true, enter another routine
|
||||
if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, (TSDB_QUERY_TYPE_STABLE_SUBQUERY|TSDB_QUERY_TYPE_SUBQUERY|TSDB_QUERY_TYPE_TAG_FILTER_QUERY))) {
|
||||
|
@ -414,7 +414,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
|
|||
} else if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_INSERT)) {
|
||||
tscHandleMultivnodeInsert(pSql);
|
||||
} else {
|
||||
SQueryInfo* pQueryInfo1 = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo1 = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
executeQuery(pSql, pQueryInfo1);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
|
|||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
// one column for each row
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
STableMeta * pMeta = pTableMetaInfo->pTableMeta;
|
||||
|
@ -154,14 +154,14 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
|
|||
|
||||
pSql->cmd.numOfCols = numOfCols;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
pQueryInfo->order.order = TSDB_ORDER_ASC;
|
||||
|
||||
TAOS_FIELD f = {.type = TSDB_DATA_TYPE_BINARY, .bytes = (TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE};
|
||||
tstrncpy(f.name, "Field", sizeof(f.name));
|
||||
|
||||
SInternalField* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY,
|
||||
pInfo->pExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY,
|
||||
(TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE, -1000, (TSDB_COL_NAME_LEN - 1), false);
|
||||
|
||||
rowLen += ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE);
|
||||
|
@ -171,7 +171,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
|
|||
tstrncpy(f.name, "Type", sizeof(f.name));
|
||||
|
||||
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, (int16_t)(typeColLength + VARSTR_HEADER_SIZE),
|
||||
pInfo->pExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, (int16_t)(typeColLength + VARSTR_HEADER_SIZE),
|
||||
-1000, typeColLength, false);
|
||||
|
||||
rowLen += typeColLength + VARSTR_HEADER_SIZE;
|
||||
|
@ -181,7 +181,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
|
|||
tstrncpy(f.name, "Length", sizeof(f.name));
|
||||
|
||||
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_INT, sizeof(int32_t),
|
||||
pInfo->pExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_INT, sizeof(int32_t),
|
||||
-1000, sizeof(int32_t), false);
|
||||
|
||||
rowLen += sizeof(int32_t);
|
||||
|
@ -191,7 +191,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
|
|||
tstrncpy(f.name, "Note", sizeof(f.name));
|
||||
|
||||
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, (int16_t)(noteColLength + VARSTR_HEADER_SIZE),
|
||||
pInfo->pExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, (int16_t)(noteColLength + VARSTR_HEADER_SIZE),
|
||||
-1000, noteColLength, false);
|
||||
|
||||
rowLen += noteColLength + VARSTR_HEADER_SIZE;
|
||||
|
@ -199,7 +199,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
|
|||
}
|
||||
|
||||
static int32_t tscProcessDescribeTable(SSqlObj *pSql) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
assert(tscGetMetaInfo(pQueryInfo, 0)->pTableMeta != NULL);
|
||||
|
||||
|
@ -389,7 +389,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
|
|||
SColumnIndex index = {0};
|
||||
pSql->cmd.numOfCols = 2;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
pQueryInfo->order.order = TSDB_ORDER_ASC;
|
||||
|
||||
TAOS_FIELD f;
|
||||
|
@ -404,7 +404,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
|
|||
}
|
||||
|
||||
SInternalField* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, f.bytes, -1000, f.bytes - VARSTR_HEADER_SIZE, false);
|
||||
pInfo->pExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, f.bytes, -1000, f.bytes - VARSTR_HEADER_SIZE, false);
|
||||
|
||||
rowLen += f.bytes;
|
||||
|
||||
|
@ -417,7 +417,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
|
|||
}
|
||||
|
||||
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY,
|
||||
pInfo->pExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY,
|
||||
(int16_t)(ddlLen + VARSTR_HEADER_SIZE), -1000, ddlLen, false);
|
||||
|
||||
rowLen += ddlLen + VARSTR_HEADER_SIZE;
|
||||
|
@ -427,7 +427,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
|
|||
static int32_t tscSCreateSetValueToResObj(SSqlObj *pSql, int32_t rowLen, const char *tableName, const char *ddl) {
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
int32_t numOfRows = 1;
|
||||
if (strlen(ddl) == 0) {
|
||||
|
||||
|
@ -444,7 +444,7 @@ static int32_t tscSCreateSetValueToResObj(SSqlObj *pSql, int32_t rowLen, const c
|
|||
return 0;
|
||||
}
|
||||
static int32_t tscSCreateBuildResult(SSqlObj *pSql, BuildType type, const char *str, const char *result) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
int32_t rowLen = tscSCreateBuildResultFields(pSql, type, result);
|
||||
|
||||
tscFieldInfoUpdateOffset(pQueryInfo);
|
||||
|
@ -552,7 +552,7 @@ static int32_t tscGetTableTagColumnName(SSqlObj *pSql, char **result) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, char *ddl) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
STableMeta * pMeta = pTableMetaInfo->pTableMeta;
|
||||
|
@ -606,7 +606,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch
|
|||
}
|
||||
|
||||
static int32_t tscRebuildDDLForNormalTable(SSqlObj *pSql, const char *tableName, char *ddl) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
STableMeta * pMeta = pTableMetaInfo->pTableMeta;
|
||||
|
||||
|
@ -633,7 +633,7 @@ static int32_t tscRebuildDDLForNormalTable(SSqlObj *pSql, const char *tableName,
|
|||
}
|
||||
static int32_t tscRebuildDDLForSuperTable(SSqlObj *pSql, const char *tableName, char *ddl) {
|
||||
char *result = ddl;
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
STableMeta * pMeta = pTableMetaInfo->pTableMeta;
|
||||
|
||||
|
@ -674,7 +674,7 @@ static int32_t tscRebuildDDLForSuperTable(SSqlObj *pSql, const char *tableName,
|
|||
}
|
||||
|
||||
static int32_t tscProcessShowCreateTable(SSqlObj *pSql) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
assert(pTableMetaInfo->pTableMeta != NULL);
|
||||
|
||||
|
@ -700,7 +700,7 @@ static int32_t tscProcessShowCreateTable(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
||||
|
@ -727,7 +727,7 @@ static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) {
|
|||
return TSDB_CODE_TSC_ACTION_IN_PROGRESS;
|
||||
}
|
||||
static int32_t tscProcessCurrentUser(SSqlObj *pSql) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0);
|
||||
pExpr->resBytes = TSDB_USER_LEN + TSDB_DATA_TYPE_BINARY;
|
||||
|
@ -754,7 +754,7 @@ static int32_t tscProcessCurrentDB(SSqlObj *pSql) {
|
|||
extractDBName(pSql->pTscObj->db, db);
|
||||
pthread_mutex_unlock(&pSql->pTscObj->mutex);
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
|
||||
SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0);
|
||||
pExpr->resType = TSDB_DATA_TYPE_BINARY;
|
||||
|
@ -781,7 +781,7 @@ static int32_t tscProcessCurrentDB(SSqlObj *pSql) {
|
|||
|
||||
static int32_t tscProcessServerVer(SSqlObj *pSql) {
|
||||
const char* v = pSql->pTscObj->sversion;
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
|
||||
SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0);
|
||||
pExpr->resType = TSDB_DATA_TYPE_BINARY;
|
||||
|
@ -804,7 +804,7 @@ static int32_t tscProcessServerVer(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
static int32_t tscProcessClientVer(SSqlObj *pSql) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0);
|
||||
pExpr->resType = TSDB_DATA_TYPE_BINARY;
|
||||
|
@ -856,7 +856,7 @@ static int32_t tscProcessServStatus(SSqlObj *pSql) {
|
|||
return pSql->res.code;
|
||||
}
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0);
|
||||
|
||||
int32_t val = 1;
|
||||
|
@ -870,7 +870,7 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
|
|||
|
||||
pCmd->numOfCols = 1;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
pQueryInfo->order.order = TSDB_ORDER_ASC;
|
||||
|
||||
tscFieldInfoClear(&pQueryInfo->fieldsInfo);
|
||||
|
@ -882,7 +882,7 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
|
|||
tscInitResObjForLocalQuery(pSql, 1, (int32_t)valueLength);
|
||||
|
||||
SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, 0);
|
||||
pInfo->pSqlExpr = taosArrayGetP(pQueryInfo->exprList, 0);
|
||||
pInfo->pExpr = taosArrayGetP(pQueryInfo->exprList, 0);
|
||||
|
||||
memcpy(pRes->data, val, pInfo->field.bytes);
|
||||
}
|
||||
|
|
|
@ -57,43 +57,43 @@ int32_t treeComparator(const void *pLeft, const void *pRight, void *param) {
|
|||
}
|
||||
|
||||
// todo merge with vnode side function
|
||||
void tsCreateSQLFunctionCtx(SQueryInfo* pQueryInfo, SQLFunctionCtx* pCtx) {
|
||||
void tsCreateSQLFunctionCtx(SQueryNodeInfo* pQueryInfo, SQLFunctionCtx* pCtx) {
|
||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
SExprInfo *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
|
||||
pCtx[i].order = pQueryInfo->order.order;
|
||||
pCtx[i].functionId = pExpr->functionId;
|
||||
pCtx[i].functionId = pExpr->base.functionId;
|
||||
|
||||
// input buffer hold only one point data
|
||||
pCtx[i].inputType = pExpr->colType;
|
||||
pCtx[i].inputBytes = pExpr->colBytes;
|
||||
pCtx[i].inputType = pExpr->base.colType;
|
||||
pCtx[i].inputBytes = pExpr->base.colBytes;
|
||||
|
||||
pCtx[i].outputBytes = pExpr->resBytes;
|
||||
pCtx[i].outputType = pExpr->resType;
|
||||
pCtx[i].outputBytes = pExpr->base.resBytes;
|
||||
pCtx[i].outputType = pExpr->base.resType;
|
||||
|
||||
pCtx[i].size = 1;
|
||||
pCtx[i].hasNull = true;
|
||||
pCtx[i].currentStage = MERGE_STAGE;
|
||||
|
||||
// for top/bottom function, the output of timestamp is the first column
|
||||
int32_t functionId = pExpr->functionId;
|
||||
int32_t functionId = pExpr->base.functionId;
|
||||
if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) {
|
||||
pCtx[i].ptsOutputBuf = pCtx[0].pOutput;
|
||||
pCtx[i].param[2].i64 = pQueryInfo->order.order;
|
||||
pCtx[i].param[2].nType = TSDB_DATA_TYPE_BIGINT;
|
||||
pCtx[i].param[1].i64 = pQueryInfo->order.orderColId;
|
||||
} else if (functionId == TSDB_FUNC_APERCT) {
|
||||
pCtx[i].param[0].i64 = pExpr->param[0].i64;
|
||||
pCtx[i].param[0].nType = pExpr->param[0].nType;
|
||||
pCtx[i].param[0].i64 = pExpr->base.param[0].i64;
|
||||
pCtx[i].param[0].nType = pExpr->base.param[0].nType;
|
||||
} else if (functionId == TSDB_FUNC_BLKINFO) {
|
||||
pCtx[i].param[0].i64 = pExpr->param[0].i64;
|
||||
pCtx[i].param[0].nType = pExpr->param[0].nType;
|
||||
pCtx[i].param[0].i64 = pExpr->base.param[0].i64;
|
||||
pCtx[i].param[0].nType = pExpr->base.param[0].nType;
|
||||
pCtx[i].numOfParams = 1;
|
||||
}
|
||||
|
||||
pCtx[i].interBufBytes = pExpr->interBytes;
|
||||
pCtx[i].interBufBytes = pExpr->base.interBytes;
|
||||
pCtx[i].resultInfo = calloc(1, pCtx[i].interBufBytes + sizeof(SResultRowCellInfo));
|
||||
pCtx[i].stableQuery = true;
|
||||
}
|
||||
|
@ -104,11 +104,11 @@ void tsCreateSQLFunctionCtx(SQueryInfo* pQueryInfo, SQLFunctionCtx* pCtx) {
|
|||
|
||||
SQLFunctionCtx *pCtx1 = NULL;
|
||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (pExpr->functionId == TSDB_FUNC_TAG_DUMMY || pExpr->functionId == TSDB_FUNC_TS_DUMMY) {
|
||||
tagLen += pExpr->resBytes;
|
||||
SExprInfo *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (pExpr->base.functionId == TSDB_FUNC_TAG_DUMMY || pExpr->base.functionId == TSDB_FUNC_TS_DUMMY) {
|
||||
tagLen += pExpr->base.resBytes;
|
||||
pTagCtx[n++] = &pCtx[i];
|
||||
} else if ((aAggs[pExpr->functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) {
|
||||
} else if ((aAggs[pExpr->base.functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) {
|
||||
pCtx1 = &pCtx[i];
|
||||
}
|
||||
}
|
||||
|
@ -122,13 +122,13 @@ void tsCreateSQLFunctionCtx(SQueryInfo* pQueryInfo, SQLFunctionCtx* pCtx) {
|
|||
}
|
||||
}
|
||||
|
||||
static void setCtxInputOutputBuffer(SQueryInfo* pQueryInfo, SQLFunctionCtx *pCtx, SLocalMerger *pReducer,
|
||||
static void setCtxInputOutputBuffer(SQueryNodeInfo* pQueryInfo, SQLFunctionCtx *pCtx, SLocalMerger *pReducer,
|
||||
tOrderDescriptor *pDesc) {
|
||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
pCtx[i].pOutput = pReducer->pResultBuf->data + pExpr->offset * pReducer->resColModel->capacity;
|
||||
SExprInfo *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
pCtx[i].pOutput = pReducer->pResultBuf->data + pExpr->base.offset * pReducer->resColModel->capacity;
|
||||
|
||||
// input buffer hold only one point data
|
||||
int16_t offset = getColumnModelOffset(pDesc->pColumnModel, i);
|
||||
|
@ -136,7 +136,7 @@ static void setCtxInputOutputBuffer(SQueryInfo* pQueryInfo, SQLFunctionCtx *pCtx
|
|||
}
|
||||
}
|
||||
|
||||
static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) {
|
||||
static SFillColInfo* createFillColInfo(SQueryNodeInfo* pQueryInfo) {
|
||||
int32_t numOfCols = (int32_t)tscNumOfFields(pQueryInfo);
|
||||
int32_t offset = 0;
|
||||
|
||||
|
@ -144,15 +144,15 @@ static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) {
|
|||
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||
SInternalField* pIField = taosArrayGet(pQueryInfo->fieldsInfo.internalField, i);
|
||||
|
||||
if (pIField->pArithExprInfo == NULL) {
|
||||
SSqlExpr* pExpr = pIField->pSqlExpr;
|
||||
if (pIField->pExpr->pExpr != NULL) {
|
||||
SExprInfo* pExpr = pIField->pExpr;
|
||||
|
||||
pFillCol[i].col.bytes = pExpr->resBytes;
|
||||
pFillCol[i].col.type = (int8_t)pExpr->resType;
|
||||
pFillCol[i].col.colId = pExpr->colInfo.colId;
|
||||
pFillCol[i].flag = pExpr->colInfo.flag;
|
||||
pFillCol[i].col.bytes = pExpr->base.resBytes;
|
||||
pFillCol[i].col.type = (int8_t)pExpr->base.resType;
|
||||
pFillCol[i].col.colId = pExpr->base.colInfo.colId;
|
||||
pFillCol[i].flag = pExpr->base.colInfo.flag;
|
||||
pFillCol[i].col.offset = offset;
|
||||
pFillCol[i].functionId = pExpr->functionId;
|
||||
pFillCol[i].functionId = pExpr->base.functionId;
|
||||
pFillCol[i].fillVal.i = pQueryInfo->fillVal[i];
|
||||
} else {
|
||||
pFillCol[i].col.bytes = pIField->field.bytes;
|
||||
|
@ -171,7 +171,7 @@ static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) {
|
|||
}
|
||||
|
||||
void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc,
|
||||
SColumnModel *finalmodel, SColumnModel *pFFModel, SSqlObj* pSql) {
|
||||
SColumnModel *finalmodel, SColumnModel *pFFModel, SSqlObj *pSql) {
|
||||
SSqlCmd* pCmd = &pSql->cmd;
|
||||
SSqlRes* pRes = &pSql->res;
|
||||
|
||||
|
@ -263,7 +263,7 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
|
|||
#ifdef _DEBUG_VIEW
|
||||
printf("load data page into mem for build loser tree: %" PRIu64 " rows\n", ds->filePage.num);
|
||||
SSrcColumnInfo colInfo[256] = {0};
|
||||
SQueryInfo * pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo * pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
tscGetSrcColumnInfo(colInfo, pQueryInfo);
|
||||
|
||||
|
@ -298,7 +298,7 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
|
|||
param->pLocalData = pReducer->pLocalDataSrc;
|
||||
param->pDesc = pReducer->pDesc;
|
||||
param->num = pReducer->pLocalDataSrc[0]->pMemBuffer->numOfElemsPerPage;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
param->groupOrderType = pQueryInfo->groupbyExpr.orderType;
|
||||
pReducer->orderPrjOnSTable = tscOrderedProjectionQueryOnSTable(pQueryInfo, 0);
|
||||
|
@ -492,7 +492,7 @@ void tscDestroyLocalMerger(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
SSqlCmd * pCmd = &pSql->cmd;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
// there is no more result, so we release all allocated resource
|
||||
SLocalMerger *pLocalMerge = (SLocalMerger *)atomic_exchange_ptr(&pRes->pLocalMerger, NULL);
|
||||
|
@ -546,7 +546,7 @@ void tscDestroyLocalMerger(SSqlObj *pSql) {
|
|||
|
||||
static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCmd, SColumnModel *pModel) {
|
||||
int32_t numOfGroupByCols = 0;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) {
|
||||
numOfGroupByCols = pQueryInfo->groupbyExpr.numOfGroupCols;
|
||||
|
@ -587,8 +587,8 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
|
|||
} else {
|
||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (pExpr->functionId == TSDB_FUNC_PRJ && pExpr->colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||
SExprInfo *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (pExpr->base.functionId == TSDB_FUNC_PRJ && pExpr->base.colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||
orderColIndexList[0] = i;
|
||||
}
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
|
|||
}
|
||||
|
||||
bool isSameGroup(SSqlCmd *pCmd, SLocalMerger *pReducer, char *pPrev, tFilePage *tmpBuffer) {
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
// disable merge procedure for column projection query
|
||||
int16_t functionId = pReducer->pCtx[0].functionId;
|
||||
|
@ -660,7 +660,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
SColumnModel *pModel = NULL;
|
||||
*pFinalModel = NULL;
|
||||
|
||||
SQueryInfo * pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo * pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
||||
(*pMemBuffer) = (tExtMemBuffer **)malloc(POINTER_BYTES * pSql->subState.numOfSub);
|
||||
|
@ -681,13 +681,13 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
|
||||
int32_t rlen = 0;
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
SExprInfo *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
|
||||
pSchema[i].bytes = pExpr->resBytes;
|
||||
pSchema[i].type = (int8_t)pExpr->resType;
|
||||
tstrncpy(pSchema[i].name, pExpr->aliasName, tListLen(pSchema[i].name));
|
||||
pSchema[i].bytes = pExpr->base.resBytes;
|
||||
pSchema[i].type = (int8_t)pExpr->base.resType;
|
||||
tstrncpy(pSchema[i].name, pExpr->base.aliasName, tListLen(pSchema[i].name));
|
||||
|
||||
rlen += pExpr->resBytes;
|
||||
rlen += pExpr->base.resBytes;
|
||||
}
|
||||
|
||||
int32_t capacity = 0;
|
||||
|
@ -720,17 +720,17 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
memset(pSchema, 0, sizeof(SSchema) * size);
|
||||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
SExprInfo *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
|
||||
SSchema p1 = {0};
|
||||
if (pExpr->colInfo.colIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
if (pExpr->base.colInfo.colIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
p1 = *tGetTbnameColumnSchema();
|
||||
} else if (TSDB_COL_IS_UD_COL(pExpr->colInfo.flag)) {
|
||||
p1.bytes = pExpr->resBytes;
|
||||
p1.type = (uint8_t) pExpr->resType;
|
||||
tstrncpy(p1.name, pExpr->aliasName, tListLen(p1.name));
|
||||
} else if (TSDB_COL_IS_UD_COL(pExpr->base.colInfo.flag)) {
|
||||
p1.bytes = pExpr->base.resBytes;
|
||||
p1.type = (uint8_t) pExpr->base.resType;
|
||||
tstrncpy(p1.name, pExpr->base.aliasName, tListLen(p1.name));
|
||||
} else {
|
||||
p1 = *tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pExpr->colInfo.colIndex);
|
||||
p1 = *tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pExpr->base.colInfo.colIndex);
|
||||
}
|
||||
|
||||
int32_t inter = 0;
|
||||
|
@ -739,7 +739,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
|
||||
// the final result size and type in the same as query on single table.
|
||||
// so here, set the flag to be false;
|
||||
int32_t functionId = pExpr->functionId;
|
||||
int32_t functionId = pExpr->base.functionId;
|
||||
if (functionId >= TSDB_FUNC_TS && functionId <= TSDB_FUNC_DIFF) {
|
||||
type = pModel->pFields[i].field.type;
|
||||
bytes = pModel->pFields[i].field.bytes;
|
||||
|
@ -866,7 +866,7 @@ void adjustLoserTreeFromNewData(SLocalMerger *pLocalMerge, SLocalDataSource *pOn
|
|||
}
|
||||
}
|
||||
|
||||
void savePrevRecordAndSetupFillInfo(SLocalMerger *pLocalMerge, SQueryInfo *pQueryInfo, SFillInfo *pFillInfo) {
|
||||
void savePrevRecordAndSetupFillInfo(SLocalMerger *pLocalMerge, SQueryNodeInfo *pQueryInfo, SFillInfo *pFillInfo) {
|
||||
// discard following dataset in the same group and reset the interpolation information
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
||||
|
@ -886,7 +886,7 @@ void savePrevRecordAndSetupFillInfo(SLocalMerger *pLocalMerge, SQueryInfo *pQuer
|
|||
tColModelAppend(pModel, pLocalMerge->discardData, pLocalMerge->prevRowOfInput, 0, 1, 1);
|
||||
}
|
||||
|
||||
static void genFinalResWithoutFill(SSqlRes* pRes, SLocalMerger *pLocalMerge, SQueryInfo* pQueryInfo) {
|
||||
static void genFinalResWithoutFill(SSqlRes* pRes, SLocalMerger *pLocalMerge, SQueryNodeInfo* pQueryInfo) {
|
||||
assert(pQueryInfo->interval.interval == 0 || pQueryInfo->fillType == TSDB_FILL_NONE);
|
||||
|
||||
tFilePage * pBeforeFillData = pLocalMerge->pResultBuf;
|
||||
|
@ -950,7 +950,7 @@ static void doFillResult(SSqlObj *pSql, SLocalMerger *pLocalMerge, bool doneOutp
|
|||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
tFilePage *pBeforeFillData = pLocalMerge->pResultBuf;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SFillInfo *pFillInfo = pLocalMerge->pFillInfo;
|
||||
|
||||
// todo extract function
|
||||
|
@ -1049,7 +1049,7 @@ static void savePreviousRow(SLocalMerger *pLocalMerge, tFilePage *tmpBuffer) {
|
|||
|
||||
static void doExecuteFinalMerge(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, bool needInit) {
|
||||
// the tag columns need to be set before all functions execution
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
for (int32_t j = 0; j < size; ++j) {
|
||||
|
@ -1069,8 +1069,8 @@ static void doExecuteFinalMerge(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, bool n
|
|||
}
|
||||
|
||||
} else if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, j);
|
||||
pCtx->param[0].i64 = pExpr->param[0].i64;
|
||||
SExprInfo *pExpr = tscSqlExprGet(pQueryInfo, j);
|
||||
pCtx->param[0].i64 = pExpr->base.param[0].i64;
|
||||
}
|
||||
|
||||
pCtx->currentStage = MERGE_STAGE;
|
||||
|
@ -1098,7 +1098,7 @@ static void handleUnprocessedRow(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, tFile
|
|||
}
|
||||
}
|
||||
|
||||
static int64_t getNumOfResultLocal(SQueryInfo *pQueryInfo, SQLFunctionCtx *pCtx) {
|
||||
static int64_t getNumOfResultLocal(SQueryNodeInfo *pQueryInfo, SQLFunctionCtx *pCtx) {
|
||||
int64_t maxOutput = 0;
|
||||
|
||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
|
@ -1127,14 +1127,14 @@ static int64_t getNumOfResultLocal(SQueryInfo *pQueryInfo, SQLFunctionCtx *pCtx)
|
|||
* filled with the same result, which is the tags, specified in group by clause
|
||||
*
|
||||
*/
|
||||
static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLocalMerger *pLocalMerge) {
|
||||
static void fillMultiRowsOfTagsVal(SQueryNodeInfo *pQueryInfo, int32_t numOfRes, SLocalMerger *pLocalMerge) {
|
||||
int32_t maxBufSize = 0; // find the max tags column length to prepare the buffer
|
||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
|
||||
for (int32_t k = 0; k < size; ++k) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, k);
|
||||
if (maxBufSize < pExpr->resBytes && pExpr->functionId == TSDB_FUNC_TAG) {
|
||||
maxBufSize = pExpr->resBytes;
|
||||
SExprInfo *pExpr = tscSqlExprGet(pQueryInfo, k);
|
||||
if (maxBufSize < pExpr->base.resBytes && pExpr->base.functionId == TSDB_FUNC_TAG) {
|
||||
maxBufSize = pExpr->base.resBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1160,7 +1160,7 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
|
|||
free(buf);
|
||||
}
|
||||
|
||||
int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge) {
|
||||
int32_t finalizeRes(SQueryNodeInfo *pQueryInfo, SLocalMerger *pLocalMerge) {
|
||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
|
||||
for (int32_t k = 0; k < size; ++k) {
|
||||
|
@ -1184,7 +1184,7 @@ int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge) {
|
|||
* results generated by simple aggregation function, we merge them all into one points
|
||||
* *Exception*: column projection query, required no merge procedure
|
||||
*/
|
||||
bool needToMerge(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge, tFilePage *tmpBuffer) {
|
||||
bool needToMerge(SQueryNodeInfo *pQueryInfo, SLocalMerger *pLocalMerge, tFilePage *tmpBuffer) {
|
||||
int32_t ret = 0; // merge all result by default
|
||||
|
||||
int16_t functionId = pLocalMerge->pCtx[0].functionId;
|
||||
|
@ -1208,7 +1208,7 @@ bool needToMerge(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge, tFilePage *t
|
|||
return (ret == 0);
|
||||
}
|
||||
|
||||
static bool reachGroupResultLimit(SQueryInfo *pQueryInfo, SSqlRes *pRes) {
|
||||
static bool reachGroupResultLimit(SQueryNodeInfo *pQueryInfo, SSqlRes *pRes) {
|
||||
return (pRes->numOfGroups >= pQueryInfo->slimit.limit && pQueryInfo->slimit.limit >= 0);
|
||||
}
|
||||
|
||||
|
@ -1216,7 +1216,7 @@ static bool saveGroupResultInfo(SSqlObj *pSql) {
|
|||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
if (pRes->numOfRowsGroup > 0) {
|
||||
pRes->numOfGroups += 1;
|
||||
|
@ -1245,7 +1245,7 @@ bool genFinalResults(SSqlObj *pSql, SLocalMerger *pLocalMerge, bool noMoreCurren
|
|||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
SQueryInfo * pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo * pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
tFilePage * pResBuf = pLocalMerge->pResultBuf;
|
||||
SColumnModel *pModel = pLocalMerge->resColModel;
|
||||
|
||||
|
@ -1292,13 +1292,13 @@ bool genFinalResults(SSqlObj *pSql, SLocalMerger *pLocalMerge, bool noMoreCurren
|
|||
return true;
|
||||
}
|
||||
|
||||
void resetOutputBuf(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge) {// reset output buffer to the beginning
|
||||
void resetOutputBuf(SQueryNodeInfo *pQueryInfo, SLocalMerger *pLocalMerge) {// reset output buffer to the beginning
|
||||
size_t t = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
for (int32_t i = 0; i < t; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
pLocalMerge->pCtx[i].pOutput = pLocalMerge->pResultBuf->data + pExpr->offset * pLocalMerge->resColModel->capacity;
|
||||
SExprInfo* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
pLocalMerge->pCtx[i].pOutput = pLocalMerge->pResultBuf->data + pExpr->base.offset * pLocalMerge->resColModel->capacity;
|
||||
|
||||
if (pExpr->functionId == TSDB_FUNC_TOP || pExpr->functionId == TSDB_FUNC_BOTTOM || pExpr->functionId == TSDB_FUNC_DIFF) {
|
||||
if (pExpr->base.functionId == TSDB_FUNC_TOP || pExpr->base.functionId == TSDB_FUNC_BOTTOM || pExpr->base.functionId == TSDB_FUNC_DIFF) {
|
||||
pLocalMerge->pCtx[i].ptsOutputBuf = pLocalMerge->pCtx[0].pOutput;
|
||||
}
|
||||
}
|
||||
|
@ -1311,7 +1311,7 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalMerger *
|
|||
pRes->numOfRows = 0;
|
||||
pRes->numOfRowsGroup = 0;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
pQueryInfo->limit.offset = pLocalMerge->offset;
|
||||
|
||||
|
@ -1334,7 +1334,7 @@ static bool doBuildFilledResultForGroup(SSqlObj *pSql) {
|
|||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SLocalMerger *pLocalMerge = pRes->pLocalMerger;
|
||||
SFillInfo *pFillInfo = pLocalMerge->pFillInfo;
|
||||
|
||||
|
@ -1365,7 +1365,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
|
|||
|
||||
bool prevGroupCompleted = (!pLocalMerge->discard) && pLocalMerge->hasUnprocessedRow;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
if ((isAllSourcesCompleted(pLocalMerge) && !pLocalMerge->hasPrevRow) || pLocalMerge->pLocalDataSrc[0] == NULL ||
|
||||
prevGroupCompleted) {
|
||||
|
@ -1406,7 +1406,7 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) {
|
|||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
SLocalMerger *pLocalMerge = pRes->pLocalMerger;
|
||||
SQueryInfo * pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo * pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
|
||||
for (int32_t k = 0; k < size; ++k) {
|
||||
|
@ -1438,7 +1438,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
SLocalMerger *pLocalMerge = pRes->pLocalMerger;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
tFilePage *tmpBuffer = pLocalMerge->pTempBuffer;
|
||||
|
||||
if (doHandleLastRemainData(pSql)) {
|
||||
|
@ -1626,7 +1626,7 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen)
|
|||
pRes->data = pRes->pLocalMerger->pResultBuf->data;
|
||||
}
|
||||
|
||||
int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize) {
|
||||
int32_t doArithmeticCalculate(SQueryNodeInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize) {
|
||||
int32_t maxRowSize = MAX(rowSize, finalRowSize);
|
||||
char* pbuf = calloc(1, (size_t)(pOutput->num * maxRowSize));
|
||||
|
||||
|
@ -1640,8 +1640,8 @@ int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_
|
|||
arithSup.data = calloc(arithSup.numOfCols, POINTER_BYTES);
|
||||
|
||||
for(int32_t k = 0; k < arithSup.numOfCols; ++k) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, k);
|
||||
arithSup.data[k] = (pOutput->data + pOutput->num* pExpr->offset);
|
||||
SExprInfo* pExpr = tscSqlExprGet(pQueryInfo, k);
|
||||
arithSup.data[k] = (pOutput->data + pOutput->num* pExpr->base.offset);
|
||||
}
|
||||
|
||||
int32_t offset = 0;
|
||||
|
@ -1650,12 +1650,12 @@ int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_
|
|||
SInternalField* pSup = TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.internalField, i);
|
||||
|
||||
// calculate the result from several other columns
|
||||
if (pSup->pArithExprInfo != NULL) {
|
||||
arithSup.pArithExpr = pSup->pArithExprInfo;
|
||||
if (pSup->pExpr->pExpr != NULL) {
|
||||
arithSup.pArithExpr = pSup->pExpr;
|
||||
arithmeticTreeTraverse(arithSup.pArithExpr->pExpr, (int32_t) pOutput->num, pbuf + pOutput->num*offset, &arithSup, TSDB_ORDER_ASC, getArithmeticInputSrc);
|
||||
} else {
|
||||
SSqlExpr* pExpr = pSup->pSqlExpr;
|
||||
memcpy(pbuf + pOutput->num * offset, pExpr->offset * pOutput->num + pOutput->data, (size_t)(pExpr->resBytes * pOutput->num));
|
||||
SExprInfo* pExpr = pSup->pExpr;
|
||||
memcpy(pbuf + pOutput->num * offset, pExpr->base.offset * pOutput->num + pOutput->data, (size_t)(pExpr->base.resBytes * pOutput->num));
|
||||
}
|
||||
|
||||
offset += pSup->field.bytes;
|
||||
|
|
|
@ -759,7 +759,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
|
|||
const int32_t STABLE_INDEX = 1;
|
||||
|
||||
SSqlCmd * pCmd = &pSql->cmd;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
|
||||
char *sql = *sqlstr;
|
||||
|
||||
|
@ -1055,7 +1055,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
|
|||
int32_t totalNum = 0;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
assert(pQueryInfo != NULL);
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = (pQueryInfo->numOfTables == 0)? tscAddEmptyMetaInfo(pQueryInfo):tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
@ -1313,7 +1313,7 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
|
|||
pCmd->count = 0;
|
||||
pCmd->command = TSDB_SQL_INSERT;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfoS(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfoS(pCmd, pCmd->clauseIndex);
|
||||
|
||||
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_INSERT | pCmd->insertType);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -302,7 +302,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
|
|||
return;
|
||||
}
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
if (pQueryInfo != NULL && pQueryInfo->type == TSDB_QUERY_TYPE_FREE_RESOURCE) {
|
||||
tscDebug("%p sqlObj needs to be released or DB connection is closed, cmd:%d type:%d, pObj:%p signature:%p",
|
||||
pSql, pCmd->command, pQueryInfo->type, pObj, pObj->signature);
|
||||
|
@ -469,7 +469,7 @@ int doProcessSql(SSqlObj *pSql) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int tscProcessSql(SSqlObj *pSql, SQueryInfo* pQueryInfo) {
|
||||
int tscProcessSql(SSqlObj *pSql, SQueryNodeInfo* pQueryInfo) {
|
||||
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
|
@ -509,7 +509,7 @@ int tscProcessSql(SSqlObj *pSql, SQueryInfo* pQueryInfo) {
|
|||
int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||
SRetrieveTableMsg *pRetrieveMsg = (SRetrieveTableMsg *) pSql->cmd.payload;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetActiveQueryInfo(&pSql->cmd);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetActiveQueryInfo(&pSql->cmd);
|
||||
|
||||
pRetrieveMsg->free = htons(pQueryInfo->type);
|
||||
pRetrieveMsg->qid = htobe64(pSql->res.qid);
|
||||
|
@ -549,7 +549,7 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
}
|
||||
|
||||
int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta;
|
||||
|
||||
char* pMsg = pSql->cmd.payload;
|
||||
|
@ -588,7 +588,7 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql, int32_t clauseIndex) {
|
|||
const static int32_t MIN_QUERY_MSG_PKT_SIZE = TSDB_MAX_BYTES_PER_ROW * 5;
|
||||
|
||||
SSqlCmd* pCmd = &pSql->cmd;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, clauseIndex);
|
||||
|
||||
int32_t srcColListSize = (int32_t)(taosArrayGetSize(pQueryInfo->colList) * sizeof(SColumnInfo));
|
||||
|
||||
|
@ -618,7 +618,7 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql, int32_t clauseIndex) {
|
|||
}
|
||||
|
||||
static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char *pMsg) {
|
||||
SQueryInfo* pQueryInfo = tscGetActiveQueryInfo(&pSql->cmd);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetActiveQueryInfo(&pSql->cmd);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
||||
TSKEY dfltKey = htobe64(pQueryMsg->window.skey);
|
||||
|
@ -704,7 +704,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
return TSDB_CODE_TSC_INVALID_SQL; // todo add test for this
|
||||
}
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetActiveQueryInfo(pCmd);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetActiveQueryInfo(pCmd);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
STableMeta * pTableMeta = pTableMetaInfo->pTableMeta;
|
||||
|
||||
|
@ -779,21 +779,20 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
char n[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
tNameExtractFullName(&pTableMetaInfo->name, n);
|
||||
|
||||
|
||||
tscError("%p tid:%d uid:%" PRIu64" id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s",
|
||||
pSql, pTableMeta->id.tid, pTableMeta->id.uid, n, tscGetNumOfColumns(pTableMeta), pCol->colIndex.columnIndex,
|
||||
pColSchema->name);
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
|
||||
pQueryMsg->colList[i].colId = htons(pColSchema->colId);
|
||||
pQueryMsg->colList[i].bytes = htons(pColSchema->bytes);
|
||||
pQueryMsg->colList[i].type = htons(pColSchema->type);
|
||||
pQueryMsg->colList[i].numOfFilters = htons(pCol->numOfFilters);
|
||||
pQueryMsg->colList[i].colId = htons(pCol->info.colId);
|
||||
pQueryMsg->colList[i].bytes = htons(pCol->info.bytes);
|
||||
pQueryMsg->colList[i].type = htons(pCol->info.type);
|
||||
pQueryMsg->colList[i].numOfFilters = htons(pCol->info.numOfFilters);
|
||||
|
||||
// append the filter information after the basic column information
|
||||
for (int32_t f = 0; f < pCol->numOfFilters; ++f) {
|
||||
SColumnFilterInfo *pColFilter = &pCol->filterInfo[f];
|
||||
for (int32_t f = 0; f < pCol->info.numOfFilters; ++f) {
|
||||
SColumnFilterInfo *pColFilter = &pCol->info.filterInfo[f];
|
||||
|
||||
SColumnFilterInfo *pFilterMsg = (SColumnFilterInfo *)pMsg;
|
||||
pFilterMsg->filterstr = htons(pColFilter->filterstr);
|
||||
|
@ -822,7 +821,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
SSqlExpr *pSqlFuncExpr = (SSqlExpr *)pMsg;
|
||||
|
||||
for (int32_t i = 0; i < tscSqlExprNumOfExprs(pQueryInfo); ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
SExprInfo *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
|
||||
// the queried table has been removed and a new table with the same name has already been created already
|
||||
// return error msg
|
||||
|
@ -831,48 +830,48 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
return TSDB_CODE_TSC_INVALID_TABLE_NAME;
|
||||
}
|
||||
|
||||
if (!tscValidateColumnId(pTableMetaInfo, pExpr->colInfo.colId, pExpr->numOfParams)) {
|
||||
if (!tscValidateColumnId(pTableMetaInfo, pExpr->base.colInfo.colId, pExpr->base.numOfParams)) {
|
||||
tscError("%p table schema is not matched with parsed sql", pSql);
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
|
||||
assert(pExpr->resColId < 0);
|
||||
assert(pExpr->base.resColId < 0);
|
||||
|
||||
pSqlFuncExpr->colInfo.colId = htons(pExpr->colInfo.colId);
|
||||
pSqlFuncExpr->colInfo.colIndex = htons(pExpr->colInfo.colIndex);
|
||||
pSqlFuncExpr->colInfo.flag = htons(pExpr->colInfo.flag);
|
||||
pSqlFuncExpr->colInfo.colId = htons(pExpr->base.colInfo.colId);
|
||||
pSqlFuncExpr->colInfo.colIndex = htons(pExpr->base.colInfo.colIndex);
|
||||
pSqlFuncExpr->colInfo.flag = htons(pExpr->base.colInfo.flag);
|
||||
|
||||
pSqlFuncExpr->colType = htons(pExpr->colType);
|
||||
pSqlFuncExpr->colBytes = htons(pExpr->colBytes);
|
||||
pSqlFuncExpr->colType = htons(pExpr->base.colType);
|
||||
pSqlFuncExpr->colBytes = htons(pExpr->base.colBytes);
|
||||
|
||||
if (TSDB_COL_IS_UD_COL(pExpr->colInfo.flag) || pExpr->colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
pSqlFuncExpr->resType = htons(pExpr->resType);
|
||||
pSqlFuncExpr->resBytes = htons(pExpr->resBytes);
|
||||
} else if (pExpr->colInfo.colId == TSDB_BLOCK_DIST_COLUMN_INDEX) {
|
||||
if (TSDB_COL_IS_UD_COL(pExpr->base.colInfo.flag) || pExpr->base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
pSqlFuncExpr->resType = htons(pExpr->base.resType);
|
||||
pSqlFuncExpr->resBytes = htons(pExpr->base.resBytes);
|
||||
} else if (pExpr->base.colInfo.colId == TSDB_BLOCK_DIST_COLUMN_INDEX) {
|
||||
SSchema s = tGetBlockDistColumnSchema();
|
||||
|
||||
pSqlFuncExpr->resType = htons(s.type);
|
||||
pSqlFuncExpr->resBytes = htons(s.bytes);
|
||||
} else {
|
||||
SSchema* s = tscGetColumnSchemaById(pTableMeta, pExpr->colInfo.colId);
|
||||
SSchema* s = tscGetColumnSchemaById(pTableMeta, pExpr->base.colInfo.colId);
|
||||
pSqlFuncExpr->resType = htons(s->type);
|
||||
pSqlFuncExpr->resBytes = htons(s->bytes);
|
||||
}
|
||||
|
||||
pSqlFuncExpr->functionId = htons(pExpr->functionId);
|
||||
pSqlFuncExpr->numOfParams = htons(pExpr->numOfParams);
|
||||
pSqlFuncExpr->resColId = htons(pExpr->resColId);
|
||||
pSqlFuncExpr->functionId = htons(pExpr->base.functionId);
|
||||
pSqlFuncExpr->numOfParams = htons(pExpr->base.numOfParams);
|
||||
pSqlFuncExpr->resColId = htons(pExpr->base.resColId);
|
||||
pMsg += sizeof(SSqlExpr);
|
||||
|
||||
for (int32_t j = 0; j < pExpr->numOfParams; ++j) { // todo add log
|
||||
pSqlFuncExpr->param[j].nType = htons((uint16_t)pExpr->param[j].nType);
|
||||
pSqlFuncExpr->param[j].nLen = htons(pExpr->param[j].nLen);
|
||||
for (int32_t j = 0; j < pExpr->base.numOfParams; ++j) { // todo add log
|
||||
pSqlFuncExpr->param[j].nType = htons((uint16_t)pExpr->base.param[j].nType);
|
||||
pSqlFuncExpr->param[j].nLen = htons(pExpr->base.param[j].nLen);
|
||||
|
||||
if (pExpr->param[j].nType == TSDB_DATA_TYPE_BINARY) {
|
||||
memcpy(pMsg, pExpr->param[j].pz, pExpr->param[j].nLen);
|
||||
pMsg += pExpr->param[j].nLen;
|
||||
if (pExpr->base.param[j].nType == TSDB_DATA_TYPE_BINARY) {
|
||||
memcpy(pMsg, pExpr->base.param[j].pz, pExpr->base.param[j].nLen);
|
||||
pMsg += pExpr->base.param[j].nLen;
|
||||
} else {
|
||||
pSqlFuncExpr->param[j].i64 = htobe64(pExpr->param[j].i64);
|
||||
pSqlFuncExpr->param[j].i64 = htobe64(pExpr->base.param[j].i64);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -888,10 +887,10 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
|
||||
for (int32_t i = 0; i < output; ++i) {
|
||||
SInternalField* pField = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, i);
|
||||
SSqlExpr *pExpr = pField->pSqlExpr;
|
||||
SExprInfo *pExpr = pField->pExpr;
|
||||
|
||||
// this should be switched to projection query
|
||||
if (pExpr != NULL) {
|
||||
if (pExpr->pExpr == NULL) {
|
||||
// the queried table has been removed and a new table with the same name has already been created already
|
||||
// return error msg
|
||||
if (pExpr->uid != pTableMeta->id.uid) {
|
||||
|
@ -899,25 +898,25 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
return TSDB_CODE_TSC_INVALID_TABLE_NAME;
|
||||
}
|
||||
|
||||
if (!tscValidateColumnId(pTableMetaInfo, pExpr->colInfo.colId, pExpr->numOfParams)) {
|
||||
if (!tscValidateColumnId(pTableMetaInfo, pExpr->base.colInfo.colId, pExpr->base.numOfParams)) {
|
||||
tscError("%p table schema is not matched with parsed sql", pSql);
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
|
||||
pExpr1->numOfParams = 0; // no params for projection query
|
||||
pExpr1->functionId = htons(TSDB_FUNC_PRJ);
|
||||
pExpr1->colInfo.colId = htons(pExpr->resColId);
|
||||
pExpr1->colInfo.colId = htons(pExpr->base.resColId);
|
||||
pExpr1->colInfo.flag = htons(TSDB_COL_NORMAL);
|
||||
pExpr1->colType = htons(pExpr->resType);
|
||||
pExpr1->colBytes = htons(pExpr->resBytes);
|
||||
pExpr1->colType = htons(pExpr->base.resType);
|
||||
pExpr1->colBytes = htons(pExpr->base.resBytes);
|
||||
|
||||
bool assign = false;
|
||||
for (int32_t f = 0; f < tscSqlExprNumOfExprs(pQueryInfo); ++f) {
|
||||
SSqlExpr *pe = tscSqlExprGet(pQueryInfo, f);
|
||||
SExprInfo *pe = tscSqlExprGet(pQueryInfo, f);
|
||||
if (pe == pExpr) {
|
||||
pExpr1->colInfo.colIndex = htons(f);
|
||||
pExpr1->resType = htons(pe->resType);
|
||||
pExpr1->resBytes = htons(pe->resBytes);
|
||||
pExpr1->resType = htons(pe->base.resType);
|
||||
pExpr1->resBytes = htons(pe->base.resBytes);
|
||||
assign = true;
|
||||
break;
|
||||
}
|
||||
|
@ -927,8 +926,8 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
pMsg += sizeof(SSqlExpr);
|
||||
pExpr1 = (SSqlExpr *)pMsg;
|
||||
} else {
|
||||
assert(pField->pArithExprInfo != NULL);
|
||||
SExprInfo* pExprInfo = pField->pArithExprInfo;
|
||||
assert(pField->pExpr != NULL);
|
||||
SExprInfo* pExprInfo = pField->pExpr;
|
||||
|
||||
pExpr1->colInfo.colId = htons(pExprInfo->base.colInfo.colId);
|
||||
pExpr1->colType = htons(pExprInfo->base.colType);
|
||||
|
@ -1050,21 +1049,21 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
}
|
||||
|
||||
// compressed ts block
|
||||
pQueryMsg->tsOffset = htonl((int32_t)(pMsg - pCmd->payload));
|
||||
pQueryMsg->tsBuf.tsOffset = htonl((int32_t)(pMsg - pCmd->payload));
|
||||
|
||||
if (pQueryInfo->tsBuf != NULL) {
|
||||
// note: here used the index instead of actual vnode id.
|
||||
int32_t vnodeIndex = pTableMetaInfo->vgroupIndex;
|
||||
int32_t code = dumpFileBlockByGroupId(pQueryInfo->tsBuf, vnodeIndex, pMsg, &pQueryMsg->tsLen, &pQueryMsg->tsNumOfBlocks);
|
||||
int32_t code = dumpFileBlockByGroupId(pQueryInfo->tsBuf, vnodeIndex, pMsg, &pQueryMsg->tsBuf.tsLen, &pQueryMsg->tsBuf.tsNumOfBlocks);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
pMsg += pQueryMsg->tsLen;
|
||||
pMsg += pQueryMsg->tsBuf.tsLen;
|
||||
|
||||
pQueryMsg->tsOrder = htonl(pQueryInfo->tsBuf->tsOrder);
|
||||
pQueryMsg->tsLen = htonl(pQueryMsg->tsLen);
|
||||
pQueryMsg->tsNumOfBlocks = htonl(pQueryMsg->tsNumOfBlocks);
|
||||
pQueryMsg->tsBuf.tsOrder = htonl(pQueryInfo->tsBuf->tsOrder);
|
||||
pQueryMsg->tsBuf.tsLen = htonl(pQueryMsg->tsBuf.tsLen);
|
||||
pQueryMsg->tsBuf.tsNumOfBlocks = htonl(pQueryMsg->tsBuf.tsNumOfBlocks);
|
||||
}
|
||||
|
||||
memcpy(pMsg, pSql->sqlstr, sqlLen);
|
||||
|
@ -1383,7 +1382,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
SSchema *pSchema;
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
||||
// Reallocate the payload size
|
||||
|
@ -1472,7 +1471,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
}
|
||||
|
||||
int tscEstimateAlterTableMsgLength(SSqlCmd *pCmd) {
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
return minMsgSize() + sizeof(SAlterTableMsg) + sizeof(SSchema) * tscNumOfFields(pQueryInfo) + TSDB_EXTRA_PAYLOAD_SIZE;
|
||||
}
|
||||
|
||||
|
@ -1481,7 +1480,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
int msgLen = 0;
|
||||
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
||||
|
@ -1530,7 +1529,7 @@ int tscBuildUpdateTagMsg(SSqlObj* pSql, SSqlInfo *pInfo) {
|
|||
SUpdateTableTagValMsg* pUpdateMsg = (SUpdateTableTagValMsg*) pCmd->payload;
|
||||
pCmd->payloadLen = htonl(pUpdateMsg->head.contLen);
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
STableMeta *pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta;
|
||||
|
||||
SNewVgroupInfo vgroupInfo = {.vgId = -1};
|
||||
|
@ -1566,7 +1565,7 @@ int tscBuildRetrieveFromMgmtMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SRetrieveTableMsg *pRetrieveMsg = (SRetrieveTableMsg*)pCmd->payload;
|
||||
pRetrieveMsg->qid = htobe64(pSql->res.qid);
|
||||
pRetrieveMsg->free = htons(pQueryInfo->type);
|
||||
|
@ -1590,7 +1589,7 @@ static int tscLocalResultCommonBuilder(SSqlObj *pSql, int32_t numOfRes) {
|
|||
pRes->row = 0;
|
||||
pRes->rspType = 1;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
if (tscCreateResPointerInfo(pRes, pQueryInfo) != TSDB_CODE_SUCCESS) {
|
||||
return pRes->code;
|
||||
}
|
||||
|
@ -1641,7 +1640,7 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) {
|
|||
pRes->code = tscDoLocalMerge(pSql);
|
||||
|
||||
if (pRes->code == TSDB_CODE_SUCCESS && pRes->numOfRows > 0) {
|
||||
SQueryInfo *pQueryInfo = tscGetActiveQueryInfo(pCmd);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetActiveQueryInfo(pCmd);
|
||||
tscCreateResPointerInfo(pRes, pQueryInfo);
|
||||
tscSetResRawPtr(pRes, pQueryInfo);
|
||||
}
|
||||
|
@ -1695,7 +1694,7 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
|
||||
int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
STableInfoMsg *pInfoMsg = (STableInfoMsg *)pCmd->payload;
|
||||
|
@ -1765,7 +1764,7 @@ int tscBuildSTableVgroupMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
|
||||
char* pMsg = pCmd->payload;
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
|
||||
SSTableVgroupMsg *pStableVgroupMsg = (SSTableVgroupMsg *)pMsg;
|
||||
pStableVgroupMsg->numOfTables = htonl(pQueryInfo->numOfTables);
|
||||
|
@ -2108,7 +2107,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
|
|||
SSqlRes *pRes = &pSql->res;
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
||||
|
@ -2143,12 +2142,12 @@ int tscProcessShowRsp(SSqlObj *pSql) {
|
|||
|
||||
for (int16_t i = 0; i < pMetaMsg->numOfColumns; ++i, ++pSchema) {
|
||||
index.columnIndex = i;
|
||||
tscColumnListInsert(pQueryInfo->colList, &index);
|
||||
tscColumnListInsert(pQueryInfo->colList, &index, &pSchema[i]);
|
||||
|
||||
TAOS_FIELD f = tscCreateField(pSchema->type, pSchema->name, pSchema->bytes);
|
||||
SInternalField* pInfo = tscFieldInfoAppend(pFieldInfo, &f);
|
||||
|
||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index,
|
||||
pInfo->pExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index,
|
||||
pTableSchema[i].type, pTableSchema[i].bytes, getNewResColId(pQueryInfo), pTableSchema[i].bytes, false);
|
||||
}
|
||||
|
||||
|
@ -2167,7 +2166,7 @@ static void createHbObj(STscObj* pObj) {
|
|||
|
||||
pSql->fp = tscProcessHeartBeatRsp;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfoS(&pSql->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfoS(&pSql->cmd, 0);
|
||||
if (pQueryInfo == NULL) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
tfree(pSql);
|
||||
|
@ -2324,7 +2323,7 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) {
|
|||
pRes->completed = (pRetrieve->completed == 1);
|
||||
pRes->data = pRetrieve->data;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetActiveQueryInfo(pCmd);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetActiveQueryInfo(pCmd);
|
||||
if (tscCreateResPointerInfo(pRes, pQueryInfo) != TSDB_CODE_SUCCESS) {
|
||||
return pRes->code;
|
||||
}
|
||||
|
@ -2381,7 +2380,7 @@ static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaIn
|
|||
|
||||
tscAddQueryInfo(&pNew->cmd);
|
||||
|
||||
SQueryInfo *pNewQueryInfo = tscGetQueryInfoS(&pNew->cmd, 0);
|
||||
SQueryNodeInfo *pNewQueryInfo = tscGetQueryInfoS(&pNew->cmd, 0);
|
||||
|
||||
pNew->cmd.autoCreated = pSql->cmd.autoCreated; // create table if not exists
|
||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(&pNew->cmd, TSDB_DEFAULT_PAYLOAD_SIZE + pSql->cmd.payloadLen)) {
|
||||
|
@ -2470,7 +2469,7 @@ int tscGetTableMetaEx(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo, bool create
|
|||
int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex) {
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex);
|
||||
|
||||
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
|
@ -2494,7 +2493,7 @@ int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex) {
|
|||
}
|
||||
|
||||
static bool allVgroupInfoRetrieved(SSqlCmd* pCmd, int32_t clauseIndex) {
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, clauseIndex);
|
||||
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, i);
|
||||
if (pTableMetaInfo->vgroupList == NULL) {
|
||||
|
@ -2521,13 +2520,13 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) {
|
|||
pNew->cmd.command = TSDB_SQL_STABLEVGROUP;
|
||||
|
||||
// TODO TEST IT
|
||||
SQueryInfo *pNewQueryInfo = tscGetQueryInfoS(&pNew->cmd, 0);
|
||||
SQueryNodeInfo *pNewQueryInfo = tscGetQueryInfoS(&pNew->cmd, 0);
|
||||
if (pNewQueryInfo == NULL) {
|
||||
tscFreeSqlObj(pNew);
|
||||
return code;
|
||||
}
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, clauseIndex);
|
||||
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
||||
STableMetaInfo *pMInfo = tscGetMetaInfo(pQueryInfo, i);
|
||||
STableMeta* pTableMeta = tscTableMetaDup(pMInfo->pTableMeta);
|
||||
|
|
|
@ -373,7 +373,7 @@ int taos_num_fields(TAOS_RES *res) {
|
|||
if (pSql == NULL || pSql->signature != pSql) return 0;
|
||||
|
||||
int32_t num = 0;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
if (pQueryInfo == NULL) {
|
||||
return num;
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
|||
SSqlObj *pSql = (SSqlObj *)res;
|
||||
if (pSql == NULL || pSql->signature != pSql) return 0;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
if (pQueryInfo == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -558,7 +558,7 @@ static bool tscKillQueryInDnode(SSqlObj* pSql) {
|
|||
return true;
|
||||
}
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
|
||||
if ((pQueryInfo == NULL) || tscIsTwoStageSTableQuery(pQueryInfo, 0)) {
|
||||
return true;
|
||||
|
@ -671,7 +671,7 @@ char *taos_get_client_info() { return version; }
|
|||
static void tscKillSTableQuery(SSqlObj *pSql) {
|
||||
SSqlCmd* pCmd = &pSql->cmd;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
if (!tscIsTwoStageSTableQuery(pQueryInfo, 0)) {
|
||||
return;
|
||||
|
@ -722,7 +722,7 @@ void taos_stop_query(TAOS_RES *res) {
|
|||
// set the error code for master pSqlObj firstly
|
||||
pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
if (tscIsTwoStageSTableQuery(pQueryInfo, 0)) {
|
||||
assert(pSql->rpcRid <= 0);
|
||||
|
@ -752,7 +752,7 @@ bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) {
|
|||
return true;
|
||||
}
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
if (pQueryInfo == NULL) {
|
||||
return true;
|
||||
}
|
||||
|
@ -932,7 +932,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
|
|||
int code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
|
||||
char *str = (char *)tblNameList;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfoS(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfoS(pCmd, pCmd->clauseIndex);
|
||||
if (pQueryInfo == NULL) {
|
||||
pSql->res.code = terrno;
|
||||
return terrno;
|
||||
|
|
|
@ -35,10 +35,10 @@ static int64_t getDelayValueAfterTimewindowClosed(SSqlStream* pStream, int64_t l
|
|||
return taosGetTimestamp(pStream->precision) + launchDelay - pStream->stime - 1;
|
||||
}
|
||||
|
||||
static bool isProjectStream(SQueryInfo* pQueryInfo) {
|
||||
static bool isProjectStream(SQueryNodeInfo* pQueryInfo) {
|
||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (pExpr->functionId != TSDB_FUNC_PRJ) {
|
||||
SExprInfo *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (pExpr->base.functionId != TSDB_FUNC_PRJ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) {
|
|||
return;
|
||||
}
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
||||
code = tscGetTableMeta(pSql, pTableMetaInfo);
|
||||
|
@ -130,7 +130,7 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
|
|||
|
||||
pStream->numOfRes = 0; // reset the numOfRes.
|
||||
SSqlObj *pSql = pStream->pSql;
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
tscDebug("%p add into timer", pSql);
|
||||
|
||||
if (pStream->isProject) {
|
||||
|
@ -208,7 +208,7 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf
|
|||
static void tscStreamFillTimeGap(SSqlStream* pStream, TSKEY ts) {
|
||||
#if 0
|
||||
SSqlObj * pSql = pStream->pSql;
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
if (pQueryInfo->fillType != TSDB_FILL_SET_VALUE && pQueryInfo->fillType != TSDB_FILL_NULL) {
|
||||
return;
|
||||
|
@ -421,7 +421,7 @@ static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
|
|||
int64_t minIntervalTime =
|
||||
(pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsMinIntervalTime * 1000L : tsMinIntervalTime;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
if (!pStream->isProject && pQueryInfo->interval.interval == 0) {
|
||||
sprintf(pSql->cmd.payload, "the interval value is 0");
|
||||
|
@ -471,7 +471,7 @@ static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
|
|||
}
|
||||
|
||||
static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, int64_t stime) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
if (pStream->isProject) {
|
||||
// no data in table, flush all data till now to destination meter, 10sec delay
|
||||
|
@ -530,7 +530,7 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) {
|
|||
return;
|
||||
}
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
|
|||
}
|
||||
size_t numOfTables = taosArrayGetSize(tables);
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SArray* progress = taosArrayInit(numOfTables, sizeof(SSubscriptionProgress));
|
||||
for( size_t i = 0; i < numOfTables; i++ ) {
|
||||
STidTags* tt = taosArrayGet( tables, i );
|
||||
|
@ -502,7 +502,7 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
|
|||
SSqlRes *pRes = &pSql->res;
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
if (taosArrayGetSize(pSub->progress) > 0) { // fix crash in single table subscription
|
||||
|
||||
size_t size = taosArrayGetSize(pSub->progress);
|
||||
|
|
|
@ -116,10 +116,8 @@ static bool subAndCheckDone(SSqlObj *pSql, SSqlObj *pParentSql, int idx) {
|
|||
return done;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJoinSupporter* pSupporter2, STimeWindow * win) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
|
||||
STSBuf* output1 = tsBufCreate(true, pQueryInfo->order.order);
|
||||
STSBuf* output2 = tsBufCreate(true, pQueryInfo->order.order);
|
||||
|
@ -130,8 +128,8 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
|
|||
SLimitVal* pLimit = &pQueryInfo->limit;
|
||||
int32_t order = pQueryInfo->order.order;
|
||||
|
||||
SQueryInfo* pSubQueryInfo1 = tscGetQueryInfo(&pSql->pSubs[0]->cmd, 0);
|
||||
SQueryInfo* pSubQueryInfo2 = tscGetQueryInfo(&pSql->pSubs[1]->cmd, 0);
|
||||
SQueryNodeInfo* pSubQueryInfo1 = tscGetQueryInfo(&pSql->pSubs[0]->cmd, 0);
|
||||
SQueryNodeInfo* pSubQueryInfo2 = tscGetQueryInfo(&pSql->pSubs[1]->cmd, 0);
|
||||
|
||||
pSubQueryInfo1->tsBuf = output1;
|
||||
pSubQueryInfo2->tsBuf = output2;
|
||||
|
@ -274,7 +272,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
|
|||
pSupporter->pObj = pSql;
|
||||
|
||||
pSupporter->subqueryIndex = index;
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
|
||||
memcpy(&pSupporter->interval, &pQueryInfo->interval, sizeof(pSupporter->interval));
|
||||
pSupporter->limit = pQueryInfo->limit;
|
||||
|
@ -335,7 +333,7 @@ static void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) {
|
|||
* primary timestamp column , the secondary query is not necessary
|
||||
*
|
||||
*/
|
||||
static UNUSED_FUNC bool needSecondaryQuery(SQueryInfo* pQueryInfo) {
|
||||
static UNUSED_FUNC bool needSecondaryQuery(SQueryNodeInfo* pQueryInfo) {
|
||||
size_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
|
||||
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
|
@ -348,7 +346,7 @@ static UNUSED_FUNC bool needSecondaryQuery(SQueryInfo* pQueryInfo) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static void filterVgroupTables(SQueryInfo* pQueryInfo, SArray* pVgroupTables) {
|
||||
static void filterVgroupTables(SQueryNodeInfo* pQueryInfo, SArray* pVgroupTables) {
|
||||
int32_t num = 0;
|
||||
int32_t* list = NULL;
|
||||
tsBufGetGroupIdList(pQueryInfo->tsBuf, &num, &list);
|
||||
|
@ -380,7 +378,7 @@ static void filterVgroupTables(SQueryInfo* pQueryInfo, SArray* pVgroupTables) {
|
|||
tfree(list);
|
||||
}
|
||||
|
||||
static SArray* buildVgroupTableByResult(SQueryInfo* pQueryInfo, SArray* pVgroupTables) {
|
||||
static SArray* buildVgroupTableByResult(SQueryNodeInfo* pQueryInfo, SArray* pVgroupTables) {
|
||||
int32_t num = 0;
|
||||
int32_t* list = NULL;
|
||||
tsBufGetGroupIdList(pQueryInfo->tsBuf, &num, &list);
|
||||
|
@ -448,7 +446,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
|||
continue;
|
||||
}
|
||||
|
||||
SQueryInfo *pSubQueryInfo = tscGetQueryInfo(&pPrevSub->cmd, 0);
|
||||
SQueryNodeInfo *pSubQueryInfo = tscGetQueryInfo(&pPrevSub->cmd, 0);
|
||||
STSBuf *pTsBuf = pSubQueryInfo->tsBuf;
|
||||
pSubQueryInfo->tsBuf = NULL;
|
||||
|
||||
|
@ -467,7 +465,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
|||
tscClearSubqueryInfo(&pNew->cmd);
|
||||
pSql->pSubs[i] = pNew;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pNew->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(&pNew->cmd, 0);
|
||||
pQueryInfo->tsBuf = pTsBuf; // transfer the ownership of timestamp comp-z data to the new created object
|
||||
|
||||
// set the second stage sub query for join process
|
||||
|
@ -504,11 +502,11 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
|||
SColumnIndex index = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||
SSchema* s = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, 0);
|
||||
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, 0);
|
||||
int16_t funcId = pExpr->functionId;
|
||||
SExprInfo* pExpr = tscSqlExprGet(pQueryInfo, 0);
|
||||
int16_t funcId = pExpr->base.functionId;
|
||||
|
||||
// add the invisible timestamp column
|
||||
if ((pExpr->colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX) ||
|
||||
if ((pExpr->base.colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX) ||
|
||||
(funcId != TSDB_FUNC_TS && funcId != TSDB_FUNC_TS_DUMMY && funcId != TSDB_FUNC_PRJ)) {
|
||||
|
||||
int16_t functionId = tscIsProjectionQuery(pQueryInfo)? TSDB_FUNC_PRJ : TSDB_FUNC_TS;
|
||||
|
@ -526,8 +524,8 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
|||
int16_t colId = tscGetJoinTagColIdByUid(&pQueryInfo->tagCond, pTableMetaInfo->pTableMeta->id.uid);
|
||||
|
||||
// set the tag column id for executor to extract correct tag value
|
||||
pExpr->param[0] = (tVariant) {.i64 = colId, .nType = TSDB_DATA_TYPE_BIGINT, .nLen = sizeof(int64_t)};
|
||||
pExpr->numOfParams = 1;
|
||||
pExpr->base.param[0] = (tVariant) {.i64 = colId, .nType = TSDB_DATA_TYPE_BIGINT, .nLen = sizeof(int64_t)};
|
||||
pExpr->base.numOfParams = 1;
|
||||
}
|
||||
|
||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||
|
@ -565,7 +563,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
|||
}
|
||||
|
||||
// tscDoQuery(pSql->pSubs[i]);
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->pSubs[i]->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->pSubs[i]->cmd, 0);
|
||||
executeQuery(pSql->pSubs[i], pQueryInfo);
|
||||
}
|
||||
|
||||
|
@ -608,7 +606,7 @@ static int32_t quitAllSubquery(SSqlObj* pSqlSub, SSqlObj* pSqlObj, SJoinSupporte
|
|||
}
|
||||
|
||||
// update the query time range according to the join results on timestamp
|
||||
static void updateQueryTimeRange(SQueryInfo* pQueryInfo, STimeWindow* win) {
|
||||
static void updateQueryTimeRange(SQueryNodeInfo* pQueryInfo, STimeWindow* win) {
|
||||
assert(pQueryInfo->window.skey <= win->skey && pQueryInfo->window.ekey >= win->ekey);
|
||||
pQueryInfo->window = *win;
|
||||
|
||||
|
@ -704,7 +702,7 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
|
|||
tscClearSubqueryInfo(pCmd);
|
||||
tscFreeSqlResult(pSql);
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
assert(pQueryInfo->numOfTables == 1);
|
||||
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
@ -723,10 +721,10 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
|
|||
|
||||
// set the tags value for ts_comp function
|
||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, 0);
|
||||
SExprInfo *pExpr = tscSqlExprGet(pQueryInfo, 0);
|
||||
int16_t tagColId = tscGetJoinTagColIdByUid(&pSupporter->tagCond, pTableMetaInfo->pTableMeta->id.uid);
|
||||
pExpr->param->i64 = tagColId;
|
||||
pExpr->numOfParams = 1;
|
||||
pExpr->base.param->i64 = tagColId;
|
||||
pExpr->base.numOfParams = 1;
|
||||
}
|
||||
|
||||
// add the filter tag column
|
||||
|
@ -736,7 +734,7 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
|
|||
for (int32_t i = 0; i < s; ++i) {
|
||||
SColumn *pCol = taosArrayGetP(pSupporter->colList, i);
|
||||
|
||||
if (pCol->numOfFilters > 0) { // copy to the pNew->cmd.colList if it is filtered.
|
||||
if (pCol->info.numOfFilters > 0) { // copy to the pNew->cmd.colList if it is filtered.
|
||||
SColumn *p = tscColumnClone(pCol);
|
||||
taosArrayPush(pQueryInfo->colList, &p);
|
||||
}
|
||||
|
@ -770,7 +768,7 @@ static bool checkForDuplicateTagVal(SSchema* pColSchema, SJoinSupporter* p1, SSq
|
|||
return true;
|
||||
}
|
||||
|
||||
static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParentSql, SArray** s1, SArray** s2) {
|
||||
static int32_t getIntersectionOfTableTuple(SQueryNodeInfo* pQueryInfo, SSqlObj* pParentSql, SArray** s1, SArray** s2) {
|
||||
SJoinSupporter* p1 = pParentSql->pSubs[0]->param;
|
||||
SJoinSupporter* p2 = pParentSql->pSubs[1]->param;
|
||||
|
||||
|
@ -849,7 +847,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
|||
SSqlCmd* pCmd = &pSql->cmd;
|
||||
SSqlRes* pRes = &pSql->res;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
// todo, the type may not include TSDB_QUERY_TYPE_TAG_FILTER_QUERY
|
||||
assert(TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY));
|
||||
|
@ -969,11 +967,11 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
|||
SSqlCmd* pSubCmd1 = &pParentSql->pSubs[0]->cmd;
|
||||
SSqlCmd* pSubCmd2 = &pParentSql->pSubs[1]->cmd;
|
||||
|
||||
SQueryInfo* pQueryInfo1 = tscGetQueryInfo(pSubCmd1, 0);
|
||||
SQueryNodeInfo* pQueryInfo1 = tscGetQueryInfo(pSubCmd1, 0);
|
||||
STableMetaInfo* pTableMetaInfo1 = tscGetMetaInfo(pQueryInfo1, 0);
|
||||
tscBuildVgroupTableInfo(pParentSql, pTableMetaInfo1, s1);
|
||||
|
||||
SQueryInfo* pQueryInfo2 = tscGetQueryInfo(pSubCmd2, 0);
|
||||
SQueryNodeInfo* pQueryInfo2 = tscGetQueryInfo(pSubCmd2, 0);
|
||||
STableMetaInfo* pTableMetaInfo2 = tscGetMetaInfo(pQueryInfo2, 0);
|
||||
tscBuildVgroupTableInfo(pParentSql, pTableMetaInfo2, s2);
|
||||
|
||||
|
@ -1007,7 +1005,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
|||
SSqlCmd* pCmd = &pSql->cmd;
|
||||
SSqlRes* pRes = &pSql->res;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
assert(!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE));
|
||||
|
||||
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -1143,7 +1141,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
|||
}
|
||||
|
||||
// launch the query the retrieve actual results from vnode along with the filtered timestamp
|
||||
SQueryInfo* pPQueryInfo = tscGetQueryInfo(&pParentSql->cmd, pParentSql->cmd.clauseIndex);
|
||||
SQueryNodeInfo* pPQueryInfo = tscGetQueryInfo(&pParentSql->cmd, pParentSql->cmd.clauseIndex);
|
||||
updateQueryTimeRange(pPQueryInfo, &win);
|
||||
|
||||
//update the vgroup that involved in real data query
|
||||
|
@ -1159,7 +1157,7 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
|
|||
SSqlCmd* pCmd = &pSql->cmd;
|
||||
SSqlRes* pRes = &pSql->res;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||
tscError("%p abort query due to other subquery failure. code:%d, global code:%d", pSql, numOfRows, pParentSql->res.code);
|
||||
|
@ -1268,7 +1266,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
|
|||
|
||||
SSqlRes *pRes = &pSub->res;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSub->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSub->cmd, 0);
|
||||
if (!tscHasReachLimitation(pQueryInfo, pRes)) {
|
||||
if (pRes->row >= pRes->numOfRows) {
|
||||
// no data left in current result buffer
|
||||
|
@ -1320,7 +1318,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
|
|||
continue;
|
||||
}
|
||||
|
||||
SQueryInfo* p = tscGetQueryInfo(&pSub->cmd, 0);
|
||||
SQueryNodeInfo* p = tscGetQueryInfo(&pSub->cmd, 0);
|
||||
orderedPrjQuery = tscNonOrderedProjectionQueryOnSTable(p, 0);
|
||||
if (orderedPrjQuery) {
|
||||
break;
|
||||
|
@ -1344,7 +1342,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
|
|||
continue;
|
||||
}
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSub->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSub->cmd, 0);
|
||||
|
||||
if (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) && pSub->res.row >= pSub->res.numOfRows &&
|
||||
pSub->res.completed) {
|
||||
|
@ -1419,7 +1417,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
|
|||
pSupporter = (SJoinSupporter*)pSql1->param;
|
||||
|
||||
// wait for all subqueries completed
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd1, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd1, 0);
|
||||
assert(pRes1->numOfRows >= 0 && pQueryInfo->numOfTables == 1);
|
||||
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
@ -1450,7 +1448,7 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
|
|||
return;
|
||||
}
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
int32_t numOfExprs = (int32_t)tscSqlExprNumOfExprs(pQueryInfo);
|
||||
pRes->pColumnIndex = calloc(1, sizeof(SColumnIndex) * numOfExprs);
|
||||
|
@ -1460,7 +1458,7 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < numOfExprs; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
SExprInfo* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
|
||||
int32_t tableIndexOfSub = -1;
|
||||
for (int32_t j = 0; j < pQueryInfo->numOfTables; ++j) {
|
||||
|
@ -1474,12 +1472,12 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
|
|||
assert(tableIndexOfSub >= 0 && tableIndexOfSub < pQueryInfo->numOfTables);
|
||||
|
||||
SSqlCmd* pSubCmd = &pSql->pSubs[tableIndexOfSub]->cmd;
|
||||
SQueryInfo* pSubQueryInfo = tscGetQueryInfo(pSubCmd, 0);
|
||||
SQueryNodeInfo* pSubQueryInfo = tscGetQueryInfo(pSubCmd, 0);
|
||||
|
||||
size_t numOfSubExpr = taosArrayGetSize(pSubQueryInfo->exprList);
|
||||
for (int32_t k = 0; k < numOfSubExpr; ++k) {
|
||||
SSqlExpr* pSubExpr = tscSqlExprGet(pSubQueryInfo, k);
|
||||
if (pExpr->functionId == pSubExpr->functionId && pExpr->colInfo.colId == pSubExpr->colInfo.colId) {
|
||||
SExprInfo* pSubExpr = tscSqlExprGet(pSubQueryInfo, k);
|
||||
if (pExpr->base.functionId == pSubExpr->base.functionId && pExpr->base.colInfo.colId == pSubExpr->base.colInfo.colId) {
|
||||
pRes->pColumnIndex[i] = (SColumnIndex){.tableIndex = tableIndexOfSub, .columnIndex = k};
|
||||
break;
|
||||
}
|
||||
|
@ -1498,7 +1496,7 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
|
|||
SSqlObj* pParentSql = pSupporter->pObj;
|
||||
|
||||
// There is only one subquery and table for each subquery.
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
||||
assert(pQueryInfo->numOfTables == 1 && pSql->cmd.numOfClause == 1);
|
||||
|
@ -1582,7 +1580,7 @@ static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsuppo
|
|||
|
||||
int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter *pSupporter) {
|
||||
SSqlCmd * pCmd = &pSql->cmd;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
pSql->res.qid = 0x1;
|
||||
assert(pSql->res.numOfRows == 0);
|
||||
|
@ -1605,7 +1603,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
|||
addGroupInfoForSubquery(pSql, pNew, 0, tableIndex);
|
||||
|
||||
// refactor as one method
|
||||
SQueryInfo *pNewQueryInfo = tscGetQueryInfo(&pNew->cmd, 0);
|
||||
SQueryNodeInfo *pNewQueryInfo = tscGetQueryInfo(&pNew->cmd, 0);
|
||||
assert(pNewQueryInfo != NULL);
|
||||
|
||||
// update the table index
|
||||
|
@ -1682,12 +1680,12 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
|||
tscAddFuncInSelectClause(pNewQueryInfo, 0, TSDB_FUNC_TS_COMP, &colIndex, &colSchema, TSDB_COL_NORMAL);
|
||||
|
||||
// set the tags value for ts_comp function
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pNewQueryInfo, 0);
|
||||
SExprInfo *pExpr = tscSqlExprGet(pNewQueryInfo, 0);
|
||||
|
||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||
int16_t tagColId = tscGetJoinTagColIdByUid(&pSupporter->tagCond, pTableMetaInfo->pTableMeta->id.uid);
|
||||
pExpr->param->i64 = tagColId;
|
||||
pExpr->numOfParams = 1;
|
||||
pExpr->base.param->i64 = tagColId;
|
||||
pExpr->base.numOfParams = 1;
|
||||
}
|
||||
|
||||
// add the filter tag column
|
||||
|
@ -1697,7 +1695,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
|||
for (int32_t i = 0; i < s; ++i) {
|
||||
SColumn *pCol = taosArrayGetP(pSupporter->colList, i);
|
||||
|
||||
if (pCol->numOfFilters > 0) { // copy to the pNew->cmd.colList if it is filtered.
|
||||
if (pCol->info.numOfFilters > 0) { // copy to the pNew->cmd.colList if it is filtered.
|
||||
SColumn *p = tscColumnClone(pCol);
|
||||
taosArrayPush(pNewQueryInfo->colList, &p);
|
||||
}
|
||||
|
@ -1714,7 +1712,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
|||
}
|
||||
} else {
|
||||
assert(0);
|
||||
SQueryInfo *pNewQueryInfo = tscGetQueryInfo(&pNew->cmd, 0);
|
||||
SQueryNodeInfo *pNewQueryInfo = tscGetQueryInfo(&pNew->cmd, 0);
|
||||
pNewQueryInfo->type |= TSDB_QUERY_TYPE_SUBQUERY;
|
||||
}
|
||||
|
||||
|
@ -1725,7 +1723,7 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) {
|
|||
SSqlCmd* pCmd = &pSql->cmd;
|
||||
SSqlRes* pRes = &pSql->res;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
assert((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) == 0);
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -1846,15 +1844,15 @@ typedef struct SFirstRoundQuerySup {
|
|||
int32_t bufLen;
|
||||
} SFirstRoundQuerySup;
|
||||
|
||||
void doAppendData(SInterResult* pInterResult, TAOS_ROW row, int32_t numOfCols, SQueryInfo* pQueryInfo) {
|
||||
void doAppendData(SInterResult* pInterResult, TAOS_ROW row, int32_t numOfCols, SQueryNodeInfo* pQueryInfo) {
|
||||
TSKEY key = INT64_MIN;
|
||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (TSDB_COL_IS_TAG(pExpr->colInfo.flag) || pExpr->functionId == TSDB_FUNC_PRJ) {
|
||||
SExprInfo* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (TSDB_COL_IS_TAG(pExpr->base.colInfo.flag) || pExpr->base.functionId == TSDB_FUNC_PRJ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pExpr->colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||
if (pExpr->base.colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||
key = *(TSKEY*) row[i];
|
||||
continue;
|
||||
}
|
||||
|
@ -1866,7 +1864,7 @@ void doAppendData(SInterResult* pInterResult, TAOS_ROW row, int32_t numOfCols, S
|
|||
SET_DOUBLE_NULL(&v);
|
||||
}
|
||||
|
||||
int32_t id = pExpr->colInfo.colId;
|
||||
int32_t id = pExpr->base.colInfo.colId;
|
||||
int32_t numOfQueriedCols = (int32_t) taosArrayGetSize(pInterResult->pResult);
|
||||
|
||||
SArray* p = NULL;
|
||||
|
@ -1910,7 +1908,7 @@ void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
|||
SFirstRoundQuerySup* pSup = param;
|
||||
|
||||
SSqlObj* pParent = pSup->pParent;
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
int32_t code = taos_errno(pSql);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -1942,16 +1940,16 @@ void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
|||
|
||||
int32_t offset = 0;
|
||||
for (int32_t i = 0; i < numOfCols && offset < pSup->tagLen; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
SExprInfo* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
|
||||
// tag or group by column
|
||||
if (TSDB_COL_IS_TAG(pExpr->colInfo.flag) || pExpr->functionId == TSDB_FUNC_PRJ) {
|
||||
if (TSDB_COL_IS_TAG(pExpr->base.colInfo.flag) || pExpr->base.functionId == TSDB_FUNC_PRJ) {
|
||||
if (row[i] == NULL) {
|
||||
setNull(p + offset, pExpr->resType, pExpr->resBytes);
|
||||
setNull(p + offset, pExpr->base.resType, pExpr->base.resBytes);
|
||||
} else {
|
||||
memcpy(p + offset, row[i], length[i]);
|
||||
}
|
||||
offset += pExpr->resBytes;
|
||||
offset += pExpr->base.resBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1993,7 +1991,7 @@ void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
|||
|
||||
// set the parameters for the second round query process
|
||||
SSqlCmd *pPCmd = &pParent->cmd;
|
||||
SQueryInfo *pQueryInfo1 = tscGetQueryInfo(pPCmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo1 = tscGetQueryInfo(pPCmd, 0);
|
||||
int32_t resRows = pSup->numOfRows;
|
||||
|
||||
if (pSup->numOfRows > 0) {
|
||||
|
@ -2044,7 +2042,7 @@ void tscFirstRoundCallback(void* param, TAOS_RES* tres, int code) {
|
|||
}
|
||||
|
||||
int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
STableMetaInfo* pTableMetaInfo1 = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
||||
|
||||
SFirstRoundQuerySup *pSup = calloc(1, sizeof(SFirstRoundQuerySup));
|
||||
|
@ -2060,7 +2058,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
|
|||
tscClearSubqueryInfo(pCmd);
|
||||
tscFreeSqlResult(pSql);
|
||||
|
||||
SQueryInfo* pNewQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
SQueryNodeInfo* pNewQueryInfo = tscGetQueryInfo(pCmd, 0);
|
||||
assert(pQueryInfo->numOfTables == 1);
|
||||
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pNewQueryInfo, 0);
|
||||
|
@ -2089,54 +2087,54 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
|
|||
|
||||
int32_t index = 0;
|
||||
for(int32_t i = 0; i < numOfExprs; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (pExpr->functionId == TSDB_FUNC_TS && pQueryInfo->interval.interval > 0) {
|
||||
taosArrayPush(pSup->pColsInfo, &pExpr->resColId);
|
||||
SExprInfo* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (pExpr->base.functionId == TSDB_FUNC_TS && pQueryInfo->interval.interval > 0) {
|
||||
taosArrayPush(pSup->pColsInfo, &pExpr->base.resColId);
|
||||
|
||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||
SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->colInfo.colId);
|
||||
SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->base.colInfo.colId);
|
||||
|
||||
SSqlExpr* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_TS, &colIndex, schema, TSDB_COL_NORMAL);
|
||||
p->resColId = pExpr->resColId; // update the result column id
|
||||
} else if (pExpr->functionId == TSDB_FUNC_STDDEV_DST) {
|
||||
taosArrayPush(pSup->pColsInfo, &pExpr->resColId);
|
||||
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_TS, &colIndex, schema, TSDB_COL_NORMAL);
|
||||
p->base.resColId = pExpr->base.resColId; // update the result column id
|
||||
} else if (pExpr->base.functionId == TSDB_FUNC_STDDEV_DST) {
|
||||
taosArrayPush(pSup->pColsInfo, &pExpr->base.resColId);
|
||||
|
||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = pExpr->colInfo.colIndex};
|
||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = pExpr->base.colInfo.colIndex};
|
||||
SSchema schema = {.type = TSDB_DATA_TYPE_DOUBLE, .bytes = sizeof(double)};
|
||||
tstrncpy(schema.name, pExpr->aliasName, tListLen(schema.name));
|
||||
tstrncpy(schema.name, pExpr->base.aliasName, tListLen(schema.name));
|
||||
|
||||
SSqlExpr* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_AVG, &colIndex, &schema, TSDB_COL_NORMAL);
|
||||
p->resColId = pExpr->resColId; // update the result column id
|
||||
} else if (pExpr->functionId == TSDB_FUNC_TAG) {
|
||||
pSup->tagLen += pExpr->resBytes;
|
||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = pExpr->colInfo.colIndex};
|
||||
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_AVG, &colIndex, &schema, TSDB_COL_NORMAL);
|
||||
p->base.resColId = pExpr->base.resColId; // update the result column id
|
||||
} else if (pExpr->base.functionId == TSDB_FUNC_TAG) {
|
||||
pSup->tagLen += pExpr->base.resBytes;
|
||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = pExpr->base.colInfo.colIndex};
|
||||
|
||||
SSchema* schema = NULL;
|
||||
if (pExpr->colInfo.colId != TSDB_TBNAME_COLUMN_INDEX) {
|
||||
schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->colInfo.colId);
|
||||
if (pExpr->base.colInfo.colId != TSDB_TBNAME_COLUMN_INDEX) {
|
||||
schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->base.colInfo.colId);
|
||||
} else {
|
||||
schema = tGetTbnameColumnSchema();
|
||||
}
|
||||
|
||||
SSqlExpr* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_TAG, &colIndex, schema, TSDB_COL_TAG);
|
||||
p->resColId = pExpr->resColId;
|
||||
} else if (pExpr->functionId == TSDB_FUNC_PRJ) {
|
||||
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_TAG, &colIndex, schema, TSDB_COL_TAG);
|
||||
p->base.resColId = pExpr->base.resColId;
|
||||
} else if (pExpr->base.functionId == TSDB_FUNC_PRJ) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pNewQueryInfo->groupbyExpr.columnInfo);
|
||||
for(int32_t k = 0; k < num; ++k) {
|
||||
SColIndex* pIndex = taosArrayGet(pNewQueryInfo->groupbyExpr.columnInfo, k);
|
||||
if (pExpr->colInfo.colId == pIndex->colId) {
|
||||
pSup->tagLen += pExpr->resBytes;
|
||||
taosArrayPush(pSup->pColsInfo, &pExpr->resColId);
|
||||
if (pExpr->base.colInfo.colId == pIndex->colId) {
|
||||
pSup->tagLen += pExpr->base.resBytes;
|
||||
taosArrayPush(pSup->pColsInfo, &pExpr->base.resColId);
|
||||
|
||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = pIndex->colIndex};
|
||||
SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->colInfo.colId);
|
||||
SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->base.colInfo.colId);
|
||||
|
||||
//doLimitOutputNormalColOfGroupby
|
||||
SSqlExpr* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_PRJ, &colIndex, schema, TSDB_COL_NORMAL);
|
||||
p->numOfParams = 1;
|
||||
p->param[0].i64 = 1;
|
||||
p->param[0].nType = TSDB_DATA_TYPE_INT;
|
||||
p->resColId = pExpr->resColId; // update the result column id
|
||||
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_PRJ, &colIndex, schema, TSDB_COL_NORMAL);
|
||||
p->base.numOfParams = 1;
|
||||
p->base.param[0].i64 = 1;
|
||||
p->base.param[0].nType = TSDB_DATA_TYPE_INT;
|
||||
p->base.resColId = pExpr->base.resColId; // update the result column id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2183,7 +2181,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
|||
|
||||
const uint32_t nBufferSize = (1u << 16u); // 64KB
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
SSubqueryState *pState = &pSql->subState;
|
||||
|
||||
|
@ -2265,7 +2263,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
|||
|
||||
// todo handle multi-vnode situation
|
||||
if (pQueryInfo->tsBuf) {
|
||||
SQueryInfo *pNewQueryInfo = tscGetQueryInfo(&pNew->cmd, 0);
|
||||
SQueryNodeInfo *pNewQueryInfo = tscGetQueryInfo(&pNew->cmd, 0);
|
||||
pNewQueryInfo->tsBuf = tsBufClone(pQueryInfo->tsBuf);
|
||||
assert(pNewQueryInfo->tsBuf != NULL);
|
||||
}
|
||||
|
@ -2453,7 +2451,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
|
|||
tscFreeRetrieveSup(pSql);
|
||||
|
||||
// in case of second stage join subquery, invoke its callback function instead of regular QueueAsyncRes
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pParentSql->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(&pParentSql->cmd, 0);
|
||||
|
||||
if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE)) {
|
||||
(*pParentSql->fp)(pParentSql->param, pParentSql, pParentSql->res.code);
|
||||
|
@ -2470,7 +2468,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
|
|||
tOrderDescriptor *pDesc = trsupport->pOrderDescriptor;
|
||||
|
||||
SSubqueryState* pState = &pParentSql->subState;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
STableMetaInfo* pTableMetaInfo = pQueryInfo->pTableMetaInfo[0];
|
||||
|
||||
|
@ -2518,7 +2516,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
|
|||
tscDebug("%p retrieve from %d vnodes completed.final NumOfRows:%" PRId64 ",start to build loser tree", pParentSql,
|
||||
pState->numOfSub, pState->numOfRetrievedRows);
|
||||
|
||||
SQueryInfo *pPQueryInfo = tscGetQueryInfo(&pParentSql->cmd, 0);
|
||||
SQueryNodeInfo *pPQueryInfo = tscGetQueryInfo(&pParentSql->cmd, 0);
|
||||
tscClearInterpInfo(pPQueryInfo);
|
||||
|
||||
tscCreateLocalMerger(trsupport->pExtMemBuffer, pState->numOfSub, pDesc, trsupport->pFinalColModel, trsupport->pFFColModel, pParentSql);
|
||||
|
@ -2594,7 +2592,7 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
|||
}
|
||||
|
||||
SSqlRes * pRes = &pSql->res;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
|
||||
if (numOfRows > 0) {
|
||||
assert(pRes->numOfRows == numOfRows);
|
||||
|
@ -2646,7 +2644,7 @@ static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsuppo
|
|||
|
||||
SSqlObj *pNew = createSubqueryObj(pSql, table_index, tscRetrieveDataRes, trsupport, TSDB_SQL_SELECT, prevSqlObj);
|
||||
if (pNew != NULL) { // the sub query of two-stage super table query
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pNew->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(&pNew->cmd, 0);
|
||||
|
||||
pQueryInfo->type |= TSDB_QUERY_TYPE_STABLE_SUBQUERY;
|
||||
|
||||
|
@ -2680,7 +2678,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
|||
SSqlObj* pParentSql = trsupport->pParentSql;
|
||||
SSqlObj* pSql = (SSqlObj *) tres;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
|
||||
assert(pSql->cmd.numOfClause == 1 && pQueryInfo->numOfTables == 1);
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
||||
|
@ -2818,7 +2816,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
|
|||
|
||||
// clean up tableMeta in cache
|
||||
tscFreeQueryInfo(&pSql->cmd, false);
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoS(&pSql->cmd, 0);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfoS(&pSql->cmd, 0);
|
||||
STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pParentObj->cmd, pSql->cmd.clauseIndex, 0);
|
||||
tscAddTableMetaInfo(pQueryInfo, &pMasterTableMetaInfo->name, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
@ -2990,13 +2988,13 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
static char* getResultBlockPosition(SSqlCmd* pCmd, SSqlRes* pRes, int32_t columnIndex, int16_t* bytes) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
SInternalField* pInfo = (SInternalField*) TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.internalField, columnIndex);
|
||||
assert(pInfo->pSqlExpr != NULL);
|
||||
assert(pInfo->pExpr->pExpr == NULL);
|
||||
|
||||
*bytes = pInfo->pSqlExpr->resBytes;
|
||||
char* pData = pRes->data + pInfo->pSqlExpr->offset * pRes->numOfRows + pRes->row * (*bytes);
|
||||
*bytes = pInfo->pExpr->base.resBytes;
|
||||
char* pData = pRes->data + pInfo->pExpr->base.offset * pRes->numOfRows + pRes->row * (*bytes);
|
||||
|
||||
return pData;
|
||||
}
|
||||
|
@ -3004,7 +3002,7 @@ static char* getResultBlockPosition(SSqlCmd* pCmd, SSqlRes* pRes, int32_t column
|
|||
static void doBuildResFromSubqueries(SSqlObj* pSql) {
|
||||
SSqlRes* pRes = &pSql->res;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
|
||||
int32_t numOfRes = INT32_MAX;
|
||||
for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) {
|
||||
|
@ -3087,7 +3085,7 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
if (pRes->tsrow == NULL) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
SQueryNodeInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
pRes->numOfCols = (int16_t) tscSqlExprNumOfExprs(pQueryInfo);
|
||||
|
||||
pRes->tsrow = calloc(pRes->numOfCols, POINTER_BYTES);
|
||||
|
@ -3117,18 +3115,18 @@ char *getArithmeticInputSrc(void *param, const char *name, int32_t colId) {
|
|||
SArithmeticSupport *pSupport = (SArithmeticSupport *) param;
|
||||
|
||||
int32_t index = -1;
|
||||
SSqlExpr* pExpr = NULL;
|
||||
SExprInfo* pExpr = NULL;
|
||||
|
||||
for (int32_t i = 0; i < pSupport->numOfCols; ++i) {
|
||||
pExpr = taosArrayGetP(pSupport->exprList, i);
|
||||
if (strncmp(name, pExpr->aliasName, sizeof(pExpr->aliasName) - 1) == 0) {
|
||||
if (strncmp(name, pExpr->base.aliasName, sizeof(pExpr->base.aliasName) - 1) == 0) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(index >= 0 && index < pSupport->numOfCols);
|
||||
return pSupport->data[index] + pSupport->offset * pExpr->resBytes;
|
||||
return pSupport->data[index] + pSupport->offset * pExpr->base.resBytes;
|
||||
}
|
||||
|
||||
TAOS_ROW doSetResultRowData(SSqlObj *pSql) {
|
||||
|
@ -3141,7 +3139,7 @@ TAOS_ROW doSetResultRowData(SSqlObj *pSql) {
|
|||
return pRes->tsrow;
|
||||
}
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
|
||||
size_t size = tscNumOfFields(pQueryInfo);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
|
@ -3168,7 +3166,7 @@ static UNUSED_FUNC bool tscHasRemainDataInSubqueryResultSet(SSqlObj *pSql) {
|
|||
bool hasData = true;
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
|
||||
if (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0)) {
|
||||
bool allSubqueryExhausted = true;
|
||||
|
||||
|
@ -3180,7 +3178,7 @@ static UNUSED_FUNC bool tscHasRemainDataInSubqueryResultSet(SSqlObj *pSql) {
|
|||
SSqlRes *pRes1 = &pSql->pSubs[i]->res;
|
||||
SSqlCmd *pCmd1 = &pSql->pSubs[i]->cmd;
|
||||
|
||||
SQueryInfo *pQueryInfo1 = tscGetQueryInfo(pCmd1, pCmd1->clauseIndex);
|
||||
SQueryNodeInfo *pQueryInfo1 = tscGetQueryInfo(pCmd1, pCmd1->clauseIndex);
|
||||
assert(pQueryInfo1->numOfTables == 1);
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo1, 0);
|
||||
|
@ -3204,7 +3202,7 @@ static UNUSED_FUNC bool tscHasRemainDataInSubqueryResultSet(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
SSqlRes * pRes1 = &pSql->pSubs[i]->res;
|
||||
SQueryInfo *pQueryInfo1 = tscGetQueryInfo(&pSql->pSubs[i]->cmd, 0);
|
||||
SQueryNodeInfo *pQueryInfo1 = tscGetQueryInfo(&pSql->pSubs[i]->cmd, 0);
|
||||
|
||||
if ((pRes1->row >= pRes1->numOfRows && tscHasReachLimitation(pQueryInfo1, pRes1) &&
|
||||
tscIsProjectionQuery(pQueryInfo1)) || (pRes1->numOfRows == 0)) {
|
||||
|
@ -3216,3 +3214,185 @@ static UNUSED_FUNC bool tscHasRemainDataInSubqueryResultSet(SSqlObj *pSql) {
|
|||
|
||||
return hasData;
|
||||
}
|
||||
|
||||
void* createQueryInfoFromQueryNode(SQueryNodeInfo* pQueryNodeInfo, SExprInfo* pExprs, STableGroupInfo* pTableGroupInfo,
|
||||
uint64_t* qId, char* sql) {
|
||||
assert(pQueryNodeInfo != NULL);
|
||||
|
||||
int16_t numOfCols = taosArrayGetSize(pQueryNodeInfo->colList);
|
||||
int16_t numOfOutput = pQueryNodeInfo->fieldsInfo.numOfOutput;
|
||||
|
||||
SQInfo *pQInfo = (SQInfo *)calloc(1, sizeof(SQInfo));
|
||||
if (pQInfo == NULL) {
|
||||
goto _cleanup;
|
||||
}
|
||||
|
||||
// to make sure third party won't overwrite this structure
|
||||
pQInfo->signature = pQInfo;
|
||||
SQuery* pQuery = &pQInfo->query;
|
||||
pQInfo->runtimeEnv.pQuery = pQuery;
|
||||
|
||||
pQuery->tableGroupInfo = *pTableGroupInfo;
|
||||
pQuery->numOfCols = numOfCols;
|
||||
pQuery->numOfOutput = numOfOutput;
|
||||
pQuery->limit = pQueryNodeInfo->limit;
|
||||
pQuery->order = pQueryNodeInfo->order;
|
||||
pQuery->pExpr1 = pExprs;
|
||||
pQuery->pExpr2 = NULL; // not support yet.
|
||||
pQuery->numOfExpr2 = 0;
|
||||
pQuery->pGroupbyExpr = NULL;
|
||||
memcpy(&pQuery->interval, &pQueryNodeInfo->interval, sizeof(pQuery->interval));
|
||||
pQuery->fillType = pQueryNodeInfo->fillType;
|
||||
pQuery->numOfTags = 0;
|
||||
pQuery->tagColList = NULL;
|
||||
// pQuery->prjInfo.vgroupLimit = pQueryNodeInfo->vgroupLimit;
|
||||
pQuery->prjInfo.ts = (pQueryNodeInfo->order.order == TSDB_ORDER_ASC)? INT64_MIN:INT64_MAX;
|
||||
pQuery->sw = pQueryNodeInfo->sessionWindow;
|
||||
pQuery->colList = calloc(numOfCols, sizeof(SSingleColumnFilterInfo));
|
||||
if (pQuery->colList == NULL) {
|
||||
goto _cleanup;
|
||||
}
|
||||
|
||||
pQuery->srcRowSize = 0;
|
||||
pQuery->maxSrcColumnSize = 0;
|
||||
for (int16_t i = 0; i < numOfCols; ++i) {
|
||||
SColumn* pCol = taosArrayGet(pQueryNodeInfo->colList, i);
|
||||
pQuery->colList[i] = pCol->info;
|
||||
pQuery->colList[i].filterInfo = tFilterInfoDup(pCol->info.filterInfo, pQuery->colList[i].numOfFilters);
|
||||
|
||||
pQuery->srcRowSize += pQuery->colList[i].bytes;
|
||||
if (pQuery->maxSrcColumnSize < pQuery->colList[i].bytes) {
|
||||
pQuery->maxSrcColumnSize = pQuery->colList[i].bytes;
|
||||
}
|
||||
}
|
||||
|
||||
// calculate the result row size
|
||||
for (int16_t col = 0; col < numOfOutput; ++col) {
|
||||
assert(pExprs[col].base.resBytes > 0);
|
||||
pQuery->resultRowSize += pExprs[col].base.resBytes;
|
||||
|
||||
// keep the tag length
|
||||
if (TSDB_COL_IS_TAG(pExprs[col].base.colInfo.flag)) {
|
||||
pQuery->tagLen += pExprs[col].base.resBytes;
|
||||
}
|
||||
}
|
||||
|
||||
// doUpdateExprColumnIndex(pQuery);
|
||||
// int32_t ret = createFilterInfo(pQInfo, pQuery);
|
||||
// if (ret != TSDB_CODE_SUCCESS) {
|
||||
// goto _cleanup;
|
||||
// }
|
||||
|
||||
if (pQuery->fillType != TSDB_FILL_NONE) {
|
||||
pQuery->fillVal = malloc(sizeof(int64_t) * pQuery->numOfOutput);
|
||||
if (pQuery->fillVal == NULL) {
|
||||
goto _cleanup;
|
||||
}
|
||||
|
||||
// the first column is the timestamp
|
||||
memcpy(pQuery->fillVal, (char *)pQueryNodeInfo->fillVal, pQuery->numOfOutput * sizeof(int64_t));
|
||||
}
|
||||
|
||||
size_t numOfGroups = 0;
|
||||
if (pTableGroupInfo->pGroupList != NULL) {
|
||||
numOfGroups = taosArrayGetSize(pTableGroupInfo->pGroupList);
|
||||
STableGroupInfo* pTableqinfo = &pQInfo->runtimeEnv.tableqinfoGroupInfo;
|
||||
|
||||
pTableqinfo->pGroupList = taosArrayInit(numOfGroups, POINTER_BYTES);
|
||||
pTableqinfo->numOfTables = pTableGroupInfo->numOfTables;
|
||||
pTableqinfo->map = taosHashInit(pTableGroupInfo->numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
}
|
||||
|
||||
pQInfo->pBuf = calloc(pTableGroupInfo->numOfTables, sizeof(STableQueryInfo));
|
||||
if (pQInfo->pBuf == NULL) {
|
||||
goto _cleanup;
|
||||
}
|
||||
|
||||
pQInfo->dataReady = QUERY_RESULT_NOT_READY;
|
||||
pQInfo->rspContext = NULL;
|
||||
pQInfo->sql = sql;
|
||||
pthread_mutex_init(&pQInfo->lock, NULL);
|
||||
tsem_init(&pQInfo->ready, 0, 0);
|
||||
|
||||
pQuery->window = pQueryNodeInfo->window;
|
||||
// changeExecuteScanOrder(pQInfo, pQueryMsg, stableQuery);
|
||||
|
||||
SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv;
|
||||
bool groupByCol = false;//isGroupbyColumn(pQuery->pGroupbyExpr);
|
||||
|
||||
STimeWindow window = pQuery->window;
|
||||
|
||||
int32_t index = 0;
|
||||
for(int32_t i = 0; i < numOfGroups; ++i) {
|
||||
SArray* pa = taosArrayGetP(pQuery->tableGroupInfo.pGroupList, i);
|
||||
|
||||
size_t s = taosArrayGetSize(pa);
|
||||
SArray* p1 = taosArrayInit(s, POINTER_BYTES);
|
||||
if (p1 == NULL) {
|
||||
goto _cleanup;
|
||||
}
|
||||
|
||||
taosArrayPush(pRuntimeEnv->tableqinfoGroupInfo.pGroupList, &p1);
|
||||
|
||||
for(int32_t j = 0; j < s; ++j) {
|
||||
STableKeyInfo* info = taosArrayGet(pa, j);
|
||||
window.skey = info->lastKey;
|
||||
|
||||
void* buf = (char*) pQInfo->pBuf + index * sizeof(STableQueryInfo);
|
||||
STableQueryInfo* item = createTableQueryInfo(pQuery, info->pTable, groupByCol, window, buf);
|
||||
if (item == NULL) {
|
||||
goto _cleanup;
|
||||
}
|
||||
|
||||
item->groupIndex = i;
|
||||
taosArrayPush(p1, &item);
|
||||
|
||||
// STableId* id = TSDB_TABLEID(info->pTable);
|
||||
STableId id = {.tid = 0, .uid = 0};
|
||||
taosHashPut(pRuntimeEnv->tableqinfoGroupInfo.map, &id.tid, sizeof(id.tid), &item, POINTER_BYTES);
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// colIdCheck(pQuery, pQInfo);
|
||||
|
||||
// todo refactor
|
||||
pQInfo->query.queryBlockDist = (numOfOutput == 1 && pExprs[0].base.colInfo.colId == TSDB_BLOCK_DIST_COLUMN_INDEX);
|
||||
|
||||
pQInfo->qId = 0;//atomic_add_fetch_64(&queryHandleId, 1);
|
||||
if (qId != NULL) {
|
||||
*qId = pQInfo->qId;
|
||||
}
|
||||
|
||||
// qDebug("qmsg:%p QInfo:%" PRIu64 "-%p created", pQueryMsg, pQInfo->qId, pQInfo);
|
||||
// return pQInfo;
|
||||
|
||||
|
||||
|
||||
// if (pGroupbyExpr != NULL) {
|
||||
// taosArrayDestroy(pGroupbyExpr->columnInfo);
|
||||
// free(pGroupbyExpr);
|
||||
// }
|
||||
//
|
||||
// tfree(pTagCols);
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
SExprInfo* pExprInfo = &pExprs[i];
|
||||
if (pExprInfo->pExpr != NULL) {
|
||||
tExprTreeDestroy(pExprInfo->pExpr, NULL);
|
||||
pExprInfo->pExpr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
tfree(pExprs);
|
||||
|
||||
STsBufInfo bufInfo = {0};
|
||||
SQueryParam param = {0};
|
||||
/*int32_t code = */initQInfo(&bufInfo, NULL, 0, pQInfo, ¶m, NULL, 0, false);
|
||||
qTableQuery(pQInfo);
|
||||
|
||||
return pQInfo;
|
||||
|
||||
_cleanup:
|
||||
freeQInfo(pQInfo);
|
||||
return NULL;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -451,7 +451,7 @@ typedef struct SColumnInfo {
|
|||
int16_t numOfFilters;
|
||||
union{
|
||||
int64_t placeholder;
|
||||
SColumnFilterInfo *filters;
|
||||
SColumnFilterInfo *filterInfo;
|
||||
};
|
||||
} SColumnInfo;
|
||||
|
||||
|
@ -466,6 +466,13 @@ typedef struct STimeWindow {
|
|||
TSKEY ekey;
|
||||
} STimeWindow;
|
||||
|
||||
typedef struct {
|
||||
int32_t tsOffset; // offset value in current msg body, NOTE: ts list is compressed
|
||||
int32_t tsLen; // total length of ts comp block
|
||||
int32_t tsNumOfBlocks; // ts comp block numbers
|
||||
int32_t tsOrder; // ts comp block order
|
||||
} STsBufInfo;
|
||||
|
||||
typedef struct {
|
||||
SMsgHead head;
|
||||
char version[TSDB_VERSION_LEN];
|
||||
|
@ -492,10 +499,7 @@ typedef struct {
|
|||
int16_t fillType; // interpolate type
|
||||
uint64_t fillVal; // default value array list
|
||||
int32_t secondStageOutput;
|
||||
int32_t tsOffset; // offset value in current msg body, NOTE: ts list is compressed
|
||||
int32_t tsLen; // total length of ts comp block
|
||||
int32_t tsNumOfBlocks; // ts comp block numbers
|
||||
int32_t tsOrder; // ts comp block order
|
||||
STsBufInfo tsBuf; // tsBuf info
|
||||
int32_t numOfTags; // number of tags columns involved
|
||||
int32_t sqlstrLen; // sql query string
|
||||
int32_t prevResultLen; // previous result length
|
||||
|
|
|
@ -177,6 +177,8 @@ typedef struct SSDataBlock {
|
|||
SDataBlockInfo info;
|
||||
} SSDataBlock;
|
||||
|
||||
// The basic query information extracted from the SQueryNodeInfo tree to support the
|
||||
// execution of query in a data node.
|
||||
typedef struct SQuery {
|
||||
SLimitVal limit;
|
||||
|
||||
|
@ -187,6 +189,10 @@ typedef struct SQuery {
|
|||
bool timeWindowInterpo;// if the time window start/end required interpolation
|
||||
bool queryBlockDist; // if query data block distribution
|
||||
bool stabledev; // super table stddev query
|
||||
bool tsCompQuery; // is tscomp query
|
||||
bool simpleAgg;
|
||||
bool pointInterpQuery; // point interpolation query
|
||||
bool needReverseScan; // need reverse scan
|
||||
int32_t interBufSize; // intermediate buffer sizse
|
||||
|
||||
SOrderVal order;
|
||||
|
@ -199,7 +205,6 @@ typedef struct SQuery {
|
|||
int16_t precision;
|
||||
int16_t numOfOutput;
|
||||
int16_t fillType;
|
||||
int16_t checkResultBuf; // check if the buffer is full during scan each block
|
||||
|
||||
int32_t srcRowSize; // todo extract struct
|
||||
int32_t resultRowSize;
|
||||
|
@ -438,9 +443,13 @@ int32_t createIndirectQueryFuncExprFromMsg(SQueryTableMsg *pQueryMsg, int32_t nu
|
|||
SSqlGroupbyExpr *createGroupbyExprFromMsg(SQueryTableMsg *pQueryMsg, SColIndex *pColIndex, int32_t *code);
|
||||
SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGroupbyExpr, SExprInfo *pExprs,
|
||||
SExprInfo *pSecExprs, STableGroupInfo *pTableGroupInfo, SColumnInfo* pTagCols, bool stableQuery, char* sql, uint64_t *qId);
|
||||
int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQInfo *pQInfo, SQueryParam* param, bool isSTable);
|
||||
int32_t initQInfo(STsBufInfo* pTsBufInfo, void* tsdb, int32_t vgId, SQInfo* pQInfo, SQueryParam* param, char* start,
|
||||
int32_t prevResultLen, bool isSTable);
|
||||
|
||||
void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters);
|
||||
|
||||
STableQueryInfo *createTableQueryInfo(SQuery* pQuery, void* pTable, bool groupbyColumn, STimeWindow win, void* buf);
|
||||
|
||||
bool isQueryKilled(SQInfo *pQInfo);
|
||||
int32_t checkForQueryBuf(size_t numOfTables);
|
||||
bool doBuildResCheck(SQInfo* pQInfo);
|
||||
|
|
|
@ -163,7 +163,7 @@ static STableIdInfo createTableIdInfo(STableQueryInfo* pTableQueryInfo);
|
|||
static void setTableScanFilterOperatorInfo(STableScanInfo* pTableScanInfo, SOperatorInfo* pDownstream);
|
||||
|
||||
static int32_t getNumOfScanTimes(SQuery* pQuery);
|
||||
static bool isFixedOutputQuery(SQuery* pQuery);
|
||||
//static bool isFixedOutputQuery(SQuery* pQuery);
|
||||
|
||||
static SOperatorInfo* createDataBlocksOptScanInfo(void* pTsdbQueryHandle, SQueryRuntimeEnv* pRuntimeEnv, int32_t repeatTime, int32_t reverseTime);
|
||||
static SOperatorInfo* createTableScanOperator(void* pTsdbQueryHandle, SQueryRuntimeEnv* pRuntimeEnv, int32_t repeatTime);
|
||||
|
@ -1790,8 +1790,8 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
|
|||
if (pQuery->pExpr2 != NULL) {
|
||||
pRuntimeEnv->proot = createArithOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQuery->pExpr2, pQuery->numOfExpr2);
|
||||
}
|
||||
} else if (isFixedOutputQuery(pQuery)) {
|
||||
if (pQuery->stableQuery && !isTsCompQuery(pQuery)) {
|
||||
} else if (pQuery->simpleAgg) {
|
||||
if (pQuery->stableQuery && !pQuery->tsCompQuery) {
|
||||
pRuntimeEnv->proot =
|
||||
createMultiTableAggOperatorInfo(pRuntimeEnv, pRuntimeEnv->pTableScanner, pQuery->pExpr1, pQuery->numOfOutput);
|
||||
} else {
|
||||
|
@ -1805,7 +1805,6 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
|
|||
pRuntimeEnv->proot = createArithOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQuery->pExpr2, pQuery->numOfExpr2);
|
||||
}
|
||||
} else { // diff/add/multiply/subtract/division
|
||||
assert(pQuery->checkResultBuf == 1);
|
||||
if (!onlyQueryTags(pQuery)) {
|
||||
pRuntimeEnv->proot =
|
||||
createArithOperatorInfo(pRuntimeEnv, pRuntimeEnv->pTableScanner, pQuery->pExpr1, pQuery->numOfOutput);
|
||||
|
@ -1905,36 +1904,30 @@ bool isQueryKilled(SQInfo *pQInfo) {
|
|||
|
||||
void setQueryKilled(SQInfo *pQInfo) { pQInfo->code = TSDB_CODE_TSC_QUERY_CANCELLED;}
|
||||
|
||||
static bool isFixedOutputQuery(SQuery* pQuery) {
|
||||
if (QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Note:top/bottom query is fixed output query
|
||||
if (pQuery->topBotQuery || pQuery->groupbyColumn || isTsCompQuery(pQuery)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
||||
SSqlExpr *pExpr = &pQuery->pExpr1[i].base;
|
||||
|
||||
// ignore the ts_comp function
|
||||
if (i == 0 && pExpr->functionId == TSDB_FUNC_PRJ && pExpr->numOfParams == 1 &&
|
||||
pExpr->colInfo.colIndex == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pExpr->functionId == TSDB_FUNC_TS || pExpr->functionId == TSDB_FUNC_TS_DUMMY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!IS_MULTIOUTPUT(aAggs[pExpr->functionId].status)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
//static bool isFixedOutputQuery(SQuery* pQuery) {
|
||||
// if (QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Note:top/bottom query is fixed output query
|
||||
// if (pQuery->topBotQuery || pQuery->groupbyColumn || pQuery->tsCompQuery) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
||||
// SSqlExpr *pExpr = &pQuery->pExpr1[i].base;
|
||||
//
|
||||
// if (pExpr->functionId == TSDB_FUNC_TS || pExpr->functionId == TSDB_FUNC_TS_DUMMY) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (!IS_MULTIOUTPUT(aAggs[pExpr->functionId].status)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
//}
|
||||
|
||||
// todo refactor with isLastRowQuery
|
||||
bool isPointInterpoQuery(SQuery *pQuery) {
|
||||
|
@ -2040,29 +2033,6 @@ void getAlignQueryTimeWindow(SQuery *pQuery, int64_t key, int64_t keyFirst, int6
|
|||
}
|
||||
}
|
||||
|
||||
static void setScanLimitationByResultBuffer(SQuery *pQuery) {
|
||||
if (isTopBottomQuery(pQuery)) {
|
||||
pQuery->checkResultBuf = 0;
|
||||
} else if (isGroupbyColumn(pQuery->pGroupbyExpr)) {
|
||||
pQuery->checkResultBuf = 0;
|
||||
} else {
|
||||
bool hasMultioutput = false;
|
||||
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
||||
SSqlExpr *pExpr = &pQuery->pExpr1[i].base;
|
||||
if (pExpr->functionId == TSDB_FUNC_TS || pExpr->functionId == TSDB_FUNC_TS_DUMMY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
hasMultioutput = IS_MULTIOUTPUT(aAggs[pExpr->functionId].status);
|
||||
if (!hasMultioutput) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pQuery->checkResultBuf = hasMultioutput ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* todo add more parameters to check soon..
|
||||
*/
|
||||
|
@ -3175,7 +3145,7 @@ static bool hasMainOutput(SQuery *pQuery) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static STableQueryInfo *createTableQueryInfo(SQuery* pQuery, void* pTable, bool groupbyColumn, STimeWindow win, void* buf) {
|
||||
STableQueryInfo *createTableQueryInfo(SQuery* pQuery, void* pTable, bool groupbyColumn, STimeWindow win, void* buf) {
|
||||
STableQueryInfo *pTableQueryInfo = buf;
|
||||
|
||||
pTableQueryInfo->win = win;
|
||||
|
@ -3893,8 +3863,8 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery)
|
|||
&& (pRuntimeEnv->tableqinfoGroupInfo.numOfTables == 1)
|
||||
&& (cond.order == TSDB_ORDER_ASC)
|
||||
&& (!QUERY_IS_INTERVAL_QUERY(pQuery))
|
||||
&& (!isGroupbyColumn(pQuery->pGroupbyExpr))
|
||||
&& (!isFixedOutputQuery(pQuery))
|
||||
&& (!pQuery->groupbyColumn)
|
||||
&& (!pQuery->simpleAgg)
|
||||
) {
|
||||
SArray* pa = GET_TABLEGROUP(pRuntimeEnv, 0);
|
||||
STableQueryInfo* pCheckInfo = taosArrayGetP(pa, 0);
|
||||
|
@ -3971,11 +3941,11 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, SArray* prevResult, void *ts
|
|||
pRuntimeEnv->prevResult = prevResult;
|
||||
pRuntimeEnv->qinfo = pQInfo;
|
||||
|
||||
setScanLimitationByResultBuffer(pQuery);
|
||||
|
||||
int32_t code = setupQueryHandle(tsdb, pQInfo, isSTableQuery);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
if (tsdb != NULL) {
|
||||
int32_t code = setupQueryHandle(tsdb, pQInfo, isSTableQuery);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
pQuery->tsdb = tsdb;
|
||||
|
@ -4013,7 +3983,7 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, SArray* prevResult, void *ts
|
|||
getIntermediateBufInfo(pRuntimeEnv, &ps, &pQuery->intermediateResultRowSize);
|
||||
|
||||
int32_t TENMB = 1024*1024*10;
|
||||
code = createDiskbasedResultBuffer(&pRuntimeEnv->pResultBuf, ps, TENMB, pQInfo);
|
||||
int32_t code = createDiskbasedResultBuffer(&pRuntimeEnv->pResultBuf, ps, TENMB, pQInfo);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -4265,6 +4235,7 @@ SOperatorInfo* createTableScanOperator(void* pTsdbQueryHandle, SQueryRuntimeEnv*
|
|||
|
||||
SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
|
||||
pOperator->name = "TableScanOperator";
|
||||
pOperator->operatorType = OP_TableScan;
|
||||
pOperator->blockingOptr = false;
|
||||
pOperator->status = OP_IN_EXECUTING;
|
||||
pOperator->info = pInfo;
|
||||
|
@ -5498,10 +5469,10 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
|
|||
pQueryMsg->numOfOutput = htons(pQueryMsg->numOfOutput);
|
||||
pQueryMsg->numOfGroupCols = htons(pQueryMsg->numOfGroupCols);
|
||||
pQueryMsg->tagCondLen = htons(pQueryMsg->tagCondLen);
|
||||
pQueryMsg->tsOffset = htonl(pQueryMsg->tsOffset);
|
||||
pQueryMsg->tsLen = htonl(pQueryMsg->tsLen);
|
||||
pQueryMsg->tsNumOfBlocks = htonl(pQueryMsg->tsNumOfBlocks);
|
||||
pQueryMsg->tsOrder = htonl(pQueryMsg->tsOrder);
|
||||
pQueryMsg->tsBuf.tsOffset = htonl(pQueryMsg->tsBuf.tsOffset);
|
||||
pQueryMsg->tsBuf.tsLen = htonl(pQueryMsg->tsBuf.tsLen);
|
||||
pQueryMsg->tsBuf.tsNumOfBlocks = htonl(pQueryMsg->tsBuf.tsNumOfBlocks);
|
||||
pQueryMsg->tsBuf.tsOrder = htonl(pQueryMsg->tsBuf.tsOrder);
|
||||
pQueryMsg->numOfTags = htonl(pQueryMsg->numOfTags);
|
||||
pQueryMsg->tbnameCondLen = htonl(pQueryMsg->tbnameCondLen);
|
||||
pQueryMsg->secondStageOutput = htonl(pQueryMsg->secondStageOutput);
|
||||
|
@ -5533,8 +5504,8 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
|
|||
|
||||
int32_t numOfFilters = pColInfo->numOfFilters;
|
||||
if (numOfFilters > 0) {
|
||||
pColInfo->filters = calloc(numOfFilters, sizeof(SColumnFilterInfo));
|
||||
if (pColInfo->filters == NULL) {
|
||||
pColInfo->filterInfo = calloc(numOfFilters, sizeof(SColumnFilterInfo));
|
||||
if (pColInfo->filterInfo == NULL) {
|
||||
code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
goto _cleanup;
|
||||
}
|
||||
|
@ -5543,7 +5514,7 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
|
|||
for (int32_t f = 0; f < numOfFilters; ++f) {
|
||||
SColumnFilterInfo *pFilterMsg = (SColumnFilterInfo *)pMsg;
|
||||
|
||||
SColumnFilterInfo *pColFilter = &pColInfo->filters[f];
|
||||
SColumnFilterInfo *pColFilter = &pColInfo->filterInfo[f];
|
||||
pColFilter->filterstr = htons(pFilterMsg->filterstr);
|
||||
|
||||
pMsg += sizeof(SColumnFilterInfo);
|
||||
|
@ -5756,8 +5727,8 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
|
|||
}
|
||||
|
||||
//skip ts buf
|
||||
if ((pQueryMsg->tsOffset + pQueryMsg->tsLen) > 0) {
|
||||
pMsg = (char *)pQueryMsg + pQueryMsg->tsOffset + pQueryMsg->tsLen;
|
||||
if ((pQueryMsg->tsBuf.tsOffset + pQueryMsg->tsBuf.tsLen) > 0) {
|
||||
pMsg = (char *)pQueryMsg + pQueryMsg->tsBuf.tsOffset + pQueryMsg->tsBuf.tsLen;
|
||||
}
|
||||
|
||||
param->sql = strndup(pMsg, pQueryMsg->sqlstrLen);
|
||||
|
@ -5772,7 +5743,7 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
|
|||
"outputCols:%d, numOfCols:%d, interval:%" PRId64 ", fillType:%d, comptsLen:%d, compNumOfBlocks:%d, limit:%" PRId64 ", offset:%" PRId64,
|
||||
pQueryMsg, pQueryMsg->numOfTables, pQueryMsg->queryType, pQueryMsg->window.skey, pQueryMsg->window.ekey, pQueryMsg->numOfGroupCols,
|
||||
pQueryMsg->order, pQueryMsg->numOfOutput, pQueryMsg->numOfCols, pQueryMsg->interval.interval,
|
||||
pQueryMsg->fillType, pQueryMsg->tsLen, pQueryMsg->tsNumOfBlocks, pQueryMsg->limit, pQueryMsg->offset);
|
||||
pQueryMsg->fillType, pQueryMsg->tsBuf.tsLen, pQueryMsg->tsBuf.tsNumOfBlocks, pQueryMsg->limit, pQueryMsg->offset);
|
||||
|
||||
qDebug("qmsg:%p, sql:%s", pQueryMsg, param->sql);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -6030,7 +6001,7 @@ static int32_t createFilterInfo(void *pQInfo, SQuery *pQuery) {
|
|||
|
||||
for (int32_t f = 0; f < pFilterInfo->numOfFilters; ++f) {
|
||||
SColumnFilterElem *pSingleColFilter = &pFilterInfo->pFilters[f];
|
||||
pSingleColFilter->filterInfo = pQuery->colList[i].filters[f];
|
||||
pSingleColFilter->filterInfo = pQuery->colList[i].filterInfo[f];
|
||||
|
||||
int32_t lower = pSingleColFilter->filterInfo.lowerRelOptr;
|
||||
int32_t upper = pSingleColFilter->filterInfo.upperRelOptr;
|
||||
|
@ -6166,7 +6137,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SSqlGroupbyExpr* pGroupbyExpr
|
|||
pQuery->maxSrcColumnSize = 0;
|
||||
for (int16_t i = 0; i < numOfCols; ++i) {
|
||||
pQuery->colList[i] = pQueryMsg->colList[i];
|
||||
pQuery->colList[i].filters = tFilterInfoDup(pQueryMsg->colList[i].filters, pQuery->colList[i].numOfFilters);
|
||||
pQuery->colList[i].filterInfo = tFilterInfoDup(pQueryMsg->colList[i].filterInfo, pQuery->colList[i].numOfFilters);
|
||||
|
||||
pQuery->srcRowSize += pQuery->colList[i].bytes;
|
||||
if (pQuery->maxSrcColumnSize < pQuery->colList[i].bytes) {
|
||||
|
@ -6309,29 +6280,31 @@ bool isValidQInfo(void *param) {
|
|||
return (sig == (uint64_t)pQInfo);
|
||||
}
|
||||
|
||||
int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQInfo *pQInfo, SQueryParam* param, bool isSTable) {
|
||||
int32_t initQInfo(STsBufInfo* pTsBufInfo, void* tsdb, int32_t vgId, SQInfo* pQInfo, SQueryParam* param, char* start,
|
||||
int32_t prevResultLen, bool isSTable) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv;
|
||||
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
|
||||
|
||||
STSBuf *pTsBuf = NULL;
|
||||
if (pQueryMsg->tsLen > 0) { // open new file to save the result
|
||||
char *tsBlock = (char *) pQueryMsg + pQueryMsg->tsOffset;
|
||||
pTsBuf = tsBufCreateFromCompBlocks(tsBlock, pQueryMsg->tsNumOfBlocks, pQueryMsg->tsLen, pQueryMsg->tsOrder, vgId);
|
||||
if (pTsBufInfo->tsLen > 0) { // open new file to save the result
|
||||
char *tsBlock = start + pTsBufInfo->tsOffset;
|
||||
pTsBuf = tsBufCreateFromCompBlocks(tsBlock, pTsBufInfo->tsNumOfBlocks, pTsBufInfo->tsLen, pTsBufInfo->tsOrder, vgId);
|
||||
|
||||
tsBufResetPos(pTsBuf);
|
||||
bool ret = tsBufNextPos(pTsBuf);
|
||||
|
||||
UNUSED(ret);
|
||||
}
|
||||
|
||||
SArray* prevResult = NULL;
|
||||
if (pQueryMsg->prevResultLen > 0) {
|
||||
prevResult = interResFromBinary(param->prevResult, pQueryMsg->prevResultLen);
|
||||
if (prevResultLen > 0) {
|
||||
prevResult = interResFromBinary(param->prevResult, prevResultLen);
|
||||
}
|
||||
|
||||
pQuery->precision = tsdbGetCfg(tsdb)->precision;
|
||||
if (tsdb != NULL) {
|
||||
pQuery->precision = tsdbGetCfg(tsdb)->precision;
|
||||
}
|
||||
|
||||
if ((QUERY_IS_ASC_QUERY(pQuery) && (pQuery->window.skey > pQuery->window.ekey)) ||
|
||||
(!QUERY_IS_ASC_QUERY(pQuery) && (pQuery->window.ekey > pQuery->window.skey))) {
|
||||
|
@ -6449,7 +6422,7 @@ void freeQInfo(SQInfo *pQInfo) {
|
|||
if (pQuery->colList != NULL) {
|
||||
for (int32_t i = 0; i < pQuery->numOfCols; i++) {
|
||||
SColumnInfo *column = pQuery->colList + i;
|
||||
freeColumnFilterInfo(column->filters, column->numOfFilters);
|
||||
freeColumnFilterInfo(column->filterInfo, column->numOfFilters);
|
||||
}
|
||||
tfree(pQuery->colList);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,99 @@
|
|||
|
||||
#include "os.h"
|
||||
#include "tsclient.h"
|
||||
#include "qUtil.h"
|
||||
#include "texpr.h"
|
||||
|
||||
UNUSED_FUNC SArray* createTableScanPlan(SQuery* pQuery) {
|
||||
SArray* plan = taosArrayInit(4, sizeof(int32_t));
|
||||
|
||||
int32_t op = 0;
|
||||
if (onlyQueryTags(pQuery)) {
|
||||
// op = OP_TagScan;
|
||||
} else if (pQuery->queryBlockDist) {
|
||||
op = OP_TableBlockInfoScan;
|
||||
} else if (pQuery->tsCompQuery || pQuery->pointInterpQuery) {
|
||||
op = OP_TableSeqScan;
|
||||
} else if (pQuery->needReverseScan) {
|
||||
op = OP_DataBlocksOptScan;
|
||||
} else {
|
||||
op = OP_TableScan;
|
||||
}
|
||||
|
||||
taosArrayPush(plan, &op);
|
||||
return plan;
|
||||
}
|
||||
|
||||
UNUSED_FUNC SArray* createExecOperatorPlan(SQuery* pQuery) {
|
||||
SArray* plan = taosArrayInit(4, sizeof(int32_t));
|
||||
int32_t op = 0;
|
||||
|
||||
if (onlyQueryTags(pQuery)) { // do nothing for tags query
|
||||
op = OP_TagScan;
|
||||
taosArrayPush(plan, &op);
|
||||
} else if (pQuery->interval.interval > 0) {
|
||||
if (pQuery->stableQuery) {
|
||||
op = OP_MultiTableTimeInterval;
|
||||
taosArrayPush(plan, &op);
|
||||
} else {
|
||||
op = OP_TimeWindow;
|
||||
taosArrayPush(plan, &op);
|
||||
|
||||
if (pQuery->pExpr2 != NULL) {
|
||||
op = OP_Arithmetic;
|
||||
taosArrayPush(plan, &op);
|
||||
}
|
||||
|
||||
if (pQuery->fillType != TSDB_FILL_NONE && (!pQuery->pointInterpQuery)) {
|
||||
op = OP_Fill;
|
||||
taosArrayPush(plan, &op);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (pQuery->groupbyColumn) {
|
||||
op = OP_Groupby;
|
||||
taosArrayPush(plan, &op);
|
||||
|
||||
if (pQuery->pExpr2 != NULL) {
|
||||
op = OP_Arithmetic;
|
||||
taosArrayPush(plan, &op);
|
||||
}
|
||||
} else if (pQuery->sw.gap > 0) {
|
||||
op = OP_SessionWindow;
|
||||
taosArrayPush(plan, &op);
|
||||
|
||||
if (pQuery->pExpr2 != NULL) {
|
||||
op = OP_Arithmetic;
|
||||
taosArrayPush(plan, &op);
|
||||
}
|
||||
} else if (pQuery->simpleAgg) {
|
||||
if (pQuery->stableQuery && !pQuery->tsCompQuery) {
|
||||
op = OP_MultiTableAggregate;
|
||||
} else {
|
||||
op = OP_Aggregate;
|
||||
}
|
||||
|
||||
taosArrayPush(plan, &op);
|
||||
|
||||
if (pQuery->pExpr2 != NULL && !pQuery->stableQuery) {
|
||||
op = OP_Arithmetic;
|
||||
taosArrayPush(plan, &op);
|
||||
}
|
||||
} else { // diff/add/multiply/subtract/division
|
||||
op = OP_Arithmetic;
|
||||
taosArrayPush(plan, &op);
|
||||
}
|
||||
|
||||
if (pQuery->limit.offset > 0) {
|
||||
op = OP_Offset;
|
||||
taosArrayPush(plan, &op);
|
||||
}
|
||||
|
||||
if (pQuery->limit.limit > 0) {
|
||||
op = OP_Limit;
|
||||
taosArrayPush(plan, &op);
|
||||
}
|
||||
|
||||
return plan;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi
|
|||
goto _over;
|
||||
}
|
||||
|
||||
code = initQInfo(pQueryMsg, tsdb, vgId, *pQInfo, ¶m, isSTableQuery);
|
||||
code = initQInfo(&pQueryMsg->tsBuf, tsdb, vgId, *pQInfo, ¶m, (char*)pQueryMsg, pQueryMsg->prevResultLen, isSTableQuery);
|
||||
|
||||
_over:
|
||||
if (param.pGroupbyExpr != NULL) {
|
||||
|
@ -184,7 +184,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi
|
|||
|
||||
for (int32_t i = 0; i < pQueryMsg->numOfCols; i++) {
|
||||
SColumnInfo* column = pQueryMsg->colList + i;
|
||||
freeColumnFilterInfo(column->filters, column->numOfFilters);
|
||||
freeColumnFilterInfo(column->filterInfo, column->numOfFilters);
|
||||
}
|
||||
|
||||
//pQInfo already freed in initQInfo, but *pQInfo may not pointer to null;
|
||||
|
|
Loading…
Reference in New Issue