~knielsen/ourdelta/bug_484127_484120_2

« back to all changes in this revision

Viewing changes to mysql/5.0/percona_maintained/innodb_dict_size_limit.patch

  • Committer: Arjen Lentz
  • Date: 2009-10-01 11:15:22 UTC
  • mfrom: (54.1.31 ourdelta-5.0.86)
  • Revision ID: arjen@openquery.com-20091001111522-3qbkgich9qfmzhyo
Tags: mysql-5.0.86-d9
Merge from ourdelta-5.0.86 work tree, preparing 5.0.86-d9 ourdelta build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
diff -ru mysql-5.0.75_base/innobase/dict/dict0boot.c mysql-5.0.75/innobase/dict/dict0boot.c
2
 
--- mysql-5.0.75_base/innobase/dict/dict0boot.c 2008-12-19 02:19:35.000000000 +0900
3
 
+++ mysql-5.0.75/innobase/dict/dict0boot.c      2009-01-23 19:28:25.000000000 +0900
 
1
diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
 
2
--- a/innobase/btr/btr0sea.c    2009-08-27 18:42:17.000000000 +0900
 
3
+++ b/innobase/btr/btr0sea.c    2009-08-27 18:43:11.000000000 +0900
 
4
@@ -1077,6 +1077,124 @@
 
5
 }
 
6
 
 
7
 /************************************************************************
 
8
+Drops a page hash index based on index */
 
9
+
 
10
+void
 
11
+btr_search_drop_page_hash_index_on_index(
 
12
+/*=====================================*/
 
13
+       dict_index_t*   index)          /* in: record descriptor */
 
14
+{
 
15
+       page_t*         page;
 
16
+       hash_table_t*   table;
 
17
+       buf_block_t*    block;
 
18
+       ulint           n_fields;
 
19
+       ulint           n_bytes;
 
20
+       rec_t*          rec;
 
21
+       ulint           fold;
 
22
+       ulint           prev_fold;
 
23
+       dulint          tree_id;
 
24
+       ulint           n_cached;
 
25
+       ulint           n_recs;
 
26
+       ulint*          folds;
 
27
+       ulint           i;
 
28
+       mem_heap_t*     heap    = NULL;
 
29
+       ulint*          offsets;
 
30
+
 
31
+       rw_lock_x_lock(&btr_search_latch);
 
32
+       mutex_enter(&buf_pool->mutex);
 
33
+
 
34
+       table = btr_search_sys->hash_index;
 
35
+
 
36
+       block = UT_LIST_GET_LAST(buf_pool->LRU);
 
37
+
 
38
+       while (block != NULL) {
 
39
+               if (block->index == index && block->is_hashed) {
 
40
+                       page = block->frame;
 
41
+
 
42
+                       /* from btr_search_drop_page_hash_index() */
 
43
+                       n_fields = block->curr_n_fields;
 
44
+                       n_bytes = block->curr_n_bytes;
 
45
+
 
46
+                       ut_a(n_fields + n_bytes > 0);
 
47
+
 
48
+                       n_recs = page_get_n_recs(page);
 
49
+
 
50
+                       /* Calculate and cache fold values into an array for fast deletion
 
51
+                       from the hash index */
 
52
+
 
53
+                       folds = mem_alloc(n_recs * sizeof(ulint));
 
54
+
 
55
+                       n_cached = 0;
 
56
+
 
57
+                       rec = page_get_infimum_rec(page);
 
58
+                       rec = page_rec_get_next(rec);
 
59
+
 
60
+                       tree_id = btr_page_get_index_id(page);
 
61
+       
 
62
+                       ut_a(0 == ut_dulint_cmp(tree_id, index->id));
 
63
+
 
64
+                       prev_fold = 0;
 
65
+
 
66
+                       offsets = NULL;
 
67
+
 
68
+                       while (!page_rec_is_supremum(rec)) {
 
69
+                               /* FIXME: in a mixed tree, not all records may have enough
 
70
+                               ordering fields: */
 
71
+                               offsets = rec_get_offsets(rec, index, offsets,
 
72
+                                                       n_fields + (n_bytes > 0), &heap);
 
73
+                               ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
 
74
+                               fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id);
 
75
+
 
76
+                               if (fold == prev_fold && prev_fold != 0) {
 
77
+
 
78
+                                       goto next_rec;
 
79
+                               }
 
80
+
 
81
+                               /* Remove all hash nodes pointing to this page from the
 
82
+                               hash chain */
 
83
+
 
84
+                               folds[n_cached] = fold;
 
85
+                               n_cached++;
 
86
+next_rec:
 
87
+                               rec = page_rec_get_next(rec);
 
88
+                               prev_fold = fold;
 
89
+                       }
 
90
+
 
91
+                       for (i = 0; i < n_cached; i++) {
 
92
+
 
93
+                               ha_remove_all_nodes_to_page(table, folds[i], page);
 
94
+                       }
 
95
+
 
96
+                       ut_a(index->search_info->ref_count > 0);
 
97
+                       index->search_info->ref_count--;
 
98
+
 
99
+                       block->is_hashed = FALSE;
 
100
+                       block->index = NULL;
 
101
+       
 
102
+                       if (UNIV_UNLIKELY(block->n_pointers)) {
 
103
+                               /* Corruption */
 
104
+                               ut_print_timestamp(stderr);
 
105
+                               fprintf(stderr,
 
106
+"  InnoDB: Corruption of adaptive hash index. After dropping\n"
 
107
+"InnoDB: the hash index to a page of %s, still %lu hash nodes remain.\n",
 
108
+                                       index->name, (ulong) block->n_pointers);
 
109
+                       }
 
110
+
 
111
+                       mem_free(folds);
 
112
+               }
 
113
+
 
114
+               block = UT_LIST_GET_PREV(LRU, block);
 
115
+       }
 
116
+
 
117
+       mutex_exit(&buf_pool->mutex);
 
118
+       rw_lock_x_unlock(&btr_search_latch);
 
119
+
 
120
+       if (UNIV_LIKELY_NULL(heap)) {
 
121
+               mem_heap_free(heap);
 
122
+       }
 
123
+}
 
124
+
 
125
+/************************************************************************
 
126
 Drops a page hash index when a page is freed from a fseg to the file system.
 
127
 Drops possible hash index if the page happens to be in the buffer pool. */
 
128
 
 
129
diff -ruN a/innobase/dict/dict0boot.c b/innobase/dict/dict0boot.c
 
130
--- a/innobase/dict/dict0boot.c 2009-07-07 21:53:58.000000000 +0900
 
131
+++ b/innobase/dict/dict0boot.c 2009-08-27 18:42:59.000000000 +0900
4
132
@@ -247,6 +247,7 @@
5
133
        system tables */
6
134
        /*-------------------------*/
33
161
 
34
162
        dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0,0,0);
35
163
        dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
36
 
diff -ru mysql-5.0.75_base/innobase/dict/dict0crea.c mysql-5.0.75/innobase/dict/dict0crea.c
37
 
--- mysql-5.0.75_base/innobase/dict/dict0crea.c 2008-12-19 02:19:35.000000000 +0900
38
 
+++ mysql-5.0.75/innobase/dict/dict0crea.c      2009-01-23 19:41:38.000000000 +0900
 
164
diff -ruN a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c
 
165
--- a/innobase/dict/dict0crea.c 2009-07-07 21:53:58.000000000 +0900
 
166
+++ b/innobase/dict/dict0crea.c 2009-08-27 18:42:59.000000000 +0900
39
167
@@ -1178,6 +1178,9 @@
40
168
                /* Foreign constraint system tables have already been
41
169
                created, and they are ok */
46
174
                mutex_exit(&(dict_sys->mutex));
47
175
 
48
176
                return(DB_SUCCESS);
49
 
@@ -1266,6 +1269,11 @@
 
177
@@ -1267,6 +1270,11 @@
50
178
        
51
179
        trx->op_info = "";
52
180
 
58
186
        row_mysql_unlock_data_dictionary(trx);
59
187
 
60
188
        trx_free_for_mysql(trx);
61
 
diff -ru mysql-5.0.75_base/innobase/dict/dict0dict.c mysql-5.0.75/innobase/dict/dict0dict.c
62
 
--- mysql-5.0.75_base/innobase/dict/dict0dict.c 2008-12-19 02:19:35.000000000 +0900
63
 
+++ mysql-5.0.75/innobase/dict/dict0dict.c      2009-01-26 16:03:29.000000000 +0900
 
189
diff -ruN a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c
 
190
--- a/innobase/dict/dict0dict.c 2009-07-07 21:53:58.000000000 +0900
 
191
+++ b/innobase/dict/dict0dict.c 2009-08-27 18:43:11.000000000 +0900
64
192
@@ -638,6 +638,8 @@
65
193
        mutex_enter(&(dict_sys->mutex));
66
194
 
156
284
        while (table && (dict_sys->size >
157
285
                         buf_pool_get_max_size() / DICT_POOL_PER_VARYING)) {
158
286
 
159
 
@@ -1292,6 +1341,7 @@
 
287
@@ -1292,6 +1342,7 @@
160
288
 
161
289
                table = prev_table;
162
290
        }
164
292
 }
165
293
 
166
294
 /**************************************************************************
167
 
diff -ru mysql-5.0.75_base/innobase/ibuf/ibuf0ibuf.c mysql-5.0.75/innobase/ibuf/ibuf0ibuf.c
168
 
--- mysql-5.0.75_base/innobase/ibuf/ibuf0ibuf.c 2009-01-23 11:44:18.000000000 +0900
169
 
+++ mysql-5.0.75/innobase/ibuf/ibuf0ibuf.c      2009-01-23 19:22:54.000000000 +0900
 
295
@@ -1565,6 +1616,10 @@
 
296
 #ifdef UNIV_SYNC_DEBUG
 
297
        ut_ad(mutex_own(&(dict_sys->mutex)));
 
298
 #endif /* UNIV_SYNC_DEBUG */
 
299
+       /* remove all entry of the index from adaptive hash index,
 
300
+       because removing from adaptive hash index needs dict_index */
 
301
+       if (srv_use_adaptive_hash_indexes && srv_dict_size_limit)
 
302
+               btr_search_drop_page_hash_index_on_index(index);
 
303
 
 
304
        /* We always create search info whether or not adaptive
 
305
        hash index is enabled or not. */
 
306
diff -ruN a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
 
307
--- a/innobase/ibuf/ibuf0ibuf.c 2009-08-27 18:42:17.000000000 +0900
 
308
+++ b/innobase/ibuf/ibuf0ibuf.c 2009-08-27 18:42:59.000000000 +0900
170
309
@@ -535,6 +535,7 @@
171
310
        sprintf(buf, "SYS_IBUF_TABLE_%lu", (ulong) space);
172
311
        /* use old-style record format for the insert buffer */
175
314
 
176
315
        dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0, 0);
177
316
        dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0, 0);
178
 
diff -ru mysql-5.0.75_base/innobase/include/dict0dict.h mysql-5.0.75/innobase/include/dict0dict.h
179
 
--- mysql-5.0.75_base/innobase/include/dict0dict.h      2008-12-19 02:19:35.000000000 +0900
180
 
+++ mysql-5.0.75/innobase/include/dict0dict.h   2009-01-23 21:46:22.000000000 +0900
 
317
diff -ruN a/innobase/include/btr0sea.h b/innobase/include/btr0sea.h
 
318
--- a/innobase/include/btr0sea.h        2009-07-07 21:54:00.000000000 +0900
 
319
+++ b/innobase/include/btr0sea.h        2009-08-27 18:43:11.000000000 +0900
 
320
@@ -97,6 +97,13 @@
 
321
 /*============================*/
 
322
        page_t* page);  /* in: index page, s- or x-latched */
 
323
 /************************************************************************
 
324
+Drops a page hash index based on index */
 
325
+
 
326
+void
 
327
+btr_search_drop_page_hash_index_on_index(
 
328
+/*=====================================*/
 
329
+       dict_index_t*   index);         /* in: record descriptor */
 
330
+/************************************************************************
 
331
 Drops a page hash index when a page is freed from a fseg to the file system.
 
332
 Drops possible hash index if the page happens to be in the buffer pool. */
 
333
 
 
334
diff -ruN a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h
 
335
--- a/innobase/include/dict0dict.h      2009-07-07 21:54:01.000000000 +0900
 
336
+++ b/innobase/include/dict0dict.h      2009-08-27 18:42:59.000000000 +0900
181
337
@@ -938,6 +938,11 @@
182
338
        const char*     ptr,    /* in: scan from */
183
339
        const char*     string);/* in: look for this */
190
346
 /* Buffers for storing detailed information about the latest foreign key
191
347
 and unique key errors */
192
348
 extern FILE*   dict_foreign_err_file;
193
 
diff -ru mysql-5.0.75_base/innobase/include/dict0dict.ic mysql-5.0.75/innobase/include/dict0dict.ic
194
 
--- mysql-5.0.75_base/innobase/include/dict0dict.ic     2008-12-19 02:19:35.000000000 +0900
195
 
