List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:November 15 2010 9:10am
Subject:bzr commit into mysql-5.1-telco-7.1 branch (ole.john.aske:3982) Bug#58163
View as plain text  
#At file:///net/fimafeng09/export/home/tmp/oleja/mysql/mysql-5.1-telco-7.1/ based on revid:magnus.blaudd@stripped

 3982 Ole John Aske	2010-11-15
      Fix for bug#58163 - for review.
      
      All 'first', 'last', 'next' 'prev' navigators should set 'table->status = STATUS_NOT_FOUND' if there is
      returned an errorcode.
      
      This pattern is more or less a verbatime copy of how the same situation is handled in most
      (all?) of the other storage engines (Checked MyISAM, heap and memory...)
      
      I think the same fix should be applied for 6.3 -> ...

    modified:
      mysql-test/suite/ndb/r/ndb_subquery.result
      mysql-test/suite/ndb/t/ndb_subquery.test
      sql/ha_ndbcluster.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_subquery.result'
--- a/mysql-test/suite/ndb/r/ndb_subquery.result	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/ndb/r/ndb_subquery.result	2010-11-15 09:10:38 +0000
@@ -89,4 +89,10 @@ a	b
 3	30
 4	30
 drop table if exists t1, t2, t3, t4;
+create table t (k int, uq int, unique key ix1 (uq)) engine = ndb;
+insert into t values (1,3), (3,6), (6,9), (9,1);
+select * from t where 
+k in (select uq from t as subq where subq.k>10);
+k	uq
+drop table if exists t;
 End of 5.1 tests

=== modified file 'mysql-test/suite/ndb/t/ndb_subquery.test'
--- a/mysql-test/suite/ndb/t/ndb_subquery.test	2007-11-29 10:29:35 +0000
+++ b/mysql-test/suite/ndb/t/ndb_subquery.test	2010-11-15 09:10:38 +0000
@@ -75,4 +75,15 @@ select * from t3 where exists (select * 
 
 drop table if exists t1, t2, t3, t4;
 
+##########
+# bug#58163
+
+create table t (k int, uq int, unique key ix1 (uq)) engine = ndb;
+insert into t values (1,3), (3,6), (6,9), (9,1);
+
+select * from t where 
+   k in (select uq from t as subq where subq.k>10);
+
+drop table if exists t;
+
 --echo End of 5.1 tests

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2010-11-10 15:37:21 +0000
+++ b/sql/ha_ndbcluster.cc	2010-11-15 09:10:38 +0000
@@ -5289,8 +5289,10 @@ int ha_ndbcluster::index_read(uchar *buf
   default:
     break;
   }
-  DBUG_RETURN(read_range_first_to_buf(&start_key, 0, descending,
-                                      m_sorted, buf));
+  const int error= read_range_first_to_buf(&start_key, 0, descending,
+                                           m_sorted, buf);
+  table->status=error ? STATUS_NOT_FOUND: 0;
+  DBUG_RETURN(error);
 }
 
 
@@ -5298,7 +5300,9 @@ int ha_ndbcluster::index_next(uchar *buf
 {
   DBUG_ENTER("ha_ndbcluster::index_next");
   ha_statistic_increment(&SSV::ha_read_next_count);
-  DBUG_RETURN(next_result(buf));
+  const int error= next_result(buf);
+  table->status=error ? STATUS_NOT_FOUND: 0;
+  DBUG_RETURN(error);
 }
 
 
@@ -5306,7 +5310,9 @@ int ha_ndbcluster::index_prev(uchar *buf
 {
   DBUG_ENTER("ha_ndbcluster::index_prev");
   ha_statistic_increment(&SSV::ha_read_prev_count);
-  DBUG_RETURN(next_result(buf));
+  const int error= next_result(buf);
+  table->status=error ? STATUS_NOT_FOUND: 0;
+  DBUG_RETURN(error);
 }
 
 
@@ -5317,7 +5323,9 @@ int ha_ndbcluster::index_first(uchar *bu
   // Start the ordered index scan and fetch the first row
 
   // Only HA_READ_ORDER indexes get called by index_first
-  DBUG_RETURN(ordered_index_scan(0, 0, TRUE, FALSE, buf, NULL));
+  const int error= ordered_index_scan(0, 0, TRUE, FALSE, buf, NULL);
+  table->status=error ? STATUS_NOT_FOUND: 0;
+  DBUG_RETURN(error);
 }
 
 
@@ -5325,7 +5333,9 @@ int ha_ndbcluster::index_last(uchar *buf
 {
   DBUG_ENTER("ha_ndbcluster::index_last");
   ha_statistic_increment(&SSV::ha_read_last_count);
-  DBUG_RETURN(ordered_index_scan(0, 0, TRUE, TRUE, buf, NULL));
+  const int error= ordered_index_scan(0, 0, TRUE, TRUE, buf, NULL);
+  table->status=error ? STATUS_NOT_FOUND: 0;
+  DBUG_RETURN(error);
 }
 
 int ha_ndbcluster::index_read_last(uchar * buf, const uchar * key, uint key_len)
@@ -5520,9 +5530,14 @@ int ha_ndbcluster::rnd_next(uchar *buf)
   DBUG_ENTER("rnd_next");
   ha_statistic_increment(&SSV::ha_read_rnd_next_count);
 
-  if (!m_active_cursor)
-    DBUG_RETURN(full_table_scan(NULL, NULL, 0, buf));
-  DBUG_RETURN(next_result(buf));
+  int error;
+  if (m_active_cursor)
+    error= next_result(buf);
+  else
+    error= full_table_scan(NULL, NULL, 0, buf);
+
+  table->status= error ? STATUS_NOT_FOUND: 0;
+  DBUG_RETURN(error);
 }
 
 
@@ -5587,6 +5602,7 @@ int ha_ndbcluster::rnd_pos(uchar *buf, u
        */
       res= HA_ERR_RECORD_DELETED;
     }
+    table->status= res ? STATUS_NOT_FOUND: 0;
     DBUG_RETURN(res);
   }
 }


Attachment: [text/bzr-bundle] bzr/ole.john.aske@oracle.com-20101115091038-9hqcy37s8oc8l5ja.bundle
Thread
bzr commit into mysql-5.1-telco-7.1 branch (ole.john.aske:3982) Bug#58163Ole John Aske15 Nov