[Commits] Rev 3013: Fix for LP#697610 ha_index_prev(uchar*): Assertion `inited==INDEX' failed with HANDLER + InnoDB in maria-5.3 in lp:maria/5.1

Michael Widenius monty at askmonty.org
Wed Jan 12 15:41:43 EET 2011


At lp:maria/5.1

------------------------------------------------------------
revno: 3013
revision-id: monty at askmonty.org-20110112134139-93qm2560jl173j8u
parent: monty at askmonty.org-20110111235056-ieelvtywtrz6xjf8
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.1
timestamp: Wed 2011-01-12 15:41:39 +0200
message:
  Fix for LP#697610 ha_index_prev(uchar*): Assertion `inited==INDEX' failed with HANDLER + InnoDB in maria-5.3
-------------- next part --------------
=== modified file 'mysql-test/suite/handler/innodb.result'
--- a/mysql-test/suite/handler/innodb.result	2011-01-10 21:22:40 +0000
+++ b/mysql-test/suite/handler/innodb.result	2011-01-12 13:41:39 +0000
@@ -560,3 +560,13 @@ HANDLER t1 READ a NEXT;
 a
 HANDLER t1 CLOSE;
 DROP TABLE t1;
+CREATE TABLE t1 (f1 integer, f2 integer, primary key (f1), key (f2)) engine=innodb;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST WHERE f2 <= 1;
+f1      f2
+1       1
+HANDLER t1 READ `PRIMARY` PREV;
+f1      f2
+3       3
+DROP TABLE t1;

=== modified file 'mysql-test/suite/handler/innodb.test'
--- a/mysql-test/suite/handler/innodb.test	2011-01-10 21:22:40 +0000
+++ b/mysql-test/suite/handler/innodb.test	2011-01-12 13:41:39 +0000
@@ -15,3 +15,14 @@ let $engine_type= InnoDB;
 
 --source init.inc
 --source handler.inc
+
+#
+# LP#697610 ha_index_prev(uchar*): Assertion `inited==INDEX'
+#
+
+CREATE TABLE t1 (f1 integer, f2 integer, primary key (f1), key (f2)) engine=innodb;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST WHERE f2 <= 1;
+HANDLER t1 READ `PRIMARY` PREV;
+DROP TABLE t1;

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2011-01-10 21:22:40 +0000
+++ b/sql/handler.h	2011-01-12 13:41:39 +0000
@@ -1195,14 +1195,18 @@ class handler :public Sql_alloc
     DBUG_ENTER("ha_index_init");
     DBUG_ASSERT(inited==NONE);
     if (!(result= index_init(idx, sorted)))
-      inited=INDEX;
+    {
+      inited=       INDEX;
+      active_index= idx;
+    }
     DBUG_RETURN(result);
   }
   int ha_index_end()
   {
     DBUG_ENTER("ha_index_end");
     DBUG_ASSERT(inited==INDEX);
-    inited=NONE;
+    inited=       NONE;
+    active_index= MAX_KEY;
     DBUG_RETURN(index_end());
   }
   /* This is called after index_init() if we need to do a index scan */
@@ -1371,7 +1375,12 @@ class handler :public Sql_alloc
     as there may be several calls to this routine.
   */
   virtual void column_bitmaps_signal();
-  uint get_index(void) const { return active_index; }
+  /*
+    We have to check for inited as some engines, like innodb, sets
+    active_index during table scan.
+  */
+  uint get_index(void) const
+  { return inited == INDEX ? active_index : MAX_KEY; }
   virtual int close(void)=0;
 
   /**
@@ -1824,8 +1833,8 @@ class handler :public Sql_alloc
   */
 
   virtual int open(const char *name, int mode, uint test_if_locked)=0;
-  virtual int index_init(uint idx, bool sorted) { active_index= idx; return 0; }
-  virtual int index_end() { active_index= MAX_KEY; return 0; }
+  virtual int index_init(uint idx, bool sorted) { return 0; }
+  virtual int index_end() { return 0; }
   /**
     rnd_init() can be called two times without rnd_end() in between
     (it only makes sense if scan=1).

=== modified file 'storage/federated/ha_federated.cc'
--- a/storage/federated/ha_federated.cc	2010-08-27 14:12:44 +0000
+++ b/storage/federated/ha_federated.cc	2011-01-12 13:41:39 +0000
@@ -2453,7 +2453,6 @@ int ha_federated::index_init(uint keynr,
 {
   DBUG_ENTER("ha_federated::index_init");
   DBUG_PRINT("info", ("table: '%s'  key: %u", table->s->table_name.str, keynr));
-  active_index= keynr;
   DBUG_RETURN(0);
 }
 
@@ -2589,7 +2588,6 @@ int ha_federated::index_end(void)
 {
   DBUG_ENTER("ha_federated::index_end");
   free_result();
-  active_index= MAX_KEY;
   DBUG_RETURN(0);
 }
 

=== modified file 'storage/maria/ma_pagecache.c'
--- a/storage/maria/ma_pagecache.c	2011-01-11 23:50:56 +0000
+++ b/storage/maria/ma_pagecache.c	2011-01-12 13:41:39 +0000
@@ -759,6 +759,8 @@ ulong init_pagecache(PAGECACHE *pagecach
   {
     if (blocks < 8)
     {
+      my_message(ENOMEM, "Not enough memory to allocate 8 pagecache pages",
+                 MYF(0));
       my_errno= ENOMEM;
       goto err;
     }



More information about the commits mailing list