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

Function update_role_table_columns

sql/sql_acl.cc:7015–7061  ·  view source on GitHub ↗

update GRANT_TABLE for a given table and a given role with merged privileges @param merged GRANT_TABLE of the role in question (or NULL if it wasn't found) @param first first GRANT_TABLE in an array for the table in question @param last last entry in the array of GRANT_TABLE's for a given table, all entries between first and last correspond to the *same* table @param pr

Source from the content-addressed store, hash-verified

7013 4 - GRANT_TABLE was deleted
7014*/
7015static int update_role_table_columns(GRANT_TABLE *merged,
7016 GRANT_TABLE **first, GRANT_TABLE **last,
7017 privilege_t privs, privilege_t cols,
7018 const char *role)
7019{
7020 if (!first)
7021 return 0;
7022
7023 DBUG_EXECUTE_IF("role_merge_stats", role_table_merges++;);
7024
7025 if (merged == NULL)
7026 {
7027 /*
7028 there's no GRANT_TABLE for this role (all table grants come from granted
7029 roles) we need to create it
7030 */
7031 DBUG_ASSERT(privs | cols);
7032 merged= new (&grant_memroot) GRANT_TABLE("", first[0]->db, role, first[0]->tname,
7033 privs, cols);
7034 merged->init_privs= merged->init_cols= NO_ACL;
7035 update_role_columns(merged, first, last);
7036 column_priv_insert(merged);
7037 return 2;
7038 }
7039 else if ((privs | cols) == NO_ACL)
7040 {
7041 /*
7042 there is GRANT_TABLE object but the role has no table or column
7043 privileges granted (all privileges were coming from granted roles, and
7044 now those roles were dropped or had their privileges revoked).
7045 we need to remove this GRANT_TABLE
7046 */
7047 DBUG_EXECUTE_IF("role_merge_stats",
7048 role_column_merges+= MY_TEST(merged->cols););
7049 my_hash_delete(&column_priv_hash,(uchar*) merged);
7050 return 4;
7051 }
7052 else
7053 {
7054 bool changed= merged->cols != cols || merged->privs != privs;
7055 merged->cols= cols;
7056 merged->privs= privs;
7057 if (update_role_columns(merged, first, last))
7058 changed= true;
7059 return changed;
7060 }
7061}
7062
7063/**
7064 merges table privileges from roles granted to the role 'grantee'.

Calls 3

update_role_columnsFunction · 0.85
column_priv_insertFunction · 0.85
my_hash_deleteFunction · 0.85

Tested by

no test coverage detected