~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_rrnd.c

  • Committer: Monty Taylor
  • Date: 2008-08-02 00:06:32 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080802000632-jsse0zdd9r6ic5ku
Actually turn gettext on...

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
 
  HP_SHARE *share=info->getShare();
 
29
  HP_SHARE *share=info->s;
30
30
 
31
31
  info->lastinx= -1;
32
32
  if (!(info->current_ptr= pos))
33
33
  {
34
34
    info->update= 0;
35
 
    return(errno= HA_ERR_END_OF_FILE);
 
35
    return(my_errno= HA_ERR_END_OF_FILE);
36
36
  }
37
 
  if (get_chunk_status(&share->recordspace, info->current_ptr) != CHUNK_STATUS_ACTIVE)
 
37
  if (!info->current_ptr[share->reclength])
38
38
  {
39
 
    /* treat deleted and linked chunks as deleted */
40
39
    info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
41
 
    return(errno=HA_ERR_RECORD_DELETED);
 
40
    return(my_errno=HA_ERR_RECORD_DELETED);
42
41
  }
43
42
  info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
44
 
  hp_extract_record(share, record, info->current_ptr);
 
43
  memcpy(record,info->current_ptr,(size_t) share->reclength);
45
44
  info->current_hash_ptr=0;                     /* Can't use rnext */
46
45
  return(0);
47
46
} /* heap_rrnd */
57
56
           HA_ERR_END_OF_FILE = EOF.
58
57
*/
59
58
 
60
 
int heap_rrnd_old(register HP_INFO *info, unsigned char *record, uint32_t pos)
 
59
int heap_rrnd_old(register HP_INFO *info, uchar *record, ulong pos)
61
60
{
62
61
  HP_SHARE *share=info->s;
63
 
asdfasdf;
 
62
 
64
63
  info->lastinx= -1;
65
 
  if (pos == (uint32_t) -1)
 
64
  if (pos == (ulong) -1)
66
65
  {
67
66
    pos= ++info->current_record;
68
67
    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))
 
68
        pos < share->records+share->deleted &&
 
69
        (info->update & HA_STATE_PREV_FOUND))
71
70
    {
72
 
      info->current_ptr+=share->block.recbufferlen;
 
71
      info->current_ptr+=share->block.recbuffer;
73
72
      goto end;
74
73
    }
75
74
  }
76
75
  else
77
76
    info->current_record=pos;
78
77
 
79
 
  if (pos >= share->used_chunk_count+share->deleted_chunk_count)
 
78
  if (pos >= share->records+share->deleted)
80
79
  {
81
80
    info->update= 0;
82
 
    return(errno= HA_ERR_END_OF_FILE);
 
81
    return(my_errno= HA_ERR_END_OF_FILE);
83
82
  }
84
83
 
85
84
        /* Find record number pos */
89
88
  if (!info->current_ptr[share->reclength])
90
89
  {
91
90
    info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
92
 
    return(errno=HA_ERR_RECORD_DELETED);
 
91
    return(my_errno=HA_ERR_RECORD_DELETED);
93
92
  }
94
93
  info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
95
94
  memcpy(record,info->current_ptr,(size_t) share->reclength);