mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug#49501 Inefficient information_schema check (system collation)
added check_length optimization for I_S_NAME comparison
This commit is contained in:
@ -1305,8 +1305,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
table_list.alias= table_list.table_name= conv_name.str;
|
||||
packet= arg_end + 1;
|
||||
|
||||
if (!my_strcasecmp(system_charset_info, table_list.db,
|
||||
INFORMATION_SCHEMA_NAME.str))
|
||||
if (is_schema_db(table_list.db, table_list.db_length))
|
||||
{
|
||||
ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, table_list.alias);
|
||||
if (schema_table)
|
||||
@ -1368,7 +1367,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
break;
|
||||
}
|
||||
if (check_access(thd, CREATE_ACL, db.str , 0, 1, 0,
|
||||
is_schema_db(db.str)))
|
||||
is_schema_db(db.str, db.length)))
|
||||
break;
|
||||
general_log_print(thd, command, "%.*s", db.length, db.str);
|
||||
bzero(&create_info, sizeof(create_info));
|
||||
@ -1387,7 +1386,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
my_error(ER_WRONG_DB_NAME, MYF(0), db.str ? db.str : "NULL");
|
||||
break;
|
||||
}
|
||||
if (check_access(thd, DROP_ACL, db.str, 0, 1, 0, is_schema_db(db.str)))
|
||||
if (check_access(thd, DROP_ACL, db.str, 0, 1, 0,
|
||||
is_schema_db(db.str, db.length)))
|
||||
break;
|
||||
if (thd->locked_tables || thd->active_transaction())
|
||||
{
|
||||
@ -2852,7 +2852,7 @@ end_with_restore_list:
|
||||
&first_table->grant.privilege, 0, 0,
|
||||
test(first_table->schema_table)) ||
|
||||
check_access(thd,INSERT_ACL | CREATE_ACL,select_lex->db,&priv,0,0,
|
||||
is_schema_db(select_lex->db))||
|
||||
is_schema_db(select_lex->db, strlen(select_lex->db)))||
|
||||
check_merge_table_access(thd, first_table->db,
|
||||
(TABLE_LIST *)
|
||||
create_info.merge_list.first))
|
||||
@ -3590,7 +3590,7 @@ end_with_restore_list:
|
||||
}
|
||||
#endif
|
||||
if (check_access(thd,CREATE_ACL,lex->name.str, 0, 1, 0,
|
||||
is_schema_db(lex->name.str)))
|
||||
is_schema_db(lex->name.str, lex->name.length)))
|
||||
break;
|
||||
res= mysql_create_db(thd,(lower_case_table_names == 2 ? alias :
|
||||
lex->name.str), &create_info, 0);
|
||||
@ -3625,7 +3625,7 @@ end_with_restore_list:
|
||||
}
|
||||
#endif
|
||||
if (check_access(thd,DROP_ACL,lex->name.str,0,1,0,
|
||||
is_schema_db(lex->name.str)))
|
||||
is_schema_db(lex->name.str, lex->name.length)))
|
||||
break;
|
||||
if (thd->locked_tables || thd->active_transaction())
|
||||
{
|
||||
@ -3659,9 +3659,12 @@ end_with_restore_list:
|
||||
my_error(ER_WRONG_DB_NAME, MYF(0), db->str);
|
||||
break;
|
||||
}
|
||||
if (check_access(thd, ALTER_ACL, db->str, 0, 1, 0, is_schema_db(db->str)) ||
|
||||
check_access(thd, DROP_ACL, db->str, 0, 1, 0, is_schema_db(db->str)) ||
|
||||
check_access(thd, CREATE_ACL, db->str, 0, 1, 0, is_schema_db(db->str)))
|
||||
if (check_access(thd, ALTER_ACL, db->str, 0, 1, 0,
|
||||
is_schema_db(db->str, db->length)) ||
|
||||
check_access(thd, DROP_ACL, db->str, 0, 1, 0,
|
||||
is_schema_db(db->str, db->length)) ||
|
||||
check_access(thd, CREATE_ACL, db->str, 0, 1, 0,
|
||||
is_schema_db(db->str, db->length)))
|
||||
{
|
||||
res= 1;
|
||||
break;
|
||||
@ -3704,7 +3707,8 @@ end_with_restore_list:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if (check_access(thd, ALTER_ACL, db->str, 0, 1, 0, is_schema_db(db->str)))
|
||||
if (check_access(thd, ALTER_ACL, db->str, 0, 1, 0,
|
||||
is_schema_db(db->str, db->length)))
|
||||
break;
|
||||
if (thd->locked_tables || thd->active_transaction())
|
||||
{
|
||||
@ -3860,7 +3864,8 @@ end_with_restore_list:
|
||||
first_table ? &first_table->grant.privilege : 0,
|
||||
first_table ? 0 : 1, 0,
|
||||
first_table ? (bool) first_table->schema_table :
|
||||
select_lex->db ? is_schema_db(select_lex->db) : 0))
|
||||
select_lex->db ?
|
||||
is_schema_db(select_lex->db, strlen(select_lex->db)) : 0))
|
||||
goto error;
|
||||
|
||||
if (thd->security_ctx->user) // If not replication
|
||||
@ -4203,7 +4208,8 @@ end_with_restore_list:
|
||||
}
|
||||
|
||||
if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0,
|
||||
is_schema_db(lex->sphead->m_db.str)))
|
||||
is_schema_db(lex->sphead->m_db.str,
|
||||
lex->sphead->m_db.length)))
|
||||
goto create_sp_error;
|
||||
|
||||
if (end_active_trans(thd))
|
||||
@ -4858,7 +4864,8 @@ create_sp_error:
|
||||
res= mysql_xa_recover(thd);
|
||||
break;
|
||||
case SQLCOM_ALTER_TABLESPACE:
|
||||
if (check_access(thd, ALTER_ACL, thd->db, 0, 1, 0, thd->db ? is_schema_db(thd->db) : 0))
|
||||
if (check_access(thd, ALTER_ACL, thd->db, 0, 1, 0,
|
||||
thd->db ? is_schema_db(thd->db, thd->db_length) : 0))
|
||||
break;
|
||||
if (!(res= mysql_alter_tablespace(thd, lex->alter_tablespace_info)))
|
||||
my_ok(thd);
|
||||
@ -5297,7 +5304,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table)
|
||||
|
||||
if (check_access(thd, SELECT_ACL, dst_db_name,
|
||||
&thd->col_access, FALSE, FALSE,
|
||||
is_schema_db(dst_db_name)))
|
||||
is_schema_db(dst_db_name, strlen(dst_db_name))))
|
||||
return TRUE;
|
||||
|
||||
if (!thd->col_access && check_grant_db(thd, dst_db_name))
|
||||
@ -6262,8 +6269,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
ptr->force_index= test(table_options & TL_OPTION_FORCE_INDEX);
|
||||
ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES);
|
||||
ptr->derived= table->sel;
|
||||
if (!ptr->derived && !my_strcasecmp(system_charset_info, ptr->db,
|
||||
INFORMATION_SCHEMA_NAME.str))
|
||||
if (!ptr->derived && is_schema_db(ptr->db, ptr->db_length))
|
||||
{
|
||||
ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->table_name);
|
||||
if (!schema_table ||
|
||||
|
Reference in New Issue
Block a user