List:Commits« Previous MessageNext Message »
From:holyfoot Date:January 12 2007 11:46am
Subject:bk commit into 5.1 tree (holyfoot:1.2384) BUG#24186
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of hf. When hf 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@stripped, 2007-01-12 15:46:20+04:00, holyfoot@stripped +3 -0
  bug #24186 (nested query across partitions returns fewer records)
  
  Subselect's engine checks table->status field to determine if the
  record was properly found when we use keyread upon the table.
  Partition engine checks all the partitions for given key
  before return. So if matching record was found in the first
  partition and no matching records were found in the second, 
  we have table->status == NOT_FOUND after the function, what
  makes subselects to skip matching records.
  The patch adds table->status= 0 if we actually found something.

  mysql-test/r/partition.result@stripped, 2007-01-12 15:46:14+04:00, holyfoot@stripped +81 -0
    result fixed

  mysql-test/t/partition.test@stripped, 2007-01-12 15:46:14+04:00, holyfoot@stripped +93 -0
    testcase

  sql/ha_partition.cc@stripped, 2007-01-12 15:46:14+04:00, holyfoot@stripped +3 -0
    table->status set to 0 if we found something in previous partitions

# 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:	holyfoot
# Host:	deer.(none)
# Root:	/home/hf/work/24186/my51-24186

--- 1.57/mysql-test/r/partition.result	2007-01-12 15:46:29 +04:00
+++ 1.58/mysql-test/r/partition.result	2007-01-12 15:46:29 +04:00
@@ -1138,4 +1138,85 @@ PARTITION p_100 VALUES LESS THAN (100), 
 PARTITION p_X VALUES LESS THAN MAXVALUE 
 );
 drop table t1;
