List:Commits« Previous MessageNext Message »
From:'Hartmut Holzgraefe' Date:September 7 2006 11:49am
Subject:bk commit into 5.0 tree (hartmut:1.2261)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of hartmut. When hartmut 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, 2006-09-07 13:48:53+02:00, hartmut@stripped +1 -0
  Merge hholzgraefe@stripped:/home/bk/mysql-5.0
  into  mysql.com:/home/hartmut/projects/mysql/dev/5.0
  MERGE: 1.2216.1.4

  sql/ha_ndbcluster.cc@stripped, 2006-09-07 13:48:45+02:00, hartmut@stripped +0 -0
    Auto merged
    MERGE: 1.273.1.5

# 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:	hartmut
# Host:	linux.site
# Root:	/home/hartmut/projects/mysql/dev/5.0/RESYNC

--- 1.274/sql/ha_ndbcluster.cc	2006-09-07 13:49:00 +02:00
+++ 1.275/sql/ha_ndbcluster.cc	2006-09-07 13:49:00 +02:00
@@ -35,6 +35,7 @@
 // options from from mysqld.cc
 extern my_bool opt_ndb_optimized_node_selection;
 extern const char *opt_ndbcluster_connectstring;
+extern ulong opt_ndb_cache_check_time;
 
 // Default value for parallelism
 static const int parallelism= 0;
@@ -228,13 +229,15 @@
 
 
 inline
-int execute_no_commit(ha_ndbcluster *h, NdbTransaction *trans)
+int execute_no_commit(ha_ndbcluster *h, NdbTransaction *trans,
+		      bool force_release)
 {
 #ifdef NOT_USED
   int m_batch_execute= 0;
   if (m_batch_execute)
     return 0;
 #endif
+  h->release_completed_operations(trans, force_release);
   return trans->execute(NdbTransaction::NoCommit,
                         NdbTransaction::AbortOnError,
                         h->m_force_send);
@@ -267,13 +270,15 @@
 }
 
 inline
-int execute_no_commit_ie(ha_ndbcluster *h, NdbTransaction *trans)
+int execute_no_commit_ie(ha_ndbcluster *h, NdbTransaction *trans,
+			 bool force_release)
 {
 #ifdef NOT_USED
   int m_batch_execute= 0;
   if (m_batch_execute)
     return 0;
 #endif
+  h->release_completed_operations(trans, force_release);
   return trans->execute(NdbTransaction::NoCommit,
                         NdbTransaction::AO_IgnoreError,
                         h->m_force_send);
@@ -290,6 +295,7 @@
   all= NULL;
   stmt= NULL;
   error= 0;
+  query_state&= NDB_QUERY_NORMAL;
 }
 
 Thd_ndb::~Thd_ndb()
@@ -1447,7 +1453,7 @@
   if ((res= define_read_attrs(buf, op)))
     DBUG_RETURN(res);
   
-  if (execute_no_commit_ie(this,trans) != 0) 
+  if (execute_no_commit_ie(this,trans,false) != 0) 
   {
     table->status= STATUS_NOT_FOUND;
     DBUG_RETURN(ndb_err(trans));
@@ -1494,7 +1500,7 @@
         ERR_RETURN(trans->getNdbError());
     }
   }
-  if (execute_no_commit(this,trans) != 0) 
+  if (execute_no_commit(this,trans,false) != 0) 
   {
     table->status= STATUS_NOT_FOUND;
     DBUG_RETURN(ndb_err(trans));
@@ -1634,7 +1640,7 @@
   }
   last= trans->getLastDefinedOperation();
   if (first)
-    res= execute_no_commit_ie(this,trans);
+    res= execute_no_commit_ie(this,trans,false);
   else
   {
     // Table has no keys
@@ -1683,7 +1689,7 @@
   if ((res= define_read_attrs(buf, op)))
     DBUG_RETURN(res);
 
-  if (execute_no_commit_ie(this,trans) != 0) 
+  if (execute_no_commit_ie(this,trans,false) != 0) 
   {
     table->status= STATUS_NOT_FOUND;
     DBUG_RETURN(ndb_err(trans));
@@ -1731,7 +1737,7 @@
     */
     if (m_ops_pending && m_blobs_pending)
     {
-      if (execute_no_commit(this,trans) != 0)
+      if (execute_no_commit(this,trans,false) != 0)
         DBUG_RETURN(ndb_err(trans));
       m_ops_pending= 0;
       m_blobs_pending= FALSE;
@@ -1763,7 +1769,7 @@
       {
         if (m_transaction_on)
         {
-          if (execute_no_commit(this,trans) != 0)
+          if (execute_no_commit(this,trans,false) != 0)
             DBUG_RETURN(-1);
         }
         else
@@ -2067,7 +2073,7 @@
     DBUG_RETURN(res);
   }
 
-  if (execute_no_commit(this,trans) != 0)
+  if (execute_no_commit(this,trans,false) != 0)
     DBUG_RETURN(ndb_err(trans));
   
   DBUG_RETURN(next_result(buf));
@@ -2100,7 +2106,7 @@
   if ((res= define_read_attrs(buf, op)))
     DBUG_RETURN(res);
 
-  if (execute_no_commit(this,trans) != 0)
+  if (execute_no_commit(this,trans,false) != 0)
     DBUG_RETURN(ndb_err(trans));
   DBUG_PRINT("exit", ("Scan started successfully"));
   DBUG_RETURN(next_result(buf));
@@ -2232,7 +2238,7 @@
     m_bulk_insert_not_flushed= FALSE;
     if (m_transaction_on)
     {
-      if (execute_no_commit(this,trans) != 0)
+      if (execute_no_commit(this,trans,false) != 0)
       {
         m_skip_auto_increment= TRUE;
         no_uncommitted_rows_execute_failure();
@@ -2432,7 +2438,7 @@
   }
 
   // Execute update operation
-  if (!cursor && execute_no_commit(this,trans) != 0) {
+  if (!cursor && execute_no_commit(this,trans,false) != 0) {
     no_uncommitted_rows_execute_failure();
     DBUG_RETURN(ndb_err(trans));
   }
@@ -2503,7 +2509,7 @@
   }
 
   // Execute delete operation
-  if (execute_no_commit(this,trans) != 0) {
+  if (execute_no_commit(this,trans,false) != 0) {
     no_uncommitted_rows_execute_failure();
     DBUG_RETURN(ndb_err(trans));
   }
@@ -2932,6 +2938,26 @@
 
   NdbScanOperation *cursor= m_active_cursor ? m_active_cursor : m_multi_cursor;
   
+  if (m_lock_tuple)
+  {
+    /*
+      Lock level m_lock.type either TL_WRITE_ALLOW_WRITE
+      (SELECT FOR UPDATE) or TL_READ_WITH_SHARED_LOCKS (SELECT
+      LOCK WITH SHARE MODE) and row was not explictly unlocked 
+      with unlock_row() call
+    */
+      NdbOperation *op;
+      // Lock row
+      DBUG_PRINT("info", ("Keeping lock on scanned row"));
+      
+      if (!(op= cursor->lockCurrentTuple()))
+      {
+	m_lock_tuple= false;
+	ERR_RETURN(trans->getNdbError());
+      }
+      m_ops_pending++;      
+  }
+  m_lock_tuple= false;
   if (m_ops_pending)
   {
     /*
@@ -2939,7 +2965,7 @@
       deleteing/updating transaction before closing the scan    
     */
     DBUG_PRINT("info", ("ops_pending: %d", m_ops_pending));    
-    if (execute_no_commit(this,trans) != 0) {
+    if (execute_no_commit(this,trans,false) != 0) {
       no_uncommitted_rows_execute_failure();
       DBUG_RETURN(ndb_err(trans));
     }
@@ -3349,7 +3375,7 @@
     m_bulk_insert_not_flushed= FALSE;
     if (m_transaction_on)
     {
-      if (execute_no_commit(this, trans) != 0)
+      if (execute_no_commit(this, trans,false) != 0)
       {
         no_uncommitted_rows_execute_failure();
         my_errno= error= ndb_err(trans);
@@ -3504,7 +3530,14 @@
   if (lock_type != F_UNLCK)
   {
     DBUG_PRINT("info", ("lock_type != F_UNLCK"));
-    if (!thd->transaction.on)
+    if (thd->lex->sql_command == SQLCOM_LOAD)
+    {
+      m_transaction_on= FALSE;
+      /* Would be simpler if has_transactions() didn't always say "yes" */
+      thd->options|= OPTION_STATUS_NO_TRANS_UPDATE;
+      thd->no_trans_update= TRUE;
+    }
+    else if (!thd->transaction.on)
       m_transaction_on= FALSE;
     else
       m_transaction_on= thd->variables.ndb_use_transactions;
@@ -3522,6 +3555,7 @@
           ERR_RETURN(ndb->getNdbError());
         no_uncommitted_rows_reset(thd);
         thd_ndb->stmt= trans;
+	thd_ndb->query_state&= NDB_QUERY_NORMAL;
         trans_register_ha(thd, FALSE, &ndbcluster_hton);
       } 
       else 
@@ -3537,6 +3571,7 @@
             ERR_RETURN(ndb->getNdbError());
           no_uncommitted_rows_reset(thd);
           thd_ndb->all= trans; 
+	  thd_ndb->query_state&= NDB_QUERY_NORMAL;
           trans_register_ha(thd, TRUE, &ndbcluster_hton);
 
           /*
@@ -3743,6 +3778,7 @@
     thd_ndb->stmt= trans;
     trans_register_ha(thd, FALSE, &ndbcluster_hton);
   }
+  thd_ndb->query_state&= NDB_QUERY_NORMAL;
   m_active_trans= trans;
 
   // Start of statement
@@ -4151,10 +4187,15 @@
       acc_row_size+= 4 + /*safety margin*/ 4;
 #endif
     ulonglong acc_fragment_size= 512*1024*1024;
+    /*
+     * if not --with-big-tables then max_rows is ulong
+     * the warning in this case is misleading though
+     */
+    ulonglong big_max_rows = (ulonglong)max_rows;
 #if MYSQL_VERSION_ID >= 50100
-    no_fragments= (max_rows*acc_row_size)/acc_fragment_size+1;
+    no_fragments= (big_max_rows*acc_row_size)/acc_fragment_size+1;
 #else
-    no_fragments= ((max_rows*acc_row_size)/acc_fragment_size+1
+    no_fragments= ((big_max_rows*acc_row_size)/acc_fragment_size+1
                    +1/*correct rounding*/)/2;
 #endif
   }
@@ -5214,6 +5255,7 @@
   pthread_cond_init(&COND_ndb_util_thread, NULL);
 
 
+  ndb_cache_check_time = opt_ndb_cache_check_time;
   // Create utility thread
   pthread_t tmp;
   if (pthread_create(&tmp, &connection_attrib, ndb_util_thread_func, 0))
@@ -5990,6 +6032,30 @@
   DBUG_RETURN(error);
 }
 
+void 
+ha_ndbcluster::release_completed_operations(NdbTransaction *trans,
+					    bool force_release)
+{
+  if (trans->hasBlobOperation())
+  {
+    /* We are reading/writing BLOB fields, 
+       releasing operation records is unsafe
+    */
+    return;
+  }
+  if (!force_release)
+  {
+    if (get_thd_ndb(current_thd)->query_state & NDB_QUERY_MULTI_READ_RANGE)
+    {
+      /* We are batching reads and have not consumed all fetched
+	 rows yet, releasing operation records is unsafe 
+      */
+      return;
+    }
+  }
+  trans->releaseCompletedOperations();
+}
+
 int
 ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p,
                                       KEY_MULTI_RANGE *ranges, 
@@ -6004,6 +6070,7 @@
   NDB_INDEX_TYPE index_type= get_index_type(active_index);
   ulong reclength= table->s->reclength;
   NdbOperation* op;
+  Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
 
   if (uses_blob_value(m_retrieve_all_fields))
   {
@@ -6017,7 +6084,7 @@
                                                 sorted, 
                                                 buffer));
   }
-
+  thd_ndb->query_state|= NDB_QUERY_MULTI_READ_RANGE;
   m_disable_multi_read= FALSE;
 
   /**
@@ -6164,7 +6231,7 @@
    */
   m_current_multi_operation= 
     lastOp ? lastOp->next() : m_active_trans->getFirstDefinedOperation();
-  if (!(res= execute_no_commit_ie(this, m_active_trans)))
+  if (!(res= execute_no_commit_ie(this, m_active_trans, true)))
   {
     m_multi_range_defined= multi_range_curr;
     multi_range_curr= ranges;
Thread
bk commit into 5.0 tree (hartmut:1.2261)'Hartmut Holzgraefe'7 Sep