MCPcopy Create free account
hub / github.com/Tencent/phxsql / binlog_query

Method binlog_query

phx_percona/percona/sql/binlog.cc:9684–9795  ·  view source on GitHub ↗

Log the current query. The query will be logged in either row format or statement format depending on the value of @c current_stmt_binlog_format_row field and the value of the @c qtype parameter. This function must be called: - After the all calls to ha_*_row() functions have been issued. - After any writes to system tables. Rationale: if system tables were written after a call

Source from the content-addressed store, hash-verified

9682 write failure), then the error code is returned.
9683*/
9684int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
9685 ulong query_len, bool is_trans, bool direct,
9686 bool suppress_use, int errcode)
9687{
9688 DBUG_ENTER("THD::binlog_query");
9689 DBUG_PRINT("enter", ("qtype: %s query: '%s'",
9690 show_query_type(qtype), query_arg));
9691 DBUG_ASSERT(query_arg && mysql_bin_log.is_open());
9692
9693 if (get_binlog_local_stmt_filter() == BINLOG_FILTER_SET)
9694 {
9695 /*
9696 The current statement is to be ignored, and not written to
9697 the binlog. Do not call issue_unsafe_warnings().
9698 */
9699 DBUG_RETURN(0);
9700 }
9701
9702 /*
9703 If we are not in prelocked mode, mysql_unlock_tables() will be
9704 called after this binlog_query(), so we have to flush the pending
9705 rows event with the STMT_END_F set to unlock all tables at the
9706 slave side as well.
9707
9708 If we are in prelocked mode, the flushing will be done inside the
9709 top-most close_thread_tables().
9710 */
9711 if (this->locked_tables_mode <= LTM_LOCK_TABLES)
9712 if (int error= binlog_flush_pending_rows_event(TRUE, is_trans))
9713 DBUG_RETURN(error);
9714
9715 /*
9716 Warnings for unsafe statements logged in statement format are
9717 printed in three places instead of in decide_logging_format().
9718 This is because the warnings should be printed only if the statement
9719 is actually logged. When executing decide_logging_format(), we cannot
9720 know for sure if the statement will be logged:
9721
9722 1 - sp_head::execute_procedure which prints out warnings for calls to
9723 stored procedures.
9724
9725 2 - sp_head::execute_function which prints out warnings for calls
9726 involving functions.
9727
9728 3 - THD::binlog_query (here) which prints warning for top level
9729 statements not covered by the two cases above: i.e., if not insided a
9730 procedure and a function.
9731
9732 Besides, we should not try to print these warnings if it is not
9733 possible to write statements to the binary log as it happens when
9734 the execution is inside a function, or generaly speaking, when
9735 the variables.option_bits & OPTION_BIN_LOG is false.
9736 */
9737 if ((variables.option_bits & OPTION_BIN_LOG) &&
9738 sp_runtime_ctx == NULL && !binlog_evt_union.do_union)
9739 {
9740 issue_unsafe_warnings();
9741 order_deterministic= true;

Callers

nothing calls this directly

Calls 2

show_query_typeFunction · 0.85
write_eventMethod · 0.80

Tested by

no test coverage detected