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-12-13 19:04:01+02:00, gkodinov@stripped +3 -0
Bug #33133: Views are not transparent
When resolving references we need to take into consideration
the view "fields" and allow qualified access to them.
Fixed by extending the reference resolution to process view
fields correctly.
mysql-test/r/func_group.result@stripped, 2007-12-13 19:03:57+02:00, gkodinov@stripped +12 -0
Bug #33133: test case
mysql-test/t/func_group.test@stripped, 2007-12-13 19:03:58+02:00, gkodinov@stripped +15 -0
Bug #33133: test case
sql/sql_base.cc@stripped, 2007-12-13 19:03:58+02:00, gkodinov@stripped +19 -1
Bug #33133: allow qualified alias refs to view fields
diff -Nrup a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
--- a/mysql-test/r/func_group.result 2007-11-01 18:36:24 +02:00
+++ b/mysql-test/r/func_group.result 2007-12-13 19:03:57 +02:00
@@ -1407,4 +1407,16 @@ SELECT COUNT(*), a FROM t1;
COUNT(*) a
4 1
DROP TABLE t1;
+set SQL_MODE=ONLY_FULL_GROUP_BY;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+CREATE VIEW v1 AS SELECT a,(a + 1) AS y FROM t1;
+EXPLAIN EXTENDED SELECT y FROM v1 GROUP BY v1.y;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort
+Warnings:
+Note 1003 select (`test`.`t1`.`a` + 1) AS `y` from `test`.`t1` group by (`test`.`t1`.`a` + 1)
+DROP VIEW v1;
+DROP TABLE t1;
+SET SQL_MODE=DEFAULT;
End of 5.0 tests
diff -Nrup a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
--- a/mysql-test/t/func_group.test 2007-11-01 18:36:24 +02:00
+++ b/mysql-test/t/func_group.test 2007-12-13 19:03:58 +02:00
@@ -901,5 +901,20 @@ SELECT COUNT(*), a FROM t1;
DROP TABLE t1;
+#
+# Bug #33133: Views are not transparent
+#
+
+set SQL_MODE=ONLY_FULL_GROUP_BY;
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+CREATE VIEW v1 AS SELECT a,(a + 1) AS y FROM t1;
+EXPLAIN EXTENDED SELECT y FROM v1 GROUP BY v1.y;
+
+DROP VIEW v1;
+DROP TABLE t1;
+SET SQL_MODE=DEFAULT;
+
###
--echo End of 5.0 tests
diff -Nrup a/sql/sql_base.cc b/sql/sql_base.cc
--- a/sql/sql_base.cc 2007-11-13 11:39:51 +02:00
+++ b/sql/sql_base.cc 2007-12-13 19:03:58 +02:00
@@ -4255,7 +4255,25 @@ find_item_in_list(Item *find, List<Item>
*resolution= RESOLVED_IGNORING_ALIAS;
break;
}
- }
+ }
+ else if (table_name && item->type() == Item::REF_ITEM &&
+ ((Item_ref *)item)->ref_type() == Item_ref::VIEW_REF)
+ {
+ /* Here we process prefixed view references. */
+ Item_direct_view_ref *item_ref= (Item_direct_view_ref *) item;
+ if (item_ref->name && item_ref->table_name &&
+ !my_strcasecmp(system_charset_info, item_ref->name, field_name) &&
+ !my_strcasecmp(table_alias_charset, item_ref->table_name,
+ table_name) &&
+ (!db_name || (item_ref->db_name &&
+ !strcmp (item_ref->db_name, db_name))))
+ {
+ found= li.ref();
+ *counter= i;
+ *resolution= RESOLVED_AGAINST_ALIAS;
+ break;
+ }
+ }
}
if (!found)
{
| Thread |
|---|
| • bk commit into 5.0 tree (gkodinov:1.2600) BUG#33133 | kgeorge | 13 Dec |