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

Function update_role_columns

sql/sql_acl.cc:6942–6997  ·  view source on GitHub ↗

merges column privileges for the entry 'merged' @param merged GRANT_TABLE to merge the privileges into @param cur first entry in the array of GRANT_TABLE's for a given table @param last last entry in the array of GRANT_TABLE's for a given table, all entries between cur and last correspond to the *same* table @return 1 if the _set of columns_ in 'merged' was changed

Source from the content-addressed store, hash-verified

6940 (not if the _set of privileges_ was changed).
6941*/
6942static int update_role_columns(GRANT_TABLE *merged,
6943 GRANT_TABLE **cur, GRANT_TABLE **last)
6944{
6945 privilege_t rights __attribute__((unused)) (NO_ACL);
6946 int changed= 0;
6947 if (!merged->cols)
6948 {
6949 changed= merged->hash_columns.records > 0;
6950 my_hash_reset(&merged->hash_columns);
6951 return changed;
6952 }
6953
6954 DBUG_EXECUTE_IF("role_merge_stats", role_column_merges++;);
6955
6956 HASH *mh= &merged->hash_columns;
6957 for (uint i=0 ; i < mh->records ; i++)
6958 {
6959 GRANT_COLUMN *col = (GRANT_COLUMN *)my_hash_element(mh, i);
6960 col->rights= col->init_rights;
6961 }
6962
6963 for (; cur < last; cur++)
6964 {
6965 if (*cur == merged)
6966 continue;
6967 HASH *ch= &cur[0]->hash_columns;
6968 for (uint i=0 ; i < ch->records ; i++)
6969 {
6970 GRANT_COLUMN *ccol = (GRANT_COLUMN *)my_hash_element(ch, i);
6971 GRANT_COLUMN *mcol = (GRANT_COLUMN *)my_hash_search(mh,
6972 (uchar *)ccol->column, ccol->key_length);
6973 if (mcol)
6974 mcol->rights|= ccol->rights;
6975 else
6976 {
6977 changed= 1;
6978 my_hash_insert(mh, (uchar*)new (&grant_memroot) GRANT_COLUMN(ccol));
6979 }
6980 }
6981 }
6982
6983restart:
6984 for (uint i=0 ; i < mh->records ; i++)
6985 {
6986 GRANT_COLUMN *col = (GRANT_COLUMN *)my_hash_element(mh, i);
6987 rights|= col->rights;
6988 if (!col->rights)
6989 {
6990 changed= 1;
6991 my_hash_delete(mh, (uchar*)col);
6992 goto restart;
6993 }
6994 }
6995 DBUG_ASSERT(rights == merged->cols);
6996 return changed;
6997}
6998
6999/**

Callers 1

Calls 5

my_hash_resetFunction · 0.85
my_hash_elementFunction · 0.85
my_hash_searchFunction · 0.85
my_hash_insertFunction · 0.85
my_hash_deleteFunction · 0.85

Tested by

no test coverage detected