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