Drizzled Public API Documentation

hp_scan.cc
1 /* Copyright (C) 2000-2002 MySQL AB
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 /* Scan through all rows */
17 
18 #include "heap_priv.h"
19 #include <drizzled/error_t.h>
20 
21 /*
22  Returns one of following values:
23  0 = Ok.
24  HA_ERR_RECORD_DELETED = Record is deleted.
25  HA_ERR_END_OF_FILE = EOF.
26 */
27 
28 int heap_scan_init(register HP_INFO *info)
29 {
30  info->lastinx= -1;
31  info->current_record= UINT32_MAX; /* No current record */
32  info->update=0;
33  info->next_block=0;
34  return(0);
35 }
36 
37 int heap_scan(register HP_INFO *info, unsigned char *record)
38 {
39  HP_SHARE *share=info->getShare();
40  uint32_t pos;
41 
42  pos= ++info->current_record;
43  if (pos < info->next_block)
44  {
45  info->current_ptr+=share->recordspace.block.recbuffer;
46  }
47  else
48  {
49  info->next_block+=share->recordspace.block.records_in_block;
50  if (info->next_block >= share->recordspace.chunk_count)
51  {
52  info->next_block= share->recordspace.chunk_count;
53  if (pos >= info->next_block)
54  {
55  info->update= 0;
56  return(errno= drizzled::HA_ERR_END_OF_FILE);
57  }
58  }
59  hp_find_record(info, pos);
60  }
61  if (get_chunk_status(&share->recordspace, info->current_ptr) != CHUNK_STATUS_ACTIVE)
62  {
63  info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
64  return(errno= drizzled::HA_ERR_RECORD_DELETED);
65  }
66  info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
67  hp_extract_record(share, record, info->current_ptr);
68  info->current_hash_ptr=0; /* Can't use read_next */
69  return(0);
70 } /* heap_scan */