~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_delete.c

  • Committer: brian
  • Date: 2008-08-01 17:43:30 UTC
  • mfrom: (261.1.8 drizzle)
  • Revision ID: brian@localhost.localdomain-20080801174330-3y6yxa7pxkzdir6p
Merge from downsource tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
  uchar *pos;
23
23
  HP_SHARE *share=info->s;
24
24
  HP_KEYDEF *keydef, *end, *p_lastinx;
 
25
  uint rec_length, chunk_count;
25
26
 
26
27
  test_active(info);
27
28
 
29
30
    return(my_errno);                   /* Record changed */
30
31
  share->changed=1;
31
32
 
 
33
  rec_length = hp_get_encoded_data_length(share, record, &chunk_count);
 
34
 
32
35
  if ( --(share->records) < share->blength >> 1) share->blength>>=1;
33
36
  pos=info->current_ptr;
34
37
 
41
44
  }
42
45
 
43
46
  info->update=HA_STATE_DELETED;
44
 
  *((uchar**) pos)=share->del_link;
45
 
  share->del_link=pos;
46
 
  pos[share->reclength]=0;              /* Record deleted */
47
 
  share->deleted++;
 
47
  hp_free_chunks(&share->recordspace, pos);
48
48
  info->current_hash_ptr=0;
49
49
 
50
50
  return(0);
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 */
109
112
  lastpos=hp_find_hash(&keyinfo->block,share->records);
110
113
  last_ptr=0;
111
114
 
135
138
    info->current_ptr = last_ptr ? last_ptr->ptr_to_rec : 0;
136
139
  }
137
140
  empty=pos;
138
 
  if (gpos)
139
 
    gpos->next_key=pos->next_key;       /* unlink current ptr */
 
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
  }
140
145
  else if (pos->next_key)
141
146
  {
 
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 */
142
150
    empty=pos->next_key;
143
151
    pos->ptr_to_rec=empty->ptr_to_rec;
144
152
    pos->next_key=empty->next_key;
145
153
  }
146
154
  else
 
155
  {
 
156
    /* this was the only HASH_INFO at this position */
147
157
    keyinfo->hash_buckets--;
 
158
  }
148
159
 
149
160
  if (empty == lastpos)                 /* deleted last hash key */
150
161
    return (0);