[MDEV-15957] Unexpected "Data too long" when doing CREATE..SELECT with stored functions Created: 2018-04-21 Updated: 2018-04-23 Resolved: 2018-04-23 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data types, Stored routines |
| Affects Version/s: | 10.0, 10.1, 10.2, 10.3, 10.4 |
| Fix Version/s: | 10.3.7 |
| Type: | Bug | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
I create a table with an INT(3) column, and a stored function returning an INT(3)) result:
Now I try to create a new table in a strict mode:
Oops. It failed. Retrying with a lose mode:
It created the table, with a warning. Checking the structure:
Column types are different. This is not correct. All data types were INT(3) in the above script. There are no any reasons why the data type for c3 should be shorter. It seems CREATE TABLE erroneously used the user-specified display width (which is 3) when creating the column corresponding to CONCAT(f1(a)), while it correctly used the maximum possible width (which is 11) for CONCAT(a) and CONCAT(COALESCE(a)). It should create varchar(11) for all three columns. The manual says:
The same problem is repeatable with stored aggregate functions:
Now if I try to create a table from the same query, it fails:
Retrying with a loose sql_mode:
The expected data type is varchar(11). |
| Comments |
| Comment by Alexander Barkov [ 2018-04-22 ] | ||||||||||||||||||
|
A similar problem happens with TEXT variants:
The data type for c1 is too long. | ||||||||||||||||||
| Comment by Alexander Barkov [ 2018-04-22 ] | ||||||||||||||||||
|
A similar problem happens with custom aggregate function returning TEXT variants:
The data type text is wrong. It should be tinytext. |