Rev Author Line No. Line
250 kaklik 1 <?php
2 /* $Id: innodb.lib.php,v 2.8 2005/12/07 11:24:38 cybot_tm Exp $ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4  
5 class PMA_StorageEngine_innodb extends PMA_StorageEngine
6 {
7 /**
8 * @uses $GLOBALS['strInnoDBDataHomeDir']
9 * @uses $GLOBALS['strInnoDBDataHomeDirDesc']
10 * @uses $GLOBALS['strInnoDBDataFilePath']
11 * @uses $GLOBALS['strInnoDBAutoextendIncrement']
12 * @uses $GLOBALS['strInnoDBAutoextendIncrementDesc']
13 * @uses $GLOBALS['strInnoDBBufferPoolSize']
14 * @uses $GLOBALS['strInnoDBBufferPoolSizeDesc']
15 * @uses PMA_ENGINE_DETAILS_TYPE_NUMERIC
16 * @uses PMA_ENGINE_DETAILS_TYPE_SIZE
17 * @return array
18 */
19 function getVariables()
20 {
21 return array(
22 'innodb_data_home_dir' => array(
23 'title' => $GLOBALS['strInnoDBDataHomeDir'],
24 'desc' => $GLOBALS['strInnoDBDataHomeDirDesc'],
25 ),
26 'innodb_data_file_path' => array(
27 'title' => $GLOBALS['strInnoDBDataFilePath'],
28 ),
29 'innodb_autoextend_increment' => array(
30 'title' => $GLOBALS['strInnoDBAutoextendIncrement'],
31 'desc' => $GLOBALS['strInnoDBAutoextendIncrementDesc'],
32 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
33 ),
34 'innodb_buffer_pool_size' => array(
35 'title' => $GLOBALS['strInnoDBBufferPoolSize'],
36 'desc' => $GLOBALS['strInnoDBBufferPoolSizeDesc'],
37 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
38 ),
39 'innodb_additional_mem_pool_size' => array(
40 'title' => 'innodb_additional_mem_pool_size',
41 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
42 ),
43 'innodb_buffer_pool_awe_mem_mb' => array(
44 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
45 ),
46 'innodb_checksums' => array(
47 ),
48 'innodb_commit_concurrency' => array(
49 ),
50 'innodb_concurrency_tickets' => array(
51 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
52 ),
53 'innodb_doublewrite' => array(
54 ),
55 'innodb_fast_shutdown' => array(
56 ),
57 'innodb_file_io_threads' => array(
58 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
59 ),
60 'innodb_file_per_table' => array(
61 ),
62 'innodb_flush_log_at_trx_commit' => array(
63 ),
64 'innodb_flush_method' => array(
65 ),
66 'innodb_force_recovery' => array(
67 ),
68 'innodb_lock_wait_timeout' => array(
69 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
70 ),
71 'innodb_locks_unsafe_for_binlog' => array(
72 ),
73 'innodb_log_arch_dir' => array(
74 ),
75 'innodb_log_archive' => array(
76 ),
77 'innodb_log_buffer_size' => array(
78 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
79 ),
80 'innodb_log_file_size' => array(
81 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
82 ),
83 'innodb_log_files_in_group' => array(
84 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
85 ),
86 'innodb_log_group_home_dir' => array(
87 ),
88 'innodb_max_dirty_pages_pct' => array(
89 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
90 ),
91 'innodb_max_purge_lag' => array(
92 ),
93 'innodb_mirrored_log_groups' => array(
94 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
95 ),
96 'innodb_open_files' => array(
97 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
98 ),
99 'innodb_support_xa' => array(
100 ),
101 'innodb_sync_spin_loops' => array(
102 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
103 ),
104 'innodb_table_locks' => array(
105 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
106 ),
107 'innodb_thread_concurrency' => array(
108 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
109 ),
110 'innodb_thread_sleep_delay' => array(
111 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
112 ),
113 );
114 }
115  
116 /**
117 * @return string SQL query LIKE pattern
118 */
119 function getVariablesLikePattern()
120 {
121 return 'innodb\\_%';
122 }
123  
124 /**
125 * @uses $this->support
126 * @uses PMA_ENGINE_SUPPORT_YES
127 * @uses PMA_MYSQL_INT_VERSION
128 * @uses $GLOBALS['strBufferPool']
129 * @uses $GLOBALS['strInnodbStat']
130 * @return array detail pages
131 */
132 function getInfoPages()
133 {
134 if ($this->support < PMA_ENGINE_SUPPORT_YES) {
135 return array();
136 }
137 $pages = array();
138 if (PMA_MYSQL_INT_VERSION >= 50002) {
139 $pages['Bufferpool'] = $GLOBALS['strBufferPool'];
140 }
141 $pages['Status'] = $GLOBALS['strInnodbStat'];
142 return $pages;
143 }
144  
145 /**
146 * returns html tables with stats over inno db buffer pool
147 *
148 * @uses PMA_MYSQL_INT_VERSION
149 * @uses PMA_DBI_fetch_result()
150 * @uses PMA_formatNumber()
151 * @uses PMA_formatByteDown()
152 * @uses $GLOBALS['number_decimal_separator']
153 * @uses $GLOBALS['number_thousands_separator']
154 * @uses $GLOBALS['strBufferPoolUsage']
155 * @uses $GLOBALS['strTotalUC']
156 * @uses $GLOBALS['strInnoDBPages']
157 * @uses $GLOBALS['strFreePages']
158 * @uses $GLOBALS['strDirtyPages']
159 * @uses $GLOBALS['strDataPages']
160 * @uses $GLOBALS['strPagesToBeFlushed']
161 * @uses $GLOBALS['strBusyPages']
162 * @uses $GLOBALS['strLatchedPages']
163 * @uses $GLOBALS['strBufferPoolActivity']
164 * @uses $GLOBALS['strReadRequests']
165 * @uses $GLOBALS['strWriteRequests']
166 * @uses $GLOBALS['strBufferReadMisses']
167 * @uses $GLOBALS['strBufferWriteWaits']
168 * @uses $GLOBALS['strBufferReadMissesInPercent']
169 * @uses $GLOBALS['strBufferWriteWaitsInPercent']
170 * @uses join()
171 * @uses htmlspecialchars()
172 * @uses number_format()
173 * @return string html table with stats
174 */
175 function getPageBufferpool()
176 {
177 if (PMA_MYSQL_INT_VERSION < 50002) {
178 return false;
179 }
180 // rabus: The following query is only possible because we know
181 // that we are on MySQL 5 here (checked above)!
182 // side note: I love MySQL 5 for this. :-)
183 $sql = '
184 SHOW STATUS
185 WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
186 OR Variable_name = \'Innodb_page_size\';';
187 $status = PMA_DBI_fetch_result( $sql, 0, 1 );
188  
189 $output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n"
190 . ' <caption class="tblHeaders">' . "\n"
191 . ' ' . $GLOBALS['strBufferPoolUsage'] . "\n"
192 . ' </caption>' . "\n"
193 . ' <tfoot>' . "\n"
194 . ' <tr>' . "\n"
195 . ' <th colspan="2">' . "\n"
196 . ' ' . $GLOBALS['strTotalUC'] . "\n"
197 . ' : ' . PMA_formatNumber(
198 $status['Innodb_buffer_pool_pages_total'], 0)
199 . '&nbsp;' . $GLOBALS['strInnoDBPages']
200 . ' / '
201 . join('&nbsp;',
202 PMA_formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])) . "\n"
203 . ' </th>' . "\n"
204 . ' </tr>' . "\n"
205 . ' </tfoot>' . "\n"
206 . ' <tbody>' . "\n"
207 . ' <tr class="odd">' . "\n"
208 . ' <th>' . $GLOBALS['strFreePages'] . '</th>' . "\n"
209 . ' <td class="value">'
210 . PMA_formatNumber($status['Innodb_buffer_pool_pages_free'], 0)
211 . '</td>' . "\n"
212 . ' </tr>' . "\n"
213 . ' <tr class="even">' . "\n"
214 . ' <th>' . $GLOBALS['strDirtyPages'] . '</th>' . "\n"
215 . ' <td class="value">'
216 . PMA_formatNumber($status['Innodb_buffer_pool_pages_dirty'], 0)
217 . '</td>' . "\n"
218 . ' </tr>' . "\n"
219 . ' <tr class="odd">' . "\n"
220 . ' <th>' . $GLOBALS['strDataPages'] . '</th>' . "\n"
221 . ' <td class="value">'
222 . PMA_formatNumber($status['Innodb_buffer_pool_pages_data'], 0) . "\n"
223 . '</td>' . "\n"
224 . ' </tr>' . "\n"
225 . ' <tr class="even">' . "\n"
226 . ' <th>' . $GLOBALS['strPagesToBeFlushed'] . '</th>' . "\n"
227 . ' <td class="value">'
228 . PMA_formatNumber($status['Innodb_buffer_pool_pages_flushed'], 0) . "\n"
229 . '</td>' . "\n"
230 . ' </tr>' . "\n"
231 . ' <tr class="odd">' . "\n"
232 . ' <th>' . $GLOBALS['strBusyPages'] . '</th>' . "\n"
233 . ' <td class="value">'
234 . PMA_formatNumber($status['Innodb_buffer_pool_pages_misc'], 0) . "\n"
235 . '</td>' . "\n"
236 . ' </tr>' . "\n"
237 . ' <tr class="even">' . "\n"
238 . ' <th>' . $GLOBALS['strLatchedPages'] . '</th>' . "\n"
239 . ' <td class="value">'
240 . PMA_formatNumber($status['Innodb_buffer_pool_pages_latched'], 0) . "\n"
241 . '</td>' . "\n"
242 . ' </tr>' . "\n"
243 . ' </tbody>' . "\n"
244 . '</table>' . "\n\n"
245 . '<table class="data" id="table_innodb_bufferpool_activity">' . "\n"
246 . ' <caption class="tblHeaders">' . "\n"
247 . ' ' . $GLOBALS['strBufferPoolActivity'] . "\n"
248 . ' </caption>' . "\n"
249 . ' <tbody>' . "\n"
250 . ' <tr class="odd">' . "\n"
251 . ' <th>' . $GLOBALS['strReadRequests'] . '</th>' . "\n"
252 . ' <td class="value">'
253 . PMA_formatNumber($status['Innodb_buffer_pool_read_requests'], 0) . "\n"
254 . '</td>' . "\n"
255 . ' </tr>' . "\n"
256 . ' <tr class="even">' . "\n"
257 . ' <th>' . $GLOBALS['strWriteRequests'] . '</th>' . "\n"
258 . ' <td class="value">'
259 . PMA_formatNumber($status['Innodb_buffer_pool_write_requests'], 0) . "\n"
260 . '</td>' . "\n"
261 . ' </tr>' . "\n"
262 . ' <tr class="odd">' . "\n"
263 . ' <th>' . $GLOBALS['strBufferReadMisses'] . '</th>' . "\n"
264 . ' <td class="value">'
265 . PMA_formatNumber($status['Innodb_buffer_pool_reads'], 0) . "\n"
266 . '</td>' . "\n"
267 . ' </tr>' . "\n"
268 . ' <tr class="even">' . "\n"
269 . ' <th>' . $GLOBALS['strBufferWriteWaits'] . '</th>' . "\n"
270 . ' <td class="value">'
271 . PMA_formatNumber($status['Innodb_buffer_pool_wait_free'], 0) . "\n"
272 . '</td>' . "\n"
273 . ' </tr>' . "\n"
274 . ' <tr class="odd">' . "\n"
275 . ' <th>' . $GLOBALS['strBufferReadMissesInPercent'] . '</th>' . "\n"
276 . ' <td class="value">'
277 . ($status['Innodb_buffer_pool_read_requests'] == 0
278 ? '---'
279 : htmlspecialchars(number_format($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 2, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator'])) . ' %') . "\n"
280 . '</td>' . "\n"
281 . ' </tr>' . "\n"
282 . ' <tr class="even">' . "\n"
283 . ' <th>' . $GLOBALS['strBufferWriteWaitsInPercent'] . '</th>' . "\n"
284 . ' <td class="value">'
285 . ($status['Innodb_buffer_pool_write_requests'] == 0
286 ? '---'
287 : htmlspecialchars(number_format($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 2, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator'])) . ' %') . "\n"
288 . '</td>' . "\n"
289 . ' </tr>' . "\n"
290 . ' </tbody>' . "\n"
291 . '</table>' . "\n";
292 return $output;
293 }
294  
295 /**
296 * returns InnoDB status
297 *
298 * @uses htmlspecialchars()
299 * @uses PMA_DBI_fetch_value()
300 * @return string result of SHOW INNODB STATUS inside pre tags
301 */
302 function getPageStatus()
303 {
304 return '<pre id="pre_innodb_status">' . "\n"
305 . htmlspecialchars(PMA_DBI_fetch_value('SHOW INNODB STATUS;')) . "\n"
306 . '</pre>' . "\n";
307 }
308  
309 /**
310 * returns content for page $id
311 *
312 * @uses $this->getInfoPages()
313 * @uses array_key_exists()
314 * @param string $id page id
315 * @return string html output
316 */
317 function getPage($id)
318 {
319 if ( ! array_key_exists( $id, $this->getInfoPages() ) ) {
320 return false;
321 }
322  
323 $id = 'getPage' . $id;
324  
325 return $this->$id();
326 }
327  
328 /**
329 * returns string with filename for the MySQL helppage
330 * about this storage engne
331 *
332 * @return string mysql helppage filename
333 */
334 function getMysqlHelpPage()
335 {
336 return 'innodb';
337 }
338 }
339  
340 ?>