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

Add support for CHECK constraints (feature request) #13592

Open
stevenwdv opened this issue Aug 18, 2017 · 8 comments
Open

Add support for CHECK constraints (feature request) #13592

stevenwdv opened this issue Aug 18, 2017 · 8 comments
Labels
enhancement A feature request for improving phpMyAdmin parser waiting on upstream Issues blocked by a third-party
Milestone

Comments

@stevenwdv
Copy link
Contributor

stevenwdv commented Aug 18, 2017

MariaDB (MySQL-compatible) added support for CHECK constraints to version 10.2.1 (stable=10.2.8). It would be very useful if PHPMyAdmin had a UI for adding and managing these in tbl_create.php and tbl_structure.php.
(Update: see also phpmyadmin/sql-parser#167)

Edit: they are also not exported by export.php.

@nijel nijel added the enhancement A feature request for improving phpMyAdmin label Aug 21, 2017
@aroralakshya
Copy link
Contributor

aroralakshya commented Mar 3, 2018

The MySQL Reference Manual says:
The CHECK clause is parsed but ignored by all storage engines.

Triggers should be used instead of check constraint.

@Gemorroj
Copy link
Contributor

Gemorroj commented Mar 3, 2018

@aroralakshya
Copy link
Contributor

It's ignored in my version of mariaDB
check
Have you tried implementing?

@Gemorroj
Copy link
Contributor

Gemorroj commented Mar 3, 2018

@nulll-pointer you use mariadb 10.1.30, but support check constraints added in 10.2.1 version.

@ibennetch
Copy link
Member

@nulll-pointer according to the documentation link posted by Gemorroj, your MariaDB is too old. MySQL ignoring it doesn't mean we shouldn't implement it for MariaDB.

@ibennetch
Copy link
Member

I see this as a three-part issue:

  • Update parser to understand this syntax
  • Update the export interface to allow including these in an export
  • Implement an interface for interacting with these constraints

@maherbo
Copy link

maherbo commented Jun 11, 2018

Using version 4.7.4, this is more than enhancement, it is a bug.

Right now, you can add the CHECK constraint with a custom SQL statement. Even though the parser indicates a syntax error, it works.

But, when you try to export the table, the CHECK constraint is unrecognized and is ignored in the CREATE TABLE statement ... but so are ALL columns definitions afterward. That is a bug.

@williamdes williamdes added the has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete label Dec 31, 2018
@williamdes williamdes added the waiting on upstream Issues blocked by a third-party label Mar 31, 2019
@williamdes williamdes added this to Triage zone in Enhancements Jan 23, 2020
@williamdes williamdes moved this from Triage zone to Nice to have soon in Enhancements Jan 23, 2020
@williamdes williamdes removed the has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete label Jun 2, 2022
@williamdes williamdes added this to the 5.3.0 milestone Jun 2, 2022
@nunoperalta
Copy link

Hey!

I came here to suggest exactly this.

  1. Add a CHECK section in the page where we add a new column to a table (similar to "Virtuality"), or when we create a new table

  2. Add CHECK section in the page where we edit an existing column, retrieving its current logic

  3. Preview SQL should contain CHECK (at the moment, if we edit an existing column with CHECK, it will be lost!)

  4. Display the CHECK logic in the Table Structure page

--

ALTER TABLE `table` ADD col TINYINT UNSIGNED NOT NULL DEFAULT 0 CHECK (col < 7)

ALTER ONLINE TABLE `table` CHANGE `col` `col` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0 CHECK (col < 8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature request for improving phpMyAdmin parser waiting on upstream Issues blocked by a third-party
Projects
Enhancements
  
Nice to have soon
Development

No branches or pull requests

8 participants