From d9b81f3a084c362d9948504b59149bade9eb4229 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Jun 2004 21:33:15 +0300 Subject: EXISTS(SELECT * ...) close table before opening in optimize mysql-test/r/subselect.result: test of EXISTS(SELECT * ...) mysql-test/t/subselect.test: test of EXISTS(SELECT * ...) sql/sql_base.cc: EXISTS(SELECT * ...) sql/sql_table.cc: close table before opening one --- sql/sql_base.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e3fbfb2d0e3..889c95125c5 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2184,8 +2184,19 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, !((Item_field*) item)->field) { uint elem= fields.elements; - if (insert_fields(thd,tables,((Item_field*) item)->db_name, - ((Item_field*) item)->table_name, &it)) + Item_subselect *subsel= thd->lex->current_select->master_unit()->item; + if (subsel && + subsel->substype() == Item_subselect::EXISTS_SUBS) + { + /* + It is EXISTS(SELECT * ...) and we can replace * by any constant. + + Item_int do not need fix_fields() because it is basic constant. + */ + it.replace(new Item_int("Not_used", (longlong) 1, 21)); + } + else if (insert_fields(thd,tables,((Item_field*) item)->db_name, + ((Item_field*) item)->table_name, &it)) { if (stmt) thd->restore_backup_item_arena(stmt, &backup); -- cgit v1.2.1