From 3db245f46206866d7873f82b15eb47e1d2f26984 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 14 Mar 2023 22:56:01 +0000 Subject: [PATCH 1/2] Optimize export of many tables Signed-off-by: Kamil Tekiela --- libraries/classes/DatabaseInterface.php | 5 ++--- libraries/classes/Export.php | 7 +++++++ libraries/classes/Query/Cache.php | 11 ++--------- phpstan-baseline.neon | 5 ----- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php index 3adfde20c5..cadc6ae9f8 100644 --- a/libraries/classes/DatabaseInterface.php +++ b/libraries/classes/DatabaseInterface.php @@ -500,8 +500,7 @@ class DatabaseInterface implements DbalInterface $this, 'escapeString', ], - $table, - $link + $table ) ) . '\')'; } else { @@ -593,7 +592,7 @@ class DatabaseInterface implements DbalInterface // cache table data // so Table does not require to issue SHOW TABLE STATUS again - $this->cache->cacheTableData($tables, $table); + $this->cache->cacheTableData($tables); if (isset($tables[$database])) { return $tables[$database]; diff --git a/libraries/classes/Export.php b/libraries/classes/Export.php index f832c39081..ec14ddf8fd 100644 --- a/libraries/classes/Export.php +++ b/libraries/classes/Export.php @@ -750,6 +750,13 @@ class Export $views = []; + if ($tables !== []) { + // Prefetch table information to improve performance. + // Table status will get saved in Query Cache, + // and all instantiations of Table below should be much faster. + $this->dbi->getTablesFull($db, $tables); + } + foreach ($tables as $table) { $tableObject = new Table($table, $db); // if this is a view, collect it for later; diff --git a/libraries/classes/Query/Cache.php b/libraries/classes/Query/Cache.php index f1c504bca8..6ea1e74ebb 100644 --- a/libraries/classes/Query/Cache.php +++ b/libraries/classes/Query/Cache.php @@ -22,10 +22,9 @@ class Cache * Caches table data so Table does not require to issue * SHOW TABLE STATUS again * - * @param array $tables information for tables of some databases - * @param string|bool $table table name + * @param array[][] $tables information for tables of some databases */ - public function cacheTableData(array $tables, $table): void + public function cacheTableData(array $tables): void { // Note: I don't see why we would need array_merge_recursive() here, // as it creates double entries for the same table (for example a double @@ -36,12 +35,6 @@ class Cache foreach ($tables as $one_database => $_) { if (isset($this->tableCache[$one_database])) { - // the + operator does not do the intended effect - // when the cache for one table already exists - if ($table && isset($this->tableCache[$one_database][$table])) { - unset($this->tableCache[$one_database][$table]); - } - $this->tableCache[$one_database] += $tables[$one_database]; } else { $this->tableCache[$one_database] = $tables[$one_database]; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b0e373150f..10a6916104 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -2765,11 +2765,6 @@ parameters: count: 1 path: libraries/classes/DatabaseInterface.php - - - message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\Query\\\\Cache\\:\\:cacheTableData\\(\\) expects bool\\|string, array\\|string given\\.$#" - count: 1 - path: libraries/classes/DatabaseInterface.php - - message: "#^Parameter \\#3 \\.\\.\\.\\$args of function array_map expects array, mixed given\\.$#" count: 1 From e9b9c120af32d5afb97b1f22b199e42f272052b3 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 15 Mar 2023 19:49:20 +0000 Subject: [PATCH 2/2] Fix getTablesFull() and related tests Signed-off-by: Kamil Tekiela --- libraries/classes/DatabaseInterface.php | 32 +- libraries/classes/Query/Cache.php | 27 +- libraries/classes/Query/Compatibility.php | 1 + phpstan-baseline.neon | 15 - psalm-baseline.xml | 42 +-- test/classes/Stubs/DbiDummy.php | 403 +++++++++++----------- test/classes/TableTest.php | 12 +- 7 files changed, 242 insertions(+), 290 deletions(-) diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php index cadc6ae9f8..5dc2886006 100644 --- a/libraries/classes/DatabaseInterface.php +++ b/libraries/classes/DatabaseInterface.php @@ -416,6 +416,7 @@ class DatabaseInterface implements DbalInterface $sql .= ' LIMIT ' . $limit_count . ' OFFSET ' . $limit_offset; } + /** @var mixed[][][] $tables */ $tables = $this->fetchResult( $sql, [ @@ -441,7 +442,7 @@ class DatabaseInterface implements DbalInterface [ $tables[$one_database_name][$one_table_name]['Data_length'], $tables[$one_database_name][$one_table_name]['Index_length'], - ] = StorageEngine::getMroongaLengths($one_database_name, $one_table_name); + ] = StorageEngine::getMroongaLengths($one_database_name, (string) $one_table_name); } } @@ -480,6 +481,15 @@ class DatabaseInterface implements DbalInterface $tables[$one_database_name] = $one_database_tables; } } + + // on windows with lower_case_table_names = 1 + // MySQL returns + // with SHOW DATABASES or information_schema.SCHEMATA: `Test` + // but information_schema.TABLES gives `test` + // see https://github.com/phpmyadmin/phpmyadmin/issues/8402 + $tables = $tables[$database] + ?? $tables[mb_strtolower($database)] + ?? []; } // If permissions are wrong on even one database directory, @@ -587,24 +597,12 @@ class DatabaseInterface implements DbalInterface $each_tables = array_slice($each_tables, $limit_offset, $limit_count, true); } - $tables[$database] = Compatibility::getISCompatForGetTablesFull($each_tables, $database); + $tables = Compatibility::getISCompatForGetTablesFull($each_tables, $database); } - // cache table data - // so Table does not require to issue SHOW TABLE STATUS again - $this->cache->cacheTableData($tables); - - if (isset($tables[$database])) { - return $tables[$database]; - } - - if (isset($tables[mb_strtolower($database)])) { - // on windows with lower_case_table_names = 1 - // MySQL returns - // with SHOW DATABASES or information_schema.SCHEMATA: `Test` - // but information_schema.TABLES gives `test` - // see https://github.com/phpmyadmin/phpmyadmin/issues/8402 - return $tables[mb_strtolower($database)]; + if ($tables !== []) { + // cache table data, so Table does not require to issue SHOW TABLE STATUS again + $this->cache->cacheTableData($database, $tables); } return $tables; diff --git a/libraries/classes/Query/Cache.php b/libraries/classes/Query/Cache.php index 6ea1e74ebb..4dc658c097 100644 --- a/libraries/classes/Query/Cache.php +++ b/libraries/classes/Query/Cache.php @@ -15,30 +15,27 @@ use function is_array; */ class Cache { - /** @var array Table data cache */ + /** @var array[] Table data cache */ private $tableCache = []; /** * Caches table data so Table does not require to issue * SHOW TABLE STATUS again * - * @param array[][] $tables information for tables of some databases + * @param mixed[][] $tables information for tables of some databases */ - public function cacheTableData(array $tables): void + public function cacheTableData(string $database, array $tables): void { - // Note: I don't see why we would need array_merge_recursive() here, - // as it creates double entries for the same table (for example a double - // entry for Comment when changing the storage engine in Operations) - // Note 2: Instead of array_merge(), simply use the + operator because - // array_merge() renumbers numeric keys starting with 0, therefore - // we would lose a db name that consists only of numbers + // Note: This function must not use array_merge because numerical indices must be preserved. + // When an entry already exists for the database in cache, we merge the incoming data with existing data. + // The union operator appends elements from right to left unless they exists on the left already. + // Doing the union with incoming data on the left ensures that when we reread table status from DB, + // we overwrite whatever was in cache with the new data. - foreach ($tables as $one_database => $_) { - if (isset($this->tableCache[$one_database])) { - $this->tableCache[$one_database] += $tables[$one_database]; - } else { - $this->tableCache[$one_database] = $tables[$one_database]; - } + if (isset($this->tableCache[$database])) { + $this->tableCache[$database] = $tables + $this->tableCache[$database]; + } else { + $this->tableCache[$database] = $tables; } } diff --git a/libraries/classes/Query/Compatibility.php b/libraries/classes/Query/Compatibility.php index 5b80d52894..d81040f0e8 100644 --- a/libraries/classes/Query/Compatibility.php +++ b/libraries/classes/Query/Compatibility.php @@ -19,6 +19,7 @@ use function substr; */ class Compatibility { + /** @return mixed[][] */ public static function getISCompatForGetTablesFull(array $eachTables, string $eachDatabase): array { foreach ($eachTables as $table_name => $_) { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 10a6916104..fcc1d843a4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -2765,11 +2765,6 @@ parameters: count: 1 path: libraries/classes/DatabaseInterface.php - - - message: "#^Parameter \\#3 \\.\\.\\.\\$args of function array_map expects array, mixed given\\.$#" - count: 1 - path: libraries/classes/DatabaseInterface.php - - message: "#^Parameter \\#4 \\$link of method PhpMyAdmin\\\\DatabaseInterface\\:\\:fetchResult\\(\\) expects int, mixed given\\.$#" count: 7 @@ -7045,11 +7040,6 @@ parameters: count: 1 path: libraries/classes/Query/Cache.php - - - message: "#^Method PhpMyAdmin\\\\Query\\\\Cache\\:\\:cacheTableData\\(\\) has parameter \\$tables with no value type specified in iterable type array\\.$#" - count: 1 - path: libraries/classes/Query/Cache.php - - message: "#^Method PhpMyAdmin\\\\Query\\\\Cache\\:\\:getCache\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -7080,11 +7070,6 @@ parameters: count: 1 path: libraries/classes/Query/Compatibility.php - - - message: "#^Method PhpMyAdmin\\\\Query\\\\Compatibility\\:\\:getISCompatForGetTablesFull\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: libraries/classes/Query/Compatibility.php - - message: "#^Method PhpMyAdmin\\\\Query\\\\Generator\\:\\:getInformationSchemaColumnsFullRequest\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 67cb0580ac..1a69e9392d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -5772,7 +5772,7 @@ int|bool - + $a $arrayKeys $b @@ -5794,10 +5794,6 @@ $link $link $link - $link - $one_database_tables - $one_database_tables - $one_table_name $password $server $sql @@ -5824,23 +5820,20 @@ $user $warningsCount - + $one_database_name - $one_database_tables - $one_database_tables $table_name uksort($each_tables, 'strnatcasecmp') + uksort($one_database_tables, 'strnatcasecmp') usort($tables, 'strnatcasecmp') - + $event['Name'] $event['Status'] $event['Type'] - $link $one_show['Db'] $one_show['Name'] $one_show['Type'] - $one_table_data['Engine'] $routine['DTD_IDENTIFIER'] $routine['Db'] $routine['Definer'] @@ -5888,7 +5881,7 @@ $this->links[$link] $this->links[$link] - + $aLength $bLength $database @@ -5899,9 +5892,6 @@ $grant $key_index $map['real_column'] - $one_database_tables - $one_database_tables - $one_database_tables $one_result['action_timing'] $one_result['definer'] $one_result['definition'] @@ -5909,8 +5899,6 @@ $one_result['name'] $one_result['table'] $one_show - $one_table_data - $one_table_name $result $result[] $result_target @@ -5932,8 +5920,7 @@ $trigger['TRIGGER_NAME'] $warningsCount - - array + array string @@ -5948,9 +5935,7 @@ $this->links[$link]->warning_count - - $tables[$database] - $tables[mb_strtolower($database)] + SessionCache::get('mysql_cur_user') reset($columns) @@ -5962,9 +5947,6 @@ $user SessionCache::get('mysql_cur_user') - - $table - $row[$value] @@ -12124,9 +12106,6 @@ - - $this->tableCache[$one_database][$table] - $loc[$key] $loc[$key] @@ -12137,9 +12116,6 @@ $loc $loc[array_shift($contentPath)] - - $this->tableCache[$one_database] - @@ -12252,6 +12228,10 @@ $eachTables[$table_name]['UPDATE_TIME'] $eachTables[$table_name]['VERSION'] + + $eachTables + mixed[][] + diff --git a/test/classes/Stubs/DbiDummy.php b/test/classes/Stubs/DbiDummy.php index a7aba1fbf5..f78326cf39 100644 --- a/test/classes/Stubs/DbiDummy.php +++ b/test/classes/Stubs/DbiDummy.php @@ -1182,152 +1182,45 @@ class DbiDummy implements DbiExtension ], 'result' => [ [ - 'def', - 'smash', - 'issues_issue', + 'ref', + 'pma_test', + 'table1', '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', + 'DBIdummy', + '11', + 'Redundant', + '123456', + '42', + '21708991', + '281474976710655',// MyISAM + '2048',// MyISAM + '2547', + '5', + '2014-06-24 17:30:00', + '2018-06-25 18:35:12', + '2015-04-24 19:30:59', + 'utf8mb4_general_ci', + '3844432963', + 'row_format=REDUNDANT', + 'Test comment for "table1" in \'pma_test\'', + 'table1', + 'DBIdummy', + '11', + 'Redundant', + '123456', + '42', + '21708991', + '281474976710655',// MyISAM + '2048',// MyISAM + '2547', + '5', + '2014-06-24 17:30:00', + '2018-06-25 18:35:12', + '2015-04-24 19:30:59', + 'utf8mb4_general_ci', + '3844432963', + 'row_format=REDUNDANT', + 'Test comment for "table1" in \'pma_test\'', ], ], ], @@ -1769,44 +1662,7 @@ class DbiDummy implements DbiExtension ], [ 'query' => "SHOW TABLE STATUS FROM `my_dataset` WHERE `Name` LIKE 'company\\\\_users%'", - '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 ('table1')" - . " AND t.`TABLE_NAME` = 'pma_test' 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', @@ -1830,16 +1686,13 @@ class DbiDummy implements DbiExtension ], 'result' => [ [ - 'ref', - 'pma_test', - 'table1', - 'BASE TABLE', + 'company_users', 'DBIdummy', '11', 'Redundant', '123456', '42', - '21708991', + '18', '281474976710655',// MyISAM '2048',// MyISAM '2547', @@ -1850,25 +1703,7 @@ class DbiDummy implements DbiExtension 'utf8mb4_general_ci', '3844432963', 'row_format=REDUNDANT', - 'Test comment for "table1" in \'pma_test\'', - 'table1', - 'DBIdummy', - '11', - 'Redundant', - '123456', - '42', - '21708991', - '281474976710655',// MyISAM - '2048',// MyISAM - '2547', - '5', - '2014-06-24 17:30:00', - '2018-06-25 18:35:12', - '2015-04-24 19:30:59', - 'utf8mb4_general_ci', - '3844432963', - 'row_format=REDUNDANT', - 'Test comment for "table1" in \'pma_test\'', + 'Test comment for "company_users" in \'my_dataset\'', ], ], ], @@ -2990,6 +2825,162 @@ class DbiDummy implements DbiExtension ], ], ], + [ + '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 (\'test_db\') AND t.`TABLE_NAME` IN (\'test_table\') 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', + 'MAX_INDEX_LENGTH', + 'TEMPORARY', + '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', + 'test_db', + 'test_table', + 'BASE TABLE', + 'InnoDB', + '10', + 'Dynamic', + '3', + '5461', + '16384', + '0', + '0', + '0', + '4', + '2011-12-13 14:15:16', + null, + null, + 'utf8mb4_general_ci', + null, + '', + '', + '0', + 'N', + 'test_db', + 'test_table', + 'BASE TABLE', + 'InnoDB', + 'InnoDB', + '10', + 'Dynamic', + '3', + '5461', + '16384', + '0', + '0', + '0', + '4', + '2011-12-13 14:15:16', + null, + null, + 'utf8mb4_general_ci', + null, + '', + '', + ], + ], + ], + [ + 'query' => 'SHOW TABLE STATUS FROM `pma_test` WHERE `Name` LIKE \'table1%\'', + 'columns' => [ + 'Name', + 'Engine', + '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', + 'Max_index_length', + 'Temporary', + ], + 'result' => [ + [ + 'table1', + 'InnoDB', + '10', + 'Dynamic', + '4046', + '101', + '409600', + '0', + '114688', + '0', + '4080', + '2020-07-03 17:24:47', + null, + null, + 'utf8mb4_general_ci', + null, + '', + '', + '0', + 'N', + ], + ], + ], [ 'query' => 'SHOW TABLE STATUS FROM `world`', 'columns' => [ diff --git a/test/classes/TableTest.php b/test/classes/TableTest.php index 27658bcac2..6082c9b5cb 100644 --- a/test/classes/TableTest.php +++ b/test/classes/TableTest.php @@ -1537,7 +1537,7 @@ class TableTest extends AbstractTestCase $target_db = 'pma_test'; $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object = new Table($target_table, $target_db, $dbi); $tbl_object->getStatusInfo(null, true); $expect = 'DBIDUMMY'; $tbl_storage_engine = $dbi->getTable($target_db, $target_table)->getStorageEngine(); @@ -1553,7 +1553,7 @@ class TableTest extends AbstractTestCase $target_db = 'pma_test'; $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object = new Table($target_table, $target_db, $dbi); $tbl_object->getStatusInfo(null, true); $expect = 'Test comment for "table1" in \'pma_test\''; $show_comment = $dbi->getTable($target_db, $target_table)->getComment(); @@ -1569,7 +1569,7 @@ class TableTest extends AbstractTestCase $target_db = 'pma_test'; $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object = new Table($target_table, $target_db, $dbi); $tbl_object->getStatusInfo(null, true); $expect = 'utf8mb4_general_ci'; $tbl_collation = $dbi->getTable($target_db, $target_table)->getCollation(); @@ -1585,7 +1585,7 @@ class TableTest extends AbstractTestCase $target_db = 'pma_test'; $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object = new Table($target_table, $target_db, $dbi); $tbl_object->getStatusInfo(null, true); $expect = 'Redundant'; $row_format = $dbi->getTable($target_db, $target_table)->getRowFormat(); @@ -1601,7 +1601,7 @@ class TableTest extends AbstractTestCase $target_db = 'pma_test'; $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object = new Table($target_table, $target_db, $dbi); $tbl_object->getStatusInfo(null, true); $expect = '5'; $auto_increment = $dbi->getTable($target_db, $target_table)->getAutoIncrement(); @@ -1617,7 +1617,7 @@ class TableTest extends AbstractTestCase $target_db = 'pma_test'; $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object = new Table($target_table, $target_db, $dbi); $tbl_object->getStatusInfo(null, true); $expect = [ 'pack_keys' => 'DEFAULT',