| 1063 | */ |
| 1064 | |
| 1065 | int write_bin_log(THD *thd, bool clear_error, |
| 1066 | char const *query, ulong query_length, bool is_trans) |
| 1067 | { |
| 1068 | int error= 0; // No logging of query |
| 1069 | if (mysql_bin_log.is_open()) |
| 1070 | { |
| 1071 | int errcode= 0; |
| 1072 | thd_proc_info(thd, "Writing to binlog"); |
| 1073 | if (clear_error) |
| 1074 | { |
| 1075 | if (global_system_variables.log_warnings > 2) |
| 1076 | { |
| 1077 | uint err_clear= thd->is_error() ? thd->get_stmt_da()->sql_errno() : 0; |
| 1078 | if (err_clear) |
| 1079 | sql_print_warning("Error code %d of query '%s' is cleared at its " |
| 1080 | "binary logging.", err_clear, query); |
| 1081 | } |
| 1082 | thd->clear_error(); |
| 1083 | } |
| 1084 | else |
| 1085 | errcode= query_error_code(thd, TRUE); |
| 1086 | error= thd->binlog_query(THD::STMT_QUERY_TYPE, |
| 1087 | query, query_length, is_trans, FALSE, FALSE, |
| 1088 | errcode) > 0; |
| 1089 | thd_proc_info(thd, 0); |
| 1090 | } |
| 1091 | return error; |
| 1092 | } |
| 1093 | |
| 1094 | |
| 1095 | /** |
no test coverage detected