Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax-errored ALTER TABLE is exported #11968

Closed
yoku0825 opened this issue Feb 16, 2016 · 0 comments
Closed

Syntax-errored ALTER TABLE is exported #11968

yoku0825 opened this issue Feb 16, 2016 · 0 comments
Assignees
Labels
Bug A problem or regression with an existing feature
Milestone

Comments

@yoku0825
Copy link

Description

  • 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 */;
@nijel nijel added the Bug A problem or regression with an existing feature label Feb 16, 2016
@nijel nijel added this to the 4.5.5 milestone Feb 16, 2016
@nijel nijel self-assigned this Feb 16, 2016
@nijel nijel closed this as completed in 50af85c Feb 16, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A problem or regression with an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants