diff --git a/ChangeLog b/ChangeLog index a5f71a4652..168a008809 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,7 @@ phpMyAdmin - ChangeLog 4.5.4.0 (not yet released) - issue #11724 live data edit of big sets is not working - issue Table list not saved in db QBE bookmarked search +- issue #11777 While 'changing a column', query fails with a syntax error after the 'CHARSET=' keyword 4.5.3.1 (2015-12-25) - issue #11774 Undefined offset 2 diff --git a/libraries/Table.php b/libraries/Table.php index 32da5adf1f..1a38b31ab9 100644 --- a/libraries/Table.php +++ b/libraries/Table.php @@ -415,7 +415,7 @@ class Table $type ); if (! empty($collation) && $collation != 'NULL' && $matches) { - $query .= PMA_generateCharsetQueryPart($collation); + $query .= PMA_generateCharsetQueryPart($collation, true); } if ($null !== false) { diff --git a/libraries/mysql_charsets.lib.php b/libraries/mysql_charsets.lib.php index 75dc9abf2b..2b5dd880fa 100644 --- a/libraries/mysql_charsets.lib.php +++ b/libraries/mysql_charsets.lib.php @@ -82,14 +82,20 @@ 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) { list($charset) = explode('_', $collation); - return ' CHARSET=' . $charset + $keyword = ' CHARSET='; + + if ($override) { + $keyword = ' CHARACTER SET '; + } + return $keyword . $charset . ($charset == $collation ? '' : ' COLLATE ' . $collation); } diff --git a/test/classes/TableTest.php b/test/classes/TableTest.php index 12880eff11..b5821dc435 100644 --- a/test/classes/TableTest.php +++ b/test/classes/TableTest.php @@ -682,7 +682,7 @@ class TableTest extends PMATestCase $extra, $comment, $virtuality, $expression, $move_to ); - $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`";