| 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 through all rows sequntially */ |
| 17 | |
| 18 | #include "maria_def.h" |
| 19 | |
| 20 | int maria_scan_init(register MARIA_HA *info) |
| 21 | { |
| 22 | DBUG_ENTER("maria_scan_init" ); |
| 23 | |
| 24 | info->cur_row.nextpos= info->s->pack.header_length; /* Read first record */ |
| 25 | info->lastinx= -1; /* Can't forward or backward */ |
| 26 | if (info->opt_flag & WRITE_CACHE_USED && flush_io_cache(&info->rec_cache)) |
| 27 | DBUG_RETURN(my_errno); |
| 28 | |
| 29 | if ((*info->s->scan_init)(info)) |
| 30 | DBUG_RETURN(my_errno); |
| 31 | DBUG_RETURN(0); |
| 32 | } |
| 33 | |
| 34 | /* |
| 35 | Read a row based on position. |
| 36 | |
| 37 | SYNOPSIS |
| 38 | maria_scan() |
| 39 | info Maria handler |
| 40 | record Read data here |
| 41 | |
| 42 | RETURN |
| 43 | 0 ok |
| 44 | HA_ERR_END_OF_FILE End of file |
| 45 | HA_ERR_RECORD_DELETED Record was deleted (can only happen for static rec) |
| 46 | # Error code |
| 47 | */ |
| 48 | |
| 49 | int maria_scan(MARIA_HA *info, uchar *record) |
| 50 | { |
| 51 | DBUG_ENTER("maria_scan" ); |
| 52 | /* Init all but update-flag */ |
| 53 | info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); |
| 54 | DBUG_RETURN((*info->s->scan)(info, record, info->cur_row.nextpos, 1)); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | void maria_scan_end(MARIA_HA *info) |
| 59 | { |
| 60 | (*info->s->scan_end)(info); |
| 61 | } |
| 62 | |
| 63 | |
| 64 | int _ma_def_scan_remember_pos(MARIA_HA *info, MARIA_RECORD_POS *lastpos) |
| 65 | { |
| 66 | *lastpos= info->cur_row.lastpos; |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | int _ma_def_scan_restore_pos(MARIA_HA *info, MARIA_RECORD_POS lastpos) |
| 72 | { |
| 73 | info->cur_row.nextpos= lastpos; |
| 74 | return 0; |
| 75 | } |
| 76 | |