+++ mysql-5.0.75/innobase/include/dict0dict.ic  2009-01-23 18:35:55.000000000 +0900
 
349
diff -ruN a/innobase/include/dict0dict.ic b/innobase/include/dict0dict.ic
 
350
--- a/innobase/include/dict0dict.ic     2009-07-07 21:54:01.000000000 +0900
 
351
+++ b/innobase/include/dict0dict.ic     2009-08-27 18:42:59.000000000 +0900
196
352
@@ -533,6 +533,13 @@
197
353
 
198
354
        HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold, table,
218
374
                /* lock_push(trx, table, LOCK_DICT_MEM_FIX) */
219
375
        }
220
376
        
221
 
diff -ru mysql-5.0.75_base/innobase/include/srv0srv.h mysql-5.0.75/innobase/include/srv0srv.h
222
 
--- mysql-5.0.75_base/innobase/include/srv0srv.h        2009-01-23 11:44:19.000000000 +0900
223
 
+++ mysql-5.0.75/innobase/include/srv0srv.h     2009-01-27 10:47:26.000000000 +0900
224
 
@@ -146,6 +146,8 @@
 
377
diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
 
378
--- a/innobase/include/srv0srv.h        2009-08-27 18:42:17.000000000 +0900
 
379
+++ b/innobase/include/srv0srv.h        2009-08-27 18:42:59.000000000 +0900
 
380
@@ -147,6 +147,8 @@
225
381
 extern uint    srv_read_ahead;
226
 
 extern ulint   srv_adaptive_checkpoint;
 
382
 extern uint    srv_adaptive_checkpoint;
227
383
 
228
384
+extern ulint   srv_dict_size_limit;
229
385
+
230
386
 extern volatile ibool srv_io_pattern;
231
387
 extern ulong   srv_io_pattern_trace;
232
388
 extern ulong   srv_io_pattern_trace_running;
233
 
@@ -545,6 +547,7 @@
 
389
@@ -552,6 +554,7 @@
234
390
         ulint innodb_data_writes;
235
391
         ulint innodb_data_written;
236
392
         ulint innodb_data_reads;
238
394
         ulint innodb_buffer_pool_pages_total;
239
395
         ulint innodb_buffer_pool_pages_data;
240
396
         ulint innodb_buffer_pool_pages_dirty;
241
 
diff -ru mysql-5.0.75_base/innobase/srv/srv0srv.c mysql-5.0.75/innobase/srv/srv0srv.c
242
 
--- mysql-5.0.75_base/innobase/srv/srv0srv.c    2009-01-23 11:44:19.000000000 +0900
243
 
+++ mysql-5.0.75/innobase/srv/srv0srv.c 2009-01-27 10:52:19.000000000 +0900
244
 
@@ -345,6 +345,8 @@
 
397
diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
 
398
--- a/innobase/srv/srv0srv.c    2009-08-27 18:42:17.000000000 +0900
 
399
+++ b/innobase/srv/srv0srv.c    2009-08-27 18:42:59.000000000 +0900
 
400
@@ -353,6 +353,8 @@
245
401
 uint   srv_read_ahead = 3; /* 1: random  2: linear  3: Both */
246
 
 ulint  srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
 
402
 uint   srv_adaptive_checkpoint = 0; /* 0: none  1: reflex  2: estimate */
247
403
 
248
404
+ulint  srv_dict_size_limit = 0;
249
405
+
250
406
 volatile ibool srv_io_pattern = FALSE;
251
407
 ulint   srv_io_pattern_trace = 0;
252
408
 ulint   srv_io_pattern_trace_running = 0;
253
 
@@ -1936,6 +1938,7 @@
 
409
@@ -1953,6 +1955,7 @@
254
410
         export_vars.innodb_data_reads= os_n_file_reads;
255
411
         export_vars.innodb_data_writes= os_n_file_writes;
256
412
         export_vars.innodb_data_written= srv_data_written;
258
414
         export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
259
415
         export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
260
416
         export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
261
 
diff -ru mysql-5.0.75_base/sql/ha_innodb.cc mysql-5.0.75/sql/ha_innodb.cc
262
 
--- mysql-5.0.75_base/sql/ha_innodb.cc  2009-01-23 11:44:19.000000000 +0900
263
 
+++ mysql-5.0.75/sql/ha_innodb.cc       2009-01-27 10:54:08.000000000 +0900
 
417
diff -ruN a/mysql-test/r/innodb_dict_size_limit.result b/mysql-test/r/innodb_dict_size_limit.result
 
