MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
myrg_rfirst.c
1 /* Copyright (C) 2000-2001, 2003 MySQL 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 02110-1301, USA */
15 
16 #include "myrg_def.h"
17 
18  /* Read first row according to specific key */
19 
20 int myrg_rfirst(MYRG_INFO *info, uchar *buf, int inx)
21 {
23  MI_INFO *mi;
24  int err;
25 
26  if (_myrg_init_queue(info,inx,HA_READ_KEY_OR_NEXT))
27  return my_errno;
28 
29  for (table=info->open_tables ; table != info->end_table ; table++)
30  {
31  if ((err=mi_rfirst(table->table,NULL,inx)))
32  {
33  if (err == HA_ERR_END_OF_FILE)
34  continue;
35  return err;
36  }
37  /* adding to queue */
38  queue_insert(&(info->by_key),(uchar *)table);
39  }
40  /* We have done a read in all tables */
41  info->last_used_table=table;
42 
43  if (!info->by_key.elements)
44  return HA_ERR_END_OF_FILE;
45 
46  mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table;
47  return _myrg_mi_read_record(mi,buf);
48 }