summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2012-08-24 13:51:16 +0200
committerunknown <knielsen@knielsen-hq.org>2012-08-24 13:51:16 +0200
commite44a800d91a887119d3b612276b37f09b076fee1 (patch)
treee6e716d515167a5b9390f8cc1af559981eceb072
parented06ba3492d55c9e9dde231b55352f854e5e4b50 (diff)
parent60561ae6133cf40f4fc445e1d6e8f395a20b2573 (diff)
downloadmariadb-git-e44a800d91a887119d3b612276b37f09b076fee1.tar.gz
Merge from 5.2
-rw-r--r--mysql-test/r/case.result4
-rw-r--r--mysql-test/r/compare.result4
-rw-r--r--mysql-test/t/case.test10
-rw-r--r--mysql-test/t/compare.test8
-rw-r--r--sql/item_cmpfunc.cc19
5 files changed, 45 insertions, 0 deletions
diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result
index 103883deb15..4a85fc8cc5c 100644
--- a/mysql-test/r/case.result
+++ b/mysql-test/r/case.result
@@ -225,3 +225,7 @@ case t1.f1 when '00:00:00' then 1 end
1
NULL
drop table t1;
+CREATE TABLE t1(a YEAR);
+SELECT 1 FROM t1 WHERE a=1 AND CASE 1 WHEN a THEN 1 ELSE 1 END;
+1
+DROP TABLE t1;
diff --git a/mysql-test/r/compare.result b/mysql-test/r/compare.result
index 75a6a38fadc..fe3a27ea0a3 100644
--- a/mysql-test/r/compare.result
+++ b/mysql-test/r/compare.result
@@ -96,3 +96,7 @@ SELECT * FROM t1 WHERE a > '2008-01-01' AND a = '0000-00-00';
a
DROP TABLE t1;
End of 5.0 tests
+CREATE TABLE t1(a INT ZEROFILL);
+SELECT 1 FROM t1 WHERE t1.a IN (1, t1.a) AND t1.a=2;
+1
+DROP TABLE t1;
diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test
index 4b775bc761f..81cd8dd06e7 100644
--- a/mysql-test/t/case.test
+++ b/mysql-test/t/case.test
@@ -179,3 +179,13 @@ create table t1 (f1 time);
insert t1 values ('00:00:00'),('00:01:00');
select case t1.f1 when '00:00:00' then 1 end from t1;
drop table t1;
+
+#
+# LP BUG#1001510
+# Bug #11764313 57135: CRASH IN ITEM_FUNC_CASE::FIND_ITEM WITH CASE WHEN
+# ELSE CLAUSE
+#
+
+CREATE TABLE t1(a YEAR);
+SELECT 1 FROM t1 WHERE a=1 AND CASE 1 WHEN a THEN 1 ELSE 1 END;
+DROP TABLE t1;
diff --git a/mysql-test/t/compare.test b/mysql-test/t/compare.test
index 103244eb2f7..d2b2a7e5523 100644
--- a/mysql-test/t/compare.test
+++ b/mysql-test/t/compare.test
@@ -86,3 +86,11 @@ SELECT * FROM t1 WHERE a > '2008-01-01' AND a = '0000-00-00';
DROP TABLE t1;
--echo End of 5.0 tests
+
+#
+# Bug #11764818 57692: Crash in item_func_in::val_int() with ZEROFILL
+#
+
+CREATE TABLE t1(a INT ZEROFILL);
+SELECT 1 FROM t1 WHERE t1.a IN (1, t1.a) AND t1.a=2;
+DROP TABLE t1;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index f5960bb6c15..fed246ef812 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -3007,6 +3007,15 @@ void Item_func_case::fix_length_and_dec()
return;
}
}
+ /*
+ Set cmp_context of all WHEN arguments. This prevents
+ Item_field::equal_fields_propagator() from transforming a
+ zerofill argument into a string constant. Such a change would
+ require rebuilding cmp_items.
+ */
+ for (i= 0; i < ncases; i+= 2)
+ args[i]->cmp_context= item_cmp_type(left_result_type,
+ args[i]->result_type());
}
if (else_expr_num == -1 || args[else_expr_num]->maybe_null)
@@ -3986,6 +3995,16 @@ void Item_func_in::fix_length_and_dec()
}
}
}
+ /*
+ Set cmp_context of all arguments. This prevents
+ Item_field::equal_fields_propagator() from transforming a zerofill integer
+ argument into a string constant. Such a change would require rebuilding
+ cmp_itmes.
+ */
+ for (arg= args + 1, arg_end= args + arg_count; arg != arg_end ; arg++)
+ {
+ arg[0]->cmp_context= item_cmp_type(left_result_type, arg[0]->result_type());
+ }
max_length= 1;
}