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

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

Open
sibwy opened this issue Dec 6, 2023 · 0 comments
Open

Comments

@sibwy
Copy link

sibwy commented Dec 6, 2023

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.

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant