Fix for bug#14861 aliased column names are not preserved.

  Create tmp table filed using original item name when it's necessary
parent c8631b41
......@@ -2456,3 +2456,19 @@ f1()
42
drop view v2,v1;
drop function f1;
create table t1 (id numeric, warehouse_id numeric);
create view v1 as select id from t1;
create view v2 as
select t1.warehouse_id, v1.id as receipt_id
from t1, v1 where t1.id = v1.id;
insert into t1 (id, warehouse_id) values(3, 2);
insert into t1 (id, warehouse_id) values(4, 2);
insert into t1 (id, warehouse_id) values(5, 1);
select v2.receipt_id as alias1, v2.receipt_id as alias2 from v2
order by v2.receipt_id;
alias1 alias2
3 3
4 4
5 5
drop view v2, v1;
drop table t1;
......@@ -2319,3 +2319,22 @@ CREATE VIEW v2 AS SELECT f1();
select * from v2;
drop view v2,v1;
drop function f1;
#
# Bug#14861: aliased column names are not preserved.
#
create table t1 (id numeric, warehouse_id numeric);
create view v1 as select id from t1;
create view v2 as
select t1.warehouse_id, v1.id as receipt_id
from t1, v1 where t1.id = v1.id;
insert into t1 (id, warehouse_id) values(3, 2);
insert into t1 (id, warehouse_id) values(4, 2);
insert into t1 (id, warehouse_id) values(5, 1);
select v2.receipt_id as alias1, v2.receipt_id as alias2 from v2
order by v2.receipt_id;
drop view v2, v1;
drop table t1;
......@@ -8189,7 +8189,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
uint convert_blob_length)
{
Item::Type orig_type= type;
Item *orig_item;
Item *orig_item= 0;
if (type != Item::FIELD_ITEM &&
item->real_item()->type() == Item::FIELD_ITEM &&
......@@ -8240,7 +8240,9 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
}
else
result= create_tmp_field_from_field(thd, (*from_field= field->field),
item->name, table,
orig_item ? orig_item->name :
item->name,
table,
modify_item ? field :
NULL,
convert_blob_length);
......
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