bug 2941037 - Database structure not sorted by table correctly
This commit is contained in:
@@ -40,6 +40,9 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
|
|||||||
+ rfe #2938579 [interface] Add class to some elements for easier theming.
|
+ rfe #2938579 [interface] Add class to some elements for easier theming.
|
||||||
+ rfe #2937840 [doc] Add some interesting configs to config.sample.inc.php.
|
+ rfe #2937840 [doc] Add some interesting configs to config.sample.inc.php.
|
||||||
|
|
||||||
|
3.3.1.0 (not yet released)
|
||||||
|
- bug #2941037 [core] Database structure not sorted by table correctly
|
||||||
|
|
||||||
3.3.0.0 (not yet released)
|
3.3.0.0 (not yet released)
|
||||||
+ rfe #2308632 [edit] Use hex for (var)binary fields,
|
+ rfe #2308632 [edit] Use hex for (var)binary fields,
|
||||||
thanks to Maarten Dieleman - maartendieleman
|
thanks to Maarten Dieleman - maartendieleman
|
||||||
|
@@ -263,19 +263,19 @@ function PMA_DBI_get_tables_full($database, $table = false, $tbl_is_group = fals
|
|||||||
|
|
||||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||||
// get table information from information_schema
|
// get table information from information_schema
|
||||||
if ($table) {
|
if ($table) {
|
||||||
if (true === $tbl_is_group) {
|
if (true === $tbl_is_group) {
|
||||||
$sql_where_table = 'AND `TABLE_NAME` LIKE \''
|
$sql_where_table = 'AND `TABLE_NAME` LIKE \''
|
||||||
. PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
|
. PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
|
||||||
} elseif ('comment' === $tbl_is_group) {
|
} elseif ('comment' === $tbl_is_group) {
|
||||||
$sql_where_table = 'AND `TABLE_COMMENT` LIKE \''
|
$sql_where_table = 'AND `TABLE_COMMENT` LIKE \''
|
||||||
. PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
|
. PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
|
||||||
} else {
|
} else {
|
||||||
$sql_where_table = 'AND `TABLE_NAME` = \'' . addslashes($table) . '\'';
|
$sql_where_table = 'AND `TABLE_NAME` = \'' . addslashes($table) . '\'';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$sql_where_table = '';
|
$sql_where_table = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// for PMA bc:
|
// for PMA bc:
|
||||||
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
|
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
|
||||||
@@ -284,9 +284,9 @@ function PMA_DBI_get_tables_full($database, $table = false, $tbl_is_group = fals
|
|||||||
// added BINARY in the WHERE clause to force a case sensitive
|
// added BINARY in the WHERE clause to force a case sensitive
|
||||||
// comparison (if we are looking for the db Aa we don't want
|
// comparison (if we are looking for the db Aa we don't want
|
||||||
// to find the db aa)
|
// to find the db aa)
|
||||||
$this_databases = array_map('PMA_sqlAddslashes', $databases);
|
$this_databases = array_map('PMA_sqlAddslashes', $databases);
|
||||||
|
|
||||||
$sql = '
|
$sql = '
|
||||||
SELECT *,
|
SELECT *,
|
||||||
`TABLE_SCHEMA` AS `Db`,
|
`TABLE_SCHEMA` AS `Db`,
|
||||||
`TABLE_NAME` AS `Name`,
|
`TABLE_NAME` AS `Name`,
|
||||||
@@ -312,41 +312,28 @@ function PMA_DBI_get_tables_full($database, $table = false, $tbl_is_group = fals
|
|||||||
WHERE ' . (PMA_IS_WINDOWS ? '' : 'BINARY') . ' `TABLE_SCHEMA` IN (\'' . implode("', '", $this_databases) . '\')
|
WHERE ' . (PMA_IS_WINDOWS ? '' : 'BINARY') . ' `TABLE_SCHEMA` IN (\'' . implode("', '", $this_databases) . '\')
|
||||||
' . $sql_where_table;
|
' . $sql_where_table;
|
||||||
|
|
||||||
// Sort the tables
|
// Sort the tables
|
||||||
if ($sort_by == 'Name' && $GLOBALS['cfg']['NaturalOrder']) {
|
$sql .= " ORDER BY $sort_by $sort_order";
|
||||||
// This crazy bit of SQL was inspired by a post here:
|
|
||||||
// http://forums.mysql.com/read.php?10,34908,35959#msg-35959
|
|
||||||
|
|
||||||
// Find the longest table name
|
if ($limit_count) {
|
||||||
$max_name_sql = "SELECT MAX(LENGTH(TABLE_NAME)) FROM `information_schema`.`TABLES`
|
$sql .= ' LIMIT ' . $limit_count . ' OFFSET ' . $limit_offset;
|
||||||
WHERE `TABLE_SCHEMA` IN ('" . implode("', '", $this_databases) . "')";
|
}
|
||||||
$max_name_array = PMA_DBI_fetch_result($max_name_sql);
|
|
||||||
$max_name_length = $max_name_array[0];
|
|
||||||
|
|
||||||
// Put the CASE statement SQL together.
|
$tables = PMA_DBI_fetch_result($sql, array('TABLE_SCHEMA', 'TABLE_NAME'),
|
||||||
$sql_case = '';
|
|
||||||
for ($i = 1; $i < $max_name_length; $i++) {
|
|
||||||
$sql_case .= " when substr(Name, $i) between '0' and '9' then $i";
|
|
||||||
}
|
|
||||||
$sql_case .= " ELSE $max_name_length end) ";
|
|
||||||
|
|
||||||
// Add the CASE statement to the main SQL
|
|
||||||
$sql .= " ORDER BY left(Name, (CASE ";
|
|
||||||
$sql .= $sql_case . "-1) $sort_order, 0+substr(Name, CASE";
|
|
||||||
$sql .= $sql_case . $sort_order;
|
|
||||||
} else {
|
|
||||||
// Just let MySQL sort as it normally does
|
|
||||||
$sql .= " ORDER BY $sort_by $sort_order";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($limit_count) {
|
|
||||||
$sql .= ' LIMIT ' . $limit_count . ' OFFSET ' . $limit_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tables = PMA_DBI_fetch_result($sql, array('TABLE_SCHEMA', 'TABLE_NAME'),
|
|
||||||
null, $link);
|
null, $link);
|
||||||
unset($sql_where_table, $sql);
|
unset($sql_where_table, $sql);
|
||||||
}
|
if ($sort_by == 'Name' && $GLOBALS['cfg']['NaturalOrder']) {
|
||||||
|
// here, the array's first key is by schema name
|
||||||
|
foreach($tables as $one_database_name => $one_database_tables) {
|
||||||
|
uksort($one_database_tables, 'strnatcasecmp');
|
||||||
|
|
||||||
|
if ($sort_order == 'DESC') {
|
||||||
|
$one_database_tables = array_reverse($one_database_tables);
|
||||||
|
}
|
||||||
|
$tables[$one_database_name] = $one_database_tables;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // end (get information from table schema)
|
||||||
|
|
||||||
// If permissions are wrong on even one database directory,
|
// If permissions are wrong on even one database directory,
|
||||||
// information_schema does not return any table info for any database
|
// information_schema does not return any table info for any database
|
||||||
|
Reference in New Issue
Block a user