1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Manual merge/pull from mysql-next-mr.

Conflicts:
  - sql/sql_insert.cc
This commit is contained in:
Alexander Nozdrin
2009-11-25 18:03:05 +03:00
161 changed files with 1611 additions and 1362 deletions

View File

@ -325,7 +325,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
init_read_record(&read_record_info,thd,table= tables[0].table,NULL,1,0,
FALSE);
table->use_all_columns();
VOID(my_init_dynamic_array(&acl_hosts,sizeof(ACL_HOST),20,50));
(void) my_init_dynamic_array(&acl_hosts,sizeof(ACL_HOST),20,50);
while (!(read_record_info.read_record(&read_record_info)))
{
ACL_HOST host;
@ -365,7 +365,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
host.access|=REFERENCES_ACL | INDEX_ACL | ALTER_ACL | CREATE_TMP_ACL;
}
#endif
VOID(push_dynamic(&acl_hosts,(uchar*) &host));
(void) push_dynamic(&acl_hosts,(uchar*) &host);
}
my_qsort((uchar*) dynamic_element(&acl_hosts,0,ACL_HOST*),acl_hosts.elements,
sizeof(ACL_HOST),(qsort_cmp) acl_compare);
@ -374,7 +374,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
init_read_record(&read_record_info,thd,table=tables[1].table,NULL,1,0,FALSE);
table->use_all_columns();
VOID(my_init_dynamic_array(&acl_users,sizeof(ACL_USER),50,100));
(void) my_init_dynamic_array(&acl_users,sizeof(ACL_USER),50,100);
password_length= table->field[2]->field_length /
table->field[2]->charset()->mbmaxlen;
if (password_length < SCRAMBLED_PASSWORD_CHAR_LENGTH_323)
@ -549,7 +549,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
user.access|= SUPER_ACL | EXECUTE_ACL;
#endif
}
VOID(push_dynamic(&acl_users,(uchar*) &user));
(void) push_dynamic(&acl_users,(uchar*) &user);
if (!user.host.hostname ||
(user.host.hostname[0] == wild_many && !user.host.hostname[1]))
allow_all_hosts=1; // Anyone can connect
@ -562,7 +562,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
init_read_record(&read_record_info,thd,table=tables[2].table,NULL,1,0,FALSE);
table->use_all_columns();
VOID(my_init_dynamic_array(&acl_dbs,sizeof(ACL_DB),50,100));
(void) my_init_dynamic_array(&acl_dbs,sizeof(ACL_DB),50,100);
while (!(read_record_info.read_record(&read_record_info)))
{
ACL_DB db;
@ -612,7 +612,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
db.access|=REFERENCES_ACL | INDEX_ACL | ALTER_ACL;
}
#endif
VOID(push_dynamic(&acl_dbs,(uchar*) &db));
(void) push_dynamic(&acl_dbs,(uchar*) &db);
}
my_qsort((uchar*) dynamic_element(&acl_dbs,0,ACL_DB*),acl_dbs.elements,
sizeof(ACL_DB),(qsort_cmp) acl_compare);
@ -705,7 +705,7 @@ my_bool acl_reload(THD *thd)
}
if ((old_initialized=initialized))
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
old_acl_hosts=acl_hosts;
old_acl_users=acl_users;
@ -732,7 +732,7 @@ my_bool acl_reload(THD *thd)
delete_dynamic(&old_acl_dbs);
}
if (old_initialized)
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
end:
close_thread_tables(thd);
DBUG_RETURN(return_val);
@ -884,7 +884,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh,
DBUG_RETURN(0);
}
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
/*
Find acl entry in user database. Note, that find_acl_user is not the same,
@ -1063,7 +1063,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh,
else
*sctx->priv_host= 0;
}
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
DBUG_RETURN(res);
}
@ -1110,7 +1110,7 @@ bool acl_getroot_no_password(Security_context *sctx, char *user, char *host,
DBUG_RETURN(FALSE);
}
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
sctx->master_access= 0;
sctx->db_access= 0;
@ -1164,7 +1164,7 @@ bool acl_getroot_no_password(Security_context *sctx, char *user, char *host,
else
*sctx->priv_host= 0;
}
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
DBUG_RETURN(res);
}
@ -1253,7 +1253,7 @@ static void acl_insert_user(const char *user, const char *host,
set_user_salt(&acl_user, password, password_len);
VOID(push_dynamic(&acl_users,(uchar*) &acl_user));
(void) push_dynamic(&acl_users,(uchar*) &acl_user);
if (!acl_user.host.hostname ||
(acl_user.host.hostname[0] == wild_many && !acl_user.host.hostname[1]))
allow_all_hosts=1; // Anyone can connect /* purecov: tested */
@ -1319,7 +1319,7 @@ static void acl_insert_db(const char *user, const char *host, const char *db,
acl_db.db=strdup_root(&mem,db);
acl_db.access=privileges;
acl_db.sort=get_sort(3,acl_db.host.hostname,acl_db.db,acl_db.user);
VOID(push_dynamic(&acl_dbs,(uchar*) &acl_db));
(void) push_dynamic(&acl_dbs,(uchar*) &acl_db);
my_qsort((uchar*) dynamic_element(&acl_dbs,0,ACL_DB*),acl_dbs.elements,
sizeof(ACL_DB),(qsort_cmp) acl_compare);
}
@ -1343,7 +1343,7 @@ ulong acl_get(const char *host, const char *ip,
acl_entry *entry;
DBUG_ENTER("acl_get");
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
end=strmov((tmp_db=strmov(strmov(key, ip ? ip : "")+1,user)+1),db);
if (lower_case_table_names)
{
@ -1355,7 +1355,7 @@ ulong acl_get(const char *host, const char *ip,
key_length)))
{
db_access=entry->access;
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
DBUG_PRINT("exit", ("access: 0x%lx", db_access));
DBUG_RETURN(db_access);
}
@ -1409,7 +1409,7 @@ exit:
memcpy((uchar*) entry->key,key,key_length);
acl_cache->add(entry);
}
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
DBUG_PRINT("exit", ("access: 0x%lx", db_access & host_access));
DBUG_RETURN(db_access & host_access);
}
@ -1425,10 +1425,11 @@ exit:
static void init_check_host(void)
{
DBUG_ENTER("init_check_host");
VOID(my_init_dynamic_array(&acl_wild_hosts,sizeof(struct acl_host_and_ip),
acl_users.elements,1));
VOID(my_hash_init(&acl_check_hosts,system_charset_info,acl_users.elements,0,0,
(my_hash_get_key) check_get_key,0,0));
(void) my_init_dynamic_array(&acl_wild_hosts,sizeof(struct acl_host_and_ip),
acl_users.elements,1);
(void) my_hash_init(&acl_check_hosts,system_charset_info,
acl_users.elements, 0, 0,
(my_hash_get_key) check_get_key, 0, 0);
if (!allow_all_hosts)
{
for (uint i=0 ; i < acl_users.elements ; i++)
@ -1490,12 +1491,12 @@ bool acl_check_host(const char *host, const char *ip)
{
if (allow_all_hosts)
return 0;
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
if ((host && my_hash_search(&acl_check_hosts,(uchar*) host,strlen(host))) ||
(ip && my_hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip))))
{
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
return 0; // Found host
}
for (uint i=0 ; i < acl_wild_hosts.elements ; i++)
@ -1503,11 +1504,11 @@ bool acl_check_host(const char *host, const char *ip)
acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,i,acl_host_and_ip*);
if (compare_hostname(acl, host, ip))
{
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
return 0; // Host ok
}
}
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
return 1; // Host is not allowed
}
@ -1621,11 +1622,11 @@ bool change_password(THD *thd, const char *host, const char *user,
if (!(table= open_ltable(thd, &tables, TL_WRITE, 0)))
DBUG_RETURN(1);
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
ACL_USER *acl_user;
if (!(acl_user= find_acl_user(host, user, TRUE)))
{
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), MYF(0));
goto end;
}
@ -1637,12 +1638,12 @@ bool change_password(THD *thd, const char *host, const char *user,
acl_user->user ? acl_user->user : "",
new_password, new_password_len))
{
VOID(pthread_mutex_unlock(&acl_cache->lock)); /* purecov: deadcode */
pthread_mutex_unlock(&acl_cache->lock); /* purecov: deadcode */
goto end;
}
acl_cache->clear(1); // Clear locked hostname cache
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
result= 0;
if (mysql_bin_log.is_open())
{
@ -1683,9 +1684,9 @@ bool is_acl_user(const char *host, const char *user)
if (!initialized)
return TRUE;
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
res= find_acl_user(host, user, TRUE) != NULL;
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
return res;
}
@ -3443,7 +3444,7 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
/* go through users in user_list */
rw_wrlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
grant_version++;
int result=0;
@ -3475,7 +3476,7 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
}
}
}
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
if (!result)
{
@ -4634,12 +4635,12 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
}
rw_rdlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
acl_user= find_acl_user(lex_user->host.str, lex_user->user.str, TRUE);
if (!acl_user)
{
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
rw_unlock(&LOCK_grant);
my_error(ER_NONEXISTING_GRANT, MYF(0),
@ -4657,7 +4658,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
{
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
rw_unlock(&LOCK_grant);
DBUG_RETURN(TRUE);
@ -4968,7 +4969,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
}
end:
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
rw_unlock(&LOCK_grant);
my_eof(thd);
@ -5766,7 +5767,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
DBUG_RETURN(result != 1);
rw_wrlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
while ((tmp_user_name= user_list++))
{
@ -5796,7 +5797,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
}
}
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
if (result)
my_error(ER_CANNOT_USER, MYF(0), "CREATE USER", wrong_users.c_ptr_safe());
@ -5848,7 +5849,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
rw_wrlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
while ((tmp_user_name= user_list++))
{
@ -5869,7 +5870,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
rebuild_check_host();
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
if (result)
my_error(ER_CANNOT_USER, MYF(0), "DROP USER", wrong_users.c_ptr_safe());
@ -5920,7 +5921,7 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
DBUG_RETURN(result != 1);
rw_wrlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
while ((tmp_user_from= user_list++))
{
@ -5954,7 +5955,7 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
rebuild_check_host();
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
if (result)
my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
@ -6001,7 +6002,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
DBUG_RETURN(result != 1);
rw_wrlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
LEX_USER *lex_user, *tmp_lex_user;
List_iterator <LEX_USER> user_list(list);
@ -6140,7 +6141,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
} while (revoked);
}
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
int binlog_error=
write_bin_log(thd, FALSE, thd->query(), thd->query_length());
@ -6251,7 +6252,7 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name,
thd->push_internal_handler(&error_handler);
rw_wrlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
/*
This statement will be replicated as a statement, even when using
@ -6289,7 +6290,7 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name,
}
} while (revoked);
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
@ -6330,7 +6331,7 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
combo->user.str= sctx->user;
VOID(pthread_mutex_lock(&acl_cache->lock));
pthread_mutex_lock(&acl_cache->lock);
if ((au= find_acl_user(combo->host.str=(char*)sctx->host_or_ip,combo->user.str,FALSE)))
goto found_acl;
@ -6341,11 +6342,11 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
if((au= find_acl_user(combo->host.str=(char*)"%", combo->user.str, FALSE)))
goto found_acl;
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
DBUG_RETURN(TRUE);
found_acl:
VOID(pthread_mutex_unlock(&acl_cache->lock));
pthread_mutex_unlock(&acl_cache->lock);
bzero((char*)tables, sizeof(TABLE_LIST));
user_list.empty();