Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
10.0(EOL), 10.1(EOL), 10.2(EOL)
-
None
Description
If we try to create a table with a too long default value for a varchar column, it produces ER_INVALID_DEFAULT "Invalid default value" error regardless the strict mode:
MariaDB [test]> set sql_mode=''; |
Query OK, 0 rows affected (0.00 sec) |
|
MariaDB [test]> create table t1 (c varchar(1) default 'foo'); |
ERROR 1067 (42000): Invalid default value for 'c' |
MariaDB [test]>
|
MariaDB [test]> set sql_mode='STRICT_ALL_TABLES'; |
Query OK, 0 rows affected (0.00 sec) |
|
MariaDB [test]> create table t1 (c varchar(1) default 'foo'); |
ERROR 1067 (42000): Invalid default value for 'c' |
But if we set the default value via an ALTER statement, the error depends on the strict mode:
MariaDB [test]> create table t1 (c varchar(1)); |
Query OK, 0 rows affected (0.29 sec) |
|
MariaDB [test]> set sql_mode=''; |
Query OK, 0 rows affected (0.00 sec) |
|
MariaDB [test]> alter table t1 alter column c set default 'foo'; |
ERROR 1067 (42000): Invalid default value for 'c' |
MariaDB [test]>
|
MariaDB [test]> set sql_mode='STRICT_ALL_TABLES'; |
Query OK, 0 rows affected (0.00 sec) |
|
MariaDB [test]> alter table t1 alter column c set default 'foo'; |
ERROR 1406 (22001): Data too long for column 'c' at row 1 |
It doesn't seem right.
It started happening in 10.0.
5.5 (and MySQL 5.6/5.7) produce the same ER_INVALID_DEFAULT consistently.
Attachments
Issue Links
- relates to
-
MDEV-7635 update defaults and simplify mysqld config parameters
- Closed
-
MDEV-16421 Make system tables crash safe
- Closed