List:Commits« Previous MessageNext Message »
From:kgeorge Date:November 13 2007 9:39am
Subject:bk commit into 5.0 tree (gkodinov:1.2564) BUG#31562
View as plain text  
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-11-13 11:39:52+02:00, gkodinov@stripped +5 -0
  Bug #31562: HAVING and lower case
  
  The columns in HAVING can reference the GROUP BY and 
  SELECT columns. There can be "table" prefixes when
  referencing these columns. And these "table" prefixes
  in HAVING use the table alias if available.
  This means that table aliases are subject to the same
  storage rules as table names and are dependent on 
  lower_case_table_names in the same way as the table 
  names are.
  Fixed by :
  1. Treating table aliases as table names
  and make them lowercase when printing out the SQL
  statement for view persistence.
  2. Using case insensitive comparison for table 
  aliases when requested by lower_case_table_names

  mysql-test/r/lowercase_view.result@stripped, 2007-11-13 11:39:51+02:00, gkodinov@stripped +19 -2
    Bug #31562: test case

  mysql-test/t/lowercase_view.test@stripped, 2007-11-13 11:39:51+02:00, gkodinov@stripped +23 -0
    Bug #31562: test case

  sql/item.cc@stripped, 2007-11-13 11:39:51+02:00, gkodinov@stripped +1 -1
    Bug #31562: lower_case_table_name contious comparison
    when searching in GROUP BY

  sql/sql_base.cc@stripped, 2007-11-13 11:39:51+02:00, gkodinov@stripped +2 -1
    Bug #31562: lower_case_table_name contious comparison
    when searching in SELECT

  sql/sql_select.cc@stripped, 2007-11-13 11:39:51+02:00, gkodinov@stripped +14 -1
    Bug #31562: treat table aliases as table names
    and make them lowercase when printing

diff -Nrup a/mysql-test/r/lowercase_view.result b/mysql-test/r/lowercase_view.result
--- a/mysql-test/r/lowercase_view.result	2005-09-14 12:24:10 +03:00
+++ b/mysql-test/r/lowercase_view.result	2007-11-13 11:39:51 +02:00
@@ -119,7 +119,7 @@ create table t1Aa (col1 int);
 create view v1Aa as select col1 from t1Aa as AaA;
 show create view v1AA;
 View	Create View
-v1aa	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `AaA`
+v1aa	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `aaa`
 drop view v1AA;
 select Aaa.col1 from t1Aa as AaA;
 col1
@@ -128,6 +128,23 @@ drop view v1AA;
 create view v1Aa as select AaA.col1 from t1Aa as AaA;
 show create view v1AA;
 View	Create View
-v1aa	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `AaA`
+v1aa	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `aaa`
 drop view v1AA;
 drop table t1Aa;
+CREATE TABLE  t1 (a int, b int);
+select X.a from t1 AS X group by X.b having (X.a = 1);
+a
+select X.a from t1 AS X group by X.b having (x.a = 1);
+a
+select X.a from t1 AS X group by X.b having (x.b = 1);
+a
+CREATE OR REPLACE VIEW v1 AS
+select X.a from t1 AS X group by X.b having (X.a = 1);
+SHOW CREATE VIEW v1;
+View	Create View
+v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `x`.`a` AS `a` from `t1` `x` group by `x`.`b` having (`x`.`a` = 1)
+SELECT * FROM v1;
+a
+DROP VIEW v1;
+DROP TABLE t1;
+End of 5.0 tests.
diff -Nrup a/mysql-test/t/lowercase_view.test b/mysql-test/t/lowercase_view.test
--- a/mysql-test/t/lowercase_view.test	2005-09-02 09:50:09 +03:00
+++ b/mysql-test/t/lowercase_view.test	2007-11-13 11:39:51 +02:00
@@ -138,3 +138,26 @@ create view v1Aa as select AaA.col1 from
 show create view v1AA;
 drop view v1AA;
 drop table t1Aa;
+
+
+#
+# Bug #31562: HAVING and lower case
+#
+
+CREATE TABLE  t1 (a int, b int);
+
+select X.a from t1 AS X group by X.b having (X.a = 1);
+select X.a from t1 AS X group by X.b having (x.a = 1);
+select X.a from t1 AS X group by X.b having (x.b = 1);
+
+CREATE OR REPLACE VIEW v1 AS
+select X.a from t1 AS X group by X.b having (X.a = 1);
+
+SHOW CREATE VIEW v1;
+
+SELECT * FROM v1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo End of 5.0 tests.
diff -Nrup a/sql/item.cc b/sql/item.cc
--- a/sql/item.cc	2007-10-23 18:51:36 +03:00
+++ b/sql/item.cc	2007-11-13 11:39:51 +02:00
@@ -3307,7 +3307,7 @@ static Item** find_field_in_group_list(I
       if (cur_field->table_name && table_name)
       {
         /* If field_name is qualified by a table name. */
-        if (strcmp(cur_field->table_name, table_name))
+        if (my_strcasecmp(table_alias_charset, cur_field->table_name, table_name))
           /* Same field names, different tables. */
           return NULL;
 
diff -Nrup a/sql/sql_base.cc b/sql/sql_base.cc
--- a/sql/sql_base.cc	2007-10-26 12:44:27 +03:00
+++ b/sql/sql_base.cc	2007-11-13 11:39:51 +02:00
@@ -4164,7 +4164,8 @@ find_item_in_list(Item *find, List<Item>
         if (item_field->field_name && item_field->table_name &&
 	    !my_strcasecmp(system_charset_info, item_field->field_name,
                            field_name) &&
-            !strcmp(item_field->table_name, table_name) &&
+            !my_strcasecmp(table_alias_charset, item_field->table_name, 
+                           table_name) &&
             (!db_name || (item_field->db_name &&
                           !strcmp(item_field->db_name, db_name))))
         {
diff -Nrup a/sql/sql_select.cc b/sql/sql_select.cc
--- a/sql/sql_select.cc	2007-11-01 18:36:24 +02:00
+++ b/sql/sql_select.cc	2007-11-13 11:39:51 +02:00
@@ -15612,8 +15612,21 @@ void TABLE_LIST::print(THD *thd, String 
     }
     if (my_strcasecmp(table_alias_charset, cmp_name, alias))
     {
+      char t_alias_buff[MAX_ALIAS_NAME];
+      const char *t_alias= alias;
+
       str->append(' ');
-      append_identifier(thd, str, alias, strlen(alias));
+      if (lower_case_table_names== 1)
+      {
+        if (alias && alias[0])
+        {
+          strmov(t_alias_buff, alias);
+          my_casedn_str(files_charset_info, t_alias_buff);
+          t_alias= t_alias_buff;
+        }
+      }
+
+      append_identifier(thd, str, t_alias, strlen(t_alias));
     }
 
     if (use_index)
Thread
bk commit into 5.0 tree (gkodinov:1.2564) BUG#31562kgeorge13 Nov
Re: bk commit into 5.0 tree (gkodinov:1.2564) BUG#31562Georgi Kodinov13 Nov