+CREATE TABLE t2 (
+taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+id int(11) NOT NULL DEFAULT '0',
+PRIMARY KEY (id,taken),
+KEY taken (taken)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t2 VALUES 
+('2006-09-27 21:50:01',16421),
+('2006-10-02 21:50:01',16421),
+('2006-09-27 21:50:01',19092),
+('2006-09-28 21:50:01',19092),
+('2006-09-29 21:50:01',19092),
+('2006-09-30 21:50:01',19092),
+('2006-10-01 21:50:01',19092),
+('2006-10-02 21:50:01',19092),
+('2006-09-27 21:50:01',22589),
+('2006-09-29 21:50:01',22589);
+CREATE TABLE t1 (
+id int(8) NOT NULL,
+PRIMARY KEY (id)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES 
+(16421),
+(19092),
+(22589);
+CREATE TABLE t4 (
+taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+id int(11) NOT NULL DEFAULT '0',
+PRIMARY KEY (id,taken),
+KEY taken (taken)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 
+PARTITION BY RANGE (to_days(taken)) 
+(
+PARTITION p01 VALUES LESS THAN (732920) , 
+PARTITION p02 VALUES LESS THAN (732950) , 
+PARTITION p03 VALUES LESS THAN MAXVALUE ) ;
+INSERT INTO t4 select * from t2;
+set @f_date='2006-09-28';
+set @t_date='2006-10-02';
+SELECT t1.id AS MyISAM_part
+FROM t1
+WHERE t1.id IN (
+SELECT distinct id
+FROM t4
+WHERE taken BETWEEN @f_date AND date_add(@t_date, INTERVAL 1 DAY))
+ORDER BY t1.id
+;
+MyISAM_part
+16421
+19092
+22589
+drop table t1, t2, t4;
+CREATE TABLE t1 (
+taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+id int(11) NOT NULL DEFAULT '0',
+status varchar(20) NOT NULL DEFAULT '',
+PRIMARY KEY (id,taken)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+PARTITION BY RANGE (to_days(taken))
+(
+PARTITION p15 VALUES LESS THAN (732950) ,
+PARTITION p16 VALUES LESS THAN MAXVALUE ) ;
+INSERT INTO t1 VALUES
+('2006-09-27 21:50:01',22589,'Open'),
+('2006-09-29 21:50:01',22589,'Verified');
+DROP TABLE IF EXISTS t2;
+Warnings:
+Note	1051	Unknown table 't2'
+CREATE TABLE t2 (
+id int(8) NOT NULL,
+severity tinyint(4) NOT NULL DEFAULT '0',
+priority tinyint(4) NOT NULL DEFAULT '0',
+status varchar(20) DEFAULT NULL,
+alien tinyint(4) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t2 VALUES
+(22589,1,1,'Need Feedback',0);
+SELECT t2.id FROM t2 WHERE t2.id IN (SELECT id FROM t1 WHERE status = 'Verified');
+id
+22589
+drop table t1, t2;
 End of 5.1 tests

--- 1.51/mysql-test/t/partition.test	2007-01-12 15:46:29 +04:00
+++ 1.52/mysql-test/t/partition.test	2007-01-12 15:46:29 +04:00
@@ -1370,4 +1370,97 @@ REORGANIZE PARTITION p_X INTO ( 
 
 drop table t1;
 
+#
+# Bug #24186 (nested query across partitions returns fewer records)
+#
+
+CREATE TABLE t2 (
+  taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  id int(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (id,taken),
+  KEY taken (taken)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+INSERT INTO t2 VALUES 
+('2006-09-27 21:50:01',16421),
+('2006-10-02 21:50:01',16421),
+('2006-09-27 21:50:01',19092),
+('2006-09-28 21:50:01',19092),
+('2006-09-29 21:50:01',19092),
+('2006-09-30 21:50:01',19092),
+('2006-10-01 21:50:01',19092),
+('2006-10-02 21:50:01',19092),
+('2006-09-27 21:50:01',22589),
+('2006-09-29 21:50:01',22589);
+
+CREATE TABLE t1 (
+  id int(8) NOT NULL,
+  PRIMARY KEY (id)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+INSERT INTO t1 VALUES 
+(16421),
+(19092),
+(22589);
+
+CREATE TABLE t4 (
+  taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  id int(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (id,taken),
+  KEY taken (taken)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 
+PARTITION BY RANGE (to_days(taken)) 
+(
+PARTITION p01 VALUES LESS THAN (732920) , 
+PARTITION p02 VALUES LESS THAN (732950) , 
+PARTITION p03 VALUES LESS THAN MAXVALUE ) ;
+
+INSERT INTO t4 select * from t2;
+
+set @f_date='2006-09-28';
+set @t_date='2006-10-02';
+
+SELECT t1.id AS MyISAM_part
+FROM t1
+WHERE t1.id IN (
+    SELECT distinct id
+    FROM t4
+    WHERE taken BETWEEN @f_date AND date_add(@t_date, INTERVAL 1 DAY))
+ORDER BY t1.id
+;
+
+drop table t1, t2, t4;
+
+CREATE TABLE t1 (
+  taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  id int(11) NOT NULL DEFAULT '0',
+  status varchar(20) NOT NULL DEFAULT '',
+  PRIMARY KEY (id,taken)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+PARTITION BY RANGE (to_days(taken))
+(
+PARTITION p15 VALUES LESS THAN (732950) ,
+PARTITION p16 VALUES LESS THAN MAXVALUE ) ;
+
+
+INSERT INTO t1 VALUES
+('2006-09-27 21:50:01',22589,'Open'),
+('2006-09-29 21:50:01',22589,'Verified');
+
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t2 (
+  id int(8) NOT NULL,
+  severity tinyint(4) NOT NULL DEFAULT '0',
+  priority tinyint(4) NOT NULL DEFAULT '0',
+  status varchar(20) DEFAULT NULL,
+  alien tinyint(4) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+INSERT INTO t2 VALUES
+(22589,1,1,'Need Feedback',0);
+
+SELECT t2.id FROM t2 WHERE t2.id IN (SELECT id FROM t1 WHERE status = 'Verified');
+
+drop table t1, t2;
+
 --echo End of 5.1 tests

--- 1.81/sql/ha_partition.cc	2007-01-12 15:46:29 +04:00
+++ 1.82/sql/ha_partition.cc	2007-01-12 15:46:29 +04:00
@@ -4015,6 +4015,7 @@ int ha_partition::handle_ordered_index_s
     m_queue.elements= j;
     queue_fix(&m_queue);
     return_top_record(buf);
+    table->status= 0;
     DBUG_PRINT("info", ("Record returned from partition %d", m_top_entry));
     DBUG_RETURN(0);
   }
@@ -4083,6 +4084,7 @@ int ha_partition::handle_ordered_next(by
          DBUG_PRINT("info", ("Record returned from partition %u (2)",
                      m_top_entry));
          return_top_record(buf);
+         table->status= 0;
          error= 0;
       }
     }
@@ -4126,6 +4128,7 @@ int ha_partition::handle_ordered_prev(by
 	DBUG_PRINT("info", ("Record returned from partition %d (2)",
 			    m_top_entry));
         error= 0;
+        table->status= 0;
       }
     }
     DBUG_RETURN(error);
Thread
bk commit into 5.1 tree (holyfoot:1.2384) BUG#24186holyfoot12 Jan