#At file:///home/msvensson/mysql/7.0/ based on revid:magnus.blaudd@stripped
3956 Magnus Blåudd 2010-11-08
ndb
- add wrappers to allow using mysql_ functions for cond and mutexes
- use mysql_ functions for all mysqld declared mutexes and conds.
modified:
sql/ha_ndbcluster.cc
sql/ha_ndbcluster_binlog.cc
sql/ha_ndbcluster_glue.h
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2010-11-08 13:59:33 +0000
+++ b/sql/ha_ndbcluster.cc 2010-11-08 14:14:10 +0000
@@ -9560,7 +9560,7 @@ int ndbcluster_drop_database_impl(THD *t
while ((tabname=it++))
{
tablename_to_filename(tabname, tmp, FN_REFLEN - (tmp - full_path)-1);
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
if (ha_ndbcluster::delete_table(thd, 0, ndb, full_path, dbname, tabname))
{
const NdbError err= dict->getNdbError();
@@ -9570,7 +9570,7 @@ int ndbcluster_drop_database_impl(THD *t
ret= ndb_to_mysql_error(&err);
}
}
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
}
dict->invalidateDbGlobal(dbname);
@@ -9731,7 +9731,7 @@ int ndbcluster_find_all_files(THD *thd)
my_free((char*) data, MYF(MY_ALLOW_ZERO_PTR));
my_free((char*) pack_data, MYF(MY_ALLOW_ZERO_PTR));
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
if (discover)
{
/* ToDo 4.1 database needs to be created if missing */
@@ -9747,7 +9747,7 @@ int ndbcluster_find_all_files(THD *thd)
elmt.database, elmt.name,
TRUE);
}
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
}
}
while (unhandled && retries);
@@ -9846,19 +9846,19 @@ int ndbcluster_find_files(handlerton *ht
file_name->str, reg_ext, 0);
if (my_access(name, F_OK))
{
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
DBUG_PRINT("info", ("Table %s listed and need discovery",
file_name->str));
if (ndb_create_table_from_engine(thd, db, file_name->str))
{
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TABLE_EXISTS_ERROR,
"Discover of table %s.%s failed",
db, file_name->str);
continue;
}
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
}
DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name->str));
file_on_disk= TRUE;
@@ -9915,10 +9915,10 @@ int ndbcluster_find_files(handlerton *ht
file_name_str= (char*)my_hash_element(&ok_tables, i);
end= end1 +
tablename_to_filename(file_name_str, end1, sizeof(name) - (end1 - name));
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
ndbcluster_create_binlog_setup(thd, ndb, name, end-name,
db, file_name_str, TRUE);
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
}
}
@@ -9971,7 +9971,7 @@ int ndbcluster_find_files(handlerton *ht
}
}
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
// Create new files
List_iterator_fast<char> it2(create_list);
while ((file_name_str=it2++))
@@ -9986,7 +9986,7 @@ int ndbcluster_find_files(handlerton *ht
}
}
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
my_hash_free(&ok_tables);
my_hash_free(&ndb_tables);
@@ -10900,10 +10900,10 @@ int handle_trailing_share(THD *thd, NDB_
if (have_lock_open)
safe_mutex_assert_owner(&LOCK_open);
else
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
close_cached_tables(thd, &table_list, TRUE, FALSE, FALSE);
if (!have_lock_open)
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
pthread_mutex_lock(&ndbcluster_mutex);
/* ndb_share reference temporary free */
@@ -12301,20 +12301,20 @@ pthread_handler_t ndb_util_thread_func(v
/*
wait for mysql server to start
*/
- pthread_mutex_lock(&LOCK_server_started);
+ mysql_mutex_lock(&LOCK_server_started);
while (!mysqld_server_started)
{
set_timespec(abstime, 1);
- pthread_cond_timedwait(&COND_server_started, &LOCK_server_started,
- &abstime);
+ mysql_cond_timedwait(&COND_server_started, &LOCK_server_started,
+ &abstime);
if (ndbcluster_terminating)
{
- pthread_mutex_unlock(&LOCK_server_started);
+ mysql_mutex_unlock(&LOCK_server_started);
pthread_mutex_lock(&LOCK_ndb_util_thread);
goto ndb_util_thread_end;
}
}
- pthread_mutex_unlock(&LOCK_server_started);
+ mysql_mutex_unlock(&LOCK_server_started);
/*
Wait for cluster to start
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2010-11-08 12:19:51 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2010-11-08 14:14:10 +0000
@@ -1486,9 +1486,9 @@ int ndbcluster_setup_binlog_table_shares
if (!ndb_schema_share &&
ndbcluster_check_ndb_schema_share() == 0)
{
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
ndb_create_table_from_engine(thd, NDB_REP_DB, NDB_SCHEMA_TABLE);
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
if (!ndb_schema_share)
{
ndbcluster_create_schema_table(thd);
@@ -1500,9 +1500,9 @@ int ndbcluster_setup_binlog_table_shares
if (!ndb_apply_status_share &&
ndbcluster_check_ndb_apply_status_share() == 0)
{
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
ndb_create_table_from_engine(thd, NDB_REP_DB, NDB_APPLY_TABLE);
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
if (!ndb_apply_status_share)
{
ndbcluster_create_ndb_apply_status_table(thd);
@@ -1518,7 +1518,7 @@ int ndbcluster_setup_binlog_table_shares
if (!ndbcluster_find_all_files(thd))
{
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
ndb_binlog_tables_inited= TRUE;
if (ndb_binlog_tables_inited &&
ndb_binlog_running && ndb_binlog_is_ready)
@@ -1533,7 +1533,7 @@ int ndbcluster_setup_binlog_table_shares
*/
ndb_notify_tables_writable();
}
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
/* Signal injector thread that all is setup */
pthread_cond_signal(&injector_cond);
}
@@ -2279,7 +2279,7 @@ end:
if (have_lock_open)
{
safe_mutex_assert_owner(&LOCK_open);
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
}
while (1)
{
@@ -2340,7 +2340,7 @@ end:
}
if (have_lock_open)
{
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
}
pthread_mutex_unlock(&ndb_schema_object->mutex);
}
@@ -2713,7 +2713,7 @@ ndb_binlog_thread_handle_schema_event(TH
// fall through
case SOT_CREATE_TABLE:
thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
if (ndbcluster_check_if_local_table(schema->db, schema->name))
{
DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
@@ -2735,7 +2735,7 @@ ndb_binlog_thread_handle_schema_event(TH
while ((err= it++))
sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg);
}
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
log_query= 1;
break;
case SOT_DROP_DB:
@@ -3031,9 +3031,9 @@ ndb_binlog_thread_handle_schema_event_po
log_query= 1;
if (share)
{
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
ndbcluster_rename_share(thd, share);
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
}
break;
case SOT_RENAME_TABLE_PREPARE:
@@ -3094,7 +3094,7 @@ ndb_binlog_thread_handle_schema_event_po
share= 0;
}
thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
if (ndbcluster_check_if_local_table(schema->db, schema->name))
{
DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
@@ -3115,7 +3115,7 @@ ndb_binlog_thread_handle_schema_event_po
while ((err= it++))
sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg);
}
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
}
break;
case SOT_ONLINE_ALTER_TABLE_PREPARE:
@@ -3135,7 +3135,7 @@ ndb_binlog_thread_handle_schema_event_po
Refresh local frm file and dictionary cache if
remote on-line alter table
*/
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
TABLE_LIST table_list;
bzero((char*) &table_list,sizeof(table_list));
table_list.db= (char *)schema->db;
@@ -3178,7 +3178,7 @@ ndb_binlog_thread_handle_schema_event_po
my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
}
if (!share)
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
else
{
if (opt_ndb_extra_logging > 9)
@@ -3190,7 +3190,7 @@ ndb_binlog_thread_handle_schema_event_po
if ((error= ndbcluster_binlog_open_table(thd, share)))
sql_print_error("NDB Binlog: Failed to re-open table %s.%s",
schema->db, schema->name);
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
if (error)
pthread_mutex_unlock(&share->mutex);
}
@@ -3276,7 +3276,7 @@ ndb_binlog_thread_handle_schema_event_po
share= 0;
}
thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
if (ndbcluster_check_if_local_table(schema->db, schema->name))
{
DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
@@ -3297,7 +3297,7 @@ ndb_binlog_thread_handle_schema_event_po
while ((err= it++))
sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg);
}
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
}
break;
default:
@@ -5027,7 +5027,7 @@ ndbcluster_handle_drop_table(THD *thd, N
thd->proc_info= "Syncing ndb table schema operation and binlog";
pthread_mutex_lock(&share->mutex);
safe_mutex_assert_owner(&LOCK_open);
- pthread_mutex_unlock(&LOCK_open);
+ mysql_mutex_unlock(&LOCK_open);
int max_timeout= DEFAULT_SYNC_TIMEOUT;
while (share->op)
{
@@ -5054,7 +5054,7 @@ ndbcluster_handle_drop_table(THD *thd, N
type_str, share->key, 0);
}
}
- pthread_mutex_lock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_open);
pthread_mutex_unlock(&share->mutex);
#else
pthread_mutex_lock(&share->mutex);
@@ -5902,9 +5902,9 @@ pthread_handler_t ndb_binlog_thread_func
/* We need to set thd->thread_id before thd->store_globals, or it will
set an invalid value for thd->variables.pseudo_thread_id.
*/
- pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
thd->thread_id= thread_id++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
thd->thread_stack= (char*) &thd; /* remember where our stack is */
if (thd->store_globals())
@@ -5939,9 +5939,9 @@ pthread_handler_t ndb_binlog_thread_func
pthread_detach_this_thread();
thd->real_id= pthread_self();
- pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
threads.append(thd);
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
thd->lex->start_transaction_opt= 0;
@@ -6008,20 +6008,20 @@ restart_cluster_failure:
wait for mysql server to start (so that the binlog is started
and thus can receive the first GAP event)
*/
- pthread_mutex_lock(&LOCK_server_started);
+ mysql_mutex_lock(&LOCK_server_started);
while (!mysqld_server_started)
{
struct timespec abstime;
set_timespec(abstime, 1);
- pthread_cond_timedwait(&COND_server_started, &LOCK_server_started,
- &abstime);
+ mysql_cond_timedwait(&COND_server_started, &LOCK_server_started,
+ &abstime);
if (ndbcluster_terminating)
{
- pthread_mutex_unlock(&LOCK_server_started);
+ mysql_mutex_unlock(&LOCK_server_started);
goto err;
}
}
- pthread_mutex_unlock(&LOCK_server_started);
+ mysql_mutex_unlock(&LOCK_server_started);
/*
Main NDB Injector loop
*/
@@ -6672,14 +6672,14 @@ restart_cluster_failure:
*/
if (thd->killed)
{
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) mysql_mutex_lock(&LOCK_thread_count);
volatile THD::killed_state killed= thd->killed;
/* We are cleaning up, allow for flushing last epoch */
thd->killed= THD::NOT_KILLED;
ndb_add_ndb_binlog_index(thd, rows);
/* Restore kill flag */
thd->killed= killed;
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) mysql_mutex_unlock(&LOCK_thread_count);
}
}
}
=== modified file 'sql/ha_ndbcluster_glue.h'
--- a/sql/ha_ndbcluster_glue.h 2010-11-08 13:59:33 +0000
+++ b/sql/ha_ndbcluster_glue.h 2010-11-08 14:14:10 +0000
@@ -97,4 +97,43 @@ ulonglong thd_options(const THD * thd)
#endif
}
+#if MYSQL_VERSION_ID < 50500
+
+/*
+ MySQL Server has got its own mutex type in 5.5, add backwards
+ compatibility support allowing to write code in 7.0 that works
+ in future MySQL Server
+*/
+
+typedef pthread_mutex_t mysql_mutex_t;
+
+static inline
+int mysql_mutex_lock(mysql_mutex_t* mutex)
+{
+ return pthread_mutex_lock(mutex);
+}
+
+static inline
+int mysql_mutex_unlock(mysql_mutex_t* mutex)
+{
+ return pthread_mutex_unlock(mutex);
+}
+
+typedef pthread_cond_t mysql_cond_t;
+
+static inline
+int mysql_cond_wait(mysql_cond_t* cond, mysql_mutex_t* mutex)
+{
+ return pthread_cond_wait(cond, mutex);
+}
+
+static inline
+int mysql_cond_timedwait(mysql_cond_t* cond, mysql_mutex_t* mutex,
+ struct timespec* abstime)
+{
+ return pthread_cond_timedwait(cond, mutex, abstime);
+}
+
+#endif
+
#endif
Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20101108141410-xzzdfmhvjgrchihf.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3956) | Magnus Blåudd | 8 Nov |