[MDEV-15318] CREATE .. SELECT VALUES produces invalid table structure Created: 2018-02-14  Updated: 2018-05-17  Resolved: 2018-05-17

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 5.5, 10.0, 10.1, 10.2
Fix Version/s: 5.5.61, 10.0.36, 10.1.34, 10.2.16, 10.3.7

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: upstream-fixed

Issue Links:
Problem/Incident
causes MDEV-15319 [SQL Layer] Server crashes in Field::... Closed

 Description   

CREATE TABLE t1 (i INT);
# For 10.3 the next statement needs to be changed to VALUE(i)
CREATE TABLE t2 AS SELECT VALUES(i) AS a FROM t1;
SHOW CREATE TABLE t2;
 
# Cleanup
DROP TABLE IF EXISTS t1, t2;

storage_engine=MyISAM

MariaDB [test]> SHOW CREATE TABLE t2;
+-------+------------------------------------------------------------------------------------+
| Table | Create Table                                                                       |
+-------+------------------------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
  `a` null DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-------+------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

storage_engine=InnoDB

MariaDB [test]> CREATE TABLE t2 AS SELECT VALUES(i) AS a FROM t1;
ERROR 1005 (HY000): Can't create table `test`.`t2` (errno: 168 "Unknown (generic) error from engine")
MariaDB [test]> SHOW WARNINGS;
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                                      |
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1005 | Error creating table 'test/t2' with column 'a'. Please check its column type and try to re-create the table with an appropriate column type. |
| Error   | 1005 | Can't create table `test`.`t2` (errno: 168 "Unknown (generic) error from engine")                                                            |
| Warning | 1030 | Got error 168 "Unknown (generic) error from engine" from storage engine InnoDB                                                               |
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)

Reproducible with 5.5-10.3, and also MySQL 5.5; seems to be fixed in 5.6+.


Generated at Thu Feb 08 08:20:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.