20 int heap_update(
HP_INFO *info,
const uchar *old,
const uchar *heap_new)
24 my_bool auto_key_changed= 0;
26 DBUG_ENTER(
"heap_update");
29 pos=info->current_ptr;
31 if (info->opt_flag & READ_CHECK_USED && hp_rectest(info,old))
32 DBUG_RETURN(my_errno);
33 if (--(share->records) < share->blength >> 1) share->blength>>= 1;
36 p_lastinx= share->keydef + info->lastinx;
37 for (keydef= share->keydef, end= keydef + share->keys; keydef < end; keydef++)
39 if (hp_rec_key_cmp(keydef, old, heap_new, 0))
41 if ((*keydef->delete_key)(info, keydef, old, pos, keydef == p_lastinx) ||
42 (*keydef->write_key)(info, keydef, heap_new, pos))
44 if (share->auto_key == (uint) (keydef - share->keydef + 1))
49 memcpy(pos,heap_new,(
size_t) share->reclength);
50 if (++(share->records) == share->blength) share->blength+= share->blength;
52 #if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG)
53 DBUG_EXECUTE(
"check_heap",heap_check_heap(info, 0););
56 heap_update_auto_increment(info, heap_new);
60 if (my_errno == HA_ERR_FOUND_DUPP_KEY)
62 info->errkey = (int) (keydef - share->keydef);
63 if (keydef->algorithm == HA_KEY_ALG_BTREE)
66 if ((*keydef->write_key)(info, keydef, old, pos))
68 if (++(share->records) == share->blength)
69 share->blength+= share->blength;
70 DBUG_RETURN(my_errno);
74 while (keydef >= share->keydef)
76 if (hp_rec_key_cmp(keydef, old, heap_new, 0))
78 if ((*keydef->delete_key)(info, keydef, heap_new, pos, 0) ||
79 (*keydef->write_key)(info, keydef, old, pos))
85 if (++(share->records) == share->blength)
86 share->blength+= share->blength;
87 DBUG_RETURN(my_errno);