bool check_single_table_access(THD *thd, ulong privilege, TABLE_LIST *tables,
                               bool no_errors)
{
  if (tables->derived)
    return 0;

  Switch_to_definer_security_ctx backup_sctx(thd, tables);

  const char *db_name;
  if ((tables->view || tables->field_translation) && !tables->schema_table)
    db_name= tables->view_db.str;
  else
    db_name= tables->db.str;

  if (check_access(thd, privilege, db_name, &tables->grant.privilege,
                   &tables->grant.m_internal, 0, no_errors))
    return 1;

  /* Show only 1 table for check_grant */
  if (!(tables->belong_to_view &&
       (thd->lex->sql_command == SQLCOM_SHOW_FIELDS)) &&
      check_grant(thd, privilege, tables, FALSE, 1, no_errors))
    return 1;

  return 0;
}
bool check_single_table_access(THD *thd, ulong privilege, TABLE_LIST *tables,
                               bool no_errors)
{
  if (tables->derived)
    return 0;

  Switch_to_definer_security_ctx backup_sctx(thd, tables);

  const char *db_name;
  if ((tables->view || tables->field_translation) && !tables->schema_table)
    db_name= tables->view_db.str;
  else
    db_name= tables->db.str;

  if (check_access(thd, privilege, db_name, &tables->grant.privilege,
                   &tables->grant.m_internal, 0, no_errors))
    return 1;

   
  if (!(tables->belong_to_view &&
       (thd->lex->sql_command == SQLCOM_SHOW_FIELDS)) &&
      check_grant(thd, privilege, tables, FALSE, 1, no_errors))
    return 1;

  return 0;
}