1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-10-30 07:25:34 +03:00

fix: MCOL-5778 sum return null value due to nullif function

This commit is contained in:
mariadb-KristinaPavlova
2025-09-24 10:58:17 +03:00
committed by Leonid Fedorov
parent af6a716079
commit b01be6ae2d
3 changed files with 39 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ bool nonConstFunc(Item_func* ifp)
{ {
if (ifp->arguments()[i]->type() == Item::FUNC_ITEM && nonConstFunc(((Item_func*)ifp->arguments()[i]))) if (ifp->arguments()[i]->type() == Item::FUNC_ITEM && nonConstFunc(((Item_func*)ifp->arguments()[i])))
return true; return true;
if (ifp->arguments()[i]->type() == Item::CACHE_ITEM)
return true;
} }
return false; return false;

View File

@@ -0,0 +1,16 @@
DROP DATABASE IF EXISTS mcol5778;
CREATE DATABASE mcol5778;
USE mcol5778;
create table test ( a double, b double ) engine=columnstore;
insert into test values (100,100);
select sum(a)/NULLIF(sum(b),0) from test;
sum(a)/NULLIF(sum(b),0)
1
select sum(a)/NULLIF(b,0) from test;
sum(a)/NULLIF(b,0)
1
select sum(a)/NULLIF(100,0) from test;
sum(a)/NULLIF(100,0)
1
drop table test;
DROP DATABASE mcol5778;

View File

@@ -0,0 +1,21 @@
-- source ../include/have_columnstore.inc
--disable_warnings
DROP DATABASE IF EXISTS mcol5778;
--enable_warnings
CREATE DATABASE mcol5778;
USE mcol5778;
create table test ( a double, b double ) engine=columnstore;
insert into test values (100,100);
select sum(a)/NULLIF(sum(b),0) from test;
select sum(a)/NULLIF(b,0) from test;
select sum(a)/NULLIF(100,0) from test;
drop table test;
DROP DATABASE mcol5778;