418
--- /dev/null   1970-01-01 09:00:00.000000000 +0900
 
419
+++ b/mysql-test/r/innodb_dict_size_limit.result        2009-08-27 18:42:59.000000000 +0900
 
420
@@ -0,0 +1,60 @@
 
421
+DROP TABLE IF EXISTS `test_5`;
 
422
+DROP TABLE IF EXISTS `test_4`;
 
423
+DROP TABLE IF EXISTS `test_3`;
 
424
+DROP TABLE IF EXISTS `test_2`;
 
425
+DROP TABLE IF EXISTS `test_1`;
 
426
+SET storage_engine=InnoDB;
 
427
+SET GLOBAL innodb_dict_size_limit=1;
 
428
+FLUSH TABLES;
 
429
+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY  (`a`));
 
430
+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY  (`a`));
 
431
+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY  (`a`));
 
432
+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY  (`a`));
 
433
+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY  (`a`));
 
434
+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
 
435
+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
 
436
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
437
+Variable_name  Value
 
438
+Innodb_dict_tables     9
 
439
+FLUSH TABLES;
 
440
+SELECT * FROM `test_1`;
 
441
+a      b
 
442
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
443
+Variable_name  Value
 
444
+Innodb_dict_tables     8
 
445
+SELECT * FROM `test_3`;
 
446
+a      b
 
447
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
448
+Variable_name  Value
 
449
+Innodb_dict_tables     11
 
450
+FLUSH TABLES;
 
451
+SELECT * FROM `test_2`;
 
452
+a      b
 
453
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
454
+Variable_name  Value
 
455
+Innodb_dict_tables     8
 
456
+SELECT * FROM `test_1`;
 
457
+a      b
 
458
+FLUSH TABLES;
 
459
+SELECT * FROM `test_4`;
 
460
+a      b
 
461
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
462
+Variable_name  Value
 
463
+Innodb_dict_tables     9
 
464
+SELECT * FROM `test_3`;
 
465
+a      b
 
466
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
467
+Variable_name  Value
 
468
+Innodb_dict_tables     10
 
469
+SET GLOBAL innodb_dict_size_limit=0;
 
470
+FLUSH TABLES;
 
471
+SELECT * FROM `test_2`;
 
472
+a      b
 
473
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
474
+Variable_name  Value
 
475
+Innodb_dict_tables     11
 
476
+DROP TABLE `test_5`;
 
477
+DROP TABLE `test_4`;
 
478
+DROP TABLE `test_3`;
 
479
+DROP TABLE `test_2`;
 
480
+DROP TABLE `test_1`;
 
481
diff -ruN a/mysql-test/t/innodb_dict_size_limit.test b/mysql-test/t/innodb_dict_size_limit.test
 
482
--- /dev/null   1970-01-01 09:00:00.000000000 +0900
 
483
+++ b/mysql-test/t/innodb_dict_size_limit.test  2009-08-27 18:42:59.000000000 +0900
 
484
@@ -0,0 +1,63 @@
 
485
+#
 
486
+# Test for new variable innodb_dict_size_limit;
 
487
+#
 
488
+-- source include/have_innodb.inc
 
489
+
 
490
+--disable_warnings
 
491
+DROP TABLE IF EXISTS `test_5`;
 
492
+DROP TABLE IF EXISTS `test_4`;
 
493
+DROP TABLE IF EXISTS `test_3`;
 
494
+DROP TABLE IF EXISTS `test_2`;
 
495
+DROP TABLE IF EXISTS `test_1`;
 
496
+--enable_warnings
 
497
+
 
498
+SET storage_engine=InnoDB;
 
499
+SET GLOBAL innodb_dict_size_limit=1;
 
500
+
 
501
+FLUSH TABLES;
 
502
+
 
503
+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY  (`a`));
 
504
+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY  (`a`));
 
505
+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY  (`a`));
 
506
+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY  (`a`));
 
507
+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY  (`a`));
 
508
+
 
509
+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
 
510
+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
 
511
+
 
512
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
513
+
 
514
+FLUSH TABLES;
 
515
+SELECT * FROM `test_1`;
 
516
+
 
517
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
518
+
 
519
+SELECT * FROM `test_3`;
 
520
+
 
521
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
522
+
 
523
+FLUSH TABLES;
 
524
+SELECT * FROM `test_2`;
 
525
+
 
526
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
527
+
 
528
+SELECT * FROM `test_1`;
 
