List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:October 5 2010 8:32am
Subject:bzr push into mysql-5.1-telco-7.0 branch (magnus.blaudd:3829 to 3830)
View as plain text  
 3830 Magnus Blåudd	2010-10-05 [merge]
      Merge

    modified:
      include/my_global.h
      mysql-test/suite/ndb/r/ndb_bulk_delete.result
      mysql-test/suite/ndb/t/ndb_bulk_delete.test
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster.h
      sql/handler.cc
      sql/handler.h
      sql/sql_delete.cc
 3829 Jonas Oreland	2010-10-04
      ndb - change constructor on PollGuard

    modified:
      storage/ndb/include/ndbapi/Ndb.hpp
      storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
      storage/ndb/src/ndbapi/NdbScanOperation.cpp
      storage/ndb/src/ndbapi/Ndbif.cpp
      storage/ndb/src/ndbapi/TransporterFacade.cpp
      storage/ndb/src/ndbapi/TransporterFacade.hpp
=== modified file 'include/my_global.h'
--- a/include/my_global.h	2010-06-16 20:49:05 +0000
+++ b/include/my_global.h	2010-10-01 11:19:52 +0000
@@ -1098,7 +1098,6 @@ typedef off_t os_off_t;
 #define SOCKET_ETIMEDOUT SOCKET_EINTR
 #define SOCKET_EWOULDBLOCK EWOULDBLOCK
 #define SOCKET_EADDRINUSE EADDRINUSE
-#define SOCKET_ECONNREFUSED ECONNREFUSED
 #define SOCKET_ENFILE	ENFILE
 #define SOCKET_EMFILE	EMFILE
 #endif

=== modified file 'mysql-test/suite/ndb/r/ndb_bulk_delete.result'
--- a/mysql-test/suite/ndb/r/ndb_bulk_delete.result	2008-09-24 14:44:11 +0000
+++ b/mysql-test/suite/ndb/r/ndb_bulk_delete.result	2010-10-01 13:20:38 +0000
@@ -1,4 +1,3 @@
-DROP TABLE IF EXISTS t1;
 create table t1 (a int key) engine ndb;
 insert into t1 values (1);
 insert into t1 select a+1 from t1;
@@ -9,6 +8,9 @@ insert into t1 select a+16 from t1;
 insert into t1 select a+32 from t1;
 insert into t1 select a+64 from t1;
 insert into t1 select a+128 from t1;
+select count(*) from t1;
+count(*)
+256
 
 # test: simple delete of multiple pk's
 # expected result 1 roundtrips
@@ -46,5 +48,26 @@ affected rows: 0
 @ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count
 1
 affected rows: 1
+select count(*) as "0(was deleted)" from t1 where a in (1,7, 90, 100, 130);
+0(was deleted)
+0
+select count(*) as "0(never existed)" from t1 where a=1000;
+0(never existed)
+0
+select count(*) as "0(never existed)" from t1
+where a in (1000, 1001, 1002, 1003, 1004);
+0(never existed)
+0
+select count(*) as "251(remaining)" from t1;
+251(remaining)
+251
+select count(*) as "5(not deleted)" from t1 where a in (2, 3, 4, 5, 6);
+5(not deleted)
+5
 drop table t1;
-affected rows: 0
+create table t2 (a int primary key, b varchar(256)) engine ndb;
+Has loaded 2000 rows
+2000
+Should be 1500 rows left now
+1500
+drop table t2, t3;

=== modified file 'mysql-test/suite/ndb/t/ndb_bulk_delete.test'
--- a/mysql-test/suite/ndb/t/ndb_bulk_delete.test	2010-09-22 11:36:01 +0000
+++ b/mysql-test/suite/ndb/t/ndb_bulk_delete.test	2010-10-01 13:34:24 +0000
@@ -1,13 +1,9 @@
 #
-# Basic test of bulk update interface.  Test counts number of execute
-# as measurement of numbre of round trips to kernel.
+# Basic test of bulk delete interface. Test counts number of execute
+# as measurement of number of round trips to kernel.
 #
 -- source include/have_ndb.inc
 
---disable_warnings
-DROP TABLE IF EXISTS t1;
---enable_warnings
-
 create table t1 (a int key) engine ndb;
 insert into t1 values (1);
 insert into t1 select a+1 from t1;
@@ -18,6 +14,7 @@ insert into t1 select a+16 from t1;
 insert into t1 select a+32 from t1;
 insert into t1 select a+64 from t1;
 insert into t1 select a+128 from t1;
+select count(*) from t1; # 256 rows
 
 --enable_info
 
@@ -57,6 +54,83 @@ delete from t1 where a=1000;
 delete from t1 where a in (1000, 1001, 1002, 1003, 1004);
 --source suite/ndb/include/ndb_execute_count.inc
 
+--disable_info
+
+# Check that the expected rows remains
+select count(*) as "0(was deleted)" from t1 where a in (1,7, 90, 100, 130);
+select count(*) as "0(never existed)" from t1 where a=1000;
+select count(*) as "0(never existed)" from t1
+  where a in (1000, 1001, 1002, 1003, 1004);
+select count(*) as "251(remaining)" from t1;
+select count(*) as "5(not deleted)" from t1 where a in (2, 3, 4, 5, 6);
 
 # cleanup
 drop table t1;
+
+
+# Build table t2 with 2000 rows
+create table t2 (a int primary key, b varchar(256)) engine ndb;
+--disable_result_log
+--disable_query_log
+let $i = 200;
+while($i)
+{
+  eval insert into t2 values
+   ($i*10,"building a table"),
+   ($i*10+1, "one row"), ($i*10+2, "another row"),
+   ($i*10+3, "the third row"), ($i*10+4, ""),
+   ($i*10+5, "fifth"), ($i*10+6, "a longer string at line six"),
+   ($i*10+7, "in the sevent it will get even longer"),
+   ($i*10+8, "another row 8"), ($i*10+9, "another row 9");
+  dec $i;
+}
+--enable_result_log
+select count(*) as "Has loaded 2000 rows" from t2;
+--enable_query_log
+
+# Build table t3 and delete from it with increasing
+# number of values in the IN clause, don't do too many
+# as mysqld will switch to full table scan
+--disable_query_log
+--disable_result_log
+create table t3 like t2;
+let $i = 50;
+let $in = $i;
+while($i)
+{
+  # Repopulate t3 with all rows
+  replace into t3 select * from t2;
+
+  # Extend the IN clause with another 10 values
+  let $in =$in,$i*10,$i*10+1,$i*10+2,$i*10+3,$i*10+4,$i*10+5,
+           $i*10+6,$i*10+7,$i*10+8,$i*10+9;
+
+  # Get the execute count before DELETE
+  let $before= `select VARIABLE_VALUE from information_schema.session_status
+                  where variable_name like 'NDB_EXECUTE_COUNT'`;
+
+  # Run the query
+  eval delete from t3 where a in ($in);
+
+  # Check that execute count after DELETE is not greater than 3
+  let $after= `select VARIABLE_VALUE from information_schema.session_status
+                 where variable_name like 'NDB_EXECUTE_COUNT'`;
+  if (!`select $after-$before <= 3`)
+  {
+    echo before: $before;
+    echo after: $after;
+    enable_result_log;
+    show session status like 'ndb%';
+    die Got unexpected ndb_execute_count value;
+  }
+
+  dec $i;
+}
+--enable_result_log
+select count(*) as "Should be 1500 rows left now" from t3;
+--enable_query_log
+
+# Cleanup
+drop table t2, t3;
+
+

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2010-09-22 12:10:34 +0000
+++ b/sql/ha_ndbcluster.cc	2010-10-01 13:34:24 +0000
@@ -1543,7 +1543,7 @@ int get_ndb_blobs_value(TABLE* table, Nd
   Check if any set or get of blob value in current query.
 */
 
-bool ha_ndbcluster::uses_blob_value(const MY_BITMAP *bitmap)
+bool ha_ndbcluster::uses_blob_value(const MY_BITMAP *bitmap) const
 {
   uint *blob_index, *blob_index_end;
   if (table_share->blob_fields == 0)
@@ -4676,18 +4676,14 @@ int ha_ndbcluster::delete_row(const ucha
 bool ha_ndbcluster::start_bulk_delete()
 {
   DBUG_ENTER("start_bulk_delete");
-  DBUG_RETURN(FALSE);
-}
-
-int ha_ndbcluster::bulk_delete_row(const uchar *record)
-{
-  DBUG_ENTER("bulk_delete_row");
-  DBUG_RETURN(ndb_delete_row(record, FALSE, TRUE));
+  m_is_bulk_delete = true;
+  DBUG_RETURN(0); // Bulk delete used by handler
 }
 
 int ha_ndbcluster::end_bulk_delete()
 {
   DBUG_ENTER("end_bulk_delete");
+  assert(m_is_bulk_delete); // Don't allow end() without start()
   if (m_thd_ndb->m_unsent_bytes &&
       !(table->in_use->options & OPTION_ALLOW_BATCH) &&
       !m_thd_ndb->m_handler)
@@ -4702,6 +4698,7 @@ int ha_ndbcluster::end_bulk_delete()
     }
     m_rows_deleted-= ignore_count;
   }
+  m_is_bulk_delete = false;
   DBUG_RETURN(0);
 }
 
@@ -4711,8 +4708,7 @@ int ha_ndbcluster::end_bulk_delete()
 */
 
 int ha_ndbcluster::ndb_delete_row(const uchar *record,
-                                  bool primary_key_update,
-                                  bool is_bulk_delete)
+                                  bool primary_key_update)
 {
   THD *thd= table->in_use;
   Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -4721,7 +4717,7 @@ int ha_ndbcluster::ndb_delete_row(const 
   const NdbOperation *op;
   uint32 part_id= ~uint32(0);
   int error;
-  bool allow_batch= is_bulk_delete || (thd->options & OPTION_ALLOW_BATCH);
+  bool allow_batch= m_is_bulk_delete || (thd->options & OPTION_ALLOW_BATCH);
   DBUG_ENTER("ndb_delete_row");
   DBUG_ASSERT(trans);
 
@@ -5862,6 +5858,9 @@ int ha_ndbcluster::reset()
   m_delete_cannot_batch= FALSE;
   m_update_cannot_batch= FALSE;
 
+  assert(m_is_bulk_delete == false);
+  m_is_bulk_delete = false;
+
   DBUG_RETURN(0);
 }
 
@@ -8698,6 +8697,7 @@ ha_ndbcluster::ha_ndbcluster(handlerton 
   m_update_cannot_batch(FALSE),
   m_skip_auto_increment(TRUE),
   m_blobs_pending(0),
+  m_is_bulk_delete(false),
   m_blobs_row_total_size(0),
   m_blobs_buffer(0),
   m_blobs_buffer_size(0),

=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h	2010-09-15 18:38:13 +0000
+++ b/sql/ha_ndbcluster.h	2010-10-01 13:34:24 +0000
@@ -660,10 +660,8 @@ private:
                     bool batched_update);
 
   bool start_bulk_delete();
-  int bulk_delete_row(const uchar *record);
   int end_bulk_delete();
-  int ndb_delete_row(const uchar *record, bool primary_key_update,
-                     bool is_bulk_delete= FALSE);
+  int ndb_delete_row(const uchar *record, bool primary_key_update);
 
   int ndb_optimize_table(THD* thd, uint delay);
 
@@ -729,7 +727,7 @@ private:
                                   ulonglong nb_desired_values,
                                   ulonglong *first_value,
                                   ulonglong *nb_reserved_values);
-  bool uses_blob_value(const MY_BITMAP *bitmap);
+  bool uses_blob_value(const MY_BITMAP *bitmap) const;
 
   static inline bool isManualBinlogExec(THD *thd);
 
@@ -848,6 +846,7 @@ private:
   bool m_skip_auto_increment;
   bool m_blobs_pending;
   bool m_slow_path;
+  bool m_is_bulk_delete;
 
   /* State for setActiveHook() callback for reading blob data. */
   uint m_blob_counter;

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2010-09-15 18:26:11 +0000
+++ b/sql/handler.cc	2010-10-01 13:34:24 +0000
@@ -4955,19 +4955,14 @@ int handler::ha_update_row(const uchar *
   return 0;
 }
 
-int handler::ha_delete_row(const uchar *buf, bool will_batch)
+int handler::ha_delete_row(const uchar *buf)
 {
   int error;
   Log_func *log_func= Delete_rows_log_event::binlog_row_logging_function;
 
   mark_trx_read_write();
 
-  if (will_batch)
-  {
-    if (unlikely((error= bulk_delete_row(buf)) != 0))
-      return error;
-  }
-  else if (unlikely((error= delete_row(buf)) != 0))
+  if (unlikely((error= delete_row(buf)) != 0))
     return error;
   if (unlikely((error= binlog_log_row(table, buf, 0, log_func)) != 0))
     return error;

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2010-09-15 18:38:13 +0000
+++ b/sql/handler.h	2010-10-01 13:34:24 +0000
@@ -290,7 +290,7 @@ typedef Bitmap<HA_MAX_ALTER_FLAGS> HA_AL
 #define HA_BLOCK_LOCK		256	/* unlock when reading some records */
 #define HA_OPEN_TEMPORARY	512
 
-/* Some key definitions */
+	/* Some key definitions */
 #define HA_KEY_NULL_LENGTH	1
 #define HA_KEY_BLOB_LENGTH	2
 
@@ -1302,7 +1302,7 @@ public:
   int ha_external_lock(THD *thd, int lock_type);
   int ha_write_row(uchar * buf);
   int ha_update_row(const uchar * old_data, uchar * new_data);
-  int ha_delete_row(const uchar * buf, bool will_batch= FALSE);
+  int ha_delete_row(const uchar * buf);
   void ha_release_auto_increment();
 
   int check_collation_compatibility();
@@ -2078,22 +2078,6 @@ private:
     DBUG_ASSERT(FALSE);
     return HA_ERR_WRONG_COMMAND;
   }
-  /*
-    This method is similar to delete_row, however the handler doesn't need
-    to execute the delete at this point in time. The handler can be certain
-    that another call to bulk_delete_row will occur OR a call to
-    end_bulk_delete before the set of deletes in this query is concluded.
-
-    @param    record       Record to delete
-
-    @retval  0   Success
-    @retval !=0  Error code
-  */
-  virtual int bulk_delete_row(const uchar *record)
-  {
-    DBUG_ASSERT(FALSE);
-    return HA_ERR_WRONG_COMMAND;
-  }
   /**
     This is called to delete all rows in a table
     If the handler don't support this, then this function will
@@ -2149,6 +2133,9 @@ private:
   { return HA_ERR_WRONG_COMMAND; }
 };
 
+
+	/* Some extern variables used with handlers */
+
 extern const char *ha_row_type[];
 extern MYSQL_PLUGIN_IMPORT const char *tx_isolation_names[];
 extern MYSQL_PLUGIN_IMPORT const char *binlog_format_names[];
@@ -2156,7 +2143,7 @@ extern TYPELIB tx_isolation_typelib;
 extern TYPELIB myisam_stats_method_typelib;
 extern ulong total_ha, total_ha_2pc;
 
-/* Wrapper functions */
+       /* Wrapper functions */
 #define ha_commit(thd) (ha_commit_trans((thd), TRUE))
 #define ha_rollback(thd) (ha_rollback_trans((thd), TRUE))
 

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2010-06-16 12:04:53 +0000
+++ b/sql/sql_delete.cc	2010-10-01 13:20:38 +0000
@@ -336,7 +336,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
         break;
       }
 
-      if (!(error= table->file->ha_delete_row(table->record[0], will_batch)))
+      if (!(error= table->file->ha_delete_row(table->record[0])))
       {
 	deleted++;
         if (triggers_applicable &&

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20101005075647-7idtjt2pechaa7or.bundle
Thread
bzr push into mysql-5.1-telco-7.0 branch (magnus.blaudd:3829 to 3830) Magnus Blåudd5 Oct