From 2467674b7364ebcb4eaa4fa9010dc53bdc1d0c04 Mon Sep 17 00:00:00 2001 From: "ramil@mysql.com" <> Date: Sun, 6 Nov 2005 12:35:49 +0400 Subject: [PATCH 1/4] Fix for bug #13044: BIT_COUNT with NULL values. --- mysql-test/r/func_op.result | 11 +++++++++++ mysql-test/t/func_op.test | 12 ++++++++++++ sql/item_func.cc | 5 +---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/func_op.result b/mysql-test/r/func_op.result index d009a66353e..486c55870c2 100644 --- a/mysql-test/r/func_op.result +++ b/mysql-test/r/func_op.result @@ -25,3 +25,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 a312d6ac8c0..ab96caaff82 100644 --- a/mysql-test/t/func_op.test +++ b/mysql-test/t/func_op.test @@ -14,3 +14,15 @@ select 1 | -1, 1 ^ -1, 1 & -1; select 0 | -1, 0 ^ -1, 0 & -1; select -1 >> 0, -1 << 0; select -1 >> 1, -1 << 1; + +# +# Bug 13044: wrong bit_count() results +# + +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; +drop table t1, t2; diff --git a/sql/item_func.cc b/sql/item_func.cc index 855e86b2382..e83d1f35db8 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1138,11 +1138,8 @@ longlong Item_func_find_in_set::val_int() longlong Item_func_bit_count::val_int() { 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); } From ba424aacb0aedba7c878557ced6dbbdc4257e8b0 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Sat, 8 Apr 2006 23:19:52 +0300 Subject: [PATCH 2/4] Check tinfo library presence and use it. (BUG#18912) --- acinclude.m4 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index f36940670a6..ddc50d2972b 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -373,7 +373,8 @@ AC_CACHE_VAL(mysql_cv_termcap_lib, [AC_CHECK_LIB(ncurses, tgetent, mysql_cv_termcap_lib=libncurses, [AC_CHECK_LIB(curses, tgetent, mysql_cv_termcap_lib=libcurses, [AC_CHECK_LIB(termcap, tgetent, mysql_cv_termcap_lib=libtermcap, - mysql_cv_termcap_lib=NOT_FOUND)])])]) + [AC_CHECK_LIB(tinfo, tgetent, mysql_cv_termcap_lib=libtinfo, + mysql_cv_termcap_lib=NOT_FOUND)])])])]) AC_MSG_CHECKING(for termcap functions library) if test "$mysql_cv_termcap_lib" = "NOT_FOUND"; then AC_MSG_ERROR([No curses/termcap library found]) @@ -381,6 +382,8 @@ elif test "$mysql_cv_termcap_lib" = "libtermcap"; then TERMCAP_LIB=-ltermcap elif test "$mysql_cv_termcap_lib" = "libncurses"; then TERMCAP_LIB=-lncurses +elif test "$mysql_cv_termcap_lib" = "libtinfo"; then +TERMCAP_LIB=-ltinfo else TERMCAP_LIB=-lcurses fi From 5fe95af80446aa9028cc7839d422448398316a89 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Mon, 10 Apr 2006 21:57:29 +0300 Subject: [PATCH 3/4] Avoid trying to include when it doesn't work in C++ code. (Bug #13621) --- configure.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.in b/configure.in index df4b0fbd5af..0445f7a05e9 100644 --- a/configure.in +++ b/configure.in @@ -830,6 +830,9 @@ AC_SUBST(WRAPLIBS) if test "$IS_LINUX" = "true"; then AC_MSG_CHECKING([for atomic operations]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + atom_ops= AC_TRY_RUN([ #include @@ -859,6 +862,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 ], From 32cabaa39f4d31e5b8dfe5df2caf53ea3ff6f304 Mon Sep 17 00:00:00 2001 From: "ramil@mysql.com" <> Date: Tue, 11 Apr 2006 15:26:18 +0500 Subject: [PATCH 4/4] after merge fix. --- mysql-test/t/func_op.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/t/func_op.test b/mysql-test/t/func_op.test index 6521349a558..0a4f5034f4c 100644 --- a/mysql-test/t/func_op.test +++ b/mysql-test/t/func_op.test @@ -21,7 +21,9 @@ 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);