| 288 | } |
| 289 | |
| 290 | int DsqlCursor::fetchFromCache(thread_db* tdbb, UCHAR* buffer, FB_UINT64 position) |
| 291 | { |
| 292 | if (position >= m_cachedCount) |
| 293 | { |
| 294 | if (m_eof || !cacheInput(tdbb, position)) |
| 295 | { |
| 296 | m_state = EOS; |
| 297 | return 1; |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | fb_assert(position < m_cachedCount); |
| 302 | |
| 303 | UCHAR* const msgBuffer = m_dsqlRequest->req_msg_buffers[m_message->msg_buffer_number]; |
| 304 | |
| 305 | const FB_UINT64 offset = position * m_message->msg_length; |
| 306 | const FB_UINT64 readBytes = m_space.read(offset, msgBuffer, m_message->msg_length); |
| 307 | fb_assert(readBytes == m_message->msg_length); |
| 308 | |
| 309 | m_dsqlRequest->mapInOut(tdbb, true, m_message, NULL, buffer); |
| 310 | |
| 311 | m_position = position; |
| 312 | m_state = POSITIONED; |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | bool DsqlCursor::cacheInput(thread_db* tdbb, FB_UINT64 position) |
| 317 | { |