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

Function get_column_grant

sql/sql_acl.cc:9245–9297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9243*/
9244
9245privilege_t get_column_grant(THD *thd, GRANT_INFO *grant,
9246 const char *db_name, const char *table_name,
9247 const Lex_ident_column &field_name)
9248{
9249 GRANT_TABLE *grant_table;
9250 GRANT_TABLE *grant_table_role;
9251 GRANT_TABLE *grant_public;
9252 GRANT_COLUMN *grant_column;
9253 privilege_t priv(NO_ACL);
9254
9255 mysql_rwlock_rdlock(&LOCK_grant);
9256 /* reload table if someone has modified any grants */
9257 grant->refresh(thd->security_ctx, db_name, table_name);
9258
9259 grant_table= grant->grant_table_user;
9260 grant_table_role= grant->grant_table_role;
9261 grant_public= grant->grant_public;
9262
9263 if (!grant_table && !grant_table_role && !grant_public)
9264 priv= grant->privilege;
9265 else
9266 {
9267 if (grant_table)
9268 {
9269 grant_column= column_hash_search(grant_table, field_name);
9270 if (!grant_column)
9271 priv= (grant->privilege | grant_table->privs);
9272 else
9273 priv= (grant->privilege | grant_table->privs | grant_column->rights);
9274 }
9275
9276 if (grant_table_role)
9277 {
9278 grant_column= column_hash_search(grant_table_role, field_name);
9279 if (!grant_column)
9280 priv|= (grant->privilege | grant_table_role->privs);
9281 else
9282 priv|= (grant->privilege | grant_table_role->privs |
9283 grant_column->rights);
9284 }
9285 if (grant_public)
9286 {
9287 grant_column= column_hash_search(grant_public, field_name);
9288 if (!grant_column)
9289 priv|= (grant->privilege | grant_public->privs);
9290 else
9291 priv|= (grant->privilege | grant_public->privs |
9292 grant_column->rights);
9293 }
9294 }
9295 mysql_rwlock_unlock(&LOCK_grant);
9296 return priv;
9297}
9298
9299
9300/* Help function for mysql_show_grants */

Callers 9

get_schema_column_recordFunction · 0.85
get_schema_stat_recordFunction · 0.85
insert_fieldsFunction · 0.85
mysql_create_viewFunction · 0.85
fix_fieldsMethod · 0.85

Calls 2

column_hash_searchFunction · 0.85
refreshMethod · 0.80

Tested by

no test coverage detected