~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/heap/hp_rrnd.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2002, 2004, 2006 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
 
 
16
 
/* Read a record from a random position */
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_rrnd(register HP_INFO *info, unsigned char *record, unsigned char *pos)
28
 
{
29
 
  HP_SHARE *share=info->s;
30
 
 
31
 
  info->lastinx= -1;
32
 
  if (!(info->current_ptr= pos))
33
 
  {
34
 
    info->update= 0;
35
 
    return(errno= HA_ERR_END_OF_FILE);
36
 
  }
37
 
  if (get_chunk_status(&share->recordspace, info->current_ptr) != CHUNK_STATUS_ACTIVE)
38
 
  {
39
 
    /* treat deleted and linked chunks as deleted */
40
 
    info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
41
 
    return(errno=HA_ERR_RECORD_DELETED);
42
 
  }
43
 
  info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
44
 
  hp_extract_record(share, record, info->current_ptr);
45
 
  info->current_hash_ptr=0;                     /* Can't use rnext */
46
 
  return(0);
47
 
} /* heap_rrnd */
48
 
 
49
 
 
50
 
#ifdef WANT_OLD_HEAP_VERSION
51
 
 
52
 
/*
53
 
           If pos == -1 then read next record
54
 
           Returns one of following values:
55
 
           0 = Ok.
56
 
           HA_ERR_RECORD_DELETED = Record is deleted.
57
 
           HA_ERR_END_OF_FILE = EOF.
58
 
*/
59
 
 
60
 
int heap_rrnd_old(register HP_INFO *info, unsigned char *record, uint32_t pos)
61
 
{
62
 
  HP_SHARE *share=info->s;
63
 
asdfasdf;
64
 
  info->lastinx= -1;
65
 
  if (pos == (uint32_t) -1)
66
 
  {
67
 
    pos= ++info->current_record;
68
 
    if (pos % share->block.records_in_block &&  /* Quick next record */
69
 
      pos < share->used_chunk_count+share->deleted_chunk_count &&
70
 
            (info->update & HA_STATE_PREV_FOUND))
71
 
    {
72
 
      info->current_ptr+=share->block.recbufferlen;
73
 
      goto end;
74
 
    }
75
 
  }
76
 
  else
77
 
    info->current_record=pos;
78
 
 
79
 
  if (pos >= share->used_chunk_count+share->deleted_chunk_count)
80
 
  {
81
 
    info->update= 0;
82
 
    return(errno= HA_ERR_END_OF_FILE);
83
 
  }
84
 
 
85
 
        /* Find record number pos */
86
 
  hp_find_record(info, pos);
87
 
 
88
 
end:
89
 
  if (!info->current_ptr[share->reclength])
90
 
  {
91
 
    info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
92
 
    return(errno=HA_ERR_RECORD_DELETED);
93
 
  }
94
 
  info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
95
 
  memcpy(record,info->current_ptr,(size_t) share->reclength);
96
 
  info->current_hash_ptr=0;                     /* Can't use rnext */
97
 
  return(0);
98
 
} /* heap_rrnd */
99
 
 
100
 
#endif /* WANT_OLD_HEAP_VERSION */