~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_write.c

Removed/replaced DBUG symbols and TRUE/FALSE

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
  HP_KEYDEF *keydef, *end;
35
35
  uchar *pos;
36
36
  HP_SHARE *share=info->s;
 
37
  DBUG_ENTER("heap_write");
 
38
#ifndef DBUG_OFF
 
39
  if (info->mode & O_RDONLY)
 
40
  {
 
41
    DBUG_RETURN(my_errno=EACCES);
 
42
  }
 
43
#endif
37
44
  if (!(pos=next_free_record_pos(share)))
38
 
    return(my_errno);
 
45
    DBUG_RETURN(my_errno);
39
46
  share->changed=1;
40
47
 
41
48
  for (keydef = share->keydef, end = keydef + share->keys; keydef < end;
52
59
  info->current_ptr=pos;
53
60
  info->current_hash_ptr=0;
54
61
  info->update|=HA_STATE_AKTIV;
 
62
#if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG)
 
63
  DBUG_EXECUTE("check_heap",heap_check_heap(info, 0););
 
64
#endif
55
65
  if (share->auto_key)
56
66
    heap_update_auto_increment(info, record);
57
 
  return(0);
 
67
  DBUG_RETURN(0);
58
68
 
59
69
err:
 
70
  if (my_errno == HA_ERR_FOUND_DUPP_KEY)
 
71
    DBUG_PRINT("info",("Duplicate key: %d", (int) (keydef - share->keydef)));
60
72
  info->errkey= keydef - share->keydef;
61
73
  /*
62
74
    We don't need to delete non-inserted key from rb-tree.  Also, if
80
92
  share->del_link=pos;
81
93
  pos[share->reclength]=0;                      /* Record deleted */
82
94
 
83
 
  return(my_errno);
 
95
  DBUG_RETURN(my_errno);
84
96
} /* heap_write */
85
97
 
86
98
/* 
123
135
  int block_pos;
124
136
  uchar *pos;
125
137
  size_t length;
 
138
  DBUG_ENTER("next_free_record_pos");
126
139
 
127
140
  if (info->del_link)
128
141
  {
129
142
    pos=info->del_link;
130
143
    info->del_link= *((uchar**) pos);
131
144
    info->deleted--;
132
 
    return(pos);
 
145
    DBUG_PRINT("exit",("Used old position: 0x%lx",(long) pos));
 
146
    DBUG_RETURN(pos);
133
147
  }
134
148
  if (!(block_pos=(info->records % info->block.records_in_block)))
135
149
  {
137
151
        (info->data_length + info->index_length >= info->max_table_size))
138
152
    {
139
153
      my_errno=HA_ERR_RECORD_FILE_FULL;
140
 
      return(NULL);
 
154
      DBUG_RETURN(NULL);
141
155
    }
142
156
    if (hp_get_new_block(&info->block,&length))
143
 
      return(NULL);
 
157
      DBUG_RETURN(NULL);
144
158
    info->data_length+=length;
145
159
  }
146
 
  return((uchar*) info->block.level_info[0].last_blocks+
 
160
  DBUG_PRINT("exit",("Used new position: 0x%lx",
 
161
                     (long) ((uchar*) info->block.level_info[0].last_blocks+
 
162
                             block_pos * info->block.recbuffer)));
 
163
  DBUG_RETURN((uchar*) info->block.level_info[0].last_blocks+
147
164
              block_pos*info->block.recbuffer);
148
165
}
149
166
 
179
196
  HP_SHARE *share = info->s;
180
197
  int flag;
181
198
  ulong halfbuff,hashnr,first_index;
182
 
  uchar *ptr_to_rec= NULL,*ptr_to_rec2= NULL;
183
 
  HASH_INFO *empty, *gpos= NULL, *gpos2= NULL, *pos;
 
199
  uchar *ptr_to_rec,*ptr_to_rec2;
 
200
  HASH_INFO *empty, *gpos, *gpos2= NULL, *pos;
 
201
  DBUG_ENTER("hp_write_key");
184
202
 
185
203
  flag=0;
186
204
  if (!(empty= hp_find_free_hash(share,&keyinfo->block,share->records)))
187
 
    return(-1);                         /* No more memory */
 
205
    DBUG_RETURN(-1);                            /* No more memory */
188
206
  halfbuff= (long) share->blength >> 1;
189
207
  pos= hp_find_hash(&keyinfo->block,(first_index=share->records-halfbuff));
190
208
  
355
373
      {
356
374
        if (! hp_rec_key_cmp(keyinfo, record, pos->ptr_to_rec, 1))
357
375
        {
358
 
          return(my_errno=HA_ERR_FOUND_DUPP_KEY);
 
376
          DBUG_RETURN(my_errno=HA_ERR_FOUND_DUPP_KEY);
359
377
        }
360
378
      } while ((pos=pos->next_key));
361
379
    }
362
380
  }
363
 
  return(0);
 
381
  DBUG_RETURN(0);
364
382
}
365
383
 
366
384
        /* Returns ptr to block, and allocates block if neaded */