Drizzled Public API Documentation

hp_rkey.cc

00001 /* Copyright (C) 2000-2004, 2006 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 "heap_priv.h"
00017 
00018 #include <string.h>
00019 
00020 using namespace drizzled;
00021 
00022 int heap_rkey(HP_INFO *info, unsigned char *record, int inx, const unsigned char *key,
00023               key_part_map , enum ha_rkey_function )
00024 {
00025   unsigned char *pos;
00026   HP_SHARE *share= info->getShare();
00027   HP_KEYDEF *keyinfo= share->keydef + inx;
00028 
00029   if ((uint) inx >= share->keys)
00030   {
00031     return(errno= HA_ERR_WRONG_INDEX);
00032   }
00033   info->lastinx= inx;
00034   info->current_record= UINT32_MAX;   /* For heap_rrnd() */
00035   {
00036     if (!(pos= hp_search(info, share->keydef + inx, key, 0)))
00037     {
00038       info->update= 0;
00039       return(errno);
00040     }
00041     if (!(keyinfo->flag & HA_NOSAME))
00042       memcpy(&info->lastkey[0], key, (size_t) keyinfo->length);
00043   }
00044   hp_extract_record(share, record, pos);
00045   info->update= HA_STATE_AKTIV;
00046   return(0);
00047 }
00048 
00049 
00050   /* Quick find of record */
00051 
00052 unsigned char* heap_find(HP_INFO *info, int inx, const unsigned char *key)
00053 {
00054   return hp_search(info, info->getShare()->keydef + inx, key, 0);
00055 }