This is related to MDEV-9181 and MDEV-9576.
select nullif(count(col1),0) from table1
|
returns 3
creating a view with the same query and it returns 5.
to recreate ->
|
CREATE DATABASE IF NOT EXISTS `testdb5` /*!40100 DEFAULT CHARACTER SET latin1 */;
|
USE `testdb5`;
|
|
CREATE TABLE IF NOT EXISTS `table1` (
|
`col1` varchar(50) DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
|
|
/*!40000 ALTER TABLE `table1` DISABLE KEYS */;
|
INSERT INTO `table1` (`col1`) VALUES
|
('hello'),
|
('hello'),
|
('hello');
|
/*!40000 ALTER TABLE `table1` ENABLE KEYS */;
|
|
|
CREATE TABLE `testview` (
|
`nullif(count(col1),0)` BIGINT(21) NULL
|
) ENGINE=MyISAM;
|
|
DROP TABLE IF EXISTS `testview`;
|
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` VIEW `testview` AS select nullif(count(col1),0) from table1 ;
|
then