Commit 795f4ea6 authored by unknown's avatar unknown

Fixing a bug #195

Fixing UNION's popping up in slow query log


mysql-test/r/cast.result:
  Fixing a bug #195
mysql-test/t/cast.test:
  Fixing a bug #195
sql/item_timefunc.h:
  Fixing a bug #195
sql/sql_union.cc:
  Fixing UNION's popping up in the slow query log
parent 2c5517ce
...@@ -37,3 +37,6 @@ cast("2001-1-1" as datetime) = "2001-01-01 00:00:00" ...@@ -37,3 +37,6 @@ cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
select cast("1:2:3" as TIME) = "1:02:03"; select cast("1:2:3" as TIME) = "1:02:03";
cast("1:2:3" as TIME) = "1:02:03" cast("1:2:3" as TIME) = "1:02:03"
0 0
select cast(NULL as DATE);
cast(NULL as DATE)
NULL
...@@ -20,3 +20,4 @@ select cast("1:2:3" as TIME); ...@@ -20,3 +20,4 @@ select cast("1:2:3" as TIME);
select cast("2001-1-1" as date) = "2001-01-01"; select cast("2001-1-1" as date) = "2001-01-01";
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"; select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
select cast("1:2:3" as TIME) = "1:02:03"; select cast("1:2:3" as TIME) = "1:02:03";
select cast(NULL as DATE);
...@@ -527,6 +527,7 @@ class Item_typecast :public Item_str_func ...@@ -527,6 +527,7 @@ class Item_typecast :public Item_str_func
{ {
String *tmp=args[0]->val_str(a); String *tmp=args[0]->val_str(a);
null_value=args[0]->null_value; null_value=args[0]->null_value;
if (tmp)
tmp->set_charset(charset()); tmp->set_charset(charset());
return tmp; return tmp;
} }
......
...@@ -248,6 +248,7 @@ int st_select_lex_unit::exec() ...@@ -248,6 +248,7 @@ int st_select_lex_unit::exec()
SELECT_LEX_NODE *lex_select_save= thd->lex.current_select; SELECT_LEX_NODE *lex_select_save= thd->lex.current_select;
SELECT_LEX *select_cursor=first_select_in_union(), *last_select; SELECT_LEX *select_cursor=first_select_in_union(), *last_select;
LINT_INIT(last_select); LINT_INIT(last_select);
bool do_print_slow=0;
if (executed && !(dependent || uncacheable)) if (executed && !(dependent || uncacheable))
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -313,6 +314,7 @@ int st_select_lex_unit::exec() ...@@ -313,6 +314,7 @@ int st_select_lex_unit::exec()
thd->lex.current_select= lex_select_save; thd->lex.current_select= lex_select_save;
DBUG_RETURN(res); DBUG_RETURN(res);
} }
do_print_slow = do_print_slow || (select_cursor->options & (QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED));
} }
} }
optimized= 1; optimized= 1;
...@@ -325,7 +327,6 @@ int st_select_lex_unit::exec() ...@@ -325,7 +327,6 @@ int st_select_lex_unit::exec()
{ {
List<Item_func_match> empty_list; List<Item_func_match> empty_list;
empty_list.empty(); empty_list.empty();
thd->lex.select_lex.ftfunc_list= &empty_list;
if (!thd->is_fatal_error) // Check if EOM if (!thd->is_fatal_error) // Check if EOM
{ {
...@@ -338,6 +339,8 @@ int st_select_lex_unit::exec() ...@@ -338,6 +339,8 @@ int st_select_lex_unit::exec()
select_limit_cnt= HA_POS_ERROR; // no limit select_limit_cnt= HA_POS_ERROR; // no limit
if (select_limit_cnt == HA_POS_ERROR) if (select_limit_cnt == HA_POS_ERROR)
thd->options&= ~OPTION_FOUND_ROWS; thd->options&= ~OPTION_FOUND_ROWS;
fake_select->ftfunc_list= &empty_list;
res= mysql_select(thd, &ref_pointer_array, &result_table_list, res= mysql_select(thd, &ref_pointer_array, &result_table_list,
0, item_list, NULL, 0, item_list, NULL,
global_parameters->order_list.elements, global_parameters->order_list.elements,
...@@ -348,9 +351,10 @@ int st_select_lex_unit::exec() ...@@ -348,9 +351,10 @@ int st_select_lex_unit::exec()
thd->limit_found_rows = (ulonglong)table->file->records; thd->limit_found_rows = (ulonglong)table->file->records;
fake_select->exclude(); fake_select->exclude();
delete fake_select; delete fake_select;
if (select_cursor == &thd->lex.select_lex && !do_print_slow)
select_cursor->options &= ~(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED);
} }
} }
thd->lex.select_lex.ftfunc_list= &thd->lex.select_lex.ftfunc_list_alloc;
thd->lex.current_select= lex_select_save; thd->lex.current_select= lex_select_save;
DBUG_RETURN(res); DBUG_RETURN(res);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment