~tsarev/percona-server/5.5-processlist_rows_stats-sporadic_fails-fix

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# name       : innodb_dict_size_limit.patch
# introduced : 11 or before
# maintainer : Yasufumi
#
#!!! notice !!!
# Any small change to this file in the main branch
# should be done or reviewed by the maintainer!
diff -ruN a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c
--- a/storage/innobase/btr/btr0sea.c	2010-11-03 07:01:13.000000000 +0900
+++ b/storage/innobase/btr/btr0sea.c	2010-12-03 15:45:47.503988924 +0900
@@ -1185,6 +1185,179 @@
 	mem_free(folds);
 }
 
+/************************************************************************
+Drops a page hash index based on index */
+UNIV_INTERN
+void
+btr_search_drop_page_hash_index_on_index(
+/*=====================================*/
+	dict_index_t*	index)		/* in: record descriptor */
+{
+
+	hash_table_t*	table;
+	buf_block_t*	block;
+	ulint		n_fields;
+	ulint		n_bytes;
+	const page_t*		page;
+	const rec_t*		rec;
+	ulint		fold;
+	ulint		prev_fold;
+	index_id_t	index_id;
+	ulint		n_cached;
+	ulint		n_recs;
+	ulint*		folds;
+	ulint		i, j;
+	mem_heap_t*	heap	= NULL;
+	ulint*		offsets;
+	ibool		released_search_latch;
+
+	rw_lock_s_lock(&btr_search_latch);
+
+	table = btr_search_sys->hash_index;
+
+	for (j = 0; j < srv_buf_pool_instances; j++) {
+		buf_pool_t*	buf_pool;
+
+		buf_pool = buf_pool_from_array(j);
+
+		do {
+			buf_chunk_t*	chunks	= buf_pool->chunks;
+			buf_chunk_t*	chunk	= chunks + buf_pool->n_chunks;
+
+			released_search_latch = FALSE;
+
+			while (--chunk >= chunks) {
+				block	= chunk->blocks;
+				i	= chunk->size;
+
+retry:
+				for (; i--; block++) {
+					if (buf_block_get_state(block)
+					    != BUF_BLOCK_FILE_PAGE
+					    || block->index != index
+					    || !block->is_hashed) {
+						continue;
+					}
+
+					page = block->frame;
+
+					/* from btr_search_drop_page_hash_index() */
+					n_fields = block->curr_n_fields;
+					n_bytes = block->curr_n_bytes;
+
+
+					/* keeping latch order */
+					rw_lock_s_unlock(&btr_search_latch);
+					released_search_latch = TRUE;
+					rw_lock_x_lock(&block->lock);
+
+
+					ut_a(n_fields + n_bytes > 0);
+
+					n_recs = page_get_n_recs(page);
+
+					/* Calculate and cache fold values into an array for fast deletion
+					from the hash index */
+
+					folds = mem_alloc(n_recs * sizeof(ulint));
+
+					n_cached = 0;
+
+					rec = page_get_infimum_rec(page);
+					rec = page_rec_get_next_low(rec, page_is_comp(page));
+
+					index_id = btr_page_get_index_id(page);
+	
+					ut_a(index_id == index->id);
+
+					prev_fold = 0;
+
+					offsets = NULL;
+
+					while (!page_rec_is_supremum(rec)) {
+						offsets = rec_get_offsets(rec, index, offsets,
+									n_fields + (n_bytes > 0), &heap);
+						ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
+						fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
+
+						if (fold == prev_fold && prev_fold != 0) {
+
+							goto next_rec;
+						}
+
+						/* Remove all hash nodes pointing to this page from the
+						hash chain */
+
+						folds[n_cached] = fold;
+						n_cached++;
+next_rec:
+						rec = page_rec_get_next_low(rec, page_rec_is_comp(rec));
+						prev_fold = fold;
+					}
+
+					if (UNIV_LIKELY_NULL(heap)) {
+						mem_heap_empty(heap);
+					}
+
+					rw_lock_x_lock(&btr_search_latch);
+
+					if (UNIV_UNLIKELY(!block->is_hashed)) {
+						goto cleanup;
+					}
+
+					ut_a(block->index == index);
+
+					if (UNIV_UNLIKELY(block->curr_n_fields != n_fields)
+					    || UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) {
+						rw_lock_x_unlock(&btr_search_latch);
+						rw_lock_x_unlock(&block->lock);
+
+						mem_free(folds);
+
+						rw_lock_s_lock(&btr_search_latch);
+						goto retry;
+					}
+
+					for (i = 0; i < n_cached; i++) {
+
+						ha_remove_all_nodes_to_page(table, folds[i], page);
+					}
+
+					ut_a(index->search_info->ref_count > 0);
+					index->search_info->ref_count--;
+
+					block->is_hashed = FALSE;
+					block->index = NULL;
+
+cleanup:
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
+					if (UNIV_UNLIKELY(block->n_pointers)) {
+						/* Corruption */
+						ut_print_timestamp(stderr);
+						fprintf(stderr,
+"InnoDB: The adaptive hash index is corrupted. After dropping\n"
+"InnoDB: the hash index to a page of %s, %lu hash nodes still remain.\n",
+							index->name, (ulong) block->n_pointers);
+					}
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
+					rw_lock_x_unlock(&btr_search_latch);
+					rw_lock_x_unlock(&block->lock);
+
+					mem_free(folds);
+
+					rw_lock_s_lock(&btr_search_latch);
+				}
+			}
+		} while (released_search_latch);
+	}
+
+	rw_lock_s_unlock(&btr_search_latch);
+
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+}
+
 /********************************************************************//**
 Drops a page hash index when a page is freed from a fseg to the file system.
 Drops possible hash index if the page happens to be in the buffer pool. */
