Welcome to mirror list, hosted at ThFree Co, Russian Federation.

innodb.lib.php « engines « libraries - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e3dd1831589ff99860f1b674d3ebc5d94d05ea29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * @version $Id$
 * @package phpMyAdmin-Engines
 */

/**
 *
 * @package phpMyAdmin-Engines
 */
class PMA_StorageEngine_innodb extends PMA_StorageEngine
{
    /**
     * @uses    __('Data home directory')
     * @uses    __('The common part of the directory path for all InnoDB data files.')
     * @uses    __('Data files')
     * @uses    __('Autoextend increment')
     * @uses    __(' The increment size for extending the size of an autoextending tablespace when it becomes full.')
     * @uses    __('Buffer pool size')
     * @uses    __('The size of the memory buffer InnoDB uses to cache data and indexes of its tables.')
     * @uses    PMA_ENGINE_DETAILS_TYPE_NUMERIC
     * @uses    PMA_ENGINE_DETAILS_TYPE_SIZE
     * @return  array
     */
    function getVariables()
    {
        return array(
            'innodb_data_home_dir' => array(
                'title' => __('Data home directory'),
                'desc'  => __('The common part of the directory path for all InnoDB data files.'),
            ),
            'innodb_data_file_path' => array(
                'title' => __('Data files'),
            ),
            'innodb_autoextend_increment' => array(
                'title' => __('Autoextend increment'),
                'desc'  => __(' The increment size for extending the size of an autoextending tablespace when it becomes full.'),
                'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
            ),
            'innodb_buffer_pool_size' => array(
                'title' => __('Buffer pool size'),
                'desc'  => __('The size of the memory buffer InnoDB uses to cache data and indexes of its tables.'),
                'type'  => PMA_ENGINE_DETAILS_TYPE_SIZE,
            ),
            'innodb_additional_mem_pool_size' => array(
                'title' => 'innodb_additional_mem_pool_size',
                'type'  => PMA_ENGINE_DETAILS_TYPE_SIZE,
            ),
            'innodb_buffer_pool_awe_mem_mb' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_SIZE,
            ),
            'innodb_checksums' => array(
            ),
            'innodb_commit_concurrency' => array(
            ),
            'innodb_concurrency_tickets' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
            ),
            'innodb_doublewrite' => array(
            ),
            'innodb_fast_shutdown' => array(
            ),
            'innodb_file_io_threads' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
            ),
            'innodb_file_per_table' => array(
            ),
            'innodb_flush_log_at_trx_commit' => array(
            ),
            'innodb_flush_method' => array(
            ),
            'innodb_force_recovery' => array(
            ),
            'innodb_lock_wait_timeout' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
            ),
            'innodb_locks_unsafe_for_binlog' => array(
            ),
            'innodb_log_arch_dir' => array(
            ),
            'innodb_log_archive' => array(
            ),
            'innodb_log_buffer_size' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_SIZE,
            ),
            'innodb_log_file_size' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_SIZE,
            ),
            'innodb_log_files_in_group' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
            ),
            'innodb_log_group_home_dir' => array(
            ),
            'innodb_max_dirty_pages_pct' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
            ),
            'innodb_max_purge_lag' => array(
            ),
            'innodb_mirrored_log_groups' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
            ),
            'innodb_open_files' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
            ),
            'innodb_support_xa' => array(
            ),
            'innodb_sync_spin_loops' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
            ),
            'innodb_table_locks' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_BOOLEAN,
            ),
            'innodb_thread_concurrency' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
            ),
            'innodb_thread_sleep_delay' => array(
                'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
            ),
         );
    }

    /**
     * @return  string  SQL query LIKE pattern
     */
    function getVariablesLikePattern()
    {
        return 'innodb\\_%';
    }

    /**
     * @uses    $this->support
     * @uses    PMA_ENGINE_SUPPORT_YES
     * @uses    __('Buffer Pool')
     * @uses    __('InnoDB Status')
     * @return  array   detail pages
     */
    function getInfoPages()
    {
        if ($this->support < PMA_ENGINE_SUPPORT_YES) {
            return array();
        }
        $pages = array();
        $pages['Bufferpool'] = __('Buffer Pool');
        $pages['Status'] = __('InnoDB Status');
        return $pages;
    }

    /**
     * returns html tables with stats over inno db buffer pool
     *
     * @uses    PMA_DBI_fetch_result()
     * @uses    PMA_formatNumber()
     * @uses    PMA_formatByteDown()
     * @uses    __('Buffer Pool Usage')
     * @uses    __('Total')
     * @uses    __('pages')
     * @uses    __('Free pages')
     * @uses    __('Dirty pages')
     * @uses    __('Pages containing data')
     * @uses    __('Pages to be flushed')
     * @uses    __('Busy pages')
     * @uses    __('Latched pages')
     * @uses    __('Buffer Pool Activity')
     * @uses    __('Read requests')
     * @uses    __('Write requests')
     * @uses    __('Read misses')
     * @uses    __('Write waits')
     * @uses    __('Read misses in %')
     * @uses    __('Write waits in %')
     * @uses    join()
     * @uses    htmlspecialchars()
     * @uses    PMA_formatNumber()
     * @return  string  html table with stats
     */
    function getPageBufferpool()
    {
        // The following query is only possible because we know
        // that we are on MySQL 5 here (checked above)!
        // side note: I love MySQL 5 for this. :-)
        $sql = '
             SHOW STATUS
            WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
               OR Variable_name = \'Innodb_page_size\';';
        $status = PMA_DBI_fetch_result($sql, 0, 1);

        $output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n"
                . '    <caption class="tblHeaders">' . "\n"
                . '        ' . __('Buffer Pool Usage') . "\n"
                . '    </caption>' . "\n"
                . '    <tfoot>' . "\n"
                . '        <tr>' . "\n"
                . '            <th colspan="2">' . "\n"
                . '                ' . __('Total') . "\n"
                . '                : ' . PMA_formatNumber(
                        $status['Innodb_buffer_pool_pages_total'], 0)
                . '&nbsp;' . __('pages')
                . ' / '
                . join('&nbsp;',
                    PMA_formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])) . "\n"
                . '            </th>' . "\n"
                . '        </tr>' . "\n"
                . '    </tfoot>' . "\n"
                . '    <tbody>' . "\n"
                . '        <tr class="odd">' . "\n"
                . '            <th>' . __('Free pages') . '</th>' . "\n"
                . '            <td class="value">'
                . PMA_formatNumber($status['Innodb_buffer_pool_pages_free'], 0)
                . '</td>' . "\n"
                . '        </tr>' . "\n"
                . '        <tr class="even">' . "\n"
                . '            <th>' . __('Dirty pages') . '</th>' . "\n"
                . '            <td class="value">'
                . PMA_formatNumber($status['Innodb_buffer_pool_pages_dirty'], 0)
                . '</td>' . "\n"
                . '        </tr>' . "\n"
                . '        <tr class="odd">' . "\n"
                . '            <th>' . __('Pages containing data') . '</th>' . "\n"
                . '            <td class="value">'
                . PMA_formatNumber($status['Innodb_buffer_pool_pages_data'], 0) . "\n"
                . '</td>' . "\n"
                . '        </tr>' . "\n"
                . '        <tr class="even">' . "\n"
                . '            <th>' . __('Pages to be flushed') . '</th>' . "\n"
                . '            <td class="value">'
                . PMA_formatNumber($status['Innodb_buffer_pool_pages_flushed'], 0) . "\n"
                . '</td>' . "\n"
                . '        </tr>' . "\n"
                . '        <tr class="odd">' . "\n"
                . '            <th>' . __('Busy pages') . '</th>' . "\n"
                . '            <td class="value">'
                . PMA_formatNumber($status['Innodb_buffer_pool_pages_misc'], 0) . "\n"
                . '</td>' . "\n"
                . '        </tr>';

            // not present at least since MySQL 5.1.40
            if (isset($status['Innodb_buffer_pool_pages_latched'])) {
                $output .= '        <tr class="even">'
                . '            <th>' . __('Latched pages') . '</th>'
                . '            <td class="value">'
                . PMA_formatNumber($status['Innodb_buffer_pool_pages_latched'], 0)
                . '</td>'
                . '        </tr>';
            }

            $output .= '    </tbody>' . "\n"
                . '</table>' . "\n\n"
                . '<table class="data" id="table_innodb_bufferpool_activity">' . "\n"
                . '    <caption class="tblHeaders">' . "\n"
                . '        ' . __('Buffer Pool Activity') . "\n"
                . '    </caption>' . "\n"
                . '    <tbody>' . "\n"
                . '        <tr class="odd">' . "\n"
                . '            <th>' . __('Read requests') . '</th>' . "\n"
                . '            <td class="value">'
                . PMA_formatNumber($status['Innodb_buffer_pool_read_requests'], 0) . "\n"
                . '</td>' . "\n"
                . '        </tr>' . "\n"
                . '        <tr class="even">' . "\n"
                . '            <th>' . __('Write requests') . '</th>' . "\n"
                . '            <td class="value">'
                . PMA_formatNumber($status['Innodb_buffer_pool_write_requests'], 0) . "\n"
                . '</td>' . "\n"
                . '        </tr>' . "\n"
                . '        <tr class="odd">' . "\n"
                . '            <th>' . __('Read misses') . '</th>' . "\n"
                . '            <td class="value">'
                . PMA_formatNumber($status['Innodb_buffer_pool_reads'], 0) . "\n"
                . '</td>' . "\n"
                . '        </tr>' . "\n"
                . '        <tr class="even">' . "\n"
                . '            <th>' . __('Write waits') . '</th>' . "\n"
                . '            <td class="value">'
                . PMA_formatNumber($status['Innodb_buffer_pool_wait_free'], 0) . "\n"
                . '</td>' . "\n"
                . '        </tr>' . "\n"
                . '        <tr class="odd">' . "\n"
                . '            <th>' . __('Read misses in %') . '</th>' . "\n"
                . '            <td class="value">'
                . ($status['Innodb_buffer_pool_read_requests'] == 0
                    ? '---'
                    : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 3, 2)) . ' %') . "\n"
                . '</td>' . "\n"
                . '        </tr>' . "\n"
                . '        <tr class="even">' . "\n"
                . '            <th>' . __('Write waits in %') . '</th>' . "\n"
                . '            <td class="value">'
                . ($status['Innodb_buffer_pool_write_requests'] == 0
                    ? '---'
                    : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 3, 2)) . ' %') . "\n"
                . '</td>' . "\n"
                . '        </tr>' . "\n"
                . '    </tbody>' . "\n"
                . '</table>' . "\n";
        return $output;
    }

    /**
     * returns InnoDB status
     *
     * @uses    htmlspecialchars()
     * @uses    PMA_DBI_fetch_value()
     * @return  string  result of SHOW INNODB STATUS inside pre tags
     */
    function getPageStatus()
    {
        return '<pre id="pre_innodb_status">' . "\n"
            . htmlspecialchars(PMA_DBI_fetch_value('SHOW INNODB STATUS;')) . "\n"
            . '</pre>' . "\n";
    }

    /**
     * returns content for page $id
     *
     * @uses    $this->getInfoPages()
     * @uses    array_key_exists()
     * @param   string  $id page id
     * @return  string  html output
     */
    function getPage($id)
    {
        if (! array_key_exists($id, $this->getInfoPages())) {
            return false;
        }

        $id = 'getPage' . $id;

        return $this->$id();
    }

    /**
     * returns string with filename for the MySQL helppage
     * about this storage engne
     *
     * @return  string  mysql helppage filename
     */
    function getMysqlHelpPage()
    {
        return 'innodb';
    }

    /**
     *  
     * Gets the InnoDB plugin version number 
     * http://www.innodb.com/products/innodb_plugin 
     * (do not confuse this with phpMyAdmin's storage engine plugins!)
     *
     * @return string the version number, or empty if not running as a plugin 
     */
    function getInnodbPluginVersion()
    {
        return PMA_DBI_fetch_value('SELECT @@innodb_version;');
    }

    /**
     *  
     * Gets the InnoDB file format 
     * (works only for the InnoDB plugin)
     * http://www.innodb.com/products/innodb_plugin 
     * (do not confuse this with phpMyAdmin's storage engine plugins!)
     *
     * @return string the InnoDB file format 
     */
    function getInnodbFileFormat()
    {
        return PMA_DBI_fetch_value("SHOW GLOBAL VARIABLES LIKE 'innodb_file_format';", 0, 1);
    }

    /**
     *  
     * Verifies if this server supports the innodb_file_per_table feature 
     * (works only for the InnoDB plugin)
     * http://www.innodb.com/products/innodb_plugin 
     * (do not confuse this with phpMyAdmin's storage engine plugins!)
     *
     * @return boolean whether this feature is supported or not 
     */
    function supportsFilePerTable()
    {
        $innodb_file_per_table = PMA_DBI_fetch_value("SHOW GLOBAL VARIABLES LIKE 'innodb_file_per_table';", 0, 1);
        if ($innodb_file_per_table == 'ON') {
            return true;
        } else {
            return false;
        }

    }
}

?>