List:Internals« Previous MessageNext Message »
From:Sergei Golubchik Date:June 7 2005 10:43pm
Subject:bk commit into 4.1 tree (serg:1.2315) BUG#5373
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of serg. When serg 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.2315 05/06/07 22:43:25 serg@stripped +3 -0
  bug#5373: handler READ NEXT w/o HANDLER READ [FIRST]
  check table->file->inited to catch incorrect calling sequence.

  sql/sql_handler.cc
    1.62 05/06/07 22:43:18 serg@stripped +27 -15
    cleanup: call index_init *correctly*, not every time.
    check table->file->inited to catch incorrect calling sequence.

  mysql-test/t/innodb_handler.test
    1.8 05/06/07 22:43:18 serg@stripped +10 -0
    bug#5373: handler READ NEXT w/o HANDLER READ [FIRST]

  mysql-test/r/innodb_handler.result
    1.11 05/06/07 22:43:18 serg@stripped +16 -0
    bug#5373: handler READ NEXT w/o HANDLER READ [FIRST]

# 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:	serg
# Host:	serg.mylan
# Root:	/usr/home/serg/Abk/mysql-4.1

--- 1.10/mysql-test/r/innodb_handler.result	Wed Jun 16 05:17:52 2004
+++ 1.11/mysql-test/r/innodb_handler.result	Tue Jun  7 22:43:18 2005
@@ -132,6 +132,22 @@ a	b
 handler t2 read last;
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '' at line 1
 handler t2 close;
+handler t1 open;
+handler t1 read a next;
+a	b
+14	aaa
+handler t1 read a next;
+a	b
+15	bbb
+handler t1 close;
+handler t1 open;
+handler t1 read a prev;
+a	b
+22	iii
+handler t1 read a prev;
+a	b
+21	hhh
+handler t1 close;
 handler t1 open as t2;
 handler t2 read first;
 a	b

--- 1.7/mysql-test/t/innodb_handler.test	Sat Mar 20 11:29:41 2004
+++ 1.8/mysql-test/t/innodb_handler.test	Tue Jun  7 22:43:18 2005
@@ -69,6 +69,16 @@ handler t2 read next;
 handler t2 read last;
 handler t2 close;
 
+handler t1 open;
+handler t1 read a next; # this used to crash as a bug#5373
+handler t1 read a next;
+handler t1 close;
+
+handler t1 open;
+handler t1 read a prev; # this used to crash as a bug#5373
+handler t1 read a prev;
+handler t1 close;
+
 handler t1 open as t2;
 handler t2 read first;
 alter table t1 engine=innodb;

--- 1.61/sql/sql_handler.cc	Fri Jun  3 21:10:21 2005
+++ 1.62/sql/sql_handler.cc	Tue Jun  7 22:43:18 2005
@@ -429,12 +429,10 @@ int mysql_ha_read(THD *thd, TABLE_LIST *
   }
   tables->table=table;
 
-  if (cond && ((!cond->fixed && 
+  if (cond && ((!cond->fixed &&
               cond->fix_fields(thd, tables, &cond)) || cond->check_cols(1)))
     goto err0;
 
-  table->file->init_table_handle_for_HANDLER(); // Only InnoDB requires it
-
   if (keyname)
   {
     if ((keyno=find_type(keyname, &table->keynames, 1+2)-1)<0)
@@ -443,8 +441,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *
           keyname,tables->alias);
       goto err0;
     }
-    table->file->ha_index_or_rnd_end();
-    table->file->ha_index_init(keyno);
   }
 
   if (insert_fields(thd,tables,tables->db,tables->alias,&it))
@@ -471,9 +467,22 @@ int mysql_ha_read(THD *thd, TABLE_LIST *
   for (num_rows=0; num_rows < select_limit; )
   {
     switch (mode) {
+    case RNEXT:
+      if (table->file->inited != handler::NONE)
+      {
+        err=keyname ?
+	  table->file->index_next(table->record[0]) :
+	  table->file->rnd_next(table->record[0]);
+        break;
+      }
+      /* else fall through */
     case RFIRST:
       if (keyname)
+      {
+        table->file->ha_index_or_rnd_end();
+        table->file->ha_index_init(keyno);
         err=table->file->index_first(table->record[0]);
+      }
       else
       {
         table->file->ha_index_or_rnd_end();
@@ -482,20 +491,21 @@ int mysql_ha_read(THD *thd, TABLE_LIST *
       }
       mode=RNEXT;
       break;
+    case RPREV:
+      DBUG_ASSERT(keyname != 0);
+      if (table->file->inited != handler::NONE)
+      {
+        err=table->file->index_prev(table->record[0]);
+        break;
+      }
+      /* else fall through */
     case RLAST:
       DBUG_ASSERT(keyname != 0);
+      table->file->ha_index_or_rnd_end();
+      table->file->ha_index_init(keyno);
       err=table->file->index_last(table->record[0]);
       mode=RPREV;
       break;
-    case RNEXT:
-      err=keyname ?
-	table->file->index_next(table->record[0]) :
-	table->file->rnd_next(table->record[0]);
-      break;
-    case RPREV:
-      DBUG_ASSERT(keyname != 0);
-      err=table->file->index_prev(table->record[0]);
-      break;
     case RNEXT_SAME:
       /* Continue scan on "(keypart1,keypart2,...)=(c1, c2, ...)  */
       DBUG_ASSERT(keyname != 0);
@@ -517,7 +527,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *
       for (key_len=0 ; (item=it_ke++) ; key_part++)
       {
 	// 'item' can be changed by fix_fields() call
-	if ((!item->fixed && 
+	if ((!item->fixed &&
              item->fix_fields(thd, tables, it_ke.ref())) ||
 	    (item= *it_ke.ref())->check_cols(1))
 	  goto err;
@@ -535,6 +545,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *
 	goto err;
       }
       key_copy(key, table, keyno, key_len);
+      table->file->ha_index_or_rnd_end();
+      table->file->ha_index_init(keyno);
       err=table->file->index_read(table->record[0],
 				  key,key_len,ha_rkey_mode);
       mode=rkey_to_rnext[(int)ha_rkey_mode];
Thread
bk commit into 4.1 tree (serg:1.2315) BUG#5373Sergei Golubchik7 Jun