timestampデフォルト値の丸め／範囲

ついでに5.6.25デフォルトのsql_modeで確認してみた。
```
 # mysqld --version
mysqld  Ver 5.6.25 for Linux on x86_64 (MySQL Community Server (GPL))
```
<pre>select @@sql_mode;
+------------------------+
| @@sql_mode             |
+------------------------+
| NO_ENGINE_SUBSTITUTION |
+------------------------+</pre>
面倒なのでタイムゾーンを変更。
<pre>SET SESSION time_zone='+0:00';
SELECT @@global.system_time_zone, @@global.time_zone, @@session.time_zone;
+---------------------------+--------------------+---------------------+
| @@global.system_time_zone | @@global.time_zone | @@session.time_zone |
+---------------------------+--------------------+---------------------+
| JST                       | SYSTEM             | +00:00              |
+---------------------------+--------------------+---------------------+
</pre>
<pre>CREATE TABLE `mytable` ( 
`id` int(10) unsigned NOT NULL, 
`field2` tinyint(3) unsigned NOT NULL, 
`last_change` timestamp NOT NULL DEFAULT '1970-01-01 00:00:00'
);</pre>エラー。

<pre>CREATE TABLE `mytable` ( 
`id` int(10) unsigned NOT NULL, 
`field2` tinyint(3) unsigned NOT NULL, 
`last_change` timestamp NOT NULL DEFAULT '1971-01-01 00:00:01'
);
DESC mytable;
+-------------+---------------------+------+-----+---------------------+-------+
| Field       | Type                | Null | Key | Default             | Extra |
+-------------+---------------------+------+-----+---------------------+-------+
| id          | int(10) unsigned    | NO   |     | NULL                |       |
| field2      | tinyint(3) unsigned | NO   |     | NULL                |       |
| last_change | timestamp           | NO   |     | 1971-01-01 00:00:01 |       |
+-------------+---------------------+------+-----+---------------------+-------+
</pre>これはOK。

<pre>CREATE TABLE `mytable` ( 
`id` int(10) unsigned NOT NULL, 
`field2` tinyint(3) unsigned NOT NULL, 
`last_change` timestamp NOT NULL DEFAULT '1970-01-00 00:00:00'
);

show warnings\G
*************************** 1. row ***************************
  Level: Warning
   Code: 1264
Message: Out of range value for column 'last_change' at row 1
1 row in set (0.00 sec)

DESC mytable;
+-------------+---------------------+------+-----+---------------------+-------+
| Field       | Type                | Null | Key | Default             | Extra |
+-------------+---------------------+------+-----+---------------------+-------+
| id          | int(10) unsigned    | NO   |     | NULL                |       |
| field2      | tinyint(3) unsigned | NO   |     | NULL                |       |
| last_change | timestamp           | NO   |     | 0000-00-00 00:00:00 |       |
+-------------+---------------------+------+-----+---------------------+-------+
</pre>
月／日を0にするとwarningでゼロ日付に丸められた。
'1971-01-00 23:59:59'や、'2037-00-00 00:00:00'でも同じ結果。

<pre>CREATE TABLE `mytable` ( 
`id` int(10) unsigned NOT NULL, 
`field2` tinyint(3) unsigned NOT NULL, 
`last_change` timestamp NOT NULL DEFAULT '2037-02-29 00:00:00'
);</pre>存在しない日付はエラー。

<pre>CREATE TABLE `mytable` ( 
`id` int(10) unsigned NOT NULL, 
`field2` tinyint(3) unsigned NOT NULL, 
`last_change` timestamp NOT NULL DEFAULT '1969-12-31 23:59:59'
);</pre>'1970-01-01 00:00:00'がダメなんだから、下回ったらエラーだよね。

<pre>CREATE TABLE `mytable` ( 
`id` int(10) unsigned NOT NULL, 
`field2` tinyint(3) unsigned NOT NULL, 
`last_change` timestamp NOT NULL DEFAULT '2038-01-19 03:14:07'
);</pre>OK。

<pre class="lang:default decode:true ">CREATE TABLE `mytable` ( 
`id` int(10) unsigned NOT NULL, 
`field2` tinyint(3) unsigned NOT NULL, 
`last_change` timestamp NOT NULL DEFAULT '2038-01-19 03:14:08'
);</pre>エラー。
おもいっきり<span style="color: #ff0000; font-size: 14pt;"><a href="https://ja.wikipedia.org/wiki/2038%E5%B9%B4%E5%95%8F%E9%A1%8C" target="_blank">2038年問題</a></span>じゃないかorz

今まで確かめたことなかったけど、まさか64bit版のMySQLに存在するとは思いませんでした。