Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 10.1, 10.0, 5.5
-
Fix Version/s: 10.0.18
-
Component/s: Data Definition - Alter Table
-
Labels:
-
Environment:Linux
Description
MariaDB has wonderful feature which allows easy create copy of any table.
create table `new_name` select * from `old_table`
But I found that this is not worked if `old_table` contain default value for timestamp field.
CREATE TABLE `table1` ( `f1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
0 row(s) affected
CREATE TABLE `table2` (
`f2` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8
0 row(s) affected
create table `table1copy` select * from `table1` limit 0;
Error Code: 1067 Invalid default value for 'f1'
create table `table2copy` select * from `table2` limit 0;
0 row(s) affected
show create table table2copy
CREATE TABLE `table2copy` ( `f2` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8
Gliffy Diagrams
Attachments
Issue Links
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Works for me (see below).
Could you please attach your cnf file(s)? We need to find what's different.
MariaDB [test]> CREATE TABLE `table1` ( -> `f1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Query OK, 0 rows affected (0.19 sec) MariaDB [test]> create table `table1copy` select * from `table1` limit 0; Query OK, 0 rows affected (0.06 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [test]> show create table table1copy; +------------+----------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +------------+----------------------------------------------------------------------------------------------------------------------------+ | table1copy | CREATE TABLE `table1copy` ( `f1` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +------------+----------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) MariaDB [test]> select @@version; +-----------------+ | @@version | +-----------------+ | 10.0.17-MariaDB | +-----------------+ 1 row in set (0.00 sec)