home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 January / Chip_2001-01_cd1.bin / tema / mysql / mysql-3.23.28g-win-source.exe / isam / rsamepos.c < prev    next >
C/C++ Source or Header  |  2000-08-31  |  2KB  |  60 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 record through position and fix key-position */
  18. /* As nisam_rsame but supply a position */
  19.  
  20. #include "isamdef.h"
  21.  
  22.  
  23.     /*
  24.     ** If inx >= 0 update index pointer
  25.     ** Returns one of the following values:
  26.     **  0 = Ok.
  27.     **  1 = Record deleted
  28.     ** -1 = EOF (or something similar. More information in my_errno)
  29.     */
  30.  
  31. int nisam_rsame_with_pos(N_INFO *info, byte *record, int inx, ulong filepos)
  32. {
  33.   DBUG_ENTER("nisam_rsame_with_pos");
  34.  
  35.   if (inx >= (int) info->s->state.keys || inx < -1)
  36.   {
  37.     my_errno=HA_ERR_WRONG_INDEX;
  38.     DBUG_RETURN(-1);
  39.   }
  40.  
  41.   info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
  42.   if ((*info->s->read_rnd)(info,record,filepos,0))
  43.   {
  44.     if (my_errno == HA_ERR_RECORD_DELETED)
  45.     {
  46.       my_errno=HA_ERR_KEY_NOT_FOUND;
  47.       DBUG_RETURN(1);
  48.     }
  49.     DBUG_RETURN(-1);
  50.   }
  51.   info->lastpos=filepos;
  52.   info->lastinx=inx;
  53.   if (inx >= 0)
  54.   {
  55.     VOID(_nisam_make_key(info,(uint) inx,info->lastkey,record,info->lastpos));
  56.     info->update|=HA_STATE_KEY_CHANGED;        /* Don't use indexposition */
  57.   }
  58.   DBUG_RETURN(0);
  59. } /* nisam_rsame_pos */
  60.