Commit d81b662b authored by Sergei Golubchik's avatar Sergei Golubchik

Asserting correct database name lettercase in

various places in the code.
parent 5b6c75ca
...@@ -596,6 +596,8 @@ Events::drop_schema_events(THD *thd, char *db) ...@@ -596,6 +596,8 @@ Events::drop_schema_events(THD *thd, char *db)
DBUG_ENTER("Events::drop_schema_events"); DBUG_ENTER("Events::drop_schema_events");
DBUG_PRINT("enter", ("dropping events from %s", db)); DBUG_PRINT("enter", ("dropping events from %s", db));
DBUG_ASSERT(ok_for_lower_case_names(db));
/* /*
Sic: no check if the scheduler is disabled or system tables Sic: no check if the scheduler is disabled or system tables
are damaged, as intended. are damaged, as intended.
......
...@@ -860,6 +860,8 @@ bool lock_object_name(THD *thd, MDL_key::enum_mdl_namespace mdl_type, ...@@ -860,6 +860,8 @@ bool lock_object_name(THD *thd, MDL_key::enum_mdl_namespace mdl_type,
MDL_request schema_request; MDL_request schema_request;
MDL_request mdl_request; MDL_request mdl_request;
DBUG_ASSERT(ok_for_lower_case_names(db));
if (thd->locked_tables_mode) if (thd->locked_tables_mode)
{ {
my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
......
...@@ -37,6 +37,7 @@ class THD; ...@@ -37,6 +37,7 @@ class THD;
class MDL_context; class MDL_context;
class MDL_lock; class MDL_lock;
class MDL_ticket; class MDL_ticket;
bool ok_for_lower_case_names(const char *name);
/** /**
@def ENTER_COND(C, M, S, O) @def ENTER_COND(C, M, S, O)
...@@ -350,6 +351,7 @@ public: ...@@ -350,6 +351,7 @@ public:
NAME_LEN) - m_ptr + 1); NAME_LEN) - m_ptr + 1);
m_hash_value= my_hash_sort(&my_charset_bin, (uchar*) m_ptr + 1, m_hash_value= my_hash_sort(&my_charset_bin, (uchar*) m_ptr + 1,
m_length - 1); m_length - 1);
DBUG_ASSERT(ok_for_lower_case_names(db));
} }
void mdl_key_init(const MDL_key *rhs) void mdl_key_init(const MDL_key *rhs)
{ {
......
...@@ -1437,6 +1437,8 @@ bool lock_db_routines(THD *thd, char *db) ...@@ -1437,6 +1437,8 @@ bool lock_db_routines(THD *thd, char *db)
uchar keybuf[MAX_KEY_LENGTH]; uchar keybuf[MAX_KEY_LENGTH];
DBUG_ENTER("lock_db_routines"); DBUG_ENTER("lock_db_routines");
DBUG_ASSERT(ok_for_lower_case_names(db));
/* /*
mysql.proc will be re-opened during deletion, so we can ignore mysql.proc will be re-opened during deletion, so we can ignore
errors when opening the table here. The error handler is errors when opening the table here. The error handler is
......
...@@ -493,6 +493,7 @@ sp_name::init_qname(THD *thd) ...@@ -493,6 +493,7 @@ sp_name::init_qname(THD *thd)
(int) m_db.length, (m_db.length ? m_db.str : ""), (int) m_db.length, (m_db.length ? m_db.str : ""),
dot, ".", dot, ".",
(int) m_name.length, m_name.str); (int) m_name.length, m_name.str);
DBUG_ASSERT(ok_for_lower_case_names(m_db.str));
} }
......
...@@ -2306,6 +2306,8 @@ void Query_cache::invalidate(THD *thd, char *db) ...@@ -2306,6 +2306,8 @@ void Query_cache::invalidate(THD *thd, char *db)
if (is_disabled()) if (is_disabled())
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
DBUG_ASSERT(ok_for_lower_case_names(db));
bool restart= FALSE; bool restart= FALSE;
/* /*
Lock the query cache and queue all invalidation attempts to avoid Lock the query cache and queue all invalidation attempts to avoid
......
...@@ -3436,6 +3436,24 @@ uint calculate_key_len(TABLE *table, uint key, const uchar *buf, ...@@ -3436,6 +3436,24 @@ uint calculate_key_len(TABLE *table, uint key, const uchar *buf,
return length; return length;
} }
#ifndef DBUG_OFF
/**
Verifies that database/table name is in lowercase, when it should be
This is supposed to be used only inside DBUG_ASSERT()
*/
bool ok_for_lower_case_names(const char *name)
{
if (!lower_case_table_names || !name)
return true;
char buf[SAFE_NAME_LEN];
strmake_buf(buf, name);
my_casedn_str(files_charset_info, buf);
return strcmp(name, buf) == 0;
}
#endif
/* /*
Check if database name is valid Check if database name is valid
......
...@@ -2511,6 +2511,8 @@ static inline void dbug_tmp_restore_column_maps(MY_BITMAP *read_set, ...@@ -2511,6 +2511,8 @@ static inline void dbug_tmp_restore_column_maps(MY_BITMAP *read_set,
#endif #endif
} }
bool ok_for_lower_case_names(const char *names);
enum get_table_share_flags { enum get_table_share_flags {
GTS_TABLE = 1, GTS_TABLE = 1,
GTS_VIEW = 2, GTS_VIEW = 2,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment