[TD-225]
This commit is contained in:
parent
bc8fb310b4
commit
a29327ef42
|
@ -884,11 +884,11 @@ static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer,
|
||||||
tFilePage * pBeforeFillData = pLocalReducer->pResultBuf;
|
tFilePage * pBeforeFillData = pLocalReducer->pResultBuf;
|
||||||
|
|
||||||
pRes->data = pLocalReducer->pFinalRes;
|
pRes->data = pLocalReducer->pFinalRes;
|
||||||
pRes->numOfRows = pBeforeFillData->num;
|
pRes->numOfRows = (int32_t) pBeforeFillData->num;
|
||||||
|
|
||||||
if (pQueryInfo->limit.offset > 0) {
|
if (pQueryInfo->limit.offset > 0) {
|
||||||
if (pQueryInfo->limit.offset < pRes->numOfRows) {
|
if (pQueryInfo->limit.offset < pRes->numOfRows) {
|
||||||
int32_t prevSize = (int32_t)pBeforeFillData->num;
|
int32_t prevSize = (int32_t) pBeforeFillData->num;
|
||||||
tColModelErase(pLocalReducer->finalModel, pBeforeFillData, prevSize, 0, (int32_t)pQueryInfo->limit.offset - 1);
|
tColModelErase(pLocalReducer->finalModel, pBeforeFillData, prevSize, 0, (int32_t)pQueryInfo->limit.offset - 1);
|
||||||
|
|
||||||
/* remove the hole in column model */
|
/* remove the hole in column model */
|
||||||
|
|
|
@ -394,7 +394,7 @@ int taos_affected_rows(TAOS_RES *tres) {
|
||||||
SSqlObj* pSql = (SSqlObj*) tres;
|
SSqlObj* pSql = (SSqlObj*) tres;
|
||||||
if (pSql == NULL || pSql->signature != pSql) return 0;
|
if (pSql == NULL || pSql->signature != pSql) return 0;
|
||||||
|
|
||||||
return (int)(pSql->res.numOfRows);
|
return pSql->res.numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
||||||
|
@ -440,53 +440,12 @@ int taos_retrieve(TAOS_RES *res) {
|
||||||
|
|
||||||
tscResetForNextRetrieve(pRes);
|
tscResetForNextRetrieve(pRes);
|
||||||
|
|
||||||
if (pCmd->command < TSDB_SQL_LOCAL) {
|
|
||||||
pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
|
|
||||||
}
|
|
||||||
tscProcessSql(pSql);
|
|
||||||
|
|
||||||
return (int)pRes->numOfRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) {
|
|
||||||
SSqlObj *pSql = (SSqlObj *)res;
|
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
|
||||||
SSqlRes *pRes = &pSql->res;
|
|
||||||
|
|
||||||
if (pRes->qhandle == 0 || pSql->signature != pSql) {
|
|
||||||
*rows = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve new block
|
|
||||||
tscResetForNextRetrieve(pRes);
|
|
||||||
if (pCmd->command < TSDB_SQL_LOCAL) {
|
if (pCmd->command < TSDB_SQL_LOCAL) {
|
||||||
pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
|
pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscProcessSql(pSql);
|
tscProcessSql(pSql);
|
||||||
if (pRes->numOfRows == 0) {
|
return pRes->numOfRows;
|
||||||
*rows = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// secondary merge has handle this situation
|
|
||||||
if (pCmd->command != TSDB_SQL_RETRIEVE_LOCALMERGE) {
|
|
||||||
pRes->numOfClauseTotal += pRes->numOfRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
|
||||||
if (pQueryInfo == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
assert(0);
|
|
||||||
for (int i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
|
||||||
tscGetResultColumnChr(pRes, &pQueryInfo->fieldsInfo, i, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
*rows = pRes->tsrow;
|
|
||||||
|
|
||||||
return (int)((pQueryInfo->order.order == TSDB_ORDER_DESC) ? pRes->numOfRows : -pRes->numOfRows);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool needToFetchNewBlock(SSqlObj* pSql) {
|
static bool needToFetchNewBlock(SSqlObj* pSql) {
|
||||||
|
@ -573,7 +532,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
|
||||||
*rows = pRes->urow;
|
*rows = pRes->urow;
|
||||||
|
|
||||||
tscClearSqlOwner(pSql);
|
tscClearSqlOwner(pSql);
|
||||||
return (int32_t) pRes->numOfRows;
|
return pRes->numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_select_db(TAOS *taos, const char *db) {
|
int taos_select_db(TAOS *taos, const char *db) {
|
||||||
|
|
|
@ -948,7 +948,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
||||||
if (!pRes->completed) {
|
if (!pRes->completed) {
|
||||||
taosGetTmpfilePath("ts-join", pSupporter->path);
|
taosGetTmpfilePath("ts-join", pSupporter->path);
|
||||||
pSupporter->f = fopen(pSupporter->path, "w");
|
pSupporter->f = fopen(pSupporter->path, "w");
|
||||||
pRes->row = (int32_t)pRes->numOfRows;
|
pRes->row = pRes->numOfRows;
|
||||||
|
|
||||||
taos_fetch_rows_a(tres, tsCompRetrieveCallback, param);
|
taos_fetch_rows_a(tres, tsCompRetrieveCallback, param);
|
||||||
return;
|
return;
|
||||||
|
@ -974,7 +974,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
||||||
|
|
||||||
// TODO check for failure
|
// TODO check for failure
|
||||||
pSupporter->f = fopen(pSupporter->path, "w");
|
pSupporter->f = fopen(pSupporter->path, "w");
|
||||||
pRes->row = (int32_t)pRes->numOfRows;
|
pRes->row = pRes->numOfRows;
|
||||||
|
|
||||||
// set the callback function
|
// set the callback function
|
||||||
pSql->fp = tscJoinQueryCallback;
|
pSql->fp = tscJoinQueryCallback;
|
||||||
|
@ -2059,7 +2059,7 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = saveToBuffer(trsupport->pExtMemBuffer[idx], pDesc, trsupport->localBuffer, pRes->data,
|
int32_t ret = saveToBuffer(trsupport->pExtMemBuffer[idx], pDesc, trsupport->localBuffer, pRes->data,
|
||||||
(int32_t)pRes->numOfRows, pQueryInfo->groupbyExpr.orderType);
|
pRes->numOfRows, pQueryInfo->groupbyExpr.orderType);
|
||||||
if (ret != 0) { // set no disk space error info, and abort retry
|
if (ret != 0) { // set no disk space error info, and abort retry
|
||||||
tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_NO_DISKSPACE);
|
tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_NO_DISKSPACE);
|
||||||
} else if (pRes->completed) {
|
} else if (pRes->completed) {
|
||||||
|
|
Loading…
Reference in New Issue