]> git.pld-linux.org Git - packages/mysql.git/blob - innodb_buffer_pool_pages_i_s.patch
- more mysqld.conf changes: skip-locking, default-character-set
[packages/mysql.git] / innodb_buffer_pool_pages_i_s.patch
1 # name       : innodb_buffer_pool_pages_i_s.patch
2 # introduced : 11 or before
3 # maintainer : Yasufumi
4 #
5 #!!! notice !!!
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
8 diff -ruN a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c
9 --- a/storage/innobase/buf/buf0buf.c    2010-12-04 20:20:44.595483291 +0900
10 +++ b/storage/innobase/buf/buf0buf.c    2010-12-06 19:28:04.055227506 +0900
11 @@ -4515,6 +4515,36 @@
12         mutex_exit(block_mutex);
13  }
14  
15 +/********************************************************************//**
16 +*/
17 +UNIV_INTERN
18 +buf_block_t*
19 +buf_page_from_array(
20 +/*================*/
21 +       buf_pool_t*     buf_pool,
22 +       ulint           n_block)
23 +{
24 +       ulint           n_chunks, offset;
25 +       buf_chunk_t*    chunk;
26 +
27 +       ut_a(n_block < buf_pool->curr_size);
28 +
29 +       chunk = buf_pool->chunks;
30 +       offset = n_block;
31 +
32 +       for (n_chunks = buf_pool->n_chunks; n_chunks--; chunk++) {
33 +               if (offset < chunk->size) {
34 +                       return(&chunk->blocks[offset]);
35 +               }
36 +
37 +               offset -= chunk->size;
38 +       }
39 +
40 +       ut_error;
41 +
42 +       return(NULL);
43 +}
44 +
45  /*********************************************************************//**
46  Asserts that all file pages in the buffer are in a replaceable state.
47  @return        TRUE */
48 diff -ruN a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
49 --- a/storage/innobase/handler/ha_innodb.cc     2010-12-04 20:20:44.614551139 +0900
50 +++ b/storage/innobase/handler/ha_innodb.cc     2010-12-06 19:23:47.622195800 +0900
51 @@ -12042,6 +12042,9 @@
52  i_s_innodb_sys_stats,
53  i_s_innodb_table_stats,
54  i_s_innodb_index_stats,
55 +i_s_innodb_buffer_pool_pages,
56 +i_s_innodb_buffer_pool_pages_index,
57 +i_s_innodb_buffer_pool_pages_blob,
58  i_s_innodb_admin_command
59  mysql_declare_plugin_end;
60  
61 diff -ruN a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
62 --- a/storage/innobase/handler/i_s.cc   2010-12-04 19:46:39.786513783 +0900
63 +++ b/storage/innobase/handler/i_s.cc   2010-12-06 19:28:52.270226921 +0900
64 @@ -51,6 +51,7 @@
65  #include "trx0sys.h" /* for trx_sys */
66  #include "dict0dict.h" /* for dict_sys */
67  #include "buf0lru.h" /* for XTRA_LRU_[DUMP/RESTORE] */
68 +#include "btr0btr.h" /* for btr_page_get_index_id */
69  }
70  
71  static const char plugin_author[] = "Innobase Oy";
72 @@ -4328,3 +4329,701 @@
73         STRUCT_FLD(system_vars, NULL),
74         STRUCT_FLD(__reserved1, NULL)
75  };
76 +
77 +/***********************************************************************
78 +*/
79 +static ST_FIELD_INFO   i_s_innodb_buffer_pool_pages_fields_info[] =
80 +{
81 +       {STRUCT_FLD(field_name,         "page_type"),
82 +        STRUCT_FLD(field_length,       64),
83 +        STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
84 +        STRUCT_FLD(value,              0),
85 +        STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
86 +        STRUCT_FLD(old_name,           ""),
87 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
88 +
89 +       {STRUCT_FLD(field_name,         "space_id"),
90 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
91 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
92 +        STRUCT_FLD(value,              0),
93 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
94 +        STRUCT_FLD(old_name,           ""),
95 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
96 +
97 +       {STRUCT_FLD(field_name,         "page_no"),
98 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
99 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
100 +        STRUCT_FLD(value,              0),
101 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
102 +        STRUCT_FLD(old_name,           ""),
103 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
104 +
105 +       {STRUCT_FLD(field_name,         "lru_position"),
106 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
107 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
108 +        STRUCT_FLD(value,              0),
109 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
110 +        STRUCT_FLD(old_name,           ""),
111 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
112 +
113 +       {STRUCT_FLD(field_name,         "fix_count"),
114 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
115 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
116 +        STRUCT_FLD(value,              0),
117 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
118 +        STRUCT_FLD(old_name,           ""),
119 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
120 +
121 +       {STRUCT_FLD(field_name,         "flush_type"),
122 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
123 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
124 +        STRUCT_FLD(value,              0),
125 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
126 +        STRUCT_FLD(old_name,           ""),
127 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
128 +
129 +       END_OF_ST_FIELD_INFO
130 +};
131 +
132 +static ST_FIELD_INFO   i_s_innodb_buffer_pool_pages_index_fields_info[] =
133 +{
134 +       {STRUCT_FLD(field_name,         "index_id"),
135 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
136 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
137 +        STRUCT_FLD(value,              0),
138 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
139 +        STRUCT_FLD(old_name,           ""),
140 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
141 +
142 +       {STRUCT_FLD(field_name,         "space_id"),
143 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
144 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
145 +        STRUCT_FLD(value,              0),
146 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
147 +        STRUCT_FLD(old_name,           ""),
148 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
149 +
150 +       {STRUCT_FLD(field_name,         "page_no"),
151 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
152 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
153 +        STRUCT_FLD(value,              0),
154 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
155 +        STRUCT_FLD(old_name,           ""),
156 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
157 +
158 +       {STRUCT_FLD(field_name,         "n_recs"),
159 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
160 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
161 +        STRUCT_FLD(value,              0),
162 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
163 +        STRUCT_FLD(old_name,           ""),
164 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
165 +
166 +       {STRUCT_FLD(field_name,         "data_size"),
167 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
168 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
169 +        STRUCT_FLD(value,              0),
170 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
171 +        STRUCT_FLD(old_name,           ""),
172 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
173 +
174 +       {STRUCT_FLD(field_name,         "hashed"),
175 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
176 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
177 +        STRUCT_FLD(value,              0),
178 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
179 +        STRUCT_FLD(old_name,           ""),
180 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
181 +
182 +       {STRUCT_FLD(field_name,         "access_time"),
183 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
184 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
185 +        STRUCT_FLD(value,              0),
186 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
187 +        STRUCT_FLD(old_name,           ""),
188 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
189 +
190 +       {STRUCT_FLD(field_name,         "modified"),
191 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
192 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
193 +        STRUCT_FLD(value,              0),
194 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
195 +        STRUCT_FLD(old_name,           ""),
196 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
197 +
198 +       {STRUCT_FLD(field_name,         "dirty"),
199 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
200 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
201 +        STRUCT_FLD(value,              0),
202 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
203 +        STRUCT_FLD(old_name,           ""),
204 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
205 +
206 +       {STRUCT_FLD(field_name,         "old"),
207 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
208 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
209 +        STRUCT_FLD(value,              0),
210 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
211 +        STRUCT_FLD(old_name,           ""),
212 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
213 +
214 +       {STRUCT_FLD(field_name,         "lru_position"),
215 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
216 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
217 +        STRUCT_FLD(value,              0),
218 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
219 +        STRUCT_FLD(old_name,           ""),
220 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
221 +
222 +       {STRUCT_FLD(field_name,         "fix_count"),
223 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
224 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
225 +        STRUCT_FLD(value,              0),
226 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
227 +        STRUCT_FLD(old_name,           ""),
228 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
229 +
230 +       {STRUCT_FLD(field_name,         "flush_type"),
231 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
232 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
233 +        STRUCT_FLD(value,              0),
234 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
235 +        STRUCT_FLD(old_name,           ""),
236 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
237 +
238 +       END_OF_ST_FIELD_INFO
239 +};
240 +
241 +static ST_FIELD_INFO   i_s_innodb_buffer_pool_pages_blob_fields_info[] =
242 +{
243 +       {STRUCT_FLD(field_name,         "space_id"),
244 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
245 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
246 +        STRUCT_FLD(value,              0),
247 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
248 +        STRUCT_FLD(old_name,           ""),
249 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
250 +
251 +       {STRUCT_FLD(field_name,         "page_no"),
252 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
253 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
254 +        STRUCT_FLD(value,              0),
255 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
256 +        STRUCT_FLD(old_name,           ""),
257 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
258 +
259 +       {STRUCT_FLD(field_name,         "compressed"),
260 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
261 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
262 +        STRUCT_FLD(value,              0),
263 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
264 +        STRUCT_FLD(old_name,           ""),
265 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
266 +
267 +       {STRUCT_FLD(field_name,         "part_len"),
268 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
269 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
270 +        STRUCT_FLD(value,              0),
271 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
272 +        STRUCT_FLD(old_name,           ""),
273 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
274 +
275 +       {STRUCT_FLD(field_name,         "next_page_no"),
276 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
277 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
278 +        STRUCT_FLD(value,              0),
279 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
280 +        STRUCT_FLD(old_name,           ""),
281 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
282 +
283 +       {STRUCT_FLD(field_name,         "lru_position"),
284 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
285 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
286 +        STRUCT_FLD(value,              0),
287 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
288 +        STRUCT_FLD(old_name,           ""),
289 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
290 +
291 +       {STRUCT_FLD(field_name,         "fix_count"),
292 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
293 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
294 +        STRUCT_FLD(value,              0),
295 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
296 +        STRUCT_FLD(old_name,           ""),
297 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
298 +
299 +       {STRUCT_FLD(field_name,         "flush_type"),
300 +        STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
301 +        STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
302 +        STRUCT_FLD(value,              0),
303 +        STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
304 +        STRUCT_FLD(old_name,           ""),
305 +        STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
306 +
307 +       END_OF_ST_FIELD_INFO
308 +};
309 +
310 +/***********************************************************************
311 +Fill the dynamic table information_schema.innodb_buffer_pool_pages. */
312 +static
313 +int
314 +i_s_innodb_buffer_pool_pages_fill(
315 +/*================*/
316 +                               /* out: 0 on success, 1 on failure */
317 +       THD*            thd,    /* in: thread */
318 +       TABLE_LIST*     tables, /* in/out: tables to fill */
319 +       COND*           cond)   /* in: condition (ignored) */
320 +{
321 +       TABLE*  table   = (TABLE *) tables->table;
322 +       int     status  = 0;
323 +       ulint   i;
324 +
325 +       DBUG_ENTER("i_s_innodb_buffer_pool_pages_fill");
326 +
327 +       /* deny access to non-superusers */
328 +       if (check_global_access(thd, PROCESS_ACL)) {
329 +
330 +               DBUG_RETURN(0);
331 +       }
332 +
333 +       RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
334 +
335 +       for (i = 0; i < srv_buf_pool_instances; i++) {
336 +               ulint           n_block;
337 +               buf_pool_t*     buf_pool;
338 +
339 +               buf_pool = buf_pool_from_array(i);
340 +
341 +               buf_pool_mutex_enter(buf_pool);
342 +
343 +               for (n_block = 0; n_block < buf_pool->curr_size; n_block++) {
344 +                       buf_block_t*    block = buf_page_from_array(buf_pool, n_block);
345 +                       const buf_frame_t*      frame = block->frame;
346 +
347 +                       char page_type[64];
348 +
349 +                       switch(fil_page_get_type(frame))
350 +                       {
351 +                               case FIL_PAGE_INDEX:
352 +                                       strcpy(page_type, "index");
353 +                                       break;
354 +                               case FIL_PAGE_UNDO_LOG:
355 +                                       strcpy(page_type, "undo_log");
356 +                                       break;
357 +                               case FIL_PAGE_INODE:
358 +                                       strcpy(page_type, "inode");
359 +                                       break;
360 +                               case FIL_PAGE_IBUF_FREE_LIST:
361 +                                       strcpy(page_type, "ibuf_free_list");
362 +                                       break;
363 +                               case FIL_PAGE_TYPE_ALLOCATED:
364 +                                       strcpy(page_type, "allocated");
365 +                                       break;
366 +                               case FIL_PAGE_IBUF_BITMAP:
367 +                                       strcpy(page_type, "bitmap");
368 +                                       break;
369 +                               case FIL_PAGE_TYPE_SYS:
370 +                                       strcpy(page_type, "sys");
371 +                                       break;
372 +                               case FIL_PAGE_TYPE_TRX_SYS:
373 +                                       strcpy(page_type, "trx_sys");
374 +                                       break;
375 +                               case FIL_PAGE_TYPE_FSP_HDR:
376 +                                       strcpy(page_type, "fsp_hdr");
377 +                                       break;
378 +                               case FIL_PAGE_TYPE_XDES:
379 +                                       strcpy(page_type, "xdes");
380 +                                       break;
381 +                               case FIL_PAGE_TYPE_BLOB:
382 +                                       strcpy(page_type, "blob");
383 +                                       break;
384 +                               case FIL_PAGE_TYPE_ZBLOB:
385 +                                       strcpy(page_type, "zblob");
386 +                                       break;
387 +                               case FIL_PAGE_TYPE_ZBLOB2:
388 +                                       strcpy(page_type, "zblob2");
389 +                                       break;
390 +                               default:
391 +                                       sprintf(page_type, "unknown (type=%li)", fil_page_get_type(frame));
392 +                       }
393 +
394 +                       field_store_string(table->field[0], page_type);
395 +                       table->field[1]->store(block->page.space);
396 +                       table->field[2]->store(block->page.offset);
397 +                       table->field[3]->store(0);
398 +                       table->field[4]->store(block->page.buf_fix_count);
399 +                       table->field[5]->store(block->page.flush_type);
400 +
401 +                       if (schema_table_store_record(thd, table)) {
402 +                               status = 1;
403 +                               break;
404 +                       }
405 +
406 +               }      
407 +
408 +               buf_pool_mutex_exit(buf_pool);
409 +       }
410 +
411 +       DBUG_RETURN(status);
412 +}
413 +
414 +/***********************************************************************
415 +Fill the dynamic table information_schema.innodb_buffer_pool_pages_index. */
416 +static
417 +int
418 +i_s_innodb_buffer_pool_pages_index_fill(
419 +/*================*/
420 +                               /* out: 0 on success, 1 on failure */
421 +       THD*            thd,    /* in: thread */
422 +       TABLE_LIST*     tables, /* in/out: tables to fill */
423 +       COND*           cond)   /* in: condition (ignored) */
424 +{
425 +       TABLE*  table   = (TABLE *) tables->table;
426 +       int     status  = 0;
427 +       ulint   i;
428 +       index_id_t      index_id;
429 +
430 +       DBUG_ENTER("i_s_innodb_buffer_pool_pages_index_fill");
431 +
432 +       /* deny access to non-superusers */
433 +       if (check_global_access(thd, PROCESS_ACL)) {
434 +
435 +               DBUG_RETURN(0);
436 +       }
437 +
438 +       RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
439 +
440 +       for (i = 0; i < srv_buf_pool_instances; i++) {
441 +               ulint           n_block;
442 +               buf_pool_t*     buf_pool;
443 +
444 +               buf_pool = buf_pool_from_array(i);
445 +
446 +               buf_pool_mutex_enter(buf_pool);
447 +       
448 +               for (n_block = 0; n_block < buf_pool->curr_size; n_block++) {
449 +                       buf_block_t*    block = buf_page_from_array(buf_pool, n_block);
450 +                       const buf_frame_t* frame = block->frame;
451 +
452 +                       if (fil_page_get_type(frame) == FIL_PAGE_INDEX) {
453 +                               index_id = btr_page_get_index_id(frame);
454 +                               table->field[0]->store(index_id);
455 +                               table->field[1]->store(block->page.space);
456 +                               table->field[2]->store(block->page.offset);
457 +                               table->field[3]->store(page_get_n_recs(frame));
458 +                               table->field[4]->store(page_get_data_size(frame));
459 +                               table->field[5]->store(block->is_hashed);
460 +                               table->field[6]->store(block->page.access_time);
461 +                               table->field[7]->store(block->page.newest_modification != 0);
462 +                               table->field[8]->store(block->page.oldest_modification != 0);
463 +                               table->field[9]->store(block->page.old);
464 +                               table->field[10]->store(0);
465 +                               table->field[11]->store(block->page.buf_fix_count);
466 +                               table->field[12]->store(block->page.flush_type);
467 +
468 +                               if (schema_table_store_record(thd, table)) {
469 +                                       status = 1;
470 +                                       break;
471 +                               }
472 +                       }      
473 +               }
474 +
475 +               buf_pool_mutex_exit(buf_pool);
476 +       }
477 +
478 +       DBUG_RETURN(status);
479 +}
480 +
481 +/***********************************************************************
482 +Fill the dynamic table information_schema.innodb_buffer_pool_pages_index. */
483 +static
484 +int
485 +i_s_innodb_buffer_pool_pages_blob_fill(
486 +/*================*/
487 +                               /* out: 0 on success, 1 on failure */
488 +       THD*            thd,    /* in: thread */
489 +       TABLE_LIST*     tables, /* in/out: tables to fill */
490 +       COND*           cond)   /* in: condition (ignored) */
491 +{
492 +       TABLE*  table   = (TABLE *) tables->table;
493 +       int     status  = 0;
494 +       ulint   i;
495 +
496 +       ulint           part_len;
497 +       ulint           next_page_no;
498 +
499 +       DBUG_ENTER("i_s_innodb_buffer_pool_pages_blob_fill");
500 +
501 +       /* deny access to non-superusers */
502 +       if (check_global_access(thd, PROCESS_ACL)) {
503 +
504 +               DBUG_RETURN(0);
505 +       }
506 +
507 +       RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
508 +
509 +       for (i = 0; i < srv_buf_pool_instances; i++) {
510 +               ulint           n_block;
511 +               buf_pool_t*     buf_pool;
512 +
513 +               buf_pool = buf_pool_from_array(i);
514 +
515 +               buf_pool_mutex_enter(buf_pool);
516 +       
517 +               for (n_block = 0; n_block < buf_pool->curr_size; n_block++) {
518 +                       buf_block_t*    block = buf_page_from_array(buf_pool, n_block);
519 +                       page_zip_des_t* block_page_zip = buf_block_get_page_zip(block);
520 +                       const buf_frame_t* frame = block->frame;
521 +
522 +                       if (fil_page_get_type(frame) == FIL_PAGE_TYPE_BLOB) {
523 +
524 +                               if (UNIV_LIKELY_NULL(block_page_zip)) {
525 +                                       part_len = 0; /* hmm, can't figure it out */
526 +
527 +                                       next_page_no = mach_read_from_4(
528 +                                                       buf_block_get_frame(block)
529 +                                                       + FIL_PAGE_NEXT);        
530 +                               } else {
531 +                                       part_len = mach_read_from_4(
532 +                                                       buf_block_get_frame(block)
533 +                                                       + FIL_PAGE_DATA
534 +                                                       + 0 /*BTR_BLOB_HDR_PART_LEN*/);
535 +
536 +                                       next_page_no = mach_read_from_4(
537 +                                                       buf_block_get_frame(block)
538 +                                                       + FIL_PAGE_DATA
539 +                                                       + 4 /*BTR_BLOB_HDR_NEXT_PAGE_NO*/);
540 +                               }
541 +
542 +                               table->field[0]->store(block->page.space);
543 +                               table->field[1]->store(block->page.offset);
544 +                               table->field[2]->store(block_page_zip != NULL);
545 +                               table->field[3]->store(part_len);
546 +
547 +                               if(next_page_no == FIL_NULL)
548 +                               {
549 +                                       table->field[4]->store(0);
550 +                               } else {
551 +                                       table->field[4]->store(block->page.offset);
552 +                               }
553 +
554 +                               table->field[5]->store(0);
555 +                               table->field[6]->store(block->page.buf_fix_count);
556 +                               table->field[7]->store(block->page.flush_type);
557 +
558 +                               if (schema_table_store_record(thd, table)) {
559 +                                       status = 1;
560 +                                       break;
561 +                               }
562 +
563 +                       }
564 +               }      
565 +
566 +               buf_pool_mutex_exit(buf_pool);
567 +       }
568 +
569 +       DBUG_RETURN(status);
570 +}
571 +
572 +/***********************************************************************
573 +Bind the dynamic table information_schema.innodb_buffer_pool_pages. */
574 +static
575 +int
576 +i_s_innodb_buffer_pool_pages_init(
577 +/*=========*/
578 +                       /* out: 0 on success */
579 +       void*   p)      /* in/out: table schema object */
580 +{
581 +       DBUG_ENTER("i_s_innodb_buffer_pool_pages_init");
582 +       ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p;
583 +
584 +       schema->fields_info = i_s_innodb_buffer_pool_pages_fields_info;
585 +       schema->fill_table = i_s_innodb_buffer_pool_pages_fill;
586 +
587 +       DBUG_RETURN(0);
588 +}
589 +
590 +/***********************************************************************
591 +Bind the dynamic table information_schema.innodb_buffer_pool_pages. */
592 +static
593 +int
594 +i_s_innodb_buffer_pool_pages_index_init(
595 +/*=========*/
596 +                       /* out: 0 on success */
597 +       void*   p)      /* in/out: table schema object */
598 +{
599 +       DBUG_ENTER("i_s_innodb_buffer_pool_pages_index_init");
600 +       ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p;
601 +
602 +       schema->fields_info = i_s_innodb_buffer_pool_pages_index_fields_info;
603 +       schema->fill_table = i_s_innodb_buffer_pool_pages_index_fill;
604 +
605 +       DBUG_RETURN(0);
606 +}
607 +
608 +/***********************************************************************
609 +Bind the dynamic table information_schema.innodb_buffer_pool_pages. */
610 +static
611 +int
612 +i_s_innodb_buffer_pool_pages_blob_init(
613 +/*=========*/
614 +                       /* out: 0 on success */
615 +       void*   p)      /* in/out: table schema object */
616 +{
617 +       DBUG_ENTER("i_s_innodb_buffer_pool_pages_blob_init");
618 +       ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p;
619 +
620 +       schema->fields_info = i_s_innodb_buffer_pool_pages_blob_fields_info;
621 +       schema->fill_table = i_s_innodb_buffer_pool_pages_blob_fill;
622 +
623 +       DBUG_RETURN(0);
624 +}
625 +
626 +
627 +UNIV_INTERN struct st_mysql_plugin     i_s_innodb_buffer_pool_pages =
628 +{
629 +       /* the plugin type (a MYSQL_XXX_PLUGIN value) */
630 +       /* int */
631 +       STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
632 +
633 +       /* pointer to type-specific plugin descriptor */
634 +       /* void* */
635 +       STRUCT_FLD(info, &i_s_info),
636 +
637 +       /* plugin name */
638 +       /* const char* */
639 +       STRUCT_FLD(name, "INNODB_BUFFER_POOL_PAGES"),
640 +
641 +       /* plugin author (for SHOW PLUGINS) */
642 +       /* const char* */
643 +       STRUCT_FLD(author, plugin_author),
644 +
645 +       /* general descriptive text (for SHOW PLUGINS) */
646 +       /* const char* */
647 +       STRUCT_FLD(descr, "InnoDB buffer pool pages"),
648 +
649 +       /* the plugin license (PLUGIN_LICENSE_XXX) */
650 +       /* int */
651 +       STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
652 +
653 +       /* the function to invoke when plugin is loaded */
654 +       /* int (*)(void*); */
655 +       STRUCT_FLD(init, i_s_innodb_buffer_pool_pages_init),
656 +
657 +       /* the function to invoke when plugin is unloaded */
658 +       /* int (*)(void*); */
659 +       STRUCT_FLD(deinit, i_s_common_deinit),
660 +
661 +       /* plugin version (for SHOW PLUGINS) */
662 +       /* unsigned int */
663 +       STRUCT_FLD(version, 0x0100 /* 1.0 */),
664 +
665 +       /* struct st_mysql_show_var* */
666 +       STRUCT_FLD(status_vars, NULL),
667 +
668 +       /* struct st_mysql_sys_var** */
669 +       STRUCT_FLD(system_vars, NULL),
670 +
671 +       /* reserved for dependency checking */
672 +       /* void* */
673 +       STRUCT_FLD(__reserved1, NULL)
674 +};
675 +
676 +UNIV_INTERN struct st_mysql_plugin     i_s_innodb_buffer_pool_pages_index =
677 +{
678 +       /* the plugin type (a MYSQL_XXX_PLUGIN value) */
679 +       /* int */
680 +       STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
681 +
682 +       /* pointer to type-specific plugin descriptor */
683 +       /* void* */
684 +       STRUCT_FLD(info, &i_s_info),
685 +
686 +       /* plugin name */
687 +       /* const char* */
688 +       STRUCT_FLD(name, "INNODB_BUFFER_POOL_PAGES_INDEX"),
689 +
690 +       /* plugin author (for SHOW PLUGINS) */
691 +       /* const char* */
692 +       STRUCT_FLD(author, plugin_author),
693 +
694 +       /* general descriptive text (for SHOW PLUGINS) */
695 +       /* const char* */
696 +       STRUCT_FLD(descr, "InnoDB buffer pool index pages"),
697 +
698 +       /* the plugin license (PLUGIN_LICENSE_XXX) */
699 +       /* int */
700 +       STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
701 +
702 +       /* the function to invoke when plugin is loaded */
703 +       /* int (*)(void*); */
704 +       STRUCT_FLD(init, i_s_innodb_buffer_pool_pages_index_init),
705 +
706 +       /* the function to invoke when plugin is unloaded */
707 +       /* int (*)(void*); */
708 +       STRUCT_FLD(deinit, i_s_common_deinit),
709 +
710 +       /* plugin version (for SHOW PLUGINS) */
711 +       /* unsigned int */
712 +       STRUCT_FLD(version, 0x0100 /* 1.0 */),
713 +
714 +       /* struct st_mysql_show_var* */
715 +       STRUCT_FLD(status_vars, NULL),
716 +
717 +       /* struct st_mysql_sys_var** */
718 +       STRUCT_FLD(system_vars, NULL),
719 +
720 +       /* reserved for dependency checking */
721 +       /* void* */
722 +       STRUCT_FLD(__reserved1, NULL)
723 +};
724 +
725 +UNIV_INTERN struct st_mysql_plugin     i_s_innodb_buffer_pool_pages_blob =
726 +{
727 +       /* the plugin type (a MYSQL_XXX_PLUGIN value) */
728 +       /* int */
729 +       STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
730 +
731 +       /* pointer to type-specific plugin descriptor */
732 +       /* void* */
733 +       STRUCT_FLD(info, &i_s_info),
734 +
735 +       /* plugin name */
736 +       /* const char* */
737 +       STRUCT_FLD(name, "INNODB_BUFFER_POOL_PAGES_BLOB"),
738 +
739 +       /* plugin author (for SHOW PLUGINS) */
740 +       /* const char* */
741 +       STRUCT_FLD(author, plugin_author),
742 +
743 +       /* general descriptive text (for SHOW PLUGINS) */
744 +       /* const char* */
745 +       STRUCT_FLD(descr, "InnoDB buffer pool blob pages"),
746 +
747 +       /* the plugin license (PLUGIN_LICENSE_XXX) */
748 +       /* int */
749 +       STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
750 +
751 +       /* the function to invoke when plugin is loaded */
752 +       /* int (*)(void*); */
753 +       STRUCT_FLD(init, i_s_innodb_buffer_pool_pages_blob_init),
754 +
755 +       /* the function to invoke when plugin is unloaded */
756 +       /* int (*)(void*); */
757 +       STRUCT_FLD(deinit, i_s_common_deinit),
758 +
759 +       /* plugin version (for SHOW PLUGINS) */
760 +       /* unsigned int */
761 +       STRUCT_FLD(version, 0x0100 /* 1.0 */),
762 +
763 +       /* struct st_mysql_show_var* */
764 +       STRUCT_FLD(status_vars, NULL),
765 +
766 +       /* struct st_mysql_sys_var** */
767 +       STRUCT_FLD(system_vars, NULL),
768 +
769 +       /* reserved for dependency checking */
770 +       /* void* */
771 +       STRUCT_FLD(__reserved1, NULL)
772 +};
773 +
774 diff -ruN a/storage/innobase/handler/i_s.h b/storage/innobase/handler/i_s.h
775 --- a/storage/innobase/handler/i_s.h    2010-12-04 19:46:39.657513849 +0900
776 +++ b/storage/innobase/handler/i_s.h    2010-12-06 19:23:47.635192988 +0900
777 @@ -45,5 +45,8 @@
778  extern struct st_mysql_plugin  i_s_innodb_table_stats;
779  extern struct st_mysql_plugin  i_s_innodb_index_stats;
780  extern struct st_mysql_plugin  i_s_innodb_admin_command;
781 +extern struct st_mysql_plugin  i_s_innodb_buffer_pool_pages;
782 +extern struct st_mysql_plugin  i_s_innodb_buffer_pool_pages_index;
783 +extern struct st_mysql_plugin  i_s_innodb_buffer_pool_pages_blob;
784  
785  #endif /* i_s_h */
786 diff -ruN a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
787 --- a/storage/innobase/include/buf0buf.h        2010-12-04 19:46:40.197471531 +0900
788 +++ b/storage/innobase/include/buf0buf.h        2010-12-06 19:23:47.638195824 +0900
789 @@ -1143,6 +1143,14 @@
790  /*===========*/
791         const buf_pool_t*       buf_pool)       /*!< in: buffer pool */
792         __attribute__((nonnull, const));
793 +/********************************************************************//**
794 +*/
795 +UNIV_INTERN
796 +buf_block_t*
797 +buf_page_from_array(
798 +/*================*/
799 +       buf_pool_t*     buf_pool,
800 +       ulint           n_block);
801  /******************************************************************//**
802  Returns the buffer pool instance given a page instance
803  @return buf_pool */
This page took 0.08476 seconds and 3 git commands to generate.