You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
phpMyAdmin exports incorrect (syntax-errored) ALTER TABLE when the table has comment of INDEX.
Environment which I can reproduce,
phpMyAdmin 4.5.4.1
MySQL 5.6.28
PHP 5.6.18
How to repeat
Create table which has comment of INDEX(This step has no difference whether using CLI or phpMyAdmin)
CREATE DATABASE d1;
CREATE TABLE d1.t1 (num int COMMENT 'This is comment of Columu', KEY (num) COMMENT 'This is comment of Index') COMMENT= 'This is comment of Table';
Click "Export" tab and choise "Quick" as Export method, "SQL" as Format. (Nothing have to do from default)
Execute statements in dump file and you'd got error.
mysql> CREATE TABLE `t1` (
-> `num` int(11) DEFAULT NULL
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='This is comment of Table';
Query OK, 0 rows affected (0.01 sec)
mysql> ALTER TABLE `t1`
-> ADD KEY `num` (`num`) COMMENT='This is comment of Index';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='This is comment of Index'' at line 2
And you can find comment of Column disappeared from dump file.
Suggested fix
Remove incorrect "=" from exported ALTER TABLE statement.
mysql> ALTER TABLE t1 Comment = 'This is correct comment of table'; -- "COMMENT" with "=" for Comment of Table
mysql> ALTER TABLE t1 Comment 'This is correct comment of table'; -- "COMMENT" without "=" for Comment of Table
mysql> ALTER TABLE t1 ADD KEY (num) Comment = 'This is wrong'; -- "COMMENT" with "=" for Comment of Index
mysql> ALTER TABLE t1 ADD KEY (num) Comment 'This is correct comment of Index'; -- "COMMENT" without "=" for Comment of Index
Whole SQL Dump file is following
-- phpMyAdmin SQL Dump
-- version 4.5.4.1
-- http://www.phpmyadmin.net
--
-- Host: 172.17.1.211
-- Generation Time: Feb 16, 2016 at 08:10 AM
-- Server version: 5.6.28
-- PHP Version: 5.6.18
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `d1`
--
CREATE DATABASE IF NOT EXISTS `d1` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
USE `d1`;
-- --------------------------------------------------------
--
-- Table structure for table `t1`
--
CREATE TABLE `t1` (
`num` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='This is comment of Table';
--
-- Indexes for dumped tables
--
--
-- Indexes for table `t1`
--
ALTER TABLE `t1`
ADD KEY `num` (`num`) COMMENT='This is comment of Index';
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
The text was updated successfully, but these errors were encountered:
Description
How to repeat
Suggested fix
Whole SQL Dump file is following
The text was updated successfully, but these errors were encountered: