~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_write.c

  • Committer: Eric Herman
  • Date: 2008-12-06 19:42:46 UTC
  • mto: (656.1.6 devel)
  • mto: This revision was merged to the branch mainline in revision 665.
  • Revision ID: eric@mysql.com-20081206194246-5cdexuu81i366eek
removed trailing whitespace with simple script:

for file in $(find . -name "*.c") $(find . -name "*.cc") $(find . -name "*.h"); do ruby -pe 'gsub(/\s+$/, $/)' < $file > $file.out; mv $file.out $file; done;

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
    if ((*keydef->delete_key)(info, keydef, record, pos, 0))
84
84
      break;
85
85
    keydef--;
86
 
  } 
 
86
  }
87
87
 
88
88
  hp_free_chunks(&share->recordspace, pos);
89
89
 
90
90
  return(my_errno);
91
91
} /* heap_write */
92
92
 
93
 
/* 
94
 
  Write a key to rb_tree-index 
 
93
/*
 
94
  Write a key to rb_tree-index
95
95
*/
96
96
 
97
 
int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, const unsigned char *record, 
 
97
int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, const unsigned char *record,
98
98
                    unsigned char *recpos)
99
99
{
100
100
  heap_rb_param custom_arg;
129
129
    info     Heap table info
130
130
    keyinfo  Key info
131
131
    record   Table record to added
132
 
    recpos   Memory buffer where the table record will be stored if added 
 
132
    recpos   Memory buffer where the table record will be stored if added
133
133
             successfully
134
134
  NOTE
135
 
    Hash index uses HP_BLOCK structure as a 'growable array' of HASH_INFO 
 
135
    Hash index uses HP_BLOCK structure as a 'growable array' of HASH_INFO
136
136
    structs. Array size == number of entries in hash index.
137
137
    hp_mask(hp_rec_hashnr()) maps hash entries values to hash array positions.
138
138
    If there are several hash entries with the same hash array position P,
139
 
    they are connected in a linked list via HASH_INFO::next_key. The first 
140
 
    list element is located at position P, next elements are located at 
 
139
    they are connected in a linked list via HASH_INFO::next_key. The first
 
140
    list element is located at position P, next elements are located at
141
141
    positions for which there is no record that should be located at that
142
142
    position. The order of elements in the list is arbitrary.
143
143
 
144
144
  RETURN
145
145
    0  - OK
146
146
    -1 - Out of memory
147
 
    HA_ERR_FOUND_DUPP_KEY - Duplicate record on unique key. The record was 
 
147
    HA_ERR_FOUND_DUPP_KEY - Duplicate record on unique key. The record was
148
148
    still added and the caller must call hp_delete_key for it.
149
149
*/
150
150
 
162
162
    return(-1);                         /* No more memory */
163
163
  halfbuff= (long) share->blength >> 1;
164
164
  pos= hp_find_hash(&keyinfo->block,(first_index=share->records-halfbuff));
165
 
  
 
165
 
166
166
  /*
167
167
    We're about to add one more hash array position, with hash_mask=#records.
168
 
    The number of hash positions will change and some entries might need to 
169
 
    be relocated to the newly added position. Those entries are currently 
170
 
    members of the list that starts at #first_index position (this is 
 
168
    The number of hash positions will change and some entries might need to
 
169
    be relocated to the newly added position. Those entries are currently
 
170
    members of the list that starts at #first_index position (this is
171
171
    guaranteed by properties of hp_mask(hp_rec_hashnr(X)) mapping function)
172
172
    At #first_index position currently there may be either:
173
173
    a) An entry with hashnr != first_index. We don't need to move it.
174
174
    or
175
175
    b) A list of items with hash_mask=first_index. The list contains entries
176
176
       of 2 types:
177
 
       1) entries that should be relocated to the list that starts at new 
 
177
       1) entries that should be relocated to the list that starts at new
178
178
          position we're adding ('uppper' list)
179
 
       2) entries that should be left in the list starting at #first_index 
 
179
       2) entries that should be left in the list starting at #first_index
180
180
          position ('lower' list)
181
181
  */
182
182
  if (pos != empty)                             /* If some records */
186
186
      hashnr = hp_rec_hashnr(keyinfo, pos->ptr_to_rec);
187
187
      if (flag == 0)
188
188
      {
189
 
        /* 
190
 
          First loop, bail out if we're dealing with case a) from above 
 
189
        /*
 
190
          First loop, bail out if we're dealing with case a) from above
191
191
          comment
192
192
        */
193
193
        if (hp_mask(hashnr, share->blength, share->records) != first_index)
205
205
        ptr_to_rec2 - same for upper list.
206
206
      */
207
207
      if (!(hashnr & halfbuff))
208
 
      {                                         
 
208
      {
209
209
        /* Key should be put into 'lower' list */
210
210
        if (!(flag & LOWFIND))
211
211
        {
221
221
          else
222
222
          {
223
223
            /*
224
 
              We can only get here at first iteration: key is at 'lower' 
 
224
              We can only get here at first iteration: key is at 'lower'
225
225
              position pos and should be left here.
226
226
            */
227
227
            flag=LOWFIND | LOWUSED;
269
269
      }
270
270
    }
271
271
    while ((pos=pos->next_key));
272
 
    
 
272
 
273
273
    if ((flag & (LOWFIND | HIGHFIND)) == (LOWFIND | HIGHFIND))
274
274
    {
275
275
      /*