PageRenderTime 21ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/ReferenceCode/administration/libraries/engines/innodb.lib.php

https://gitlab.com/ctheilman92/Aging-In-Place
PHP | 411 lines | 314 code | 17 blank | 80 comment | 9 complexity | 5cc3ff9c02ab37e4936dc759f358209a MD5 | raw file
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * The InnoDB storage engine
  5. *
  6. * @package PhpMyAdmin-Engines
  7. */
  8. if (! defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. /**
  12. * The InnoDB storage engine
  13. *
  14. * @package PhpMyAdmin-Engines
  15. */
  16. class PMA_StorageEngine_innodb extends PMA_StorageEngine
  17. {
  18. /**
  19. * Returns array with variable names related to InnoDB storage engine
  20. *
  21. * @return array variable names
  22. */
  23. function getVariables()
  24. {
  25. return array(
  26. 'innodb_data_home_dir' => array(
  27. 'title' => __('Data home directory'),
  28. 'desc' => __('The common part of the directory path for all InnoDB data files.'),
  29. ),
  30. 'innodb_data_file_path' => array(
  31. 'title' => __('Data files'),
  32. ),
  33. 'innodb_autoextend_increment' => array(
  34. 'title' => __('Autoextend increment'),
  35. 'desc' => __('The increment size for extending the size of an autoextending tablespace when it becomes full.'),
  36. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  37. ),
  38. 'innodb_buffer_pool_size' => array(
  39. 'title' => __('Buffer pool size'),
  40. 'desc' => __('The size of the memory buffer InnoDB uses to cache data and indexes of its tables.'),
  41. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  42. ),
  43. 'innodb_additional_mem_pool_size' => array(
  44. 'title' => 'innodb_additional_mem_pool_size',
  45. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  46. ),
  47. 'innodb_buffer_pool_awe_mem_mb' => array(
  48. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  49. ),
  50. 'innodb_checksums' => array(
  51. ),
  52. 'innodb_commit_concurrency' => array(
  53. ),
  54. 'innodb_concurrency_tickets' => array(
  55. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  56. ),
  57. 'innodb_doublewrite' => array(
  58. ),
  59. 'innodb_fast_shutdown' => array(
  60. ),
  61. 'innodb_file_io_threads' => array(
  62. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  63. ),
  64. 'innodb_file_per_table' => array(
  65. ),
  66. 'innodb_flush_log_at_trx_commit' => array(
  67. ),
  68. 'innodb_flush_method' => array(
  69. ),
  70. 'innodb_force_recovery' => array(
  71. ),
  72. 'innodb_lock_wait_timeout' => array(
  73. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  74. ),
  75. 'innodb_locks_unsafe_for_binlog' => array(
  76. ),
  77. 'innodb_log_arch_dir' => array(
  78. ),
  79. 'innodb_log_archive' => array(
  80. ),
  81. 'innodb_log_buffer_size' => array(
  82. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  83. ),
  84. 'innodb_log_file_size' => array(
  85. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  86. ),
  87. 'innodb_log_files_in_group' => array(
  88. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  89. ),
  90. 'innodb_log_group_home_dir' => array(
  91. ),
  92. 'innodb_max_dirty_pages_pct' => array(
  93. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  94. ),
  95. 'innodb_max_purge_lag' => array(
  96. ),
  97. 'innodb_mirrored_log_groups' => array(
  98. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  99. ),
  100. 'innodb_open_files' => array(
  101. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  102. ),
  103. 'innodb_support_xa' => array(
  104. ),
  105. 'innodb_sync_spin_loops' => array(
  106. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  107. ),
  108. 'innodb_table_locks' => array(
  109. 'type' => PMA_ENGINE_DETAILS_TYPE_BOOLEAN,
  110. ),
  111. 'innodb_thread_concurrency' => array(
  112. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  113. ),
  114. 'innodb_thread_sleep_delay' => array(
  115. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  116. ),
  117. );
  118. }
  119. /**
  120. * Returns the pattern to be used in the query for SQL variables
  121. * related to InnoDb storage engine
  122. *
  123. * @return string SQL query LIKE pattern
  124. */
  125. function getVariablesLikePattern()
  126. {
  127. return 'innodb\\_%';
  128. }
  129. /**
  130. * Get information pages
  131. *
  132. * @return array detail pages
  133. */
  134. function getInfoPages()
  135. {
  136. if ($this->support < PMA_ENGINE_SUPPORT_YES) {
  137. return array();
  138. }
  139. $pages = array();
  140. $pages['Bufferpool'] = __('Buffer Pool');
  141. $pages['Status'] = __('InnoDB Status');
  142. return $pages;
  143. }
  144. /**
  145. * returns html tables with stats over inno db buffer pool
  146. *
  147. * @return string html table with stats
  148. */
  149. function getPageBufferpool()
  150. {
  151. // The following query is only possible because we know
  152. // that we are on MySQL 5 here (checked above)!
  153. // side note: I love MySQL 5 for this. :-)
  154. $sql = '
  155. SHOW STATUS
  156. WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
  157. OR Variable_name = \'Innodb_page_size\';';
  158. $status = PMA_DBI_fetch_result($sql, 0, 1);
  159. $output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n"
  160. . ' <caption class="tblHeaders">' . "\n"
  161. . ' ' . __('Buffer Pool Usage') . "\n"
  162. . ' </caption>' . "\n"
  163. . ' <tfoot>' . "\n"
  164. . ' <tr>' . "\n"
  165. . ' <th colspan="2">' . "\n"
  166. . ' ' . __('Total') . "\n"
  167. . ' : '
  168. . PMA_Util::formatNumber(
  169. $status['Innodb_buffer_pool_pages_total'], 0
  170. )
  171. . '&nbsp;' . __('pages')
  172. . ' / '
  173. . join(
  174. '&nbsp;',
  175. PMA_Util::formatByteDown(
  176. $status['Innodb_buffer_pool_pages_total']
  177. * $status['Innodb_page_size']
  178. )
  179. ) . "\n"
  180. . ' </th>' . "\n"
  181. . ' </tr>' . "\n"
  182. . ' </tfoot>' . "\n"
  183. . ' <tbody>' . "\n"
  184. . ' <tr class="odd">' . "\n"
  185. . ' <th>' . __('Free pages') . '</th>' . "\n"
  186. . ' <td class="value">'
  187. . PMA_Util::formatNumber(
  188. $status['Innodb_buffer_pool_pages_free'], 0
  189. )
  190. . '</td>' . "\n"
  191. . ' </tr>' . "\n"
  192. . ' <tr class="even">' . "\n"
  193. . ' <th>' . __('Dirty pages') . '</th>' . "\n"
  194. . ' <td class="value">'
  195. . PMA_Util::formatNumber(
  196. $status['Innodb_buffer_pool_pages_dirty'], 0
  197. )
  198. . '</td>' . "\n"
  199. . ' </tr>' . "\n"
  200. . ' <tr class="odd">' . "\n"
  201. . ' <th>' . __('Pages containing data') . '</th>' . "\n"
  202. . ' <td class="value">'
  203. . PMA_Util::formatNumber(
  204. $status['Innodb_buffer_pool_pages_data'], 0
  205. ) . "\n"
  206. . '</td>' . "\n"
  207. . ' </tr>' . "\n"
  208. . ' <tr class="even">' . "\n"
  209. . ' <th>' . __('Pages to be flushed') . '</th>' . "\n"
  210. . ' <td class="value">'
  211. . PMA_Util::formatNumber(
  212. $status['Innodb_buffer_pool_pages_flushed'], 0
  213. ) . "\n"
  214. . '</td>' . "\n"
  215. . ' </tr>' . "\n"
  216. . ' <tr class="odd">' . "\n"
  217. . ' <th>' . __('Busy pages') . '</th>' . "\n"
  218. . ' <td class="value">'
  219. . PMA_Util::formatNumber(
  220. $status['Innodb_buffer_pool_pages_misc'], 0
  221. ) . "\n"
  222. . '</td>' . "\n"
  223. . ' </tr>';
  224. // not present at least since MySQL 5.1.40
  225. if (isset($status['Innodb_buffer_pool_pages_latched'])) {
  226. $output .= ' <tr class="even">'
  227. . ' <th>' . __('Latched pages') . '</th>'
  228. . ' <td class="value">'
  229. . PMA_Util::formatNumber(
  230. $status['Innodb_buffer_pool_pages_latched'], 0
  231. )
  232. . '</td>'
  233. . ' </tr>';
  234. }
  235. $output .= ' </tbody>' . "\n"
  236. . '</table>' . "\n\n"
  237. . '<table class="data" id="table_innodb_bufferpool_activity">' . "\n"
  238. . ' <caption class="tblHeaders">' . "\n"
  239. . ' ' . __('Buffer Pool Activity') . "\n"
  240. . ' </caption>' . "\n"
  241. . ' <tbody>' . "\n"
  242. . ' <tr class="odd">' . "\n"
  243. . ' <th>' . __('Read requests') . '</th>' . "\n"
  244. . ' <td class="value">'
  245. . PMA_Util::formatNumber(
  246. $status['Innodb_buffer_pool_read_requests'], 0
  247. ) . "\n"
  248. . '</td>' . "\n"
  249. . ' </tr>' . "\n"
  250. . ' <tr class="even">' . "\n"
  251. . ' <th>' . __('Write requests') . '</th>' . "\n"
  252. . ' <td class="value">'
  253. . PMA_Util::formatNumber(
  254. $status['Innodb_buffer_pool_write_requests'], 0
  255. ) . "\n"
  256. . '</td>' . "\n"
  257. . ' </tr>' . "\n"
  258. . ' <tr class="odd">' . "\n"
  259. . ' <th>' . __('Read misses') . '</th>' . "\n"
  260. . ' <td class="value">'
  261. . PMA_Util::formatNumber(
  262. $status['Innodb_buffer_pool_reads'], 0
  263. ) . "\n"
  264. . '</td>' . "\n"
  265. . ' </tr>' . "\n"
  266. . ' <tr class="even">' . "\n"
  267. . ' <th>' . __('Write waits') . '</th>' . "\n"
  268. . ' <td class="value">'
  269. . PMA_Util::formatNumber(
  270. $status['Innodb_buffer_pool_wait_free'], 0
  271. ) . "\n"
  272. . '</td>' . "\n"
  273. . ' </tr>' . "\n"
  274. . ' <tr class="odd">' . "\n"
  275. . ' <th>' . __('Read misses in %') . '</th>' . "\n"
  276. . ' <td class="value">'
  277. . ($status['Innodb_buffer_pool_read_requests'] == 0
  278. ? '---'
  279. : htmlspecialchars(
  280. PMA_Util::formatNumber(
  281. $status['Innodb_buffer_pool_reads'] * 100
  282. / $status['Innodb_buffer_pool_read_requests'],
  283. 3,
  284. 2
  285. )
  286. ) . ' %') . "\n"
  287. . '</td>' . "\n"
  288. . ' </tr>' . "\n"
  289. . ' <tr class="even">' . "\n"
  290. . ' <th>' . __('Write waits in %') . '</th>' . "\n"
  291. . ' <td class="value">'
  292. . ($status['Innodb_buffer_pool_write_requests'] == 0
  293. ? '---'
  294. : htmlspecialchars(
  295. PMA_Util::formatNumber(
  296. $status['Innodb_buffer_pool_wait_free'] * 100
  297. / $status['Innodb_buffer_pool_write_requests'],
  298. 3,
  299. 2
  300. )
  301. ) . ' %') . "\n"
  302. . '</td>' . "\n"
  303. . ' </tr>' . "\n"
  304. . ' </tbody>' . "\n"
  305. . '</table>' . "\n";
  306. return $output;
  307. }
  308. /**
  309. * returns InnoDB status
  310. *
  311. * @return string result of SHOW INNODB STATUS inside pre tags
  312. */
  313. function getPageStatus()
  314. {
  315. return '<pre id="pre_innodb_status">' . "\n"
  316. . htmlspecialchars(
  317. PMA_DBI_fetch_value('SHOW INNODB STATUS;', 0, 'Status')
  318. ) . "\n"
  319. . '</pre>' . "\n";
  320. }
  321. /**
  322. * Returns content for page $id
  323. *
  324. * @param string $id page id
  325. *
  326. * @return string html output
  327. */
  328. function getPage($id)
  329. {
  330. if (! array_key_exists($id, $this->getInfoPages())) {
  331. return false;
  332. }
  333. $id = 'getPage' . $id;
  334. return $this->$id();
  335. }
  336. /**
  337. * returns string with filename for the MySQL helppage
  338. * about this storage engine
  339. *
  340. * @return string mysql helppage filename
  341. */
  342. function getMysqlHelpPage()
  343. {
  344. return 'innodb-storage-engine';
  345. }
  346. /**
  347. * Gets the InnoDB plugin version number
  348. *
  349. * http://www.innodb.com/products/innodb_plugin
  350. * (do not confuse this with phpMyAdmin's storage engine plugins!)
  351. *
  352. * @return string the version number, or empty if not running as a plugin
  353. */
  354. function getInnodbPluginVersion()
  355. {
  356. return PMA_DBI_fetch_value('SELECT @@innodb_version;');
  357. }
  358. /**
  359. * Gets the InnoDB file format
  360. *
  361. * (works only for the InnoDB plugin)
  362. * http://www.innodb.com/products/innodb_plugin
  363. * (do not confuse this with phpMyAdmin's storage engine plugins!)
  364. *
  365. * @return string the InnoDB file format
  366. */
  367. function getInnodbFileFormat()
  368. {
  369. return PMA_DBI_fetch_value(
  370. "SHOW GLOBAL VARIABLES LIKE 'innodb_file_format';", 0, 1
  371. );
  372. }
  373. /**
  374. * Verifies if this server supports the innodb_file_per_table feature
  375. *
  376. * (works only for the InnoDB plugin)
  377. * http://www.innodb.com/products/innodb_plugin
  378. * (do not confuse this with phpMyAdmin's storage engine plugins!)
  379. *
  380. * @return boolean whether this feature is supported or not
  381. */
  382. function supportsFilePerTable()
  383. {
  384. $innodb_file_per_table = PMA_DBI_fetch_value(
  385. "SHOW GLOBAL VARIABLES LIKE 'innodb_file_per_table';", 0, 1
  386. );
  387. if ($innodb_file_per_table == 'ON') {
  388. return true;
  389. } else {
  390. return false;
  391. }
  392. }
  393. }
  394. ?>