Drizzled Public API Documentation

hp_rsame.cc
00001 /* Copyright (C) 2000-2002 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 /* re-read current record */
00017 
00018 #include "heap_priv.h"
00019 
00020   /* If inx != -1 the new record is read according to index
00021      (for next/prev). Record must in this case point to last record
00022      Returncodes:
00023      0 = Ok.
00024      HA_ERR_RECORD_DELETED = Record was removed
00025      HA_ERR_KEY_NOT_FOUND = Record not found with key
00026   */
00027 
00028 int heap_rsame(register HP_INFO *info, unsigned char *record, int inx)
00029 {
00030   HP_SHARE *share= info->getShare();
00031 
00032   test_active(info);
00033   if (get_chunk_status(&share->recordspace, info->current_ptr) == CHUNK_STATUS_ACTIVE)
00034   {
00035     if (inx < -1 || inx >= (int) share->keys)
00036     {
00037       return(errno= drizzled::HA_ERR_WRONG_INDEX);
00038     }
00039     else if (inx != -1)
00040     {
00041       info->lastinx=inx;
00042       hp_make_key(share->keydef + inx, &info->lastkey[0], record);
00043       if (!hp_search(info, share->keydef + inx, &info->lastkey[0], 3))
00044       {
00045   info->update=0;
00046   return(errno);
00047       }
00048     }
00049     hp_extract_record(share, record, info->current_ptr);
00050     return(0);
00051   }
00052   info->update=0;
00053 
00054   return(errno= drizzled::HA_ERR_RECORD_DELETED);
00055 }