Commit b478276b authored by Monty's avatar Monty

Removed complex and wrong set_name_for_rollback()

This was wrong because:
- There was no reason to rollback name for item that will be deleted
  after query.
- name_length was not rolled back
- Changing real_item() doesn't work as it may be used many times in the
  same query

After removing all the old code and extending the test case, all the
related test cases passes.

Sanja and I concluded that the old code isn't needed anymore.  If it
still needed for some scenario not covered by our test system, it needs
to be coded in some other way, so better to remove the wrong code.
parent e2b03cd3
...@@ -2268,12 +2268,32 @@ create table t1 (s1 int); ...@@ -2268,12 +2268,32 @@ create table t1 (s1 int);
create view abc as select * from t1 as abc; create view abc as select * from t1 as abc;
drop table t1; drop table t1;
drop view abc; drop view abc;
flush status;
create table t1(f1 char(1)); create table t1(f1 char(1));
create view v1 as select * from t1; create view v1 as select * from t1;
select * from (select f1 as f2 from v1) v where v.f2='a'; select * from (select f1 as f2, f1 as f3 from v1) v where v.f2='a';
f2 f2 f3
show status like "Created_tmp%";
Variable_name Value
Created_tmp_disk_tables 0
Created_tmp_files 0
Created_tmp_tables 0
drop view v1;
drop table t1;
set @tmp=@@optimizer_switch;
set @@optimizer_switch='derived_merge=OFF';
create table t1(f1 char(1));
create view v1 as select * from t1;
select * from (select f1 as f2, f1 as f3 from v1) v where v.f2='a';
f2 f3
show status like "Created_tmp%";
Variable_name Value
Created_tmp_disk_tables 0
Created_tmp_files 0
Created_tmp_tables 1
drop view v1; drop view v1;
drop table t1; drop table t1;
set @@optimizer_switch=@tmp;
create view v1 as SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET'); create view v1 as SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET');
select * from v1; select * from v1;
CONVERT_TZ('2004-01-01 12:00:00','GMT','MET') CONVERT_TZ('2004-01-01 12:00:00','GMT','MET')
......
...@@ -2124,12 +2124,24 @@ drop view abc; ...@@ -2124,12 +2124,24 @@ drop view abc;
# #
# Bug#12993 View column rename broken in subselect # Bug#12993 View column rename broken in subselect
# #
flush status;
create table t1(f1 char(1)); create table t1(f1 char(1));
create view v1 as select * from t1; create view v1 as select * from t1;
select * from (select f1 as f2 from v1) v where v.f2='a'; select * from (select f1 as f2, f1 as f3 from v1) v where v.f2='a';
show status like "Created_tmp%";
drop view v1; drop view v1;
drop table t1; drop table t1;
set @tmp=@@optimizer_switch;
set @@optimizer_switch='derived_merge=OFF';
create table t1(f1 char(1));
create view v1 as select * from t1;
select * from (select f1 as f2, f1 as f3 from v1) v where v.f2='a';
show status like "Created_tmp%";
drop view v1;
drop table t1;
set @@optimizer_switch=@tmp;
# #
# Bug#11416 Server crash if using a view that uses function convert_tz # Bug#11416 Server crash if using a view that uses function convert_tz
......
...@@ -1117,21 +1117,6 @@ void Item::set_name_no_truncate(THD *thd, const char *str, uint length, ...@@ -1117,21 +1117,6 @@ void Item::set_name_no_truncate(THD *thd, const char *str, uint length,
} }
void Item::set_name_for_rollback(THD *thd, const char *str, uint length,
CHARSET_INFO *cs)
{
char *old_name, *new_name;
old_name= name;
set_name(thd, str, length, cs);
new_name= name;
if (old_name != new_name)
{
name= old_name;
thd->change_item_tree((Item **) &name, (Item *) new_name);
}
}
/** /**
@details @details
This function is called when: This function is called when:
......
...@@ -645,8 +645,6 @@ class Item: public Value_source, ...@@ -645,8 +645,6 @@ class Item: public Value_source,
void set_name(THD *thd, const char *str, uint length, CHARSET_INFO *cs); void set_name(THD *thd, const char *str, uint length, CHARSET_INFO *cs);
void set_name_no_truncate(THD *thd, const char *str, uint length, void set_name_no_truncate(THD *thd, const char *str, uint length,
CHARSET_INFO *cs); CHARSET_INFO *cs);
void set_name_for_rollback(THD *thd, const char *str, uint length,
CHARSET_INFO *cs);
void rename(char *new_name); void rename(char *new_name);
void init_make_field(Send_field *tmp_field,enum enum_field_types type); void init_make_field(Send_field *tmp_field,enum enum_field_types type);
virtual void cleanup(); virtual void cleanup();
......
...@@ -5268,27 +5268,10 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list, ...@@ -5268,27 +5268,10 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
*ref != NULL means that *ref contains the item that we need to *ref != NULL means that *ref contains the item that we need to
replace. If the item was aliased by the user, set the alias to replace. If the item was aliased by the user, set the alias to
the replacing item. the replacing item.
We need to set alias on both ref itself and on ref real item.
*/ */
if (*ref && !(*ref)->is_autogenerated_name) if (*ref && !(*ref)->is_autogenerated_name)
{ item->set_name(thd, (*ref)->name, (*ref)->name_length,
if (register_tree_change) system_charset_info);
{
item->set_name_for_rollback(thd, (*ref)->name,
(*ref)->name_length,
system_charset_info);
item->real_item()->set_name_for_rollback(thd, (*ref)->name,
(*ref)->name_length,
system_charset_info);
}
else
{
item->set_name(thd, (*ref)->name, (*ref)->name_length,
system_charset_info);
item->real_item()->set_name(thd, (*ref)->name, (*ref)->name_length,
system_charset_info);
}
}
if (register_tree_change) if (register_tree_change)
thd->change_item_tree(ref, item); thd->change_item_tree(ref, item);
else else
......
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