1 /* Copyright (c) 2000, 2001, 2005-2007 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #include "myisamdef.h"
19 ** Find current row with read on position or read on key
20 ** If inx >= 0 find record using key
23 ** HA_ERR_KEY_NOT_FOUND = Row is deleted
24 ** HA_ERR_END_OF_FILE = End of file
28 int mi_rsame(MI_INFO
*info
, uchar
*record
, int inx
)
30 DBUG_ENTER("mi_rsame");
32 if (inx
!= -1 && ! mi_is_key_active(info
->s
->state
.key_map
, inx
))
34 DBUG_RETURN(my_errno
=HA_ERR_WRONG_INDEX
);
36 if (info
->lastpos
== HA_OFFSET_ERROR
|| info
->update
& HA_STATE_DELETED
)
38 DBUG_RETURN(my_errno
=HA_ERR_KEY_NOT_FOUND
); /* No current record */
40 info
->update
&= (HA_STATE_CHANGED
| HA_STATE_ROW_CHANGED
);
42 /* Read row from data file */
43 if (fast_mi_readinfo(info
))
44 DBUG_RETURN(my_errno
);
49 info
->lastkey_length
=_mi_make_key(info
,(uint
) inx
,info
->lastkey
,record
,
51 if (info
->s
->concurrent_insert
)
52 rw_rdlock(&info
->s
->key_root_lock
[inx
]);
53 VOID(_mi_search(info
,info
->s
->keyinfo
+inx
,info
->lastkey
, USE_WHOLE_KEY
,
55 info
->s
->state
.key_root
[inx
]));
56 if (info
->s
->concurrent_insert
)
57 rw_unlock(&info
->s
->key_root_lock
[inx
]);
60 if (!(*info
->read_record
)(info
,info
->lastpos
,record
))
62 if (my_errno
== HA_ERR_RECORD_DELETED
)
63 my_errno
=HA_ERR_KEY_NOT_FOUND
;
64 DBUG_RETURN(my_errno
);