dbi_dummy.inc.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Fake database driver for testing purposes
  5. *
  6. * It has hardcoded results for given queries what makes easy to use it
  7. * in testsuite. Feel free to include other queries which your test will
  8. * need.
  9. *
  10. * @package PhpMyAdmin-DBI
  11. * @subpackage Dummy
  12. */
  13. if (!defined('PHPMYADMIN')) {
  14. exit;
  15. }
  16. /**
  17. * Array of queries this "driver" supports
  18. */
  19. $GLOBALS['dummy_queries'] = array(
  20. array('query' => 'SELECT 1', 'result' => array(array('1'))),
  21. array(
  22. 'query' => 'SELECT CURRENT_USER();',
  23. 'result' => array(array('pma_test@localhost')),
  24. ),
  25. array(
  26. 'query' => "SHOW VARIABLES LIKE 'lower_case_table_names'",
  27. 'result' => array(array('lower_case_table_names', '1')),
  28. ),
  29. array(
  30. 'query' => 'SELECT 1 FROM mysql.user LIMIT 1',
  31. 'result' => array(array('1')),
  32. ),
  33. array(
  34. 'query' => "SELECT 1 FROM `INFORMATION_SCHEMA`.`USER_PRIVILEGES`"
  35. . " WHERE `PRIVILEGE_TYPE` = 'CREATE USER'"
  36. . " AND '''pma_test''@''localhost''' LIKE `GRANTEE` LIMIT 1",
  37. 'result' => array(array('1')),
  38. ),
  39. array(
  40. 'query' => "SELECT 1 FROM (SELECT `GRANTEE`, `IS_GRANTABLE`"
  41. . " FROM `INFORMATION_SCHEMA`.`COLUMN_PRIVILEGES`"
  42. . " UNION SELECT `GRANTEE`, `IS_GRANTABLE`"
  43. . " FROM `INFORMATION_SCHEMA`.`TABLE_PRIVILEGES`"
  44. . " UNION SELECT `GRANTEE`, `IS_GRANTABLE`"
  45. . " FROM `INFORMATION_SCHEMA`.`SCHEMA_PRIVILEGES`"
  46. . " UNION SELECT `GRANTEE`, `IS_GRANTABLE`"
  47. . " FROM `INFORMATION_SCHEMA`.`USER_PRIVILEGES`) t"
  48. . " WHERE `IS_GRANTABLE` = 'YES'"
  49. . " AND '''pma_test''@''localhost''' LIKE `GRANTEE` LIMIT 1",
  50. 'result' => array(array('1')),
  51. ),
  52. array(
  53. 'query' => 'SHOW MASTER LOGS',
  54. 'result' => false,
  55. ),
  56. array(
  57. 'query' => 'SHOW STORAGE ENGINES',
  58. 'result' => array(
  59. array(
  60. 'Engine' => 'dummy',
  61. 'Support' => 'YES',
  62. 'Comment' => 'dummy comment',
  63. ),
  64. array(
  65. 'Engine' => 'dummy2',
  66. 'Support' => 'NO',
  67. 'Comment' => 'dummy2 comment',
  68. ),
  69. array(
  70. 'Engine' => 'FEDERATED',
  71. 'Support' => 'NO',
  72. 'Comment' => 'Federated MySQL storage engine',
  73. ),
  74. ),
  75. ),
  76. array(
  77. 'query' => 'SHOW STATUS WHERE Variable_name'
  78. . ' LIKE \'Innodb\\_buffer\\_pool\\_%\''
  79. . ' OR Variable_name = \'Innodb_page_size\';',
  80. 'result' => array(
  81. array('Innodb_buffer_pool_pages_data', 0),
  82. array('Innodb_buffer_pool_pages_dirty', 0),
  83. array('Innodb_buffer_pool_pages_flushed', 0),
  84. array('Innodb_buffer_pool_pages_free', 0),
  85. array('Innodb_buffer_pool_pages_misc', 0),
  86. array('Innodb_buffer_pool_pages_total', 4096),
  87. array('Innodb_buffer_pool_read_ahead_rnd', 0),
  88. array('Innodb_buffer_pool_read_ahead', 0),
  89. array('Innodb_buffer_pool_read_ahead_evicted', 0),
  90. array('Innodb_buffer_pool_read_requests', 64),
  91. array('Innodb_buffer_pool_reads', 32),
  92. array('Innodb_buffer_pool_wait_free', 0),
  93. array('Innodb_buffer_pool_write_requests', 64),
  94. array('Innodb_page_size', 16384),
  95. ),
  96. ),
  97. array(
  98. 'query' => 'SHOW ENGINE INNODB STATUS;',
  99. 'result' => false,
  100. ),
  101. array(
  102. 'query' => 'SELECT @@innodb_version;',
  103. 'result' => array(
  104. array('1.1.8'),
  105. ),
  106. ),
  107. array(
  108. 'query' => 'SELECT @@disabled_storage_engines',
  109. 'result' => array(
  110. array(''),
  111. ),
  112. ),
  113. array(
  114. 'query' => 'SHOW GLOBAL VARIABLES LIKE \'innodb_file_per_table\';',
  115. 'result' => array(
  116. array('innodb_file_per_table', 'OFF'),
  117. ),
  118. ),
  119. array(
  120. 'query' => 'SHOW GLOBAL VARIABLES LIKE \'innodb_file_format\';',
  121. 'result' => array(
  122. array('innodb_file_format', 'Antelope'),
  123. ),
  124. ),
  125. array(
  126. 'query' => 'SELECT @@collation_server',
  127. 'result' => array(
  128. array('utf8_general_ci'),
  129. ),
  130. ),
  131. array(
  132. 'query' => 'SELECT @@lc_messages;',
  133. 'result' => array(),
  134. ),
  135. array(
  136. 'query' => 'SHOW SESSION VARIABLES LIKE \'FOREIGN_KEY_CHECKS\';',
  137. 'result' => array(
  138. array('foreign_key_checks', 'ON'),
  139. ),
  140. ),
  141. array(
  142. 'query' => 'SHOW TABLES FROM `pma_test`;',
  143. 'result' => array(
  144. array('table1'),
  145. array('table2'),
  146. ),
  147. ),
  148. array(
  149. 'query' => 'SHOW TABLES FROM `pmadb`',
  150. 'result' => array(
  151. array('column_info'),
  152. ),
  153. ),
  154. array(
  155. 'query' => 'SHOW COLUMNS FROM `pma_test`.`table1`',
  156. 'columns' => array(
  157. 'Field',
  158. 'Type',
  159. 'Null',
  160. 'Key',
  161. 'Default',
  162. 'Extra',
  163. ),
  164. 'result' => array(
  165. array('i', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'),
  166. array('o', 'int(11)', 'NO', 'MUL', 'NULL', ''),
  167. ),
  168. ),
  169. array(
  170. 'query' => 'SHOW INDEXES FROM `pma_test`.`table1` WHERE (Non_unique = 0)',
  171. 'result' => array(),
  172. ),
  173. array(
  174. 'query' => 'SHOW COLUMNS FROM `pma_test`.`table2`',
  175. 'columns' => array(
  176. 'Field',
  177. 'Type',
  178. 'Null',
  179. 'Key',
  180. 'Default',
  181. 'Extra',
  182. ),
  183. 'result' => array(
  184. array('i', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'),
  185. array('o', 'int(11)', 'NO', 'MUL', 'NULL', ''),
  186. ),
  187. ),
  188. array(
  189. 'query' => 'SHOW INDEXES FROM `pma_test`.`table1`',
  190. 'result' => array(),
  191. ),
  192. array(
  193. 'query' => 'SHOW INDEXES FROM `pma_test`.`table2`',
  194. 'result' => array(),
  195. ),
  196. array(
  197. 'query' => 'SHOW COLUMNS FROM `pma`.`table1`',
  198. 'columns' => array(
  199. 'Field',
  200. 'Type',
  201. 'Null',
  202. 'Key',
  203. 'Default',
  204. 'Extra',
  205. 'Privileges',
  206. 'Comment',
  207. ),
  208. 'result' => array(
  209. array(
  210. 'i',
  211. 'int(11)',
  212. 'NO',
  213. 'PRI',
  214. 'NULL',
  215. 'auto_increment',
  216. 'select,insert,update,references',
  217. '',
  218. ),
  219. array(
  220. 'o',
  221. 'varchar(100)',
  222. 'NO',
  223. 'MUL',
  224. 'NULL',
  225. '',
  226. 'select,insert,update,references',
  227. '',
  228. ),
  229. ),
  230. ),
  231. array(
  232. 'query' => 'SELECT `CHARACTER_SET_NAME` AS `Charset`,'
  233. . ' `DESCRIPTION` AS `Description`'
  234. . ' FROM `information_schema`.`CHARACTER_SETS`',
  235. 'columns' => array(
  236. 'Charset',
  237. 'Description',
  238. ),
  239. 'result' => array(
  240. array('utf8', 'UTF-8 Unicode'),
  241. array('latin1', 'cp1252 West European'),
  242. ),
  243. ),
  244. array(
  245. 'query' => 'SELECT `CHARACTER_SET_NAME` AS `Charset`,'
  246. . ' `COLLATION_NAME` AS `Collation`, `IS_DEFAULT` AS `Default`'
  247. . ' FROM `information_schema`.`COLLATIONS`',
  248. 'columns' => array(
  249. 'Charset',
  250. 'Collation',
  251. 'Default',
  252. ),
  253. 'result' => array(
  254. array('utf8', 'utf8_general_ci','Yes'),
  255. array('utf8', 'utf8_bin', ''),
  256. array('latin1', 'latin1_swedish_ci', 'Yes'),
  257. ),
  258. ),
  259. array(
  260. 'query' => 'SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`TABLES`'
  261. . ' WHERE `TABLE_SCHEMA`=\'pma_test\' AND `TABLE_TYPE` IN (\'BASE TABLE\', \'SYSTEM VERSIONED\')',
  262. 'result' => array(),
  263. ),
  264. array(
  265. 'query' => 'SELECT `column_name`, `mimetype`, `transformation`,'
  266. . ' `transformation_options`, `input_transformation`,'
  267. . ' `input_transformation_options`'
  268. . ' FROM `pmadb`.`column_info`'
  269. . ' WHERE `db_name` = \'pma_test\' AND `table_name` = \'table1\''
  270. . ' AND ( `mimetype` != \'\' OR `transformation` != \'\''
  271. . ' OR `transformation_options` != \'\''
  272. . ' OR `input_transformation` != \'\''
  273. . ' OR `input_transformation_options` != \'\')',
  274. 'columns' => array(
  275. 'column_name',
  276. 'mimetype',
  277. 'transformation',
  278. 'transformation_options',
  279. 'input_transformation',
  280. 'input_transformation_options',
  281. ),
  282. 'result' => array(
  283. array('o', 'text/plain', 'sql', '', 'regex', '/pma/i'),
  284. array('col', 't', 'o/p', '', 'i/p', ''),
  285. ),
  286. ),
  287. array(
  288. 'query' => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
  289. . ' WHERE TABLE_SCHEMA = \'pma_test\' AND TABLE_NAME = \'table1\'',
  290. 'result' => array(),
  291. ),
  292. array(
  293. 'query' => 'SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`,'
  294. . ' `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`,'
  295. . ' `ENGINE` AS `Type`, `VERSION` AS `Version`,'
  296. . ' `ROW_FORMAT` AS `Row_format`, `TABLE_ROWS` AS `Rows`,'
  297. . ' `AVG_ROW_LENGTH` AS `Avg_row_length`,'
  298. . ' `DATA_LENGTH` AS `Data_length`,'
  299. . ' `MAX_DATA_LENGTH` AS `Max_data_length`,'
  300. . ' `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`,'
  301. . ' `AUTO_INCREMENT` AS `Auto_increment`,'
  302. . ' `CREATE_TIME` AS `Create_time`, `UPDATE_TIME` AS `Update_time`,'
  303. . ' `CHECK_TIME` AS `Check_time`, `TABLE_COLLATION` AS `Collation`,'
  304. . ' `CHECKSUM` AS `Checksum`, `CREATE_OPTIONS` AS `Create_options`,'
  305. . ' `TABLE_COMMENT` AS `Comment`'
  306. . ' FROM `information_schema`.`TABLES` t'
  307. . ' WHERE `TABLE_SCHEMA` IN (\'pma_test\')'
  308. . ' AND t.`TABLE_NAME` = \'table1\' ORDER BY Name ASC',
  309. 'columns' => array(
  310. 'TABLE_CATALOG',
  311. 'TABLE_SCHEMA',
  312. 'TABLE_NAME',
  313. 'TABLE_TYPE',
  314. 'ENGINE',
  315. 'VERSION',
  316. 'ROW_FORMAT',
  317. 'TABLE_ROWS',
  318. 'AVG_ROW_LENGTH',
  319. 'DATA_LENGTH',
  320. 'MAX_DATA_LENGTH',
  321. 'INDEX_LENGTH',
  322. 'DATA_FREE',
  323. 'AUTO_INCREMENT',
  324. 'CREATE_TIME',
  325. 'UPDATE_TIME',
  326. 'CHECK_TIME',
  327. 'TABLE_COLLATION',
  328. 'CHECKSUM',
  329. 'CREATE_OPTIONS',
  330. 'TABLE_COMMENT',
  331. 'Db',
  332. 'Name',
  333. 'TABLE_TYPE',
  334. 'Engine',
  335. 'Type',
  336. 'Version',
  337. 'Row_format',
  338. 'Rows',
  339. 'Avg_row_length',
  340. 'Data_length',
  341. 'Max_data_length',
  342. 'Index_length',
  343. 'Data_free',
  344. 'Auto_increment',
  345. 'Create_time',
  346. 'Update_time',
  347. 'Check_time',
  348. 'Collation',
  349. 'Checksum',
  350. 'Create_options',
  351. 'Comment',
  352. ),
  353. 'result' => array(
  354. array(
  355. 'def',
  356. 'smash',
  357. 'issues_issue',
  358. 'BASE TABLE',
  359. 'InnoDB',
  360. '10',
  361. 'Compact',
  362. '9136',
  363. '862',
  364. '7880704',
  365. '0',
  366. '1032192',
  367. '420478976',
  368. '155862',
  369. '2012-08-29 13:28:28',
  370. 'NULL',
  371. 'NULL',
  372. 'utf8_general_ci',
  373. 'NULL',
  374. '',
  375. '',
  376. 'smash',
  377. 'issues_issue',
  378. 'BASE TABLE',
  379. 'InnoDB',
  380. 'InnoDB',
  381. '10',
  382. 'Compact',
  383. '9136',
  384. '862',
  385. '7880704',
  386. '0',
  387. '1032192',
  388. '420478976',
  389. '155862',
  390. '2012-08-29 13:28:28',
  391. 'NULL',
  392. 'NULL',
  393. 'utf8_general_ci',
  394. 'NULL',
  395. ),
  396. ),
  397. ),
  398. array(
  399. 'query' => 'SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`,'
  400. . ' `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`,'
  401. . ' `ENGINE` AS `Type`, `VERSION` AS `Version`,'
  402. . ' `ROW_FORMAT` AS `Row_format`, `TABLE_ROWS` AS `Rows`,'
  403. . ' `AVG_ROW_LENGTH` AS `Avg_row_length`,'
  404. . ' `DATA_LENGTH` AS `Data_length`,'
  405. . ' `MAX_DATA_LENGTH` AS `Max_data_length`,'
  406. . ' `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`,'
  407. . ' `AUTO_INCREMENT` AS `Auto_increment`,'
  408. . ' `CREATE_TIME` AS `Create_time`, `UPDATE_TIME` AS `Update_time`,'
  409. . ' `CHECK_TIME` AS `Check_time`, `TABLE_COLLATION` AS `Collation`,'
  410. . ' `CHECKSUM` AS `Checksum`, `CREATE_OPTIONS` AS `Create_options`,'
  411. . ' `TABLE_COMMENT` AS `Comment`'
  412. . ' FROM `information_schema`.`TABLES` t'
  413. . ' WHERE `TABLE_SCHEMA` IN (\'pma_test\')'
  414. . ' AND t.`TABLE_NAME` = \'table1\' ORDER BY Name ASC',
  415. 'columns' => array(
  416. 'TABLE_CATALOG',
  417. 'TABLE_SCHEMA',
  418. 'TABLE_NAME',
  419. 'TABLE_TYPE',
  420. 'ENGINE',
  421. 'VERSION',
  422. 'ROW_FORMAT',
  423. 'TABLE_ROWS',
  424. 'AVG_ROW_LENGTH',
  425. 'DATA_LENGTH',
  426. 'MAX_DATA_LENGTH',
  427. 'INDEX_LENGTH',
  428. 'DATA_FREE',
  429. 'AUTO_INCREMENT',
  430. 'CREATE_TIME',
  431. 'UPDATE_TIME',
  432. 'CHECK_TIME',
  433. 'TABLE_COLLATION',
  434. 'CHECKSUM',
  435. 'CREATE_OPTIONS',
  436. 'TABLE_COMMENT',
  437. 'Db',
  438. 'Name',
  439. 'TABLE_TYPE',
  440. 'Engine',
  441. 'Type',
  442. 'Version',
  443. 'Row_format',
  444. 'Rows',
  445. 'Avg_row_length',
  446. 'Data_length',
  447. 'Max_data_length',
  448. 'Index_length',
  449. 'Data_free',
  450. 'Auto_increment',
  451. 'Create_time',
  452. 'Update_time',
  453. 'Check_time',
  454. 'Collation',
  455. 'Checksum',
  456. 'Create_options',
  457. 'Comment',
  458. ),
  459. 'result' => array(
  460. array(
  461. 'def',
  462. 'smash',
  463. 'issues_issue',
  464. 'BASE TABLE',
  465. 'InnoDB',
  466. '10',
  467. 'Compact',
  468. '9136',
  469. '862',
  470. '7880704',
  471. '0',
  472. '1032192',
  473. '420478976',
  474. '155862',
  475. '2012-08-29 13:28:28',
  476. 'NULL',
  477. 'NULL',
  478. 'utf8_general_ci',
  479. 'NULL',
  480. '',
  481. '',
  482. 'smash',
  483. 'issues_issue',
  484. 'BASE TABLE',
  485. 'InnoDB',
  486. 'InnoDB',
  487. '10',
  488. 'Compact',
  489. '9136',
  490. '862',
  491. '7880704',
  492. '0',
  493. '1032192',
  494. '420478976',
  495. '155862',
  496. '2012-08-29 13:28:28',
  497. 'NULL',
  498. 'NULL',
  499. 'utf8_general_ci',
  500. 'NULL',
  501. ),
  502. ),
  503. ),
  504. array(
  505. 'query' => 'SELECT COUNT(*) FROM `pma_test`.`table1`',
  506. 'result' => array(array(0)),
  507. ),
  508. array(
  509. 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
  510. . '`USER_PRIVILEGES`'
  511. . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
  512. . ' AND PRIVILEGE_TYPE=\'TRIGGER\'',
  513. 'result' => array(),
  514. ),
  515. array(
  516. 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
  517. . '`SCHEMA_PRIVILEGES`'
  518. . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
  519. . ' AND PRIVILEGE_TYPE=\'TRIGGER\' AND \'pma_test\''
  520. . ' LIKE `TABLE_SCHEMA`',
  521. 'result' => array(),
  522. ),
  523. array(
  524. 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
  525. . '`TABLE_PRIVILEGES`'
  526. . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
  527. . ' AND PRIVILEGE_TYPE=\'TRIGGER\' AND \'pma_test\''
  528. . ' LIKE `TABLE_SCHEMA` AND TABLE_NAME=\'table1\'',
  529. 'result' => array(),
  530. ),
  531. array(
  532. 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
  533. . '`USER_PRIVILEGES`'
  534. . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
  535. . ' AND PRIVILEGE_TYPE=\'EVENT\'',
  536. 'result' => array(),
  537. ),
  538. array(
  539. 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
  540. . '`SCHEMA_PRIVILEGES`'
  541. . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
  542. . ' AND PRIVILEGE_TYPE=\'EVENT\' AND \'pma_test\''
  543. . ' LIKE `TABLE_SCHEMA`',
  544. 'result' => array(),
  545. ),
  546. array(
  547. 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
  548. . '`TABLE_PRIVILEGES`'
  549. . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
  550. . ' AND PRIVILEGE_TYPE=\'EVENT\''
  551. . ' AND TABLE_SCHEMA=\'pma\\\\_test\' AND TABLE_NAME=\'table1\'',
  552. 'result' => array(),
  553. ),
  554. array(
  555. 'query' => 'RENAME TABLE `pma_test`.`table1` TO `pma_test`.`table3`;',
  556. 'result' => array(),
  557. ),
  558. array(
  559. 'query' => 'SELECT TRIGGER_SCHEMA, TRIGGER_NAME, EVENT_MANIPULATION,'
  560. . ' EVENT_OBJECT_TABLE, ACTION_TIMING, ACTION_STATEMENT, '
  561. . 'EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, DEFINER'
  562. . ' FROM information_schema.TRIGGERS'
  563. . ' WHERE EVENT_OBJECT_SCHEMA= \'pma_test\''
  564. . ' AND EVENT_OBJECT_TABLE = \'table1\';',
  565. 'result' => array(),
  566. ),
  567. array(
  568. 'query' => 'SHOW TABLES FROM `pma`;',
  569. 'result' => array(),
  570. ),
  571. array(
  572. 'query' => "SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`."
  573. . "`SCHEMA_PRIVILEGES` WHERE GRANTEE='''pma_test''@''localhost'''"
  574. . " AND PRIVILEGE_TYPE='EVENT' AND TABLE_SCHEMA='pma'",
  575. 'result' => array(),
  576. ),
  577. array(
  578. 'query' => "SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`."
  579. . "`SCHEMA_PRIVILEGES` WHERE GRANTEE='''pma_test''@''localhost'''"
  580. . " AND PRIVILEGE_TYPE='TRIGGER' AND TABLE_SCHEMA='pma'",
  581. 'result' => array(),
  582. ),
  583. array(
  584. 'query' => 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA'
  585. . ' WHERE SCHEMA_NAME = \'pma_test\' LIMIT 1',
  586. 'columns' => array('DEFAULT_COLLATION_NAME'),
  587. 'result' => array(
  588. array('utf8_general_ci'),
  589. ),
  590. ),
  591. array(
  592. 'query' => 'SELECT @@collation_database',
  593. 'columns' => array('@@collation_database'),
  594. 'result' => array(
  595. array('bar'),
  596. ),
  597. ),
  598. array(
  599. 'query' => "SHOW TABLES FROM `phpmyadmin`",
  600. 'result' => array(),
  601. ),
  602. array(
  603. 'query' => "SELECT tracking_active FROM `pmadb`.`tracking`" .
  604. " WHERE db_name = 'pma_test_db'" .
  605. " AND table_name = 'pma_test_table'" .
  606. " ORDER BY version DESC LIMIT 1",
  607. 'columns' => array('tracking_active'),
  608. 'result' => array(
  609. array(1),
  610. ),
  611. ),
  612. array(
  613. 'query' => "SELECT tracking_active FROM `pmadb`.`tracking`" .
  614. " WHERE db_name = 'pma_test_db'" .
  615. " AND table_name = 'pma_test_table2'" .
  616. " ORDER BY version DESC LIMIT 1",
  617. 'result' => array(),
  618. ),
  619. array(
  620. 'query' => "SHOW SLAVE STATUS",
  621. 'result' => array(
  622. array(
  623. 'Slave_IO_State' => 'running',
  624. 'Master_Host' => 'locahost',
  625. 'Master_User' => 'Master_User',
  626. 'Master_Port' => '1002',
  627. 'Connect_Retry' => 'Connect_Retry',
  628. 'Master_Log_File' => 'Master_Log_File',
  629. 'Read_Master_Log_Pos' => 'Read_Master_Log_Pos',
  630. 'Relay_Log_File' => 'Relay_Log_File',
  631. 'Relay_Log_Pos' => 'Relay_Log_Pos',
  632. 'Relay_Master_Log_File' => 'Relay_Master_Log_File',
  633. 'Slave_IO_Running' => 'NO',
  634. 'Slave_SQL_Running' => 'NO',
  635. 'Replicate_Do_DB' => 'Replicate_Do_DB',
  636. 'Replicate_Ignore_DB' => 'Replicate_Ignore_DB',
  637. 'Replicate_Do_Table' => 'Replicate_Do_Table',
  638. 'Replicate_Ignore_Table' => 'Replicate_Ignore_Table',
  639. 'Replicate_Wild_Do_Table' => 'Replicate_Wild_Do_Table',
  640. 'Replicate_Wild_Ignore_Table' => 'Replicate_Wild_Ignore_Table',
  641. 'Last_Errno' => 'Last_Errno',
  642. 'Last_Error' => 'Last_Error',
  643. 'Skip_Counter' => 'Skip_Counter',
  644. 'Exec_Master_Log_Pos' => 'Exec_Master_Log_Pos',
  645. 'Relay_Log_Space' => 'Relay_Log_Space',
  646. 'Until_Condition' => 'Until_Condition',
  647. 'Until_Log_File' => 'Until_Log_File',
  648. 'Until_Log_Pos' => 'Until_Log_Pos',
  649. 'Master_SSL_Allowed' => 'Master_SSL_Allowed',
  650. 'Master_SSL_CA_File' => 'Master_SSL_CA_File',
  651. 'Master_SSL_CA_Path' => 'Master_SSL_CA_Path',
  652. 'Master_SSL_Cert' => 'Master_SSL_Cert',
  653. 'Master_SSL_Cipher' => 'Master_SSL_Cipher',
  654. 'Master_SSL_Key' => 'Master_SSL_Key',
  655. 'Seconds_Behind_Master' => 'Seconds_Behind_Master',
  656. ),
  657. ),
  658. ),
  659. array(
  660. 'query' => "SHOW MASTER STATUS",
  661. 'result' => array(
  662. array(
  663. "File" => "master-bin.000030",
  664. "Position" => "107",
  665. "Binlog_Do_DB" => "Binlog_Do_DB",
  666. "Binlog_Ignore_DB" => "Binlog_Ignore_DB",
  667. ),
  668. ),
  669. ),
  670. array(
  671. 'query' => "SHOW GRANTS",
  672. 'result' => array(),
  673. ),
  674. array(
  675. 'query' => "SELECT `SCHEMA_NAME` FROM `INFORMATION_SCHEMA`.`SCHEMATA`, "
  676. . "(SELECT DB_first_level FROM ( SELECT DISTINCT "
  677. . "SUBSTRING_INDEX(SCHEMA_NAME, '_', 1) DB_first_level "
  678. . "FROM INFORMATION_SCHEMA.SCHEMATA WHERE TRUE ) t ORDER BY "
  679. . "DB_first_level ASC LIMIT 0, 100) t2 WHERE TRUE AND 1 = LOCATE("
  680. . "CONCAT(DB_first_level, '_'), CONCAT(SCHEMA_NAME, '_')) "
  681. . "ORDER BY SCHEMA_NAME ASC",
  682. 'result' => array(
  683. "test",
  684. ),
  685. ),
  686. array(
  687. 'query' => "SELECT COUNT(*) FROM ( SELECT DISTINCT SUBSTRING_INDEX("
  688. . "SCHEMA_NAME, '_', 1) DB_first_level "
  689. . "FROM INFORMATION_SCHEMA.SCHEMATA WHERE TRUE ) t",
  690. 'result' => array(
  691. array(1),
  692. ),
  693. ),
  694. array(
  695. 'query' => "SELECT `PARTITION_METHOD` "
  696. . "FROM `information_schema`.`PARTITIONS` "
  697. . "WHERE `TABLE_SCHEMA` = 'db' AND `TABLE_NAME` = 'table' LIMIT 1",
  698. 'result' => array(),
  699. ),
  700. array(
  701. 'query' => "SHOW PLUGINS",
  702. 'result' => array(
  703. array('Name' => 'partition'),
  704. ),
  705. ),
  706. array(
  707. 'query' => "SHOW FULL TABLES FROM `default` WHERE `Table_type`IN('BASE TABLE', 'SYSTEM VERSIONED')",
  708. 'result' => array(
  709. array("test1", "BASE TABLE"),
  710. array("test2", "BASE TABLE"),
  711. ),
  712. ),
  713. array(
  714. 'query' => "SHOW FULL TABLES FROM `default` "
  715. . "WHERE `Table_type`NOT IN('BASE TABLE', 'SYSTEM VERSIONED')",
  716. 'result' => array(),
  717. ),
  718. array(
  719. 'query' => "SHOW FUNCTION STATUS WHERE `Db`='default'",
  720. 'result' => array(array("Name" => "testFunction")),
  721. ),
  722. array(
  723. 'query' => "SHOW PROCEDURE STATUS WHERE `Db`='default'",
  724. 'result' => array(),
  725. ),
  726. array(
  727. 'query' => "SHOW EVENTS FROM `default`",
  728. 'result' => array(),
  729. ),
  730. array(
  731. 'query' => "FLUSH PRIVILEGES",
  732. 'result' => array(),
  733. ),
  734. array(
  735. 'query' => "SELECT * FROM `mysql`.`db` LIMIT 1",
  736. 'result' => array(),
  737. ),
  738. array(
  739. 'query' => "SELECT * FROM `mysql`.`columns_priv` LIMIT 1",
  740. 'result' => array(),
  741. ),
  742. array(
  743. 'query' => "SELECT * FROM `mysql`.`tables_priv` LIMIT 1",
  744. 'result' => array(),
  745. ),
  746. array(
  747. 'query' => "SELECT * FROM `mysql`.`procs_priv` LIMIT 1",
  748. 'result' => array(),
  749. ),
  750. array(
  751. 'query' => 'DELETE FROM `mysql`.`db` WHERE `host` = "" '
  752. . 'AND `Db` = "" AND `User` = ""',
  753. 'result' => true
  754. ),
  755. array(
  756. 'query' => 'DELETE FROM `mysql`.`columns_priv` WHERE '
  757. . '`host` = "" AND `Db` = "" AND `User` = ""',
  758. 'result' => true
  759. ),
  760. array(
  761. 'query' => 'DELETE FROM `mysql`.`tables_priv` WHERE '
  762. . '`host` = "" AND `Db` = "" AND `User` = "" AND Table_name = ""',
  763. 'result' => true
  764. ),
  765. array(
  766. 'query' => 'DELETE FROM `mysql`.`procs_priv` WHERE '
  767. . '`host` = "" AND `Db` = "" AND `User` = "" AND `Routine_name` = "" '
  768. . 'AND `Routine_type` = ""',
  769. 'result' => true
  770. ),
  771. array(
  772. 'query' => 'SELECT `plugin` FROM `mysql`.`user` WHERE '
  773. . '`User` = "pma_username" AND `Host` = "pma_hostname" LIMIT 1',
  774. 'result' => array()
  775. ),
  776. array(
  777. 'query' => 'SELECT @@default_authentication_plugin',
  778. 'result' => array(
  779. array('@@default_authentication_plugin' => 'mysql_native_password'),
  780. ),
  781. ),
  782. array(
  783. 'query' => "SELECT TABLE_NAME FROM information_schema.VIEWS WHERE "
  784. . "TABLE_SCHEMA = 'db' AND TABLE_NAME = 'table'",
  785. 'result' => array(),
  786. ),
  787. array(
  788. 'query' => "SELECT *, `TABLE_SCHEMA` AS `Db`, "
  789. . "`TABLE_NAME` AS `Name`, `TABLE_TYPE` AS `TABLE_TYPE`, "
  790. . "`ENGINE` AS `Engine`, `ENGINE` AS `Type`, "
  791. . "`VERSION` AS `Version`, `ROW_FORMAT` AS `Row_format`, "
  792. . "`TABLE_ROWS` AS `Rows`, `AVG_ROW_LENGTH` AS `Avg_row_length`, "
  793. . "`DATA_LENGTH` AS `Data_length`, "
  794. . "`MAX_DATA_LENGTH` AS `Max_data_length`, "
  795. . "`INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`, "
  796. . "`AUTO_INCREMENT` AS `Auto_increment`, "
  797. . "`CREATE_TIME` AS `Create_time`, "
  798. . "`UPDATE_TIME` AS `Update_time`, `CHECK_TIME` AS `Check_time`, "
  799. . "`TABLE_COLLATION` AS `Collation`, `CHECKSUM` AS `Checksum`, "
  800. . "`CREATE_OPTIONS` AS `Create_options`, "
  801. . "`TABLE_COMMENT` AS `Comment` "
  802. . "FROM `information_schema`.`TABLES` t "
  803. . "WHERE `TABLE_SCHEMA` IN ('db') "
  804. . "AND t.`TABLE_NAME` = 'table' ORDER BY Name ASC",
  805. 'result' => array(),
  806. ),
  807. array(
  808. 'query' => "SHOW TABLE STATUS FROM `db` WHERE `Name` LIKE 'table%'",
  809. 'result' => array(),
  810. ),
  811. array(
  812. 'query' => "SELECT @@have_partitioning;",
  813. 'result' => array(),
  814. ),
  815. array(
  816. 'query' => "SELECT @@lower_case_table_names",
  817. 'result' => array(),
  818. ),
  819. array(
  820. 'query' => "SELECT `PLUGIN_NAME`, `PLUGIN_DESCRIPTION` "
  821. . "FROM `information_schema`.`PLUGINS` "
  822. . "WHERE `PLUGIN_TYPE` = 'AUTHENTICATION';",
  823. 'result' => array(),
  824. ),
  825. array(
  826. 'query' => "SHOW TABLES FROM `db`;",
  827. 'result' => array(),
  828. ),
  829. array(
  830. 'query' => "SELECT `PRIVILEGE_TYPE` FROM "
  831. . "`INFORMATION_SCHEMA`.`SCHEMA_PRIVILEGES` "
  832. . "WHERE GRANTEE='''pma_test''@''localhost''' "
  833. . "AND PRIVILEGE_TYPE='EVENT' AND 'db' LIKE `TABLE_SCHEMA`",
  834. 'result' => array(),
  835. ),
  836. array(
  837. 'query' => "SELECT `PRIVILEGE_TYPE` FROM "
  838. . "`INFORMATION_SCHEMA`.`SCHEMA_PRIVILEGES` "
  839. . "WHERE GRANTEE='''pma_test''@''localhost''' "
  840. . "AND PRIVILEGE_TYPE='TRIGGER' AND 'db' LIKE `TABLE_SCHEMA`",
  841. 'result' => array(),
  842. ),
  843. array(
  844. 'query' => "SELECT (COUNT(DB_first_level) DIV 100) * 100 from "
  845. . "( SELECT distinct SUBSTRING_INDEX(SCHEMA_NAME, '_', 1) "
  846. . "DB_first_level FROM INFORMATION_SCHEMA.SCHEMATA "
  847. . "WHERE `SCHEMA_NAME` < 'db' ) t",
  848. 'result' => array(),
  849. ),
  850. array(
  851. 'query' => "SELECT `SCHEMA_NAME` FROM "
  852. . "`INFORMATION_SCHEMA`.`SCHEMATA`, "
  853. . "(SELECT DB_first_level FROM ( SELECT DISTINCT "
  854. . "SUBSTRING_INDEX(SCHEMA_NAME, '_', 1) DB_first_level FROM "
  855. . "INFORMATION_SCHEMA.SCHEMATA WHERE TRUE ) t "
  856. . "ORDER BY DB_first_level ASC LIMIT , 100) t2 WHERE TRUE AND "
  857. . "1 = LOCATE(CONCAT(DB_first_level, '_'), "
  858. . "CONCAT(SCHEMA_NAME, '_')) ORDER BY SCHEMA_NAME ASC",
  859. 'result' => array(),
  860. ),
  861. array(
  862. 'query' => 'SELECT @@ndb_version_string',
  863. 'result' => array(array('ndb-7.4.10')),
  864. ),
  865. array(
  866. 'query' => "SELECT *, `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`, `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`, `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment` FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = 'information_schema' AND `TABLE_NAME` = 'PMA'",
  867. 'result' => array(),
  868. ),
  869. [
  870. 'query' => "SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME FROM information_schema.key_column_usage WHERE referenced_table_name IS NOT NULL AND TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('table1','table2') AND REFERENCED_TABLE_NAME IN ('table1','table2');",
  871. 'result' => [
  872. [
  873. 'TABLE_NAME' => 'table2',
  874. 'COLUMN_NAME' => 'idtable2',
  875. 'REFERENCED_TABLE_NAME' => 'table1',
  876. 'REFERENCED_COLUMN_NAME' => 'idtable1',
  877. ]
  878. ],
  879. ],
  880. );
  881. /**
  882. * Current database.
  883. */
  884. $GLOBALS['dummy_db'] = '';
  885. /* Some basic setup for dummy driver */
  886. $GLOBALS['cfg']['DBG']['sql'] = false;