Commit e452546c authored by Jacob Mathew's avatar Jacob Mathew

Merge branch 'bb-10.2-MDEV-14019' into 10.2

parents 649b7a64 1b82bec3
...@@ -35,6 +35,86 @@ ...@@ -35,6 +35,86 @@
extern handlerton *spider_hton_ptr; extern handlerton *spider_hton_ptr;
/**
Insert a Spider system table row.
@param table The spider system table.
@param do_handle_error TRUE if an error message should be printed
before returning.
@return Error code returned by the write.
*/
inline int spider_write_sys_table_row(TABLE *table, bool do_handle_error = TRUE)
{
int error_num;
THD *thd = table->in_use;
tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */
error_num = table->file->ha_write_row(table->record[0]);
reenable_binlog(thd);
if (error_num && do_handle_error)
table->file->print_error(error_num, MYF(0));
return error_num;
}
/**
Update a Spider system table row.
@param table The spider system table.
@return Error code returned by the update.
*/
inline int spider_update_sys_table_row(TABLE *table)
{
int error_num;
THD *thd = table->in_use;
tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */
error_num = table->file->ha_update_row(table->record[1], table->record[0]);
reenable_binlog(thd);
if (error_num)
{
if (error_num == HA_ERR_RECORD_IS_THE_SAME)
error_num = 0;
else
table->file->print_error(error_num, MYF(0));
}
return error_num;
}
/**
Delete a Spider system table row.
@param table The spider system table.
@param record_number Location of the record: 0 or 1.
@param do_handle_error TRUE if an error message should be printed
before returning.
@return Error code returned by the update.
*/
inline int spider_delete_sys_table_row(TABLE *table, int record_number = 0,
bool do_handle_error = TRUE)
{
int error_num;
THD *thd = table->in_use;
tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */
error_num = table->file->ha_delete_row(table->record[record_number]);
reenable_binlog(thd);
if (error_num && do_handle_error)
table->file->print_error(error_num, MYF(0));
return error_num;
}
#if MYSQL_VERSION_ID < 50500 #if MYSQL_VERSION_ID < 50500
TABLE *spider_open_sys_table( TABLE *spider_open_sys_table(
THD *thd, THD *thd,
...@@ -983,11 +1063,8 @@ int spider_insert_xa( ...@@ -983,11 +1063,8 @@ int spider_insert_xa(
table->use_all_columns(); table->use_all_columns();
spider_store_xa_bqual_length(table, xid); spider_store_xa_bqual_length(table, xid);
spider_store_xa_status(table, status); spider_store_xa_status(table, status);
if ((error_num = table->file->ha_write_row(table->record[0]))) if ((error_num = spider_write_sys_table_row(table)))
{
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
}
} else { } else {
my_message(ER_SPIDER_XA_EXISTS_NUM, ER_SPIDER_XA_EXISTS_STR, MYF(0)); my_message(ER_SPIDER_XA_EXISTS_NUM, ER_SPIDER_XA_EXISTS_STR, MYF(0));
DBUG_RETURN(ER_SPIDER_XA_EXISTS_NUM); DBUG_RETURN(ER_SPIDER_XA_EXISTS_NUM);
...@@ -1017,11 +1094,8 @@ int spider_insert_xa_member( ...@@ -1017,11 +1094,8 @@ int spider_insert_xa_member(
} }
table->use_all_columns(); table->use_all_columns();
spider_store_xa_member_info(table, xid, conn); spider_store_xa_member_info(table, xid, conn);
if ((error_num = table->file->ha_write_row(table->record[0]))) if ((error_num = spider_write_sys_table_row(table)))
{
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
}
} else { } else {
my_message(ER_SPIDER_XA_MEMBER_EXISTS_NUM, ER_SPIDER_XA_MEMBER_EXISTS_STR, my_message(ER_SPIDER_XA_MEMBER_EXISTS_NUM, ER_SPIDER_XA_MEMBER_EXISTS_STR,
MYF(0)); MYF(0));
...@@ -1051,12 +1125,9 @@ int spider_insert_tables( ...@@ -1051,12 +1125,9 @@ int spider_insert_tables(
SPIDER_LINK_STATUS_NO_CHANGE ? SPIDER_LINK_STATUS_NO_CHANGE ?
share->alter_table.tmp_link_statuses[roop_count] : share->alter_table.tmp_link_statuses[roop_count] :
SPIDER_LINK_STATUS_OK); SPIDER_LINK_STATUS_OK);
if ((error_num = table->file->ha_write_row(table->record[0]))) if ((error_num = spider_write_sys_table_row(table)))
{
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1077,11 +1148,8 @@ int spider_log_tables_link_failed( ...@@ -1077,11 +1148,8 @@ int spider_log_tables_link_failed(
if (table->field[3] == table->timestamp_field) if (table->field[3] == table->timestamp_field)
table->timestamp_field->set_time(); table->timestamp_field->set_time();
#endif #endif
if ((error_num = table->file->ha_write_row(table->record[0]))) if ((error_num = spider_write_sys_table_row(table)))
{
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1115,11 +1183,8 @@ int spider_log_xa_failed( ...@@ -1115,11 +1183,8 @@ int spider_log_xa_failed(
if (table->field[20] == table->timestamp_field) if (table->field[20] == table->timestamp_field)
table->timestamp_field->set_time(); table->timestamp_field->set_time();
#endif #endif
if ((error_num = table->file->ha_write_row(table->record[0]))) if ((error_num = spider_write_sys_table_row(table)))
{
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1148,15 +1213,9 @@ int spider_update_xa( ...@@ -1148,15 +1213,9 @@ int spider_update_xa(
store_record(table, record[1]); store_record(table, record[1]);
table->use_all_columns(); table->use_all_columns();
spider_store_xa_status(table, status); spider_store_xa_status(table, status);
if ( if ((error_num = spider_update_sys_table_row(table)))
(error_num = table->file->ha_update_row(
table->record[1], table->record[0])) &&
error_num != HA_ERR_RECORD_IS_THE_SAME
) {
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1188,15 +1247,9 @@ int spider_update_tables_name( ...@@ -1188,15 +1247,9 @@ int spider_update_tables_name(
store_record(table, record[1]); store_record(table, record[1]);
table->use_all_columns(); table->use_all_columns();
spider_store_tables_name(table, to, strlen(to)); spider_store_tables_name(table, to, strlen(to));
if ( if ((error_num = spider_update_sys_table_row(table)))
(error_num = table->file->ha_update_row(
table->record[1], table->record[0])) &&
error_num != HA_ERR_RECORD_IS_THE_SAME
) {
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
}
roop_count++; roop_count++;
} }
...@@ -1239,11 +1292,8 @@ int spider_update_tables_priority( ...@@ -1239,11 +1292,8 @@ int spider_update_tables_priority(
SPIDER_LINK_STATUS_NO_CHANGE ? SPIDER_LINK_STATUS_NO_CHANGE ?
alter_table->tmp_link_statuses[roop_count] : alter_table->tmp_link_statuses[roop_count] :
SPIDER_LINK_STATUS_OK); SPIDER_LINK_STATUS_OK);
if ((error_num = table->file->ha_write_row(table->record[0]))) if ((error_num = spider_write_sys_table_row(table)))
{
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
}
roop_count++; roop_count++;
} while (roop_count < (int) alter_table->all_link_count); } while (roop_count < (int) alter_table->all_link_count);
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -1259,16 +1309,10 @@ int spider_update_tables_priority( ...@@ -1259,16 +1309,10 @@ int spider_update_tables_priority(
spider_store_tables_connect_info(table, alter_table, roop_count); spider_store_tables_connect_info(table, alter_table, roop_count);
spider_store_tables_link_status(table, spider_store_tables_link_status(table,
alter_table->tmp_link_statuses[roop_count]); alter_table->tmp_link_statuses[roop_count]);
if ( if ((error_num = spider_update_sys_table_row(table)))
(error_num = table->file->ha_update_row(
table->record[1], table->record[0])) &&
error_num != HA_ERR_RECORD_IS_THE_SAME
) {
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
} }
}
while (TRUE) while (TRUE)
{ {
/* delete for subtracting link */ /* delete for subtracting link */
...@@ -1284,12 +1328,9 @@ int spider_update_tables_priority( ...@@ -1284,12 +1328,9 @@ int spider_update_tables_priority(
table->file->print_error(error_num, MYF(0)); table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
if ((error_num = table->file->ha_delete_row(table->record[0]))) if ((error_num = spider_delete_sys_table_row(table)))
{
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
}
roop_count++; roop_count++;
} }
...@@ -1324,15 +1365,9 @@ int spider_update_tables_link_status( ...@@ -1324,15 +1365,9 @@ int spider_update_tables_link_status(
store_record(table, record[1]); store_record(table, record[1]);
table->use_all_columns(); table->use_all_columns();
spider_store_tables_link_status(table, link_status); spider_store_tables_link_status(table, link_status);
if ( if ((error_num = spider_update_sys_table_row(table)))
(error_num = table->file->ha_update_row(
table->record[1], table->record[0])) &&
error_num != HA_ERR_RECORD_IS_THE_SAME
) {
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1358,12 +1393,9 @@ int spider_delete_xa( ...@@ -1358,12 +1393,9 @@ int spider_delete_xa(
MYF(0)); MYF(0));
DBUG_RETURN(ER_SPIDER_XA_NOT_EXISTS_NUM); DBUG_RETURN(ER_SPIDER_XA_NOT_EXISTS_NUM);
} else { } else {
if ((error_num = table->file->ha_delete_row(table->record[0]))) if ((error_num = spider_delete_sys_table_row(table)))
{
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1389,7 +1421,7 @@ int spider_delete_xa_member( ...@@ -1389,7 +1421,7 @@ int spider_delete_xa_member(
DBUG_RETURN(0); DBUG_RETURN(0);
} else { } else {
do { do {
if ((error_num = table->file->ha_delete_row(table->record[0]))) if ((error_num = spider_delete_sys_table_row(table, 0, FALSE)))
{ {
spider_sys_index_end(table); spider_sys_index_end(table);
table->file->print_error(error_num, MYF(0)); table->file->print_error(error_num, MYF(0));
...@@ -1424,12 +1456,9 @@ int spider_delete_tables( ...@@ -1424,12 +1456,9 @@ int spider_delete_tables(
if ((error_num = spider_check_sys_table(table, table_key))) if ((error_num = spider_check_sys_table(table, table_key)))
break; break;
else { else {
if ((error_num = table->file->ha_delete_row(table->record[0]))) if ((error_num = spider_delete_sys_table_row(table)))
{
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
}
roop_count++; roop_count++;
} }
...@@ -2305,7 +2334,7 @@ int spider_sys_replace( ...@@ -2305,7 +2334,7 @@ int spider_sys_replace(
char table_key[MAX_KEY_LENGTH]; char table_key[MAX_KEY_LENGTH];
DBUG_ENTER("spider_sys_replace"); DBUG_ENTER("spider_sys_replace");
while ((error_num = table->file->ha_write_row(table->record[0]))) while ((error_num = spider_write_sys_table_row(table, FALSE)))
{ {
if ( if (
table->file->is_fatal_error(error_num, HA_CHECK_DUP) || table->file->is_fatal_error(error_num, HA_CHECK_DUP) ||
...@@ -2357,13 +2386,11 @@ int spider_sys_replace( ...@@ -2357,13 +2386,11 @@ int spider_sys_replace(
last_uniq_key && last_uniq_key &&
!table->file->referenced_by_foreign_key() !table->file->referenced_by_foreign_key()
) { ) {
error_num = table->file->ha_update_row(table->record[1], if ((error_num = spider_update_sys_table_row(table)))
table->record[0]);
if (error_num && error_num != HA_ERR_RECORD_IS_THE_SAME)
goto error; goto error;
DBUG_RETURN(0); DBUG_RETURN(0);
} else { } else {
if ((error_num = table->file->ha_delete_row(table->record[1]))) if ((error_num = spider_delete_sys_table_row(table, 1, FALSE)))
goto error; goto error;
*modified_non_trans_table = TRUE; *modified_non_trans_table = 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