~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_update.c

  • Committer: Jay Pipes
  • Date: 2008-09-11 16:03:22 UTC
  • mto: (383.5.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 386.
  • Revision ID: jay@mysql.com-20080911160322-vrl0k1djo6q6ytv1
Removed SQL_MODE variances from comment_table.test and ensured correct error thrown when a comment that is too long was input.  After moving to proto buffer definition for table, the 2048 length will go away.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* Update an old row in a MyISAM table */
17
17
 
18
 
#include "myisam_priv.h"
19
 
#include <drizzled/util/test.h>
20
 
 
21
 
using namespace drizzled;
22
 
 
23
 
int mi_update(register MI_INFO *info, const unsigned char *oldrec, unsigned char *newrec)
 
18
#include "myisamdef.h"
 
19
 
 
20
int mi_update(register MI_INFO *info, const uchar *oldrec, uchar *newrec)
24
21
{
25
22
  int flag,key_changed,save_errno;
26
 
  register internal::my_off_t pos;
27
 
  uint32_t i;
28
 
  unsigned char old_key[MI_MAX_KEY_BUFF],*new_key;
 
23
  register my_off_t pos;
 
24
  uint i;
 
25
  uchar old_key[MI_MAX_KEY_BUFF],*new_key;
29
26
  bool auto_key_changed=0;
30
27
  uint64_t changed;
31
28
  MYISAM_SHARE *share= info->s;
32
 
  internal::ha_checksum old_checksum= 0;
 
29
  ha_checksum old_checksum= 0;
33
30
 
34
31
  if (!(info->update & HA_STATE_AKTIV))
35
32
  {
36
 
    return(errno=HA_ERR_KEY_NOT_FOUND);
 
33
    return(my_errno=HA_ERR_KEY_NOT_FOUND);
37
34
  }
38
35
  if (share->options & HA_OPTION_READ_ONLY_DATA)
39
36
  {
40
 
    return(errno=EACCES);
 
37
    return(my_errno=EACCES);
41
38
  }
42
39
  if (info->state->key_file_length >= share->base.margin_key_file_length)
43
40
  {
44
 
    return(errno=HA_ERR_INDEX_FILE_FULL);
 
41
    return(my_errno=HA_ERR_INDEX_FILE_FULL);
45
42
  }
46
43
  pos=info->lastpos;
47
44
  if (_mi_readinfo(info,F_WRLCK,1))
48
 
    return(errno);
 
45
    return(my_errno);
49
46
 
50
47
  if (share->calc_checksum)
51
48
    old_checksum=info->checksum=(*share->calc_checksum)(info,oldrec);
52
49
  if ((*share->compare_record)(info,oldrec))
53
50
  {
54
 
    save_errno=errno;
 
51
    save_errno=my_errno;
55
52
    goto err_end;                       /* Record has changed */
56
53
  }
57
54
 
65
62
        mi_check_unique(info, def, newrec, mi_unique_hash(def, newrec),
66
63
                        info->lastpos))
67
64
    {
68
 
      save_errno=errno;
 
65
      save_errno=my_errno;
69
66
      goto err_end;
70
67
    }
71
68
  }
72
69
  if (_mi_mark_file_changed(info))
73
70
  {
74
 
    save_errno=errno;
 
71
    save_errno=my_errno;
75
72
    goto err_end;
76
73
  }
77
74
 
84
81
    if (mi_is_key_active(share->state.key_map, i))
85
82
    {
86
83
      {
87
 
        uint32_t new_length=_mi_make_key(info,i,new_key,newrec,pos);
88
 
        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);
89
86
 
90
87
        /* The above changed info->lastkey2. Inform mi_rnext_same(). */
91
88
        info->update&= ~HA_STATE_RNEXT_SAME;
125
122
    */
126
123
    MI_STATUS_INFO state;
127
124
    ha_rows org_split;
128
 
    internal::my_off_t org_delete_link;
 
125
    my_off_t org_delete_link;
129
126
 
130
127
    memcpy(&state, info->state, sizeof(state));
131
128
    org_split=       share->state.split;
156
153
    mi_update() must always pass !0 value as operation, since even if
157
154
    there is no index change there could be data change.
158
155
  */
159
 
  _mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE);
 
156
  VOID(_mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE));
 
157
  if (info->invalidator != 0)
 
158
  {
 
159
    (*info->invalidator)(info->filename);
 
160
    info->invalidator=0;
 
161
  }
160
162
  return(0);
161
163
 
162
164
err:
163
 
  save_errno=errno;
 
165
  save_errno=my_errno;
164
166
  if (changed)
165
167
    key_changed|= HA_STATE_CHANGED;
166
 
  if (errno == HA_ERR_FOUND_DUPP_KEY || errno == HA_ERR_OUT_OF_MEM ||
167
 
      errno == HA_ERR_RECORD_FILE_FULL)
 
168
  if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_OUT_OF_MEM ||
 
169
      my_errno == HA_ERR_RECORD_FILE_FULL)
168
170
  {
169
171
    info->errkey= (int) i;
170
172
    flag=0;
173
175
      if (((uint64_t) 1 << i) & changed)
174
176
      {
175
177
        {
176
 
          uint32_t new_length=_mi_make_key(info,i,new_key,newrec,pos);
177
 
          uint32_t old_length= _mi_make_key(info,i,old_key,oldrec,pos);
 
178
          uint new_length=_mi_make_key(info,i,new_key,newrec,pos);
 
179
          uint old_length= _mi_make_key(info,i,old_key,oldrec,pos);
178
180
          if ((flag++ && _mi_ck_delete(info,i,new_key,new_length)) ||
179
181
              _mi_ck_write(info,i,old_key,old_length))
180
182
            break;
191
193
                 key_changed);
192
194
 
193
195
 err_end:
194
 
  _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
 
196
  VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
195
197
  if (save_errno == HA_ERR_KEY_NOT_FOUND)
196
198
  {
197
199
    mi_print_error(info->s, HA_ERR_CRASHED);
198
200
    save_errno=HA_ERR_CRASHED;
199
201
  }
200
 
  return(errno=save_errno);
 
202
  return(my_errno=save_errno);
201
203
} /* mi_update */