Commit 008363e8 authored by unknown's avatar unknown

MDEV-26: Global transaction ID.

Add a missing check for correct table definition.
parent 5e414f6b
......@@ -50,7 +50,8 @@ rpl_slave_state::update_state_hash(uint64 sub_id, rpl_gtid *gtid)
{
sql_print_warning("Slave: Out of memory during slave state maintenance. "
"Some no longer necessary rows in table "
"mysql.rpl_slave_state may be left undeleted.");
"mysql.%s may be left undeleted.",
rpl_gtid_slave_state_table_name.str);
/*
Such failure is not fatal. We will fail to delete the row for this
GTID, but it will do no harm and will be removed automatically on next
......@@ -253,6 +254,21 @@ protected:
static Gtid_db_intact gtid_table_intact;
/*
Check that the mysql.rpl_slave_state table has the correct definition.
*/
int
gtid_check_rpl_slave_state_table(TABLE *table)
{
int err;
if ((err= gtid_table_intact.check(table, &mysql_rpl_slave_state_tabledef)))
my_error(ER_GTID_OPEN_TABLE_FAILED, MYF(0), "mysql",
rpl_gtid_slave_state_table_name.str);
return err;
}
/*
Write a gtid to the replication slave state table.
......@@ -290,22 +306,14 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id,
table_opened= true;
table= tlist.table;
if ((err= gtid_table_intact.check(table, &mysql_rpl_slave_state_tabledef)))
{
my_error(ER_GTID_OPEN_TABLE_FAILED, MYF(0), "mysql",
rpl_gtid_slave_state_table_name.str);
if ((err= gtid_check_rpl_slave_state_table(table)))
goto end;
}
table->no_replicate= 1;
if (!in_transaction)
thd->variables.option_bits&=
~(ulonglong)(OPTION_NOT_AUTOCOMMIT|OPTION_BEGIN);
/*
ToDo: Check the table definition, error if not as expected.
We need the correct first 4 columns with correct type, and the primary key.
*/
bitmap_set_all(table->write_set);
table->field[0]->store((ulonglong)gtid->domain_id, true);
......
......@@ -19,6 +19,8 @@
/* Definitions for MariaDB global transaction ID (GTID). */
extern const LEX_STRING rpl_gtid_slave_state_table_name;
class String;
struct rpl_gtid
......@@ -165,6 +167,6 @@ struct slave_connection_state
extern bool rpl_slave_state_tostring_helper(String *dest, const rpl_gtid *gtid,
bool *first);
extern const LEX_STRING rpl_gtid_slave_state_table_name;
extern int gtid_check_rpl_slave_state_table(TABLE *table);
#endif /* RPL_GTID_H */
......@@ -3076,17 +3076,11 @@ rpl_load_gtid_slave_state(THD *thd)
goto end;
table_opened= true;
table= tlist.table;
table->no_replicate= 1;
/*
ToDo: Check the table definition, error if not as expected.
We need the correct first 4 columns with correct type, and the primary key.
*/
if ((err= gtid_check_rpl_slave_state_table(table)))
goto end;
bitmap_set_bit(table->read_set, table->field[0]->field_index);
bitmap_set_bit(table->read_set, table->field[1]->field_index);
bitmap_set_bit(table->read_set, table->field[2]->field_index);
bitmap_set_bit(table->read_set, table->field[3]->field_index);
bitmap_set_all(table->read_set);
if ((err= table->file->ha_rnd_init_with_error(1)))
goto end;
table_scanned= true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment