Commit 05459903 authored by unknown's avatar unknown

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

into  janus.mylan:/usr/home/serg/Abk/mysql-5.1


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
parents 5713d2e0 1acc3441
...@@ -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,43 +2196,50 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2192,43 +2196,50 @@ 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",
opt_quoted_table); opt_quoted_table);
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"
Get first row, following loop will prepend comma - keeps "SET character_set_client = utf8;\n"
from having to know if the row being printed is last to "/*!50001 CREATE TABLE %s (\n",
determine if there should be a _trailing_ comma. result_table);
*/
row= mysql_fetch_row(result);
fprintf(sql_file, " %s %s", quote_name(row[0], name_buff, 0), /*
row[1]); Get first row, following loop will prepend comma - keeps from
having to know if the row being printed is last to determine if
there should be a _trailing_ comma.
*/
while((row= mysql_fetch_row(result))) row= mysql_fetch_row(result);
{
/* col name, col type */ fprintf(sql_file, " %s %s", quote_name(row[0], name_buff, 0),
fprintf(sql_file, ",\n %s %s", row[1]);
quote_name(row[0], name_buff, 0), row[1]);
} while((row= mysql_fetch_row(result)))
fprintf(sql_file, "\n) */;\n"); {
check_io(sql_file); /* col name, col type */
fprintf(sql_file, ",\n %s %s",
quote_name(row[0], name_buff, 0), row[1]);
} }
fprintf(sql_file,
"\n) */;\n"
"SET character_set_client = @saved_cs_client;\n");
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,10 +3837,15 @@ static my_bool dump_all_views_in_db(char *database) ...@@ -3813,10 +3837,15 @@ 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)); )
{ {
dynstr_append_checked(&query, quote_name(table, table_buff, 1)); char *end= strmov(afterdot, table);
dynstr_append_checked(&query, " READ /*!32311 LOCAL */,"); if (include_table(hash_key,end - hash_key))
{
numrows++;
dynstr_append_checked(&query, quote_name(table, table_buff, 1));
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");
...@@ -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)))
get_view_structure(table, database); {
char *end= strmov(afterdot, table);
if (include_table(hash_key, end - hash_key))
get_view_structure(table, database);
}
if (opt_xml) if (opt_xml)
{ {
fputs("</database>\n", md_result_file); fputs("</database>\n", md_result_file);
......
...@@ -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
......
...@@ -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 Reset flags and start Instance Monitor thread, which will start mysqld.
start_mysqld()
DESCRIPTION
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 @@ class Instance ...@@ -104,7 +104,7 @@ class Instance
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;
......
...@@ -1035,44 +1035,6 @@ class handler :public Sql_alloc ...@@ -1035,44 +1035,6 @@ class handler :public Sql_alloc
{ {
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();
......
...@@ -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,
...@@ -445,7 +519,8 @@ void mysql_lock_downgrade_write(THD *thd, TABLE *table, ...@@ -445,7 +519,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 +779,19 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, ...@@ -704,25 +779,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.
...@@ -212,6 +212,7 @@ class MYSQL_QUERY_LOG: public MYSQL_LOG ...@@ -212,6 +212,7 @@ class MYSQL_QUERY_LOG: public MYSQL_LOG
return open(generate_name(log_name, ".log", 0, buf), LOG_NORMAL, 0, return open(generate_name(log_name, ".log", 0, buf), LOG_NORMAL, 0,
WRITE_CACHE); WRITE_CACHE);
} }
private: private:
time_t last_time; time_t last_time;
}; };
...@@ -398,7 +399,7 @@ class Log_event_handler ...@@ -398,7 +399,7 @@ class Log_event_handler
const char *sql_text, uint sql_text_len)= 0; const char *sql_text, uint sql_text_len)= 0;
virtual bool log_error(enum loglevel level, const char *format, virtual bool log_error(enum loglevel level, const char *format,
va_list args)= 0; va_list args)= 0;
virtual bool log_general(time_t event_time, const char *user_host, virtual bool log_general(THD *thd, time_t event_time, const char *user_host,
uint user_host_len, int thread_id, uint user_host_len, int thread_id,
const char *command_type, uint command_type_len, const char *command_type, uint command_type_len,
const char *sql_text, uint sql_text_len, const char *sql_text, uint sql_text_len,
...@@ -412,27 +413,7 @@ int check_if_log_table(uint db_len, const char *db, uint table_name_len, ...@@ -412,27 +413,7 @@ int check_if_log_table(uint db_len, const char *db, uint table_name_len,
class Log_to_csv_event_handler: public Log_event_handler class Log_to_csv_event_handler: public Log_event_handler
{ {
/*
We create artificial THD for each of the logs. This is to avoid
locking issues: we don't want locks on the log tables reside in the
THD's of the query. The reason is the locking order and duration.
*/
THD *general_log_thd, *slow_log_thd;
/*
This is for the thread, which called tmp_close_log_tables. The thread
will be allowed to write-lock the log tables (as it explicitly disabled
logging). This is used for such operations as REPAIR, which require
exclusive lock on the log tables.
NOTE: there can be only one priviliged thread, as one should
lock logger with logger.lock() before calling tmp_close_log_tables().
So no other thread could get privileged status at the same time.
*/
THD *privileged_thread;
friend class LOGGER; friend class LOGGER;
TABLE_LIST general_log, slow_log;
private:
bool open_log_table(uint log_type);
public: public:
Log_to_csv_event_handler(); Log_to_csv_event_handler();
...@@ -447,18 +428,13 @@ class Log_to_csv_event_handler: public Log_event_handler ...@@ -447,18 +428,13 @@ class Log_to_csv_event_handler: public Log_event_handler
const char *sql_text, uint sql_text_len); const char *sql_text, uint sql_text_len);
virtual bool log_error(enum loglevel level, const char *format, virtual bool log_error(enum loglevel level, const char *format,
va_list args); va_list args);
virtual bool log_general(time_t event_time, const char *user_host, virtual bool log_general(THD *thd, time_t event_time, const char *user_host,
uint user_host_len, int thread_id, uint user_host_len, int thread_id,
const char *command_type, uint command_type_len, const char *command_type, uint command_type_len,
const char *sql_text, uint sql_text_len, const char *sql_text, uint sql_text_len,
CHARSET_INFO *client_cs); CHARSET_INFO *client_cs);
void tmp_close_log_tables(THD *thd);
void close_log_table(uint log_type, bool lock_in_use); int activate_log(THD *thd, uint log_type);
bool reopen_log_table(uint log_type);
THD* get_privileged_thread()
{
return privileged_thread;
}
}; };
...@@ -484,7 +460,7 @@ class Log_to_file_event_handler: public Log_event_handler ...@@ -484,7 +460,7 @@ class Log_to_file_event_handler: public Log_event_handler
const char *sql_text, uint sql_text_len); const char *sql_text, uint sql_text_len);
virtual bool log_error(enum loglevel level, const char *format, virtual bool log_error(enum loglevel level, const char *format,
va_list args); va_list args);
virtual bool log_general(time_t event_time, const char *user_host, virtual bool log_general(THD *thd, time_t event_time, const char *user_host,
uint user_host_len, int thread_id, uint user_host_len, int thread_id,
const char *command_type, uint command_type_len, const char *command_type, uint command_type_len,
const char *sql_text, uint sql_text_len, const char *sql_text, uint sql_text_len,
...@@ -499,7 +475,7 @@ class Log_to_file_event_handler: public Log_event_handler ...@@ -499,7 +475,7 @@ class Log_to_file_event_handler: public Log_event_handler
/* Class which manages slow, general and error log event handlers */ /* Class which manages slow, general and error log event handlers */
class LOGGER class LOGGER
{ {
pthread_mutex_t LOCK_logger; rw_lock_t LOCK_logger;
/* flag to check whether logger mutex is initialized */ /* flag to check whether logger mutex is initialized */
uint inited; uint inited;
...@@ -519,21 +495,10 @@ class LOGGER ...@@ -519,21 +495,10 @@ class LOGGER
LOGGER() : inited(0), table_log_handler(NULL), LOGGER() : inited(0), table_log_handler(NULL),
file_log_handler(NULL), is_log_tables_initialized(FALSE) file_log_handler(NULL), is_log_tables_initialized(FALSE)
{} {}
void lock() { (void) pthread_mutex_lock(&LOCK_logger); } void lock_shared() { rw_rdlock(&LOCK_logger); }
void unlock() { (void) pthread_mutex_unlock(&LOCK_logger); } void lock_exclusive() { rw_wrlock(&LOCK_logger); }
void tmp_close_log_tables(THD *thd); void unlock() { rw_unlock(&LOCK_logger); }
bool is_log_table_enabled(uint log_table_type) bool is_log_table_enabled(uint log_table_type);
{
switch (log_table_type) {
case QUERY_LOG_SLOW:
return table_log_handler && table_log_handler->slow_log.table != 0;
case QUERY_LOG_GENERAL:
return table_log_handler && table_log_handler->general_log.table != 0;
default:
DBUG_ASSERT(0);
return FALSE; /* make compiler happy */
}
}
/* /*
We want to initialize all log mutexes as soon as possible, We want to initialize all log mutexes as soon as possible,
but we cannot do it in constructor, as safe_mutex relies on but we cannot do it in constructor, as safe_mutex relies on
...@@ -543,20 +508,6 @@ class LOGGER ...@@ -543,20 +508,6 @@ class LOGGER
void init_base(); void init_base();
void init_log_tables(); void init_log_tables();
bool flush_logs(THD *thd); bool flush_logs(THD *thd);
THD *get_general_log_thd()
{
if (table_log_handler)
return (THD *) table_log_handler->general_log_thd;
else
return NULL;
}
THD *get_slow_log_thd()
{
if (table_log_handler)
return (THD *) table_log_handler->slow_log_thd;
else
return NULL;
}
/* Perform basic logger cleanup. this will leave e.g. error log open. */ /* Perform basic logger cleanup. this will leave e.g. error log open. */
void cleanup_base(); void cleanup_base();
/* Free memory. Nothing could be logged after this function is called */ /* Free memory. Nothing could be logged after this function is called */
...@@ -568,10 +519,6 @@ class LOGGER ...@@ -568,10 +519,6 @@ class LOGGER
bool general_log_print(THD *thd,enum enum_server_command command, bool general_log_print(THD *thd,enum enum_server_command command,
const char *format, va_list args); const char *format, va_list args);
void close_log_table(uint log_type, bool lock_in_use);
bool reopen_log_table(uint log_type);
bool reopen_log_tables();
/* we use this function to setup all enabled log event handlers */ /* we use this function to setup all enabled log event handlers */
int set_handlers(uint error_log_printer, int set_handlers(uint error_log_printer,
uint slow_log_printer, uint slow_log_printer,
...@@ -593,19 +540,6 @@ class LOGGER ...@@ -593,19 +540,6 @@ class LOGGER
return file_log_handler->get_mysql_log(); return file_log_handler->get_mysql_log();
return NULL; return NULL;
} }
THD* get_privileged_thread()
{
if (table_log_handler)
return table_log_handler->get_privileged_thread();
else
return NULL;
}
bool is_privileged_thread(THD *thd)
{
return thd == get_general_log_thd() ||
thd == get_slow_log_thd() ||
thd == get_privileged_thread();
}
}; };
enum enum_binlog_format { enum enum_binlog_format {
......
...@@ -944,6 +944,7 @@ void mysql_parse(THD *thd, const char *inBuf, uint length, ...@@ -944,6 +944,7 @@ void mysql_parse(THD *thd, const char *inBuf, uint length,
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length); bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
bool is_update_query(enum enum_sql_command command); bool is_update_query(enum enum_sql_command command);
bool is_log_table_write_query(enum enum_sql_command command);
bool alloc_query(THD *thd, const char *packet, uint packet_length); bool alloc_query(THD *thd, const char *packet, uint packet_length);
void mysql_init_select(LEX *lex); void mysql_init_select(LEX *lex);
void mysql_reset_thd_for_next_command(THD *thd); void mysql_reset_thd_for_next_command(THD *thd);
...@@ -1123,7 +1124,8 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, ...@@ -1123,7 +1124,8 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
uint key_length, uint db_flags, int *error); uint key_length, uint db_flags, int *error);
void release_table_share(TABLE_SHARE *share, enum release_type type); void release_table_share(TABLE_SHARE *share, enum release_type type);
TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name); TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update); TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
uint lock_flags);
TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT* mem, TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT* mem,
bool *refresh, uint flags); bool *refresh, uint flags);
bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list, bool link_in); bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list, bool link_in);
...@@ -1231,6 +1233,11 @@ void reset_status_vars(); ...@@ -1231,6 +1233,11 @@ void reset_status_vars();
/* information schema */ /* information schema */
extern LEX_STRING INFORMATION_SCHEMA_NAME; extern LEX_STRING INFORMATION_SCHEMA_NAME;
/* log tables */
extern LEX_STRING MYSQL_SCHEMA_NAME;
extern LEX_STRING GENERAL_LOG_NAME;
extern LEX_STRING SLOW_LOG_NAME;
extern const LEX_STRING partition_keywords[]; extern const LEX_STRING partition_keywords[];
ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name); ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name);
ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx); ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
...@@ -1557,6 +1564,10 @@ bool open_system_tables_for_read(THD *thd, TABLE_LIST *table_list, ...@@ -1557,6 +1564,10 @@ bool open_system_tables_for_read(THD *thd, TABLE_LIST *table_list,
void close_system_tables(THD *thd, Open_tables_state *backup); void close_system_tables(THD *thd, Open_tables_state *backup);
TABLE *open_system_table_for_update(THD *thd, TABLE_LIST *one_table); TABLE *open_system_table_for_update(THD *thd, TABLE_LIST *one_table);
TABLE *open_performance_schema_table(THD *thd, TABLE_LIST *one_table,
Open_tables_state *backup);
void close_performance_schema_table(THD *thd, Open_tables_state *backup);
bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables, bool have_lock = FALSE); bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables, bool have_lock = FALSE);
bool close_cached_connection_tables(THD *thd, bool wait_for_refresh, bool close_cached_connection_tables(THD *thd, bool wait_for_refresh,
LEX_STRING *connect_string, LEX_STRING *connect_string,
...@@ -1891,6 +1902,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, ...@@ -1891,6 +1902,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count,
#define MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN 0x0004 #define MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN 0x0004
#define MYSQL_OPEN_TEMPORARY_ONLY 0x0008 #define MYSQL_OPEN_TEMPORARY_ONLY 0x0008
#define MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY 0x0010 #define MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY 0x0010
#define MYSQL_LOCK_PERF_SCHEMA 0x0020
void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock);
void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock);
......
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;
......
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.
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