~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_delete.c

  • Committer: Monty Taylor
  • Date: 2008-08-01 22:33:44 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080801223344-vzhlflfmtijp1imv
First pass at gettexizing the error messages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* remove current record in heap-database */
17
17
 
18
 
#include "heap_priv.h"
 
18
#include "heapdef.h"
19
19
 
20
 
int heap_delete(HP_INFO *info, const unsigned char *record)
 
20
int heap_delete(HP_INFO *info, const uchar *record)
21
21
{
22
 
  unsigned char *pos;
 
22
  uchar *pos;
23
23
  HP_SHARE *share=info->s;
24
24
  HP_KEYDEF *keydef, *end, *p_lastinx;
25
 
  uint32_t rec_length, chunk_count;
26
25
 
27
26
  test_active(info);
28
27
 
29
28
  if (info->opt_flag & READ_CHECK_USED)
30
 
    return(errno);                      /* Record changed */
 
29
    return(my_errno);                   /* Record changed */
31
30
  share->changed=1;
32
31
 
33
 
  rec_length = hp_get_encoded_data_length(share, record, &chunk_count);
34
 
 
35
32
  if ( --(share->records) < share->blength >> 1) share->blength>>=1;
36
33
  pos=info->current_ptr;
37
34
 
38
35
  p_lastinx = share->keydef + info->lastinx;
39
 
  for (keydef = share->keydef, end = keydef + share->keys; keydef < end;
 
36
  for (keydef = share->keydef, end = keydef + share->keys; keydef < end; 
40
37
       keydef++)
41
38
  {
42
39
    if ((*keydef->delete_key)(info, keydef, record, pos, keydef == p_lastinx))
44
41
  }
45
42
 
46
43
  info->update=HA_STATE_DELETED;
47
 
  hp_free_chunks(&share->recordspace, pos);
 
44
  *((uchar**) pos)=share->del_link;
 
45
  share->del_link=pos;
 
46
  pos[share->reclength]=0;              /* Record deleted */
 
47
  share->deleted++;
48
48
  info->current_hash_ptr=0;
49
49
 
50
50
  return(0);
51
51
err:
52
52
  if (++(share->records) == share->blength)
53
53
    share->blength+= share->blength;
54
 
  return(errno);
 
54
  return(my_errno);
55
55
}
56
56
 
57
57
 
60
60
*/
61
61
 
62
62
int hp_rb_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo,
63
 
                   const unsigned char *record, unsigned char *recpos, int flag)
 
63
                   const uchar *record, uchar *recpos, int flag)
64
64
{
65
65
  heap_rb_param custom_arg;
66
 
  uint32_t old_allocated;
 
66
  uint old_allocated;
67
67
  int res;
68
68
 
69
 
  if (flag)
 
69
  if (flag) 
70
70
    info->last_pos= NULL; /* For heap_rnext/heap_rprev */
71
71
 
72
72
  custom_arg.keyseg= keyinfo->seg;
97
97
*/
98
98
 
99
99
int hp_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo,
100
 
                  const unsigned char *record, unsigned char *recpos, int flag)
 
100
                  const uchar *record, uchar *recpos, int flag)
101
101
{
102
 
  uint32_t blength,pos2,pos_hashnr,lastpos_hashnr;
 
102
  ulong blength,pos2,pos_hashnr,lastpos_hashnr;
103
103
  HASH_INFO *lastpos,*gpos,*pos,*pos3,*empty,*last_ptr;
104
104
  HP_SHARE *share=info->s;
105
105
 
106
106
  blength=share->blength;
107
107
  if (share->records+1 == blength)
108
108
    blength+= blength;
109
 
 
110
 
  /* find the very last HASH_INFO pointer in the index */
111
 
  /* note that records has already been decremented */
112
109
  lastpos=hp_find_hash(&keyinfo->block,share->records);
113
110
  last_ptr=0;
114
111
 
125
122
    gpos=pos;
126
123
    if (!(pos=pos->next_key))
127
124
    {
128
 
      return(errno=HA_ERR_CRASHED);     /* This shouldn't happend */
 
125
      return(my_errno=HA_ERR_CRASHED);  /* This shouldn't happend */
129
126
    }
130
127
  }
131
128
 
138
135
    info->current_ptr = last_ptr ? last_ptr->ptr_to_rec : 0;
139
136
  }
140
137
  empty=pos;
141
 
  if (gpos) {
142
 
    /* gpos says we have previous HASH_INFO, change previous to point to next, this way unlinking "empty" */
143
 
    gpos->next_key=pos->next_key;
144
 
  }
 
138
  if (gpos)
 
139
    gpos->next_key=pos->next_key;       /* unlink current ptr */
145
140
  else if (pos->next_key)
146
141
  {
147
 
    /* no previous gpos, this pos is the first in the list and it has pointer to "next" */
148
 
    /* move next HASH_INFO data to our pos, to free up space at the next position */
149
 
    /* remember next pos as "empty", nobody refers to "empty" at this point */
150
142
    empty=pos->next_key;
151
143
    pos->ptr_to_rec=empty->ptr_to_rec;
152
144
    pos->next_key=empty->next_key;
153
145
  }
154
146
  else
155
 
  {
156
 
    /* this was the only HASH_INFO at this position */
157
147
    keyinfo->hash_buckets--;
158
 
  }
159
148
 
160
149
  if (empty == lastpos)                 /* deleted last hash key */
161
150
    return (0);