[MDEV-7778] impossible create copy of table, if table contain default value for timestamp field Created: 2015-03-14 Updated: 2015-05-05 Resolved: 2015-05-05 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table |
| Affects Version/s: | 5.5, 10.0, 10.1 |
| Fix Version/s: | 10.0.18 |
| Type: | Bug | Priority: | Major |
| Reporter: | Mikhail Gavrilov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | upstream-fixed, verified | ||
| Environment: |
Linux |
||
| Issue Links: |
|
||||||||||||||||
| Description |
|
MariaDB has wonderful feature which allows easy create copy of any table.
But I found that this is not worked if `old_table` contain default value for timestamp field.
|
| Comments |
| Comment by Elena Stepanova [ 2015-03-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Works for me (see below).
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Mikhail Gavrilov [ 2015-03-16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2015-03-16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you. It's sql_mode="NO_ZERO_DATE".
Same result can be observed in MySQL 5.5, but in MySQL 5.6 it works. There were at least 3 changes in MySQL related to this use case. First, there was the bug https://bugs.mysql.com/bug.php?id=34280, which complained that 0 as a default didn't work for timestamps under NO_ZERO_DATE. It was fixed in 5.6.6. After that, the table would be created, although with a warning:
That's because the second table's definition was different from the first one:
It was also fixed some time between 5.6.10 and current version, and now in 5.6 the second table has the same definition as the initial one:
Finally, in current 5.6 NO_ZERO_DATE is deprecated. None of these changes are present in 10.0 – NO_ZERO_DATE still gets set without a warning, the copy of the table is produced with zero as a default, and NO_ZERO_DATE forbids it. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2015-04-30 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
A smaller SQL script reproducing the problem:
It returns:
|