[td-225]refactor code.
This commit is contained in:
parent
bc39673ca6
commit
d54ea3c297
|
@ -327,7 +327,6 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
|
|||
pMerger->pCtx = (SQLFunctionCtx *)calloc(tscSqlExprNumOfExprs(pQueryInfo), sizeof(SQLFunctionCtx));
|
||||
pMerger->rowSize = pMemBuffer[0]->nElemSize;
|
||||
|
||||
// tscRestoreFuncForSTableQuery(pQueryInfo);
|
||||
tscFieldInfoUpdateOffset(pQueryInfo);
|
||||
|
||||
if (pMerger->rowSize > pMemBuffer[0]->pageSize) {
|
||||
|
|
|
@ -3379,9 +3379,9 @@ static int32_t getColumnQueryCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSq
|
|||
static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pExpr) {
|
||||
int32_t code = 0;
|
||||
const char* msg1 = "timestamp required for join tables";
|
||||
const char* msg2 = "only support one join tag for each table";
|
||||
const char* msg3 = "type of join columns must be identical";
|
||||
const char* msg4 = "invalid column name in join condition";
|
||||
const char* msg5 = "only support one join tag for each table";
|
||||
|
||||
if (pExpr == NULL) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -3415,11 +3415,14 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
|
|||
(*leftNode)->tagColId = pTagSchema1->colId;
|
||||
|
||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
||||
|
||||
index.columnIndex = index.columnIndex - tscGetNumOfColumns(pTableMetaInfo->pTableMeta);
|
||||
if (!tscColumnExists(pTableMetaInfo->tagColList, index.columnIndex, pTableMetaInfo->pTableMeta->id.uid)) {
|
||||
// tscColumnListInsert(pTableMetaInfo->tagColList, &index, );
|
||||
tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMeta->id.uid, pTagSchema1);
|
||||
|
||||
if (taosArrayGetSize(pTableMetaInfo->tagColList) > 1) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg5);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3451,7 +3454,7 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
|
|||
|
||||
tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMeta->id.uid, pTagSchema2);
|
||||
if (taosArrayGetSize(pTableMetaInfo->tagColList) > 1) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg5);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -604,7 +604,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
|||
* during the timestamp intersection.
|
||||
*/
|
||||
pSupporter->limit = pQueryInfo->limit;
|
||||
pQueryInfo->limit = pSupporter->limit;
|
||||
// pQueryInfo->limit = pSupporter->limit;
|
||||
|
||||
SColumnIndex index = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||
SSchema* s = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, 0);
|
||||
|
@ -3239,9 +3239,11 @@ static char* getResultBlockPosition(SSqlCmd* pCmd, SSqlRes* pRes, int32_t column
|
|||
assert(pInfo->pExpr->pExpr == NULL);
|
||||
|
||||
*bytes = pInfo->pExpr->base.resBytes;
|
||||
char* pData = pRes->data + pInfo->pExpr->base.offset * pRes->numOfRows + pRes->row * (*bytes);
|
||||
|
||||
return pData;
|
||||
if (pRes->data != NULL) {
|
||||
return pRes->data + pInfo->pExpr->base.offset * pRes->numOfRows + pRes->row * (*bytes);
|
||||
} else {
|
||||
return pRes->urow[columnIndex] + pRes->row * (*bytes);
|
||||
}
|
||||
}
|
||||
|
||||
static void doBuildResFromSubqueries(SSqlObj* pSql) {
|
||||
|
@ -3265,6 +3267,7 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) {
|
|||
return;
|
||||
}
|
||||
|
||||
tscRestoreFuncForSTableQuery(pQueryInfo);
|
||||
int32_t rowSize = tscGetResRowLength(pQueryInfo->exprList);
|
||||
|
||||
assert(numOfRes * rowSize > 0);
|
||||
|
@ -3284,6 +3287,19 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) {
|
|||
|
||||
int16_t bytes = 0;
|
||||
|
||||
tscRestoreFuncForSTableQuery(pQueryInfo);
|
||||
tscFieldInfoUpdateOffset(pQueryInfo);
|
||||
for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) {
|
||||
SSqlObj* pSub = pSql->pSubs[i];
|
||||
if (pSub == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SQueryInfo* pSubQueryInfo = pSub->cmd.pQueryInfo[0];
|
||||
tscRestoreFuncForSTableQuery(pSubQueryInfo);
|
||||
tscFieldInfoUpdateOffset(pSubQueryInfo);
|
||||
}
|
||||
|
||||
size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
for(int32_t i = 0; i < numOfExprs; ++i) {
|
||||
SColumnIndex* pIndex = &pRes->pColumnIndex[i];
|
||||
|
|
|
@ -2353,7 +2353,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, SName* name, STableM
|
|||
}
|
||||
|
||||
if (pTagCols != NULL) {
|
||||
tscColumnListCopy(pTableMetaInfo->tagColList, pTagCols, -1);
|
||||
tscColumnListCopy(pTableMetaInfo->tagColList, pTagCols, pTableMetaInfo->pTableMeta->id.uid);
|
||||
}
|
||||
|
||||
pTableMetaInfo->pVgroupTables = tscVgroupTableInfoDup(pVgroupTables);
|
||||
|
@ -2584,8 +2584,9 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
|
|||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
}
|
||||
|
||||
tscColumnListCopy(pNewQueryInfo->colList, pQueryInfo->colList, (int16_t)tableIndex);
|
||||
|
||||
uint64_t uid = pTableMetaInfo->pTableMeta->id.uid;
|
||||
tscColumnListCopy(pNewQueryInfo->colList, pQueryInfo->colList, uid);
|
||||
|
||||
// set the correct query type
|
||||
if (pPrevSql != NULL) {
|
||||
|
@ -2595,7 +2596,6 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
|
|||
TSDB_QUERY_SET_TYPE(pNewQueryInfo->type, TSDB_QUERY_TYPE_SUBQUERY);// it must be the subquery
|
||||
}
|
||||
|
||||
uint64_t uid = pTableMetaInfo->pTableMeta->id.uid;
|
||||
if (tscSqlExprCopy(pNewQueryInfo->exprList, pQueryInfo->exprList, uid, true) != 0) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
|
|
Loading…
Reference in New Issue