List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:July 17 2011 3:50am
Subject:bzr push into mysql-trunk branch (chris.powers:3316 to 3319) WL#4896
View as plain text  
 3319 Christopher Powers	2011-07-16
      WL#4896 "Performance Schema Net IO"
      
      Integrating peformance improvements in socket instrumentation. 

    modified:
      include/mysql/psi/mysql_idle.h
      include/mysql/psi/mysql_socket.h
      sql/sql_parse.cc
      storage/perfschema/pfs.cc
 3318 Christopher Powers	2011-07-16
      WL#4896 "Performance Schema Net IO"
      
      Integrating performance improvements

    modified:
      sql/sql_parse.cc
      storage/perfschema/pfs.cc
 3317 Christopher Powers	2011-07-16
      Integrating performance improvements

    modified:
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_instr.cc
      storage/perfschema/pfs_instr.h
      storage/perfschema/table_setup_instruments.cc
 3316 Christopher Powers	2011-07-14 [merge]
      Merge with mysql-trunk

    added:
      mysql-test/suite/rpl/r/rpl_row_corruption.result
      mysql-test/suite/rpl/t/rpl_row_corruption-slave.opt
      mysql-test/suite/rpl/t/rpl_row_corruption.test
    modified:
      mysql-test/r/grant.result
      mysql-test/r/information_schema.result
      mysql-test/r/sp.result
      mysql-test/r/view.result
      mysql-test/t/disabled.def
      mysql-test/t/grant.test
      mysql-test/t/information_schema.test
      mysql-test/t/sp.test
      mysql-test/t/view.test
      sql/log_event.cc
      sql/sp_head.cc
      sql/sp_head.h
      sql/sql_insert.cc
      sql/sql_parse.cc
      sql/sql_select.cc
      sql/sql_view.cc
      sql/sql_yacc.yy
      storage/innobase/lock/lock0lock.c
      tests/mysql_client_test.c
=== modified file 'include/mysql/psi/mysql_idle.h'
--- a/include/mysql/psi/mysql_idle.h	2011-03-16 15:36:35 +0000
+++ b/include/mysql/psi/mysql_idle.h	2011-07-17 03:30:21 +0000
@@ -87,11 +87,8 @@ static inline struct PSI_idle_locker *
 inline_mysql_start_idle_wait(PSI_idle_locker_state *state,
                              const char *src_file, int src_line)
 {
-  struct PSI_idle_locker *locker= NULL;
-  if (likely(PSI_server != NULL))
-  {
-    locker= PSI_server->start_idle_wait(state, src_file, src_line);
-  }
+  struct PSI_idle_locker *locker;
+  locker= PSI_CALL(start_idle_wait)(state, src_file, src_line);
   return locker;
 }
 
@@ -103,7 +100,7 @@ static inline void
 inline_mysql_end_idle_wait(struct PSI_idle_locker *locker)
 {
   if (likely(locker != NULL))
-    PSI_server->end_idle_wait(locker);
+    PSI_CALL(end_idle_wait)(locker);
 }
 #endif
 

=== modified file 'include/mysql/psi/mysql_socket.h'
--- a/include/mysql/psi/mysql_socket.h	2011-04-28 00:15:11 +0000
+++ b/include/mysql/psi/mysql_socket.h	2011-07-17 03:30:21 +0000
@@ -103,8 +103,7 @@ static inline void
 mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
 {
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  if ((PSI_server != NULL) && (socket.m_psi != NULL))
-    PSI_server->set_socket_state(socket.m_psi, state);
+  PSI_CALL(set_socket_state)(socket.m_psi, state);
 #endif
 }
 
@@ -114,15 +113,14 @@ mysql_socket_set_state(MYSQL_SOCKET sock
   @param fd socket descriptor
   @param addr unformatted socket address
   @param adr_len length of socket addres
-*/ 
+*/
 static inline void
 mysql_socket_set_address(MYSQL_SOCKET socket,
                          const struct sockaddr *addr,
                          socklen_t addr_len)
 {
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(PSI_server != NULL && socket.m_psi != NULL))
-    PSI_server->set_socket_info(socket.m_psi, NULL, addr, addr_len);
+  PSI_CALL(set_socket_info)(socket.m_psi, NULL, addr, addr_len);
 #endif
 }
 
@@ -130,13 +128,12 @@ mysql_socket_set_address(MYSQL_SOCKET so
   Set socket descriptor and address.
   @param socket instrumented socket
   @param thread instrumented owning thread
-*/ 
+*/
 static inline void
 mysql_socket_set_thread_owner(MYSQL_SOCKET socket)
 {
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(PSI_server != NULL && socket.m_psi != NULL))
-    PSI_server->set_socket_thread_owner(socket.m_psi);
+  PSI_CALL(set_socket_thread_owner)(socket.m_psi);
 #endif
 }
 
@@ -144,7 +141,7 @@ mysql_socket_set_thread_owner(MYSQL_SOCK
   MYSQL_SOCKET helper. Get socket descriptor.
   @param mysql_socket Instrumented socket
   @sa mysql_socket_setfd
-*/ 
+*/
 static inline my_socket
 mysql_socket_getfd(MYSQL_SOCKET mysql_socket)
 {
@@ -156,7 +153,7 @@ mysql_socket_getfd(MYSQL_SOCKET mysql_so
   @param mysql_socket Instrumented socket
   @param fd Socket descriptor
   @sa mysql_socket_getfd
-*/ 
+*/
 static inline void
 mysql_socket_setfd(MYSQL_SOCKET *mysql_socket, my_socket fd)
 {
@@ -232,15 +229,10 @@ inline_mysql_start_socket_wait(PSI_socke
                                size_t byte_count,
                                const char *src_file, int src_line)
 {
-  struct PSI_socket_locker *locker= NULL;
-  struct PSI_socket *psi= mysql_socket.m_psi;
-
-  if (likely(PSI_server && psi))
-  {
-    locker= PSI_server->get_thread_socket_locker(state, psi, op);
-    if (likely(locker != NULL))
-      PSI_server->start_socket_wait(locker, byte_count, src_file, src_line);
-  }
+  struct PSI_socket_locker *locker;
+  locker= PSI_CALL(get_thread_socket_locker)(state, mysql_socket.m_psi, op);
+  if (likely(locker != NULL))
+    PSI_CALL(start_socket_wait)(locker, byte_count, src_file, src_line);
   return locker;
 }
 
@@ -252,7 +244,7 @@ static inline void
 inline_mysql_end_socket_wait(struct PSI_socket_locker *locker, size_t byte_count)
 {
   if (likely(locker != NULL))
-    PSI_server->end_socket_wait(locker, byte_count);
+    PSI_CALL(end_socket_wait)(locker, byte_count);
 }
 #endif
 
@@ -521,8 +513,7 @@ static inline void inline_mysql_socket_r
 )
 {
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(PSI_server != NULL))
-    PSI_server->register_socket(category, info, count);
+  PSI_CALL(register_socket)(category, info, count);
 #endif
 }
 
@@ -537,17 +528,12 @@ inline_mysql_socket_socket
   int domain, int type, int protocol)
 {
   MYSQL_SOCKET mysql_socket;
-
   mysql_socket.fd= socket(domain, type, protocol);
 
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  mysql_socket.m_psi = PSI_server ?
-                       PSI_server->init_socket(key,
-                       (const my_socket*)&mysql_socket.fd) : NULL;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL
-             && mysql_socket.fd != INVALID_SOCKET))
-    PSI_server->set_socket_info(mysql_socket.m_psi, &mysql_socket.fd, NULL, 0);
+  mysql_socket.m_psi = PSI_CALL(init_socket)(key, (const my_socket*)&mysql_socket.fd);
+  if (likely(mysql_socket.fd != INVALID_SOCKET))
+    PSI_CALL(set_socket_info)(mysql_socket.m_psi, &mysql_socket.fd, NULL, 0);
 #endif
   return mysql_socket;
 }
@@ -564,27 +550,20 @@ inline_mysql_socket_bind
 {
   int result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
+  struct PSI_socket_locker *locker;
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_BIND);
+  if (likely(locker != NULL))
   {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_BIND);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
+    PSI_CALL(start_socket_wait)(locker, (size_t)0, src_file, src_line);
+    result= bind(mysql_socket.fd, addr, len);
+    PSI_CALL(set_socket_info)(mysql_socket.m_psi, NULL, addr, len);
+    PSI_CALL(end_socket_wait)(locker, (size_t)0);
+    return result;
   }
 #endif
-  
   result= bind(mysql_socket.fd, addr, len);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL
-             && result == 0))
-    PSI_server->set_socket_info(mysql_socket.m_psi, NULL, addr, len);
-
-  if (likely(locker != NULL))
-    PSI_server->end_socket_wait(locker, (size_t)0);
-#endif
   return result;
 }
 
@@ -600,23 +579,19 @@ inline_mysql_socket_getsockname
 {
   int result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
-  {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_BIND);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_BIND);
+  if (likely(locker !=NULL))
+  {
+    PSI_CALL(start_socket_wait)(locker, (size_t)0, src_file, src_line);
+    result= getsockname(mysql_socket.fd, addr, len);
+    PSI_CALL(end_socket_wait)(locker, (size_t)0);
+    return result;
   }
 #endif
-
   result= getsockname(mysql_socket.fd, addr, len);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(locker != NULL))
-    PSI_server->end_socket_wait(locker, (size_t)0);
-#endif
   return result;
 }
 
@@ -632,23 +607,19 @@ inline_mysql_socket_connect
 {
   int result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_CONNECT);
+  if (likely(locker != NULL))
   {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_CONNECT);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
+    PSI_CALL(start_socket_wait)(locker, (size_t)0, src_file, src_line);
+    result= connect(mysql_socket.fd, addr, len);
+    PSI_CALL(end_socket_wait)(locker, (size_t)0);
+    return result;
   }
 #endif
-  
   result= connect(mysql_socket.fd, addr, len);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(locker != NULL))
-    PSI_server->end_socket_wait(locker, (size_t)0);
-#endif
   return result;
 }
 
@@ -664,23 +635,19 @@ inline_mysql_socket_getpeername
 {
   int result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_BIND);
+  if (likely(locker != NULL))
   {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_BIND);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
+    PSI_CALL(start_socket_wait)(locker, (size_t)0, src_file, src_line);
+    result= getpeername(mysql_socket.fd, addr, len);
+    PSI_CALL(end_socket_wait)(locker, (size_t)0);
+    return result;
   }
 #endif
-  
   result= getpeername(mysql_socket.fd, addr, len);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(locker != NULL))
-    PSI_server->end_socket_wait(locker, (size_t)0);
-#endif
   return result;
 }
 
@@ -696,26 +663,21 @@ inline_mysql_socket_send
 {
   ssize_t result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
-  {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_SEND);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, n, src_file, src_line);
-  }
-#endif
-  
-  result= send(mysql_socket.fd, buf, n, flags);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
+  size_t bytes_written;
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_SEND);
   if (likely(locker != NULL))
   {
-    size_t bytes_written = (result > -1) ? result : 0;
-    PSI_server->end_socket_wait(locker, bytes_written);
+    PSI_CALL(start_socket_wait)(locker, n, src_file, src_line);
+    result= send(mysql_socket.fd, buf, n, flags);
+    bytes_written= (result > -1) ? result : 0;
+    PSI_CALL(end_socket_wait)(locker, bytes_written);
+    return result;
   }
 #endif
+  result= send(mysql_socket.fd, buf, n, flags);
   return result;
 }
 
@@ -731,26 +693,21 @@ inline_mysql_socket_recv
 {
   ssize_t result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
-  {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_RECV);
-    if (likely(locker != NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
-  }
-#endif
-  
-  result= recv(mysql_socket.fd, buf, n, flags);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
+  size_t bytes_read;
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_RECV);
   if (likely(locker != NULL))
   {
-    size_t bytes_read= (result > -1) ? result : 0;
-    PSI_server->end_socket_wait(locker, bytes_read);
+    PSI_CALL(start_socket_wait)(locker, (size_t)0, src_file, src_line);
+    result= recv(mysql_socket.fd, buf, n, flags);
+    bytes_read= (result > -1) ? result : 0;
+    PSI_CALL(end_socket_wait)(locker, bytes_read);
+    return result;
   }
 #endif
+  result= recv(mysql_socket.fd, buf, n, flags);
   return result;
 }
 
@@ -766,26 +723,21 @@ inline_mysql_socket_sendto
 {
   ssize_t result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
-  {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_SEND);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, n, src_file, src_line);
-  }
-#endif
-  
-  result= sendto(mysql_socket.fd, buf, n, flags, addr, addr_len);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
+  size_t bytes_written;
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_SEND);
   if (likely(locker != NULL))
   {
-    size_t bytes_written = (result > -1) ? result : 0;
-    PSI_server->end_socket_wait(locker, bytes_written);
+    PSI_CALL(start_socket_wait)(locker, n, src_file, src_line);
+    result= sendto(mysql_socket.fd, buf, n, flags, addr, addr_len);
+    bytes_written = (result > -1) ? result : 0;
+    PSI_CALL(end_socket_wait)(locker, bytes_written);
+    return result;
   }
 #endif
+  result= sendto(mysql_socket.fd, buf, n, flags, addr, addr_len);
   return result;
 }
 
@@ -802,27 +754,21 @@ inline_mysql_socket_recvfrom
 {
   ssize_t result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
-  {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi,
-                                                 PSI_SOCKET_RECV);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
-  }
-#endif
-  
-  result= recvfrom(mysql_socket.fd, buf, n, flags, addr, addr_len);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
+  size_t bytes_read;
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_RECV);
   if (likely(locker != NULL))
   {
-    size_t bytes_read = (result > -1) ? result : 0;
-    PSI_server->end_socket_wait(locker, bytes_read);
+    PSI_CALL(start_socket_wait)(locker, (size_t)0, src_file, src_line);
+    result= recvfrom(mysql_socket.fd, buf, n, flags, addr, addr_len);
+    bytes_read = (result > -1) ? result : 0;
+    PSI_CALL(end_socket_wait)(locker, bytes_read);
+    return result;
   }
 #endif
+  result= recvfrom(mysql_socket.fd, buf, n, flags, addr, addr_len);
   return result;
 }
 
@@ -838,23 +784,19 @@ inline_mysql_socket_getsockopt
 {
   int result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_OPT);
+  if (likely(locker != NULL))
   {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_OPT);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
+    PSI_CALL(start_socket_wait)(locker, (size_t)0, src_file, src_line);
+    result= getsockopt(mysql_socket.fd, level, optname, optval, optlen);
+    PSI_CALL(end_socket_wait)(locker, (size_t)0);
+    return result;
   }
 #endif
-  
   result= getsockopt(mysql_socket.fd, level, optname, optval, optlen);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(locker != NULL))
-    PSI_server->end_socket_wait(locker, (size_t)0);
-#endif
   return result;
 }
 
@@ -866,27 +808,24 @@ inline_mysql_socket_setsockopt
 #ifdef HAVE_PSI_SOCKET_INTERFACE
   const char *src_file, uint src_line,
 #endif
- MYSQL_SOCKET mysql_socket, int level, int optname, const SOCKBUF_T *optval, socklen_t optlen)
+ MYSQL_SOCKET mysql_socket, int level, int optname, const SOCKBUF_T *optval,
+ socklen_t optlen)
 {
   int result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                   PSI_SOCKET_OPT);
+  if (likely(locker != NULL))
   {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_OPT);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
+    PSI_CALL(start_socket_wait)(locker, (size_t)0, src_file, src_line);
+    result= setsockopt(mysql_socket.fd, level, optname, optval, optlen);
+    PSI_CALL(end_socket_wait)(locker, (size_t)0);
+    return result;
   }
 #endif
-  
   result= setsockopt(mysql_socket.fd, level, optname, optval, optlen);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(locker != NULL))
-    PSI_server->end_socket_wait(locker, (size_t)0);
-#endif
   return result;
 }
 
@@ -902,23 +841,19 @@ inline_mysql_socket_listen
 {
   int result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_CONNECT);
+  if (likely(locker != NULL))
   {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_CONNECT);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
+    PSI_CALL(start_socket_wait)(locker, (size_t)0, src_file, src_line);
+    result= listen(mysql_socket.fd, backlog);
+    PSI_CALL(end_socket_wait)(locker, (size_t)0);
+    return result;
   }
 #endif
-  
   result= listen(mysql_socket.fd, backlog);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(locker != NULL))
-    PSI_server->end_socket_wait(locker, (size_t)0);
-#endif
   return result;
 }
 
@@ -939,14 +874,14 @@ inline_mysql_socket_accept
 
   /** Initialize the instrument with the new socket descriptor and address */
   #ifdef HAVE_PSI_SOCKET_INTERFACE
-  socket_accept.m_psi = PSI_server ?
-          PSI_server->init_socket(key, (const my_socket*)&socket_accept.fd) : NULL;
+  socket_accept.m_psi= PSI_CALL(init_socket)(key, (const my_socket*)&socket_accept.fd);
 
-  if (likely(PSI_server != NULL && socket_accept.m_psi != NULL
-             && socket_accept.fd != INVALID_SOCKET))
-    PSI_server->set_socket_info(socket_accept.m_psi, &socket_accept.fd,
-                                addr, addr_length);
+  if (likely(socket_accept.fd != INVALID_SOCKET))
+    PSI_CALL(set_socket_info)(socket_accept.m_psi, &socket_accept.fd,
+                             addr, addr_length);
+  return socket_accept;
 #endif
+  socket_accept.fd= accept(socket_listen.fd, addr, addr_len);
   return socket_accept;
 }
 
@@ -962,23 +897,19 @@ inline_mysql_socket_close
 {
   int result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_CLOSE);
+  if (likely(locker != NULL))
   {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_CLOSE);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
+    PSI_CALL(start_socket_wait)(locker, (size_t)0, src_file, src_line);
+    result= closesocket(mysql_socket.fd);
+    PSI_CALL(end_socket_wait)(locker, (size_t)0);
+    return result;
   }
 #endif
-  
   result= closesocket(mysql_socket.fd);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(locker != NULL))
-    PSI_server->end_socket_wait(locker, (size_t)0);
-#endif
   return result;
 }
 
@@ -994,23 +925,19 @@ inline_mysql_socket_shutdown
 {
   int result;
 #ifdef HAVE_PSI_SOCKET_INTERFACE
-  struct PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker;
   PSI_socket_locker_state state;
-
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
+  locker= PSI_CALL(get_thread_socket_locker)(&state, mysql_socket.m_psi,
+                                             PSI_SOCKET_SHUTDOWN);
+  if (likely(locker != NULL))
   {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_SHUTDOWN);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
+    PSI_CALL(start_socket_wait)(locker, (size_t)0, src_file, src_line);
+    result= shutdown(mysql_socket.fd, how);
+    PSI_CALL(end_socket_wait)(locker, (size_t)0);
+    return result;
   }
 #endif
-  
   result= shutdown(mysql_socket.fd, how);
-
-#ifdef HAVE_PSI_SOCKET_INTERFACE
-  if (likely(locker != NULL))
-    PSI_server->end_socket_wait(locker, (size_t)0);
-#endif
   return result;
 }
 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-07-15 00:55:03 +0000
+++ b/sql/sql_parse.cc	2011-07-17 03:30:21 +0000
@@ -790,7 +790,7 @@ bool do_command(THD *thd)
   ulong packet_length;
   NET *net= &thd->net;
   enum enum_server_command command;
-  // TODO: WL4896 Disabled:  MYSQL_IDLE_WAIT_VARIABLES(idle_locker, idle_state) /* no ; */
+  // CWP: MYSQL_IDLE_WAIT_VARIABLES(idle_locker, idle_state) /* no ; */
 
   DBUG_ENTER("do_command");
 
@@ -838,13 +838,13 @@ bool do_command(THD *thd)
     - do not time the wait on the socket
     - time the wait as IDLE server time instead.
   */
-  // TODO: WL4896 Disabled: mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_IDLE);
-  //  MYSQL_START_IDLE_WAIT(idle_locker, & idle_state);
+  // CWP: disabled mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_IDLE);
+  // CWP: MYSQL_START_IDLE_WAIT(idle_locker, &idle_state);
 
   packet_length= my_net_read(net);
 
-  //  MYSQL_END_IDLE_WAIT(idle_locker);
-  //  mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_ACTIVE);
+  // CWP: MYSQL_END_IDLE_WAIT(idle_locker);
+  // CWP: mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_ACTIVE);
 
   if (packet_length == packet_error)
   {

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2011-07-08 21:31:33 +0000
+++ b/storage/perfschema/pfs.cc	2011-07-17 03:30:21 +0000
@@ -1565,6 +1565,10 @@ init_socket_v1(PSI_socket_key key, const
 static void destroy_socket_v1(PSI_socket *socket)
 {
   PFS_socket *pfs= reinterpret_cast<PFS_socket*> (socket);
+
+  if (unlikely(pfs == NULL))
+    return;
+
   destroy_socket(pfs);
 }
 
@@ -2757,17 +2761,11 @@ get_thread_socket_locker_v1(PSI_socket_l
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(socket_operation_map));
   DBUG_ASSERT(state != NULL);
   PFS_socket *pfs_socket= reinterpret_cast<PFS_socket*> (socket);
-  DBUG_ASSERT(pfs_socket != NULL);
-  DBUG_ASSERT(pfs_socket->m_class != NULL);
-
-  if (!flag_global_instrumentation)
-    return NULL;
-
-  if (pfs_socket->m_idle)
+  if (unlikely(pfs_socket == NULL))
     return NULL;
+  DBUG_ASSERT(pfs_socket->m_class != NULL);
 
-  PFS_socket_class *klass= pfs_socket->m_class;
-  if (!klass->m_enabled)
+  if (pfs_socket->m_idle || !pfs_socket->m_enabled)
     return NULL;
 
   register uint flags;
@@ -2779,13 +2777,13 @@ get_thread_socket_locker_v1(PSI_socket_l
     if (unlikely(pfs_thread == NULL))
       return NULL;
 
-    if (! pfs_thread->m_enabled)
+    if (!pfs_thread->m_enabled)
       return NULL;
 
     state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
     flags= STATE_FLAG_THREAD;
 
-    if (klass->m_timed)
+    if (pfs_socket->m_timed)
       flags|= STATE_FLAG_TIMED;
 
     if (flag_events_waits_current)
@@ -2804,7 +2802,7 @@ get_thread_socket_locker_v1(PSI_socket_l
       wait->m_nesting_event_id= parent_event->m_event_id;
       wait->m_nesting_event_id= parent_event->m_event_type;
       wait->m_thread=       pfs_thread;
-      wait->m_class=        klass;
+      wait->m_class=        pfs_socket->m_class;
       wait->m_timer_start=  0;
       wait->m_timer_end=    0;
       wait->m_object_instance_addr= pfs_socket->m_identity;
@@ -2819,7 +2817,7 @@ get_thread_socket_locker_v1(PSI_socket_l
   }
   else
   {
-    if (klass->m_timed)
+    if (pfs_socket->m_timed)
     {
       flags= STATE_FLAG_TIMED;
     }
@@ -2845,7 +2843,6 @@ get_thread_socket_locker_v1(PSI_socket_l
       case PSI_SOCKET_CLOSE:
       case PSI_SOCKET_SELECT:
         {
-        PFS_socket *pfs_socket= reinterpret_cast<PFS_socket *>(socket);
         pfs_socket->m_socket_stat.m_io_stat.m_misc.aggregate_counted();
         return NULL;
         }
@@ -3031,10 +3028,10 @@ start_idle_wait_v1(PSI_idle_locker_state
 {
   DBUG_ASSERT(state != NULL);
 
-  if (! flag_global_instrumentation)
+  if (!flag_global_instrumentation)
     return NULL;
 
-  if (! global_idle_class.m_enabled)
+  if (!global_idle_class.m_enabled)
     return NULL;
 
   register uint flags= 0;
@@ -3045,14 +3042,14 @@ start_idle_wait_v1(PSI_idle_locker_state
     PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
     if (unlikely(pfs_thread == NULL))
       return NULL;
-    if (! pfs_thread->m_enabled)
+    if (!pfs_thread->m_enabled)
       return NULL;
     state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
     flags= STATE_FLAG_THREAD;
 
     if (global_idle_class.m_timed)
     {
-      timer_start= get_timer_raw_value_and_function(idle_timer, & state->m_timer);
+      timer_start= get_timer_raw_value_and_function(idle_timer, &state->m_timer);
       state->m_timer_start= timer_start;
       flags|= STATE_FLAG_TIMED;
     }
@@ -3073,7 +3070,7 @@ start_idle_wait_v1(PSI_idle_locker_state
 #endif
 
       wait->m_thread= pfs_thread;
-      wait->m_class= & global_idle_class;
+      wait->m_class= &global_idle_class;
       wait->m_timer_start= timer_start;
       wait->m_timer_end= 0;
       wait->m_event_id= pfs_thread->m_event_id++;
@@ -3089,7 +3086,7 @@ start_idle_wait_v1(PSI_idle_locker_state
   {
     if (global_idle_class.m_timed)
     {
-      timer_start= get_timer_raw_value_and_function(idle_timer, & state->m_timer);
+      timer_start= get_timer_raw_value_and_function(idle_timer, &state->m_timer);
       state->m_timer_start= timer_start;
       flags= STATE_FLAG_TIMED;
     }
@@ -4697,6 +4694,8 @@ static void set_socket_state_v1(PSI_sock
   DBUG_ASSERT(socket);
   DBUG_ASSERT((state == PSI_SOCKET_STATE_IDLE) || (state == PSI_SOCKET_STATE_ACTIVE));
   PFS_socket *pfs= reinterpret_cast<PFS_socket*>(socket);
+  if (unlikely(pfs == NULL))
+    return;
   pfs->m_idle= (state == PSI_SOCKET_STATE_IDLE);
 }
 
@@ -4711,6 +4710,9 @@ static void set_socket_info_v1(PSI_socke
   DBUG_ASSERT(socket);
   PFS_socket *pfs= reinterpret_cast<PFS_socket*>(socket);
 
+  if (unlikely(pfs == NULL))
+    return;
+
   /** Set socket descriptor */
   if (fd != NULL)
     pfs->m_fd= *fd;
@@ -4737,6 +4739,8 @@ static void set_socket_thread_owner_v1(P
   if (likely(socket != NULL))
   {
     PFS_socket *pfs_socket= reinterpret_cast<PFS_socket*>(socket);
+    if (unlikely(pfs_socket == NULL))
+      return;
     pfs_socket->m_thread_owner= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
   }
 }

=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc	2011-07-08 21:31:33 +0000
+++ b/storage/perfschema/pfs_instr.cc	2011-07-16 19:25:42 +0000
@@ -1785,6 +1785,28 @@ void update_table_derived_flags()
   }
 }
 
+void update_socket_derived_flags()
+{
+  PFS_socket *pfs= socket_array;
+  PFS_socket *pfs_last= socket_array + socket_max;
+  PFS_socket_class *klass;
+
+  for ( ; pfs < pfs_last; pfs++)
+  {
+    klass= sanitize_socket_class(pfs->m_class);
+    if (likely(klass != NULL))
+    {
+      pfs->m_enabled= klass->m_enabled && flag_global_instrumentation;
+      pfs->m_timed= klass->m_timed;
+    }
+    else
+    {
+      pfs->m_enabled= false;
+      pfs->m_timed= false;
+    }
+  }
+}
+
 void update_instruments_derived_flags()
 {
   update_mutex_derived_flags();
@@ -1792,6 +1814,7 @@ void update_instruments_derived_flags()
   update_cond_derived_flags();
   update_file_derived_flags();
   update_table_derived_flags();
+  update_socket_derived_flags();
   /* nothing for stages and statements (no instances) */
 }
 

=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h	2011-07-08 21:31:33 +0000
+++ b/storage/perfschema/pfs_instr.h	2011-07-16 19:25:42 +0000
@@ -567,6 +567,8 @@ void update_cond_derived_flags();
 void update_file_derived_flags();
 /** Update derived flags for all table handles. */
 void update_table_derived_flags();
+/** Update derived flags for all socket instances. */
+void update_socket_derived_flags();
 /** Update derived flags for all instruments. */
 void update_instruments_derived_flags();
 

=== modified file 'storage/perfschema/table_setup_instruments.cc'
--- a/storage/perfschema/table_setup_instruments.cc	2011-07-08 21:31:33 +0000
+++ b/storage/perfschema/table_setup_instruments.cc	2011-07-16 19:25:42 +0000
@@ -282,6 +282,12 @@ int table_setup_instruments::update_row_
     case pos_setup_instruments::VIEW_STATEMENT:
       /* No flag to update. */
       break;
+    case pos_setup_instruments::VIEW_SOCKET:
+      update_socket_derived_flags();
+      break;
+    case pos_setup_instruments::VIEW_IDLE:
+      /* No flag to update. */
+      break;
     default:
       DBUG_ASSERT(false);
       break;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (chris.powers:3316 to 3319) WL#4896Christopher Powers17 Jul