Translation update done using Pootle.
[phpmyadmin/crack.git] / libraries / engines / innodb.lib.php
blobdfdc5da072026e41d89a240722313866ff9bed39
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @package phpMyAdmin-Engines
5 */
7 /**
9 * @package phpMyAdmin-Engines
11 class PMA_StorageEngine_innodb extends PMA_StorageEngine
13 /**
14 * @uses PMA_ENGINE_DETAILS_TYPE_NUMERIC
15 * @uses PMA_ENGINE_DETAILS_TYPE_SIZE
16 * @return array
18 function getVariables()
20 return array(
21 'innodb_data_home_dir' => array(
22 'title' => __('Data home directory'),
23 'desc' => __('The common part of the directory path for all InnoDB data files.'),
25 'innodb_data_file_path' => array(
26 'title' => __('Data files'),
28 'innodb_autoextend_increment' => array(
29 'title' => __('Autoextend increment'),
30 'desc' => __(' The increment size for extending the size of an autoextending tablespace when it becomes full.'),
31 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
33 'innodb_buffer_pool_size' => array(
34 'title' => __('Buffer pool size'),
35 'desc' => __('The size of the memory buffer InnoDB uses to cache data and indexes of its tables.'),
36 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
38 'innodb_additional_mem_pool_size' => array(
39 'title' => 'innodb_additional_mem_pool_size',
40 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
42 'innodb_buffer_pool_awe_mem_mb' => array(
43 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
45 'innodb_checksums' => array(
47 'innodb_commit_concurrency' => array(
49 'innodb_concurrency_tickets' => array(
50 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
52 'innodb_doublewrite' => array(
54 'innodb_fast_shutdown' => array(
56 'innodb_file_io_threads' => array(
57 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
59 'innodb_file_per_table' => array(
61 'innodb_flush_log_at_trx_commit' => array(
63 'innodb_flush_method' => array(
65 'innodb_force_recovery' => array(
67 'innodb_lock_wait_timeout' => array(
68 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
70 'innodb_locks_unsafe_for_binlog' => array(
72 'innodb_log_arch_dir' => array(
74 'innodb_log_archive' => array(
76 'innodb_log_buffer_size' => array(
77 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
79 'innodb_log_file_size' => array(
80 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
82 'innodb_log_files_in_group' => array(
83 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
85 'innodb_log_group_home_dir' => array(
87 'innodb_max_dirty_pages_pct' => array(
88 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
90 'innodb_max_purge_lag' => array(
92 'innodb_mirrored_log_groups' => array(
93 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
95 'innodb_open_files' => array(
96 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
98 'innodb_support_xa' => array(
100 'innodb_sync_spin_loops' => array(
101 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
103 'innodb_table_locks' => array(
104 'type' => PMA_ENGINE_DETAILS_TYPE_BOOLEAN,
106 'innodb_thread_concurrency' => array(
107 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
109 'innodb_thread_sleep_delay' => array(
110 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
116 * @return string SQL query LIKE pattern
118 function getVariablesLikePattern()
120 return 'innodb\\_%';
124 * @uses $this->support
125 * @uses PMA_ENGINE_SUPPORT_YES
126 * @return array detail pages
128 function getInfoPages()
130 if ($this->support < PMA_ENGINE_SUPPORT_YES) {
131 return array();
133 $pages = array();
134 $pages['Bufferpool'] = __('Buffer Pool');
135 $pages['Status'] = __('InnoDB Status');
136 return $pages;
140 * returns html tables with stats over inno db buffer pool
142 * @uses PMA_DBI_fetch_result()
143 * @uses PMA_formatNumber()
144 * @uses PMA_formatByteDown()
145 * @uses join()
146 * @uses htmlspecialchars()
147 * @uses PMA_formatNumber()
148 * @return string html table with stats
150 function getPageBufferpool()
152 // The following query is only possible because we know
153 // that we are on MySQL 5 here (checked above)!
154 // side note: I love MySQL 5 for this. :-)
155 $sql = '
156 SHOW STATUS
157 WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
158 OR Variable_name = \'Innodb_page_size\';';
159 $status = PMA_DBI_fetch_result($sql, 0, 1);
161 $output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n"
162 . ' <caption class="tblHeaders">' . "\n"
163 . ' ' . __('Buffer Pool Usage') . "\n"
164 . ' </caption>' . "\n"
165 . ' <tfoot>' . "\n"
166 . ' <tr>' . "\n"
167 . ' <th colspan="2">' . "\n"
168 . ' ' . __('Total') . "\n"
169 . ' : ' . PMA_formatNumber(
170 $status['Innodb_buffer_pool_pages_total'], 0)
171 . '&nbsp;' . __('pages')
172 . ' / '
173 . join('&nbsp;',
174 PMA_formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])) . "\n"
175 . ' </th>' . "\n"
176 . ' </tr>' . "\n"
177 . ' </tfoot>' . "\n"
178 . ' <tbody>' . "\n"
179 . ' <tr class="odd">' . "\n"
180 . ' <th>' . __('Free pages') . '</th>' . "\n"
181 . ' <td class="value">'
182 . PMA_formatNumber($status['Innodb_buffer_pool_pages_free'], 0)
183 . '</td>' . "\n"
184 . ' </tr>' . "\n"
185 . ' <tr class="even">' . "\n"
186 . ' <th>' . __('Dirty pages') . '</th>' . "\n"
187 . ' <td class="value">'
188 . PMA_formatNumber($status['Innodb_buffer_pool_pages_dirty'], 0)
189 . '</td>' . "\n"
190 . ' </tr>' . "\n"
191 . ' <tr class="odd">' . "\n"
192 . ' <th>' . __('Pages containing data') . '</th>' . "\n"
193 . ' <td class="value">'
194 . PMA_formatNumber($status['Innodb_buffer_pool_pages_data'], 0) . "\n"
195 . '</td>' . "\n"
196 . ' </tr>' . "\n"
197 . ' <tr class="even">' . "\n"
198 . ' <th>' . __('Pages to be flushed') . '</th>' . "\n"
199 . ' <td class="value">'
200 . PMA_formatNumber($status['Innodb_buffer_pool_pages_flushed'], 0) . "\n"
201 . '</td>' . "\n"
202 . ' </tr>' . "\n"
203 . ' <tr class="odd">' . "\n"
204 . ' <th>' . __('Busy pages') . '</th>' . "\n"
205 . ' <td class="value">'
206 . PMA_formatNumber($status['Innodb_buffer_pool_pages_misc'], 0) . "\n"
207 . '</td>' . "\n"
208 . ' </tr>';
210 // not present at least since MySQL 5.1.40
211 if (isset($status['Innodb_buffer_pool_pages_latched'])) {
212 $output .= ' <tr class="even">'
213 . ' <th>' . __('Latched pages') . '</th>'
214 . ' <td class="value">'
215 . PMA_formatNumber($status['Innodb_buffer_pool_pages_latched'], 0)
216 . '</td>'
217 . ' </tr>';
220 $output .= ' </tbody>' . "\n"
221 . '</table>' . "\n\n"
222 . '<table class="data" id="table_innodb_bufferpool_activity">' . "\n"
223 . ' <caption class="tblHeaders">' . "\n"
224 . ' ' . __('Buffer Pool Activity') . "\n"
225 . ' </caption>' . "\n"
226 . ' <tbody>' . "\n"
227 . ' <tr class="odd">' . "\n"
228 . ' <th>' . __('Read requests') . '</th>' . "\n"
229 . ' <td class="value">'
230 . PMA_formatNumber($status['Innodb_buffer_pool_read_requests'], 0) . "\n"
231 . '</td>' . "\n"
232 . ' </tr>' . "\n"
233 . ' <tr class="even">' . "\n"
234 . ' <th>' . __('Write requests') . '</th>' . "\n"
235 . ' <td class="value">'
236 . PMA_formatNumber($status['Innodb_buffer_pool_write_requests'], 0) . "\n"
237 . '</td>' . "\n"
238 . ' </tr>' . "\n"
239 . ' <tr class="odd">' . "\n"
240 . ' <th>' . __('Read misses') . '</th>' . "\n"
241 . ' <td class="value">'
242 . PMA_formatNumber($status['Innodb_buffer_pool_reads'], 0) . "\n"
243 . '</td>' . "\n"
244 . ' </tr>' . "\n"
245 . ' <tr class="even">' . "\n"
246 . ' <th>' . __('Write waits') . '</th>' . "\n"
247 . ' <td class="value">'
248 . PMA_formatNumber($status['Innodb_buffer_pool_wait_free'], 0) . "\n"
249 . '</td>' . "\n"
250 . ' </tr>' . "\n"
251 . ' <tr class="odd">' . "\n"
252 . ' <th>' . __('Read misses in %') . '</th>' . "\n"
253 . ' <td class="value">'
254 . ($status['Innodb_buffer_pool_read_requests'] == 0
255 ? '---'
256 : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 3, 2)) . ' %') . "\n"
257 . '</td>' . "\n"
258 . ' </tr>' . "\n"
259 . ' <tr class="even">' . "\n"
260 . ' <th>' . __('Write waits in %') . '</th>' . "\n"
261 . ' <td class="value">'
262 . ($status['Innodb_buffer_pool_write_requests'] == 0
263 ? '---'
264 : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 3, 2)) . ' %') . "\n"
265 . '</td>' . "\n"
266 . ' </tr>' . "\n"
267 . ' </tbody>' . "\n"
268 . '</table>' . "\n";
269 return $output;
273 * returns InnoDB status
275 * @uses htmlspecialchars()
276 * @uses PMA_DBI_fetch_value()
277 * @return string result of SHOW INNODB STATUS inside pre tags
279 function getPageStatus()
281 return '<pre id="pre_innodb_status">' . "\n"
282 . htmlspecialchars(PMA_DBI_fetch_value('SHOW INNODB STATUS;', 0, 'Status')) . "\n"
283 . '</pre>' . "\n";
287 * returns content for page $id
289 * @uses $this->getInfoPages()
290 * @uses array_key_exists()
291 * @param string $id page id
292 * @return string html output
294 function getPage($id)
296 if (! array_key_exists($id, $this->getInfoPages())) {
297 return false;
300 $id = 'getPage' . $id;
302 return $this->$id();
306 * returns string with filename for the MySQL helppage
307 * about this storage engne
309 * @return string mysql helppage filename
311 function getMysqlHelpPage()
313 return 'innodb';
318 * Gets the InnoDB plugin version number
319 * http://www.innodb.com/products/innodb_plugin
320 * (do not confuse this with phpMyAdmin's storage engine plugins!)
322 * @return string the version number, or empty if not running as a plugin
324 function getInnodbPluginVersion()
326 return PMA_DBI_fetch_value('SELECT @@innodb_version;');
331 * Gets the InnoDB file format
332 * (works only for the InnoDB plugin)
333 * http://www.innodb.com/products/innodb_plugin
334 * (do not confuse this with phpMyAdmin's storage engine plugins!)
336 * @return string the InnoDB file format
338 function getInnodbFileFormat()
340 return PMA_DBI_fetch_value("SHOW GLOBAL VARIABLES LIKE 'innodb_file_format';", 0, 1);
345 * Verifies if this server supports the innodb_file_per_table feature
346 * (works only for the InnoDB plugin)
347 * http://www.innodb.com/products/innodb_plugin
348 * (do not confuse this with phpMyAdmin's storage engine plugins!)
350 * @return boolean whether this feature is supported or not
352 function supportsFilePerTable()
354 $innodb_file_per_table = PMA_DBI_fetch_value("SHOW GLOBAL VARIABLES LIKE 'innodb_file_per_table';", 0, 1);
355 if ($innodb_file_per_table == 'ON') {
356 return true;
357 } else {
358 return false;