2006-12-31 01:02:27 +01:00
|
|
|
/* Copyright (C) 2000-2003 MySQL AB
|
2000-08-14 13:27:19 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2000-08-14 13:27:19 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
2001-10-08 03:58:07 +02:00
|
|
|
#include "myrg_def.h"
|
2000-08-14 13:27:19 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Read next row with the same key as previous read
|
|
|
|
*/
|
|
|
|
|
|
|
|
int myrg_rnext(MYRG_INFO *info, byte *buf, int inx)
|
|
|
|
{
|
|
|
|
int err;
|
2000-09-14 01:39:07 +02:00
|
|
|
MI_INFO *mi;
|
2000-08-14 13:27:19 +02:00
|
|
|
|
2002-06-25 16:32:16 +02:00
|
|
|
if (!info->current_table)
|
2002-07-04 12:25:13 +02:00
|
|
|
return (HA_ERR_KEY_NOT_FOUND);
|
2002-06-25 16:32:16 +02:00
|
|
|
|
2000-08-14 13:27:19 +02:00
|
|
|
/* at first, do rnext for the table found before */
|
2000-09-14 01:39:07 +02:00
|
|
|
if ((err=mi_rnext(info->current_table->table,NULL,inx)))
|
2000-08-14 13:27:19 +02:00
|
|
|
{
|
2000-09-14 01:39:07 +02:00
|
|
|
if (err == HA_ERR_END_OF_FILE)
|
2001-05-16 23:06:30 +02:00
|
|
|
{
|
2000-09-14 01:39:07 +02:00
|
|
|
queue_remove(&(info->by_key),0);
|
2001-05-16 23:06:30 +02:00
|
|
|
if (!info->by_key.elements)
|
|
|
|
return HA_ERR_END_OF_FILE;
|
|
|
|
}
|
2000-09-14 01:39:07 +02:00
|
|
|
else
|
|
|
|
return err;
|
2000-08-14 13:27:19 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Found here, adding to queue */
|
|
|
|
queue_top(&(info->by_key))=(byte *)(info->current_table);
|
|
|
|
queue_replaced(&(info->by_key));
|
|
|
|
}
|
|
|
|
|
2000-09-14 01:39:07 +02:00
|
|
|
/* now, mymerge's read_next is as simple as one queue_top */
|
|
|
|
mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table;
|
2003-08-01 14:58:03 +02:00
|
|
|
return _myrg_mi_read_record(mi,buf);
|
2000-09-14 01:39:07 +02:00
|
|
|
}
|