[td-225] update the intermediate result size
This commit is contained in:
parent
87c5f7ca54
commit
c454def8b7
|
@ -84,7 +84,7 @@ typedef struct SSqlExpr {
|
|||
int16_t functionId; // function id in aAgg array
|
||||
int16_t resType; // return value type
|
||||
int16_t resBytes; // length of return value
|
||||
int16_t interBytes; // inter result buffer size
|
||||
int32_t interBytes; // inter result buffer size
|
||||
int16_t numOfParams; // argument value of each function
|
||||
tVariant param[3]; // parameters are not more than 3
|
||||
int32_t offset; // sub result column value of arithmetic expression.
|
||||
|
|
|
@ -153,7 +153,7 @@ typedef struct SRateInfo {
|
|||
|
||||
|
||||
int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, int16_t *type,
|
||||
int16_t *bytes, int16_t *interBytes, int16_t extLength, bool isSuperTable) {
|
||||
int16_t *bytes, int32_t *interBytes, int16_t extLength, bool isSuperTable) {
|
||||
if (!isValidDataType(dataType, dataBytes)) {
|
||||
tscError("Illegal data type %d or data type length %d", dataType, dataBytes);
|
||||
return TSDB_CODE_INVALID_SQL;
|
||||
|
|
|
@ -1594,7 +1594,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
|
|||
|
||||
int16_t resultType = 0;
|
||||
int16_t resultSize = 0;
|
||||
int16_t intermediateResSize = 0;
|
||||
int32_t intermediateResSize = 0;
|
||||
|
||||
int16_t functionID = 0;
|
||||
if (changeFunctionID(optr, &functionID) != TSDB_CODE_SUCCESS) {
|
||||
|
@ -1901,7 +1901,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
|
|||
|
||||
int16_t bytes = 0;
|
||||
int16_t type = 0;
|
||||
int16_t inter = 0;
|
||||
int32_t inter = 0;
|
||||
|
||||
int32_t ret = getResultDataInfo(s.type, s.bytes, TSDB_FUNC_TID_TAG, 0, &type, &bytes, &inter, 0, 0);
|
||||
assert(ret == TSDB_CODE_SUCCESS);
|
||||
|
@ -2287,7 +2287,7 @@ int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
|||
|
||||
int16_t bytes = 0;
|
||||
int16_t type = 0;
|
||||
int16_t intermediateBytes = 0;
|
||||
int32_t interBytes = 0;
|
||||
|
||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
for (int32_t k = 0; k < size; ++k) {
|
||||
|
@ -2301,13 +2301,13 @@ int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
|||
(functionId >= TSDB_FUNC_FIRST_DST && functionId <= TSDB_FUNC_LAST_DST) ||
|
||||
(functionId >= TSDB_FUNC_RATE && functionId <= TSDB_FUNC_AVG_IRATE)) {
|
||||
if (getResultDataInfo(pSrcSchema->type, pSrcSchema->bytes, functionId, pExpr->param[0].i64Key, &type, &bytes,
|
||||
&intermediateBytes, 0, true) != TSDB_CODE_SUCCESS) {
|
||||
&interBytes, 0, true) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_INVALID_SQL;
|
||||
}
|
||||
|
||||
tscSqlExprUpdate(pQueryInfo, k, functionId, pExpr->colInfo.colIndex, TSDB_DATA_TYPE_BINARY, bytes);
|
||||
// todo refactor
|
||||
pExpr->interBytes = intermediateBytes;
|
||||
pExpr->interBytes = interBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2327,27 +2327,23 @@ void tscRestoreSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
|||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pExpr->colInfo.colIndex);
|
||||
|
||||
// if (/*(pExpr->functionId >= TSDB_FUNC_FIRST_DST && pExpr->functionId <= TSDB_FUNC_LAST_DST) ||
|
||||
// (pExpr->functionId >= TSDB_FUNC_SUM && pExpr->functionId <= TSDB_FUNC_MAX) ||
|
||||
// pExpr->functionId == TSDB_FUNC_LAST_ROW*/) {
|
||||
// the final result size and type in the same as query on single table.
|
||||
// so here, set the flag to be false;
|
||||
int16_t inter = 0;
|
||||
|
||||
int32_t functionId = pExpr->functionId;
|
||||
if (functionId >= TSDB_FUNC_TS && functionId <= TSDB_FUNC_DIFF) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (functionId == TSDB_FUNC_FIRST_DST) {
|
||||
functionId = TSDB_FUNC_FIRST;
|
||||
} else if (functionId == TSDB_FUNC_LAST_DST) {
|
||||
functionId = TSDB_FUNC_LAST;
|
||||
}
|
||||
|
||||
getResultDataInfo(pSchema->type, pSchema->bytes, functionId, 0, &pExpr->resType, &pExpr->resBytes,
|
||||
&inter, 0, false);
|
||||
// }
|
||||
// the final result size and type in the same as query on single table.
|
||||
// so here, set the flag to be false;
|
||||
int32_t inter = 0;
|
||||
|
||||
int32_t functionId = pExpr->functionId;
|
||||
if (functionId >= TSDB_FUNC_TS && functionId <= TSDB_FUNC_DIFF) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (functionId == TSDB_FUNC_FIRST_DST) {
|
||||
functionId = TSDB_FUNC_FIRST;
|
||||
} else if (functionId == TSDB_FUNC_LAST_DST) {
|
||||
functionId = TSDB_FUNC_LAST;
|
||||
}
|
||||
|
||||
getResultDataInfo(pSchema->type, pSchema->bytes, functionId, 0, &pExpr->resType, &pExpr->resBytes,
|
||||
&inter, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -689,7 +689,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
|
||||
SSchema *p1 = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pExpr->colInfo.colIndex);
|
||||
|
||||
int16_t inter = 0;
|
||||
int32_t inter = 0;
|
||||
int16_t type = -1;
|
||||
int16_t bytes = 0;
|
||||
|
||||
|
|
|
@ -1084,7 +1084,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
|||
|
||||
int16_t bytes = 0;
|
||||
int16_t type = 0;
|
||||
int16_t inter = 0;
|
||||
int32_t inter = 0;
|
||||
|
||||
getResultDataInfo(s.type, s.bytes, TSDB_FUNC_TID_TAG, 0, &type, &bytes, &inter, 0, 0);
|
||||
|
||||
|
|
|
@ -370,7 +370,7 @@ typedef struct SExprInfo {
|
|||
struct tExprNode* pExpr;
|
||||
int16_t bytes;
|
||||
int16_t type;
|
||||
int16_t interBytes;
|
||||
int32_t interBytes;
|
||||
} SExprInfo;
|
||||
|
||||
typedef struct SColumnFilterInfo {
|
||||
|
|
|
@ -217,7 +217,7 @@ typedef struct SQLAggFuncElem {
|
|||
#define GET_RES_INFO(ctx) ((ctx)->resultInfo)
|
||||
|
||||
int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, int16_t *type,
|
||||
int16_t *len, int16_t *interBytes, int16_t extLength, bool isSuperTable);
|
||||
int16_t *len, int32_t *interBytes, int16_t extLength, bool isSuperTable);
|
||||
|
||||
#define IS_STREAM_QUERY_VALID(x) (((x)&TSDB_FUNCSTATE_STREAM) != 0)
|
||||
#define IS_MULTIOUTPUT(x) (((x)&TSDB_FUNCSTATE_MO) != 0)
|
||||
|
|
Loading…
Reference in New Issue