Commit abbb2016 authored by unknown's avatar unknown
Browse files

Post-review fixes for

Bug #18559 "log tables cannot change engine, and
            gets deadlocked when dropping w/ log on":
1) Add more generic error messages
2) Add new handlerton flag for engines, which support
   log tables
3) Remove (log-tables related) mutex lock in myisam to
   improve performance


mysql-test/r/log_tables.result:
  update result file to use new error messages
mysql-test/t/log_tables.test:
  update test file with new error messages
sql/handler.h:
  Add new handlerton flag, to mark whether engine
  supports log tables
sql/share/errmsg.txt:
  Add more generic error messages
sql/sql_table.cc:
  Update error messages
storage/csv/ha_tina.cc:
  CSV supports log tables
storage/myisam/ha_myisam.cc:
  MyISAM supports log tables
storage/myisam/mi_write.c:
  remove mutex lock to improve performance
parent d57163fc
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -73,16 +73,16 @@ select * from mysql.slow_log;
start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
TIMESTAMP	USER_HOST	QUERY_TIME	00:00:00	1	0	test	0	0	1	select sleep(2)
alter table mysql.general_log engine=myisam;
ERROR HY000: You can't alter a log table if logging is enabled
ERROR HY000: You cannot alter a log table if logging is enabled
alter table mysql.slow_log engine=myisam;
ERROR HY000: You can't alter a log table if logging is enabled
ERROR HY000: You cannot alter a log table if logging is enabled
drop table mysql.general_log;
ERROR HY000: Cannot drop log table if log is enabled
ERROR HY000: You cannot drop a log table if logging is enabled
drop table mysql.slow_log;
ERROR HY000: Cannot drop log table if log is enabled
ERROR HY000: You cannot drop a log table if logging is enabled
set global general_log='OFF';
alter table mysql.slow_log engine=myisam;
ERROR HY000: You can't alter a log table if logging is enabled
ERROR HY000: You cannot alter a log table if logging is enabled
set global slow_query_log='OFF';
show create table mysql.general_log;
Table	Create Table
@@ -173,13 +173,13 @@ unlock tables;
set global general_log='OFF';
set global slow_query_log='OFF';
alter table mysql.slow_log engine=ndb;
ERROR HY000: One can use only CSV and MyISAM engines for the log tables
ERROR HY000: This storage engine cannot be used for log tables"
alter table mysql.slow_log engine=innodb;
ERROR HY000: One can use only CSV and MyISAM engines for the log tables
ERROR HY000: This storage engine cannot be used for log tables"
alter table mysql.slow_log engine=archive;
ERROR HY000: One can use only CSV and MyISAM engines for the log tables
ERROR HY000: This storage engine cannot be used for log tables"
alter table mysql.slow_log engine=blackhole;
ERROR HY000: One can use only CSV and MyISAM engines for the log tables
ERROR HY000: This storage engine cannot be used for log tables"
drop table mysql.slow_log;
drop table mysql.general_log;
drop table mysql.general_log;
+9 −9
Original line number Diff line number Diff line
@@ -178,21 +178,21 @@ select * from mysql.slow_log;

# check that appropriate error messages are given when one attempts to alter
# or drop a log tables, while corresponding logs are enabled
--error ER_CANT_ALTER_LOG_TABLE
--error ER_BAD_LOG_STATEMENT
alter table mysql.general_log engine=myisam;
--error ER_CANT_ALTER_LOG_TABLE
--error ER_BAD_LOG_STATEMENT
alter table mysql.slow_log engine=myisam;

--error ER_CANT_DROP_LOG_TABLE
--error ER_BAD_LOG_STATEMENT
drop table mysql.general_log;
--error ER_CANT_DROP_LOG_TABLE
--error ER_BAD_LOG_STATEMENT
drop table mysql.slow_log;

# check that one can alter log tables to MyISAM
set global general_log='OFF';

# cannot convert another log table
--error ER_CANT_ALTER_LOG_TABLE
--error ER_BAD_LOG_STATEMENT
alter table mysql.slow_log engine=myisam;

# alter both tables
@@ -252,13 +252,13 @@ set global general_log='OFF';
set global slow_query_log='OFF';

# check that alter table doesn't work for other engines
--error ER_BAD_LOG_ENGINE
--error ER_UNSUPORTED_LOG_ENGINE
alter table mysql.slow_log engine=ndb;
--error ER_BAD_LOG_ENGINE
--error ER_UNSUPORTED_LOG_ENGINE
alter table mysql.slow_log engine=innodb;
--error ER_BAD_LOG_ENGINE
--error ER_UNSUPORTED_LOG_ENGINE
alter table mysql.slow_log engine=archive;
--error ER_BAD_LOG_ENGINE
--error ER_UNSUPORTED_LOG_ENGINE
alter table mysql.slow_log engine=blackhole;

drop table mysql.slow_log;
+1 −0
Original line number Diff line number Diff line
@@ -681,6 +681,7 @@ struct handlerton
#define HTON_FLUSH_AFTER_RENAME      (1 << 4)
#define HTON_NOT_USER_SELECTABLE     (1 << 5)
#define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported
#define HTON_SUPPORT_LOG_TABLES      (1 << 7) //Engine supports log tables

typedef struct st_thd_trans
{
+4 −0
Original line number Diff line number Diff line
@@ -5960,3 +5960,7 @@ ER_HOSTNAME
	eng "host name"
ER_WRONG_STRING_LENGTH
	eng "String '%-.70s' is too long for %s (should be no longer than %d)"
ER_UNSUPORTED_LOG_ENGINE
        eng "This storage engine cannot be used for log tables""
ER_BAD_LOG_STATEMENT
        eng "You cannot %s a log table if logging is enabled"
+4 −5
Original line number Diff line number Diff line
@@ -1628,7 +1628,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
         (!my_strcasecmp(system_charset_info, table->table_name, "slow_log")
          && opt_slow_log && logger.is_slow_log_table_enabled())))
    {
      my_error(ER_CANT_DROP_LOG_TABLE, MYF(0));
      my_error(ER_BAD_LOG_STATEMENT, MYF(0), "drop");
      DBUG_RETURN(1);
    }
  }
@@ -5174,7 +5174,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
       (table_kind == SLOW_LOG && opt_slow_log &&
         logger.is_slow_log_table_enabled()))
    {
      my_error(ER_CANT_ALTER_LOG_TABLE, MYF(0));
      my_error(ER_BAD_LOG_STATEMENT, MYF(0), "alter");
      DBUG_RETURN(TRUE);
    }

@@ -5182,10 +5182,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
    if ((table_kind == GENERAL_LOG || table_kind == SLOW_LOG) &&
        (lex_create_info->used_fields & HA_CREATE_USED_ENGINE) &&
        (!lex_create_info->db_type || /* unknown engine */
        !(lex_create_info->db_type->db_type == DB_TYPE_MYISAM ||
          lex_create_info->db_type->db_type == DB_TYPE_CSV_DB)))
        !(lex_create_info->db_type->flags & HTON_SUPPORT_LOG_TABLES)))
    {
      my_error(ER_BAD_LOG_ENGINE, MYF(0));
      my_error(ER_UNSUPORTED_LOG_ENGINE, MYF(0));
      DBUG_RETURN(TRUE);
    }
  }
Loading