Commit c5e6a11e authored by Ramil Kalimullin's avatar Ramil Kalimullin

Fix for bug#49517: Inconsistent behavior while using

NULLable BIGINT and INT columns in comparison

Problem: a consequence of the fix for 43668.
Some Arg_comparator inner initialization missed,
that may lead to unpredictable (wrong) comparison
results.

Fix: always properly initialize Arg_comparator
before its usage.


mysql-test/r/select.result:
  Fix for bug#49517: Inconsistent behavior while using 
  NULLable BIGINT and INT columns in comparison
    -test result.
mysql-test/t/select.test:
  Fix for bug#49517: Inconsistent behavior while using 
  NULLable BIGINT and INT columns in comparison
    -test case.
sql/item_cmpfunc.cc:
  Fix for bug#49517: Inconsistent behavior while using 
  NULLable BIGINT and INT columns in comparison
    - now all Arg_comparator::set_cmp_func() set
  Arg_comparator::set_null to ensure its proper initialization
  in all cases (by default it's set to TRUE in constructors).
sql/item_cmpfunc.h:
  Fix for bug#49517: Inconsistent behavior while using 
  NULLable BIGINT and INT columns in comparison
    - now all Arg_comparator::set_cmp_func() set
  Arg_comparator::set_null to ensure its proper initialization
  in all cases (by default it's set to TRUE in constructors).
parent d2e723bf
......@@ -4619,4 +4619,19 @@ c1
9.1234
DROP TABLE t1;
# End of test for bug#49489.
#
# Bug #49517: Inconsistent behavior while using
# NULLable BIGINT and INT columns in comparison
#
CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL);
INSERT INTO t1 VALUES(105, NULL, NULL);
SELECT * FROM t1 WHERE b < 102;
a b c
SELECT * FROM t1 WHERE c < 102;
a b c
SELECT * FROM t1 WHERE 102 < b;
a b c
SELECT * FROM t1 WHERE 102 < c;
a b c
DROP TABLE t1;
End of 5.1 tests
......@@ -3973,4 +3973,18 @@ SELECT * FROM t1 WHERE c1 < 9.12345;
DROP TABLE t1;
--echo # End of test for bug#49489.
--echo #
--echo # Bug #49517: Inconsistent behavior while using
--echo # NULLable BIGINT and INT columns in comparison
--echo #
CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL);
INSERT INTO t1 VALUES(105, NULL, NULL);
SELECT * FROM t1 WHERE b < 102;
SELECT * FROM t1 WHERE c < 102;
SELECT * FROM t1 WHERE 102 < b;
SELECT * FROM t1 WHERE 102 < c;
DROP TABLE t1;
--echo End of 5.1 tests
......@@ -895,9 +895,9 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg,
ulonglong const_value= (ulonglong)-1;
thd= current_thd;
owner= owner_arg;
set_null= set_null && owner_arg;
a= a1;
b= a2;
owner= owner_arg;
thd= current_thd;
if ((cmp_type= can_compare_as_dates(*a, *b, &const_value)))
......
......@@ -54,10 +54,10 @@ public:
/* Allow owner function to use string buffers. */
String value1, value2;
Arg_comparator(): thd(0), a_cache(0), b_cache(0), set_null(0),
Arg_comparator(): thd(0), a_cache(0), b_cache(0), set_null(TRUE),
get_value_a_func(0), get_value_b_func(0) {};
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), thd(0),
a_cache(0), b_cache(0), set_null(0),
a_cache(0), b_cache(0), set_null(TRUE),
get_value_a_func(0), get_value_b_func(0) {};
int set_compare_func(Item_result_field *owner, Item_result type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment