From c7a440d1c6d0158a43880745971d20d95bcf6803 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Dec 2005 15:36:03 +0400 Subject: Fix for bug#14861 aliased column names are not preserved. Create tmp table filed using original item name when it's necessary mysql-test/r/view.result: Fix for bug#14861 aliased column names are not preserved. test case mysql-test/t/view.test: Fix for bug#14861 aliased column names are not preserved. test case --- mysql-test/r/view.result | 16 ++++++++++++++++ mysql-test/t/view.test | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index e4f2671eb34..7e7d0617b51 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -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; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 6d2afb908a4..718e1a9932b 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -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; -- cgit v1.2.1