List:Internals« Previous MessageNext Message »
From:Sergei Golubchik Date:October 5 2005 4:39pm
Subject:bk commit into 5.0 tree (serg:1.2015) BUG#13143
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of serg. When serg 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
  1.2015 05/10/05 16:38:53 serg@stripped +4 -0
  Bug#13143 - formatID should not affect XID's uniqueness

  sql/sql_class.cc
    1.214 05/10/05 16:38:40 serg@stripped +6 -6
    Bug#13143 - formatID should not affect XID's uniqueness

  sql/handler.h
    1.160 05/10/05 16:38:40 serg@stripped +9 -1
    Bug#13143 - formatID should not affect XID's uniqueness

  mysql-test/t/xa.test
    1.5 05/10/05 16:38:40 serg@stripped +2 -0
    Bug#13143 - formatID should not affect XID's uniqueness

  mysql-test/r/xa.result
    1.3 05/10/05 16:38:40 serg@stripped +2 -0
    Bug#13143 - formatID should not affect XID's uniqueness

# 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:	serg
# Host:	serg.mylan
# Root:	/usr/home/serg/Abk/mysql-5.0

--- 1.159/sql/handler.h	Tue Oct  4 21:43:42 2005
+++ 1.160/sql/handler.h	Wed Oct  5 16:38:40 2005
@@ -228,7 +228,7 @@ struct xid_t {
   char data[XIDDATASIZE];  // not \0-terminated !
 
   bool eq(struct xid_t *xid)
-  { return !memcmp(this, xid, length()); }
+  { return eq(xid->gtrid_length, xid->bqual_length, xid->data); }
   bool eq(long g, long b, const char *d)
   { return g == gtrid_length && b == bqual_length && !memcmp(d, data,
g+b); }
   void set(struct xid_t *xid)
@@ -275,6 +275,14 @@ struct xid_t {
   {
     return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+
            gtrid_length+bqual_length;
+  }
+  byte *key()
+  {
+    return (byte *)&gtrid_length;
+  }
+  uint key_length()
+  {
+    return sizeof(gtrid_length)+sizeof(bqual_length)+gtrid_length+bqual_length;
   }
 };
 typedef struct xid_t XID;

--- 1.213/sql/sql_class.cc	Thu Sep 22 22:46:50 2005
+++ 1.214/sql/sql_class.cc	Wed Oct  5 16:38:40 2005
@@ -1982,8 +1982,8 @@ HASH xid_cache;
 static byte *xid_get_hash_key(const byte *ptr,uint *length,
                                   my_bool not_used __attribute__((unused)))
 {
-  *length=((XID_STATE*)ptr)->xid.length();
-  return (byte *)&((XID_STATE*)ptr)->xid;
+  *length=((XID_STATE*)ptr)->xid.key_length();
+  return ((XID_STATE*)ptr)->xid.key();
 }
 
 static void xid_free_hash (void *ptr)
@@ -2011,7 +2011,7 @@ void xid_cache_free()
 XID_STATE *xid_cache_search(XID *xid)
 {
   pthread_mutex_lock(&LOCK_xid_cache);
-  XID_STATE *res=(XID_STATE *)hash_search(&xid_cache, (byte *)xid, xid->length());
+  XID_STATE *res=(XID_STATE *)hash_search(&xid_cache, xid->key(),
xid->key_length());
   pthread_mutex_unlock(&LOCK_xid_cache);
   return res;
 }
@@ -2022,7 +2022,7 @@ bool xid_cache_insert(XID *xid, enum xa_
   XID_STATE *xs;
   my_bool res;
   pthread_mutex_lock(&LOCK_xid_cache);
-  if (hash_search(&xid_cache, (byte *)xid, xid->length()))
+  if (hash_search(&xid_cache, xid->key(), xid->key_length()))
     res=0;
   else if (!(xs=(XID_STATE *)my_malloc(sizeof(*xs), MYF(MY_WME))))
     res=1;
@@ -2041,8 +2041,8 @@ bool xid_cache_insert(XID *xid, enum xa_
 bool xid_cache_insert(XID_STATE *xid_state)
 {
   pthread_mutex_lock(&LOCK_xid_cache);
-  DBUG_ASSERT(hash_search(&xid_cache, (byte *)&xid_state->xid,
-                          xid_state->xid.length())==0);
+  DBUG_ASSERT(hash_search(&xid_cache, xid_state->xid.key(),
+                          xid_state->xid.key_length())==0);
   my_bool res=my_hash_insert(&xid_cache, (byte*)xid_state);
   pthread_mutex_unlock(&LOCK_xid_cache);
   return res;

--- 1.2/mysql-test/r/xa.result	Fri Aug 12 21:04:15 2005
+++ 1.3/mysql-test/r/xa.result	Wed Oct  5 16:38:40 2005
@@ -24,6 +24,8 @@ insert t1 values (30);
 xa end 'testa','testb';
 xa start 'testa','testb';
 ERROR XAE08: XAER_DUPID: The XID already exists
+xa start 'testa','testb', 123;
+ERROR XAE08: XAER_DUPID: The XID already exists
 xa start 0x7465737462, 0x2030405060, 0xb;
 insert t1 values (40);
 xa end 'testb',' 0@P`',11;

--- 1.4/mysql-test/t/xa.test	Sat Aug 13 08:42:27 2005
+++ 1.5/mysql-test/t/xa.test	Wed Oct  5 16:38:40 2005
@@ -33,6 +33,8 @@ connection con1;
 
 --error 1440
 xa start 'testa','testb';
+--error 1440
+xa start 'testa','testb', 123;
 
 #        gtrid [ , bqual [ , formatID ] ]
 xa start 0x7465737462, 0x2030405060, 0xb;
Thread
bk commit into 5.0 tree (serg:1.2015) BUG#13143Sergei Golubchik5 Oct