List:Commits« Previous MessageNext Message »
From:tomas Date:October 2 2007 10:15am
Subject:bk commit into 5.2 tree (tomas:1.2579)
View as plain text  
Below is the list of changes that have just been committed into a local
5.2 repository of tomas. When tomas 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-10-02 12:15:41+02:00, tomas@stripped +5 -0
  execute count patch

  mysql-test/suite/ndb/r/ndb_read_multi_range.result@stripped, 2007-10-02 12:15:37+02:00, tomas@stripped +40 -0
    execute count patch

  mysql-test/suite/ndb/t/ndb_read_multi_range.test@stripped, 2007-10-02 12:15:37+02:00, tomas@stripped +40 -0
    execute count patch

  sql/ha_ndbcluster.cc@stripped, 2007-10-02 12:15:37+02:00, tomas@stripped +73 -6
    execute count patch

  sql/ha_ndbcluster.h@stripped, 2007-10-02 12:15:38+02:00, tomas@stripped +2 -0
    execute count patch

  sql/set_var.cc@stripped, 2007-10-02 12:15:38+02:00, tomas@stripped +3 -0
    execute count patch

diff -Nrup a/mysql-test/suite/ndb/r/ndb_read_multi_range.result b/mysql-test/suite/ndb/r/ndb_read_multi_range.result
--- a/mysql-test/suite/ndb/r/ndb_read_multi_range.result	2007-07-04 22:06:22 +02:00
+++ b/mysql-test/suite/ndb/r/ndb_read_multi_range.result	2007-10-02 12:15:37 +02:00
@@ -9,7 +9,11 @@ insert into t1 values
 (1,2,1),(2,3,2),(3,4,3),(4,5,4),
 (5,2,12),(6,3,11),(7,4,10),(8,5,9),
 (9,2,8),(10,3,7),(11,4,6),(12,5,5);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+3
 create table r1 as select * from t1 where a in (2,8,12);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from r1 order by a;
 a	b	c
 2	3	2
@@ -17,6 +21,8 @@ a	b	c
 12	5	5
 drop table r1;
 create table r1 as select * from t1 where b in (1,2,5);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from r1 order by a;
 a	b	c
 1	2	1
@@ -27,6 +33,8 @@ a	b	c
 12	5	5
 drop table r1;
 create table r1 as select * from t1 where c in (2,8,12);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from r1 order by a;
 a	b	c
 2	3	2
@@ -34,6 +42,8 @@ a	b	c
 9	2	8
 drop table r1;
 create table r1 as select * from t1 where a in (2,8) or (a > 11) or (a <= 1);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from r1 order by a;
 a	b	c
 1	2	1
@@ -42,12 +52,16 @@ a	b	c
 12	5	5
 drop table r1;
 create table r1 as select * from t1 where a in (33,8,12);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from r1 order by a;
 a	b	c
 8	5	9
 12	5	5
 drop table r1;
 create table r1 as select * from t1 where a in (2,33,8,12,34);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from r1 order by a;
 a	b	c
 2	3	2
@@ -55,6 +69,8 @@ a	b	c
 12	5	5
 drop table r1;
 create table r1 as select * from t1 where b in (1,33,5);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from r1 order by a;
 a	b	c
 4	5	4
@@ -66,7 +82,11 @@ a	b	c
 4	5	4
 8	5	9
 12	5	5
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 create table r1 as select * from t1 where b in (45,1,33,5,44);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from r1 order by a;
 a	b	c
 4	5	4
@@ -75,13 +95,19 @@ a	b	c
 drop table r1;
 select * from t1 where b in (45,22) order by a;
 a	b	c
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 create table r1 as select * from t1 where c in (2,8,33);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from r1 order by a;
 a	b	c
 2	3	2
 9	2	8
 drop table r1;
 create table r1 as select * from t1 where c in (13,2,8,33,12);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from r1 order by a;
 a	b	c
 2	3	2
@@ -92,14 +118,20 @@ select * from t1 where a in (33,8,12) or
 a	b	c
 8	5	9
 12	5	5
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from t1 where a in (33,34,35) order by a;
 a	b	c
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from t1 where a in (2,8) or (a > 11) or (a <= 1) order by a;
 a	b	c
 1	2	1
 2	3	2
 8	5	9
 12	5	5
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from t1 where b in (6,7) or (b <= 5) or (b >= 10) order by b,a;
 a	b	c
 1	2	1
@@ -114,11 +146,15 @@ a	b	c
 4	5	4
 8	5	9
 12	5	5
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from t1 where c in (13,2,8,33,12) order by c,a;
 a	b	c
 2	3	2
 9	2	8
 5	2	12
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 drop table t1;
 create table t1 (
 a int not null,
@@ -136,8 +172,12 @@ insert into t1 values
 (1,2,1,3,1),
 (1,2,1,4,1),
 (1,2,1,5,1);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+3
 create table r1 as select * from t1
 where a=1 and b=2 and c=1 and d in (1,4,3,2);
+@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
+2
 select * from r1 order by a,b,c,d;
 a	b	c	d	e
 1	2	1	1	1
diff -Nrup a/mysql-test/suite/ndb/t/ndb_read_multi_range.test b/mysql-test/suite/ndb/t/ndb_read_multi_range.test
--- a/mysql-test/suite/ndb/t/ndb_read_multi_range.test	2007-07-04 22:06:24 +02:00
+++ b/mysql-test/suite/ndb/t/ndb_read_multi_range.test	2007-10-02 12:15:37 +02:00
@@ -15,62 +15,98 @@ create table t1 (
   c int not null,
   index(b), unique index using hash(c)
 ) engine = ndb;
+--source include/ndb_init_execute_count.inc
 insert into t1 values
   (1,2,1),(2,3,2),(3,4,3),(4,5,4),
   (5,2,12),(6,3,11),(7,4,10),(8,5,9),
   (9,2,8),(10,3,7),(11,4,6),(12,5,5);
+--source include/ndb_execute_count.inc
 
 # batch on primary key
+--source include/ndb_init_execute_count.inc
 create table r1 as select * from t1 where a in (2,8,12);
+--source include/ndb_execute_count.inc
 select * from r1 order by a;
 drop table r1;
 
 # batch on ordered index
+--source include/ndb_init_execute_count.inc
 create table r1 as select * from t1 where b in (1,2,5);
+--source include/ndb_execute_count.inc
 select * from r1 order by a;
 drop table r1;
 
 # batch on unique hash index
+--source include/ndb_init_execute_count.inc
 create table r1 as select * from t1 where c in (2,8,12);
+--source include/ndb_execute_count.inc
 select * from r1 order by a;
 drop table r1;
 
 # batch mixed
+--source include/ndb_init_execute_count.inc
 create table r1 as select * from t1 where a in (2,8) or (a > 11) or (a <= 1);
+--source include/ndb_execute_count.inc
 select * from r1 order by a;
 drop table r1;
 
 # batch on primary key, missing values
+--source include/ndb_init_execute_count.inc
 create table r1 as select * from t1 where a in (33,8,12);
+--source include/ndb_execute_count.inc
 select * from r1 order by a;
 drop table r1;
+--source include/ndb_init_execute_count.inc
 create table r1 as select * from t1 where a in (2,33,8,12,34);
+--source include/ndb_execute_count.inc
 select * from r1 order by a;
 drop table r1;
 
 # batch on ordered index, missing values
+--source include/ndb_init_execute_count.inc
 create table r1 as select * from t1 where b in (1,33,5);
+--source include/ndb_execute_count.inc
 select * from r1 order by a;
 drop table r1;
+--source include/ndb_init_execute_count.inc
 select * from t1 where b in (1,33,5) order by a;
+--source include/ndb_execute_count.inc
+--source include/ndb_init_execute_count.inc
 create table r1 as select * from t1 where b in (45,1,33,5,44);
+--source include/ndb_execute_count.inc
 select * from r1 order by a;
 drop table r1;
+--source include/ndb_init_execute_count.inc
 select * from t1 where b in (45,22) order by a;
+--source include/ndb_execute_count.inc
 
 # batch on unique hash index, missing values
+--source include/ndb_init_execute_count.inc
 create table r1 as select * from t1 where c in (2,8,33);
+--source include/ndb_execute_count.inc
 select * from r1 order by a;
 drop table r1;
+--source include/ndb_init_execute_count.inc
 create table r1 as select * from t1 where c in (13,2,8,33,12);
+--source include/ndb_execute_count.inc
 select * from r1 order by a;
 drop table r1;
 
+--source include/ndb_init_execute_count.inc
 select * from t1 where a in (33,8,12) order by a;
+--source include/ndb_execute_count.inc
+--source include/ndb_init_execute_count.inc
 select * from t1 where a in (33,34,35) order by a;
+--source include/ndb_execute_count.inc
+--source include/ndb_init_execute_count.inc
 select * from t1 where a in (2,8) or (a > 11) or (a <= 1) order by a;
+--source include/ndb_execute_count.inc
+--source include/ndb_init_execute_count.inc
 select * from t1 where b in (6,7) or (b <= 5) or (b >= 10) order by b,a;
+--source include/ndb_execute_count.inc
+--source include/ndb_init_execute_count.inc
 select * from t1 where c in (13,2,8,33,12) order by c,a;
+--source include/ndb_execute_count.inc
 drop table t1;
 
 #
@@ -86,6 +122,7 @@ create table t1 (
   primary key (a,b,c,d), index (d)
 ) engine = ndb;
 
+--source include/ndb_init_execute_count.inc
 insert into t1 values
   (1,2,1,1,1),(2,3,2,3,1),(3,4,3,1,1),(4,5,4,7,1),
   (5,2,12,12,1),(6,3,11,1,1),(7,4,10,3,1),(8,5,9,5,1),
@@ -94,10 +131,13 @@ insert into t1 values
   (1,2,1,3,1),
   (1,2,1,4,1),
   (1,2,1,5,1);
+--source include/ndb_execute_count.inc
 
 # batch on primary key
+--source include/ndb_init_execute_count.inc
 create table r1 as select * from t1
   where a=1 and b=2 and c=1 and d in (1,4,3,2);
+--source include/ndb_execute_count.inc
 select * from r1 order by a,b,c,d;
 drop table r1;
 
diff -Nrup a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
--- a/sql/ha_ndbcluster.cc	2007-08-26 13:52:54 +02:00
+++ b/sql/ha_ndbcluster.cc	2007-10-02 12:15:37 +02:00
@@ -198,11 +198,14 @@ struct st_ndb_status {
   long number_of_data_nodes;
   long number_of_ready_data_nodes;
   long connect_count;
+  long execute_count;
 };
 
 static struct st_ndb_status g_ndb_status;
 
-static int update_status_variables(st_ndb_status *ns, Ndb_cluster_connection *c)
+static int update_status_variables(Thd_ndb *thd_ndb,
+                                   st_ndb_status *ns,
+                                   Ndb_cluster_connection *c)
 {
   ns->connected_port= c->get_connected_port();
   ns->connected_host= c->get_connected_host();
@@ -218,6 +221,10 @@ static int update_status_variables(st_nd
   ns->number_of_ready_data_nodes= c->get_no_ready();
   ns->number_of_data_nodes= c->no_db_nodes();
   ns->connect_count= c->get_connect_count();
+  if (thd_ndb)
+  {
+    ns->execute_count= thd_ndb->m_execute_count;
+  }
   return 0;
 }
 
@@ -227,6 +234,10 @@ SHOW_VAR ndb_status_variables[]= {
   {"config_from_port",    (char*) &g_ndb_status.connected_port,       SHOW_LONG},
 //{"number_of_replicas",  (char*) &g_ndb_status.number_of_replicas,   SHOW_LONG},
   {"number_of_data_nodes",(char*) &g_ndb_status.number_of_data_nodes, SHOW_LONG},
+  {"number_of_ready_data_nodes",
+   (char*) &g_ndb_status.number_of_ready_data_nodes,                  SHOW_LONG},
+  {"connect_count",      (char*) &g_ndb_status.connect_count,         SHOW_LONG},
+  {"execute_count",      (char*) &g_ndb_status.execute_count,         SHOW_LONG},
   {NullS, NullS, SHOW_LONG}
 };
 
@@ -283,6 +294,7 @@ int execute_no_commit_ignore_no_key(ha_n
                           h->m_force_send);
   Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
   thd_ndb->m_unsent_bytes= 0;
+  thd_ndb->m_execute_count++;
   if (res == -1)
     return -1;
 
@@ -309,6 +321,7 @@ int execute_no_commit(ha_ndbcluster *h, 
                             h->m_force_send);
     Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
     thd_ndb->m_unsent_bytes= 0;
+    thd_ndb->m_execute_count++;
     return res;
   }
 }
@@ -321,6 +334,7 @@ int execute_commit(ha_ndbcluster *h, Ndb
                           h->m_force_send);
   Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
   thd_ndb->m_unsent_bytes= 0;
+  thd_ndb->m_execute_count++;
   return res;
 }
 
@@ -332,6 +346,7 @@ int execute_commit(THD *thd, NdbTransact
                           thd->variables.ndb_force_send);
   Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
   thd_ndb->m_unsent_bytes= 0;
+  thd_ndb->m_execute_count++;
   return res;
 }
 
@@ -345,6 +360,7 @@ int execute_no_commit_ie(ha_ndbcluster *
                           h->m_force_send);
   Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
   thd_ndb->m_unsent_bytes= 0;
+  thd_ndb->m_execute_count++;
   return res;
 }
 
@@ -380,6 +396,7 @@ Thd_ndb::Thd_ndb()
   (void) hash_init(&open_tables, &my_charset_bin, 5, 0, 0,
                    (hash_get_key)thd_ndb_share_get_key, 0, 0);
   m_unsent_bytes= 0;
+  m_execute_count= 0;
   init_alloc_root(&m_batch_mem_root, BATCH_FLUSH_SIZE/4, 0);
 }
 
@@ -3661,7 +3678,8 @@ int ha_ndbcluster::update_row(const ucha
     Batch update operation if we are doing a scan for update, unless
     there exist UPDATE AFTER triggers
   */
-  if (cursor && !m_update_cannot_batch)
+  if ((cursor || (thd->options & OPTION_ALLOW_BATCH)) &&
+      !m_update_cannot_batch)
   {
     /* For a scan, we only need to execute() if the batch buffer is full. */
     row= batch_copy_row_to_buffer(thd_ndb, new_data, need_execute);
@@ -3711,16 +3729,31 @@ int ha_ndbcluster::update_row(const ucha
   {  
     const NdbRecord *key_rec;
     const uchar *key_row;
+    uint key_len;
     if (table_share->primary_key != MAX_KEY)
     {
       key_rec= m_index[table_share->primary_key].ndb_unique_record_row;
       key_row= old_data;
+      key_len= table->s->reclength;
     }
     else
     {
       /* Use hidden primary key previously read into m_ref. */
       key_rec= m_ndb_hidden_key_record;
       key_row= (const uchar *)(&m_ref);
+      key_len= sizeof(m_ref);
+    }
+
+    if (!need_execute)
+    {
+      /*
+        Poor approx. let delete ~ tabsize / 4
+      */
+      uint delete_size= 12 + m_bytes_per_write >> 2;
+      key_row= batch_copy_key_to_buffer(thd_ndb, key_row, key_len,
+                                        delete_size, need_execute);
+      if (unlikely(!key_row))
+        DBUG_RETURN(ER_OUTOFMEMORY);
     }
 
     if (!(op= trans->updateTuple(key_rec, (const char *)key_row,
@@ -5182,6 +5215,7 @@ static int ndbcluster_commit(handlerton 
 
   if (thd->slave_thread)
   {
+    thd_ndb->m_execute_count++;
     if ((res= trans->execute(Commit, AO_IgnoreError, 1)) != 0)
     {
       const NdbError err= trans->getNdbError();
@@ -5251,6 +5285,7 @@ static int ndbcluster_rollback(handlerto
                             "stmt" : "all"));
   DBUG_ASSERT(ndb && trans);
 
+  thd_ndb->m_execute_count++;
   if (trans->execute(NdbTransaction::Rollback) != 0)
   {
     const NdbError err= trans->getNdbError();
@@ -7873,7 +7908,7 @@ int ndbcluster_find_files(handlerton *ht
 static int connect_callback()
 {
   pthread_mutex_lock(&LOCK_ndb_util_thread);
-  update_status_variables(&g_ndb_status,
+  update_status_variables(NULL, &g_ndb_status,
                           g_ndb_cluster_connection);
 
   uint node_id, i= 0;
@@ -9229,6 +9264,7 @@ ndb_get_table_statistics(ha_ndbcluster* 
                          const NdbRecord *record,
                          struct Ndb_statistics * ndbstat)
 {
+  Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
   NdbTransaction* pTrans;
   NdbError error;
   int retries= 10;
@@ -9272,6 +9308,7 @@ ndb_get_table_statistics(ha_ndbcluster* 
       goto retry;
     }
     
+    thd_ndb->m_execute_count++;
     if (pTrans->execute(NdbTransaction::NoCommit,
                         NdbOperation::AbortOnError,
                         TRUE) == -1)
@@ -9361,6 +9398,7 @@ int
 ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb, const NDBTAB *ndbtab,
                          struct Ndb_statistics * ndbstat)
 {
+  Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
   NdbTransaction* pTrans;
   NdbError error;
   int retries= 10;
@@ -9422,6 +9460,7 @@ ndb_get_table_statistics(ha_ndbcluster* 
     pOp->getValue(NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY, 
 		  (char*)&var_mem);
     
+    thd_ndb->m_execute_count++;
     if (pTrans->execute(NdbTransaction::NoCommit,
                         NdbOperation::AbortOnError,
                         TRUE) == -1)
@@ -10524,11 +10563,12 @@ ndbcluster_show_status(handlerton *hton,
   }
 
   Ndb* ndb= check_ndb_in_thd(thd);
+  Thd_ndb *thd_ndb= get_thd_ndb(thd);
   struct st_ndb_status ns;
   if (ndb)
-    update_status_variables(&ns, get_thd_ndb(thd)->connection);
+    update_status_variables(thd_ndb, &ns, thd_ndb->connection);
   else
-    update_status_variables(&ns, g_ndb_cluster_connection);
+    update_status_variables(NULL, &ns, g_ndb_cluster_connection);
 
   buflen=
     my_snprintf(buf, sizeof(buf),
@@ -11524,8 +11564,35 @@ static int ndbcluster_fill_files_table(h
   DBUG_RETURN(0);
 }
 
+static int show_ndb_vars(THD *thd, SHOW_VAR *var, char *buff)
+{
+  if (!check_ndb_in_thd(thd))
+    return -1;
+  struct st_ndb_status *st;
+  SHOW_VAR *st_var;
+  {
+    char *mem= (char*)sql_alloc(sizeof(struct st_ndb_status) +
+                                sizeof(ndb_status_variables));
+    st= new (mem) struct st_ndb_status;
+    st_var= (SHOW_VAR*)(mem + sizeof(struct st_ndb_status));
+    memcpy(st_var, &ndb_status_variables, sizeof(ndb_status_variables));
+    int i= 0;
+    SHOW_VAR *tmp= &(ndb_status_variables[0]);
+    for (; tmp->value; tmp++, i++)
+      st_var[i].value= mem + (tmp->value - (char*)&g_ndb_status);
+  }
+  {
+    Thd_ndb *thd_ndb= get_thd_ndb(thd);
+    Ndb_cluster_connection *c= thd_ndb->connection;
+    update_status_variables(thd_ndb, st, c);
+  }
+  var->type= SHOW_ARRAY;
+  var->value= (char *) st_var;
+  return 0;
+}
+
 SHOW_VAR ndb_status_variables_export[]= {
-  {"Ndb",                      (char*) &ndb_status_variables,   SHOW_ARRAY},
+  {"Ndb", (char*) &show_ndb_vars,                 SHOW_FUNC},
   {NullS, NullS, SHOW_LONG}
 };
 
diff -Nrup a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
--- a/sql/ha_ndbcluster.h	2007-08-25 21:13:31 +02:00
+++ b/sql/ha_ndbcluster.h	2007-10-02 12:15:38 +02:00
@@ -236,6 +236,8 @@ class Thd_ndb 
     we execute() to flush the rows buffered in m_batch_mem_root.
   */
   uint m_unsent_bytes;
+
+  uint m_execute_count;
 };
 
 class ha_ndbcluster: public handler
diff -Nrup a/sql/set_var.cc b/sql/set_var.cc
--- a/sql/set_var.cc	2007-08-26 13:31:16 +02:00
+++ b/sql/set_var.cc	2007-10-02 12:15:38 +02:00
@@ -551,6 +551,9 @@ static sys_var_thd_bit	sys_sql_big_table
 					   set_option_bit,
 					   OPTION_BIG_TABLES);
 #endif
+static sys_var_thd_bit	sys_allow_batch(&vars, "sql_allow_batch", 0,
+                                        set_option_bit,
+                                        OPTION_ALLOW_BATCH);
 static sys_var_thd_bit	sys_big_selects(&vars, "sql_big_selects", 0,
 					set_option_bit,
 					OPTION_BIG_SELECTS);
Thread
bk commit into 5.2 tree (tomas:1.2579)tomas2 Oct