Download | Plain Text | No Line Numbers


  1. diff -Naur mysql.orig/aclocal.m4 mysql/aclocal.m4
  2. --- mysql.orig/aclocal.m4 2007-12-14 21:44:56.000000000 +0100
  3. +++ mysql/aclocal.m4 2008-11-27 20:08:06.000000000 +0100
  4. @@ -1597,7 +1597,7 @@
  5.  
  6. # Append ld.so.conf contents to the search path
  7. if test -f /etc/ld.so.conf; then
  8. - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
  9. + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
  10. sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
  11. fi
  12.  
  13. @@ -4305,6 +4305,9 @@
  14. # Is the compiler the GNU C compiler?
  15. with_gcc=$_LT_AC_TAGVAR(GCC, $1)
  16.  
  17. +gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
  18. +gcc_ver=\`gcc -dumpversion\`
  19. +
  20. # An ERE matcher.
  21. EGREP=$lt_EGREP
  22.  
  23. @@ -4438,11 +4441,11 @@
  24.  
  25. # Dependencies to place before the objects being linked to create a
  26. # shared library.
  27. -predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
  28. +predep_objects=\`echo $lt_[]_LT_AC_TAGVAR(predep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
  29.  
  30. # Dependencies to place after the objects being linked to create a
  31. # shared library.
  32. -postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
  33. +postdep_objects=\`echo $lt_[]_LT_AC_TAGVAR(postdep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
  34.  
  35. # Dependencies to place before the objects being linked to create a
  36. # shared library.
  37. @@ -4454,7 +4457,7 @@
  38.  
  39. # The library search path used internally by the compiler when linking
  40. # a shared library.
  41. -compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
  42. +compiler_lib_search_path=\`echo $lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
  43.  
  44. # Method to check whether dependent libraries are shared objects.
  45. deplibs_check_method=$lt_deplibs_check_method
  46. @@ -4534,7 +4537,7 @@
  47. link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
  48.  
  49. # Compile-time system search path for libraries
  50. -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
  51. +sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
  52.  
  53. # Run-time system search path for libraries
  54. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
  55. @@ -6370,6 +6373,7 @@
  56. done
  57. done
  58. done
  59. +IFS=$as_save_IFS
  60. lt_ac_max=0
  61. lt_ac_count=0
  62. # Add /usr/xpg4/bin/sed as it is typically found on Solaris
  63. @@ -6402,6 +6406,7 @@
  64. done
  65. ])
  66. SED=$lt_cv_path_SED
  67. +AC_SUBST([SED])
  68. AC_MSG_RESULT([$SED])
  69. ])
  70.  
  71. diff -Naur mysql.orig/BUILD/Makefile.in mysql/BUILD/Makefile.in
  72. --- mysql.orig/BUILD/Makefile.in 2007-12-14 21:45:22.000000000 +0100
  73. +++ mysql/BUILD/Makefile.in 2008-11-27 20:08:06.000000000 +0100
  74. @@ -167,6 +167,7 @@
  75. LIBDL = @LIBDL@
  76. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  77. LIBOBJS = @LIBOBJS@
  78. +LIBRT = @LIBRT@
  79. LIBS = @LIBS@
  80. LIBTOOL = @LIBTOOL@
  81. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  82. diff -Naur mysql.orig/client/Makefile.in mysql/client/Makefile.in
  83. --- mysql.orig/client/Makefile.in 2007-12-14 21:45:24.000000000 +0100
  84. +++ mysql/client/Makefile.in 2008-11-27 20:08:06.000000000 +0100
  85. @@ -266,6 +266,7 @@
  86. LIBDL = @LIBDL@
  87. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  88. LIBOBJS = @LIBOBJS@
  89. +LIBRT = @LIBRT@
  90. LIBS = @CLIENT_LIBS@
  91. LIBTOOL = @LIBTOOL@
  92. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  93. diff -Naur mysql.orig/cmd-line-utils/libedit/Makefile.in mysql/cmd-line-utils/libedit/Makefile.in
  94. --- mysql.orig/cmd-line-utils/libedit/Makefile.in 2007-12-14 21:45:25.000000000 +0100
  95. +++ mysql/cmd-line-utils/libedit/Makefile.in 2008-11-27 20:08:06.000000000 +0100
  96. @@ -195,6 +195,7 @@
  97. LIBDL = @LIBDL@
  98. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  99. LIBOBJS = @LIBOBJS@
  100. +LIBRT = @LIBRT@
  101. LIBS = @LIBS@
  102. LIBTOOL = @LIBTOOL@
  103. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  104. diff -Naur mysql.orig/cmd-line-utils/Makefile.in mysql/cmd-line-utils/Makefile.in
  105. --- mysql.orig/cmd-line-utils/Makefile.in 2007-12-14 21:45:24.000000000 +0100
  106. +++ mysql/cmd-line-utils/Makefile.in 2008-11-27 20:08:06.000000000 +0100
  107. @@ -175,6 +175,7 @@
  108. LIBDL = @LIBDL@
  109. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  110. LIBOBJS = @LIBOBJS@
  111. +LIBRT = @LIBRT@
  112. LIBS = @LIBS@
  113. LIBTOOL = @LIBTOOL@
  114. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  115. diff -Naur mysql.orig/cmd-line-utils/readline/Makefile.in mysql/cmd-line-utils/readline/Makefile.in
  116. --- mysql.orig/cmd-line-utils/readline/Makefile.in 2007-12-14 21:45:26.000000000 +0100
  117. +++ mysql/cmd-line-utils/readline/Makefile.in 2008-11-27 20:08:06.000000000 +0100
  118. @@ -193,6 +193,7 @@
  119. LIBDL = @LIBDL@
  120. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  121. LIBOBJS = @LIBOBJS@
  122. +LIBRT = @LIBRT@
  123. LIBS = @LIBS@
  124. LIBTOOL = @LIBTOOL@
  125. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  126. diff -Naur mysql.orig/configure mysql/configure
  127. --- mysql.orig/configure 2007-12-14 21:46:16.000000000 +0100
  128. +++ mysql/configure 2008-11-27 20:08:06.000000000 +0100
  129. @@ -477,7 +477,7 @@
  130. #endif"
  131.  
  132. ac_subdirs_all="$ac_subdirs_all innobase"
  133. -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MYSQL_NO_DASH_VERSION MYSQL_BASE_VERSION MYSQL_VERSION_ID MYSQL_PREVIOUS_BASE_VERSION PROTOCOL_VERSION DOT_FRM_VERSION SHARED_LIB_MAJOR_VERSION SHARED_LIB_VERSION NDB_SHARED_LIB_MAJOR_VERSION NDB_SHARED_LIB_VERSION AVAILABLE_LANGUAGES NDB_VERSION_MAJOR NDB_VERSION_MINOR NDB_VERSION_BUILD NDB_VERSION_STATUS SYSTEM_TYPE MACHINE_TYPE CONF_COMMAND SAVE_CC SAVE_CXX SAVE_ASFLAGS SAVE_CFLAGS SAVE_CXXFLAGS SAVE_LDFLAGS SAVE_CXXLDFLAGS CXXLDFLAGS AR RANLIB DARWIN_MWCC_TRUE DARWIN_MWCC_FALSE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CPP CC_VERSION CXX_VERSION AS ac_ct_RANLIB EGREP LN_S ECHO ac_ct_AR CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL NM YACC PDFMANUAL DVIS uname_prog ASFLAGS LD ARFLAGS LD_VERSION_SCRIPT MYSQLD_DEFAULT_SWITCHES TARGET_LINUX LN LN_CP_F MV RM CP SED CMP CHMOD HOSTNAME TAR PERL PERL5 DOXYGEN PDFLATEX MAKEINDEX ICHECK PS FIND_PROC KILL CHECK_PID CCAS CCASFLAGS NOINST_LDFLAGS MYSQL_SERVER_SUFFIX ASSEMBLER_x86_TRUE ASSEMBLER_x86_FALSE ASSEMBLER_sparc32_TRUE ASSEMBLER_sparc32_FALSE ASSEMBLER_sparc64_TRUE ASSEMBLER_sparc64_FALSE ASSEMBLER_TRUE ASSEMBLER_FALSE MYSQL_UNIX_ADDR MYSQL_TCP_PORT MYSQL_TCP_PORT_DEFAULT MYSQLD_USER GETCONF ac_ct_GETCONF zlib_dir ZLIB_LIBS ZLIB_DEPS ZLIB_INCLUDES WRAPLIBS pstack_dirs pstack_libs COMPILE_PSTACK_TRUE COMPILE_PSTACK_FALSE LIBDL MYSQLD_EXTRA_LDFLAGS CLIENT_EXTRA_LDFLAGS MYSQLD_EXTRA_LIBS LIB_EXTRA_CCFLAGS LM_CFLAGS COMPILATION_COMMENT ALLOCA MAKE_SHELL TERMCAP_LIB LIBEDIT_LOBJECTS tools_dirs openssl_libs openssl_includes yassl_taocrypt_extra_cxxflags yassl_h_ln_cmd yassl_libs yassl_dir HAVE_YASSL_TRUE HAVE_YASSL_FALSE libmysqld_dirs linked_libmysqld_targets docs_dirs extra_docs bench_dirs readline_dir readline_topdir readline_basedir readline_link readline_h_ln_cmd bdb_includes bdb_libs bdb_libs_with_path innodb_includes innodb_libs innodb_system_libs NDB_SCI_INCLUDES NDB_SCI_LIBS NDB_LD_VERSION_SCRIPT HAVE_NDBCLUSTER_DB_TRUE HAVE_NDBCLUSTER_DB_FALSE ndbcluster_includes ndbcluster_libs ndbcluster_system_libs ndb_mgmclient_libs man_dirs man1_files man8_files CLIENT_LIBS NON_THREADED_LIBS STATIC_NSS_FLAGS sql_client_dirs linked_client_targets netware_dir linked_netware_sources HAVE_NETWARE_TRUE HAVE_NETWARE_FALSE THREAD_LOBJECTS subdirs sql_server_dirs thread_dirs server_scripts sql_union_dirs GXX NDB_DEFS ndb_cxxflags_fix ndb_port ndb_transporter_opt_objs ndb_bin_am_ldflags ndb_opt_subdirs NDB_SIZEOF_CHARP NDB_SIZEOF_CHAR NDB_SIZEOF_SHORT NDB_SIZEOF_INT NDB_SIZEOF_LONG NDB_SIZEOF_LONG_LONG MAKE_BINARY_DISTRIBUTION_OPTIONS LIBOBJS LTLIBOBJS'
  134. +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MYSQL_NO_DASH_VERSION MYSQL_BASE_VERSION MYSQL_VERSION_ID MYSQL_PREVIOUS_BASE_VERSION PROTOCOL_VERSION DOT_FRM_VERSION SHARED_LIB_MAJOR_VERSION SHARED_LIB_VERSION NDB_SHARED_LIB_MAJOR_VERSION NDB_SHARED_LIB_VERSION AVAILABLE_LANGUAGES NDB_VERSION_MAJOR NDB_VERSION_MINOR NDB_VERSION_BUILD NDB_VERSION_STATUS SYSTEM_TYPE MACHINE_TYPE CONF_COMMAND SAVE_CC SAVE_CXX SAVE_ASFLAGS SAVE_CFLAGS SAVE_CXXFLAGS SAVE_LDFLAGS SAVE_CXXLDFLAGS CXXLDFLAGS AR RANLIB DARWIN_MWCC_TRUE DARWIN_MWCC_FALSE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CPP CC_VERSION CXX_VERSION AS ac_ct_RANLIB SED EGREP LN_S ECHO ac_ct_AR CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL NM YACC PDFMANUAL DVIS uname_prog ASFLAGS LD ARFLAGS LD_VERSION_SCRIPT MYSQLD_DEFAULT_SWITCHES TARGET_LINUX LN LN_CP_F MV RM CP CMP CHMOD HOSTNAME TAR PERL PERL5 DOXYGEN PDFLATEX MAKEINDEX ICHECK PS FIND_PROC KILL CHECK_PID CCAS CCASFLAGS NOINST_LDFLAGS MYSQL_SERVER_SUFFIX ASSEMBLER_x86_TRUE ASSEMBLER_x86_FALSE ASSEMBLER_sparc32_TRUE ASSEMBLER_sparc32_FALSE ASSEMBLER_sparc64_TRUE ASSEMBLER_sparc64_FALSE ASSEMBLER_TRUE ASSEMBLER_FALSE MYSQL_UNIX_ADDR MYSQL_TCP_PORT MYSQL_TCP_PORT_DEFAULT MYSQLD_USER GETCONF ac_ct_GETCONF zlib_dir ZLIB_LIBS ZLIB_DEPS ZLIB_INCLUDES WRAPLIBS pstack_dirs pstack_libs COMPILE_PSTACK_TRUE COMPILE_PSTACK_FALSE LIBDL MYSQLD_EXTRA_LDFLAGS CLIENT_EXTRA_LDFLAGS MYSQLD_EXTRA_LIBS LIB_EXTRA_CCFLAGS LM_CFLAGS COMPILATION_COMMENT ALLOCA MAKE_SHELL TERMCAP_LIB LIBEDIT_LOBJECTS LIBRT tools_dirs openssl_libs openssl_includes yassl_taocrypt_extra_cxxflags yassl_h_ln_cmd yassl_libs yassl_dir HAVE_YASSL_TRUE HAVE_YASSL_FALSE libmysqld_dirs linked_libmysqld_targets docs_dirs extra_docs bench_dirs readline_dir readline_topdir readline_basedir readline_link readline_h_ln_cmd bdb_includes bdb_libs bdb_libs_with_path innodb_includes innodb_libs innodb_system_libs NDB_SCI_INCLUDES NDB_SCI_LIBS NDB_LD_VERSION_SCRIPT HAVE_NDBCLUSTER_DB_TRUE HAVE_NDBCLUSTER_DB_FALSE ndbcluster_includes ndbcluster_libs ndbcluster_system_libs ndb_mgmclient_libs man_dirs man1_files man8_files CLIENT_LIBS NON_THREADED_LIBS STATIC_NSS_FLAGS sql_client_dirs linked_client_targets netware_dir linked_netware_sources HAVE_NETWARE_TRUE HAVE_NETWARE_FALSE THREAD_LOBJECTS subdirs sql_server_dirs thread_dirs server_scripts sql_union_dirs GXX NDB_DEFS ndb_cxxflags_fix ndb_port ndb_transporter_opt_objs ndb_bin_am_ldflags ndb_opt_subdirs NDB_SIZEOF_CHARP NDB_SIZEOF_CHAR NDB_SIZEOF_SHORT NDB_SIZEOF_INT NDB_SIZEOF_LONG NDB_SIZEOF_LONG_LONG MAKE_BINARY_DISTRIBUTION_OPTIONS LIBOBJS LTLIBOBJS'
  135. ac_subst_files=''
  136.  
  137. # Initialize some variables set by options.
  138. @@ -38058,7 +38058,91 @@
  139. # We also disable for SCO for the time being, the headers for the
  140. # thread library we use conflicts with other headers.
  141. ;;
  142. - *)
  143. +*)
  144. + # most systems require the program be linked with librt library to use
  145. + # the function clock_gettime
  146. + my_save_LIBS="$LIBS"
  147. + LIBS=""
  148. +
  149. +echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
  150. +echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
  151. +if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
  152. + echo $ECHO_N "(cached) $ECHO_C" >&6
  153. +else
  154. + ac_check_lib_save_LIBS=$LIBS
  155. +LIBS="-lrt $LIBS"
  156. +cat >conftest.$ac_ext <<_ACEOF
  157. +/* confdefs.h. */
  158. +_ACEOF
  159. +cat confdefs.h >>conftest.$ac_ext
  160. +cat >>conftest.$ac_ext <<_ACEOF
  161. +/* end confdefs.h. */
  162. +
  163. +/* Override any gcc2 internal prototype to avoid an error. */
  164. +#ifdef __cplusplus
  165. +extern "C"
  166. +#endif
  167. +/* We use char because int might match the return type of a gcc2
  168. + builtin and then its argument prototype would still apply. */
  169. +char clock_gettime ();
  170. +int
  171. +main ()
  172. +{
  173. +clock_gettime ();
  174. + ;
  175. + return 0;
  176. +}
  177. +_ACEOF
  178. +rm -f conftest.$ac_objext conftest$ac_exeext
  179. +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
  180. + (eval $ac_link) 2>conftest.er1
  181. + ac_status=$?
  182. + grep -v '^ *+' conftest.er1 >conftest.err
  183. + rm -f conftest.er1
  184. + cat conftest.err >&5
  185. + echo "$as_me:$LINENO: \$? = $ac_status" >&5
  186. + (exit $ac_status); } &&
  187. + { ac_try='test -z "$ac_c_werror_flag"
  188. + || test ! -s conftest.err'
  189. + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
  190. + (eval $ac_try) 2>&5
  191. + ac_status=$?
  192. + echo "$as_me:$LINENO: \$? = $ac_status" >&5
  193. + (exit $ac_status); }; } &&
  194. + { ac_try='test -s conftest$ac_exeext'
  195. + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
  196. + (eval $ac_try) 2>&5
  197. + ac_status=$?
  198. + echo "$as_me:$LINENO: \$? = $ac_status" >&5
  199. + (exit $ac_status); }; }; then
  200. + ac_cv_lib_rt_clock_gettime=yes
  201. +else
  202. + echo "$as_me: failed program was:" >&5
  203. +sed 's/^/| /' conftest.$ac_ext >&5
  204. +
  205. +ac_cv_lib_rt_clock_gettime=no
  206. +fi
  207. +rm -f conftest.err conftest.$ac_objext \
  208. + conftest$ac_exeext conftest.$ac_ext
  209. +LIBS=$ac_check_lib_save_LIBS
  210. +fi
  211. +echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
  212. +echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
  213. +if test $ac_cv_lib_rt_clock_gettime = yes; then
  214. + cat >>confdefs.h <<_ACEOF
  215. +#define HAVE_LIBRT 1
  216. +_ACEOF
  217. +
  218. + LIBS="-lrt $LIBS"
  219. +
  220. +fi
  221. +
  222. + LIBRT=$LIBS
  223. + LIBS="$my_save_LIBS"
  224. +
  225. +
  226. + LIBS="$LIBS $LIBRT"
  227. +
  228. for ac_func in clock_gettime
  229. do
  230. as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
  231. @@ -41466,7 +41550,7 @@
  232.  
  233. fi
  234.  
  235. -CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
  236. +CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
  237.  
  238.  
  239.  
  240. @@ -42763,6 +42847,7 @@
  241. s,@MAKE_SHELL@,$MAKE_SHELL,;t t
  242. s,@TERMCAP_LIB@,$TERMCAP_LIB,;t t
  243. s,@LIBEDIT_LOBJECTS@,$LIBEDIT_LOBJECTS,;t t
  244. +s,@LIBRT@,$LIBRT,;t t
  245. s,@tools_dirs@,$tools_dirs,;t t
  246. s,@openssl_libs@,$openssl_libs,;t t
  247. s,@openssl_includes@,$openssl_includes,;t t
  248. diff -Naur mysql.orig/configure.in mysql/configure.in
  249. --- mysql.orig/configure.in 2007-12-14 21:43:00.000000000 +0100
  250. +++ mysql/configure.in 2008-11-27 20:08:07.000000000 +0100
  251. @@ -2062,7 +2062,18 @@
  252. # We also disable for SCO for the time being, the headers for the
  253. # thread library we use conflicts with other headers.
  254. ;;
  255. - *) AC_CHECK_FUNCS(clock_gettime)
  256. +*)
  257. + # most systems require the program be linked with librt library to use
  258. + # the function clock_gettime
  259. + my_save_LIBS="$LIBS"
  260. + LIBS=""
  261. + AC_CHECK_LIB(rt,clock_gettime)
  262. + LIBRT=$LIBS
  263. + LIBS="$my_save_LIBS"
  264. + AC_SUBST(LIBRT)
  265. +
  266. + LIBS="$LIBS $LIBRT"
  267. + AC_CHECK_FUNCS(clock_gettime)
  268. ;;
  269. esac
  270.  
  271. @@ -2677,7 +2688,7 @@
  272. AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
  273. fi
  274.  
  275. -CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
  276. +CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
  277.  
  278. AC_SUBST(CLIENT_LIBS)
  279. AC_SUBST(NON_THREADED_LIBS)
  280. diff -Naur mysql.orig/dbug/Makefile.in mysql/dbug/Makefile.in
  281. --- mysql.orig/dbug/Makefile.in 2007-12-14 21:45:26.000000000 +0100
  282. +++ mysql/dbug/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  283. @@ -212,6 +212,7 @@
  284. LIBDL = @LIBDL@
  285. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  286. LIBOBJS = @LIBOBJS@
  287. +LIBRT = @LIBRT@
  288. LIBS = @LIBS@
  289. LIBTOOL = @LIBTOOL@
  290. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  291. diff -Naur mysql.orig/Docs/Makefile.in mysql/Docs/Makefile.in
  292. --- mysql.orig/Docs/Makefile.in 2007-12-14 21:45:23.000000000 +0100
  293. +++ mysql/Docs/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  294. @@ -165,6 +165,7 @@
  295. LIBDL = @LIBDL@
  296. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  297. LIBOBJS = @LIBOBJS@
  298. +LIBRT = @LIBRT@
  299. LIBS = @LIBS@
  300. LIBTOOL = @LIBTOOL@
  301. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  302. diff -Naur mysql.orig/extra/Makefile.in mysql/extra/Makefile.in
  303. --- mysql.orig/extra/Makefile.in 2007-12-14 21:45:27.000000000 +0100
  304. +++ mysql/extra/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  305. @@ -254,6 +254,7 @@
  306. LIBDL = @LIBDL@
  307. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  308. LIBOBJS = @LIBOBJS@
  309. +LIBRT = @LIBRT@
  310. LIBS = @LIBS@
  311. LIBTOOL = @LIBTOOL@
  312. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  313. diff -Naur mysql.orig/extra/yassl/Makefile.in mysql/extra/yassl/Makefile.in
  314. --- mysql.orig/extra/yassl/Makefile.in 2007-12-14 21:45:27.000000000 +0100
  315. +++ mysql/extra/yassl/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  316. @@ -160,6 +160,7 @@
  317. LIBDL = @LIBDL@
  318. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  319. LIBOBJS = @LIBOBJS@
  320. +LIBRT = @LIBRT@
  321. LIBS = @LIBS@
  322. LIBTOOL = @LIBTOOL@
  323. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  324. diff -Naur mysql.orig/extra/yassl/src/Makefile.in mysql/extra/yassl/src/Makefile.in
  325. --- mysql.orig/extra/yassl/src/Makefile.in 2007-12-14 21:45:28.000000000 +0100
  326. +++ mysql/extra/yassl/src/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  327. @@ -171,6 +171,7 @@
  328. LIBDL = @LIBDL@
  329. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  330. LIBOBJS = @LIBOBJS@
  331. +LIBRT = @LIBRT@
  332. LIBS = @LIBS@
  333. LIBTOOL = @LIBTOOL@
  334. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  335. diff -Naur mysql.orig/extra/yassl/taocrypt/benchmark/Makefile.in mysql/extra/yassl/taocrypt/benchmark/Makefile.in
  336. --- mysql.orig/extra/yassl/taocrypt/benchmark/Makefile.in 2007-12-14 21:45:29.000000000 +0100
  337. +++ mysql/extra/yassl/taocrypt/benchmark/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  338. @@ -170,6 +170,7 @@
  339. LIBDL = @LIBDL@
  340. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  341. LIBOBJS = @LIBOBJS@
  342. +LIBRT = @LIBRT@
  343. LIBS = @LIBS@
  344. LIBTOOL = @LIBTOOL@
  345. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  346. diff -Naur mysql.orig/extra/yassl/taocrypt/Makefile.in mysql/extra/yassl/taocrypt/Makefile.in
  347. --- mysql.orig/extra/yassl/taocrypt/Makefile.in 2007-12-14 21:45:28.000000000 +0100
  348. +++ mysql/extra/yassl/taocrypt/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  349. @@ -160,6 +160,7 @@
  350. LIBDL = @LIBDL@
  351. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  352. LIBOBJS = @LIBOBJS@
  353. +LIBRT = @LIBRT@
  354. LIBS = @LIBS@
  355. LIBTOOL = @LIBTOOL@
  356. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  357. diff -Naur mysql.orig/extra/yassl/taocrypt/src/Makefile.in mysql/extra/yassl/taocrypt/src/Makefile.in
  358. --- mysql.orig/extra/yassl/taocrypt/src/Makefile.in 2007-12-14 21:45:29.000000000 +0100
  359. +++ mysql/extra/yassl/taocrypt/src/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  360. @@ -180,6 +180,7 @@
  361. LIBDL = @LIBDL@
  362. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  363. LIBOBJS = @LIBOBJS@
  364. +LIBRT = @LIBRT@
  365. LIBS = @LIBS@
  366. LIBTOOL = @LIBTOOL@
  367. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  368. diff -Naur mysql.orig/extra/yassl/taocrypt/test/Makefile.in mysql/extra/yassl/taocrypt/test/Makefile.in
  369. --- mysql.orig/extra/yassl/taocrypt/test/Makefile.in 2007-12-14 21:45:30.000000000 +0100
  370. +++ mysql/extra/yassl/taocrypt/test/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  371. @@ -170,6 +170,7 @@
  372. LIBDL = @LIBDL@
  373. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  374. LIBOBJS = @LIBOBJS@
  375. +LIBRT = @LIBRT@
  376. LIBS = @LIBS@
  377. LIBTOOL = @LIBTOOL@
  378. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  379. diff -Naur mysql.orig/extra/yassl/testsuite/Makefile.in mysql/extra/yassl/testsuite/Makefile.in
  380. --- mysql.orig/extra/yassl/testsuite/Makefile.in 2007-12-14 21:45:30.000000000 +0100
  381. +++ mysql/extra/yassl/testsuite/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  382. @@ -173,6 +173,7 @@
  383. LIBDL = @LIBDL@
  384. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  385. LIBOBJS = @LIBOBJS@
  386. +LIBRT = @LIBRT@
  387. LIBS = @LIBS@
  388. LIBTOOL = @LIBTOOL@
  389. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  390. diff -Naur mysql.orig/heap/Makefile.in mysql/heap/Makefile.in
  391. --- mysql.orig/heap/Makefile.in 2007-12-14 21:45:31.000000000 +0100
  392. +++ mysql/heap/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  393. @@ -216,6 +216,7 @@
  394. LIBDL = @LIBDL@
  395. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  396. LIBOBJS = @LIBOBJS@
  397. +LIBRT = @LIBRT@
  398. LIBS = @LIBS@
  399. LIBTOOL = @LIBTOOL@
  400. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  401. diff -Naur mysql.orig/include/Makefile.in mysql/include/Makefile.in
  402. --- mysql.orig/include/Makefile.in 2007-12-14 21:45:32.000000000 +0100
  403. +++ mysql/include/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  404. @@ -181,6 +181,7 @@
  405. LIBDL = @LIBDL@
  406. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  407. LIBOBJS = @LIBOBJS@
  408. +LIBRT = @LIBRT@
  409. LIBS = @LIBS@
  410. LIBTOOL = @LIBTOOL@
  411. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  412. diff -Naur mysql.orig/include/mysql_com.h mysql/include/mysql_com.h
  413. --- mysql.orig/include/mysql_com.h 2007-12-14 21:42:51.000000000 +0100
  414. +++ mysql/include/mysql_com.h 2008-11-27 20:08:07.000000000 +0100
  415. @@ -106,6 +106,11 @@
  416. thread */
  417. #define REFRESH_MASTER 128 /* Remove all bin logs in the index
  418. and truncate the index */
  419. +#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
  420. +#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
  421. +#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
  422. +#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
  423. +#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
  424.  
  425. /* The following can't be set with mysql_refresh() */
  426. #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
  427. diff -Naur mysql.orig/libmysql/Makefile.in mysql/libmysql/Makefile.in
  428. --- mysql.orig/libmysql/Makefile.in 2007-12-14 21:45:32.000000000 +0100
  429. +++ mysql/libmysql/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  430. @@ -276,6 +276,7 @@
  431. LIBDL = @LIBDL@
  432. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  433. LIBOBJS = @LIBOBJS@
  434. +LIBRT = @LIBRT@
  435. LIBS = @CLIENT_LIBS@
  436. LIBTOOL = @LIBTOOL@
  437. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  438. diff -Naur mysql.orig/libmysqld/examples/Makefile.in mysql/libmysqld/examples/Makefile.in
  439. --- mysql.orig/libmysqld/examples/Makefile.in 2007-12-14 21:45:35.000000000 +0100
  440. +++ mysql/libmysqld/examples/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  441. @@ -211,6 +211,7 @@
  442. LIBDL = @LIBDL@
  443. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  444. LIBOBJS = @LIBOBJS@
  445. +LIBRT = @LIBRT@
  446. LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
  447. LIBTOOL = @LIBTOOL@
  448. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  449. diff -Naur mysql.orig/libmysqld/Makefile.in mysql/libmysqld/Makefile.in
  450. --- mysql.orig/libmysqld/Makefile.in 2007-12-14 21:45:34.000000000 +0100
  451. +++ mysql/libmysqld/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  452. @@ -262,6 +262,7 @@
  453. LIBDL = @LIBDL@
  454. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  455. LIBOBJS = @LIBOBJS@
  456. +LIBRT = @LIBRT@
  457. LIBS = @LIBS@
  458. LIBTOOL = @LIBTOOL@
  459. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  460. diff -Naur mysql.orig/libmysql_r/Makefile.in mysql/libmysql_r/Makefile.in
  461. --- mysql.orig/libmysql_r/Makefile.in 2007-12-14 21:45:33.000000000 +0100
  462. +++ mysql/libmysql_r/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  463. @@ -273,6 +273,7 @@
  464. LIBDL = @LIBDL@
  465. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  466. LIBOBJS = @LIBOBJS@
  467. +LIBRT = @LIBRT@
  468. LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
  469. LIBTOOL = @LIBTOOL@
  470. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  471. diff -Naur mysql.orig/Makefile.in mysql/Makefile.in
  472. --- mysql.orig/Makefile.in 2007-12-14 21:46:14.000000000 +0100
  473. +++ mysql/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  474. @@ -189,6 +189,7 @@
  475. LIBDL = @LIBDL@
  476. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  477. LIBOBJS = @LIBOBJS@
  478. +LIBRT = @LIBRT@
  479. LIBS = @LIBS@
  480. LIBTOOL = @LIBTOOL@
  481. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  482. diff -Naur mysql.orig/man/Makefile.in mysql/man/Makefile.in
  483. --- mysql.orig/man/Makefile.in 2007-12-14 21:45:35.000000000 +0100
  484. +++ mysql/man/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  485. @@ -172,6 +172,7 @@
  486. LIBDL = @LIBDL@
  487. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  488. LIBOBJS = @LIBOBJS@
  489. +LIBRT = @LIBRT@
  490. LIBS = @LIBS@
  491. LIBTOOL = @LIBTOOL@
  492. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  493. diff -Naur mysql.orig/myisam/Makefile.in mysql/myisam/Makefile.in
  494. --- mysql.orig/myisam/Makefile.in 2007-12-14 21:45:36.000000000 +0100
  495. +++ mysql/myisam/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  496. @@ -255,6 +255,7 @@
  497. LIBDL = @LIBDL@
  498. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  499. LIBOBJS = @LIBOBJS@
  500. +LIBRT = @LIBRT@
  501. LIBS = @LIBS@
  502. LIBTOOL = @LIBTOOL@
  503. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  504. diff -Naur mysql.orig/myisammrg/Makefile.in mysql/myisammrg/Makefile.in
  505. --- mysql.orig/myisammrg/Makefile.in 2007-12-14 21:45:37.000000000 +0100
  506. +++ mysql/myisammrg/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  507. @@ -203,6 +203,7 @@
  508. LIBDL = @LIBDL@
  509. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  510. LIBOBJS = @LIBOBJS@
  511. +LIBRT = @LIBRT@
  512. LIBS = @LIBS@
  513. LIBTOOL = @LIBTOOL@
  514. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  515. diff -Naur mysql.orig/mysql-test/Makefile.in mysql/mysql-test/Makefile.in
  516. --- mysql.orig/mysql-test/Makefile.in 2007-12-14 21:45:38.000000000 +0100
  517. +++ mysql/mysql-test/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  518. @@ -179,6 +179,7 @@
  519. LIBDL = @LIBDL@
  520. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  521. LIBOBJS = @LIBOBJS@
  522. +LIBRT = @LIBRT@
  523. LIBS = @LIBS@
  524. LIBTOOL = @LIBTOOL@
  525. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  526. diff -Naur mysql.orig/mysql-test/ndb/Makefile.in mysql/mysql-test/ndb/Makefile.in
  527. --- mysql.orig/mysql-test/ndb/Makefile.in 2007-12-14 21:45:39.000000000 +0100
  528. +++ mysql/mysql-test/ndb/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  529. @@ -168,6 +168,7 @@
  530. LIBDL = @LIBDL@
  531. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  532. LIBOBJS = @LIBOBJS@
  533. +LIBRT = @LIBRT@
  534. LIBS = @LIBS@
  535. LIBTOOL = @LIBTOOL@
  536. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  537. diff -Naur mysql.orig/mysql-test/r/information_schema_db.result mysql/mysql-test/r/information_schema_db.result
  538. --- mysql.orig/mysql-test/r/information_schema_db.result 2007-12-14 22:14:18.000000000 +0100
  539. +++ mysql/mysql-test/r/information_schema_db.result 2008-11-27 20:08:07.000000000 +0100
  540. @@ -6,10 +6,12 @@
  541. show tables;
  542. Tables_in_information_schema
  543. CHARACTER_SETS
  544. +CLIENT_STATISTICS
  545. COLLATIONS
  546. COLLATION_CHARACTER_SET_APPLICABILITY
  547. COLUMNS
  548. COLUMN_PRIVILEGES
  549. +INDEX_STATISTICS
  550. KEY_COLUMN_USAGE
  551. ROUTINES
  552. SCHEMATA
  553. @@ -18,14 +20,17 @@
  554. TABLES
  555. TABLE_CONSTRAINTS
  556. TABLE_PRIVILEGES
  557. +TABLE_STATISTICS
  558. TRIGGERS
  559. USER_PRIVILEGES
  560. +USER_STATISTICS
  561. VIEWS
  562. show tables from INFORMATION_SCHEMA like 'T%';
  563. Tables_in_information_schema (T%)
  564. TABLES
  565. TABLE_CONSTRAINTS
  566. TABLE_PRIVILEGES
  567. +TABLE_STATISTICS
  568. TRIGGERS
  569. create database `inf%`;
  570. create database mbase;
  571. diff -Naur mysql.orig/mysql-test/r/information_schema.result mysql/mysql-test/r/information_schema.result
  572. --- mysql.orig/mysql-test/r/information_schema.result 2007-12-14 22:14:18.000000000 +0100
  573. +++ mysql/mysql-test/r/information_schema.result 2008-11-27 20:08:07.000000000 +0100
  574. @@ -37,10 +37,12 @@
  575. select * from v1;
  576. c
  577. CHARACTER_SETS
  578. +CLIENT_STATISTICS
  579. COLLATIONS
  580. COLLATION_CHARACTER_SET_APPLICABILITY
  581. COLUMNS
  582. COLUMN_PRIVILEGES
  583. +INDEX_STATISTICS
  584. KEY_COLUMN_USAGE
  585. ROUTINES
  586. SCHEMATA
  587. @@ -49,8 +51,10 @@
  588. TABLES
  589. TABLE_CONSTRAINTS
  590. TABLE_PRIVILEGES
  591. +TABLE_STATISTICS
  592. TRIGGERS
  593. USER_PRIVILEGES
  594. +USER_STATISTICS
  595. VIEWS
  596. columns_priv
  597. db
  598. @@ -82,6 +86,7 @@
  599. TABLES TABLES
  600. TABLE_CONSTRAINTS TABLE_CONSTRAINTS
  601. TABLE_PRIVILEGES TABLE_PRIVILEGES
  602. +TABLE_STATISTICS TABLE_STATISTICS
  603. TRIGGERS TRIGGERS
  604. tables_priv tables_priv
  605. time_zone time_zone
  606. @@ -101,6 +106,7 @@
  607. TABLES TABLES
  608. TABLE_CONSTRAINTS TABLE_CONSTRAINTS
  609. TABLE_PRIVILEGES TABLE_PRIVILEGES
  610. +TABLE_STATISTICS TABLE_STATISTICS
  611. TRIGGERS TRIGGERS
  612. tables_priv tables_priv
  613. time_zone time_zone
  614. @@ -120,6 +126,7 @@
  615. TABLES TABLES
  616. TABLE_CONSTRAINTS TABLE_CONSTRAINTS
  617. TABLE_PRIVILEGES TABLE_PRIVILEGES
  618. +TABLE_STATISTICS TABLE_STATISTICS
  619. TRIGGERS TRIGGERS
  620. tables_priv tables_priv
  621. time_zone time_zone
  622. @@ -593,12 +600,13 @@
  623. where table_schema='information_schema' limit 2;
  624. TABLE_NAME TABLE_TYPE ENGINE
  625. CHARACTER_SETS SYSTEM VIEW MEMORY
  626. -COLLATIONS SYSTEM VIEW MEMORY
  627. +CLIENT_STATISTICS SYSTEM VIEW MEMORY
  628. show tables from information_schema like "T%";
  629. Tables_in_information_schema (T%)
  630. TABLES
  631. TABLE_CONSTRAINTS
  632. TABLE_PRIVILEGES
  633. +TABLE_STATISTICS
  634. TRIGGERS
  635. create database information_schema;
  636. ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
  637. @@ -608,6 +616,7 @@
  638. TABLES SYSTEM VIEW
  639. TABLE_CONSTRAINTS SYSTEM VIEW
  640. TABLE_PRIVILEGES SYSTEM VIEW
  641. +TABLE_STATISTICS SYSTEM VIEW
  642. TRIGGERS SYSTEM VIEW
  643. create table t1(a int);
  644. ERROR 42S02: Unknown table 't1' in information_schema
  645. @@ -620,6 +629,7 @@
  646. TABLES
  647. TABLE_CONSTRAINTS
  648. TABLE_PRIVILEGES
  649. +TABLE_STATISTICS
  650. TRIGGERS
  651. select table_name from tables where table_name='user';
  652. table_name
  653. @@ -729,7 +739,7 @@
  654. CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
  655. CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
  656. count(*)
  657. -101
  658. +106
  659. drop view a2, a1;
  660. drop table t_crashme;
  661. select table_schema,table_name, column_name from
  662. @@ -789,18 +799,20 @@
  663. TABLE_NAME COLUMN_NAME PRIVILEGES
  664. COLUMNS TABLE_NAME select
  665. COLUMN_PRIVILEGES TABLE_NAME select
  666. +INDEX_STATISTICS TABLE_NAME select
  667. KEY_COLUMN_USAGE TABLE_NAME select
  668. STATISTICS TABLE_NAME select
  669. TABLES TABLE_NAME select
  670. TABLE_CONSTRAINTS TABLE_NAME select
  671. TABLE_PRIVILEGES TABLE_NAME select
  672. +TABLE_STATISTICS TABLE_NAME select
  673. VIEWS TABLE_NAME select
  674. delete from mysql.user where user='mysqltest_4';
  675. delete from mysql.db where user='mysqltest_4';
  676. flush privileges;
  677. SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
  678. table_schema count(*)
  679. -information_schema 16
  680. +information_schema 21
  681. mysql 17
  682. create table t1 (i int, j int);
  683. create trigger trg1 before insert on t1 for each row
  684. @@ -1186,10 +1198,12 @@
  685. );
  686. table_name column_name
  687. CHARACTER_SETS CHARACTER_SET_NAME
  688. +CLIENT_STATISTICS CLIENT
  689. COLLATIONS COLLATION_NAME
  690. COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
  691. COLUMNS TABLE_SCHEMA
  692. COLUMN_PRIVILEGES TABLE_SCHEMA
  693. +INDEX_STATISTICS TABLE_SCHEMA
  694. KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
  695. ROUTINES ROUTINE_SCHEMA
  696. SCHEMATA SCHEMA_NAME
  697. @@ -1198,8 +1212,10 @@
  698. TABLES TABLE_SCHEMA
  699. TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
  700. TABLE_PRIVILEGES TABLE_SCHEMA
  701. +TABLE_STATISTICS TABLE_SCHEMA
  702. TRIGGERS TRIGGER_SCHEMA
  703. USER_PRIVILEGES GRANTEE
  704. +USER_STATISTICS USER
  705. VIEWS TABLE_SCHEMA
  706. SELECT t.table_name, c1.column_name
  707. FROM information_schema.tables t
  708. @@ -1217,10 +1233,12 @@
  709. );
  710. table_name column_name
  711. CHARACTER_SETS CHARACTER_SET_NAME
  712. +CLIENT_STATISTICS CLIENT
  713. COLLATIONS COLLATION_NAME
  714. COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
  715. COLUMNS TABLE_SCHEMA
  716. COLUMN_PRIVILEGES TABLE_SCHEMA
  717. +INDEX_STATISTICS TABLE_SCHEMA
  718. KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
  719. ROUTINES ROUTINE_SCHEMA
  720. SCHEMATA SCHEMA_NAME
  721. @@ -1229,8 +1247,10 @@
  722. TABLES TABLE_SCHEMA
  723. TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
  724. TABLE_PRIVILEGES TABLE_SCHEMA
  725. +TABLE_STATISTICS TABLE_SCHEMA
  726. TRIGGERS TRIGGER_SCHEMA
  727. USER_PRIVILEGES GRANTEE
  728. +USER_STATISTICS USER
  729. VIEWS TABLE_SCHEMA
  730. SELECT MAX(table_name) FROM information_schema.tables;
  731. MAX(table_name)
  732. @@ -1299,10 +1319,12 @@
  733. group by t.table_name order by num1, t.table_name;
  734. table_name group_concat(t.table_schema, '.', t.table_name) num1
  735. CHARACTER_SETS information_schema.CHARACTER_SETS 1
  736. +CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
  737. COLLATIONS information_schema.COLLATIONS 1
  738. COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
  739. COLUMNS information_schema.COLUMNS 1
  740. COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
  741. +INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
  742. KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
  743. ROUTINES information_schema.ROUTINES 1
  744. SCHEMATA information_schema.SCHEMATA 1
  745. @@ -1311,8 +1333,10 @@
  746. TABLES information_schema.TABLES 1
  747. TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
  748. TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
  749. +TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
  750. TRIGGERS information_schema.TRIGGERS 1
  751. USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
  752. +USER_STATISTICS information_schema.USER_STATISTICS 1
  753. VIEWS information_schema.VIEWS 1
  754. create table t1(f1 int);
  755. create view v1 as select f1+1 as a from t1;
  756. diff -Naur mysql.orig/mysql-test/r/mysqlshow.result mysql/mysql-test/r/mysqlshow.result
  757. --- mysql.orig/mysql-test/r/mysqlshow.result 2007-12-14 22:14:18.000000000 +0100
  758. +++ mysql/mysql-test/r/mysqlshow.result 2008-11-27 20:08:07.000000000 +0100
  759. @@ -80,10 +80,12 @@
  760. | Tables |
  761. +---------------------------------------+
  762. | CHARACTER_SETS |
  763. +| CLIENT_STATISTICS |
  764. | COLLATIONS |
  765. | COLLATION_CHARACTER_SET_APPLICABILITY |
  766. | COLUMNS |
  767. | COLUMN_PRIVILEGES |
  768. +| INDEX_STATISTICS |
  769. | KEY_COLUMN_USAGE |
  770. | ROUTINES |
  771. | SCHEMATA |
  772. @@ -92,8 +94,10 @@
  773. | TABLES |
  774. | TABLE_CONSTRAINTS |
  775. | TABLE_PRIVILEGES |
  776. +| TABLE_STATISTICS |
  777. | TRIGGERS |
  778. | USER_PRIVILEGES |
  779. +| USER_STATISTICS |
  780. | VIEWS |
  781. +---------------------------------------+
  782. Database: INFORMATION_SCHEMA
  783. @@ -101,10 +105,12 @@
  784. | Tables |
  785. +---------------------------------------+
  786. | CHARACTER_SETS |
  787. +| CLIENT_STATISTICS |
  788. | COLLATIONS |
  789. | COLLATION_CHARACTER_SET_APPLICABILITY |
  790. | COLUMNS |
  791. | COLUMN_PRIVILEGES |
  792. +| INDEX_STATISTICS |
  793. | KEY_COLUMN_USAGE |
  794. | ROUTINES |
  795. | SCHEMATA |
  796. @@ -113,8 +119,10 @@
  797. | TABLES |
  798. | TABLE_CONSTRAINTS |
  799. | TABLE_PRIVILEGES |
  800. +| TABLE_STATISTICS |
  801. | TRIGGERS |
  802. | USER_PRIVILEGES |
  803. +| USER_STATISTICS |
  804. | VIEWS |
  805. +---------------------------------------+
  806. Wildcard: inf_rmation_schema
  807. diff -Naur mysql.orig/mysys/Makefile.in mysql/mysys/Makefile.in
  808. --- mysql.orig/mysys/Makefile.in 2007-12-14 21:45:40.000000000 +0100
  809. +++ mysql/mysys/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  810. @@ -247,6 +247,7 @@
  811. LIBDL = @LIBDL@
  812. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  813. LIBOBJS = @LIBOBJS@
  814. +LIBRT = @LIBRT@
  815. LIBS = @LIBS@
  816. LIBTOOL = @LIBTOOL@
  817. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  818. diff -Naur mysql.orig/ndb/docs/Makefile.in mysql/ndb/docs/Makefile.in
  819. --- mysql.orig/ndb/docs/Makefile.in 2007-12-14 21:45:40.000000000 +0100
  820. +++ mysql/ndb/docs/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  821. @@ -170,6 +170,7 @@
  822. LIBDL = @LIBDL@
  823. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  824. LIBOBJS = @LIBOBJS@
  825. +LIBRT = @LIBRT@
  826. LIBS = @LIBS@
  827. LIBTOOL = @LIBTOOL@
  828. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  829. diff -Naur mysql.orig/ndb/include/Makefile.in mysql/ndb/include/Makefile.in
  830. --- mysql.orig/ndb/include/Makefile.in 2007-12-14 21:45:41.000000000 +0100
  831. +++ mysql/ndb/include/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  832. @@ -200,6 +200,7 @@
  833. LIBDL = @LIBDL@
  834. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  835. LIBOBJS = @LIBOBJS@
  836. +LIBRT = @LIBRT@
  837. LIBS = @LIBS@
  838. LIBTOOL = @LIBTOOL@
  839. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  840. diff -Naur mysql.orig/ndb/Makefile.in mysql/ndb/Makefile.in
  841. --- mysql.orig/ndb/Makefile.in 2007-12-14 21:45:40.000000000 +0100
  842. +++ mysql/ndb/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  843. @@ -189,6 +189,7 @@
  844. LIBDL = @LIBDL@
  845. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  846. LIBOBJS = @LIBOBJS@
  847. +LIBRT = @LIBRT@
  848. LIBS = @LIBS@
  849. LIBTOOL = @LIBTOOL@
  850. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  851. diff -Naur mysql.orig/ndb/src/common/debugger/Makefile.in mysql/ndb/src/common/debugger/Makefile.in
  852. --- mysql.orig/ndb/src/common/debugger/Makefile.in 2007-12-14 21:45:43.000000000 +0100
  853. +++ mysql/ndb/src/common/debugger/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  854. @@ -223,6 +223,7 @@
  855. LIBDL = @LIBDL@
  856. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  857. LIBOBJS = @LIBOBJS@
  858. +LIBRT = @LIBRT@
  859. LIBS = @LIBS@
  860. LIBTOOL = @LIBTOOL@
  861. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  862. diff -Naur mysql.orig/ndb/src/common/debugger/signaldata/Makefile.in mysql/ndb/src/common/debugger/signaldata/Makefile.in
  863. --- mysql.orig/ndb/src/common/debugger/signaldata/Makefile.in 2007-12-14 21:45:43.000000000 +0100
  864. +++ mysql/ndb/src/common/debugger/signaldata/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  865. @@ -231,6 +231,7 @@
  866. LIBDL = @LIBDL@
  867. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  868. LIBOBJS = @LIBOBJS@
  869. +LIBRT = @LIBRT@
  870. LIBS = @LIBS@
  871. LIBTOOL = @LIBTOOL@
  872. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  873. diff -Naur mysql.orig/ndb/src/common/logger/Makefile.in mysql/ndb/src/common/logger/Makefile.in
  874. --- mysql.orig/ndb/src/common/logger/Makefile.in 2007-12-14 21:45:44.000000000 +0100
  875. +++ mysql/ndb/src/common/logger/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  876. @@ -217,6 +217,7 @@
  877. LIBDL = @LIBDL@
  878. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  879. LIBOBJS = @LIBOBJS@
  880. +LIBRT = @LIBRT@
  881. LIBS = @LIBS@
  882. LIBTOOL = @LIBTOOL@
  883. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  884. diff -Naur mysql.orig/ndb/src/common/Makefile.in mysql/ndb/src/common/Makefile.in
  885. --- mysql.orig/ndb/src/common/Makefile.in 2007-12-14 21:45:42.000000000 +0100
  886. +++ mysql/ndb/src/common/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  887. @@ -191,6 +191,7 @@
  888. LIBDL = @LIBDL@
  889. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  890. LIBOBJS = @LIBOBJS@
  891. +LIBRT = @LIBRT@
  892. LIBS = @LIBS@
  893. LIBTOOL = @LIBTOOL@
  894. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  895. diff -Naur mysql.orig/ndb/src/common/mgmcommon/Makefile.in mysql/ndb/src/common/mgmcommon/Makefile.in
  896. --- mysql.orig/ndb/src/common/mgmcommon/Makefile.in 2007-12-14 21:45:45.000000000 +0100
  897. +++ mysql/ndb/src/common/mgmcommon/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  898. @@ -231,6 +231,7 @@
  899. LIBDL = @LIBDL@
  900. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  901. LIBOBJS = @LIBOBJS@
  902. +LIBRT = @LIBRT@
  903. LIBS = @LIBS@
  904. LIBTOOL = @LIBTOOL@
  905. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  906. diff -Naur mysql.orig/ndb/src/common/portlib/Makefile.in mysql/ndb/src/common/portlib/Makefile.in
  907. --- mysql.orig/ndb/src/common/portlib/Makefile.in 2007-12-14 21:45:45.000000000 +0100
  908. +++ mysql/ndb/src/common/portlib/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  909. @@ -241,6 +241,7 @@
  910. LIBDL = @LIBDL@
  911. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  912. LIBOBJS = @LIBOBJS@
  913. +LIBRT = @LIBRT@
  914. LIBS = @LIBS@
  915. LIBTOOL = @LIBTOOL@
  916. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  917. diff -Naur mysql.orig/ndb/src/common/transporter/Makefile.in mysql/ndb/src/common/transporter/Makefile.in
  918. --- mysql.orig/ndb/src/common/transporter/Makefile.in 2007-12-14 21:45:46.000000000 +0100
  919. +++ mysql/ndb/src/common/transporter/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  920. @@ -217,6 +217,7 @@
  921. LIBDL = @LIBDL@
  922. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  923. LIBOBJS = @LIBOBJS@
  924. +LIBRT = @LIBRT@
  925. LIBS = @LIBS@
  926. LIBTOOL = @LIBTOOL@
  927. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  928. diff -Naur mysql.orig/ndb/src/common/util/Makefile.in mysql/ndb/src/common/util/Makefile.in
  929. --- mysql.orig/ndb/src/common/util/Makefile.in 2007-12-14 21:45:47.000000000 +0100
  930. +++ mysql/ndb/src/common/util/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  931. @@ -233,6 +233,7 @@
  932. LIBDL = @LIBDL@
  933. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  934. LIBOBJS = @LIBOBJS@
  935. +LIBRT = @LIBRT@
  936. LIBS = @LIBS@
  937. LIBTOOL = @LIBTOOL@
  938. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  939. diff -Naur mysql.orig/ndb/src/cw/cpcd/Makefile.in mysql/ndb/src/cw/cpcd/Makefile.in
  940. --- mysql.orig/ndb/src/cw/cpcd/Makefile.in 2007-12-14 21:45:48.000000000 +0100
  941. +++ mysql/ndb/src/cw/cpcd/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  942. @@ -224,6 +224,7 @@
  943. LIBDL = @LIBDL@
  944. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  945. LIBOBJS = @LIBOBJS@
  946. +LIBRT = @LIBRT@
  947. LIBS = @LIBS@
  948. LIBTOOL = @LIBTOOL@
  949. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  950. diff -Naur mysql.orig/ndb/src/cw/Makefile.in mysql/ndb/src/cw/Makefile.in
  951. --- mysql.orig/ndb/src/cw/Makefile.in 2007-12-14 21:45:47.000000000 +0100
  952. +++ mysql/ndb/src/cw/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  953. @@ -174,6 +174,7 @@
  954. LIBDL = @LIBDL@
  955. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  956. LIBOBJS = @LIBOBJS@
  957. +LIBRT = @LIBRT@
  958. LIBS = @LIBS@
  959. LIBTOOL = @LIBTOOL@
  960. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  961. diff -Naur mysql.orig/ndb/src/kernel/blocks/backup/Makefile.in mysql/ndb/src/kernel/blocks/backup/Makefile.in
  962. --- mysql.orig/ndb/src/kernel/blocks/backup/Makefile.in 2007-12-14 21:45:49.000000000 +0100
  963. +++ mysql/ndb/src/kernel/blocks/backup/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  964. @@ -216,6 +216,7 @@
  965. LIBDL = @LIBDL@
  966. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  967. LIBOBJS = @LIBOBJS@
  968. +LIBRT = @LIBRT@
  969. LIBS = @LIBS@
  970. LIBTOOL = @LIBTOOL@
  971. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  972. diff -Naur mysql.orig/ndb/src/kernel/blocks/cmvmi/Makefile.in mysql/ndb/src/kernel/blocks/cmvmi/Makefile.in
  973. --- mysql.orig/ndb/src/kernel/blocks/cmvmi/Makefile.in 2007-12-14 21:45:50.000000000 +0100
  974. +++ mysql/ndb/src/kernel/blocks/cmvmi/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  975. @@ -216,6 +216,7 @@
  976. LIBDL = @LIBDL@
  977. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  978. LIBOBJS = @LIBOBJS@
  979. +LIBRT = @LIBRT@
  980. LIBS = @LIBS@
  981. LIBTOOL = @LIBTOOL@
  982. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  983. diff -Naur mysql.orig/ndb/src/kernel/blocks/dbacc/Makefile.in mysql/ndb/src/kernel/blocks/dbacc/Makefile.in
  984. --- mysql.orig/ndb/src/kernel/blocks/dbacc/Makefile.in 2007-12-14 21:45:50.000000000 +0100
  985. +++ mysql/ndb/src/kernel/blocks/dbacc/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  986. @@ -216,6 +216,7 @@
  987. LIBDL = @LIBDL@
  988. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  989. LIBOBJS = @LIBOBJS@
  990. +LIBRT = @LIBRT@
  991. LIBS = @LIBS@
  992. LIBTOOL = @LIBTOOL@
  993. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  994. diff -Naur mysql.orig/ndb/src/kernel/blocks/dbdict/Makefile.in mysql/ndb/src/kernel/blocks/dbdict/Makefile.in
  995. --- mysql.orig/ndb/src/kernel/blocks/dbdict/Makefile.in 2007-12-14 21:45:51.000000000 +0100
  996. +++ mysql/ndb/src/kernel/blocks/dbdict/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  997. @@ -226,6 +226,7 @@
  998. LIBDL = @LIBDL@
  999. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1000. LIBOBJS = @LIBOBJS@
  1001. +LIBRT = @LIBRT@
  1002. LIBS = @LIBS@
  1003. LIBTOOL = @LIBTOOL@
  1004. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1005. diff -Naur mysql.orig/ndb/src/kernel/blocks/dbdih/Makefile.in mysql/ndb/src/kernel/blocks/dbdih/Makefile.in
  1006. --- mysql.orig/ndb/src/kernel/blocks/dbdih/Makefile.in 2007-12-14 21:45:52.000000000 +0100
  1007. +++ mysql/ndb/src/kernel/blocks/dbdih/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1008. @@ -223,6 +223,7 @@
  1009. LIBDL = @LIBDL@
  1010. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1011. LIBOBJS = @LIBOBJS@
  1012. +LIBRT = @LIBRT@
  1013. LIBS = @LIBS@
  1014. LIBTOOL = @LIBTOOL@
  1015. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1016. diff -Naur mysql.orig/ndb/src/kernel/blocks/dblqh/Makefile.in mysql/ndb/src/kernel/blocks/dblqh/Makefile.in
  1017. --- mysql.orig/ndb/src/kernel/blocks/dblqh/Makefile.in 2007-12-14 21:45:52.000000000 +0100
  1018. +++ mysql/ndb/src/kernel/blocks/dblqh/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1019. @@ -224,6 +224,7 @@
  1020. LIBDL = @LIBDL@
  1021. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1022. LIBOBJS = @LIBOBJS@
  1023. +LIBRT = @LIBRT@
  1024. LIBS = @LIBS@
  1025. LIBTOOL = @LIBTOOL@
  1026. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1027. diff -Naur mysql.orig/ndb/src/kernel/blocks/dbtc/Makefile.in mysql/ndb/src/kernel/blocks/dbtc/Makefile.in
  1028. --- mysql.orig/ndb/src/kernel/blocks/dbtc/Makefile.in 2007-12-14 21:45:53.000000000 +0100
  1029. +++ mysql/ndb/src/kernel/blocks/dbtc/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1030. @@ -216,6 +216,7 @@
  1031. LIBDL = @LIBDL@
  1032. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1033. LIBOBJS = @LIBOBJS@
  1034. +LIBRT = @LIBRT@
  1035. LIBS = @LIBS@
  1036. LIBTOOL = @LIBTOOL@
  1037. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1038. diff -Naur mysql.orig/ndb/src/kernel/blocks/dbtup/Makefile.in mysql/ndb/src/kernel/blocks/dbtup/Makefile.in
  1039. --- mysql.orig/ndb/src/kernel/blocks/dbtup/Makefile.in 2007-12-14 21:45:53.000000000 +0100
  1040. +++ mysql/ndb/src/kernel/blocks/dbtup/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1041. @@ -224,6 +224,7 @@
  1042. LIBDL = @LIBDL@
  1043. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1044. LIBOBJS = @LIBOBJS@
  1045. +LIBRT = @LIBRT@
  1046. LIBS = @LIBS@
  1047. LIBTOOL = @LIBTOOL@
  1048. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1049. diff -Naur mysql.orig/ndb/src/kernel/blocks/dbtux/Makefile.in mysql/ndb/src/kernel/blocks/dbtux/Makefile.in
  1050. --- mysql.orig/ndb/src/kernel/blocks/dbtux/Makefile.in 2007-12-14 21:45:54.000000000 +0100
  1051. +++ mysql/ndb/src/kernel/blocks/dbtux/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1052. @@ -219,6 +219,7 @@
  1053. LIBDL = @LIBDL@
  1054. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1055. LIBOBJS = @LIBOBJS@
  1056. +LIBRT = @LIBRT@
  1057. LIBS = @LIBS@
  1058. LIBTOOL = @LIBTOOL@
  1059. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1060. diff -Naur mysql.orig/ndb/src/kernel/blocks/dbutil/Makefile.in mysql/ndb/src/kernel/blocks/dbutil/Makefile.in
  1061. --- mysql.orig/ndb/src/kernel/blocks/dbutil/Makefile.in 2007-12-14 21:45:54.000000000 +0100
  1062. +++ mysql/ndb/src/kernel/blocks/dbutil/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1063. @@ -216,6 +216,7 @@
  1064. LIBDL = @LIBDL@
  1065. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1066. LIBOBJS = @LIBOBJS@
  1067. +LIBRT = @LIBRT@
  1068. LIBS = @LIBS@
  1069. LIBTOOL = @LIBTOOL@
  1070. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1071. diff -Naur mysql.orig/ndb/src/kernel/blocks/Makefile.in mysql/ndb/src/kernel/blocks/Makefile.in
  1072. --- mysql.orig/ndb/src/kernel/blocks/Makefile.in 2007-12-14 21:45:49.000000000 +0100
  1073. +++ mysql/ndb/src/kernel/blocks/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1074. @@ -174,6 +174,7 @@
  1075. LIBDL = @LIBDL@
  1076. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1077. LIBOBJS = @LIBOBJS@
  1078. +LIBRT = @LIBRT@
  1079. LIBS = @LIBS@
  1080. LIBTOOL = @LIBTOOL@
  1081. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1082. diff -Naur mysql.orig/ndb/src/kernel/blocks/ndbcntr/Makefile.in mysql/ndb/src/kernel/blocks/ndbcntr/Makefile.in
  1083. --- mysql.orig/ndb/src/kernel/blocks/ndbcntr/Makefile.in 2007-12-14 21:45:55.000000000 +0100
  1084. +++ mysql/ndb/src/kernel/blocks/ndbcntr/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1085. @@ -217,6 +217,7 @@
  1086. LIBDL = @LIBDL@
  1087. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1088. LIBOBJS = @LIBOBJS@
  1089. +LIBRT = @LIBRT@
  1090. LIBS = @LIBS@
  1091. LIBTOOL = @LIBTOOL@
  1092. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1093. diff -Naur mysql.orig/ndb/src/kernel/blocks/ndbfs/Makefile.in mysql/ndb/src/kernel/blocks/ndbfs/Makefile.in
  1094. --- mysql.orig/ndb/src/kernel/blocks/ndbfs/Makefile.in 2007-12-14 21:45:56.000000000 +0100
  1095. +++ mysql/ndb/src/kernel/blocks/ndbfs/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1096. @@ -217,6 +217,7 @@
  1097. LIBDL = @LIBDL@
  1098. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1099. LIBOBJS = @LIBOBJS@
  1100. +LIBRT = @LIBRT@
  1101. LIBS = @LIBS@
  1102. LIBTOOL = @LIBTOOL@
  1103. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1104. diff -Naur mysql.orig/ndb/src/kernel/blocks/qmgr/Makefile.in mysql/ndb/src/kernel/blocks/qmgr/Makefile.in
  1105. --- mysql.orig/ndb/src/kernel/blocks/qmgr/Makefile.in 2007-12-14 21:45:56.000000000 +0100
  1106. +++ mysql/ndb/src/kernel/blocks/qmgr/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1107. @@ -216,6 +216,7 @@
  1108. LIBDL = @LIBDL@
  1109. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1110. LIBOBJS = @LIBOBJS@
  1111. +LIBRT = @LIBRT@
  1112. LIBS = @LIBS@
  1113. LIBTOOL = @LIBTOOL@
  1114. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1115. diff -Naur mysql.orig/ndb/src/kernel/blocks/suma/Makefile.in mysql/ndb/src/kernel/blocks/suma/Makefile.in
  1116. --- mysql.orig/ndb/src/kernel/blocks/suma/Makefile.in 2007-12-14 21:45:57.000000000 +0100
  1117. +++ mysql/ndb/src/kernel/blocks/suma/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1118. @@ -216,6 +216,7 @@
  1119. LIBDL = @LIBDL@
  1120. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1121. LIBOBJS = @LIBOBJS@
  1122. +LIBRT = @LIBRT@
  1123. LIBS = @LIBS@
  1124. LIBTOOL = @LIBTOOL@
  1125. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1126. diff -Naur mysql.orig/ndb/src/kernel/blocks/trix/Makefile.in mysql/ndb/src/kernel/blocks/trix/Makefile.in
  1127. --- mysql.orig/ndb/src/kernel/blocks/trix/Makefile.in 2007-12-14 21:45:57.000000000 +0100
  1128. +++ mysql/ndb/src/kernel/blocks/trix/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1129. @@ -216,6 +216,7 @@
  1130. LIBDL = @LIBDL@
  1131. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1132. LIBOBJS = @LIBOBJS@
  1133. +LIBRT = @LIBRT@
  1134. LIBS = @LIBS@
  1135. LIBTOOL = @LIBTOOL@
  1136. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1137. diff -Naur mysql.orig/ndb/src/kernel/error/Makefile.in mysql/ndb/src/kernel/error/Makefile.in
  1138. --- mysql.orig/ndb/src/kernel/error/Makefile.in 2007-12-14 21:45:58.000000000 +0100
  1139. +++ mysql/ndb/src/kernel/error/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1140. @@ -225,6 +225,7 @@
  1141. LIBDL = @LIBDL@
  1142. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1143. LIBOBJS = @LIBOBJS@
  1144. +LIBRT = @LIBRT@
  1145. LIBS = @LIBS@
  1146. LIBTOOL = @LIBTOOL@
  1147. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1148. diff -Naur mysql.orig/ndb/src/kernel/Makefile.in mysql/ndb/src/kernel/Makefile.in
  1149. --- mysql.orig/ndb/src/kernel/Makefile.in 2007-12-14 21:45:48.000000000 +0100
  1150. +++ mysql/ndb/src/kernel/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1151. @@ -244,6 +244,7 @@
  1152. LIBDL = @LIBDL@
  1153. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1154. LIBOBJS = @LIBOBJS@
  1155. +LIBRT = @LIBRT@
  1156. LIBS = @LIBS@
  1157. LIBTOOL = @LIBTOOL@
  1158. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1159. diff -Naur mysql.orig/ndb/src/kernel/vm/Makefile.in mysql/ndb/src/kernel/vm/Makefile.in
  1160. --- mysql.orig/ndb/src/kernel/vm/Makefile.in 2007-12-14 21:45:59.000000000 +0100
  1161. +++ mysql/ndb/src/kernel/vm/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1162. @@ -227,6 +227,7 @@
  1163. LIBDL = @LIBDL@
  1164. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1165. LIBOBJS = @LIBOBJS@
  1166. +LIBRT = @LIBRT@
  1167. LIBS = @LIBS@
  1168. LIBTOOL = @LIBTOOL@
  1169. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1170. diff -Naur mysql.orig/ndb/src/Makefile.in mysql/ndb/src/Makefile.in
  1171. --- mysql.orig/ndb/src/Makefile.in 2007-12-14 21:45:42.000000000 +0100
  1172. +++ mysql/ndb/src/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1173. @@ -218,6 +218,7 @@
  1174. LIBDL = @LIBDL@
  1175. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1176. LIBOBJS = @LIBOBJS@
  1177. +LIBRT = @LIBRT@
  1178. LIBS = @LIBS@
  1179. LIBTOOL = @LIBTOOL@
  1180. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1181. diff -Naur mysql.orig/ndb/src/mgmapi/Makefile.in mysql/ndb/src/mgmapi/Makefile.in
  1182. --- mysql.orig/ndb/src/mgmapi/Makefile.in 2007-12-14 21:45:59.000000000 +0100
  1183. +++ mysql/ndb/src/mgmapi/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1184. @@ -224,6 +224,7 @@
  1185. LIBDL = @LIBDL@
  1186. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1187. LIBOBJS = @LIBOBJS@
  1188. +LIBRT = @LIBRT@
  1189. LIBS = @LIBS@
  1190. LIBTOOL = @LIBTOOL@
  1191. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1192. diff -Naur mysql.orig/ndb/src/mgmclient/Makefile.in mysql/ndb/src/mgmclient/Makefile.in
  1193. --- mysql.orig/ndb/src/mgmclient/Makefile.in 2007-12-14 21:46:00.000000000 +0100
  1194. +++ mysql/ndb/src/mgmclient/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1195. @@ -234,6 +234,7 @@
  1196. LIBDL = @LIBDL@
  1197. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1198. LIBOBJS = @LIBOBJS@
  1199. +LIBRT = @LIBRT@
  1200. LIBS = @LIBS@
  1201. LIBTOOL = @LIBTOOL@
  1202. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1203. diff -Naur mysql.orig/ndb/src/mgmsrv/Makefile.in mysql/ndb/src/mgmsrv/Makefile.in
  1204. --- mysql.orig/ndb/src/mgmsrv/Makefile.in 2007-12-14 21:46:00.000000000 +0100
  1205. +++ mysql/ndb/src/mgmsrv/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1206. @@ -230,6 +230,7 @@
  1207. LIBDL = @LIBDL@
  1208. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1209. LIBOBJS = @LIBOBJS@
  1210. +LIBRT = @LIBRT@
  1211. LIBS = @LIBS@
  1212. LIBTOOL = @LIBTOOL@
  1213. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1214. diff -Naur mysql.orig/ndb/src/ndbapi/Makefile.in mysql/ndb/src/ndbapi/Makefile.in
  1215. --- mysql.orig/ndb/src/ndbapi/Makefile.in 2007-12-14 21:46:01.000000000 +0100
  1216. +++ mysql/ndb/src/ndbapi/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1217. @@ -234,6 +234,7 @@
  1218. LIBDL = @LIBDL@
  1219. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1220. LIBOBJS = @LIBOBJS@
  1221. +LIBRT = @LIBRT@
  1222. LIBS = @LIBS@
  1223. LIBTOOL = @LIBTOOL@
  1224. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1225. diff -Naur mysql.orig/ndb/test/Makefile.in mysql/ndb/test/Makefile.in
  1226. --- mysql.orig/ndb/test/Makefile.in 2007-12-14 21:46:01.000000000 +0100
  1227. +++ mysql/ndb/test/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1228. @@ -174,6 +174,7 @@
  1229. LIBDL = @LIBDL@
  1230. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1231. LIBOBJS = @LIBOBJS@
  1232. +LIBRT = @LIBRT@
  1233. LIBS = @LIBS@
  1234. LIBTOOL = @LIBTOOL@
  1235. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1236. diff -Naur mysql.orig/ndb/test/ndbapi/bank/Makefile.in mysql/ndb/test/ndbapi/bank/Makefile.in
  1237. --- mysql.orig/ndb/test/ndbapi/bank/Makefile.in 2007-12-14 21:46:03.000000000 +0100
  1238. +++ mysql/ndb/test/ndbapi/bank/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1239. @@ -303,6 +303,7 @@
  1240. LIBDL = @LIBDL@
  1241. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1242. LIBOBJS = @LIBOBJS@
  1243. +LIBRT = @LIBRT@
  1244. LIBS = @LIBS@
  1245. LIBTOOL = @LIBTOOL@
  1246. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1247. diff -Naur mysql.orig/ndb/test/ndbapi/Makefile.in mysql/ndb/test/ndbapi/Makefile.in
  1248. --- mysql.orig/ndb/test/ndbapi/Makefile.in 2007-12-14 21:46:02.000000000 +0100
  1249. +++ mysql/ndb/test/ndbapi/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1250. @@ -611,6 +611,7 @@
  1251. LIBDL = @LIBDL@
  1252. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1253. LIBOBJS = @LIBOBJS@
  1254. +LIBRT = @LIBRT@
  1255. LIBS = @LIBS@
  1256. LIBTOOL = @LIBTOOL@
  1257. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1258. diff -Naur mysql.orig/ndb/test/run-test/Makefile.in mysql/ndb/test/run-test/Makefile.in
  1259. --- mysql.orig/ndb/test/run-test/Makefile.in 2007-12-14 21:46:04.000000000 +0100
  1260. +++ mysql/ndb/test/run-test/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1261. @@ -262,6 +262,7 @@
  1262. LIBDL = @LIBDL@
  1263. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1264. LIBOBJS = @LIBOBJS@
  1265. +LIBRT = @LIBRT@
  1266. LIBS = @LIBS@
  1267. LIBTOOL = @LIBTOOL@
  1268. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1269. diff -Naur mysql.orig/ndb/test/src/Makefile.in mysql/ndb/test/src/Makefile.in
  1270. --- mysql.orig/ndb/test/src/Makefile.in 2007-12-14 21:46:04.000000000 +0100
  1271. +++ mysql/ndb/test/src/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1272. @@ -232,6 +232,7 @@
  1273. LIBDL = @LIBDL@
  1274. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1275. LIBOBJS = @LIBOBJS@
  1276. +LIBRT = @LIBRT@
  1277. LIBS = @LIBS@
  1278. LIBTOOL = @LIBTOOL@
  1279. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1280. diff -Naur mysql.orig/ndb/test/tools/Makefile.in mysql/ndb/test/tools/Makefile.in
  1281. --- mysql.orig/ndb/test/tools/Makefile.in 2007-12-14 21:46:05.000000000 +0100
  1282. +++ mysql/ndb/test/tools/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1283. @@ -345,6 +345,7 @@
  1284. LIBDL = @LIBDL@
  1285. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1286. LIBOBJS = @LIBOBJS@
  1287. +LIBRT = @LIBRT@
  1288. LIBS = @LIBS@
  1289. LIBTOOL = @LIBTOOL@
  1290. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1291. diff -Naur mysql.orig/ndb/tools/Makefile.in mysql/ndb/tools/Makefile.in
  1292. --- mysql.orig/ndb/tools/Makefile.in 2007-12-14 21:46:06.000000000 +0100
  1293. +++ mysql/ndb/tools/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1294. @@ -331,6 +331,7 @@
  1295. LIBDL = @LIBDL@
  1296. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1297. LIBOBJS = @LIBOBJS@
  1298. +LIBRT = @LIBRT@
  1299. LIBS = @LIBS@
  1300. LIBTOOL = @LIBTOOL@
  1301. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1302. diff -Naur mysql.orig/netware/Makefile.in mysql/netware/Makefile.in
  1303. --- mysql.orig/netware/Makefile.in 2007-12-14 21:46:06.000000000 +0100
  1304. +++ mysql/netware/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1305. @@ -219,6 +219,7 @@
  1306. LIBDL = @LIBDL@
  1307. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1308. LIBOBJS = @LIBOBJS@
  1309. +LIBRT = @LIBRT@
  1310. LIBS = @LIBS@
  1311. LIBTOOL = @LIBTOOL@
  1312. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1313. diff -Naur mysql.orig/os2/include/Makefile.in mysql/os2/include/Makefile.in
  1314. --- mysql.orig/os2/include/Makefile.in 2007-12-14 21:46:07.000000000 +0100
  1315. +++ mysql/os2/include/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1316. @@ -174,6 +174,7 @@
  1317. LIBDL = @LIBDL@
  1318. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1319. LIBOBJS = @LIBOBJS@
  1320. +LIBRT = @LIBRT@
  1321. LIBS = @LIBS@
  1322. LIBTOOL = @LIBTOOL@
  1323. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1324. diff -Naur mysql.orig/os2/include/sys/Makefile.in mysql/os2/include/sys/Makefile.in
  1325. --- mysql.orig/os2/include/sys/Makefile.in 2007-12-14 21:46:07.000000000 +0100
  1326. +++ mysql/os2/include/sys/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1327. @@ -165,6 +165,7 @@
  1328. LIBDL = @LIBDL@
  1329. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1330. LIBOBJS = @LIBOBJS@
  1331. +LIBRT = @LIBRT@
  1332. LIBS = @LIBS@
  1333. LIBTOOL = @LIBTOOL@
  1334. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1335. diff -Naur mysql.orig/os2/Makefile.in mysql/os2/Makefile.in
  1336. --- mysql.orig/os2/Makefile.in 2007-12-14 21:46:06.000000000 +0100
  1337. +++ mysql/os2/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1338. @@ -174,6 +174,7 @@
  1339. LIBDL = @LIBDL@
  1340. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1341. LIBOBJS = @LIBOBJS@
  1342. +LIBRT = @LIBRT@
  1343. LIBS = @LIBS@
  1344. LIBTOOL = @LIBTOOL@
  1345. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1346. diff -Naur mysql.orig/patch_info/userstats.info mysql/patch_info/userstats.info
  1347. --- mysql.orig/patch_info/userstats.info 1970-01-01 01:00:00.000000000 +0100
  1348. +++ mysql/patch_info/userstats.info 2008-11-27 20:08:07.000000000 +0100
  1349. @@ -0,0 +1,6 @@
  1350. +File=userstatsv2.patch
  1351. +Name=SHOW USER/TABLE/INDEX statistics
  1352. +Version=V2
  1353. +Author=Google
  1354. +License=GPL
  1355. +Comment=Added INFORMATION_SCHEMA.*_STATISTICS
  1356. diff -Naur mysql.orig/pstack/aout/Makefile.in mysql/pstack/aout/Makefile.in
  1357. --- mysql.orig/pstack/aout/Makefile.in 2007-12-14 21:46:08.000000000 +0100
  1358. +++ mysql/pstack/aout/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1359. @@ -155,6 +155,7 @@
  1360. LIBDL = @LIBDL@
  1361. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1362. LIBOBJS = @LIBOBJS@
  1363. +LIBRT = @LIBRT@
  1364. LIBS = @LIBS@
  1365. LIBTOOL = @LIBTOOL@
  1366. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1367. diff -Naur mysql.orig/pstack/Makefile.in mysql/pstack/Makefile.in
  1368. --- mysql.orig/pstack/Makefile.in 2007-12-14 21:46:07.000000000 +0100
  1369. +++ mysql/pstack/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1370. @@ -213,6 +213,7 @@
  1371. LIBDL = @LIBDL@
  1372. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1373. LIBOBJS = @LIBOBJS@
  1374. +LIBRT = @LIBRT@
  1375. LIBS = @LIBS@
  1376. LIBTOOL = @LIBTOOL@
  1377. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1378. diff -Naur mysql.orig/regex/Makefile.in mysql/regex/Makefile.in
  1379. --- mysql.orig/regex/Makefile.in 2007-12-14 21:46:08.000000000 +0100
  1380. +++ mysql/regex/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1381. @@ -197,6 +197,7 @@
  1382. LIBDL = @LIBDL@
  1383. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1384. LIBOBJS = @LIBOBJS@
  1385. +LIBRT = @LIBRT@
  1386. LIBS = @LIBS@
  1387. LIBTOOL = @LIBTOOL@
  1388. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1389. diff -Naur mysql.orig/scripts/Makefile.in mysql/scripts/Makefile.in
  1390. --- mysql.orig/scripts/Makefile.in 2007-12-14 21:46:08.000000000 +0100
  1391. +++ mysql/scripts/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1392. @@ -196,6 +196,7 @@
  1393. LIBDL = @LIBDL@
  1394. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1395. LIBOBJS = @LIBOBJS@
  1396. +LIBRT = @LIBRT@
  1397. LIBS = @LIBS@
  1398. LIBTOOL = @LIBTOOL@
  1399. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1400. diff -Naur mysql.orig/server-tools/instance-manager/Makefile.in mysql/server-tools/instance-manager/Makefile.in
  1401. --- mysql.orig/server-tools/instance-manager/Makefile.in 2007-12-14 21:46:09.000000000 +0100
  1402. +++ mysql/server-tools/instance-manager/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1403. @@ -221,6 +221,7 @@
  1404. LIBDL = @LIBDL@
  1405. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1406. LIBOBJS = @LIBOBJS@
  1407. +LIBRT = @LIBRT@
  1408. LIBS = @LIBS@
  1409. LIBTOOL = @LIBTOOL@
  1410. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1411. diff -Naur mysql.orig/server-tools/Makefile.in mysql/server-tools/Makefile.in
  1412. --- mysql.orig/server-tools/Makefile.in 2007-12-14 21:46:09.000000000 +0100
  1413. +++ mysql/server-tools/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1414. @@ -173,6 +173,7 @@
  1415. LIBDL = @LIBDL@
  1416. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1417. LIBOBJS = @LIBOBJS@
  1418. +LIBRT = @LIBRT@
  1419. LIBS = @LIBS@
  1420. LIBTOOL = @LIBTOOL@
  1421. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1422. diff -Naur mysql.orig/sql/ha_innodb.cc mysql/sql/ha_innodb.cc
  1423. --- mysql.orig/sql/ha_innodb.cc 2007-12-14 21:43:42.000000000 +0100
  1424. +++ mysql/sql/ha_innodb.cc 2008-11-27 20:08:07.000000000 +0100
  1425. @@ -3286,6 +3286,8 @@
  1426.  
  1427. error = row_insert_for_mysql((byte*) record, prebuilt);
  1428.  
  1429. + if (error == DB_SUCCESS) rows_changed++;
  1430. +
  1431. if (error == DB_SUCCESS && auto_inc_used) {
  1432.  
  1433. /* Fetch the value that was set in the autoincrement field */
  1434. @@ -3558,6 +3560,8 @@
  1435. }
  1436. }
  1437.  
  1438. + if (error == DB_SUCCESS) rows_changed++;
  1439. +
  1440. innodb_srv_conc_exit_innodb(prebuilt->trx);
  1441.  
  1442. error = convert_error_code_to_mysql(error, user_thd);
  1443. @@ -3606,6 +3610,8 @@
  1444.  
  1445. error = row_update_for_mysql((byte*) record, prebuilt);
  1446.  
  1447. + if (error == DB_SUCCESS) rows_changed++;
  1448. +
  1449. innodb_srv_conc_exit_innodb(prebuilt->trx);
  1450.  
  1451. error = convert_error_code_to_mysql(error, user_thd);
  1452. @@ -4038,6 +4044,9 @@
  1453. if (ret == DB_SUCCESS) {
  1454. error = 0;
  1455. table->status = 0;
  1456. + rows_read++;
  1457. + if (active_index >= 0 && active_index < MAX_KEY)
  1458. + index_rows_read[active_index]++;
  1459.  
  1460. } else if (ret == DB_RECORD_NOT_FOUND) {
  1461. error = HA_ERR_END_OF_FILE;
  1462. diff -Naur mysql.orig/sql/ha_myisam.cc mysql/sql/ha_myisam.cc
  1463. --- mysql.orig/sql/ha_myisam.cc 2007-12-14 21:43:13.000000000 +0100
  1464. +++ mysql/sql/ha_myisam.cc 2008-11-27 20:08:07.000000000 +0100
  1465. @@ -670,7 +670,9 @@
  1466. if ((error= update_auto_increment()))
  1467. return error;
  1468. }
  1469. - return mi_write(file,buf);
  1470. + int error=mi_write(file,buf);
  1471. + if (!error) rows_changed++;
  1472. + return error;
  1473. }
  1474.  
  1475. int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
  1476. @@ -1518,13 +1520,17 @@
  1477. statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
  1478. if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
  1479. table->timestamp_field->set_time();
  1480. - return mi_update(file,old_data,new_data);
  1481. + int error=mi_update(file,old_data,new_data);
  1482. + if (!error) rows_changed++;
  1483. + return error;
  1484. }
  1485.  
  1486. int ha_myisam::delete_row(const byte * buf)
  1487. {
  1488. statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
  1489. - return mi_delete(file,buf);
  1490. + int error=mi_delete(file,buf);
  1491. + if (!error) rows_changed++;
  1492. + return error;
  1493. }
  1494.  
  1495. int ha_myisam::index_read(byte * buf, const byte * key,
  1496. @@ -1535,6 +1541,13 @@
  1497. &LOCK_status);
  1498. int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
  1499. table->status=error ? STATUS_NOT_FOUND: 0;
  1500. + if (!error) {
  1501. + rows_read++;
  1502. +
  1503. + int inx = (active_index == -1) ? file->lastinx : active_index;
  1504. + if (inx >= 0 && inx < MAX_KEY)
  1505. + index_rows_read[inx]++;
  1506. + }
  1507. return error;
  1508. }
  1509.  
  1510. @@ -1545,6 +1558,13 @@
  1511. &LOCK_status);
  1512. int error=mi_rkey(file,buf,index, key, key_len, find_flag);
  1513. table->status=error ? STATUS_NOT_FOUND: 0;
  1514. + if (!error) {
  1515. + rows_read++;
  1516. +
  1517. + int inx = index;
  1518. + if (inx >= 0 && inx < MAX_KEY)
  1519. + index_rows_read[inx]++;
  1520. + }
  1521. return error;
  1522. }
  1523.  
  1524. @@ -1555,6 +1575,13 @@
  1525. &LOCK_status);
  1526. int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
  1527. table->status=error ? STATUS_NOT_FOUND: 0;
  1528. + if (!error) {
  1529. + rows_read++;
  1530. +
  1531. + int inx = (active_index == -1) ? file->lastinx : active_index;
  1532. + if (inx >= 0 && inx < MAX_KEY)
  1533. + index_rows_read[inx]++;
  1534. + }
  1535. return error;
  1536. }
  1537.  
  1538. @@ -1565,6 +1592,13 @@
  1539. &LOCK_status);
  1540. int error=mi_rnext(file,buf,active_index);
  1541. table->status=error ? STATUS_NOT_FOUND: 0;
  1542. + if (!error) {
  1543. + rows_read++;
  1544. +
  1545. + int inx = (active_index == -1) ? file->lastinx : active_index;
  1546. + if (inx >= 0 && inx < MAX_KEY)
  1547. + index_rows_read[inx]++;
  1548. + }
  1549. return error;
  1550. }
  1551.  
  1552. @@ -1575,6 +1609,13 @@
  1553. &LOCK_status);
  1554. int error=mi_rprev(file,buf, active_index);
  1555. table->status=error ? STATUS_NOT_FOUND: 0;
  1556. + if (!error) {
  1557. + rows_read++;
  1558. +
  1559. + int inx = (active_index == -1) ? file->lastinx : active_index;
  1560. + if (inx >= 0 && inx < MAX_KEY)
  1561. + index_rows_read[inx]++;
  1562. + }
  1563. return error;
  1564. }
  1565.  
  1566. @@ -1585,6 +1626,13 @@
  1567. &LOCK_status);
  1568. int error=mi_rfirst(file, buf, active_index);
  1569. table->status=error ? STATUS_NOT_FOUND: 0;
  1570. + if (!error) {
  1571. + rows_read++;
  1572. +
  1573. + int inx = (active_index == -1) ? file->lastinx : active_index;
  1574. + if (inx >= 0 && inx < MAX_KEY)
  1575. + index_rows_read[inx]++;
  1576. + }
  1577. return error;
  1578. }
  1579.  
  1580. @@ -1595,6 +1643,13 @@
  1581. &LOCK_status);
  1582. int error=mi_rlast(file, buf, active_index);
  1583. table->status=error ? STATUS_NOT_FOUND: 0;
  1584. + if (!error) {
  1585. + rows_read++;
  1586. +
  1587. + int inx = (active_index == -1) ? file->lastinx : active_index;
  1588. + if (inx >= 0 && inx < MAX_KEY)
  1589. + index_rows_read[inx]++;
  1590. + }
  1591. return error;
  1592. }
  1593.  
  1594. @@ -1611,6 +1666,13 @@
  1595. error= mi_rnext_same(file,buf);
  1596. } while (error == HA_ERR_RECORD_DELETED);
  1597. table->status=error ? STATUS_NOT_FOUND: 0;
  1598. + if (!error) {
  1599. + rows_read++;
  1600. +
  1601. + int inx = (active_index == -1) ? file->lastinx : active_index;
  1602. + if (inx >= 0 && inx < MAX_KEY)
  1603. + index_rows_read[inx]++;
  1604. + }
  1605. return error;
  1606. }
  1607.  
  1608. @@ -1628,6 +1690,7 @@
  1609. &LOCK_status);
  1610. int error=mi_scan(file, buf);
  1611. table->status=error ? STATUS_NOT_FOUND: 0;
  1612. + if (!error) rows_read++;
  1613. return error;
  1614. }
  1615.  
  1616. @@ -1642,6 +1705,7 @@
  1617. &LOCK_status);
  1618. int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
  1619. table->status=error ? STATUS_NOT_FOUND: 0;
  1620. + if (!error) rows_read++;
  1621. return error;
  1622. }
  1623.  
  1624. diff -Naur mysql.orig/sql/handler.cc mysql/sql/handler.cc
  1625. --- mysql.orig/sql/handler.cc 2007-12-14 21:43:00.000000000 +0100
  1626. +++ mysql/sql/handler.cc 2008-11-27 20:08:07.000000000 +0100
  1627. @@ -20,6 +20,13 @@
  1628. #pragma implementation // gcc: Class implementation
  1629. #endif
  1630.  
  1631. +/*
  1632. + * Ugh. Something is fishy with the SAFE_MUTEX stuff in include/my_pthread.h.
  1633. + * This makes things compile with gcc 4.1
  1634. + */
  1635. +#include <string>
  1636. +
  1637. +
  1638. #include "mysql_priv.h"
  1639. #include "ha_heap.h"
  1640. #include "ha_myisam.h"
  1641. @@ -725,6 +732,8 @@
  1642. if (cookie)
  1643. tc_log->unlog(cookie, xid);
  1644. DBUG_EXECUTE_IF("crash_commit_after", abort(););
  1645. + if (is_real_trans)
  1646. + thd->diff_commit_trans++;
  1647. end:
  1648. if (is_real_trans)
  1649. start_waiting_global_read_lock(thd);
  1650. @@ -824,6 +833,7 @@
  1651. thd->transaction.cleanup();
  1652. }
  1653. }
  1654. + thd->diff_rollback_trans++;
  1655. #endif /* USING_TRANSACTIONS */
  1656. if (all)
  1657. thd->transaction_rollback_request= FALSE;
  1658. @@ -1207,6 +1217,7 @@
  1659. statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
  1660. *ht=0; // keep it conveniently zero-filled
  1661. }
  1662. + thd->diff_rollback_trans++;
  1663. DBUG_RETURN(error);
  1664. }
  1665.  
  1666. @@ -1429,6 +1440,8 @@
  1667. else
  1668. dupp_ref=ref+ALIGN_SIZE(ref_length);
  1669. }
  1670. + rows_read = rows_changed = 0;
  1671. + memset(index_rows_read, 0, sizeof(index_rows_read));
  1672. DBUG_RETURN(error);
  1673. }
  1674.  
  1675. @@ -2212,6 +2225,99 @@
  1676. return error;
  1677. }
  1678.  
  1679. +// Updates the global table stats with the TABLE this handler represents.
  1680. +void handler::update_global_table_stats() {
  1681. + if (!rows_read && !rows_changed) return; // Nothing to update.
  1682. + // table_cache_key is db_name + '\0' + table_name + '\0'.
  1683. + if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
  1684. +
  1685. + TABLE_STATS* table_stats;
  1686. + char key[NAME_LEN * 2 + 2];
  1687. + // [db] + '.' + [table]
  1688. + sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
  1689. +
  1690. + pthread_mutex_lock(&LOCK_global_table_stats);
  1691. + // Gets the global table stats, creating one if necessary.
  1692. + if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
  1693. + (byte*)key,
  1694. + strlen(key)))) {
  1695. + if (!(table_stats = ((TABLE_STATS*)
  1696. + my_malloc(sizeof(TABLE_STATS), MYF(MY_WME))))) {
  1697. + // Out of memory.
  1698. + sql_print_error("Allocating table stats failed.");
  1699. + goto end;
  1700. + }
  1701. + strncpy(table_stats->table, key, sizeof(table_stats->table));
  1702. + table_stats->rows_read = 0;
  1703. + table_stats->rows_changed = 0;
  1704. + table_stats->rows_changed_x_indexes = 0;
  1705. + table_stats->engine_type = (int) ht->db_type;
  1706. +
  1707. + if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
  1708. + // Out of memory.
  1709. + sql_print_error("Inserting table stats failed.");
  1710. + my_free((char*)table_stats, 0);
  1711. + goto end;
  1712. + }
  1713. + }
  1714. + // Updates the global table stats.
  1715. + table_stats->rows_read += rows_read;
  1716. + table_stats->rows_changed += rows_changed;
  1717. + table_stats->rows_changed_x_indexes +=
  1718. + rows_changed * (table->s->keys ? table->s->keys : 1);
  1719. + current_thd->diff_total_read_rows += rows_read;
  1720. + rows_read = rows_changed = 0;
  1721. +end:
  1722. + pthread_mutex_unlock(&LOCK_global_table_stats);
  1723. +}
  1724. +
  1725. +// Updates the global index stats with this handler's accumulated index reads.
  1726. +void handler::update_global_index_stats() {
  1727. + // table_cache_key is db_name + '\0' + table_name + '\0'.
  1728. + if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
  1729. +
  1730. + for (int x = 0; x < table->s->keys; x++) {
  1731. + if (index_rows_read[x]) {
  1732. + // Rows were read using this index.
  1733. + KEY* key_info = &table->key_info[x];
  1734. +
  1735. + if (!key_info->name) continue;
  1736. +
  1737. + INDEX_STATS* index_stats;
  1738. + char key[NAME_LEN * 3 + 3];
  1739. + // [db] + '.' + [table] + '.' + [index]
  1740. + sprintf(key, "%s.%s.%s", table->s->table_cache_key,
  1741. + table->s->table_name, key_info->name);
  1742. +
  1743. + pthread_mutex_lock(&LOCK_global_index_stats);
  1744. + // Gets the global index stats, creating one if necessary.
  1745. + if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
  1746. + (byte*)key,
  1747. + strlen(key)))) {
  1748. + if (!(index_stats = ((INDEX_STATS*)
  1749. + my_malloc(sizeof(INDEX_STATS), MYF(MY_WME))))) {
  1750. + // Out of memory.
  1751. + sql_print_error("Allocating index stats failed.");
  1752. + goto end;
  1753. + }
  1754. + strncpy(index_stats->index, key, sizeof(index_stats->index));
  1755. + index_stats->rows_read = 0;
  1756. +
  1757. + if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
  1758. + // Out of memory.
  1759. + sql_print_error("Inserting index stats failed.");
  1760. + my_free((char*)index_stats, 0);
  1761. + goto end;
  1762. + }
  1763. + }
  1764. + // Updates the global index stats.
  1765. + index_stats->rows_read += index_rows_read[x];
  1766. + index_rows_read[x] = 0;
  1767. +end:
  1768. + pthread_mutex_unlock(&LOCK_global_index_stats);
  1769. + }
  1770. + }
  1771. +}
  1772.  
  1773. /****************************************************************************
  1774. ** Some general functions that isn't in the handler class
  1775. diff -Naur mysql.orig/sql/handler.h mysql/sql/handler.h
  1776. --- mysql.orig/sql/handler.h 2007-12-14 21:43:15.000000000 +0100
  1777. +++ mysql/sql/handler.h 2008-11-27 20:08:07.000000000 +0100
  1778. @@ -32,6 +32,10 @@
  1779. #define USING_TRANSACTIONS
  1780. #endif
  1781.  
  1782. +#if MAX_KEY > 128
  1783. +#error MAX_KEY is too large. Values up to 128 are supported.
  1784. +#endif
  1785. +
  1786. // the following is for checking tables
  1787.  
  1788. #define HA_ADMIN_ALREADY_DONE 1
  1789. @@ -604,6 +608,9 @@
  1790. bool auto_increment_column_changed;
  1791. bool implicit_emptied; /* Can be !=0 only if HEAP */
  1792. const COND *pushed_cond;
  1793. + ulonglong rows_read;
  1794. + ulonglong rows_changed;
  1795. + ulonglong index_rows_read[MAX_KEY];
  1796.  
  1797. handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
  1798. ht(ht_arg),
  1799. @@ -615,8 +622,10 @@
  1800. ref_length(sizeof(my_off_t)), block_size(0),
  1801. raid_type(0), ft_handler(0), inited(NONE),
  1802. locked(FALSE), implicit_emptied(0),
  1803. - pushed_cond(NULL)
  1804. - {}
  1805. + pushed_cond(NULL), rows_read(0), rows_changed(0)
  1806. + {
  1807. + memset(index_rows_read, 0, sizeof(index_rows_read));
  1808. + }
  1809. virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
  1810. virtual handler *clone(MEM_ROOT *mem_root);
  1811. int ha_open(const char *name, int mode, int test_if_locked);
  1812. @@ -625,7 +634,11 @@
  1813. virtual void print_error(int error, myf errflag);
  1814. virtual bool get_error_message(int error, String *buf);
  1815. uint get_dup_key(int error);
  1816. - void change_table_ptr(TABLE *table_arg) { table=table_arg; }
  1817. + void change_table_ptr(TABLE *table_arg) {
  1818. + table=table_arg;
  1819. + rows_read = rows_changed = 0;
  1820. + memset(index_rows_read, 0, sizeof(index_rows_read));
  1821. + }
  1822. virtual double scan_time()
  1823. { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
  1824. virtual double read_time(uint index, uint ranges, ha_rows rows)
  1825. @@ -885,6 +898,9 @@
  1826. virtual bool is_crashed() const { return 0; }
  1827. virtual bool auto_repair() const { return 0; }
  1828.  
  1829. + void update_global_table_stats();
  1830. + void update_global_index_stats();
  1831. +
  1832. /*
  1833. default rename_table() and delete_table() rename/delete files with a
  1834. given name and extensions from bas_ext()
  1835. diff -Naur mysql.orig/sql/lex.h mysql/sql/lex.h
  1836. --- mysql.orig/sql/lex.h 2007-12-14 21:43:42.000000000 +0100
  1837. +++ mysql/sql/lex.h 2008-11-27 20:08:07.000000000 +0100
  1838. @@ -108,6 +108,7 @@
  1839. { "CHECKSUM", SYM(CHECKSUM_SYM)},
  1840. { "CIPHER", SYM(CIPHER_SYM)},
  1841. { "CLIENT", SYM(CLIENT_SYM)},
  1842. + { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
  1843. { "CLOSE", SYM(CLOSE_SYM)},
  1844. { "CODE", SYM(CODE_SYM)},
  1845. { "COLLATE", SYM(COLLATE_SYM)},
  1846. @@ -234,6 +235,7 @@
  1847. { "IN", SYM(IN_SYM)},
  1848. { "INDEX", SYM(INDEX_SYM)},
  1849. { "INDEXES", SYM(INDEXES)},
  1850. + { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
  1851. { "INFILE", SYM(INFILE)},
  1852. { "INNER", SYM(INNER_SYM)},
  1853. { "INNOBASE", SYM(INNOBASE_SYM)},
  1854. @@ -432,6 +434,7 @@
  1855. { "SIGNED", SYM(SIGNED_SYM)},
  1856. { "SIMPLE", SYM(SIMPLE_SYM)},
  1857. { "SLAVE", SYM(SLAVE)},
  1858. + { "SLOW", SYM(SLOW_SYM)},
  1859. { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
  1860. { "SMALLINT", SYM(SMALLINT)},
  1861. { "SOME", SYM(ANY_SYM)},
  1862. @@ -474,6 +477,7 @@
  1863. { "TABLE", SYM(TABLE_SYM)},
  1864. { "TABLES", SYM(TABLES)},
  1865. { "TABLESPACE", SYM(TABLESPACE)},
  1866. + { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
  1867. { "TEMPORARY", SYM(TEMPORARY)},
  1868. { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
  1869. { "TERMINATED", SYM(TERMINATED)},
  1870. @@ -511,6 +515,7 @@
  1871. { "USE", SYM(USE_SYM)},
  1872. { "USER", SYM(USER)},
  1873. { "USER_RESOURCES", SYM(RESOURCES)},
  1874. + { "USER_STATISTICS", SYM(USER_STATS_SYM)},
  1875. { "USE_FRM", SYM(USE_FRM)},
  1876. { "USING", SYM(USING)},
  1877. { "UTC_DATE", SYM(UTC_DATE_SYM)},
  1878. diff -Naur mysql.orig/sql/log.cc mysql/sql/log.cc
  1879. --- mysql.orig/sql/log.cc 2007-12-14 21:43:51.000000000 +0100
  1880. +++ mysql/sql/log.cc 2008-11-27 20:08:52.000000000 +0100
  1881. @@ -1708,18 +1708,24 @@
  1882. thd->current_insert_id);
  1883. if (e.write(file))
  1884. goto err;
  1885. + if (file == &log_file)
  1886. + thd->binlog_bytes_written += e.data_written;
  1887. }
  1888. if (thd->insert_id_used)
  1889. {
  1890. Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
  1891. if (e.write(file))
  1892. goto err;
  1893. + if (file == &log_file)
  1894. + thd->binlog_bytes_written += e.data_written;
  1895. }
  1896. if (thd->rand_used)
  1897. {
  1898. Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
  1899. if (e.write(file))
  1900. goto err;
  1901. + if (file == &log_file)
  1902. + thd->binlog_bytes_written += e.data_written;
  1903. }
  1904. if (thd->user_var_events.elements)
  1905. {
  1906. @@ -1735,6 +1741,8 @@
  1907. user_var_event->charset_number);
  1908. if (e.write(file))
  1909. goto err;
  1910. + if (file == &log_file)
  1911. + thd->binlog_bytes_written += e.data_written;
  1912. }
  1913. }
  1914. }
  1915. @@ -1745,6 +1753,8 @@
  1916.  
  1917. if (event_info->write(file))
  1918. goto err;
  1919. + if (file == &log_file)
  1920. + thd->binlog_bytes_written += event_info->data_written;
  1921.  
  1922. if (file == &log_file) // we are writing to the real log (disk)
  1923. {
  1924. @@ -1862,6 +1872,7 @@
  1925. */
  1926. if (qinfo.write(&log_file))
  1927. goto err;
  1928. + thd->binlog_bytes_written += qinfo.data_written;
  1929. }
  1930. /* Read from the file used to cache the queries .*/
  1931. if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
  1932. @@ -1908,6 +1919,7 @@
  1933. /* write the first half of the split header */
  1934. if (my_b_write(&log_file, header, carry))
  1935. goto err;
  1936. + thd->binlog_bytes_written += carry;
  1937.  
  1938. /*
  1939. copy fixed second half of header to cache so the correct
  1940. @@ -1976,6 +1988,8 @@
  1941. /* Write data to the binary log file */
  1942. if (my_b_write(&log_file, cache->read_pos, length))
  1943. goto err;
  1944. + thd->binlog_bytes_written += length;
  1945. +
  1946. cache->read_pos=cache->read_end; // Mark buffer used up
  1947. DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
  1948. } while ((length=my_b_fill(cache)));
  1949. @@ -1984,6 +1998,8 @@
  1950.  
  1951. if (commit_event->write(&log_file))
  1952. goto err;
  1953. + thd->binlog_bytes_written += commit_event->data_written;
  1954. +
  1955. #ifndef DBUG_OFF
  1956. DBUG_skip_commit:
  1957. #endif
  1958. diff -Naur mysql.orig/sql/Makefile.in mysql/sql/Makefile.in
  1959. --- mysql.orig/sql/Makefile.in 2007-12-14 21:46:10.000000000 +0100
  1960. +++ mysql/sql/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  1961. @@ -282,6 +282,7 @@
  1962. LIBDL = @LIBDL@
  1963. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  1964. LIBOBJS = @LIBOBJS@
  1965. +LIBRT = @LIBRT@
  1966. LIBS = @LIBS@
  1967. LIBTOOL = @LIBTOOL@
  1968. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  1969. diff -Naur mysql.orig/sql/mysqld.cc mysql/sql/mysqld.cc
  1970. --- mysql.orig/sql/mysqld.cc 2007-12-14 21:42:59.000000000 +0100
  1971. +++ mysql/sql/mysqld.cc 2008-11-27 20:08:07.000000000 +0100
  1972. @@ -438,6 +438,7 @@
  1973. ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
  1974. ulong max_connections, max_connect_errors;
  1975. uint max_user_connections= 0;
  1976. +ulonglong denied_connections = 0;
  1977. /*
  1978. Limit of the total number of prepared statements in the server.
  1979. Is necessary to protect the server against out-of-memory attacks.
  1980. @@ -537,6 +538,10 @@
  1981. LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
  1982. LOCK_global_system_variables,
  1983. LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
  1984. +pthread_mutex_t LOCK_stats;
  1985. +pthread_mutex_t LOCK_global_user_client_stats;
  1986. +pthread_mutex_t LOCK_global_table_stats;
  1987. +pthread_mutex_t LOCK_global_index_stats;
  1988. /*
  1989. The below lock protects access to two global server variables:
  1990. max_prepared_stmt_count and prepared_stmt_count. These variables
  1991. @@ -1184,6 +1189,10 @@
  1992. x_free(opt_secure_file_priv);
  1993. bitmap_free(&temp_pool);
  1994. free_max_user_conn();
  1995. + free_global_user_stats();
  1996. + free_global_client_stats();
  1997. + free_global_table_stats();
  1998. + free_global_index_stats();
  1999. #ifdef HAVE_REPLICATION
  2000. end_slave_list();
  2001. free_list(&replicate_do_db);
  2002. @@ -1298,6 +1307,10 @@
  2003. (void) pthread_cond_destroy(&COND_thread_cache);
  2004. (void) pthread_cond_destroy(&COND_flush_thread_cache);
  2005. (void) pthread_cond_destroy(&COND_manager);
  2006. + (void) pthread_mutex_destroy(&LOCK_stats);
  2007. + (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
  2008. + (void) pthread_mutex_destroy(&LOCK_global_table_stats);
  2009. + (void) pthread_mutex_destroy(&LOCK_global_index_stats);
  2010. }
  2011.  
  2012. #endif /*EMBEDDED_LIBRARY*/
  2013. @@ -3014,6 +3027,10 @@
  2014. (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
  2015. (void) pthread_cond_init(&COND_rpl_status, NULL);
  2016. #endif
  2017. + (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
  2018. + (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
  2019. + (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
  2020. + (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
  2021. sp_cache_init();
  2022. /* Parameter for threads created for connections */
  2023. (void) pthread_attr_init(&connection_attrib);
  2024. @@ -3285,6 +3302,10 @@
  2025. sql_print_error("Out of memory");
  2026. unireg_abort(1);
  2027. }
  2028. +
  2029. + init_global_table_stats();
  2030. + init_global_index_stats();
  2031. +
  2032. if (ha_init())
  2033. {
  2034. sql_print_error("Can't init databases");
  2035. @@ -3367,6 +3388,8 @@
  2036.  
  2037. init_max_user_conn();
  2038. init_update_queries();
  2039. + init_global_user_stats();
  2040. + init_global_client_stats();
  2041. DBUG_RETURN(0);
  2042. }
  2043.  
  2044. @@ -4053,6 +4076,7 @@
  2045. {
  2046. DBUG_PRINT("error",("Too many connections"));
  2047. close_connection(thd, ER_CON_COUNT_ERROR, 1);
  2048. + statistic_increment(denied_connections, &LOCK_status);
  2049. delete thd;
  2050. DBUG_VOID_RETURN;
  2051. }
  2052. diff -Naur mysql.orig/sql/mysql_priv.h mysql/sql/mysql_priv.h
  2053. --- mysql.orig/sql/mysql_priv.h 2007-12-14 21:43:41.000000000 +0100
  2054. +++ mysql/sql/mysql_priv.h 2008-11-27 20:08:07.000000000 +0100
  2055. @@ -725,7 +725,15 @@
  2056. bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
  2057. void init_max_user_conn(void);
  2058. void init_update_queries(void);
  2059. +void init_global_user_stats(void);
  2060. +void init_global_table_stats(void);
  2061. +void init_global_index_stats(void);
  2062. +void init_global_client_stats(void);
  2063. void free_max_user_conn(void);
  2064. +void free_global_user_stats(void);
  2065. +void free_global_table_stats(void);
  2066. +void free_global_index_stats(void);
  2067. +void free_global_client_stats(void);
  2068. pthread_handler_t handle_one_connection(void *arg);
  2069. pthread_handler_t handle_bootstrap(void *arg);
  2070. void end_thread(THD *thd,bool put_in_cache);
  2071. @@ -1291,6 +1299,7 @@
  2072. extern ulong max_connections,max_connect_errors, connect_timeout;
  2073. extern ulong slave_net_timeout, slave_trans_retries;
  2074. extern uint max_user_connections;
  2075. +extern ulonglong denied_connections;
  2076. extern ulong what_to_log,flush_time;
  2077. extern ulong query_buff_size, thread_stack;
  2078. extern ulong max_prepared_stmt_count, prepared_stmt_count;
  2079. @@ -1363,6 +1372,14 @@
  2080. extern struct system_variables max_system_variables;
  2081. extern struct system_status_var global_status_var;
  2082. extern struct rand_struct sql_rand;
  2083. +extern HASH global_user_stats;
  2084. +extern HASH global_client_stats;
  2085. +extern pthread_mutex_t LOCK_global_user_client_stats;
  2086. +extern HASH global_table_stats;
  2087. +extern pthread_mutex_t LOCK_global_table_stats;
  2088. +extern HASH global_index_stats;
  2089. +extern pthread_mutex_t LOCK_global_index_stats;
  2090. +extern pthread_mutex_t LOCK_stats;
  2091.  
  2092. extern const char *opt_date_time_formats[];
  2093. extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
  2094. diff -Naur mysql.orig/sql/share/Makefile.in mysql/sql/share/Makefile.in
  2095. --- mysql.orig/sql/share/Makefile.in 2007-12-14 21:46:10.000000000 +0100
  2096. +++ mysql/sql/share/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  2097. @@ -165,6 +165,7 @@
  2098. LIBDL = @LIBDL@
  2099. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  2100. LIBOBJS = @LIBOBJS@
  2101. +LIBRT = @LIBRT@
  2102. LIBS = @LIBS@
  2103. LIBTOOL = @LIBTOOL@
  2104. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  2105. diff -Naur mysql.orig/sql/sql_base.cc mysql/sql/sql_base.cc
  2106. --- mysql.orig/sql/sql_base.cc 2007-12-14 21:43:00.000000000 +0100
  2107. +++ mysql/sql/sql_base.cc 2008-11-27 20:08:07.000000000 +0100
  2108. @@ -624,6 +624,12 @@
  2109. DBUG_ENTER("close_thread_table");
  2110. DBUG_ASSERT(table->key_read == 0);
  2111. DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
  2112. +
  2113. + if(table->file)
  2114. + {
  2115. + table->file->update_global_table_stats();
  2116. + table->file->update_global_index_stats();
  2117. + }
  2118.  
  2119. *table_ptr=table->next;
  2120. if (table->needs_reopen_or_name_lock() ||
  2121. @@ -670,6 +676,9 @@
  2122. {
  2123. DBUG_ENTER("close_temporary");
  2124. char path[FN_REFLEN];
  2125. +
  2126. + table->file->update_global_table_stats();
  2127. + table->file->update_global_index_stats();
  2128. db_type table_type=table->s->db_type;
  2129. strmov(path,table->s->path);
  2130. free_io_cache(table);
  2131. diff -Naur mysql.orig/sql/sql_class.cc mysql/sql/sql_class.cc
  2132. --- mysql.orig/sql/sql_class.cc 2007-12-14 21:43:42.000000000 +0100
  2133. +++ mysql/sql/sql_class.cc 2008-11-27 20:08:07.000000000 +0100
  2134. @@ -221,6 +221,12 @@
  2135. bzero(ha_data, sizeof(ha_data));
  2136. mysys_var=0;
  2137. binlog_evt_union.do_union= FALSE;
  2138. + busy_time = 0;
  2139. + cpu_time = 0;
  2140. + bytes_received = 0;
  2141. + bytes_sent = 0;
  2142. + binlog_bytes_written = 0;
  2143. + updated_row_count = 0;
  2144. #ifndef DBUG_OFF
  2145. dbug_sentry=THD_SENTRY_MAGIC;
  2146. #endif
  2147. @@ -351,6 +357,86 @@
  2148. total_warn_count= 0;
  2149. update_charset();
  2150. bzero((char *) &status_var, sizeof(status_var));
  2151. + reset_stats();
  2152. +}
  2153. +
  2154. +// Resets stats in a THD.
  2155. +void THD::reset_stats(void) {
  2156. + current_connect_time = time(NULL);
  2157. + last_global_update_time = current_connect_time;
  2158. + reset_diff_stats();
  2159. +}
  2160. +
  2161. +// Resets the 'diff' stats, which are used to update global stats.
  2162. +void THD::reset_diff_stats(void) {
  2163. + diff_total_busy_time = 0;
  2164. + diff_total_cpu_time = 0;
  2165. + diff_total_bytes_received = 0;
  2166. + diff_total_bytes_sent = 0;
  2167. + diff_total_binlog_bytes_written = 0;
  2168. + diff_total_sent_rows = 0;
  2169. + diff_total_updated_rows = 0;
  2170. + diff_total_read_rows = 0;
  2171. + diff_select_commands = 0;
  2172. + diff_update_commands = 0;
  2173. + diff_other_commands = 0;
  2174. + diff_commit_trans = 0;
  2175. + diff_rollback_trans = 0;
  2176. + diff_denied_connections = 0;
  2177. + diff_lost_connections = 0;
  2178. + diff_access_denied_errors = 0;
  2179. + diff_empty_queries = 0;
  2180. +}
  2181. +
  2182. +// Updates 'diff' stats of a THD.
  2183. +void THD::update_stats(bool ran_command) {
  2184. + diff_total_busy_time += busy_time;
  2185. + diff_total_cpu_time += cpu_time;
  2186. + diff_total_bytes_received += bytes_received;
  2187. + diff_total_bytes_sent += bytes_sent;
  2188. + diff_total_binlog_bytes_written += binlog_bytes_written;
  2189. + diff_total_sent_rows += sent_row_count;
  2190. + diff_total_updated_rows += updated_row_count;
  2191. + // diff_total_read_rows is updated in handler.cc.
  2192. +
  2193. + if (ran_command) {
  2194. + // The replication thread has the COM_CONNECT command.
  2195. + if ((old_command == COM_QUERY || command == COM_CONNECT) &&
  2196. + (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
  2197. + // A SQL query.
  2198. + if (lex->sql_command == SQLCOM_SELECT) {
  2199. + if (lex->orig_sql_command == SQLCOM_END) {
  2200. + diff_select_commands++;
  2201. + if (!sent_row_count)
  2202. + diff_empty_queries++;
  2203. + } else {
  2204. + // 'SHOW ' commands become SQLCOM_SELECT.
  2205. + diff_other_commands++;
  2206. + // 'SHOW ' commands shouldn't inflate total sent row count.
  2207. + diff_total_sent_rows -= sent_row_count;
  2208. + }
  2209. + } else if (is_update_query(lex->sql_command)) {
  2210. + diff_update_commands++;
  2211. + } else {
  2212. + diff_other_commands++;
  2213. + }
  2214. + }
  2215. + }
  2216. + // diff_commit_trans is updated in handler.cc.
  2217. + // diff_rollback_trans is updated in handler.cc.
  2218. + // diff_denied_connections is updated in sql_parse.cc.
  2219. + // diff_lost_connections is updated in sql_parse.cc.
  2220. + // diff_access_denied_errors is updated in sql_parse.cc.
  2221. +
  2222. + /* reset counters to zero to avoid double-counting since values
  2223. + are already store in diff_total_*. */
  2224. + busy_time = 0;
  2225. + cpu_time = 0;
  2226. + bytes_received = 0;
  2227. + bytes_sent = 0;
  2228. + binlog_bytes_written = 0;
  2229. + sent_row_count = 0;
  2230. + updated_row_count = 0;
  2231. }
  2232.  
  2233.  
  2234. @@ -390,6 +476,9 @@
  2235.  
  2236. void THD::change_user(void)
  2237. {
  2238. + pthread_mutex_lock(&LOCK_status);
  2239. + add_to_status(&global_status_var, &status_var);
  2240. + pthread_mutex_unlock(&LOCK_status);
  2241. cleanup();
  2242. cleanup_done= 0;
  2243. init();
  2244. @@ -867,6 +956,33 @@
  2245. }
  2246. #endif
  2247.  
  2248. +char *THD::get_client_host_port(THD *client)
  2249. +{
  2250. + Security_context *client_sctx= client->security_ctx;
  2251. + char *client_host= NULL;
  2252. +
  2253. + if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
  2254. + security_ctx->host_or_ip[0])
  2255. + {
  2256. + if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
  2257. + my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
  2258. + "%s:%u", client_sctx->host_or_ip, client->peer_port);
  2259. + }
  2260. + else
  2261. + client_host= this->strdup(client_sctx->host_or_ip[0] ?
  2262. + client_sctx->host_or_ip :
  2263. + client_sctx->host ? client_sctx->host : "");
  2264. +
  2265. + return client_host;
  2266. +}
  2267. +
  2268. +const char *get_client_host(THD *client)
  2269. +{
  2270. + return client->security_ctx->host_or_ip[0] ?
  2271. + client->security_ctx->host_or_ip :
  2272. + client->security_ctx->host ? client->security_ctx->host : "";
  2273. +}
  2274. +
  2275.  
  2276. struct Item_change_record: public ilink
  2277. {
  2278. @@ -2053,6 +2169,7 @@
  2279. if (likely(thd != 0))
  2280. { /* current_thd==0 when close_connection() calls net_send_error() */
  2281. thd->status_var.bytes_sent+= length;
  2282. + thd->bytes_sent+= length;
  2283. }
  2284. }
  2285.  
  2286. @@ -2060,6 +2177,7 @@
  2287. void thd_increment_bytes_received(ulong length)
  2288. {
  2289. current_thd->status_var.bytes_received+= length;
  2290. + current_thd->bytes_received+= length;
  2291. }
  2292.  
  2293.  
  2294. diff -Naur mysql.orig/sql/sql_class.h mysql/sql/sql_class.h
  2295. --- mysql.orig/sql/sql_class.h 2007-12-14 21:43:41.000000000 +0100
  2296. +++ mysql/sql/sql_class.h 2008-11-27 20:08:07.000000000 +0100
  2297. @@ -1263,6 +1263,8 @@
  2298. first byte of the packet in do_command()
  2299. */
  2300. enum enum_server_command command;
  2301. + // Used to save the command, before it is set to COM_SLEEP.
  2302. + enum enum_server_command old_command;
  2303. uint32 server_id;
  2304. uint32 file_id; // for LOAD DATA INFILE
  2305. /*
  2306. @@ -1434,6 +1436,7 @@
  2307. /* variables.transaction_isolation is reset to this after each commit */
  2308. enum_tx_isolation session_tx_isolation;
  2309. enum_check_fields count_cuted_fields;
  2310. + ha_rows updated_row_count;
  2311.  
  2312. DYNAMIC_ARRAY user_var_events; /* For user variables replication */
  2313. MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
  2314. @@ -1540,6 +1543,49 @@
  2315. */
  2316. LOG_INFO* current_linfo;
  2317. NET* slave_net; // network connection from slave -> m.
  2318. +
  2319. + /*
  2320. + Used to update global user stats. The global user stats are updated
  2321. + occasionally with the 'diff' variables. After the update, the 'diff'
  2322. + variables are reset to 0.
  2323. + */
  2324. + // Time when the current thread connected to MySQL.
  2325. + time_t current_connect_time;
  2326. + // Last time when THD stats were updated in global_user_stats.
  2327. + time_t last_global_update_time;
  2328. + // Busy (non-idle) time for just one command.
  2329. + double busy_time;
  2330. + // Busy time not updated in global_user_stats yet.
  2331. + double diff_total_busy_time;
  2332. + // Cpu (non-idle) time for just one thread.
  2333. + double cpu_time;
  2334. + // Cpu time not updated in global_user_stats yet.
  2335. + double diff_total_cpu_time;
  2336. + /* bytes counting */
  2337. + ulonglong bytes_received;
  2338. + ulonglong diff_total_bytes_received;
  2339. + ulonglong bytes_sent;
  2340. + ulonglong diff_total_bytes_sent;
  2341. + ulonglong binlog_bytes_written;
  2342. + ulonglong diff_total_binlog_bytes_written;
  2343. +
  2344. + // Number of rows not reflected in global_user_stats yet.
  2345. + ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
  2346. + // Number of commands not reflected in global_user_stats yet.
  2347. + ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
  2348. + // Number of transactions not reflected in global_user_stats yet.
  2349. + ulonglong diff_commit_trans, diff_rollback_trans;
  2350. + // Number of connection errors not reflected in global_user_stats yet.
  2351. + ulonglong diff_denied_connections, diff_lost_connections;
  2352. + // Number of db access denied, not reflected in global_user_stats yet.
  2353. + ulonglong diff_access_denied_errors;
  2354. + // Number of queries that return 0 rows
  2355. + ulonglong diff_empty_queries;
  2356. +
  2357. + // Per account query delay in miliseconds. When not 0, sleep this number of
  2358. + // milliseconds before every SQL command.
  2359. + ulonglong query_delay_millis;
  2360. +
  2361. /* Used by the sys_var class to store temporary values */
  2362. union
  2363. {
  2364. @@ -1597,6 +1643,11 @@
  2365. alloc_root.
  2366. */
  2367. void init_for_queries();
  2368. + void reset_stats(void);
  2369. + void reset_diff_stats(void);
  2370. + // ran_command is true when this is called immediately after a
  2371. + // command has been run.
  2372. + void update_stats(bool ran_command);
  2373. void change_user(void);
  2374. void cleanup(void);
  2375. void cleanup_after_query();
  2376. @@ -1826,8 +1877,14 @@
  2377. if (p_db_length)
  2378. *p_db_length= db_length;
  2379. return FALSE;
  2380. +
  2381. + // Returns string as 'IP:port' for the client-side of the connnection represented
  2382. + // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
  2383. + // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
  2384. }
  2385.  
  2386. + char *get_client_host_port(THD *client);
  2387. +
  2388. public:
  2389. /**
  2390. Add an internal error handler to the thread execution context.
  2391. @@ -1870,6 +1927,11 @@
  2392. MEM_ROOT main_mem_root;
  2393. };
  2394.  
  2395. +// Returns string as 'IP' for the client-side of the connection represented by
  2396. +// 'client'. Does not allocate memory. May return "".
  2397. +const char *get_client_host(THD *client);
  2398. +
  2399. +#define LIST_PROCESS_HOST_LEN 64
  2400.  
  2401. #define tmp_disable_binlog(A) \
  2402. {ulonglong tmp_disable_binlog__save_options= (A)->options; \
  2403. diff -Naur mysql.orig/sql/sql_delete.cc mysql/sql/sql_delete.cc
  2404. --- mysql.orig/sql/sql_delete.cc 2007-12-14 21:43:51.000000000 +0100
  2405. +++ mysql/sql/sql_delete.cc 2008-11-27 20:08:07.000000000 +0100
  2406. @@ -353,6 +353,7 @@
  2407. send_ok(thd,deleted);
  2408. DBUG_PRINT("info",("%ld records deleted",(long) deleted));
  2409. }
  2410. + thd->updated_row_count += deleted;
  2411. DBUG_RETURN(error >= 0 || thd->net.report_error);
  2412. }
  2413.  
  2414. @@ -868,6 +869,7 @@
  2415. thd->row_count_func= deleted;
  2416. ::send_ok(thd, deleted);
  2417. }
  2418. + thd->updated_row_count += deleted;
  2419. return 0;
  2420. }
  2421.  
  2422. diff -Naur mysql.orig/sql/sql_insert.cc mysql/sql/sql_insert.cc
  2423. --- mysql.orig/sql/sql_insert.cc 2007-12-14 21:42:41.000000000 +0100
  2424. +++ mysql/sql/sql_insert.cc 2008-11-27 20:08:07.000000000 +0100
  2425. @@ -978,6 +978,7 @@
  2426. thd->row_count_func= info.copied + info.deleted + updated;
  2427. ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
  2428. }
  2429. + thd->updated_row_count += thd->row_count_func;
  2430. thd->abort_on_warning= 0;
  2431. DBUG_RETURN(FALSE);
  2432.  
  2433. @@ -3007,6 +3008,7 @@
  2434. id= autoinc_value_of_first_inserted_row > 0 ?
  2435. autoinc_value_of_first_inserted_row : thd->last_insert_id;
  2436. ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
  2437. + thd->updated_row_count += thd->row_count_func;
  2438. DBUG_RETURN(0);
  2439. }
  2440.  
  2441. diff -Naur mysql.orig/sql/sql_lex.h mysql/sql/sql_lex.h
  2442. --- mysql.orig/sql/sql_lex.h 2007-12-14 21:42:51.000000000 +0100
  2443. +++ mysql/sql/sql_lex.h 2008-11-27 20:08:07.000000000 +0100
  2444. @@ -94,6 +94,9 @@
  2445. SQLCOM_XA_START, SQLCOM_XA_END, SQLCOM_XA_PREPARE,
  2446. SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
  2447. SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
  2448. + // TODO(mcallaghan): update status_vars in mysqld to export these
  2449. + SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
  2450. + SQLCOM_SHOW_CLIENT_STATS,
  2451. /* This should be the last !!! */
  2452.  
  2453. SQLCOM_END
  2454. diff -Naur mysql.orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
  2455. --- mysql.orig/sql/sql_parse.cc 2007-12-14 21:43:41.000000000 +0100
  2456. +++ mysql/sql/sql_parse.cc 2008-11-27 20:08:07.000000000 +0100
  2457. @@ -77,6 +77,12 @@
  2458. const char *table_name);
  2459. static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
  2460.  
  2461. +// Increments connection count for user.
  2462. +static int increment_connection_count(THD* thd, bool use_lock);
  2463. +
  2464. +// Uses the THD to update the global stats by user name and client IP
  2465. +static void update_global_user_stats(THD* thd, bool create_user, time_t now);
  2466. +
  2467. const char *any_db="*any*"; // Special symbol for check_access
  2468.  
  2469. const char *command_name[]={
  2470. @@ -97,6 +103,17 @@
  2471. static bool do_command(THD *thd);
  2472. #endif // EMBEDDED_LIBRARY
  2473.  
  2474. +HASH global_user_stats;
  2475. +HASH global_client_stats;
  2476. +// Protects global_user_stats and global_client_stats
  2477. +extern pthread_mutex_t LOCK_global_user_client_stats;
  2478. +
  2479. +HASH global_table_stats;
  2480. +extern pthread_mutex_t LOCK_global_table_stats;
  2481. +
  2482. +HASH global_index_stats;
  2483. +extern pthread_mutex_t LOCK_global_index_stats;
  2484. +
  2485. #ifdef __WIN__
  2486. static void test_signal(int sig_ptr)
  2487. {
  2488. @@ -470,6 +487,7 @@
  2489. mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
  2490. DBUG_RETURN(-1);
  2491. }
  2492. + thd->diff_access_denied_errors++;
  2493. net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
  2494. thd->main_security_ctx.user,
  2495. thd->main_security_ctx.host_or_ip,
  2496. @@ -502,13 +520,191 @@
  2497. void init_max_user_conn(void)
  2498. {
  2499. #ifndef NO_EMBEDDED_ACCESS_CHECKS
  2500. - (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
  2501. - 0,0,
  2502. - (hash_get_key) get_key_conn, (hash_free_key) free_user,
  2503. - 0);
  2504. + if (hash_init(&hash_user_connections,system_charset_info,max_connections,
  2505. + 0,0,
  2506. + (hash_get_key) get_key_conn, (hash_free_key) free_user,
  2507. + 0)) {
  2508. + sql_print_error("Initializing hash_user_connections failed.");
  2509. + exit(1);
  2510. + }
  2511. #endif
  2512. }
  2513.  
  2514. +byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
  2515. + my_bool not_used __attribute__((unused)))
  2516. +{
  2517. + *length = strlen(user_stats->user);
  2518. + return (byte*)user_stats->user;
  2519. +}
  2520. +
  2521. +void free_user_stats(USER_STATS* user_stats)
  2522. +{
  2523. + my_free((char*)user_stats, MYF(0));
  2524. +}
  2525. +
  2526. +void init_user_stats(USER_STATS *user_stats,
  2527. + const char *user,
  2528. + const char *priv_user,
  2529. + uint total_connections,
  2530. + uint concurrent_connections,
  2531. + time_t connected_time,
  2532. + double busy_time,
  2533. + double cpu_time,
  2534. + ulonglong bytes_received,
  2535. + ulonglong bytes_sent,
  2536. + ulonglong binlog_bytes_written,
  2537. + ha_rows rows_fetched,
  2538. + ha_rows rows_updated,
  2539. + ha_rows rows_read,
  2540. + ulonglong select_commands,
  2541. + ulonglong update_commands,
  2542. + ulonglong other_commands,
  2543. + ulonglong commit_trans,
  2544. + ulonglong rollback_trans,
  2545. + ulonglong denied_connections,
  2546. + ulonglong lost_connections,
  2547. + ulonglong access_denied_errors,
  2548. + ulonglong empty_queries)
  2549. +{
  2550. + DBUG_ENTER("init_user_stats");
  2551. + DBUG_PRINT("info",
  2552. + ("Add user_stats entry for user %s - priv_user %s",
  2553. + user, priv_user));
  2554. + strncpy(user_stats->user, user, sizeof(user_stats->user));
  2555. + strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
  2556. +
  2557. + user_stats->total_connections = total_connections;
  2558. + user_stats->concurrent_connections = concurrent_connections;
  2559. + user_stats->connected_time = connected_time;
  2560. + user_stats->busy_time = busy_time;
  2561. + user_stats->cpu_time = cpu_time;
  2562. + user_stats->bytes_received = bytes_received;
  2563. + user_stats->bytes_sent = bytes_sent;
  2564. + user_stats->binlog_bytes_written = binlog_bytes_written;
  2565. + user_stats->rows_fetched = rows_fetched;
  2566. + user_stats->rows_updated = rows_updated;
  2567. + user_stats->rows_read = rows_read;
  2568. + user_stats->select_commands = select_commands;
  2569. + user_stats->update_commands = update_commands;
  2570. + user_stats->other_commands = other_commands;
  2571. + user_stats->commit_trans = commit_trans;
  2572. + user_stats->rollback_trans = rollback_trans;
  2573. + user_stats->denied_connections = denied_connections;
  2574. + user_stats->lost_connections = lost_connections;
  2575. + user_stats->access_denied_errors = access_denied_errors;
  2576. + user_stats->empty_queries = empty_queries;
  2577. + DBUG_VOID_RETURN;
  2578. +}
  2579. +
  2580. +void add_user_stats(USER_STATS *user_stats,
  2581. + uint total_connections,
  2582. + uint concurrent_connections,
  2583. + time_t connected_time,
  2584. + double busy_time,
  2585. + double cpu_time,
  2586. + ulonglong bytes_received,
  2587. + ulonglong bytes_sent,
  2588. + ulonglong binlog_bytes_written,
  2589. + ha_rows rows_fetched,
  2590. + ha_rows rows_updated,
  2591. + ha_rows rows_read,
  2592. + ulonglong select_commands,
  2593. + ulonglong update_commands,
  2594. + ulonglong other_commands,
  2595. + ulonglong commit_trans,
  2596. + ulonglong rollback_trans,
  2597. + ulonglong denied_connections,
  2598. + ulonglong lost_connections,
  2599. + ulonglong access_denied_errors,
  2600. + ulonglong empty_queries)
  2601. +{
  2602. + user_stats->total_connections += total_connections;
  2603. + user_stats->concurrent_connections += concurrent_connections;
  2604. + user_stats->connected_time += connected_time;
  2605. + user_stats->busy_time += busy_time;
  2606. + user_stats->cpu_time += cpu_time;
  2607. + user_stats->bytes_received += bytes_received;
  2608. + user_stats->bytes_sent += bytes_sent;
  2609. + user_stats->binlog_bytes_written += binlog_bytes_written;
  2610. + user_stats->rows_fetched += rows_fetched;
  2611. + user_stats->rows_updated += rows_updated;
  2612. + user_stats->rows_read += rows_read;
  2613. + user_stats->select_commands += select_commands;
  2614. + user_stats->update_commands += update_commands;
  2615. + user_stats->other_commands += other_commands;
  2616. + user_stats->commit_trans += commit_trans;
  2617. + user_stats->rollback_trans += rollback_trans;
  2618. + user_stats->denied_connections += denied_connections;
  2619. + user_stats->lost_connections += lost_connections;
  2620. + user_stats->access_denied_errors += access_denied_errors;
  2621. + user_stats->empty_queries += empty_queries;
  2622. +}
  2623. +
  2624. +void init_global_user_stats(void)
  2625. +{
  2626. + if (hash_init(&global_user_stats, system_charset_info, max_connections,
  2627. + 0, 0, (hash_get_key)get_key_user_stats,
  2628. + (hash_free_key)free_user_stats, 0)) {
  2629. + sql_print_error("Initializing global_user_stats failed.");
  2630. + exit(1);
  2631. + }
  2632. +}
  2633. +
  2634. +void init_global_client_stats(void)
  2635. +{
  2636. + if (hash_init(&global_client_stats, system_charset_info, max_connections,
  2637. + 0, 0, (hash_get_key)get_key_user_stats,
  2638. + (hash_free_key)free_user_stats, 0)) {
  2639. + sql_print_error("Initializing global_client_stats failed.");
  2640. + exit(1);
  2641. + }
  2642. +}
  2643. +
  2644. +extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
  2645. + my_bool not_used __attribute__((unused)))
  2646. +{
  2647. + *length = strlen(table_stats->table);
  2648. + return (byte*)table_stats->table;
  2649. +}
  2650. +
  2651. +extern "C" void free_table_stats(TABLE_STATS* table_stats)
  2652. +{
  2653. + my_free((char*)table_stats, MYF(0));
  2654. +}
  2655. +
  2656. +void init_global_table_stats(void)
  2657. +{
  2658. + if (hash_init(&global_table_stats, system_charset_info, max_connections,
  2659. + 0, 0, (hash_get_key)get_key_table_stats,
  2660. + (hash_free_key)free_table_stats, 0)) {
  2661. + sql_print_error("Initializing global_table_stats failed.");
  2662. + exit(1);
  2663. + }
  2664. +}
  2665. +
  2666. +extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
  2667. + my_bool not_used __attribute__((unused)))
  2668. +{
  2669. + *length = strlen(index_stats->index);
  2670. + return (byte*)index_stats->index;
  2671. +}
  2672. +
  2673. +extern "C" void free_index_stats(INDEX_STATS* index_stats)
  2674. +{
  2675. + my_free((char*)index_stats, MYF(0));
  2676. +}
  2677. +
  2678. +void init_global_index_stats(void)
  2679. +{
  2680. + if (hash_init(&global_index_stats, system_charset_info, max_connections,
  2681. + 0, 0, (hash_get_key)get_key_index_stats,
  2682. + (hash_free_key)free_index_stats, 0)) {
  2683. + sql_print_error("Initializing global_index_stats failed.");
  2684. + exit(1);
  2685. + }
  2686. +}
  2687. +
  2688. +
  2689.  
  2690. /*
  2691. check if user has already too many connections
  2692. @@ -565,7 +761,10 @@
  2693.  
  2694. end:
  2695. if (error)
  2696. + {
  2697. + statistic_increment(denied_connections, &LOCK_status);
  2698. uc->connections--; // no need for decrease_user_connections() here
  2699. + }
  2700. (void) pthread_mutex_unlock(&LOCK_user_conn);
  2701. DBUG_RETURN(error);
  2702. }
  2703. @@ -612,6 +811,25 @@
  2704. #endif /* NO_EMBEDDED_ACCESS_CHECKS */
  2705. }
  2706.  
  2707. +void free_global_user_stats(void)
  2708. +{
  2709. + hash_free(&global_user_stats);
  2710. +}
  2711. +
  2712. +void free_global_table_stats(void)
  2713. +{
  2714. + hash_free(&global_table_stats);
  2715. +}
  2716. +
  2717. +void free_global_index_stats(void)
  2718. +{
  2719. + hash_free(&global_index_stats);
  2720. +}
  2721. +
  2722. +void free_global_client_stats(void)
  2723. +{
  2724. + hash_free(&global_client_stats);
  2725. +}
  2726.  
  2727.  
  2728. /*
  2729. @@ -664,6 +882,207 @@
  2730. return uc_update_queries[command] != 0;
  2731. }
  2732.  
  2733. +// 'mysql_system_user' is used for when the user is not defined for a THD.
  2734. +static char mysql_system_user[] = "#mysql_system#";
  2735. +
  2736. +// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
  2737. +static char* get_valid_user_string(char* user) {
  2738. + return user ? user : mysql_system_user;
  2739. +}
  2740. +
  2741. +// Increments the global stats connection count for an entry from
  2742. +// global_client_stats or global_user_stats. Returns 0 on success
  2743. +// and 1 on error.
  2744. +static int increment_count_by_name(const char *name, const char *role_name,
  2745. + HASH *users_or_clients, THD *thd)
  2746. +{
  2747. + USER_STATS* user_stats;
  2748. +
  2749. + if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
  2750. + strlen(name))))
  2751. + {
  2752. + // First connection for this user or client
  2753. + if (!(user_stats = ((USER_STATS*)
  2754. + my_malloc(sizeof(USER_STATS), MYF(MY_WME)))))
  2755. + {
  2756. + return 1; // Out of memory
  2757. + }
  2758. +
  2759. + init_user_stats(user_stats, name, role_name,
  2760. + 0, 0, // connections
  2761. + 0, 0, 0, // time
  2762. + 0, 0, 0, // bytes sent, received and written
  2763. + 0, 0, 0, // rows fetched, updated and read
  2764. + 0, 0, 0, // select, update and other commands
  2765. + 0, 0, // commit and rollback trans
  2766. + thd->diff_denied_connections,
  2767. + 0, // lost connections
  2768. + 0, // access denied errors
  2769. + 0); // empty queries
  2770. +
  2771. + if (my_hash_insert(users_or_clients, (byte*)user_stats))
  2772. + {
  2773. + my_free((char*)user_stats, 0);
  2774. + return 1; // Out of memory
  2775. + }
  2776. + }
  2777. + user_stats->total_connections++;
  2778. + return 0;
  2779. +}
  2780. +
  2781. +// Increments the global user and client stats connection count. If 'use_lock'
  2782. +// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
  2783. +// 0 on success, 1 on error.
  2784. +static int increment_connection_count(THD* thd, bool use_lock)
  2785. +{
  2786. + char* user_string = get_valid_user_string(thd->main_security_ctx.user);
  2787. + const char* client_string = get_client_host(thd);
  2788. + int return_value = 0;
  2789. +
  2790. + if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
  2791. +
  2792. + if (increment_count_by_name(user_string, user_string,
  2793. + &global_user_stats, thd))
  2794. + {
  2795. + return_value = 1;
  2796. + goto end;
  2797. + }
  2798. + if (increment_count_by_name(client_string,
  2799. + user_string,
  2800. + &global_client_stats, thd))
  2801. + {
  2802. + return_value = 1;
  2803. + goto end;
  2804. + }
  2805. +
  2806. +end:
  2807. + if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
  2808. + return return_value;
  2809. +}
  2810. +
  2811. +// Used to update the global user and client stats.
  2812. +static void update_global_user_stats_with_user(THD* thd,
  2813. + USER_STATS* user_stats,
  2814. + time_t now)
  2815. +{
  2816. + user_stats->connected_time += now - thd->last_global_update_time;
  2817. + thd->last_global_update_time = now;
  2818. + user_stats->busy_time += thd->diff_total_busy_time;
  2819. + user_stats->cpu_time += thd->diff_total_cpu_time;
  2820. + user_stats->bytes_received += thd->diff_total_bytes_received;
  2821. + user_stats->bytes_sent += thd->diff_total_bytes_sent;
  2822. + user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
  2823. + user_stats->rows_fetched += thd->diff_total_sent_rows;
  2824. + user_stats->rows_updated += thd->diff_total_updated_rows;
  2825. + user_stats->rows_read += thd->diff_total_read_rows;
  2826. + user_stats->select_commands += thd->diff_select_commands;
  2827. + user_stats->update_commands += thd->diff_update_commands;
  2828. + user_stats->other_commands += thd->diff_other_commands;
  2829. + user_stats->commit_trans += thd->diff_commit_trans;
  2830. + user_stats->rollback_trans += thd->diff_rollback_trans;
  2831. + user_stats->denied_connections += thd->diff_denied_connections;
  2832. + user_stats->lost_connections += thd->diff_lost_connections;
  2833. + user_stats->access_denied_errors += thd->diff_access_denied_errors;
  2834. + user_stats->empty_queries += thd->diff_empty_queries;
  2835. +}
  2836. +
  2837. +// Updates the global stats of a user or client
  2838. +static void update_global_user_stats(THD* thd, bool create_user, time_t now)
  2839. +{
  2840. + char* user_string = get_valid_user_string(thd->main_security_ctx.user);
  2841. + const char* client_string = get_client_host(thd);
  2842. +
  2843. + USER_STATS* user_stats;
  2844. + pthread_mutex_lock(&LOCK_global_user_client_stats);
  2845. +
  2846. + // Update by user name
  2847. + if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
  2848. + (byte*)user_string,
  2849. + strlen(user_string)))) {
  2850. + // Found user.
  2851. + update_global_user_stats_with_user(thd, user_stats, now);
  2852. + } else {
  2853. + // Create the entry
  2854. + if (create_user) {
  2855. + increment_count_by_name(user_string, user_string,
  2856. + &global_user_stats, thd);
  2857. + }
  2858. + }
  2859. +
  2860. + // Update by client IP
  2861. + if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
  2862. + (byte*)client_string,
  2863. + strlen(client_string)))) {
  2864. + // Found by client IP
  2865. + update_global_user_stats_with_user(thd, user_stats, now);
  2866. + } else {
  2867. + // Create the entry
  2868. + if (create_user) {
  2869. + increment_count_by_name(client_string,
  2870. + user_string,
  2871. + &global_client_stats, thd);
  2872. + }
  2873. + }
  2874. + thd->reset_diff_stats();
  2875. +
  2876. + pthread_mutex_unlock(&LOCK_global_user_client_stats);
  2877. +}
  2878. +
  2879. +// Determines the concurrent number of connections of current threads.
  2880. +static void set_connections_stats()
  2881. +{
  2882. + USER_STATS* user_stats;
  2883. +
  2884. + pthread_mutex_lock(&LOCK_global_user_client_stats);
  2885. + pthread_mutex_lock(&LOCK_thread_count);
  2886. +
  2887. + // Resets all concurrent connections to 0.
  2888. + for (int i = 0; i < global_user_stats.records; ++i) {
  2889. + user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
  2890. + user_stats->concurrent_connections = 0;
  2891. + }
  2892. + for (int i = 0; i < global_client_stats.records; ++i) {
  2893. + user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
  2894. + user_stats->concurrent_connections = 0;
  2895. + }
  2896. +
  2897. + I_List_iterator<THD> it(threads);
  2898. + THD* thd;
  2899. + time_t now = time(NULL);
  2900. + // Iterates through the current threads.
  2901. + while ((thd = it++)) {
  2902. + char* user_string = get_valid_user_string(thd->main_security_ctx.user);
  2903. + if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
  2904. + (byte*)user_string,
  2905. + strlen(user_string)))) {
  2906. + // Found user.
  2907. + user_stats->concurrent_connections++;
  2908. + update_global_user_stats_with_user(thd, user_stats, now);
  2909. + } else {
  2910. + // The user name should exist.
  2911. + if (user_string == mysql_system_user) {
  2912. + // Only create the user if it is the mysql_system_user
  2913. + increment_count_by_name(user_string, user_string,
  2914. + &global_user_stats, thd);
  2915. + }
  2916. + }
  2917. +
  2918. + const char* client_string = get_client_host(thd);
  2919. + if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
  2920. + (byte*)client_string,
  2921. + strlen(client_string)))) {
  2922. + // Found user.
  2923. + user_stats->concurrent_connections++;
  2924. + update_global_user_stats_with_user(thd, user_stats, now);
  2925. + } else {
  2926. + // Do nothing, unlike what is done for global_user_stats
  2927. + }
  2928. + thd->reset_diff_stats();
  2929. + }
  2930. + pthread_mutex_unlock(&LOCK_thread_count);
  2931. + pthread_mutex_unlock(&LOCK_global_user_client_stats);
  2932. +}
  2933. +
  2934. /*
  2935. Reset per-hour user resource limits when it has been more than
  2936. an hour since they were last checked
  2937. @@ -1150,6 +1569,8 @@
  2938. my_net_set_read_timeout(net, connect_timeout);
  2939. my_net_set_write_timeout(net, connect_timeout);
  2940.  
  2941. + bool create_user = true;
  2942. +
  2943. if ((error=check_connection(thd)))
  2944. { // Wrong permissions
  2945. if (error > 0)
  2946. @@ -1159,8 +1580,22 @@
  2947. my_sleep(1000); /* must wait after eof() */
  2948. #endif
  2949. statistic_increment(aborted_connects,&LOCK_status);
  2950. + thd->diff_denied_connections++;
  2951. + if (error == -2) {
  2952. + // Do not create statistics for a user who does not exist, or failed
  2953. + // to authenticate.
  2954. + create_user = false;
  2955. + }
  2956. + goto end_thread;
  2957. + }
  2958. +
  2959. + thd->reset_stats();
  2960. + // Updates global user connection stats.
  2961. + if (increment_connection_count(thd, true)) {
  2962. + net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
  2963. goto end_thread;
  2964. }
  2965. +
  2966. #ifdef __NETWARE__
  2967. netware_reg_user(sctx->ip, sctx->user, "MySQL");
  2968. #endif
  2969. @@ -1208,6 +1643,7 @@
  2970. net->vio && net->error && net->report_error)
  2971. {
  2972. statistic_increment(aborted_threads, &LOCK_status);
  2973. + thd->diff_lost_connections++;
  2974. }
  2975.  
  2976. if (net->error && net->vio != 0 && net->report_error)
  2977. @@ -1227,6 +1663,8 @@
  2978.  
  2979. end_thread:
  2980. close_connection(thd, 0, 1);
  2981. + thd->update_stats(false);
  2982. + update_global_user_stats(thd, create_user, time(NULL));
  2983. end_thread(thd,1);
  2984. /*
  2985. If end_thread returns, we are either running with --one-thread
  2986. @@ -1553,6 +1991,13 @@
  2987.  
  2988. thd->clear_error(); // Clear error message
  2989.  
  2990. + thd->updated_row_count=0;
  2991. + thd->busy_time=0;
  2992. + thd->cpu_time=0;
  2993. + thd->bytes_received=0;
  2994. + thd->bytes_sent=0;
  2995. + thd->binlog_bytes_written=0;
  2996. +
  2997. net_new_transaction(net);
  2998. if ((packet_length=my_net_read(net)) == packet_error)
  2999. {
  3000. @@ -1628,6 +2073,9 @@
  3001. }
  3002.  
  3003. thd->command=command;
  3004. + // To increment the corrent command counter for user stats, 'command' must
  3005. + // be saved because it is set to COM_SLEEP at the end of this function.
  3006. + thd->old_command = command;
  3007. /*
  3008. Commands which always take a long time are logged into
  3009. the slow log only if opt_log_slow_admin_statements is set.
  3010. @@ -4204,6 +4652,15 @@
  3011. if (check_global_access(thd,RELOAD_ACL))
  3012. goto error;
  3013.  
  3014. + if(lex->type & REFRESH_SLOW_QUERY_LOG) {
  3015. + /* We are only flushing slow query log */
  3016. + mysql_slow_log.new_file(1);
  3017. +
  3018. + send_ok(thd);
  3019. + break;
  3020. + }
  3021. +
  3022. +
  3023. /*
  3024. reload_acl_and_cache() will tell us if we are allowed to write to the
  3025. binlog or not.
  3026. @@ -4511,6 +4968,7 @@
  3027. {
  3028. if (check_global_access(thd, SUPER_ACL))
  3029. {
  3030. + thd->diff_access_denied_errors++;
  3031. my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
  3032. goto create_sp_error;
  3033. }
  3034. @@ -5334,6 +5792,7 @@
  3035. if (!no_errors)
  3036. {
  3037. const char *db_name= db ? db : thd->db;
  3038. + thd->diff_access_denied_errors++;
  3039. my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
  3040. sctx->priv_user, sctx->priv_host, db_name);
  3041. }
  3042. @@ -5369,6 +5828,7 @@
  3043. { // We can never grant this
  3044. DBUG_PRINT("error",("No possible access"));
  3045. if (!no_errors)
  3046. + thd->diff_access_denied_errors++;
  3047. my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
  3048. sctx->priv_user,
  3049. sctx->priv_host,
  3050. @@ -5401,11 +5861,15 @@
  3051.  
  3052. DBUG_PRINT("error",("Access denied"));
  3053. if (!no_errors)
  3054. + {
  3055. + // increment needs !no_errors condition, otherwise double counting.
  3056. + thd->diff_access_denied_errors++;
  3057. my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
  3058. sctx->priv_user, sctx->priv_host,
  3059. (db ? db : (thd->db ?
  3060. thd->db :
  3061. "unknown"))); /* purecov: tested */
  3062. + }
  3063. DBUG_RETURN(TRUE); /* purecov: tested */
  3064. #endif /* NO_EMBEDDED_ACCESS_CHECKS */
  3065. }
  3066. @@ -5439,6 +5903,7 @@
  3067. if ((thd->security_ctx->master_access & want_access))
  3068. return 0;
  3069. get_privilege_desc(command, sizeof(command), want_access);
  3070. + thd->diff_access_denied_errors++;
  3071. my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
  3072. return 1;
  3073. #endif /* NO_EMBEDDED_ACCESS_CHECKS */
  3074. @@ -5471,6 +5936,7 @@
  3075.  
  3076. if (!thd->col_access && check_grant_db(thd, dst_db_name))
  3077. {
  3078. + thd->diff_access_denied_errors++;
  3079. my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
  3080. thd->security_ctx->priv_user,
  3081. thd->security_ctx->priv_host,
  3082. @@ -5502,6 +5968,12 @@
  3083. check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
  3084. }
  3085.  
  3086. +
  3087. + case SCH_USER_STATS:
  3088. + case SCH_CLIENT_STATS:
  3089. + return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
  3090. + case SCH_TABLE_STATS:
  3091. + case SCH_INDEX_STATS:
  3092. case SCH_OPEN_TABLES:
  3093. case SCH_VARIABLES:
  3094. case SCH_STATUS:
  3095. @@ -5554,8 +6026,8 @@
  3096. #ifndef NO_EMBEDDED_ACCESS_CHECKS
  3097. TABLE_LIST *org_tables= tables;
  3098. #endif
  3099. - TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
  3100. Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
  3101. + TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
  3102. /*
  3103. The check that first_not_own_table is not reached is for the case when
  3104. the given table list refers to the list for prelocking (contains tables
  3105. @@ -5572,9 +6044,12 @@
  3106. (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
  3107. {
  3108. if (!no_errors)
  3109. + {
  3110. + thd->diff_access_denied_errors++;
  3111. my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
  3112. sctx->priv_user, sctx->priv_host,
  3113. INFORMATION_SCHEMA_NAME.str);
  3114. + }
  3115. return TRUE;
  3116. }
  3117. /*
  3118. @@ -6069,6 +6544,29 @@
  3119. lex_start(thd);
  3120. mysql_reset_thd_for_next_command(thd);
  3121.  
  3122. + int start_time_error = 0;
  3123. + int end_time_error = 0;
  3124. + struct timeval start_time, end_time;
  3125. + double start_usecs = 0;
  3126. + double end_usecs = 0;
  3127. + /* cpu time */
  3128. + int cputime_error = 0;
  3129. + struct timespec tp;
  3130. + double start_cpu_nsecs = 0;
  3131. + double end_cpu_nsecs = 0;
  3132. +
  3133. +#ifdef HAVE_CLOCK_GETTIME
  3134. + /* get start cputime */
  3135. + if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
  3136. + start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
  3137. +#endif
  3138. +
  3139. + // Gets the start time, in order to measure how long this command takes.
  3140. + if (!(start_time_error = gettimeofday(&start_time, NULL))) {
  3141. + start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
  3142. + }
  3143. +
  3144. +
  3145. if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
  3146. {
  3147. LEX *lex= thd->lex;
  3148. @@ -6140,6 +6638,39 @@
  3149. *found_semicolon= NULL;
  3150. }
  3151.  
  3152. +
  3153. + // Gets the end time.
  3154. + if (!(end_time_error = gettimeofday(&end_time, NULL))) {
  3155. + end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
  3156. + }
  3157. +
  3158. + // Calculates the difference between the end and start times.
  3159. + if (end_usecs >= start_usecs && !start_time_error && !end_time_error) {
  3160. + thd->busy_time = (end_usecs - start_usecs) / 1000000;
  3161. + // In case there are bad values, 2629743 is the #seconds in a month.
  3162. + if (thd->busy_time > 2629743) {
  3163. + thd->busy_time = 0;
  3164. + }
  3165. + } else {
  3166. + // end time went back in time, or gettimeofday() failed.
  3167. + thd->busy_time = 0;
  3168. + }
  3169. +
  3170. +#ifdef HAVE_CLOCK_GETTIME
  3171. + /* get end cputime */
  3172. + if (!cputime_error &&
  3173. + !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
  3174. + end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
  3175. +#endif
  3176. + if (!cputime_error)
  3177. + thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
  3178. + else
  3179. + thd->cpu_time = 0;
  3180. +
  3181. + // Updates THD stats and the global user stats.
  3182. + thd->update_stats(true);
  3183. + update_global_user_stats(thd, true, time(NULL));
  3184. +
  3185. DBUG_VOID_RETURN;
  3186. }
  3187.  
  3188. @@ -7132,8 +7663,35 @@
  3189. pthread_mutex_unlock(&LOCK_active_mi);
  3190. }
  3191. #endif
  3192. - if (options & REFRESH_USER_RESOURCES)
  3193. - reset_mqh((LEX_USER *) NULL);
  3194. + if (options & REFRESH_TABLE_STATS)
  3195. + {
  3196. + pthread_mutex_lock(&LOCK_global_table_stats);
  3197. + free_global_table_stats();
  3198. + init_global_table_stats();
  3199. + pthread_mutex_unlock(&LOCK_global_table_stats);
  3200. + }
  3201. + if (options & REFRESH_INDEX_STATS)
  3202. + {
  3203. + pthread_mutex_lock(&LOCK_global_index_stats);
  3204. + free_global_index_stats();
  3205. + init_global_index_stats();
  3206. + pthread_mutex_unlock(&LOCK_global_index_stats);
  3207. + }
  3208. + if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
  3209. + {
  3210. + pthread_mutex_lock(&LOCK_global_user_client_stats);
  3211. + if (options & REFRESH_USER_STATS)
  3212. + {
  3213. + free_global_user_stats();
  3214. + init_global_user_stats();
  3215. + }
  3216. + if (options & REFRESH_CLIENT_STATS)
  3217. + {
  3218. + free_global_client_stats();
  3219. + init_global_client_stats();
  3220. + }
  3221. + pthread_mutex_unlock(&LOCK_global_user_client_stats);
  3222. + }
  3223. *write_to_binlog= tmp_write_to_binlog;
  3224. return result;
  3225. }
  3226. diff -Naur mysql.orig/sql/sql_show.cc mysql/sql/sql_show.cc
  3227. --- mysql.orig/sql/sql_show.cc 2007-12-14 21:43:13.000000000 +0100
  3228. +++ mysql/sql/sql_show.cc 2008-11-27 20:08:07.000000000 +0100
  3229. @@ -488,6 +488,7 @@
  3230. sctx->master_access);
  3231. if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
  3232. {
  3233. + thd->diff_access_denied_errors++;
  3234. my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
  3235. sctx->priv_user, sctx->host_or_ip, dbname);
  3236. mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
  3237. @@ -1807,6 +1808,300 @@
  3238. DBUG_RETURN(FALSE);
  3239. }
  3240.  
  3241. +/*
  3242. + Aggregate values for mapped_user entries by their role.
  3243. +
  3244. + SYNOPSIS
  3245. + aggregate_user_stats
  3246. + all_user_stats - input to aggregate
  3247. + agg_user_stats - returns aggregated values
  3248. +
  3249. + RETURN
  3250. + 0 - OK
  3251. + 1 - error
  3252. + */
  3253. +static int
  3254. +aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
  3255. +{
  3256. + DBUG_ENTER("aggregate_user_stats");
  3257. + if (hash_init(agg_user_stats, system_charset_info,
  3258. + MYSQL_MAX(all_user_stats->records, 1),
  3259. + 0, 0, (hash_get_key)get_key_user_stats,
  3260. + (hash_free_key)free_user_stats, 0))
  3261. + {
  3262. + sql_print_error("Malloc in aggregate_user_stats failed");
  3263. + DBUG_RETURN(1);
  3264. + }
  3265. +
  3266. + for (int i = 0; i < all_user_stats->records; ++i) {
  3267. + USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
  3268. + USER_STATS *agg_user;
  3269. + if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
  3270. + (byte*)user->priv_user,
  3271. + strlen(user->priv_user))))
  3272. + {
  3273. + // First entry for this role.
  3274. + if (!(agg_user =
  3275. + (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME))))
  3276. + {
  3277. + sql_print_error("Malloc in aggregate_user_stats failed");
  3278. + DBUG_RETURN(1);
  3279. + }
  3280. +
  3281. + init_user_stats(agg_user, user->priv_user, user->priv_user,
  3282. + user->total_connections, user->concurrent_connections,
  3283. + user->connected_time, user->busy_time, user->cpu_time,
  3284. + user->bytes_received, user->bytes_sent,
  3285. + user->binlog_bytes_written,
  3286. + user->rows_fetched, user->rows_updated, user->rows_read,
  3287. + user->select_commands, user->update_commands,
  3288. + user->other_commands,
  3289. + user->commit_trans, user->rollback_trans,
  3290. + user->denied_connections, user->lost_connections,
  3291. + user->access_denied_errors, user->empty_queries);
  3292. +
  3293. + if (my_hash_insert(agg_user_stats, (byte*)agg_user))
  3294. + {
  3295. + // Out of memory.
  3296. + my_free((char*)agg_user, 0);
  3297. + sql_print_error("Malloc in aggregate_user_stats failed");
  3298. + DBUG_RETURN(1);
  3299. + }
  3300. + }
  3301. + else
  3302. + {
  3303. + // Aggregate with existing values for this role.
  3304. + add_user_stats(agg_user,
  3305. + user->total_connections, user->concurrent_connections,
  3306. + user->connected_time, user->busy_time, user->cpu_time,
  3307. + user->bytes_received, user->bytes_sent,
  3308. + user->binlog_bytes_written,
  3309. + user->rows_fetched, user->rows_updated, user->rows_read,
  3310. + user->select_commands, user->update_commands,
  3311. + user->other_commands,
  3312. + user->commit_trans, user->rollback_trans,
  3313. + user->denied_connections, user->lost_connections,
  3314. + user->access_denied_errors, user->empty_queries);
  3315. + }
  3316. + }
  3317. + DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
  3318. + all_user_stats->records, agg_user_stats->records));
  3319. + DBUG_RETURN(0);
  3320. +}
  3321. +
  3322. +/*
  3323. + Write result to network for SHOW USER_STATISTICS
  3324. +
  3325. + SYNOPSIS
  3326. + send_user_stats
  3327. + all_user_stats - values to return
  3328. + table - I_S table
  3329. +
  3330. + RETURN
  3331. + 0 - OK
  3332. + 1 - error
  3333. + */
  3334. +int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
  3335. +{
  3336. + DBUG_ENTER("send_user_stats");
  3337. + for (int i = 0; i < all_user_stats->records; ++i) {
  3338. + restore_record(table, s->default_values);
  3339. + USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
  3340. + table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
  3341. + table->field[1]->store((longlong)user_stats->total_connections);
  3342. + table->field[2]->store((longlong)user_stats->concurrent_connections);
  3343. + table->field[3]->store((longlong)user_stats->connected_time);
  3344. + table->field[4]->store((longlong)user_stats->busy_time);
  3345. + table->field[5]->store((longlong)user_stats->cpu_time);
  3346. + table->field[6]->store((longlong)user_stats->bytes_received);
  3347. + table->field[7]->store((longlong)user_stats->bytes_sent);
  3348. + table->field[8]->store((longlong)user_stats->binlog_bytes_written);
  3349. + table->field[9]->store((longlong)user_stats->rows_fetched);
  3350. + table->field[10]->store((longlong)user_stats->rows_updated);
  3351. + table->field[11]->store((longlong)user_stats->rows_read);
  3352. + table->field[12]->store((longlong)user_stats->select_commands);
  3353. + table->field[13]->store((longlong)user_stats->update_commands);
  3354. + table->field[14]->store((longlong)user_stats->other_commands);
  3355. + table->field[15]->store((longlong)user_stats->commit_trans);
  3356. + table->field[16]->store((longlong)user_stats->rollback_trans);
  3357. + table->field[17]->store((longlong)user_stats->denied_connections);
  3358. + table->field[18]->store((longlong)user_stats->lost_connections);
  3359. + table->field[19]->store((longlong)user_stats->access_denied_errors);
  3360. + table->field[20]->store((longlong)user_stats->empty_queries);
  3361. + if (schema_table_store_record(thd, table))
  3362. + {
  3363. + DBUG_PRINT("error", ("store record error"));
  3364. + DBUG_RETURN(1);
  3365. + }
  3366. + }
  3367. + DBUG_RETURN(0);
  3368. +}
  3369. +
  3370. +/*
  3371. + Process SHOW USER_STATISTICS
  3372. +
  3373. + SYNOPSIS
  3374. + mysqld_show_user_stats
  3375. + thd - current thread
  3376. + wild - limit results to the entry for this user
  3377. + with_roles - when true, display role for mapped users
  3378. +
  3379. + RETURN
  3380. + 0 - OK
  3381. + 1 - error
  3382. + */
  3383. +
  3384. +
  3385. +int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
  3386. +{
  3387. + TABLE *table= tables->table;
  3388. + DBUG_ENTER("fill_schema_user_stats");
  3389. +
  3390. + if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
  3391. + DBUG_RETURN(1);
  3392. +
  3393. + // Iterates through all the global stats and sends them to the client.
  3394. + // Pattern matching on the client IP is supported.
  3395. +
  3396. + pthread_mutex_lock(&LOCK_global_user_client_stats);
  3397. + int result= send_user_stats(thd, &global_user_stats, table);
  3398. + pthread_mutex_unlock(&LOCK_global_user_client_stats);
  3399. + if (result)
  3400. + goto err;
  3401. +
  3402. + DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
  3403. + DBUG_RETURN(0);
  3404. +
  3405. + err:
  3406. + DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
  3407. + DBUG_RETURN(1);
  3408. +}
  3409. +
  3410. +/*
  3411. + Process SHOW CLIENT_STATISTICS
  3412. +
  3413. + SYNOPSIS
  3414. + mysqld_show_client_stats
  3415. + thd - current thread
  3416. + wild - limit results to the entry for this client
  3417. +
  3418. + RETURN
  3419. + 0 - OK
  3420. + 1 - error
  3421. + */
  3422. +
  3423. +
  3424. +int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
  3425. +{
  3426. + TABLE *table= tables->table;
  3427. + DBUG_ENTER("fill_schema_client_stats");
  3428. +
  3429. + if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
  3430. + DBUG_RETURN(1);
  3431. +
  3432. + // Iterates through all the global stats and sends them to the client.
  3433. + // Pattern matching on the client IP is supported.
  3434. +
  3435. + pthread_mutex_lock(&LOCK_global_user_client_stats);
  3436. + int result= send_user_stats(thd, &global_client_stats, table);
  3437. + pthread_mutex_unlock(&LOCK_global_user_client_stats);
  3438. + if (result)
  3439. + goto err;
  3440. +
  3441. + DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
  3442. + DBUG_RETURN(0);
  3443. +
  3444. + err:
  3445. + DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
  3446. + DBUG_RETURN(1);
  3447. +}
  3448. +
  3449. +
  3450. +// Sends the global table stats back to the client.
  3451. +int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
  3452. +{
  3453. + TABLE *table= tables->table;
  3454. + DBUG_ENTER("fill_schema_table_stats");
  3455. + char *table_full_name, *table_schema;
  3456. +
  3457. + pthread_mutex_lock(&LOCK_global_table_stats);
  3458. + for (int i = 0; i < global_table_stats.records; ++i) {
  3459. + restore_record(table, s->default_values);
  3460. + TABLE_STATS *table_stats =
  3461. + (TABLE_STATS*)hash_element(&global_table_stats, i);
  3462. +
  3463. + table_full_name= thd->strdup(table_stats->table);
  3464. + table_schema= strsep(&table_full_name, ".");
  3465. +
  3466. + TABLE_LIST tmp_table;
  3467. + bzero((char*) &tmp_table,sizeof(tmp_table));
  3468. + tmp_table.table_name= table_full_name;
  3469. + tmp_table.db= table_schema;
  3470. + tmp_table.grant.privilege= 0;
  3471. + if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
  3472. + &tmp_table.grant.privilege, 0, 0,
  3473. + is_schema_db(table_schema)) ||
  3474. + grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
  3475. + continue;
  3476. +
  3477. + table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
  3478. + table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
  3479. + table->field[2]->store((longlong)table_stats->rows_read, TRUE);
  3480. + table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
  3481. + table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
  3482. +
  3483. + if (schema_table_store_record(thd, table))
  3484. + {
  3485. + VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
  3486. + DBUG_RETURN(1);
  3487. + }
  3488. + }
  3489. + pthread_mutex_unlock(&LOCK_global_table_stats);
  3490. + DBUG_RETURN(0);
  3491. +}
  3492. +
  3493. +// Sends the global index stats back to the client.
  3494. +int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
  3495. +{
  3496. + TABLE *table= tables->table;
  3497. + DBUG_ENTER("fill_schema_index_stats");
  3498. + char *index_full_name, *table_schema, *table_name;
  3499. +
  3500. + pthread_mutex_lock(&LOCK_global_index_stats);
  3501. + for (int i = 0; i < global_index_stats.records; ++i) {
  3502. + restore_record(table, s->default_values);
  3503. + INDEX_STATS *index_stats =
  3504. + (INDEX_STATS*)hash_element(&global_index_stats, i);
  3505. +
  3506. + index_full_name= thd->strdup(index_stats->index);
  3507. + table_schema= strsep(&index_full_name, ".");
  3508. + table_name= strsep(&index_full_name, ".");
  3509. +
  3510. + TABLE_LIST tmp_table;
  3511. + bzero((char*) &tmp_table,sizeof(tmp_table));
  3512. + tmp_table.table_name= table_name;
  3513. + tmp_table.db= table_schema;
  3514. + tmp_table.grant.privilege= 0;
  3515. + if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
  3516. + &tmp_table.grant.privilege, 0, 0,
  3517. + is_schema_db(table_schema)) ||
  3518. + grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
  3519. + continue;
  3520. +
  3521. + table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
  3522. + table->field[1]->store(table_name, strlen(table_name), system_charset_info);
  3523. + table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
  3524. + table->field[3]->store((longlong)index_stats->rows_read, TRUE);
  3525. +
  3526. + if (schema_table_store_record(thd, table))
  3527. + {
  3528. + VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
  3529. + DBUG_RETURN(1);
  3530. + }
  3531. + }
  3532. + pthread_mutex_unlock(&LOCK_global_index_stats);
  3533. + DBUG_RETURN(0);
  3534. +}
  3535.  
  3536. /* collect status for all running threads */
  3537.  
  3538. @@ -4372,6 +4667,77 @@
  3539. {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
  3540. };
  3541.  
  3542. +ST_FIELD_INFO user_stats_fields_info[]=
  3543. +{
  3544. + {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
  3545. + {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
  3546. + {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
  3547. + {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
  3548. + {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
  3549. + {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
  3550. + {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
  3551. + {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
  3552. + {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
  3553. + {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
  3554. + {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
  3555. + {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
  3556. + {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
  3557. + {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
  3558. + {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
  3559. + {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
  3560. + {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
  3561. + {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
  3562. + {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
  3563. + {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
  3564. + {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
  3565. + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
  3566. +};
  3567. +
  3568. +ST_FIELD_INFO client_stats_fields_info[]=
  3569. +{
  3570. + {"CLIENT", 16, MYSQL_TYPE_STRING, 0, 0, "Client"},
  3571. + {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
  3572. + {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
  3573. + {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
  3574. + {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
  3575. + {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
  3576. + {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
  3577. + {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
  3578. + {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
  3579. + {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
  3580. + {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
  3581. + {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
  3582. + {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
  3583. + {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
  3584. + {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
  3585. + {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
  3586. + {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
  3587. + {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
  3588. + {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
  3589. + {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
  3590. + {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
  3591. + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
  3592. +};
  3593. +
  3594. +
  3595. +ST_FIELD_INFO table_stats_fields_info[]=
  3596. +{
  3597. + {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
  3598. + {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
  3599. + {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
  3600. + {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
  3601. + {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
  3602. + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
  3603. +};
  3604. +
  3605. +ST_FIELD_INFO index_stats_fields_info[]=
  3606. +{
  3607. + {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
  3608. + {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
  3609. + {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
  3610. + {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
  3611. + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
  3612. +};
  3613.  
  3614. /*
  3615. Description of ST_FIELD_INFO in table.h
  3616. @@ -4381,6 +4747,8 @@
  3617. {
  3618. {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
  3619. fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
  3620. + {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
  3621. + fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
  3622. {"COLLATIONS", collation_fields_info, create_schema_table,
  3623. fill_schema_collation, make_old_format, 0, -1, -1, 0},
  3624. {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
  3625. @@ -4389,6 +4757,8 @@
  3626. get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
  3627. {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
  3628. fill_schema_column_privileges, 0, 0, -1, -1, 0},
  3629. + {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
  3630. + fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
  3631. {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
  3632. get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
  3633. {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
  3634. @@ -4411,10 +4781,14 @@
  3635. get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
  3636. {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
  3637. fill_schema_table_privileges, 0, 0, -1, -1, 0},
  3638. + {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
  3639. + fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
  3640. {"TRIGGERS", triggers_fields_info, create_schema_table,
  3641. get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
  3642. {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
  3643. fill_schema_user_privileges, 0, 0, -1, -1, 0},
  3644. + {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
  3645. + fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
  3646. {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
  3647. make_old_format, 0, -1, -1, 1},
  3648. {"VIEWS", view_fields_info, create_schema_table,
  3649. diff -Naur mysql.orig/sql/sql_update.cc mysql/sql/sql_update.cc
  3650. --- mysql.orig/sql/sql_update.cc 2007-12-14 21:43:00.000000000 +0100
  3651. +++ mysql/sql/sql_update.cc 2008-11-27 20:08:07.000000000 +0100
  3652. @@ -601,7 +601,8 @@
  3653. (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
  3654. send_ok(thd, (ulong) thd->row_count_func,
  3655. thd->insert_id_used ? thd->last_insert_id : 0L,buff);
  3656. - DBUG_PRINT("info",("%ld records updated", (long) updated));
  3657. + thd->updated_row_count += thd->row_count_func;
  3658. + DBUG_PRINT("info",("%d records updated",updated));
  3659. }
  3660. thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
  3661. thd->abort_on_warning= 0;
  3662. @@ -1769,5 +1770,6 @@
  3663. (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
  3664. ::send_ok(thd, (ulong) thd->row_count_func,
  3665. thd->insert_id_used ? thd->last_insert_id : 0L,buff);
  3666. + thd->updated_row_count += thd->row_count_func;
  3667. return FALSE;
  3668. }
  3669. diff -Naur mysql.orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
  3670. --- mysql.orig/sql/sql_yacc.yy 2007-12-14 21:43:24.000000000 +0100
  3671. +++ mysql/sql/sql_yacc.yy 2008-11-27 20:08:07.000000000 +0100
  3672. @@ -521,6 +521,7 @@
  3673. %token CHECK_SYM
  3674. %token CIPHER_SYM
  3675. %token CLIENT_SYM
  3676. +%token CLIENT_STATS_SYM
  3677. %token CLOSE_SYM
  3678. %token COALESCE
  3679. %token CODE_SYM
  3680. @@ -675,6 +676,7 @@
  3681. %token IMPORT
  3682. %token INDEXES
  3683. %token INDEX_SYM
  3684. +%token INDEX_STATS_SYM
  3685. %token INFILE
  3686. %token INNER_SYM
  3687. %token INNOBASE_SYM
  3688. @@ -897,6 +899,7 @@
  3689. %token SIGNED_SYM
  3690. %token SIMPLE_SYM
  3691. %token SLAVE
  3692. +%token SLOW_SYM
  3693. %token SMALLINT
  3694. %token SNAPSHOT_SYM
  3695. %token SOUNDS_SYM
  3696. @@ -934,6 +937,7 @@
  3697. %token TABLES
  3698. %token TABLESPACE
  3699. %token TABLE_SYM
  3700. +%token TABLE_STATS_SYM
  3701. %token TEMPORARY
  3702. %token TEMPTABLE_SYM
  3703. %token TERMINATED
  3704. @@ -976,6 +980,7 @@
  3705. %token UPGRADE_SYM
  3706. %token USAGE
  3707. %token USER
  3708. +%token USER_STATS_SYM
  3709. %token USE_FRM
  3710. %token USE_SYM
  3711. %token USING
  3712. @@ -7120,6 +7125,38 @@
  3713. {
  3714. Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
  3715. }
  3716. + | CLIENT_STATS_SYM wild_and_where
  3717. + {
  3718. + LEX *lex= Lex;
  3719. + Lex->sql_command = SQLCOM_SELECT;
  3720. + lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
  3721. + if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
  3722. + MYSQL_YYABORT;
  3723. + }
  3724. + | USER_STATS_SYM wild_and_where
  3725. + {
  3726. + LEX *lex= Lex;
  3727. + lex->sql_command = SQLCOM_SELECT;
  3728. + lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
  3729. + if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
  3730. + MYSQL_YYABORT;
  3731. + }
  3732. + | TABLE_STATS_SYM wild_and_where
  3733. + {
  3734. + LEX *lex= Lex;
  3735. + lex->sql_command= SQLCOM_SELECT;
  3736. + lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
  3737. + if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
  3738. + MYSQL_YYABORT;
  3739. + }
  3740. + | INDEX_STATS_SYM wild_and_where
  3741. + {
  3742. + LEX *lex= Lex;
  3743. + lex->sql_command= SQLCOM_SELECT;
  3744. + lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
  3745. + if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
  3746. + MYSQL_YYABORT;
  3747. + }
  3748. | CREATE PROCEDURE sp_name
  3749. {
  3750. LEX *lex= Lex;
  3751. @@ -7313,9 +7350,14 @@
  3752. | LOGS_SYM { Lex->type|= REFRESH_LOG; }
  3753. | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
  3754. | SLAVE { Lex->type|= REFRESH_SLAVE; }
  3755. + | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
  3756. | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
  3757. | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
  3758. - | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
  3759. + | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
  3760. + | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
  3761. + | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
  3762. + | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
  3763. + | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
  3764.  
  3765. opt_table_list:
  3766. /* empty */ {;}
  3767. diff -Naur mysql.orig/sql/structs.h mysql/sql/structs.h
  3768. --- mysql.orig/sql/structs.h 2007-12-14 21:43:13.000000000 +0100
  3769. +++ mysql/sql/structs.h 2008-11-27 20:08:07.000000000 +0100
  3770. @@ -272,6 +272,98 @@
  3771. time_t intime;
  3772. } USER_CONN;
  3773.  
  3774. +typedef struct st_user_stats {
  3775. + char user[USERNAME_LENGTH + 1];
  3776. + // Account name the user is mapped to when this is a user from mapped_user.
  3777. + // Otherwise, the same value as user.
  3778. + char priv_user[USERNAME_LENGTH + 1];
  3779. + uint total_connections;
  3780. + uint concurrent_connections;
  3781. + time_t connected_time; // in seconds
  3782. + double busy_time; // in seconds
  3783. + double cpu_time; // in seconds
  3784. + ulonglong bytes_received;
  3785. + ulonglong bytes_sent;
  3786. + ulonglong binlog_bytes_written;
  3787. + ha_rows rows_fetched, rows_updated, rows_read;
  3788. + ulonglong select_commands, update_commands, other_commands;
  3789. + ulonglong commit_trans, rollback_trans;
  3790. + ulonglong denied_connections, lost_connections;
  3791. + ulonglong access_denied_errors;
  3792. + ulonglong empty_queries;
  3793. +} USER_STATS;
  3794. +
  3795. +/* Lookup function for hash tables with USER_STATS entries */
  3796. +extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
  3797. + my_bool not_used __attribute__((unused)));
  3798. +
  3799. +/* Free all memory for a hash table with USER_STATS entries */
  3800. +extern void free_user_stats(USER_STATS* user_stats);
  3801. +
  3802. +/* Intialize an instance of USER_STATS */
  3803. +extern void
  3804. +init_user_stats(USER_STATS *user_stats,
  3805. + const char *user,
  3806. + const char *priv_user,
  3807. + uint total_connections,
  3808. + uint concurrent_connections,
  3809. + time_t connected_time,
  3810. + double busy_time,
  3811. + double cpu_time,
  3812. + ulonglong bytes_received,
  3813. + ulonglong bytes_sent,
  3814. + ulonglong binlog_bytes_written,
  3815. + ha_rows rows_fetched,
  3816. + ha_rows rows_updated,
  3817. + ha_rows rows_read,
  3818. + ulonglong select_commands,
  3819. + ulonglong update_commands,
  3820. + ulonglong other_commands,
  3821. + ulonglong commit_trans,
  3822. + ulonglong rollback_trans,
  3823. + ulonglong denied_connections,
  3824. + ulonglong lost_connections,
  3825. + ulonglong access_denied_errors,
  3826. + ulonglong empty_queries);
  3827. +
  3828. +/* Increment values of an instance of USER_STATS */
  3829. +extern void
  3830. +add_user_stats(USER_STATS *user_stats,
  3831. + uint total_connections,
  3832. + uint concurrent_connections,
  3833. + time_t connected_time,
  3834. + double busy_time,
  3835. + double cpu_time,
  3836. + ulonglong bytes_received,
  3837. + ulonglong bytes_sent,
  3838. + ulonglong binlog_bytes_written,
  3839. + ha_rows rows_fetched,
  3840. + ha_rows rows_updated,
  3841. + ha_rows rows_read,
  3842. + ulonglong select_commands,
  3843. + ulonglong update_commands,
  3844. + ulonglong other_commands,
  3845. + ulonglong commit_trans,
  3846. + ulonglong rollback_trans,
  3847. + ulonglong denied_connections,
  3848. + ulonglong lost_connections,
  3849. + ulonglong access_denied_errors,
  3850. + ulonglong empty_queries);
  3851. +
  3852. +typedef struct st_table_stats {
  3853. + char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
  3854. + ulonglong rows_read, rows_changed;
  3855. + ulonglong rows_changed_x_indexes;
  3856. + /* Stores enum db_type, but forward declarations cannot be done */
  3857. + int engine_type;
  3858. +} TABLE_STATS;
  3859. +
  3860. +typedef struct st_index_stats {
  3861. + char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
  3862. + ulonglong rows_read;
  3863. +} INDEX_STATS;
  3864. +
  3865. +
  3866. /* Bits in form->update */
  3867. #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
  3868. #define REG_NEW_RECORD 2 /* Write a new record if not found */
  3869. diff -Naur mysql.orig/sql/table.h mysql/sql/table.h
  3870. --- mysql.orig/sql/table.h 2007-12-14 21:43:00.000000000 +0100
  3871. +++ mysql/sql/table.h 2008-11-27 20:08:07.000000000 +0100
  3872. @@ -370,10 +370,12 @@
  3873. enum enum_schema_tables
  3874. {
  3875. SCH_CHARSETS= 0,
  3876. + SCH_CLIENT_STATS,
  3877. SCH_COLLATIONS,
  3878. SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
  3879. SCH_COLUMNS,
  3880. SCH_COLUMN_PRIVILEGES,
  3881. + SCH_INDEX_STATS,
  3882. SCH_KEY_COLUMN_USAGE,
  3883. SCH_OPEN_TABLES,
  3884. SCH_PROCEDURES,
  3885. @@ -385,8 +387,10 @@
  3886. SCH_TABLE_CONSTRAINTS,
  3887. SCH_TABLE_NAMES,
  3888. SCH_TABLE_PRIVILEGES,
  3889. + SCH_TABLE_STATS,
  3890. SCH_TRIGGERS,
  3891. SCH_USER_PRIVILEGES,
  3892. + SCH_USER_STATS,
  3893. SCH_VARIABLES,
  3894. SCH_VIEWS
  3895. };
  3896. diff -Naur mysql.orig/sql-bench/Makefile.in mysql/sql-bench/Makefile.in
  3897. --- mysql.orig/sql-bench/Makefile.in 2007-12-14 21:46:09.000000000 +0100
  3898. +++ mysql/sql-bench/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  3899. @@ -172,6 +172,7 @@
  3900. LIBDL = @LIBDL@
  3901. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  3902. LIBOBJS = @LIBOBJS@
  3903. +LIBRT = @LIBRT@
  3904. LIBS = @LIBS@
  3905. LIBTOOL = @LIBTOOL@
  3906. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  3907. diff -Naur mysql.orig/sql-common/Makefile.in mysql/sql-common/Makefile.in
  3908. --- mysql.orig/sql-common/Makefile.in 2007-12-14 21:46:10.000000000 +0100
  3909. +++ mysql/sql-common/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  3910. @@ -165,6 +165,7 @@
  3911. LIBDL = @LIBDL@
  3912. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  3913. LIBOBJS = @LIBOBJS@
  3914. +LIBRT = @LIBRT@
  3915. LIBS = @LIBS@
  3916. LIBTOOL = @LIBTOOL@
  3917. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  3918. diff -Naur mysql.orig/SSL/Makefile.in mysql/SSL/Makefile.in
  3919. --- mysql.orig/SSL/Makefile.in 2007-12-14 21:45:23.000000000 +0100
  3920. +++ mysql/SSL/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  3921. @@ -165,6 +165,7 @@
  3922. LIBDL = @LIBDL@
  3923. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  3924. LIBOBJS = @LIBOBJS@
  3925. +LIBRT = @LIBRT@
  3926. LIBS = @LIBS@
  3927. LIBTOOL = @LIBTOOL@
  3928. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  3929. diff -Naur mysql.orig/strings/Makefile.in mysql/strings/Makefile.in
  3930. --- mysql.orig/strings/Makefile.in 2007-12-14 21:46:11.000000000 +0100
  3931. +++ mysql/strings/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  3932. @@ -359,6 +359,7 @@
  3933. LIBDL = @LIBDL@
  3934. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  3935. LIBOBJS = @LIBOBJS@
  3936. +LIBRT = @LIBRT@
  3937. LIBS = @LIBS@
  3938. LIBTOOL = @LIBTOOL@
  3939. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  3940. diff -Naur mysql.orig/support-files/MacOSX/Makefile.in mysql/support-files/MacOSX/Makefile.in
  3941. --- mysql.orig/support-files/MacOSX/Makefile.in 2007-12-14 21:46:11.000000000 +0100
  3942. +++ mysql/support-files/MacOSX/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  3943. @@ -169,6 +169,7 @@
  3944. LIBDL = @LIBDL@
  3945. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  3946. LIBOBJS = @LIBOBJS@
  3947. +LIBRT = @LIBRT@
  3948. LIBS = @LIBS@
  3949. LIBTOOL = @LIBTOOL@
  3950. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  3951. diff -Naur mysql.orig/support-files/Makefile.in mysql/support-files/Makefile.in
  3952. --- mysql.orig/support-files/Makefile.in 2007-12-14 21:46:11.000000000 +0100
  3953. +++ mysql/support-files/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  3954. @@ -189,6 +189,7 @@
  3955. LIBDL = @LIBDL@
  3956. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  3957. LIBOBJS = @LIBOBJS@
  3958. +LIBRT = @LIBRT@
  3959. LIBS = @LIBS@
  3960. LIBTOOL = @LIBTOOL@
  3961. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  3962. diff -Naur mysql.orig/support-files/RHEL4-SElinux/Makefile.in mysql/support-files/RHEL4-SElinux/Makefile.in
  3963. --- mysql.orig/support-files/RHEL4-SElinux/Makefile.in 2007-12-14 21:46:12.000000000 +0100
  3964. +++ mysql/support-files/RHEL4-SElinux/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  3965. @@ -167,6 +167,7 @@
  3966. LIBDL = @LIBDL@
  3967. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  3968. LIBOBJS = @LIBOBJS@
  3969. +LIBRT = @LIBRT@
  3970. LIBS = @LIBS@
  3971. LIBTOOL = @LIBTOOL@
  3972. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  3973. diff -Naur mysql.orig/tests/Makefile.in mysql/tests/Makefile.in
  3974. --- mysql.orig/tests/Makefile.in 2007-12-14 21:46:12.000000000 +0100
  3975. +++ mysql/tests/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  3976. @@ -213,6 +213,7 @@
  3977. LIBDL = @LIBDL@
  3978. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  3979. LIBOBJS = @LIBOBJS@
  3980. +LIBRT = @LIBRT@
  3981. LIBS = @CLIENT_LIBS@
  3982. LIBTOOL = @LIBTOOL@
  3983. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  3984. diff -Naur mysql.orig/tools/Makefile.in mysql/tools/Makefile.in
  3985. --- mysql.orig/tools/Makefile.in 2007-12-14 21:46:12.000000000 +0100
  3986. +++ mysql/tools/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  3987. @@ -187,6 +187,7 @@
  3988. LIBDL = @LIBDL@
  3989. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  3990. LIBOBJS = @LIBOBJS@
  3991. +LIBRT = @LIBRT@
  3992. LIBS = @LIBS@
  3993. LIBTOOL = @LIBTOOL@
  3994. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  3995. diff -Naur mysql.orig/vio/Makefile.in mysql/vio/Makefile.in
  3996. --- mysql.orig/vio/Makefile.in 2007-12-14 21:46:13.000000000 +0100
  3997. +++ mysql/vio/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  3998. @@ -196,6 +196,7 @@
  3999. LIBDL = @LIBDL@
  4000. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  4001. LIBOBJS = @LIBOBJS@
  4002. +LIBRT = @LIBRT@
  4003. LIBS = @LIBS@
  4004. LIBTOOL = @LIBTOOL@
  4005. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  4006. diff -Naur mysql.orig/win/Makefile.in mysql/win/Makefile.in
  4007. --- mysql.orig/win/Makefile.in 2007-12-14 21:46:13.000000000 +0100
  4008. +++ mysql/win/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  4009. @@ -165,6 +165,7 @@
  4010. LIBDL = @LIBDL@
  4011. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  4012. LIBOBJS = @LIBOBJS@
  4013. +LIBRT = @LIBRT@
  4014. LIBS = @LIBS@
  4015. LIBTOOL = @LIBTOOL@
  4016. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  4017. diff -Naur mysql.orig/zlib/Makefile.in mysql/zlib/Makefile.in
  4018. --- mysql.orig/zlib/Makefile.in 2007-12-14 21:46:13.000000000 +0100
  4019. +++ mysql/zlib/Makefile.in 2008-11-27 20:08:07.000000000 +0100
  4020. @@ -204,6 +204,7 @@
  4021. LIBDL = @LIBDL@
  4022. LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
  4023. LIBOBJS = @LIBOBJS@
  4024. +LIBRT = @LIBRT@
  4025. LIBS = $(NON_THREADED_LIBS)
  4026. LIBTOOL = @LIBTOOL@
  4027. LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
  4028.