| 6837 | */ |
| 6838 | |
| 6839 | bool check_single_table_access(THD *thd, privilege_t privilege, |
| 6840 | TABLE_LIST *tables, bool no_errors) |
| 6841 | { |
| 6842 | if (tables->derived) |
| 6843 | return 0; |
| 6844 | |
| 6845 | Switch_to_definer_security_ctx backup_sctx(thd, tables); |
| 6846 | |
| 6847 | const char *db_name; |
| 6848 | if ((tables->view || tables->field_translation) && !tables->schema_table) |
| 6849 | db_name= tables->view_db.str; |
| 6850 | else |
| 6851 | db_name= tables->db.str; |
| 6852 | |
| 6853 | if (check_access(thd, privilege, db_name, &tables->grant.privilege, |
| 6854 | &tables->grant.m_internal, 0, no_errors)) |
| 6855 | return 1; |
| 6856 | |
| 6857 | /* Show only 1 table for check_grant */ |
| 6858 | if (!(tables->belong_to_view && |
| 6859 | (thd->lex->sql_command == SQLCOM_SHOW_FIELDS)) && |
| 6860 | check_grant(thd, privilege, tables, FALSE, 1, no_errors)) |
| 6861 | return 1; |
| 6862 | |
| 6863 | return 0; |
| 6864 | } |
| 6865 | |
| 6866 | /** |
| 6867 | Check grants for commands which work only with one table and all other |
no test coverage detected