WL#2360 Performance schema

Part IV: sql instrumentation
This commit is contained in:
Marc Alff 2010-01-06 22:42:07 -07:00
parent b2b055034c
commit a4c3bc618b
133 changed files with 5198 additions and 2295 deletions

View File

@ -101,7 +101,7 @@ enum options_client
/** /**
First mysql version supporting the performance schema. First mysql version supporting the performance schema.
*/ */
#define FIRST_PERFORMANCE_SCHEMA_VERSION 50600 #define FIRST_PERFORMANCE_SCHEMA_VERSION 50599
/** /**
Name of the performance schema database. Name of the performance schema database.

View File

@ -501,7 +501,19 @@ int init_embedded_server(int argc, char **argv, char **groups)
*/ */
logger.init_base(); logger.init_base();
if (init_common_variables("my", *argcp, *argvp, (const char **)groups)) orig_argc= *argcp;
orig_argv= *argvp;
load_defaults("my", (const char **)groups, argcp, argvp);
defaults_argc= *argcp;
defaults_argv= *argvp;
remaining_argc= argc;
remaining_argv= argv;
/* Must be initialized early for comparison of options name */
system_charset_info= &my_charset_utf8_general_ci;
sys_var_init();
if (init_common_variables())
{ {
mysql_server_end(); mysql_server_end();
return 1; return 1;

View File

@ -0,0 +1,20 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
if (!`SELECT count(*) FROM information_schema.engines WHERE
(support = 'YES' OR support = 'DEFAULT') AND
engine = 'PERFORMANCE_SCHEMA'`){
skip Need performance schema compiled in;
}

View File

@ -1,12 +1,14 @@
create table t1 (test_name text); create table t1 (test_name text);
create table t2 (variable_name text);
load data infile "MYSQLTEST_VARDIR/tmp/sys_vars.all_vars.txt" into table t1; load data infile "MYSQLTEST_VARDIR/tmp/sys_vars.all_vars.txt" into table t1;
select variable_name as `There should be *no* variables listed below:` insert into t2 select variable_name from information_schema.global_variables;
from information_schema.global_variables insert into t2 select variable_name from information_schema.session_variables;
left join t1 on variable_name=test_name where update t2 set variable_name= replace(variable_name, "PERFORMANCE_SCHEMA_", "PFS_");
test_name is null select variable_name as `There should be *no* long test name listed below:` from t2
union where length(variable_name) > 50;
select variable_name from information_schema.session_variables There should be *no* long test name listed below:
left join t1 on variable_name=test_name where select variable_name as `There should be *no* variables listed below:` from t2
test_name is null; left join t1 on variable_name=test_name where test_name is null;
There should be *no* variables listed below: There should be *no* variables listed below:
drop table t1; drop table t1;
drop table t2;

View File

@ -0,0 +1,23 @@
select @@global.performance_schema;
@@global.performance_schema
1
select @@session.performance_schema;
ERROR HY000: Variable 'performance_schema' is a GLOBAL variable
show global variables like 'performance_schema';
Variable_name Value
performance_schema ON
show session variables like 'performance_schema';
Variable_name Value
performance_schema ON
select * from information_schema.global_variables
where variable_name='performance_schema';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA ON
select * from information_schema.session_variables
where variable_name='performance_schema';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA ON
set global performance_schema=1;
ERROR HY000: Variable 'performance_schema' is a read only variable
set session performance_schema=1;
ERROR HY000: Variable 'performance_schema' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_events_waits_history_long_size;
@@global.performance_schema_events_waits_history_long_size
15000
select @@session.performance_schema_events_waits_history_long_size;
ERROR HY000: Variable 'performance_schema_events_waits_history_long_size' is a GLOBAL variable
show global variables like 'performance_schema_events_waits_history_long_size';
Variable_name Value
performance_schema_events_waits_history_long_size 15000
show session variables like 'performance_schema_events_waits_history_long_size';
Variable_name Value
performance_schema_events_waits_history_long_size 15000
select * from information_schema.global_variables
where variable_name='performance_schema_events_waits_history_long_size';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_LONG_SIZE 15000
select * from information_schema.session_variables
where variable_name='performance_schema_events_waits_history_long_size';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_LONG_SIZE 15000
set global performance_schema_events_waits_history_long_size=1;
ERROR HY000: Variable 'performance_schema_events_waits_history_long_size' is a read only variable
set session performance_schema_events_waits_history_long_size=1;
ERROR HY000: Variable 'performance_schema_events_waits_history_long_size' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_events_waits_history_size;
@@global.performance_schema_events_waits_history_size
15
select @@session.performance_schema_events_waits_history_size;
ERROR HY000: Variable 'performance_schema_events_waits_history_size' is a GLOBAL variable
show global variables like 'performance_schema_events_waits_history_size';
Variable_name Value
performance_schema_events_waits_history_size 15
show session variables like 'performance_schema_events_waits_history_size';
Variable_name Value
performance_schema_events_waits_history_size 15
select * from information_schema.global_variables
where variable_name='performance_schema_events_waits_history_size';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_SIZE 15
select * from information_schema.session_variables
where variable_name='performance_schema_events_waits_history_size';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_SIZE 15
set global performance_schema_events_waits_history_size=1;
ERROR HY000: Variable 'performance_schema_events_waits_history_size' is a read only variable
set session performance_schema_events_waits_history_size=1;
ERROR HY000: Variable 'performance_schema_events_waits_history_size' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_cond_classes;
@@global.performance_schema_max_cond_classes
123
select @@session.performance_schema_max_cond_classes;
ERROR HY000: Variable 'performance_schema_max_cond_classes' is a GLOBAL variable
show global variables like 'performance_schema_max_cond_classes';
Variable_name Value
performance_schema_max_cond_classes 123
show session variables like 'performance_schema_max_cond_classes';
Variable_name Value
performance_schema_max_cond_classes 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_cond_classes';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_COND_CLASSES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_cond_classes';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_COND_CLASSES 123
set global performance_schema_max_cond_classes=1;
ERROR HY000: Variable 'performance_schema_max_cond_classes' is a read only variable
set session performance_schema_max_cond_classes=1;
ERROR HY000: Variable 'performance_schema_max_cond_classes' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_cond_instances;
@@global.performance_schema_max_cond_instances
123
select @@session.performance_schema_max_cond_instances;
ERROR HY000: Variable 'performance_schema_max_cond_instances' is a GLOBAL variable
show global variables like 'performance_schema_max_cond_instances';
Variable_name Value
performance_schema_max_cond_instances 123
show session variables like 'performance_schema_max_cond_instances';
Variable_name Value
performance_schema_max_cond_instances 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_cond_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_COND_INSTANCES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_cond_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_COND_INSTANCES 123
set global performance_schema_max_cond_instances=1;
ERROR HY000: Variable 'performance_schema_max_cond_instances' is a read only variable
set session performance_schema_max_cond_instances=1;
ERROR HY000: Variable 'performance_schema_max_cond_instances' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_file_classes;
@@global.performance_schema_max_file_classes
123
select @@session.performance_schema_max_file_classes;
ERROR HY000: Variable 'performance_schema_max_file_classes' is a GLOBAL variable
show global variables like 'performance_schema_max_file_classes';
Variable_name Value
performance_schema_max_file_classes 123
show session variables like 'performance_schema_max_file_classes';
Variable_name Value
performance_schema_max_file_classes 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_file_classes';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_FILE_CLASSES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_file_classes';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_FILE_CLASSES 123
set global performance_schema_max_file_classes=1;
ERROR HY000: Variable 'performance_schema_max_file_classes' is a read only variable
set session performance_schema_max_file_classes=1;
ERROR HY000: Variable 'performance_schema_max_file_classes' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_file_handles;
@@global.performance_schema_max_file_handles
123
select @@session.performance_schema_max_file_handles;
ERROR HY000: Variable 'performance_schema_max_file_handles' is a GLOBAL variable
show global variables like 'performance_schema_max_file_handles';
Variable_name Value
performance_schema_max_file_handles 123
show session variables like 'performance_schema_max_file_handles';
Variable_name Value
performance_schema_max_file_handles 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_file_handles';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_FILE_HANDLES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_file_handles';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_FILE_HANDLES 123
set global performance_schema_max_file_handles=1;
ERROR HY000: Variable 'performance_schema_max_file_handles' is a read only variable
set session performance_schema_max_file_handles=1;
ERROR HY000: Variable 'performance_schema_max_file_handles' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_file_instances;
@@global.performance_schema_max_file_instances
123
select @@session.performance_schema_max_file_instances;
ERROR HY000: Variable 'performance_schema_max_file_instances' is a GLOBAL variable
show global variables like 'performance_schema_max_file_instances';
Variable_name Value
performance_schema_max_file_instances 123
show session variables like 'performance_schema_max_file_instances';
Variable_name Value
performance_schema_max_file_instances 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_file_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_FILE_INSTANCES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_file_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_FILE_INSTANCES 123
set global performance_schema_max_file_instances=1;
ERROR HY000: Variable 'performance_schema_max_file_instances' is a read only variable
set session performance_schema_max_file_instances=1;
ERROR HY000: Variable 'performance_schema_max_file_instances' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_mutex_classes;
@@global.performance_schema_max_mutex_classes
123
select @@session.performance_schema_max_mutex_classes;
ERROR HY000: Variable 'performance_schema_max_mutex_classes' is a GLOBAL variable
show global variables like 'performance_schema_max_mutex_classes';
Variable_name Value
performance_schema_max_mutex_classes 123
show session variables like 'performance_schema_max_mutex_classes';
Variable_name Value
performance_schema_max_mutex_classes 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_mutex_classes';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_MUTEX_CLASSES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_mutex_classes';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_MUTEX_CLASSES 123
set global performance_schema_max_mutex_classes=1;
ERROR HY000: Variable 'performance_schema_max_mutex_classes' is a read only variable
set session performance_schema_max_mutex_classes=1;
ERROR HY000: Variable 'performance_schema_max_mutex_classes' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_mutex_instances;
@@global.performance_schema_max_mutex_instances
123
select @@session.performance_schema_max_mutex_instances;
ERROR HY000: Variable 'performance_schema_max_mutex_instances' is a GLOBAL variable
show global variables like 'performance_schema_max_mutex_instances';
Variable_name Value
performance_schema_max_mutex_instances 123
show session variables like 'performance_schema_max_mutex_instances';
Variable_name Value
performance_schema_max_mutex_instances 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_mutex_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_MUTEX_INSTANCES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_mutex_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_MUTEX_INSTANCES 123
set global performance_schema_max_mutex_instances=1;
ERROR HY000: Variable 'performance_schema_max_mutex_instances' is a read only variable
set session performance_schema_max_mutex_instances=1;
ERROR HY000: Variable 'performance_schema_max_mutex_instances' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_rwlock_classes;
@@global.performance_schema_max_rwlock_classes
123
select @@session.performance_schema_max_rwlock_classes;
ERROR HY000: Variable 'performance_schema_max_rwlock_classes' is a GLOBAL variable
show global variables like 'performance_schema_max_rwlock_classes';
Variable_name Value
performance_schema_max_rwlock_classes 123
show session variables like 'performance_schema_max_rwlock_classes';
Variable_name Value
performance_schema_max_rwlock_classes 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_rwlock_classes';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_RWLOCK_CLASSES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_rwlock_classes';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_RWLOCK_CLASSES 123
set global performance_schema_max_rwlock_classes=1;
ERROR HY000: Variable 'performance_schema_max_rwlock_classes' is a read only variable
set session performance_schema_max_rwlock_classes=1;
ERROR HY000: Variable 'performance_schema_max_rwlock_classes' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_rwlock_instances;
@@global.performance_schema_max_rwlock_instances
123
select @@session.performance_schema_max_rwlock_instances;
ERROR HY000: Variable 'performance_schema_max_rwlock_instances' is a GLOBAL variable
show global variables like 'performance_schema_max_rwlock_instances';
Variable_name Value
performance_schema_max_rwlock_instances 123
show session variables like 'performance_schema_max_rwlock_instances';
Variable_name Value
performance_schema_max_rwlock_instances 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_rwlock_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_RWLOCK_INSTANCES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_rwlock_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_RWLOCK_INSTANCES 123
set global performance_schema_max_rwlock_instances=1;
ERROR HY000: Variable 'performance_schema_max_rwlock_instances' is a read only variable
set session performance_schema_max_rwlock_instances=1;
ERROR HY000: Variable 'performance_schema_max_rwlock_instances' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_table_handles;
@@global.performance_schema_max_table_handles
123
select @@session.performance_schema_max_table_handles;
ERROR HY000: Variable 'performance_schema_max_table_handles' is a GLOBAL variable
show global variables like 'performance_schema_max_table_handles';
Variable_name Value
performance_schema_max_table_handles 123
show session variables like 'performance_schema_max_table_handles';
Variable_name Value
performance_schema_max_table_handles 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_table_handles';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_TABLE_HANDLES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_table_handles';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_TABLE_HANDLES 123
set global performance_schema_max_table_handles=1;
ERROR HY000: Variable 'performance_schema_max_table_handles' is a read only variable
set session performance_schema_max_table_handles=1;
ERROR HY000: Variable 'performance_schema_max_table_handles' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_table_instances;
@@global.performance_schema_max_table_instances
123
select @@session.performance_schema_max_table_instances;
ERROR HY000: Variable 'performance_schema_max_table_instances' is a GLOBAL variable
show global variables like 'performance_schema_max_table_instances';
Variable_name Value
performance_schema_max_table_instances 123
show session variables like 'performance_schema_max_table_instances';
Variable_name Value
performance_schema_max_table_instances 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_table_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_TABLE_INSTANCES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_table_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_TABLE_INSTANCES 123
set global performance_schema_max_table_instances=1;
ERROR HY000: Variable 'performance_schema_max_table_instances' is a read only variable
set session performance_schema_max_table_instances=1;
ERROR HY000: Variable 'performance_schema_max_table_instances' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_thread_classes;
@@global.performance_schema_max_thread_classes
123
select @@session.performance_schema_max_thread_classes;
ERROR HY000: Variable 'performance_schema_max_thread_classes' is a GLOBAL variable
show global variables like 'performance_schema_max_thread_classes';
Variable_name Value
performance_schema_max_thread_classes 123
show session variables like 'performance_schema_max_thread_classes';
Variable_name Value
performance_schema_max_thread_classes 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_thread_classes';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_THREAD_CLASSES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_thread_classes';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_THREAD_CLASSES 123
set global performance_schema_max_thread_classes=1;
ERROR HY000: Variable 'performance_schema_max_thread_classes' is a read only variable
set session performance_schema_max_thread_classes=1;
ERROR HY000: Variable 'performance_schema_max_thread_classes' is a read only variable

View File

@ -0,0 +1,23 @@
select @@global.performance_schema_max_thread_instances;
@@global.performance_schema_max_thread_instances
123
select @@session.performance_schema_max_thread_instances;
ERROR HY000: Variable 'performance_schema_max_thread_instances' is a GLOBAL variable
show global variables like 'performance_schema_max_thread_instances';
Variable_name Value
performance_schema_max_thread_instances 123
show session variables like 'performance_schema_max_thread_instances';
Variable_name Value
performance_schema_max_thread_instances 123
select * from information_schema.global_variables
where variable_name='performance_schema_max_thread_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_THREAD_INSTANCES 123
select * from information_schema.session_variables
where variable_name='performance_schema_max_thread_instances';
VARIABLE_NAME VARIABLE_VALUE
PERFORMANCE_SCHEMA_MAX_THREAD_INSTANCES 123
set global performance_schema_max_thread_instances=1;
ERROR HY000: Variable 'performance_schema_max_thread_instances' is a read only variable
set session performance_schema_max_thread_instances=1;
ERROR HY000: Variable 'performance_schema_max_thread_instances' is a read only variable

View File

@ -1,3 +1,18 @@
# Copyright (C) 2009-2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc --source include/not_embedded.inc
# #
@ -20,16 +35,26 @@ perl;
EOF EOF
create table t1 (test_name text); create table t1 (test_name text);
create table t2 (variable_name text);
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data infile "$MYSQLTEST_VARDIR/tmp/sys_vars.all_vars.txt" into table t1; eval load data infile "$MYSQLTEST_VARDIR/tmp/sys_vars.all_vars.txt" into table t1;
select variable_name as `There should be *no* variables listed below:` insert into t2 select variable_name from information_schema.global_variables;
from information_schema.global_variables insert into t2 select variable_name from information_schema.session_variables;
left join t1 on variable_name=test_name where
test_name is null # Performance schema variables are too long for files named
union # 'mysql-test/suite/sys_vars/t/' ...
select variable_name from information_schema.session_variables # ... 'performance_schema_events_waits_history_long_size_basic-master.opt'
left join t1 on variable_name=test_name where # to fit in the tar source distribution (limit in old tar)
test_name is null; # Renaming the tests to aliases below.
update t2 set variable_name= replace(variable_name, "PERFORMANCE_SCHEMA_", "PFS_");
select variable_name as `There should be *no* long test name listed below:` from t2
where length(variable_name) > 50;
select variable_name as `There should be *no* variables listed below:` from t2
left join t1 on variable_name=test_name where test_name is null;
drop table t1; drop table t1;
drop table t2;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema;
show global variables like 'performance_schema';
show session variables like 'performance_schema';
select * from information_schema.global_variables
where variable_name='performance_schema';
select * from information_schema.session_variables
where variable_name='performance_schema';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-events-waits-history-long-size=15000

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_events_waits_history_long_size;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_events_waits_history_long_size;
show global variables like 'performance_schema_events_waits_history_long_size';
show session variables like 'performance_schema_events_waits_history_long_size';
select * from information_schema.global_variables
where variable_name='performance_schema_events_waits_history_long_size';
select * from information_schema.session_variables
where variable_name='performance_schema_events_waits_history_long_size';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_events_waits_history_long_size=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_events_waits_history_long_size=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-events-waits-history-size=15

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_events_waits_history_size;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_events_waits_history_size;
show global variables like 'performance_schema_events_waits_history_size';
show session variables like 'performance_schema_events_waits_history_size';
select * from information_schema.global_variables
where variable_name='performance_schema_events_waits_history_size';
select * from information_schema.session_variables
where variable_name='performance_schema_events_waits_history_size';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_events_waits_history_size=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_events_waits_history_size=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-cond-classes=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_cond_classes;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_cond_classes;
show global variables like 'performance_schema_max_cond_classes';
show session variables like 'performance_schema_max_cond_classes';
select * from information_schema.global_variables
where variable_name='performance_schema_max_cond_classes';
select * from information_schema.session_variables
where variable_name='performance_schema_max_cond_classes';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_cond_classes=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_cond_classes=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-cond-instances=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_cond_instances;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_cond_instances;
show global variables like 'performance_schema_max_cond_instances';
show session variables like 'performance_schema_max_cond_instances';
select * from information_schema.global_variables
where variable_name='performance_schema_max_cond_instances';
select * from information_schema.session_variables
where variable_name='performance_schema_max_cond_instances';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_cond_instances=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_cond_instances=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-file-classes=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_file_classes;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_file_classes;
show global variables like 'performance_schema_max_file_classes';
show session variables like 'performance_schema_max_file_classes';
select * from information_schema.global_variables
where variable_name='performance_schema_max_file_classes';
select * from information_schema.session_variables
where variable_name='performance_schema_max_file_classes';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_file_classes=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_file_classes=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-file-handles=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_file_handles;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_file_handles;
show global variables like 'performance_schema_max_file_handles';
show session variables like 'performance_schema_max_file_handles';
select * from information_schema.global_variables
where variable_name='performance_schema_max_file_handles';
select * from information_schema.session_variables
where variable_name='performance_schema_max_file_handles';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_file_handles=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_file_handles=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-file-instances=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_file_instances;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_file_instances;
show global variables like 'performance_schema_max_file_instances';
show session variables like 'performance_schema_max_file_instances';
select * from information_schema.global_variables
where variable_name='performance_schema_max_file_instances';
select * from information_schema.session_variables
where variable_name='performance_schema_max_file_instances';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_file_instances=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_file_instances=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-mutex-classes=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_mutex_classes;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_mutex_classes;
show global variables like 'performance_schema_max_mutex_classes';
show session variables like 'performance_schema_max_mutex_classes';
select * from information_schema.global_variables
where variable_name='performance_schema_max_mutex_classes';
select * from information_schema.session_variables
where variable_name='performance_schema_max_mutex_classes';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_mutex_classes=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_mutex_classes=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-mutex-instances=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_mutex_instances;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_mutex_instances;
show global variables like 'performance_schema_max_mutex_instances';
show session variables like 'performance_schema_max_mutex_instances';
select * from information_schema.global_variables
where variable_name='performance_schema_max_mutex_instances';
select * from information_schema.session_variables
where variable_name='performance_schema_max_mutex_instances';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_mutex_instances=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_mutex_instances=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-rwlock-classes=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_rwlock_classes;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_rwlock_classes;
show global variables like 'performance_schema_max_rwlock_classes';
show session variables like 'performance_schema_max_rwlock_classes';
select * from information_schema.global_variables
where variable_name='performance_schema_max_rwlock_classes';
select * from information_schema.session_variables
where variable_name='performance_schema_max_rwlock_classes';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_rwlock_classes=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_rwlock_classes=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-rwlock-instances=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_rwlock_instances;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_rwlock_instances;
show global variables like 'performance_schema_max_rwlock_instances';
show session variables like 'performance_schema_max_rwlock_instances';
select * from information_schema.global_variables
where variable_name='performance_schema_max_rwlock_instances';
select * from information_schema.session_variables
where variable_name='performance_schema_max_rwlock_instances';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_rwlock_instances=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_rwlock_instances=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-table-handles=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_table_handles;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_table_handles;
show global variables like 'performance_schema_max_table_handles';
show session variables like 'performance_schema_max_table_handles';
select * from information_schema.global_variables
where variable_name='performance_schema_max_table_handles';
select * from information_schema.session_variables
where variable_name='performance_schema_max_table_handles';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_table_handles=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_table_handles=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-table-instances=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_table_instances;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_table_instances;
show global variables like 'performance_schema_max_table_instances';
show session variables like 'performance_schema_max_table_instances';
select * from information_schema.global_variables
where variable_name='performance_schema_max_table_instances';
select * from information_schema.session_variables
where variable_name='performance_schema_max_table_instances';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_table_instances=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_table_instances=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-thread-classes=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_thread_classes;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_thread_classes;
show global variables like 'performance_schema_max_thread_classes';
show session variables like 'performance_schema_max_thread_classes';
select * from information_schema.global_variables
where variable_name='performance_schema_max_thread_classes';
select * from information_schema.session_variables
where variable_name='performance_schema_max_thread_classes';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_thread_classes=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_thread_classes=1;

View File

@ -0,0 +1 @@
--loose-enable-performance-schema --loose-performance-schema-max-thread-instances=123

View File

@ -0,0 +1,47 @@
# Copyright (C) 2010 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
#
# Only global
#
select @@global.performance_schema_max_thread_instances;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_max_thread_instances;
show global variables like 'performance_schema_max_thread_instances';
show session variables like 'performance_schema_max_thread_instances';
select * from information_schema.global_variables
where variable_name='performance_schema_max_thread_instances';
select * from information_schema.session_variables
where variable_name='performance_schema_max_thread_instances';
#
# Read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_max_thread_instances=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_max_thread_instances=1;

View File

@ -600,7 +600,7 @@ PSI_mutex_key key_BITMAP_mutex, key_IO_CACHE_append_buffer_lock,
key_THR_LOCK_isam, key_THR_LOCK_lock, key_THR_LOCK_malloc, key_THR_LOCK_isam, key_THR_LOCK_lock, key_THR_LOCK_malloc,
key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net, key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net,
key_THR_LOCK_open, key_THR_LOCK_threads, key_THR_LOCK_time, key_THR_LOCK_open, key_THR_LOCK_threads, key_THR_LOCK_time,
key_TMPDIR_mutex; key_TMPDIR_mutex, key_THR_LOCK_myisam_mmap;
static PSI_mutex_info all_mysys_mutexes[]= static PSI_mutex_info all_mysys_mutexes[]=
{ {
@ -630,7 +630,8 @@ static PSI_mutex_info all_mysys_mutexes[]=
{ &key_THR_LOCK_open, "THR_LOCK_open", PSI_FLAG_GLOBAL}, { &key_THR_LOCK_open, "THR_LOCK_open", PSI_FLAG_GLOBAL},
{ &key_THR_LOCK_threads, "THR_LOCK_threads", PSI_FLAG_GLOBAL}, { &key_THR_LOCK_threads, "THR_LOCK_threads", PSI_FLAG_GLOBAL},
{ &key_THR_LOCK_time, "THR_LOCK_time", PSI_FLAG_GLOBAL}, { &key_THR_LOCK_time, "THR_LOCK_time", PSI_FLAG_GLOBAL},
{ &key_TMPDIR_mutex, "TMPDIR_mutex", PSI_FLAG_GLOBAL} { &key_TMPDIR_mutex, "TMPDIR_mutex", PSI_FLAG_GLOBAL},
{ &key_THR_LOCK_myisam_mmap, "THR_LOCK_myisam_mmap", PSI_FLAG_GLOBAL}
}; };
PSI_cond_key key_COND_alarm, key_IO_CACHE_SHARE_cond, PSI_cond_key key_COND_alarm, key_IO_CACHE_SHARE_cond,

View File

@ -24,8 +24,8 @@
#ifdef THREAD #ifdef THREAD
pthread_key(struct st_my_thread_var*, THR_KEY_mysys); pthread_key(struct st_my_thread_var*, THR_KEY_mysys);
mysql_mutex_t THR_LOCK_malloc,THR_LOCK_open, mysql_mutex_t THR_LOCK_malloc, THR_LOCK_open,
THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap, THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_myisam, THR_LOCK_heap,
THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads, THR_LOCK_time, THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads, THR_LOCK_time,
THR_LOCK_myisam_mmap; THR_LOCK_myisam_mmap;

View File

@ -47,7 +47,7 @@ extern PSI_mutex_key key_BITMAP_mutex, key_IO_CACHE_append_buffer_lock,
key_THR_LOCK_isam, key_THR_LOCK_lock, key_THR_LOCK_malloc, key_THR_LOCK_isam, key_THR_LOCK_lock, key_THR_LOCK_malloc,
key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net, key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net,
key_THR_LOCK_open, key_THR_LOCK_threads, key_THR_LOCK_time, key_THR_LOCK_open, key_THR_LOCK_threads, key_THR_LOCK_time,
key_TMPDIR_mutex; key_TMPDIR_mutex, key_THR_LOCK_myisam_mmap;
extern PSI_cond_key key_COND_alarm, key_IO_CACHE_SHARE_cond, extern PSI_cond_key key_COND_alarm, key_IO_CACHE_SHARE_cond,
key_IO_CACHE_SHARE_cond_writer, key_my_thread_var_suspend, key_IO_CACHE_SHARE_cond_writer, key_my_thread_var_suspend,

View File

@ -39,7 +39,7 @@ struct show_table_authors_st {
struct show_table_authors_st show_table_authors[]= { struct show_table_authors_st show_table_authors[]= {
{ "Brian (Krow) Aker", "Seattle, WA, USA", { "Brian (Krow) Aker", "Seattle, WA, USA",
"Architecture, archive, federated, bunch of little stuff :)" }, "Architecture, archive, federated, bunch of little stuff :)" },
{ "Marc Alff", "Denver, CO, USA", "Signal, Resignal" }, { "Marc Alff", "Denver, CO, USA", "Signal, Resignal, Performance schema" },
{ "Venu Anuganti", "", "Client/server protocol (4.1)" }, { "Venu Anuganti", "", "Client/server protocol (4.1)" },
{ "David Axmark", "Uppsala, Sweden", { "David Axmark", "Uppsala, Sweden",
"Small stuff long time ago, Monty ripped it out!" }, "Small stuff long time ago, Monty ripped it out!" },

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2005 MySQL AB /* Copyright (C) 2000-2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -107,8 +107,8 @@ bool read_texts(const char *file_name, const char *language,
funktpos=0; funktpos=0;
convert_dirname(lang_path, language, NullS); convert_dirname(lang_path, language, NullS);
(void) my_load_path(lang_path, lang_path, lc_messages_dir); (void) my_load_path(lang_path, lang_path, lc_messages_dir);
if ((file=my_open(fn_format(name,file_name, if ((file= mysql_file_open(key_file_ERRMSG,
lang_path, "", 4), fn_format(name, file_name, lang_path, "", 4),
O_RDONLY | O_SHARE | O_BINARY, O_RDONLY | O_SHARE | O_BINARY,
MYF(0))) < 0) MYF(0))) < 0)
{ {
@ -118,7 +118,8 @@ bool read_texts(const char *file_name, const char *language,
--language=/path/to/english/ --language=/path/to/english/
*/ */
if ((file= my_open(fn_format(name, file_name, lc_messages_dir, "", 4), if ((file= mysql_file_open(key_file_ERRMSG,
fn_format(name, file_name, lc_messages_dir, "", 4),
O_RDONLY | O_SHARE | O_BINARY, O_RDONLY | O_SHARE | O_BINARY,
MYF(0))) < 0) MYF(0))) < 0)
goto err; goto err;
@ -127,7 +128,8 @@ bool read_texts(const char *file_name, const char *language,
} }
funktpos=1; funktpos=1;
if (my_read(file,(uchar*) head,32,MYF(MY_NABP))) goto err; if (mysql_file_read(file, (uchar*) head, 32, MYF(MY_NABP)))
goto err;
if (head[0] != (uchar) 254 || head[1] != (uchar) 254 || if (head[0] != (uchar) 254 || head[1] != (uchar) 254 ||
head[2] != 2 || head[3] != 1) head[2] != 2 || head[3] != 1)
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
@ -143,7 +145,7 @@ Error message file '%s' had only %d error messages,\n\
but it should contain at least %d error messages.\n\ but it should contain at least %d error messages.\n\
Check that the above file is the right version for this program!", Check that the above file is the right version for this program!",
name,count,error_messages); name,count,error_messages);
(void) my_close(file,MYF(MY_WME)); (void) mysql_file_close(file, MYF(MY_WME));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -156,21 +158,21 @@ Check that the above file is the right version for this program!",
} }
buff= (uchar*) (*point + count); buff= (uchar*) (*point + count);
if (my_read(file, buff, (size_t) count*2,MYF(MY_NABP))) if (mysql_file_read(file, buff, (size_t) count*2, MYF(MY_NABP)))
goto err; goto err;
for (i=0, pos= buff ; i< count ; i++) for (i=0, pos= buff ; i< count ; i++)
{ {
(*point)[i]= (char*) buff+uint2korr(pos); (*point)[i]= (char*) buff+uint2korr(pos);
pos+=2; pos+=2;
} }
if (my_read(file, buff, length, MYF(MY_NABP))) if (mysql_file_read(file, buff, length, MYF(MY_NABP)))
goto err; goto err;
for (i=1 ; i < textcount ; i++) for (i=1 ; i < textcount ; i++)
{ {
point[i]= *point +uint2korr(head+10+i+i); point[i]= *point +uint2korr(head+10+i+i);
} }
(void) my_close(file,MYF(0)); (void) mysql_file_close(file, MYF(0));
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
@ -187,7 +189,7 @@ err:
} }
sql_print_error(errmsg, name); sql_print_error(errmsg, name);
if (file != FERR) if (file != FERR)
(void) my_close(file,MYF(MY_WME)); (void) mysql_file_close(file, MYF(MY_WME));
DBUG_RETURN(1); DBUG_RETURN(1);
} /* read_texts */ } /* read_texts */

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2001-2003, 2005 MySQL AB /* Copyright (C) 2001-2003, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -43,8 +43,9 @@ load_des_key_file(const char *file_name)
DBUG_ENTER("load_des_key_file"); DBUG_ENTER("load_des_key_file");
DBUG_PRINT("enter",("name: %s",file_name)); DBUG_PRINT("enter",("name: %s",file_name));
pthread_mutex_lock(&LOCK_des_key_file); mysql_mutex_lock(&LOCK_des_key_file);
if ((file=my_open(file_name,O_RDONLY | O_BINARY ,MYF(MY_WME))) < 0 || if ((file= mysql_file_open(key_file_des_key_file, file_name,
O_RDONLY | O_BINARY, MYF(MY_WME))) < 0 ||
init_io_cache(&io, file, IO_SIZE*2, READ_CACHE, 0, 0, MYF(MY_WME))) init_io_cache(&io, file, IO_SIZE*2, READ_CACHE, 0, 0, MYF(MY_WME)))
goto error; goto error;
@ -93,10 +94,10 @@ load_des_key_file(const char *file_name)
error: error:
if (file >= 0) if (file >= 0)
{ {
my_close(file,MYF(0)); mysql_file_close(file, MYF(0));
end_io_cache(&io); end_io_cache(&io);
} }
pthread_mutex_unlock(&LOCK_des_key_file); mysql_mutex_unlock(&LOCK_des_key_file);
DBUG_RETURN(result); DBUG_RETURN(result);
} }
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2004 MySQL AB /* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -57,7 +57,8 @@ int readfrm(const char *name, uchar **frmdata, size_t *len)
*frmdata= NULL; // In case of errors *frmdata= NULL; // In case of errors
*len= 0; *len= 0;
error= 1; error= 1;
if ((file=my_open(fn_format(index_file,name,"",reg_ext, if ((file= mysql_file_open(key_file_frm,
fn_format(index_file, name, "", reg_ext,
MY_UNPACK_FILENAME|MY_APPEND_EXT), MY_UNPACK_FILENAME|MY_APPEND_EXT),
O_RDONLY | O_SHARE, O_RDONLY | O_SHARE,
MYF(0))) < 0) MYF(0))) < 0)
@ -65,7 +66,7 @@ int readfrm(const char *name, uchar **frmdata, size_t *len)
// Get length of file // Get length of file
error= 2; error= 2;
if (my_fstat(file, &state, MYF(0))) if (mysql_file_fstat(file, &state, MYF(0)))
goto err; goto err;
read_len= state.st_size; read_len= state.st_size;
@ -82,7 +83,7 @@ int readfrm(const char *name, uchar **frmdata, size_t *len)
err: err:
if (file > 0) if (file > 0)
(void) my_close(file,MYF(MY_WME)); (void) mysql_file_close(file, MYF(MY_WME));
err_end: /* Here when no file */ err_end: /* Here when no file */
DBUG_RETURN (error); DBUG_RETURN (error);
@ -112,13 +113,15 @@ int writefrm(const char *name, const uchar *frmdata, size_t len)
DBUG_PRINT("enter",("name: '%s' len: %lu ",name, (ulong) len)); DBUG_PRINT("enter",("name: '%s' len: %lu ",name, (ulong) len));
error= 0; error= 0;
if ((file=my_create(fn_format(index_file,name,"",reg_ext, if ((file= mysql_file_create(key_file_frm,
MY_UNPACK_FILENAME|MY_APPEND_EXT), fn_format(index_file, name, "", reg_ext,
CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0) MY_UNPACK_FILENAME | MY_APPEND_EXT),
CREATE_MODE, O_RDWR | O_TRUNC,
MYF(MY_WME))) >= 0)
{ {
if (my_write(file, frmdata, len,MYF(MY_WME | MY_NABP))) if (mysql_file_write(file, frmdata, len, MYF(MY_WME | MY_NABP)))
error= 2; error= 2;
(void) my_close(file,MYF(0)); (void) mysql_file_close(file, MYF(0));
} }
DBUG_RETURN(error); DBUG_RETURN(error);
} /* writefrm */ } /* writefrm */

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2004-2006 MySQL AB /* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1402,8 +1402,7 @@ Event_job_data::execute(THD *thd, bool drop)
} }
#endif #endif
if (check_access(thd, EVENT_ACL, dbname.str, if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0))
0, 0, 0, is_schema_db(dbname.str)))
{ {
/* /*
This aspect of behavior is defined in the worklog, This aspect of behavior is defined in the worklog,

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2004-2006 MySQL AB /* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -94,16 +94,16 @@ Event_queue::Event_queue()
mutex_queue_data_attempting_lock(FALSE), mutex_queue_data_attempting_lock(FALSE),
waiting_on_cond(FALSE) waiting_on_cond(FALSE)
{ {
pthread_mutex_init(&LOCK_event_queue, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_event_queue, &LOCK_event_queue, MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_queue_state, NULL); mysql_cond_init(key_COND_queue_state, &COND_queue_state, NULL);
} }
Event_queue::~Event_queue() Event_queue::~Event_queue()
{ {
deinit_queue(); deinit_queue();
pthread_mutex_destroy(&LOCK_event_queue); mysql_mutex_destroy(&LOCK_event_queue);
pthread_cond_destroy(&COND_queue_state); mysql_cond_destroy(&COND_queue_state);
} }
@ -210,7 +210,7 @@ Event_queue::create_event(THD *thd, Event_queue_element *new_element,
LOCK_QUEUE_DATA(); LOCK_QUEUE_DATA();
*created= (queue_insert_safe(&queue, (uchar *) new_element) == FALSE); *created= (queue_insert_safe(&queue, (uchar *) new_element) == FALSE);
dbug_dump_queue(thd->query_start()); dbug_dump_queue(thd->query_start());
pthread_cond_broadcast(&COND_queue_state); mysql_cond_broadcast(&COND_queue_state);
UNLOCK_QUEUE_DATA(); UNLOCK_QUEUE_DATA();
DBUG_RETURN(!*created); DBUG_RETURN(!*created);
@ -258,7 +258,7 @@ Event_queue::update_event(THD *thd, LEX_STRING dbname, LEX_STRING name,
{ {
DBUG_PRINT("info", ("new event in the queue: 0x%lx", (long) new_element)); DBUG_PRINT("info", ("new event in the queue: 0x%lx", (long) new_element));
queue_insert_safe(&queue, (uchar *) new_element); queue_insert_safe(&queue, (uchar *) new_element);
pthread_cond_broadcast(&COND_queue_state); mysql_cond_broadcast(&COND_queue_state);
} }
dbug_dump_queue(thd->query_start()); dbug_dump_queue(thd->query_start());
@ -669,7 +669,7 @@ Event_queue::lock_data(const char *func, uint line)
mutex_last_attempted_lock_in_func= func; mutex_last_attempted_lock_in_func= func;
mutex_last_attempted_lock_at_line= line; mutex_last_attempted_lock_at_line= line;
mutex_queue_data_attempting_lock= TRUE; mutex_queue_data_attempting_lock= TRUE;
pthread_mutex_lock(&LOCK_event_queue); mysql_mutex_lock(&LOCK_event_queue);
mutex_last_attempted_lock_in_func= ""; mutex_last_attempted_lock_in_func= "";
mutex_last_attempted_lock_at_line= 0; mutex_last_attempted_lock_at_line= 0;
mutex_queue_data_attempting_lock= FALSE; mutex_queue_data_attempting_lock= FALSE;
@ -700,7 +700,7 @@ Event_queue::unlock_data(const char *func, uint line)
mutex_last_unlocked_at_line= line; mutex_last_unlocked_at_line= line;
mutex_queue_data_locked= FALSE; mutex_queue_data_locked= FALSE;
mutex_last_unlocked_in_func= func; mutex_last_unlocked_in_func= func;
pthread_mutex_unlock(&LOCK_event_queue); mysql_mutex_unlock(&LOCK_event_queue);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -731,9 +731,9 @@ Event_queue::cond_wait(THD *thd, struct timespec *abstime, const char* msg,
DBUG_PRINT("info", ("pthread_cond_%swait", abstime? "timed":"")); DBUG_PRINT("info", ("pthread_cond_%swait", abstime? "timed":""));
if (!abstime) if (!abstime)
pthread_cond_wait(&COND_queue_state, &LOCK_event_queue); mysql_cond_wait(&COND_queue_state, &LOCK_event_queue);
else else
pthread_cond_timedwait(&COND_queue_state, &LOCK_event_queue, abstime); mysql_cond_timedwait(&COND_queue_state, &LOCK_event_queue, abstime);
mutex_last_locked_in_func= func; mutex_last_locked_in_func= func;
mutex_last_locked_at_line= line; mutex_last_locked_at_line= line;

View File

@ -1,6 +1,6 @@
#ifndef _EVENT_QUEUE_H_ #ifndef _EVENT_QUEUE_H_
#define _EVENT_QUEUE_H_ #define _EVENT_QUEUE_H_
/* Copyright (C) 2004-2006 MySQL AB /* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -25,6 +25,11 @@
Queue of events awaiting execution. Queue of events awaiting execution.
*/ */
#ifdef HAVE_PSI_INTERFACE
extern PSI_mutex_key key_LOCK_event_queue;
extern PSI_cond_key key_COND_queue_state;
#endif /* HAVE_PSI_INTERFACE */
class Event_basic; class Event_basic;
class Event_queue_element; class Event_queue_element;
class Event_queue_element_for_exec; class Event_queue_element_for_exec;
@ -101,8 +106,8 @@ private:
dbug_dump_queue(time_t now); dbug_dump_queue(time_t now);
/* LOCK_event_queue is the mutex which protects the access to the queue. */ /* LOCK_event_queue is the mutex which protects the access to the queue. */
pthread_mutex_t LOCK_event_queue; mysql_mutex_t LOCK_event_queue;
pthread_cond_t COND_queue_state; mysql_cond_t COND_queue_state;
/* The sorted queue with the Event_queue_element objects */ /* The sorted queue with the Event_queue_element objects */
QUEUE queue; QUEUE queue;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2004-2006 MySQL AB /* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -163,7 +163,7 @@ deinit_event_thread(THD *thd)
/* /*
Performs pre- pthread_create() initialisation of THD. Do this Performs pre- mysql_thread_create() initialisation of THD. Do this
in the thread that will pass THD to the child thread. In the in the thread that will pass THD to the child thread. In the
child thread call post_init_event_thread(). child thread call post_init_event_thread().
@ -227,6 +227,9 @@ event_scheduler_thread(void *arg)
bool res; bool res;
thd->thread_stack= (char *)&thd; // remember where our stack is thd->thread_stack= (char *)&thd; // remember where our stack is
mysql_thread_set_psi_id(thd->thread_id);
res= post_init_event_thread(thd); res= post_init_event_thread(thd);
DBUG_ENTER("event_scheduler_thread"); DBUG_ENTER("event_scheduler_thread");
@ -259,6 +262,8 @@ event_worker_thread(void *arg)
thd= event->thd; thd= event->thd;
mysql_thread_set_psi_id(thd->thread_id);
Event_worker_thread worker_thread; Event_worker_thread worker_thread;
worker_thread.run(thd, event); worker_thread.run(thd, event);
@ -335,16 +340,17 @@ Event_scheduler::Event_scheduler(Event_queue *queue_arg)
waiting_on_cond(FALSE), waiting_on_cond(FALSE),
started_events(0) started_events(0)
{ {
pthread_mutex_init(&LOCK_scheduler_state, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_event_scheduler_LOCK_scheduler_state,
pthread_cond_init(&COND_state, NULL); &LOCK_scheduler_state, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_event_scheduler_COND_state, &COND_state, NULL);
} }
Event_scheduler::~Event_scheduler() Event_scheduler::~Event_scheduler()
{ {
stop(); /* does nothing if not running */ stop(); /* does nothing if not running */
pthread_mutex_destroy(&LOCK_scheduler_state); mysql_mutex_destroy(&LOCK_scheduler_state);
pthread_cond_destroy(&COND_state); mysql_cond_destroy(&COND_state);
} }
@ -403,7 +409,8 @@ Event_scheduler::start()
DBUG_PRINT("info", ("Setting state go RUNNING")); DBUG_PRINT("info", ("Setting state go RUNNING"));
state= RUNNING; state= RUNNING;
DBUG_PRINT("info", ("Forking new thread for scheduler. THD: 0x%lx", (long) new_thd)); DBUG_PRINT("info", ("Forking new thread for scheduler. THD: 0x%lx", (long) new_thd));
if (pthread_create(&th, &connection_attrib, event_scheduler_thread, if (mysql_thread_create(key_thread_event_scheduler,
&th, &connection_attrib, event_scheduler_thread,
(void*)scheduler_param_value)) (void*)scheduler_param_value))
{ {
DBUG_PRINT("error", ("cannot create a new thread")); DBUG_PRINT("error", ("cannot create a new thread"));
@ -487,7 +494,7 @@ Event_scheduler::run(THD *thd)
scheduler_thd= NULL; scheduler_thd= NULL;
state= INITIALIZED; state= INITIALIZED;
DBUG_PRINT("info", ("Signalling back to the stopper COND_state")); DBUG_PRINT("info", ("Signalling back to the stopper COND_state"));
pthread_cond_signal(&COND_state); mysql_cond_signal(&COND_state);
UNLOCK_DATA(); UNLOCK_DATA();
DBUG_RETURN(res); DBUG_RETURN(res);
@ -531,7 +538,8 @@ Event_scheduler::execute_top(Event_queue_element_for_exec *event_name)
reasonable level. reasonable level.
*/ */
/* Major failure */ /* Major failure */
if ((res= pthread_create(&th, &connection_attrib, event_worker_thread, if ((res= mysql_thread_create(key_thread_event_worker,
&th, &connection_attrib, event_worker_thread,
event_name))) event_name)))
goto error; goto error;
@ -632,13 +640,13 @@ Event_scheduler::stop()
DBUG_PRINT("info", ("Scheduler thread has id %lu", DBUG_PRINT("info", ("Scheduler thread has id %lu",
scheduler_thd->thread_id)); scheduler_thd->thread_id));
/* Lock from delete */ /* Lock from delete */
pthread_mutex_lock(&scheduler_thd->LOCK_thd_data); mysql_mutex_lock(&scheduler_thd->LOCK_thd_data);
/* This will wake up the thread if it waits on Queue's conditional */ /* This will wake up the thread if it waits on Queue's conditional */
sql_print_information("Event Scheduler: Killing the scheduler thread, " sql_print_information("Event Scheduler: Killing the scheduler thread, "
"thread id %lu", "thread id %lu",
scheduler_thd->thread_id); scheduler_thd->thread_id);
scheduler_thd->awake(THD::KILL_CONNECTION); scheduler_thd->awake(THD::KILL_CONNECTION);
pthread_mutex_unlock(&scheduler_thd->LOCK_thd_data); mysql_mutex_unlock(&scheduler_thd->LOCK_thd_data);
/* thd could be 0x0, when shutting down */ /* thd could be 0x0, when shutting down */
sql_print_information("Event Scheduler: " sql_print_information("Event Scheduler: "
@ -693,7 +701,7 @@ Event_scheduler::lock_data(const char *func, uint line)
{ {
DBUG_ENTER("Event_scheduler::lock_data"); DBUG_ENTER("Event_scheduler::lock_data");
DBUG_PRINT("enter", ("func=%s line=%u", func, line)); DBUG_PRINT("enter", ("func=%s line=%u", func, line));
pthread_mutex_lock(&LOCK_scheduler_state); mysql_mutex_lock(&LOCK_scheduler_state);
mutex_last_locked_in_func= func; mutex_last_locked_in_func= func;
mutex_last_locked_at_line= line; mutex_last_locked_at_line= line;
mutex_scheduler_data_locked= TRUE; mutex_scheduler_data_locked= TRUE;
@ -719,7 +727,7 @@ Event_scheduler::unlock_data(const char *func, uint line)
mutex_last_unlocked_at_line= line; mutex_last_unlocked_at_line= line;
mutex_scheduler_data_locked= FALSE; mutex_scheduler_data_locked= FALSE;
mutex_last_unlocked_in_func= func; mutex_last_unlocked_in_func= func;
pthread_mutex_unlock(&LOCK_scheduler_state); mysql_mutex_unlock(&LOCK_scheduler_state);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -750,9 +758,9 @@ Event_scheduler::cond_wait(THD *thd, struct timespec *abstime, const char* msg,
DBUG_PRINT("info", ("pthread_cond_%swait", abstime? "timed":"")); DBUG_PRINT("info", ("pthread_cond_%swait", abstime? "timed":""));
if (!abstime) if (!abstime)
pthread_cond_wait(&COND_state, &LOCK_scheduler_state); mysql_cond_wait(&COND_state, &LOCK_scheduler_state);
else else
pthread_cond_timedwait(&COND_state, &LOCK_scheduler_state, abstime); mysql_cond_timedwait(&COND_state, &LOCK_scheduler_state, abstime);
if (thd) if (thd)
{ {
/* /*

View File

@ -1,6 +1,6 @@
#ifndef _EVENT_SCHEDULER_H_ #ifndef _EVENT_SCHEDULER_H_
#define _EVENT_SCHEDULER_H_ #define _EVENT_SCHEDULER_H_
/* Copyright (C) 2004-2006 MySQL AB /* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -115,7 +115,7 @@ private:
cond_wait(THD *thd, struct timespec *abstime, const char* msg, cond_wait(THD *thd, struct timespec *abstime, const char* msg,
const char *func, uint line); const char *func, uint line);
pthread_mutex_t LOCK_scheduler_state; mysql_mutex_t LOCK_scheduler_state;
enum enum_state enum enum_state
{ {
@ -129,7 +129,7 @@ private:
THD *scheduler_thd; THD *scheduler_thd;
pthread_cond_t COND_state; mysql_cond_t COND_state;
Event_queue *queue; Event_queue *queue;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2004-2006 MySQL AB /* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -68,7 +68,7 @@ Event_queue *Events::event_queue;
Event_scheduler *Events::scheduler; Event_scheduler *Events::scheduler;
Event_db_repository *Events::db_repository; Event_db_repository *Events::db_repository;
uint Events::opt_event_scheduler= Events::EVENTS_OFF; uint Events::opt_event_scheduler= Events::EVENTS_OFF;
pthread_mutex_t Events::LOCK_event_metadata; mysql_mutex_t Events::LOCK_event_metadata;
bool Events::check_system_tables_error= FALSE; bool Events::check_system_tables_error= FALSE;
@ -319,8 +319,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
/* At create, one of them must be set */ /* At create, one of them must be set */
DBUG_ASSERT(parse_data->expression || parse_data->execute_at); DBUG_ASSERT(parse_data->expression || parse_data->execute_at);
if (check_access(thd, EVENT_ACL, parse_data->dbname.str, 0, 0, 0, if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0))
is_schema_db(parse_data->dbname.str)))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (check_db_dir_existence(parse_data->dbname.str)) if (check_db_dir_existence(parse_data->dbname.str))
@ -338,7 +337,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
if (thd->current_stmt_binlog_row_based) if (thd->current_stmt_binlog_row_based)
thd->clear_current_stmt_binlog_row_based(); thd->clear_current_stmt_binlog_row_based();
pthread_mutex_lock(&LOCK_event_metadata); mysql_mutex_lock(&LOCK_event_metadata);
/* On error conditions my_error() is called so no need to handle here */ /* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists))) if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists)))
@ -383,7 +382,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
ret= write_bin_log(thd, TRUE, log_query.c_ptr(), log_query.length()); ret= write_bin_log(thd, TRUE, log_query.c_ptr(), log_query.length());
} }
} }
pthread_mutex_unlock(&LOCK_event_metadata); mysql_mutex_unlock(&LOCK_event_metadata);
DBUG_RETURN(ret); DBUG_RETURN(ret);
} }
@ -430,8 +429,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
if (parse_data->check_parse_data(thd) || parse_data->do_not_create) if (parse_data->check_parse_data(thd) || parse_data->do_not_create)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (check_access(thd, EVENT_ACL, parse_data->dbname.str, 0, 0, 0, if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0))
is_schema_db(parse_data->dbname.str)))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (new_dbname) /* It's a rename */ if (new_dbname) /* It's a rename */
@ -452,8 +450,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
to tell the user that a database doesn't exist if they can not to tell the user that a database doesn't exist if they can not
access it. access it.
*/ */
if (check_access(thd, EVENT_ACL, new_dbname->str, 0, 0, 0, if (check_access(thd, EVENT_ACL, new_dbname->str, NULL, NULL, 0, 0))
is_schema_db(new_dbname->str)))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
/* Check that the target database exists */ /* Check that the target database exists */
@ -471,7 +468,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
if (thd->current_stmt_binlog_row_based) if (thd->current_stmt_binlog_row_based)
thd->clear_current_stmt_binlog_row_based(); thd->clear_current_stmt_binlog_row_based();
pthread_mutex_lock(&LOCK_event_metadata); mysql_mutex_lock(&LOCK_event_metadata);
/* On error conditions my_error() is called so no need to handle here */ /* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->update_event(thd, parse_data, if (!(ret= db_repository->update_event(thd, parse_data,
@ -504,7 +501,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
ret= write_bin_log(thd, TRUE, thd->query(), thd->query_length()); ret= write_bin_log(thd, TRUE, thd->query(), thd->query_length());
} }
} }
pthread_mutex_unlock(&LOCK_event_metadata); mysql_mutex_unlock(&LOCK_event_metadata);
DBUG_RETURN(ret); DBUG_RETURN(ret);
} }
@ -557,8 +554,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
if (check_if_system_tables_error()) if (check_if_system_tables_error())
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (check_access(thd, EVENT_ACL, dbname.str, 0, 0, 0, if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0))
is_schema_db(dbname.str)))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
/* /*
@ -568,7 +564,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
if (thd->current_stmt_binlog_row_based) if (thd->current_stmt_binlog_row_based)
thd->clear_current_stmt_binlog_row_based(); thd->clear_current_stmt_binlog_row_based();
pthread_mutex_lock(&LOCK_event_metadata); mysql_mutex_lock(&LOCK_event_metadata);
/* On error conditions my_error() is called so no need to handle here */ /* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->drop_event(thd, dbname, name, if_exists))) if (!(ret= db_repository->drop_event(thd, dbname, name, if_exists)))
{ {
@ -578,7 +574,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
DBUG_ASSERT(thd->query() && thd->query_length()); DBUG_ASSERT(thd->query() && thd->query_length());
ret= write_bin_log(thd, TRUE, thd->query(), thd->query_length()); ret= write_bin_log(thd, TRUE, thd->query(), thd->query_length());
} }
pthread_mutex_unlock(&LOCK_event_metadata); mysql_mutex_unlock(&LOCK_event_metadata);
DBUG_RETURN(ret); DBUG_RETURN(ret);
} }
@ -607,11 +603,11 @@ Events::drop_schema_events(THD *thd, char *db)
are damaged, as intended. are damaged, as intended.
*/ */
pthread_mutex_lock(&LOCK_event_metadata); mysql_mutex_lock(&LOCK_event_metadata);
if (event_queue) if (event_queue)
event_queue->drop_schema_events(thd, db_lex); event_queue->drop_schema_events(thd, db_lex);
db_repository->drop_schema_events(thd, db_lex); db_repository->drop_schema_events(thd, db_lex);
pthread_mutex_unlock(&LOCK_event_metadata); mysql_mutex_unlock(&LOCK_event_metadata);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -714,8 +710,7 @@ Events::show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name)
if (check_if_system_tables_error()) if (check_if_system_tables_error())
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (check_access(thd, EVENT_ACL, dbname.str, 0, 0, 0, if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0))
is_schema_db(dbname.str)))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
/* /*
@ -773,8 +768,9 @@ Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
if (thd->lex->sql_command == SQLCOM_SHOW_EVENTS) if (thd->lex->sql_command == SQLCOM_SHOW_EVENTS)
{ {
DBUG_ASSERT(thd->lex->select_lex.db); DBUG_ASSERT(thd->lex->select_lex.db);
if (!is_schema_db(thd->lex->select_lex.db) && // There is no events in I_S if (!is_infoschema_db(thd->lex->select_lex.db) && // There is no events in I_S
check_access(thd, EVENT_ACL, thd->lex->select_lex.db, 0, 0, 0, 0)) check_access(thd, EVENT_ACL, thd->lex->select_lex.db,
NULL, NULL, 0, 0))
DBUG_RETURN(1); DBUG_RETURN(1);
db= thd->lex->select_lex.db; db= thd->lex->select_lex.db;
} }
@ -934,6 +930,51 @@ Events::deinit()
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
#ifdef HAVE_PSI_INTERFACE
PSI_mutex_key key_LOCK_event_metadata, key_LOCK_event_queue,
key_event_scheduler_LOCK_scheduler_state;
static PSI_mutex_info all_events_mutexes[]=
{
{ &key_LOCK_event_metadata, "LOCK_event_metadata", PSI_FLAG_GLOBAL},
{ &key_LOCK_event_queue, "LOCK_event_queue", PSI_FLAG_GLOBAL},
{ &key_event_scheduler_LOCK_scheduler_state, "Event_scheduler::LOCK_scheduler_state", PSI_FLAG_GLOBAL}
};
PSI_cond_key key_event_scheduler_COND_state, key_COND_queue_state;
static PSI_cond_info all_events_conds[]=
{
{ &key_event_scheduler_COND_state, "Event_scheduler::COND_state", PSI_FLAG_GLOBAL},
{ &key_COND_queue_state, "COND_queue_state", PSI_FLAG_GLOBAL},
};
PSI_thread_key key_thread_event_scheduler, key_thread_event_worker;
static PSI_thread_info all_events_threads[]=
{
{ &key_thread_event_scheduler, "event_scheduler", PSI_FLAG_GLOBAL},
{ &key_thread_event_worker, "event_worker", 0}
};
static void init_events_psi_keys(void)
{
const char* category= "sql";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_events_mutexes);
PSI_server->register_mutex(category, all_events_mutexes, count);
count= array_elements(all_events_conds);
PSI_server->register_cond(category, all_events_conds, count);
count= array_elements(all_events_threads);
PSI_server->register_thread(category, all_events_threads, count);
}
#endif /* HAVE_PSI_INTERFACE */
/** /**
Inits Events mutexes Inits Events mutexes
@ -946,7 +987,12 @@ Events::deinit()
void void
Events::init_mutexes() Events::init_mutexes()
{ {
pthread_mutex_init(&LOCK_event_metadata, MY_MUTEX_INIT_FAST); #ifdef HAVE_PSI_INTERFACE
init_events_psi_keys();
#endif
mysql_mutex_init(key_LOCK_event_metadata,
&LOCK_event_metadata, MY_MUTEX_INIT_FAST);
} }
@ -960,7 +1006,7 @@ Events::init_mutexes()
void void
Events::destroy_mutexes() Events::destroy_mutexes()
{ {
pthread_mutex_destroy(&LOCK_event_metadata); mysql_mutex_destroy(&LOCK_event_metadata);
} }
@ -982,7 +1028,7 @@ Events::dump_internal_status()
puts("LLA = Last Locked At LUA = Last Unlocked At"); puts("LLA = Last Locked At LUA = Last Unlocked At");
puts("WOC = Waiting On Condition DL = Data Locked"); puts("WOC = Waiting On Condition DL = Data Locked");
pthread_mutex_lock(&LOCK_event_metadata); mysql_mutex_lock(&LOCK_event_metadata);
if (opt_event_scheduler == EVENTS_DISABLED) if (opt_event_scheduler == EVENTS_DISABLED)
puts("The Event Scheduler is disabled"); puts("The Event Scheduler is disabled");
else else
@ -991,7 +1037,7 @@ Events::dump_internal_status()
event_queue->dump_internal_status(); event_queue->dump_internal_status();
} }
pthread_mutex_unlock(&LOCK_event_metadata); mysql_mutex_unlock(&LOCK_event_metadata);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }

View File

@ -1,6 +1,6 @@
#ifndef _EVENT_H_ #ifndef _EVENT_H_
#define _EVENT_H_ #define _EVENT_H_
/* Copyright (C) 2004-2006 MySQL AB /* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -25,6 +25,13 @@
A public interface of Events_Scheduler module. A public interface of Events_Scheduler module.
*/ */
#ifdef HAVE_PSI_INTERFACE
extern PSI_mutex_key key_LOCK_event_metadata,
key_event_scheduler_LOCK_scheduler_state;
extern PSI_cond_key key_event_scheduler_COND_state;
extern PSI_thread_key key_thread_event_scheduler, key_thread_event_worker;
#endif /* HAVE_PSI_INTERFACE */
class Event_parse_data; class Event_parse_data;
class Event_db_repository; class Event_db_repository;
class Event_queue; class Event_queue;
@ -77,7 +84,7 @@ public:
*/ */
enum enum_opt_event_scheduler { EVENTS_OFF, EVENTS_ON, EVENTS_DISABLED }; enum enum_opt_event_scheduler { EVENTS_OFF, EVENTS_ON, EVENTS_DISABLED };
static uint opt_event_scheduler; static uint opt_event_scheduler;
static pthread_mutex_t LOCK_event_metadata; static mysql_mutex_t LOCK_event_metadata;
static bool check_if_system_tables_error(); static bool check_if_system_tables_error();
static bool start(); static bool start();
static bool stop(); static bool stop();

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1119,8 +1119,9 @@ uint read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count))) if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
{ {
if (my_pread(fromfile->file,(uchar*) buffpek->base, if (mysql_file_pread(fromfile->file, (uchar*) buffpek->base,
(length= rec_length*count),buffpek->file_pos,MYF_RW)) (length= rec_length*count),
buffpek->file_pos, MYF_RW))
return((uint) -1); /* purecov: inspected */ return((uint) -1); /* purecov: inspected */
buffpek->key=buffpek->base; buffpek->key=buffpek->base;
buffpek->file_pos+= length; /* New filepos */ buffpek->file_pos+= length; /* New filepos */

View File

@ -264,7 +264,7 @@ Ndb_cluster_connection* g_ndb_cluster_connection= NULL;
uchar g_node_id_map[max_ndb_nodes]; uchar g_node_id_map[max_ndb_nodes];
/// Handler synchronization /// Handler synchronization
pthread_mutex_t ndbcluster_mutex; mysql_mutex_t ndbcluster_mutex;
/// Table lock handling /// Table lock handling
HASH ndbcluster_open_tables; HASH ndbcluster_open_tables;
@ -281,9 +281,9 @@ static int ndb_get_table_statistics(ha_ndbcluster*, bool, Ndb*, const NDBTAB *,
// Util thread variables // Util thread variables
pthread_t ndb_util_thread; pthread_t ndb_util_thread;
int ndb_util_thread_running= 0; int ndb_util_thread_running= 0;
pthread_mutex_t LOCK_ndb_util_thread; mysql_mutex_t LOCK_ndb_util_thread;
pthread_cond_t COND_ndb_util_thread; mysql_cond_t COND_ndb_util_thread;
pthread_cond_t COND_ndb_util_ready; mysql_cond_t COND_ndb_util_ready;
pthread_handler_t ndb_util_thread_func(void *arg); pthread_handler_t ndb_util_thread_func(void *arg);
/** /**
@ -4778,11 +4778,11 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
thd_ndb->changed_tables.push_back(m_share, &thd->transaction.mem_root); thd_ndb->changed_tables.push_back(m_share, &thd->transaction.mem_root);
} }
pthread_mutex_lock(&m_share->mutex); mysql_mutex_lock(&m_share->mutex);
DBUG_PRINT("info", ("Invalidating commit_count")); DBUG_PRINT("info", ("Invalidating commit_count"));
m_share->commit_count= 0; m_share->commit_count= 0;
m_share->commit_count_lock++; m_share->commit_count_lock++;
pthread_mutex_unlock(&m_share->mutex); mysql_mutex_unlock(&m_share->mutex);
} }
if (!--thd_ndb->lock_count) if (!--thd_ndb->lock_count)
@ -4943,12 +4943,12 @@ static int ndbcluster_commit(handlerton *hton, THD *thd, bool all)
List_iterator_fast<NDB_SHARE> it(thd_ndb->changed_tables); List_iterator_fast<NDB_SHARE> it(thd_ndb->changed_tables);
while ((share= it++)) while ((share= it++))
{ {
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
DBUG_PRINT("info", ("Invalidate commit_count for %s, share->commit_count: %lu", DBUG_PRINT("info", ("Invalidate commit_count for %s, share->commit_count: %lu",
share->table_name, (ulong) share->commit_count)); share->table_name, (ulong) share->commit_count));
share->commit_count= 0; share->commit_count= 0;
share->commit_count_lock++; share->commit_count_lock++;
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
} }
thd_ndb->changed_tables.empty(); thd_ndb->changed_tables.empty();
@ -5622,7 +5622,7 @@ int ha_ndbcluster::create(const char *name,
if (!my_errno) if (!my_errno)
{ {
NDB_SHARE *share= 0; NDB_SHARE *share= 0;
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
/* /*
First make sure we get a "fresh" share here, not an old trailing one... First make sure we get a "fresh" share here, not an old trailing one...
*/ */
@ -5647,7 +5647,7 @@ int ha_ndbcluster::create(const char *name,
DBUG_PRINT("NDB_SHARE", ("%s binlog create use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s binlog create use_count: %u",
share->key, share->use_count)); share->key, share->use_count));
} }
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
while (!IS_TMP_PREFIX(m_tabname)) while (!IS_TMP_PREFIX(m_tabname))
{ {
@ -6286,7 +6286,7 @@ retry_temporary_error1:
/* the drop table failed for some reason, drop the share anyways */ /* the drop table failed for some reason, drop the share anyways */
if (share) if (share)
{ {
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
if (share->state != NSS_DROPPED) if (share->state != NSS_DROPPED)
{ {
/* /*
@ -6302,7 +6302,7 @@ retry_temporary_error1:
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
share->key, share->use_count)); share->key, share->use_count));
free_share(&share, TRUE); free_share(&share, TRUE);
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
} }
#endif #endif
DBUG_RETURN(res); DBUG_RETURN(res);
@ -6343,7 +6343,7 @@ retry_temporary_error1:
if (share) if (share)
{ {
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
if (share->state != NSS_DROPPED) if (share->state != NSS_DROPPED)
{ {
/* /*
@ -6359,7 +6359,7 @@ retry_temporary_error1:
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
share->key, share->use_count)); share->key, share->use_count));
free_share(&share, TRUE); free_share(&share, TRUE);
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
} }
#endif #endif
DBUG_RETURN(0); DBUG_RETURN(0);
@ -7451,7 +7451,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
/* Call back after cluster connect */ /* Call back after cluster connect */
static int connect_callback() static int connect_callback()
{ {
pthread_mutex_lock(&LOCK_ndb_util_thread); mysql_mutex_lock(&LOCK_ndb_util_thread);
update_status_variables(g_ndb_cluster_connection); update_status_variables(g_ndb_cluster_connection);
uint node_id, i= 0; uint node_id, i= 0;
@ -7460,13 +7460,92 @@ static int connect_callback()
while ((node_id= g_ndb_cluster_connection->get_next_node(node_iter))) while ((node_id= g_ndb_cluster_connection->get_next_node(node_iter)))
g_node_id_map[node_id]= i++; g_node_id_map[node_id]= i++;
pthread_cond_signal(&COND_ndb_util_thread); mysql_cond_signal(&COND_ndb_util_thread);
pthread_mutex_unlock(&LOCK_ndb_util_thread); mysql_mutex_unlock(&LOCK_ndb_util_thread);
return 0; return 0;
} }
extern int ndb_dictionary_is_mysqld; extern int ndb_dictionary_is_mysqld;
extern pthread_mutex_t LOCK_plugin; extern mysql_mutex_t LOCK_plugin;
#ifdef HAVE_PSI_INTERFACE
#ifdef HAVE_NDB_BINLOG
PSI_mutex_key key_injector_mutex, key_ndb_schema_share_mutex,
key_ndb_schema_object_mutex;
#endif /* HAVE_NDB_BINLOG */
PSI_mutex_key key_NDB_SHARE_mutex, key_ndbcluster_mutex,
key_LOCK_ndb_util_thread;
static PSI_mutex_info all_ndbcluster_mutexes[]=
{
#ifdef HAVE_NDB_BINLOG
{& key_injector_mutex, "injector_mutex", PSI_FLAG_GLOBAL},
{& key_ndb_schema_share_mutex, "ndb_schema_share_mutex", PSI_FLAG_GLOBAL},
{& key_ndb_schema_object_mutex, "ndb_schema_object_mutex", PSI_FLAG_GLOBAL},
#endif /* HAVE_NDB_BINLOG */
{& key_NDB_SHARE_mutex, "NDB_SHARE::mutex", PSI_FLAG_GLOBAL},
{& key_ndbcluster_mutex, "ndbcluster_mutex", PSI_FLAG_GLOBAL},
{& key_LOCK_ndb_util_thread, "LOCK_ndb_util_thread", PSI_FLAG_GLOBAL}
};
#ifdef HAVE_NDB_BINLOG
PSI_cond_key key_injector_cond;
#endif /* HAVE_NDB_BINLOG */
PSI_cond_key key_COND_ndb_util_thread, key_COND_ndb_util_ready;
static PSI_cond_info all_ndbcluster_conds[]=
{
#ifdef HAVE_NDB_BINLOG
{& key_injector_cond, "injector_cond", PSI_FLAG_GLOBAL},
#endif /* HAVE_NDB_BINLOG */
{& key_COND_ndb_util_thread, "COND_ndb_util_thread", PSI_FLAG_GLOBAL},
{& key_COND_ndb_util_ready, "COND_ndb_util_ready", PSI_FLAG_GLOBAL}
};
#ifdef HAVE_NDB_BINLOG
PSI_thread_key key_thread_ndb_binlog;
#endif /* HAVE_NDB_BINLOG */
PSI_thread_key key_thread_ndb_util;
static PSI_thread_info all_ndbcluster_threads[]=
{
#ifdef HAVE_NDB_BINLOG
{ &key_thread_ndb_binlog, "ndb_binlog", PSI_FLAG_GLOBAL},
#endif /* HAVE_NDB_BINLOG */
{ &key_thread_ndb_util, "ndb_util", PSI_FLAG_GLOBAL}
};
PSI_file_key key_file_ndb;
static PSI_file_info all_ndbcluster_files[]=
{
{ &key_file_ndb, "ndb", 0}
};
void init_ndbcluster_psi_keys()
{
const char* category= "ndbcluster";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_ndbcluster_mutexes);
PSI_server->register_mutex(category, all_ndbcluster_mutexes, count);
count= array_elements(all_ndbcluster_conds);
PSI_server->register_cond(category, all_ndbcluster_conds, count);
count= array_elements(all_ndbcluster_threads);
PSI_server->register_thread(category, all_ndbcluster_threads, count);
count= array_elements(all_ndbcluster_files);
PSI_server->register_file(category, all_ndbcluster_files, count);
}
#endif /* HAVE_PSI_INTERFACE */
static int ndbcluster_init(void *p) static int ndbcluster_init(void *p)
{ {
@ -7476,17 +7555,23 @@ static int ndbcluster_init(void *p)
if (ndbcluster_inited) if (ndbcluster_inited)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
#ifdef HAVE_PSI_INTERFACE
init_ndbcluster_psi_keys();
#endif
/* /*
Below we create new THD's. They'll need LOCK_plugin, but it's taken now by Below we create new THD's. They'll need LOCK_plugin, but it's taken now by
plugin initialization code. Release it to avoid deadlocks. It's safe, as plugin initialization code. Release it to avoid deadlocks. It's safe, as
there're no threads that may concurrently access plugin control structures. there're no threads that may concurrently access plugin control structures.
*/ */
pthread_mutex_unlock(&LOCK_plugin); mysql_mutex_unlock(&LOCK_plugin);
pthread_mutex_init(&ndbcluster_mutex,MY_MUTEX_INIT_FAST); mysql_mutex_init(key_ndbcluster_mutex,
pthread_mutex_init(&LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST); &ndbcluster_mutex, MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_ndb_util_thread, NULL); mysql_mutex_init(key_LOCK_ndb_util_thread,
pthread_cond_init(&COND_ndb_util_ready, NULL); &LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_ndb_util_thread, &COND_ndb_util_thread, NULL);
mysql_cond_init(key_COND_ndb_util_ready, &COND_ndb_util_ready, NULL);
ndb_util_thread_running= -1; ndb_util_thread_running= -1;
ndbcluster_terminating= 0; ndbcluster_terminating= 0;
ndb_dictionary_is_mysqld= 1; ndb_dictionary_is_mysqld= 1;
@ -7608,35 +7693,36 @@ static int ndbcluster_init(void *p)
// Create utility thread // Create utility thread
pthread_t tmp; pthread_t tmp;
if (pthread_create(&tmp, &connection_attrib, ndb_util_thread_func, 0)) if (mysql_thread_create(key_thread_ndb_util,
&tmp, &connection_attrib, ndb_util_thread_func, 0))
{ {
DBUG_PRINT("error", ("Could not create ndb utility thread")); DBUG_PRINT("error", ("Could not create ndb utility thread"));
my_hash_free(&ndbcluster_open_tables); my_hash_free(&ndbcluster_open_tables);
pthread_mutex_destroy(&ndbcluster_mutex); mysql_mutex_destroy(&ndbcluster_mutex);
pthread_mutex_destroy(&LOCK_ndb_util_thread); mysql_mutex_destroy(&LOCK_ndb_util_thread);
pthread_cond_destroy(&COND_ndb_util_thread); mysql_cond_destroy(&COND_ndb_util_thread);
pthread_cond_destroy(&COND_ndb_util_ready); mysql_cond_destroy(&COND_ndb_util_ready);
goto ndbcluster_init_error; goto ndbcluster_init_error;
} }
/* Wait for the util thread to start */ /* Wait for the util thread to start */
pthread_mutex_lock(&LOCK_ndb_util_thread); mysql_mutex_lock(&LOCK_ndb_util_thread);
while (ndb_util_thread_running < 0) while (ndb_util_thread_running < 0)
pthread_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread); mysql_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread);
pthread_mutex_unlock(&LOCK_ndb_util_thread); mysql_mutex_unlock(&LOCK_ndb_util_thread);
if (!ndb_util_thread_running) if (!ndb_util_thread_running)
{ {
DBUG_PRINT("error", ("ndb utility thread exited prematurely")); DBUG_PRINT("error", ("ndb utility thread exited prematurely"));
my_hash_free(&ndbcluster_open_tables); my_hash_free(&ndbcluster_open_tables);
pthread_mutex_destroy(&ndbcluster_mutex); mysql_mutex_destroy(&ndbcluster_mutex);
pthread_mutex_destroy(&LOCK_ndb_util_thread); mysql_mutex_destroy(&LOCK_ndb_util_thread);
pthread_cond_destroy(&COND_ndb_util_thread); mysql_cond_destroy(&COND_ndb_util_thread);
pthread_cond_destroy(&COND_ndb_util_ready); mysql_cond_destroy(&COND_ndb_util_ready);
goto ndbcluster_init_error; goto ndbcluster_init_error;
} }
pthread_mutex_lock(&LOCK_plugin); mysql_mutex_lock(&LOCK_plugin);
ndbcluster_inited= 1; ndbcluster_inited= 1;
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
@ -7650,7 +7736,7 @@ ndbcluster_init_error:
g_ndb_cluster_connection= NULL; g_ndb_cluster_connection= NULL;
ndbcluster_hton->state= SHOW_OPTION_DISABLED; // If we couldn't use handler ndbcluster_hton->state= SHOW_OPTION_DISABLED; // If we couldn't use handler
pthread_mutex_lock(&LOCK_plugin); mysql_mutex_lock(&LOCK_plugin);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -7693,17 +7779,17 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type)
/* wait for util thread to finish */ /* wait for util thread to finish */
sql_print_information("Stopping Cluster Utility thread"); sql_print_information("Stopping Cluster Utility thread");
pthread_mutex_lock(&LOCK_ndb_util_thread); mysql_mutex_lock(&LOCK_ndb_util_thread);
ndbcluster_terminating= 1; ndbcluster_terminating= 1;
pthread_cond_signal(&COND_ndb_util_thread); mysql_cond_signal(&COND_ndb_util_thread);
while (ndb_util_thread_running > 0) while (ndb_util_thread_running > 0)
pthread_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread); mysql_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread);
pthread_mutex_unlock(&LOCK_ndb_util_thread); mysql_mutex_unlock(&LOCK_ndb_util_thread);
#ifdef HAVE_NDB_BINLOG #ifdef HAVE_NDB_BINLOG
{ {
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
while (ndbcluster_open_tables.records) while (ndbcluster_open_tables.records)
{ {
NDB_SHARE *share= NDB_SHARE *share=
@ -7714,7 +7800,7 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type)
#endif #endif
ndbcluster_real_free_share(&share); ndbcluster_real_free_share(&share);
} }
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
} }
#endif #endif
my_hash_free(&ndbcluster_open_tables); my_hash_free(&ndbcluster_open_tables);
@ -7743,10 +7829,10 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type)
// cleanup ndb interface // cleanup ndb interface
ndb_end_internal(); ndb_end_internal();
pthread_mutex_destroy(&ndbcluster_mutex); mysql_mutex_destroy(&ndbcluster_mutex);
pthread_mutex_destroy(&LOCK_ndb_util_thread); mysql_mutex_destroy(&LOCK_ndb_util_thread);
pthread_cond_destroy(&COND_ndb_util_thread); mysql_cond_destroy(&COND_ndb_util_thread);
pthread_cond_destroy(&COND_ndb_util_ready); mysql_cond_destroy(&COND_ndb_util_ready);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -8049,12 +8135,12 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
build_table_filename(name, sizeof(name) - 1, build_table_filename(name, sizeof(name) - 1,
dbname, tabname, "", 0); dbname, tabname, "", 0);
DBUG_PRINT("enter", ("name: %s", name)); DBUG_PRINT("enter", ("name: %s", name));
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
if (!(share=(NDB_SHARE*) my_hash_search(&ndbcluster_open_tables, if (!(share=(NDB_SHARE*) my_hash_search(&ndbcluster_open_tables,
(uchar*) name, (uchar*) name,
strlen(name)))) strlen(name))))
{ {
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
DBUG_PRINT("info", ("Table %s not found in ndbcluster_open_tables", name)); DBUG_PRINT("info", ("Table %s not found in ndbcluster_open_tables", name));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -8062,9 +8148,9 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
share->use_count++; share->use_count++;
DBUG_PRINT("NDB_SHARE", ("%s temporary use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s temporary use_count: %u",
share->key, share->use_count)); share->key, share->use_count));
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
if (opt_ndb_cache_check_time > 0) if (opt_ndb_cache_check_time > 0)
{ {
if (share->commit_count != 0) if (share->commit_count != 0)
@ -8075,7 +8161,7 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
#endif #endif
DBUG_PRINT("info", ("Getting commit_count: %s from share", DBUG_PRINT("info", ("Getting commit_count: %s from share",
llstr(share->commit_count, buff))); llstr(share->commit_count, buff)));
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
/* ndb_share reference temporary free */ /* ndb_share reference temporary free */
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
share->key, share->use_count)); share->key, share->use_count));
@ -8092,7 +8178,7 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
ERR_RETURN(ndb->getNdbError()); ERR_RETURN(ndb->getNdbError());
} }
uint lock= share->commit_count_lock; uint lock= share->commit_count_lock;
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
struct Ndb_statistics stat; struct Ndb_statistics stat;
{ {
@ -8108,7 +8194,7 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
} }
} }
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
if (share->commit_count_lock == lock) if (share->commit_count_lock == lock)
{ {
#ifndef DBUG_OFF #ifndef DBUG_OFF
@ -8124,7 +8210,7 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
DBUG_PRINT("info", ("Discarding commit_count, comit_count_lock changed")); DBUG_PRINT("info", ("Discarding commit_count, comit_count_lock changed"));
*commit_count= 0; *commit_count= 0;
} }
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
/* ndb_share reference temporary free */ /* ndb_share reference temporary free */
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
share->key, share->use_count)); share->key, share->use_count));
@ -8340,7 +8426,7 @@ static void print_ndbcluster_open_tables()
to avoid segmentation faults. There is a risk that the memory for to avoid segmentation faults. There is a risk that the memory for
this trailing share leaks. this trailing share leaks.
Must be called with previous pthread_mutex_lock(&ndbcluster_mutex) Must be called with previous mysql_mutex_lock(&ndbcluster_mutex)
*/ */
int handle_trailing_share(NDB_SHARE *share) int handle_trailing_share(NDB_SHARE *share)
{ {
@ -8352,7 +8438,7 @@ int handle_trailing_share(NDB_SHARE *share)
++share->use_count; ++share->use_count;
DBUG_PRINT("NDB_SHARE", ("%s temporary use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s temporary use_count: %u",
share->key, share->use_count)); share->key, share->use_count));
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
TABLE_LIST table_list; TABLE_LIST table_list;
bzero((char*) &table_list,sizeof(table_list)); bzero((char*) &table_list,sizeof(table_list));
@ -8361,7 +8447,7 @@ int handle_trailing_share(NDB_SHARE *share)
mysql_mutex_assert_owner(&LOCK_open); mysql_mutex_assert_owner(&LOCK_open);
close_cached_tables(thd, &table_list, TRUE, FALSE, FALSE); close_cached_tables(thd, &table_list, TRUE, FALSE, FALSE);
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
/* ndb_share reference temporary free */ /* ndb_share reference temporary free */
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
share->key, share->use_count)); share->key, share->use_count));
@ -8452,7 +8538,7 @@ int handle_trailing_share(NDB_SHARE *share)
static int rename_share(NDB_SHARE *share, const char *new_key) static int rename_share(NDB_SHARE *share, const char *new_key)
{ {
NDB_SHARE *tmp; NDB_SHARE *tmp;
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
uint new_length= (uint) strlen(new_key); uint new_length= (uint) strlen(new_key);
DBUG_PRINT("rename_share", ("old_key: %s old__length: %d", DBUG_PRINT("rename_share", ("old_key: %s old__length: %d",
share->key, share->key_length)); share->key, share->key_length));
@ -8490,7 +8576,7 @@ static int rename_share(NDB_SHARE *share, const char *new_key)
share->key)); share->key));
} }
dbug_print_open_tables(); dbug_print_open_tables();
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
return -1; return -1;
} }
dbug_print_open_tables(); dbug_print_open_tables();
@ -8515,7 +8601,7 @@ static int rename_share(NDB_SHARE *share, const char *new_key)
share->old_names= old_key; share->old_names= old_key;
// ToDo free old_names after ALTER EVENT // ToDo free old_names after ALTER EVENT
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
return 0; return 0;
} }
#endif #endif
@ -8526,12 +8612,12 @@ static int rename_share(NDB_SHARE *share, const char *new_key)
*/ */
NDB_SHARE *ndbcluster_get_share(NDB_SHARE *share) NDB_SHARE *ndbcluster_get_share(NDB_SHARE *share)
{ {
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
share->use_count++; share->use_count++;
dbug_print_open_tables(); dbug_print_open_tables();
dbug_print_share("ndbcluster_get_share:", share); dbug_print_share("ndbcluster_get_share:", share);
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
return share; return share;
} }
@ -8548,7 +8634,7 @@ NDB_SHARE *ndbcluster_get_share(NDB_SHARE *share)
create_if_not_exists == FALSE: create_if_not_exists == FALSE:
returns 0 if share does not exist returns 0 if share does not exist
have_lock == TRUE, pthread_mutex_lock(&ndbcluster_mutex) already taken have_lock == TRUE, mysql_mutex_lock(&ndbcluster_mutex) already taken
*/ */
NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table, NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
@ -8561,7 +8647,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
DBUG_PRINT("enter", ("key: '%s'", key)); DBUG_PRINT("enter", ("key: '%s'", key));
if (!have_lock) if (!have_lock)
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
if (!(share= (NDB_SHARE*) my_hash_search(&ndbcluster_open_tables, if (!(share= (NDB_SHARE*) my_hash_search(&ndbcluster_open_tables,
(uchar*) key, (uchar*) key,
length))) length)))
@ -8570,7 +8656,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
{ {
DBUG_PRINT("error", ("get_share: %s does not exist", key)); DBUG_PRINT("error", ("get_share: %s does not exist", key));
if (!have_lock) if (!have_lock)
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if ((share= (NDB_SHARE*) my_malloc(sizeof(*share), if ((share= (NDB_SHARE*) my_malloc(sizeof(*share),
@ -8592,11 +8678,11 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
my_free((uchar*) share, 0); my_free((uchar*) share, 0);
*root_ptr= old_root; *root_ptr= old_root;
if (!have_lock) if (!have_lock)
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
thr_lock_init(&share->lock); thr_lock_init(&share->lock);
pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_NDB_SHARE_mutex, &share->mutex, MY_MUTEX_INIT_FAST);
share->commit_count= 0; share->commit_count= 0;
share->commit_count_lock= 0; share->commit_count_lock= 0;
share->db= share->key + length + 1; share->db= share->key + length + 1;
@ -8610,7 +8696,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
ndbcluster_real_free_share(&share); ndbcluster_real_free_share(&share);
*root_ptr= old_root; *root_ptr= old_root;
if (!have_lock) if (!have_lock)
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
#endif #endif
@ -8620,7 +8706,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
{ {
DBUG_PRINT("error", ("get_share: failed to alloc share")); DBUG_PRINT("error", ("get_share: failed to alloc share"));
if (!have_lock) if (!have_lock)
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
my_error(ER_OUTOFMEMORY, MYF(0), sizeof(*share)); my_error(ER_OUTOFMEMORY, MYF(0), sizeof(*share));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -8630,7 +8716,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
dbug_print_open_tables(); dbug_print_open_tables();
dbug_print_share("ndbcluster_get_share:", share); dbug_print_share("ndbcluster_get_share:", share);
if (!have_lock) if (!have_lock)
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
DBUG_RETURN(share); DBUG_RETURN(share);
} }
@ -8642,7 +8728,7 @@ void ndbcluster_real_free_share(NDB_SHARE **share)
my_hash_delete(&ndbcluster_open_tables, (uchar*) *share); my_hash_delete(&ndbcluster_open_tables, (uchar*) *share);
thr_lock_delete(&(*share)->lock); thr_lock_delete(&(*share)->lock);
pthread_mutex_destroy(&(*share)->mutex); mysql_mutex_destroy(&(*share)->mutex);
#ifdef HAVE_NDB_BINLOG #ifdef HAVE_NDB_BINLOG
if ((*share)->table) if ((*share)->table)
@ -8671,7 +8757,7 @@ void ndbcluster_real_free_share(NDB_SHARE **share)
void ndbcluster_free_share(NDB_SHARE **share, bool have_lock) void ndbcluster_free_share(NDB_SHARE **share, bool have_lock)
{ {
if (!have_lock) if (!have_lock)
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
if ((*share)->util_lock == current_thd) if ((*share)->util_lock == current_thd)
(*share)->util_lock= 0; (*share)->util_lock= 0;
if (!--(*share)->use_count) if (!--(*share)->use_count)
@ -8684,7 +8770,7 @@ void ndbcluster_free_share(NDB_SHARE **share, bool have_lock)
dbug_print_share("ndbcluster_free_share:", *share); dbug_print_share("ndbcluster_free_share:", *share);
} }
if (!have_lock) if (!have_lock)
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
} }
@ -8844,11 +8930,12 @@ int ha_ndbcluster::write_ndb_file(const char *name)
(void)strxnmov(path, FN_REFLEN-1, (void)strxnmov(path, FN_REFLEN-1,
mysql_data_home,"/",name,ha_ndb_ext,NullS); mysql_data_home,"/",name,ha_ndb_ext,NullS);
if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0) if ((file= mysql_file_create(key_file_ndb, path, CREATE_MODE,
O_RDWR | O_TRUNC, MYF(MY_WME))) >= 0)
{ {
// It's an empty file // It's an empty file
error=0; error=0;
my_close(file,MYF(0)); mysql_file_close(file, MYF(0));
} }
DBUG_RETURN(error); DBUG_RETURN(error);
} }
@ -9401,7 +9488,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
DBUG_ENTER("ndb_util_thread"); DBUG_ENTER("ndb_util_thread");
DBUG_PRINT("enter", ("cache_check_time: %lu", opt_ndb_cache_check_time)); DBUG_PRINT("enter", ("cache_check_time: %lu", opt_ndb_cache_check_time));
pthread_mutex_lock(&LOCK_ndb_util_thread); mysql_mutex_lock(&LOCK_ndb_util_thread);
thd= new THD; /* note that contructor of THD uses DBUG_ */ thd= new THD; /* note that contructor of THD uses DBUG_ */
if (thd == NULL) if (thd == NULL)
@ -9434,45 +9521,45 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
/* Signal successful initialization */ /* Signal successful initialization */
ndb_util_thread_running= 1; ndb_util_thread_running= 1;
pthread_cond_signal(&COND_ndb_util_ready); mysql_cond_signal(&COND_ndb_util_ready);
pthread_mutex_unlock(&LOCK_ndb_util_thread); mysql_mutex_unlock(&LOCK_ndb_util_thread);
/* /*
wait for mysql server to start wait for mysql server to start
*/ */
pthread_mutex_lock(&LOCK_server_started); mysql_mutex_lock(&LOCK_server_started);
while (!mysqld_server_started) while (!mysqld_server_started)
{ {
set_timespec(abstime, 1); set_timespec(abstime, 1);
pthread_cond_timedwait(&COND_server_started, &LOCK_server_started, mysql_cond_timedwait(&COND_server_started, &LOCK_server_started,
&abstime); &abstime);
if (ndbcluster_terminating) if (ndbcluster_terminating)
{ {
pthread_mutex_unlock(&LOCK_server_started); mysql_mutex_unlock(&LOCK_server_started);
pthread_mutex_lock(&LOCK_ndb_util_thread); mysql_mutex_lock(&LOCK_ndb_util_thread);
goto ndb_util_thread_end; goto ndb_util_thread_end;
} }
} }
pthread_mutex_unlock(&LOCK_server_started); mysql_mutex_unlock(&LOCK_server_started);
/* /*
Wait for cluster to start Wait for cluster to start
*/ */
pthread_mutex_lock(&LOCK_ndb_util_thread); mysql_mutex_lock(&LOCK_ndb_util_thread);
while (!ndb_cluster_node_id && (ndbcluster_hton->slot != ~(uint)0)) while (!ndb_cluster_node_id && (ndbcluster_hton->slot != ~(uint)0))
{ {
/* ndb not connected yet */ /* ndb not connected yet */
pthread_cond_wait(&COND_ndb_util_thread, &LOCK_ndb_util_thread); mysql_cond_wait(&COND_ndb_util_thread, &LOCK_ndb_util_thread);
if (ndbcluster_terminating) if (ndbcluster_terminating)
goto ndb_util_thread_end; goto ndb_util_thread_end;
} }
pthread_mutex_unlock(&LOCK_ndb_util_thread); mysql_mutex_unlock(&LOCK_ndb_util_thread);
/* Get thd_ndb for this thread */ /* Get thd_ndb for this thread */
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb())) if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb()))
{ {
sql_print_error("Could not allocate Thd_ndb object"); sql_print_error("Could not allocate Thd_ndb object");
pthread_mutex_lock(&LOCK_ndb_util_thread); mysql_mutex_lock(&LOCK_ndb_util_thread);
goto ndb_util_thread_end; goto ndb_util_thread_end;
} }
set_thd_ndb(thd, thd_ndb); set_thd_ndb(thd, thd_ndb);
@ -9493,14 +9580,14 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
set_timespec(abstime, 0); set_timespec(abstime, 0);
for (;;) for (;;)
{ {
pthread_mutex_lock(&LOCK_ndb_util_thread); mysql_mutex_lock(&LOCK_ndb_util_thread);
if (!ndbcluster_terminating) if (!ndbcluster_terminating)
pthread_cond_timedwait(&COND_ndb_util_thread, mysql_cond_timedwait(&COND_ndb_util_thread,
&LOCK_ndb_util_thread, &LOCK_ndb_util_thread,
&abstime); &abstime);
if (ndbcluster_terminating) /* Shutting down server */ if (ndbcluster_terminating) /* Shutting down server */
goto ndb_util_thread_end; goto ndb_util_thread_end;
pthread_mutex_unlock(&LOCK_ndb_util_thread); mysql_mutex_unlock(&LOCK_ndb_util_thread);
#ifdef NDB_EXTRA_DEBUG_UTIL_THREAD #ifdef NDB_EXTRA_DEBUG_UTIL_THREAD
DBUG_PRINT("ndb_util_thread", ("Started, opt_ndb_cache_check_time: %lu", DBUG_PRINT("ndb_util_thread", ("Started, opt_ndb_cache_check_time: %lu",
opt_ndb_cache_check_time)); opt_ndb_cache_check_time));
@ -9525,7 +9612,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
/* Lock mutex and fill list with pointers to all open tables */ /* Lock mutex and fill list with pointers to all open tables */
NDB_SHARE *share; NDB_SHARE *share;
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
uint i, open_count, record_count= ndbcluster_open_tables.records; uint i, open_count, record_count= ndbcluster_open_tables.records;
if (share_list_size < record_count) if (share_list_size < record_count)
{ {
@ -9534,7 +9621,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
{ {
sql_print_warning("ndb util thread: malloc failure, " sql_print_warning("ndb util thread: malloc failure, "
"query cache not maintained properly"); "query cache not maintained properly");
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
goto next; // At least do not crash goto next; // At least do not crash
} }
delete [] share_list; delete [] share_list;
@ -9561,7 +9648,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
/* Store pointer to table */ /* Store pointer to table */
share_list[open_count++]= share; share_list[open_count++]= share;
} }
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
/* Iterate through the open files list */ /* Iterate through the open files list */
for (i= 0; i < open_count; i++) for (i= 0; i < open_count; i++)
@ -9586,9 +9673,9 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
struct Ndb_statistics stat; struct Ndb_statistics stat;
uint lock; uint lock;
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
lock= share->commit_count_lock; lock= share->commit_count_lock;
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
{ {
/* Contact NDB to get commit count for table */ /* Contact NDB to get commit count for table */
Ndb* ndb= thd_ndb->ndb; Ndb* ndb= thd_ndb->ndb;
@ -9619,10 +9706,10 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
} }
} }
loop_next: loop_next:
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
if (share->commit_count_lock == lock) if (share->commit_count_lock == lock)
share->commit_count= stat.commit_count; share->commit_count= stat.commit_count;
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
/* ndb_share reference temporary free */ /* ndb_share reference temporary free */
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
@ -9652,7 +9739,7 @@ next:
} }
} }
pthread_mutex_lock(&LOCK_ndb_util_thread); mysql_mutex_lock(&LOCK_ndb_util_thread);
ndb_util_thread_end: ndb_util_thread_end:
net_end(&thd->net); net_end(&thd->net);
@ -9664,8 +9751,8 @@ ndb_util_thread_fail:
/* signal termination */ /* signal termination */
ndb_util_thread_running= 0; ndb_util_thread_running= 0;
pthread_cond_signal(&COND_ndb_util_ready); mysql_cond_signal(&COND_ndb_util_ready);
pthread_mutex_unlock(&LOCK_ndb_util_thread); mysql_mutex_unlock(&LOCK_ndb_util_thread);
DBUG_PRINT("exit", ("ndb_util_thread")); DBUG_PRINT("exit", ("ndb_util_thread"));
DBUG_LEAVE; // Must match DBUG_ENTER() DBUG_LEAVE; // Must match DBUG_ENTER()

View File

@ -1,7 +1,7 @@
#ifndef HA_NDBCLUSTER_INCLUDED #ifndef HA_NDBCLUSTER_INCLUDED
#define HA_NDBCLUSTER_INCLUDED #define HA_NDBCLUSTER_INCLUDED
/* Copyright (C) 2000-2003 MySQL AB /* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -35,6 +35,10 @@
#define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8 #define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8
#ifdef HAVE_PSI_INTERFACE
extern PSI_file_key key_file_ndb;
#endif /* HAVE_PSI_INTERFACE */
class Ndb; // Forward declaration class Ndb; // Forward declaration
class NdbOperation; // Forward declaration class NdbOperation; // Forward declaration
@ -102,7 +106,7 @@ typedef struct st_ndbcluster_share {
NDB_SHARE_STATE state; NDB_SHARE_STATE state;
MEM_ROOT mem_root; MEM_ROOT mem_root;
THR_LOCK lock; THR_LOCK lock;
pthread_mutex_t mutex; mysql_mutex_t mutex;
char *key; char *key;
uint key_length; uint key_length;
THD *util_lock; THD *util_lock;
@ -131,9 +135,9 @@ NDB_SHARE_STATE
get_ndb_share_state(NDB_SHARE *share) get_ndb_share_state(NDB_SHARE *share)
{ {
NDB_SHARE_STATE state; NDB_SHARE_STATE state;
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
state= share->state; state= share->state;
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
return state; return state;
} }
@ -141,19 +145,19 @@ inline
void void
set_ndb_share_state(NDB_SHARE *share, NDB_SHARE_STATE state) set_ndb_share_state(NDB_SHARE *share, NDB_SHARE_STATE state)
{ {
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
share->state= state; share->state= state;
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
} }
struct Ndb_tuple_id_range_guard { struct Ndb_tuple_id_range_guard {
Ndb_tuple_id_range_guard(NDB_SHARE* _share) : Ndb_tuple_id_range_guard(NDB_SHARE* _share) :
share(_share), share(_share),
range(share->tuple_id_range) { range(share->tuple_id_range) {
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
} }
~Ndb_tuple_id_range_guard() { ~Ndb_tuple_id_range_guard() {
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
} }
NDB_SHARE* share; NDB_SHARE* share;
Ndb::TupleIdRange& range; Ndb::TupleIdRange& range;
@ -578,6 +582,6 @@ static const char ndbcluster_hton_name[]= "ndbcluster";
static const int ndbcluster_hton_name_length=sizeof(ndbcluster_hton_name)-1; static const int ndbcluster_hton_name_length=sizeof(ndbcluster_hton_name)-1;
extern int ndbcluster_terminating; extern int ndbcluster_terminating;
extern int ndb_util_thread_running; extern int ndb_util_thread_running;
extern pthread_cond_t COND_ndb_util_ready; extern mysql_cond_t COND_ndb_util_ready;
#endif /* HA_NDBCLUSTER_INCLUDED */ #endif /* HA_NDBCLUSTER_INCLUDED */

View File

@ -79,7 +79,7 @@ THD *injector_thd= 0;
to enable ndb injector thread receiving events. to enable ndb injector thread receiving events.
Must therefore always be used with a surrounding Must therefore always be used with a surrounding
pthread_mutex_lock(&injector_mutex), when doing create/dropEventOperation mysql_mutex_lock(&injector_mutex), when doing create/dropEventOperation
*/ */
static Ndb *injector_ndb= 0; static Ndb *injector_ndb= 0;
static Ndb *schema_ndb= 0; static Ndb *schema_ndb= 0;
@ -106,8 +106,8 @@ static int ndbcluster_binlog_terminating= 0;
and injector thread and injector thread
*/ */
pthread_t ndb_binlog_thread; pthread_t ndb_binlog_thread;
pthread_mutex_t injector_mutex; mysql_mutex_t injector_mutex;
pthread_cond_t injector_cond; mysql_cond_t injector_cond;
/* NDB Injector thread (used for binlog creation) */ /* NDB Injector thread (used for binlog creation) */
static ulonglong ndb_latest_applied_binlog_epoch= 0; static ulonglong ndb_latest_applied_binlog_epoch= 0;
@ -116,7 +116,7 @@ static ulonglong ndb_latest_received_binlog_epoch= 0;
NDB_SHARE *ndb_apply_status_share= 0; NDB_SHARE *ndb_apply_status_share= 0;
NDB_SHARE *ndb_schema_share= 0; NDB_SHARE *ndb_schema_share= 0;
pthread_mutex_t ndb_schema_share_mutex; mysql_mutex_t ndb_schema_share_mutex;
extern my_bool opt_log_slave_updates; extern my_bool opt_log_slave_updates;
static my_bool g_ndb_log_slave_updates; static my_bool g_ndb_log_slave_updates;
@ -124,7 +124,7 @@ static my_bool g_ndb_log_slave_updates;
/* Schema object distribution handling */ /* Schema object distribution handling */
HASH ndb_schema_objects; HASH ndb_schema_objects;
typedef struct st_ndb_schema_object { typedef struct st_ndb_schema_object {
pthread_mutex_t mutex; mysql_mutex_t mutex;
char *key; char *key;
uint key_length; uint key_length;
uint use_count; uint use_count;
@ -641,28 +641,28 @@ static int ndbcluster_binlog_end(THD *thd)
however be a likely case as the ndbcluster_binlog_end is supposed to however be a likely case as the ndbcluster_binlog_end is supposed to
be called before ndb_cluster_end(). be called before ndb_cluster_end().
*/ */
pthread_mutex_lock(&LOCK_ndb_util_thread); mysql_mutex_lock(&LOCK_ndb_util_thread);
/* Ensure mutex are not freed if ndb_cluster_end is running at same time */ /* Ensure mutex are not freed if ndb_cluster_end is running at same time */
ndb_util_thread_running++; ndb_util_thread_running++;
ndbcluster_terminating= 1; ndbcluster_terminating= 1;
pthread_cond_signal(&COND_ndb_util_thread); mysql_cond_signal(&COND_ndb_util_thread);
while (ndb_util_thread_running > 1) while (ndb_util_thread_running > 1)
pthread_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread); mysql_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread);
ndb_util_thread_running--; ndb_util_thread_running--;
pthread_mutex_unlock(&LOCK_ndb_util_thread); mysql_mutex_unlock(&LOCK_ndb_util_thread);
} }
/* wait for injector thread to finish */ /* wait for injector thread to finish */
ndbcluster_binlog_terminating= 1; ndbcluster_binlog_terminating= 1;
pthread_mutex_lock(&injector_mutex); mysql_mutex_lock(&injector_mutex);
pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
while (ndb_binlog_thread_running > 0) while (ndb_binlog_thread_running > 0)
pthread_cond_wait(&injector_cond, &injector_mutex); mysql_cond_wait(&injector_cond, &injector_mutex);
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
pthread_mutex_destroy(&injector_mutex); mysql_mutex_destroy(&injector_mutex);
pthread_cond_destroy(&injector_cond); mysql_cond_destroy(&injector_cond);
pthread_mutex_destroy(&ndb_schema_share_mutex); mysql_mutex_destroy(&ndb_schema_share_mutex);
#endif #endif
DBUG_RETURN(0); DBUG_RETURN(0);
@ -742,14 +742,14 @@ void ndbcluster_binlog_init_handlerton()
*/ */
static NDB_SHARE *ndbcluster_check_ndb_apply_status_share() static NDB_SHARE *ndbcluster_check_ndb_apply_status_share()
{ {
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
void *share= my_hash_search(&ndbcluster_open_tables, void *share= my_hash_search(&ndbcluster_open_tables,
(uchar*) NDB_APPLY_TABLE_FILE, (uchar*) NDB_APPLY_TABLE_FILE,
sizeof(NDB_APPLY_TABLE_FILE) - 1); sizeof(NDB_APPLY_TABLE_FILE) - 1);
DBUG_PRINT("info",("ndbcluster_check_ndb_apply_status_share %s 0x%lx", DBUG_PRINT("info",("ndbcluster_check_ndb_apply_status_share %s 0x%lx",
NDB_APPLY_TABLE_FILE, (long) share)); NDB_APPLY_TABLE_FILE, (long) share));
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
return (NDB_SHARE*) share; return (NDB_SHARE*) share;
} }
@ -760,14 +760,14 @@ static NDB_SHARE *ndbcluster_check_ndb_apply_status_share()
*/ */
static NDB_SHARE *ndbcluster_check_ndb_schema_share() static NDB_SHARE *ndbcluster_check_ndb_schema_share()
{ {
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
void *share= my_hash_search(&ndbcluster_open_tables, void *share= my_hash_search(&ndbcluster_open_tables,
(uchar*) NDB_SCHEMA_TABLE_FILE, (uchar*) NDB_SCHEMA_TABLE_FILE,
sizeof(NDB_SCHEMA_TABLE_FILE) - 1); sizeof(NDB_SCHEMA_TABLE_FILE) - 1);
DBUG_PRINT("info",("ndbcluster_check_ndb_schema_share %s 0x%lx", DBUG_PRINT("info",("ndbcluster_check_ndb_schema_share %s 0x%lx",
NDB_SCHEMA_TABLE_FILE, (long) share)); NDB_SCHEMA_TABLE_FILE, (long) share));
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
return (NDB_SHARE*) share; return (NDB_SHARE*) share;
} }
@ -802,7 +802,7 @@ static int ndbcluster_create_ndb_apply_status_table(THD *thd)
{ {
build_table_filename(buf, sizeof(buf) - 1, build_table_filename(buf, sizeof(buf) - 1,
NDB_REP_DB, NDB_APPLY_TABLE, reg_ext, 0); NDB_REP_DB, NDB_APPLY_TABLE, reg_ext, 0);
my_delete(buf, MYF(0)); mysql_file_delete(key_file_frm, buf, MYF(0));
} }
/* /*
@ -860,7 +860,7 @@ static int ndbcluster_create_schema_table(THD *thd)
{ {
build_table_filename(buf, sizeof(buf) - 1, build_table_filename(buf, sizeof(buf) - 1,
NDB_REP_DB, NDB_SCHEMA_TABLE, reg_ext, 0); NDB_REP_DB, NDB_SCHEMA_TABLE, reg_ext, 0);
my_delete(buf, MYF(0)); mysql_file_delete(key_file_frm, buf, MYF(0));
} }
/* /*
@ -928,7 +928,7 @@ int ndbcluster_setup_binlog_table_shares(THD *thd)
close_cached_tables(NULL, NULL, TRUE, FALSE, FALSE); close_cached_tables(NULL, NULL, TRUE, FALSE, FALSE);
mysql_mutex_unlock(&LOCK_open); mysql_mutex_unlock(&LOCK_open);
/* Signal injector thread that all is setup */ /* Signal injector thread that all is setup */
pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
} }
return 0; return 0;
} }
@ -1239,12 +1239,12 @@ static void ndb_report_waiting(const char *key,
{ {
ulonglong ndb_latest_epoch= 0; ulonglong ndb_latest_epoch= 0;
const char *proc_info= "<no info>"; const char *proc_info= "<no info>";
pthread_mutex_lock(&injector_mutex); mysql_mutex_lock(&injector_mutex);
if (injector_ndb) if (injector_ndb)
ndb_latest_epoch= injector_ndb->getLatestGCI(); ndb_latest_epoch= injector_ndb->getLatestGCI();
if (injector_thd) if (injector_thd)
proc_info= injector_thd->proc_info; proc_info= injector_thd->proc_info;
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
sql_print_information("NDB %s:" sql_print_information("NDB %s:"
" waiting max %u sec for %s %s." " waiting max %u sec for %s %s."
" epochs: (%u,%u,%u)" " epochs: (%u,%u,%u)"
@ -1357,15 +1357,15 @@ int ndbcluster_log_schema_op(THD *thd, NDB_SHARE *share,
bitmap_set_all(&schema_subscribers); bitmap_set_all(&schema_subscribers);
/* begin protect ndb_schema_share */ /* begin protect ndb_schema_share */
pthread_mutex_lock(&ndb_schema_share_mutex); mysql_mutex_lock(&ndb_schema_share_mutex);
if (ndb_schema_share == 0) if (ndb_schema_share == 0)
{ {
pthread_mutex_unlock(&ndb_schema_share_mutex); mysql_mutex_unlock(&ndb_schema_share_mutex);
if (ndb_schema_object) if (ndb_schema_object)
ndb_free_schema_object(&ndb_schema_object, FALSE); ndb_free_schema_object(&ndb_schema_object, FALSE);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
(void) pthread_mutex_lock(&ndb_schema_share->mutex); mysql_mutex_lock(&ndb_schema_share->mutex);
for (i= 0; i < no_storage_nodes; i++) for (i= 0; i < no_storage_nodes; i++)
{ {
MY_BITMAP *table_subscribers= &ndb_schema_share->subscriber_bitmap[i]; MY_BITMAP *table_subscribers= &ndb_schema_share->subscriber_bitmap[i];
@ -1376,8 +1376,8 @@ int ndbcluster_log_schema_op(THD *thd, NDB_SHARE *share,
updated= 1; updated= 1;
} }
} }
(void) pthread_mutex_unlock(&ndb_schema_share->mutex); mysql_mutex_unlock(&ndb_schema_share->mutex);
pthread_mutex_unlock(&ndb_schema_share_mutex); mysql_mutex_unlock(&ndb_schema_share_mutex);
/* end protect ndb_schema_share */ /* end protect ndb_schema_share */
if (updated) if (updated)
@ -1397,10 +1397,10 @@ int ndbcluster_log_schema_op(THD *thd, NDB_SHARE *share,
if (ndb_schema_object) if (ndb_schema_object)
{ {
(void) pthread_mutex_lock(&ndb_schema_object->mutex); mysql_mutex_lock(&ndb_schema_object->mutex);
memcpy(ndb_schema_object->slock, schema_subscribers.bitmap, memcpy(ndb_schema_object->slock, schema_subscribers.bitmap,
sizeof(ndb_schema_object->slock)); sizeof(ndb_schema_object->slock));
(void) pthread_mutex_unlock(&ndb_schema_object->mutex); mysql_mutex_unlock(&ndb_schema_object->mutex);
} }
DBUG_DUMP("schema_subscribers", (uchar*)schema_subscribers.bitmap, DBUG_DUMP("schema_subscribers", (uchar*)schema_subscribers.bitmap,
@ -1566,7 +1566,7 @@ end:
dict->forceGCPWait(); dict->forceGCPWait();
int max_timeout= DEFAULT_SYNC_TIMEOUT; int max_timeout= DEFAULT_SYNC_TIMEOUT;
(void) pthread_mutex_lock(&ndb_schema_object->mutex); mysql_mutex_lock(&ndb_schema_object->mutex);
if (have_lock_open) if (have_lock_open)
{ {
mysql_mutex_assert_owner(&LOCK_open); mysql_mutex_assert_owner(&LOCK_open);
@ -1578,20 +1578,20 @@ end:
int i; int i;
int no_storage_nodes= g_ndb_cluster_connection->no_db_nodes(); int no_storage_nodes= g_ndb_cluster_connection->no_db_nodes();
set_timespec(abstime, 1); set_timespec(abstime, 1);
int ret= pthread_cond_timedwait(&injector_cond, int ret= mysql_cond_timedwait(&injector_cond,
&ndb_schema_object->mutex, &ndb_schema_object->mutex,
&abstime); &abstime);
if (thd->killed) if (thd->killed)
break; break;
/* begin protect ndb_schema_share */ /* begin protect ndb_schema_share */
pthread_mutex_lock(&ndb_schema_share_mutex); mysql_mutex_lock(&ndb_schema_share_mutex);
if (ndb_schema_share == 0) if (ndb_schema_share == 0)
{ {
pthread_mutex_unlock(&ndb_schema_share_mutex); mysql_mutex_unlock(&ndb_schema_share_mutex);
break; break;
} }
(void) pthread_mutex_lock(&ndb_schema_share->mutex); mysql_mutex_lock(&ndb_schema_share->mutex);
for (i= 0; i < no_storage_nodes; i++) for (i= 0; i < no_storage_nodes; i++)
{ {
/* remove any unsubscribed from schema_subscribers */ /* remove any unsubscribed from schema_subscribers */
@ -1599,8 +1599,8 @@ end:
if (!bitmap_is_clear_all(tmp)) if (!bitmap_is_clear_all(tmp))
bitmap_intersect(&schema_subscribers, tmp); bitmap_intersect(&schema_subscribers, tmp);
} }
(void) pthread_mutex_unlock(&ndb_schema_share->mutex); mysql_mutex_unlock(&ndb_schema_share->mutex);
pthread_mutex_unlock(&ndb_schema_share_mutex); mysql_mutex_unlock(&ndb_schema_share_mutex);
/* end protect ndb_schema_share */ /* end protect ndb_schema_share */
/* remove any unsubscribed from ndb_schema_object->slock */ /* remove any unsubscribed from ndb_schema_object->slock */
@ -1631,7 +1631,7 @@ end:
{ {
mysql_mutex_lock(&LOCK_open); mysql_mutex_lock(&LOCK_open);
} }
(void) pthread_mutex_unlock(&ndb_schema_object->mutex); mysql_mutex_unlock(&ndb_schema_object->mutex);
} }
if (ndb_schema_object) if (ndb_schema_object)
@ -1761,11 +1761,11 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
if (is_online_alter_table) if (is_online_alter_table)
{ {
/* Signal ha_ndbcluster::alter_table that drop is done */ /* Signal ha_ndbcluster::alter_table that drop is done */
(void) pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
(void) pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
if (is_rename_table && !is_remote_change) if (is_rename_table && !is_remote_change)
{ {
DBUG_PRINT("info", ("Detected name change of table %s.%s", DBUG_PRINT("info", ("Detected name change of table %s.%s",
@ -1801,10 +1801,10 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
// either just us or drop table handling as well // either just us or drop table handling as well
/* Signal ha_ndbcluster::delete/rename_table that drop is done */ /* Signal ha_ndbcluster::delete/rename_table that drop is done */
(void) pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
(void) pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
/* ndb_share reference binlog free */ /* ndb_share reference binlog free */
DBUG_PRINT("NDB_SHARE", ("%s binlog free use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s binlog free use_count: %u",
share->key, share->use_count)); share->key, share->use_count));
@ -1830,14 +1830,14 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
} }
else else
share= 0; share= 0;
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
pOp->setCustomData(0); pOp->setCustomData(0);
pthread_mutex_lock(&injector_mutex); mysql_mutex_lock(&injector_mutex);
ndb->dropEventOperation(pOp); ndb->dropEventOperation(pOp);
pOp= 0; pOp= 0;
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
if (do_close_cached_tables) if (do_close_cached_tables)
{ {
@ -2072,7 +2072,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
"read only on reconnect."); "read only on reconnect.");
/* begin protect ndb_schema_share */ /* begin protect ndb_schema_share */
pthread_mutex_lock(&ndb_schema_share_mutex); mysql_mutex_lock(&ndb_schema_share_mutex);
/* ndb_share reference binlog extra free */ /* ndb_share reference binlog extra free */
DBUG_PRINT("NDB_SHARE", ("%s binlog extra free use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s binlog extra free use_count: %u",
ndb_schema_share->key, ndb_schema_share->key,
@ -2080,7 +2080,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
free_share(&ndb_schema_share); free_share(&ndb_schema_share);
ndb_schema_share= 0; ndb_schema_share= 0;
ndb_binlog_tables_inited= 0; ndb_binlog_tables_inited= 0;
pthread_mutex_unlock(&ndb_schema_share_mutex); mysql_mutex_unlock(&ndb_schema_share_mutex);
/* end protect ndb_schema_share */ /* end protect ndb_schema_share */
close_cached_tables(NULL, NULL, FALSE, FALSE, FALSE); close_cached_tables(NULL, NULL, FALSE, FALSE, FALSE);
@ -2092,7 +2092,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
{ {
uint8 node_id= g_node_id_map[pOp->getNdbdNodeId()]; uint8 node_id= g_node_id_map[pOp->getNdbdNodeId()];
DBUG_ASSERT(node_id != 0xFF); DBUG_ASSERT(node_id != 0xFF);
(void) pthread_mutex_lock(&tmp_share->mutex); mysql_mutex_lock(&tmp_share->mutex);
bitmap_clear_all(&tmp_share->subscriber_bitmap[node_id]); bitmap_clear_all(&tmp_share->subscriber_bitmap[node_id]);
DBUG_PRINT("info",("NODE_FAILURE UNSUBSCRIBE[%d]", node_id)); DBUG_PRINT("info",("NODE_FAILURE UNSUBSCRIBE[%d]", node_id));
if (opt_ndb_extra_logging) if (opt_ndb_extra_logging)
@ -2103,8 +2103,8 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
tmp_share->subscriber_bitmap[node_id].bitmap[1], tmp_share->subscriber_bitmap[node_id].bitmap[1],
tmp_share->subscriber_bitmap[node_id].bitmap[0]); tmp_share->subscriber_bitmap[node_id].bitmap[0]);
} }
(void) pthread_mutex_unlock(&tmp_share->mutex); mysql_mutex_unlock(&tmp_share->mutex);
(void) pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
break; break;
} }
case NDBEVENT::TE_SUBSCRIBE: case NDBEVENT::TE_SUBSCRIBE:
@ -2112,7 +2112,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
uint8 node_id= g_node_id_map[pOp->getNdbdNodeId()]; uint8 node_id= g_node_id_map[pOp->getNdbdNodeId()];
uint8 req_id= pOp->getReqNodeId(); uint8 req_id= pOp->getReqNodeId();
DBUG_ASSERT(req_id != 0 && node_id != 0xFF); DBUG_ASSERT(req_id != 0 && node_id != 0xFF);
(void) pthread_mutex_lock(&tmp_share->mutex); mysql_mutex_lock(&tmp_share->mutex);
bitmap_set_bit(&tmp_share->subscriber_bitmap[node_id], req_id); bitmap_set_bit(&tmp_share->subscriber_bitmap[node_id], req_id);
DBUG_PRINT("info",("SUBSCRIBE[%d] %d", node_id, req_id)); DBUG_PRINT("info",("SUBSCRIBE[%d] %d", node_id, req_id));
if (opt_ndb_extra_logging) if (opt_ndb_extra_logging)
@ -2124,8 +2124,8 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
tmp_share->subscriber_bitmap[node_id].bitmap[1], tmp_share->subscriber_bitmap[node_id].bitmap[1],
tmp_share->subscriber_bitmap[node_id].bitmap[0]); tmp_share->subscriber_bitmap[node_id].bitmap[0]);
} }
(void) pthread_mutex_unlock(&tmp_share->mutex); mysql_mutex_unlock(&tmp_share->mutex);
(void) pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
break; break;
} }
case NDBEVENT::TE_UNSUBSCRIBE: case NDBEVENT::TE_UNSUBSCRIBE:
@ -2133,7 +2133,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
uint8 node_id= g_node_id_map[pOp->getNdbdNodeId()]; uint8 node_id= g_node_id_map[pOp->getNdbdNodeId()];
uint8 req_id= pOp->getReqNodeId(); uint8 req_id= pOp->getReqNodeId();
DBUG_ASSERT(req_id != 0 && node_id != 0xFF); DBUG_ASSERT(req_id != 0 && node_id != 0xFF);
(void) pthread_mutex_lock(&tmp_share->mutex); mysql_mutex_lock(&tmp_share->mutex);
bitmap_clear_bit(&tmp_share->subscriber_bitmap[node_id], req_id); bitmap_clear_bit(&tmp_share->subscriber_bitmap[node_id], req_id);
DBUG_PRINT("info",("UNSUBSCRIBE[%d] %d", node_id, req_id)); DBUG_PRINT("info",("UNSUBSCRIBE[%d] %d", node_id, req_id));
if (opt_ndb_extra_logging) if (opt_ndb_extra_logging)
@ -2145,8 +2145,8 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
tmp_share->subscriber_bitmap[node_id].bitmap[1], tmp_share->subscriber_bitmap[node_id].bitmap[1],
tmp_share->subscriber_bitmap[node_id].bitmap[0]); tmp_share->subscriber_bitmap[node_id].bitmap[0]);
} }
(void) pthread_mutex_unlock(&tmp_share->mutex); mysql_mutex_unlock(&tmp_share->mutex);
(void) pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
break; break;
} }
default: default:
@ -2186,22 +2186,22 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd,
build_table_filename(key, sizeof(key) - 1, schema->db, schema->name, "", 0); build_table_filename(key, sizeof(key) - 1, schema->db, schema->name, "", 0);
if (schema_type == SOT_CLEAR_SLOCK) if (schema_type == SOT_CLEAR_SLOCK)
{ {
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
NDB_SCHEMA_OBJECT *ndb_schema_object= NDB_SCHEMA_OBJECT *ndb_schema_object=
(NDB_SCHEMA_OBJECT*) my_hash_search(&ndb_schema_objects, (NDB_SCHEMA_OBJECT*) my_hash_search(&ndb_schema_objects,
(uchar*) key, strlen(key)); (uchar*) key, strlen(key));
if (ndb_schema_object) if (ndb_schema_object)
{ {
pthread_mutex_lock(&ndb_schema_object->mutex); mysql_mutex_lock(&ndb_schema_object->mutex);
memcpy(ndb_schema_object->slock, schema->slock, memcpy(ndb_schema_object->slock, schema->slock,
sizeof(ndb_schema_object->slock)); sizeof(ndb_schema_object->slock));
DBUG_DUMP("ndb_schema_object->slock_bitmap.bitmap", DBUG_DUMP("ndb_schema_object->slock_bitmap.bitmap",
(uchar*)ndb_schema_object->slock_bitmap.bitmap, (uchar*)ndb_schema_object->slock_bitmap.bitmap,
no_bytes_in_map(&ndb_schema_object->slock_bitmap)); no_bytes_in_map(&ndb_schema_object->slock_bitmap));
pthread_mutex_unlock(&ndb_schema_object->mutex); mysql_mutex_unlock(&ndb_schema_object->mutex);
pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
} }
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
continue; continue;
} }
/* ndb_share reference temporary, free below */ /* ndb_share reference temporary, free below */
@ -2462,27 +2462,29 @@ int ndbcluster_binlog_start()
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
pthread_mutex_init(&injector_mutex, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_injector_mutex, &injector_mutex, MY_MUTEX_INIT_FAST);
pthread_cond_init(&injector_cond, NULL); mysql_cond_init(key_injector_cond, &injector_cond, NULL);
pthread_mutex_init(&ndb_schema_share_mutex, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_ndb_schema_share_mutex,
&ndb_schema_share_mutex, MY_MUTEX_INIT_FAST);
/* Create injector thread */ /* Create injector thread */
if (pthread_create(&ndb_binlog_thread, &connection_attrib, if (mysql_thread_create(key_thread_ndb_binlog,
&ndb_binlog_thread, &connection_attrib,
ndb_binlog_thread_func, 0)) ndb_binlog_thread_func, 0))
{ {
DBUG_PRINT("error", ("Could not create ndb injector thread")); DBUG_PRINT("error", ("Could not create ndb injector thread"));
pthread_cond_destroy(&injector_cond); mysql_cond_destroy(&injector_cond);
pthread_mutex_destroy(&injector_mutex); mysql_mutex_destroy(&injector_mutex);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
ndbcluster_binlog_inited= 1; ndbcluster_binlog_inited= 1;
/* Wait for the injector thread to start */ /* Wait for the injector thread to start */
pthread_mutex_lock(&injector_mutex); mysql_mutex_lock(&injector_mutex);
while (!ndb_binlog_thread_running) while (!ndb_binlog_thread_running)
pthread_cond_wait(&injector_cond, &injector_mutex); mysql_cond_wait(&injector_cond, &injector_mutex);
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
if (ndb_binlog_thread_running < 0) if (ndb_binlog_thread_running < 0)
DBUG_RETURN(-1); DBUG_RETURN(-1);
@ -2572,7 +2574,7 @@ int ndbcluster_create_binlog_setup(Ndb *ndb, const char *key,
DBUG_ASSERT(! IS_NDB_BLOB_PREFIX(table_name)); DBUG_ASSERT(! IS_NDB_BLOB_PREFIX(table_name));
DBUG_ASSERT(strlen(key) == key_len); DBUG_ASSERT(strlen(key) == key_len);
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
/* Handle any trailing share */ /* Handle any trailing share */
NDB_SHARE *share= (NDB_SHARE*) my_hash_search(&ndbcluster_open_tables, NDB_SHARE *share= (NDB_SHARE*) my_hash_search(&ndbcluster_open_tables,
@ -2584,7 +2586,7 @@ int ndbcluster_create_binlog_setup(Ndb *ndb, const char *key,
share->op != 0 || share->op != 0 ||
share->op_old != 0) share->op_old != 0)
{ {
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
DBUG_RETURN(0); // replication already setup, or should not DBUG_RETURN(0); // replication already setup, or should not
} }
} }
@ -2594,7 +2596,7 @@ int ndbcluster_create_binlog_setup(Ndb *ndb, const char *key,
if (share->op || share->op_old) if (share->op || share->op_old)
{ {
my_errno= HA_ERR_TABLE_EXIST; my_errno= HA_ERR_TABLE_EXIST;
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (!share_may_exist || share->connect_count != if (!share_may_exist || share->connect_count !=
@ -2637,10 +2639,10 @@ int ndbcluster_create_binlog_setup(Ndb *ndb, const char *key,
if (!do_event_op) if (!do_event_op)
{ {
share->flags|= NSF_NO_BINLOG; share->flags|= NSF_NO_BINLOG;
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
while (share && !IS_TMP_PREFIX(table_name)) while (share && !IS_TMP_PREFIX(table_name))
{ {
@ -2933,14 +2935,14 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab,
int retry_sleep= 100; int retry_sleep= 100;
while (1) while (1)
{ {
pthread_mutex_lock(&injector_mutex); mysql_mutex_lock(&injector_mutex);
Ndb *ndb= injector_ndb; Ndb *ndb= injector_ndb;
if (do_ndb_schema_share) if (do_ndb_schema_share)
ndb= schema_ndb; ndb= schema_ndb;
if (ndb == 0) if (ndb == 0)
{ {
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
@ -2965,7 +2967,7 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab,
ndb->getNdbError().code, ndb->getNdbError().code,
ndb->getNdbError().message, ndb->getNdbError().message,
"NDB"); "NDB");
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
@ -3015,7 +3017,7 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab,
op->getNdbError().message, op->getNdbError().message,
"NDB"); "NDB");
ndb->dropEventOperation(op); ndb->dropEventOperation(op);
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
} }
@ -3057,7 +3059,7 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab,
op->getNdbError().code, op->getNdbError().message); op->getNdbError().code, op->getNdbError().message);
} }
ndb->dropEventOperation(op); ndb->dropEventOperation(op);
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
if (retries) if (retries)
{ {
my_sleep(retry_sleep); my_sleep(retry_sleep);
@ -3065,7 +3067,7 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab,
} }
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
break; break;
} }
@ -3079,7 +3081,7 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab,
ndb_apply_status_share= get_share(share); ndb_apply_status_share= get_share(share);
DBUG_PRINT("NDB_SHARE", ("%s binlog extra use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s binlog extra use_count: %u",
share->key, share->use_count)); share->key, share->use_count));
(void) pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
} }
else if (do_ndb_schema_share) else if (do_ndb_schema_share)
{ {
@ -3087,7 +3089,7 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab,
ndb_schema_share= get_share(share); ndb_schema_share= get_share(share);
DBUG_PRINT("NDB_SHARE", ("%s binlog extra use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s binlog extra use_count: %u",
share->key, share->use_count)); share->key, share->use_count));
(void) pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
} }
DBUG_PRINT("info",("%s share->op: 0x%lx share->use_count: %u", DBUG_PRINT("info",("%s share->op: 0x%lx share->use_count: %u",
@ -3158,7 +3160,7 @@ ndbcluster_handle_drop_table(Ndb *ndb, const char *event_name,
#define SYNC_DROP_ #define SYNC_DROP_
#ifdef SYNC_DROP_ #ifdef SYNC_DROP_
thd->proc_info= "Syncing ndb table schema operation and binlog"; thd->proc_info= "Syncing ndb table schema operation and binlog";
(void) pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
mysql_mutex_assert_owner(&LOCK_open); mysql_mutex_assert_owner(&LOCK_open);
mysql_mutex_unlock(&LOCK_open); mysql_mutex_unlock(&LOCK_open);
int max_timeout= DEFAULT_SYNC_TIMEOUT; int max_timeout= DEFAULT_SYNC_TIMEOUT;
@ -3166,7 +3168,7 @@ ndbcluster_handle_drop_table(Ndb *ndb, const char *event_name,
{ {
struct timespec abstime; struct timespec abstime;
set_timespec(abstime, 1); set_timespec(abstime, 1);
int ret= pthread_cond_timedwait(&injector_cond, int ret= mysql_cond_timedwait(&injector_cond,
&share->mutex, &share->mutex,
&abstime); &abstime);
if (thd->killed || if (thd->killed ||
@ -3187,12 +3189,12 @@ ndbcluster_handle_drop_table(Ndb *ndb, const char *event_name,
} }
} }
mysql_mutex_lock(&LOCK_open); mysql_mutex_lock(&LOCK_open);
(void) pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
#else #else
(void) pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
share->op_old= share->op; share->op_old= share->op;
share->op= 0; share->op= 0;
(void) pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
#endif #endif
thd->proc_info= save_proc_info; thd->proc_info= save_proc_info;
@ -3560,7 +3562,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key,
DBUG_PRINT("enter", ("key: '%s'", key)); DBUG_PRINT("enter", ("key: '%s'", key));
if (!have_lock) if (!have_lock)
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
while (!(ndb_schema_object= while (!(ndb_schema_object=
(NDB_SCHEMA_OBJECT*) my_hash_search(&ndb_schema_objects, (NDB_SCHEMA_OBJECT*) my_hash_search(&ndb_schema_objects,
(uchar*) key, (uchar*) key,
@ -3586,7 +3588,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key,
my_free((uchar*) ndb_schema_object, 0); my_free((uchar*) ndb_schema_object, 0);
break; break;
} }
pthread_mutex_init(&ndb_schema_object->mutex, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_ndb_schema_object_mutex, &ndb_schema_object->mutex, MY_MUTEX_INIT_FAST);
bitmap_init(&ndb_schema_object->slock_bitmap, ndb_schema_object->slock, bitmap_init(&ndb_schema_object->slock_bitmap, ndb_schema_object->slock,
sizeof(ndb_schema_object->slock)*8, FALSE); sizeof(ndb_schema_object->slock)*8, FALSE);
bitmap_clear_all(&ndb_schema_object->slock_bitmap); bitmap_clear_all(&ndb_schema_object->slock_bitmap);
@ -3598,7 +3600,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key,
DBUG_PRINT("info", ("use_count: %d", ndb_schema_object->use_count)); DBUG_PRINT("info", ("use_count: %d", ndb_schema_object->use_count));
} }
if (!have_lock) if (!have_lock)
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
DBUG_RETURN(ndb_schema_object); DBUG_RETURN(ndb_schema_object);
} }
@ -3609,12 +3611,12 @@ static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object,
DBUG_ENTER("ndb_free_schema_object"); DBUG_ENTER("ndb_free_schema_object");
DBUG_PRINT("enter", ("key: '%s'", (*ndb_schema_object)->key)); DBUG_PRINT("enter", ("key: '%s'", (*ndb_schema_object)->key));
if (!have_lock) if (!have_lock)
pthread_mutex_lock(&ndbcluster_mutex); mysql_mutex_lock(&ndbcluster_mutex);
if (!--(*ndb_schema_object)->use_count) if (!--(*ndb_schema_object)->use_count)
{ {
DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count)); DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count));
my_hash_delete(&ndb_schema_objects, (uchar*) *ndb_schema_object); my_hash_delete(&ndb_schema_objects, (uchar*) *ndb_schema_object);
pthread_mutex_destroy(&(*ndb_schema_object)->mutex); mysql_mutex_destroy(&(*ndb_schema_object)->mutex);
my_free((uchar*) *ndb_schema_object, MYF(0)); my_free((uchar*) *ndb_schema_object, MYF(0));
*ndb_schema_object= 0; *ndb_schema_object= 0;
} }
@ -3623,7 +3625,7 @@ static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object,
DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count)); DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count));
} }
if (!have_lock) if (!have_lock)
pthread_mutex_unlock(&ndbcluster_mutex); mysql_mutex_unlock(&ndbcluster_mutex);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -3644,7 +3646,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
Timer main_timer; Timer main_timer;
#endif #endif
pthread_mutex_lock(&injector_mutex); mysql_mutex_lock(&injector_mutex);
/* /*
Set up the Thread Set up the Thread
*/ */
@ -3661,14 +3663,16 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
thd->thread_id= thread_id++; thd->thread_id= thread_id++;
pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_thread_count);
mysql_thread_set_psi_id(thd->thread_id);
thd->thread_stack= (char*) &thd; /* remember where our stack is */ thd->thread_stack= (char*) &thd; /* remember where our stack is */
if (thd->store_globals()) if (thd->store_globals())
{ {
thd->cleanup(); thd->cleanup();
delete thd; delete thd;
ndb_binlog_thread_running= -1; ndb_binlog_thread_running= -1;
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
DBUG_LEAVE; // Must match DBUG_ENTER() DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end(); my_thread_end();
@ -3703,8 +3707,8 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
{ {
sql_print_error("NDB Binlog: Getting Schema Ndb object failed"); sql_print_error("NDB Binlog: Getting Schema Ndb object failed");
ndb_binlog_thread_running= -1; ndb_binlog_thread_running= -1;
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
goto err; goto err;
} }
@ -3714,8 +3718,8 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
{ {
sql_print_error("NDB Binlog: Getting Ndb object failed"); sql_print_error("NDB Binlog: Getting Ndb object failed");
ndb_binlog_thread_running= -1; ndb_binlog_thread_running= -1;
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
goto err; goto err;
} }
@ -3728,7 +3732,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
Used by both sql client thread and binlog thread to interact Used by both sql client thread and binlog thread to interact
with the storage with the storage
pthread_mutex_lock(&injector_mutex); mysql_mutex_lock(&injector_mutex);
*/ */
injector_thd= thd; injector_thd= thd;
injector_ndb= i_ndb; injector_ndb= i_ndb;
@ -3743,27 +3747,27 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
/* Thread start up completed */ /* Thread start up completed */
ndb_binlog_thread_running= 1; ndb_binlog_thread_running= 1;
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
/* /*
wait for mysql server to start (so that the binlog is started wait for mysql server to start (so that the binlog is started
and thus can receive the first GAP event) and thus can receive the first GAP event)
*/ */
pthread_mutex_lock(&LOCK_server_started); mysql_mutex_lock(&LOCK_server_started);
while (!mysqld_server_started) while (!mysqld_server_started)
{ {
struct timespec abstime; struct timespec abstime;
set_timespec(abstime, 1); set_timespec(abstime, 1);
pthread_cond_timedwait(&COND_server_started, &LOCK_server_started, mysql_cond_timedwait(&COND_server_started, &LOCK_server_started,
&abstime); &abstime);
if (ndbcluster_terminating) if (ndbcluster_terminating)
{ {
pthread_mutex_unlock(&LOCK_server_started); mysql_mutex_unlock(&LOCK_server_started);
goto err; goto err;
} }
} }
pthread_mutex_unlock(&LOCK_server_started); mysql_mutex_unlock(&LOCK_server_started);
restart: restart:
/* /*
Main NDB Injector loop Main NDB Injector loop
@ -3806,21 +3810,21 @@ restart:
{ {
thd->proc_info= "Waiting for ndbcluster to start"; thd->proc_info= "Waiting for ndbcluster to start";
pthread_mutex_lock(&injector_mutex); mysql_mutex_lock(&injector_mutex);
while (!ndb_schema_share || while (!ndb_schema_share ||
(ndb_binlog_running && !ndb_apply_status_share)) (ndb_binlog_running && !ndb_apply_status_share))
{ {
/* ndb not connected yet */ /* ndb not connected yet */
struct timespec abstime; struct timespec abstime;
set_timespec(abstime, 1); set_timespec(abstime, 1);
pthread_cond_timedwait(&injector_cond, &injector_mutex, &abstime); mysql_cond_timedwait(&injector_cond, &injector_mutex, &abstime);
if (ndbcluster_binlog_terminating) if (ndbcluster_binlog_terminating)
{ {
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
goto err; goto err;
} }
} }
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
if (thd_ndb == NULL) if (thd_ndb == NULL)
{ {
@ -4291,13 +4295,13 @@ err:
DBUG_PRINT("info",("Shutting down cluster binlog thread")); DBUG_PRINT("info",("Shutting down cluster binlog thread"));
thd->proc_info= "Shutting down"; thd->proc_info= "Shutting down";
close_thread_tables(thd); close_thread_tables(thd);
pthread_mutex_lock(&injector_mutex); mysql_mutex_lock(&injector_mutex);
/* don't mess with the injector_ndb anymore from other threads */ /* don't mess with the injector_ndb anymore from other threads */
injector_thd= 0; injector_thd= 0;
injector_ndb= 0; injector_ndb= 0;
p_latest_trans_gci= 0; p_latest_trans_gci= 0;
schema_ndb= 0; schema_ndb= 0;
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
thd->db= 0; // as not to try to free memory thd->db= 0; // as not to try to free memory
if (ndb_apply_status_share) if (ndb_apply_status_share)
@ -4312,7 +4316,7 @@ err:
if (ndb_schema_share) if (ndb_schema_share)
{ {
/* begin protect ndb_schema_share */ /* begin protect ndb_schema_share */
pthread_mutex_lock(&ndb_schema_share_mutex); mysql_mutex_lock(&ndb_schema_share_mutex);
/* ndb_share reference binlog extra free */ /* ndb_share reference binlog extra free */
DBUG_PRINT("NDB_SHARE", ("%s binlog extra free use_count: %u", DBUG_PRINT("NDB_SHARE", ("%s binlog extra free use_count: %u",
ndb_schema_share->key, ndb_schema_share->key,
@ -4320,7 +4324,7 @@ err:
free_share(&ndb_schema_share); free_share(&ndb_schema_share);
ndb_schema_share= 0; ndb_schema_share= 0;
ndb_binlog_tables_inited= 0; ndb_binlog_tables_inited= 0;
pthread_mutex_unlock(&ndb_schema_share_mutex); mysql_mutex_unlock(&ndb_schema_share_mutex);
/* end protect ndb_schema_share */ /* end protect ndb_schema_share */
} }
@ -4380,7 +4384,7 @@ err:
ndb_binlog_thread_running= -1; ndb_binlog_thread_running= -1;
ndb_binlog_running= FALSE; ndb_binlog_running= FALSE;
(void) pthread_cond_signal(&injector_cond); mysql_cond_signal(&injector_cond);
DBUG_PRINT("exit", ("ndb_binlog_thread")); DBUG_PRINT("exit", ("ndb_binlog_thread"));
@ -4399,12 +4403,12 @@ ndbcluster_show_status_binlog(THD* thd, stat_print_fn *stat_print,
ulonglong ndb_latest_epoch= 0; ulonglong ndb_latest_epoch= 0;
DBUG_ENTER("ndbcluster_show_status_binlog"); DBUG_ENTER("ndbcluster_show_status_binlog");
pthread_mutex_lock(&injector_mutex); mysql_mutex_lock(&injector_mutex);
if (injector_ndb) if (injector_ndb)
{ {
char buff1[22],buff2[22],buff3[22],buff4[22],buff5[22]; char buff1[22],buff2[22],buff3[22],buff4[22],buff5[22];
ndb_latest_epoch= injector_ndb->getLatestGCI(); ndb_latest_epoch= injector_ndb->getLatestGCI();
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
buflen= buflen=
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
@ -4424,7 +4428,7 @@ ndbcluster_show_status_binlog(THD* thd, stat_print_fn *stat_print,
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
else else
pthread_mutex_unlock(&injector_mutex); mysql_mutex_unlock(&injector_mutex);
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }

View File

@ -1,7 +1,7 @@
#ifndef HA_NDBCLUSTER_BINLOG_INCLUDED #ifndef HA_NDBCLUSTER_BINLOG_INCLUDED
#define HA_NDBCLUSTER_BINLOG_INCLUDED #define HA_NDBCLUSTER_BINLOG_INCLUDED
/* Copyright (C) 2000-2003 MySQL AB /* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -104,16 +104,24 @@ private:
}; };
#ifdef HAVE_NDB_BINLOG #ifdef HAVE_NDB_BINLOG
#ifdef HAVE_PSI_INTERFACE
extern PSI_mutex_key key_injector_mutex, key_ndb_schema_share_mutex,
key_ndb_schema_object_mutex;
extern PSI_cond_key key_injector_cond;
extern PSI_thread_key key_thread_ndb_binlog;
#endif /* HAVE_PSI_INTERFACE */
extern pthread_t ndb_binlog_thread; extern pthread_t ndb_binlog_thread;
extern pthread_mutex_t injector_mutex; extern mysql_mutex_t injector_mutex;
extern pthread_cond_t injector_cond; extern mysql_cond_t injector_cond;
extern unsigned char g_node_id_map[max_ndb_nodes]; extern unsigned char g_node_id_map[max_ndb_nodes];
extern pthread_t ndb_util_thread; extern pthread_t ndb_util_thread;
extern pthread_mutex_t LOCK_ndb_util_thread; extern mysql_mutex_t LOCK_ndb_util_thread;
extern pthread_cond_t COND_ndb_util_thread; extern mysql_cond_t COND_ndb_util_thread;
extern int ndbcluster_util_inited; extern int ndbcluster_util_inited;
extern pthread_mutex_t ndbcluster_mutex; extern mysql_mutex_t ndbcluster_mutex;
extern HASH ndbcluster_open_tables; extern HASH ndbcluster_open_tables;
extern Ndb_cluster_connection* g_ndb_cluster_connection; extern Ndb_cluster_connection* g_ndb_cluster_connection;
extern long ndb_number_of_storage_nodes; extern long ndb_number_of_storage_nodes;

View File

@ -500,9 +500,9 @@ int ha_partition::create_handler_files(const char *path,
strxmov(name, path, ha_par_ext, NullS); strxmov(name, path, ha_par_ext, NullS);
strxmov(old_name, old_path, ha_par_ext, NullS); strxmov(old_name, old_path, ha_par_ext, NullS);
if ((action_flag == CHF_DELETE_FLAG && if ((action_flag == CHF_DELETE_FLAG &&
my_delete(name, MYF(MY_WME))) || mysql_file_delete(key_file_partition, name, MYF(MY_WME))) ||
(action_flag == CHF_RENAME_FLAG && (action_flag == CHF_RENAME_FLAG &&
my_rename(old_name, name, MYF(MY_WME)))) mysql_file_rename(key_file_partition, old_name, name, MYF(MY_WME))))
{ {
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -2205,12 +2205,13 @@ bool ha_partition::create_handler_file(const char *name)
to be used at open, delete_table and rename_table to be used at open, delete_table and rename_table
*/ */
fn_format(file_name, name, "", ha_par_ext, MY_APPEND_EXT); fn_format(file_name, name, "", ha_par_ext, MY_APPEND_EXT);
if ((file= my_create(file_name, CREATE_MODE, O_RDWR | O_TRUNC, if ((file= mysql_file_create(key_file_partition,
file_name, CREATE_MODE, O_RDWR | O_TRUNC,
MYF(MY_WME))) >= 0) MYF(MY_WME))) >= 0)
{ {
result= my_write(file, (uchar *) file_buffer, tot_len_byte, result= mysql_file_write(file, (uchar *) file_buffer, tot_len_byte,
MYF(MY_WME | MY_NABP)) != 0; MYF(MY_WME | MY_NABP)) != 0;
(void) my_close(file, MYF(0)); (void) mysql_file_close(file, MYF(0));
} }
else else
result= TRUE; result= TRUE;
@ -2387,17 +2388,18 @@ bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
fn_format(buff, name, "", ha_par_ext, MY_APPEND_EXT); fn_format(buff, name, "", ha_par_ext, MY_APPEND_EXT);
/* Following could be done with my_stat to read in whole file */ /* Following could be done with mysql_file_stat to read in whole file */
if ((file= my_open(buff, O_RDONLY | O_SHARE, MYF(0))) < 0) if ((file= mysql_file_open(key_file_partition,
buff, O_RDONLY | O_SHARE, MYF(0))) < 0)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (my_read(file, (uchar *) & buff[0], 8, MYF(MY_NABP))) if (mysql_file_read(file, (uchar *) &buff[0], 8, MYF(MY_NABP)))
goto err1; goto err1;
len_words= uint4korr(buff); len_words= uint4korr(buff);
len_bytes= 4 * len_words; len_bytes= 4 * len_words;
if (!(file_buffer= (char*) my_malloc(len_bytes, MYF(0)))) if (!(file_buffer= (char*) my_malloc(len_bytes, MYF(0))))
goto err1; goto err1;
my_seek(file, 0, MY_SEEK_SET, MYF(0)); mysql_file_seek(file, 0, MY_SEEK_SET, MYF(0));
if (my_read(file, (uchar *) file_buffer, len_bytes, MYF(MY_NABP))) if (mysql_file_read(file, (uchar *) file_buffer, len_bytes, MYF(MY_NABP)))
goto err2; goto err2;
chksum= 0; chksum= 0;
@ -2418,7 +2420,7 @@ bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root)
if (len_words != (tot_partition_words + tot_name_words + 4)) if (len_words != (tot_partition_words + tot_name_words + 4))
goto err3; goto err3;
name_buffer_ptr= file_buffer + 16 + 4 * tot_partition_words; name_buffer_ptr= file_buffer + 16 + 4 * tot_partition_words;
(void) my_close(file, MYF(0)); (void) mysql_file_close(file, MYF(0));
m_file_buffer= file_buffer; // Will be freed in clear_handler_file() m_file_buffer= file_buffer; // Will be freed in clear_handler_file()
m_name_buffer_ptr= name_buffer_ptr; m_name_buffer_ptr= name_buffer_ptr;
@ -2443,7 +2445,7 @@ err3:
err2: err2:
my_free(file_buffer, MYF(0)); my_free(file_buffer, MYF(0));
err1: err1:
(void) my_close(file, MYF(0)); (void) mysql_file_close(file, MYF(0));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -2606,7 +2608,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
for the same table. for the same table.
*/ */
if (is_not_tmp_table) if (is_not_tmp_table)
pthread_mutex_lock(&table_share->mutex); mysql_mutex_lock(&table_share->mutex);
if (!table_share->ha_data) if (!table_share->ha_data)
{ {
HA_DATA_PARTITION *ha_data; HA_DATA_PARTITION *ha_data;
@ -2617,7 +2619,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
if (!ha_data) if (!ha_data)
{ {
if (is_not_tmp_table) if (is_not_tmp_table)
pthread_mutex_unlock(&table_share->mutex); mysql_mutex_unlock(&table_share->mutex);
goto err_handler; goto err_handler;
} }
DBUG_PRINT("info", ("table_share->ha_data 0x%p", ha_data)); DBUG_PRINT("info", ("table_share->ha_data 0x%p", ha_data));
@ -2626,7 +2628,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
pthread_mutex_init(&ha_data->mutex, MY_MUTEX_INIT_FAST); pthread_mutex_init(&ha_data->mutex, MY_MUTEX_INIT_FAST);
} }
if (is_not_tmp_table) if (is_not_tmp_table)
pthread_mutex_unlock(&table_share->mutex); mysql_mutex_unlock(&table_share->mutex);
/* /*
Some handlers update statistics as part of the open call. This will in Some handlers update statistics as part of the open call. This will in
some cases corrupt the statistics of the partition handler and thus some cases corrupt the statistics of the partition handler and thus
@ -6633,7 +6635,7 @@ int ha_partition::indexes_are_disabled(void)
#ifdef NOT_USED #ifdef NOT_USED
static HASH partition_open_tables; static HASH partition_open_tables;
static pthread_mutex_t partition_mutex; static mysql_mutex_t partition_mutex;
static int partition_init= 0; static int partition_init= 0;
@ -6671,17 +6673,17 @@ static PARTITION_SHARE *get_share(const char *table_name, TABLE *table)
if (!partition_init) if (!partition_init)
{ {
/* Hijack a mutex for init'ing the storage engine */ /* Hijack a mutex for init'ing the storage engine */
pthread_mutex_lock(&LOCK_mysql_create_db); mysql_mutex_lock(&LOCK_mysql_create_db);
if (!partition_init) if (!partition_init)
{ {
partition_init++; partition_init++;
pthread_mutex_init(&partition_mutex, MY_MUTEX_INIT_FAST); mysql_mutex_init(INSTRUMENT_ME, &partition_mutex, MY_MUTEX_INIT_FAST);
(void) hash_init(&partition_open_tables, system_charset_info, 32, 0, 0, (void) hash_init(&partition_open_tables, system_charset_info, 32, 0, 0,
(hash_get_key) partition_get_key, 0, 0); (hash_get_key) partition_get_key, 0, 0);
} }
pthread_mutex_unlock(&LOCK_mysql_create_db); mysql_mutex_unlock(&LOCK_mysql_create_db);
} }
pthread_mutex_lock(&partition_mutex); mysql_mutex_lock(&partition_mutex);
length= (uint) strlen(table_name); length= (uint) strlen(table_name);
if (!(share= (PARTITION_SHARE *) hash_search(&partition_open_tables, if (!(share= (PARTITION_SHARE *) hash_search(&partition_open_tables,
@ -6692,7 +6694,7 @@ static PARTITION_SHARE *get_share(const char *table_name, TABLE *table)
&share, (uint) sizeof(*share), &share, (uint) sizeof(*share),
&tmp_name, (uint) length + 1, NullS))) &tmp_name, (uint) length + 1, NullS)))
{ {
pthread_mutex_unlock(&partition_mutex); mysql_mutex_unlock(&partition_mutex);
return NULL; return NULL;
} }
@ -6703,15 +6705,15 @@ static PARTITION_SHARE *get_share(const char *table_name, TABLE *table)
if (my_hash_insert(&partition_open_tables, (uchar *) share)) if (my_hash_insert(&partition_open_tables, (uchar *) share))
goto error; goto error;
thr_lock_init(&share->lock); thr_lock_init(&share->lock);
pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST); mysql_mutex_init(INSTRUMENT_ME, &share->mutex, MY_MUTEX_INIT_FAST);
} }
share->use_count++; share->use_count++;
pthread_mutex_unlock(&partition_mutex); mysql_mutex_unlock(&partition_mutex);
return share; return share;
error: error:
pthread_mutex_unlock(&partition_mutex); mysql_mutex_unlock(&partition_mutex);
my_free((uchar*) share, MYF(0)); my_free((uchar*) share, MYF(0));
return NULL; return NULL;
@ -6726,15 +6728,15 @@ error:
static int free_share(PARTITION_SHARE *share) static int free_share(PARTITION_SHARE *share)
{ {
pthread_mutex_lock(&partition_mutex); mysql_mutex_lock(&partition_mutex);
if (!--share->use_count) if (!--share->use_count)
{ {
hash_delete(&partition_open_tables, (uchar *) share); hash_delete(&partition_open_tables, (uchar *) share);
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex); mysql_mutex_destroy(&share->mutex);
my_free((uchar*) share, MYF(0)); my_free((uchar*) share, MYF(0));
} }
pthread_mutex_unlock(&partition_mutex); mysql_mutex_unlock(&partition_mutex);
return 0; return 0;
} }

View File

@ -36,7 +36,7 @@ typedef struct st_partition_share
{ {
char *table_name; char *table_name;
uint table_name_length, use_count; uint table_name_length, use_count;
pthread_mutex_t mutex; mysql_mutex_t mutex;
THR_LOCK lock; THR_LOCK lock;
} PARTITION_SHARE; } PARTITION_SHARE;
#endif #endif
@ -933,7 +933,7 @@ private:
if(table_share->tmp_table == NO_TMP_TABLE) if(table_share->tmp_table == NO_TMP_TABLE)
{ {
auto_increment_lock= TRUE; auto_increment_lock= TRUE;
pthread_mutex_lock(&table_share->mutex); mysql_mutex_lock(&table_share->mutex);
} }
} }
virtual void unlock_auto_increment() virtual void unlock_auto_increment()
@ -946,7 +946,7 @@ private:
*/ */
if(auto_increment_lock && !auto_increment_safe_stmt_log_lock) if(auto_increment_lock && !auto_increment_safe_stmt_log_lock)
{ {
pthread_mutex_unlock(&table_share->mutex); mysql_mutex_unlock(&table_share->mutex);
auto_increment_lock= FALSE; auto_increment_lock= FALSE;
} }
} }

View File

@ -1,4 +1,4 @@
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. /* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1682,7 +1682,7 @@ bool mysql_xa_recover(THD *thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1); DBUG_RETURN(1);
pthread_mutex_lock(&LOCK_xid_cache); mysql_mutex_lock(&LOCK_xid_cache);
while ((xs= (XID_STATE*) my_hash_element(&xid_cache, i++))) while ((xs= (XID_STATE*) my_hash_element(&xid_cache, i++)))
{ {
if (xs->xa_state==XA_PREPARED) if (xs->xa_state==XA_PREPARED)
@ -1695,13 +1695,13 @@ bool mysql_xa_recover(THD *thd)
&my_charset_bin); &my_charset_bin);
if (protocol->write()) if (protocol->write())
{ {
pthread_mutex_unlock(&LOCK_xid_cache); mysql_mutex_unlock(&LOCK_xid_cache);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
} }
} }
pthread_mutex_unlock(&LOCK_xid_cache); mysql_mutex_unlock(&LOCK_xid_cache);
my_eof(thd); my_eof(thd);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -2104,6 +2104,10 @@ THD *handler::ha_thd(void) const
return (table && table->in_use) ? table->in_use : current_thd; return (table && table->in_use) ? table->in_use : current_thd;
} }
PSI_table_share *handler::ha_table_share_psi(const TABLE_SHARE *share) const
{
return share->m_psi;
}
/** @brief /** @brief
Open database-handler. Open database-handler.
@ -2993,7 +2997,8 @@ static bool update_frm_version(TABLE *table)
strxmov(path, table->s->normalized_path.str, reg_ext, NullS); strxmov(path, table->s->normalized_path.str, reg_ext, NullS);
if ((file= my_open(path, O_RDWR|O_BINARY, MYF(MY_WME))) >= 0) if ((file= mysql_file_open(key_file_frm,
path, O_RDWR|O_BINARY, MYF(MY_WME))) >= 0)
{ {
uchar version[4]; uchar version[4];
char *key= table->s->table_cache_key.str; char *key= table->s->table_cache_key.str;
@ -3003,7 +3008,7 @@ static bool update_frm_version(TABLE *table)
int4store(version, MYSQL_VERSION_ID); int4store(version, MYSQL_VERSION_ID);
if ((result= my_pwrite(file,(uchar*) version,4,51L,MYF_RW))) if ((result= mysql_file_pwrite(file, (uchar*) version, 4, 51L, MYF_RW)))
goto err; goto err;
for (entry=(TABLE*) my_hash_first(&open_cache,(uchar*) key,key_length, &state); for (entry=(TABLE*) my_hash_first(&open_cache,(uchar*) key,key_length, &state);
@ -3013,7 +3018,7 @@ static bool update_frm_version(TABLE *table)
} }
err: err:
if (file >= 0) if (file >= 0)
(void) my_close(file,MYF(MY_WME)); (void) mysql_file_close(file, MYF(MY_WME));
DBUG_RETURN(result); DBUG_RETURN(result);
} }
@ -3060,7 +3065,7 @@ int handler::delete_table(const char *name)
for (const char **ext=bas_ext(); *ext ; ext++) for (const char **ext=bas_ext(); *ext ; ext++)
{ {
fn_format(buff, name, "", *ext, MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(buff, name, "", *ext, MY_UNPACK_FILENAME|MY_APPEND_EXT);
if (my_delete_with_symlink(buff, MYF(0))) if (mysql_file_delete_with_symlink(key_file_misc, buff, MYF(0)))
{ {
if (my_errno != ENOENT) if (my_errno != ENOENT)
{ {
@ -3717,12 +3722,12 @@ int ha_init_key_cache(const char *name, KEY_CACHE *key_cache)
if (!key_cache->key_cache_inited) if (!key_cache->key_cache_inited)
{ {
pthread_mutex_lock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_global_system_variables);
size_t tmp_buff_size= (size_t) key_cache->param_buff_size; size_t tmp_buff_size= (size_t) key_cache->param_buff_size;
uint tmp_block_size= (uint) key_cache->param_block_size; uint tmp_block_size= (uint) key_cache->param_block_size;
uint division_limit= key_cache->param_division_limit; uint division_limit= key_cache->param_division_limit;
uint age_threshold= key_cache->param_age_threshold; uint age_threshold= key_cache->param_age_threshold;
pthread_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_unlock(&LOCK_global_system_variables);
DBUG_RETURN(!init_key_cache(key_cache, DBUG_RETURN(!init_key_cache(key_cache,
tmp_block_size, tmp_block_size,
tmp_buff_size, tmp_buff_size,
@ -3741,12 +3746,12 @@ int ha_resize_key_cache(KEY_CACHE *key_cache)
if (key_cache->key_cache_inited) if (key_cache->key_cache_inited)
{ {
pthread_mutex_lock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_global_system_variables);
size_t tmp_buff_size= (size_t) key_cache->param_buff_size; size_t tmp_buff_size= (size_t) key_cache->param_buff_size;
long tmp_block_size= (long) key_cache->param_block_size; long tmp_block_size= (long) key_cache->param_block_size;
uint division_limit= key_cache->param_division_limit; uint division_limit= key_cache->param_division_limit;
uint age_threshold= key_cache->param_age_threshold; uint age_threshold= key_cache->param_age_threshold;
pthread_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_unlock(&LOCK_global_system_variables);
DBUG_RETURN(!resize_key_cache(key_cache, tmp_block_size, DBUG_RETURN(!resize_key_cache(key_cache, tmp_block_size,
tmp_buff_size, tmp_buff_size,
division_limit, age_threshold)); division_limit, age_threshold));
@ -3762,10 +3767,10 @@ int ha_change_key_cache_param(KEY_CACHE *key_cache)
{ {
if (key_cache->key_cache_inited) if (key_cache->key_cache_inited)
{ {
pthread_mutex_lock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_global_system_variables);
uint division_limit= key_cache->param_division_limit; uint division_limit= key_cache->param_division_limit;
uint age_threshold= key_cache->param_age_threshold; uint age_threshold= key_cache->param_age_threshold;
pthread_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_unlock(&LOCK_global_system_variables);
change_key_cache_param(key_cache, division_limit, age_threshold); change_key_cache_param(key_cache, division_limit, age_threshold);
} }
return 0; return 0;
@ -4794,7 +4799,8 @@ int example_of_iterator_using_for_logs_cleanup(handlerton *hton)
{ {
printf("%s\n", data.filename.str); printf("%s\n", data.filename.str);
if (data.status == HA_LOG_STATUS_FREE && if (data.status == HA_LOG_STATUS_FREE &&
my_delete(data.filename.str, MYF(MY_WME))) mysql_file_delete(INSTRUMENT_ME,
data.filename.str, MYF(MY_WME)))
goto err; goto err;
} }
res= 0; res= 0;
@ -4822,7 +4828,7 @@ err:
enum log_status fl_get_log_status(char *log) enum log_status fl_get_log_status(char *log)
{ {
MY_STAT stat_buff; MY_STAT stat_buff;
if (my_stat(log, &stat_buff, MYF(0))) if (mysql_file_stat(INSTRUMENT_ME, log, &stat_buff, MYF(0)))
return HA_LOG_STATUS_INUSE; return HA_LOG_STATUS_INUSE;
return HA_LOG_STATUS_NOSUCHLOG; return HA_LOG_STATUS_NOSUCHLOG;
} }

View File

@ -1,7 +1,7 @@
#ifndef HANDLER_INCLUDED #ifndef HANDLER_INCLUDED
#define HANDLER_INCLUDED #define HANDLER_INCLUDED
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. /* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -16,7 +16,6 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Definitions for parameters to do with handler-routines */ /* Definitions for parameters to do with handler-routines */
#ifdef USE_PRAGMA_INTERFACE #ifdef USE_PRAGMA_INTERFACE
@ -305,6 +304,8 @@ enum legacy_db_type
DB_TYPE_MEMCACHE, DB_TYPE_MEMCACHE,
DB_TYPE_FALCON, DB_TYPE_FALCON,
DB_TYPE_MARIA, DB_TYPE_MARIA,
/** Performance schema engine. */
DB_TYPE_PERFORMANCE_SCHEMA,
DB_TYPE_FIRST_DYNAMIC=42, DB_TYPE_FIRST_DYNAMIC=42,
DB_TYPE_DEFAULT=127 // Must be last DB_TYPE_DEFAULT=127 // Must be last
}; };
@ -1216,6 +1217,20 @@ public:
*/ */
uint auto_inc_intervals_count; uint auto_inc_intervals_count;
/**
Instrumented table associated with this handler.
This member should be set to NULL when no instrumentation is in place,
so that linking an instrumented/non instrumented server/plugin works.
For example:
- the server is compiled with the instrumentation.
The server expects either NULL or valid pointers in m_psi.
- an engine plugin is compiled without instrumentation.
The plugin can not leave this pointer uninitialized,
or can not leave a trash value on purpose in this pointer,
as this would crash the server.
*/
PSI_table *m_psi;
handler(handlerton *ht_arg, TABLE_SHARE *share_arg) handler(handlerton *ht_arg, TABLE_SHARE *share_arg)
:table_share(share_arg), table(0), :table_share(share_arg), table(0),
estimation_rows_to_insert(0), ht(ht_arg), estimation_rows_to_insert(0), ht(ht_arg),
@ -1224,7 +1239,8 @@ public:
ft_handler(0), inited(NONE), ft_handler(0), inited(NONE),
locked(FALSE), implicit_emptied(0), locked(FALSE), implicit_emptied(0),
pushed_cond(0), next_insert_id(0), insert_id_for_cur_row(0), pushed_cond(0), next_insert_id(0), insert_id_for_cur_row(0),
auto_inc_intervals_count(0) auto_inc_intervals_count(0),
m_psi(NULL)
{} {}
virtual ~handler(void) virtual ~handler(void)
{ {
@ -1824,6 +1840,39 @@ protected:
void **ha_data(THD *) const; void **ha_data(THD *) const;
THD *ha_thd(void) const; THD *ha_thd(void) const;
/**
Acquire the instrumented table information from a table share.
@param share a table share
@return an instrumented table share, or NULL.
*/
PSI_table_share *ha_table_share_psi(const TABLE_SHARE *share) const;
inline void psi_open()
{
DBUG_ASSERT(m_psi == NULL);
DBUG_ASSERT(table_share != NULL);
#ifdef HAVE_PSI_INTERFACE
if (PSI_server)
{
PSI_table_share *share_psi= ha_table_share_psi(table_share);
if (share_psi)
m_psi= PSI_server->open_table(share_psi, this);
}
#endif
}
inline void psi_close()
{
#ifdef HAVE_PSI_INTERFACE
if (PSI_server && m_psi)
{
PSI_server->close_table(m_psi);
m_psi= NULL; /* instrumentation handle, invalid after close_table() */
}
#endif
DBUG_ASSERT(m_psi == NULL);
}
/** /**
Default rename_table() and delete_table() rename/delete files with a Default rename_table() and delete_table() rename/delete files with a
given name and extensions from bas_ext(). given name and extensions from bas_ext().

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2003, 2005 MySQL AB /* Copyright (C) 2000-2003, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -45,7 +45,7 @@ class hash_filo
hash_filo_element *first_link,*last_link; hash_filo_element *first_link,*last_link;
public: public:
pthread_mutex_t lock; mysql_mutex_t lock;
HASH cache; HASH cache;
hash_filo(uint size_arg, uint key_offset_arg , uint key_length_arg, hash_filo(uint size_arg, uint key_offset_arg , uint key_length_arg,
@ -64,7 +64,7 @@ public:
{ {
if (cache.array.buffer) /* Avoid problems with thread library */ if (cache.array.buffer) /* Avoid problems with thread library */
(void) my_hash_free(&cache); (void) my_hash_free(&cache);
pthread_mutex_destroy(&lock); mysql_mutex_destroy(&lock);
} }
} }
void clear(bool locked=0) void clear(bool locked=0)
@ -72,15 +72,15 @@ public:
if (!init) if (!init)
{ {
init=1; init=1;
(void) pthread_mutex_init(&lock,MY_MUTEX_INIT_FAST); mysql_mutex_init(key_hash_filo_lock, &lock, MY_MUTEX_INIT_FAST);
} }
if (!locked) if (!locked)
(void) pthread_mutex_lock(&lock); mysql_mutex_lock(&lock);
(void) my_hash_free(&cache); (void) my_hash_free(&cache);
(void) my_hash_init(&cache,hash_charset,size,key_offset, (void) my_hash_init(&cache,hash_charset,size,key_offset,
key_length, get_key, free_element,0); key_length, get_key, free_element,0);
if (!locked) if (!locked)
(void) pthread_mutex_unlock(&lock); mysql_mutex_unlock(&lock);
first_link=last_link=0; first_link=last_link=0;
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -169,11 +169,11 @@ static bool add_hostname(const char *ip_key, const char *hostname)
if (specialflag & SPECIAL_NO_HOST_CACHE) if (specialflag & SPECIAL_NO_HOST_CACHE)
return FALSE; return FALSE;
pthread_mutex_lock(&hostname_cache->lock); mysql_mutex_lock(&hostname_cache->lock);
bool err_status= add_hostname_impl(ip_key, hostname); bool err_status= add_hostname_impl(ip_key, hostname);
pthread_mutex_unlock(&hostname_cache->lock); mysql_mutex_unlock(&hostname_cache->lock);
return err_status; return err_status;
} }
@ -186,14 +186,14 @@ void inc_host_errors(const char *ip_string)
char ip_key[HOST_ENTRY_KEY_SIZE]; char ip_key[HOST_ENTRY_KEY_SIZE];
prepare_hostname_cache_key(ip_string, ip_key); prepare_hostname_cache_key(ip_string, ip_key);
pthread_mutex_lock(&hostname_cache->lock); mysql_mutex_lock(&hostname_cache->lock);
Host_entry *entry= hostname_cache_search(ip_key); Host_entry *entry= hostname_cache_search(ip_key);
if (entry) if (entry)
entry->connect_errors++; entry->connect_errors++;
pthread_mutex_unlock(&hostname_cache->lock); mysql_mutex_unlock(&hostname_cache->lock);
} }
@ -205,14 +205,14 @@ void reset_host_errors(const char *ip_string)
char ip_key[HOST_ENTRY_KEY_SIZE]; char ip_key[HOST_ENTRY_KEY_SIZE];
prepare_hostname_cache_key(ip_string, ip_key); prepare_hostname_cache_key(ip_string, ip_key);
pthread_mutex_lock(&hostname_cache->lock); mysql_mutex_lock(&hostname_cache->lock);
Host_entry *entry= hostname_cache_search(ip_key); Host_entry *entry= hostname_cache_search(ip_key);
if (entry) if (entry)
entry->connect_errors= 0; entry->connect_errors= 0;
pthread_mutex_unlock(&hostname_cache->lock); mysql_mutex_unlock(&hostname_cache->lock);
} }
@ -319,7 +319,7 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
if (!(specialflag & SPECIAL_NO_HOST_CACHE)) if (!(specialflag & SPECIAL_NO_HOST_CACHE))
{ {
pthread_mutex_lock(&hostname_cache->lock); mysql_mutex_lock(&hostname_cache->lock);
Host_entry *entry= hostname_cache_search(ip_key); Host_entry *entry= hostname_cache_search(ip_key);
@ -337,12 +337,12 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
(const char *) (*hostname? *hostname : "null"), (const char *) (*hostname? *hostname : "null"),
(int) *connect_errors)); (int) *connect_errors));
pthread_mutex_unlock(&hostname_cache->lock); mysql_mutex_unlock(&hostname_cache->lock);
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
pthread_mutex_unlock(&hostname_cache->lock); mysql_mutex_unlock(&hostname_cache->lock);
} }
/* /*

View File

@ -5008,7 +5008,7 @@ void Item_func_get_system_var::fix_length_and_dec()
break; break;
case SHOW_CHAR: case SHOW_CHAR:
case SHOW_CHAR_PTR: case SHOW_CHAR_PTR:
pthread_mutex_lock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_global_system_variables);
cptr= var->show_type() == SHOW_CHAR ? cptr= var->show_type() == SHOW_CHAR ?
(char*) var->value_ptr(current_thd, var_type, &component) : (char*) var->value_ptr(current_thd, var_type, &component) :
*(char**) var->value_ptr(current_thd, var_type, &component); *(char**) var->value_ptr(current_thd, var_type, &component);
@ -5016,19 +5016,19 @@ void Item_func_get_system_var::fix_length_and_dec()
max_length= system_charset_info->cset->numchars(system_charset_info, max_length= system_charset_info->cset->numchars(system_charset_info,
cptr, cptr,
cptr + strlen(cptr)); cptr + strlen(cptr));
pthread_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_unlock(&LOCK_global_system_variables);
collation.set(system_charset_info, DERIVATION_SYSCONST); collation.set(system_charset_info, DERIVATION_SYSCONST);
max_length*= system_charset_info->mbmaxlen; max_length*= system_charset_info->mbmaxlen;
decimals=NOT_FIXED_DEC; decimals=NOT_FIXED_DEC;
break; break;
case SHOW_LEX_STRING: case SHOW_LEX_STRING:
{ {
pthread_mutex_lock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_global_system_variables);
LEX_STRING *ls= ((LEX_STRING*)var->value_ptr(current_thd, var_type, &component)); LEX_STRING *ls= ((LEX_STRING*)var->value_ptr(current_thd, var_type, &component));
max_length= system_charset_info->cset->numchars(system_charset_info, max_length= system_charset_info->cset->numchars(system_charset_info,
ls->str, ls->str,
ls->str + ls->length); ls->str + ls->length);
pthread_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_unlock(&LOCK_global_system_variables);
collation.set(system_charset_info, DERIVATION_SYSCONST); collation.set(system_charset_info, DERIVATION_SYSCONST);
max_length*= system_charset_info->mbmaxlen; max_length*= system_charset_info->mbmaxlen;
decimals=NOT_FIXED_DEC; decimals=NOT_FIXED_DEC;
@ -5113,9 +5113,9 @@ enum_field_types Item_func_get_system_var::field_type() const
#define get_sys_var_safe(type) \ #define get_sys_var_safe(type) \
do { \ do { \
type value; \ type value; \
pthread_mutex_lock(&LOCK_global_system_variables); \ mysql_mutex_lock(&LOCK_global_system_variables); \
value= *(type*) var->value_ptr(thd, var_type, &component); \ value= *(type*) var->value_ptr(thd, var_type, &component); \
pthread_mutex_unlock(&LOCK_global_system_variables); \ mysql_mutex_unlock(&LOCK_global_system_variables); \
cache_present |= GET_SYS_VAR_CACHE_LONG; \ cache_present |= GET_SYS_VAR_CACHE_LONG; \
used_query_id= thd->query_id; \ used_query_id= thd->query_id; \
cached_llval= null_value ? 0 : (longlong) value; \ cached_llval= null_value ? 0 : (longlong) value; \
@ -5238,7 +5238,7 @@ String* Item_func_get_system_var::val_str(String* str)
case SHOW_CHAR_PTR: case SHOW_CHAR_PTR:
case SHOW_LEX_STRING: case SHOW_LEX_STRING:
{ {
pthread_mutex_lock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_global_system_variables);
char *cptr= var->show_type() == SHOW_CHAR ? char *cptr= var->show_type() == SHOW_CHAR ?
(char*) var->value_ptr(thd, var_type, &component) : (char*) var->value_ptr(thd, var_type, &component) :
*(char**) var->value_ptr(thd, var_type, &component); *(char**) var->value_ptr(thd, var_type, &component);
@ -5258,7 +5258,7 @@ String* Item_func_get_system_var::val_str(String* str)
null_value= TRUE; null_value= TRUE;
str= NULL; str= NULL;
} }
pthread_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_unlock(&LOCK_global_system_variables);
break; break;
} }
@ -5323,9 +5323,9 @@ double Item_func_get_system_var::val_real()
switch (var->show_type()) switch (var->show_type())
{ {
case SHOW_DOUBLE: case SHOW_DOUBLE:
pthread_mutex_lock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_global_system_variables);
cached_dval= *(double*) var->value_ptr(thd, var_type, &component); cached_dval= *(double*) var->value_ptr(thd, var_type, &component);
pthread_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_unlock(&LOCK_global_system_variables);
used_query_id= thd->query_id; used_query_id= thd->query_id;
cached_null_value= null_value; cached_null_value= null_value;
if (null_value) if (null_value)
@ -5336,7 +5336,7 @@ double Item_func_get_system_var::val_real()
case SHOW_LEX_STRING: case SHOW_LEX_STRING:
case SHOW_CHAR_PTR: case SHOW_CHAR_PTR:
{ {
pthread_mutex_lock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_global_system_variables);
char *cptr= var->show_type() == SHOW_CHAR ? char *cptr= var->show_type() == SHOW_CHAR ?
(char*) var->value_ptr(thd, var_type, &component) : (char*) var->value_ptr(thd, var_type, &component) :
*(char**) var->value_ptr(thd, var_type, &component); *(char**) var->value_ptr(thd, var_type, &component);
@ -5348,7 +5348,7 @@ double Item_func_get_system_var::val_real()
null_value= TRUE; null_value= TRUE;
cached_dval= 0; cached_dval= 0;
} }
pthread_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_unlock(&LOCK_global_system_variables);
used_query_id= thd->query_id; used_query_id= thd->query_id;
cached_null_value= null_value; cached_null_value= null_value;
cache_present|= GET_SYS_VAR_CACHE_DOUBLE; cache_present|= GET_SYS_VAR_CACHE_DOUBLE;
@ -6281,8 +6281,8 @@ void uuid_short_init()
longlong Item_func_uuid_short::val_int() longlong Item_func_uuid_short::val_int()
{ {
ulonglong val; ulonglong val;
pthread_mutex_lock(&LOCK_uuid_generator); mysql_mutex_lock(&LOCK_uuid_generator);
val= uuid_value++; val= uuid_value++;
pthread_mutex_unlock(&LOCK_uuid_generator); mysql_mutex_unlock(&LOCK_uuid_generator);
return (longlong) val; return (longlong) val;
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -465,18 +465,18 @@ String *Item_func_des_encrypt::val_str(String *str)
if (arg_count == 1) if (arg_count == 1)
{ {
/* Protect against someone doing FLUSH DES_KEY_FILE */ /* Protect against someone doing FLUSH DES_KEY_FILE */
pthread_mutex_lock(&LOCK_des_key_file); mysql_mutex_lock(&LOCK_des_key_file);
keyschedule= des_keyschedule[key_number=des_default_key]; keyschedule= des_keyschedule[key_number=des_default_key];
pthread_mutex_unlock(&LOCK_des_key_file); mysql_mutex_unlock(&LOCK_des_key_file);
} }
else if (args[1]->result_type() == INT_RESULT) else if (args[1]->result_type() == INT_RESULT)
{ {
key_number= (uint) args[1]->val_int(); key_number= (uint) args[1]->val_int();
if (key_number > 9) if (key_number > 9)
goto error; goto error;
pthread_mutex_lock(&LOCK_des_key_file); mysql_mutex_lock(&LOCK_des_key_file);
keyschedule= des_keyschedule[key_number]; keyschedule= des_keyschedule[key_number];
pthread_mutex_unlock(&LOCK_des_key_file); mysql_mutex_unlock(&LOCK_des_key_file);
} }
else else
{ {
@ -566,9 +566,9 @@ String *Item_func_des_decrypt::val_str(String *str)
key_number > 9) key_number > 9)
goto error; goto error;
pthread_mutex_lock(&LOCK_des_key_file); mysql_mutex_lock(&LOCK_des_key_file);
keyschedule= des_keyschedule[key_number]; keyschedule= des_keyschedule[key_number];
pthread_mutex_unlock(&LOCK_des_key_file); mysql_mutex_unlock(&LOCK_des_key_file);
} }
else else
{ {
@ -1702,17 +1702,17 @@ String *Item_func_encrypt::val_str(String *str)
return 0; return 0;
salt_ptr= salt_str->c_ptr_safe(); salt_ptr= salt_str->c_ptr_safe();
} }
pthread_mutex_lock(&LOCK_crypt); mysql_mutex_lock(&LOCK_crypt);
char *tmp= crypt(res->c_ptr_safe(),salt_ptr); char *tmp= crypt(res->c_ptr_safe(),salt_ptr);
if (!tmp) if (!tmp)
{ {
pthread_mutex_unlock(&LOCK_crypt); mysql_mutex_unlock(&LOCK_crypt);
null_value= 1; null_value= 1;
return 0; return 0;
} }
str->set(tmp, (uint) strlen(tmp), &my_charset_bin); str->set(tmp, (uint) strlen(tmp), &my_charset_bin);
str->copy(); str->copy();
pthread_mutex_unlock(&LOCK_crypt); mysql_mutex_unlock(&LOCK_crypt);
return str; return str;
#else #else
null_value=1; null_value=1;
@ -2998,7 +2998,7 @@ String *Item_load_file::val_str(String *str)
strncmp(opt_secure_file_priv, path, strlen(opt_secure_file_priv))) strncmp(opt_secure_file_priv, path, strlen(opt_secure_file_priv)))
goto err; goto err;
if (!my_stat(path, &stat_info, MYF(0))) if (!mysql_file_stat(key_file_loadfile, path, &stat_info, MYF(0)))
goto err; goto err;
if (!(stat_info.st_mode & S_IROTH)) if (!(stat_info.st_mode & S_IROTH))
@ -3016,15 +3016,17 @@ String *Item_load_file::val_str(String *str)
} }
if (tmp_value.alloc(stat_info.st_size)) if (tmp_value.alloc(stat_info.st_size))
goto err; goto err;
if ((file = my_open(file_name->ptr(), O_RDONLY, MYF(0))) < 0) if ((file= mysql_file_open(key_file_loadfile,
file_name->ptr(), O_RDONLY, MYF(0))) < 0)
goto err; goto err;
if (my_read(file, (uchar*) tmp_value.ptr(), stat_info.st_size, MYF(MY_NABP))) if (mysql_file_read(file, (uchar*) tmp_value.ptr(), stat_info.st_size,
MYF(MY_NABP)))
{ {
my_close(file, MYF(0)); mysql_file_close(file, MYF(0));
goto err; goto err;
} }
tmp_value.length(stat_info.st_size); tmp_value.length(stat_info.st_size);
my_close(file, MYF(0)); mysql_file_close(file, MYF(0));
null_value = 0; null_value = 0;
DBUG_RETURN(&tmp_value); DBUG_RETURN(&tmp_value);
@ -3468,7 +3470,7 @@ String *Item_func_uuid::val_str(String *str)
char *s; char *s;
THD *thd= current_thd; THD *thd= current_thd;
pthread_mutex_lock(&LOCK_uuid_generator); mysql_mutex_lock(&LOCK_uuid_generator);
if (! uuid_time) /* first UUID() call. initializing data */ if (! uuid_time) /* first UUID() call. initializing data */
{ {
ulong tmp=sql_rnd_with_mutex(); ulong tmp=sql_rnd_with_mutex();
@ -3558,7 +3560,7 @@ String *Item_func_uuid::val_str(String *str)
} }
uuid_time=tv; uuid_time=tv;
pthread_mutex_unlock(&LOCK_uuid_generator); mysql_mutex_unlock(&LOCK_uuid_generator);
uint32 time_low= (uint32) (tv & 0xFFFFFFFF); uint32 time_low= (uint32) (tv & 0xFFFFFFFF);
uint16 time_mid= (uint16) ((tv >> 32) & 0xFFFF); uint16 time_mid= (uint16) ((tv >> 32) & 0xFFFF);

