mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fix for bug#14861 aliased column names are not preserved.
Create tmp table filed using original item name when it's necessary
This commit is contained in:
@ -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,10 +8240,12 @@ 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,
|
||||
modify_item ? field :
|
||||
NULL,
|
||||
convert_blob_length);
|
||||
orig_item ? orig_item->name :
|
||||
item->name,
|
||||
table,
|
||||
modify_item ? field :
|
||||
NULL,
|
||||
convert_blob_length);
|
||||
if (orig_type == Item::REF_ITEM && orig_modify)
|
||||
((Item_ref*)orig_item)->set_result_field(result);
|
||||
return result;
|
||||
|
Reference in New Issue
Block a user