~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_write.c

Merged uint fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
        /* Functions declared in this file */
23
23
 
24
24
static int w_search(MI_INFO *info,MI_KEYDEF *keyinfo,
25
 
                    uint comp_flag, unsigned char *key,
26
 
                    uint key_length, my_off_t pos, unsigned char *father_buff,
 
25
                    uint32_t comp_flag, unsigned char *key,
 
26
                    uint32_t key_length, my_off_t pos, unsigned char *father_buff,
27
27
                    unsigned char *father_keypos, my_off_t father_page,
28
28
                    bool insert_last);
29
29
static int _mi_balance_page(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,
30
30
                            unsigned char *curr_buff,unsigned char *father_buff,
31
31
                            unsigned char *father_keypos,my_off_t father_page);
32
32
static unsigned char *_mi_find_last_pos(MI_KEYDEF *keyinfo, unsigned char *page,
33
 
                                unsigned char *key, uint *return_key_length,
 
33
                                unsigned char *key, uint32_t *return_key_length,
34
34
                                unsigned char **after_key);
35
 
int _mi_ck_write_tree(register MI_INFO *info, uint keynr,unsigned char *key,
36
 
                      uint key_length);
37
 
int _mi_ck_write_btree(register MI_INFO *info, uint keynr,unsigned char *key,
38
 
                       uint key_length);
 
35
int _mi_ck_write_tree(register MI_INFO *info, uint32_t keynr,unsigned char *key,
 
36
                      uint32_t key_length);
 
37
int _mi_ck_write_btree(register MI_INFO *info, uint32_t keynr,unsigned char *key,
 
38
                       uint32_t key_length);
39
39
 
40
40
        /* Write new record to database */
41
41
 
