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, 2006-11-09 16:55:42+02:00, gkodinov@stripped +4 -0
Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs
When compiling GROUP BY Item_ref instances are dereferenced in
setup_copy_fields(), i.e. replaced with the corresponding Item_field
(if they point to one) or Item_copy_string for the other cases.
Since the Item_ref (in the Item_field case) is no longer used the information
about the aliases stored in it is lost.
Fixed by preserving the column, table and DB alias on dereferencing Item_ref
mysql-test/r/metadata.result@stripped, 2006-11-09 16:55:34+02:00, gkodinov@stripped +34
-0
Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs
- test case
mysql-test/t/metadata.test@stripped, 2006-11-09 16:55:35+02:00, gkodinov@stripped +19 -0
Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs
- test case
sql/item.cc@stripped, 2006-11-09 16:55:36+02:00, gkodinov@stripped +4 -0
Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs
- use the table and db name to fill up the metadata for columns
sql/sql_select.cc@stripped, 2006-11-09 16:55:37+02:00, gkodinov@stripped +9 -2
Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs
- preserve the field, table and DB name on dereferencing an Item_ref
# 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.gmz
# Root: /Users/kgeorge/mysql/work/B20191-5.0-opt
--- 1.240/sql/item.cc 2006-11-07 15:38:57 +02:00
+++ 1.241/sql/item.cc 2006-11-09 16:55:36 +02:00
@@ -4202,6 +4202,10 @@
DBUG_ASSERT(tmp_field->table_name != 0);
if (name)
tmp_field->col_name=name; // Use user supplied name
+ if (table_name)
+ tmp_field->table_name= table_name;
+ if (db_name)
+ tmp_field->db_name= db_name;
}
--- 1.469/sql/sql_select.cc 2006-11-02 00:50:06 +02:00
+++ 1.470/sql/sql_select.cc 2006-11-09 16:55:37 +02:00
@@ -13594,9 +13594,16 @@
if (real_pos->type() == Item::FIELD_ITEM)
{
Item_field *item;
- pos= real_pos;
- if (!(item= new Item_field(thd, ((Item_field*) pos))))
+ if (!(item= new Item_field(thd, ((Item_field*) real_pos))))
goto err;
+ if (pos->type() == Item::REF_ITEM)
+ {
+ /* preserve the names of the ref when dereferncing */
+ Item_ref *ref= (Item_ref *) pos;
+ item->db_name= ref->db_name;
+ item->table_name= ref->table_name;
+ item->name= ref->name;
+ }
pos= item;
if (item->field->flags & BLOB_FLAG)
{
--- 1.14/mysql-test/r/metadata.result 2006-05-13 11:11:36 +03:00
+++ 1.15/mysql-test/r/metadata.result 2006-11-09 16:55:34 +02:00
@@ -96,3 +96,37 @@
2
affected rows: 1
affected rows: 0
+create table t1 (id int(10));
+insert into t1 values (1);
+CREATE VIEW v1 AS select t1.id as id from t1;
+CREATE VIEW v2 AS select t1.id as renamed from t1;
+CREATE VIEW v3 AS select t1.id + 12 as renamed from t1;
+select * from v1 group by id limit 1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max
length Is_null Flags Decimals Charsetnr
+def test t1 v1 id id 3 10 1 Y 32768 0 63
+id
+1
+select * from v1 group by id limit 0;
+Catalog Database Table Table_alias Column Column_alias Type Length Max
length Is_null Flags Decimals Charsetnr
+def test t1 v1 id id 3 10 0 Y 32768 0 63
+id
+select * from v1 where id=1000 group by id;
+Catalog Database Table Table_alias Column Column_alias Type Length Max
length Is_null Flags Decimals Charsetnr
+def test t1 v1 id id 3 10 0 Y 32768 0 63
+id
+select * from v1 where id=1 group by id;
+Catalog Database Table Table_alias Column Column_alias Type Length Max
length Is_null Flags Decimals Charsetnr
+def test t1 v1 id id 3 10 1 Y 32768 0 63
+id
+1
+select * from v2 where renamed=1 group by renamed;
+Catalog Database Table Table_alias Column Column_alias Type Length Max
length Is_null Flags Decimals Charsetnr
+def test t1 v2 id renamed 3 10 1 Y 32768 0 63
+renamed
+1
+select * from v3 where renamed=1 group by renamed;
+Catalog Database Table Table_alias Column Column_alias Type Length Max
length Is_null Flags Decimals Charsetnr
+def v3 renamed 8 12 0 Y 32896 0 63
+renamed
+drop table t1;
+drop view v1,v2,v3;
--- 1.5/mysql-test/t/metadata.test 2005-08-11 04:32:14 +03:00
+++ 1.6/mysql-test/t/metadata.test 2006-11-09 16:55:35 +02:00
@@ -61,4 +61,23 @@
delimiter ;//
--disable_info
+#
+# Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs
+#
+--enable_metadata
+create table t1 (id int(10));
+insert into t1 values (1);
+CREATE VIEW v1 AS select t1.id as id from t1;
+CREATE VIEW v2 AS select t1.id as renamed from t1;
+CREATE VIEW v3 AS select t1.id + 12 as renamed from t1;
+select * from v1 group by id limit 1;
+select * from v1 group by id limit 0;
+select * from v1 where id=1000 group by id;
+select * from v1 where id=1 group by id;
+select * from v2 where renamed=1 group by renamed;
+select * from v3 where renamed=1 group by renamed;
+drop table t1;
+drop view v1,v2,v3;
+--disable_metadata
+
# End of 4.1 tests
| Thread |
|---|
| • bk commit into 5.0 tree (gkodinov:1.2302) BUG#20191 | kgeorge | 9 Nov |