diff -ruN a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c
--- a/storage/innobase/buf/buf0buf.c	2011-02-01 18:00:03.000000000 +0900
+++ b/storage/innobase/buf/buf0buf.c	2011-02-01 18:01:59.000000000 +0900
@@ -294,14 +294,14 @@
 # endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */
 #endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */
 
-/** A chunk of buffers.  The buffer pool is allocated in chunks. */
-struct buf_chunk_struct{
-	ulint		mem_size;	/*!< allocated size of the chunk */
-	ulint		size;		/*!< size of frames[] and blocks[] */
-	void*		mem;		/*!< pointer to the memory area which
-					was allocated for the frames */
-	buf_block_t*	blocks;		/*!< array of buffer control blocks */
-};
+/** A chunk of buffers.  The buffer pool is allocated in chunks. (moved to buf0buf.h)*/
+//struct buf_chunk_struct{
+//	ulint		mem_size;	/*!< allocated size of the chunk */
+//	ulint		size;		/*!< size of frames[] and blocks[] */
+//	void*		mem;		/*!< pointer to the memory area which
+//					was allocated for the frames */
+//	buf_block_t*	blocks;		/*!< array of buffer control blocks */
+//};
 #endif /* !UNIV_HOTBACKUP */
 
 /********************************************************************//**
diff -ruN a/storage/innobase/dict/dict0boot.c b/storage/innobase/dict/dict0boot.c
--- a/storage/innobase/dict/dict0boot.c	2010-11-03 07:01:13.000000000 +0900
+++ b/storage/innobase/dict/dict0boot.c	2010-12-03 15:45:47.503988924 +0900
@@ -284,6 +284,7 @@
 	system tables */
 	/*-------------------------*/
 	table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0);
+	table->n_mysql_handles_opened = 1; /* for pin */
 
 	dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
 	dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
@@ -336,6 +337,7 @@
 
 	/*-------------------------*/
 	table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0);
+	table->n_mysql_handles_opened = 1; /* for pin */
 
 	dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
 	dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
@@ -368,6 +370,7 @@
 
 	/*-------------------------*/
 	table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0);
+	table->n_mysql_handles_opened = 1; /* for pin */
 
 	dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
 	dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
@@ -413,6 +416,7 @@
 
 	/*-------------------------*/
 	table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0);
+	table->n_mysql_handles_opened = 1; /* for pin */
 
 	dict_mem_table_add_col(table, heap, "INDEX_ID", DATA_BINARY, 0, 0);
 	dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
diff -ruN a/storage/innobase/dict/dict0crea.c b/storage/innobase/dict/dict0crea.c
--- a/storage/innobase/dict/dict0crea.c	2010-11-03 07:01:13.000000000 +0900
+++ b/storage/innobase/dict/dict0crea.c	2010-12-03 15:45:47.521955810 +0900
@@ -1210,6 +1210,9 @@
 		/* Foreign constraint system tables have already been
 		created, and they are ok */
 
+		table1->n_mysql_handles_opened = 1; /* for pin */
+		table2->n_mysql_handles_opened = 1; /* for pin */
+
 		mutex_exit(&(dict_sys->mutex));
 
 		return(DB_SUCCESS);
@@ -1291,6 +1294,11 @@
 
 	trx_commit_for_mysql(trx);
 
+	table1 = dict_table_get_low("SYS_FOREIGN");
+	table2 = dict_table_get_low("SYS_FOREIGN_COLS");
+	table1->n_mysql_handles_opened = 1; /* for pin */
+	table2->n_mysql_handles_opened = 1; /* for pin */
+
 	row_mysql_unlock_data_dictionary(trx);
 
 	trx_free_for_mysql(trx);
diff -ruN a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
--- a/storage/innobase/dict/dict0dict.c	2010-11-03 07:01:13.000000000 +0900
+++ b/storage/innobase/dict/dict0dict.c	2010-12-03 15:45:47.525953769 +0900
@@ -626,6 +626,8 @@
 
 	table = dict_table_get_on_id_low(table_id);
 
+	dict_table_LRU_trim(table);
+
 	mutex_exit(&(dict_sys->mutex));
 
 	return(table);
@@ -744,6 +746,8 @@
 		table->n_mysql_handles_opened++;
 	}
 
+	dict_table_LRU_trim(table);
+
 	mutex_exit(&(dict_sys->mutex));
 
 	if (table != NULL) {
@@ -1259,6 +1263,64 @@
 	dict_mem_table_free(table);
 }
 
+/**************************************************************************
+Frees tables from the end of table_LRU if the dictionary cache occupies
+too much space. */
+UNIV_INTERN
+void
+dict_table_LRU_trim(
+/*================*/
+	dict_table_t*	self)
+{
+	dict_table_t*	table;
+	dict_table_t*	prev_table;
+	dict_foreign_t*	foreign;
+	ulint		n_removed;
+	ulint		n_have_parent;
+	ulint		cached_foreign_tables;
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(mutex_own(&(dict_sys->mutex)));
+#endif /* UNIV_SYNC_DEBUG */
+
+retry:
+	n_removed = n_have_parent = 0;
+	table = UT_LIST_GET_LAST(dict_sys->table_LRU);
+
+	while ( srv_dict_size_limit && table
+		&& ((dict_sys->table_hash->n_cells
+		     + dict_sys->table_id_hash->n_cells) * sizeof(hash_cell_t)
+		    + dict_sys->size) > srv_dict_size_limit ) {
+		prev_table = UT_LIST_GET_PREV(table_LRU, table);
+
+		if (table == self || table->n_mysql_handles_opened)
+			goto next_loop;
+
+		cached_foreign_tables = 0;
+		foreign = UT_LIST_GET_FIRST(table->foreign_list);
+		while (foreign != NULL) {
+			if (foreign->referenced_table)
+				cached_foreign_tables++;
+			foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
+		}
+
+		if (cached_foreign_tables == 0) {
+			dict_table_remove_from_cache(table);
+			n_removed++;
+		} else {
+			n_have_parent++;
+		}
+next_loop:
+		table = prev_table;
+	}
+
+	if ( srv_dict_size_limit && n_have_parent && n_removed
+		&& ((dict_sys->table_hash->n_cells
+		     + dict_sys->table_id_hash->n_cells) * sizeof(hash_cell_t)
+		    + dict_sys->size) > srv_dict_size_limit )
+		goto retry;
+}
+
 /****************************************************************//**
 If the given column name is reserved for InnoDB system columns, return
 TRUE.
@@ -1728,6 +1790,11 @@
 	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 
+	/* remove all entry of the index from adaptive hash index,
+	because removing from adaptive hash index needs dict_index */
+	if (btr_search_enabled && srv_dict_size_limit)
+		btr_search_drop_page_hash_index_on_index(index);
+
 	/* We always create search info whether or not adaptive
 	hash index is enabled or not. */
 	info = index->search_info;
diff -ruN a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
--- a/storage/innobase/handler/ha_innodb.cc	2010-12-03 15:43:57.294986852 +0900
+++ b/storage/innobase/handler/ha_innodb.cc	2010-12-03 15:45:47.534959966 +0900
@@ -674,6 +674,8 @@
   (char*) &export_vars.innodb_dblwr_pages_written,	  SHOW_LONG},
   {"dblwr_writes",
   (char*) &export_vars.innodb_dblwr_writes,		  SHOW_LONG},
+  {"dict_tables",
+  (char*) &export_vars.innodb_dict_tables,		  SHOW_LONG},
   {"have_atomic_builtins",
   (char*) &export_vars.innodb_have_atomic_builtins,	  SHOW_BOOL},
   {"log_waits",
@@ -11642,6 +11644,11 @@
   "Choose method of innodb_adaptive_flushing. (native, [estimate], keep_average)",
   NULL, innodb_adaptive_flushing_method_update, 1, &adaptive_flushing_method_typelib);
 
+static MYSQL_SYSVAR_ULONG(dict_size_limit, srv_dict_size_limit,
+  PLUGIN_VAR_RQCMDARG,
+  "Limit the allocated memory for dictionary cache. (0: unlimited)",
+  NULL, NULL, 0, 0, LONG_MAX, 0);
+
 static struct st_mysql_sys_var* innobase_system_variables[]= {
   MYSQL_SYSVAR(additional_mem_pool_size),
   MYSQL_SYSVAR(autoextend_increment),
@@ -11709,6 +11716,7 @@
   MYSQL_SYSVAR(flush_neighbor_pages),
   MYSQL_SYSVAR(read_ahead),
   MYSQL_SYSVAR(adaptive_flushing_method),
+  MYSQL_SYSVAR(dict_size_limit),
   MYSQL_SYSVAR(use_sys_malloc),
   MYSQL_SYSVAR(use_native_aio),
   MYSQL_SYSVAR(change_buffering),
diff -ruN a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c
--- a/storage/innobase/ibuf/ibuf0ibuf.c	2010-12-03 15:18:48.889024455 +0900
+++ b/storage/innobase/ibuf/ibuf0ibuf.c	2010-12-03 15:45:47.553025057 +0900
@@ -566,6 +566,7 @@
 
 	/* Use old-style record format for the insert buffer. */
 	table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0);
+	table->n_mysql_handles_opened = 1; /* for pin */
 
 	dict_mem_table_add_col(table, heap, "DUMMY_COLUMN", DATA_BINARY, 0, 0);
 
diff -ruN a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h
--- a/storage/innobase/include/btr0sea.h	2010-11-03 07:01:13.000000000 +0900
+++ b/storage/innobase/include/btr0sea.h	2010-12-03 15:45:47.555024229 +0900
@@ -140,6 +140,13 @@
 				s- or x-latched, or an index page
 				for which we know that
 				block->buf_fix_count == 0 */
+/************************************************************************
+Drops a page hash index based on index */
+UNIV_INTERN
+void
+btr_search_drop_page_hash_index_on_index(
+/*=====================================*/
+	dict_index_t*	index);		/* in: record descriptor */
 /********************************************************************//**
 Drops a page hash index when a page is freed from a fseg to the file system.
 Drops possible hash index if the page happens to be in the buffer pool. */
diff -ruN a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
--- a/storage/innobase/include/buf0buf.h	2011-02-01 18:00:03.000000000 +0900
+++ b/storage/innobase/include/buf0buf.h	2011-02-01 18:03:29.000000000 +0900
@@ -1555,6 +1555,15 @@
 #define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
 /* @} */
 
+/** A chunk of buffers.  The buffer pool is allocated in chunks. */
+struct buf_chunk_struct{
+	ulint		mem_size;	/*!< allocated size of the chunk */
+	ulint		size;		/*!< size of frames[] and blocks[] */
+	void*		mem;		/*!< pointer to the memory area which
+					was allocated for the frames */
+	buf_block_t*	blocks;		/*!< array of buffer control blocks */
+};
+
 /** @brief The buffer pool statistics structure. */
 struct buf_pool_stat_struct{
 	ulint	n_page_gets;	/*!< number of page gets performed;
diff -ruN a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
--- a/storage/innobase/include/dict0dict.h	2010-11-03 07:01:13.000000000 +0900
+++ b/storage/innobase/include/dict0dict.h	2010-12-03 15:45:47.558024515 +0900
@@ -1170,6 +1170,12 @@
 /*====================================*/
 	dict_table_t*	table,	/*!< in: table */
 	const char*	name);	/*!< in: name of the index to find */
+
+UNIV_INTERN
+void
+dict_table_LRU_trim(
+/*================*/
+	dict_table_t*	self);
 /* Buffers for storing detailed information about the latest foreign key
 and unique key errors */
 extern FILE*	dict_foreign_err_file;
diff -ruN a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic
--- a/storage/innobase/include/dict0dict.ic	2010-11-03 07:01:13.000000000 +0900
+++ b/storage/innobase/include/dict0dict.ic	2010-12-03 15:45:47.560024398 +0900
@@ -824,6 +824,13 @@
 	HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold,
 		    dict_table_t*, table, ut_ad(table->cached),
 		    !strcmp(table->name, table_name));
+
+	/* make young in table_LRU */
+	if (table) {
+		UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
+		UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
+	}
+
 	return(table);
 }
 
@@ -905,6 +912,12 @@
 		table = dict_load_table_on_id(table_id);
 	}
 
+	/* make young in table_LRU */
+	if (table) {
+		UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
+		UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
+	}
+
 	ut_ad(!table || table->cached);
 
 	/* TODO: should get the type information from MySQL */
diff -ruN a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
--- a/storage/innobase/include/srv0srv.h	2010-12-03 15:43:57.297067100 +0900
+++ b/storage/innobase/include/srv0srv.h	2010-12-03 15:45:47.562024404 +0900
@@ -229,6 +229,7 @@
 extern ulint	srv_read_ahead;
 extern ulint	srv_adaptive_flushing_method;
 
+extern ulint	srv_dict_size_limit;
 /*-------------------------------------------*/
 
 extern ulint	srv_n_rows_inserted;
@@ -709,6 +710,7 @@
 	ulint innodb_data_writes;		/*!< I/O write requests */
 	ulint innodb_data_written;		/*!< Data bytes written */
 	ulint innodb_data_reads;		/*!< I/O read requests */
+	ulint innodb_dict_tables;
 	ulint innodb_buffer_pool_pages_total;	/*!< Buffer pool size */
 	ulint innodb_buffer_pool_pages_data;	/*!< Data pages */
 	ulint innodb_buffer_pool_pages_dirty;	/*!< Dirty data pages */
diff -ruN a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c
--- a/storage/innobase/srv/srv0srv.c	2010-12-03 15:43:57.301024390 +0900
+++ b/storage/innobase/srv/srv0srv.c	2010-12-03 15:45:47.565023830 +0900
@@ -415,6 +415,8 @@
 UNIV_INTERN ulint	srv_enable_unsafe_group_commit = 0; /* 0:disable 1:enable */
 UNIV_INTERN ulint	srv_read_ahead = 3; /* 1: random  2: linear  3: Both */
 UNIV_INTERN ulint	srv_adaptive_flushing_method = 0; /* 0: native  1: estimate  2: keep_average */
+
+UNIV_INTERN ulint	srv_dict_size_limit = 0;
 /*-------------------------------------------*/
 UNIV_INTERN ulong	srv_n_spin_wait_rounds	= 30;
 UNIV_INTERN ulong	srv_n_free_tickets_to_enter = 500;
@@ -2220,6 +2222,7 @@
 	export_vars.innodb_data_reads = os_n_file_reads;
 	export_vars.innodb_data_writes = os_n_file_writes;
 	export_vars.innodb_data_written = srv_data_written;
+	export_vars.innodb_dict_tables= (dict_sys ? UT_LIST_GET_LEN(dict_sys->table_LRU) : 0);
 	export_vars.innodb_buffer_pool_read_requests = stat.n_page_gets;
 	export_vars.innodb_buffer_pool_write_requests
 		= srv_buf_pool_write_requests;