Commit 65b9f4a3 authored by Sinisa@sinisa.nasamreza.org's avatar Sinisa@sinisa.nasamreza.org

Merge sinisa@bk-internal.mysql.com:/home/bk/mysql-4.1

into sinisa.nasamreza.org:/mnt/work/mysql-4.1
parents 05982c85 165b3960
...@@ -37,3 +37,9 @@ cast("2001-1-1" as datetime) = "2001-01-01 00:00:00" ...@@ -37,3 +37,9 @@ 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
select cast(NULL as BINARY);
cast(NULL as BINARY)
NULL
...@@ -333,4 +333,5 @@ check table t1,t2; ...@@ -333,4 +333,5 @@ check table t1,t2;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
test.t2 check status OK test.t2 check status OK
select max(a) +1, max(a) +2 into @xx,@yy from t1;
drop table t1,t2; drop table t1,t2;
...@@ -20,3 +20,5 @@ select cast("1:2:3" as TIME); ...@@ -20,3 +20,5 @@ 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);
select cast(NULL as BINARY);
...@@ -241,5 +241,6 @@ select @@key_buffer_size; ...@@ -241,5 +241,6 @@ select @@key_buffer_size;
select * from t1 where a=2; select * from t1 where a=2;
select * from t2 where a=3; select * from t2 where a=3;
check table t1,t2; check table t1,t2;
select max(a) +1, max(a) +2 into @xx,@yy from t1;
drop table t1,t2; drop table t1,t2;
...@@ -1252,7 +1252,16 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) ...@@ -1252,7 +1252,16 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
} }
} }
if (((*ref)->with_sum_func && /*
* The following conditional is changed as to correctly identify
* incorrect references in group functions or forward references
* with sub-select's / derived tables, while it prevents this
* check when Item_ref is created in an expression involving
* summing function, which is to be placed in the user variable.
*
*/
if (((*ref)->with_sum_func && name &&
(depended_from || (depended_from ||
!(thd->lex.current_select->linkage != GLOBAL_OPTIONS_TYPE && !(thd->lex.current_select->linkage != GLOBAL_OPTIONS_TYPE &&
thd->lex.current_select->select_lex()->having_fix_field))) || thd->lex.current_select->select_lex()->having_fix_field))) ||
......
...@@ -769,7 +769,8 @@ Item_func_if::val_str(String *str) ...@@ -769,7 +769,8 @@ Item_func_if::val_str(String *str)
{ {
Item *arg= args[0]->val_int() ? args[1] : args[2]; Item *arg= args[0]->val_int() ? args[1] : args[2];
String *res=arg->val_str(str); String *res=arg->val_str(str);
res->set_charset(charset()); if (res)
res->set_charset(charset());
null_value=arg->null_value; null_value=arg->null_value;
return res; return res;
} }
......
...@@ -512,7 +512,8 @@ class Item_func_binary :public Item_str_func ...@@ -512,7 +512,8 @@ class Item_func_binary :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;
tmp->set_charset(&my_charset_bin); if (tmp)
tmp->set_charset(&my_charset_bin);
return tmp; return tmp;
} }
void fix_length_and_dec() void fix_length_and_dec()
......
...@@ -527,7 +527,8 @@ class Item_typecast :public Item_str_func ...@@ -527,7 +527,8 @@ 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;
tmp->set_charset(charset()); if (tmp)
tmp->set_charset(charset());
return tmp; return tmp;
} }
void fix_length_and_dec() void fix_length_and_dec()
......
...@@ -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