Commit ae3d1248 authored by unknown's avatar unknown

Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-4.1

into  mysql.com:/home/hf/work/mysql-4.1.16017

parents 3c2bdb59 d9992cc7
...@@ -216,6 +216,7 @@ enum mysql_rpl_type ...@@ -216,6 +216,7 @@ enum mysql_rpl_type
}; };
struct st_mysql_methods; struct st_mysql_methods;
struct st_mysql_stmt;
typedef struct st_mysql typedef struct st_mysql
{ {
...@@ -269,6 +270,12 @@ typedef struct st_mysql ...@@ -269,6 +270,12 @@ typedef struct st_mysql
from mysql_stmt_close if close had to cancel result set of this object. from mysql_stmt_close if close had to cancel result set of this object.
*/ */
my_bool *unbuffered_fetch_owner; my_bool *unbuffered_fetch_owner;
/*
In embedded server it points to the statement that is processed
in the current query. We store some results directly in statement
fields then.
*/
struct st_mysql_stmt *current_stmt;
} MYSQL; } MYSQL;
typedef struct st_mysql_res { typedef struct st_mysql_res {
...@@ -636,7 +643,8 @@ typedef struct st_mysql_methods ...@@ -636,7 +643,8 @@ typedef struct st_mysql_methods
unsigned long header_length, unsigned long header_length,
const char *arg, const char *arg,
unsigned long arg_length, unsigned long arg_length,
my_bool skip_check); my_bool skip_check,
MYSQL_STMT *stmt);
MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
unsigned int fields); unsigned int fields);
MYSQL_RES * (*use_result)(MYSQL *mysql); MYSQL_RES * (*use_result)(MYSQL *mysql);
...@@ -724,8 +732,11 @@ int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); ...@@ -724,8 +732,11 @@ int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
*/ */
#define simple_command(mysql, command, arg, length, skip_check) \ #define simple_command(mysql, command, arg, length, skip_check) \
(*(mysql)->methods->advanced_command)(mysql, command, \ (*(mysql)->methods->advanced_command)(mysql, command, NullS, \
NullS, 0, arg, length, skip_check) 0, arg, length, skip_check, NULL)
#define stmt_command(mysql, command, arg, length, stmt) \
(*(mysql)->methods->advanced_command)(mysql, command, NullS, \
0, arg, length, 1, stmt)
unsigned long net_safe_read(MYSQL* mysql); unsigned long net_safe_read(MYSQL* mysql);
#ifdef __NETWARE__ #ifdef __NETWARE__
......
...@@ -34,7 +34,8 @@ void mysql_read_default_options(struct st_mysql_options *options, ...@@ -34,7 +34,8 @@ void mysql_read_default_options(struct st_mysql_options *options,
my_bool my_bool
cli_advanced_command(MYSQL *mysql, enum enum_server_command command, cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length, const char *header, ulong header_length,
const char *arg, ulong arg_length, my_bool skip_check); const char *arg, ulong arg_length, my_bool skip_check,
MYSQL_STMT *stmt);
void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode, void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode,
const char *sqlstate); const char *sqlstate);
......
...@@ -2085,7 +2085,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) ...@@ -2085,7 +2085,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length)
mysql_use_result it won't be freed in mysql_stmt_free_result and mysql_use_result it won't be freed in mysql_stmt_free_result and
we should get 'Commands out of sync' here. we should get 'Commands out of sync' here.
*/ */
if (simple_command(mysql, COM_CLOSE_STMT, buff, 4, 1)) if (stmt_command(mysql, COM_CLOSE_STMT, buff, 4, stmt))
{ {
set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
mysql->net.sqlstate); mysql->net.sqlstate);
...@@ -2094,7 +2094,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) ...@@ -2094,7 +2094,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length)
stmt->state= MYSQL_STMT_INIT_DONE; stmt->state= MYSQL_STMT_INIT_DONE;
} }
if (simple_command(mysql, COM_PREPARE, query, length, 1)) if (stmt_command(mysql, COM_PREPARE, query, length, stmt))
{ {
set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
mysql->net.sqlstate); mysql->net.sqlstate);
...@@ -2504,7 +2504,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) ...@@ -2504,7 +2504,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
buff[4]= (char) 0; /* no flags */ buff[4]= (char) 0; /* no flags */
int4store(buff+5, 1); /* iteration count */ int4store(buff+5, 1); /* iteration count */
if (cli_advanced_command(mysql, COM_EXECUTE, buff, sizeof(buff), if (cli_advanced_command(mysql, COM_EXECUTE, buff, sizeof(buff),
packet, length, 1) || packet, length, 1, NULL) ||
(*mysql->methods->read_query_result)(mysql)) (*mysql->methods->read_query_result)(mysql))
{ {
set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
...@@ -3278,7 +3278,8 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, ...@@ -3278,7 +3278,8 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
This is intentional to save bandwidth. This is intentional to save bandwidth.
*/ */
if ((*mysql->methods->advanced_command)(mysql, COM_LONG_DATA, buff, if ((*mysql->methods->advanced_command)(mysql, COM_LONG_DATA, buff,
sizeof(buff), data, length, 1)) sizeof(buff), data, length, 1,
NULL))
{ {
set_stmt_errmsg(stmt, mysql->net.last_error, set_stmt_errmsg(stmt, mysql->net.last_error,
mysql->net.last_errno, mysql->net.sqlstate); mysql->net.last_errno, mysql->net.sqlstate);
...@@ -4602,7 +4603,7 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt) ...@@ -4602,7 +4603,7 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
mysql->status= MYSQL_STATUS_READY; mysql->status= MYSQL_STATUS_READY;
} }
int4store(buff, stmt->stmt_id); int4store(buff, stmt->stmt_id);
if ((rc= simple_command(mysql, COM_CLOSE_STMT, buff, 4, 1))) if ((rc= stmt_command(mysql, COM_CLOSE_STMT, buff, 4, stmt)))
{ {
set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
mysql->net.sqlstate); mysql->net.sqlstate);
...@@ -4640,7 +4641,7 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt) ...@@ -4640,7 +4641,7 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt)
mysql= stmt->mysql->last_used_con; mysql= stmt->mysql->last_used_con;
int4store(buff, stmt->stmt_id); /* Send stmt id to server */ int4store(buff, stmt->stmt_id); /* Send stmt id to server */
if ((*mysql->methods->advanced_command)(mysql, COM_RESET_STMT, buff, if ((*mysql->methods->advanced_command)(mysql, COM_RESET_STMT, buff,
sizeof(buff), 0, 0, 0)) sizeof(buff), 0, 0, 0, 0))
{ {
set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
mysql->net.sqlstate); mysql->net.sqlstate);
......
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
C_MODE_START C_MODE_START
void lib_connection_phase(NET *net, int phase); void lib_connection_phase(NET *net, int phase);
void init_embedded_mysql(MYSQL *mysql, int client_flag, char *db); void init_embedded_mysql(MYSQL *mysql, int client_flag);
void *create_embedded_thd(int client_flag, char *db); void *create_embedded_thd(int client_flag);
int check_embedded_connection(MYSQL *mysql); int check_embedded_connection(MYSQL *mysql, const char *db);
void free_old_query(MYSQL *mysql); void free_old_query(MYSQL *mysql);
void embedded_get_error(MYSQL *mysql); void embedded_get_error(MYSQL *mysql);
extern MYSQL_METHODS embedded_methods; extern MYSQL_METHODS embedded_methods;
......
...@@ -49,6 +49,7 @@ C_MODE_START ...@@ -49,6 +49,7 @@ C_MODE_START
#include "errmsg.h" #include "errmsg.h"
#include <sql_common.h> #include <sql_common.h>
void embedded_get_error(MYSQL *mysql) void embedded_get_error(MYSQL *mysql)
{ {
THD *thd=(THD *) mysql->thd; THD *thd=(THD *) mysql->thd;
...@@ -68,7 +69,8 @@ void embedded_get_error(MYSQL *mysql) ...@@ -68,7 +69,8 @@ void embedded_get_error(MYSQL *mysql)
static my_bool static my_bool
emb_advanced_command(MYSQL *mysql, enum enum_server_command command, emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length, const char *header, ulong header_length,
const char *arg, ulong arg_length, my_bool skip_check) const char *arg, ulong arg_length, my_bool skip_check,
MYSQL_STMT *stmt)
{ {
my_bool result= 1; my_bool result= 1;
THD *thd=(THD *) mysql->thd; THD *thd=(THD *) mysql->thd;
...@@ -92,6 +94,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, ...@@ -92,6 +94,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
mysql->affected_rows= ~(my_ulonglong) 0; mysql->affected_rows= ~(my_ulonglong) 0;
mysql->field_count= 0; mysql->field_count= 0;
net->last_errno= 0; net->last_errno= 0;
mysql->current_stmt= stmt;
thd->store_globals(); // Fix if more than one connect thd->store_globals(); // Fix if more than one connect
/* /*
...@@ -185,7 +188,6 @@ static my_bool emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) ...@@ -185,7 +188,6 @@ static my_bool emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
mysql->server_status|= SERVER_STATUS_IN_TRANS; mysql->server_status|= SERVER_STATUS_IN_TRANS;
stmt->fields= mysql->fields; stmt->fields= mysql->fields;
stmt->mem_root= mysql->field_alloc;
mysql->fields= NULL; mysql->fields= NULL;
} }
...@@ -227,7 +229,7 @@ static int emb_stmt_execute(MYSQL_STMT *stmt) ...@@ -227,7 +229,7 @@ static int emb_stmt_execute(MYSQL_STMT *stmt)
thd->client_param_count= stmt->param_count; thd->client_param_count= stmt->param_count;
thd->client_params= stmt->params; thd->client_params= stmt->params;
if (emb_advanced_command(stmt->mysql, COM_EXECUTE,0,0, if (emb_advanced_command(stmt->mysql, COM_EXECUTE,0,0,
header, sizeof(header), 1) || header, sizeof(header), 1, stmt) ||
emb_mysql_read_query_result(stmt->mysql)) emb_mysql_read_query_result(stmt->mysql))
{ {
NET *net= &stmt->mysql->net; NET *net= &stmt->mysql->net;
...@@ -244,8 +246,6 @@ int emb_read_binary_rows(MYSQL_STMT *stmt) ...@@ -244,8 +246,6 @@ int emb_read_binary_rows(MYSQL_STMT *stmt)
MYSQL_DATA *data; MYSQL_DATA *data;
if (!(data= emb_read_rows(stmt->mysql, 0, 0))) if (!(data= emb_read_rows(stmt->mysql, 0, 0)))
return 1; return 1;
stmt->result= *data;
my_free((char *) data, MYF(0));
return 0; return 0;
} }
...@@ -300,7 +300,8 @@ my_bool emb_next_result(MYSQL *mysql) ...@@ -300,7 +300,8 @@ my_bool emb_next_result(MYSQL *mysql)
DBUG_ENTER("emb_next_result"); DBUG_ENTER("emb_next_result");
if (emb_advanced_command(mysql, COM_QUERY,0,0, if (emb_advanced_command(mysql, COM_QUERY,0,0,
thd->query_rest.ptr(),thd->query_rest.length(),1) || thd->query_rest.ptr(),
thd->query_rest.length(),1, 0) ||
emb_mysql_read_query_result(mysql)) emb_mysql_read_query_result(mysql))
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -484,14 +485,14 @@ void end_embedded_server() ...@@ -484,14 +485,14 @@ void end_embedded_server()
} /* extern "C" */ } /* extern "C" */
C_MODE_START C_MODE_START
void init_embedded_mysql(MYSQL *mysql, int client_flag, char *db) void init_embedded_mysql(MYSQL *mysql, int client_flag)
{ {
THD *thd = (THD *)mysql->thd; THD *thd = (THD *)mysql->thd;
thd->mysql= mysql; thd->mysql= mysql;
mysql->server_version= server_version; mysql->server_version= server_version;
} }
void *create_embedded_thd(int client_flag, char *db) void *create_embedded_thd(int client_flag)
{ {
THD * thd= new THD; THD * thd= new THD;
thd->thread_id= thread_id++; thd->thread_id= thread_id++;
...@@ -517,8 +518,8 @@ void *create_embedded_thd(int client_flag, char *db) ...@@ -517,8 +518,8 @@ void *create_embedded_thd(int client_flag, char *db)
thd->init_for_queries(); thd->init_for_queries();
thd->client_capabilities= client_flag; thd->client_capabilities= client_flag;
thd->db= db; thd->db= NULL;
thd->db_length= db ? strip_sp(db) : 0; thd->db_length= 0;
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
thd->db_access= DB_ACLS; thd->db_access= DB_ACLS;
thd->master_access= ~NO_ACCESS; thd->master_access= ~NO_ACCESS;
...@@ -536,7 +537,7 @@ err: ...@@ -536,7 +537,7 @@ err:
#ifdef NO_EMBEDDED_ACCESS_CHECKS #ifdef NO_EMBEDDED_ACCESS_CHECKS
int check_embedded_connection(MYSQL *mysql) int check_embedded_connection(MYSQL *mysql, const char *db)
{ {
THD *thd= (THD*)mysql->thd; THD *thd= (THD*)mysql->thd;
thd_init_client_charset(thd, mysql->charset->number); thd_init_client_charset(thd, mysql->charset->number);
...@@ -545,11 +546,11 @@ int check_embedded_connection(MYSQL *mysql) ...@@ -545,11 +546,11 @@ int check_embedded_connection(MYSQL *mysql)
thd->host_or_ip= thd->host; thd->host_or_ip= thd->host;
thd->user= my_strdup(mysql->user, MYF(0)); thd->user= my_strdup(mysql->user, MYF(0));
thd->priv_user= thd->user; thd->priv_user= thd->user;
return check_user(thd, COM_CONNECT, NULL, 0, thd->db, true); return check_user(thd, COM_CONNECT, NULL, 0, db, true);
} }
#else #else
int check_embedded_connection(MYSQL *mysql) int check_embedded_connection(MYSQL *mysql, const char *db)
{ {
THD *thd= (THD*)mysql->thd; THD *thd= (THD*)mysql->thd;
int result; int result;
...@@ -585,7 +586,7 @@ int check_embedded_connection(MYSQL *mysql) ...@@ -585,7 +586,7 @@ int check_embedded_connection(MYSQL *mysql)
passwd_len= 0; passwd_len= 0;
if((result= check_user(thd, COM_CONNECT, if((result= check_user(thd, COM_CONNECT,
scramble_buff, passwd_len, thd->db, true))) scramble_buff, passwd_len, db, true)))
goto err; goto err;
return 0; return 0;
...@@ -643,8 +644,9 @@ bool Protocol::send_fields(List<Item> *list, uint flag) ...@@ -643,8 +644,9 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
DBUG_RETURN(0); DBUG_RETURN(0);
field_count= list->elements; field_count= list->elements;
field_alloc= &mysql->field_alloc; field_alloc= mysql->current_stmt ? &mysql->current_stmt->mem_root :
if (!(client_field= thd->mysql->fields= &mysql->field_alloc;
if (!(client_field= mysql->fields=
(MYSQL_FIELD *)alloc_root(field_alloc, (MYSQL_FIELD *)alloc_root(field_alloc,
sizeof(MYSQL_FIELD) * field_count))) sizeof(MYSQL_FIELD) * field_count)))
goto err; goto err;
...@@ -714,7 +716,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag) ...@@ -714,7 +716,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
client_field->max_length= 0; client_field->max_length= 0;
++client_field; ++client_field;
} }
thd->mysql->field_count= field_count; mysql->field_count= field_count;
DBUG_RETURN(prepare_for_send(list)); DBUG_RETURN(prepare_for_send(list));
err: err:
...@@ -743,13 +745,20 @@ bool Protocol_prep::write() ...@@ -743,13 +745,20 @@ bool Protocol_prep::write()
if (!data) if (!data)
{ {
if (!(data= (MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA), MYSQL *mysql= thd->mysql;
MYF(MY_WME | MY_ZEROFILL))))
return true; if (mysql->current_stmt)
data= &mysql->current_stmt->result;
else
{
if (!(data= (MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
MYF(MY_WME | MY_ZEROFILL))))
return true;
init_alloc_root(&data->alloc,8192,0); /* Assume rowlength < 8192 */
data->alloc.min_malloc=sizeof(MYSQL_ROWS);
}
alloc= &data->alloc; alloc= &data->alloc;
init_alloc_root(alloc,8192,0); /* Assume rowlength < 8192 */
alloc->min_malloc=sizeof(MYSQL_ROWS);
data->rows=0; data->rows=0;
data->fields=field_count; data->fields=field_count;
data->prev_ptr= &data->data; data->prev_ptr= &data->data;
......
...@@ -92,7 +92,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -92,7 +92,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db, const char *passwd, const char *db,
uint port, const char *unix_socket,ulong client_flag) uint port, const char *unix_socket,ulong client_flag)
{ {
char *db_name;
char name_buff[USERNAME_LENGTH]; char name_buff[USERNAME_LENGTH];
DBUG_ENTER("mysql_real_connect"); DBUG_ENTER("mysql_real_connect");
...@@ -155,16 +154,14 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -155,16 +154,14 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
port=0; port=0;
unix_socket=0; unix_socket=0;
db_name = db ? my_strdup(db,MYF(MY_WME)) : NULL; mysql->thd= create_embedded_thd(client_flag);
mysql->thd= create_embedded_thd(client_flag, db_name); init_embedded_mysql(mysql, client_flag);
init_embedded_mysql(mysql, client_flag, db_name);
if (mysql_init_character_set(mysql)) if (mysql_init_character_set(mysql))
goto error; goto error;
if (check_embedded_connection(mysql)) if (check_embedded_connection(mysql, db))
goto error; goto error;
/* Send client information for access check */ /* Send client information for access check */
......
...@@ -650,7 +650,8 @@ void free_rows(MYSQL_DATA *cur) ...@@ -650,7 +650,8 @@ void free_rows(MYSQL_DATA *cur)
my_bool my_bool
cli_advanced_command(MYSQL *mysql, enum enum_server_command command, cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length, const char *header, ulong header_length,
const char *arg, ulong arg_length, my_bool skip_check) const char *arg, ulong arg_length, my_bool skip_check,
MYSQL_STMT *stmt __attribute__((unused)))
{ {
NET *net= &mysql->net; NET *net= &mysql->net;
my_bool result= 1; my_bool result= 1;
......
...@@ -54,8 +54,8 @@ extern "C" int gethostname(char *name, int namelen); ...@@ -54,8 +54,8 @@ extern "C" int gethostname(char *name, int namelen);
static void time_out_user_resource_limits(THD *thd, USER_CONN *uc); static void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
static int check_for_max_user_connections(THD *thd, USER_CONN *uc); static int check_for_max_user_connections(THD *thd, USER_CONN *uc);
#endif
static void decrease_user_connections(USER_CONN *uc); static void decrease_user_connections(USER_CONN *uc);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
static bool check_db_used(THD *thd,TABLE_LIST *tables); static bool check_db_used(THD *thd,TABLE_LIST *tables);
static bool check_multi_update_lock(THD *thd, TABLE_LIST *tables, static bool check_multi_update_lock(THD *thd, TABLE_LIST *tables,
List<Item> *fields, SELECT_LEX *select_lex); List<Item> *fields, SELECT_LEX *select_lex);
...@@ -137,6 +137,7 @@ inline bool all_tables_not_ok(THD *thd, TABLE_LIST *tables) ...@@ -137,6 +137,7 @@ inline bool all_tables_not_ok(THD *thd, TABLE_LIST *tables)
#endif #endif
#ifndef NO_EMBEDDED_ACCESS_CHECKS
static HASH hash_user_connections; static HASH hash_user_connections;
static int get_or_create_user_conn(THD *thd, const char *user, static int get_or_create_user_conn(THD *thd, const char *user,
...@@ -190,6 +191,7 @@ end: ...@@ -190,6 +191,7 @@ end:
return return_val; return return_val;
} }
#endif /* !NO_EMBEDDED_ACCESS_CHECKS */
/* /*
...@@ -231,11 +233,7 @@ int check_user(THD *thd, enum enum_server_command command, ...@@ -231,11 +233,7 @@ int check_user(THD *thd, enum enum_server_command command,
thd->db= 0; thd->db= 0;
thd->db_length= 0; thd->db_length= 0;
if (mysql_change_db(thd, db)) if (mysql_change_db(thd, db))
{
if (thd->user_connect)
decrease_user_connections(thd->user_connect);
DBUG_RETURN(-1); DBUG_RETURN(-1);
}
} }
else else
send_ok(thd); send_ok(thd);
...@@ -409,10 +407,12 @@ extern "C" void free_user(struct user_conn *uc) ...@@ -409,10 +407,12 @@ extern "C" void free_user(struct user_conn *uc)
void init_max_user_conn(void) void init_max_user_conn(void)
{ {
#ifndef NO_EMBEDDED_ACCESS_CHECKS
(void) hash_init(&hash_user_connections,system_charset_info,max_connections, (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
0,0, 0,0,
(hash_get_key) get_key_conn, (hash_free_key) free_user, (hash_get_key) get_key_conn, (hash_free_key) free_user,
0); 0);
#endif
} }
...@@ -466,7 +466,6 @@ static int check_for_max_user_connections(THD *thd, USER_CONN *uc) ...@@ -466,7 +466,6 @@ static int check_for_max_user_connections(THD *thd, USER_CONN *uc)
(void) pthread_mutex_unlock(&LOCK_user_conn); (void) pthread_mutex_unlock(&LOCK_user_conn);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
/* /*
Decrease user connection count Decrease user connection count
...@@ -500,13 +499,18 @@ static void decrease_user_connections(USER_CONN *uc) ...@@ -500,13 +499,18 @@ static void decrease_user_connections(USER_CONN *uc)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
void free_max_user_conn(void) void free_max_user_conn(void)
{ {
#ifndef NO_EMBEDDED_ACCESS_CHECKS
hash_free(&hash_user_connections); hash_free(&hash_user_connections);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
} }
/* /*
Mark all commands that somehow changes a table Mark all commands that somehow changes a table
This is used to check number of updates / hour This is used to check number of updates / hour
...@@ -1481,9 +1485,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1481,9 +1485,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
} }
else else
{ {
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/* we've authenticated new user */ /* we've authenticated new user */
if (save_user_connect) if (save_user_connect)
decrease_user_connections(save_user_connect); decrease_user_connections(save_user_connect);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
x_free((gptr) save_db); x_free((gptr) save_db);
x_free((gptr) save_user); x_free((gptr) save_user);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment