diff options
author | unknown <ingo@mysql.com> | 2005-01-26 15:51:46 +0100 |
---|---|---|
committer | unknown <ingo@mysql.com> | 2005-01-26 15:51:46 +0100 |
commit | 9d570cdbdda2577599218c8dd76dab06fe17acae (patch) | |
tree | 529f781833794ea64fd20c882773a307e9bf1095 /sql/examples | |
parent | f2b752567581edd6db97f18e0c4d48172f0deaf0 (diff) | |
parent | 9990b5d26040afddc0e1c9abb7d52ae43f31a2e9 (diff) | |
download | mariadb-git-9d570cdbdda2577599218c8dd76dab06fe17acae.tar.gz |
Merge from 4.1
Archive fix by Ingo.
Innodb compile fix by Monty.
configure.in:
Auto merged
innobase/include/univ.i:
Auto merged
BUILD/SETUP.sh:
Auto merged
mysql-test/t/archive.test:
Auto merged
sql/examples/ha_archive.cc:
Auto merged
sql/examples/ha_archive.h:
Auto merged
sql/handler.cc:
Auto merged
sql/sql_select.cc:
Auto merged
innobase/fil/fil0fil.c:
Merged Montys fix.
Diffstat (limited to 'sql/examples')
-rw-r--r-- | sql/examples/ha_archive.cc | 59 | ||||
-rw-r--r-- | sql/examples/ha_archive.h | 4 |
2 files changed, 45 insertions, 18 deletions
diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index dccff88bf1f..f0d0f617a5d 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -117,7 +117,6 @@ /* Variables for archive share methods */ pthread_mutex_t archive_mutex; static HASH archive_open_tables; -static int archive_init= 0; /* The file extension */ #define ARZ ".ARZ" // The data file @@ -143,6 +142,46 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length, return (byte*) share->table_name; } + +/* + Initialize the archive handler. + + SYNOPSIS + archive_db_init() + void + + RETURN + FALSE OK + TRUE Error +*/ + +bool archive_db_init() +{ + VOID(pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST)); + return (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0, + (hash_get_key) archive_get_key, 0, 0)); +} + + +/* + Release the archive handler. + + SYNOPSIS + archive_db_end() + void + + RETURN + FALSE OK +*/ + +bool archive_db_end() +{ + hash_free(&archive_open_tables); + VOID(pthread_mutex_destroy(&archive_mutex)); + return FALSE; +} + + /* This method reads the header of a datafile and returns whether or not it was successful. */ @@ -269,23 +308,6 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) uint length; char *tmp_name; - if (!archive_init) - { - /* Hijack a mutex for init'ing the storage engine */ - pthread_mutex_lock(&LOCK_mysql_create_db); - if (!archive_init) - { - VOID(pthread_mutex_init(&archive_mutex,MY_MUTEX_INIT_FAST)); - if (hash_init(&archive_open_tables,system_charset_info,32,0,0, - (hash_get_key) archive_get_key,0,0)) - { - pthread_mutex_unlock(&LOCK_mysql_create_db); - return NULL; - } - archive_init++; - } - pthread_mutex_unlock(&LOCK_mysql_create_db); - } pthread_mutex_lock(&archive_mutex); length=(uint) strlen(table_name); @@ -371,6 +393,7 @@ int ha_archive::free_share(ARCHIVE_SHARE *share) (void)write_meta_file(share->meta_file, share->rows_recorded, FALSE); if (gzclose(share->archive_write) == Z_ERRNO) rc= 1; + my_close(share->meta_file,MYF(0)); my_free((gptr) share, MYF(0)); } pthread_mutex_unlock(&archive_mutex); diff --git a/sql/examples/ha_archive.h b/sql/examples/ha_archive.h index 07bc7baa400..a511b5c67d6 100644 --- a/sql/examples/ha_archive.h +++ b/sql/examples/ha_archive.h @@ -105,3 +105,7 @@ public: THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); }; + +bool archive_db_init(void); +bool archive_db_end(void); + |