1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2001, 2005 MySQL AB
|
2 |
||
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.
|
|
6 |
||
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.
|
|
11 |
||
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
#include "myisamdef.h" |
|
17 |
||
18 |
/*
|
|
19 |
** Find current row with read on position or read on key
|
|
20 |
** If inx >= 0 find record using key
|
|
21 |
** Return values:
|
|
22 |
** 0 = Ok.
|
|
23 |
** HA_ERR_KEY_NOT_FOUND = Row is deleted
|
|
24 |
** HA_ERR_END_OF_FILE = End of file
|
|
25 |
*/
|
|
26 |
||
27 |
||
28 |
int mi_rsame(MI_INFO *info, uchar *record, int inx) |
|
29 |
{
|
|
30 |
if (inx != -1 && ! mi_is_key_active(info->s->state.key_map, inx)) |
|
31 |
{
|
|
51.1.109
by Jay Pipes
Removed/replaced DBUG |
32 |
return(my_errno=HA_ERR_WRONG_INDEX); |
1
by brian
clean slate |
33 |
}
|
34 |
if (info->lastpos == HA_OFFSET_ERROR || info->update & HA_STATE_DELETED) |
|
35 |
{
|
|
51.1.109
by Jay Pipes
Removed/replaced DBUG |
36 |
return(my_errno=HA_ERR_KEY_NOT_FOUND); /* No current record */ |
1
by brian
clean slate |
37 |
}
|
38 |
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); |
|
39 |
||
40 |
/* Read row from data file */
|
|
41 |
if (fast_mi_readinfo(info)) |
|
51.1.109
by Jay Pipes
Removed/replaced DBUG |
42 |
return(my_errno); |
1
by brian
clean slate |
43 |
|
44 |
if (inx >= 0) |
|
45 |
{
|
|
46 |
info->lastinx=inx; |
|
47 |
info->lastkey_length=_mi_make_key(info,(uint) inx,info->lastkey,record, |
|
48 |
info->lastpos); |
|
49 |
if (info->s->concurrent_insert) |
|
50 |
rw_rdlock(&info->s->key_root_lock[inx]); |
|
51 |
VOID(_mi_search(info,info->s->keyinfo+inx,info->lastkey, USE_WHOLE_KEY, |
|
52 |
SEARCH_SAME, |
|
53 |
info->s->state.key_root[inx])); |
|
54 |
if (info->s->concurrent_insert) |
|
55 |
rw_unlock(&info->s->key_root_lock[inx]); |
|
56 |
}
|
|
57 |
||
58 |
if (!(*info->read_record)(info,info->lastpos,record)) |
|
51.1.109
by Jay Pipes
Removed/replaced DBUG |
59 |
return(0); |
1
by brian
clean slate |
60 |
if (my_errno == HA_ERR_RECORD_DELETED) |
61 |
my_errno=HA_ERR_KEY_NOT_FOUND; |
|
51.1.109
by Jay Pipes
Removed/replaced DBUG |
62 |
return(my_errno); |
1
by brian
clean slate |
63 |
} /* mi_rsame */ |