Merge next-mr -> next-4284

This commit is contained in:
Konstantin Osipov 2010-02-03 16:43:03 +03:00
commit c8555bdb35
133 changed files with 5204 additions and 2281 deletions

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2003 MySQL AB
/* Copyright (C) 2000-2003 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
@ -48,7 +48,7 @@
static HASH servers_cache;
static MEM_ROOT mem;
static rw_lock_t THR_LOCK_servers;
static mysql_rwlock_t THR_LOCK_servers;
static bool get_server_from_table_to_cache(TABLE *table);
@ -90,6 +90,26 @@ static uchar *servers_cache_get_key(FOREIGN_SERVER *server, size_t *length,
DBUG_RETURN((uchar*) server->server_name);
}
#ifdef HAVE_PSI_INTERFACE
static PSI_rwlock_key key_rwlock_THR_LOCK_servers;
static PSI_rwlock_info all_servers_cache_rwlocks[]=
{
{ &key_rwlock_THR_LOCK_servers, "THR_LOCK_servers", PSI_FLAG_GLOBAL}
};
static void init_servers_cache_psi_keys(void)
{
const char* category= "sql";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_servers_cache_rwlocks);
PSI_server->register_rwlock(category, all_servers_cache_rwlocks, count);
}
#endif /* HAVE_PSI_INTERFACE */
/*
Initialize structures responsible for servers used in federated
@ -116,8 +136,12 @@ bool servers_init(bool dont_read_servers_table)
bool return_val= FALSE;
DBUG_ENTER("servers_init");
#ifdef HAVE_PSI_INTERFACE
init_servers_cache_psi_keys();
#endif
/* init the mutex */
if (my_rwlock_init(&THR_LOCK_servers, NULL))
if (mysql_rwlock_init(key_rwlock_THR_LOCK_servers, &THR_LOCK_servers))
DBUG_RETURN(TRUE);
/* initialise our servers cache */
@ -225,7 +249,7 @@ bool servers_reload(THD *thd)
DBUG_ENTER("servers_reload");
DBUG_PRINT("info", ("locking servers_cache"));
rw_wrlock(&THR_LOCK_servers);
mysql_rwlock_wrlock(&THR_LOCK_servers);
tables[0].init_one_table("mysql", 5, "servers", 7, "servers", TL_READ);
@ -249,7 +273,7 @@ end:
close_thread_tables(thd);
thd->mdl_context.release_transactional_locks();
DBUG_PRINT("info", ("unlocking servers_cache"));
rw_unlock(&THR_LOCK_servers);
mysql_rwlock_unlock(&THR_LOCK_servers);
DBUG_RETURN(return_val);
}
@ -575,7 +599,7 @@ int drop_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
tables.init_one_table("mysql", 5, "servers", 7, "servers", TL_WRITE);
rw_wrlock(&THR_LOCK_servers);
mysql_rwlock_wrlock(&THR_LOCK_servers);
/* hit the memory hit first */
if ((error= delete_server_record_in_cache(server_options)))
@ -599,7 +623,7 @@ int drop_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
}
end:
rw_unlock(&THR_LOCK_servers);
mysql_rwlock_unlock(&THR_LOCK_servers);
DBUG_RETURN(error);
}
@ -950,7 +974,7 @@ int create_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
DBUG_PRINT("info", ("server_options->server_name %s",
server_options->server_name));
rw_wrlock(&THR_LOCK_servers);
mysql_rwlock_wrlock(&THR_LOCK_servers);
/* hit the memory first */
if (my_hash_search(&servers_cache, (uchar*) server_options->server_name,
@ -971,7 +995,7 @@ int create_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
DBUG_PRINT("info", ("error returned %d", error));
end:
rw_unlock(&THR_LOCK_servers);
mysql_rwlock_unlock(&THR_LOCK_servers);
DBUG_RETURN(error);
}
@ -1000,7 +1024,7 @@ int alter_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
DBUG_PRINT("info", ("server_options->server_name %s",
server_options->server_name));
rw_wrlock(&THR_LOCK_servers);
mysql_rwlock_wrlock(&THR_LOCK_servers);
if (!(existing= (FOREIGN_SERVER *) my_hash_search(&servers_cache,
(uchar*) name.str,
@ -1025,7 +1049,7 @@ int alter_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
end:
DBUG_PRINT("info", ("error returned %d", error));
rw_unlock(&THR_LOCK_servers);
mysql_rwlock_unlock(&THR_LOCK_servers);
DBUG_RETURN(error);
}
@ -1191,7 +1215,7 @@ void servers_free(bool end)
my_hash_reset(&servers_cache);
DBUG_VOID_RETURN;
}
rwlock_destroy(&THR_LOCK_servers);
mysql_rwlock_destroy(&THR_LOCK_servers);
free_root(&mem,MYF(0));
my_hash_free(&servers_cache);
DBUG_VOID_RETURN;
@ -1273,7 +1297,7 @@ FOREIGN_SERVER *get_server_by_name(MEM_ROOT *mem, const char *server_name,
}
DBUG_PRINT("info", ("locking servers_cache"));
rw_rdlock(&THR_LOCK_servers);
mysql_rwlock_rdlock(&THR_LOCK_servers);
if (!(server= (FOREIGN_SERVER *) my_hash_search(&servers_cache,
(uchar*) server_name,
server_name_length)))
@ -1287,7 +1311,7 @@ FOREIGN_SERVER *get_server_by_name(MEM_ROOT *mem, const char *server_name,
server= clone_server(mem, server, buff);
DBUG_PRINT("info", ("unlocking servers_cache"));
rw_unlock(&THR_LOCK_servers);
mysql_rwlock_unlock(&THR_LOCK_servers);
DBUG_RETURN(server);
}