webyog / sqlyog-community

Webyog provides monitoring and management tools for open source relational databases. We develop easy-to-use MySQL client tools for performance tuning and database management. Webyog's solutions include SQL Diagnostic Manager for MySQL performance optimization and SQLyog for MySQL administration. More than 35,000 companies (including Amazon, IBM, Salesforce, AT&T, eBay, and GE) and 2.5 million users rely on Webyog's solutions to provide valuable insights into their databases. Webyog is an Idera, Inc. company.
https://webyog.com/
GNU General Public License v2.0
2.16k stars 318 forks source link

Altering a table with column level CHECK constraint returns syntax error #2337

Open sibwy opened 7 months ago

sibwy commented 7 months ago

Server affected: MariaDB 11.1.3 and below

Steps to reproduce:

  1. Create the below table using the SQLyog ‘Create Table’ option/grid, but do not type the parentheses for the CHECK condition (i.e., type the text highlighted `val` = 1 OR `val` IS NULL ).

    CREATE TABLE `test` (
    `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `val` INT(11)COMMENT 'abcd' CHECK (`val` = 1 OR `val` IS NULL),
    PRIMARY KEY (`id`)
    ) ENGINE=INNODB DEFAULT CHARSET=utf8;

    NB: SQLyog encloses the column level CHECK constraint's condition in parenthesis in the query generated.

  2. Using the ‘Alter Table’ option, replace the entire column level check condition with `val` = 1. And save the changes.

  3. It returns the syntax error since the check condition isn’t enclosed in parenthesis.