Commit 71215f68 authored by stewart@mysql.com's avatar stewart@mysql.com

Merge ssmith@bk-internal.mysql.com:/home/bk/mysql-4.0

into  mysql.com:/home/stewart/Documents/MySQL/4.0/main
parents d5cb88ce 9f5e591f
......@@ -107,7 +107,7 @@ void thr_unlock(THR_LOCK_DATA *data);
int thr_multi_lock(THR_LOCK_DATA **data,uint count);
void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
void thr_abort_locks(THR_LOCK *lock);
void thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread);
bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread);
void thr_print_locks(void); /* For debugging */
my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data);
my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data);
......
......@@ -966,9 +966,10 @@ void thr_abort_locks(THR_LOCK *lock)
This is used to abort all locks for a specific thread
*/
void thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread)
bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread)
{
THR_LOCK_DATA *data;
bool found= FALSE;
DBUG_ENTER("thr_abort_locks_for_thread");
pthread_mutex_lock(&lock->mutex);
......@@ -978,6 +979,7 @@ void thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread)
{
DBUG_PRINT("info",("Aborting read-wait lock"));
data->type= TL_UNLOCK; /* Mark killed */
found= TRUE;
pthread_cond_signal(data->cond);
data->cond= 0; /* Removed from list */
......@@ -993,6 +995,7 @@ void thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread)
{
DBUG_PRINT("info",("Aborting write-wait lock"));
data->type= TL_UNLOCK;
found= TRUE;
pthread_cond_signal(data->cond);
data->cond= 0;
......@@ -1003,7 +1006,7 @@ void thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread)
}
}
pthread_mutex_unlock(&lock->mutex);
DBUG_VOID_RETURN;
DBUG_RETURN(found);
}
......
......@@ -32,9 +32,7 @@ bin_SCRIPTS = @server_scripts@ \
mysqldumpslow \
mysql_explain_log \
mysql_tableinfo \
mysqld_multi \
make_win_src_distribution \
make_win_binary_distribution
mysqld_multi
EXTRA_SCRIPTS = make_binary_distribution.sh \
make_sharedlib_distribution.sh \
......@@ -63,8 +61,6 @@ EXTRA_DIST = $(EXTRA_SCRIPTS) \
mysqlaccess.conf \
mysqlbug
pkgdata_DATA = make_binary_distribution make_sharedlib_distribution
# mysqlbug should be distributed built so that people can report build
# failures with it.
CLEANFILES = @server_scripts@ \
......
......@@ -333,20 +333,25 @@ void mysql_lock_abort(THD *thd, TABLE *table)
/* Abort one thread / table combination */
void mysql_lock_abort_for_thread(THD *thd, TABLE *table)
bool mysql_lock_abort_for_thread(THD *thd, TABLE *table)
{
MYSQL_LOCK *locked;
TABLE *write_lock_used;
bool result= FALSE;
DBUG_ENTER("mysql_lock_abort_for_thread");
if ((locked = get_lock_data(thd,&table,1,1,&write_lock_used)))
{
for (uint i=0; i < locked->lock_count; i++)
thr_abort_locks_for_thread(locked->locks[i]->lock,
table->in_use->real_id);
{
bool found;
found= thr_abort_locks_for_thread(locked->locks[i]->lock,
table->in_use->real_id);
result|= found;
}
my_free((gptr) locked,MYF(0));
}
DBUG_VOID_RETURN;
DBUG_RETURN(result);
}
......@@ -542,8 +547,14 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
my_free((gptr) table,MYF(0));
DBUG_RETURN(-1);
}
if (remove_table_from_cache(thd, db, table_list->real_name))
DBUG_RETURN(1); // Table is in use
{
if (remove_table_from_cache(thd, db,
table_list->real_name, RTFC_NO_FLAG))
{
DBUG_RETURN(1); // Table is in use
}
}
DBUG_RETURN(0);
}
......
......@@ -606,8 +606,12 @@ bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db,
const char *table_name);
void remove_db_from_cache(const my_string db);
void flush_tables();
#define RTFC_NO_FLAG 0x0000
#define RTFC_OWNED_BY_THD_FLAG 0x0001
#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
#define RTFC_CHECK_KILLED_FLAG 0x0004
bool remove_table_from_cache(THD *thd, const char *db, const char *table,
bool return_if_owned_by_thd=0);
uint flags);
bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables);
void copy_field_from_tmp_record(Field *field,int offset);
int fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors);
......@@ -776,7 +780,7 @@ void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock);
void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count);
void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table);
void mysql_lock_abort(THD *thd, TABLE *table);
void mysql_lock_abort_for_thread(THD *thd, TABLE *table);
bool mysql_lock_abort_for_thread(THD *thd, TABLE *table);
MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b);
bool lock_global_read_lock(THD *thd);
void unlock_global_read_lock(THD *thd);
......
......@@ -370,7 +370,8 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
bool found=0;
for (TABLE_LIST *table=tables ; table ; table=table->next)
{
if (remove_table_from_cache(thd, table->db, table->real_name, 1))
if (remove_table_from_cache(thd, table->db, table->real_name,
RTFC_OWNED_BY_THD_FLAG))
found=1;
}
if (!found)
......@@ -2407,62 +2408,99 @@ void flush_tables()
*/
bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
bool return_if_owned_by_thd)
uint flags)
{
char key[MAX_DBKEY_LENGTH];
uint key_length;
TABLE *table;
bool result=0;
bool result=0, signalled= 0;
DBUG_ENTER("remove_table_from_cache");
key_length=(uint) (strmov(strmov(key,db)+1,table_name)-key)+1;
for (table=(TABLE*) hash_search(&open_cache,(byte*) key,key_length) ;
table;
table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length))
for (;;)
{
THD *in_use;
table->version=0L; /* Free when thread is ready */
if (!(in_use=table->in_use))
{
DBUG_PRINT("info",("Table was not in use"));
relink_unused(table);
}
else if (in_use != thd)
result= signalled= 0;
for (table=(TABLE*) hash_search(&open_cache,(byte*) key,key_length) ;
table;
table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length))
{
in_use->some_tables_deleted=1;
if (table->db_stat)
result=1;
/* Kill delayed insert threads */
if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&
! in_use->killed)
THD *in_use;
table->version=0L; /* Free when thread is ready */
if (!(in_use=table->in_use))
{
in_use->killed=1;
pthread_mutex_lock(&in_use->mysys_var->mutex);
if (in_use->mysys_var->current_cond)
{
pthread_mutex_lock(in_use->mysys_var->current_mutex);
pthread_cond_broadcast(in_use->mysys_var->current_cond);
pthread_mutex_unlock(in_use->mysys_var->current_mutex);
}
pthread_mutex_unlock(&in_use->mysys_var->mutex);
DBUG_PRINT("info",("Table was not in use"));
relink_unused(table);
}
/*
Now we must abort all tables locks used by this thread
as the thread may be waiting to get a lock for another table
*/
for (TABLE *thd_table= in_use->open_tables;
thd_table ;
thd_table= thd_table->next)
else if (in_use != thd)
{
in_use->some_tables_deleted=1;
if (table->db_stat)
result=1;
/* Kill delayed insert threads */
if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&
! in_use->killed)
{
in_use->killed=1;
pthread_mutex_lock(&in_use->mysys_var->mutex);
if (in_use->mysys_var->current_cond)
{
pthread_mutex_lock(in_use->mysys_var->current_mutex);
signalled= 1;
pthread_cond_broadcast(in_use->mysys_var->current_cond);
pthread_mutex_unlock(in_use->mysys_var->current_mutex);
}
pthread_mutex_unlock(&in_use->mysys_var->mutex);
}
/*
Now we must abort all tables locks used by this thread
as the thread may be waiting to get a lock for another table
*/
for (TABLE *thd_table= in_use->open_tables;
thd_table ;
thd_table= thd_table->next)
{
if (thd_table->db_stat) // If table is open
signalled|= mysql_lock_abort_for_thread(thd, thd_table);
}
}
else
result= result || (flags & RTFC_OWNED_BY_THD_FLAG);
}
while (unused_tables && !unused_tables->version)
VOID(hash_delete(&open_cache,(byte*) unused_tables));
if (result && (flags & RTFC_WAIT_OTHER_THREAD_FLAG))
{
if (!(flags & RTFC_CHECK_KILLED_FLAG) || !thd->killed)
{
if (thd_table->db_stat) // If table is open
mysql_lock_abort_for_thread(thd, thd_table);
if (likely(signalled))
{
dropping_tables++;
(void) pthread_cond_wait(&COND_refresh, &LOCK_open);
dropping_tables--;
continue;
}
else
{
/*
It can happen that another thread has opened the
table but has not yet locked any table at all. Since
it can be locked waiting for a table that our thread
has done LOCK TABLE x WRITE on previously, we need to
ensure that the thread actually hears our signal
before we go to sleep. Thus we wait for a short time
and then we retry another loop in the
remove_table_from_cache routine.
*/
pthread_mutex_unlock(&LOCK_open);
my_sleep(10);
pthread_mutex_lock(&LOCK_open);
continue;
}
}
}
else
result= result || return_if_owned_by_thd;
break;
}
while (unused_tables && !unused_tables->version)
VOID(hash_delete(&open_cache,(byte*) unused_tables));
DBUG_RETURN(result);
}
......
......@@ -178,6 +178,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
for (table=tables ; table ; table=table->next)
{
char *db=table->db;
uint flags;
mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL);
if (!close_temporary_table(thd, db, table->real_name))
{
......@@ -186,12 +187,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
abort_locked_tables(thd,db,table->real_name);
while (remove_table_from_cache(thd,db,table->real_name) && !thd->killed)
{
dropping_tables++;
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
dropping_tables--;
}
flags= RTFC_WAIT_OTHER_THREAD_FLAG | RTFC_CHECK_KILLED_FLAG;
remove_table_from_cache(thd,db,table->real_name,flags);
drop_locked_tables(thd,db,table->real_name);
if (thd->killed)
DBUG_RETURN(-1);
......@@ -988,13 +985,8 @@ static void wait_while_table_is_used(THD *thd,TABLE *table,
mysql_lock_abort(thd, table); // end threads waiting on lock
/* Wait until all there are no other threads that has this table open */
while (remove_table_from_cache(thd,table->table_cache_key,
table->real_name))
{
dropping_tables++;
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
dropping_tables--;
}
remove_table_from_cache(thd,table->table_cache_key,
table->real_name, RTFC_WAIT_OTHER_THREAD_FLAG);
DBUG_VOID_RETURN;
}
......@@ -1306,18 +1298,14 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
/* Close all instances of the table to allow repair to rename files */
if (lock_type == TL_WRITE && table->table->version)
{
uint flags;
pthread_mutex_lock(&LOCK_open);
const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open,
"Waiting to get writelock");
mysql_lock_abort(thd,table->table);
while (remove_table_from_cache(thd, table->table->table_cache_key,
table->table->real_name) &&
! thd->killed)
{
dropping_tables++;
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
dropping_tables--;
}
flags= RTFC_WAIT_OTHER_THREAD_FLAG | RTFC_CHECK_KILLED_FLAG;
remove_table_from_cache(thd, table->table->table_cache_key,
table->table->real_name, flags);
thd->exit_cond(old_message);
if (thd->killed)
goto err;
......@@ -1384,7 +1372,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
{
pthread_mutex_lock(&LOCK_open);
remove_table_from_cache(thd, table->table->table_cache_key,
table->table->real_name);
table->table->real_name, RTFC_NO_FLAG);
pthread_mutex_unlock(&LOCK_open);
/* May be something modified consequently we have to invalidate cache */
query_cache_invalidate3(thd, table->table, 0);
......@@ -2109,7 +2097,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (table)
{
VOID(table->file->extra(HA_EXTRA_FORCE_REOPEN)); // Use new file
remove_table_from_cache(thd,db,table_name); // Mark all in-use copies old
remove_table_from_cache(thd,db,table_name,RTFC_NO_FLAG);
// Mark in-use copies old
mysql_lock_abort(thd,table); // end threads waiting on lock
}
VOID(quick_rm_table(old_db_type,db,old_name));
......
......@@ -28,12 +28,6 @@ EXTRA_DIST = Info.plist.sh \
StartupItem.Info.plist \
StartupItem.postinstall
pkgdata_DATA = Info.plist \
Description.plist \
StartupParameters.plist \
postinstall \
preinstall
CLEANFILES = Info.plist \
Description.plist \
StartupParameters.plist \
......
......@@ -37,9 +37,7 @@ pkgdata_DATA = my-small.cnf \
my-huge.cnf \
my-innodb-heavy-4G.cnf \
mysql-log-rotate \
mysql-@VERSION@.spec \
binary-configure \
MySQL-shared-compat.spec
binary-configure
pkgdata_SCRIPTS = mysql.server
......
%define mysql_version @VERSION@
%define release 0
%define license GPL
%define mysqld_user mysql
%define server_suffix -standard
%define mysqldatadir /var/lib/mysql
# We don't package all files installed into the build root by intention -
# See BUG#998 for details.
......@@ -12,11 +14,9 @@
Name: MySQL
Summary: MySQL: a very fast and reliable SQL database server
Group: Applications/Databases
Summary(pt_BR): MySQL: Um servidor SQL rpido e confivel.
Group(pt_BR): Aplicaes/Banco_de_Dados
Version: @MYSQL_NO_DASH_VERSION@
Release: %{release}
License: GPL
License: %{license}
Source: http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/mysql-%{mysql_version}.tar.gz
URL: http://www.mysql.com/
Packager: Lenz Grimmer <build@mysql.com>
......@@ -50,11 +50,8 @@ news and information about the MySQL software. Also please see the
documentation and the manual for more information.
%package server
Release: %{release}
Summary: MySQL: a very fast and reliable SQL database server
Group: Applications/Databases
Summary(pt_BR): MySQL: Um servidor SQL rpido e confivel.
Group(pt_BR): Aplicaes/Banco_de_Dados
Requires: fileutils sh-utils
Provides: msqlormysql mysql-server mysql MySQL
Obsoletes: MySQL mysql mysql-server
......@@ -85,11 +82,8 @@ If you want to access and work with the database, you have to install
package "MySQL-client" as well!
%package client
Release: %{release}
Summary: MySQL - Client
Group: Applications/Databases
Summary(pt_BR): MySQL - Cliente
Group(pt_BR): Aplicaes/Banco_de_Dados
Obsoletes: mysql-client
Provides: mysql-client
......@@ -98,16 +92,11 @@ This package contains the standard MySQL clients and administration tools.
%{see_base}
%description client -l pt_BR
Este pacote contm os clientes padro para o MySQL.
%package bench
Release: %{release}
Requires: %{name}-client perl-DBI perl
Summary: MySQL - Benchmarks and test system
Group: Applications/Databases
Summary(pt_BR): MySQL - Medies de desempenho
Group(pt_BR): Aplicaes/Banco_de_Dados
Provides: mysql-bench
Obsoletes: mysql-bench
......@@ -116,15 +105,9 @@ This package contains MySQL benchmark scripts and data.
%{see_base}
%description bench -l pt_BR
Este pacote contm medies de desempenho de scripts e dados do MySQL.
%package devel
Release: %{release}
Summary: MySQL - Development header files and libraries
Group: Applications/Databases
Summary(pt_BR): MySQL - Medies de desempenho
Group(pt_BR): Aplicaes/Banco_de_Dados
Provides: mysql-devel
Obsoletes: mysql-devel
......@@ -134,12 +117,7 @@ necessary to develop MySQL client applications.
%{see_base}
%description devel -l pt_BR
Este pacote contm os arquivos de cabealho (header files) e bibliotecas
necessrias para desenvolver aplicaes clientes do MySQL.
%package shared
Release: %{release}
Summary: MySQL - Shared libraries
Group: Applications/Databases
......@@ -148,12 +126,11 @@ This package contains the shared libraries (*.so*) which certain
languages and applications need to dynamically load and use MySQL.
%package Max
Release: %{release}
Summary: MySQL - server with Berkeley BD, RAID and UDF support
Group: Applications/Databases
Provides: mysql-Max
Obsoletes: mysql-Max
Requires: MySQL-server >= 4.0
Requires: MySQL-server >= @MYSQL_BASE_VERSION@
%description Max
Optional MySQL server binary that supports additional features like
......@@ -164,12 +141,9 @@ the standard MySQL package.
Please note that this is a dynamically linked binary!
%package embedded
Release: %{release}
Requires: %{name}-devel
Summary: MySQL - embedded library
Group: Applications/Databases
Summary(pt_BR): MySQL - Medies de desempenho
Group(pt_BR): Aplicaes/Banco_de_Dados
Obsoletes: mysql-embedded
%description embedded
......@@ -216,7 +190,7 @@ sh -c "PATH=\"${MYSQL_BUILD_PATH:-$PATH}\" \
--libdir=%{_libdir} \
--sysconfdir=%{_sysconfdir} \
--datadir=%{_datadir} \
--localstatedir=/var/lib/mysql \
--localstatedir=%{mysqldatadir} \
--infodir=%{_infodir} \
--includedir=%{_includedir} \
--mandir=%{_mandir} \
......@@ -325,7 +299,7 @@ MBD=$RPM_BUILD_DIR/mysql-%{mysql_version}
# Ensure that needed directories exists
install -d $RBR%{_sysconfdir}/{logrotate.d,init.d}
install -d $RBR/var/lib/mysql/mysql
install -d $RBR%{mysqldatadir}/mysql
install -d $RBR%{_datadir}/{sql-bench,mysql-test}
install -d $RBR%{_includedir}
install -d $RBR%{_libdir}
......@@ -377,7 +351,7 @@ then
fi
%post server
mysql_datadir=/var/lib/mysql
mysql_datadir=%{mysqldatadir}
# Create data directory if needed
if test ! -d $mysql_datadir; then mkdir -m755 $mysql_datadir; fi
......@@ -395,19 +369,20 @@ then
/sbin/chkconfig --add mysql
fi
# Create a MySQL user. Do not report any problems if it already
# exists. This is redhat specific and should be handled more portable
useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" mysql 2> /dev/null || true
# Create a MySQL user and group. Do not report any problems if it already
# exists.
groupadd -r -c "MySQL server" %{mysqld_user} 2> /dev/null || true
useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" -g %{mysqld_user} %{mysqld_user} 2> /dev/null || true
# Change permissions so that the user that will run the MySQL daemon
# owns all database files.
chown -R mysql $mysql_datadir
chown -R %{mysqld_user}:%{mysqld_user} $mysql_datadir
# Initiate databases
mysql_install_db -IN-RPM --user=mysql
%{_bindir}/mysql_install_db -IN-RPM --user=%{mysqld_user}
# Change permissions again to fix any new files.
chown -R mysql $mysql_datadir
chown -R %{mysqld_user}:%{mysqld_user} $mysql_datadir
# Fix permissions for the permission database so that only the user
# can read them.
......@@ -587,6 +562,18 @@ fi
# itself - note that they must be ordered by date (important when
# merging BK trees)
%changelog
* Fri Jul 15 2005 Lenz Grimmer <lenz@mysql.com>
- create a "mysql" user group and assign the mysql user account to that group
in the server postinstall section. (BUG 10984)
* Wed Jun 01 2005 Lenz Grimmer <lenz@mysql.com>
- use "mysqldatadir" variable instead of hard-coding the path multiple times
- use the "mysqld_user" variable on all occasions a user name is referenced
- removed (incomplete) Brazilian translations
- removed redundant release tags from the subpackage descriptions
* Wed May 25 2005 Joerg Bruehe <joerg@mysql.com>
- Added a "make clean" between separate calls to "BuildMySQL".
......
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