Drizzled Public API Documentation

mi_rsame.cc

00001 /* Copyright (C) 2000-2001, 2005 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 #include "myisam_priv.h"
00017 #include <drizzled/util/test.h>
00018 
00019 using namespace drizzled;
00020 
00021   /*
00022   ** Find current row with read on position or read on key
00023   ** If inx >= 0 find record using key
00024   ** Return values:
00025   ** 0 = Ok.
00026   ** HA_ERR_KEY_NOT_FOUND = Row is deleted
00027   ** HA_ERR_END_OF_FILE   = End of file
00028   */
00029 
00030 
00031 int mi_rsame(MI_INFO *info, unsigned char *record, int inx)
00032 {
00033   if (inx != -1 && ! mi_is_key_active(info->s->state.key_map, inx))
00034   {
00035     return(errno=HA_ERR_WRONG_INDEX);
00036   }
00037   if (info->lastpos == HA_OFFSET_ERROR || info->update & HA_STATE_DELETED)
00038   {
00039     return(errno=HA_ERR_KEY_NOT_FOUND); /* No current record */
00040   }
00041   info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
00042 
00043   /* Read row from data file */
00044   if (fast_mi_readinfo(info))
00045     return(errno);
00046 
00047   if (inx >= 0)
00048   {
00049     info->lastinx=inx;
00050     info->lastkey_length=_mi_make_key(info,(uint) inx,info->lastkey,record,
00051               info->lastpos);
00052     _mi_search(info,info->s->keyinfo+inx,info->lastkey, USE_WHOLE_KEY,
00053                SEARCH_SAME,
00054                info->s->state.key_root[inx]);
00055   }
00056 
00057   if (!(*info->read_record)(info,info->lastpos,record))
00058     return(0);
00059   if (errno == HA_ERR_RECORD_DELETED)
00060     errno=HA_ERR_KEY_NOT_FOUND;
00061   return(errno);
00062 } /* mi_rsame */