Drizzled Public API Documentation

mi_rrnd.cc
00001 /* Copyright (C) 2000-2002, 2004 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 /* Read a record with random-access. The position to the record must
00017    get by MI_INFO. The next record can be read with pos= MI_POS_ERROR */
00018 
00019 
00020 #include "myisam_priv.h"
00021 
00022 using namespace drizzled;
00023 
00024 /*
00025      Read a row based on position.
00026      If filepos= HA_OFFSET_ERROR then read next row
00027      Return values
00028      Returns one of following values:
00029      0 = Ok.
00030      HA_ERR_RECORD_DELETED = Record is deleted.
00031      HA_ERR_END_OF_FILE = EOF.
00032 */
00033 
00034 int mi_rrnd(MI_INFO *info, unsigned char *buf, register internal::my_off_t filepos)
00035 {
00036   bool skip_deleted_blocks;
00037 
00038   skip_deleted_blocks=0;
00039 
00040   if (filepos == HA_OFFSET_ERROR)
00041   {
00042     skip_deleted_blocks=1;
00043     if (info->lastpos == HA_OFFSET_ERROR) /* First read ? */
00044       filepos= info->s->pack.header_length; /* Read first record */
00045     else
00046       filepos= info->nextpos;
00047   }
00048 
00049   if (info->once_flags & RRND_PRESERVE_LASTINX)
00050     info->once_flags&= ~RRND_PRESERVE_LASTINX;
00051   else
00052     info->lastinx= -1;                          /* Can't forward or backward */
00053   /* Init all but update-flag */
00054   info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
00055 
00056   if (info->opt_flag & WRITE_CACHE_USED && flush_io_cache(&info->rec_cache))
00057     return(errno);
00058 
00059   return ((*info->s->read_rnd)(info,buf,filepos,skip_deleted_blocks));
00060 }