Commit 9251e7f7 authored by unknown's avatar unknown

Merge bk-internal:/home/bk/mysql-5.0

into  devsrv-b.mysql.com:/space/magnus/bug17377/my50-bug17377

parents cda64c11 84168eba
......@@ -1558,6 +1558,49 @@ id
3
4
5
DROP TABLE IF EXISTS federated.bug_17377_table;
CREATE TABLE federated.bug_17377_table (
`fld_cid` bigint(20) NOT NULL auto_increment,
`fld_name` varchar(255) NOT NULL default '',
`fld_parentid` bigint(20) NOT NULL default '0',
`fld_delt` int(1) NOT NULL default '0',
PRIMARY KEY (`fld_cid`),
KEY `fld_parentid` (`fld_parentid`),
KEY `fld_delt` (`fld_delt`),
KEY `fld_cid` (`fld_cid`)
) ENGINE=MyISAM;
insert into federated.bug_17377_table( fld_name )
values
("Mats"), ("Sivert"), ("Sigvard"), ("Torgny"), ("Torkel");
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
`fld_cid` bigint(20) NOT NULL auto_increment,
`fld_name` varchar(255) NOT NULL default '',
`fld_parentid` bigint(20) NOT NULL default '0',
`fld_delt` int(1) NOT NULL default '0',
PRIMARY KEY (`fld_cid`),
KEY `fld_parentid` (`fld_parentid`),
KEY `fld_delt` (`fld_delt`),
KEY `fld_cid` (`fld_cid`)
) ENGINE=FEDERATED
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/bug_17377_table';
select * from federated.t1 where fld_parentid=0 and fld_delt=0
order by fld_name;
fld_cid fld_name fld_parentid fld_delt
1 Mats 0 0
3 Sigvard 0 0
2 Sivert 0 0
4 Torgny 0 0
5 Torkel 0 0
select * from federated.t1 where fld_parentid=0 and fld_delt=0;
fld_cid fld_name fld_parentid fld_delt
1 Mats 0 0
2 Sivert 0 0
3 Sigvard 0 0
4 Torgny 0 0
5 Torkel 0 0
DROP TABLE federated.t1;
DROP TABLE federated.bug_17377_table;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
......
......@@ -1255,4 +1255,59 @@ INSERT INTO federated.t1 VALUES ();
SELECT LAST_INSERT_ID();
SELECT * FROM federated.t1;
#
# Bug#17377 Federated Engine returns wrong Data, always the rows
# with the highest ID
#
connection slave;
--disable_warnings
DROP TABLE IF EXISTS federated.bug_17377_table;
--enable_warnings
CREATE TABLE federated.bug_17377_table (
`fld_cid` bigint(20) NOT NULL auto_increment,
`fld_name` varchar(255) NOT NULL default '',
`fld_parentid` bigint(20) NOT NULL default '0',
`fld_delt` int(1) NOT NULL default '0',
PRIMARY KEY (`fld_cid`),
KEY `fld_parentid` (`fld_parentid`),
KEY `fld_delt` (`fld_delt`),
KEY `fld_cid` (`fld_cid`)
) ENGINE=MyISAM;
# Insert some test-data
insert into federated.bug_17377_table( fld_name )
values
("Mats"), ("Sivert"), ("Sigvard"), ("Torgny"), ("Torkel");
connection master;
--disable_warnings
DROP TABLE IF EXISTS federated.t1;
--enable_warnings
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.t1 (
`fld_cid` bigint(20) NOT NULL auto_increment,
`fld_name` varchar(255) NOT NULL default '',
`fld_parentid` bigint(20) NOT NULL default '0',
`fld_delt` int(1) NOT NULL default '0',
PRIMARY KEY (`fld_cid`),
KEY `fld_parentid` (`fld_parentid`),
KEY `fld_delt` (`fld_delt`),
KEY `fld_cid` (`fld_cid`)
) ENGINE=FEDERATED
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/bug_17377_table';
select * from federated.t1 where fld_parentid=0 and fld_delt=0
order by fld_name;
select * from federated.t1 where fld_parentid=0 and fld_delt=0;
DROP TABLE federated.t1;
connection slave;
DROP TABLE federated.bug_17377_table;
source include/federated_cleanup.inc;
......@@ -740,7 +740,7 @@ error:
ha_federated::ha_federated(TABLE *table_arg)
:handler(&federated_hton, table_arg),
mysql(0), stored_result(0), scan_flag(0),
mysql(0), stored_result(0),
ref_length(sizeof(MYSQL_ROW_OFFSET)), current_position(0)
{}
......@@ -2243,7 +2243,7 @@ int ha_federated::rnd_init(bool scan)
containing the correct record, hence update the wrong row!
*/
scan_flag= scan;
if (scan)
{
DBUG_PRINT("info", ("share->select_query %s", share->select_query));
......@@ -2365,24 +2365,13 @@ void ha_federated::position(const byte *record)
int ha_federated::rnd_pos(byte *buf, byte *pos)
{
DBUG_ENTER("ha_federated::rnd_pos");
/*
we do not need to do any of this if there has been a scan performed
already, or if this is an update and index_read_idx already has a result
set in which to build it's update query from
*/
if (scan_flag)
{
int retval;
statistic_increment(table->in_use->status_var.ha_read_rnd_count,
&LOCK_status);
memcpy_fixed(&current_position, pos, sizeof(MYSQL_ROW_OFFSET)); // pos
/* is not aligned */
stored_result->current_row= 0;
stored_result->data_cursor= current_position;
retval= rnd_next(buf);
DBUG_RETURN(retval);
}
DBUG_RETURN(0);
statistic_increment(table->in_use->status_var.ha_read_rnd_count,
&LOCK_status);
memcpy_fixed(&current_position, pos, sizeof(MYSQL_ROW_OFFSET));
stored_result->current_row= 0;
stored_result->data_cursor= current_position;
DBUG_RETURN(rnd_next(buf));
}
......
......@@ -153,7 +153,6 @@ class ha_federated: public handler
FEDERATED_SHARE *share; /* Shared lock info */
MYSQL *mysql; /* MySQL connection */
MYSQL_RES *stored_result;
bool scan_flag;
uint ref_length;
uint fetch_num; // stores the fetch num
MYSQL_ROW_OFFSET current_position; // Current position used by ::position()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment