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