~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_write.c

  • Committer: Jay Pipes
  • Date: 2008-07-16 16:14:22 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080716161422-fy1bl8o5q7m8kglq
Removed all DBUG symbols from heap storage engine

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