2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * The InnoDB storage engine
6 * @package PhpMyAdmin-Engines
8 if (! defined('PHPMYADMIN')) {
13 * The InnoDB storage engine
15 * @package PhpMyAdmin-Engines
17 class PMA_StorageEngine_innodb
extends PMA_StorageEngine
20 * Returns array with variable names related to InnoDB storage engine
22 * @return array variable names
24 function getVariables()
27 'innodb_data_home_dir' => array(
28 'title' => __('Data home directory'),
29 'desc' => __('The common part of the directory path for all InnoDB data files.'),
31 'innodb_data_file_path' => array(
32 'title' => __('Data files'),
34 'innodb_autoextend_increment' => array(
35 'title' => __('Autoextend increment'),
36 'desc' => __('The increment size for extending the size of an autoextending tablespace when it becomes full.'),
37 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
,
39 'innodb_buffer_pool_size' => array(
40 'title' => __('Buffer pool size'),
41 'desc' => __('The size of the memory buffer InnoDB uses to cache data and indexes of its tables.'),
42 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE
,
44 'innodb_additional_mem_pool_size' => array(
45 'title' => 'innodb_additional_mem_pool_size',
46 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE
,
48 'innodb_buffer_pool_awe_mem_mb' => array(
49 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE
,
51 'innodb_checksums' => array(
53 'innodb_commit_concurrency' => array(
55 'innodb_concurrency_tickets' => array(
56 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
,
58 'innodb_doublewrite' => array(
60 'innodb_fast_shutdown' => array(
62 'innodb_file_io_threads' => array(
63 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
,
65 'innodb_file_per_table' => array(
67 'innodb_flush_log_at_trx_commit' => array(
69 'innodb_flush_method' => array(
71 'innodb_force_recovery' => array(
73 'innodb_lock_wait_timeout' => array(
74 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
,
76 'innodb_locks_unsafe_for_binlog' => array(
78 'innodb_log_arch_dir' => array(
80 'innodb_log_archive' => array(
82 'innodb_log_buffer_size' => array(
83 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE
,
85 'innodb_log_file_size' => array(
86 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE
,
88 'innodb_log_files_in_group' => array(
89 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
,
91 'innodb_log_group_home_dir' => array(
93 'innodb_max_dirty_pages_pct' => array(
94 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
,
96 'innodb_max_purge_lag' => array(
98 'innodb_mirrored_log_groups' => array(
99 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
,
101 'innodb_open_files' => array(
102 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
,
104 'innodb_support_xa' => array(
106 'innodb_sync_spin_loops' => array(
107 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
,
109 'innodb_table_locks' => array(
110 'type' => PMA_ENGINE_DETAILS_TYPE_BOOLEAN
,
112 'innodb_thread_concurrency' => array(
113 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
,
115 'innodb_thread_sleep_delay' => array(
116 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
,
122 * Returns the pattern to be used in the query for SQL variables
123 * related to InnoDb storage engine
125 * @return string SQL query LIKE pattern
127 function getVariablesLikePattern()
133 * Get information pages
135 * @return array detail pages
137 function getInfoPages()
139 if ($this->support
< PMA_ENGINE_SUPPORT_YES
) {
143 $pages['Bufferpool'] = __('Buffer Pool');
144 $pages['Status'] = __('InnoDB Status');
149 * returns html tables with stats over inno db buffer pool
151 * @return string html table with stats
153 function getPageBufferpool()
155 // The following query is only possible because we know
156 // that we are on MySQL 5 here (checked above)!
157 // side note: I love MySQL 5 for this. :-)
160 WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
161 OR Variable_name = \'Innodb_page_size\';';
162 $status = PMA_DBI_fetch_result($sql, 0, 1);
164 $output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n"
165 . ' <caption class="tblHeaders">' . "\n"
166 . ' ' . __('Buffer Pool Usage') . "\n"
167 . ' </caption>' . "\n"
170 . ' <th colspan="2">' . "\n"
171 . ' ' . __('Total') . "\n"
173 . PMA_Util
::formatNumber(
174 $status['Innodb_buffer_pool_pages_total'], 0
176 . ' ' . __('pages')
180 PMA_Util
::formatByteDown(
181 $status['Innodb_buffer_pool_pages_total']
182 * $status['Innodb_page_size']
189 . ' <tr class="odd">' . "\n"
190 . ' <th>' . __('Free pages') . '</th>' . "\n"
191 . ' <td class="value">'
192 . PMA_Util
::formatNumber(
193 $status['Innodb_buffer_pool_pages_free'], 0
197 . ' <tr class="even">' . "\n"
198 . ' <th>' . __('Dirty pages') . '</th>' . "\n"
199 . ' <td class="value">'
200 . PMA_Util
::formatNumber(
201 $status['Innodb_buffer_pool_pages_dirty'], 0
205 . ' <tr class="odd">' . "\n"
206 . ' <th>' . __('Pages containing data') . '</th>' . "\n"
207 . ' <td class="value">'
208 . PMA_Util
::formatNumber(
209 $status['Innodb_buffer_pool_pages_data'], 0
213 . ' <tr class="even">' . "\n"
214 . ' <th>' . __('Pages to be flushed') . '</th>' . "\n"
215 . ' <td class="value">'
216 . PMA_Util
::formatNumber(
217 $status['Innodb_buffer_pool_pages_flushed'], 0
221 . ' <tr class="odd">' . "\n"
222 . ' <th>' . __('Busy pages') . '</th>' . "\n"
223 . ' <td class="value">'
224 . PMA_Util
::formatNumber(
225 $status['Innodb_buffer_pool_pages_misc'], 0
230 // not present at least since MySQL 5.1.40
231 if (isset($status['Innodb_buffer_pool_pages_latched'])) {
232 $output .= ' <tr class="even">'
233 . ' <th>' . __('Latched pages') . '</th>'
234 . ' <td class="value">'
235 . PMA_Util
::formatNumber(
236 $status['Innodb_buffer_pool_pages_latched'], 0
242 $output .= ' </tbody>' . "\n"
243 . '</table>' . "\n\n"
244 . '<table class="data" id="table_innodb_bufferpool_activity">' . "\n"
245 . ' <caption class="tblHeaders">' . "\n"
246 . ' ' . __('Buffer Pool Activity') . "\n"
247 . ' </caption>' . "\n"
249 . ' <tr class="odd">' . "\n"
250 . ' <th>' . __('Read requests') . '</th>' . "\n"
251 . ' <td class="value">'
252 . PMA_Util
::formatNumber(
253 $status['Innodb_buffer_pool_read_requests'], 0
257 . ' <tr class="even">' . "\n"
258 . ' <th>' . __('Write requests') . '</th>' . "\n"
259 . ' <td class="value">'
260 . PMA_Util
::formatNumber(
261 $status['Innodb_buffer_pool_write_requests'], 0
265 . ' <tr class="odd">' . "\n"
266 . ' <th>' . __('Read misses') . '</th>' . "\n"
267 . ' <td class="value">'
268 . PMA_Util
::formatNumber(
269 $status['Innodb_buffer_pool_reads'], 0
273 . ' <tr class="even">' . "\n"
274 . ' <th>' . __('Write waits') . '</th>' . "\n"
275 . ' <td class="value">'
276 . PMA_Util
::formatNumber(
277 $status['Innodb_buffer_pool_wait_free'], 0
281 . ' <tr class="odd">' . "\n"
282 . ' <th>' . __('Read misses in %') . '</th>' . "\n"
283 . ' <td class="value">'
284 . ($status['Innodb_buffer_pool_read_requests'] == 0
287 PMA_Util
::formatNumber(
288 $status['Innodb_buffer_pool_reads'] * 100
289 / $status['Innodb_buffer_pool_read_requests'],
296 . ' <tr class="even">' . "\n"
297 . ' <th>' . __('Write waits in %') . '</th>' . "\n"
298 . ' <td class="value">'
299 . ($status['Innodb_buffer_pool_write_requests'] == 0
302 PMA_Util
::formatNumber(
303 $status['Innodb_buffer_pool_wait_free'] * 100
304 / $status['Innodb_buffer_pool_write_requests'],
317 * returns InnoDB status
319 * @return string result of SHOW INNODB STATUS inside pre tags
321 function getPageStatus()
323 return '<pre id="pre_innodb_status">' . "\n"
325 PMA_DBI_fetch_value('SHOW INNODB STATUS;', 0, 'Status')
331 * Returns content for page $id
333 * @param string $id page id
335 * @return string html output
337 function getPage($id)
339 if (! array_key_exists($id, $this->getInfoPages())) {
343 $id = 'getPage' . $id;
349 * returns string with filename for the MySQL helppage
350 * about this storage engine
352 * @return string mysql helppage filename
354 function getMysqlHelpPage()
356 return 'innodb-storage-engine';
360 * Gets the InnoDB plugin version number
362 * http://www.innodb.com/products/innodb_plugin
363 * (do not confuse this with phpMyAdmin's storage engine plugins!)
365 * @return string the version number, or empty if not running as a plugin
367 function getInnodbPluginVersion()
369 return PMA_DBI_fetch_value('SELECT @@innodb_version;');
373 * Gets the InnoDB file format
375 * (works only for the InnoDB plugin)
376 * http://www.innodb.com/products/innodb_plugin
377 * (do not confuse this with phpMyAdmin's storage engine plugins!)
379 * @return string the InnoDB file format
381 function getInnodbFileFormat()
383 return PMA_DBI_fetch_value(
384 "SHOW GLOBAL VARIABLES LIKE 'innodb_file_format';", 0, 1
389 * Verifies if this server supports the innodb_file_per_table feature
391 * (works only for the InnoDB plugin)
392 * http://www.innodb.com/products/innodb_plugin
393 * (do not confuse this with phpMyAdmin's storage engine plugins!)
395 * @return boolean whether this feature is supported or not
397 function supportsFilePerTable()
399 $innodb_file_per_table = PMA_DBI_fetch_value(
400 "SHOW GLOBAL VARIABLES LIKE 'innodb_file_per_table';", 0, 1
402 if ($innodb_file_per_table == 'ON') {