~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_update.c

  • Committer: Patrick Galbraith
  • Date: 2008-07-24 16:57:40 UTC
  • mto: (202.2.4 rename-mysql-to-drizzle)
  • mto: This revision was merged to the branch mainline in revision 212.
  • Revision ID: patg@ishvara-20080724165740-x58yw6zs6d9o17lf
Most everything working with client rename
mysqlslap test still fails... can't connect to the server

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
/* Update an old row in a MyISAM table */
17
17
 
18
18
#include "myisamdef.h"
19
 
#include <drizzled/util/test.h>
20
19
 
21
 
int mi_update(register MI_INFO *info, const unsigned char *oldrec, unsigned char *newrec)
 
20
int mi_update(register MI_INFO *info, const uchar *oldrec, uchar *newrec)
22
21
{
23
22
  int flag,key_changed,save_errno;
24
23
  register my_off_t pos;
25
 
  uint32_t i;
26
 
  unsigned char old_key[MI_MAX_KEY_BUFF],*new_key;
27
 
  bool auto_key_changed=0;
 
24
  uint i;
 
25
  uchar old_key[MI_MAX_KEY_BUFF],*new_key;
 
26
  my_bool auto_key_changed=0;
28
27
  uint64_t changed;
29
28
  MYISAM_SHARE *share= info->s;
30
29
  ha_checksum old_checksum= 0;
82
81
    if (mi_is_key_active(share->state.key_map, i))
83
82
    {
84
83
      {
85
 
        uint32_t new_length=_mi_make_key(info,i,new_key,newrec,pos);
86
 
        uint32_t old_length=_mi_make_key(info,i,old_key,oldrec,pos);
 
84
        uint new_length=_mi_make_key(info,i,new_key,newrec,pos);
 
85
        uint old_length=_mi_make_key(info,i,old_key,oldrec,pos);
87
86
 
88
87
        /* The above changed info->lastkey2. Inform mi_rnext_same(). */
89
88
        info->update&= ~HA_STATE_RNEXT_SAME;
90
89
 
91
90
        if (new_length != old_length ||
92
 
            memcmp(old_key,new_key,new_length))
 
91
            memcmp((uchar*) old_key,(uchar*) new_key,new_length))
93
92
        {
94
93
          if ((int) i == info->lastinx)
95
94
            key_changed|=HA_STATE_WRITTEN;      /* Mark that keyfile changed */
125
124
    ha_rows org_split;
126
125
    my_off_t org_delete_link;
127
126
 
128
 
    memcpy(&state, info->state, sizeof(state));
 
127
    memcpy((char*) &state, (char*) info->state, sizeof(state));
129
128
    org_split=       share->state.split;
130
129
    org_delete_link= share->state.dellink;
131
130
    if ((*share->update_record)(info,pos,newrec))
132
131
      goto err;
133
132
    if (!key_changed &&
134
 
        (memcmp(&state, info->state, sizeof(state)) ||
 
133
        (memcmp((char*) &state, (char*) info->state, sizeof(state)) ||
135
134
         org_split != share->state.split ||
136
135
         org_delete_link != share->state.dellink))
137
136
      key_changed|= HA_STATE_CHANGED;           /* Must update index file */
144
143
 
145
144
  info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED | HA_STATE_AKTIV |
146
145
                 key_changed);
 
146
  myisam_log_record(MI_LOG_UPDATE,info,newrec,info->lastpos,0);
147
147
  /*
148
148
    Every myisam function that updates myisam table must end with
149
149
    call to _mi_writeinfo(). If operation (second param of
154
154
    mi_update() must always pass !0 value as operation, since even if
155
155
    there is no index change there could be data change.
156
156
  */
157
 
  _mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE);
 
157
  VOID(_mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE));
158
158
  if (info->invalidator != 0)
159
159
  {
160
160
    (*info->invalidator)(info->filename);
176
176
      if (((uint64_t) 1 << i) & changed)
177
177
      {
178
178
        {
179
 
          uint32_t new_length=_mi_make_key(info,i,new_key,newrec,pos);
180
 
          uint32_t old_length= _mi_make_key(info,i,old_key,oldrec,pos);
 
179
          uint new_length=_mi_make_key(info,i,new_key,newrec,pos);
 
180
          uint old_length= _mi_make_key(info,i,old_key,oldrec,pos);
181
181
          if ((flag++ && _mi_ck_delete(info,i,new_key,new_length)) ||
182
182
              _mi_ck_write(info,i,old_key,old_length))
183
183
            break;
194
194
                 key_changed);
195
195
 
196
196
 err_end:
197
 
  _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
 
197
  myisam_log_record(MI_LOG_UPDATE,info,newrec,info->lastpos,my_errno);
 
198
  VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
198
199
  if (save_errno == HA_ERR_KEY_NOT_FOUND)
199
200
  {
200
201
    mi_print_error(info->s, HA_ERR_CRASHED);