List:Commits« Previous MessageNext Message »
From:Mayank Prasad Date:February 4 2012 7:04pm
Subject:[Resend] bzr commit into mysql-trunk-wl5767 branch (mayank.prasad:3428)
WL#5767
View as plain text  
[This commit e-mail is a repeat.]

#At file:///home/mayank/mysql-tree/my_WL/5767/ based on
revid:mayank.prasad@stripped

 3428 Mayank Prasad	2012-02-05
      WL#5767: Performance Schema, Statements Digest
      
      Details:
      - probable fix for failing test case on PB2.
      - A little Code cleanup.

    modified:
      storage/perfschema/pfs_digest.cc
      storage/perfschema/pfs_digest.h
=== modified file 'storage/perfschema/pfs_digest.cc'
--- a/storage/perfschema/pfs_digest.cc	2012-02-03 16:00:30 +0000
+++ b/storage/perfschema/pfs_digest.cc	2012-02-04 19:02:49 +0000
@@ -440,7 +440,7 @@ PSI_digest_locker* pfs_digest_add_token_
     /*
       If digest storage record is full, do nothing.
     */
-    return locker;
+    return NULL;
   }
 
   /* 

=== modified file 'storage/perfschema/pfs_digest.h'
--- a/storage/perfschema/pfs_digest.h	2012-02-03 16:00:30 +0000
+++ b/storage/perfschema/pfs_digest.h	2012-02-04 19:02:49 +0000
@@ -104,9 +104,16 @@ PSI_digest_locker* pfs_digest_add_token_
 inline void read_token(uint *dest, int *index, char *src)
 {
   unsigned short sh;
-  sh= ((0x00ff & src[*index + 1])<<8) | (0x00ff & src[*index]);
-  *dest= (uint)(sh);
-  *index= *index + PFS_SIZE_OF_A_TOKEN;
+  int remaining_bytes= PFS_MAX_DIGEST_STORAGE_SIZE - *index;
+  DBUG_ASSERT(remaining_bytes >= 0);
+
+  /* Make sure we have enough space to read a token. */
+  if(remaining_bytes >= PFS_SIZE_OF_A_TOKEN)
+  {
+    sh= ((0x00ff & src[*index + 1])<<8) | (0x00ff & src[*index]);
+    *dest= (uint)(sh);
+    *index= *index + PFS_SIZE_OF_A_TOKEN;
+  }
 }
 
 /**
@@ -117,11 +124,17 @@ inline void store_token(PFS_digest_stora
   char* dest= digest_storage->m_token_array;
   int* index= &digest_storage->m_byte_count;
   unsigned short sh= (unsigned short)token;
+  int remaining_bytes= PFS_MAX_DIGEST_STORAGE_SIZE - *index;
+  DBUG_ASSERT(remaining_bytes >= 0);
 
-  dest[*index]= (sh) & 0xff;
-  *index= *index + 1;
-  dest[*index]= (sh>>8) & 0xff;
-  *index= *index + 1;
+  /* Make sure we have enough space to store a token. */
+  if(remaining_bytes >= PFS_SIZE_OF_A_TOKEN)
+  {
+    dest[*index]= (sh) & 0xff;
+    *index= *index + 1;
+    dest[*index]= (sh>>8) & 0xff;
+    *index= *index + 1;
+  }
 }
 
 /**


Attachment: [text/bzr-bundle] bzr/mayank.prasad@oracle.com-20120204190249-vnp89rceusz239ka.bundle
Thread
[Resend] bzr commit into mysql-trunk-wl5767 branch (mayank.prasad:3428)WL#5767Mayank Prasad6 Feb