fix M-SQL select data disorder from queue
parent
acd4542b0c
commit
66ac81d29b
71
src/tree.c
71
src/tree.c
|
@ -6924,6 +6924,38 @@ long _lFetchGroup(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
|||
return RC_NOTFOUND;
|
||||
}
|
||||
|
||||
/*************************************************************************************************
|
||||
description:Queue-fetch the data as truck
|
||||
parameters:
|
||||
pstSavm --stvm handle
|
||||
pstRun --table handle
|
||||
t --table
|
||||
psvout --result data
|
||||
return:
|
||||
RC_SUCC --success
|
||||
RC_FAIL --failure
|
||||
*************************************************************************************************/
|
||||
long _lFetchQueue(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
||||
{
|
||||
SHTruck *pstTruck = NULL;
|
||||
TblDef *pv = (TblDef *)pstRun->m_pvAddr;
|
||||
size_t lOffset = lGetListOfs(t) + pstRun->m_lCurLine;
|
||||
|
||||
for(; pstRun->m_lCurLine <= pv->m_lMaxRow; pstRun->m_lCurLine ++)
|
||||
{
|
||||
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr,
|
||||
pv->m_lData + pv->m_lTruck * (lOffset % pv->m_lMaxRow));
|
||||
if(IS_TRUCK_NULL(pstTruck))
|
||||
continue;
|
||||
|
||||
pstRun->m_lCurLine ++;
|
||||
memcpy(psvOut, pstTruck->m_pvData, pv->m_lReSize);
|
||||
return RC_SUCC;
|
||||
}
|
||||
|
||||
return RC_NOTFOUND;
|
||||
}
|
||||
|
||||
/*************************************************************************************************
|
||||
description:Cursor-fetch the data as truck
|
||||
parameters:
|
||||
|
@ -7105,8 +7137,13 @@ long lTableFetch(SATvm *pstSavm, void *psvOut)
|
|||
lRet = _lFetchIndex(pstSavm, pstRun, pstSavm->tblName, psvOut);
|
||||
else if(EXE_PLAN_GRP == pstRun->m_lCurType)
|
||||
lRet = _lFetchGroup(pstSavm, pstRun, pstSavm->tblName, psvOut);
|
||||
else
|
||||
{
|
||||
if(TYPE_MQUEUE == pstRun->m_lType)
|
||||
lRet = _lFetchQueue(pstSavm, pstRun, pstSavm->tblName, psvOut);
|
||||
else
|
||||
lRet = _lFetchTruck(pstSavm, pstRun, pstSavm->tblName, psvOut);
|
||||
}
|
||||
if(RC_NOTFOUND == lRet)
|
||||
{
|
||||
pstRun->m_pvCurAddr = NULL;
|
||||
|
@ -9312,37 +9349,6 @@ long lImportTable(TABLE t, size_t lCount, void *psvData)
|
|||
return lRet;
|
||||
}
|
||||
|
||||
/*************************************************************************************************
|
||||
description:Queue-fetch the data as truck
|
||||
parameters:
|
||||
pstSavm --stvm handle
|
||||
pstRun --table handle
|
||||
t --table
|
||||
psvout --result data
|
||||
return:
|
||||
RC_SUCC --success
|
||||
RC_FAIL --failure
|
||||
*************************************************************************************************/
|
||||
long _lFetchQueue(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
||||
{
|
||||
SHTruck *pstTruck = NULL;
|
||||
TblDef *pv = (TblDef *)pstRun->m_pvAddr;
|
||||
size_t lRow, lOffset = pv->m_lListOfs + 1;
|
||||
|
||||
for(; pstRun->m_lCurLine <= pv->m_lMaxRow; lOffset ++, pstRun->m_lCurLine ++)
|
||||
{
|
||||
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr,
|
||||
pv->m_lData + pv->m_lTruck * (lOffset % pv->m_lMaxRow));
|
||||
if(IS_TRUCK_NULL(pstTruck))
|
||||
continue;
|
||||
|
||||
memcpy(psvOut, pstTruck->m_pvData, pv->m_lReSize);
|
||||
return RC_SUCC;
|
||||
}
|
||||
|
||||
return RC_NOTFOUND;
|
||||
}
|
||||
|
||||
/*************************************************************************************************
|
||||
description:Export the memory table to a file
|
||||
parameters:
|
||||
|
@ -9404,6 +9410,9 @@ long lExportFile(TABLE t, char *pszFile, char *pszFlag)
|
|||
{
|
||||
while(RC_NOTFOUND != _lFetchQueue(pstSavm, pstRun, t, psvOut))
|
||||
{
|
||||
if(lGetFldNum(t) > 0)
|
||||
_lExportContext(fp, psvOut, lGetFldNum(t), pGetTblKey(t), pszFlag);
|
||||
else
|
||||
fwrite(psvOut, 1, lGetRowSize(t), fp);
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue