List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:June 25 2010 12:59pm
Subject:bzr commit into mysql-5.1-bugteam branch (Georgi.Kodinov:3438) Bug#53095
View as plain text  
#At file:///home/kgeorge/mysql/work/B53095-5.1-bugteam/ based on revid:sergey.glukhov@stripped

 3438 Georgi Kodinov	2010-06-25
      Bug #53095: SELECT column_name FROM INFORMATION_SCHEMA.STATISTICS 
      returns nothing
            
      When looking for table or database names inside INFORMATION_SCHEMA
      we must convert the table and database names to lowercase (just as it's
      done in the rest of the server) when lowercase_table_names is non-zero.
      This will allow us to find the same tables that we would find if there
      is no condition.
      
      Fixed by converting to lower case when extracting the database and 
      table name conditions.
      Test case added.

    modified:
      mysql-test/r/lowercase_view.result
      mysql-test/t/lowercase_view.test
      sql/sql_show.cc
=== modified file 'mysql-test/r/lowercase_view.result'
--- a/mysql-test/r/lowercase_view.result	2007-11-13 17:32:12 +0000
+++ b/mysql-test/r/lowercase_view.result	2010-06-25 12:59:44 +0000
@@ -148,3 +148,20 @@ a
 DROP VIEW v1;
 DROP TABLE t1;
 End of 5.0 tests.
+#
+# Bug #53095: SELECT column_name FROM INFORMATION_SCHEMA.STATISTICS
+#  returns nothing
+#
+CREATE TABLE `ttt` (
+`f1` char(3) NOT NULL,
+PRIMARY KEY (`f1`)
+) ENGINE=myisam DEFAULT CHARSET=latin1;
+SELECT count(COLUMN_NAME) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME =
+'TTT';
+count(COLUMN_NAME)
+1
+SELECT count(*) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 'TTT';
+count(*)
+1
+DROP TABLE `ttt`;
+End of 5.0 tests.

=== modified file 'mysql-test/t/lowercase_view.test'
--- a/mysql-test/t/lowercase_view.test	2007-11-13 09:39:52 +0000
+++ b/mysql-test/t/lowercase_view.test	2010-06-25 12:59:44 +0000
@@ -160,4 +160,26 @@ SELECT * FROM v1;
 DROP VIEW v1;
 DROP TABLE t1;
 
+
+--echo End of 5.0 tests.
+
+
+--echo #
+--echo # Bug #53095: SELECT column_name FROM INFORMATION_SCHEMA.STATISTICS
+--echo #  returns nothing
+--echo #
+
+CREATE TABLE `ttt` (
+  `f1` char(3) NOT NULL,
+  PRIMARY KEY (`f1`)
+) ENGINE=myisam DEFAULT CHARSET=latin1;
+
+SELECT count(COLUMN_NAME) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME =
+'TTT';
+SELECT count(*) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 'TTT';
+
+DROP TABLE `ttt`;
+
+
 --echo End of 5.0 tests.
+

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2010-06-10 20:45:22 +0000
+++ b/sql/sql_show.cc	2010-06-25 12:59:44 +0000
@@ -2690,36 +2690,54 @@ bool get_lookup_field_values(THD *thd, C
 {
   LEX *lex= thd->lex;
   const char *wild= lex->wild ? lex->wild->ptr() : NullS;
+  bool rc= 0;
+
   bzero((char*) lookup_field_values, sizeof(LOOKUP_FIELD_VALUES));
   switch (lex->sql_command) {
   case SQLCOM_SHOW_DATABASES:
     if (wild)
     {
-      lookup_field_values->db_value.str= (char*) wild;
-      lookup_field_values->db_value.length= strlen(wild);
+      thd->make_lex_string(&lookup_field_values->db_value, 
+                           wild, strlen(wild), 0);
       lookup_field_values->wild_db_value= 1;
     }
-    return 0;
+    break;
   case SQLCOM_SHOW_TABLES:
   case SQLCOM_SHOW_TABLE_STATUS:
   case SQLCOM_SHOW_TRIGGERS:
   case SQLCOM_SHOW_EVENTS:
-    lookup_field_values->db_value.str= lex->select_lex.db;
-    lookup_field_values->db_value.length=strlen(lex->select_lex.db);
+    thd->make_lex_string(&lookup_field_values->db_value, 
+                         lex->select_lex.db, strlen(lex->select_lex.db), 0);
     if (wild)
     {
-      lookup_field_values->table_value.str= (char*)wild;
-      lookup_field_values->table_value.length= strlen(wild);
+      thd->make_lex_string(&lookup_field_values->table_value, 
+                           wild, strlen(wild), 0);
       lookup_field_values->wild_table_value= 1;
     }
-    return 0;
+    break;
   default:
     /*
       The "default" is for queries over I_S.
       All previous cases handle SHOW commands.
     */
-    return calc_lookup_values_from_cond(thd, cond, tables, lookup_field_values);
+    rc= calc_lookup_values_from_cond(thd, cond, tables, lookup_field_values);
+    break;
   }
+
+  if (lower_case_table_names && !rc)
+  {
+    /* 
+      We can safely do in-place upgrades here since all of the above cases
+      are allocating a new memory buffer for these strings.
+    */  
+    if (lookup_field_values->db_value.str && lookup_field_values->db_value.str[0])
+      my_casedn_str(system_charset_info, lookup_field_values->db_value.str);
+    if (lookup_field_values->table_value.str && 
+        lookup_field_values->table_value.str[0])
+      my_casedn_str(system_charset_info, lookup_field_values->table_value.str);
+  }
+
+  return rc;
 }
 
 
@@ -3322,6 +3340,7 @@ int get_all_tables(THD *thd, TABLE_LIST 
     error= 0;
     goto err;
   }
+
   DBUG_PRINT("INDEX VALUES",("db_name='%s', table_name='%s'",
                              STR_OR_NIL(lookup_field_vals.db_value.str),
                              STR_OR_NIL(lookup_field_vals.table_value.str)));


Attachment: [text/bzr-bundle] bzr/georgi.kodinov@oracle.com-20100625125944-50h0bcolxtk7q2r0.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Georgi.Kodinov:3438) Bug#53095Georgi Kodinov25 Jun