Skip to content

Commit 47d24e2

Browse files
committed
Bug#17774971 MOVE "THD_MARK_TRANSACTION_FOR_ROLLBACK"
DEFINITION FROM HA_INNODB.H TO PLUGIN.H A post push fix for bug#16041903 modified ha_ndbcluster.cc to call THD::mark_transaction_to_rollback instead. The Cluster team requested that the function should be defined as part of the API in include/mysql/plugin.h. There is a corresponding function in sql/sql_class.cc. The function is used by InnoDB, and is defined in ha_innodb.h. Thus, the suggested refactoring is to: 1. Move the definition of thd_mark_transaction_to_rollback from ha_innodb.h to plugin.h 2. Change the type of the paramter "all" from bool to int, because it is now defined in plugin.h which is compiled as both C and C++, and the type "my_bool" is not available in plugin.h 3. Change ha_ndbcluster.cc to call the above function. 4. Change ha_innodb.cc to submit int rather than ibool for the "all" parameter 5. Change the implemntation in sql_class.cc to test for (all != 0) explicitly when calling the THD member function
1 parent dc6ff60 commit 47d24e2

File tree

8 files changed

+28
-12
lines changed

8 files changed

+28
-12
lines changed

include/mysql/plugin.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,17 @@ char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length,
564564
void thd_inc_row_count(MYSQL_THD thd);
565565
int thd_allow_batch(MYSQL_THD thd);
566566

567+
568+
/**
569+
Mark transaction to rollback and mark error as fatal to a
570+
sub-statement if in sub statement mode.
571+
572+
@param thd user thread connection handle
573+
@param all if all != 0, rollback the main transaction
574+
*/
575+
576+
void thd_mark_transaction_to_rollback(MYSQL_THD thd, int all);
577+
567578
/**
568579
Create a temporary file.
569580

include/mysql/plugin_audit.h.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@
265265
unsigned int max_query_len);
266266
void thd_inc_row_count(void* thd);
267267
int thd_allow_batch(void* thd);
268+
void thd_mark_transaction_to_rollback(void* thd, int all);
268269
int mysql_tmpfile(const char *prefix);
269270
int thd_killed(const void* thd);
270271
void thd_binlog_pos(const void* thd,

include/mysql/plugin_auth.h.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@
265265
unsigned int max_query_len);
266266
void thd_inc_row_count(void* thd);
267267
int thd_allow_batch(void* thd);
268+
void thd_mark_transaction_to_rollback(void* thd, int all);
268269
int mysql_tmpfile(const char *prefix);
269270
int thd_killed(const void* thd);
270271
void thd_binlog_pos(const void* thd,

include/mysql/plugin_ftparser.h.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
unsigned int max_query_len);
218218
void thd_inc_row_count(void* thd);
219219
int thd_allow_batch(void* thd);
220+
void thd_mark_transaction_to_rollback(void* thd, int all);
220221
int mysql_tmpfile(const char *prefix);
221222
int thd_killed(const void* thd);
222223
void thd_binlog_pos(const void* thd,

sql/ha_ndbcluster.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8393,7 +8393,7 @@ static int ndbcluster_rollback(handlerton *hton, THD *thd, bool all)
83938393
of the transaction
83948394
*/
83958395
DBUG_PRINT("info", ("Rollback before start or end-of-statement only"));
8396-
thd->mark_transaction_to_rollback(1);
8396+
thd_mark_transaction_to_rollback(thd, 1);
83978397
my_error(ER_WARN_ENGINE_TRANSACTION_ROLLBACK, MYF(0), "NDB");
83988398
DBUG_RETURN(0);
83998399
}

sql/sql_class.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4000,10 +4000,17 @@ extern "C" int thd_binlog_format(const MYSQL_THD thd)
40004000
return BINLOG_FORMAT_UNSPEC;
40014001
}
40024002

4003-
extern "C" void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all)
4003+
extern "C" void thd_mark_transaction_to_rollback(MYSQL_THD thd, int all)
40044004
{
40054005
DBUG_ASSERT(thd);
4006-
thd->mark_transaction_to_rollback(all);
4006+
/*
4007+
The parameter "all" has type int since the function is defined
4008+
in plugin.h. The corresponding parameter in the call below has
4009+
type bool. The comment in plugin.h states that "all != 0"
4010+
means to rollback the main transaction. Thus, check this
4011+
specifically.
4012+
*/
4013+
thd->mark_transaction_to_rollback((all != 0));
40074014
}
40084015

40094016
extern "C" bool thd_binlog_filter_ok(const MYSQL_THD thd)

storage/innobase/handler/ha_innodb.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ convert_error_code_to_mysql(
13761376
cached binlog for this transaction */
13771377

13781378
if (thd) {
1379-
thd_mark_transaction_to_rollback(thd, true);
1379+
thd_mark_transaction_to_rollback(thd, 1);
13801380
}
13811381

13821382
return(HA_ERR_LOCK_DEADLOCK);
@@ -1388,7 +1388,7 @@ convert_error_code_to_mysql(
13881388

13891389
if (thd) {
13901390
thd_mark_transaction_to_rollback(
1391-
thd, (bool) row_rollback_on_timeout);
1391+
thd, (int) row_rollback_on_timeout);
13921392
}
13931393

13941394
return(HA_ERR_LOCK_WAIT_TIMEOUT);
@@ -1463,7 +1463,7 @@ convert_error_code_to_mysql(
14631463
cached binlog for this transaction */
14641464

14651465
if (thd) {
1466-
thd_mark_transaction_to_rollback(thd, true);
1466+
thd_mark_transaction_to_rollback(thd, 1);
14671467
}
14681468

14691469
return(HA_ERR_LOCK_TABLE_FULL);
@@ -10236,7 +10236,7 @@ ha_innobase::records()
1023610236
case DB_DEADLOCK:
1023710237
case DB_LOCK_TABLE_FULL:
1023810238
case DB_LOCK_WAIT_TIMEOUT:
10239-
thd_mark_transaction_to_rollback(user_thd, true);
10239+
thd_mark_transaction_to_rollback(user_thd, 1);
1024010240
DBUG_RETURN(HA_POS_ERROR);
1024110241
case DB_INTERRUPTED:
1024210242
my_error(ER_QUERY_INTERRUPTED, MYF(0));

storage/innobase/handler/ha_innodb.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,6 @@ int thd_non_transactional_update(const MYSQL_THD thd);
394394
@return Value to be used as index into the binlog_format_names array */
395395
int thd_binlog_format(const MYSQL_THD thd);
396396

397-
/** Mark transaction to rollback and mark error as fatal to a sub-statement.
398-
@param thd Thread handle
399-
@param all TRUE <=> rollback main transaction. */
400-
void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all);
401-
402397
/** Check if binary logging is filtered for thread's current db.
403398
@param thd Thread handle
404399
@retval 1 the query is not filtered, 0 otherwise. */

0 commit comments

Comments
 (0)