List:Commits« Previous MessageNext Message »
From:Mayank Prasad Date:February 3 2012 4:01pm
Subject:bzr push into mysql-trunk-wl5767 branch (mayank.prasad:3426 to 3427) WL#5767
View as plain text  
 3427 Mayank Prasad	2012-02-03
      WL#5767 : Performance Schema, Statements Digest
      
      Detials:
      - Removed digest_end completely.
      - Moved processing of digest_end to end_statement.
      - Removed unwanted function yyLength_PS (added 
        earlier by me only).
      - Modified token PASS_TOKEN_TO_PS.

    modified:
      include/mysql/psi/mysql_statement.h
      include/mysql/psi/psi.h
      include/mysql/psi/psi_abi_v1.h.pp
      mysys/psi_noop.c
      sql/sql_lex.cc
      sql/sql_lex.h
      sql/sql_parse.cc
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_digest.cc
      storage/perfschema/pfs_digest.h
 3426 Mayank Prasad	2012-02-03
      WL#5767 Performance Schema, Statements Digest
      
      Details:
      - Removed duplicates from PFS_statements_digest_stat.
      - Added code to delete hash entries once truncate table is called.
      - Did few code cleanup.

    modified:
      storage/perfschema/pfs_digest.cc
      storage/perfschema/pfs_digest.h
      storage/perfschema/table_esms_by_digest.cc
      storage/perfschema/table_events_statements.cc
      storage/perfschema/table_helper.cc
=== modified file 'include/mysql/psi/mysql_statement.h'
--- a/include/mysql/psi/mysql_statement.h	2011-12-05 18:32:34 +0000
+++ b/include/mysql/psi/mysql_statement.h	2012-02-03 16:00:30 +0000
@@ -42,13 +42,6 @@
 #endif
 
 #ifdef HAVE_PSI_STATEMENT_INTERFACE
-  #define MYSQL_DIGEST_END(LOCKER) \
-    inline_mysql_digest_end(LOCKER)
-#else
-  #define MYSQL_DIGEST_END(LOCKER) 
-#endif
-
-#ifdef HAVE_PSI_STATEMENT_INTERFACE
   #define MYSQL_DIGEST_START(LOCKER) \
     inline_mysql_digest_start(LOCKER)
 #else
@@ -129,13 +122,6 @@ inline_mysql_digest_start(PSI_statement_
   return digest_locker;
 }
 
-static inline void
-inline_mysql_digest_end(PSI_digest_locker *locker)
-{
-  if (likely(locker != NULL))
-    PSI_CALL(digest_end)(locker);
-}
-
 static inline struct PSI_statement_locker *
 inline_mysql_start_statement(PSI_statement_locker_state *state,
                              PSI_statement_key key,

=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h	2012-01-09 09:09:26 +0000
+++ b/include/mysql/psi/psi.h	2012-02-03 16:00:30 +0000
@@ -1826,12 +1826,9 @@ typedef void (*set_socket_thread_owner_v
 typedef struct PSI_digest_locker * (*digest_start_v1_t)
   (struct PSI_statement_locker *locker);
 
-typedef void (*digest_add_token_v1_t)
+typedef struct PSI_digest_locker* (*digest_add_token_v1_t)
   (struct PSI_digest_locker *locker, uint token, char *yytext, int yylen);
 
-typedef void (*digest_end_v1_t)
-  (struct PSI_digest_locker *locker);
-
 /**
   Performance Schema Interface, version 1.
   @since PSI_VERSION_1
@@ -2027,8 +2024,6 @@ struct PSI_v1
   digest_start_v1_t digest_start;
   /** @sa digest_add_token_v1_t. */
   digest_add_token_v1_t digest_add_token;
-  /** @sa digest_end_v1_t. */
-  digest_end_v1_t digest_end;
 };
 
 /** @} (end of group Group_PSI_v1) */

=== modified file 'include/mysql/psi/psi_abi_v1.h.pp'
--- a/include/mysql/psi/psi_abi_v1.h.pp	2012-01-09 09:09:26 +0000
+++ b/include/mysql/psi/psi_abi_v1.h.pp	2012-02-03 16:00:30 +0000
@@ -487,10 +487,8 @@ typedef void (*set_socket_info_v1_t)(str
 typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
 typedef struct PSI_digest_locker * (*digest_start_v1_t)
   (struct PSI_statement_locker *locker);
-typedef void (*digest_add_token_v1_t)
+typedef struct PSI_digest_locker* (*digest_add_token_v1_t)
   (struct PSI_digest_locker *locker, uint token, char *yytext, int yylen);
-typedef void (*digest_end_v1_t)
-  (struct PSI_digest_locker *locker);
 struct PSI_v1
 {
   register_mutex_v1_t register_mutex;
@@ -588,7 +586,6 @@ struct PSI_v1
   set_socket_thread_owner_v1_t set_socket_thread_owner;
   digest_start_v1_t digest_start;
   digest_add_token_v1_t digest_add_token;
-  digest_end_v1_t digest_end;
 };
 typedef struct PSI_v1 PSI;
 typedef struct PSI_mutex_info_v1 PSI_mutex_info;

=== modified file 'mysys/psi_noop.c'
--- a/mysys/psi_noop.c	2012-01-09 09:09:26 +0000
+++ b/mysys/psi_noop.c	2012-02-03 16:00:30 +0000
@@ -615,17 +615,12 @@ digest_start_noop(PSI_statement_locker *
   return NULL;
 }
 
-static void digest_add_token_noop(PSI_digest_locker *locker NNN,
+static PSI_digest_locker* digest_add_token_noop(PSI_digest_locker *locker NNN,
                                 uint token NNN,
                                 char *yytext NNN,
                                 int yylen NNN)
 {
-  return;
-}
-
-static void digest_end_noop(PSI_digest_locker *locker NNN)
-{
-  return;
+  return NULL;
 }
 
 static PSI PSI_noop=
@@ -723,8 +718,7 @@ static PSI PSI_noop=
   set_socket_info_noop,
   set_socket_thread_owner_noop,
   digest_start_noop,
-  digest_add_token_noop,
-  digest_end_noop
+  digest_add_token_noop
 };
 
 /**

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2012-01-23 07:25:50 +0000
+++ b/sql/sql_lex.cc	2012-02-03 16:00:30 +0000
@@ -32,34 +32,28 @@
 #include "sql_select.h"                // JOIN
 #include "sql_optimizer.h"             // JOIN
 
-#define PASS_TOKEN_TO_PS(_token,_yychar,_yylen)                              \
+#define PASS_TOKEN_TO_PS(_token)                                             \
   /*
     Passing token to PS function to calculate statement digest
     for this statement.
   */                                                                         \
-  if( _token != 0 )                                                          \
+  if( _token != 0 && lip->m_digest_psi != NULL)                              \
   {                                                                          \
     uint yylen= 0;                                                           \
     char *yychar= NULL;                                                      \
-    if( _token != END_OF_INPUT )                                             \
+    if( _token == IDENT_QUOTED || _token == IDENT )                          \
     {                                                                        \
-      if( _yylen!=0 )                                                        \
-      {                                                                      \
-        yylen= _yylen;                                                       \
-        yychar= (char*)_yychar;                                              \
-      }                                                                      \
-      else                                                                   \
-      {                                                                      \
-        /*
-          Get the length of processed token and make sure it doesn't exceed  \
-          TOCK_NAME_LENGTH. If it does, truncate it to TOCK_NAME_LENGTH.     \
-        */                                                                   \
-        yylen= lip->yyLength_PS();                                           \
-        yylen= yylen<TOCK_NAME_LENGTH ? yylen : TOCK_NAME_LENGTH-1;          \
-        yychar= (char*)lip->get_cpp_tok_start();                             \
-      }                                                                      \
-    }                                                                        \
-    PSI_CALL(digest_add_token)(lip->m_digest_psi,_token,yychar,yylen);       \
+      /*
+        If it is an identifier, get the length of processed token and
+        make sure it doesn't exceed TOCK_NAME_LENGTH. If it does,
+        truncate it to TOCK_NAME_LENGTH.
+      */                                                                    \
+      yylen= lip->yyLength() + 1;                                           \
+      yylen= yylen<TOCK_NAME_LENGTH ? yylen : TOCK_NAME_LENGTH-1;           \
+      yychar= (char*)lip->get_cpp_tok_start();                              \
+    }                                                                       \
+    lip->m_digest_psi= PSI_CALL(digest_add_token)(lip->m_digest_psi,        \
+                                                  _token, yychar, yylen);   \
   }
 
 static int lex_one_token(void *arg, void *yythd);
@@ -912,7 +906,7 @@ int MYSQLlex(void *arg, void *yythd)
     lip->lookahead_token= -1;
     *yylval= *(lip->lookahead_yylval);
     lip->lookahead_yylval= NULL;
-    PASS_TOKEN_TO_PS(token,NULL,0);
+    PASS_TOKEN_TO_PS(token);
     return token;
   }
 
@@ -930,10 +924,10 @@ int MYSQLlex(void *arg, void *yythd)
     token= lex_one_token(arg, yythd);
     switch(token) {
     case CUBE_SYM:
-      PASS_TOKEN_TO_PS(WITH_CUBE_SYM,"WITH CUBE",9);
+      PASS_TOKEN_TO_PS(WITH_CUBE_SYM);
       return WITH_CUBE_SYM;
     case ROLLUP_SYM:
-      PASS_TOKEN_TO_PS(WITH_ROLLUP_SYM,"WITH ROLLUP",11);
+      PASS_TOKEN_TO_PS(WITH_ROLLUP_SYM);
       return WITH_ROLLUP_SYM;
     default:
       /*
@@ -942,7 +936,7 @@ int MYSQLlex(void *arg, void *yythd)
       lip->lookahead_yylval= lip->yylval;
       lip->yylval= NULL;
       lip->lookahead_token= token;
-      PASS_TOKEN_TO_PS(WITH,"WITH",4);
+      PASS_TOKEN_TO_PS(WITH);
       return WITH;
     }
     break;
@@ -950,7 +944,7 @@ int MYSQLlex(void *arg, void *yythd)
     break;
   }
 
-  PASS_TOKEN_TO_PS(token,NULL,0);
+  PASS_TOKEN_TO_PS(token);
   return token;
 }
 

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2012-01-09 09:09:26 +0000
+++ b/sql/sql_lex.h	2012-02-03 16:00:30 +0000
@@ -1952,18 +1952,6 @@ public:
     return (uint) ((m_ptr - m_tok_start) - 1);
   }
    
-  uint yyLength_PS()
-  {
-    /* 
-      Length of the last token processed.
-      This new function is introduced because while using yylength(), there
-      were cases when (m_ptr < m_tok_start) and due to which it was aborting
-      when was called from SQLlex() for PS.
-    */
-    DBUG_ASSERT(m_cpp_ptr >= m_cpp_tok_start);
-    return (uint) (m_cpp_ptr - m_cpp_tok_start);
-  }
-
   /** Get the utf8-body string. */
   const char *get_body_utf8_str()
   {

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2012-02-01 09:20:33 +0000
+++ b/sql/sql_parse.cc	2012-02-03 16:00:30 +0000
@@ -7789,9 +7789,6 @@ bool parse_sql(THD *thd,
               (mysql_parse_status && thd->is_error()) ||
               (mysql_parse_status && thd->get_internal_handler()));
 
-  /* End Digest */
-  MYSQL_DIGEST_END(thd->m_parser_state->m_lip.m_digest_psi);
-
   /* Reset parser state. */
 
   thd->m_parser_state= NULL;

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2012-01-09 09:09:26 +0000
+++ b/storage/perfschema/pfs.cc	2012-02-03 16:00:30 +0000
@@ -4535,7 +4535,17 @@ static void end_statement_v1(PSI_stateme
 
     /* Set digest stat. */
     digest_storage= &pfs->m_digest_storage;
-    /* Populate PFS_statements_digest_stat with computed digest information. */
+
+    /*
+      Calculate MD5 Hash of the tokens received.
+    */
+    MY_MD5_HASH(digest_storage->m_digest_hash.m_md5,
+                (unsigned char *)digest_storage->m_token_array,
+                (uint) sizeof(digest_storage->m_token_array));
+
+    /* 
+      Populate PFS_statements_digest_stat with computed digest information.
+    */
     pfs->statement_digest_stat_ptr= 
                        find_or_create_digest(thread, digest_storage);
     if(pfs->statement_digest_stat_ptr)
@@ -4591,7 +4601,17 @@ static void end_statement_v1(PSI_stateme
 
     /* Set digest stat. */
     digest_storage= &pfs->m_digest_storage;
-    /* Populate PFS_statements_digest_stat with computed digest information. */
+
+    /*
+      Calculate MD5 Hash of the tokens received.
+    */
+    MY_MD5_HASH(digest_storage->m_digest_hash.m_md5,
+                (unsigned char *)digest_storage->m_token_array,
+                (uint) sizeof(digest_storage->m_token_array));
+
+    /*
+       Populate PFS_statements_digest_stat with computed digest information.
+    */
     pfs->statement_digest_stat_ptr= 
                        find_or_create_digest(thread, digest_storage);
     if(pfs->statement_digest_stat_ptr)
@@ -4913,8 +4933,7 @@ PSI_v1 PFS_v1=
   set_socket_info_v1,
   set_socket_thread_owner_v1,
   pfs_digest_start_v1,
-  pfs_digest_add_token_v1,
-  pfs_digest_end_v1
+  pfs_digest_add_token_v1
 };
 
 static void* get_interface(int version)

=== modified file 'storage/perfschema/pfs_digest.cc'
--- a/storage/perfschema/pfs_digest.cc	2012-02-03 11:38:42 +0000
+++ b/storage/perfschema/pfs_digest.cc	2012-02-03 16:00:30 +0000
@@ -416,17 +416,17 @@ struct PSI_digest_locker* pfs_digest_sta
   return reinterpret_cast<PSI_digest_locker*> (state);
 }
 
-void pfs_digest_add_token_v1(PSI_digest_locker *locker,
-                             uint token,
-                             char *yytext,
-                             int yylen)
+PSI_digest_locker* pfs_digest_add_token_v1(PSI_digest_locker *locker,
+                                           uint token,
+                                           char *yytext,
+                                           int yylen)
 {
   PSI_digest_locker_state *state= NULL;
   PFS_events_statements   *pfs= NULL;
   PFS_digest_storage      *digest_storage= NULL;
 
   if(!locker)
-    return;
+    return NULL;
 
   state= reinterpret_cast<PSI_digest_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
@@ -440,7 +440,7 @@ void pfs_digest_add_token_v1(PSI_digest_
     /*
       If digest storage record is full, do nothing.
     */
-    return;
+    return locker;
   }
 
   /* 
@@ -589,27 +589,6 @@ void pfs_digest_add_token_v1(PSI_digest_
       break;
     }
   }
-}
-
-void pfs_digest_end_v1(PSI_digest_locker *locker)
-{
-  PSI_digest_locker_state *state= NULL;
-  PFS_events_statements   *pfs= NULL;
-  PFS_digest_storage      *digest_storage= NULL;
-
-  if(!locker)
-    return;
 
-  state= reinterpret_cast<PSI_digest_locker_state*> (locker);
-  DBUG_ASSERT(state != NULL);
-
-  pfs= reinterpret_cast<PFS_events_statements *>(state->m_statement);
-  digest_storage= &pfs->m_digest_storage;
-
-  /*
-    Calculate MD5 Hash of the tokens received.
-  */
-  MY_MD5_HASH(digest_storage->m_digest_hash.m_md5,
-              (unsigned char *)digest_storage->m_token_array,
-              (uint) sizeof(digest_storage->m_token_array));
+  return locker;
 }

=== modified file 'storage/perfschema/pfs_digest.h'
--- a/storage/perfschema/pfs_digest.h	2012-02-03 11:38:42 +0000
+++ b/storage/perfschema/pfs_digest.h	2012-02-03 16:00:30 +0000
@@ -93,13 +93,10 @@ extern PFS_statements_digest_stat *state
 /* Instrumentation callbacks for pfs.cc */
 
 struct PSI_digest_locker* pfs_digest_start_v1(PSI_statement_locker *locker);
-void pfs_digest_add_token_v1(PSI_digest_locker *locker,
-                             uint token,
-                             char *yytext,
-                             int yylen);
-void pfs_digest_end_v1(PSI_digest_locker *locker);
-
-
+PSI_digest_locker* pfs_digest_add_token_v1(PSI_digest_locker *locker,
+                                           uint token,
+                                           char *yytext,
+                                           int yylen);
 
 /** 
   Function to read a single token from token array.

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5767 branch (mayank.prasad:3426 to 3427) WL#5767Mayank Prasad6 Feb