Details

    • Bug
    • Status: In Review (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.11.2, 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11
    • 10.5, 10.6, 10.11
    • Server
    • None

    Description

      Run the following statements, you will see the last statement fails to drop the CHECK constraint, and reports an error ` Can't DROP CONSTRAINT `c1`; check that it exists`

      DROP TABLE IF EXISTS t0;
      CREATE TABLE t0 (c1 INT CHECK ( c1 > 0 ));
      SELECT CONSTRAINT_NAME, TABLE_NAME, CONSTRAINT_TYPE FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_NAME = 't0' AND TABLE_SCHEMA = 'test';
      ALTER TABLE t0 DROP CONSTRAINT c1;
      

      Attachments

        Issue Links

          Activity

            alice Alice Sherepa added a comment - - edited

            Thanks for the report, it should be fixed.
            Currently it works like this - there are 2 ways to define a constraint:

            CHECK(expression) given as part of a column definition – to drop it one should use ALTER TABLE ..MODIFY COLUMN.
            CONSTRAINT constraint_name CHECK (expression) – here ALTER TABLE .. DROP CONSTRAINT ;

            MariaDB [test]> CREATE TABLE t0 (c1 INT CHECK ( c1 > 0 ));
            Query OK, 0 rows affected (0,054 sec)
             
            MariaDB [test]> show create table t0;
            +-------+-----------------------------------------------------------------------------------------------------------------------------------+
            | Table | Create Table                                                                                                                      |
            +-------+-----------------------------------------------------------------------------------------------------------------------------------+
            | t0    | CREATE TABLE `t0` (
              `c1` int(11) DEFAULT NULL CHECK (`c1` > 0)
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
            +-------+-----------------------------------------------------------------------------------------------------------------------------------+
            1 row in set (0,001 sec)
             
            MariaDB [test]> ALTER TABLE t0 MODIFY COLUMN c1 INT ;
            Query OK, 0 rows affected (0,037 sec)
            Records: 0  Duplicates: 0  Warnings: 0
             
            MariaDB [test]> show create table t0;
            +-------+------------------------------------------------------------------------------------------------------------------+
            | Table | Create Table                                                                                                     |
            +-------+------------------------------------------------------------------------------------------------------------------+
            | t0    | CREATE TABLE `t0` (
              `c1` int(11) DEFAULT NULL
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
            +-------+------------------------------------------------------------------------------------------------------------------+
            1 row in set (0,003 sec)
             
            MariaDB [test]> CREATE or replace TABLE t0 (c1 INT, CHECK ( c1 > 0 ));
            Query OK, 0 rows affected (0,059 sec)
             
            MariaDB [test]> show create table t0;
            +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
            | Table | Create Table                                                                                                                                                   |
            +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
            | t0    | CREATE TABLE `t0` (
              `c1` int(11) DEFAULT NULL,
              CONSTRAINT `CONSTRAINT_1` CHECK (`c1` > 0)
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
            +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
            1 row in set (0,001 sec)
             
            MariaDB [test]> ALTER TABLE t0 DROP CONSTRAINT CONSTRAINT_1;
            Query OK, 0 rows affected (0,031 sec)
            Records: 0  Duplicates: 0  Warnings: 0
             
            MariaDB [test]> show create table t0;
            +-------+------------------------------------------------------------------------------------------------------------------+
            | Table | Create Table                                                                                                     |
            +-------+------------------------------------------------------------------------------------------------------------------+
            | t0    | CREATE TABLE `t0` (
              `c1` int(11) DEFAULT NULL
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
            +-------+------------------------------------------------------------------------------------------------------------------+
            1 row in set (0,001 sec)
            

            alice Alice Sherepa added a comment - - edited Thanks for the report, it should be fixed. Currently it works like this - there are 2 ways to define a constraint: CHECK(expression) given as part of a column definition – to drop it one should use ALTER TABLE ..MODIFY COLUMN. CONSTRAINT constraint_name CHECK (expression) – here ALTER TABLE .. DROP CONSTRAINT ; MariaDB [test]> CREATE TABLE t0 (c1 INT CHECK ( c1 > 0 )); Query OK, 0 rows affected (0,054 sec)   MariaDB [test]> show create table t0; +-------+-----------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+-----------------------------------------------------------------------------------------------------------------------------------+ | t0 | CREATE TABLE `t0` ( `c1` int(11) DEFAULT NULL CHECK (`c1` > 0) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs | +-------+-----------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0,001 sec)   MariaDB [test]> ALTER TABLE t0 MODIFY COLUMN c1 INT ; Query OK, 0 rows affected (0,037 sec) Records: 0 Duplicates: 0 Warnings: 0   MariaDB [test]> show create table t0; +-------+------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+------------------------------------------------------------------------------------------------------------------+ | t0 | CREATE TABLE `t0` ( `c1` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs | +-------+------------------------------------------------------------------------------------------------------------------+ 1 row in set (0,003 sec)   MariaDB [test]> CREATE or replace TABLE t0 (c1 INT, CHECK ( c1 > 0 )); Query OK, 0 rows affected (0,059 sec)   MariaDB [test]> show create table t0; +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | t0 | CREATE TABLE `t0` ( `c1` int(11) DEFAULT NULL, CONSTRAINT `CONSTRAINT_1` CHECK (`c1` > 0) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs | +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0,001 sec)   MariaDB [test]> ALTER TABLE t0 DROP CONSTRAINT CONSTRAINT_1; Query OK, 0 rows affected (0,031 sec) Records: 0 Duplicates: 0 Warnings: 0   MariaDB [test]> show create table t0; +-------+------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+------------------------------------------------------------------------------------------------------------------+ | t0 | CREATE TABLE `t0` ( `c1` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs | +-------+------------------------------------------------------------------------------------------------------------------+ 1 row in set (0,001 sec)
            John Jove John Jove added a comment -

            Thanks for your generous reply. I'll follow your advice to improve my tool.

            John Jove John Jove added a comment - Thanks for your generous reply. I'll follow your advice to improve my tool.
            amilyushkin Alexander Ilyushkin added a comment - - edited

            @alice, I'm confirming this bug on 11.3.2-MariaDB-1:11.3.2+maria~ubu2204, could you please clarify to me which version it is fixed in and approximately when?

            amilyushkin Alexander Ilyushkin added a comment - - edited @alice, I'm confirming this bug on 11.3.2-MariaDB-1:11.3.2+maria~ubu2204, could you please clarify to me which version it is fixed in and approximately when?

            People

              serg Sergei Golubchik
              John Jove John Jove
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.