1 | /* Copyright (c) 2000, 2001, 2003, 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 | #include "myrg_def.h" |
18 | |
19 | /* Read last row with the same key as the previous read. */ |
20 | |
21 | int myrg_rlast(MYRG_INFO *info, uchar *buf, int inx) |
22 | { |
23 | MYRG_TABLE *table; |
24 | MI_INFO *mi; |
25 | int err; |
26 | |
27 | if (_myrg_init_queue(info,inx, HA_READ_KEY_OR_PREV)) |
28 | return my_errno; |
29 | |
30 | for (table=info->open_tables ; table < info->end_table ; table++) |
31 | { |
32 | if ((err=mi_rlast(table->table,NULL,inx))) |
33 | { |
34 | if (err == HA_ERR_END_OF_FILE) |
35 | continue; |
36 | return err; |
37 | } |
38 | /* adding to queue */ |
39 | queue_insert(&(info->by_key),(uchar *)table); |
40 | } |
41 | /* We have done a read in all tables */ |
42 | info->last_used_table=table; |
43 | |
44 | if (!info->by_key.elements) |
45 | return HA_ERR_END_OF_FILE; |
46 | |
47 | mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table; |
48 | return _myrg_mi_read_record(mi,buf); |
49 | } |
50 | |
51 | |