diff options
author | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2008-12-23 18:56:08 +0400 |
---|---|---|
committer | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2008-12-23 18:56:08 +0400 |
commit | e138336894c047298b10c476f961e57abb9faf75 (patch) | |
tree | 427c50d88a9295fee1de073c72138ccb3866bb7b /sql/sql_acl.cc | |
parent | c06df92af647e67731cb3a76bd91d57219407f01 (diff) | |
download | mariadb-git-e138336894c047298b10c476f961e57abb9faf75.tar.gz |
Bug#41079 information_schema.schema_privileges is limited to 7680 records.
The problem is that we cannot insert new record into memory table
when table size exceeds max memory table size.
The fix is to use schema_table_store_record() function which
converts memory table into MyISAM in case of table size exceeding.
Note:
There is no test case for this bug, the reason is that
1. The code that was added already is checked(i.e. works) with existing tests
2. Correct work of schema_table_store_record() is checked with other test cases
(information_schema tests)
So new code is fully covered with existing test cases.
sql/mysql_priv.h:
make schema_table_store_record() function global
sql/sql_acl.cc:
The problem is that we cannot insert new record into memory table
when table size exceeds max memory table size.
The fix is to use schema_table_store_record() function which
converts memory table into MyISAM in case of table size exceeding.
sql/sql_show.cc:
make schema_table_store_record() function global
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r-- | sql/sql_acl.cc | 119 |
1 files changed, 84 insertions, 35 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index df5e844749f..57029f46162 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5953,10 +5953,11 @@ int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr) } -void update_schema_privilege(TABLE *table, char *buff, const char* db, - const char* t_name, const char* column, - uint col_length, const char *priv, - uint priv_length, const char* is_grantable) +static bool update_schema_privilege(THD *thd, TABLE *table, char *buff, + const char* db, const char* t_name, + const char* column, uint col_length, + const char *priv, uint priv_length, + const char* is_grantable) { int i= 2; CHARSET_INFO *cs= system_charset_info; @@ -5970,13 +5971,14 @@ void update_schema_privilege(TABLE *table, char *buff, const char* db, table->field[i++]->store(column, col_length, cs); table->field[i++]->store(priv, priv_length, cs); table->field[i]->store(is_grantable, strlen(is_grantable), cs); - table->file->write_row(table->record[0]); + return schema_table_store_record(thd, table); } int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond) { #ifndef NO_EMBEDDED_ACCESS_CHECKS + int error= 0; uint counter; ACL_USER *acl_user; ulong want_access; @@ -6010,8 +6012,14 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond) strxmov(buff,"'",user,"'@'",host,"'",NullS); if (!(want_access & ~GRANT_ACL)) - update_schema_privilege(table, buff, 0, 0, 0, 0, - STRING_WITH_LEN("USAGE"), is_grantable); + { + if (update_schema_privilege(thd, table, buff, 0, 0, 0, 0, + STRING_WITH_LEN("USAGE"), is_grantable)) + { + error= 1; + goto err; + } + } else { uint priv_id; @@ -6019,16 +6027,22 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond) for (priv_id=0, j = SELECT_ACL;j <= GLOBAL_ACLS; priv_id++,j <<= 1) { if (test_access & j) - update_schema_privilege(table, buff, 0, 0, 0, 0, - command_array[priv_id], - command_lengths[priv_id], is_grantable); + { + if (update_schema_privilege(thd, table, buff, 0, 0, 0, 0, + command_array[priv_id], + command_lengths[priv_id], is_grantable)) + { + error= 1; + goto err; + } + } } } } - +err: pthread_mutex_unlock(&acl_cache->lock); - DBUG_RETURN(0); + DBUG_RETURN(error); #else return(0); #endif @@ -6038,6 +6052,7 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond) int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond) { #ifndef NO_EMBEDDED_ACCESS_CHECKS + int error= 0; uint counter; ACL_DB *acl_db; ulong want_access; @@ -6075,24 +6090,36 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond) } strxmov(buff,"'",user,"'@'",host,"'",NullS); if (!(want_access & ~GRANT_ACL)) - update_schema_privilege(table, buff, acl_db->db, 0, 0, - 0, STRING_WITH_LEN("USAGE"), is_grantable); + { + if (update_schema_privilege(thd, table, buff, acl_db->db, 0, 0, + 0, STRING_WITH_LEN("USAGE"), is_grantable)) + { + error= 1; + goto err; + } + } else { int cnt; ulong j,test_access= want_access & ~GRANT_ACL; for (cnt=0, j = SELECT_ACL; j <= DB_ACLS; cnt++,j <<= 1) if (test_access & j) - update_schema_privilege(table, buff, acl_db->db, 0, 0, 0, - command_array[cnt], command_lengths[cnt], - is_grantable); + { + if (update_schema_privilege(thd, table, buff, acl_db->db, 0, 0, 0, + command_array[cnt], command_lengths[cnt], + is_grantable)) + { + error= 1; + goto err; + } + } } } } - +err: pthread_mutex_unlock(&acl_cache->lock); - DBUG_RETURN(0); + DBUG_RETURN(error); #else return (0); #endif @@ -6102,6 +6129,7 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond) int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond) { #ifndef NO_EMBEDDED_ACCESS_CHECKS + int error= 0; uint index; char buff[100]; TABLE *table= tables->table; @@ -6141,8 +6169,15 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond) strxmov(buff, "'", user, "'@'", host, "'", NullS); if (!test_access) - update_schema_privilege(table, buff, grant_table->db, grant_table->tname, - 0, 0, STRING_WITH_LEN("USAGE"), is_grantable); + { + if (update_schema_privilege(thd, table, buff, grant_table->db, + grant_table->tname, 0, 0, + STRING_WITH_LEN("USAGE"), is_grantable)) + { + error= 1; + goto err; + } + } else { ulong j; @@ -6150,17 +6185,24 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond) for (cnt= 0, j= SELECT_ACL; j <= TABLE_ACLS; cnt++, j<<= 1) { if (test_access & j) - update_schema_privilege(table, buff, grant_table->db, - grant_table->tname, 0, 0, command_array[cnt], - command_lengths[cnt], is_grantable); + { + if (update_schema_privilege(thd, table, buff, grant_table->db, + grant_table->tname, 0, 0, + command_array[cnt], + command_lengths[cnt], is_grantable)) + { + error= 1; + goto err; + } + } } } - } + } } - +err: rw_unlock(&LOCK_grant); - DBUG_RETURN(0); + DBUG_RETURN(error); #else return (0); #endif @@ -6170,6 +6212,7 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond) int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond) { #ifndef NO_EMBEDDED_ACCESS_CHECKS + int error= 0; uint index; char buff[100]; TABLE *table= tables->table; @@ -6219,22 +6262,28 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond) GRANT_COLUMN *grant_column = (GRANT_COLUMN*) hash_element(&grant_table->hash_columns,col_index); if ((grant_column->rights & j) && (table_access & j)) - update_schema_privilege(table, buff, grant_table->db, - grant_table->tname, - grant_column->column, - grant_column->key_length, - command_array[cnt], - command_lengths[cnt], is_grantable); + { + if (update_schema_privilege(thd, table, buff, grant_table->db, + grant_table->tname, + grant_column->column, + grant_column->key_length, + command_array[cnt], + command_lengths[cnt], is_grantable)) + { + error= 1; + goto err; + } + } } } } } } } - +err: rw_unlock(&LOCK_grant); - DBUG_RETURN(0); + DBUG_RETURN(error); #else return (0); #endif |