MCPcopy Create free account
hub / github.com/Tencent/phxsql / mysql_table_grant

Function mysql_table_grant

phx_percona/percona/sql/sql_acl.cc:4634–4961  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4632*/
4633
4634int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
4635 List <LEX_USER> &user_list,
4636 List <LEX_COLUMN> &columns, ulong rights,
4637 bool revoke_grant)
4638{
4639 ulong column_priv= 0;
4640 List_iterator <LEX_USER> str_list (user_list);
4641 LEX_USER *Str, *tmp_Str;
4642 TABLE_LIST tables[3];
4643 bool create_new_users=0;
4644 char *db_name, *table_name;
4645 bool save_binlog_row_based;
4646 bool transactional_tables;
4647 DBUG_ENTER("mysql_table_grant");
4648
4649 if (!initialized)
4650 {
4651 my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0),
4652 "--skip-grant-tables"); /* purecov: inspected */
4653 DBUG_RETURN(TRUE); /* purecov: inspected */
4654 }
4655 if (rights & ~TABLE_ACLS)
4656 {
4657 my_message(ER_ILLEGAL_GRANT_FOR_TABLE, ER(ER_ILLEGAL_GRANT_FOR_TABLE),
4658 MYF(0));
4659 DBUG_RETURN(TRUE);
4660 }
4661
4662 if (!revoke_grant)
4663 {
4664 if (columns.elements)
4665 {
4666 class LEX_COLUMN *column;
4667 List_iterator <LEX_COLUMN> column_iter(columns);
4668
4669 if (open_normal_and_derived_tables(thd, table_list, 0))
4670 DBUG_RETURN(TRUE);
4671
4672 while ((column = column_iter++))
4673 {
4674 uint unused_field_idx= NO_CACHED_FIELD_INDEX;
4675 TABLE_LIST *dummy;
4676 Field *f=find_field_in_table_ref(thd, table_list, column->column.ptr(),
4677 column->column.length(),
4678 column->column.ptr(), NULL, NULL,
4679 NULL, TRUE, FALSE,
4680 &unused_field_idx, FALSE, &dummy);
4681 if (f == (Field*)0)
4682 {
4683 my_error(ER_BAD_FIELD_ERROR, MYF(0),
4684 column->column.c_ptr(), table_list->alias);
4685 DBUG_RETURN(TRUE);
4686 }
4687 if (f == (Field *)-1)
4688 DBUG_RETURN(TRUE);
4689 column_priv|= column->rights;
4690 }
4691 close_mysql_tables(thd);

Callers

nothing calls this directly

Calls 10

get_privilege_descFunction · 0.85
test_if_create_new_usersFunction · 0.85
replace_user_tableFunction · 0.85
table_hash_searchFunction · 0.85
column_hash_searchFunction · 0.85
replace_table_tableFunction · 0.85
replace_column_tableFunction · 0.85
write_incidentMethod · 0.80

Tested by

no test coverage detected