Commit 5cb5a11b authored by unknown's avatar unknown

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
...@@ -762,6 +762,14 @@ static char* xid_to_str(char *buf, XID *xid) ...@@ -762,6 +762,14 @@ static char* xid_to_str(char *buf, XID *xid)
for (i=0; i < xid->gtrid_length+xid->bqual_length; i++) for (i=0; i < xid->gtrid_length+xid->bqual_length; i++)
{ {
uchar c=(uchar)xid->data[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) if (i == xid->gtrid_length)
{ {
*s++='\''; *s++='\'';
...@@ -774,9 +782,11 @@ static char* xid_to_str(char *buf, XID *xid) ...@@ -774,9 +782,11 @@ static char* xid_to_str(char *buf, XID *xid)
if (c < 32 || c > 126) if (c < 32 || c > 126)
{ {
*s++='\\'; *s++='\\';
*s++='x'; if (c > 077 || is_next_dig)
*s++=_dig_vec_lower[c >> 4]; *s++=_dig_vec_lower[c >> 6];
*s++=_dig_vec_lower[c & 15]; if (c > 007 || is_next_dig)
*s++=_dig_vec_lower[(c >> 3) & 7];
*s++=_dig_vec_lower[c & 7];
} }
else else
{ {
...@@ -862,6 +872,10 @@ int ha_recover(HASH *commit_list) ...@@ -862,6 +872,10 @@ int ha_recover(HASH *commit_list)
my_xid x=list[i].get_my_xid(); my_xid x=list[i].get_my_xid();
if (!x) // not "mine" - that is generated by external TM 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++; found_foreign_xids++;
continue; continue;
} }
...@@ -962,9 +976,9 @@ bool mysql_xa_recover(THD *thd) ...@@ -962,9 +976,9 @@ bool mysql_xa_recover(THD *thd)
if (xid->get_my_xid()) if (xid->get_my_xid())
continue; // skip "our" xids continue; // skip "our" xids
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store_long((longlong)xid->formatID); protocol->store_longlong((longlong)xid->formatID, FALSE);
protocol->store_long((longlong)xid->gtrid_length); protocol->store_longlong((longlong)xid->gtrid_length, FALSE);
protocol->store_long((longlong)xid->bqual_length); protocol->store_longlong((longlong)xid->bqual_length, FALSE);
protocol->store(xid->data, xid->gtrid_length+xid->bqual_length, protocol->store(xid->data, xid->gtrid_length+xid->bqual_length,
&my_charset_bin); &my_charset_bin);
if (protocol->write()) if (protocol->write())
......
...@@ -4382,6 +4382,8 @@ unsent_create_error: ...@@ -4382,6 +4382,8 @@ unsent_create_error:
{ {
if (!(res= !ha_commit_or_rollback_by_xid(&thd->lex->ident, 1))) if (!(res= !ha_commit_or_rollback_by_xid(&thd->lex->ident, 1)))
my_error(ER_XAER_NOTA, MYF(0)); my_error(ER_XAER_NOTA, MYF(0));
else
send_ok(thd);
break; break;
} }
if (thd->transaction.xa_state == XA_IDLE && thd->lex->xa_opt == XA_ONE_PHASE) if (thd->transaction.xa_state == XA_IDLE && thd->lex->xa_opt == XA_ONE_PHASE)
...@@ -4390,20 +4392,16 @@ unsent_create_error: ...@@ -4390,20 +4392,16 @@ unsent_create_error:
if ((r= ha_commit(thd))) if ((r= ha_commit(thd)))
my_error(r == 1 ? ER_XA_RBROLLBACK : ER_XAER_RMERR, MYF(0)); my_error(r == 1 ? ER_XA_RBROLLBACK : ER_XAER_RMERR, MYF(0));
else else
{
send_ok(thd); send_ok(thd);
} }
}
else else
if (thd->transaction.xa_state == XA_PREPARED && thd->lex->xa_opt == XA_NONE) if (thd->transaction.xa_state == XA_PREPARED && thd->lex->xa_opt == XA_NONE)
{ {
if (ha_commit_one_phase(thd, 1)) if (ha_commit_one_phase(thd, 1))
my_error(ER_XAER_RMERR, MYF(0)); my_error(ER_XAER_RMERR, MYF(0));
else else
{
send_ok(thd); send_ok(thd);
} }
}
else else
{ {
my_error(ER_XAER_RMFAIL, MYF(0), my_error(ER_XAER_RMFAIL, MYF(0),
...@@ -4419,6 +4417,8 @@ unsent_create_error: ...@@ -4419,6 +4417,8 @@ unsent_create_error:
{ {
if (!(res= !ha_commit_or_rollback_by_xid(&thd->lex->ident, 0))) if (!(res= !ha_commit_or_rollback_by_xid(&thd->lex->ident, 0)))
my_error(ER_XAER_NOTA, MYF(0)); my_error(ER_XAER_NOTA, MYF(0));
else
send_ok(thd);
break; break;
} }
if (thd->transaction.xa_state != XA_IDLE && if (thd->transaction.xa_state != XA_IDLE &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment