diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/events.cc | 2 | ||||
-rw-r--r-- | sql/lock.cc | 2 | ||||
-rw-r--r-- | sql/mdl.h | 2 | ||||
-rw-r--r-- | sql/sp.cc | 2 | ||||
-rw-r--r-- | sql/sp_head.cc | 1 | ||||
-rw-r--r-- | sql/sql_cache.cc | 2 | ||||
-rw-r--r-- | sql/table.cc | 18 | ||||
-rw-r--r-- | sql/table.h | 2 |
8 files changed, 31 insertions, 0 deletions
diff --git a/sql/events.cc b/sql/events.cc index 0c0fb0d5a38..63627b21777 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -596,6 +596,8 @@ Events::drop_schema_events(THD *thd, char *db) DBUG_ENTER("Events::drop_schema_events"); 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 are damaged, as intended. diff --git a/sql/lock.cc b/sql/lock.cc index 54681d25b0a..d5124ebc0f8 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -860,6 +860,8 @@ bool lock_object_name(THD *thd, MDL_key::enum_mdl_namespace mdl_type, MDL_request schema_request; MDL_request mdl_request; + DBUG_ASSERT(ok_for_lower_case_names(db)); + if (thd->locked_tables_mode) { my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, diff --git a/sql/mdl.h b/sql/mdl.h index dbd44e8c6ab..47c587eb3be 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -37,6 +37,7 @@ class THD; class MDL_context; class MDL_lock; class MDL_ticket; +bool ok_for_lower_case_names(const char *name); /** @def ENTER_COND(C, M, S, O) @@ -350,6 +351,7 @@ public: NAME_LEN) - m_ptr + 1); m_hash_value= my_hash_sort(&my_charset_bin, (uchar*) m_ptr + 1, m_length - 1); + DBUG_ASSERT(ok_for_lower_case_names(db)); } void mdl_key_init(const MDL_key *rhs) { diff --git a/sql/sp.cc b/sql/sp.cc index 6ad38956cee..188b311ae86 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1437,6 +1437,8 @@ bool lock_db_routines(THD *thd, char *db) uchar keybuf[MAX_KEY_LENGTH]; 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 errors when opening the table here. The error handler is diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 92f7ac020f5..89248f5746b 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -493,6 +493,7 @@ sp_name::init_qname(THD *thd) (int) m_db.length, (m_db.length ? m_db.str : ""), dot, ".", (int) m_name.length, m_name.str); + DBUG_ASSERT(ok_for_lower_case_names(m_db.str)); } diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index c6c5418e0cf..cf68ba36997 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -2306,6 +2306,8 @@ void Query_cache::invalidate(THD *thd, char *db) if (is_disabled()) DBUG_VOID_RETURN; + DBUG_ASSERT(ok_for_lower_case_names(db)); + bool restart= FALSE; /* Lock the query cache and queue all invalidation attempts to avoid diff --git a/sql/table.cc b/sql/table.cc index 210a9246a16..5da15dab9e7 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3436,6 +3436,24 @@ uint calculate_key_len(TABLE *table, uint key, const uchar *buf, 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 diff --git a/sql/table.h b/sql/table.h index 975f79fc02d..f23e678697c 100644 --- a/sql/table.h +++ b/sql/table.h @@ -2511,6 +2511,8 @@ static inline void dbug_tmp_restore_column_maps(MY_BITMAP *read_set, #endif } +bool ok_for_lower_case_names(const char *names); + enum get_table_share_flags { GTS_TABLE = 1, GTS_VIEW = 2, |