1 | /* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ |
15 | |
16 | /* read record through position and fix key-position */ |
17 | /* As maria_rsame but supply a position */ |
18 | |
19 | #include "maria_def.h" |
20 | |
21 | |
22 | /* |
23 | Read row based on postion |
24 | |
25 | @param inx If inx >= 0 postion the given index on found row |
26 | |
27 | @return |
28 | @retval 0 Ok |
29 | @retval HA_ERR_KEY_NOT_FOUND Row is deleted |
30 | @retval HA_ERR_END_OF_FILE End of file |
31 | */ |
32 | |
33 | int maria_rsame_with_pos(MARIA_HA *info, uchar *record, int inx, |
34 | MARIA_RECORD_POS filepos) |
35 | { |
36 | DBUG_ENTER("maria_rsame_with_pos" ); |
37 | DBUG_PRINT("enter" ,("index: %d filepos: %ld" , inx, (long) filepos)); |
38 | |
39 | if (inx < -1 || |
40 | (inx >= 0 && ! maria_is_key_active(info->s->state.key_map, inx))) |
41 | { |
42 | DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); |
43 | } |
44 | |
45 | info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); |
46 | if ((*info->s->read_record)(info, record, filepos)) |
47 | { |
48 | if (my_errno == HA_ERR_RECORD_DELETED) |
49 | my_errno=HA_ERR_KEY_NOT_FOUND; |
50 | DBUG_RETURN(my_errno); |
51 | } |
52 | info->cur_row.lastpos= filepos; |
53 | info->lastinx= inx; |
54 | if (inx >= 0) |
55 | { |
56 | (*info->s->keyinfo[inx].make_key)(info, &info->last_key, (uint) inx, |
57 | info->lastkey_buff, |
58 | record, info->cur_row.lastpos, |
59 | info->cur_row.trid); |
60 | info->update|=HA_STATE_KEY_CHANGED; /* Don't use indexposition */ |
61 | } |
62 | DBUG_RETURN(0); |
63 | } /* maria_rsame_pos */ |
64 | |