Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Duplicate
-
10.3.13
-
Windows 10 64bit
Description
When you create a table that has a column with both a CHECK and a COMMENT (or alter a table to add such a column), then the SHOW CREATE TABLE statement provides the two attributes in the wrong order, causing a syntax error.
Please see the test script for examples.
SELECT VERSION(); |
|
# Initial SQL for Create Table |
CREATE TABLE `testTableWithComment`( |
`i` INT NOT NULL COMMENT 'A comment!' CHECK (`i` > 5), |
PRIMARY KEY (`i`) |
) ENGINE=INNODB;
|
|
# Get the Create Table SQL |
SHOW CREATE TABLE `testTableWithComment`; |
/*
|
CREATE TABLE `testTableWithComment` (
|
`i` int(11) NOT NULL CHECK (`i` > 5) COMMENT 'A comment!',
|
PRIMARY KEY (`i`)
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
*/
|
|
/* When the above is run, you get:
|
Error Code: 1064
|
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'COMMENT 'A comment!',
|
PRIMARY KEY (`i`)
|
) ENGINE=InnoDB DEFAULT CHARSET=lati' at line 10
|
*/
|
|
# Altering Table |
ALTER TABLE `testTableWithComment` |
ADD COLUMN `q` INT NOT NULL COMMENT 'A boring comment' CHECK (`q` > 2); |
|
# Get the Create Table SQL |
SHOW CREATE TABLE `testTableWithComment`; |
/* Same issue with the new column:
|
CREATE TABLE `testTableWithComment` (
|
`i` int(11) NOT NULL CHECK (`i` > 5) COMMENT 'A comment!',
|
`q` int(11) NOT NULL CHECK (`q` > 2) COMMENT 'A boring comment',
|
PRIMARY KEY (`i`)
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1*/ |
Attachments
Issue Links
- is duplicated by
-
MDEV-17654 Incorrect syntax returned for column with CHECK constraint in the "SHOW CREATE TABLE ..." result
- Closed
-
MDEV-18473 DB restore fails when CHECK and COMMENT are used
- Closed