create database if not exists test; use test; DROP TABLE IF EXISTS select_tab; CREATE TABLE `select_tab` ( `pk` bigint(11) NOT NULL AUTO_INCREMENT, `year_test` year(4) DEFAULT NULL, PRIMARY KEY (`pk`), KEY `index_year_test` (`year_test`) ) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=gbk ROW_FORMAT=DYNAMIC; show create table select_tab\G insert into select_tab (pk , year_test) values(1,2014); select count(*) FROM select_tab where year_test < 2155; select count(*) FROM select_tab where year_test < 2156; ALTER TABLE select_tab engine=myisam; show create table select_tab\G select count(*) FROM select_tab where year_test < 2155; select count(*) FROM select_tab where year_test < 2156; ## 5.1.77, 5.5.59 -- not affected [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.1.77: bin/mysql -uroot -S /tmp/mysql_ushastry.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.77 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database if not exists test; Query OK, 1 row affected, 1 warning (0.00 sec) mysql> use test; Database changed mysql> DROP TABLE IF EXISTS select_tab; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> CREATE TABLE `select_tab` ( -> `pk` bigint(11) NOT NULL AUTO_INCREMENT, -> `year_test` year(4) DEFAULT NULL, -> PRIMARY KEY (`pk`), -> KEY `index_year_test` (`year_test`) -> ) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=gbk ROW_FORMAT=DYNAMIC; Query OK, 0 rows affected (0.00 sec) mysql> show create table select_tab\G *************************** 1. row *************************** Table: select_tab Create Table: CREATE TABLE `select_tab` ( `pk` bigint(11) NOT NULL AUTO_INCREMENT, `year_test` year(4) DEFAULT NULL, PRIMARY KEY (`pk`), KEY `index_year_test` (`year_test`) ) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=gbk ROW_FORMAT=DYNAMIC 1 row in set (0.00 sec) mysql> insert into select_tab (pk , year_test) values(1,2014); Query OK, 1 row affected (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2155; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2156; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.5.59: bin/mysql -uroot -S /tmp/mysql_ushastry.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.59 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database if not exists test; Query OK, 1 row affected, 1 warning (0.00 sec) mysql> use test; Database changed mysql> DROP TABLE IF EXISTS select_tab; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> CREATE TABLE `select_tab` ( -> `pk` bigint(11) NOT NULL AUTO_INCREMENT, -> `year_test` year(4) DEFAULT NULL, -> PRIMARY KEY (`pk`), -> KEY `index_year_test` (`year_test`) -> ) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=gbk ROW_FORMAT=DYNAMIC; Query OK, 0 rows affected, 2 warnings (0.01 sec) mysql> show create table select_tab\G *************************** 1. row *************************** Table: select_tab Create Table: CREATE TABLE `select_tab` ( `pk` bigint(11) NOT NULL AUTO_INCREMENT, `year_test` year(4) DEFAULT NULL, PRIMARY KEY (`pk`), KEY `index_year_test` (`year_test`) ) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=gbk ROW_FORMAT=DYNAMIC 1 row in set (0.00 sec) mysql> insert into select_tab (pk , year_test) values(1,2014); Query OK, 1 row affected (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2155; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2156; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.01 sec) mysql> \q -- 5.6.39, 5.7.21 -- affected [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.6.39: bin/mysql -uroot -S /tmp/mysql_ushastry.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.39 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database if not exists test; Query OK, 1 row affected, 1 warning (0.00 sec) mysql> use test; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> DROP TABLE IF EXISTS select_tab; Query OK, 0 rows affected (0.00 sec) mysql> CREATE TABLE `select_tab` ( -> `pk` bigint(11) NOT NULL AUTO_INCREMENT, -> `year_test` year(4) DEFAULT NULL, -> PRIMARY KEY (`pk`), -> KEY `index_year_test` (`year_test`) -> ) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=gbk ROW_FORMAT=DYNAMIC; Query OK, 0 rows affected (0.00 sec) mysql> show create table select_tab\G *************************** 1. row *************************** Table: select_tab Create Table: CREATE TABLE `select_tab` ( `pk` bigint(11) NOT NULL AUTO_INCREMENT, `year_test` year(4) DEFAULT NULL, PRIMARY KEY (`pk`), KEY `index_year_test` (`year_test`) ) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=gbk ROW_FORMAT=DYNAMIC 1 row in set (0.00 sec) mysql> insert into select_tab (pk , year_test) values(1,2014); Query OK, 1 row affected (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2155; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2156; +----------+ | count(*) | +----------+ | 0 | +----------+ 1 row in set (0.00 sec) -- looks fine for myisam mysql> ALTER TABLE select_tab engine=myisam; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> show create table select_tab\G *************************** 1. row *************************** Table: select_tab Create Table: CREATE TABLE `select_tab` ( `pk` bigint(11) NOT NULL AUTO_INCREMENT, `year_test` year(4) DEFAULT NULL, PRIMARY KEY (`pk`), KEY `index_year_test` (`year_test`) ) ENGINE=MyISAM AUTO_INCREMENT=1001 DEFAULT CHARSET=gbk ROW_FORMAT=DYNAMIC 1 row in set (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2155; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2156; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.21: bin/mysql -uroot -S /tmp/mysql_ushastry.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.21 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database if not exists test; Query OK, 1 row affected (0.01 sec) mysql> use test; Database changed mysql> DROP TABLE IF EXISTS select_tab; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> CREATE TABLE `select_tab` ( -> `pk` bigint(11) NOT NULL AUTO_INCREMENT, -> `year_test` year(4) DEFAULT NULL, -> PRIMARY KEY (`pk`), -> KEY `index_year_test` (`year_test`) -> ) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=gbk ROW_FORMAT=DYNAMIC; Query OK, 0 rows affected (0.01 sec) mysql> show create table select_tab\G *************************** 1. row *************************** Table: select_tab Create Table: CREATE TABLE `select_tab` ( `pk` bigint(11) NOT NULL AUTO_INCREMENT, `year_test` year(4) DEFAULT NULL, PRIMARY KEY (`pk`), KEY `index_year_test` (`year_test`) ) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=gbk ROW_FORMAT=DYNAMIC 1 row in set (0.01 sec) mysql> insert into select_tab (pk , year_test) values(1,2014); Query OK, 1 row affected (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2155; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2156; +----------+ | count(*) | +----------+ | 0 | +----------+ 1 row in set (0.00 sec) -- looks fine for myisam mysql> ALTER TABLE select_tab engine=myisam; Query OK, 1 row affected (0.01 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> show create table select_tab\G *************************** 1. row *************************** Table: select_tab Create Table: CREATE TABLE `select_tab` ( `pk` bigint(11) NOT NULL AUTO_INCREMENT, `year_test` year(4) DEFAULT NULL, PRIMARY KEY (`pk`), KEY `index_year_test` (`year_test`) ) ENGINE=MyISAM AUTO_INCREMENT=1001 DEFAULT CHARSET=gbk ROW_FORMAT=DYNAMIC 1 row in set (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2155; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) mysql> select count(*) FROM select_tab where year_test < 2156; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec)