summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorKristian Nielsen <knielsen@knielsen-hq.org>2017-05-10 09:56:31 +0200
committerKristian Nielsen <knielsen@knielsen-hq.org>2017-05-10 09:56:31 +0200
commit0db2cd7c7600c8cd03a1005d299cd0112d80b4ad (patch)
treef22bf1b838726f1a4befd4e3c0e2706dba9cc94d /sql
parent8683052389e8f59caeb4218dc300d98627be1750 (diff)
downloadmariadb-git-0db2cd7c7600c8cd03a1005d299cd0112d80b4ad.tar.gz
MDEV-12179: Per-engine mysql.gtid_slave_pos table
Intermediate commit. Fix compilation failure with different my_atomic implementation. The my_atomic_loadptr* takes void ** as first argument, so variables updated with it needs to be void * (it is not legal C to cast some_type ** to void **).
Diffstat (limited to 'sql')
-rw-r--r--sql/rpl_gtid.cc13
-rw-r--r--sql/rpl_gtid.h7
-rw-r--r--sql/rpl_rli.cc6
-rw-r--r--sql/slave.cc6
4 files changed, 20 insertions, 12 deletions
diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc
index a4a774a0200..b1b65119d0b 100644
--- a/sql/rpl_gtid.cc
+++ b/sql/rpl_gtid.cc
@@ -258,7 +258,7 @@ rpl_slave_state::rpl_slave_state()
rpl_slave_state::~rpl_slave_state()
{
- free_gtid_pos_tables(gtid_pos_tables);
+ free_gtid_pos_tables((struct gtid_pos_table *)gtid_pos_tables);
truncate_hash();
my_hash_free(&hash);
delete_dynamic(&gtid_sort_array);
@@ -484,7 +484,8 @@ rpl_slave_state::select_gtid_pos_table(THD *thd, LEX_STRING *out_tablename)
See comments on rpl_slave_state::gtid_pos_tables for rules around proper
access to the list.
*/
- list= my_atomic_loadptr_explicit(&gtid_pos_tables, MY_MEMORY_ORDER_ACQUIRE);
+ list= (struct gtid_pos_table *)
+ my_atomic_loadptr_explicit(&gtid_pos_tables, MY_MEMORY_ORDER_ACQUIRE);
Ha_trx_info *ha_info;
uint count = 0;
@@ -545,8 +546,8 @@ rpl_slave_state::select_gtid_pos_table(THD *thd, LEX_STRING *out_tablename)
already active in the transaction, or if there is no current transaction
engines available, we return the default gtid_slave_pos table.
*/
- default_entry= my_atomic_loadptr_explicit(&default_gtid_pos_table,
- MY_MEMORY_ORDER_ACQUIRE);
+ default_entry= (struct gtid_pos_table *)
+ my_atomic_loadptr_explicit(&default_gtid_pos_table, MY_MEMORY_ORDER_ACQUIRE);
*out_tablename= default_entry->table_name;
/* Record in status that we failed to find a suitable gtid_pos table. */
if (count > 0)
@@ -1268,7 +1269,7 @@ rpl_slave_state::set_gtid_pos_tables_list(rpl_slave_state::gtid_pos_table *new_l
gtid_pos_table *old_list;
mysql_mutex_assert_owner(&LOCK_slave_state);
- old_list= gtid_pos_tables;
+ old_list= (struct gtid_pos_table *)gtid_pos_tables;
my_atomic_storeptr_explicit(&gtid_pos_tables, new_list, MY_MEMORY_ORDER_RELEASE);
my_atomic_storeptr_explicit(&default_gtid_pos_table, default_entry,
MY_MEMORY_ORDER_RELEASE);
@@ -1280,7 +1281,7 @@ void
rpl_slave_state::add_gtid_pos_table(rpl_slave_state::gtid_pos_table *entry)
{
mysql_mutex_assert_owner(&LOCK_slave_state);
- entry->next= gtid_pos_tables;
+ entry->next= (struct gtid_pos_table *)gtid_pos_tables;
my_atomic_storeptr_explicit(&gtid_pos_tables, entry, MY_MEMORY_ORDER_RELEASE);
}
diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h
index 4ff1ca563b8..452f3676704 100644
--- a/sql/rpl_gtid.h
+++ b/sql/rpl_gtid.h
@@ -206,10 +206,13 @@ struct rpl_slave_state
The list can be read without lock by an SQL driver thread or worker thread
by reading the gtid_pos_tables pointer atomically with acquire semantics,
to ensure that it will see the correct next pointer of a new head element.
+
+ The type is struct gtid_pos_table *, but needs to be void * to allow using
+ my_atomic operations without violating C strict aliasing semantics.
*/
- struct gtid_pos_table *gtid_pos_tables;
+ void * volatile gtid_pos_tables;
/* The default entry in gtid_pos_tables, mysql.gtid_slave_pos. */
- struct gtid_pos_table *default_gtid_pos_table;
+ void * volatile default_gtid_pos_table;
bool loaded;
rpl_slave_state();
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 59138a23daf..63179f5d8e9 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -1973,7 +1973,8 @@ find_gtid_slave_pos_tables(THD *thd)
*/
rpl_slave_state::gtid_pos_table *old_entry, *new_entry, **next_ptr_ptr;
- old_entry= rpl_global_gtid_slave_state->gtid_pos_tables;
+ old_entry= (rpl_slave_state::gtid_pos_table *)
+ rpl_global_gtid_slave_state->gtid_pos_tables;
while (old_entry)
{
new_entry= cb_data.table_list;
@@ -1995,7 +1996,8 @@ find_gtid_slave_pos_tables(THD *thd)
while (new_entry)
{
/* Check if we already have a table with this storage engine. */
- old_entry= rpl_global_gtid_slave_state->gtid_pos_tables;
+ old_entry= (rpl_slave_state::gtid_pos_table *)
+ rpl_global_gtid_slave_state->gtid_pos_tables;
while (old_entry)
{
if (new_entry->table_hton == old_entry->table_hton)
diff --git a/sql/slave.cc b/sql/slave.cc
index a892bba82c9..ffce356c2ec 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -383,7 +383,8 @@ handle_gtid_pos_auto_create_request(THD *thd, void *hton)
/* Find the entry for the table to auto-create. */
mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state);
- entry= rpl_global_gtid_slave_state->gtid_pos_tables;
+ entry= (rpl_slave_state::gtid_pos_table *)
+ rpl_global_gtid_slave_state->gtid_pos_tables;
while (entry)
{
if (entry->table_hton == hton &&
@@ -419,7 +420,8 @@ handle_gtid_pos_auto_create_request(THD *thd, void *hton)
/* Now enable the entry for the auto-created table. */
mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state);
- entry= rpl_global_gtid_slave_state->gtid_pos_tables;
+ entry= (rpl_slave_state::gtid_pos_table *)
+ rpl_global_gtid_slave_state->gtid_pos_tables;
while (entry)
{
if (entry->table_hton == hton &&