From 0264ade412ef4a85464737ad6e2aa1c558dc4266 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Mon, 23 Aug 2004 13:19:59 +0300 Subject: [PATCH] fixed LIMIT clause printing (BUG#4839) --- mysql-test/r/view.result | 5 +++++ mysql-test/t/view.test | 7 +++++++ sql/sql_lex.cc | 5 +++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index e4218ffe89f..7bade28f395 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1042,3 +1042,8 @@ SHOW TABLES; Tables_in_test table_type t2 BASE TABLE v4 VIEW +CREATE VIEW v1 AS SELECT EXISTS (SELECT 1 UNION SELECT 2); +select * from v1; +EXISTS (SELECT 1 UNION SELECT 2) +1 +drop view v1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 4e388c3fd28..c00489c1d1a 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -980,3 +980,10 @@ drop table t1; -- error 1096 CREATE VIEW v02 AS SELECT * FROM DUAL; SHOW TABLES; + +# +# EXISTS with UNION VIEW +# +CREATE VIEW v1 AS SELECT EXISTS (SELECT 1 UNION SELECT 2); +select * from v1; +drop view v1; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index c4390ce0f9a..0fe0cf51041 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1481,8 +1481,9 @@ void st_select_lex::print_order(String *str, ORDER *order) void st_select_lex::print_limit(THD *thd, String *str) { - Item_subselect *item= master_unit()->item; - if (item && + SELECT_LEX_UNIT *unit= master_unit(); + Item_subselect *item= unit->item; + if (item && unit->global_parameters == this && (item->substype() == Item_subselect::EXISTS_SUBS || item->substype() == Item_subselect::IN_SUBS || item->substype() == Item_subselect::ALL_SUBS)) -- 2.30.9