mirror of
https://github.com/MariaDB/server.git
synced 2026-04-24 09:15:30 +02:00
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.
This commit is contained in:
parent
e2b03cd3b5
commit
b478276b04
5 changed files with 37 additions and 39 deletions
|
|
@ -2268,12 +2268,32 @@ create table t1 (s1 int);
|
|||
create view abc as select * from t1 as abc;
|
||||
drop table t1;
|
||||
drop view abc;
|
||||
flush status;
|
||||
create table t1(f1 char(1));
|
||||
create view v1 as select * from t1;
|
||||
select * from (select f1 as f2 from v1) v where v.f2='a';
|
||||
f2
|
||||
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 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 table t1;
|
||||
set @@optimizer_switch=@tmp;
|
||||
create view v1 as SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET');
|
||||
select * from v1;
|
||||
CONVERT_TZ('2004-01-01 12:00:00','GMT','MET')
|
||||
|
|
|
|||
|
|
@ -2124,12 +2124,24 @@ drop view abc;
|
|||
#
|
||||
# Bug#12993 View column rename broken in subselect
|
||||
#
|
||||
|
||||
flush status;
|
||||
create table t1(f1 char(1));
|
||||
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 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
|
||||
|
|
|
|||
15
sql/item.cc
15
sql/item.cc
|
|
@ -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
|
||||
This function is called when:
|
||||
|
|
|
|||
|
|
@ -645,8 +645,6 @@ public:
|
|||
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,
|
||||
CHARSET_INFO *cs);
|
||||
void set_name_for_rollback(THD *thd, const char *str, uint length,
|
||||
CHARSET_INFO *cs);
|
||||
void rename(char *new_name);
|
||||
void init_make_field(Send_field *tmp_field,enum enum_field_types type);
|
||||
virtual void cleanup();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
replace. If the item was aliased by the user, set the alias to
|
||||
the replacing item.
|
||||
We need to set alias on both ref itself and on ref real item.
|
||||
*/
|
||||
if (*ref && !(*ref)->is_autogenerated_name)
|
||||
{
|
||||
if (register_tree_change)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
item->set_name(thd, (*ref)->name, (*ref)->name_length,
|
||||
system_charset_info);
|
||||
if (register_tree_change)
|
||||
thd->change_item_tree(ref, item);
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue