home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 January / Chip_2001-01_cd1.bin / tema / mysql / mysql-3.23.28g-win-source.exe / myisam / mi_rrnd.c < prev    next >
C/C++ Source or Header  |  2000-08-31  |  2KB  |  58 lines

  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2.    
  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 2 of the License, or
  6.    (at your option) any later version.
  7.    
  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.
  12.    
  13.    You should have received a copy of the GNU General Public License
  14.    along with this program; if not, write to the Free Software
  15.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  16.  
  17. /* Read a record with random-access. The position to the record must
  18.    get by MI_INFO. The next record can be read with pos= MI_POS_ERROR */
  19.  
  20.  
  21. #include "myisamdef.h"
  22.  
  23. /*
  24.        Read a row based on position.
  25.        If filepos= HA_OFFSET_ERROR then read next row
  26.        Return values
  27.        Returns one of following values:
  28.        0 = Ok.
  29.        HA_ERR_RECORD_DELETED = Record is deleted.
  30.        HA_ERR_END_OF_FILE = EOF.
  31. */
  32.  
  33. int mi_rrnd(MI_INFO *info, byte *buf, register my_off_t filepos)
  34. {
  35.   my_bool skipp_deleted_blocks;
  36.   DBUG_ENTER("mi_rrnd");
  37.  
  38.   skipp_deleted_blocks=0;
  39.  
  40.   if (filepos == HA_OFFSET_ERROR)
  41.   {
  42.     skipp_deleted_blocks=1;
  43.     if (info->lastpos == HA_OFFSET_ERROR)    /* First read ? */
  44.       filepos= info->s->pack.header_length;    /* Read first record */
  45.     else
  46.       filepos= info->nextpos;
  47.   }
  48.  
  49.   info->lastinx= -1;                /* Can't forward or backward */
  50.   /* Init all but update-flag */
  51.   info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
  52.  
  53.   if (info->opt_flag & WRITE_CACHE_USED && flush_io_cache(&info->rec_cache))
  54.     DBUG_RETURN(my_errno);
  55.  
  56.   DBUG_RETURN ((*info->s->read_rnd)(info,buf,filepos,skipp_deleted_blocks));
  57. }
  58.