MCPcopy Create free account
hub / github.com/MariaDB/server / check_table_access

Function check_table_access

sql/sql_parse.cc:7033–7083  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7031*/
7032
7033bool
7034check_table_access(THD *thd, privilege_t requirements, TABLE_LIST *tables,
7035 bool any_combination_of_privileges_will_do,
7036 uint number, bool no_errors)
7037{
7038 TABLE_LIST *org_tables= tables;
7039 TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
7040 uint i= 0;
7041 /*
7042 The check that first_not_own_table is not reached is for the case when
7043 the given table list refers to the list for prelocking (contains tables
7044 of other queries). For simple queries first_not_own_table is 0.
7045 */
7046 for (; i < number && tables != first_not_own_table && tables;
7047 tables= tables->next_global, i++)
7048 {
7049 TABLE_LIST *const table_ref= tables->correspondent_table ?
7050 tables->correspondent_table : tables;
7051 Switch_to_definer_security_ctx backup_ctx(thd, table_ref);
7052
7053 privilege_t want_access(requirements);
7054
7055 /*
7056 Register access for view underlying table.
7057 Remove SHOW_VIEW_ACL, because it will be checked during making view
7058 */
7059 table_ref->grant.orig_want_privilege= (want_access & ~SHOW_VIEW_ACL);
7060
7061 if (table_ref->schema_table_reformed)
7062 {
7063 if (check_show_access(thd, table_ref))
7064 return 1;
7065 continue;
7066 }
7067
7068 DBUG_PRINT("info", ("derived: %d view: %d", table_ref->derived != 0,
7069 table_ref->view != 0));
7070
7071 if (table_ref->is_anonymous_derived_table() || table_ref->sequence)
7072 continue;
7073
7074 if (check_access(thd, want_access, table_ref->get_db_name().str,
7075 &table_ref->grant.privilege,
7076 &table_ref->grant.m_internal,
7077 0, no_errors))
7078 return 1;
7079 }
7080 return check_grant(thd,requirements,org_tables,
7081 any_combination_of_privileges_will_do,
7082 number, no_errors);
7083}
7084
7085
7086bool

Callers 7

sql_parse.ccFile · 0.70
executeMethod · 0.70
execute_show_statusFunction · 0.70
check_one_table_accessFunction · 0.70
multi_delete_precheckFunction · 0.70
create_table_precheckFunction · 0.70
lock_tables_precheckFunction · 0.70

Calls 6

check_show_accessFunction · 0.85
check_grantFunction · 0.85
first_not_own_tableMethod · 0.80
check_accessFunction · 0.70
get_db_nameMethod · 0.45

Tested by

no test coverage detected