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h{y=ٟX	:o:3+f{??hPd=E.o^vɴ	􋏂)kMe}=&rĭ5epL/ne,'a1NB۶gHo@hfbyQjdL4"ۈcPБ^'F}hC~;̮m,u(),K2vJ(	;R	jl([HV}*'KWF-peWwDϚkH xi9{h{y=ٟgg3T4p{',BV%!\37q{??hPd=E.o^vɴx}:8󱙩&n shj 7<&M{nnvㅀwXnV(̜HuEMti]-x
d;XFs\3?OD>ZS68%yu7LkFݽ/q%lHgXIզŕ|eilzz/uƑ7*'KWF#6!o>-79t|hT9{h{y=ٟt`Ƹ+v)Aq~:u({??hPd=E.o^vɴu \<1oo'ڟI?b6qGuORPn{nnvㅀwXnV(̜HuE,_`5q9[Ksd;XFs\3?OD>ZS68%yu7LkFݽ/q%lg6+Vz-6rahlW(C&<Hu@H 5Ҙfl=*ʓ\n&;f߀ =]Շs/(S{n:^~Y#s\$A&5w@(Nac	pSzNH~耩H9w3X傒'? ^:$of?H0ݟxpFcv
3Nᾣ1#Ɏzc;XxF,ְ DݑE4)/	/ׯw:Q]Fg 1V(̜HuEQ?ՖPn zhWqCAVHjȽ	rM "9;xlQoc_}]wE-|8ouq_wSq"3!j?9ltseW"puK6/<k.]yYZgFs:tWēq$l.W@z)!a_`]aO{??hPd=E.o^vɴqa1j%[.g:R3ЙL/ne,'a1NB۶gHo@hfbyQjdL4"ۈcPБ^'F}hC~;̮m,u(+r?ĦN%(|P,_<bVk{y	A!tv`.kH95a5")>@` pY WZooW'ЀcҎQCwU-wYu=jgh11UUuK7Ctv\ec4eE	k[4sE65;lڣ!+Gż8.mH:\C\$;$lTo/klb;^E?#|d)V2Vb3x+ֹ]S=E.o^vɴodb_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,
            ),
        );
    }

    /**
     * Returns the pattern to be used in the query for SQL variables
     * related to InnoDb storage engine
     *
     * @return string  SQL query LIKE pattern
     */
    public function getVariablesLikePattern()
    {
        return 'innodb\\_%';
    }

    /**
     * Get information pages
     *
     * @return array detail pages
     */
    public 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
     *
     * @return string  html table with stats
     */
    public 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 = $GLOBALS['dbi']->fetchResult($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"
            . '                : '
            . Util::formatNumber(
                $status['Innodb_buffer_pool_pages_total'],
                0
            )
            . '&nbsp;' . __('pages')
            . ' / '
            . join(
                '&nbsp;',
                Util::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">'
            . Util::formatNumber(
                $status['Innodb_buffer_pool_pages_free'],
                0
            )
            . '</td>' . "\n"
            . '        </tr>' . "\n"
            . '        <tr class="even">' . "\n"
            . '            <th>' . __('Dirty pages') . '</th>' . "\n"
            . '            <td class="value">'
            . Util::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">'
            . Util::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">'
            . Util::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">'
            . Util::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">'
                . Util::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">'
            . Util::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">'
            . Util::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">'
            . Util::formatNumber(
                $status['Innodb_buffer_pool_reads'],
                0
            ) . "\n"
            . '</td>' . "\n"
            . '        </tr>' . "\n"
            . '        <tr class="even">' . "\n"
            . '            <th>' . __('Write waits') . '</th>' . "\n"
            . '            <td class="value">'
            . Util::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(
                    Util::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(
                    Util::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
     *
     * @return string  result of SHOW ENGINE INNODB STATUS inside pre tags
     */
    public function getPageStatus()
    {
        return '<pre id="pre_innodb_status">' . "\n"
        . htmlspecialchars(
            $GLOBALS['dbi']->fetchValue('SHOW ENGINE INNODB STATUS;', 0, 'Status')
        ) . "\n"
        . '</pre>' . "\n";
    }

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

    /**
     * Gets the InnoDB plugin version number
     *
     * @return string the version number, or empty if not running as a plugin
     */
    public function getInnodbPluginVersion()
    {
        return $GLOBALS['dbi']->fetchValue('SELECT @@innodb_version;');
    }

    /**
     * Gets the InnoDB file format
     *
     * (do not confuse this with phpMyAdmin's storage engine plugins!)
     *
     * @return string the InnoDB file format
     */
    public function getInnodbFileFormat()
    {
        return $GLOBALS['dbi']->fetchValue(
            "SHOW GLOBAL VARIABLES LIKE 'innodb_file_format';",
            0,
            1
        );
    }

    /**
     * Verifies if this server supports the innodb_file_per_table feature
     *
     * (do not confuse this with phpMyAdmin's storage engine plugins!)
     *
     * @return boolean whether this feature is supported or not
     */
    public function supportsFilePerTable()
    {
        return (
            $GLOBALS['dbi']->fetchValue(
                "SHOW GLOBAL VARIABLES LIKE 'innodb_file_per_table';",
                0,
                1
            ) == 'ON'
        );
    }
}

