mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Removed init_hash_columns hash and instead added an init_rights field
to the hash_columns' original elements (GRANT_COLUMN)
This commit is contained in:
committed by
Sergei Golubchik
parent
6f9d26f09f
commit
1aedd4a585
@ -2484,11 +2484,8 @@ void merge_role_grant_privileges(ACL_ROLE *target, ACL_ROLE *source)
|
|||||||
delete_dynamic(&source_dbs);
|
delete_dynamic(&source_dbs);
|
||||||
delete_dynamic(&target_dbs);
|
delete_dynamic(&target_dbs);
|
||||||
|
|
||||||
/* Merge table privileges */
|
/* Merge table and column privileges */
|
||||||
/* TODO */
|
|
||||||
|
|
||||||
/* Merge column privileges */
|
|
||||||
/* TODO */
|
|
||||||
|
|
||||||
/* Merge function and procedure privileges */
|
/* Merge function and procedure privileges */
|
||||||
/* TODO */
|
/* TODO */
|
||||||
@ -3901,8 +3898,9 @@ class GRANT_COLUMN :public Sql_alloc
|
|||||||
public:
|
public:
|
||||||
char *column;
|
char *column;
|
||||||
ulong rights;
|
ulong rights;
|
||||||
|
ulong init_rights;
|
||||||
uint key_length;
|
uint key_length;
|
||||||
GRANT_COLUMN(String &c, ulong y) :rights (y)
|
GRANT_COLUMN(String &c, ulong y) :rights (y), init_rights(y)
|
||||||
{
|
{
|
||||||
column= (char*) memdup_root(&memex,c.ptr(), key_length=c.length());
|
column= (char*) memdup_root(&memex,c.ptr(), key_length=c.length());
|
||||||
}
|
}
|
||||||
@ -3943,7 +3941,6 @@ public:
|
|||||||
ulong cols;
|
ulong cols;
|
||||||
ulong init_cols; /* privileges found in physical table */
|
ulong init_cols; /* privileges found in physical table */
|
||||||
HASH hash_columns;
|
HASH hash_columns;
|
||||||
HASH init_hash_columns;
|
|
||||||
|
|
||||||
GRANT_TABLE(const char *h, const char *d,const char *u,
|
GRANT_TABLE(const char *h, const char *d,const char *u,
|
||||||
const char *t, ulong p, ulong c);
|
const char *t, ulong p, ulong c);
|
||||||
@ -3991,9 +3988,6 @@ GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u,
|
|||||||
{
|
{
|
||||||
(void) my_hash_init2(&hash_columns,4,system_charset_info,
|
(void) my_hash_init2(&hash_columns,4,system_charset_info,
|
||||||
0,0,0, (my_hash_get_key) get_key_column,0,0);
|
0,0,0, (my_hash_get_key) get_key_column,0,0);
|
||||||
(void) my_hash_init2(&init_hash_columns,4,system_charset_info,
|
|
||||||
0,0,0, (my_hash_get_key) get_key_column,0,0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4054,12 +4048,6 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
|
|||||||
(void) my_hash_init2(&hash_columns,4,system_charset_info,
|
(void) my_hash_init2(&hash_columns,4,system_charset_info,
|
||||||
0,0,0, (my_hash_get_key) get_key_column,0,0);
|
0,0,0, (my_hash_get_key) get_key_column,0,0);
|
||||||
|
|
||||||
/*
|
|
||||||
The same inheritance scheme is true for hash_columns in case of roles.
|
|
||||||
Init_hash_columns always holds the init_hash_columns
|
|
||||||
*/
|
|
||||||
(void) my_hash_init2(&init_hash_columns,4,system_charset_info,
|
|
||||||
0,0,0, (my_hash_get_key) get_key_column,0,0);
|
|
||||||
if (cols)
|
if (cols)
|
||||||
{
|
{
|
||||||
uint key_prefix_len;
|
uint key_prefix_len;
|
||||||
@ -4115,21 +4103,6 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
|
|||||||
privs= cols= init_privs= init_cols=0;
|
privs= cols= init_privs= init_cols=0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add an entry into the init_hash_columns hash aswell */
|
|
||||||
if (!(mem_check = new GRANT_COLUMN(*res,
|
|
||||||
fix_rights_for_column(priv))))
|
|
||||||
{
|
|
||||||
/* Don't use this entry */
|
|
||||||
privs= cols= init_privs= init_cols=0; /* purecov: deadcode */
|
|
||||||
return; /* purecov: deadcode */
|
|
||||||
}
|
|
||||||
if (my_hash_insert(&init_hash_columns, (uchar *) mem_check))
|
|
||||||
{
|
|
||||||
/* Invalidate this entry */
|
|
||||||
privs= cols= init_privs= init_cols=0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} while (!col_privs->file->ha_index_next(col_privs->record[0]) &&
|
} while (!col_privs->file->ha_index_next(col_privs->record[0]) &&
|
||||||
!key_cmp_if_same(col_privs,key,0,key_prefix_len));
|
!key_cmp_if_same(col_privs,key,0,key_prefix_len));
|
||||||
col_privs->file->ha_index_end();
|
col_privs->file->ha_index_end();
|
||||||
@ -4140,7 +4113,6 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
|
|||||||
GRANT_TABLE::~GRANT_TABLE()
|
GRANT_TABLE::~GRANT_TABLE()
|
||||||
{
|
{
|
||||||
my_hash_free(&hash_columns);
|
my_hash_free(&hash_columns);
|
||||||
my_hash_free(&init_hash_columns);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4410,7 +4382,10 @@ static int replace_column_table(GRANT_TABLE *g_t,
|
|||||||
goto end; /* purecov: deadcode */
|
goto end; /* purecov: deadcode */
|
||||||
}
|
}
|
||||||
if (grant_column)
|
if (grant_column)
|
||||||
grant_column->rights = privileges; // Update hash
|
{
|
||||||
|
grant_column->rights = privileges; // Update hash
|
||||||
|
grant_column->init_rights = privileges;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -7045,10 +7020,7 @@ static bool show_table_and_column_privileges(THD *thd,
|
|||||||
{
|
{
|
||||||
uint found_col= 0;
|
uint found_col= 0;
|
||||||
HASH *hash_columns;
|
HASH *hash_columns;
|
||||||
if (handle_as_role)
|
hash_columns= &grant_table->hash_columns;
|
||||||
hash_columns= &grant_table->init_hash_columns;
|
|
||||||
else
|
|
||||||
hash_columns= &grant_table->hash_columns;
|
|
||||||
|
|
||||||
for (uint col_index=0 ;
|
for (uint col_index=0 ;
|
||||||
col_index < hash_columns->records ;
|
col_index < hash_columns->records ;
|
||||||
@ -7056,7 +7028,8 @@ static bool show_table_and_column_privileges(THD *thd,
|
|||||||
{
|
{
|
||||||
GRANT_COLUMN *grant_column = (GRANT_COLUMN*)
|
GRANT_COLUMN *grant_column = (GRANT_COLUMN*)
|
||||||
my_hash_element(hash_columns,col_index);
|
my_hash_element(hash_columns,col_index);
|
||||||
if (grant_column->rights & j)
|
if ((!handle_as_role && (grant_column->rights & j)) ||
|
||||||
|
(handle_as_role && (grant_column->init_rights & j)))
|
||||||
{
|
{
|
||||||
if (!found_col)
|
if (!found_col)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user