529
+FLUSH TABLES;
 
530
+SELECT * FROM `test_4`;
 
531
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
532
+
 
533
+SELECT * FROM `test_3`;
 
534
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
535
+
 
536
+SET GLOBAL innodb_dict_size_limit=0;
 
537
+FLUSH TABLES;
 
538
+SELECT * FROM `test_2`;
 
539
+
 
540
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
 
541
+
 
542
+DROP TABLE `test_5`;
 
543
+DROP TABLE `test_4`;
 
544
+DROP TABLE `test_3`;
 
545
+DROP TABLE `test_2`;
 
546
+DROP TABLE `test_1`;
 
547
+
 
548
diff -ruN a/patch_info/innodb_dict_size_limit.info b/patch_info/innodb_dict_size_limit.info
 
549
--- /dev/null   1970-01-01 09:00:00.000000000 +0900
 
550
+++ b/patch_info/innodb_dict_size_limit.info    2009-08-27 18:42:59.000000000 +0900
 
551
@@ -0,0 +1,9 @@
 
552
+File=innodb_dict_size_limit.patch
 
553
+Name=Limit dictionary cache size
 
554
+Version=1.0
 
555
+Author=Percona
 
556
+License=GPL
 
557
+Comment=Variable innodb_dict_size_limit in bytes
 
558
+ChangeLog=
 
559
+2009-01-26
 
560
+YK: Initial release
 
561
diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
 
562
--- a/sql/ha_innodb.cc  2009-08-27 18:42:17.000000000 +0900
 
563
+++ b/sql/ha_innodb.cc  2009-08-27 18:42:59.000000000 +0900
264
564
@@ -288,6 +288,8 @@
265
565
   (char*) &export_vars.innodb_dblwr_pages_written,        SHOW_LONG},
266
566
   {"dblwr_writes",
270
570
   {"log_waits",
271
571
   (char*) &export_vars.innodb_log_waits,                  SHOW_LONG},
272
572
   {"log_write_requests",
273
 
diff -ru mysql-5.0.75_base/sql/ha_innodb.h mysql-5.0.75/sql/ha_innodb.h
274
 
--- mysql-5.0.75_base/sql/ha_innodb.h   2009-01-23 11:44:19.000000000 +0900
275
 
+++ mysql-5.0.75/sql/ha_innodb.h        2009-01-26 15:49:37.000000000 +0900
276
 
@@ -242,6 +242,7 @@
277
 
 extern ulong srv_flush_neighbor_pages;
 
573
diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
 
574
--- a/sql/ha_innodb.h   2009-08-27 18:42:17.000000000 +0900
 
575
+++ b/sql/ha_innodb.h   2009-08-27 18:42:59.000000000 +0900
 
576
@@ -243,6 +243,7 @@
 
577
 extern ulong srv_enable_unsafe_group_commit;
278
578
 extern uint srv_read_ahead;
279
 
 extern ulong srv_adaptive_checkpoint;
 
579
 extern uint srv_adaptive_checkpoint;
280
580
+extern ulong srv_dict_size_limit;
281
581
 extern ulong srv_show_locks_held;
282
582
 extern ulong srv_show_verbose_locks;
283
583
 extern ulong srv_io_pattern_trace;
284
 
diff -ru mysql-5.0.75_base/sql/mysqld.cc mysql-5.0.75/sql/mysqld.cc
285
 
--- mysql-5.0.75_base/sql/mysqld.cc     2009-01-23 11:44:19.000000000 +0900
286
 
+++ mysql-5.0.75/sql/mysqld.cc  2009-01-26 15:29:45.000000000 +0900
287
 
@@ -5053,6 +5053,7 @@
 
584
diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
 
585
--- a/sql/mysqld.cc     2009-08-27 18:42:17.000000000 +0900
 
586
+++ b/sql/mysqld.cc     2009-08-27 18:42:59.000000000 +0900
 
587
@@ -5101,6 +5101,7 @@
288
588
   OPT_INNODB_ADAPTIVE_CHECKPOINT,
289
589
   OPT_INNODB_READ_IO_THREADS,
290
590
   OPT_INNODB_WRITE_IO_THREADS,
291
591
+  OPT_INNODB_DICT_SIZE_LIMIT,
292
592
   OPT_INNODB_ADAPTIVE_HASH_INDEX,
293
 
   OPT_RPL_MIRROR_BINLOG,
294
 
   OPT_SYNC_MIRROR_BINLOG,
295
 
@@ -5406,6 +5407,10 @@
 
593
   OPT_FEDERATED,
 
594
   OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
 
595
@@ -5464,6 +5465,10 @@
296
596
    "Number of background write I/O threads in InnoDB.",
297
597
    (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
298
 
    0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
 
598
    0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
299
599
+  {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
300
600
+   "Limit the allocated memory for dictionary cache. (0: unlimited)",
301
601
+   (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
303
603
   {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
304
604
    "Create/Drop the internal hash table for IO pattern tracing.",
305
605
    (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
306
 
diff -ru mysql-5.0.75_base/sql/set_var.cc mysql-5.0.75/sql/set_var.cc
307
 
--- mysql-5.0.75_base/sql/set_var.cc    2009-01-23 11:44:19.000000000 +0900
308
 
+++ mysql-5.0.75/sql/set_var.cc 2009-01-26 15:46:45.000000000 +0900
309
 
@@ -522,6 +522,8 @@
310
 
                                       &innodb_read_ahead_typelib, fix_innodb_read_ahead);
311
 
 sys_var_long_ptr       sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
312
 
                                                       &srv_adaptive_checkpoint);
 
606
diff -ruN a/sql/set_var.cc b/sql/set_var.cc
 
607
--- a/sql/set_var.cc    2009-08-27 18:42:17.000000000 +0900
 
608
+++ b/sql/set_var.cc    2009-08-27 18:42:59.000000000 +0900
 
609
@@ -540,6 +540,8 @@
 
610
 sys_var_enum   sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
 
611
                            &srv_adaptive_checkpoint,
 
612
                            &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
313
613
+sys_var_long_ptr       sys_innodb_dict_size_limit("innodb_dict_size_limit",
314
614
+                                                   &srv_dict_size_limit);
315
615
 sys_var_long_ptr  sys_innodb_show_locks_held(
316
616
                                         "innodb_show_locks_held",
317
617
                                         &srv_show_locks_held);
318
 
@@ -905,6 +907,7 @@
319
 
   &sys_innodb_flush_neighbor_pages,
 
618
@@ -930,6 +932,7 @@
320
619
   &sys_innodb_read_ahead,
 
620
   &sys_innodb_enable_unsafe_group_commit,
321
621
   &sys_innodb_adaptive_checkpoint,
322
622
+  &sys_innodb_dict_size_limit,
323
623
   &sys_innodb_show_locks_held,
324
624
   &sys_innodb_show_verbose_locks,
325
625
   &sys_innodb_io_pattern_trace,
326
 
@@ -1056,6 +1059,7 @@
 
626
@@ -1084,6 +1087,7 @@
327
627
   {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
328
628
   {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
329
629
   {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
331
631
   {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
332
632
   {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
333
633
   {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
334
 
diff -ruN mysql-5.0.75_base/mysql-test/r/innodb_dict_size_limit.result mysql-5.0.75/mysql-test/r/innodb_dict_size_limit.result
335
 
--- /dev/null   1970-01-01 09:00:00.000000000 +0900
336
 
+++ mysql-5.0.75/mysql-test/r/innodb_dict_size_limit.result     2009-01-27 11:43:46.000000000 +0900
337
 
@@ -0,0 +1,60 @@
338
 
+DROP TABLE IF EXISTS `test_5`;
339
 
+DROP TABLE IF EXISTS `test_4`;
340
 
+DROP TABLE IF EXISTS `test_3`;
341
 
+DROP TABLE IF EXISTS `test_2`;
342
 
+DROP TABLE IF EXISTS `test_1`;
343
 
+SET storage_engine=InnoDB;
344
 
+SET GLOBAL innodb_dict_size_limit=1;
345
 
+FLUSH TABLES;
346
 
+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY  (`a`));
347
 
+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY  (`a`));
348
 
+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY  (`a`));
349
 
+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY  (`a`));
350
 
+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY  (`a`));
351
 
+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
352
 
+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
353
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
354
 
+Variable_name  Value
355
 
+Innodb_dict_tables     9
356
 
+FLUSH TABLES;
357
 
+SELECT * FROM `test_1`;
358
 
+a      b
359
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
360
 
+Variable_name  Value
361
 
+Innodb_dict_tables     8
362
 
+SELECT * FROM `test_3`;
363
 
+a      b
364
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
365
 
+Variable_name  Value
366
 
+Innodb_dict_tables     11
367
 
+FLUSH TABLES;
368
 
+SELECT * FROM `test_2`;
369
 
+a      b
370
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
371
 
+Variable_name  Value
372
 
+Innodb_dict_tables     8
373
 
+SELECT * FROM `test_1`;
374
 
+a      b
375
 
+FLUSH TABLES;
376
 
+SELECT * FROM `test_4`;
377
 
+a      b
378
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
379
 
+Variable_name  Value
380
 
+Innodb_dict_tables     9
381
 
+SELECT * FROM `test_3`;
382
 
+a      b
383
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
384
 
+Variable_name  Value
385
 
+Innodb_dict_tables     10
386
 
+SET GLOBAL innodb_dict_size_limit=0;
387
 
+FLUSH TABLES;
388
 
+SELECT * FROM `test_2`;
389
 
+a      b
390
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
391
 
+Variable_name  Value
392
 
+Innodb_dict_tables     11
393
 
+DROP TABLE `test_5`;
394
 
+DROP TABLE `test_4`;
395
 
+DROP TABLE `test_3`;
396
 
+DROP TABLE `test_2`;
397
 
+DROP TABLE `test_1`;
398
 
diff -ruN mysql-5.0.75_base/mysql-test/t/innodb_dict_size_limit.test mysql-5.0.75/mysql-test/t/innodb_dict_size_limit.test
399
 
--- /dev/null   1970-01-01 09:00:00.000000000 +0900
400
 
+++ mysql-5.0.75/mysql-test/t/innodb_dict_size_limit.test       2009-01-27 11:43:36.000000000 +0900
401
 
@@ -0,0 +1,63 @@
402
 
+#
403
 
+# Test for new variable innodb_dict_size_limit;
404
 
+#
405
 
+-- source include/have_innodb.inc
406
 
+
407
 
+--disable_warnings
408
 
+DROP TABLE IF EXISTS `test_5`;
409
 
+DROP TABLE IF EXISTS `test_4`;
410
 
+DROP TABLE IF EXISTS `test_3`;
411
 
+DROP TABLE IF EXISTS `test_2`;
412
 
+DROP TABLE IF EXISTS `test_1`;
413
 
+--enable_warnings
414
 
+
415
 
+SET storage_engine=InnoDB;
416
 
+SET GLOBAL innodb_dict_size_limit=1;
417
 
+
418
 
+FLUSH TABLES;
419
 
+
420
 
+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY  (`a`));
421
 
+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY  (`a`));
422
 
+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY  (`a`));
423
 
+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY  (`a`));
424
 
+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY  (`a`));
425
 
+
426
 
+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
427
 
+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
428
 
+
429
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
430
 
+
431
 
+FLUSH TABLES;
432
 
+SELECT * FROM `test_1`;
433
 
+
434
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
435
 
+
436
 
+SELECT * FROM `test_3`;
437
 
+
438
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
439
 
+
440
 
+FLUSH TABLES;
441
 
+SELECT * FROM `test_2`;
442
 
+
443
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
444
 
+
445
 
+SELECT * FROM `test_1`;
446
 
+FLUSH TABLES;
447
 
+SELECT * FROM `test_4`;
448
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
449
 
+
450
 
+SELECT * FROM `test_3`;
451
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
452
 
+
453
 
+SET GLOBAL innodb_dict_size_limit=0;
454
 
+FLUSH TABLES;
455
 
+SELECT * FROM `test_2`;
456
 
+
457
 
+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
458
 
+
459
 
+DROP TABLE `test_5`;
460
 
+DROP TABLE `test_4`;
461
 
+DROP TABLE `test_3`;
462
 
+DROP TABLE `test_2`;
463
 
+DROP TABLE `test_1`;
464
 
+
465
 
diff -ruN mysql-5.0.75_base/patch_info/innodb_dict_size_limit.info mysql-5.0.75/patch_info/innodb_dict_size_limit.info
466
 
--- /dev/null   1970-01-01 09:00:00.000000000 +0900
467
 
+++ mysql-5.0.75/patch_info/innodb_dict_size_limit.info 2009-01-26 15:46:45.000000000 +0900
468
 
@@ -0,0 +1,9 @@
469
 
+File=innodb_dict_size_limit.patch
470
 
+Name=Limit dictionary cache size
471
 
+Version=1.0
472
 
+Author=Percona
473
 
+License=GPL
474
 
+Comment=Variable innodb_dict_size_limit in bytes
475
 
+ChangeLog=
476
 
+2009-01-26
477
 
+YK: Initial release