| 1 | /* Copyright (c) 2000, 2001, 2005-2007 MySQL AB |
| 2 | Use is subject to license terms |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by |
| 6 | the Free Software Foundation; version 2 of the License. |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program; if not, write to the Free Software |
| 15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ |
| 16 | |
| 17 | /* read record through position and fix key-position */ |
| 18 | /* As mi_rsame but supply a position */ |
| 19 | |
| 20 | #include "myisamdef.h" |
| 21 | |
| 22 | |
| 23 | /* |
| 24 | ** If inx >= 0 update index pointer |
| 25 | ** Returns one of the following values: |
| 26 | ** 0 = Ok. |
| 27 | ** HA_ERR_KEY_NOT_FOUND = Row is deleted |
| 28 | ** HA_ERR_END_OF_FILE = End of file |
| 29 | */ |
| 30 | |
| 31 | int mi_rsame_with_pos(MI_INFO *info, uchar *record, int inx, my_off_t filepos) |
| 32 | { |
| 33 | DBUG_ENTER("mi_rsame_with_pos" ); |
| 34 | DBUG_PRINT("enter" ,("index: %d filepos: %ld" , inx, (long) filepos)); |
| 35 | |
| 36 | if (inx < -1 || |
| 37 | (inx >= 0 && ! mi_is_key_active(info->s->state.key_map, inx))) |
| 38 | { |
| 39 | DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); |
| 40 | } |
| 41 | |
| 42 | info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); |
| 43 | if ((*info->s->read_rnd)(info,record,filepos,0)) |
| 44 | { |
| 45 | if (my_errno == HA_ERR_RECORD_DELETED) |
| 46 | my_errno=HA_ERR_KEY_NOT_FOUND; |
| 47 | DBUG_RETURN(my_errno); |
| 48 | } |
| 49 | info->lastpos=filepos; |
| 50 | info->lastinx=inx; |
| 51 | if (inx >= 0) |
| 52 | { |
| 53 | info->lastkey_length=_mi_make_key(info,(uint) inx,info->lastkey,record, |
| 54 | info->lastpos); |
| 55 | info->update|=HA_STATE_KEY_CHANGED; /* Don't use indexposition */ |
| 56 | } |
| 57 | DBUG_RETURN(0); |
| 58 | } /* mi_rsame_pos */ |
| 59 | |