diff --git a/ChangeLog b/ChangeLog index ac16edb02f..7ed213d8ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ phpMyAdmin - ChangeLog 4.2.1.0 (not yet released) - bug #4380 Cannot display table structure with enums containing special characters - bug #4381 Cannot remove the last remembered sorted column +- bug Correctly fetch length of user and host fields in MySQL tables 4.2.0.0 (not yet released) + rfe #1403 Export only triggers diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index e566b0296a..0ca07f9d40 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -1513,22 +1513,22 @@ function PMA_getHtmlForLoginInformationFields($mode = 'new') */ function PMA_getUsernameAndHostnameLength() { - $fields_info = $GLOBALS['dbi']->getColumns('mysql', 'user', null, true); + /* Fallback values */ $username_length = 16; $hostname_length = 41; + + /* Try to get real lengths from the database */ + $fields_info = $GLOBALS['dbi']->fetchResult( + 'SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH ' + . 'FROM information_schema.columns ' + . "WHERE table_schema = 'mysql' AND table_name = 'user' " + . "AND COLUMN_NAME IN ('User', 'Host')" + ); foreach ($fields_info as $val) { - if ($val['Field'] == 'User') { - strtok($val['Type'], '()'); - $value = strtok('()'); - if (is_int($value)) { - $username_length = $value; - } - } elseif ($val['Field'] == 'Host') { - strtok($val['Type'], '()'); - $value = strtok('()'); - if (is_int($value)) { - $hostname_length = $value; - } + if ($val['COLUMN_NAME'] == 'User') { + $username_length = $val['CHARACTER_MAXIMUM_LENGTH']; + } elseif ($val['COLUMN_NAME'] == 'Host') { + $hostname_length = $val['CHARACTER_MAXIMUM_LENGTH']; } } return array($username_length, $hostname_length);