582
585
static int binlog_savepoint_set(handlerton *, Session *session, void *sv)
587
(void)replicator_savepoint_set(session, sv);
584
588
binlog_trans_log_savepos(session, (my_off_t*) sv);
585
589
/* Write it to the binary log */
593
597
static int binlog_savepoint_rollback(handlerton *, Session *session, void *sv)
596
601
Write ROLLBACK TO SAVEPOINT to the binlog cache if we have updated some
597
602
non-transactional table. Otherwise, truncate the binlog cache starting
604
609
session->binlog_query(Session::STMT_QUERY_TYPE,
605
session->query, session->query_length, true, false);
610
session->query, session->query_length, true, false);
608
613
binlog_trans_log_truncate(session, *(my_off_t*)sv);
616
error= replicator_rollback_to_savepoint(session, sv);
2148
Function to start a statement and optionally a transaction for the
2152
binlog_start_trans_and_stmt()
2156
This function does three things:
2157
- Start a transaction if not in autocommit mode or if a BEGIN
2158
statement has been seen.
2160
- Start a statement transaction to allow us to truncate the binary
2163
- Save the currrent binlog position so that we can roll back the
2164
statement by truncating the transaction log.
2166
We only update the saved position if the old one was undefined,
2167
the reason is that there are some cases (e.g., for CREATE-SELECT)
2168
where the position is saved twice (e.g., both in
2169
select_create::prepare() and Session::binlog_write_table_map()) , but
2170
we should use the first. This means that calls to this function
2171
can be used to start the statement before the first table map
2172
event, to include some extra events.
2176
Session::binlog_start_trans_and_stmt()
2178
binlog_trx_data *trx_data= (binlog_trx_data*) session_get_ha_data(this, binlog_hton);
2180
if (trx_data == NULL ||
2181
trx_data->before_stmt_pos == MY_OFF_T_UNDEF)
2183
this->binlog_set_stmt_begin();
2184
if (options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
2185
trans_register_ha(this, true, binlog_hton);
2186
trans_register_ha(this, false, binlog_hton);
2188
Mark statement transaction as read/write. We never start
2189
a binary log transaction and keep it read-only,
2190
therefore it's best to mark the transaction read/write just
2191
at the same time we start it.
2192
Not necessary to mark the normal transaction read/write
2193
since the statement-level flag will be propagated automatically
2194
inside ha_commit_trans.
2196
ha_data[binlog_hton->slot].ha_info[0].set_trx_read_write();
2201
2156
void Session::binlog_set_stmt_begin() {
2202
2157
binlog_trx_data *trx_data=
2203
2158
(binlog_trx_data*) session_get_ha_data(this, binlog_hton);
2219
Write a table map to the binary log.
2222
int Session::binlog_write_table_map(Table *table, bool is_trans)
2226
/* Pre-conditions */
2227
assert(table->s->table_map_id != UINT32_MAX);
2229
Table_map_log_event::flag_set const
2230
flags= Table_map_log_event::TM_NO_FLAGS;
2233
the_event(this, table, table->s->table_map_id, is_trans, flags);
2235
if (is_trans && binlog_table_maps == 0)
2236
binlog_start_trans_and_stmt();
2238
if ((error= drizzle_bin_log.write(&the_event)))
2241
binlog_table_maps++;
2242
table->s->table_map_version= drizzle_bin_log.table_map_version();
2246
2173
Rows_log_event*
2247
2174
Session::binlog_get_pending_rows_event() const