MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:msvensson Date:February 28 2006 10:17am
Subject:bk commit into 5.0 tree (msvensson:1.2068) BUG#17377
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2068 06/02/28 11:17:40 msvensson@stripped +4 -0
  Bug#17377 Federated Engine returns wrong Data, always the rows with the highest ID
   - Always make rnd_pos reposition the cursor in the fetched result set.

  sql/ha_federated.h
    1.24 06/02/28 11:17:35 msvensson@stripped +0 -1
    Remove class variable "scan_flag"

  sql/ha_federated.cc
    1.60 06/02/28 11:17:35 msvensson@stripped +9 -20
    Remove the "scan_flag" variable. rnd_pos should always move to a new position in the result set. 
    The "scan" flag in rnd_init will protect from the old result set being 
    closed and a new fecthed. I think the "scan_flag" was added before check of the "scan" argument in rnd_init was added.

  mysql-test/t/federated.test
    1.22 06/02/28 11:17:35 msvensson@stripped +55 -0
    Add test for bug#17377

  mysql-test/r/federated.result
    1.26 06/02/28 11:17:35 msvensson@stripped +43 -0
    Update test result

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	msvensson
# Host:	devsrv-b.mysql.com
# Root:	/space/magnus/bug17377/my50-bug17377

--- 1.25/mysql-test/r/federated.result	2006-01-31 09:15:01 +01:00
+++ 1.26/mysql-test/r/federated.result	2006-02-28 11:17:35 +01:00
@@ -1558,6 +1558,49 @@
 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@stripped: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;

--- 1.21/mysql-test/t/federated.test	2006-01-31 09:14:53 +01:00
+++ 1.22/mysql-test/t/federated.test	2006-02-28 11:17:35 +01:00
@@ -1255,4 +1255,59 @@
 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@stripped:$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;

--- 1.59/sql/ha_federated.cc	2006-01-28 00:43:40 +01:00
+++ 1.60/sql/ha_federated.cc	2006-02-28 11:17:35 +01:00
@@ -740,7 +740,7 @@
 
 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 @@
     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 @@
 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));
 }
 
 

--- 1.23/sql/ha_federated.h	2006-01-28 00:43:40 +01:00
+++ 1.24/sql/ha_federated.h	2006-02-28 11:17:35 +01:00
@@ -153,7 +153,6 @@
   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()
Thread
bk commit into 5.0 tree (msvensson:1.2068) BUG#17377msvensson28 Feb