mysql 复制命令源码(二)--show master status

sql文件里sql_repl.cc中

/**

  Execute a SHOW MASTER STATUS statement.


  @param thd Pointer to THD object for the client thread executing the

  statement.


  @retval FALSE success

  @retval TRUE failure

*/

bool show_binlog_info(THD* thd)

{

  Protocol *protocol= thd->protocol;

  DBUG_ENTER("show_binlog_info");

  List<Item> field_list;

  field_list.push_back(new Item_empty_string("File", FN_REFLEN));

  field_list.push_back(new Item_return_int("Position",20,

  MYSQL_TYPE_LONGLONG));

  field_list.push_back(new Item_empty_string("Binlog_Do_DB",255));

  field_list.push_back(new Item_empty_string("Binlog_Ignore_DB",255));


  if (protocol->send_result_set_metadata(&field_list,

                            Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))

    DBUG_RETURN(TRUE);

  protocol->prepare_for_resend();


  if (mysql_bin_log.is_open())

  {

    LOG_INFO li;

    mysql_bin_log.get_current_log(&li);

    int dir_len = dirname_length(li.log_file_name);

    protocol->store(li.log_file_name + dir_len, &my_charset_bin);

    protocol->store((ulonglong) li.pos);

    protocol->store(binlog_filter->get_do_db());

    protocol->store(binlog_filter->get_ignore_db());

    if (protocol->write())

      DBUG_RETURN(TRUE);

  }

  my_eof(thd);

  DBUG_RETURN(FALSE);

}


你可能感兴趣的:(thread,protocol,master,success,failure)