Drizzled Public API Documentation

hp_scan.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 /* Scan through all rows */
00017 
00018 #include "heap_priv.h"
00019 #include <drizzled/error_t.h>
00020 
00021 /*
00022      Returns one of following values:
00023      0 = Ok.
00024      HA_ERR_RECORD_DELETED = Record is deleted.
00025      HA_ERR_END_OF_FILE = EOF.
00026 */
00027 
00028 int heap_scan_init(register HP_INFO *info)
00029 {
00030   info->lastinx= -1;
00031   info->current_record= UINT32_MAX;   /* No current record */
00032   info->update=0;
00033   info->next_block=0;
00034   return(0);
00035 }
00036 
00037 int heap_scan(register HP_INFO *info, unsigned char *record)
00038 {
00039   HP_SHARE *share=info->getShare();
00040   uint32_t pos;
00041 
00042   pos= ++info->current_record;
00043   if (pos < info->next_block)
00044   {
00045     info->current_ptr+=share->recordspace.block.recbuffer;
00046   }
00047   else
00048   {
00049     info->next_block+=share->recordspace.block.records_in_block;
00050     if (info->next_block >= share->recordspace.chunk_count)
00051     {
00052       info->next_block= share->recordspace.chunk_count;
00053       if (pos >= info->next_block)
00054       {
00055   info->update= 0;
00056   return(errno=  drizzled::HA_ERR_END_OF_FILE);
00057       }
00058     }
00059     hp_find_record(info, pos);
00060   }
00061   if (get_chunk_status(&share->recordspace, info->current_ptr) != CHUNK_STATUS_ACTIVE)
00062   {
00063     info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
00064     return(errno= drizzled::HA_ERR_RECORD_DELETED);
00065   }
00066   info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
00067   hp_extract_record(share, record, info->current_ptr);
00068   info->current_hash_ptr=0;     /* Can't use read_next */
00069   return(0);
00070 } /* heap_scan */