diff --git a/configure.in b/configure.in index 3e936ae422f..174c9a16d8e 100644 --- a/configure.in +++ b/configure.in @@ -805,6 +805,9 @@ AC_SUBST(WRAPLIBS) if test "$TARGET_LINUX" = "true"; then AC_MSG_CHECKING([for atomic operations]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + atom_ops= AC_TRY_RUN([ #include @@ -840,6 +843,8 @@ int main() if test -z "$atom_ops"; then atom_ops="no"; fi AC_MSG_RESULT($atom_ops) + AC_LANG_RESTORE + AC_ARG_WITH(pstack, [ --with-pstack Use the pstack backtrace library], [ USE_PSTACK=$withval ], diff --git a/mysql-test/r/func_op.result b/mysql-test/r/func_op.result index 61b29e9380d..24685d07f3d 100644 --- a/mysql-test/r/func_op.result +++ b/mysql-test/r/func_op.result @@ -35,3 +35,14 @@ select -1 >> 0, -1 << 0; select -1 >> 1, -1 << 1; -1 >> 1 -1 << 1 9223372036854775807 18446744073709551614 +drop table if exists t1,t2; +create table t1(a int); +create table t2(a int, b int); +insert into t1 values (1), (2), (3); +insert into t2 values (1, 7), (3, 7); +select t1.a, t2.a, t2.b, bit_count(t2.b) from t1 left join t2 on t1.a=t2.a; +a a b bit_count(t2.b) +1 1 7 3 +2 NULL NULL NULL +3 3 7 3 +drop table t1, t2; diff --git a/mysql-test/t/func_op.test b/mysql-test/t/func_op.test index 24266150e4c..0a4f5034f4c 100644 --- a/mysql-test/t/func_op.test +++ b/mysql-test/t/func_op.test @@ -17,4 +17,18 @@ select 0 | -1, 0 ^ -1, 0 & -1; select -1 >> 0, -1 << 0; select -1 >> 1, -1 << 1; +# +# Bug 13044: wrong bit_count() results +# + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings +create table t1(a int); +create table t2(a int, b int); +insert into t1 values (1), (2), (3); +insert into t2 values (1, 7), (3, 7); +select t1.a, t2.a, t2.b, bit_count(t2.b) from t1 left join t2 on t1.a=t2.a; +drop table t1, t2; + # End of 4.1 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index f40f868f75f..e22a7b45f33 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2462,11 +2462,8 @@ longlong Item_func_bit_count::val_int() { DBUG_ASSERT(fixed == 1); ulonglong value= (ulonglong) args[0]->val_int(); - if (args[0]->null_value) - { - null_value=1; /* purecov: inspected */ + if ((null_value= args[0]->null_value)) return 0; /* purecov: inspected */ - } return (longlong) my_count_bits(value); }