Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2(EOL), 10.3(EOL), 10.4(EOL)
-
None
Description
I create this table and intentionally pass a too long value as a default:
EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a TINYTEXT DEFAULT ?)' USING REPEAT('a', 256); |
SHOW CREATE TABLE t1; |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| t1 | CREATE TABLE `t1` (
|
`a` tinytext DEFAULT 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
The table was created without problems.
Note, instead EXECUTE IMMEDIATE it can be also a directly executed CREATE statement with an explicit long string literal:
CREATE OR REPLACE TABLE t1 (a TINYTEXT DEFAULT '...256 or more characters...'); |
Now if I run any query which sets t1.a to the default value, I get an error:
INSERT INTO t1 VALUES (); |
ERROR 1406 (22001): Data too long for column 'a' at row 1
|
Looks wrong. Too long literals should be caught at CREATE time, like they are caught in case of VARCHAR:
CREATE OR REPLACE TABLE t1 (a VARCHAR(10) DEFAULT '...10 or more characters...'); |
ERROR 1067 (42000): Invalid default value for 'a'
|
Attachments
Issue Links
- blocks
-
MDEV-4912 Data type plugin API version 1
- Closed