static my_bool process_set_gtid_purged(MYSQL* mysql_con)
{
  MYSQL_RES  *gtid_mode_res;
  MYSQL_ROW  gtid_mode_row;
  char       *gtid_mode_val= 0;
  char buf[32], query[64];

  if (opt_set_gtid_purged_mode == SET_GTID_PURGED_OFF)
    return FALSE;  /* nothing to be done */

  /*
    Check if the server has the knowledge of GTIDs(pre mysql-5.6)
    or if the gtid_mode is ON or OFF.
  */
  my_snprintf(query, sizeof(query), "SHOW VARIABLES LIKE %s",
              quote_for_like("gtid_mode", buf));

  if (mysql_query_with_error_report(mysql_con, &gtid_mode_res, query))
    return TRUE;

  gtid_mode_row = mysql_fetch_row(gtid_mode_res);

  /*
     gtid_mode_row is NULL for pre 5.6 versions. For versions >= 5.6,
     get the gtid_mode value from the second column.
  */
  gtid_mode_val = gtid_mode_row ? (char*)gtid_mode_row[1] : NULL;

  if (gtid_mode_val && strcmp(gtid_mode_val, "OFF"))
  {
    /*
       For any gtid_mode !=OFF and irrespective of --set-gtid-purged
       being AUTO or ON,  add GTID_PURGED in the output.
    */
    if (opt_databases || !opt_alldbs || !opt_dump_triggers
        || !opt_routines || !opt_events)
    {
      fprintf(stderr,"Warning: A partial dump from a server that has GTIDs will "
                     "by default include the GTIDs of all transactions, even "
                     "those that changed suppressed parts of the database. If "
                     "you don't want to restore GTIDs, pass "
                     "--set-gtid-purged=OFF. To make a complete dump, pass "
                     "--all-databases --triggers --routines --events. \n");
    }

    set_session_binlog(FALSE);
    if (add_set_gtid_purged(mysql_con))
      return TRUE;
  }
  else /* gtid_mode is off */
  {
    if (opt_set_gtid_purged_mode == SET_GTID_PURGED_ON)
    {
      fprintf(stderr, "Error: Server has GTIDs disabled.\n");
      return TRUE;
    }
  }

  return FALSE;
}
static my_bool process_set_gtid_purged(MYSQL* mysql_con)
{
  MYSQL_RES  *gtid_mode_res;
  MYSQL_ROW  gtid_mode_row;
  char       *gtid_mode_val= 0;
  char buf[32], query[64];

  if (opt_set_gtid_purged_mode == SET_GTID_PURGED_OFF)
    return FALSE;   

   
  my_snprintf(query, sizeof(query), "SHOW VARIABLES LIKE %s",
              quote_for_like("gtid_mode", buf));

  if (mysql_query_with_error_report(mysql_con, &gtid_mode_res, query))
    return TRUE;

  gtid_mode_row = mysql_fetch_row(gtid_mode_res);

   
  gtid_mode_val = gtid_mode_row ? (char*)gtid_mode_row[1] : NULL;

  if (gtid_mode_val && strcmp(gtid_mode_val, "OFF"))
  {
     
    if (opt_databases || !opt_alldbs || !opt_dump_triggers
        || !opt_routines || !opt_events)
    {
      fprintf(stderr,"Warning: A partial dump from a server that has GTIDs will "
                     "by default include the GTIDs of all transactions, even "
                     "those that changed suppressed parts of the database. If "
                     "you don't want to restore GTIDs, pass "
                     "--set-gtid-purged=OFF. To make a complete dump, pass "
                     "--all-databases --triggers --routines --events. \n");
    }

    set_session_binlog(FALSE);
    if (add_set_gtid_purged(mysql_con))
      return TRUE;
  }
  else  
  {
    if (opt_set_gtid_purged_mode == SET_GTID_PURGED_ON)
    {
      fprintf(stderr, "Error: Server has GTIDs disabled.\n");
      return TRUE;
    }
  }

  return FALSE;
}