Commit 2914bad6 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.1

into  bodhi.(none):/opt/local/work/mysql-5.1-runtime


client/mysqldump.c:
  Auto merged
mysql-test/r/mysqldump.result:
  Auto merged
mysql-test/t/disabled.def:
  Auto merged
mysql-test/t/mysqldump.test:
  Auto merged
sql/handler.cc:
  Auto merged
sql/lock.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/table.cc:
  Auto merged
sql/table.h:
  Auto merged
mysql-test/include/mix1.inc:
  Manual merge.
mysql-test/r/innodb_mysql.result:
  Manual merge.
parents 5713d2e0 5404ba42
...@@ -2116,7 +2116,10 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2116,7 +2116,10 @@ static uint get_table_structure(char *table, char *db, char *table_type,
MYSQL_FIELD *field; MYSQL_FIELD *field;
my_snprintf(buff, sizeof(buff), "show create table %s", result_table); my_snprintf(buff, sizeof(buff), "show create table %s", result_table);
if (mysql_query_with_error_report(mysql, 0, buff))
if (switch_character_set_results(mysql, "binary") ||
mysql_query_with_error_report(mysql, &result, buff) ||
switch_character_set_results(mysql, default_charset))
DBUG_RETURN(0); DBUG_RETURN(0);
if (path) if (path)
...@@ -2147,7 +2150,6 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2147,7 +2150,6 @@ static uint get_table_structure(char *table, char *db, char *table_type,
check_io(sql_file); check_io(sql_file);
} }
result= mysql_store_result(mysql);
field= mysql_fetch_field_direct(result, 0); field= mysql_fetch_field_direct(result, 0);
if (strcmp(field->name, "View") == 0) if (strcmp(field->name, "View") == 0)
{ {
...@@ -2174,7 +2176,9 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2174,7 +2176,9 @@ static uint get_table_structure(char *table, char *db, char *table_type,
*/ */
my_snprintf(query_buff, sizeof(query_buff), my_snprintf(query_buff, sizeof(query_buff),
"SHOW FIELDS FROM %s", result_table); "SHOW FIELDS FROM %s", result_table);
if (mysql_query_with_error_report(mysql, 0, query_buff)) if (switch_character_set_results(mysql, "binary") ||
mysql_query_with_error_report(mysql, &result, query_buff) ||
switch_character_set_results(mysql, default_charset))
{ {
/* /*
View references invalid or privileged table/col/fun (err 1356), View references invalid or privileged table/col/fun (err 1356),
...@@ -2192,15 +2196,13 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2192,15 +2196,13 @@ static uint get_table_structure(char *table, char *db, char *table_type,
else else
my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR)); my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR));
if ((result= mysql_store_result(mysql)))
{
if (mysql_num_rows(result)) if (mysql_num_rows(result))
{ {
if (opt_drop) if (opt_drop)
{ {
/* /*
We have already dropped any table of the same name We have already dropped any table of the same name above, so
above, so here we just drop the view. here we just drop the view.
*/ */
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n", fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n",
...@@ -2208,12 +2210,18 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2208,12 +2210,18 @@ static uint get_table_structure(char *table, char *db, char *table_type,
check_io(sql_file); check_io(sql_file);
} }
fprintf(sql_file, "/*!50001 CREATE TABLE %s (\n", result_table); fprintf(sql_file,
"SET @saved_cs_client = @@character_set_client;\n"
"SET character_set_client = utf8;\n"
"/*!50001 CREATE TABLE %s (\n",
result_table);
/* /*
Get first row, following loop will prepend comma - keeps Get first row, following loop will prepend comma - keeps from
from having to know if the row being printed is last to having to know if the row being printed is last to determine if
determine if there should be a _trailing_ comma. there should be a _trailing_ comma.
*/ */
row= mysql_fetch_row(result); row= mysql_fetch_row(result);
fprintf(sql_file, " %s %s", quote_name(row[0], name_buff, 0), fprintf(sql_file, " %s %s", quote_name(row[0], name_buff, 0),
...@@ -2225,10 +2233,13 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2225,10 +2233,13 @@ static uint get_table_structure(char *table, char *db, char *table_type,
fprintf(sql_file, ",\n %s %s", fprintf(sql_file, ",\n %s %s",
quote_name(row[0], name_buff, 0), row[1]); quote_name(row[0], name_buff, 0), row[1]);
} }
fprintf(sql_file, "\n) */;\n"); fprintf(sql_file,
"\n) */;\n"
"SET character_set_client = @saved_cs_client;\n");
check_io(sql_file); check_io(sql_file);
} }
}
mysql_free_result(result); mysql_free_result(result);
if (path) if (path)
...@@ -2239,7 +2250,14 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2239,7 +2250,14 @@ static uint get_table_structure(char *table, char *db, char *table_type,
} }
row= mysql_fetch_row(result); row= mysql_fetch_row(result);
fprintf(sql_file, "%s;\n", row[1]);
fprintf(sql_file,
"SET @saved_cs_client = @@character_set_client;\n"
"SET character_set_client = utf8;\n"
"%s;\n"
"SET character_set_client = @saved_cs_client;\n",
row[1]);
check_io(sql_file); check_io(sql_file);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -3726,11 +3744,12 @@ static int dump_all_tables_in_db(char *database) ...@@ -3726,11 +3744,12 @@ static int dump_all_tables_in_db(char *database)
{ {
DYNAMIC_STRING query; DYNAMIC_STRING query;
init_dynamic_string_checked(&query, "LOCK TABLES ", 256, 1024); init_dynamic_string_checked(&query, "LOCK TABLES ", 256, 1024);
for (numrows= 0 ; (table= getTableName(1)) ; numrows++) for (numrows= 0 ; (table= getTableName(1)) ; )
{ {
char *end= strmov(afterdot, table); char *end= strmov(afterdot, table);
if (include_table(hash_key,end - hash_key)) if (include_table(hash_key,end - hash_key))
{ {
numrows++;
dynstr_append_checked(&query, quote_name(table, table_buff, 1)); dynstr_append_checked(&query, quote_name(table, table_buff, 1));
dynstr_append_checked(&query, " READ /*!32311 LOCAL */,"); dynstr_append_checked(&query, " READ /*!32311 LOCAL */,");
} }
...@@ -3804,6 +3823,11 @@ static my_bool dump_all_views_in_db(char *database) ...@@ -3804,6 +3823,11 @@ static my_bool dump_all_views_in_db(char *database)
char *table; char *table;
uint numrows; uint numrows;
char table_buff[NAME_LEN*2+3]; char table_buff[NAME_LEN*2+3];
char hash_key[2*NAME_LEN+2]; /* "db.tablename" */
char *afterdot;
afterdot= strmov(hash_key, database);
*afterdot++= '.';
if (init_dumping(database, init_dumping_views)) if (init_dumping(database, init_dumping_views))
return 1; return 1;
...@@ -3813,11 +3837,16 @@ static my_bool dump_all_views_in_db(char *database) ...@@ -3813,11 +3837,16 @@ static my_bool dump_all_views_in_db(char *database)
{ {
DYNAMIC_STRING query; DYNAMIC_STRING query;
init_dynamic_string_checked(&query, "LOCK TABLES ", 256, 1024); init_dynamic_string_checked(&query, "LOCK TABLES ", 256, 1024);
for (numrows= 0 ; (table= getTableName(1)); numrows++) for (numrows= 0 ; (table= getTableName(1)); )
{
char *end= strmov(afterdot, table);
if (include_table(hash_key,end - hash_key))
{ {
numrows++;
dynstr_append_checked(&query, quote_name(table, table_buff, 1)); dynstr_append_checked(&query, quote_name(table, table_buff, 1));
dynstr_append_checked(&query, " READ /*!32311 LOCAL */,"); dynstr_append_checked(&query, " READ /*!32311 LOCAL */,");
} }
}
if (numrows && mysql_real_query(mysql, query.str, query.length-1)) if (numrows && mysql_real_query(mysql, query.str, query.length-1))
DB_error(mysql, "when using LOCK TABLES"); DB_error(mysql, "when using LOCK TABLES");
/* We shall continue here, if --force was given */ /* We shall continue here, if --force was given */
...@@ -3830,7 +3859,11 @@ static my_bool dump_all_views_in_db(char *database) ...@@ -3830,7 +3859,11 @@ static my_bool dump_all_views_in_db(char *database)
/* We shall continue here, if --force was given */ /* We shall continue here, if --force was given */
} }
while ((table= getTableName(0))) while ((table= getTableName(0)))
{
char *end= strmov(afterdot, table);
if (include_table(hash_key, end - hash_key))
get_view_structure(table, database); get_view_structure(table, database);
}
if (opt_xml) if (opt_xml)
{ {
fputs("</database>\n", md_result_file); fputs("</database>\n", md_result_file);
......
...@@ -814,6 +814,38 @@ create table t1 (a int) engine=innodb; ...@@ -814,6 +814,38 @@ create table t1 (a int) engine=innodb;
alter table t1 alter a set default 1; alter table t1 alter a set default 1;
drop table t1; drop table t1;
--echo
--echo Bug#24918 drop table and lock / inconsistent between
--echo perm and temp tables
--echo
--echo Check transactional tables under LOCK TABLES
--echo
--disable_warnings
drop table if exists t24918, t24918_tmp, t24918_trans, t24918_trans_tmp,
t24918_access;
--enable_warnings
create table t24918_access (id int);
create table t24918 (id int) engine=myisam;
create temporary table t24918_tmp (id int) engine=myisam;
create table t24918_trans (id int) engine=innodb;
create temporary table t24918_trans_tmp (id int) engine=innodb;
lock table t24918 write, t24918_tmp write, t24918_trans write, t24918_trans_tmp write;
drop table t24918;
--error ER_TABLE_NOT_LOCKED
select * from t24918_access;
drop table t24918_trans;
--error ER_TABLE_NOT_LOCKED
select * from t24918_access;
drop table t24918_trans_tmp;
--error ER_TABLE_NOT_LOCKED
select * from t24918_access;
drop table t24918_tmp;
--error ER_TABLE_NOT_LOCKED
select * from t24918_access;
unlock tables;
drop table t24918_access;
# #
# Bug #28591: MySQL need not sort the records in case of ORDER BY # Bug #28591: MySQL need not sort the records in case of ORDER BY
# primary_key on InnoDB table # primary_key on InnoDB table
......
...@@ -1689,12 +1689,18 @@ DELETE FROM mysqltest2.log| ...@@ -1689,12 +1689,18 @@ DELETE FROM mysqltest2.log|
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */; CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest1`; USE `mysqltest1`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `log` ( CREATE TABLE `log` (
`msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL `msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`c` int(11) DEFAULT NULL `c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SET character_set_client = @saved_cs_client;
INSERT INTO `t1` VALUES (1),(0),(1); INSERT INTO `t1` VALUES (1),(0),(1);
ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ; ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ;
...@@ -1762,12 +1768,18 @@ ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ; ...@@ -1762,12 +1768,18 @@ ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */; CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest2`; USE `mysqltest2`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `log` ( CREATE TABLE `log` (
`msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL `msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`c` int(11) DEFAULT NULL `c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SET character_set_client = @saved_cs_client;
INSERT INTO `t1` VALUES (1),(0),(1); INSERT INTO `t1` VALUES (1),(0),(1);
ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ; ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ;
......
...@@ -1689,12 +1689,18 @@ DELETE FROM mysqltest2.log| ...@@ -1689,12 +1689,18 @@ DELETE FROM mysqltest2.log|
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */; CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest1`; USE `mysqltest1`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `log` ( CREATE TABLE `log` (
`msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL `msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`c` int(11) DEFAULT NULL `c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SET character_set_client = @saved_cs_client;
INSERT INTO `t1` VALUES (1),(0),(1); INSERT INTO `t1` VALUES (1),(0),(1);
ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ; ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ;
...@@ -1762,12 +1768,18 @@ ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ; ...@@ -1762,12 +1768,18 @@ ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */; CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest2`; USE `mysqltest2`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `log` ( CREATE TABLE `log` (
`msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL `msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`c` int(11) DEFAULT NULL `c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SET character_set_client = @saved_cs_client;
INSERT INTO `t1` VALUES (1),(0),(1); INSERT INTO `t1` VALUES (1),(0),(1);
ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ; ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ;
......
...@@ -611,3 +611,10 @@ id ev_nm ev_cnt ...@@ -611,3 +611,10 @@ id ev_nm ev_cnt
DROP TABLE event_log; DROP TABLE event_log;
SET GLOBAL event_scheduler = OFF; SET GLOBAL event_scheduler = OFF;
DROP DATABASE events_test; DROP DATABASE events_test;
SET GLOBAL event_scheduler= ON;
CREATE EVENT bug28641 ON SCHEDULE AT '2038.01.18 03:00:00'
DO BEGIN
SELECT 1;
END;|
SET GLOBAL event_scheduler= OFF;
DROP EVENT bug28641;
...@@ -37,9 +37,10 @@ log-slow-queries option_value ...@@ -37,9 +37,10 @@ log-slow-queries option_value
language option_value language option_value
character-sets-dir option_value character-sets-dir option_value
basedir option_value basedir option_value
shutdown-delay option_value
skip-stack-trace option_value skip-stack-trace option_value
skip-innodb option_value loose-skip-innodb option_value
skip-ndbcluster option_value loose-skip-ndbcluster option_value
nonguarded option_value nonguarded option_value
log-output option_value log-output option_value
SET mysqld2.server_id = 2; SET mysqld2.server_id = 2;
...@@ -57,9 +58,10 @@ log-slow-queries option_value ...@@ -57,9 +58,10 @@ log-slow-queries option_value
language option_value language option_value
character-sets-dir option_value character-sets-dir option_value
basedir option_value basedir option_value
shutdown-delay option_value
skip-stack-trace option_value skip-stack-trace option_value
skip-innodb option_value loose-skip-innodb option_value
skip-ndbcluster option_value loose-skip-ndbcluster option_value
nonguarded option_value nonguarded option_value
log-output option_value log-output option_value
server_id option_value server_id option_value
......
...@@ -814,6 +814,34 @@ drop table if exists t1; ...@@ -814,6 +814,34 @@ drop table if exists t1;
create table t1 (a int) engine=innodb; create table t1 (a int) engine=innodb;
alter table t1 alter a set default 1; alter table t1 alter a set default 1;
drop table t1; drop table t1;
Bug#24918 drop table and lock / inconsistent between
perm and temp tables
Check transactional tables under LOCK TABLES
drop table if exists t24918, t24918_tmp, t24918_trans, t24918_trans_tmp,
t24918_access;
create table t24918_access (id int);
create table t24918 (id int) engine=myisam;
create temporary table t24918_tmp (id int) engine=myisam;
create table t24918_trans (id int) engine=innodb;
create temporary table t24918_trans_tmp (id int) engine=innodb;
lock table t24918 write, t24918_tmp write, t24918_trans write, t24918_trans_tmp write;
drop table t24918;
select * from t24918_access;
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
drop table t24918_trans;
select * from t24918_access;
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
drop table t24918_trans_tmp;
select * from t24918_access;
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
drop table t24918_tmp;
select * from t24918_access;
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
unlock tables;
drop table t24918_access;
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY bkey (b)) ENGINE=InnoDB; CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY bkey (b)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,2),(3,2),(2,2),(4,2),(5,2),(6,2),(7,2),(8,2); INSERT INTO t1 VALUES (1,2),(3,2),(2,2),(4,2),(5,2),(6,2),(7,2),(8,2);
INSERT INTO t1 SELECT a + 8, 2 FROM t1; INSERT INTO t1 SELECT a + 8, 2 FROM t1;
......
...@@ -153,3 +153,25 @@ select * from mysql.general_log; ...@@ -153,3 +153,25 @@ select * from mysql.general_log;
event_time user_host thread_id server_id command_type argument event_time user_host thread_id server_id command_type argument
TIMESTAMP USER_HOST # 1 Query drop table t1 TIMESTAMP USER_HOST # 1 Query drop table t1
TIMESTAMP USER_HOST # 1 Query select * from mysql.general_log TIMESTAMP USER_HOST # 1 Query select * from mysql.general_log
SET @old_general_log_state = @@global.general_log;
SET @old_slow_log_state = @@global.slow_query_log;
SET GLOBAL general_log = ON;
SET GLOBAL slow_query_log = ON;
FLUSH TABLES WITH READ LOCK;
SET GLOBAL general_log = OFF;
SET GLOBAL slow_query_log = OFF;
UNLOCK TABLES;
FLUSH TABLES WITH READ LOCK;
SET GLOBAL general_log = ON;
SET GLOBAL slow_query_log = ON;
UNLOCK TABLES;
SET GLOBAL READ_ONLY = ON;
SET GLOBAL general_log = OFF;
SET GLOBAL slow_query_log = OFF;
SET GLOBAL READ_ONLY = OFF;
SET GLOBAL READ_ONLY = ON;
SET GLOBAL general_log = ON;
SET GLOBAL slow_query_log = ON;
SET GLOBAL READ_ONLY = OFF;
SET GLOBAL general_log = @old_general_log_state;
SET GLOBAL slow_query_log = @old_slow_log_state;
This diff is collapsed.
...@@ -93,55 +93,73 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l ...@@ -93,55 +93,73 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`; USE `test`;
DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t1`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `t2`; DROP TABLE IF EXISTS `t2`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t2` ( CREATE TABLE `t2` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */; /*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */; /*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `t3`; DROP TABLE IF EXISTS `t3`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t3` ( CREATE TABLE `t3` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1; ) ENGINE=MEMORY DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */; /*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */; /*!40000 ALTER TABLE `t3` ENABLE KEYS */;
DROP TABLE IF EXISTS `t4`; DROP TABLE IF EXISTS `t4`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t4` ( CREATE TABLE `t4` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1; ) ENGINE=MEMORY DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */; /*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */; /*!40000 ALTER TABLE `t4` ENABLE KEYS */;
DROP TABLE IF EXISTS `t5`; DROP TABLE IF EXISTS `t5`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t5` ( CREATE TABLE `t5` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1; ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */; /*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */; /*!40000 ALTER TABLE `t5` ENABLE KEYS */;
DROP TABLE IF EXISTS `t6`; DROP TABLE IF EXISTS `t6`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t6` ( CREATE TABLE `t6` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t6` DISABLE KEYS */; /*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
...@@ -172,55 +190,73 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l ...@@ -172,55 +190,73 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`; USE `test`;
DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t1`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `t2`; DROP TABLE IF EXISTS `t2`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t2` ( CREATE TABLE `t2` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */; /*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */; /*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `t3`; DROP TABLE IF EXISTS `t3`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t3` ( CREATE TABLE `t3` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1; ) ENGINE=MEMORY DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */; /*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */; /*!40000 ALTER TABLE `t3` ENABLE KEYS */;
DROP TABLE IF EXISTS `t4`; DROP TABLE IF EXISTS `t4`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t4` ( CREATE TABLE `t4` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1; ) ENGINE=MEMORY DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */; /*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */; /*!40000 ALTER TABLE `t4` ENABLE KEYS */;
DROP TABLE IF EXISTS `t5`; DROP TABLE IF EXISTS `t5`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t5` ( CREATE TABLE `t5` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1; ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */; /*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */; /*!40000 ALTER TABLE `t5` ENABLE KEYS */;
DROP TABLE IF EXISTS `t6`; DROP TABLE IF EXISTS `t6`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t6` ( CREATE TABLE `t6` (
`id` int(8) DEFAULT NULL, `id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL `name` varchar(32) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40000 ALTER TABLE `t6` DISABLE KEYS */; /*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
......
This diff is collapsed.
...@@ -99,9 +99,12 @@ INSERT INTO t1 VALUES (1), (2); ...@@ -99,9 +99,12 @@ INSERT INTO t1 VALUES (1), (2);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t1`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL `a` int(11) DEFAULT NULL
); );
SET character_set_client = @saved_cs_client;
LOCK TABLES `t1` WRITE; LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
...@@ -130,9 +133,12 @@ UNLOCK TABLES; ...@@ -130,9 +133,12 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t1`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL `a` int(11) DEFAULT NULL
); );
SET character_set_client = @saved_cs_client;
LOCK TABLES `t1` WRITE; LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
...@@ -161,9 +167,12 @@ UNLOCK TABLES; ...@@ -161,9 +167,12 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t1`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL `a` int(11) DEFAULT NULL
); );
SET character_set_client = @saved_cs_client;
LOCK TABLES `t1` WRITE; LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
......
...@@ -1850,61 +1850,57 @@ create procedure proc_1() flush tables; ...@@ -1850,61 +1850,57 @@ create procedure proc_1() flush tables;
flush tables; flush tables;
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0
select Host, User from mysql.user limit 0; select Host, User from mysql.user limit 0;
Host User Host User
select Host, Db from mysql.host limit 0; select Host, Db from mysql.host limit 0;
Host Db Host Db
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0 mysql slow_log 0 0
mysql host 0 0 mysql host 0 0
mysql user 0 0 mysql user 0 0
call proc_1(); call proc_1();
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0
select Host, User from mysql.user limit 0; select Host, User from mysql.user limit 0;
Host User Host User
select Host, Db from mysql.host limit 0; select Host, Db from mysql.host limit 0;
Host Db Host Db
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0 mysql slow_log 0 0
mysql host 0 0 mysql host 0 0
mysql user 0 0 mysql user 0 0
call proc_1(); call proc_1();
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0
select Host, User from mysql.user limit 0; select Host, User from mysql.user limit 0;
Host User Host User
select Host, Db from mysql.host limit 0; select Host, Db from mysql.host limit 0;
Host Db Host Db
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0 mysql slow_log 0 0
mysql host 0 0 mysql host 0 0
mysql user 0 0 mysql user 0 0
call proc_1(); call proc_1();
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0
select Host, User from mysql.user limit 0; select Host, User from mysql.user limit 0;
Host User Host User
select Host, Db from mysql.host limit 0; select Host, Db from mysql.host limit 0;
Host Db Host Db
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0 mysql slow_log 0 0
mysql host 0 0 mysql host 0 0
mysql user 0 0 mysql user 0 0
flush tables; flush tables;
...@@ -1922,54 +1918,50 @@ select Host, Db from mysql.host limit 0; ...@@ -1922,54 +1918,50 @@ select Host, Db from mysql.host limit 0;
Host Db Host Db
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0
mysql slow_log 1 0
mysql host 0 0
mysql user 0 0 mysql user 0 0
mysql general_log 0 0
mysql host 0 0
prepare abc from "flush tables"; prepare abc from "flush tables";
execute abc; execute abc;
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0
select Host, User from mysql.user limit 0; select Host, User from mysql.user limit 0;
Host User Host User
select Host, Db from mysql.host limit 0; select Host, Db from mysql.host limit 0;
Host Db Host Db
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0 mysql slow_log 0 0
mysql host 0 0 mysql host 0 0
mysql user 0 0 mysql user 0 0
execute abc; execute abc;
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0
select Host, User from mysql.user limit 0; select Host, User from mysql.user limit 0;
Host User Host User
select Host, Db from mysql.host limit 0; select Host, Db from mysql.host limit 0;
Host Db Host Db
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0 mysql slow_log 0 0
mysql host 0 0 mysql host 0 0
mysql user 0 0 mysql user 0 0
execute abc; execute abc;
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0
select Host, User from mysql.user limit 0; select Host, User from mysql.user limit 0;
Host User Host User
select Host, Db from mysql.host limit 0; select Host, Db from mysql.host limit 0;
Host Db Host Db
show open tables from mysql; show open tables from mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0 mysql slow_log 0 0
mysql host 0 0 mysql host 0 0
mysql user 0 0 mysql user 0 0
flush tables; flush tables;
......
...@@ -251,14 +251,13 @@ drop table t1; ...@@ -251,14 +251,13 @@ drop table t1;
flush tables; flush tables;
show open tables; show open tables;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0
create table t1(n int); create table t1(n int);
insert into t1 values (1); insert into t1 values (1);
show open tables; show open tables;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0 mysql slow_log 0 0
test t1 0 0 test t1 0 0
drop table t1; drop table t1;
create table t1 (a int not null, b VARCHAR(10), INDEX (b) ) AVG_ROW_LENGTH=10 CHECKSUM=1 COMMENT="test" ENGINE=MYISAM MIN_ROWS=10 MAX_ROWS=100 PACK_KEYS=1 DELAY_KEY_WRITE=1 ROW_FORMAT=fixed; create table t1 (a int not null, b VARCHAR(10), INDEX (b) ) AVG_ROW_LENGTH=10 CHECKSUM=1 COMMENT="test" ENGINE=MYISAM MIN_ROWS=10 MAX_ROWS=100 PACK_KEYS=1 DELAY_KEY_WRITE=1 ROW_FORMAT=fixed;
...@@ -672,24 +671,23 @@ SELECT 1 FROM mysql.db, mysql.proc, mysql.user, mysql.time_zone, mysql.time_zone ...@@ -672,24 +671,23 @@ SELECT 1 FROM mysql.db, mysql.proc, mysql.user, mysql.time_zone, mysql.time_zone
1 1
SHOW OPEN TABLES; SHOW OPEN TABLES;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql proc 0 0 mysql db 0 0
test urkunde 0 0 test urkunde 0 0
mysql time_zone 0 0 mysql time_zone 0 0
mysql db 0 0 mysql general_log 0 0
test txt1 0 0 test txt1 0 0
mysql slow_log 1 0 mysql proc 0 0
test tyt2 0 0 test tyt2 0 0
mysql general_log 1 0
mysql user 0 0 mysql user 0 0
mysql time_zone_name 0 0 mysql time_zone_name 0 0
SHOW OPEN TABLES FROM mysql; SHOW OPEN TABLES FROM mysql;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql proc 0 0
mysql time_zone 0 0
mysql db 0 0 mysql db 0 0
mysql slow_log 1 0 mysql time_zone 0 0
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 0 0
mysql user 0 0 mysql user 0 0
mysql proc 0 0
mysql time_zone_name 0 0 mysql time_zone_name 0 0
SHOW OPEN TABLES FROM mysql LIKE 'u%'; SHOW OPEN TABLES FROM mysql LIKE 'u%';
Database Table In_use Name_locked Database Table In_use Name_locked
...@@ -702,16 +700,15 @@ test tyt2 0 0 ...@@ -702,16 +700,15 @@ test tyt2 0 0
mysql time_zone_name 0 0 mysql time_zone_name 0 0
SHOW OPEN TABLES LIKE '%o%'; SHOW OPEN TABLES LIKE '%o%';
Database Table In_use Name_locked Database Table In_use Name_locked
mysql proc 0 0
mysql time_zone 0 0 mysql time_zone 0 0
mysql slow_log 1 0 mysql general_log 0 0
mysql general_log 1 0 mysql slow_log 0 0
mysql proc 0 0
mysql time_zone_name 0 0 mysql time_zone_name 0 0
FLUSH TABLES; FLUSH TABLES;
SHOW OPEN TABLES; SHOW OPEN TABLES;
Database Table In_use Name_locked Database Table In_use Name_locked
mysql general_log 1 0 mysql general_log 0 0
mysql slow_log 1 0
DROP TABLE txt1; DROP TABLE txt1;
DROP TABLE tyt2; DROP TABLE tyt2;
DROP TABLE urkunde; DROP TABLE urkunde;
...@@ -1148,6 +1145,26 @@ DROP TABLE t1; ...@@ -1148,6 +1145,26 @@ DROP TABLE t1;
DROP VIEW v1; DROP VIEW v1;
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP FUNCTION f1; DROP FUNCTION f1;
set names koi8r;
DROP DATABASE IF EXISTS mysqltest1;
CREATE DATABASE mysqltest1;
use mysqltest1;
CREATE TABLE t1(1 INT);
---> Dumping mysqltest1 to show_check.mysqltest1.sql
DROP DATABASE mysqltest1;
---> Restoring mysqltest1...
SHOW CREATE TABLE mysqltest1.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`1` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP DATABASE mysqltest1;
use test;
flush status; flush status;
show variables like "log_queries_not_using_indexes"; show variables like "log_queries_not_using_indexes";
Variable_name Value Variable_name Value
......
...@@ -289,4 +289,34 @@ create table t1 select f_bug22427() as i; ...@@ -289,4 +289,34 @@ create table t1 select f_bug22427() as i;
ERROR 42S01: Table 't1' already exists ERROR 42S01: Table 't1' already exists
drop table t1; drop table t1;
drop function f_bug22427; drop function f_bug22427;
#
# Bug #29929 LOCK TABLES does not pre-lock tables used in triggers of the locked tables
#
DROP table IF EXISTS t1,t2;
CREATE TABLE t1 (c1 INT);
CREATE TABLE t2 (c2 INT);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
BEGIN
UPDATE t2 SET c2= c2 + 1;
END//
# Take a table lock on t1.
# This should pre-lock t2 through the trigger.
LOCK TABLE t1 WRITE;
INSERT INTO t1 VALUES (3);
UNLOCK TABLES;
LOCK TABLE t1 READ;
INSERT INTO t2 values(4);
ERROR HY000: Table 't2' was not locked with LOCK TABLES
UNLOCK TABLES;
SELECT * FROM t1;
c1
1
3
SELECT * FROM t2;
c2
3
DROP TRIGGER t1_ai;
DROP TABLE t1, t2;
End of 5.0 tests End of 5.0 tests
flush status; flush status;
show status like 'Table_lock%'; show status like 'Table_lock%';
Variable_name Value Variable_name Value
Table_locks_immediate 0 Table_locks_immediate 1
Table_locks_waited 0 Table_locks_waited 0
select * from information_schema.session_status where variable_name like 'Table_lock%'; select * from information_schema.session_status where variable_name like 'Table_lock%';
VARIABLE_NAME VARIABLE_VALUE VARIABLE_NAME VARIABLE_VALUE
TABLE_LOCKS_IMMEDIATE 0 TABLE_LOCKS_IMMEDIATE 2
TABLE_LOCKS_WAITED 0 TABLE_LOCKS_WAITED 0
SET SQL_LOG_BIN=0; SET SQL_LOG_BIN=0;
drop table if exists t1; drop table if exists t1;
...@@ -18,11 +18,11 @@ update t1 set n = 3; ...@@ -18,11 +18,11 @@ update t1 set n = 3;
unlock tables; unlock tables;
show status like 'Table_lock%'; show status like 'Table_lock%';
Variable_name Value Variable_name Value
Table_locks_immediate 3 Table_locks_immediate 17
Table_locks_waited 1 Table_locks_waited 1
select * from information_schema.session_status where variable_name like 'Table_lock%'; select * from information_schema.session_status where variable_name like 'Table_lock%';
VARIABLE_NAME VARIABLE_VALUE VARIABLE_NAME VARIABLE_VALUE
TABLE_LOCKS_IMMEDIATE 3 TABLE_LOCKS_IMMEDIATE 18
TABLE_LOCKS_WAITED 1 TABLE_LOCKS_WAITED 1
drop table t1; drop table t1;
select 1; select 1;
...@@ -97,7 +97,7 @@ Variable_name Value ...@@ -97,7 +97,7 @@ Variable_name Value
Com_show_status 3 Com_show_status 3
show status like 'hand%write%'; show status like 'hand%write%';
Variable_name Value Variable_name Value
Handler_write 0 Handler_write 5
show status like '%tmp%'; show status like '%tmp%';
Variable_name Value Variable_name Value
Created_tmp_disk_tables 0 Created_tmp_disk_tables 0
...@@ -105,7 +105,7 @@ Created_tmp_files 0 ...@@ -105,7 +105,7 @@ Created_tmp_files 0
Created_tmp_tables 0 Created_tmp_tables 0
show status like 'hand%write%'; show status like 'hand%write%';
Variable_name Value Variable_name Value
Handler_write 0 Handler_write 7
show status like '%tmp%'; show status like '%tmp%';
Variable_name Value Variable_name Value
Created_tmp_disk_tables 0 Created_tmp_disk_tables 0
......
...@@ -19,6 +19,7 @@ im_instance_conf : Bug#20294 2007-05-30 alik Instance manager tests ...@@ -19,6 +19,7 @@ im_instance_conf : Bug#20294 2007-05-30 alik Instance manager tests
im_life_cycle : BUG#27851 Instance manager dies on ASSERT in ~Thread_registry() or from not being able to close a mysqld instance. im_life_cycle : BUG#27851 Instance manager dies on ASSERT in ~Thread_registry() or from not being able to close a mysqld instance.
im_instance_conf : BUG#28743 Instance manager generates warnings in test suite im_instance_conf : BUG#28743 Instance manager generates warnings in test suite
im_utils : BUG#28743 Instance manager generates warnings in test suite im_utils : BUG#28743 Instance manager generates warnings in test suite
concurrent_innodb : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences concurrent_innodb : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences
ctype_big5 : BUG#26711 2007-06-21 Lars Test has never worked on Double Whopper ctype_big5 : BUG#26711 2007-06-21 Lars Test has never worked on Double Whopper
......
...@@ -722,3 +722,18 @@ let $wait_condition= ...@@ -722,3 +722,18 @@ let $wait_condition=
--source include/wait_condition.inc --source include/wait_condition.inc
DROP DATABASE events_test; DROP DATABASE events_test;
#
# Bug#28641 CREATE EVENT with '2038.01.18 03:00:00' let server crash.
#
SET GLOBAL event_scheduler= ON;
DELIMITER |;
CREATE EVENT bug28641 ON SCHEDULE AT '2038.01.18 03:00:00'
DO BEGIN
SELECT 1;
END;|
DELIMITER ;|
SET GLOBAL event_scheduler= OFF;
DROP EVENT bug28641;
...@@ -126,6 +126,59 @@ drop table t1; ...@@ -126,6 +126,59 @@ drop table t1;
--replace_column 1 TIMESTAMP 2 USER_HOST 3 # --replace_column 1 TIMESTAMP 2 USER_HOST 3 #
select * from mysql.general_log; select * from mysql.general_log;
#
# Bug#29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
# a deadlock)
# save state
SET @old_general_log_state = @@global.general_log;
SET @old_slow_log_state = @@global.slow_query_log;
# Test ON->OFF transition under a GLOBAL READ LOCK
SET GLOBAL general_log = ON;
SET GLOBAL slow_query_log = ON;
FLUSH TABLES WITH READ LOCK;
SET GLOBAL general_log = OFF;
SET GLOBAL slow_query_log = OFF;
UNLOCK TABLES;
# Test OFF->ON transition under a GLOBAL READ LOCK
FLUSH TABLES WITH READ LOCK;
SET GLOBAL general_log = ON;
SET GLOBAL slow_query_log = ON;
UNLOCK TABLES;
# Test ON->OFF transition under a GLOBAL READ_ONLY
SET GLOBAL READ_ONLY = ON;
SET GLOBAL general_log = OFF;
SET GLOBAL slow_query_log = OFF;
SET GLOBAL READ_ONLY = OFF;
# Test OFF->ON transition under a GLOBAL READ_ONLY
SET GLOBAL READ_ONLY = ON;
SET GLOBAL general_log = ON;
SET GLOBAL slow_query_log = ON;
SET GLOBAL READ_ONLY = OFF;
# Restore state
SET GLOBAL general_log = @old_general_log_state;
SET GLOBAL slow_query_log = @old_slow_log_state;
--enable_ps_protocol --enable_ps_protocol
# #
......
This diff is collapsed.
...@@ -1698,6 +1698,63 @@ drop database mysqldump_test_db; ...@@ -1698,6 +1698,63 @@ drop database mysqldump_test_db;
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug26121.sql --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug26121.sql
--remove_file $MYSQLTEST_VARDIR/tmp/bug26121.sql --remove_file $MYSQLTEST_VARDIR/tmp/bug26121.sql
###########################################################################
--echo #
--echo # Bug #30027: mysqldump does not dump views properly.
--echo #
--echo
--echo # Cleanup.
--disable_warnings
DROP DATABASE IF EXISTS mysqldump_test_db;
--enable_warnings
--echo
--echo # Create objects.
CREATE DATABASE mysqldump_test_db;
set names koi8r;
CREATE VIEW mysqldump_test_db.v2 AS SELECT 1 AS 1;
CREATE VIEW mysqldump_test_db.v1 AS SELECT 1 FROM mysqldump_test_db.v2;
set names latin1;
--echo
--echo # Dump mysqldump_test_db to bug30027.sql.
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=latin1 --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30027.sql
--echo
--echo # Drop mysqldump_test_db.
DROP DATABASE mysqldump_test_db;
--echo
--echo # Restore mysqldump_test_db from bug30027.sql.
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug30027.sql
--echo
--echo # Check the view.
set names utf8;
SHOW CREATE VIEW mysqldump_test_db.v1;
SHOW CREATE VIEW mysqldump_test_db.v2;
set names latin1;
--echo
--echo # Cleanup.
DROP DATABASE mysqldump_test_db;
###########################################################################
--echo # --echo #
--echo # End of 5.1 tests --echo # End of 5.1 tests
--echo # --echo #
...@@ -2018,10 +2018,17 @@ delimiter ;| ...@@ -2018,10 +2018,17 @@ delimiter ;|
select func_1(), func_1(), func_1() from dual; select func_1(), func_1(), func_1() from dual;
drop function func_1; drop function func_1;
drop procedure proc_1; drop procedure proc_1;
# make the output deterministic:
# the order used in SHOW OPEN TABLES
# is too much implementation dependent
--disable_ps_protocol
flush tables; flush tables;
select Host, User from mysql.user limit 0; select Host, User from mysql.user limit 0;
select Host, Db from mysql.host limit 0; select Host, Db from mysql.host limit 0;
show open tables from mysql; show open tables from mysql;
--enable_ps_protocol
prepare abc from "flush tables"; prepare abc from "flush tables";
execute abc; execute abc;
show open tables from mysql; show open tables from mysql;
......
...@@ -438,6 +438,11 @@ drop table if exists t1; ...@@ -438,6 +438,11 @@ drop table if exists t1;
CREATE TABLE txt1(a int); CREATE TABLE txt1(a int);
CREATE TABLE tyt2(a int); CREATE TABLE tyt2(a int);
CREATE TABLE urkunde(a int); CREATE TABLE urkunde(a int);
# make the output deterministic:
# the order used in SHOW OPEN TABLES
# is too much implementation dependent
--disable_ps_protocol
FLUSH TABLES; FLUSH TABLES;
SELECT 1 FROM mysql.db, mysql.proc, mysql.user, mysql.time_zone, mysql.time_zone_name, txt1, tyt2, urkunde LIMIT 0; SELECT 1 FROM mysql.db, mysql.proc, mysql.user, mysql.time_zone, mysql.time_zone_name, txt1, tyt2, urkunde LIMIT 0;
SHOW OPEN TABLES; SHOW OPEN TABLES;
...@@ -447,6 +452,8 @@ SHOW OPEN TABLES LIKE 't%'; ...@@ -447,6 +452,8 @@ SHOW OPEN TABLES LIKE 't%';
SHOW OPEN TABLES LIKE '%o%'; SHOW OPEN TABLES LIKE '%o%';
FLUSH TABLES; FLUSH TABLES;
SHOW OPEN TABLES; SHOW OPEN TABLES;
--enable_ps_protocol
DROP TABLE txt1; DROP TABLE txt1;
DROP TABLE tyt2; DROP TABLE tyt2;
DROP TABLE urkunde; DROP TABLE urkunde;
...@@ -554,6 +561,10 @@ show status like 'slow_queries'; ...@@ -554,6 +561,10 @@ show status like 'slow_queries';
# FROM I_S. # FROM I_S.
# #
#
# Part 1: check that meta-data specifies not-binary character set.
#
# Ensure that all needed objects are dropped. # Ensure that all needed objects are dropped.
--disable_warnings --disable_warnings
...@@ -761,6 +772,59 @@ DROP VIEW v1; ...@@ -761,6 +772,59 @@ DROP VIEW v1;
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP FUNCTION f1; DROP FUNCTION f1;
#
# Part 2: check that table with non-latin1 characters are dumped/restored
# correctly.
#
# Ensure that all needed objects are dropped.
set names koi8r;
--disable_warnings
DROP DATABASE IF EXISTS mysqltest1;
--enable_warnings
# Create objects.
CREATE DATABASE mysqltest1;
use mysqltest1;
CREATE TABLE t1(1 INT);
# Check:
# - Dump mysqltest1;
--echo
--echo ---> Dumping mysqltest1 to show_check.mysqltest1.sql
--exec $MYSQL_DUMP --default-character-set=latin1 --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/show_check.mysqltest1.sql
# - Clean mysqltest1;
--echo
--echo
DROP DATABASE mysqltest1;
# - Restore mysqltest1;
--echo
--echo
--echo ---> Restoring mysqltest1...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/show_check.mysqltest1.sql
# - Check definition of the table.
SHOW CREATE TABLE mysqltest1.t1;
# Cleanup.
DROP DATABASE mysqltest1;
use test;
# #
# Bug #28808: log_queries_not_using_indexes variable dynamic change is ignored # Bug #28808: log_queries_not_using_indexes variable dynamic change is ignored
# #
......
...@@ -356,4 +356,35 @@ create table t1 select f_bug22427() as i; ...@@ -356,4 +356,35 @@ create table t1 select f_bug22427() as i;
drop table t1; drop table t1;
drop function f_bug22427; drop function f_bug22427;
--echo #
--echo # Bug #29929 LOCK TABLES does not pre-lock tables used in triggers of the locked tables
--echo #
--disable_warnings
DROP table IF EXISTS t1,t2;
--enable_warnings
CREATE TABLE t1 (c1 INT);
CREATE TABLE t2 (c2 INT);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
DELIMITER //;
CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
BEGIN
UPDATE t2 SET c2= c2 + 1;
END//
DELIMITER ;//
--echo # Take a table lock on t1.
--echo # This should pre-lock t2 through the trigger.
LOCK TABLE t1 WRITE;
INSERT INTO t1 VALUES (3);
UNLOCK TABLES;
LOCK TABLE t1 READ;
--error ER_TABLE_NOT_LOCKED
INSERT INTO t2 values(4);
UNLOCK TABLES;
SELECT * FROM t1;
SELECT * FROM t2;
DROP TRIGGER t1_ai;
DROP TABLE t1, t2;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -63,16 +63,21 @@ CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NUL ...@@ -63,16 +63,21 @@ CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NUL
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges'; CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
-- Create general_log if CSV is enabled.
delimiter ;; SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT, thread_id INTEGER, server_id INTEGER, command_type VARCHAR(64), argument MEDIUMTEXT) engine=CSV CHARACTER SET utf8 comment="General log"', 'SET @dummy = 0');
CREATE PROCEDURE create_general_log_table() BEGIN DECLARE is_csv_enabled int DEFAULT 0; SELECT @@have_csv = 'YES' INTO is_csv_enabled; IF (is_csv_enabled) THEN CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT, thread_id INTEGER, server_id INTEGER, command_type VARCHAR(64), argument MEDIUMTEXT) engine=CSV CHARACTER SET utf8 comment='General log'; END IF; END;;
CALL create_general_log_table();;
DROP PROCEDURE create_general_log_table;;
CREATE PROCEDURE create_slow_log_table() BEGIN DECLARE is_csv_enabled int DEFAULT 0; SELECT @@have_csv = 'YES' INTO is_csv_enabled; IF (is_csv_enabled) THEN CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512), last_insert_id INTEGER, insert_id INTEGER, server_id INTEGER, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment='Slow log'; END IF; END;; PREPARE stmt FROM @str;
CALL create_slow_log_table();; EXECUTE stmt;
DROP PROCEDURE create_slow_log_table;; DROP PREPARE stmt;
delimiter ;
-- Create slow_log if CSV is enabled.
SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512), last_insert_id INTEGER, insert_id INTEGER, server_id INTEGER, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log"', 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;
CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator int(10) NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events'; CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator int(10) NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
......
...@@ -403,6 +403,8 @@ void Guardian::init() ...@@ -403,6 +403,8 @@ void Guardian::init()
void Guardian::stop_instances() void Guardian::stop_instances()
{ {
static const int NUM_STOP_ATTEMPTS = 100;
Instance_map::Iterator instances_it(instance_map); Instance_map::Iterator instances_it(instance_map);
Instance *instance; Instance *instance;
...@@ -438,7 +440,34 @@ void Guardian::stop_instances() ...@@ -438,7 +440,34 @@ void Guardian::stop_instances()
/* Request mysqld to stop. */ /* Request mysqld to stop. */
instance->kill_mysqld(SIGTERM); bool instance_stopped= FALSE;
for (int cur_attempt= 0; cur_attempt < NUM_STOP_ATTEMPTS; ++cur_attempt)
{
if (!instance->kill_mysqld(SIGTERM))
{
instance_stopped= TRUE;
break;
}
if (!instance->is_active())
{
instance_stopped= TRUE;
break;
}
/* Sleep for 0.3 sec and check again. */
my_sleep(300000);
}
/*
Abort if we failed to stop mysqld instance. That should not happen,
but if it happened, we don't know what to do and prefer to have clear
failure with coredump.
*/
DBUG_ASSERT(instance_stopped);
instance->unlock(); instance->unlock();
} }
......
...@@ -524,24 +524,17 @@ bool Instance::init(const LEX_STRING *name_arg) ...@@ -524,24 +524,17 @@ bool Instance::init(const LEX_STRING *name_arg)
/** /**
Complete instance options initialization. @brief Complete instance options initialization.
SYNOPSIS @return Error status.
complete_initialization() @retval FALSE ok
@retval TRUE error
RETURN
FALSE - ok
TRUE - error
*/ */
bool Instance::complete_initialization() bool Instance::complete_initialization()
{ {
configured= ! options.complete_initialization(); configured= ! options.complete_initialization();
return FALSE; return !configured;
/*
TODO: return actual status (from
Instance_options::complete_initialization()) here.
*/
} }
/************************************************************************** /**************************************************************************
...@@ -644,25 +637,24 @@ bool Instance::is_mysqld_running() ...@@ -644,25 +637,24 @@ bool Instance::is_mysqld_running()
/** /**
Start mysqld. @brief Start mysqld.
SYNOPSIS
start_mysqld()
DESCRIPTION
Reset flags and start Instance Monitor thread, which will start mysqld. Reset flags and start Instance Monitor thread, which will start mysqld.
MT-NOTE: instance must be locked before calling the operation. @note Instance must be locked before calling the operation.
RETURN @return Error status code
FALSE - ok @retval FALSE Ok
TRUE - could not start instance @retval TRUE Could not start instance
*/ */
bool Instance::start_mysqld() bool Instance::start_mysqld()
{ {
Instance_monitor *instance_monitor; Instance_monitor *instance_monitor;
if (!configured)
return TRUE;
/* /*
Prepare instance to start Instance Monitor thread. Prepare instance to start Instance Monitor thread.
...@@ -779,7 +771,7 @@ bool Instance::stop_mysqld() ...@@ -779,7 +771,7 @@ bool Instance::stop_mysqld()
These operations should also be used in Guardian to manage instances. These operations should also be used in Guardian to manage instances.
*/ */
void Instance::kill_mysqld(int signum) bool Instance::kill_mysqld(int signum)
{ {
pid_t mysqld_pid= options.load_pid(); pid_t mysqld_pid= options.load_pid();
...@@ -788,7 +780,7 @@ void Instance::kill_mysqld(int signum) ...@@ -788,7 +780,7 @@ void Instance::kill_mysqld(int signum)
log_info("Instance '%s': no pid file to send a signal (%d).", log_info("Instance '%s': no pid file to send a signal (%d).",
(const char *) get_name()->str, (const char *) get_name()->str,
(int) signum); (int) signum);
return; return TRUE;
} }
log_info("Instance '%s': sending %d to %d...", log_info("Instance '%s': sending %d to %d...",
...@@ -800,7 +792,7 @@ void Instance::kill_mysqld(int signum) ...@@ -800,7 +792,7 @@ void Instance::kill_mysqld(int signum)
{ {
log_info("Instance '%s': kill() failed.", log_info("Instance '%s': kill() failed.",
(const char *) get_name()->str); (const char *) get_name()->str);
return; return TRUE;
} }
/* Kill suceeded */ /* Kill suceeded */
...@@ -812,6 +804,8 @@ void Instance::kill_mysqld(int signum) ...@@ -812,6 +804,8 @@ void Instance::kill_mysqld(int signum)
/* After sucessful hard kill the pidfile need to be removed */ /* After sucessful hard kill the pidfile need to be removed */
options.unlink_pidfile(); options.unlink_pidfile();
} }
return FALSE;
} }
......
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
bool start_mysqld(); bool start_mysqld();
bool stop_mysqld(); bool stop_mysqld();
void kill_mysqld(int signo); bool kill_mysqld(int signo);
void lock(); void lock();
void unlock(); void unlock();
......
...@@ -156,7 +156,8 @@ int Instance_options::get_default_option(char *result, size_t result_len, ...@@ -156,7 +156,8 @@ int Instance_options::get_default_option(char *result, size_t result_len,
goto err; goto err;
/* +2 eats first "--" from the option string (E.g. "--datadir") */ /* +2 eats first "--" from the option string (E.g. "--datadir") */
rc= parse_output_and_get_value((char*) cmd.buffer, option_name + 2, rc= parse_output_and_get_value((char*) cmd.buffer,
option_name + 2, strlen(option_name + 2),
result, result_len, GET_VALUE); result, result_len, GET_VALUE);
err: err:
return rc; return rc;
...@@ -194,8 +195,8 @@ bool Instance_options::fill_instance_version() ...@@ -194,8 +195,8 @@ bool Instance_options::fill_instance_version()
bzero(result, MAX_VERSION_LENGTH); bzero(result, MAX_VERSION_LENGTH);
if (parse_output_and_get_value((char*) cmd.buffer, "Ver", result, if (parse_output_and_get_value((char*) cmd.buffer, STRING_WITH_LEN("Ver"),
MAX_VERSION_LENGTH, GET_LINE)) result, MAX_VERSION_LENGTH, GET_LINE))
{ {
log_error("Failed to get version of '%s': unexpected output.", log_error("Failed to get version of '%s': unexpected output.",
(const char *) mysqld_path.str); (const char *) mysqld_path.str);
...@@ -206,8 +207,7 @@ bool Instance_options::fill_instance_version() ...@@ -206,8 +207,7 @@ bool Instance_options::fill_instance_version()
{ {
char *start; char *start;
/* chop the newline from the end of the version string */
result[strlen(result) - NEWLINE_LEN]= '\0';
/* trim leading whitespaces */ /* trim leading whitespaces */
start= result; start= result;
while (my_isspace(default_charset_info, *start)) while (my_isspace(default_charset_info, *start))
...@@ -255,7 +255,8 @@ bool Instance_options::fill_mysqld_real_path() ...@@ -255,7 +255,8 @@ bool Instance_options::fill_mysqld_real_path()
bzero(result, FN_REFLEN); bzero(result, FN_REFLEN);
if (parse_output_and_get_value((char*) cmd.buffer, "Usage: ", if (parse_output_and_get_value((char*) cmd.buffer,
STRING_WITH_LEN("Usage: "),
result, FN_REFLEN, result, FN_REFLEN,
GET_LINE)) GET_LINE))
{ {
......
...@@ -17,11 +17,17 @@ ...@@ -17,11 +17,17 @@
#include <my_global.h> #include <my_global.h>
#define GET_VALUE 1 enum enum_option_type
#define GET_LINE 2 {
GET_VALUE = 1,
GET_LINE
};
int parse_output_and_get_value(const char *command, const char *word, bool parse_output_and_get_value(const char *command,
char *result, size_t input_buffer_len, const char *option_name_str,
uint flag); uint option_name_length,
char *option_value_buf,
size_t option_value_buf_size,
enum_option_type option_type);
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H */ #endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H */
...@@ -48,11 +48,16 @@ typedef int pid_t; ...@@ -48,11 +48,16 @@ typedef int pid_t;
#define NEWLINE "\r\n" #define NEWLINE "\r\n"
#define NEWLINE_LEN 2 #define NEWLINE_LEN 2
const char CR = '\r';
const char LF = '\n';
#else /* ! __WIN__ */ #else /* ! __WIN__ */
#define NEWLINE "\n" #define NEWLINE "\n"
#define NEWLINE_LEN 1 #define NEWLINE_LEN 1
const char LF = '\n';
#endif /* __WIN__ */ #endif /* __WIN__ */
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PORTABILITY_H */ #endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PORTABILITY_H */
......
...@@ -64,11 +64,14 @@ Thread_registry::~Thread_registry() ...@@ -64,11 +64,14 @@ Thread_registry::~Thread_registry()
/* Check that no one uses the repository. */ /* Check that no one uses the repository. */
pthread_mutex_lock(&LOCK_thread_registry); pthread_mutex_lock(&LOCK_thread_registry);
if (head.next != &head) for (Thread_info *ti= head.next; ti != &head; ti= ti->next)
log_error("Not all threads died properly\n"); {
log_error("Thread_registry: unregistered thread: %lu.",
(unsigned long) ti->thread_id);
}
/* All threads must unregister */ /* All threads must unregister */
// Disabled assert temporarily - BUG#28030 DBUG_ASSERT(head.next == &head);
// DBUG_ASSERT(head.next == &head);
pthread_mutex_unlock(&LOCK_thread_registry); pthread_mutex_unlock(&LOCK_thread_registry);
pthread_cond_destroy(&COND_thread_registry_is_empty); pthread_cond_destroy(&COND_thread_registry_is_empty);
......
...@@ -979,17 +979,18 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table) ...@@ -979,17 +979,18 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
starts_null= table->field[ET_FIELD_STARTS]->is_null(); starts_null= table->field[ET_FIELD_STARTS]->is_null();
my_bool not_used= FALSE;
if (!starts_null) if (!starts_null)
{ {
table->field[ET_FIELD_STARTS]->get_date(&time, TIME_NO_ZERO_DATE); table->field[ET_FIELD_STARTS]->get_date(&time, TIME_NO_ZERO_DATE);
starts= sec_since_epoch_TIME(&time); starts= my_tz_OFFSET0->TIME_to_gmt_sec(&time,&not_used);
} }
ends_null= table->field[ET_FIELD_ENDS]->is_null(); ends_null= table->field[ET_FIELD_ENDS]->is_null();
if (!ends_null) if (!ends_null)
{ {
table->field[ET_FIELD_ENDS]->get_date(&time, TIME_NO_ZERO_DATE); table->field[ET_FIELD_ENDS]->get_date(&time, TIME_NO_ZERO_DATE);
ends= sec_since_epoch_TIME(&time); ends= my_tz_OFFSET0->TIME_to_gmt_sec(&time,&not_used);
} }
if (!table->field[ET_FIELD_INTERVAL_EXPR]->is_null()) if (!table->field[ET_FIELD_INTERVAL_EXPR]->is_null())
...@@ -1007,7 +1008,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table) ...@@ -1007,7 +1008,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
if (table->field[ET_FIELD_EXECUTE_AT]->get_date(&time, if (table->field[ET_FIELD_EXECUTE_AT]->get_date(&time,
TIME_NO_ZERO_DATE)) TIME_NO_ZERO_DATE))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
execute_at= sec_since_epoch_TIME(&time); execute_at= my_tz_OFFSET0->TIME_to_gmt_sec(&time,&not_used);
} }
/* /*
...@@ -1039,7 +1040,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table) ...@@ -1039,7 +1040,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
{ {
table->field[ET_FIELD_LAST_EXECUTED]->get_date(&time, table->field[ET_FIELD_LAST_EXECUTED]->get_date(&time,
TIME_NO_ZERO_DATE); TIME_NO_ZERO_DATE);
last_executed= sec_since_epoch_TIME(&time); last_executed= my_tz_OFFSET0->TIME_to_gmt_sec(&time,&not_used);
} }
last_executed_changed= FALSE; last_executed_changed= FALSE;
......
...@@ -250,7 +250,7 @@ mysql_event_fill_row(THD *thd, ...@@ -250,7 +250,7 @@ mysql_event_fill_row(THD *thd,
if (!et->starts_null) if (!et->starts_null)
{ {
MYSQL_TIME time; MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, et->starts); my_tz_OFFSET0->gmt_sec_to_TIME(&time, et->starts);
fields[ET_FIELD_STARTS]->set_notnull(); fields[ET_FIELD_STARTS]->set_notnull();
fields[ET_FIELD_STARTS]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); fields[ET_FIELD_STARTS]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
...@@ -259,7 +259,7 @@ mysql_event_fill_row(THD *thd, ...@@ -259,7 +259,7 @@ mysql_event_fill_row(THD *thd,
if (!et->ends_null) if (!et->ends_null)
{ {
MYSQL_TIME time; MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, et->ends); my_tz_OFFSET0->gmt_sec_to_TIME(&time, et->ends);
fields[ET_FIELD_ENDS]->set_notnull(); fields[ET_FIELD_ENDS]->set_notnull();
fields[ET_FIELD_ENDS]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); fields[ET_FIELD_ENDS]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
...@@ -278,7 +278,7 @@ mysql_event_fill_row(THD *thd, ...@@ -278,7 +278,7 @@ mysql_event_fill_row(THD *thd,
fields[ET_FIELD_ENDS]->set_null(); fields[ET_FIELD_ENDS]->set_null();
MYSQL_TIME time; MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, et->execute_at); my_tz_OFFSET0->gmt_sec_to_TIME(&time, et->execute_at);
fields[ET_FIELD_EXECUTE_AT]->set_notnull(); fields[ET_FIELD_EXECUTE_AT]->set_notnull();
fields[ET_FIELD_EXECUTE_AT]-> fields[ET_FIELD_EXECUTE_AT]->
...@@ -1004,7 +1004,7 @@ update_timing_fields_for_event(THD *thd, ...@@ -1004,7 +1004,7 @@ update_timing_fields_for_event(THD *thd,
if (update_last_executed) if (update_last_executed)
{ {
MYSQL_TIME time; MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, last_executed); my_tz_OFFSET0->gmt_sec_to_TIME(&time, last_executed);
fields[ET_FIELD_LAST_EXECUTED]->set_notnull(); fields[ET_FIELD_LAST_EXECUTED]->set_notnull();
fields[ET_FIELD_LAST_EXECUTED]->store_time(&time, fields[ET_FIELD_LAST_EXECUTED]->store_time(&time,
......
...@@ -740,7 +740,7 @@ Event_queue::dump_internal_status() ...@@ -740,7 +740,7 @@ Event_queue::dump_internal_status()
printf("WOC : %s\n", waiting_on_cond? "YES":"NO"); printf("WOC : %s\n", waiting_on_cond? "YES":"NO");
MYSQL_TIME time; MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, next_activation_at); my_tz_OFFSET0->gmt_sec_to_TIME(&time, next_activation_at);
if (time.year != 1970) if (time.year != 1970)
printf("Next activation : %04d-%02d-%02d %02d:%02d:%02d\n", printf("Next activation : %04d-%02d-%02d %02d:%02d:%02d\n",
time.year, time.month, time.day, time.hour, time.minute, time.second); time.year, time.month, time.day, time.hour, time.minute, time.second);
......
...@@ -1516,34 +1516,6 @@ THD *handler::ha_thd(void) const ...@@ -1516,34 +1516,6 @@ THD *handler::ha_thd(void) const
} }
bool handler::check_if_log_table_locking_is_allowed(uint sql_command,
ulong type, TABLE *table)
{
/*
Deny locking of the log tables, which is incompatible with
concurrent insert. The routine is not called if the table is
being locked from a logger THD (general_log_thd or slow_log_thd)
or from a privileged thread (see log.cc for details)
*/
if (table->s->log_table &&
sql_command != SQLCOM_TRUNCATE &&
sql_command != SQLCOM_ALTER_TABLE &&
!(sql_command == SQLCOM_FLUSH &&
type & REFRESH_LOG) &&
(table->reginfo.lock_type >= TL_READ_NO_INSERT))
{
/*
The check >= TL_READ_NO_INSERT denies all write locks
plus the only read lock (TL_READ_NO_INSERT itself)
*/
table->reginfo.lock_type == TL_READ_NO_INSERT ?
my_error(ER_CANT_READ_LOCK_LOG_TABLE, MYF(0)) :
my_error(ER_CANT_WRITE_LOCK_LOG_TABLE, MYF(0));
return FALSE;
}
return TRUE;
}
/** @brief /** @brief
Open database-handler. Open database-handler.
...@@ -3687,6 +3659,7 @@ int handler::ha_write_row(uchar *buf) ...@@ -3687,6 +3659,7 @@ int handler::ha_write_row(uchar *buf)
return 0; return 0;
} }
int handler::ha_update_row(const uchar *old_data, uchar *new_data) int handler::ha_update_row(const uchar *old_data, uchar *new_data)
{ {
int error; int error;
......
...@@ -992,6 +992,7 @@ public: ...@@ -992,6 +992,7 @@ public:
uint ref_length; uint ref_length;
FT_INFO *ft_handler; FT_INFO *ft_handler;
enum {NONE=0, INDEX, RND} inited; enum {NONE=0, INDEX, RND} inited;
bool locked;
bool implicit_emptied; /* Can be !=0 only if HEAP */ bool implicit_emptied; /* Can be !=0 only if HEAP */
const COND *pushed_cond; const COND *pushed_cond;
/* /*
...@@ -1022,11 +1023,13 @@ public: ...@@ -1022,11 +1023,13 @@ public:
estimation_rows_to_insert(0), ht(ht_arg), estimation_rows_to_insert(0), ht(ht_arg),
ref(0), key_used_on_scan(MAX_KEY), active_index(MAX_KEY), ref(0), key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
ref_length(sizeof(my_off_t)), ref_length(sizeof(my_off_t)),
ft_handler(0), inited(NONE), implicit_emptied(0), ft_handler(0), inited(NONE),
locked(FALSE), implicit_emptied(0),
pushed_cond(0), next_insert_id(0), insert_id_for_cur_row(0) pushed_cond(0), next_insert_id(0), insert_id_for_cur_row(0)
{} {}
virtual ~handler(void) virtual ~handler(void)
{ {
DBUG_ASSERT(locked == FALSE);
/* TODO: DBUG_ASSERT(inited == NONE); */ /* TODO: DBUG_ASSERT(inited == NONE); */
} }
virtual handler *clone(MEM_ROOT *mem_root); virtual handler *clone(MEM_ROOT *mem_root);
...@@ -1035,44 +1038,6 @@ public: ...@@ -1035,44 +1038,6 @@ public:
{ {
cached_table_flags= table_flags(); cached_table_flags= table_flags();
} }
/*
Check whether a handler allows to lock the table.
SYNOPSIS
check_if_locking_is_allowed()
thd Handler of the thread, trying to lock the table
table Table handler to check
count Total number of tables to be locked
current Index of the current table in the list of the tables
to be locked.
system_count Pointer to the counter of system tables seen thus
far.
called_by_privileged_thread TRUE if called from a logger THD
(general_log_thd or slow_log_thd)
or by a privileged thread, which
has the right to lock log tables.
DESCRIPTION
Check whether a handler allows to lock the table. For instance,
MyISAM does not allow to lock mysql.proc along with other tables.
This limitation stems from the fact that MyISAM does not support
row-level locking and we have to add this limitation to avoid
deadlocks.
RETURN
TRUE Locking is allowed
FALSE Locking is not allowed. The error was thrown.
*/
virtual bool check_if_locking_is_allowed(uint sql_command,
ulong type, TABLE *table,
uint count, uint current,
uint *system_count,
bool called_by_privileged_thread)
{
return TRUE;
}
bool check_if_log_table_locking_is_allowed(uint sql_command,
ulong type, TABLE *table);
int ha_open(TABLE *table, const char *name, int mode, int test_if_locked); int ha_open(TABLE *table, const char *name, int mode, int test_if_locked);
void adjust_next_insert_id_after_explicit_value(ulonglong nr); void adjust_next_insert_id_after_explicit_value(ulonglong nr);
int update_auto_increment(); int update_auto_increment();
...@@ -1629,8 +1594,10 @@ public: ...@@ -1629,8 +1594,10 @@ public:
/* lock_count() can be more than one if the table is a MERGE */ /* lock_count() can be more than one if the table is a MERGE */
virtual uint lock_count(void) const { return 1; } virtual uint lock_count(void) const { return 1; }
/* /**
NOTE that one can NOT rely on table->in_use in store_lock(). It may Is not invoked for non-transactional temporary tables.
@note that one can NOT rely on table->in_use in store_lock(). It may
refer to a different thread if called from mysql_lock_abort_for_thread(). refer to a different thread if called from mysql_lock_abort_for_thread().
*/ */
virtual THR_LOCK_DATA **store_lock(THD *thd, virtual THR_LOCK_DATA **store_lock(THD *thd,
...@@ -1761,6 +1728,29 @@ private: ...@@ -1761,6 +1728,29 @@ private:
overridden by the storage engine class. To call these methods, use overridden by the storage engine class. To call these methods, use
the corresponding 'ha_*' method above. the corresponding 'ha_*' method above.
*/ */
/**
Is not invoked for non-transactional temporary tables.
Tells the storage engine that we intend to read or write data
from the table. This call is prefixed with a call to handler::store_lock()
and is invoked only for those handler instances that stored the lock.
Calls to rnd_init/index_init are prefixed with this call. When table
IO is complete, we call external_lock(F_UNLCK).
A storage engine writer should expect that each call to
::external_lock(F_[RD|WR]LOCK is followed by a call to
::external_lock(F_UNLCK). If it is not, it is a bug in MySQL.
The name and signature originate from the first implementation
in MyISAM, which would call fcntl to set/clear an advisory
lock on the data file in this method.
@param lock_type F_RDLCK, F_WRLCK, F_UNLCK
@return non-0 in case of failure, 0 in case of success.
When lock_type is F_UNLCK, the return value is ignored.
*/
virtual int external_lock(THD *thd __attribute__((unused)), virtual int external_lock(THD *thd __attribute__((unused)),
int lock_type __attribute__((unused))) int lock_type __attribute__((unused)))
{ {
......
...@@ -116,16 +116,90 @@ static void print_lock_error(int error, const char *); ...@@ -116,16 +116,90 @@ static void print_lock_error(int error, const char *);
static int thr_lock_errno_to_mysql[]= static int thr_lock_errno_to_mysql[]=
{ 0, 1, ER_LOCK_WAIT_TIMEOUT, ER_LOCK_DEADLOCK }; { 0, 1, ER_LOCK_WAIT_TIMEOUT, ER_LOCK_DEADLOCK };
/**
Perform semantic checks for mysql_lock_tables.
@param thd The current thread
@param tables The tables to lock
@param count The number of tables to lock
@param flags Lock flags
@return 0 if all the check passed, non zero if a check failed.
*/
int mysql_lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags)
{
bool log_table_write_query;
uint system_count;
uint i;
DBUG_ENTER("mysql_lock_tables_check");
system_count= 0;
log_table_write_query= (is_log_table_write_query(thd->lex->sql_command)
|| ((flags & MYSQL_LOCK_PERF_SCHEMA) != 0));
for (i=0 ; i<count; i++)
{
TABLE *t= tables[i];
/* Protect against 'fake' partially initialized TABLE_SHARE */
DBUG_ASSERT(t->s->table_category != TABLE_UNKNOWN_CATEGORY);
/*
Table I/O to performance schema tables is performed
only internally by the server implementation.
When a user is requesting a lock, the following
constraints are enforced:
*/
if (t->s->require_write_privileges() &&
! log_table_write_query)
{
/*
A user should not be able to prevent writes,
or hold any type of lock in a session,
since this would be a DOS attack.
*/
if ((t->reginfo.lock_type >= TL_READ_NO_INSERT)
|| (thd->lex->sql_command == SQLCOM_LOCK_TABLES))
{
my_error(ER_CANT_LOCK_LOG_TABLE, MYF(0));
DBUG_RETURN(1);
}
}
if ((t->s->table_category == TABLE_CATEGORY_SYSTEM) &&
(t->reginfo.lock_type >= TL_WRITE_ALLOW_WRITE))
{
system_count++;
}
}
/*
Locking of system tables is restricted:
locking a mix of system and non-system tables in the same lock
is prohibited, to prevent contention.
*/
if ((system_count > 0) && (system_count < count))
{
my_error(ER_WRONG_LOCK_OF_SYSTEM_TABLE, MYF(0));
DBUG_RETURN(1);
}
DBUG_RETURN(0);
}
MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
uint flags, bool *need_reopen) uint flags, bool *need_reopen)
{ {
MYSQL_LOCK *sql_lock; MYSQL_LOCK *sql_lock;
TABLE *write_lock_used; TABLE *write_lock_used;
int rc; int rc;
DBUG_ENTER("mysql_lock_tables"); DBUG_ENTER("mysql_lock_tables");
*need_reopen= FALSE; *need_reopen= FALSE;
if (mysql_lock_tables_check(thd, tables, count, flags))
DBUG_RETURN (NULL);
for (;;) for (;;)
{ {
if (! (sql_lock= get_lock_data(thd, tables, count, GET_LOCK_STORE_LOCKS, if (! (sql_lock= get_lock_data(thd, tables, count, GET_LOCK_STORE_LOCKS,
...@@ -175,7 +249,8 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, ...@@ -175,7 +249,8 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
thd->proc_info="System lock"; thd->proc_info="System lock";
DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info)); DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info));
if (lock_external(thd, tables, count)) if (sql_lock->table_count && lock_external(thd, sql_lock->table,
sql_lock->table_count))
{ {
/* Clear the lock type of all lock data to avoid reusage. */ /* Clear the lock type of all lock data to avoid reusage. */
reset_lock_data(sql_lock); reset_lock_data(sql_lock);
...@@ -271,6 +346,7 @@ static int lock_external(THD *thd, TABLE **tables, uint count) ...@@ -271,6 +346,7 @@ static int lock_external(THD *thd, TABLE **tables, uint count)
((*tables)->reginfo.lock_type >= TL_READ && ((*tables)->reginfo.lock_type >= TL_READ &&
(*tables)->reginfo.lock_type <= TL_READ_NO_INSERT)) (*tables)->reginfo.lock_type <= TL_READ_NO_INSERT))
lock_type=F_RDLCK; lock_type=F_RDLCK;
if ((error=(*tables)->file->ha_external_lock(thd,lock_type))) if ((error=(*tables)->file->ha_external_lock(thd,lock_type)))
{ {
print_lock_error(error, (*tables)->file->table_type()); print_lock_error(error, (*tables)->file->table_type());
...@@ -379,10 +455,28 @@ void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock) ...@@ -379,10 +455,28 @@ void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock)
} }
/**
Try to find the table in the list of locked tables.
In case of success, unlock the table and remove it from this list.
@note This function has a legacy side effect: the table is
unlocked even if it is not found in the locked list.
It's not clear if this side effect is intentional or still
desirable. It might lead to unmatched calls to
unlock_external(). Moreover, a discrepancy can be left
unnoticed by the storage engine, because in
unlock_external() we call handler::external_lock(F_UNLCK) only
if table->current_lock is not F_UNLCK.
@param always_unlock specify explicitly if the legacy side
effect is desired.
*/
void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table) void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table,
bool always_unlock)
{ {
mysql_unlock_some_tables(thd, &table,1); if (always_unlock == TRUE)
mysql_unlock_some_tables(thd, &table, /* table count */ 1);
if (locked) if (locked)
{ {
reg1 uint i; reg1 uint i;
...@@ -396,6 +490,10 @@ void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table) ...@@ -396,6 +490,10 @@ void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table)
DBUG_ASSERT(table->lock_position == i); DBUG_ASSERT(table->lock_position == i);
/* Unlock if not yet unlocked */
if (always_unlock == FALSE)
mysql_unlock_some_tables(thd, &table, /* table count */ 1);
/* Decrement table_count in advance, making below expressions easier */ /* Decrement table_count in advance, making below expressions easier */
old_tables= --locked->table_count; old_tables= --locked->table_count;
...@@ -445,7 +543,8 @@ void mysql_lock_downgrade_write(THD *thd, TABLE *table, ...@@ -445,7 +543,8 @@ void mysql_lock_downgrade_write(THD *thd, TABLE *table,
{ {
MYSQL_LOCK *locked; MYSQL_LOCK *locked;
TABLE *write_lock_used; TABLE *write_lock_used;
if ((locked = get_lock_data(thd,&table,1,1,&write_lock_used))) if ((locked = get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK,
&write_lock_used)))
{ {
for (uint i=0; i < locked->lock_count; i++) for (uint i=0; i < locked->lock_count; i++)
thr_downgrade_write_lock(locked->locks[i], new_lock_type); thr_downgrade_write_lock(locked->locks[i], new_lock_type);
...@@ -704,25 +803,19 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, ...@@ -704,25 +803,19 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
TABLE **to, **table_buf; TABLE **to, **table_buf;
DBUG_ENTER("get_lock_data"); DBUG_ENTER("get_lock_data");
DBUG_ASSERT((flags == GET_LOCK_UNLOCK) || (flags == GET_LOCK_STORE_LOCKS));
DBUG_PRINT("info", ("count %d", count)); DBUG_PRINT("info", ("count %d", count));
*write_lock_used=0; *write_lock_used=0;
uint system_count= 0;
for (i=tables=lock_count=0 ; i < count ; i++) for (i=tables=lock_count=0 ; i < count ; i++)
{ {
if (table_ptr[i]->s->tmp_table != NON_TRANSACTIONAL_TMP_TABLE) TABLE *t= table_ptr[i];
if (t->s->tmp_table != NON_TRANSACTIONAL_TMP_TABLE)
{ {
tables+=table_ptr[i]->file->lock_count(); tables+= t->file->lock_count();
lock_count++; lock_count++;
} }
/*
Check if we can lock the table. For some tables we cannot do that
beacause of handler-specific locking issues.
*/
if (!table_ptr[i]-> file->
check_if_locking_is_allowed(thd->lex->sql_command, thd->lex->type,
table_ptr[i], count, i, &system_count,
logger.is_privileged_thread(thd)))
DBUG_RETURN(0);
} }
/* /*
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -5936,8 +5936,8 @@ ER_WARN_DEPRECATED_SYNTAX_WITH_VER ...@@ -5936,8 +5936,8 @@ ER_WARN_DEPRECATED_SYNTAX_WITH_VER
ER_CANT_WRITE_LOCK_LOG_TABLE ER_CANT_WRITE_LOCK_LOG_TABLE
eng "You can't write-lock a log table. Only read access is possible" eng "You can't write-lock a log table. Only read access is possible"
ger "Eine Log-Tabelle kann nicht schreibgesperrt werden. Es ist ohnehin nur Lesezugriff mglich" ger "Eine Log-Tabelle kann nicht schreibgesperrt werden. Es ist ohnehin nur Lesezugriff mglich"
ER_CANT_READ_LOCK_LOG_TABLE ER_CANT_LOCK_LOG_TABLE
eng "You can't use usual read lock with log tables. Try READ LOCAL instead" eng "You can't use locks with log tables."
ger "Log-Tabellen knnen nicht mit normalen Lesesperren gesperrt werden. Verwenden Sie statt dessen READ LOCAL" ger "Log-Tabellen knnen nicht mit normalen Lesesperren gesperrt werden. Verwenden Sie statt dessen READ LOCAL"
ER_FOREIGN_DUPLICATE_KEY 23000 S1009 ER_FOREIGN_DUPLICATE_KEY 23000 S1009
eng "Upholding foreign key constraints for table '%.192s', entry '%-.192s', key %d would lead to a duplicate entry" eng "Upholding foreign key constraints for table '%.192s', entry '%-.192s', key %d would lead to a duplicate entry"
......
...@@ -977,7 +977,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, ...@@ -977,7 +977,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
thd->proc_info = "Opening master dump table"; thd->proc_info = "Opening master dump table";
tables.lock_type = TL_WRITE; tables.lock_type = TL_WRITE;
if (!open_ltable(thd, &tables, TL_WRITE)) if (!open_ltable(thd, &tables, TL_WRITE, 0))
{ {
sql_print_error("create_table_from_dump: could not open created table"); sql_print_error("create_table_from_dump: could not open created table");
goto err; goto err;
......
...@@ -406,7 +406,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) ...@@ -406,7 +406,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp)
if ((ret= db_find_routine_aux(thd, type, name, table)) != SP_OK) if ((ret= db_find_routine_aux(thd, type, name, table)) != SP_OK)
goto done; goto done;
if (table->s->fields != MYSQL_PROC_FIELD_COUNT) if (table->s->fields < MYSQL_PROC_FIELD_COUNT)
{ {
ret= SP_GET_FIELD_FAILED; ret= SP_GET_FIELD_FAILED;
goto done; goto done;
...@@ -695,7 +695,7 @@ sp_create_routine(THD *thd, int type, sp_head *sp) ...@@ -695,7 +695,7 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
strxnmov(definer, sizeof(definer)-1, thd->lex->definer->user.str, "@", strxnmov(definer, sizeof(definer)-1, thd->lex->definer->user.str, "@",
thd->lex->definer->host.str, NullS); thd->lex->definer->host.str, NullS);
if (table->s->fields != MYSQL_PROC_FIELD_COUNT) if (table->s->fields < MYSQL_PROC_FIELD_COUNT)
{ {
ret= SP_GET_FIELD_FAILED; ret= SP_GET_FIELD_FAILED;
goto done; goto done;
...@@ -1067,7 +1067,7 @@ sp_show_status_routine(THD *thd, int type, const char *name_pattern) ...@@ -1067,7 +1067,7 @@ sp_show_status_routine(THD *thd, int type, const char *name_pattern)
tables.db= (char*)"mysql"; tables.db= (char*)"mysql";
tables.table_name= tables.alias= (char*)"proc"; tables.table_name= tables.alias= (char*)"proc";
if (! (table= open_ltable(thd, &tables, TL_READ))) if (! (table= open_ltable(thd, &tables, TL_READ, 0)))
{ {
res= SP_OPEN_TABLE_FAILED; res= SP_OPEN_TABLE_FAILED;
goto done; goto done;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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