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

Manual merge from mysql-next-mr.

Conflicts:
  - sql/sql_plugin.cc
This commit is contained in:
Alexander Nozdrin
2010-01-18 23:19:19 +03:00
1467 changed files with 109087 additions and 31025 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2007 MySQL AB
/* Copyright (C) 2007 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -60,7 +60,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
user_len= strlen(user);
temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1;
(void) pthread_mutex_lock(&LOCK_user_conn);
mysql_mutex_lock(&LOCK_user_conn);
if (!(uc = (struct user_conn *) my_hash_search(&hash_user_connections,
(uchar*) temp_user, temp_len)))
{
@ -91,7 +91,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
thd->user_connect=uc;
uc->connections++;
end:
(void) pthread_mutex_unlock(&LOCK_user_conn);
mysql_mutex_unlock(&LOCK_user_conn);
return return_val;
}
@ -120,9 +120,10 @@ int check_for_max_user_connections(THD *thd, USER_CONN *uc)
int error=0;
DBUG_ENTER("check_for_max_user_connections");
(void) pthread_mutex_lock(&LOCK_user_conn);
if (max_user_connections && !uc->user_resources.user_conn &&
max_user_connections < (uint) uc->connections)
mysql_mutex_lock(&LOCK_user_conn);
if (global_system_variables.max_user_connections &&
!uc->user_resources.user_conn &&
global_system_variables.max_user_connections < (uint) uc->connections)
{
my_error(ER_TOO_MANY_USER_CONNECTIONS, MYF(0), uc->user);
error=1;
@ -160,7 +161,7 @@ end:
*/
thd->user_connect= NULL;
}
(void) pthread_mutex_unlock(&LOCK_user_conn);
mysql_mutex_unlock(&LOCK_user_conn);
DBUG_RETURN(error);
}
@ -186,14 +187,14 @@ end:
void decrease_user_connections(USER_CONN *uc)
{
DBUG_ENTER("decrease_user_connections");
(void) pthread_mutex_lock(&LOCK_user_conn);
mysql_mutex_lock(&LOCK_user_conn);
DBUG_ASSERT(uc->connections);
if (!--uc->connections && !mqh_used)
{
/* Last connection for user; Delete it */
(void) my_hash_delete(&hash_user_connections,(uchar*) uc);
}
(void) pthread_mutex_unlock(&LOCK_user_conn);
mysql_mutex_unlock(&LOCK_user_conn);
DBUG_VOID_RETURN;
}
@ -241,7 +242,7 @@ bool check_mqh(THD *thd, uint check_command)
DBUG_ENTER("check_mqh");
DBUG_ASSERT(uc != 0);
(void) pthread_mutex_lock(&LOCK_user_conn);
mysql_mutex_lock(&LOCK_user_conn);
time_out_user_resource_limits(thd, uc);
@ -268,7 +269,7 @@ bool check_mqh(THD *thd, uint check_command)
}
}
end:
(void) pthread_mutex_unlock(&LOCK_user_conn);
mysql_mutex_unlock(&LOCK_user_conn);
DBUG_RETURN(error);
}
@ -329,9 +330,9 @@ check_user(THD *thd, enum enum_server_command command,
#else
my_bool opt_secure_auth_local;
pthread_mutex_lock(&LOCK_global_system_variables);
mysql_mutex_lock(&LOCK_global_system_variables);
opt_secure_auth_local= opt_secure_auth;
pthread_mutex_unlock(&LOCK_global_system_variables);
mysql_mutex_unlock(&LOCK_global_system_variables);
/*
If the server is running in secure auth mode, short scrambles are
@ -408,10 +409,10 @@ check_user(THD *thd, enum enum_server_command command,
if (check_count)
{
pthread_mutex_lock(&LOCK_connection_count);
mysql_mutex_lock(&LOCK_connection_count);
bool count_ok= connection_count <= max_connections ||
(thd->main_security_ctx.master_access & SUPER_ACL);
pthread_mutex_unlock(&LOCK_connection_count);
mysql_mutex_unlock(&LOCK_connection_count);
if (!count_ok)
{ // too many connections
@ -443,7 +444,7 @@ check_user(THD *thd, enum enum_server_command command,
/* Don't allow user to connect if he has done too many queries */
if ((ur.questions || ur.updates || ur.conn_per_hour || ur.user_conn ||
max_user_connections) &&
global_system_variables.max_user_connections) &&
get_or_create_user_conn(thd,
(opt_old_style_user_limits ? thd->main_security_ctx.user :
thd->main_security_ctx.priv_user),
@ -457,7 +458,7 @@ check_user(THD *thd, enum enum_server_command command,
if (thd->user_connect &&
(thd->user_connect->user_resources.conn_per_hour ||
thd->user_connect->user_resources.user_conn ||
max_user_connections) &&
global_system_variables.max_user_connections) &&
check_for_max_user_connections(thd, thd->user_connect))
{
/* The error is set in check_for_max_user_connections(). */
@ -556,7 +557,7 @@ void free_max_user_conn(void)
void reset_mqh(LEX_USER *lu, bool get_them= 0)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
(void) pthread_mutex_lock(&LOCK_user_conn);
mysql_mutex_lock(&LOCK_user_conn);
if (lu) // for GRANT
{
USER_CONN *uc;
@ -590,7 +591,7 @@ void reset_mqh(LEX_USER *lu, bool get_them= 0)
uc->conn_per_hour=0;
}
}
(void) pthread_mutex_unlock(&LOCK_user_conn);
mysql_mutex_unlock(&LOCK_user_conn);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
}
@ -1052,8 +1053,6 @@ static void prepare_new_connection_state(THD* thd)
netware_reg_user(sctx->ip, sctx->user, "MySQL");
#endif
if (thd->variables.max_join_size == HA_POS_ERROR)
thd->options |= OPTION_BIG_SELECTS;
if (thd->client_capabilities & CLIENT_COMPRESS)
thd->net.compress=1; // Use compression
@ -1068,9 +1067,9 @@ static void prepare_new_connection_state(THD* thd)
thd->set_time();
thd->init_for_queries();
if (sys_init_connect.value_length && !(sctx->master_access & SUPER_ACL))
if (opt_init_connect.length && !(sctx->master_access & SUPER_ACL))
{
execute_init_command(thd, &sys_init_connect, &LOCK_sys_init_connect);
execute_init_command(thd, &opt_init_connect, &LOCK_sys_init_connect);
if (thd->is_error())
{
thd->killed= THD::KILL_CONNECTION;
@ -1108,6 +1107,16 @@ pthread_handler_t handle_one_connection(void *arg)
{
THD *thd= (THD*) arg;
mysql_thread_set_psi_id(thd->thread_id);
do_handle_one_connection(thd);
return 0;
}
void do_handle_one_connection(THD *thd_arg)
{
THD *thd= thd_arg;
thd->thr_create_utime= my_micro_time();
if (thread_scheduler.init_new_connection_thread())
@ -1115,7 +1124,7 @@ pthread_handler_t handle_one_connection(void *arg)
close_connection(thd, ER_OUT_OF_RESOURCES, 1);
statistic_increment(aborted_connects,&LOCK_status);
thread_scheduler.end_thread(thd,0);
return 0;
return;
}
/*
@ -1142,7 +1151,7 @@ pthread_handler_t handle_one_connection(void *arg)
*/
thd->thread_stack= (char*) &thd;
if (setup_connection_thread_globals(thd))
return 0;
return;
for (;;)
{
@ -1168,7 +1177,7 @@ pthread_handler_t handle_one_connection(void *arg)
end_thread:
close_connection(thd, 0, 1);
if (thread_scheduler.end_thread(thd,1))
return 0; // Probably no-threads
return; // Probably no-threads
/*
If end_thread() returns, we are either running with