Commit 5cb5a11b authored by unknown's avatar unknown
Browse files

sql/handler.cc

    smarter xid-to-str routiine
    fixed assert crash in XA RECOVER
sql/sql_parse.cc
    XA COMMIT/ROLLBACK did not send_ok in some cases


sql/handler.cc:
  smarter xid-to-str routiine
  fixed assert crash in XA RECOVER
sql/sql_parse.cc:
  XA COMMIT/ROLLBACK did not send_ok in some cases
parent 232dc922
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -762,6 +762,14 @@ static char* xid_to_str(char *buf, XID *xid)
  for (i=0; i < xid->gtrid_length+xid->bqual_length; i++)
  {
    uchar c=(uchar)xid->data[i];
    bool is_next_dig;
    if (i < XIDDATASIZE)
    {
      char ch=xid->data[i+1];
      is_next_dig=(c >= '0' && c <='9');
    }
    else
      is_next_dig=FALSE;
    if (i == xid->gtrid_length)
    {
      *s++='\'';
@@ -774,9 +782,11 @@ static char* xid_to_str(char *buf, XID *xid)
    if (c < 32 || c > 126)
    {
      *s++='\\';
      *s++='x';
      *s++=_dig_vec_lower[c >> 4];
      *s++=_dig_vec_lower[c & 15];
      if (c > 077 || is_next_dig)
        *s++=_dig_vec_lower[c >> 6];
      if (c > 007 || is_next_dig)
        *s++=_dig_vec_lower[(c >> 3) & 7];
      *s++=_dig_vec_lower[c & 7];
    }
    else
    {
@@ -862,6 +872,10 @@ int ha_recover(HASH *commit_list)
        my_xid x=list[i].get_my_xid();
        if (!x) // not "mine" - that is generated by external TM
        {
#ifndef DBUG_OFF
          char buf[XIDDATASIZE*4+6]; // see xid_to_str
          sql_print_information("ignore xid %s", xid_to_str(buf, list+i));
#endif
          found_foreign_xids++;
          continue;
        }
@@ -962,9 +976,9 @@ bool mysql_xa_recover(THD *thd)
        if (xid->get_my_xid())
          continue; // skip "our" xids
        protocol->prepare_for_resend();
        protocol->store_long((longlong)xid->formatID);
        protocol->store_long((longlong)xid->gtrid_length);
        protocol->store_long((longlong)xid->bqual_length);
        protocol->store_longlong((longlong)xid->formatID, FALSE);
        protocol->store_longlong((longlong)xid->gtrid_length, FALSE);
        protocol->store_longlong((longlong)xid->bqual_length, FALSE);
        protocol->store(xid->data, xid->gtrid_length+xid->bqual_length,
                        &my_charset_bin);
        if (protocol->write())
+4 −4
Original line number Diff line number Diff line
@@ -4382,6 +4382,8 @@ mysql_execute_command(THD *thd)
    {
      if (!(res= !ha_commit_or_rollback_by_xid(&thd->lex->ident, 1)))
        my_error(ER_XAER_NOTA, MYF(0));
      else
        send_ok(thd);
      break;
    }
    if (thd->transaction.xa_state == XA_IDLE && thd->lex->xa_opt == XA_ONE_PHASE)
@@ -4390,20 +4392,16 @@ mysql_execute_command(THD *thd)
      if ((r= ha_commit(thd)))
        my_error(r == 1 ? ER_XA_RBROLLBACK : ER_XAER_RMERR, MYF(0));
      else
      {
        send_ok(thd);
    }
    }
    else
    if (thd->transaction.xa_state == XA_PREPARED && thd->lex->xa_opt == XA_NONE)
    {
      if (ha_commit_one_phase(thd, 1))
        my_error(ER_XAER_RMERR, MYF(0));
      else
      {
        send_ok(thd);
    }
    }
    else
    {
      my_error(ER_XAER_RMFAIL, MYF(0),
@@ -4419,6 +4417,8 @@ mysql_execute_command(THD *thd)
    {
      if (!(res= !ha_commit_or_rollback_by_xid(&thd->lex->ident, 0)))
        my_error(ER_XAER_NOTA, MYF(0));
      else
        send_ok(thd);
      break;
    }
    if (thd->transaction.xa_state != XA_IDLE &&