From 87c60ca3d6bcb182ceee095928326db51d089541 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Sat, 9 Aug 2003 14:39:54 +0300 Subject: [PATCH] fixed union unlocking problem (BUG#906) --- mysql-test/r/subselect.result | 12 ++++++++++++ mysql-test/t/subselect.test | 16 +++++++++++++++- sql/sql_union.cc | 3 ++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index bba86ff8891..fbf037d5147 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1225,3 +1225,15 @@ a (select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 an 2 2 1 2 drop table t1,t2,t3; +create table t1 (a int) type=innodb; +create table t2 (a int) type=innodb; +create table t3 (a int) type=innodb; +insert into t1 values (1),(2),(3),(4); +insert into t2 values (10),(20),(30),(40); +insert into t3 values (1),(2),(10),(50); +select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30); +a +1 +2 +10 +drop table t1,t2; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 66d8dd2bc32..3896676f3ab 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -807,6 +807,7 @@ INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", " INSERT INTO t1 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL); SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1'); drop table t1; + # # alloc_group_fields() working # @@ -817,4 +818,17 @@ insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10); insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1); insert into t3 values (3,3), (2,2), (1,1); select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3; -drop table t1,t2,t3;s +drop table t1,t2,t3; + +# +# UNION unlocking test +# +create table t1 (a int) type=innodb; +create table t2 (a int) type=innodb; +create table t3 (a int) type=innodb; +insert into t1 values (1),(2),(3),(4); +insert into t2 values (10),(20),(30),(40); +insert into t3 values (1),(2),(10),(50); +select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30); +drop table t1,t2; + diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 724cc658b15..bbf0781bc19 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -351,7 +351,8 @@ int st_select_lex_unit::exec() global_parameters->order_list.elements, (ORDER*)global_parameters->order_list.first, (ORDER*) NULL, NULL, (ORDER*) NULL, - thd->options, result, this, fake_select, 0); + thd->options | SELECT_NO_UNLOCK, + result, this, fake_select, 0); if (found_rows_for_union && !res) thd->limit_found_rows = (ulonglong)table->file->records; fake_select->exclude();