summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-06-25 15:59:44 +0300
committerGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-06-25 15:59:44 +0300
commit3e1a47070518a1995cc48e28c36b7c817d5f6008 (patch)
tree0e836662ec6132532d5428bce51937f74320bbff /sql
parentfd0eb0c1b02879b527471f4304f4a443fdd96fa9 (diff)
downloadmariadb-git-3e1a47070518a1995cc48e28c36b7c817d5f6008.tar.gz
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.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_show.cc37
1 files changed, 28 insertions, 9 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 33abf356718..0eeb333f278 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2690,36 +2690,54 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables,
{
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;
}
@@ -3324,6 +3342,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
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)));