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