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