summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc154
1 files changed, 29 insertions, 125 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 242c45a7ed7..7f6cff3cc59 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -490,24 +490,10 @@ private:
};
handlerton *binlog_hton;
-#ifdef WITH_WSREP
-extern handlerton *wsrep_hton;
-#endif
-
-bool LOGGER::is_log_table_enabled(uint log_table_type)
-{
- switch (log_table_type) {
- case QUERY_LOG_SLOW:
- return (table_log_handler != NULL) && opt_slow_log;
- case QUERY_LOG_GENERAL:
- return (table_log_handler != NULL) && opt_log ;
- default:
- DBUG_ASSERT(0);
- return FALSE; /* make compiler happy */
- }
-}
-#ifdef WITH_WSREP
+#if WITH_WSREP
+/* the functions below depend on the definition of binlog_cache_manager class,
+ * so have to stay in this unit. */
IO_CACHE * get_trans_log(THD * thd)
{
binlog_cache_mngr *cache_mngr = (binlog_cache_mngr*)
@@ -515,7 +501,7 @@ IO_CACHE * get_trans_log(THD * thd)
if (cache_mngr)
{
return cache_mngr->get_binlog_cache_log(true);
- }
+ }
else
{
WSREP_DEBUG("binlog cache not initialized, conn :%ld", thd->thread_id);
@@ -523,7 +509,6 @@ IO_CACHE * get_trans_log(THD * thd)
}
}
-
bool wsrep_trans_cache_is_empty(THD *thd)
{
binlog_cache_mngr *const cache_mngr=
@@ -535,6 +520,7 @@ void thd_binlog_flush_pending_rows_event(THD *thd, bool stmt_end)
{
thd->binlog_flush_pending_rows_event(stmt_end);
}
+
void thd_binlog_trx_reset(THD * thd)
{
/*
@@ -556,74 +542,21 @@ void thd_binlog_rollback_stmt(THD * thd)
(binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton);
if (cache_mngr) cache_mngr->trx_cache.set_prev_position(MY_OFF_T_UNDEF);
}
-/*
- Write the contents of a cache to memory buffer.
-
- This function quite the same as MYSQL_BIN_LOG::write_cache(),
- with the exception that here we write in buffer instead of log file.
- */
+#endif /* WITH_WSREP */
-int wsrep_write_cache(IO_CACHE *cache, uchar **buf, uint *buf_len)
+bool LOGGER::is_log_table_enabled(uint log_table_type)
{
-
- if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
- return ER_ERROR_ON_WRITE;
- uint length= my_b_bytes_in_cache(cache);
- long long total_length = 0;
- uchar *buf_ptr = NULL;
-
- do
- {
- /* bail out if buffer grows too large
- This is a temporary fix to avoid flooding replication
- TODO: remove this check for 0.7.4 release
- */
- if (total_length > wsrep_max_ws_size)
- {
- WSREP_WARN("transaction size limit (%lld) exceeded: %lld",
- wsrep_max_ws_size, total_length);
- if (reinit_io_cache(cache, WRITE_CACHE, 0, 0, 0))
- {
- WSREP_WARN("failed to initialize io-cache");
- }
- if (buf_ptr) my_free(*buf);
- *buf_len = 0;
- return ER_ERROR_ON_WRITE;
- }
- if (total_length > 0)
- {
- *buf_len += length;
- *buf = (uchar *)my_realloc(*buf, total_length+length, MYF(0));
- if (!*buf)
- {
- WSREP_ERROR("io cache write problem: %d %d", *buf_len, length);
- return ER_ERROR_ON_WRITE;
- }
- buf_ptr = *buf+total_length;
- }
- else
- {
- if (buf_ptr != NULL)
- {
- WSREP_ERROR("io cache alloc error: %d %d", *buf_len, length);
- my_free(*buf);
- }
- if (length > 0)
- {
- *buf = (uchar *) my_malloc(length, MYF(0));
- buf_ptr = *buf;
- *buf_len = length;
- }
- }
- total_length += length;
-
- memcpy(buf_ptr, cache->read_pos, length);
- cache->read_pos=cache->read_end;
- } while ((cache->file >= 0) && (length= my_b_fill(cache)));
-
- return 0;
+ switch (log_table_type) {
+ case QUERY_LOG_SLOW:
+ return (table_log_handler != NULL) && opt_slow_log;
+ case QUERY_LOG_GENERAL:
+ return (table_log_handler != NULL) && opt_log ;
+ default:
+ DBUG_ASSERT(0);
+ return FALSE; /* make compiler happy */
+ }
}
-#endif
+
/* Check if a given table is opened log table */
int check_if_log_table(size_t db_len, const char *db, size_t table_name_len,
@@ -1817,13 +1750,6 @@ static inline int
binlog_commit_flush_stmt_cache(THD *thd, bool all,
binlog_cache_mngr *cache_mngr)
{
-#ifdef WITH_WSREP
- if (thd->wsrep_mysql_replicated > 0)
- {
- WSREP_DEBUG("avoiding binlog_commit_flush_trx_cache: %d", thd->wsrep_mysql_replicated);
- return 0;
- }
-#endif
Query_log_event end_evt(thd, STRING_WITH_LEN("COMMIT"),
FALSE, TRUE, TRUE, 0);
return (binlog_flush_cache(thd, cache_mngr, &end_evt, all, TRUE, FALSE));
@@ -1841,6 +1767,13 @@ binlog_commit_flush_stmt_cache(THD *thd, bool all,
static inline int
binlog_commit_flush_trx_cache(THD *thd, bool all, binlog_cache_mngr *cache_mngr)
{
+#ifdef WITH_WSREP
+ if (thd->wsrep_mysql_replicated > 0)
+ {
+ WSREP_DEBUG("avoiding binlog_commit_flush_trx_cache: %d", thd->wsrep_mysql_replicated);
+ return 0;
+ }
+#endif
Query_log_event end_evt(thd, STRING_WITH_LEN("COMMIT"),
TRUE, TRUE, TRUE, 0);
return (binlog_flush_cache(thd, cache_mngr, &end_evt, all, FALSE, TRUE));
@@ -2104,12 +2037,12 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
if (ending_trans(thd, all) &&
((thd->variables.option_bits & OPTION_KEEP_LOG) ||
(trans_has_updated_non_trans_table(thd) &&
- WSREP_FORMAT(thd->variables.binlog_format) == BINLOG_FORMAT_STMT) ||
+ WSREP_BINLOG_FORMAT(thd->variables.binlog_format) == BINLOG_FORMAT_STMT) ||
(cache_mngr->trx_cache.changes_to_non_trans_temp_table() &&
- WSREP_FORMAT(thd->variables.binlog_format) == BINLOG_FORMAT_MIXED) ||
+ WSREP_BINLOG_FORMAT(thd->variables.binlog_format) == BINLOG_FORMAT_MIXED) ||
(trans_has_updated_non_trans_table(thd) &&
ending_single_stmt_trans(thd,all) &&
- WSREP_FORMAT(thd->variables.binlog_format) == BINLOG_FORMAT_MIXED)))
+ WSREP_BINLOG_FORMAT(thd->variables.binlog_format) == BINLOG_FORMAT_MIXED)))
error= binlog_rollback_flush_trx_cache(thd, all, cache_mngr);
/*
Truncate the cache if:
@@ -2123,9 +2056,9 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
else if (ending_trans(thd, all) ||
(!(thd->variables.option_bits & OPTION_KEEP_LOG) &&
(!stmt_has_updated_non_trans_table(thd) ||
- WSREP_FORMAT(thd->variables.binlog_format) != BINLOG_FORMAT_STMT) &&
+ WSREP_BINLOG_FORMAT(thd->variables.binlog_format) != BINLOG_FORMAT_STMT) &&
(!cache_mngr->trx_cache.changes_to_non_trans_temp_table() ||
- WSREP_FORMAT(thd->variables.binlog_format) != BINLOG_FORMAT_MIXED)))
+ WSREP_BINLOG_FORMAT(thd->variables.binlog_format) != BINLOG_FORMAT_MIXED)))
error= binlog_truncate_trx_cache(thd, cache_mngr, all);
}
@@ -5439,35 +5372,6 @@ err:
}
}
-#ifdef WITH_WSREP
- if (WSREP(thd) && wsrep_incremental_data_collection &&
- (wsrep_emulate_bin_log || mysql_bin_log.is_open()))
- {
- DBUG_ASSERT(thd->wsrep_trx_handle.trx_id != (unsigned long)-1);
- if (!error)
- {
- IO_CACHE* cache= get_trans_log(thd);
- uchar* buf= NULL;
- uint buf_len= 0;
-
- if (wsrep_emulate_bin_log)
- thd->binlog_flush_pending_rows_event(false);
- error= wsrep_write_cache(cache, &buf, &buf_len);
- if (!error && buf_len > 0)
- {
- wsrep_status_t rc= wsrep->append_data(wsrep,
- &thd->wsrep_trx_handle,
- buf, buf_len);
- if (rc != WSREP_OK)
- {
- sql_print_warning("WSREP: append_data() returned %d", rc);
- error= 1;
- }
- }
- if (buf_len) my_free(buf);
- }
- }
-#endif /* WITH_WSREP */
DBUG_RETURN(error);
}