Below is the list of changes that have just been committed into a local
5.0 repository of kgeorge. When kgeorge does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-01-08 17:20:52+02:00, gkodinov@stripped +3 -0
BUG#25106: A USING clause in combination with a VIEW results in column
aliases ignored
When making a new Item on resolving column reference to a JOIN USING
column the user defined alias was lost.
Made the code to preserve the alias by setting it into the new Item
before replacing.
mysql-test/r/view.result@stripped, 2007-01-08 17:20:44+02:00, gkodinov@stripped +15 -0
BUG#25106: A USING clause in combination with a VIEW results in column
aliases ignored
- test case
mysql-test/t/view.test@stripped, 2007-01-08 17:20:45+02:00, gkodinov@stripped +17 -0
BUG#25106: A USING clause in combination with a VIEW results in column
aliases ignored
- test case
sql/sql_base.cc@stripped, 2007-01-08 17:20:45+02:00, gkodinov@stripped +13 -0
BUG#25106: A USING clause in combination with a VIEW results in column
aliases ignored
- take the alias of the Item to be replaced and set it into the newly
allocated Item.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: gkodinov
# Host: macbook.local
# Root: /Users/kgeorge/mysql/work/B25106-5.0-opt
--- 1.360/sql/sql_base.cc 2006-12-30 22:02:07 +02:00
+++ 1.361/sql/sql_base.cc 2007-01-08 17:20:45 +02:00
@@ -2977,6 +2977,19 @@ find_field_in_natural_join(THD *thd, TAB
column reference. See create_view_field() for details.
*/
item= nj_col->create_item(thd);
+ /*
+ *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)
+ {
+ item->set_name((*ref)->name, (*ref)->name_length,
+ system_charset_info);
+ item->real_item()->set_name((*ref)->name, (*ref)->name_length,
+ system_charset_info);
+ }
if (register_tree_change && arena)
thd->restore_active_arena(arena, &backup);
--- 1.185/mysql-test/r/view.result 2007-01-02 12:01:39 +02:00
+++ 1.186/mysql-test/r/view.result 2007-01-08 17:20:44 +02:00
@@ -3014,4 +3014,19 @@ i j
6 3
DROP VIEW v1, v2;
DROP TABLE t1;
+CREATE TABLE t1 (ID INTEGER, Name VARCHAR(50));
+CREATE TABLE t2 (Test_ID INTEGER);
+CREATE VIEW v1 (Test_ID, Description) AS SELECT ID, Name FROM t1;
+CREATE TABLE tv1 SELECT Description AS Name FROM v1 LEFT JOIN t2
+USING (Test_ID);
+DESCRIBE tv1;
+Field Type Null Key Default Extra
+Name varchar(50) YES NULL
+CREATE TABLE tv2 SELECT Description AS Name FROM v1 LEFT JOIN t2
+ON v1.Test_ID = t2.Test_ID;
+DESCRIBE tv2;
+Field Type Null Key Default Extra
+Name varchar(50) YES NULL
+DROP VIEW v1;
+DROP TABLE t1,t2,tv1,tv2;
End of 5.0 tests.
--- 1.170/mysql-test/t/view.test 2006-11-03 00:34:16 +02:00
+++ 1.171/mysql-test/t/view.test 2007-01-08 17:20:45 +02:00
@@ -2959,5 +2959,22 @@ SELECT * FROM t1;
DROP VIEW v1, v2;
DROP TABLE t1;
+#
+# BUG#25106: A USING clause in combination with a VIEW results in column
+# aliases ignored
+#
+CREATE TABLE t1 (ID INTEGER, Name VARCHAR(50));
+CREATE TABLE t2 (Test_ID INTEGER);
+CREATE VIEW v1 (Test_ID, Description) AS SELECT ID, Name FROM t1;
+
+CREATE TABLE tv1 SELECT Description AS Name FROM v1 LEFT JOIN t2
+ USING (Test_ID);
+DESCRIBE tv1;
+CREATE TABLE tv2 SELECT Description AS Name FROM v1 LEFT JOIN t2
+ ON v1.Test_ID = t2.Test_ID;
+DESCRIBE tv2;
+
+DROP VIEW v1;
+DROP TABLE t1,t2,tv1,tv2;
--echo End of 5.0 tests.
| Thread |
|---|
| • bk commit into 5.0 tree (gkodinov:1.2367) BUG#25106 | kgeorge | 8 Jan |