List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:June 30 2010 9:37am
Subject:bzr push into mysql-trunk branch (Dmitry.Shulga:3087 to 3089)
View as plain text  
 3089 Dmitry Shulga	2010-06-30 [merge]
      Auto-merge from mysql-trunk-merge.

    modified:
      libmysql/libmysql.c
 3088 Dmitry Shulga	2010-06-30 [merge]
      Merge fix for bug #51855
     @ sql/sql_class.cc
        xid_cache_insert modified: added checking for element in cache
        before insert it,
     @ sql/transaction.cc
        trans_xa_start modified: sequence of calls to 
        xid_cache_search/xid_cache_insert replaced to xid_cache_insert
        that does cache search/insert operations atomically

    modified:
      sql/sql_class.cc
      sql/transaction.cc
 3087 Luis Soares	2010-06-28 [merge]
      BUG 53657: empty merge from mysql-5.1-bugteam.

=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c	2010-04-11 06:52:42 +0000
+++ b/libmysql/libmysql.c	2010-06-30 09:17:27 +0000
@@ -2127,7 +2127,12 @@ static my_bool execute(MYSQL_STMT *stmt,
   stmt->insert_id= mysql->insert_id;
   if (res)
   {
-    set_stmt_errmsg(stmt, net);
+    /* 
+      Don't set stmt error if stmt->mysql is NULL, as the error in this case 
+      has already been set by mysql_prune_stmt_list(). 
+    */
+    if (stmt->mysql)
+      set_stmt_errmsg(stmt, net);
     DBUG_RETURN(1);
   }
   DBUG_RETURN(0);
@@ -2338,7 +2343,12 @@ stmt_read_row_from_cursor(MYSQL_STMT *st
                                             buff, sizeof(buff), (uchar*) 0, 0,
                                             1, stmt))
     {
-      set_stmt_errmsg(stmt, net);
+      /* 
+        Don't set stmt error if stmt->mysql is NULL, as the error in this case 
+        has already been set by mysql_prune_stmt_list(). 
+      */
+      if (stmt->mysql)
+        set_stmt_errmsg(stmt, net);
       return 1;
     }
     if ((*mysql->methods->read_rows_from_cursor)(stmt))
@@ -3025,7 +3035,12 @@ mysql_stmt_send_long_data(MYSQL_STMT *st
                                             buff, sizeof(buff), (uchar*) data,
                                             length, 1, stmt))
     {
-      set_stmt_errmsg(stmt, &mysql->net);
+      /* 
+        Don't set stmt error if stmt->mysql is NULL, as the error in this case 
+        has already been set by mysql_prune_stmt_list(). 
+      */
+      if (stmt->mysql)
+        set_stmt_errmsg(stmt, &mysql->net);
       DBUG_RETURN(1);
     }
   }
@@ -4440,7 +4455,12 @@ int STDCALL mysql_stmt_store_result(MYSQ
     if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff),
                              (uchar*) 0, 0, 1, stmt))
     {
-      set_stmt_errmsg(stmt, net);
+      /* 
+        Don't set stmt error if stmt->mysql is NULL, as the error in this case 
+        has already been set by mysql_prune_stmt_list(). 
+      */
+      if (stmt->mysql)
+        set_stmt_errmsg(stmt, net);
       DBUG_RETURN(1);
     }
   }

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-06-28 22:18:22 +0000
+++ b/sql/sql_class.cc	2010-06-30 04:40:54 +0000
@@ -3525,9 +3525,13 @@ bool xid_cache_insert(XID *xid, enum xa_
 bool xid_cache_insert(XID_STATE *xid_state)
 {
   mysql_mutex_lock(&LOCK_xid_cache);
-  DBUG_ASSERT(my_hash_search(&xid_cache, xid_state->xid.key(),
-                             xid_state->xid.key_length())==0);
-  my_bool res=my_hash_insert(&xid_cache, (uchar*)xid_state);
+  if (my_hash_search(&xid_cache, xid_state->xid.key(), xid_state->xid.key_length()))
+  {
+    mysql_mutex_unlock(&LOCK_xid_cache);
+    my_error(ER_XAER_DUPID, MYF(0));
+    return TRUE;
+  }
+  my_bool res= my_hash_insert(&xid_cache, (uchar*)xid_state);
   mysql_mutex_unlock(&LOCK_xid_cache);
   return res;
 }

=== modified file 'sql/transaction.cc'
--- a/sql/transaction.cc	2010-05-07 16:28:59 +0000
+++ b/sql/transaction.cc	2010-06-30 04:40:54 +0000
@@ -488,21 +488,36 @@ bool trans_xa_start(THD *thd)
   }
 
   /* TODO: JOIN is not supported yet. */
-  if (thd->lex->xa_opt != XA_NONE)
+  if (thd->in_sub_stmt)
+    my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
+  else if (thd->lex->xa_opt != XA_NONE)
     my_error(ER_XAER_INVAL, MYF(0));
   else if (xa_state != XA_NOTR)
     my_error(ER_XAER_RMFAIL, MYF(0), xa_state_names[xa_state]);
   else if (thd->locked_tables_mode || thd->in_active_multi_stmt_transaction())
     my_error(ER_XAER_OUTSIDE, MYF(0));
-  else if (xid_cache_search(thd->lex->xid))
-    my_error(ER_XAER_DUPID, MYF(0));
-  else if (!trans_begin(thd))
+  else
   {
     DBUG_ASSERT(thd->transaction.xid_state.xid.is_null());
     thd->transaction.xid_state.xa_state= XA_ACTIVE;
     thd->transaction.xid_state.rm_error= 0;
     thd->transaction.xid_state.xid.set(thd->lex->xid);
-    xid_cache_insert(&thd->transaction.xid_state);
+
+    if (xid_cache_insert(&thd->transaction.xid_state))
+    {
+      thd->transaction.xid_state.xa_state= XA_NOTR;
+      thd->transaction.xid_state.xid.null();
+      DBUG_RETURN(TRUE);
+    }
+    thd->variables.option_bits&= ~OPTION_KEEP_LOG;
+    thd->transaction.all.modified_non_trans_table= FALSE;
+    thd->variables.option_bits|= OPTION_BEGIN;
+    thd->server_status|= SERVER_STATUS_IN_TRANS;
+    /*
+      Release transactional metadata locks only after the
+      transaction has been committed.
+    */
+    thd->mdl_context.release_transactional_locks();
     DBUG_RETURN(FALSE);
   }
 


Attachment: [text/bzr-bundle] bzr/dmitry.shulga@sun.com-20100630093620-hn2k19cfs72zuuzd.bundle
Thread
bzr push into mysql-trunk branch (Dmitry.Shulga:3087 to 3089)Dmitry Shulga30 Jun