~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_rrnd.c

Merged in changes. 
Edited a the comment test case so deal with our version bump.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* Read a record from a random position */
17
17
 
18
 
#include "heap_priv.h"
 
18
#include "heapdef.h"
19
19
 
20
20
/*
21
21
           Returns one of following values:
24
24
           HA_ERR_END_OF_FILE = EOF.
25
25
*/
26
26
 
27
 
int heap_rrnd(register HP_INFO *info, unsigned char *record, unsigned char *pos)
 
27
int heap_rrnd(register HP_INFO *info, uchar *record, uchar *pos)
28
28
{
29
29
  HP_SHARE *share=info->s;
 
30
  DBUG_ENTER("heap_rrnd");
 
31
  DBUG_PRINT("enter",("info: 0x%lx  pos: %lx",(long) info, (long) pos));
30
32
 
31
33
  info->lastinx= -1;
32
34
  if (!(info->current_ptr= pos))
33
35
  {
34
36
    info->update= 0;
35
 
    return(errno= HA_ERR_END_OF_FILE);
 
37
    DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
36
38
  }
37
 
  if (get_chunk_status(&share->recordspace, info->current_ptr) != CHUNK_STATUS_ACTIVE)
 
39
  if (!info->current_ptr[share->reclength])
38
40
  {
39
 
    /* treat deleted and linked chunks as deleted */
40
41
    info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
41
 
    return(errno=HA_ERR_RECORD_DELETED);
 
42
    DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
42
43
  }
43
44
  info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
44
 
  hp_extract_record(share, record, info->current_ptr);
 
45
  memcpy(record,info->current_ptr,(size_t) share->reclength);
 
46
  DBUG_PRINT("exit", ("found record at 0x%lx", (long) info->current_ptr));
45
47
  info->current_hash_ptr=0;                     /* Can't use rnext */
46
 
  return(0);
 
48
  DBUG_RETURN(0);
47
49
} /* heap_rrnd */
48
50
 
49
51
 
57
59
           HA_ERR_END_OF_FILE = EOF.
58
60
*/
59
61
 
60
 
int heap_rrnd_old(register HP_INFO *info, unsigned char *record, uint32_t pos)
 
62
int heap_rrnd_old(register HP_INFO *info, uchar *record, ulong pos)
61
63
{
62
64
  HP_SHARE *share=info->s;
63
 
asdfasdf;
 
65
  DBUG_ENTER("heap_rrnd");
 
66
  DBUG_PRINT("enter",("info: 0x%lx  pos: %ld",info,pos));
 
67
 
64
68
  info->lastinx= -1;
65
 
  if (pos == (uint32_t) -1)
 
69
  if (pos == (ulong) -1)
66
70
  {
67
71
    pos= ++info->current_record;
68
72
    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))
 
73
        pos < share->records+share->deleted &&
 
74
        (info->update & HA_STATE_PREV_FOUND))
71
75
    {
72
 
      info->current_ptr+=share->block.recbufferlen;
 
76
      info->current_ptr+=share->block.recbuffer;
73
77
      goto end;
74
78
    }
75
79
  }
76
80
  else
77
81
    info->current_record=pos;
78
82
 
79
 
  if (pos >= share->used_chunk_count+share->deleted_chunk_count)
 
83
  if (pos >= share->records+share->deleted)
80
84
  {
81
85
    info->update= 0;
82
 
    return(errno= HA_ERR_END_OF_FILE);
 
86
    DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
83
87
  }
84
88
 
85
89
        /* Find record number pos */
89
93
  if (!info->current_ptr[share->reclength])
90
94
  {
91
95
    info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
92
 
    return(errno=HA_ERR_RECORD_DELETED);
 
96
    DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
93
97
  }
94
98
  info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
95
99
  memcpy(record,info->current_ptr,(size_t) share->reclength);
 
100
  DBUG_PRINT("exit",("found record at 0x%lx",info->current_ptr));
96
101
  info->current_hash_ptr=0;                     /* Can't use rnext */
97
 
  return(0);
 
102
  DBUG_RETURN(0);
98
103
} /* heap_rrnd */
99
104
 
100
105
#endif /* WANT_OLD_HEAP_VERSION */