47
47
static bool test_if_number(const char *str,
48
48
long *res, bool allow_wildcards);
49
49
static int binlog_init(void *p);
50
static int binlog_close_connection(handlerton *hton, Session *thd);
51
static int binlog_savepoint_set(handlerton *hton, Session *thd, void *sv);
52
static int binlog_savepoint_rollback(handlerton *hton, Session *thd, void *sv);
53
static int binlog_commit(handlerton *hton, Session *thd, bool all);
54
static int binlog_rollback(handlerton *hton, Session *thd, bool all);
55
static int binlog_prepare(handlerton *hton, Session *thd, bool all);
50
static int binlog_close_connection(handlerton *hton, Session *session);
51
static int binlog_savepoint_set(handlerton *hton, Session *session, void *sv);
52
static int binlog_savepoint_rollback(handlerton *hton, Session *session, void *sv);
53
static int binlog_commit(handlerton *hton, Session *session, bool all);
54
static int binlog_rollback(handlerton *hton, Session *session, bool all);
55
static int binlog_prepare(handlerton *hton, Session *session, bool all);
58
58
sql_print_message_func sql_print_message_handlers[3] =
323
binlog_trans_log_savepos(Session *thd, my_off_t *pos)
323
binlog_trans_log_savepos(Session *session, my_off_t *pos)
325
325
assert(pos != NULL);
326
if (thd_get_ha_data(thd, binlog_hton) == NULL)
327
thd->binlog_setup_trx_data();
326
if (session_get_ha_data(session, binlog_hton) == NULL)
327
session->binlog_setup_trx_data();
328
328
binlog_trx_data *const trx_data=
329
(binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
329
(binlog_trx_data*) session_get_ha_data(session, binlog_hton);
330
330
assert(mysql_bin_log.is_open());
331
331
*pos= trx_data->position();
352
binlog_trans_log_truncate(Session *thd, my_off_t pos)
352
binlog_trans_log_truncate(Session *session, my_off_t pos)
354
assert(thd_get_ha_data(thd, binlog_hton) != NULL);
354
assert(session_get_ha_data(session, binlog_hton) != NULL);
355
355
/* Only true if binlog_trans_log_savepos() wasn't called before */
356
356
assert(pos != ~(my_off_t) 0);
358
358
binlog_trx_data *const trx_data=
359
(binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
359
(binlog_trx_data*) session_get_ha_data(session, binlog_hton);
360
360
trx_data->truncate(pos);
387
387
static int binlog_close_connection(handlerton *hton __attribute__((unused)),
390
390
binlog_trx_data *const trx_data=
391
(binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
391
(binlog_trx_data*) session_get_ha_data(session, binlog_hton);
392
392
assert(trx_data->empty());
393
thd_set_ha_data(thd, binlog_hton, NULL);
393
session_set_ha_data(session, binlog_hton, NULL);
394
394
trx_data->~binlog_trx_data();
395
395
free((unsigned char*)trx_data);
403
403
binlog_end_trans()
405
thd The thread whose transaction should be ended
405
session The thread whose transaction should be ended
406
406
trx_data Pointer to the transaction data to use
407
407
end_ev The end event to use, or NULL
408
408
all True if the entire transaction should be ended, false if
420
420
'all' is false), or reset completely (if 'all' is true).
423
binlog_end_trans(Session *thd, binlog_trx_data *trx_data,
423
binlog_end_trans(Session *session, binlog_trx_data *trx_data,
424
424
Log_event *end_ev, bool all)
444
444
were, we would have to ensure that we're not ending a statement
445
445
inside a stored function.
447
thd->binlog_flush_pending_rows_event(true);
447
session->binlog_flush_pending_rows_event(true);
449
error= mysql_bin_log.write(thd, &trx_data->trans_log, end_ev);
449
error= mysql_bin_log.write(session, &trx_data->trans_log, end_ev);
450
450
trx_data->reset();
470
470
If rolling back a statement in a transaction, we truncate the
471
471
transaction cache to remove the statement.
473
if (all || !(thd->options & (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT)))
473
if (all || !(session->options & (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT)))
475
475
trx_data->reset();
477
assert(!thd->binlog_get_pending_rows_event());
478
thd->clear_binlog_table_maps();
477
assert(!session->binlog_get_pending_rows_event());
478
session->clear_binlog_table_maps();
480
480
else // ...statement
481
481
trx_data->truncate(trx_data->before_stmt_pos);
511
511
binlog file on commits.
513
513
@param hton The binlog handlerton.
514
@param thd The client thread that executes the transaction.
514
@param session The client thread that executes the transaction.
515
515
@param all This is @c true if this is a real transaction commit, and
516
516
@false otherwise.
518
518
@see handlerton::commit
520
520
static int binlog_commit(handlerton *hton __attribute__((unused)),
521
Session *thd, bool all)
521
Session *session, bool all)
523
523
binlog_trx_data *const trx_data=
524
(binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
524
(binlog_trx_data*) session_get_ha_data(session, binlog_hton);
526
526
if (trx_data->empty())
589
589
Otherwise, we accumulate the statement
591
591
uint64_t const in_transaction=
592
thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN);
593
if ((in_transaction && (all || (!trx_data->at_least_one_stmt && thd->transaction.stmt.modified_non_trans_table))) || (!in_transaction && !all))
592
session->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN);
593
if ((in_transaction && (all || (!trx_data->at_least_one_stmt && session->transaction.stmt.modified_non_trans_table))) || (!in_transaction && !all))
595
Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), true, false);
595
Query_log_event qev(session, STRING_WITH_LEN("COMMIT"), true, false);
596
596
qev.error_code= 0; // see comment in DRIZZLE_LOG::write(Session, IO_CACHE)
597
int error= binlog_end_trans(thd, trx_data, &qev, all);
597
int error= binlog_end_trans(session, trx_data, &qev, all);
609
609
non-transactional tables, nothing needs to be logged.
611
611
@param hton The binlog handlerton.
612
@param thd The client thread that executes the transaction.
612
@param session The client thread that executes the transaction.
613
613
@param all This is @c true if this is a real transaction rollback, and
614
614
@false otherwise.
616
616
@see handlerton::rollback
618
618
static int binlog_rollback(handlerton *hton __attribute__((unused)),
619
Session *thd, bool all)
619
Session *session, bool all)
622
622
binlog_trx_data *const trx_data=
623
(binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
623
(binlog_trx_data*) session_get_ha_data(session, binlog_hton);
625
625
if (trx_data->empty()) {
626
626
trx_data->reset();
630
if ((all && thd->transaction.all.modified_non_trans_table) ||
631
(!all && thd->transaction.stmt.modified_non_trans_table) ||
632
(thd->options & OPTION_KEEP_LOG))
630
if ((all && session->transaction.all.modified_non_trans_table) ||
631
(!all && session->transaction.stmt.modified_non_trans_table) ||
632
(session->options & OPTION_KEEP_LOG))
635
635
We write the transaction cache with a rollback last if we have
639
639
transactional table in that statement as well, which needs to be
640
640
rolled back on the slave.
642
Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), true, false);
642
Query_log_event qev(session, STRING_WITH_LEN("ROLLBACK"), true, false);
643
643
qev.error_code= 0; // see comment in DRIZZLE_LOG::write(Session, IO_CACHE)
644
error= binlog_end_trans(thd, trx_data, &qev, all);
644
error= binlog_end_trans(session, trx_data, &qev, all);
646
else if ((all && !thd->transaction.all.modified_non_trans_table) ||
647
(!all && !thd->transaction.stmt.modified_non_trans_table))
646
else if ((all && !session->transaction.all.modified_non_trans_table) ||
647
(!all && !session->transaction.stmt.modified_non_trans_table))
650
650
If we have modified only transactional tables, we can truncate
651
651
the transaction cache without writing anything to the binary
654
error= binlog_end_trans(thd, trx_data, 0, all);
654
error= binlog_end_trans(session, trx_data, 0, all);
683
683
static int binlog_savepoint_set(handlerton *hton __attribute__((unused)),
684
Session *thd, void *sv)
684
Session *session, void *sv)
686
binlog_trans_log_savepos(thd, (my_off_t*) sv);
686
binlog_trans_log_savepos(session, (my_off_t*) sv);
687
687
/* Write it to the binary log */
690
thd->binlog_query(Session::STMT_QUERY_TYPE,
691
thd->query, thd->query_length, true, false);
690
session->binlog_query(Session::STMT_QUERY_TYPE,
691
session->query, session->query_length, true, false);
695
695
static int binlog_savepoint_rollback(handlerton *hton __attribute__((unused)),
696
Session *thd, void *sv)
696
Session *session, void *sv)
699
699
Write ROLLBACK TO SAVEPOINT to the binlog cache if we have updated some
700
700
non-transactional table. Otherwise, truncate the binlog cache starting
701
701
from the SAVEPOINT command.
703
if (unlikely(thd->transaction.all.modified_non_trans_table ||
704
(thd->options & OPTION_KEEP_LOG)))
703
if (unlikely(session->transaction.all.modified_non_trans_table ||
704
(session->options & OPTION_KEEP_LOG)))
707
thd->binlog_query(Session::STMT_QUERY_TYPE,
708
thd->query, thd->query_length, true, false);
707
session->binlog_query(Session::STMT_QUERY_TYPE,
708
session->query, session->query_length, true, false);
711
binlog_trans_log_truncate(thd, *(my_off_t*)sv);
711
binlog_trans_log_truncate(session, *(my_off_t*)sv);
1510
1510
The following mutex is needed to ensure that no threads call
1511
'delete thd' as we would then risk missing a 'rollback' from this
1511
'delete session' as we would then risk missing a 'rollback' from this
1512
1512
thread. If the transaction involved MyISAM tables, it should go
1513
1513
into binlog even on rollback.
1534
1534
if (my_errno == ENOENT)
1536
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1536
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1537
1537
ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1538
1538
linfo.log_file_name);
1539
1539
sql_print_information(_("Failed to delete file '%s'"),
1546
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1546
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1547
1547
ER_BINLOG_PURGE_FATAL_ERR,
1548
1548
_("a problem with deleting %s; "
1549
1549
"consider examining correspondence "
1565
1565
if (my_errno == ENOENT)
1567
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1567
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1568
1568
ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1569
1569
index_file_name);
1570
1570
sql_print_information(_("Failed to delete file '%s'"),
1577
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1577
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1578
1578
ER_BINLOG_PURGE_FATAL_ERR,
1579
1579
"a problem with deleting %s; "
1580
1580
"consider examining correspondence "
1588
if (!thd->slave_thread)
1588
if (!session->slave_thread)
1589
1589
need_start_event=1;
1590
1590
if (!open_index_file(index_file_name, 0))
1591
1591
open(save_name, log_type, 0, io_cache_type, no_auto_events, max_size, 0);
1779
1779
It's not fatal if we can't stat a log file that does not exist;
1780
1780
If we could not stat, we won't delete.
1782
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1782
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1783
1783
ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1784
1784
log_info.log_file_name);
1785
1785
sql_print_information(_("Failed to execute stat() on file '%s'"),
1792
1792
Other than ENOENT are fatal
1794
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1794
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1795
1795
ER_BINLOG_PURGE_FATAL_ERR,
1796
1796
_("a problem with getting info on being purged %s; "
1797
1797
"consider examining correspondence "
1814
1814
if (my_errno == ENOENT)
1816
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1816
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1817
1817
ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1818
1818
log_info.log_file_name);
1819
1819
sql_print_information(_("Failed to delete file '%s'"),
1825
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1825
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1826
1826
ER_BINLOG_PURGE_FATAL_ERR,
1827
1827
_("a problem with deleting %s; "
1828
1828
"consider examining correspondence "
1904
1904
It's not fatal if we can't stat a log file that does not exist.
1906
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1906
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1907
1907
ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1908
1908
log_info.log_file_name);
1909
1909
sql_print_information(_("Failed to execute stat() on file '%s'"),
1916
1916
Other than ENOENT are fatal
1918
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1918
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1919
1919
ER_BINLOG_PURGE_FATAL_ERR,
1920
1920
_("a problem with getting info on being purged %s; "
1921
1921
"consider examining correspondence "
1935
1935
if (my_errno == ENOENT)
1937
1937
/* It's not fatal even if we can't delete a log file */
1938
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1938
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1939
1939
ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
1940
1940
log_info.log_file_name);
1941
1941
sql_print_information(_("Failed to delete file '%s'"),
1947
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1947
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1948
1948
ER_BINLOG_PURGE_FATAL_ERR,
1949
1949
_("a problem with deleting %s; "
1950
1950
"consider examining correspondence "
2198
void DRIZZLE_BIN_LOG::start_union_events(Session *thd, query_id_t query_id_param)
2200
assert(!thd->binlog_evt_union.do_union);
2201
thd->binlog_evt_union.do_union= true;
2202
thd->binlog_evt_union.unioned_events= false;
2203
thd->binlog_evt_union.unioned_events_trans= false;
2204
thd->binlog_evt_union.first_query_id= query_id_param;
2207
void DRIZZLE_BIN_LOG::stop_union_events(Session *thd)
2209
assert(thd->binlog_evt_union.do_union);
2210
thd->binlog_evt_union.do_union= false;
2213
bool DRIZZLE_BIN_LOG::is_query_in_union(Session *thd, query_id_t query_id_param)
2215
return (thd->binlog_evt_union.do_union &&
2216
query_id_param >= thd->binlog_evt_union.first_query_id);
2198
void DRIZZLE_BIN_LOG::start_union_events(Session *session, query_id_t query_id_param)
2200
assert(!session->binlog_evt_union.do_union);
2201
session->binlog_evt_union.do_union= true;
2202
session->binlog_evt_union.unioned_events= false;
2203
session->binlog_evt_union.unioned_events_trans= false;
2204
session->binlog_evt_union.first_query_id= query_id_param;
2207
void DRIZZLE_BIN_LOG::stop_union_events(Session *session)
2209
assert(session->binlog_evt_union.do_union);
2210
session->binlog_evt_union.do_union= false;
2213
bool DRIZZLE_BIN_LOG::is_query_in_union(Session *session, query_id_t query_id_param)
2215
return (session->binlog_evt_union.do_union &&
2216
query_id_param >= session->binlog_evt_union.first_query_id);
2225
2225
int Session::binlog_setup_trx_data()
2227
2227
binlog_trx_data *trx_data=
2228
(binlog_trx_data*) thd_get_ha_data(this, binlog_hton);
2228
(binlog_trx_data*) session_get_ha_data(this, binlog_hton);
2231
2231
return(0); // Already set up
2238
2238
free((unsigned char*)trx_data);
2239
2239
return(1); // Didn't manage to set it up
2241
thd_set_ha_data(this, binlog_hton, trx_data);
2241
session_set_ha_data(this, binlog_hton, trx_data);
2243
trx_data= new (thd_get_ha_data(this, binlog_hton)) binlog_trx_data;
2243
trx_data= new (session_get_ha_data(this, binlog_hton)) binlog_trx_data;
2302
2302
void Session::binlog_set_stmt_begin() {
2303
2303
binlog_trx_data *trx_data=
2304
(binlog_trx_data*) thd_get_ha_data(this, binlog_hton);
2304
(binlog_trx_data*) session_get_ha_data(this, binlog_hton);
2307
2307
The call to binlog_trans_log_savepos() might create the trx_data
2312
2312
my_off_t pos= 0;
2313
2313
binlog_trans_log_savepos(this, &pos);
2314
trx_data= (binlog_trx_data*) thd_get_ha_data(this, binlog_hton);
2314
trx_data= (binlog_trx_data*) session_get_ha_data(this, binlog_hton);
2315
2315
trx_data->before_stmt_pos= pos;
2349
2349
Session::binlog_get_pending_rows_event() const
2351
2351
binlog_trx_data *const trx_data=
2352
(binlog_trx_data*) thd_get_ha_data(this, binlog_hton);
2352
(binlog_trx_data*) session_get_ha_data(this, binlog_hton);
2354
2354
This is less than ideal, but here's the story: If there is no
2355
2355
trx_data, prepare_pending_rows_event() has never been called
2363
2363
Session::binlog_set_pending_rows_event(Rows_log_event* ev)
2365
if (thd_get_ha_data(this, binlog_hton) == NULL)
2365
if (session_get_ha_data(this, binlog_hton) == NULL)
2366
2366
binlog_setup_trx_data();
2368
2368
binlog_trx_data *const trx_data=
2369
(binlog_trx_data*) thd_get_ha_data(this, binlog_hton);
2369
(binlog_trx_data*) session_get_ha_data(this, binlog_hton);
2371
2371
assert(trx_data);
2372
2372
trx_data->set_pending(ev);
2464
2464
bool DRIZZLE_BIN_LOG::write(Log_event *event_info)
2466
Session *thd= event_info->thd;
2466
Session *session= event_info->session;
2469
if (thd->binlog_evt_union.do_union)
2469
if (session->binlog_evt_union.do_union)
2472
2472
In Stored function; Remember that function call caused an update.
2473
2473
We will log the function call to the binary log on function exit
2475
thd->binlog_evt_union.unioned_events= true;
2476
thd->binlog_evt_union.unioned_events_trans |= event_info->cache_stmt;
2475
session->binlog_evt_union.unioned_events= true;
2476
session->binlog_evt_union.unioned_events_trans |= event_info->cache_stmt;
2506
2506
binlog_[wild_]{do|ignore}_table?" (WL#1049)"
2508
2508
const char *local_db= event_info->get_db();
2509
if ((thd && !(thd->options & OPTION_BIN_LOG)) ||
2509
if ((session && !(session->options & OPTION_BIN_LOG)) ||
2510
2510
(!binlog_filter->db_ok(local_db)))
2512
2512
pthread_mutex_unlock(&LOCK_log);
2522
2522
trans/non-trans table types the best possible in binlogging)
2523
2523
- or if the event asks for it (cache_stmt == TRUE).
2525
if (opt_using_transactions && thd)
2525
if (opt_using_transactions && session)
2527
if (thd->binlog_setup_trx_data())
2527
if (session->binlog_setup_trx_data())
2530
2530
binlog_trx_data *const trx_data=
2531
(binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
2531
(binlog_trx_data*) session_get_ha_data(session, binlog_hton);
2532
2532
IO_CACHE *trans_log= &trx_data->trans_log;
2533
2533
my_off_t trans_log_pos= my_b_tell(trans_log);
2534
2534
if (event_info->get_cache_stmt() || trans_log_pos != 0)
2536
2536
if (trans_log_pos == 0)
2537
thd->binlog_start_trans_and_stmt();
2537
session->binlog_start_trans_and_stmt();
2538
2538
file= trans_log;
2559
2559
If row-based binlogging, Insert_id, Rand and other kind of "setting
2560
2560
context" events are not needed.
2564
if (!thd->current_stmt_binlog_row_based)
2564
if (!session->current_stmt_binlog_row_based)
2566
if (thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt)
2566
if (session->stmt_depends_on_first_successful_insert_id_in_prev_stmt)
2568
Intvar_log_event e(thd,(unsigned char) LAST_INSERT_ID_EVENT,
2569
thd->first_successful_insert_id_in_prev_stmt_for_binlog);
2568
Intvar_log_event e(session,(unsigned char) LAST_INSERT_ID_EVENT,
2569
session->first_successful_insert_id_in_prev_stmt_for_binlog);
2570
2570
if (e.write(file))
2573
if (thd->auto_inc_intervals_in_cur_stmt_for_binlog.nb_elements() > 0)
2573
if (session->auto_inc_intervals_in_cur_stmt_for_binlog.nb_elements() > 0)
2576
2576
If the auto_increment was second in a table's index (possible with
2577
2577
MyISAM or BDB) (table->next_number_keypart != 0), such event is
2578
2578
in fact not necessary. We could avoid logging it.
2580
Intvar_log_event e(thd, (unsigned char) INSERT_ID_EVENT,
2581
thd->auto_inc_intervals_in_cur_stmt_for_binlog.
2580
Intvar_log_event e(session, (unsigned char) INSERT_ID_EVENT,
2581
session->auto_inc_intervals_in_cur_stmt_for_binlog.
2583
2583
if (e.write(file))
2586
if (session->rand_used)
2588
Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
2588
Rand_log_event e(session,session->rand_saved_seed1,session->rand_saved_seed2);
2589
2589
if (e.write(file))
2592
if (thd->user_var_events.elements)
2592
if (session->user_var_events.elements)
2594
for (uint32_t i= 0; i < thd->user_var_events.elements; i++)
2594
for (uint32_t i= 0; i < session->user_var_events.elements; i++)
2596
2596
BINLOG_USER_VAR_EVENT *user_var_event;
2597
get_dynamic(&thd->user_var_events,(unsigned char*) &user_var_event, i);
2598
User_var_log_event e(thd, user_var_event->user_var_event->name.str,
2597
get_dynamic(&session->user_var_events,(unsigned char*) &user_var_event, i);
2598
User_var_log_event e(session, user_var_event->user_var_event->name.str,
2599
2599
user_var_event->user_var_event->name.length,
2600
2600
user_var_event->value,
2601
2601
user_var_event->length,
2840
2840
'cache' needs to be reinitialized after this functions returns.
2843
bool DRIZZLE_BIN_LOG::write(Session *thd, IO_CACHE *cache, Log_event *commit_event)
2843
bool DRIZZLE_BIN_LOG::write(Session *session, IO_CACHE *cache, Log_event *commit_event)
2845
2845
pthread_mutex_lock(&LOCK_log);
2861
2861
transaction is either a BEGIN..COMMIT block or a single
2862
2862
statement in autocommit mode.
2864
Query_log_event qinfo(thd, STRING_WITH_LEN("BEGIN"), true, false);
2864
Query_log_event qinfo(session, STRING_WITH_LEN("BEGIN"), true, false);
2866
2866
Imagine this is rollback due to net timeout, after all
2867
2867
statements of the transaction succeeded. Then we want a
2937
2937
Wait until we get a signal that the relay log has been updated
2939
@param[in] thd a Session struct
2939
@param[in] session a Session struct
2941
2941
LOCK_log must be taken before calling this function.
2942
2942
It will be released at the end of the function.
2945
void DRIZZLE_BIN_LOG::wait_for_update_relay_log(Session* thd)
2945
void DRIZZLE_BIN_LOG::wait_for_update_relay_log(Session* session)
2947
2947
const char *old_msg;
2948
old_msg= thd->enter_cond(&update_cond, &LOCK_log,
2948
old_msg= session->enter_cond(&update_cond, &LOCK_log,
2949
2949
"Slave has read all relay log; "
2950
2950
"waiting for the slave I/O "
2951
2951
"thread to update it" );
2952
2952
pthread_cond_wait(&update_cond, &LOCK_log);
2953
thd->exit_cond(old_msg);
2953
session->exit_cond(old_msg);
2971
2971
LOCK_log is released by the caller.
2974
int DRIZZLE_BIN_LOG::wait_for_update_bin_log(Session* thd,
2974
int DRIZZLE_BIN_LOG::wait_for_update_bin_log(Session* session,
2975
2975
const struct timespec *timeout)
2978
const char* old_msg = thd->get_proc_info();
2979
old_msg= thd->enter_cond(&update_cond, &LOCK_log,
2978
const char* old_msg = session->get_proc_info();
2979
old_msg= session->enter_cond(&update_cond, &LOCK_log,
2980
2980
"Master has sent all binlog to slave; "
2981
2981
"waiting for binlog to be updated");
3886
int TC_LOG_BINLOG::log_xid(Session *thd, my_xid xid)
3886
int TC_LOG_BINLOG::log_xid(Session *session, my_xid xid)
3888
Xid_log_event xle(thd, xid);
3888
Xid_log_event xle(session, xid);
3889
3889
binlog_trx_data *trx_data=
3890
(binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
3890
(binlog_trx_data*) session_get_ha_data(session, binlog_hton);
3892
3892
We always commit the entire transaction when writing an XID. Also
3893
3893
note that the return value is inverted.
3895
return(!binlog_end_trans(thd, trx_data, &xle, true));
3895
return(!binlog_end_trans(session, trx_data, &xle, true));
3898
3898
void TC_LOG_BINLOG::unlog(ulong cookie __attribute__((unused)),