hp_rsame.c
Upload User: tsgydb
Upload Date: 2007-04-14
Package Size: 10674k
Code Size: 2k
Category:

MySQL

Development Platform:

Visual C++

  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. /* re-read current record */
  17. #include "heapdef.h"
  18. /* If inx != -1 the new record is read according to index
  19.    (for next/prev). Record must in this case point to last record
  20.    Returncodes:
  21.    0 = Ok.
  22.    HA_ERR_RECORD_DELETED = Record was removed
  23.    HA_ERR_KEY_NOT_FOUND = Record not found with key
  24. */
  25. int heap_rsame(register HP_INFO *info, byte *record, int inx)
  26. {
  27.   HP_SHARE *share=info->s;
  28.   DBUG_ENTER("heap_rsame");
  29.   test_active(info);
  30.   if (info->current_ptr[share->reclength])
  31.   {
  32.     if (inx < -1 || inx >= (int) share->keys)
  33.     {
  34.       DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
  35.     }
  36.     else if (inx != -1)
  37.     {
  38.       info->lastinx=inx;
  39.       _hp_make_key(share->keydef+inx,info->lastkey,record);
  40.       if (!_hp_search(info,share->keydef+inx,info->lastkey,3))
  41.       {
  42. info->update=0;
  43. DBUG_RETURN(my_errno);
  44.       }
  45.     }
  46.     memcpy(record,info->current_ptr,(size_t) share->reclength);
  47.     DBUG_RETURN(0);
  48.   }
  49.   info->update=0;
  50.   DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
  51. }