From 84a53543c5cca294e771cd7629e8beb8327320f5 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 27 Mar 2012 14:43:26 +0400 Subject: [PATCH] BUG#965872: Server crashes in embedding_sjm on a simple 1-table select with AND and OR - This is a regession introduced by fix for BUG#951937 - The problem was that there were scenarios where check_simple_equality() would create an Item_equal object but would not call item_equal->set_context_field() on it. - The fix was to add the missing calls. --- mysql-test/r/subselect_sj2.result | 9 +++++++++ mysql-test/r/subselect_sj2_jcl6.result | 9 +++++++++ mysql-test/r/subselect_sj2_mat.result | 9 +++++++++ mysql-test/t/subselect_sj2.test | 10 ++++++++++ sql/sql_select.cc | 2 ++ 5 files changed, 39 insertions(+) diff --git a/mysql-test/r/subselect_sj2.result b/mysql-test/r/subselect_sj2.result index a938cf8d5e2..8a9946c404e 100644 --- a/mysql-test/r/subselect_sj2.result +++ b/mysql-test/r/subselect_sj2.result @@ -1043,6 +1043,15 @@ y y y y DROP VIEW v1; DROP TABLE t1, t2; +# +# BUG#965872: Server crashes in embedding_sjm on a simple 1-table select with AND and OR +# (this is a regression caused by the fix for BUG#951937) +CREATE TABLE t1 ( a INT, b INT, c INT, d INT ); +INSERT INTO t1 VALUES (4,2,8,9),(4,2,7,8); +SELECT * FROM t1 +WHERE a = d AND ( b = 50 AND b = d OR a = c ); +a b c d +DROP TABLE t1; # # BUG#951283: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery # diff --git a/mysql-test/r/subselect_sj2_jcl6.result b/mysql-test/r/subselect_sj2_jcl6.result index 1d0cf23f510..c2cfbb44d86 100644 --- a/mysql-test/r/subselect_sj2_jcl6.result +++ b/mysql-test/r/subselect_sj2_jcl6.result @@ -1057,6 +1057,15 @@ y y y y DROP VIEW v1; DROP TABLE t1, t2; +# +# BUG#965872: Server crashes in embedding_sjm on a simple 1-table select with AND and OR +# (this is a regression caused by the fix for BUG#951937) +CREATE TABLE t1 ( a INT, b INT, c INT, d INT ); +INSERT INTO t1 VALUES (4,2,8,9),(4,2,7,8); +SELECT * FROM t1 +WHERE a = d AND ( b = 50 AND b = d OR a = c ); +a b c d +DROP TABLE t1; # # BUG#951283: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery # diff --git a/mysql-test/r/subselect_sj2_mat.result b/mysql-test/r/subselect_sj2_mat.result index f64974349bf..378bf1d8844 100644 --- a/mysql-test/r/subselect_sj2_mat.result +++ b/mysql-test/r/subselect_sj2_mat.result @@ -1045,6 +1045,15 @@ y y y y DROP VIEW v1; DROP TABLE t1, t2; +# +# BUG#965872: Server crashes in embedding_sjm on a simple 1-table select with AND and OR +# (this is a regression caused by the fix for BUG#951937) +CREATE TABLE t1 ( a INT, b INT, c INT, d INT ); +INSERT INTO t1 VALUES (4,2,8,9),(4,2,7,8); +SELECT * FROM t1 +WHERE a = d AND ( b = 50 AND b = d OR a = c ); +a b c d +DROP TABLE t1; # # BUG#951283: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery # diff --git a/mysql-test/t/subselect_sj2.test b/mysql-test/t/subselect_sj2.test index 2b8c5597719..b9a1b91771e 100644 --- a/mysql-test/t/subselect_sj2.test +++ b/mysql-test/t/subselect_sj2.test @@ -1175,6 +1175,16 @@ SELECT * FROM t2 DROP VIEW v1; DROP TABLE t1, t2; +--echo # +--echo # BUG#965872: Server crashes in embedding_sjm on a simple 1-table select with AND and OR +--echo # (this is a regression caused by the fix for BUG#951937) +CREATE TABLE t1 ( a INT, b INT, c INT, d INT ); +INSERT INTO t1 VALUES (4,2,8,9),(4,2,7,8); + +SELECT * FROM t1 +WHERE a = d AND ( b = 50 AND b = d OR a = c ); +DROP TABLE t1; + --echo # --echo # BUG#951283: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery --echo # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 61a10fa2b50..506c7387a32 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -10788,6 +10788,7 @@ static bool check_simple_equality(Item *left_item, Item *right_item, Item_equal *item_equal= new Item_equal(orig_left_item, orig_right_item, FALSE); + item_equal->set_context_field((Item_field*)left_item); cond_equal->current_level.push_back(item_equal); } } @@ -10858,6 +10859,7 @@ static bool check_simple_equality(Item *left_item, Item *right_item, else { item_equal= new Item_equal(const_item, orig_field_item, TRUE); + item_equal->set_context_field(field_item); cond_equal->current_level.push_back(item_equal); } return TRUE;