List:Commits« Previous MessageNext Message »
From:mhansson Date:September 3 2007 4:46pm
Subject:bk commit into 5.2 tree (mhansson:1.2576) BUG#30622
View as plain text  
Below is the list of changes that have just been committed into a local
5.2 repository of martin. When martin 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-09-03 18:46:29+02:00, mhansson@stripped +6 -0
  Bug #30622: Unexpected behavior using DELETE with AS and USING
  Since WL 2474, the handler uses a disk sweep multi-range read implementation,
  which is encapsulated in the handler, and coexists with the old (default) MRR 
  implementation. But when positioning the pointer to the current
  row, the position is always fetched from the default implementaion.
  This leads to an incorrect position of the pointer when doing MRR  
  access using index lookup to rows that contain one of the eight BLOB types,
  and hence no result.
  
  Fixed by:
  - moving the default implementation of handler::position to 
    handler::position_default_impl, not part of public interface.
  - Modifying the public interface handler::position to position
    pointer according to which MMR implementation is used. 

  mysql-test/r/order_by.result@stripped, 2007-09-03 18:46:25+02:00, mhansson@stripped +93 -0
    Bug#30622: Test result

  mysql-test/t/order_by.test@stripped, 2007-09-03 18:46:25+02:00, mhansson@stripped +80 -0
    Bug#30622: Test case

  sql/handler.cc@stripped, 2007-09-03 18:46:26+02:00, mhansson@stripped +1 -1
    Bug#30622: Calling the new method, which will always use default 
    implementation of ::position.

  sql/handler.h@stripped, 2007-09-03 18:46:26+02:00, mhansson@stripped +10 -0
    Bug#30622: The new method, declared in base class with default implementation.

  storage/myisam/ha_myisam.cc@stripped, 2007-09-03 18:46:26+02:00, mhansson@stripped +9 -2
    Bug#30622: Moved the default implementation of ha_myisam::position
    to ::position_default_impl. The new method ::position will call this method
    only if the default implementation is used. If not, the pointer will be 
    retrieved from the new MRR implementation.

  storage/myisam/ha_myisam.h@stripped, 2007-09-03 18:46:26+02:00, mhansson@stripped +1 -0
    Bug#30622: declaration of new private method.

diff -Nrup a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
--- a/mysql-test/r/order_by.result	2007-06-28 02:07:16 +02:00
+++ b/mysql-test/r/order_by.result	2007-09-03 18:46:25 +02:00
@@ -1073,3 +1073,96 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	const	PRIMARY,b	b	5	const	1	
 1	SIMPLE	t2	ref	a	a	5	const	2	Using where; Using index
 DROP TABLE t1,t2;
+CREATE TABLE t1 (
+a INT,
+b INT,
+c TINYTEXT,
+KEY (a)
+);
+INSERT INTO t1 VALUES (1, 1, 'one'), (1, 2, 'two');
+CREATE TABLE t2 (
+a INT,
+b INT,
+c TEXT,
+KEY (a)
+);
+INSERT INTO t2 SELECT * FROM t1;
+CREATE TABLE t3 (
+a INT,
+b INT,
+c MEDIUMTEXT,
+KEY (a)
+);
+INSERT INTO t3 SELECT * FROM t1;
+CREATE TABLE t4 (
+a INT,
+b INT,
+c LONGTEXT,
+KEY (a)
+);
+INSERT INTO t4 SELECT * FROM t1;
+CREATE TABLE t5 (
+a INT,
+b INT,
+c TINYBLOB,
+KEY (a)
+);
+INSERT INTO t5 SELECT * FROM t1;
+CREATE TABLE t6 (
+a INT,
+b INT,
+c BLOB,
+KEY (a)
+);
+INSERT INTO t6 SELECT * FROM t1;
+CREATE TABLE t7 (
+a INT,
+b INT,
+c MEDIUMBLOB,
+KEY (a)
+);
+INSERT INTO t7 SELECT * FROM t1;
+CREATE TABLE t8 (
+a INT,
+b INT,
+c LONGBLOB,
+KEY (a)
+);
+INSERT INTO t8 SELECT * FROM t1;
+SELECT * FROM t1 WHERE a = 1;
+a	b	c
+1	1	one
+1	2	two
+SELECT * FROM t1 WHERE a = 1 ORDER BY b;
+a	b	c
+1	1	one
+1	2	two
+SELECT * FROM t2 WHERE a = 1 ORDER BY b;
+a	b	c
+1	1	one
+1	2	two
+SELECT * FROM t3 WHERE a = 1 ORDER BY b;
+a	b	c
+1	1	one
+1	2	two
+SELECT * FROM t4 WHERE a = 1 ORDER BY b;
+a	b	c
+1	1	one
+1	2	two
+SELECT * FROM t5 WHERE a = 1 ORDER BY b;
+a	b	c
+1	1	one
+1	2	two
+SELECT * FROM t6 WHERE a = 1 ORDER BY b;
+a	b	c
+1	1	one
+1	2	two
+SELECT * FROM t7 WHERE a = 1 ORDER BY b;
+a	b	c
+1	1	one
+1	2	two
+SELECT * FROM t8 WHERE a = 1 ORDER BY b;
+a	b	c
+1	1	one
+1	2	two
+DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8;
diff -Nrup a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
--- a/mysql-test/t/order_by.test	2007-06-01 15:49:38 +02:00
+++ b/mysql-test/t/order_by.test	2007-09-03 18:46:25 +02:00
@@ -739,3 +739,83 @@ INSERT INTO t2 VALUES (1,1),(1,2),(2,1),
 EXPLAIN SELECT 1 FROM t1,t2 WHERE t1.b=2 AND t1.a=t2.a ORDER BY t2.b;
 
 DROP TABLE t1,t2;
+
+#
+# Bug #30622: ORDER BY on a SELECT causes results to be missed
+#
+
+CREATE TABLE t1 (
+  a INT,
+  b INT,
+  c TINYTEXT,
+  KEY (a)
+);
+INSERT INTO t1 VALUES (1, 1, 'one'), (1, 2, 'two');
+
+CREATE TABLE t2 (
+  a INT,
+  b INT,
+  c TEXT,
+  KEY (a)
+);
+INSERT INTO t2 SELECT * FROM t1;
+
+CREATE TABLE t3 (
+  a INT,
+  b INT,
+  c MEDIUMTEXT,
+  KEY (a)
+);
+INSERT INTO t3 SELECT * FROM t1;
+
+CREATE TABLE t4 (
+  a INT,
+  b INT,
+  c LONGTEXT,
+  KEY (a)
+);
+INSERT INTO t4 SELECT * FROM t1;
+
+CREATE TABLE t5 (
+  a INT,
+  b INT,
+  c TINYBLOB,
+  KEY (a)
+);
+INSERT INTO t5 SELECT * FROM t1;
+
+CREATE TABLE t6 (
+  a INT,
+  b INT,
+  c BLOB,
+  KEY (a)
+);
+INSERT INTO t6 SELECT * FROM t1;
+
+CREATE TABLE t7 (
+  a INT,
+  b INT,
+  c MEDIUMBLOB,
+  KEY (a)
+);
+INSERT INTO t7 SELECT * FROM t1;
+
+CREATE TABLE t8 (
+  a INT,
+  b INT,
+  c LONGBLOB,
+  KEY (a)
+);
+INSERT INTO t8 SELECT * FROM t1;
+
+SELECT * FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1 ORDER BY b;
+SELECT * FROM t2 WHERE a = 1 ORDER BY b;
+SELECT * FROM t3 WHERE a = 1 ORDER BY b;
+SELECT * FROM t4 WHERE a = 1 ORDER BY b;
+SELECT * FROM t5 WHERE a = 1 ORDER BY b;
+SELECT * FROM t6 WHERE a = 1 ORDER BY b;
+SELECT * FROM t7 WHERE a = 1 ORDER BY b;
+SELECT * FROM t8 WHERE a = 1 ORDER BY b;
+
+DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8;
diff -Nrup a/sql/handler.cc b/sql/handler.cc
--- a/sql/handler.cc	2007-08-25 00:17:37 +02:00
+++ b/sql/handler.cc	2007-09-03 18:46:26 +02:00
@@ -3575,7 +3575,7 @@ int DsMrr_impl::dsmrr_fill_buffer(handle
          !(res= h->handler::multi_range_read_next(&range_info)))
   {
     /* Put rowid, or {rowid, range_id} pair into the buffer */
-    h->position(h->table->record[0]);
+    h->position_default_impl(h->table->record[0]);
     memcpy(rowids_buf_cur, h->ref, h->ref_length);
     rowids_buf_cur += h->ref_length;
 
diff -Nrup a/sql/handler.h b/sql/handler.h
--- a/sql/handler.h	2007-08-25 00:17:37 +02:00
+++ b/sql/handler.h	2007-09-03 18:46:26 +02:00
@@ -1498,6 +1498,12 @@ public:
   private:
   virtual int index_read_last(uchar * buf, const uchar * key, uint key_len)
    { return (my_errno=HA_ERR_WRONG_COMMAND); }
+  /**
+     Stores a reference to the current row to 'ref' field of the handler using 
+     the 'default' MRR implementation.
+     @param record Row in MySQL format
+  */
+  virtual void position_default_impl(const uchar *record) { position(record); }
   public:
 /**
   @brief
@@ -1533,6 +1539,10 @@ public:
     { return HA_ERR_WRONG_COMMAND; }
   virtual ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key)
     { return (ha_rows) 10; }
+  /**
+     Stores a reference to the current row to 'ref' field of the handler.
+     @param record Row in MySQL format
+  */
   virtual void position(const uchar *record)=0;
   virtual int info(uint)=0; // see my_base.h for full description
   virtual void get_dynamic_partition_info(PARTITION_INFO *stat_info,
diff -Nrup a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
--- a/storage/myisam/ha_myisam.cc	2007-08-24 23:08:22 +02:00
+++ b/storage/myisam/ha_myisam.cc	2007-09-03 18:46:26 +02:00
@@ -1569,10 +1569,17 @@ int ha_myisam::rnd_pos(uchar *buf, uchar
   return error;
 }
 
-void ha_myisam::position(const uchar *record)
-{
+void ha_myisam::position_default_impl(const uchar *record) {
   my_off_t row_position= mi_position(file);
   my_store_ptr(ref, ref_length, row_position);
+}
+
+void ha_myisam::position(const uchar *record)
+{
+  if (ds_mrr.use_default_impl)
+    position_default_impl(record);
+  else
+    memcpy(ref, ds_mrr.rowids_buf_cur - ref_length, ref_length);
 }
 
 int ha_myisam::info(uint flag)
diff -Nrup a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h
--- a/storage/myisam/ha_myisam.h	2007-08-24 23:08:22 +02:00
+++ b/storage/myisam/ha_myisam.h	2007-09-03 18:46:26 +02:00
@@ -172,5 +172,6 @@ private:
     in_range_read= on;
   }
   friend my_bool index_cond_func_myisam(void *arg);
+  virtual void position_default_impl(const uchar *record);
 };
 
Thread
bk commit into 5.2 tree (mhansson:1.2576) BUG#30622mhansson3 Sep