~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/memory/hp_scan.cc

  • Committer: Monty Taylor
  • Date: 2010-09-16 23:12:30 UTC
  • mto: (1775.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1773.
  • Revision ID: mordred@inaugust.com-20100916231230-uchkqks21rwzbmpz
Include files in tarball that were being left out.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
20
 
/*
21
 
           Returns one of following values:
22
 
           0 = Ok.
23
 
           HA_ERR_RECORD_DELETED = Record is deleted.
24
 
           HA_ERR_END_OF_FILE = EOF.
25
 
*/
26
 
 
27
 
int heap_scan_init(register HP_INFO *info)
28
 
{
29
 
  info->lastinx= -1;
30
 
  info->current_record= UINT32_MAX;             /* No current record */
31
 
  info->update=0;
32
 
  info->next_block=0;
33
 
  return(0);
34
 
}
35
 
 
36
 
int heap_scan(register HP_INFO *info, unsigned char *record)
37
 
{
38
 
  HP_SHARE *share=info->getShare();
39
 
  uint32_t pos;
40
 
 
41
 
  pos= ++info->current_record;
42
 
  if (pos < info->next_block)
43
 
  {
44
 
    info->current_ptr+=share->recordspace.block.recbuffer;
45
 
  }
46
 
  else
47
 
  {
48
 
    info->next_block+=share->recordspace.block.records_in_block;
49
 
    if (info->next_block >= share->recordspace.chunk_count)
50
 
    {
51
 
      info->next_block= share->recordspace.chunk_count;
52
 
      if (pos >= info->next_block)
53
 
      {
54
 
        info->update= 0;
55
 
        return(errno=  drizzled::HA_ERR_END_OF_FILE);
56
 
      }
57
 
    }
58
 
    hp_find_record(info, pos);
59
 
  }
60
 
  if (get_chunk_status(&share->recordspace, info->current_ptr) != CHUNK_STATUS_ACTIVE)
61
 
  {
62
 
    info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
63
 
    return(errno= drizzled::HA_ERR_RECORD_DELETED);
64
 
  }
65
 
  info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
66
 
  hp_extract_record(share, record, info->current_ptr);
67
 
  info->current_hash_ptr=0;                     /* Can't use read_next */
68
 
  return(0);
69
 
} /* heap_scan */