diff --git a/dbcon/mysql/ha_mcs_execplan.cpp b/dbcon/mysql/ha_mcs_execplan.cpp index db13d115a..8c9376f98 100644 --- a/dbcon/mysql/ha_mcs_execplan.cpp +++ b/dbcon/mysql/ha_mcs_execplan.cpp @@ -2247,7 +2247,8 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip) idbassert(ifp->argument_count() == 1); ParseTree* ptp = 0; - if (((Item_func*)(ifp->arguments()[0]))->functype() == Item_func::EQUAL_FUNC) + Item_func* argfp = dynamic_cast(ifp->arguments()[0]); + if (argfp && argfp->functype() == Item_func::EQUAL_FUNC) { // negate it in place // Note that an EQUAL_FUNC ( a <=> b) was converted to diff --git a/mysql-test/columnstore/bugfixes/mcol-4756.result b/mysql-test/columnstore/bugfixes/mcol-4756.result new file mode 100644 index 000000000..e150d4cc8 --- /dev/null +++ b/mysql-test/columnstore/bugfixes/mcol-4756.result @@ -0,0 +1,9 @@ +DROP DATABASE IF EXISTS `mcol_4756`; +CREATE DATABASE `mcol_4756`; +USE `mcol_4756`; +CREATE TABLE `manu_test` (id tinyint unsigned NOT NULL, test tinyint default null) ENGINE=Columnstore DEFAULT CHARSET=utf8; +INSERT INTO `manu_test` (`id`, `test`) VALUES (1,0), (2,1), (3,null); +SELECT id, test FROM manu_test HAVING NOT(test); +id test +1 0 +DROP DATABASE `mcol_4756`; diff --git a/mysql-test/columnstore/bugfixes/mcol-4756.test b/mysql-test/columnstore/bugfixes/mcol-4756.test new file mode 100644 index 000000000..e15a960a4 --- /dev/null +++ b/mysql-test/columnstore/bugfixes/mcol-4756.test @@ -0,0 +1,15 @@ +--source ../include/have_columnstore.inc +--disable_warnings +DROP DATABASE IF EXISTS `mcol_4756`; +--enable_warnings +CREATE DATABASE `mcol_4756`; +USE `mcol_4756`; + +CREATE TABLE `manu_test` (id tinyint unsigned NOT NULL, test tinyint default null) ENGINE=Columnstore DEFAULT CHARSET=utf8; + +INSERT INTO `manu_test` (`id`, `test`) VALUES (1,0), (2,1), (3,null); + +SELECT id, test FROM manu_test HAVING NOT(test); + +# cleanup +DROP DATABASE `mcol_4756`;