View File

@ -1436,7 +1436,7 @@ bool lock_global_read_lock(THD *thd)
if (!thd->global_read_lock) if (!thd->global_read_lock)
{ {
const char *old_message; const char *old_message;
(void) pthread_mutex_lock(&LOCK_global_read_lock); mysql_mutex_lock(&LOCK_global_read_lock);
old_message=thd->enter_cond(&COND_global_read_lock, &LOCK_global_read_lock, old_message=thd->enter_cond(&COND_global_read_lock, &LOCK_global_read_lock,
"Waiting to get readlock"); "Waiting to get readlock");
DBUG_PRINT("info", DBUG_PRINT("info",
@ -1445,7 +1445,7 @@ bool lock_global_read_lock(THD *thd)
waiting_for_read_lock++; waiting_for_read_lock++;
while (protect_against_global_read_lock && !thd->killed) while (protect_against_global_read_lock && !thd->killed)
pthread_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock); mysql_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
waiting_for_read_lock--; waiting_for_read_lock--;
if (thd->killed) if (thd->killed)
{ {
@ -1476,16 +1476,16 @@ void unlock_global_read_lock(THD *thd)
("global_read_lock: %u global_read_lock_blocks_commit: %u", ("global_read_lock: %u global_read_lock_blocks_commit: %u",
global_read_lock, global_read_lock_blocks_commit)); global_read_lock, global_read_lock_blocks_commit));
pthread_mutex_lock(&LOCK_global_read_lock); mysql_mutex_lock(&LOCK_global_read_lock);
tmp= --global_read_lock; tmp= --global_read_lock;
if (thd->global_read_lock == MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT) if (thd->global_read_lock == MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT)
--global_read_lock_blocks_commit; --global_read_lock_blocks_commit;
pthread_mutex_unlock(&LOCK_global_read_lock); mysql_mutex_unlock(&LOCK_global_read_lock);
/* Send the signal outside the mutex to avoid a context switch */ /* Send the signal outside the mutex to avoid a context switch */
if (!tmp) if (!tmp)
{ {
DBUG_PRINT("signal", ("Broadcasting COND_global_read_lock")); DBUG_PRINT("signal", ("Broadcasting COND_global_read_lock"));
pthread_cond_broadcast(&COND_global_read_lock); mysql_cond_broadcast(&COND_global_read_lock);
} }
thd->global_read_lock= 0; thd->global_read_lock= 0;
@ -1510,7 +1510,7 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
*/ */
mysql_mutex_assert_not_owner(&LOCK_open); mysql_mutex_assert_not_owner(&LOCK_open);
(void) pthread_mutex_lock(&LOCK_global_read_lock); mysql_mutex_lock(&LOCK_global_read_lock);
if ((need_exit_cond= must_wait)) if ((need_exit_cond= must_wait))
{ {
if (thd->global_read_lock) // This thread had the read locks if (thd->global_read_lock) // This thread had the read locks
@ -1518,7 +1518,7 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
if (is_not_commit) if (is_not_commit)
my_message(ER_CANT_UPDATE_WITH_READLOCK, my_message(ER_CANT_UPDATE_WITH_READLOCK,
ER(ER_CANT_UPDATE_WITH_READLOCK), MYF(0)); ER(ER_CANT_UPDATE_WITH_READLOCK), MYF(0));
(void) pthread_mutex_unlock(&LOCK_global_read_lock); mysql_mutex_unlock(&LOCK_global_read_lock);
/* /*
We allow FLUSHer to COMMIT; we assume FLUSHer knows what it does. We allow FLUSHer to COMMIT; we assume FLUSHer knows what it does.
This allowance is needed to not break existing versions of innobackup This allowance is needed to not break existing versions of innobackup
@ -1532,7 +1532,7 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
(!abort_on_refresh || thd->version == refresh_version)) (!abort_on_refresh || thd->version == refresh_version))
{ {
DBUG_PRINT("signal", ("Waiting for COND_global_read_lock")); DBUG_PRINT("signal", ("Waiting for COND_global_read_lock"));
(void) pthread_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock); mysql_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
DBUG_PRINT("signal", ("Got COND_global_read_lock")); DBUG_PRINT("signal", ("Got COND_global_read_lock"));
} }
if (thd->killed) if (thd->killed)
@ -1547,7 +1547,7 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
if (unlikely(need_exit_cond)) if (unlikely(need_exit_cond))
thd->exit_cond(old_message); // this unlocks LOCK_global_read_lock thd->exit_cond(old_message); // this unlocks LOCK_global_read_lock
else else
pthread_mutex_unlock(&LOCK_global_read_lock); mysql_mutex_unlock(&LOCK_global_read_lock);
DBUG_RETURN(result); DBUG_RETURN(result);
} }
@ -1558,13 +1558,13 @@ void start_waiting_global_read_lock(THD *thd)
DBUG_ENTER("start_waiting_global_read_lock"); DBUG_ENTER("start_waiting_global_read_lock");
if (unlikely(thd->global_read_lock)) if (unlikely(thd->global_read_lock))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
(void) pthread_mutex_lock(&LOCK_global_read_lock); mysql_mutex_lock(&LOCK_global_read_lock);
DBUG_ASSERT(protect_against_global_read_lock); DBUG_ASSERT(protect_against_global_read_lock);
tmp= (!--protect_against_global_read_lock && tmp= (!--protect_against_global_read_lock &&
(waiting_for_read_lock || global_read_lock_blocks_commit)); (waiting_for_read_lock || global_read_lock_blocks_commit));
(void) pthread_mutex_unlock(&LOCK_global_read_lock); mysql_mutex_unlock(&LOCK_global_read_lock);
if (tmp) if (tmp)
pthread_cond_broadcast(&COND_global_read_lock); mysql_cond_broadcast(&COND_global_read_lock);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -1580,7 +1580,7 @@ bool make_global_read_lock_block_commit(THD *thd)
*/ */
if (thd->global_read_lock != GOT_GLOBAL_READ_LOCK) if (thd->global_read_lock != GOT_GLOBAL_READ_LOCK)
DBUG_RETURN(0); DBUG_RETURN(0);
pthread_mutex_lock(&LOCK_global_read_lock); mysql_mutex_lock(&LOCK_global_read_lock);
/* increment this BEFORE waiting on cond (otherwise race cond) */ /* increment this BEFORE waiting on cond (otherwise race cond) */
global_read_lock_blocks_commit++; global_read_lock_blocks_commit++;
/* For testing we set up some blocking, to see if we can be killed */ /* For testing we set up some blocking, to see if we can be killed */
@ -1589,7 +1589,7 @@ bool make_global_read_lock_block_commit(THD *thd)
old_message= thd->enter_cond(&COND_global_read_lock, &LOCK_global_read_lock, old_message= thd->enter_cond(&COND_global_read_lock, &LOCK_global_read_lock,
"Waiting for all running commits to finish"); "Waiting for all running commits to finish");
while (protect_against_global_read_lock && !thd->killed) while (protect_against_global_read_lock && !thd->killed)
pthread_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock); mysql_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
DBUG_EXECUTE_IF("make_global_read_lock_block_commit_loop", DBUG_EXECUTE_IF("make_global_read_lock_block_commit_loop",
protect_against_global_read_lock--;); protect_against_global_read_lock--;);
if ((error= test(thd->killed))) if ((error= test(thd->killed)))
@ -1623,7 +1623,7 @@ bool make_global_read_lock_block_commit(THD *thd)
void broadcast_refresh(void) void broadcast_refresh(void)
{ {
mysql_cond_broadcast(&COND_refresh); mysql_cond_broadcast(&COND_refresh);
pthread_cond_broadcast(&COND_global_read_lock); mysql_cond_broadcast(&COND_global_read_lock);
} }
/** /**

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2005 MySQL AB /* Copyright (C) 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -65,8 +65,8 @@ class TC_LOG_MMAP: public TC_LOG
int size, free; // max and current number of free xid slots on the page int size, free; // max and current number of free xid slots on the page
int waiters; // number of waiters on condition int waiters; // number of waiters on condition
PAGE_STATE state; // see above PAGE_STATE state; // see above
pthread_mutex_t lock; // to access page data or control structure mysql_mutex_t lock; // to access page data or control structure
pthread_cond_t cond; // to wait for a sync mysql_cond_t cond; // to wait for a sync
} PAGE; } PAGE;
char logname[FN_REFLEN]; char logname[FN_REFLEN];
@ -81,8 +81,8 @@ class TC_LOG_MMAP: public TC_LOG
one has to use active->lock. one has to use active->lock.
Same for LOCK_pool and LOCK_sync Same for LOCK_pool and LOCK_sync
*/ */
pthread_mutex_t LOCK_active, LOCK_pool, LOCK_sync; mysql_mutex_t LOCK_active, LOCK_pool, LOCK_sync;
pthread_cond_t COND_pool, COND_active; mysql_cond_t COND_pool, COND_active;
public: public:
TC_LOG_MMAP(): inited(0) {} TC_LOG_MMAP(): inited(0) {}
@ -136,21 +136,25 @@ extern TC_LOG_DUMMY tc_log_dummy;
class Relay_log_info; class Relay_log_info;
#ifdef HAVE_PSI_INTERFACE
extern PSI_mutex_key key_LOG_INFO_lock;
#endif
typedef struct st_log_info typedef struct st_log_info
{ {
char log_file_name[FN_REFLEN]; char log_file_name[FN_REFLEN];
my_off_t index_file_offset, index_file_start_offset; my_off_t index_file_offset, index_file_start_offset;
my_off_t pos; my_off_t pos;
bool fatal; // if the purge happens to give us a negative offset bool fatal; // if the purge happens to give us a negative offset
pthread_mutex_t lock; mysql_mutex_t lock;
st_log_info() st_log_info()
: index_file_offset(0), index_file_start_offset(0), : index_file_offset(0), index_file_start_offset(0),
pos(0), fatal(0) pos(0), fatal(0)
{ {
log_file_name[0] = '\0'; log_file_name[0] = '\0';
pthread_mutex_init(&lock, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOG_INFO_lock, &lock, MY_MUTEX_INIT_FAST);
} }
~st_log_info() { pthread_mutex_destroy(&lock);} ~st_log_info() { mysql_mutex_destroy(&lock);}
} LOG_INFO; } LOG_INFO;
/* /*
@ -198,7 +202,7 @@ public:
int generate_new_name(char *new_name, const char *log_name); int generate_new_name(char *new_name, const char *log_name);
protected: protected:
/* LOCK_log is inited by init_pthread_objects() */ /* LOCK_log is inited by init_pthread_objects() */
pthread_mutex_t LOCK_log; mysql_mutex_t LOCK_log;
char *name; char *name;
char log_file_name[FN_REFLEN]; char log_file_name[FN_REFLEN];
char time_buff[20], db[NAME_LEN + 1]; char time_buff[20], db[NAME_LEN + 1];
@ -244,10 +248,10 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
{ {
private: private:
/* LOCK_log and LOCK_index are inited by init_pthread_objects() */ /* LOCK_log and LOCK_index are inited by init_pthread_objects() */
pthread_mutex_t LOCK_index; mysql_mutex_t LOCK_index;
pthread_mutex_t LOCK_prep_xids; mysql_mutex_t LOCK_prep_xids;
pthread_cond_t COND_prep_xids; mysql_cond_t COND_prep_xids;
pthread_cond_t update_cond; mysql_cond_t update_cond;
ulonglong bytes_written; ulonglong bytes_written;
IO_CACHE index_file; IO_CACHE index_file;
char index_file_name[FN_REFLEN]; char index_file_name[FN_REFLEN];
@ -452,11 +456,11 @@ public:
inline char* get_index_fname() { return index_file_name;} inline char* get_index_fname() { return index_file_name;}
inline char* get_log_fname() { return log_file_name; } inline char* get_log_fname() { return log_file_name; }
inline char* get_name() { return name; } inline char* get_name() { return name; }
inline pthread_mutex_t* get_log_lock() { return &LOCK_log; } inline mysql_mutex_t* get_log_lock() { return &LOCK_log; }
inline IO_CACHE* get_log_file() { return &log_file; } inline IO_CACHE* get_log_file() { return &log_file; }
inline void lock_index() { pthread_mutex_lock(&LOCK_index);} inline void lock_index() { mysql_mutex_lock(&LOCK_index);}
inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);} inline void unlock_index() { mysql_mutex_unlock(&LOCK_index);}
inline IO_CACHE *get_index_file() { return &index_file;} inline IO_CACHE *get_index_file() { return &index_file;}
inline uint32 get_open_count() { return open_count; } inline uint32 get_open_count() { return open_count; }
}; };
@ -551,7 +555,7 @@ public:
/* Class which manages slow, general and error log event handlers */ /* Class which manages slow, general and error log event handlers */
class LOGGER class LOGGER
{ {
rw_lock_t LOCK_logger; mysql_rwlock_t LOCK_logger;
/* flag to check whether logger mutex is initialized */ /* flag to check whether logger mutex is initialized */
uint inited; uint inited;
@ -571,9 +575,9 @@ public:
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_shared() { rw_rdlock(&LOCK_logger); } void lock_shared() { mysql_rwlock_rdlock(&LOCK_logger); }
void lock_exclusive() { rw_wrlock(&LOCK_logger); } void lock_exclusive() { mysql_rwlock_wrlock(&LOCK_logger); }
void unlock() { rw_unlock(&LOCK_logger); } void unlock() { mysql_rwlock_unlock(&LOCK_logger); }
bool is_log_table_enabled(uint log_table_type); bool is_log_table_enabled(uint log_table_type);
bool log_command(THD *thd, enum enum_server_command command); bool log_command(THD *thd, enum enum_server_command command);

View File

@ -1,4 +1,4 @@
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. /* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -497,7 +497,7 @@ static void cleanup_load_tmpdir()
if (is_prefix(file->name, prefbuf)) if (is_prefix(file->name, prefbuf))
{ {
fn_format(fname,file->name,slave_load_tmpdir,"",MY_UNPACK_FILENAME); fn_format(fname,file->name,slave_load_tmpdir,"",MY_UNPACK_FILENAME);
my_delete(fname, MYF(0)); mysql_file_delete(key_file_misc, fname, MYF(0));
} }
} }
@ -967,7 +967,7 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
*/ */
int Log_event::read_log_event(IO_CACHE* file, String* packet, int Log_event::read_log_event(IO_CACHE* file, String* packet,
pthread_mutex_t* log_lock) mysql_mutex_t* log_lock)
{ {
ulong data_len; ulong data_len;
int result=0; int result=0;
@ -975,7 +975,7 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
DBUG_ENTER("Log_event::read_log_event"); DBUG_ENTER("Log_event::read_log_event");
if (log_lock) if (log_lock)
pthread_mutex_lock(log_lock); mysql_mutex_lock(log_lock);
if (my_b_read(file, (uchar*) buf, sizeof(buf))) if (my_b_read(file, (uchar*) buf, sizeof(buf)))
{ {
/* /*
@ -1033,14 +1033,14 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
end: end:
if (log_lock) if (log_lock)
pthread_mutex_unlock(log_lock); mysql_mutex_unlock(log_lock);
DBUG_RETURN(result); DBUG_RETURN(result);
} }
#endif /* !MYSQL_CLIENT */ #endif /* !MYSQL_CLIENT */
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
#define UNLOCK_MUTEX if (log_lock) pthread_mutex_unlock(log_lock); #define UNLOCK_MUTEX if (log_lock) mysql_mutex_unlock(log_lock);
#define LOCK_MUTEX if (log_lock) pthread_mutex_lock(log_lock); #define LOCK_MUTEX if (log_lock) mysql_mutex_lock(log_lock);
#else #else
#define UNLOCK_MUTEX #define UNLOCK_MUTEX
#define LOCK_MUTEX #define LOCK_MUTEX
@ -1052,7 +1052,7 @@ end:
Allocates memory; The caller is responsible for clean-up. Allocates memory; The caller is responsible for clean-up.
*/ */
Log_event* Log_event::read_log_event(IO_CACHE* file, Log_event* Log_event::read_log_event(IO_CACHE* file,
pthread_mutex_t* log_lock, mysql_mutex_t* log_lock,
const Format_description_log_event const Format_description_log_event
*description_event) *description_event)
#else #else
@ -4932,7 +4932,7 @@ int Rotate_log_event::do_update_pos(Relay_log_info *rli)
!is_relay_log_event() && !is_relay_log_event() &&
!rli->is_in_group()) !rli->is_in_group())
{ {
pthread_mutex_lock(&rli->data_lock); mysql_mutex_lock(&rli->data_lock);
DBUG_PRINT("info", ("old group_master_log_name: '%s' " DBUG_PRINT("info", ("old group_master_log_name: '%s' "
"old group_master_log_pos: %lu", "old group_master_log_pos: %lu",
rli->group_master_log_name, rli->group_master_log_name,
@ -4944,7 +4944,7 @@ int Rotate_log_event::do_update_pos(Relay_log_info *rli)
"new group_master_log_pos: %lu", "new group_master_log_pos: %lu",
rli->group_master_log_name, rli->group_master_log_name,
(ulong) rli->group_master_log_pos)); (ulong) rli->group_master_log_pos));
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
flush_relay_log_info(rli); flush_relay_log_info(rli);
/* /*
@ -5765,8 +5765,8 @@ Slave_log_event::Slave_log_event(THD* thd_arg,
Master_info* mi = rli->mi; Master_info* mi = rli->mi;
// TODO: re-write this better without holding both locks at the same time // TODO: re-write this better without holding both locks at the same time
pthread_mutex_lock(&mi->data_lock); mysql_mutex_lock(&mi->data_lock);
pthread_mutex_lock(&rli->data_lock); mysql_mutex_lock(&rli->data_lock);
master_host_len = strlen(mi->host); master_host_len = strlen(mi->host);
master_log_len = strlen(rli->group_master_log_name); master_log_len = strlen(rli->group_master_log_name);
// on OOM, just do not initialize the structure and print the error // on OOM, just do not initialize the structure and print the error
@ -5784,8 +5784,8 @@ Slave_log_event::Slave_log_event(THD* thd_arg,
} }
else else
sql_print_error("Out of memory while recording slave event"); sql_print_error("Out of memory while recording slave event");
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
#endif /* !MYSQL_CLIENT */ #endif /* !MYSQL_CLIENT */
@ -6142,8 +6142,10 @@ int Create_file_log_event::do_apply_event(Relay_log_info const *rli)
fname_buf= strmov(proc_info, "Making temp file "); fname_buf= strmov(proc_info, "Making temp file ");
ext= slave_load_file_stem(fname_buf, file_id, server_id, ".info"); ext= slave_load_file_stem(fname_buf, file_id, server_id, ".info");
thd_proc_info(thd, proc_info); thd_proc_info(thd, proc_info);
my_delete(fname_buf, MYF(0)); // old copy may exist already /* old copy may exist already */
if ((fd= my_create(fname_buf, CREATE_MODE, mysql_file_delete(key_file_log_event_info, fname_buf, MYF(0));
if ((fd= mysql_file_create(key_file_log_event_info,
fname_buf, CREATE_MODE,
O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
MYF(MY_WME))) < 0 || MYF(MY_WME))) < 0 ||
init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0, init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0,
@ -6167,11 +6169,13 @@ int Create_file_log_event::do_apply_event(Relay_log_info const *rli)
goto err; goto err;
} }
end_io_cache(&file); end_io_cache(&file);
my_close(fd, MYF(0)); mysql_file_close(fd, MYF(0));
// fname_buf now already has .data, not .info, because we did our trick // fname_buf now already has .data, not .info, because we did our trick
my_delete(fname_buf, MYF(0)); // old copy may exist already /* old copy may exist already */
if ((fd= my_create(fname_buf, CREATE_MODE, mysql_file_delete(key_file_log_event_data, fname_buf, MYF(0));
if ((fd= mysql_file_create(key_file_log_event_data,
fname_buf, CREATE_MODE,
O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
{ {
@ -6180,7 +6184,7 @@ int Create_file_log_event::do_apply_event(Relay_log_info const *rli)
fname_buf); fname_buf);
goto err; goto err;
} }
if (my_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP))) if (mysql_file_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP)))
{ {
rli->report(ERROR_LEVEL, my_errno, rli->report(ERROR_LEVEL, my_errno,
"Error in Create_file event: write to '%s' failed", "Error in Create_file event: write to '%s' failed",
@ -6193,7 +6197,7 @@ err:
if (error) if (error)
end_io_cache(&file); end_io_cache(&file);
if (fd >= 0) if (fd >= 0)
my_close(fd, MYF(0)); mysql_file_close(fd, MYF(0));
thd_proc_info(thd, 0); thd_proc_info(thd, 0);
return error != 0; return error != 0;
} }
@ -6325,8 +6329,10 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli)
*/ */
lex_start(thd); lex_start(thd);
mysql_reset_thd_for_next_command(thd); mysql_reset_thd_for_next_command(thd);
my_delete(fname, MYF(0)); // old copy may exist already /* old copy may exist already */
if ((fd= my_create(fname, CREATE_MODE, mysql_file_delete(key_file_log_event_data, fname, MYF(0));
if ((fd= mysql_file_create(key_file_log_event_data,
fname, CREATE_MODE,
O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
{ {
@ -6336,7 +6342,9 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli)
goto err; goto err;
} }
} }
else if ((fd = my_open(fname, O_WRONLY | O_APPEND | O_BINARY | O_NOFOLLOW, else if ((fd= mysql_file_open(key_file_log_event_data,
fname,
O_WRONLY | O_APPEND | O_BINARY | O_NOFOLLOW,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
{ {
rli->report(ERROR_LEVEL, my_errno, rli->report(ERROR_LEVEL, my_errno,
@ -6346,9 +6354,13 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli)
} }
DBUG_EXECUTE_IF("remove_slave_load_file_before_write", DBUG_EXECUTE_IF("remove_slave_load_file_before_write",
my_close(fd,MYF(0)); fd= -1; my_delete(fname, MYF(0));); {
mysql_file_close(fd, MYF(0));
fd= -1;
mysql_file_delete(0, fname, MYF(0));
});
if (my_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP))) if (mysql_file_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP)))
{ {
rli->report(ERROR_LEVEL, my_errno, rli->report(ERROR_LEVEL, my_errno,
"Error in %s event: write to '%s' failed", "Error in %s event: write to '%s' failed",
@ -6359,7 +6371,7 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli)
err: err:
if (fd >= 0) if (fd >= 0)
my_close(fd, MYF(0)); mysql_file_close(fd, MYF(0));
thd_proc_info(thd, 0); thd_proc_info(thd, 0);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
@ -6453,9 +6465,9 @@ int Delete_file_log_event::do_apply_event(Relay_log_info const *rli)
{ {
char fname[FN_REFLEN+10]; char fname[FN_REFLEN+10];
char *ext= slave_load_file_stem(fname, file_id, server_id, ".data"); char *ext= slave_load_file_stem(fname, file_id, server_id, ".data");
(void) my_delete(fname, MYF(MY_WME)); mysql_file_delete(key_file_log_event_data, fname, MYF(MY_WME));
strmov(ext, ".info"); strmov(ext, ".info");
(void) my_delete(fname, MYF(MY_WME)); mysql_file_delete(key_file_log_event_info, fname, MYF(MY_WME));
return 0; return 0;
} }
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
@ -6556,7 +6568,8 @@ int Execute_load_log_event::do_apply_event(Relay_log_info const *rli)
Load_log_event *lev= 0; Load_log_event *lev= 0;
ext= slave_load_file_stem(fname, file_id, server_id, ".info"); ext= slave_load_file_stem(fname, file_id, server_id, ".info");
if ((fd = my_open(fname, O_RDONLY | O_BINARY | O_NOFOLLOW, if ((fd= mysql_file_open(key_file_log_event_info,
fname, O_RDONLY | O_BINARY | O_NOFOLLOW,
MYF(MY_WME))) < 0 || MYF(MY_WME))) < 0 ||
init_io_cache(&file, fd, IO_SIZE, READ_CACHE, (my_off_t)0, 0, init_io_cache(&file, fd, IO_SIZE, READ_CACHE, (my_off_t)0, 0,
MYF(MY_WME|MY_NABP))) MYF(MY_WME|MY_NABP)))
@ -6567,7 +6580,7 @@ int Execute_load_log_event::do_apply_event(Relay_log_info const *rli)
goto err; goto err;
} }
if (!(lev = (Load_log_event*)Log_event::read_log_event(&file, if (!(lev = (Load_log_event*)Log_event::read_log_event(&file,
(pthread_mutex_t*)0, (mysql_mutex_t*)0,
rli->relay_log.description_event_for_exec)) || rli->relay_log.description_event_for_exec)) ||
lev->get_type_code() != NEW_LOAD_EVENT) lev->get_type_code() != NEW_LOAD_EVENT)
{ {
@ -6607,24 +6620,24 @@ int Execute_load_log_event::do_apply_event(Relay_log_info const *rli)
} }
/* /*
We have an open file descriptor to the .info file; we need to close it We have an open file descriptor to the .info file; we need to close it
or Windows will refuse to delete the file in my_delete(). or Windows will refuse to delete the file in mysql_file_delete().
*/ */
if (fd >= 0) if (fd >= 0)
{ {
my_close(fd, MYF(0)); mysql_file_close(fd, MYF(0));
end_io_cache(&file); end_io_cache(&file);
fd= -1; fd= -1;
} }
(void) my_delete(fname, MYF(MY_WME)); mysql_file_delete(key_file_log_event_info, fname, MYF(MY_WME));
memcpy(ext, ".data", 6); memcpy(ext, ".data", 6);
(void) my_delete(fname, MYF(MY_WME)); mysql_file_delete(key_file_log_event_data, fname, MYF(MY_WME));
error = 0; error = 0;
err: err:
delete lev; delete lev;
if (fd >= 0) if (fd >= 0)
{ {
my_close(fd, MYF(0)); mysql_file_close(fd, MYF(0));
end_io_cache(&file); end_io_cache(&file);
} }
return error; return error;
@ -6863,7 +6876,7 @@ Execute_load_query_log_event::do_apply_event(Relay_log_info const *rli)
file so that we can re-execute this event at START SLAVE. file so that we can re-execute this event at START SLAVE.
*/ */
if (!error) if (!error)
(void) my_delete(fname, MYF(MY_WME)); mysql_file_delete(key_file_log_event_data, fname, MYF(MY_WME));
my_free(buf, MYF(MY_ALLOW_ZERO_PTR)); my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
return error; return error;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -946,11 +946,11 @@ public:
constructor and pass description_event as an argument. constructor and pass description_event as an argument.
*/ */
static Log_event* read_log_event(IO_CACHE* file, static Log_event* read_log_event(IO_CACHE* file,
pthread_mutex_t* log_lock, mysql_mutex_t* log_lock,
const Format_description_log_event const Format_description_log_event
*description_event); *description_event);
static int read_log_event(IO_CACHE* file, String* packet, static int read_log_event(IO_CACHE* file, String* packet,
pthread_mutex_t* log_lock); mysql_mutex_t* log_lock);
/* /*
init_show_field_list() prepares the column names and types for the init_show_field_list() prepares the column names and types for the
output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG

View File

@ -891,7 +891,10 @@ inline bool check_routine_access(THD *thd,ulong want_access,char *db,
char *name, bool is_proc, bool no_errors) char *name, bool is_proc, bool no_errors)
{ return false; } { return false; }
inline bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table) inline bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table)
{ return false; } {
table->grant.privilege= want_access;
return false;
}
inline bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list) inline bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list)
{ return false; } { return false; }
inline bool check_some_routine_access(THD *thd, const char *db, inline bool check_some_routine_access(THD *thd, const char *db,
@ -1041,6 +1044,7 @@ int check_user(THD *thd, enum enum_server_command command,
const char *passwd, uint passwd_len, const char *db, const char *passwd, uint passwd_len, const char *db,
bool check_count); bool check_count);
pthread_handler_t handle_one_connection(void *arg); pthread_handler_t handle_one_connection(void *arg);
void do_handle_one_connection(THD *thd_arg);
bool init_new_connection_handler_thread(); bool init_new_connection_handler_thread();
void reset_mqh(LEX_USER *lu, bool get_them); void reset_mqh(LEX_USER *lu, bool get_them);
bool check_mqh(THD *thd, uint check_command); bool check_mqh(THD *thd, uint check_command);
@ -1093,6 +1097,7 @@ void init_max_user_conn(void);
void init_update_queries(void); void init_update_queries(void);
void free_max_user_conn(void); void free_max_user_conn(void);
pthread_handler_t handle_bootstrap(void *arg); pthread_handler_t handle_bootstrap(void *arg);
void do_handle_bootstrap(THD *thd);
int mysql_execute_command(THD *thd); int mysql_execute_command(THD *thd);
bool do_command(THD *thd); bool do_command(THD *thd);
bool dispatch_command(enum enum_server_command command, THD *thd, bool dispatch_command(enum enum_server_command command, THD *thd,
@ -1117,15 +1122,17 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
bool *write_to_binlog); bool *write_to_binlog);
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
bool check_access(THD *thd, ulong access, const char *db, ulong *save_priv, bool check_access(THD *thd, ulong access, const char *db, ulong *save_priv,
bool no_grant, bool no_errors, bool schema_db); GRANT_INTERNAL_INFO *grant_internal_info,
bool check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables, bool no_grant, bool no_errors);
bool check_table_access(THD *thd, ulong requirements, TABLE_LIST *tables,
bool any_combination_of_privileges_will_do, bool any_combination_of_privileges_will_do,
uint number, uint number,
bool no_errors); bool no_errors);
#else #else
inline bool check_access(THD *thd, ulong access, const char *db, inline bool check_access(THD *thd, ulong access, const char *db,
ulong *save_priv, bool no_grant, bool no_errors, ulong *save_priv,
bool schema_db) GRANT_INTERNAL_INFO *grant_internal_info,
bool no_grant, bool no_errors)
{ {
if (save_priv) if (save_priv)
*save_priv= GLOBAL_ACLS; *save_priv= GLOBAL_ACLS;
@ -1314,7 +1321,7 @@ bool table_is_used(TABLE *table, bool wait_for_name_lock);
TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name); TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name);
void abort_locked_tables(THD *thd,const char *db, const char *table_name); void abort_locked_tables(THD *thd,const char *db, const char *table_name);
void execute_init_command(THD *thd, LEX_STRING *init_command, void execute_init_command(THD *thd, LEX_STRING *init_command,
rw_lock_t *var_mutex); mysql_rwlock_t *var_mutex);
extern Field *not_found_field; extern Field *not_found_field;
extern Field *view_ref_found; extern Field *view_ref_found;
@ -1355,7 +1362,7 @@ struct st_des_keyschedule
extern char *des_key_file; extern char *des_key_file;
extern struct st_des_keyschedule des_keyschedule[10]; extern struct st_des_keyschedule des_keyschedule[10];
extern uint des_default_key; extern uint des_default_key;
extern pthread_mutex_t LOCK_des_key_file; extern mysql_mutex_t LOCK_des_key_file;
bool load_des_key_file(const char *file_name); bool load_des_key_file(const char *file_name);
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
@ -1402,6 +1409,8 @@ void free_status_vars();
void reset_status_vars(); void reset_status_vars();
/* information schema */ /* information schema */
extern LEX_STRING INFORMATION_SCHEMA_NAME; extern LEX_STRING INFORMATION_SCHEMA_NAME;
/* performance schema */
extern LEX_STRING PERFORMANCE_SCHEMA_DB_NAME;
/* log tables */ /* log tables */
extern LEX_STRING MYSQL_SCHEMA_NAME; extern LEX_STRING MYSQL_SCHEMA_NAME;
extern LEX_STRING GENERAL_LOG_NAME; extern LEX_STRING GENERAL_LOG_NAME;
@ -1423,9 +1432,11 @@ bool get_schema_tables_result(JOIN *join,
enum enum_schema_table_state executed_place); enum enum_schema_table_state executed_place);
enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table); enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table);
#define is_schema_db(X) \ #define is_infoschema_db(X) \
!my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X)) !my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X))
void initialize_information_schema_acl();
/* sql_handler.cc */ /* sql_handler.cc */
bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen); bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen);
bool mysql_ha_close(THD *thd, TABLE_LIST *tables); bool mysql_ha_close(THD *thd, TABLE_LIST *tables);
@ -1728,7 +1739,7 @@ void release_ddl_log();
void execute_ddl_log_recovery(); void execute_ddl_log_recovery();
bool execute_ddl_log_entry(THD *thd, uint first_entry); bool execute_ddl_log_entry(THD *thd, uint first_entry);
extern pthread_mutex_t LOCK_gdl; extern mysql_mutex_t LOCK_gdl;
#define WFRM_WRITE_SHADOW 1 #define WFRM_WRITE_SHADOW 1
#define WFRM_INSTALL_SHADOW 2 #define WFRM_INSTALL_SHADOW 2
@ -1745,9 +1756,8 @@ 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, TABLE *open_log_table(THD *thd, TABLE_LIST *one_table, Open_tables_state *backup);
Open_tables_state *backup); void close_log_table(THD *thd, Open_tables_state *backup);
void close_performance_schema_table(THD *thd, Open_tables_state *backup);
bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
bool wait_for_refresh, bool wait_for_placeholders); bool wait_for_refresh, bool wait_for_placeholders);
@ -2034,31 +2044,29 @@ extern my_bool old_mode;
extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log; extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log;
extern LOGGER logger; extern LOGGER logger;
extern TABLE_LIST general_log, slow_log; extern TABLE_LIST general_log, slow_log;
extern FILE *bootstrap_file; extern MYSQL_FILE *bootstrap_file;
extern int bootstrap_error; extern int bootstrap_error;
extern FILE *stderror_file; extern FILE *stderror_file;
extern pthread_key(MEM_ROOT**,THR_MALLOC); extern pthread_key(MEM_ROOT**,THR_MALLOC);
extern pthread_mutex_t LOCK_mapped_file, extern mysql_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_lock_db,
LOCK_error_log, LOCK_uuid_generator, LOCK_mapped_file, LOCK_user_locks, LOCK_status,
LOCK_crypt, LOCK_timezone, LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator,
LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock, LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
LOCK_global_system_variables, LOCK_user_conn, LOCK_global_system_variables, LOCK_user_conn,
LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count; LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count;
extern mysql_mutex_t LOCK_mysql_create_db, LOCK_lock_db, LOCK_open,
LOCK_user_locks, LOCK_status, LOCK_delayed_status, LOCK_delayed_insert,
LOCK_delayed_create;
extern MYSQL_PLUGIN_IMPORT pthread_mutex_t LOCK_thread_count; extern MYSQL_PLUGIN_IMPORT pthread_mutex_t LOCK_thread_count;
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
extern pthread_mutex_t LOCK_des_key_file; extern mysql_mutex_t LOCK_des_key_file;
#endif #endif
extern pthread_mutex_t LOCK_server_started; extern mysql_mutex_t LOCK_server_started;
extern pthread_cond_t COND_server_started; extern mysql_cond_t COND_server_started;
extern int mysqld_server_started; extern int mysqld_server_started;
extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; extern mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
extern rw_lock_t LOCK_system_variables_hash; extern mysql_rwlock_t LOCK_system_variables_hash;
extern mysql_cond_t COND_refresh; extern pthread_cond_t COND_thread_count;
extern pthread_cond_t COND_thread_count, COND_manager; extern mysql_cond_t COND_refresh, COND_manager;
extern pthread_cond_t COND_global_read_lock; extern mysql_cond_t COND_global_read_lock;
extern pthread_attr_t connection_attrib; extern pthread_attr_t connection_attrib;
extern I_List<THD> threads; extern I_List<THD> threads;
extern MY_BITMAP temp_pool; extern MY_BITMAP temp_pool;
@ -2081,7 +2089,6 @@ extern String null_string;
extern HASH open_cache, lock_db_cache; extern HASH open_cache, lock_db_cache;
extern TABLE *unused_tables; extern TABLE *unused_tables;
extern const char* any_db; extern const char* any_db;
extern struct my_option my_long_options[];
extern const LEX_STRING view_type; extern const LEX_STRING view_type;
extern scheduler_functions thread_scheduler; extern scheduler_functions thread_scheduler;
extern TYPELIB thread_handling_typelib; extern TYPELIB thread_handling_typelib;
@ -2644,4 +2651,69 @@ extern "C" int test_if_data_home_dir(const char *dir);
#endif /* MYSQL_CLIENT */ #endif /* MYSQL_CLIENT */
#ifdef MYSQL_SERVER
#ifdef HAVE_PSI_INTERFACE
#ifdef HAVE_MMAP
extern PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active,
key_LOCK_pool;
#endif /* HAVE_MMAP */
#ifdef HAVE_OPENSSL
extern PSI_mutex_key key_LOCK_des_key_file;
#endif
extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
key_delayed_insert_mutex, key_hash_filo_lock, key_LOCK_active_mi,
key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log,
key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables,
key_LOCK_lock_db, key_LOCK_logger, key_LOCK_manager, key_LOCK_mapped_file,
key_LOCK_mysql_create_db, key_LOCK_open, key_LOCK_prepared_stmt_count,
key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status,
key_LOCK_table_share, key_LOCK_thd_data,
key_LOCK_user_conn, key_LOCK_uuid_generator, key_LOG_LOCK_log,
key_master_info_data_lock, key_master_info_run_lock,
key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock,
key_relay_log_info_log_space_lock, key_relay_log_info_run_lock,
key_structure_guard_mutex, key_TABLE_SHARE_mutex, key_LOCK_error_messages;
extern PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger,
key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave,
key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock;
#ifdef HAVE_MMAP
extern PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool;
#endif /* HAVE_MMAP */
extern PSI_cond_key key_BINLOG_COND_prep_xids, key_BINLOG_update_cond,
key_COND_cache_status_changed, key_COND_global_read_lock, key_COND_manager,
key_COND_refresh, key_COND_rpl_status, key_COND_server_started,
key_delayed_insert_cond, key_delayed_insert_cond_client,
key_item_func_sleep_cond, key_master_info_data_cond,
key_master_info_start_cond, key_master_info_stop_cond,
key_relay_log_info_data_cond, key_relay_log_info_log_space_cond,
key_relay_log_info_start_cond, key_relay_log_info_stop_cond,
key_TABLE_SHARE_cond, key_user_level_lock_cond;
extern PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert,
key_thread_handle_manager, key_thread_kill_server, key_thread_main,
key_thread_one_connection, key_thread_signal_hand;
#ifdef HAVE_MMAP
extern PSI_file_key key_file_map;
#endif /* HAVE_MMAP */
extern PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest,
key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file,
key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load,
key_file_loadfile, key_file_log_event_data, key_file_log_event_info,
key_file_master_info, key_file_misc, key_file_MYSQL_LOG, key_file_partition,
key_file_pid, key_file_relay_log_info, key_file_send_file, key_file_tclog,
key_file_trg, key_file_trn, key_file_init;
void init_server_psi_keys();
#endif /* HAVE_PSI_INTERFACE */
#endif /* MYSQL_SERVER */
#endif /* MYSQL_PRIV_H */ #endif /* MYSQL_PRIV_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2004 MySQL AB /* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -237,7 +237,8 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
// temporary file name // temporary file name
path[path_end]='~'; path[path_end]='~';
path[path_end+1]= '\0'; path[path_end+1]= '\0';
if ((handler= my_create(path, CREATE_MODE, O_RDWR | O_TRUNC, if ((handler= mysql_file_create(key_file_fileparser,
path, CREATE_MODE, O_RDWR | O_TRUNC,
MYF(MY_WME))) <= 0) MYF(MY_WME))) <= 0)
{ {
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
@ -267,11 +268,11 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
goto err_w_file; goto err_w_file;
if (opt_sync_frm) { if (opt_sync_frm) {
if (my_sync(handler, MYF(MY_WME))) if (mysql_file_sync(handler, MYF(MY_WME)))
goto err_w_file; goto err_w_file;
} }
if (my_close(handler, MYF(MY_WME))) if (mysql_file_close(handler, MYF(MY_WME)))
{ {
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -283,7 +284,7 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
char path_to[FN_REFLEN]; char path_to[FN_REFLEN];
memcpy(path_to, path, path_end+1); memcpy(path_to, path, path_end+1);
path[path_end]='~'; path[path_end]='~';
if (my_rename(path, path_to, MYF(MY_WME))) if (mysql_file_rename(key_file_fileparser, path, path_to, MYF(MY_WME)))
{ {
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -292,7 +293,7 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
err_w_cache: err_w_cache:
end_io_cache(&file); end_io_cache(&file);
err_w_file: err_w_file:
my_close(handler, MYF(MY_WME)); mysql_file_close(handler, MYF(MY_WME));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -321,7 +322,7 @@ my_bool rename_in_schema_file(THD *thd,
build_table_filename(new_path, sizeof(new_path) - 1, build_table_filename(new_path, sizeof(new_path) - 1,
new_db, new_name, reg_ext, 0); new_db, new_name, reg_ext, 0);
if (my_rename(old_path, new_path, MYF(MY_WME))) if (mysql_file_rename(key_file_frm, old_path, new_path, MYF(MY_WME)))
return 1; return 1;
/* check if arc_dir exists: disabled unused feature (see bug #17823). */ /* check if arc_dir exists: disabled unused feature (see bug #17823). */
@ -365,7 +366,8 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
File file; File file;
DBUG_ENTER("sql_parse_prepare"); DBUG_ENTER("sql_parse_prepare");
if (!my_stat(file_name->str, &stat_info, MYF(MY_WME))) if (!mysql_file_stat(key_file_fileparser,
file_name->str, &stat_info, MYF(MY_WME)))
{ {
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -386,20 +388,21 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if ((file= my_open(file_name->str, O_RDONLY | O_SHARE, MYF(MY_WME))) < 0) if ((file= mysql_file_open(key_file_fileparser, file_name->str,
O_RDONLY | O_SHARE, MYF(MY_WME))) < 0)
{ {
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if ((len= my_read(file, (uchar *)parser->buff, if ((len= mysql_file_read(file, (uchar *)parser->buff,
stat_info.st_size, MYF(MY_WME))) == stat_info.st_size, MYF(MY_WME))) ==
MY_FILE_ERROR) MY_FILE_ERROR)
{ {
my_close(file, MYF(MY_WME)); mysql_file_close(file, MYF(MY_WME));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (my_close(file, MYF(MY_WME))) if (mysql_file_close(file, MYF(MY_WME)))
{ {
DBUG_RETURN(0); DBUG_RETURN(0);
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2001-2006 MySQL AB & Sasha /* Copyright (C) 2001-2006 MySQL AB & Sasha, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -39,8 +39,8 @@
uint rpl_status=RPL_NULL; uint rpl_status=RPL_NULL;
pthread_mutex_t LOCK_rpl_status; mysql_mutex_t LOCK_rpl_status;
pthread_cond_t COND_rpl_status; mysql_cond_t COND_rpl_status;
HASH slave_list; HASH slave_list;
const char *rpl_role_type[] = {"MASTER","SLAVE",NullS}; const char *rpl_role_type[] = {"MASTER","SLAVE",NullS};
@ -107,11 +107,11 @@ static int init_failsafe_rpl_thread(THD* thd)
void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status) void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status)
{ {
pthread_mutex_lock(&LOCK_rpl_status); mysql_mutex_lock(&LOCK_rpl_status);
if (rpl_status == from_status || rpl_status == RPL_ANY) if (rpl_status == from_status || rpl_status == RPL_ANY)
rpl_status = to_status; rpl_status = to_status;
pthread_cond_signal(&COND_rpl_status); mysql_cond_signal(&COND_rpl_status);
pthread_mutex_unlock(&LOCK_rpl_status); mysql_mutex_unlock(&LOCK_rpl_status);
} }
@ -140,7 +140,7 @@ void unregister_slave(THD* thd, bool only_mine, bool need_mutex)
if (thd->server_id) if (thd->server_id)
{ {
if (need_mutex) if (need_mutex)
pthread_mutex_lock(&LOCK_slave_list); mysql_mutex_lock(&LOCK_slave_list);
SLAVE_INFO* old_si; SLAVE_INFO* old_si;
if ((old_si = (SLAVE_INFO*)my_hash_search(&slave_list, if ((old_si = (SLAVE_INFO*)my_hash_search(&slave_list,
@ -149,7 +149,7 @@ void unregister_slave(THD* thd, bool only_mine, bool need_mutex)
my_hash_delete(&slave_list, (uchar*)old_si); my_hash_delete(&slave_list, (uchar*)old_si);
if (need_mutex) if (need_mutex)
pthread_mutex_unlock(&LOCK_slave_list); mysql_mutex_unlock(&LOCK_slave_list);
} }
} }
@ -170,7 +170,7 @@ int register_slave(THD* thd, uchar* packet, uint packet_length)
uchar *p= packet, *p_end= packet + packet_length; uchar *p= packet, *p_end= packet + packet_length;
const char *errmsg= "Wrong parameters to function register_slave"; const char *errmsg= "Wrong parameters to function register_slave";
if (check_access(thd, REPL_SLAVE_ACL, any_db,0,0,0,0)) if (check_access(thd, REPL_SLAVE_ACL, any_db, NULL, NULL, 0, 0))
return 1; return 1;
if (!(si = (SLAVE_INFO*)my_malloc(sizeof(SLAVE_INFO), MYF(MY_WME)))) if (!(si = (SLAVE_INFO*)my_malloc(sizeof(SLAVE_INFO), MYF(MY_WME))))
goto err2; goto err2;
@ -189,10 +189,10 @@ int register_slave(THD* thd, uchar* packet, uint packet_length)
si->master_id= server_id; si->master_id= server_id;
si->thd= thd; si->thd= thd;
pthread_mutex_lock(&LOCK_slave_list); mysql_mutex_lock(&LOCK_slave_list);
unregister_slave(thd,0,0); unregister_slave(thd,0,0);
res= my_hash_insert(&slave_list, (uchar*) si); res= my_hash_insert(&slave_list, (uchar*) si);
pthread_mutex_unlock(&LOCK_slave_list); mysql_mutex_unlock(&LOCK_slave_list);
return res; return res;
err: err:
@ -215,12 +215,37 @@ extern "C" void slave_info_free(void *s)
my_free(s, MYF(MY_WME)); my_free(s, MYF(MY_WME));
} }
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key key_LOCK_slave_list;
static PSI_mutex_info all_slave_list_mutexes[]=
{
{ &key_LOCK_slave_list, "LOCK_slave_list", PSI_FLAG_GLOBAL}
};
static void init_all_slave_list_mutexes(void)
{
const char* category= "sql";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_slave_list_mutexes);
PSI_server->register_mutex(category, all_slave_list_mutexes, count);
}
#endif /* HAVE_PSI_INTERFACE */
void init_slave_list() void init_slave_list()
{ {
#ifdef HAVE_PSI_INTERFACE
init_all_slave_list_mutexes();
#endif
my_hash_init(&slave_list, system_charset_info, SLAVE_LIST_CHUNK, 0, 0, my_hash_init(&slave_list, system_charset_info, SLAVE_LIST_CHUNK, 0, 0,
(my_hash_get_key) slave_list_key, (my_hash_get_key) slave_list_key,
(my_hash_free_key) slave_info_free, 0); (my_hash_free_key) slave_info_free, 0);
pthread_mutex_init(&LOCK_slave_list, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_slave_list, &LOCK_slave_list, MY_MUTEX_INIT_FAST);
} }
void end_slave_list() void end_slave_list()
@ -229,7 +254,7 @@ void end_slave_list()
if (my_hash_inited(&slave_list)) if (my_hash_inited(&slave_list))
{ {
my_hash_free(&slave_list); my_hash_free(&slave_list);
pthread_mutex_destroy(&LOCK_slave_list); mysql_mutex_destroy(&LOCK_slave_list);
} }
} }
@ -241,7 +266,7 @@ static int find_target_pos(LEX_MASTER_INFO *mi, IO_CACHE *log, char *errmsg)
for (;;) for (;;)
{ {
Log_event* ev; Log_event* ev;
if (!(ev = Log_event::read_log_event(log, (pthread_mutex_t*) 0, 0))) if (!(ev= Log_event::read_log_event(log, (mysql_mutex_t*) 0, 0)))
{ {
if (log->error > 0) if (log->error > 0)
strmov(errmsg, "Binary log truncated in the middle of event"); strmov(errmsg, "Binary log truncated in the middle of event");
@ -283,7 +308,7 @@ int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg)
char last_log_name[FN_REFLEN]; char last_log_name[FN_REFLEN];
IO_CACHE log; IO_CACHE log;
File file = -1, last_file = -1; File file = -1, last_file = -1;
pthread_mutex_t *log_lock; mysql_mutex_t *log_lock;
const char* errmsg_p; const char* errmsg_p;
Slave_log_event* sev = 0; Slave_log_event* sev = 0;
my_off_t last_pos = 0; my_off_t last_pos = 0;
@ -313,7 +338,7 @@ int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg)
bzero((char*) &log,sizeof(log)); bzero((char*) &log,sizeof(log));
log_lock = mysql_bin_log.get_log_lock(); log_lock = mysql_bin_log.get_log_lock();
pthread_mutex_lock(log_lock); mysql_mutex_lock(log_lock);
for (;;) for (;;)
{ {
@ -345,7 +370,7 @@ int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg)
goto err; goto err;
} }
end_io_cache(&log); end_io_cache(&log);
(void) my_close(file, MYF(MY_WME)); mysql_file_close(file, MYF(MY_WME));
if (init_io_cache(&log, (file = last_file), IO_SIZE, READ_CACHE, 0, 0, if (init_io_cache(&log, (file = last_file), IO_SIZE, READ_CACHE, 0, 0,
MYF(MY_WME))) MYF(MY_WME)))
{ {
@ -361,7 +386,7 @@ int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg)
switch (mysql_bin_log.find_next_log(&linfo, 1)) { switch (mysql_bin_log.find_next_log(&linfo, 1)) {
case LOG_INFO_EOF: case LOG_INFO_EOF:
if (last_file >= 0) if (last_file >= 0)
(void)my_close(last_file, MYF(MY_WME)); mysql_file_close(last_file, MYF(MY_WME));
last_file = -1; last_file = -1;
goto found_log; goto found_log;
case 0: case 0:
@ -373,7 +398,7 @@ int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg)
end_io_cache(&log); end_io_cache(&log);
if (last_file >= 0) if (last_file >= 0)
(void) my_close(last_file, MYF(MY_WME)); mysql_file_close(last_file, MYF(MY_WME));
last_file = file; last_file = file;
} }
@ -386,15 +411,15 @@ found_log:
mi_inited: mi_inited:
error = 0; error = 0;
err: err:
pthread_mutex_unlock(log_lock); mysql_mutex_unlock(log_lock);
end_io_cache(&log); end_io_cache(&log);
pthread_mutex_lock(&LOCK_thread_count); pthread_mutex_lock(&LOCK_thread_count);
thd->current_linfo = 0; thd->current_linfo = 0;
pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_thread_count);
if (file >= 0) if (file >= 0)
(void) my_close(file, MYF(MY_WME)); mysql_file_close(file, MYF(MY_WME));
if (last_file >= 0 && last_file != file) if (last_file >= 0 && last_file != file)
(void) my_close(last_file, MYF(MY_WME)); mysql_file_close(last_file, MYF(MY_WME));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
@ -415,7 +440,7 @@ static Slave_log_event* find_slave_event(IO_CACHE* log,
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
if (!(ev = Log_event::read_log_event(log, (pthread_mutex_t*)0, 0))) if (!(ev= Log_event::read_log_event(log, (mysql_mutex_t*)0, 0)))
{ {
my_snprintf(errmsg, SLAVE_ERRMSG_SIZE, my_snprintf(errmsg, SLAVE_ERRMSG_SIZE,
"Error reading event in log '%s'", "Error reading event in log '%s'",
@ -537,7 +562,7 @@ HOSTS";
goto err; goto err;
} }
pthread_mutex_lock(&LOCK_slave_list); mysql_mutex_lock(&LOCK_slave_list);
while ((row= mysql_fetch_row(res))) while ((row= mysql_fetch_row(res)))
{ {
@ -552,14 +577,14 @@ HOSTS";
if (!(si = (SLAVE_INFO*)my_malloc(sizeof(SLAVE_INFO), MYF(MY_WME)))) if (!(si = (SLAVE_INFO*)my_malloc(sizeof(SLAVE_INFO), MYF(MY_WME))))
{ {
error= "the slave is out of memory"; error= "the slave is out of memory";
pthread_mutex_unlock(&LOCK_slave_list); mysql_mutex_unlock(&LOCK_slave_list);
goto err; goto err;
} }
si->server_id = log_server_id; si->server_id = log_server_id;
if (my_hash_insert(&slave_list, (uchar*)si)) if (my_hash_insert(&slave_list, (uchar*)si))
{ {
error= "the slave is out of memory"; error= "the slave is out of memory";
pthread_mutex_unlock(&LOCK_slave_list); mysql_mutex_unlock(&LOCK_slave_list);
goto err; goto err;
} }
} }
@ -573,7 +598,7 @@ HOSTS";
strmake(si->password, row[3], sizeof(si->password)-1); strmake(si->password, row[3], sizeof(si->password)-1);
} }
} }
pthread_mutex_unlock(&LOCK_slave_list); mysql_mutex_unlock(&LOCK_slave_list);
err: err:
if (res) if (res)
@ -611,13 +636,13 @@ pthread_handler_t handle_failsafe_rpl(void *arg)
sql_print_error("Could not initialize failsafe replication thread"); sql_print_error("Could not initialize failsafe replication thread");
goto err; goto err;
} }
pthread_mutex_lock(&LOCK_rpl_status); mysql_mutex_lock(&LOCK_rpl_status);
msg= thd->enter_cond(&COND_rpl_status, msg= thd->enter_cond(&COND_rpl_status,
&LOCK_rpl_status, "Waiting for request"); &LOCK_rpl_status, "Waiting for request");
while (!thd->killed && !abort_loop) while (!thd->killed && !abort_loop)
{ {
bool break_req_chain = 0; bool break_req_chain = 0;
pthread_cond_wait(&COND_rpl_status, &LOCK_rpl_status); mysql_cond_wait(&COND_rpl_status, &LOCK_rpl_status);
thd_proc_info(thd, "Processing request"); thd_proc_info(thd, "Processing request");
while (!break_req_chain) while (!break_req_chain)
{ {
@ -680,7 +705,7 @@ bool show_slave_hosts(THD* thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
pthread_mutex_lock(&LOCK_slave_list); mysql_mutex_lock(&LOCK_slave_list);
for (uint i = 0; i < slave_list.records; ++i) for (uint i = 0; i < slave_list.records; ++i)
{ {
@ -697,11 +722,11 @@ bool show_slave_hosts(THD* thd)
protocol->store((uint32) si->master_id); protocol->store((uint32) si->master_id);
if (protocol->write()) if (protocol->write())
{ {
pthread_mutex_unlock(&LOCK_slave_list); mysql_mutex_unlock(&LOCK_slave_list);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
} }
pthread_mutex_unlock(&LOCK_slave_list); mysql_mutex_unlock(&LOCK_slave_list);
my_eof(thd); my_eof(thd);
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }

View File

@ -1,7 +1,7 @@
#ifndef REPL_FAILSAFE_INCLUDED #ifndef REPL_FAILSAFE_INCLUDED
#define REPL_FAILSAFE_INCLUDED #define REPL_FAILSAFE_INCLUDED
/* Copyright (C) 2001-2005 MySQL AB & Sasha /* Copyright (C) 2001-2005 MySQL AB & Sasha, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -28,8 +28,8 @@ typedef enum {RPL_AUTH_MASTER=0,RPL_IDLE_SLAVE,RPL_ACTIVE_SLAVE,
RPL_ANY /* wild card used by change_rpl_status */ } RPL_STATUS; RPL_ANY /* wild card used by change_rpl_status */ } RPL_STATUS;
extern uint rpl_status; extern uint rpl_status;
extern pthread_mutex_t LOCK_rpl_status; extern mysql_mutex_t LOCK_rpl_status;
extern pthread_cond_t COND_rpl_status; extern mysql_cond_t COND_rpl_status;
extern TYPELIB rpl_role_typelib, rpl_status_typelib; extern TYPELIB rpl_role_typelib, rpl_status_typelib;
extern const char* rpl_role_type[], *rpl_status_type[]; extern const char* rpl_role_type[], *rpl_status_type[];

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2003 MySQL AB /* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -44,21 +44,21 @@ Master_info::Master_info(bool is_slave_recovery)
my_init_dynamic_array(&ignore_server_ids, sizeof(::server_id), 16, 16); my_init_dynamic_array(&ignore_server_ids, sizeof(::server_id), 16, 16);
bzero((char*) &file, sizeof(file)); bzero((char*) &file, sizeof(file));
pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_master_info_run_lock, &run_lock, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_master_info_data_lock, &data_lock, MY_MUTEX_INIT_FAST);
pthread_cond_init(&data_cond, NULL); mysql_cond_init(key_master_info_data_cond, &data_cond, NULL);
pthread_cond_init(&start_cond, NULL); mysql_cond_init(key_master_info_start_cond, &start_cond, NULL);
pthread_cond_init(&stop_cond, NULL); mysql_cond_init(key_master_info_stop_cond, &stop_cond, NULL);
} }
Master_info::~Master_info() Master_info::~Master_info()
{ {
delete_dynamic(&ignore_server_ids); delete_dynamic(&ignore_server_ids);
pthread_mutex_destroy(&run_lock); mysql_mutex_destroy(&run_lock);
pthread_mutex_destroy(&data_lock); mysql_mutex_destroy(&data_lock);
pthread_cond_destroy(&data_cond); mysql_cond_destroy(&data_cond);
pthread_cond_destroy(&start_cond); mysql_cond_destroy(&start_cond);
pthread_cond_destroy(&stop_cond); mysql_cond_destroy(&stop_cond);
} }
/** /**
@ -175,7 +175,7 @@ int init_master_info(Master_info* mi, const char* master_info_fname,
keep other threads from reading bogus info keep other threads from reading bogus info
*/ */
pthread_mutex_lock(&mi->data_lock); mysql_mutex_lock(&mi->data_lock);
fd = mi->fd; fd = mi->fd;
/* does master.info exist ? */ /* does master.info exist ? */
@ -184,7 +184,7 @@ int init_master_info(Master_info* mi, const char* master_info_fname,
{ {
if (abort_if_no_master_info_file) if (abort_if_no_master_info_file)
{ {
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/* /*
@ -192,8 +192,9 @@ int init_master_info(Master_info* mi, const char* master_info_fname,
the old descriptor and re-create the old file the old descriptor and re-create the old file
*/ */
if (fd >= 0) if (fd >= 0)
my_close(fd, MYF(MY_WME)); mysql_file_close(fd, MYF(MY_WME));
if ((fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0 ) if ((fd= mysql_file_open(key_file_master_info,
fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0 )
{ {
sql_print_error("Failed to create a new master info file (\ sql_print_error("Failed to create a new master info file (\
file '%s', errno %d)", fname, my_errno); file '%s', errno %d)", fname, my_errno);
@ -217,7 +218,8 @@ file '%s')", fname);
reinit_io_cache(&mi->file, READ_CACHE, 0L,0,0); reinit_io_cache(&mi->file, READ_CACHE, 0L,0,0);
else else
{ {
if ((fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0 ) if ((fd= mysql_file_open(key_file_master_info,
fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0 )
{ {
sql_print_error("Failed to open the existing master info file (\ sql_print_error("Failed to open the existing master info file (\
file '%s', errno %d)", fname, my_errno); file '%s', errno %d)", fname, my_errno);
@ -369,7 +371,7 @@ file '%s')", fname);
reinit_io_cache(&mi->file, WRITE_CACHE, 0L, 0, 1); reinit_io_cache(&mi->file, WRITE_CACHE, 0L, 0, 1);
if ((error=test(flush_master_info(mi, 1)))) if ((error=test(flush_master_info(mi, 1))))
sql_print_error("Failed to flush master info file"); sql_print_error("Failed to flush master info file");
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
DBUG_RETURN(error); DBUG_RETURN(error);
errwithmsg: errwithmsg:
@ -378,11 +380,11 @@ errwithmsg:
err: err:
if (fd >= 0) if (fd >= 0)
{ {
my_close(fd, MYF(0)); mysql_file_close(fd, MYF(0));
end_io_cache(&mi->file); end_io_cache(&mi->file);
} }
mi->fd= -1; mi->fd= -1;
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -494,7 +496,7 @@ void end_master_info(Master_info* mi)
if (mi->fd >= 0) if (mi->fd >= 0)
{ {
end_io_cache(&mi->file); end_io_cache(&mi->file);
(void)my_close(mi->fd, MYF(MY_WME)); mysql_file_close(mi->fd, MYF(MY_WME));
mi->fd = -1; mi->fd = -1;
} }
mi->inited = 0; mi->inited = 0;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2003 MySQL AB /* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -77,8 +77,8 @@ class Master_info : public Slave_reporting_capability
File fd; // we keep the file open, so we need to remember the file pointer File fd; // we keep the file open, so we need to remember the file pointer
IO_CACHE file; IO_CACHE file;
pthread_mutex_t data_lock,run_lock; mysql_mutex_t data_lock, run_lock;
pthread_cond_t data_cond,start_cond,stop_cond; mysql_cond_t data_cond, start_cond, stop_cond;
THD *io_thd; THD *io_thd;
MYSQL* mysql; MYSQL* mysql;
uint32 file_id; /* for 3.23 load data infile */ uint32 file_id; /* for 3.23 load data infile */

View File

@ -1,7 +1,29 @@
/* Copyright (C) 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysql_priv.h" #include "mysql_priv.h"
#include "rpl_reporting.h" #include "rpl_reporting.h"
Slave_reporting_capability::Slave_reporting_capability(char const *thread_name)
: m_thread_name(thread_name)
{
mysql_mutex_init(key_mutex_slave_reporting_capability_err_lock,
&err_lock, MY_MUTEX_INIT_FAST);
}
void void
Slave_reporting_capability::report(loglevel level, int err_code, Slave_reporting_capability::report(loglevel level, int err_code,
const char *msg, ...) const const char *msg, ...) const
@ -13,7 +35,7 @@ Slave_reporting_capability::report(loglevel level, int err_code,
va_list args; va_list args;
va_start(args, msg); va_start(args, msg);
pthread_mutex_lock(&err_lock); mysql_mutex_lock(&err_lock);
switch (level) switch (level)
{ {
case ERROR_LEVEL: case ERROR_LEVEL:
@ -39,7 +61,7 @@ Slave_reporting_capability::report(loglevel level, int err_code,
my_vsnprintf(pbuff, pbuffsize, msg, args); my_vsnprintf(pbuff, pbuffsize, msg, args);
pthread_mutex_unlock(&err_lock); mysql_mutex_unlock(&err_lock);
va_end(args); va_end(args);
/* If the msg string ends with '.', do not add a ',' it would be ugly */ /* If the msg string ends with '.', do not add a ',' it would be ugly */
@ -51,5 +73,5 @@ Slave_reporting_capability::report(loglevel level, int err_code,
Slave_reporting_capability::~Slave_reporting_capability() Slave_reporting_capability::~Slave_reporting_capability()
{ {
pthread_mutex_destroy(&err_lock); mysql_mutex_destroy(&err_lock);
} }

View File

@ -1,6 +1,21 @@
#ifndef RPL_REPORTING_H #ifndef RPL_REPORTING_H
#define RPL_REPORTING_H #define RPL_REPORTING_H
/* Copyright (C) 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/** /**
Maximum size of an error message from a slave thread. Maximum size of an error message from a slave thread.
*/ */
@ -17,17 +32,13 @@ class Slave_reporting_capability
{ {
public: public:
/** lock used to synchronize m_last_error on 'SHOW SLAVE STATUS' **/ /** lock used to synchronize m_last_error on 'SHOW SLAVE STATUS' **/
mutable pthread_mutex_t err_lock; mutable mysql_mutex_t err_lock;
/** /**
Constructor. Constructor.
@param thread_name Printable name of the slave thread that is reporting. @param thread_name Printable name of the slave thread that is reporting.
*/ */
Slave_reporting_capability(char const *thread_name) Slave_reporting_capability(char const *thread_name);
: m_thread_name(thread_name)
{
pthread_mutex_init(&err_lock, MY_MUTEX_INIT_FAST);
}
/** /**
Writes a message and, if it's an error message, to Last_Error Writes a message and, if it's an error message, to Last_Error
@ -47,9 +58,9 @@ public:
STATUS</code>. STATUS</code>.
*/ */
void clear_error() { void clear_error() {
pthread_mutex_lock(&err_lock); mysql_mutex_lock(&err_lock);
m_last_error.clear(); m_last_error.clear();
pthread_mutex_unlock(&err_lock); mysql_mutex_unlock(&err_lock);
} }
/** /**

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2003 MySQL AB /* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -54,13 +54,15 @@ Relay_log_info::Relay_log_info(bool is_slave_recovery)
bzero((char*) &info_file, sizeof(info_file)); bzero((char*) &info_file, sizeof(info_file));
bzero((char*) &cache_buf, sizeof(cache_buf)); bzero((char*) &cache_buf, sizeof(cache_buf));
cached_charset_invalidate(); cached_charset_invalidate();
pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_relay_log_info_run_lock, &run_lock, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_relay_log_info_data_lock,
pthread_mutex_init(&log_space_lock, MY_MUTEX_INIT_FAST); &data_lock, MY_MUTEX_INIT_FAST);
pthread_cond_init(&data_cond, NULL); mysql_mutex_init(key_relay_log_info_log_space_lock,
pthread_cond_init(&start_cond, NULL); &log_space_lock, MY_MUTEX_INIT_FAST);
pthread_cond_init(&stop_cond, NULL); mysql_cond_init(key_relay_log_info_data_cond, &data_cond, NULL);
pthread_cond_init(&log_space_cond, NULL); mysql_cond_init(key_relay_log_info_start_cond, &start_cond, NULL);
mysql_cond_init(key_relay_log_info_stop_cond, &stop_cond, NULL);
mysql_cond_init(key_relay_log_info_log_space_cond, &log_space_cond, NULL);
relay_log.init_pthread_objects(); relay_log.init_pthread_objects();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -70,13 +72,13 @@ Relay_log_info::~Relay_log_info()
{ {
DBUG_ENTER("Relay_log_info::~Relay_log_info"); DBUG_ENTER("Relay_log_info::~Relay_log_info");
pthread_mutex_destroy(&run_lock); mysql_mutex_destroy(&run_lock);
pthread_mutex_destroy(&data_lock); mysql_mutex_destroy(&data_lock);
pthread_mutex_destroy(&log_space_lock); mysql_mutex_destroy(&log_space_lock);
pthread_cond_destroy(&data_cond); mysql_cond_destroy(&data_cond);
pthread_cond_destroy(&start_cond); mysql_cond_destroy(&start_cond);
pthread_cond_destroy(&stop_cond); mysql_cond_destroy(&stop_cond);
pthread_cond_destroy(&log_space_cond); mysql_cond_destroy(&log_space_cond);
relay_log.cleanup(); relay_log.cleanup();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -95,7 +97,7 @@ int init_relay_log_info(Relay_log_info* rli,
if (rli->inited) // Set if this function called if (rli->inited) // Set if this function called
DBUG_RETURN(0); DBUG_RETURN(0);
fn_format(fname, info_fname, mysql_data_home, "", 4+32); fn_format(fname, info_fname, mysql_data_home, "", 4+32);
pthread_mutex_lock(&rli->data_lock); mysql_mutex_lock(&rli->data_lock);
info_fd = rli->info_fd; info_fd = rli->info_fd;
rli->cur_log_fd = -1; rli->cur_log_fd = -1;
rli->slave_skip_counter=0; rli->slave_skip_counter=0;
@ -110,7 +112,7 @@ int init_relay_log_info(Relay_log_info* rli,
if (fn_format(pattern, PREFIX_SQL_LOAD, pattern, "", if (fn_format(pattern, PREFIX_SQL_LOAD, pattern, "",
MY_SAFE_PATH | MY_RETURN_REAL_PATH) == NullS) MY_SAFE_PATH | MY_RETURN_REAL_PATH) == NullS)
{ {
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
sql_print_error("Unable to use slave's temporary directory %s", sql_print_error("Unable to use slave's temporary directory %s",
slave_load_tmpdir); slave_load_tmpdir);
DBUG_RETURN(1); DBUG_RETURN(1);
@ -139,7 +141,7 @@ int init_relay_log_info(Relay_log_info* rli,
if (opt_relay_logname && if (opt_relay_logname &&
opt_relay_logname[strlen(opt_relay_logname) - 1] == FN_LIBCHAR) opt_relay_logname[strlen(opt_relay_logname) - 1] == FN_LIBCHAR)
{ {
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
sql_print_error("Path '%s' is a directory name, please specify \ sql_print_error("Path '%s' is a directory name, please specify \
a file name for --relay-log option", opt_relay_logname); a file name for --relay-log option", opt_relay_logname);
DBUG_RETURN(1); DBUG_RETURN(1);
@ -151,7 +153,7 @@ a file name for --relay-log option", opt_relay_logname);
opt_relaylog_index_name[strlen(opt_relaylog_index_name) - 1] opt_relaylog_index_name[strlen(opt_relaylog_index_name) - 1]
== FN_LIBCHAR) == FN_LIBCHAR)
{ {
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
sql_print_error("Path '%s' is a directory name, please specify \ sql_print_error("Path '%s' is a directory name, please specify \
a file name for --relay-log-index option", opt_relaylog_index_name); a file name for --relay-log-index option", opt_relaylog_index_name);
DBUG_RETURN(1); DBUG_RETURN(1);
@ -188,7 +190,7 @@ a file name for --relay-log-index option", opt_relaylog_index_name);
(max_relay_log_size ? max_relay_log_size : (max_relay_log_size ? max_relay_log_size :
max_binlog_size), 1, TRUE)) max_binlog_size), 1, TRUE))
{ {
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
sql_print_error("Failed in open_log() called from init_relay_log_info()"); sql_print_error("Failed in open_log() called from init_relay_log_info()");
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -203,8 +205,9 @@ a file name for --relay-log-index option", opt_relaylog_index_name);
the old descriptor and re-create the old file the old descriptor and re-create the old file
*/ */
if (info_fd >= 0) if (info_fd >= 0)
my_close(info_fd, MYF(MY_WME)); mysql_file_close(info_fd, MYF(MY_WME));
if ((info_fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0) if ((info_fd= mysql_file_open(key_file_relay_log_info,
fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
{ {
sql_print_error("Failed to create a new relay log info file (\ sql_print_error("Failed to create a new relay log info file (\
file '%s', errno %d)", fname, my_errno); file '%s', errno %d)", fname, my_errno);
@ -238,7 +241,8 @@ file '%s', errno %d)", fname, my_errno);
else else
{ {
int error=0; int error=0;
if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0) if ((info_fd= mysql_file_open(key_file_relay_log_info,
fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
{ {
sql_print_error("\ sql_print_error("\
Failed to open the existing relay log info file '%s' (errno %d)", Failed to open the existing relay log info file '%s' (errno %d)",
@ -255,10 +259,10 @@ Failed to open the existing relay log info file '%s' (errno %d)",
if (error) if (error)
{ {
if (info_fd >= 0) if (info_fd >= 0)
my_close(info_fd, MYF(0)); mysql_file_close(info_fd, MYF(0));
rli->info_fd= -1; rli->info_fd= -1;
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT); rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
} }
@ -327,17 +331,17 @@ Failed to open the existing relay log info file '%s' (errno %d)",
goto err; goto err;
} }
rli->inited= 1; rli->inited= 1;
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
DBUG_RETURN(error); DBUG_RETURN(error);
err: err:
sql_print_error("%s", msg); sql_print_error("%s", msg);
end_io_cache(&rli->info_file); end_io_cache(&rli->info_file);
if (info_fd >= 0) if (info_fd >= 0)
my_close(info_fd, MYF(0)); mysql_file_close(info_fd, MYF(0));
rli->info_fd= -1; rli->info_fd= -1;
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT); rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -346,7 +350,8 @@ static inline int add_relay_log(Relay_log_info* rli,LOG_INFO* linfo)
{ {
MY_STAT s; MY_STAT s;
DBUG_ENTER("add_relay_log"); DBUG_ENTER("add_relay_log");
if (!my_stat(linfo->log_file_name,&s,MYF(0))) if (!mysql_file_stat(key_file_binlog,
linfo->log_file_name, &s, MYF(0)))
{ {
sql_print_error("log %s listed in the index, but failed to stat", sql_print_error("log %s listed in the index, but failed to stat",
linfo->log_file_name); linfo->log_file_name);
@ -446,10 +451,10 @@ int init_relay_log_pos(Relay_log_info* rli,const char* log,
DBUG_PRINT("info", ("pos: %lu", (ulong) pos)); DBUG_PRINT("info", ("pos: %lu", (ulong) pos));
*errmsg=0; *errmsg=0;
pthread_mutex_t *log_lock=rli->relay_log.get_log_lock(); mysql_mutex_t *log_lock= rli->relay_log.get_log_lock();
if (need_data_lock) if (need_data_lock)
pthread_mutex_lock(&rli->data_lock); mysql_mutex_lock(&rli->data_lock);
/* /*
Slave threads are not the only users of init_relay_log_pos(). CHANGE MASTER Slave threads are not the only users of init_relay_log_pos(). CHANGE MASTER
@ -469,13 +474,13 @@ int init_relay_log_pos(Relay_log_info* rli,const char* log,
rli->relay_log.description_event_for_exec= new rli->relay_log.description_event_for_exec= new
Format_description_log_event(3); Format_description_log_event(3);
pthread_mutex_lock(log_lock); mysql_mutex_lock(log_lock);
/* Close log file and free buffers if it's already open */ /* Close log file and free buffers if it's already open */
if (rli->cur_log_fd >= 0) if (rli->cur_log_fd >= 0)
{ {
end_io_cache(&rli->cache_buf); end_io_cache(&rli->cache_buf);
my_close(rli->cur_log_fd, MYF(MY_WME)); mysql_file_close(rli->cur_log_fd, MYF(MY_WME));
rli->cur_log_fd = -1; rli->cur_log_fd = -1;
} }
@ -609,12 +614,12 @@ err:
*/ */
if (!relay_log_purge) if (!relay_log_purge)
rli->log_space_limit= 0; rli->log_space_limit= 0;
pthread_cond_broadcast(&rli->data_cond); mysql_cond_broadcast(&rli->data_cond);
pthread_mutex_unlock(log_lock); mysql_mutex_unlock(log_lock);
if (need_data_lock) if (need_data_lock)
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
if (!rli->relay_log.description_event_for_exec->is_valid() && !*errmsg) if (!rli->relay_log.description_event_for_exec->is_valid() && !*errmsg)
*errmsg= "Invalid Format_description log event; could be out of memory"; *errmsg= "Invalid Format_description log event; could be out of memory";
@ -665,7 +670,7 @@ int Relay_log_info::wait_for_pos(THD* thd, String* log_name,
log_name->c_ptr(), (ulong) log_pos, (ulong) timeout)); log_name->c_ptr(), (ulong) log_pos, (ulong) timeout));
set_timespec(abstime,timeout); set_timespec(abstime,timeout);
pthread_mutex_lock(&data_lock); mysql_mutex_lock(&data_lock);
msg= thd->enter_cond(&data_cond, &data_lock, msg= thd->enter_cond(&data_cond, &data_lock,
"Waiting for the slave SQL thread to " "Waiting for the slave SQL thread to "
"advance position"); "advance position");
@ -778,26 +783,26 @@ int Relay_log_info::wait_for_pos(THD* thd, String* log_name,
DBUG_PRINT("info",("Waiting for master update")); DBUG_PRINT("info",("Waiting for master update"));
/* /*
We are going to pthread_cond_(timed)wait(); if the SQL thread stops it We are going to mysql_cond_(timed)wait(); if the SQL thread stops it
will wake us up. will wake us up.
*/ */
if (timeout > 0) if (timeout > 0)
{ {
/* /*
Note that pthread_cond_timedwait checks for the timeout Note that mysql_cond_timedwait checks for the timeout
before for the condition ; i.e. it returns ETIMEDOUT before for the condition ; i.e. it returns ETIMEDOUT
if the system time equals or exceeds the time specified by abstime if the system time equals or exceeds the time specified by abstime
before the condition variable is signaled or broadcast, _or_ if before the condition variable is signaled or broadcast, _or_ if
the absolute time specified by abstime has already passed at the time the absolute time specified by abstime has already passed at the time
of the call. of the call.
For that reason, pthread_cond_timedwait will do the "timeoutting" job For that reason, mysql_cond_timedwait will do the "timeoutting" job
even if its condition is always immediately signaled (case of a loaded even if its condition is always immediately signaled (case of a loaded
master). master).
*/ */
error=pthread_cond_timedwait(&data_cond, &data_lock, &abstime); error= mysql_cond_timedwait(&data_cond, &data_lock, &abstime);
} }
else else
pthread_cond_wait(&data_cond, &data_lock); mysql_cond_wait(&data_cond, &data_lock);
DBUG_PRINT("info",("Got signal of master update or timed out")); DBUG_PRINT("info",("Got signal of master update or timed out"));
if (error == ETIMEDOUT || error == ETIME) if (error == ETIMEDOUT || error == ETIME)
{ {
@ -833,7 +838,7 @@ void Relay_log_info::inc_group_relay_log_pos(ulonglong log_pos,
DBUG_ENTER("Relay_log_info::inc_group_relay_log_pos"); DBUG_ENTER("Relay_log_info::inc_group_relay_log_pos");
if (!skip_lock) if (!skip_lock)
pthread_mutex_lock(&data_lock); mysql_mutex_lock(&data_lock);
inc_event_relay_log_pos(); inc_event_relay_log_pos();
group_relay_log_pos= event_relay_log_pos; group_relay_log_pos= event_relay_log_pos;
strmake(group_relay_log_name,event_relay_log_name, strmake(group_relay_log_name,event_relay_log_name,
@ -877,9 +882,9 @@ void Relay_log_info::inc_group_relay_log_pos(ulonglong log_pos,
{ {
group_master_log_pos= log_pos; group_master_log_pos= log_pos;
} }
pthread_cond_broadcast(&data_cond); mysql_cond_broadcast(&data_cond);
if (!skip_lock) if (!skip_lock)
pthread_mutex_unlock(&data_lock); mysql_mutex_unlock(&data_lock);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -948,7 +953,7 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
DBUG_ASSERT(rli->mi->slave_running == 0); DBUG_ASSERT(rli->mi->slave_running == 0);
rli->slave_skip_counter=0; rli->slave_skip_counter=0;
pthread_mutex_lock(&rli->data_lock); mysql_mutex_lock(&rli->data_lock);
/* /*
we close the relay log fd possibly left open by the slave SQL thread, we close the relay log fd possibly left open by the slave SQL thread,
@ -959,7 +964,7 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
if (rli->cur_log_fd >= 0) if (rli->cur_log_fd >= 0)
{ {
end_io_cache(&rli->cache_buf); end_io_cache(&rli->cache_buf);
my_close(rli->cur_log_fd, MYF(MY_WME)); mysql_file_close(rli->cur_log_fd, MYF(MY_WME));
rli->cur_log_fd= -1; rli->cur_log_fd= -1;
} }
@ -991,7 +996,7 @@ err:
char buf[22]; char buf[22];
#endif #endif
DBUG_PRINT("info",("log_space_total: %s",llstr(rli->log_space_total,buf))); DBUG_PRINT("info",("log_space_total: %s",llstr(rli->log_space_total,buf)));
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
DBUG_RETURN(error); DBUG_RETURN(error);
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2005 MySQL AB /* Copyright (C) 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -123,17 +123,17 @@ public:
TABLE *save_temporary_tables; TABLE *save_temporary_tables;
/* /*
standard lock acquistion order to avoid deadlocks: standard lock acquisition order to avoid deadlocks:
run_lock, data_lock, relay_log.LOCK_log, relay_log.LOCK_index run_lock, data_lock, relay_log.LOCK_log, relay_log.LOCK_index
*/ */
pthread_mutex_t data_lock,run_lock; mysql_mutex_t data_lock, run_lock;
/* /*
start_cond is broadcast when SQL thread is started start_cond is broadcast when SQL thread is started
stop_cond - when stopped stop_cond - when stopped
data_cond - when data protected by data_lock changes data_cond - when data protected by data_lock changes
*/ */
pthread_cond_t start_cond, stop_cond, data_cond; mysql_cond_t start_cond, stop_cond, data_cond;
/* parent Master_info structure */ /* parent Master_info structure */
Master_info *mi; Master_info *mi;
@ -215,8 +215,8 @@ public:
volatile uint32 slave_skip_counter; volatile uint32 slave_skip_counter;
volatile ulong abort_pos_wait; /* Incremented on change master */ volatile ulong abort_pos_wait; /* Incremented on change master */
volatile ulong slave_run_id; /* Incremented on slave start */ volatile ulong slave_run_id; /* Incremented on slave start */
pthread_mutex_t log_space_lock; mysql_mutex_t log_space_lock;
pthread_cond_t log_space_cond; mysql_cond_t log_space_cond;
THD * sql_thd; THD * sql_thd;
#ifndef DBUG_OFF #ifndef DBUG_OFF
int events_till_abort; int events_till_abort;

View File

@ -1,4 +1,4 @@
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. /* Copyright 2000-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -38,16 +38,12 @@ static uchar *get_sys_var_length(const sys_var *var, size_t *length,
sys_var_chain all_sys_vars = { NULL, NULL }; sys_var_chain all_sys_vars = { NULL, NULL };
int sys_var_init(DYNAMIC_ARRAY *long_options) int sys_var_init()
{ {
uint count= 0;
uint saved_elements= long_options->elements;
DBUG_ENTER("sys_var_init"); DBUG_ENTER("sys_var_init");
for (sys_var *var=all_sys_vars.first; var; var= var->next, count++) /* Must be already initialized. */
if (var->register_option(long_options)) DBUG_ASSERT(system_charset_info != NULL);
goto error;
if (my_hash_init(&system_variable_hash, system_charset_info, 100, 0, if (my_hash_init(&system_variable_hash, system_charset_info, 100, 0,
0, (my_hash_get_key) get_sys_var_length, 0, HASH_UNIQUE)) 0, (my_hash_get_key) get_sys_var_length, 0, HASH_UNIQUE))
@ -58,6 +54,25 @@ int sys_var_init(DYNAMIC_ARRAY *long_options)
DBUG_RETURN(0); DBUG_RETURN(0);
error:
fprintf(stderr, "failed to initialize System variables");
DBUG_RETURN(1);
}
int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags)
{
uint saved_elements= long_options->elements;
DBUG_ENTER("sys_var_add_options");
for (sys_var *var=all_sys_vars.first; var; var= var->next)
{
if (var->register_option(long_options, parse_flags))
goto error;
}
DBUG_RETURN(0);
error: error:
fprintf(stderr, "failed to initialize System variables"); fprintf(stderr, "failed to initialize System variables");
long_options->elements= saved_elements; long_options->elements= saved_elements;
@ -99,6 +114,7 @@ void sys_var_end()
@param deprecated_version if not 0 - when this variable will go away @param deprecated_version if not 0 - when this variable will go away
@param substitute if not 0 - what one should use instead when this @param substitute if not 0 - what one should use instead when this
deprecated variable deprecated variable
@param parse_flag either PARSE_EARLY or PARSE_NORMAL
*/ */
sys_var::sys_var(sys_var_chain *chain, const char *name_arg, sys_var::sys_var(sys_var_chain *chain, const char *name_arg,
const char *comment, int flags_arg, ptrdiff_t off, const char *comment, int flags_arg, ptrdiff_t off,
@ -107,10 +123,11 @@ sys_var::sys_var(sys_var_chain *chain, const char *name_arg,
PolyLock *lock, enum binlog_status_enum binlog_status_arg, PolyLock *lock, enum binlog_status_enum binlog_status_arg,
on_check_function on_check_func, on_check_function on_check_func,
on_update_function on_update_func, on_update_function on_update_func,
uint deprecated_version, const char *substitute) : uint deprecated_version, const char *substitute,
int parse_flag) :
next(0), next(0),
binlog_status(binlog_status_arg), binlog_status(binlog_status_arg),
flags(flags_arg), show_val_type(show_val_type_arg), flags(flags_arg), m_parse_flag(parse_flag), show_val_type(show_val_type_arg),
guard(lock), offset(off), on_check(on_check_func), on_update(on_update_func), guard(lock), offset(off), on_check(on_check_func), on_update(on_update_func),
is_os_charset(FALSE) is_os_charset(FALSE)
{ {
@ -203,7 +220,7 @@ uchar *sys_var::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
{ {
if (type == OPT_GLOBAL || scope() == GLOBAL) if (type == OPT_GLOBAL || scope() == GLOBAL)
{ {
safe_mutex_assert_owner(&LOCK_global_system_variables); mysql_mutex_assert_owner(&LOCK_global_system_variables);
AutoRLock lock(guard); AutoRLock lock(guard);
return global_value_ptr(thd, base); return global_value_ptr(thd, base);
} }

View File

@ -1,6 +1,6 @@
#ifndef SET_VAR_INCLUDED #ifndef SET_VAR_INCLUDED
#define SET_VAR_INCLUDED #define SET_VAR_INCLUDED
/* Copyright 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc. /* Copyright (C) 2000-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -56,6 +56,8 @@ public:
LEX_CSTRING name; LEX_CSTRING name;
enum flag_enum { GLOBAL, SESSION, ONLY_SESSION, SCOPE_MASK=1023, enum flag_enum { GLOBAL, SESSION, ONLY_SESSION, SCOPE_MASK=1023,
READONLY=1024, ALLOCATED=2048 }; READONLY=1024, ALLOCATED=2048 };
static const int PARSE_EARLY= 1;
static const int PARSE_NORMAL= 2;
/** /**
Enumeration type to indicate for a system variable whether Enumeration type to indicate for a system variable whether
it will be written to the binlog or not. it will be written to the binlog or not.
@ -68,6 +70,7 @@ protected:
typedef bool (*on_update_function)(sys_var *self, THD *thd, enum_var_type type); typedef bool (*on_update_function)(sys_var *self, THD *thd, enum_var_type type);
int flags; ///< or'ed flag_enum values int flags; ///< or'ed flag_enum values
int m_parse_flag; ///< either PARSE_EARLY or PARSE_NORMAL.
const SHOW_TYPE show_val_type; ///< what value_ptr() returns for sql_show.cc const SHOW_TYPE show_val_type; ///< what value_ptr() returns for sql_show.cc
my_option option; ///< min, max, default values are stored here my_option option; ///< min, max, default values are stored here
PolyLock *guard; ///< *second* lock that protects the variable PolyLock *guard; ///< *second* lock that protects the variable
@ -83,7 +86,7 @@ public:
enum get_opt_arg_type getopt_arg_type, SHOW_TYPE show_val_type_arg, enum get_opt_arg_type getopt_arg_type, SHOW_TYPE show_val_type_arg,
longlong def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg, longlong def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg,
on_check_function on_check_func, on_update_function on_update_func, on_check_function on_check_func, on_update_function on_update_func,
uint deprecated_version, const char *substitute); uint deprecated_version, const char *substitute, int parse_flag);
/** /**
The instance should only be destroyed on shutdown, as it doesn't unlink The instance should only be destroyed on shutdown, as it doesn't unlink
itself from the chain. itself from the chain.
@ -122,8 +125,11 @@ public:
} }
return true; // keep gcc happy return true; // keep gcc happy
} }
bool register_option(DYNAMIC_ARRAY *array) bool register_option(DYNAMIC_ARRAY *array, int parse_flags)
{ return option.id != -1 && insert_dynamic(array, (uchar*)&option); } {
return (option.id != -1) && (m_parse_flag & parse_flags) &&
insert_dynamic(array, (uchar*)&option);
}
private: private:
virtual bool do_check(THD *thd, set_var *var) = 0; virtual bool do_check(THD *thd, set_var *var) = 0;
@ -289,7 +295,8 @@ extern sys_var *Sys_autocommit_ptr;
CHARSET_INFO *get_old_charset_by_name(const char *old_name); CHARSET_INFO *get_old_charset_by_name(const char *old_name);
int sys_var_init(DYNAMIC_ARRAY *long_options); int sys_var_init();
int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags);
void sys_var_end(void); void sys_var_end(void);
#endif #endif

View File

@ -6266,3 +6266,8 @@ ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT
eng "The syntax '%s' is deprecated and will be removed in MySQL %s." eng "The syntax '%s' is deprecated and will be removed in MySQL %s."
ger "Die Syntax '%s' ist veraltet und wird in MySQL %s entfernt." ger "Die Syntax '%s' ist veraltet und wird in MySQL %s entfernt."
ER_WRONG_NATIVE_TABLE_STRUCTURE
eng "Native table '%-.64s'.'%-.64s' has the wrong structure"
ER_WRONG_PERFSCHEMA_USAGE
eng "Invalid performance_schema usage."

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2003 MySQL AB /* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -148,8 +148,8 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi);
static Log_event* next_event(Relay_log_info* rli); static Log_event* next_event(Relay_log_info* rli);
static int queue_event(Master_info* mi,const char* buf,ulong event_len); static int queue_event(Master_info* mi,const char* buf,ulong event_len);
static int terminate_slave_thread(THD *thd, static int terminate_slave_thread(THD *thd,
pthread_mutex_t *term_lock, mysql_mutex_t *term_lock,
pthread_cond_t *term_cond, mysql_cond_t *term_cond,
volatile uint *slave_running, volatile uint *slave_running,
bool skip_lock); bool skip_lock);
static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info); static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info);
@ -198,8 +198,8 @@ void lock_slave_threads(Master_info* mi)
DBUG_ENTER("lock_slave_threads"); DBUG_ENTER("lock_slave_threads");
//TODO: see if we can do this without dual mutex //TODO: see if we can do this without dual mutex
pthread_mutex_lock(&mi->run_lock); mysql_mutex_lock(&mi->run_lock);
pthread_mutex_lock(&mi->rli.run_lock); mysql_mutex_lock(&mi->rli.run_lock);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -213,11 +213,32 @@ void unlock_slave_threads(Master_info* mi)
DBUG_ENTER("unlock_slave_threads"); DBUG_ENTER("unlock_slave_threads");
//TODO: see if we can do this without dual mutex //TODO: see if we can do this without dual mutex
pthread_mutex_unlock(&mi->rli.run_lock); mysql_mutex_unlock(&mi->rli.run_lock);
pthread_mutex_unlock(&mi->run_lock); mysql_mutex_unlock(&mi->run_lock);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
#ifdef HAVE_PSI_INTERFACE
static PSI_thread_key key_thread_slave_io, key_thread_slave_sql;
static PSI_thread_info all_slave_threads[]=
{
{ &key_thread_slave_io, "slave_io", PSI_FLAG_GLOBAL},
{ &key_thread_slave_sql, "slave_sql", PSI_FLAG_GLOBAL}
};
static void init_slave_psi_keys(void)
{
const char* category= "sql";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_slave_threads);
PSI_server->register_thread(category, all_slave_threads, count);
}
#endif /* HAVE_PSI_INTERFACE */
/* Initialize slave structures */ /* Initialize slave structures */
@ -226,12 +247,16 @@ int init_slave()
DBUG_ENTER("init_slave"); DBUG_ENTER("init_slave");
int error= 0; int error= 0;
#ifdef HAVE_PSI_INTERFACE
init_slave_psi_keys();
#endif
/* /*
This is called when mysqld starts. Before client connections are This is called when mysqld starts. Before client connections are
accepted. However bootstrap may conflict with us if it does START SLAVE. accepted. However bootstrap may conflict with us if it does START SLAVE.
So it's safer to take the lock. So it's safer to take the lock.
*/ */
pthread_mutex_lock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_active_mi);
/* /*
TODO: re-write this to interate through the list of files TODO: re-write this to interate through the list of files
for multi-master for multi-master
@ -288,7 +313,7 @@ int init_slave()
} }
err: err:
pthread_mutex_unlock(&LOCK_active_mi); mysql_mutex_unlock(&LOCK_active_mi);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
@ -466,7 +491,7 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
if (!mi->inited) if (!mi->inited)
DBUG_RETURN(0); /* successfully do nothing */ DBUG_RETURN(0); /* successfully do nothing */
int error,force_all = (thread_mask & SLAVE_FORCE_ALL); int error,force_all = (thread_mask & SLAVE_FORCE_ALL);
pthread_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock; mysql_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock;
if (thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL)) if (thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL))
{ {
@ -530,19 +555,19 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
*/ */
static int static int
terminate_slave_thread(THD *thd, terminate_slave_thread(THD *thd,
pthread_mutex_t *term_lock, mysql_mutex_t *term_lock,
pthread_cond_t *term_cond, mysql_cond_t *term_cond,
volatile uint *slave_running, volatile uint *slave_running,
bool skip_lock) bool skip_lock)
{ {
DBUG_ENTER("terminate_slave_thread"); DBUG_ENTER("terminate_slave_thread");
if (!skip_lock) if (!skip_lock)
{ {
pthread_mutex_lock(term_lock); mysql_mutex_lock(term_lock);
} }
else else
{ {
safe_mutex_assert_owner(term_lock); mysql_mutex_assert_owner(term_lock);
} }
if (!*slave_running) if (!*slave_running)
{ {
@ -552,7 +577,7 @@ terminate_slave_thread(THD *thd,
if run_lock (term_lock) is acquired locally then either if run_lock (term_lock) is acquired locally then either
slave_running status is fine slave_running status is fine
*/ */
pthread_mutex_unlock(term_lock); mysql_mutex_unlock(term_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
else else
@ -573,7 +598,7 @@ terminate_slave_thread(THD *thd,
int error; int error;
DBUG_PRINT("loop", ("killing slave thread")); DBUG_PRINT("loop", ("killing slave thread"));
pthread_mutex_lock(&thd->LOCK_thd_data); mysql_mutex_lock(&thd->LOCK_thd_data);
#ifndef DONT_USE_THR_ALARM #ifndef DONT_USE_THR_ALARM
/* /*
Error codes from pthread_kill are: Error codes from pthread_kill are:
@ -584,7 +609,7 @@ terminate_slave_thread(THD *thd,
DBUG_ASSERT(err != EINVAL); DBUG_ASSERT(err != EINVAL);
#endif #endif
thd->awake(THD::NOT_KILLED); thd->awake(THD::NOT_KILLED);
pthread_mutex_unlock(&thd->LOCK_thd_data); mysql_mutex_unlock(&thd->LOCK_thd_data);
/* /*
There is a small chance that slave thread might miss the first There is a small chance that slave thread might miss the first
@ -592,21 +617,25 @@ terminate_slave_thread(THD *thd,
*/ */
struct timespec abstime; struct timespec abstime;
set_timespec(abstime,2); set_timespec(abstime,2);
error= pthread_cond_timedwait(term_cond, term_lock, &abstime); error= mysql_cond_timedwait(term_cond, term_lock, &abstime);
DBUG_ASSERT(error == ETIMEDOUT || error == 0); DBUG_ASSERT(error == ETIMEDOUT || error == 0);
} }
DBUG_ASSERT(*slave_running == 0); DBUG_ASSERT(*slave_running == 0);
if (!skip_lock) if (!skip_lock)
pthread_mutex_unlock(term_lock); mysql_mutex_unlock(term_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, int start_slave_thread(
pthread_mutex_t *cond_lock, #ifdef HAVE_PSI_INTERFACE
pthread_cond_t *start_cond, PSI_thread_key thread_key,
#endif
pthread_handler h_func, mysql_mutex_t *start_lock,
mysql_mutex_t *cond_lock,
mysql_cond_t *start_cond,
volatile uint *slave_running, volatile uint *slave_running,
volatile ulong *slave_run_id, volatile ulong *slave_run_id,
Master_info* mi) Master_info* mi)
@ -618,13 +647,13 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
DBUG_ASSERT(mi->inited); DBUG_ASSERT(mi->inited);
if (start_lock) if (start_lock)
pthread_mutex_lock(start_lock); mysql_mutex_lock(start_lock);
if (!server_id) if (!server_id)
{ {
if (start_cond) if (start_cond)
pthread_cond_broadcast(start_cond); mysql_cond_broadcast(start_cond);
if (start_lock) if (start_lock)
pthread_mutex_unlock(start_lock); mysql_mutex_unlock(start_lock);
sql_print_error("Server id not set, will not start slave"); sql_print_error("Server id not set, will not start slave");
DBUG_RETURN(ER_BAD_SLAVE); DBUG_RETURN(ER_BAD_SLAVE);
} }
@ -632,17 +661,18 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
if (*slave_running) if (*slave_running)
{ {
if (start_cond) if (start_cond)
pthread_cond_broadcast(start_cond); mysql_cond_broadcast(start_cond);
if (start_lock) if (start_lock)
pthread_mutex_unlock(start_lock); mysql_mutex_unlock(start_lock);
DBUG_RETURN(ER_SLAVE_MUST_STOP); DBUG_RETURN(ER_SLAVE_MUST_STOP);
} }
start_id= *slave_run_id; start_id= *slave_run_id;
DBUG_PRINT("info",("Creating new slave thread")); DBUG_PRINT("info",("Creating new slave thread"));
if (pthread_create(&th, &connection_attrib, h_func, (void*)mi)) if (mysql_thread_create(thread_key,
&th, &connection_attrib, h_func, (void*)mi))
{ {
if (start_lock) if (start_lock)
pthread_mutex_unlock(start_lock); mysql_mutex_unlock(start_lock);
DBUG_RETURN(ER_SLAVE_THREAD); DBUG_RETURN(ER_SLAVE_THREAD);
} }
if (start_cond && cond_lock) // caller has cond_lock if (start_cond && cond_lock) // caller has cond_lock
@ -653,19 +683,19 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
DBUG_PRINT("sleep",("Waiting for slave thread to start")); DBUG_PRINT("sleep",("Waiting for slave thread to start"));
const char* old_msg = thd->enter_cond(start_cond,cond_lock, const char* old_msg = thd->enter_cond(start_cond,cond_lock,
"Waiting for slave thread to start"); "Waiting for slave thread to start");
pthread_cond_wait(start_cond, cond_lock); mysql_cond_wait(start_cond, cond_lock);
thd->exit_cond(old_msg); thd->exit_cond(old_msg);
pthread_mutex_lock(cond_lock); // re-acquire it as exit_cond() released mysql_mutex_lock(cond_lock); // re-acquire it as exit_cond() released
if (thd->killed) if (thd->killed)
{ {
if (start_lock) if (start_lock)
pthread_mutex_unlock(start_lock); mysql_mutex_unlock(start_lock);
DBUG_RETURN(thd->killed_errno()); DBUG_RETURN(thd->killed_errno());
} }
} }
} }
if (start_lock) if (start_lock)
pthread_mutex_unlock(start_lock); mysql_mutex_unlock(start_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -683,8 +713,8 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
Master_info* mi, const char* master_info_fname, Master_info* mi, const char* master_info_fname,
const char* slave_info_fname, int thread_mask) const char* slave_info_fname, int thread_mask)
{ {
pthread_mutex_t *lock_io=0,*lock_sql=0,*lock_cond_io=0,*lock_cond_sql=0; mysql_mutex_t *lock_io=0, *lock_sql=0, *lock_cond_io=0, *lock_cond_sql=0;
pthread_cond_t* cond_io=0,*cond_sql=0; mysql_cond_t* cond_io=0, *cond_sql=0;
int error=0; int error=0;
DBUG_ENTER("start_slave_threads"); DBUG_ENTER("start_slave_threads");
@ -702,13 +732,21 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
} }
if (thread_mask & SLAVE_IO) if (thread_mask & SLAVE_IO)
error=start_slave_thread(handle_slave_io,lock_io,lock_cond_io, error= start_slave_thread(
#ifdef HAVE_PSI_INTERFACE
key_thread_slave_io,
#endif
handle_slave_io, lock_io, lock_cond_io,
cond_io, cond_io,
&mi->slave_running, &mi->slave_run_id, &mi->slave_running, &mi->slave_run_id,
mi); mi);
if (!error && (thread_mask & SLAVE_SQL)) if (!error && (thread_mask & SLAVE_SQL))
{ {
error=start_slave_thread(handle_slave_sql,lock_sql,lock_cond_sql, error= start_slave_thread(
#ifdef HAVE_PSI_INTERFACE
key_thread_slave_sql,
#endif
handle_slave_sql, lock_sql, lock_cond_sql,
cond_sql, cond_sql,
&mi->rli.slave_running, &mi->rli.slave_run_id, &mi->rli.slave_running, &mi->rli.slave_run_id,
mi); mi);
@ -748,7 +786,7 @@ void end_slave()
will make us wait until slave threads have started, and START SLAVE will make us wait until slave threads have started, and START SLAVE
returns, then we terminate them here. returns, then we terminate them here.
*/ */
pthread_mutex_lock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_active_mi);
if (active_mi) if (active_mi)
{ {
/* /*
@ -758,7 +796,7 @@ void end_slave()
*/ */
terminate_slave_threads(active_mi,SLAVE_FORCE_ALL); terminate_slave_threads(active_mi,SLAVE_FORCE_ALL);
} }
pthread_mutex_unlock(&LOCK_active_mi); mysql_mutex_unlock(&LOCK_active_mi);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -773,14 +811,14 @@ void end_slave()
*/ */
void close_active_mi() void close_active_mi()
{ {
pthread_mutex_lock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_active_mi);
if (active_mi) if (active_mi)
{ {
end_master_info(active_mi); end_master_info(active_mi);
delete active_mi; delete active_mi;
active_mi= 0; active_mi= 0;
} }
pthread_mutex_unlock(&LOCK_active_mi); mysql_mutex_unlock(&LOCK_active_mi);
} }
static bool io_slave_killed(THD* thd, Master_info* mi) static bool io_slave_killed(THD* thd, Master_info* mi)
@ -1479,7 +1517,7 @@ static bool wait_for_relay_log_space(Relay_log_info* rli)
THD* thd = mi->io_thd; THD* thd = mi->io_thd;
DBUG_ENTER("wait_for_relay_log_space"); DBUG_ENTER("wait_for_relay_log_space");
pthread_mutex_lock(&rli->log_space_lock); mysql_mutex_lock(&rli->log_space_lock);
save_proc_info= thd->enter_cond(&rli->log_space_cond, save_proc_info= thd->enter_cond(&rli->log_space_cond,
&rli->log_space_lock, &rli->log_space_lock,
"\ "\
@ -1487,7 +1525,7 @@ Waiting for the slave SQL thread to free enough relay log space");
while (rli->log_space_limit < rli->log_space_total && while (rli->log_space_limit < rli->log_space_total &&
!(slave_killed=io_slave_killed(thd,mi)) && !(slave_killed=io_slave_killed(thd,mi)) &&
!rli->ignore_log_space_limit) !rli->ignore_log_space_limit)
pthread_cond_wait(&rli->log_space_cond, &rli->log_space_lock); mysql_cond_wait(&rli->log_space_cond, &rli->log_space_lock);
thd->exit_cond(save_proc_info); thd->exit_cond(save_proc_info);
DBUG_RETURN(slave_killed); DBUG_RETURN(slave_killed);
} }
@ -1509,11 +1547,11 @@ Waiting for the slave SQL thread to free enough relay log space");
static void write_ignored_events_info_to_relay_log(THD *thd, Master_info *mi) static void write_ignored_events_info_to_relay_log(THD *thd, Master_info *mi)
{ {
Relay_log_info *rli= &mi->rli; Relay_log_info *rli= &mi->rli;
pthread_mutex_t *log_lock= rli->relay_log.get_log_lock(); mysql_mutex_t *log_lock= rli->relay_log.get_log_lock();
DBUG_ENTER("write_ignored_events_info_to_relay_log"); DBUG_ENTER("write_ignored_events_info_to_relay_log");
DBUG_ASSERT(thd == mi->io_thd); DBUG_ASSERT(thd == mi->io_thd);
pthread_mutex_lock(log_lock); mysql_mutex_lock(log_lock);
if (rli->ign_master_log_name_end[0]) if (rli->ign_master_log_name_end[0])
{ {
DBUG_PRINT("info",("writing a Rotate event to track down ignored events")); DBUG_PRINT("info",("writing a Rotate event to track down ignored events"));
@ -1522,7 +1560,7 @@ static void write_ignored_events_info_to_relay_log(THD *thd, Master_info *mi)
Rotate_log_event::DUP_NAME); Rotate_log_event::DUP_NAME);
rli->ign_master_log_name_end[0]= 0; rli->ign_master_log_name_end[0]= 0;
/* can unlock before writing as slave SQL thd will soon see our Rotate */ /* can unlock before writing as slave SQL thd will soon see our Rotate */
pthread_mutex_unlock(log_lock); mysql_mutex_unlock(log_lock);
if (likely((bool)ev)) if (likely((bool)ev))
{ {
ev->server_id= 0; // don't be ignored by slave SQL thread ev->server_id= 0; // don't be ignored by slave SQL thread
@ -1544,7 +1582,7 @@ static void write_ignored_events_info_to_relay_log(THD *thd, Master_info *mi)
" SHOW SLAVE STATUS may be inaccurate"); " SHOW SLAVE STATUS may be inaccurate");
} }
else else
pthread_mutex_unlock(log_lock); mysql_mutex_unlock(log_lock);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -1715,14 +1753,14 @@ bool show_master_info(THD* thd, Master_info* mi)
slave_running can be accessed without run_lock but not other slave_running can be accessed without run_lock but not other
non-volotile members like mi->io_thd, which is guarded by the mutex. non-volotile members like mi->io_thd, which is guarded by the mutex.
*/ */
pthread_mutex_lock(&mi->run_lock); mysql_mutex_lock(&mi->run_lock);
protocol->store(mi->io_thd ? mi->io_thd->proc_info : "", &my_charset_bin); protocol->store(mi->io_thd ? mi->io_thd->proc_info : "", &my_charset_bin);
pthread_mutex_unlock(&mi->run_lock); mysql_mutex_unlock(&mi->run_lock);
pthread_mutex_lock(&mi->data_lock); mysql_mutex_lock(&mi->data_lock);
pthread_mutex_lock(&mi->rli.data_lock); mysql_mutex_lock(&mi->rli.data_lock);
pthread_mutex_lock(&mi->err_lock); mysql_mutex_lock(&mi->err_lock);
pthread_mutex_lock(&mi->rli.err_lock); mysql_mutex_lock(&mi->rli.err_lock);
protocol->store(mi->host, &my_charset_bin); protocol->store(mi->host, &my_charset_bin);
protocol->store(mi->user, &my_charset_bin); protocol->store(mi->user, &my_charset_bin);
protocol->store((uint32) mi->port); protocol->store((uint32) mi->port);
@ -1849,10 +1887,10 @@ bool show_master_info(THD* thd, Master_info* mi)
// Master_Server_id // Master_Server_id
protocol->store((uint32) mi->master_id); protocol->store((uint32) mi->master_id);
pthread_mutex_unlock(&mi->rli.err_lock); mysql_mutex_unlock(&mi->rli.err_lock);
pthread_mutex_unlock(&mi->err_lock); mysql_mutex_unlock(&mi->err_lock);
pthread_mutex_unlock(&mi->rli.data_lock); mysql_mutex_unlock(&mi->rli.data_lock);
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
if (my_net_write(&thd->net, (uchar*) thd->packet.ptr(), packet->length())) if (my_net_write(&thd->net, (uchar*) thd->packet.ptr(), packet->length()))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
@ -2228,7 +2266,7 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli)
int reason= ev->shall_skip(rli); int reason= ev->shall_skip(rli);
if (reason == Log_event::EVENT_SKIP_COUNT) if (reason == Log_event::EVENT_SKIP_COUNT)
sql_slave_skip_counter= --rli->slave_skip_counter; sql_slave_skip_counter= --rli->slave_skip_counter;
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
if (reason == Log_event::EVENT_SKIP_NOT) if (reason == Log_event::EVENT_SKIP_NOT)
exec_res= ev->apply_event(rli); exec_res= ev->apply_event(rli);
@ -2334,7 +2372,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli)
event execution. But we will release it in places where we will event execution. But we will release it in places where we will
wait for something for example inside of next_event(). wait for something for example inside of next_event().
*/ */
pthread_mutex_lock(&rli->data_lock); mysql_mutex_lock(&rli->data_lock);
Log_event * ev = next_event(rli); Log_event * ev = next_event(rli);
@ -2342,7 +2380,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli)
if (sql_slave_killed(thd,rli)) if (sql_slave_killed(thd,rli))
{ {
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
delete ev; delete ev;
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -2365,7 +2403,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli)
error in query execution to be printed. error in query execution to be printed.
*/ */
rli->abort_slave= 1; rli->abort_slave= 1;
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
delete ev; delete ev;
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -2383,7 +2421,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli)
{ {
DBUG_ASSERT(thd->transaction.all.modified_non_trans_table); DBUG_ASSERT(thd->transaction.all.modified_non_trans_table);
rli->abort_slave= 1; rli->abort_slave= 1;
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
delete ev; delete ev;
rli->inc_event_relay_log_pos(); rli->inc_event_relay_log_pos();
DBUG_RETURN(0); DBUG_RETURN(0);
@ -2447,10 +2485,10 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli)
/* chance for concurrent connection to get more locks */ /* chance for concurrent connection to get more locks */
safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE), safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
(CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli); (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS mysql_mutex_lock(&rli->data_lock); // because of SHOW STATUS
rli->trans_retries++; rli->trans_retries++;
rli->retried_trans++; rli->retried_trans++;
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
DBUG_PRINT("info", ("Slave retries transaction " DBUG_PRINT("info", ("Slave retries transaction "
"rli->trans_retries: %lu", rli->trans_retries)); "rli->trans_retries: %lu", rli->trans_retries));
} }
@ -2478,7 +2516,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli)
} }
DBUG_RETURN(exec_res); DBUG_RETURN(exec_res);
} }
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
rli->report(ERROR_LEVEL, ER_SLAVE_RELAY_LOG_READ_FAILURE, rli->report(ERROR_LEVEL, ER_SLAVE_RELAY_LOG_READ_FAILURE,
ER(ER_SLAVE_RELAY_LOG_READ_FAILURE), "\ ER(ER_SLAVE_RELAY_LOG_READ_FAILURE), "\
Could not parse relay log event entry. The possible reasons are: the master's \ Could not parse relay log event entry. The possible reasons are: the master's \
@ -2609,7 +2647,7 @@ pthread_handler_t handle_slave_io(void *arg)
mysql= NULL ; mysql= NULL ;
retry_count= 0; retry_count= 0;
pthread_mutex_lock(&mi->run_lock); mysql_mutex_lock(&mi->run_lock);
/* Inform waiting threads that slave has started */ /* Inform waiting threads that slave has started */
mi->slave_run_id++; mi->slave_run_id++;
@ -2626,8 +2664,8 @@ pthread_handler_t handle_slave_io(void *arg)
mi->clear_error(); mi->clear_error();
if (init_slave_thread(thd, SLAVE_THD_IO)) if (init_slave_thread(thd, SLAVE_THD_IO))
{ {
pthread_cond_broadcast(&mi->start_cond); mysql_cond_broadcast(&mi->start_cond);
pthread_mutex_unlock(&mi->run_lock); mysql_mutex_unlock(&mi->run_lock);
sql_print_error("Failed during slave I/O thread initialization"); sql_print_error("Failed during slave I/O thread initialization");
goto err; goto err;
} }
@ -2636,8 +2674,8 @@ pthread_handler_t handle_slave_io(void *arg)
pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_thread_count);
mi->slave_running = 1; mi->slave_running = 1;
mi->abort_slave = 0; mi->abort_slave = 0;
pthread_mutex_unlock(&mi->run_lock); mysql_mutex_unlock(&mi->run_lock);
pthread_cond_broadcast(&mi->start_cond); mysql_cond_broadcast(&mi->start_cond);
DBUG_PRINT("master_info",("log_file_name: '%s' position: %s", DBUG_PRINT("master_info",("log_file_name: '%s' position: %s",
mi->master_log_name, mi->master_log_name,
@ -2920,7 +2958,7 @@ err:
} }
write_ignored_events_info_to_relay_log(thd, mi); write_ignored_events_info_to_relay_log(thd, mi);
thd_proc_info(thd, "Waiting for slave mutex on exit"); thd_proc_info(thd, "Waiting for slave mutex on exit");
pthread_mutex_lock(&mi->run_lock); mysql_mutex_lock(&mi->run_lock);
/* Forget the relay log's format */ /* Forget the relay log's format */
delete mi->rli.relay_log.description_event_for_queue; delete mi->rli.relay_log.description_event_for_queue;
@ -2942,9 +2980,9 @@ err:
is important. Otherwise a killer_thread can execute between the calls and is important. Otherwise a killer_thread can execute between the calls and
delete the mi structure leading to a crash! (see BUG#25306 for details) delete the mi structure leading to a crash! (see BUG#25306 for details)
*/ */
pthread_cond_broadcast(&mi->stop_cond); // tell the world we are done mysql_cond_broadcast(&mi->stop_cond); // tell the world we are done
DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5);); DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
pthread_mutex_unlock(&mi->run_lock); mysql_mutex_unlock(&mi->run_lock);
DBUG_LEAVE; // Must match DBUG_ENTER() DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end(); my_thread_end();
@ -2981,7 +3019,8 @@ int check_temp_dir(char* tmp_file)
/* /*
Check permissions to create a file. Check permissions to create a file.
*/ */
if ((fd= my_create(tmp_file, CREATE_MODE, if ((fd= mysql_file_create(key_file_misc,
tmp_file, CREATE_MODE,
O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
DBUG_RETURN(1); DBUG_RETURN(1);
@ -2989,8 +3028,8 @@ int check_temp_dir(char* tmp_file)
/* /*
Clean up. Clean up.
*/ */
my_close(fd, MYF(0)); mysql_file_close(fd, MYF(0));
my_delete(tmp_file, MYF(0)); mysql_file_delete(key_file_misc, tmp_file, MYF(0));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -3016,7 +3055,7 @@ pthread_handler_t handle_slave_sql(void *arg)
DBUG_ENTER("handle_slave_sql"); DBUG_ENTER("handle_slave_sql");
DBUG_ASSERT(rli->inited); DBUG_ASSERT(rli->inited);
pthread_mutex_lock(&rli->run_lock); mysql_mutex_lock(&rli->run_lock);
DBUG_ASSERT(!rli->slave_running); DBUG_ASSERT(!rli->slave_running);
errmsg= 0; errmsg= 0;
#ifndef DBUG_OFF #ifndef DBUG_OFF
@ -3038,8 +3077,8 @@ pthread_handler_t handle_slave_sql(void *arg)
TODO: this is currently broken - slave start and change master TODO: this is currently broken - slave start and change master
will be stuck if we fail here will be stuck if we fail here
*/ */
pthread_cond_broadcast(&rli->start_cond); mysql_cond_broadcast(&rli->start_cond);
pthread_mutex_unlock(&rli->run_lock); mysql_mutex_unlock(&rli->run_lock);
rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
"Failed during slave thread initialization"); "Failed during slave thread initialization");
goto err; goto err;
@ -3059,8 +3098,8 @@ pthread_handler_t handle_slave_sql(void *arg)
Seconds_Behind_Master grows. No big deal. Seconds_Behind_Master grows. No big deal.
*/ */
rli->abort_slave = 0; rli->abort_slave = 0;
pthread_mutex_unlock(&rli->run_lock); mysql_mutex_unlock(&rli->run_lock);
pthread_cond_broadcast(&rli->start_cond); mysql_cond_broadcast(&rli->start_cond);
/* /*
Reset errors for a clean start (otherwise, if the master is idle, the SQL Reset errors for a clean start (otherwise, if the master is idle, the SQL
@ -3075,9 +3114,9 @@ pthread_handler_t handle_slave_sql(void *arg)
rli->clear_error(); rli->clear_error();
//tell the I/O thread to take relay_log_space_limit into account from now on //tell the I/O thread to take relay_log_space_limit into account from now on
pthread_mutex_lock(&rli->log_space_lock); mysql_mutex_lock(&rli->log_space_lock);
rli->ignore_log_space_limit= 0; rli->ignore_log_space_limit= 0;
pthread_mutex_unlock(&rli->log_space_lock); mysql_mutex_unlock(&rli->log_space_lock);
rli->trans_retries= 0; // start from "no error" rli->trans_retries= 0; // start from "no error"
DBUG_PRINT("info", ("rli->trans_retries: %lu", rli->trans_retries)); DBUG_PRINT("info", ("rli->trans_retries: %lu", rli->trans_retries));
@ -3151,17 +3190,17 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME,
First check until condition - probably there is nothing to execute. We First check until condition - probably there is nothing to execute. We
do not want to wait for next event in this case. do not want to wait for next event in this case.
*/ */
pthread_mutex_lock(&rli->data_lock); mysql_mutex_lock(&rli->data_lock);
if (rli->until_condition != Relay_log_info::UNTIL_NONE && if (rli->until_condition != Relay_log_info::UNTIL_NONE &&
rli->is_until_satisfied(thd, NULL)) rli->is_until_satisfied(thd, NULL))
{ {
char buf[22]; char buf[22];
sql_print_information("Slave SQL thread stopped because it reached its" sql_print_information("Slave SQL thread stopped because it reached its"
" UNTIL position %s", llstr(rli->until_pos(), buf)); " UNTIL position %s", llstr(rli->until_pos(), buf));
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
goto err; goto err;
} }
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
/* Read queries from the IO/THREAD until this thread is killed */ /* Read queries from the IO/THREAD until this thread is killed */
@ -3264,9 +3303,9 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
thd->set_query(NULL, 0); thd->set_query(NULL, 0);
thd->reset_db(NULL, 0); thd->reset_db(NULL, 0);
thd_proc_info(thd, "Waiting for slave mutex on exit"); thd_proc_info(thd, "Waiting for slave mutex on exit");
pthread_mutex_lock(&rli->run_lock); mysql_mutex_lock(&rli->run_lock);
/* We need data_lock, at least to wake up any waiting master_pos_wait() */ /* We need data_lock, at least to wake up any waiting master_pos_wait() */
pthread_mutex_lock(&rli->data_lock); mysql_mutex_lock(&rli->data_lock);
DBUG_ASSERT(rli->slave_running == 1); // tracking buffer overrun DBUG_ASSERT(rli->slave_running == 1); // tracking buffer overrun
/* When master_pos_wait() wakes up it will check this and terminate */ /* When master_pos_wait() wakes up it will check this and terminate */
rli->slave_running= 0; rli->slave_running= 0;
@ -3274,9 +3313,9 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
delete rli->relay_log.description_event_for_exec; delete rli->relay_log.description_event_for_exec;
rli->relay_log.description_event_for_exec= 0; rli->relay_log.description_event_for_exec= 0;
/* Wake up master_pos_wait() */ /* Wake up master_pos_wait() */
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
DBUG_PRINT("info",("Signaling possibly waiting master_pos_wait() functions")); DBUG_PRINT("info",("Signaling possibly waiting master_pos_wait() functions"));
pthread_cond_broadcast(&rli->data_cond); mysql_cond_broadcast(&rli->data_cond);
rli->ignore_log_space_limit= 0; /* don't need any lock */ rli->ignore_log_space_limit= 0; /* don't need any lock */
/* we die so won't remember charset - re-update them on next thread start */ /* we die so won't remember charset - re-update them on next thread start */
rli->cached_charset_invalidate(); rli->cached_charset_invalidate();
@ -3302,9 +3341,9 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
is important. Otherwise a killer_thread can execute between the calls and is important. Otherwise a killer_thread can execute between the calls and
delete the mi structure leading to a crash! (see BUG#25306 for details) delete the mi structure leading to a crash! (see BUG#25306 for details)
*/ */
pthread_cond_broadcast(&rli->stop_cond); mysql_cond_broadcast(&rli->stop_cond);
DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5);); DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
pthread_mutex_unlock(&rli->run_lock); // tell the world we are done mysql_mutex_unlock(&rli->run_lock); // tell the world we are done
DBUG_LEAVE; // Must match DBUG_ENTER() DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end(); my_thread_end();
@ -3447,7 +3486,7 @@ err:
static int process_io_rotate(Master_info *mi, Rotate_log_event *rev) static int process_io_rotate(Master_info *mi, Rotate_log_event *rev)
{ {
DBUG_ENTER("process_io_rotate"); DBUG_ENTER("process_io_rotate");
safe_mutex_assert_owner(&mi->data_lock); mysql_mutex_assert_owner(&mi->data_lock);
if (unlikely(!rev->is_valid())) if (unlikely(!rev->is_valid()))
DBUG_RETURN(1); DBUG_RETURN(1);
@ -3543,7 +3582,7 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
DBUG_RETURN(1); DBUG_RETURN(1);
} }
pthread_mutex_lock(&mi->data_lock); mysql_mutex_lock(&mi->data_lock);
ev->log_pos= mi->master_log_pos; /* 3.23 events don't contain log_pos */ ev->log_pos= mi->master_log_pos; /* 3.23 events don't contain log_pos */
switch (ev->get_type_code()) { switch (ev->get_type_code()) {
case STOP_EVENT: case STOP_EVENT:
@ -3554,7 +3593,7 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
if (unlikely(process_io_rotate(mi,(Rotate_log_event*)ev))) if (unlikely(process_io_rotate(mi,(Rotate_log_event*)ev)))
{ {
delete ev; delete ev;
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
inc_pos= 0; inc_pos= 0;
@ -3575,7 +3614,7 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
delete ev; delete ev;
mi->master_log_pos += inc_pos; mi->master_log_pos += inc_pos;
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos)); DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
my_free((char*)tmp_buf, MYF(0)); my_free((char*)tmp_buf, MYF(0));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
@ -3594,7 +3633,7 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
if (unlikely(rli->relay_log.append(ev))) if (unlikely(rli->relay_log.append(ev)))
{ {
delete ev; delete ev;
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
rli->relay_log.harvest_bytes_written(&rli->log_space_total); rli->relay_log.harvest_bytes_written(&rli->log_space_total);
@ -3602,7 +3641,7 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
delete ev; delete ev;
mi->master_log_pos+= inc_pos; mi->master_log_pos+= inc_pos;
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos)); DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -3630,7 +3669,7 @@ static int queue_binlog_ver_3_event(Master_info *mi, const char *buf,
my_free((char*) tmp_buf, MYF(MY_ALLOW_ZERO_PTR)); my_free((char*) tmp_buf, MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
pthread_mutex_lock(&mi->data_lock); mysql_mutex_lock(&mi->data_lock);
switch (ev->get_type_code()) { switch (ev->get_type_code()) {
case STOP_EVENT: case STOP_EVENT:
goto err; goto err;
@ -3638,7 +3677,7 @@ static int queue_binlog_ver_3_event(Master_info *mi, const char *buf,
if (unlikely(process_io_rotate(mi,(Rotate_log_event*)ev))) if (unlikely(process_io_rotate(mi,(Rotate_log_event*)ev)))
{ {
delete ev; delete ev;
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
inc_pos= 0; inc_pos= 0;
@ -3650,7 +3689,7 @@ static int queue_binlog_ver_3_event(Master_info *mi, const char *buf,
if (unlikely(rli->relay_log.append(ev))) if (unlikely(rli->relay_log.append(ev)))
{ {
delete ev; delete ev;
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
rli->relay_log.harvest_bytes_written(&rli->log_space_total); rli->relay_log.harvest_bytes_written(&rli->log_space_total);
@ -3658,7 +3697,7 @@ static int queue_binlog_ver_3_event(Master_info *mi, const char *buf,
mi->master_log_pos+= inc_pos; mi->master_log_pos+= inc_pos;
err: err:
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos)); DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -3708,7 +3747,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
String error_msg; String error_msg;
ulong inc_pos; ulong inc_pos;
Relay_log_info *rli= &mi->rli; Relay_log_info *rli= &mi->rli;
pthread_mutex_t *log_lock= rli->relay_log.get_log_lock(); mysql_mutex_t *log_lock= rli->relay_log.get_log_lock();
ulong s_id; ulong s_id;
DBUG_ENTER("queue_event"); DBUG_ENTER("queue_event");
@ -3719,7 +3758,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
DBUG_RETURN(queue_old_event(mi,buf,event_len)); DBUG_RETURN(queue_old_event(mi,buf,event_len));
LINT_INIT(inc_pos); LINT_INIT(inc_pos);
pthread_mutex_lock(&mi->data_lock); mysql_mutex_lock(&mi->data_lock);
switch (buf[EVENT_TYPE_OFFSET]) { switch (buf[EVENT_TYPE_OFFSET]) {
case STOP_EVENT: case STOP_EVENT:
@ -3855,7 +3894,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
direct master (an unsupported, useless setup!). direct master (an unsupported, useless setup!).
*/ */
pthread_mutex_lock(log_lock); mysql_mutex_lock(log_lock);
s_id= uint4korr(buf + SERVER_ID_OFFSET); s_id= uint4korr(buf + SERVER_ID_OFFSET);
if ((s_id == ::server_id && !mi->rli.replicate_same_server_id) || if ((s_id == ::server_id && !mi->rli.replicate_same_server_id) ||
/* /*
@ -3917,12 +3956,12 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
} }
rli->ign_master_log_name_end[0]= 0; // last event is not ignored rli->ign_master_log_name_end[0]= 0; // last event is not ignored
} }
pthread_mutex_unlock(log_lock); mysql_mutex_unlock(log_lock);
skip_relay_logging: skip_relay_logging:
err: err:
pthread_mutex_unlock(&mi->data_lock); mysql_mutex_unlock(&mi->data_lock);
DBUG_PRINT("info", ("error: %d", error)); DBUG_PRINT("info", ("error: %d", error));
if (error) if (error)
mi->report(ERROR_LEVEL, error, ER(error), mi->report(ERROR_LEVEL, error, ER(error),
@ -3942,13 +3981,13 @@ void end_relay_log_info(Relay_log_info* rli)
if (rli->info_fd >= 0) if (rli->info_fd >= 0)
{ {
end_io_cache(&rli->info_file); end_io_cache(&rli->info_file);
(void) my_close(rli->info_fd, MYF(MY_WME)); mysql_file_close(rli->info_fd, MYF(MY_WME));
rli->info_fd = -1; rli->info_fd = -1;
} }
if (rli->cur_log_fd >= 0) if (rli->cur_log_fd >= 0)
{ {
end_io_cache(&rli->cache_buf); end_io_cache(&rli->cache_buf);
(void)my_close(rli->cur_log_fd, MYF(MY_WME)); mysql_file_close(rli->cur_log_fd, MYF(MY_WME));
rli->cur_log_fd = -1; rli->cur_log_fd = -1;
} }
rli->inited = 0; rli->inited = 0;
@ -4304,7 +4343,7 @@ static Log_event* next_event(Relay_log_info* rli)
{ {
Log_event* ev; Log_event* ev;
IO_CACHE* cur_log = rli->cur_log; IO_CACHE* cur_log = rli->cur_log;
pthread_mutex_t *log_lock = rli->relay_log.get_log_lock(); mysql_mutex_t *log_lock = rli->relay_log.get_log_lock();
const char* errmsg=0; const char* errmsg=0;
THD* thd = rli->sql_thd; THD* thd = rli->sql_thd;
DBUG_ENTER("next_event"); DBUG_ENTER("next_event");
@ -4321,9 +4360,9 @@ static Log_event* next_event(Relay_log_info* rli)
so we assume calling function acquired this mutex for us and we will so we assume calling function acquired this mutex for us and we will
hold it for the most of the loop below However, we will release it hold it for the most of the loop below However, we will release it
whenever it is worth the hassle, and in the cases when we go into a whenever it is worth the hassle, and in the cases when we go into a
pthread_cond_wait() with the non-data_lock mutex mysql_cond_wait() with the non-data_lock mutex
*/ */
safe_mutex_assert_owner(&rli->data_lock); mysql_mutex_assert_owner(&rli->data_lock);
while (!sql_slave_killed(thd,rli)) while (!sql_slave_killed(thd,rli))
{ {
@ -4342,7 +4381,7 @@ static Log_event* next_event(Relay_log_info* rli)
if ((hot_log = (cur_log != &rli->cache_buf))) if ((hot_log = (cur_log != &rli->cache_buf)))
{ {
DBUG_ASSERT(rli->cur_log_fd == -1); // foreign descriptor DBUG_ASSERT(rli->cur_log_fd == -1); // foreign descriptor
pthread_mutex_lock(log_lock); mysql_mutex_lock(log_lock);
/* /*
Reading xxx_file_id is safe because the log will only Reading xxx_file_id is safe because the log will only
@ -4352,7 +4391,7 @@ static Log_event* next_event(Relay_log_info* rli)
{ {
// The master has switched to a new log file; Reopen the old log file // The master has switched to a new log file; Reopen the old log file
cur_log=reopen_relay_log(rli, &errmsg); cur_log=reopen_relay_log(rli, &errmsg);
pthread_mutex_unlock(log_lock); mysql_mutex_unlock(log_lock);
if (!cur_log) // No more log files if (!cur_log) // No more log files
goto err; goto err;
hot_log=0; // Using old binary log hot_log=0; // Using old binary log
@ -4399,7 +4438,7 @@ static Log_event* next_event(Relay_log_info* rli)
*/ */
rli->future_event_relay_log_pos= my_b_tell(cur_log); rli->future_event_relay_log_pos= my_b_tell(cur_log);
if (hot_log) if (hot_log)
pthread_mutex_unlock(log_lock); mysql_mutex_unlock(log_lock);
DBUG_RETURN(ev); DBUG_RETURN(ev);
} }
DBUG_ASSERT(thd==rli->sql_thd); DBUG_ASSERT(thd==rli->sql_thd);
@ -4409,7 +4448,7 @@ static Log_event* next_event(Relay_log_info* rli)
{ {
errmsg = "slave SQL thread aborted because of I/O error"; errmsg = "slave SQL thread aborted because of I/O error";
if (hot_log) if (hot_log)
pthread_mutex_unlock(log_lock); mysql_mutex_unlock(log_lock);
goto err; goto err;
} }
if (!cur_log->error) /* EOF */ if (!cur_log->error) /* EOF */
@ -4456,7 +4495,7 @@ static Log_event* next_event(Relay_log_info* rli)
0, rli->ign_master_log_pos_end, 0, rli->ign_master_log_pos_end,
Rotate_log_event::DUP_NAME); Rotate_log_event::DUP_NAME);
rli->ign_master_log_name_end[0]= 0; rli->ign_master_log_name_end[0]= 0;
pthread_mutex_unlock(log_lock); mysql_mutex_unlock(log_lock);
if (unlikely(!ev)) if (unlikely(!ev))
{ {
errmsg= "Slave SQL thread failed to create a Rotate event " errmsg= "Slave SQL thread failed to create a Rotate event "
@ -4471,7 +4510,7 @@ static Log_event* next_event(Relay_log_info* rli)
We can, and should release data_lock while we are waiting for We can, and should release data_lock while we are waiting for
update. If we do not, show slave status will block update. If we do not, show slave status will block
*/ */
pthread_mutex_unlock(&rli->data_lock); mysql_mutex_unlock(&rli->data_lock);
/* /*
Possible deadlock : Possible deadlock :
@ -4497,7 +4536,7 @@ static Log_event* next_event(Relay_log_info* rli)
be stopped, and the SQL thread sets ignore_log_space_limit to 0 when be stopped, and the SQL thread sets ignore_log_space_limit to 0 when
it stops. it stops.
*/ */
pthread_mutex_lock(&rli->log_space_lock); mysql_mutex_lock(&rli->log_space_lock);
// prevent the I/O thread from blocking next times // prevent the I/O thread from blocking next times
rli->ignore_log_space_limit= 1; rli->ignore_log_space_limit= 1;
/* /*
@ -4506,12 +4545,12 @@ static Log_event* next_event(Relay_log_info* rli)
~Relay_log_info(), i.e. when rli is destroyed, and rli will ~Relay_log_info(), i.e. when rli is destroyed, and rli will
not be destroyed before we exit the present function. not be destroyed before we exit the present function.
*/ */
pthread_mutex_unlock(&rli->log_space_lock); mysql_mutex_unlock(&rli->log_space_lock);
pthread_cond_broadcast(&rli->log_space_cond); mysql_cond_broadcast(&rli->log_space_cond);
// Note that wait_for_update_relay_log unlocks lock_log ! // Note that wait_for_update_relay_log unlocks lock_log !
rli->relay_log.wait_for_update_relay_log(rli->sql_thd); rli->relay_log.wait_for_update_relay_log(rli->sql_thd);
// re-acquire data lock since we released it earlier // re-acquire data lock since we released it earlier
pthread_mutex_lock(&rli->data_lock); mysql_mutex_lock(&rli->data_lock);
rli->last_master_timestamp= save_timestamp; rli->last_master_timestamp= save_timestamp;
continue; continue;
} }
@ -4522,7 +4561,7 @@ static Log_event* next_event(Relay_log_info* rli)
*/ */
end_io_cache(cur_log); end_io_cache(cur_log);
DBUG_ASSERT(rli->cur_log_fd >= 0); DBUG_ASSERT(rli->cur_log_fd >= 0);
my_close(rli->cur_log_fd, MYF(MY_WME)); mysql_file_close(rli->cur_log_fd, MYF(MY_WME));
rli->cur_log_fd = -1; rli->cur_log_fd = -1;
if (relay_log_purge) if (relay_log_purge)
@ -4579,7 +4618,7 @@ static Log_event* next_event(Relay_log_info* rli)
DBUG_PRINT("info",("hot_log: %d",hot_log)); DBUG_PRINT("info",("hot_log: %d",hot_log));
if (!hot_log) /* if hot_log, we already have this mutex */ if (!hot_log) /* if hot_log, we already have this mutex */
pthread_mutex_lock(log_lock); mysql_mutex_lock(log_lock);
if (rli->relay_log.is_active(rli->linfo.log_file_name)) if (rli->relay_log.is_active(rli->linfo.log_file_name))
{ {
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
@ -4600,13 +4639,16 @@ static Log_event* next_event(Relay_log_info* rli)
*/ */
if (check_binlog_magic(cur_log,&errmsg)) if (check_binlog_magic(cur_log,&errmsg))
{ {
if (!hot_log) pthread_mutex_unlock(log_lock); if (!hot_log)
mysql_mutex_unlock(log_lock);
goto err; goto err;
} }
if (!hot_log) pthread_mutex_unlock(log_lock); if (!hot_log)
mysql_mutex_unlock(log_lock);
continue; continue;
} }
if (!hot_log) pthread_mutex_unlock(log_lock); if (!hot_log)
mysql_mutex_unlock(log_lock);
/* /*
if we get here, the log was not hot, so we will have to open it if we get here, the log was not hot, so we will have to open it
ourselves. We are sure that the log is still not hot now (a log can get ourselves. We are sure that the log is still not hot now (a log can get
@ -4629,7 +4671,7 @@ static Log_event* next_event(Relay_log_info* rli)
TODO: come up with something better to handle this error TODO: come up with something better to handle this error
*/ */
if (hot_log) if (hot_log)
pthread_mutex_unlock(log_lock); mysql_mutex_unlock(log_lock);
sql_print_error("Slave SQL thread: I/O error reading \ sql_print_error("Slave SQL thread: I/O error reading \
event(errno: %d cur_log->error: %d)", event(errno: %d cur_log->error: %d)",
my_errno,cur_log->error); my_errno,cur_log->error);

Some files were not shown because too many files have changed in this diff Show More