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