42
42
int mi_write(MI_INFO *info, unsigned char *record)
43
43
{
44
44
  MYISAM_SHARE *share=info->s;
45
 
  uint i;
 
45
  uint32_t i;
46
46
  int save_errno;
47
47
  my_off_t filepos;
48
48
  unsigned char *buff;
157
157
  {
158
158
    if (info->bulk_insert)
159
159
    {
160
 
      uint j;
 
160
      uint32_t j;
161
161
      for (j=0 ; j < share->base.keys ; j++)
162
162
        mi_flush_bulk_insert(info, j);
163
163
    }
172
172
        if (local_lock_tree)
173
173
          rw_wrlock(&share->key_root_lock[i]);
174
174
        {
175
 
          uint key_length=_mi_make_key(info,i,buff,record,filepos);
 
175
          uint32_t key_length=_mi_make_key(info,i,buff,record,filepos);
176
176
          if (_mi_ck_delete(info,i,buff,key_length))
177
177
          {
178
178
            if (local_lock_tree)
201
201
 
202
202
        /* Write one key to btree */
203
203
 
204
 
int _mi_ck_write(MI_INFO *info, uint keynr, unsigned char *key, uint key_length)
 
204
int _mi_ck_write(MI_INFO *info, uint32_t keynr, unsigned char *key, uint32_t key_length)
205
205
{
206
206
  if (info->bulk_insert && is_tree_inited(&info->bulk_insert[keynr]))
207
207
  {
218
218
 *                Normal insert code                                  *
219
219
 **********************************************************************/
220
220
 
221
 
int _mi_ck_write_btree(register MI_INFO *info, uint keynr, unsigned char *key,
222
 
                       uint key_length)
 
221
int _mi_ck_write_btree(register MI_INFO *info, uint32_t keynr, unsigned char *key,
 
222
                       uint32_t key_length)
223
223
{
224
 
  uint error;
225
 
  uint comp_flag;
 
224
  uint32_t error;
 
225
  uint32_t comp_flag;
226
226
  MI_KEYDEF *keyinfo=info->s->keyinfo+keynr;
227
227
  my_off_t  *root=&info->s->state.key_root[keynr];
228
228
 
243
243
} /* _mi_ck_write_btree */
244
244
 
245
245
int _mi_ck_real_write_btree(MI_INFO *info, MI_KEYDEF *keyinfo,
246
 
    unsigned char *key, uint key_length, my_off_t *root, uint comp_flag)
 
246
    unsigned char *key, uint32_t key_length, my_off_t *root, uint32_t comp_flag)
247
247
{
248
248
  int error;
249
249
  /* key_length parameter is used only if comp_flag is SEARCH_FIND */
261
261
int _mi_enlarge_root(MI_INFO *info, MI_KEYDEF *keyinfo, unsigned char *key,
262
262
                     my_off_t *root)
263
263
{
264
 
  uint t_length,nod_flag;
 
264
  uint32_t t_length,nod_flag;
265
265
  MI_KEY_PARAM s_temp;
266
266
  MYISAM_SHARE *share=info->s;
267
267
 
287
287
        */
288
288
 
289
289
static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
290
 
                    uint comp_flag, unsigned char *key, uint key_length, my_off_t page,
 
290
                    uint32_t comp_flag, unsigned char *key, uint32_t key_length, my_off_t page,
291
291
                    unsigned char *father_buff, unsigned char *father_keypos,
292
292
                    my_off_t father_page, bool insert_last)
293
293
{
294
294
  int error,flag;
295
 
  uint nod_flag, search_key_length;
 
295
  uint32_t nod_flag, search_key_length;
296
296
  unsigned char *temp_buff,*keypos;
297
297
  unsigned char keybuff[MI_MAX_KEY_BUFF];
298
298
  bool was_last_key;
310
310
  nod_flag=mi_test_if_nod(temp_buff);
311
311
  if (flag == 0)
312
312
  {
313
 
    uint tmp_key_length;
 
313
    uint32_t tmp_key_length;
314
314
        /* get position to record with duplicated key */
315
315
    tmp_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&keypos,keybuff);
316
316
    if (tmp_key_length)
377
377
               unsigned char *father_buff, unsigned char *father_key_pos, my_off_t father_page,
378
378
               bool insert_last)
379
379
{
380
 
  uint a_length,nod_flag;
 
380
  uint32_t a_length,nod_flag;
381
381
  int t_length;
382
382
  unsigned char *endpos, *prev_key;
383
383
  MI_KEY_PARAM s_temp;
435
435
                   unsigned char *key, unsigned char *buff, unsigned char *key_buff,
436
436
                   bool insert_last_key)
437
437
{
438
 
  uint length,a_length,key_ref_length,t_length,nod_flag,key_length;
 
438
  uint32_t length,a_length,key_ref_length,t_length,nod_flag,key_length;
439
439
  unsigned char *key_pos,*pos, *after_key= NULL;
440
440
  my_off_t new_pos;
441
441
  MI_KEY_PARAM s_temp;
495
495
          after_key will contain the position to where the next key starts
496
496
        */
497
497
 
498
 
unsigned char *_mi_find_half_pos(uint nod_flag, MI_KEYDEF *keyinfo, unsigned char *page,
499
 
                         unsigned char *key, uint *return_key_length,
 
498
unsigned char *_mi_find_half_pos(uint32_t nod_flag, MI_KEYDEF *keyinfo, unsigned char *page,
 
499
                         unsigned char *key, uint32_t *return_key_length,
500
500
                         unsigned char **after_key)
501
501
{
502
 
  uint keys,length,key_ref_length;
 
502
  uint32_t keys,length,key_ref_length;
503
503
  unsigned char *end,*lastpos;
504
504
 
505
505
  key_ref_length=2+nod_flag;
539
539
        */
540
540
 
541
541
static unsigned char *_mi_find_last_pos(MI_KEYDEF *keyinfo, unsigned char *page,
542
 
                                unsigned char *key, uint *return_key_length,
 
542
                                unsigned char *key, uint32_t *return_key_length,
543
543
                                unsigned char **after_key)
544
544
{
545
 
  uint keys;
546
 
  uint length;
547
 
  uint last_length= 0;
548
 
  uint key_ref_length;
 
545
  uint32_t keys;
 
546
  uint32_t length;
 
547
  uint32_t last_length= 0;
 
548
  uint32_t key_ref_length;
549
549
  unsigned char *end, *lastpos, *prevpos= NULL;
550
550
  unsigned char key_buff[MI_MAX_KEY_BUFF];
551
551
 
594
594
                            unsigned char *father_key_pos, my_off_t father_page)
595
595
{
596
596
  bool right;
597
 
  uint k_length,father_length,father_keylength,nod_flag,curr_keylength,
 
597
  uint32_t k_length,father_length,father_keylength,nod_flag,curr_keylength,
598
598
       right_length,left_length,new_right_length,new_left_length,extra_length,
599
599
       length,keys;
600
600
  unsigned char *pos,*buff,*extra_buff;
723
723
 
724
724
typedef struct {
725
725
  MI_INFO *info;
726
 
  uint keynr;
 
726
  uint32_t keynr;
727
727
} bulk_insert_param;
728
728
 
729
 
int _mi_ck_write_tree(register MI_INFO *info, uint keynr, unsigned char *key,
730
 
                      uint key_length)
 
729
int _mi_ck_write_tree(register MI_INFO *info, uint32_t keynr, unsigned char *key,
 
730
                      uint32_t key_length)
731
731
{
732
732
  int error;
733
733
 
743
743
 
744
744
static int keys_compare(bulk_insert_param *param, unsigned char *key1, unsigned char *key2)
745
745
{
746
 
  uint not_used[2];
 
746
  uint32_t not_used[2];
747
747
  return ha_key_cmp(param->info->s->keyinfo[param->keynr].seg,
748
748
                    key1, key2, USE_WHOLE_KEY, SEARCH_SAME,
749
749
                    not_used);
757
757
    and to be safe I'd better use local lastkey.
758
758
  */
759
759
  unsigned char lastkey[MI_MAX_KEY_BUFF];
760
 
  uint keylen;
 
760
  uint32_t keylen;
761
761
  MI_KEYDEF *keyinfo;
762
762
 
763
763
  switch (mode) {
788
788
  MYISAM_SHARE *share=info->s;
789
789
  MI_KEYDEF *key=share->keyinfo;
790
790
  bulk_insert_param *params;
791
 
  uint i, num_keys, total_keylength;
 
791
  uint32_t i, num_keys, total_keylength;
792
792
  uint64_t key_map;
793
793
 
794
794
  assert(!info->bulk_insert &&
843
843
  return(0);
844
844
}
845
845
 
846
 
void mi_flush_bulk_insert(MI_INFO *info, uint inx)
 
846
void mi_flush_bulk_insert(MI_INFO *info, uint32_t inx)
847
847
{
848
848
  if (info->bulk_insert)
849
849
  {
856
856
{
857
857
  if (info->bulk_insert)
858
858
  {
859
 
    uint i;
 
859
    uint32_t i;
860
860
    for (i=0 ; i < info->s->base.keys ; i++)
861
861
    {
862
862
      if (is_tree_inited(& info->bulk_insert[i]))