Merge pull request #11779 from devenbansod/fix_error_in_11757_correction

Fix #11777: While 'changing a column', query fails with a syntax error after the 'CHARSET=' keyword
This commit is contained in:
Deven Bansod 2015-12-27 10:55:40 +05:30
commit 8bd97563b4
3 changed files with 11 additions and 5 deletions

View File

@ -410,7 +410,7 @@ class PMA_Table
$type
);
if (! empty($collation) && $collation != 'NULL' && $matches) {
$query .= PMA_generateCharsetQueryPart($collation);
$query .= PMA_generateCharsetQueryPart($collation, true);
}
if ($null !== false) {

View File

@ -84,15 +84,21 @@ function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION,
/**
* Generate the charset query part
*
* @param string $collation Collation
* @param string $collation Collation
* @param boolean optional $override force 'CHARACTER SET' keyword
*
* @return string
*/
function PMA_generateCharsetQueryPart($collation)
function PMA_generateCharsetQueryPart($collation, $override = false)
{
if (!PMA_DRIZZLE) {
list($charset) = explode('_', $collation);
return ' CHARSET=' . $charset
$keyword = ' CHARSET=';
if ($override) {
$keyword = ' CHARACTER SET ';
}
return $keyword . $charset
. ($charset == $collation ? '' : ' COLLATE ' . $collation);
} else {
return ' COLLATE ' . $collation;

View File

@ -713,7 +713,7 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
. "COLLATE charset1 NULL DEFAULT 'VARCHAR' "
. "AUTO_INCREMENT COMMENT 'PMA comment' AFTER `new_name`";
} else {
$expect = "`name` `new_name` VARCHAR(2) new_name CHARSET="
$expect = "`name` `new_name` VARCHAR(2) new_name CHARACTER SET "
. "charset1 NULL DEFAULT 'VARCHAR' "
. "AUTO_INCREMENT COMMENT 'PMA comment' AFTER `new_name`";
}