We're updating the issue view to help you get more done. 

select nullif(count(col1),0) gives wrong result if in a view

Description

This is related to and MDEV-9576.

1 select nullif(count(col1),0) from table1

returns 3

creating a view with the same query and it returns 5.
to recreate ->

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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

1 select * from testview

Environment

openbsd, windows

Status

Assignee

Sergei Golubchik

Reporter

MartinL

Labels

None

External issue ID

None

External issue ID

None

Components

Fix versions

Affects versions

10.1.12

Priority

Critical