/test/classes/Stubs/DbiDummy.php
PHP | 3128 lines | 2795 code | 83 blank | 250 comment | 22 complexity | 9232677f1a0aa16104a7c9c5a2b81cd9 MD5 | raw file
Possible License(s): GPL-2.0, MIT, LGPL-3.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * Fake database driver for testing purposes
- *
- * It has hardcoded results for given queries what makes easy to use it
- * in testsuite. Feel free to include other queries which your test will
- * need.
- */
- declare(strict_types=1);
- namespace PhpMyAdmin\Tests\Stubs;
- use PhpMyAdmin\Dbal\DatabaseName;
- use PhpMyAdmin\Dbal\DbiExtension;
- use PhpMyAdmin\FieldMetadata;
- use function addslashes;
- use function count;
- use function debug_backtrace;
- use function fwrite;
- use function is_array;
- use function is_bool;
- use function is_int;
- use function json_encode;
- use function preg_replace;
- use function str_replace;
- use function trim;
- use const DEBUG_BACKTRACE_IGNORE_ARGS;
- use const JSON_PRETTY_PRINT;
- use const JSON_UNESCAPED_SLASHES;
- use const MYSQLI_TYPE_BLOB;
- use const MYSQLI_TYPE_DATETIME;
- use const MYSQLI_TYPE_DECIMAL;
- use const MYSQLI_TYPE_STRING;
- use const PHP_EOL;
- use const STDERR;
- /**
- * Fake database driver for testing purposes
- *
- * It has hardcoded results for given queries what makes easy to use it
- * in testsuite. Feel free to include other queries which your test will
- * need.
- */
- class DbiDummy implements DbiExtension
- {
- /**
- * First in, last out queries
- *
- * The results will be distributed in the filo way
- *
- * @var array
- * @phpstan-var array{
- * 'query': string,
- * 'result': ((int[]|string[]|array{string: string})[])|bool|bool[]|empty-array,
- * 'columns'?: string[],
- * 'metadata'?: object[]|empty-array,
- * 'used'?: bool,
- * 'pos'?: int
- * }[]
- */
- private $filoQueries = [];
- /**
- * First in, last out queries
- *
- * The results will be distributed in the fifo way
- *
- * @var string[]
- */
- private $fifoDatabasesToSelect = [];
- /**
- * @var array
- * @phpstan-var array{
- * 'query': string,
- * 'result': ((int[]|string[]|array{string: string})[])|bool|bool[]|empty-array,
- * 'columns'?: string[],
- * 'metadata'?: object[]|empty-array,
- * 'pos'?: int
- * }[]
- */
- private $dummyQueries = [];
- /** @var array<int,string|false> */
- private $fifoErrorCodes = [];
- public const OFFSET_GLOBAL = 1000;
- public function __construct()
- {
- $this->init();
- }
- /**
- * connects to the database server
- *
- * @param string $user mysql user name
- * @param string $password mysql user password
- * @param array $server host/port/socket/persistent
- *
- * @return mixed false on error or a mysqli object on success
- */
- public function connect(
- $user,
- $password,
- array $server = []
- ) {
- return true;
- }
- /**
- * selects given database
- *
- * @param string|DatabaseName $databaseName name of db to select
- * @param object $link mysql link resource
- */
- public function selectDb($databaseName, $link): bool
- {
- $databaseName = $databaseName instanceof DatabaseName
- ? $databaseName->getName() : $databaseName;
- foreach ($this->fifoDatabasesToSelect as $key => $databaseNameItem) {
- if ($databaseNameItem !== $databaseName) {
- continue;
- }
- // It was used
- unset($this->fifoDatabasesToSelect[$key]);
- return true;
- }
- fwrite(STDERR, 'Non expected select of database: ' . $databaseName . PHP_EOL);
- fwrite(STDERR, 'Trace: ' . json_encode(
- debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5),
- JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
- ) . PHP_EOL);
- return false;
- }
- public function hasUnUsedErrors(): bool
- {
- return $this->fifoErrorCodes !== [];
- }
- /**
- * @return string[]
- */
- public function getUnUsedDatabaseSelects(): array
- {
- return $this->fifoDatabasesToSelect;
- }
- /**
- * @return array[]
- */
- public function getUnUsedQueries(): array
- {
- $unUsed = [];
- foreach ($this->filoQueries as $query) {
- if (($query['used'] ?? false) === true) {
- continue;
- }
- $unUsed[] = $query;
- }
- return $unUsed;
- }
- /**
- * @return false|int|null
- */
- private function findFiloQuery(string $query)
- {
- for ($i = 0, $nb = count($this->filoQueries); $i < $nb; $i++) {
- if ($this->filoQueries[$i]['query'] !== $query) {
- continue;
- }
- if ($this->filoQueries[$i]['used'] ?? false) {
- continue;// Is has already been used
- }
- $this->filoQueries[$i]['pos'] = 0;
- $this->filoQueries[$i]['used'] = true;
- if (! is_array($this->filoQueries[$i]['result'])) {
- return false;
- }
- return $i;
- }
- return null;
- }
- /**
- * runs a query and returns the result
- *
- * @param string $query query to run
- * @param object $link mysql link resource
- * @param int $options query options
- *
- * @return mixed
- */
- public function realQuery($query, $link = null, $options = 0)
- {
- $query = trim((string) preg_replace('/ */', ' ', str_replace("\n", ' ', $query)));
- $filoQuery = $this->findFiloQuery($query);
- if ($filoQuery !== null) {// Found a matching query
- return $filoQuery;
- }
- for ($i = 0, $nb = count($this->dummyQueries); $i < $nb; $i++) {
- if ($this->dummyQueries[$i]['query'] !== $query) {
- continue;
- }
- $this->dummyQueries[$i]['pos'] = 0;
- if (! is_array($this->dummyQueries[$i]['result'])) {
- return false;
- }
- return $i + self::OFFSET_GLOBAL;
- }
- echo 'Not supported query: ' . $query . "\n";
- return false;
- }
- /**
- * Run the multi query and output the results
- *
- * @param object $link connection object
- * @param string $query multi query statement to execute
- *
- * @return array|bool
- */
- public function realMultiQuery($link, $query)
- {
- return false;
- }
- /**
- * returns result data from $result
- *
- * @param object $result MySQL result
- */
- public function fetchAny($result): ?array
- {
- $query_data = &$this->getQueryData($result);
- if ($query_data['pos'] >= count((array) $query_data['result'])) {
- return null;
- }
- $ret = $query_data['result'][$query_data['pos']];
- $query_data['pos'] += 1;
- return $ret;
- }
- /**
- * returns array of rows with associative and numeric keys from $result
- *
- * @param object $result result MySQL result
- */
- public function fetchArray($result): ?array
- {
- $query_data = &$this->getQueryData($result);
- $data = $this->fetchAny($result);
- if (! is_array($data) || ! isset($query_data['columns'])) {
- return $data;
- }
- foreach ($data as $key => $val) {
- $data[$query_data['columns'][$key]] = $val;
- }
- return $data;
- }
- /**
- * returns array of rows with associative keys from $result
- *
- * @param object $result MySQL result
- */
- public function fetchAssoc($result): ?array
- {
- $data = $this->fetchAny($result);
- $query_data = &$this->getQueryData($result);
- if (! is_array($data) || ! isset($query_data['columns'])) {
- return $data;
- }
- $ret = [];
- foreach ($data as $key => $val) {
- $ret[$query_data['columns'][$key]] = $val;
- }
- return $ret;
- }
- /**
- * returns array of rows with numeric keys from $result
- *
- * @param object $result MySQL result
- */
- public function fetchRow($result): ?array
- {
- return $this->fetchAny($result);
- }
- /**
- * Adjusts the result pointer to an arbitrary row in the result
- *
- * @param object $result database result
- * @param int $offset offset to seek
- */
- public function dataSeek($result, $offset): bool
- {
- $query_data = &$this->getQueryData($result);
- if ($offset > count($query_data['result'])) {
- return false;
- }
- $query_data['pos'] = $offset;
- return true;
- }
- /**
- * Frees memory associated with the result
- *
- * @param object $result database result
- */
- public function freeResult($result): void
- {
- }
- /**
- * Check if there are any more query results from a multi query
- *
- * @param object $link the connection object
- */
- public function moreResults($link): bool
- {
- return false;
- }
- /**
- * Prepare next result from multi_query
- *
- * @param object $link the connection object
- */
- public function nextResult($link): bool
- {
- return false;
- }
- /**
- * Store the result returned from multi query
- *
- * @param object $link the connection object
- *
- * @return mixed false when empty results / result set when not empty
- */
- public function storeResult($link)
- {
- return false;
- }
- /**
- * Returns a string representing the type of connection used
- *
- * @param object $link mysql link
- *
- * @return string type of connection used
- */
- public function getHostInfo($link)
- {
- return '';
- }
- /**
- * Returns the version of the MySQL protocol used
- *
- * @param object $link mysql link
- *
- * @return int version of the MySQL protocol used
- */
- public function getProtoInfo($link)
- {
- return -1;
- }
- /**
- * returns a string that represents the client library version
- *
- * @return string MySQL client library version
- */
- public function getClientInfo()
- {
- return 'libmysql - mysqlnd x.x.x-dev (phpMyAdmin tests)';
- }
- /**
- * returns last error message or false if no errors occurred
- *
- * @param object $link connection link
- *
- * @return string|bool error or false
- */
- public function getError($link)
- {
- foreach ($this->fifoErrorCodes as $i => $code) {
- unset($this->fifoErrorCodes[$i]);
- return $code;
- }
- return false;
- }
- /**
- * returns the number of rows returned by last query
- *
- * @param object|bool $result MySQL result
- *
- * @return string|int
- * @psalm-return int|numeric-string
- */
- public function numRows($result)
- {
- if (is_bool($result)) {
- return 0;
- }
- $query_data = &$this->getQueryData($result);
- return count($query_data['result']);
- }
- /**
- * returns the number of rows affected by last query
- *
- * @param object $link the mysql object
- * @param bool $get_from_cache whether to retrieve from cache
- *
- * @return int|string
- * @psalm-return int|numeric-string
- */
- public function affectedRows($link = null, $get_from_cache = true)
- {
- global $cached_affected_rows;
- return $cached_affected_rows ?? 0;
- }
- /**
- * returns metainfo for fields in $result
- *
- * @param object $result result set identifier
- *
- * @return FieldMetadata[]|null meta info for fields in $result
- */
- public function getFieldsMeta($result): ?array
- {
- $query_data = &$this->getQueryData($result);
- if (! isset($query_data['metadata'])) {
- return [];
- }
- return $query_data['metadata'];
- }
- /**
- * return number of fields in given $result
- *
- * @param object $result MySQL result
- *
- * @return int field count
- */
- public function numFields($result)
- {
- $query_data = &$this->getQueryData($result);
- if (! isset($query_data['columns'])) {
- return 0;
- }
- return count($query_data['columns']);
- }
- /**
- * returns the length of the given field $i in $result
- *
- * @param object $result result set identifier
- * @param int $i field
- *
- * @return int length of field
- */
- public function fieldLen($result, $i)
- {
- return -1;
- }
- /**
- * returns name of $i. field in $result
- *
- * @param object $result result set identifier
- * @param int $i field
- *
- * @return string name of $i. field in $result
- */
- public function fieldName($result, $i)
- {
- $query_data = &$this->getQueryData($result);
- if (! isset($query_data['columns'])) {
- return '';
- }
- return $query_data['columns'][$i];
- }
- /**
- * returns properly escaped string for use in MySQL queries
- *
- * @param mixed $link database link
- * @param string $string string to be escaped
- *
- * @return string a MySQL escaped string
- */
- public function escapeString($link, $string)
- {
- return addslashes($string);
- }
- public function addSelectDb(string $databaseName): void
- {
- $this->fifoDatabasesToSelect[] = $databaseName;
- }
- /**
- * Adds query result for testing
- *
- * @param string $query SQL
- * @param array|bool $result Expected result
- * @param string[] $columns The result columns
- * @param object[] $metadata The result metadata
- * @phpstan-param (int[]|string[]|array{string: string}|null[])[]|bool|bool[] $result
- */
- public function addResult(string $query, $result, array $columns = [], array $metadata = []): void
- {
- $this->filoQueries[] = [
- 'query' => $query,
- 'result' => $result,
- 'columns' => $columns,
- 'metadata' => $metadata,
- ];
- }
- /**
- * Adds an error or false as no error to the stack
- *
- * @param string|false $code
- */
- public function addErrorCode($code): void
- {
- $this->fifoErrorCodes[] = $code;
- }
- public function removeDefaultResults(): void
- {
- $this->dummyQueries = [];
- }
- /**
- * @param mixed $link link
- * @param string $query query
- *
- * @return object|false
- */
- public function prepare($link, string $query)
- {
- return false;
- }
- /**
- * Return query data for ID
- *
- * @param object|int $result result set identifier
- *
- * @return array
- */
- private function &getQueryData($result): array
- {
- if (! is_int($result)) {
- // This never happens
- return [];
- }
- if ($result >= self::OFFSET_GLOBAL) {
- return $this->dummyQueries[$result - self::OFFSET_GLOBAL];
- }
- return $this->filoQueries[$result];
- }
- private function init(): void
- {
- /**
- * Array of queries this "driver" supports
- */
- $this->dummyQueries = [
- [
- 'query' => 'SELECT 1',
- 'result' => [['1']],
- ],
- [
- 'query' => 'SELECT CURRENT_USER();',
- 'result' => [['pma_test@localhost']],
- ],
- [
- 'query' => "SHOW VARIABLES LIKE 'lower_case_table_names'",
- 'result' => [
- [
- 'lower_case_table_names',
- '1',
- ],
- ],
- ],
- [
- 'query' => 'SELECT 1 FROM mysql.user LIMIT 1',
- 'result' => [['1']],
- ],
- [
- 'query' => 'SELECT 1 FROM `INFORMATION_SCHEMA`.`USER_PRIVILEGES`'
- . " WHERE `PRIVILEGE_TYPE` = 'CREATE USER'"
- . " AND '''pma_test''@''localhost''' LIKE `GRANTEE` LIMIT 1",
- 'result' => [['1']],
- ],
- [
- 'query' => 'SELECT 1 FROM (SELECT `GRANTEE`, `IS_GRANTABLE`'
- . ' FROM `INFORMATION_SCHEMA`.`COLUMN_PRIVILEGES`'
- . ' UNION SELECT `GRANTEE`, `IS_GRANTABLE`'
- . ' FROM `INFORMATION_SCHEMA`.`TABLE_PRIVILEGES`'
- . ' UNION SELECT `GRANTEE`, `IS_GRANTABLE`'
- . ' FROM `INFORMATION_SCHEMA`.`SCHEMA_PRIVILEGES`'
- . ' UNION SELECT `GRANTEE`, `IS_GRANTABLE`'
- . ' FROM `INFORMATION_SCHEMA`.`USER_PRIVILEGES`) t'
- . " WHERE `IS_GRANTABLE` = 'YES'"
- . " AND '''pma_test''@''localhost''' LIKE `GRANTEE` LIMIT 1",
- 'result' => [['1']],
- ],
- [
- 'query' => 'SHOW MASTER LOGS',
- 'result' => [
- [
- 'Log_name' => 'index1',
- 'File_size' => 100,
- ],
- [
- 'Log_name' => 'index2',
- 'File_size' => 200,
- ],
- ],
- ],
- [
- 'query' => 'SHOW STORAGE ENGINES',
- 'result' => [
- [
- 'Engine' => 'dummy',
- 'Support' => 'YES',
- 'Comment' => 'dummy comment',
- ],
- [
- 'Engine' => 'dummy2',
- 'Support' => 'NO',
- 'Comment' => 'dummy2 comment',
- ],
- [
- 'Engine' => 'FEDERATED',
- 'Support' => 'NO',
- 'Comment' => 'Federated MySQL storage engine',
- ],
- [
- 'Engine' => 'Pbxt',
- 'Support' => 'NO',
- 'Comment' => 'Pbxt storage engine',
- ],
- ],
- ],
- [
- 'query' => 'SHOW STATUS WHERE Variable_name'
- . ' LIKE \'Innodb\\_buffer\\_pool\\_%\''
- . ' OR Variable_name = \'Innodb_page_size\';',
- 'result' => [
- [
- 'Innodb_buffer_pool_pages_data',
- 0,
- ],
- [
- 'Innodb_buffer_pool_pages_dirty',
- 0,
- ],
- [
- 'Innodb_buffer_pool_pages_flushed',
- 0,
- ],
- [
- 'Innodb_buffer_pool_pages_free',
- 0,
- ],
- [
- 'Innodb_buffer_pool_pages_misc',
- 0,
- ],
- [
- 'Innodb_buffer_pool_pages_total',
- 4096,
- ],
- [
- 'Innodb_buffer_pool_read_ahead_rnd',
- 0,
- ],
- [
- 'Innodb_buffer_pool_read_ahead',
- 0,
- ],
- [
- 'Innodb_buffer_pool_read_ahead_evicted',
- 0,
- ],
- [
- 'Innodb_buffer_pool_read_requests',
- 64,
- ],
- [
- 'Innodb_buffer_pool_reads',
- 32,
- ],
- [
- 'Innodb_buffer_pool_wait_free',
- 0,
- ],
- [
- 'Innodb_buffer_pool_write_requests',
- 64,
- ],
- [
- 'Innodb_page_size',
- 16384,
- ],
- ],
- ],
- [
- 'query' => 'SHOW ENGINE INNODB STATUS;',
- 'result' => false,
- ],
- [
- 'query' => 'SELECT @@innodb_version;',
- 'result' => [
- ['1.1.8'],
- ],
- ],
- [
- 'query' => 'SELECT @@disabled_storage_engines',
- 'result' => [
- [''],
- ],
- ],
- [
- 'query' => 'SHOW GLOBAL VARIABLES ;',
- 'result' => [],
- ],
- [
- 'query' => 'SHOW GLOBAL VARIABLES LIKE \'innodb_file_per_table\';',
- 'result' => [
- [
- 'innodb_file_per_table',
- 'OFF',
- ],
- ],
- ],
- [
- 'query' => 'SHOW GLOBAL VARIABLES LIKE \'innodb_file_format\';',
- 'result' => [
- [
- 'innodb_file_format',
- 'Antelope',
- ],
- ],
- ],
- [
- 'query' => 'SELECT @@collation_server',
- 'result' => [
- ['utf8_general_ci'],
- ],
- ],
- [
- 'query' => 'SELECT @@lc_messages;',
- 'result' => [],
- ],
- [
- 'query' => 'SHOW SESSION VARIABLES LIKE \'FOREIGN_KEY_CHECKS\';',
- 'result' => [
- [
- 'foreign_key_checks',
- 'ON',
- ],
- ],
- ],
- [
- 'query' => 'SHOW TABLES FROM `pma_test`;',
- 'result' => [
- ['table1'],
- ['table2'],
- ],
- ],
- [
- 'query' => 'SHOW TABLES FROM `pmadb`',
- 'result' => [
- ['column_info'],
- ],
- ],
- [
- 'query' => 'SHOW COLUMNS FROM `pma_test`.`table1`',
- 'columns' => [
- 'Field',
- 'Type',
- 'Null',
- 'Key',
- 'Default',
- 'Extra',
- ],
- 'result' => [
- [
- 'i',
- 'int(11)',
- 'NO',
- 'PRI',
- 'NULL',
- 'auto_increment',
- ],
- [
- 'o',
- 'int(11)',
- 'NO',
- 'MUL',
- 'NULL',
- '',
- ],
- ],
- ],
- [
- 'query' => 'SHOW INDEXES FROM `pma_test`.`table1` WHERE (Non_unique = 0)',
- 'result' => [],
- ],
- [
- 'query' => 'SHOW COLUMNS FROM `pma_test`.`table2`',
- 'columns' => [
- 'Field',
- 'Type',
- 'Null',
- 'Key',
- 'Default',
- 'Extra',
- ],
- 'result' => [
- [
- 'i',
- 'int(11)',
- 'NO',
- 'PRI',
- 'NULL',
- 'auto_increment',
- ],
- [
- 'o',
- 'int(11)',
- 'NO',
- 'MUL',
- 'NULL',
- '',
- ],
- ],
- ],
- [
- 'query' => 'SHOW INDEXES FROM `pma_test`.`table1`',
- 'result' => [],
- ],
- [
- 'query' => 'SHOW INDEXES FROM `pma_test`.`table2`',
- 'result' => [],
- ],
- [
- 'query' => 'SHOW COLUMNS FROM `pma`.`table1`',
- 'columns' => [
- 'Field',
- 'Type',
- 'Null',
- 'Key',
- 'Default',
- 'Extra',
- 'Privileges',
- 'Comment',
- ],
- 'result' => [
- [
- 'i',
- 'int(11)',
- 'NO',
- 'PRI',
- 'NULL',
- 'auto_increment',
- 'select,insert,update,references',
- '',
- ],
- [
- 'o',
- 'varchar(100)',
- 'NO',
- 'MUL',
- 'NULL',
- '',
- 'select,insert,update,references',
- '',
- ],
- ],
- ],
- [
- 'query' => 'SELECT `CHARACTER_SET_NAME` AS `Charset`,'
- . ' `DEFAULT_COLLATE_NAME` AS `Default collation`,'
- . ' `DESCRIPTION` AS `Description`,'
- . ' `MAXLEN` AS `Maxlen`'
- . ' FROM `information_schema`.`CHARACTER_SETS`',
- 'columns' => [
- 'Charset',
- 'Default collation',
- 'Description',
- 'Maxlen',
- ],
- 'result' => [
- [
- 'armscii8',
- 'ARMSCII-8 Armenian',
- 'armscii8_general_ci',
- '1',
- ],
- [
- 'utf8',
- 'utf8_general_ci',
- 'UTF-8 Unicode',
- '3',
- ],
- [
- 'utf8mb4',
- 'UTF-8 Unicode',
- 'utf8mb4_0900_ai_ci',
- '4',
- ],
- [
- 'latin1',
- 'latin1_swedish_ci',
- 'cp1252 West European',
- '1',
- ],
- ],
- ],
- [
- 'query' => 'SELECT `COLLATION_NAME` AS `Collation`,'
- . ' `CHARACTER_SET_NAME` AS `Charset`,'
- . ' `ID` AS `Id`,'
- . ' `IS_DEFAULT` AS `Default`,'
- . ' `IS_COMPILED` AS `Compiled`,'
- . ' `SORTLEN` AS `Sortlen`'
- . ' FROM `information_schema`.`COLLATIONS`',
- 'columns' => [
- 'Collation',
- 'Charset',
- 'Id',
- 'Default',
- 'Compiled',
- 'Sortlen',
- ],
- 'result' => [
- [
- 'utf8mb4_general_ci',
- 'utf8mb4',
- '45',
- 'Yes',
- 'Yes',
- '1',
- ],
- [
- 'armscii8_general_ci',
- 'armscii8',
- '32',
- 'Yes',
- 'Yes',
- '1',
- ],
- [
- 'utf8_general_ci',
- 'utf8',
- '33',
- 'Yes',
- 'Yes',
- '1',
- ],
- [
- 'utf8_bin',
- 'utf8',
- '83',
- '',
- 'Yes',
- '1',
- ],
- [
- 'latin1_swedish_ci',
- 'latin1',
- '8',
- 'Yes',
- 'Yes',
- '1',
- ],
- ],
- ],
- [
- 'query' => 'SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`TABLES`'
- . ' WHERE `TABLE_SCHEMA`=\'pma_test\' AND `TABLE_TYPE` IN (\'BASE TABLE\', \'SYSTEM VERSIONED\')',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT `column_name`, `mimetype`, `transformation`,'
- . ' `transformation_options`, `input_transformation`,'
- . ' `input_transformation_options`'
- . ' FROM `pmadb`.`column_info`'
- . ' WHERE `db_name` = \'pma_test\' AND `table_name` = \'table1\''
- . ' AND ( `mimetype` != \'\' OR `transformation` != \'\''
- . ' OR `transformation_options` != \'\''
- . ' OR `input_transformation` != \'\''
- . ' OR `input_transformation_options` != \'\')',
- 'columns' => [
- 'column_name',
- 'mimetype',
- 'transformation',
- 'transformation_options',
- 'input_transformation',
- 'input_transformation_options',
- ],
- 'result' => [
- [
- 'o',
- 'text/plain',
- 'sql',
- '',
- 'regex',
- '/pma/i',
- ],
- [
- 'col',
- 't',
- 'o/p',
- '',
- 'i/p',
- '',
- ],
- ],
- ],
- [
- 'query' => 'SELECT `column_name`, `mimetype`, `transformation`,'
- . ' `transformation_options`, `input_transformation`,'
- . ' `input_transformation_options`'
- . ' FROM `information_schema`.`column_info`'
- . ' WHERE `db_name` = \'my_db\' AND `table_name` = \'test_tbl\''
- . ' AND ( `mimetype` != \'\' OR `transformation` != \'\''
- . ' OR `transformation_options` != \'\''
- . ' OR `input_transformation` != \'\''
- . ' OR `input_transformation_options` != \'\')',
- 'columns' => [
- 'column_name',
- 'mimetype',
- 'transformation',
- 'transformation_options',
- 'input_transformation',
- 'input_transformation_options',
- ],
- 'result' => [
- [
- 'vc',
- '',
- 'output/text_plain_json.php',
- '',
- 'Input/Text_Plain_JsonEditor.php',
- '',
- ],
- [
- 'vc',
- '',
- 'output/text_plain_formatted.php',
- '',
- 'Text_Plain_Substring.php',
- '1',
- ],
- ],
- ],
- [
- 'query' => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
- . ' WHERE TABLE_SCHEMA = \'pma_test\' AND TABLE_NAME = \'table1\'',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
- . ' WHERE TABLE_SCHEMA = \'ODS_DB\' AND TABLE_NAME = \'Shop\'',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
- . ' WHERE TABLE_SCHEMA = \'ODS_DB\' AND TABLE_NAME = \'pma_bookmark\'',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
- . ' WHERE TABLE_SCHEMA = \'my_dataset\' AND TABLE_NAME = \'company_users\'',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
- . ' WHERE TABLE_SCHEMA = \'my_db\' '
- . 'AND TABLE_NAME = \'test_tbl\' AND IS_UPDATABLE = \'YES\'',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`,'
- . ' `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`,'
- . ' `ENGINE` AS `Type`, `VERSION` AS `Version`,'
- . ' `ROW_FORMAT` AS `Row_format`, `TABLE_ROWS` AS `Rows`,'
- . ' `AVG_ROW_LENGTH` AS `Avg_row_length`,'
- . ' `DATA_LENGTH` AS `Data_length`,'
- . ' `MAX_DATA_LENGTH` AS `Max_data_length`,'
- . ' `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`,'
- . ' `AUTO_INCREMENT` AS `Auto_increment`,'
- . ' `CREATE_TIME` AS `Create_time`, `UPDATE_TIME` AS `Update_time`,'
- . ' `CHECK_TIME` AS `Check_time`, `TABLE_COLLATION` AS `Collation`,'
- . ' `CHECKSUM` AS `Checksum`, `CREATE_OPTIONS` AS `Create_options`,'
- . ' `TABLE_COMMENT` AS `Comment`'
- . ' FROM `information_schema`.`TABLES` t'
- . ' WHERE `TABLE_SCHEMA` IN (\'pma_test\')'
- . ' AND t.`TABLE_NAME` = \'table1\' ORDER BY Name ASC',
- 'columns' => [
- 'TABLE_CATALOG',
- 'TABLE_SCHEMA',
- 'TABLE_NAME',
- 'TABLE_TYPE',
- 'ENGINE',
- 'VERSION',
- 'ROW_FORMAT',
- 'TABLE_ROWS',
- 'AVG_ROW_LENGTH',
- 'DATA_LENGTH',
- 'MAX_DATA_LENGTH',
- 'INDEX_LENGTH',
- 'DATA_FREE',
- 'AUTO_INCREMENT',
- 'CREATE_TIME',
- 'UPDATE_TIME',
- 'CHECK_TIME',
- 'TABLE_COLLATION',
- 'CHECKSUM',
- 'CREATE_OPTIONS',
- 'TABLE_COMMENT',
- 'Db',
- 'Name',
- 'TABLE_TYPE',
- 'Engine',
- 'Type',
- 'Version',
- 'Row_format',
- 'Rows',
- 'Avg_row_length',
- 'Data_length',
- 'Max_data_length',
- 'Index_length',
- 'Data_free',
- 'Auto_increment',
- 'Create_time',
- 'Update_time',
- 'Check_time',
- 'Collation',
- 'Checksum',
- 'Create_options',
- 'Comment',
- ],
- 'result' => [
- [
- 'def',
- 'smash',
- 'issues_issue',
- 'BASE TABLE',
- 'InnoDB',
- '10',
- 'Compact',
- '9136',
- '862',
- '7880704',
- '0',
- '1032192',
- '420478976',
- '155862',
- '2012-08-29 13:28:28',
- 'NULL',
- 'NULL',
- 'utf8_general_ci',
- 'NULL',
- '',
- '',
- 'smash',
- 'issues_issue',
- 'BASE TABLE',
- 'InnoDB',
- 'InnoDB',
- '10',
- 'Compact',
- '9136',
- '862',
- '7880704',
- '0',
- '1032192',
- '420478976',
- '155862',
- '2012-08-29 13:28:28',
- 'NULL',
- 'NULL',
- 'utf8_general_ci',
- 'NULL',
- ],
- ],
- ],
- [
- 'query' => 'SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`,'
- . ' `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`,'
- . ' `ENGINE` AS `Type`, `VERSION` AS `Version`,'
- . ' `ROW_FORMAT` AS `Row_format`, `TABLE_ROWS` AS `Rows`,'
- . ' `AVG_ROW_LENGTH` AS `Avg_row_length`,'
- . ' `DATA_LENGTH` AS `Data_length`,'
- . ' `MAX_DATA_LENGTH` AS `Max_data_length`,'
- . ' `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`,'
- . ' `AUTO_INCREMENT` AS `Auto_increment`,'
- . ' `CREATE_TIME` AS `Create_time`, `UPDATE_TIME` AS `Update_time`,'
- . ' `CHECK_TIME` AS `Check_time`, `TABLE_COLLATION` AS `Collation`,'
- . ' `CHECKSUM` AS `Checksum`, `CREATE_OPTIONS` AS `Create_options`,'
- . ' `TABLE_COMMENT` AS `Comment`'
- . ' FROM `information_schema`.`TABLES` t'
- . ' WHERE `TABLE_SCHEMA` IN (\'pma_test\')'
- . ' AND t.`TABLE_NAME` = \'table1\' ORDER BY Name ASC',
- 'columns' => [
- 'TABLE_CATALOG',
- 'TABLE_SCHEMA',
- 'TABLE_NAME',
- 'TABLE_TYPE',
- 'ENGINE',
- 'VERSION',
- 'ROW_FORMAT',
- 'TABLE_ROWS',
- 'AVG_ROW_LENGTH',
- 'DATA_LENGTH',
- 'MAX_DATA_LENGTH',
- 'INDEX_LENGTH',
- 'DATA_FREE',
- 'AUTO_INCREMENT',
- 'CREATE_TIME',
- 'UPDATE_TIME',
- 'CHECK_TIME',
- 'TABLE_COLLATION',
- 'CHECKSUM',
- 'CREATE_OPTIONS',
- 'TABLE_COMMENT',
- 'Db',
- 'Name',
- 'TABLE_TYPE',
- 'Engine',
- 'Type',
- 'Version',
- 'Row_format',
- 'Rows',
- 'Avg_row_length',
- 'Data_length',
- 'Max_data_length',
- 'Index_length',
- 'Data_free',
- 'Auto_increment',
- 'Create_time',
- 'Update_time',
- 'Check_time',
- 'Collation',
- 'Checksum',
- 'Create_options',
- 'Comment',
- ],
- 'result' => [
- [
- 'def',
- 'smash',
- 'issues_issue',
- 'BASE TABLE',
- 'InnoDB',
- '10',
- 'Compact',
- '9136',
- '862',
- '7880704',
- '0',
- '1032192',
- '420478976',
- '155862',
- '2012-08-29 13:28:28',
- 'NULL',
- 'NULL',
- 'utf8_general_ci',
- 'NULL',
- '',
- '',
- 'smash',
- 'issues_issue',
- 'BASE TABLE',
- 'InnoDB',
- 'InnoDB',
- '10',
- 'Compact',
- '9136',
- '862',
- '7880704',
- '0',
- '1032192',
- '420478976',
- '155862',
- '2012-08-29 13:28:28',
- 'NULL',
- 'NULL',
- 'utf8_general_ci',
- 'NULL',
- ],
- ],
- ],
- [
- 'query' => 'SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`,'
- . ' `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`,'
- . ' `ENGINE` AS `Type`, `VERSION` AS `Version`,'
- . ' `ROW_FORMAT` AS `Row_format`, `TABLE_ROWS` AS `Rows`,'
- . ' `AVG_ROW_LENGTH` AS `Avg_row_length`,'
- . ' `DATA_LENGTH` AS `Data_length`,'
- . ' `MAX_DATA_LENGTH` AS `Max_data_length`,'
- . ' `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`,'
- . ' `AUTO_INCREMENT` AS `Auto_increment`,'
- . ' `CREATE_TIME` AS `Create_time`, `UPDATE_TIME` AS `Update_time`,'
- . ' `CHECK_TIME` AS `Check_time`, `TABLE_COLLATION` AS `Collation`,'
- . ' `CHECKSUM` AS `Checksum`, `CREATE_OPTIONS` AS `Create_options`,'
- . ' `TABLE_COMMENT` AS `Comment`'
- . ' FROM `information_schema`.`TABLES` t'
- . ' WHERE `TABLE_SCHEMA` IN (\'my_db\')'
- . ' AND t.`TABLE_NAME` = \'test_tbl\' ORDER BY Name ASC',
- 'columns' => [
- 'TABLE_CATALOG',
- 'TABLE_SCHEMA',
- 'TABLE_NAME',
- 'TABLE_TYPE',
- 'ENGINE',
- 'VERSION',
- 'ROW_FORMAT',
- 'TABLE_ROWS',
- 'AVG_ROW_LENGTH',
- 'DATA_LENGTH',
- 'MAX_DATA_LENGTH',
- 'INDEX_LENGTH',
- 'DATA_FREE',
- 'AUTO_INCREMENT',
- 'CREATE_TIME',
- 'UPDATE_TIME',
- 'CHECK_TIME',
- 'TABLE_COLLATION',
- 'CHECKSUM',
- 'CREATE_OPTIONS',
- 'TABLE_COMMENT',
- 'Db',
- 'Name',
- 'TABLE_TYPE',
- 'Engine',
- 'Type',
- 'Version',
- 'Row_format',
- 'Rows',
- 'Avg_row_length',
- 'Data_length',
- 'Max_data_length',
- 'Index_length',
- 'Data_free',
- 'Auto_increment',
- 'Create_time',
- 'Update_time',
- 'Check_time',
- 'Collation',
- 'Checksum',
- 'Create_options',
- 'Comment',
- ],
- 'result' => [],
- ],
- [
- 'query' => 'SELECT COUNT(*) FROM `pma_test`.`table1`',
- 'result' => [[0]],
- ],
- [
- 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
- . '`USER_PRIVILEGES`'
- . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
- . ' AND PRIVILEGE_TYPE=\'TRIGGER\'',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
- . '`SCHEMA_PRIVILEGES`'
- . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
- . ' AND PRIVILEGE_TYPE=\'TRIGGER\' AND \'pma_test\''
- . ' LIKE `TABLE_SCHEMA`',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
- . '`TABLE_PRIVILEGES`'
- . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
- . ' AND PRIVILEGE_TYPE=\'TRIGGER\' AND \'pma_test\''
- . ' LIKE `TABLE_SCHEMA` AND TABLE_NAME=\'table1\'',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
- . '`USER_PRIVILEGES`'
- . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
- . ' AND PRIVILEGE_TYPE=\'EVENT\'',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
- . '`SCHEMA_PRIVILEGES`'
- . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
- . ' AND PRIVILEGE_TYPE=\'EVENT\' AND \'pma_test\''
- . ' LIKE `TABLE_SCHEMA`',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
- . '`TABLE_PRIVILEGES`'
- . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
- . ' AND PRIVILEGE_TYPE=\'EVENT\''
- . ' AND TABLE_SCHEMA=\'pma\\\\_test\' AND TABLE_NAME=\'table1\'',
- 'result' => [],
- ],
- [
- 'query' => 'RENAME TABLE `pma_test`.`table1` TO `pma_test`.`table3`;',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT TRIGGER_SCHEMA, TRIGGER_NAME, EVENT_MANIPULATION,'
- . ' EVENT_OBJECT_TABLE, ACTION_TIMING, ACTION_STATEMENT, '
- . 'EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, DEFINER'
- . ' FROM information_schema.TRIGGERS'
- . ' WHERE EVENT_OBJECT_SCHEMA= \'pma_test\''
- . ' AND EVENT_OBJECT_TABLE = \'table1\';',
- 'result' => [],
- ],
- [
- 'query' => 'SHOW TABLES FROM `pma`;',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
- . "`SCHEMA_PRIVILEGES` WHERE GRANTEE='''pma_test''@''localhost'''"
- . " AND PRIVILEGE_TYPE='EVENT' AND TABLE_SCHEMA='pma'",
- 'result' => [],
- ],
- [
- 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
- . "`SCHEMA_PRIVILEGES` WHERE GRANTEE='''pma_test''@''localhost'''"
- . " AND PRIVILEGE_TYPE='TRIGGER' AND TABLE_SCHEMA='pma'",
- 'result' => [],
- ],
- [
- 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
- . "`TABLE_PRIVILEGES` WHERE GRANTEE='''pma_test''@''localhost'''"
- . " AND PRIVILEGE_TYPE='TRIGGER' AND 'db' LIKE `TABLE_SCHEMA` AND TABLE_NAME='table'",
- 'result' => [],
- ],
- [
- 'query' => 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA'
- . ' WHERE SCHEMA_NAME = \'pma_test\' LIMIT 1',
- 'columns' => ['DEFAULT_COLLATION_NAME'],
- 'result' => [
- ['utf8_general_ci'],
- ],
- ],
- [
- 'query' => 'SELECT @@collation_database',
- 'columns' => ['@@collation_database'],
- 'result' => [
- ['bar'],
- ],
- ],
- [
- 'query' => 'SHOW TABLES FROM `phpmyadmin`',
- 'result' => [],
- ],
- [
- 'query' => 'SELECT tracking_active FROM `pmadb`.`tracking`' .
- " WHERE db_name = 'pma_test_db'" .
- " AND table_name = 'pma_test_table'" .
- ' ORDER BY version DESC LIMIT 1',
- 'columns' => ['tracking_active'],
- 'result' => [
- [1],
- ],
- ],
- [
- 'query' => 'SELECT tracking_active FROM `pmadb`.`tracking`' .
- " WHERE db_name = 'pma_test_db'" .
- " AND table_name = 'pma_test_table2'" .
- ' ORDER BY version DESC LIMIT 1',
- 'result' => [],
- ],
- [
- 'query' => 'SHOW SLAVE STATUS',
- 'result' => [
- [
- 'Slave_IO_State' => 'running',
- 'Master_Host' => 'localhost',
- 'Master_User' => 'Master_User',
- 'Master_Port' => '1002',
- 'Connect_Re…
Large files files are truncated, but you can click here to view the full file