mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / myisammrg / myrg_rlast.c
blob8becec23a448df5ffce6ab38fe2d3c5b650f7d84
1 /* Copyright (c) 2000, 2001, 2003, 2005-2007 MySQL AB
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.
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.
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 02110-1301, USA */
16 #include "myrg_def.h"
18 /* Read last row with the same key as the previous read. */
20 int myrg_rlast(MYRG_INFO *info, uchar *buf, int inx)
22 MYRG_TABLE *table;
23 MI_INFO *mi;
24 int err;
26 if (_myrg_init_queue(info,inx, HA_READ_KEY_OR_PREV))
27 return my_errno;
29 for (table=info->open_tables ; table < info->end_table ; table++)
31 if ((err=mi_rlast(table->table,NULL,inx)))
33 if (err == HA_ERR_END_OF_FILE)
34 continue;
35 return err;
37 /* adding to queue */
38 queue_insert(&(info->by_key),(uchar *)table);
40 /* We have done a read in all tables */
41 info->last_used_table=table;
43 if (!info->by_key.elements)
44 return HA_ERR_END_OF_FILE;
46 mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table;
47 return _myrg_mi_read_record(mi,buf);