~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_update.c

  • Committer: Stewart Smith
  • Date: 2008-07-25 03:48:54 UTC
  • mfrom: (207.1.1 drizzle)
  • mto: (210.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 211.
  • Revision ID: stewart@flamingspork.com-20080725034854-p34pdb0lhpoc159d
merge mainline and update md5 and crc32 plugins to new interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
  uint i;
25
25
  uchar old_key[MI_MAX_KEY_BUFF],*new_key;
26
26
  my_bool auto_key_changed=0;
27
 
  ulonglong changed;
 
27
  uint64_t changed;
28
28
  MYISAM_SHARE *share= info->s;
29
29
  ha_checksum old_checksum= 0;
30
 
  DBUG_ENTER("mi_update");
31
30
 
32
 
  DBUG_EXECUTE_IF("myisam_pretend_crashed_table_on_usage",
33
 
                  mi_print_error(info->s, HA_ERR_CRASHED);
34
 
                  DBUG_RETURN(my_errno= HA_ERR_CRASHED););
35
31
  if (!(info->update & HA_STATE_AKTIV))
36
32
  {
37
 
    DBUG_RETURN(my_errno=HA_ERR_KEY_NOT_FOUND);
 
33
    return(my_errno=HA_ERR_KEY_NOT_FOUND);
38
34
  }
39
35
  if (share->options & HA_OPTION_READ_ONLY_DATA)
40
36
  {
41
 
    DBUG_RETURN(my_errno=EACCES);
 
37
    return(my_errno=EACCES);
42
38
  }
43
39
  if (info->state->key_file_length >= share->base.margin_key_file_length)
44
40
  {
45
 
    DBUG_RETURN(my_errno=HA_ERR_INDEX_FILE_FULL);
 
41
    return(my_errno=HA_ERR_INDEX_FILE_FULL);
46
42
  }
47
43
  pos=info->lastpos;
48
44
  if (_mi_readinfo(info,F_WRLCK,1))
49
 
    DBUG_RETURN(my_errno);
 
45
    return(my_errno);
50
46
 
51
47
  if (share->calc_checksum)
52
48
    old_checksum=info->checksum=(*share->calc_checksum)(info,oldrec);
96
92
        {
97
93
          if ((int) i == info->lastinx)
98
94
            key_changed|=HA_STATE_WRITTEN;      /* Mark that keyfile changed */
99
 
          changed|=((ulonglong) 1 << i);
 
95
          changed|=((uint64_t) 1 << i);
100
96
          share->keyinfo[i].version++;
101
97
          if (share->keyinfo[i].ck_delete(info,i,old_key,old_length)) goto err;
102
98
          if (share->keyinfo[i].ck_insert(info,i,new_key,new_length)) goto err;
110
106
    If we are running with external locking, we must update the index file
111
107
    that something has changed.
112
108
  */
113
 
  if (changed || !my_disable_locking)
 
109
  if (changed)
114
110
    key_changed|= HA_STATE_CHANGED;
115
111
 
116
112
  if (share->calc_checksum)
161
157
  VOID(_mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE));
162
158
  if (info->invalidator != 0)
163
159
  {
164
 
    DBUG_PRINT("info", ("invalidator... '%s' (update)", info->filename));
165
160
    (*info->invalidator)(info->filename);
166
161
    info->invalidator=0;
167
162
  }
168
 
  DBUG_RETURN(0);
 
163
  return(0);
169
164
 
170
165
err:
171
 
  DBUG_PRINT("error",("key: %d  errno: %d",i,my_errno));
172
166
  save_errno=my_errno;
173
167
  if (changed)
174
168
    key_changed|= HA_STATE_CHANGED;
179
173
    flag=0;
180
174
    do
181
175
    {
182
 
      if (((ulonglong) 1 << i) & changed)
 
176
      if (((uint64_t) 1 << i) & changed)
183
177
      {
184
178
        {
185
179
          uint new_length=_mi_make_key(info,i,new_key,newrec,pos);
207
201
    mi_print_error(info->s, HA_ERR_CRASHED);
208
202
    save_errno=HA_ERR_CRASHED;
209
203
  }
210
 
  DBUG_RETURN(my_errno=save_errno);
 
204
  return(my_errno=save_errno);
211
205
} /* mi_update */