Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2(EOL)
-
10.2.6-3
Description
MariaDB [test]> create table t1 (a int, check(a>0 or a is null)); |
Query OK, 0 rows affected (0.41 sec) |
|
MariaDB [test]> insert into t1 values (null); |
Query OK, 1 row affected (0.06 sec)
|
|
MariaDB [test]> alter table t1 modify a int auto_increment primary key; |
ERROR 4025 (23000): CONSTRAINT `CONSTRAINT_1` failed for `test`.`#sql-4c9e_4` |
If there were no CHECK, a column would have been given the value 1 which actually satisfies the condition.
MariaDB [test]> set check_constraint_checks=0; |
Query OK, 0 rows affected (0.00 sec) |
|
MariaDB [test]> alter table t1 modify a int auto_increment primary key; |
Query OK, 1 row affected (1.01 sec)
|
Records: 1 Duplicates: 0 Warnings: 0
|
|
MariaDB [test]> select * from t1; |
+---+ |
| a |
|
+---+ |
| 1 |
|
+---+ |
1 row in set (0.00 sec) |
But apparently the column gets the intermediate value 0 which is checked before the auto_increment is applied.
Attachments
Issue Links
- relates to
-
MDEV-7563 Support CHECK constraint as in (or close to) SQL Standard
- Closed