Commit 04fe4039 authored by Marc Alff's avatar Marc Alff

WL#2360 Performance schema

Part II, engines instrumentation
parent 560e76c5
/* Copyright (C) 2000,2004 MySQL AB /* Copyright (C) 2000-2004 MySQL AB, 2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -148,7 +148,7 @@ typedef struct st_heap_share ...@@ -148,7 +148,7 @@ typedef struct st_heap_share
char * name; /* Name of "memory-file" */ char * name; /* Name of "memory-file" */
#ifdef THREAD #ifdef THREAD
THR_LOCK lock; THR_LOCK lock;
pthread_mutex_t intern_lock; /* Locking for use with _locking */ mysql_mutex_t intern_lock; /* Locking for use with _locking */
#endif #endif
my_bool delete_on_close; my_bool delete_on_close;
LIST open_list; LIST open_list;
......
/* Copyright (C) 2000 MySQL AB /* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -433,7 +433,7 @@ typedef struct st_mi_check_param ...@@ -433,7 +433,7 @@ typedef struct st_mi_check_param
const char *op_name; const char *op_name;
enum_mi_stats_method stats_method; enum_mi_stats_method stats_method;
#ifdef THREAD #ifdef THREAD
pthread_mutex_t print_msg_mutex; mysql_mutex_t print_msg_mutex;
my_bool need_print_msg_lock; my_bool need_print_msg_lock;
#endif #endif
} MI_CHECK; } MI_CHECK;
...@@ -460,8 +460,8 @@ typedef struct st_sort_info ...@@ -460,8 +460,8 @@ typedef struct st_sort_info
/* sync things */ /* sync things */
uint got_error, threads_running; uint got_error, threads_running;
#ifdef THREAD #ifdef THREAD
pthread_mutex_t mutex; mysql_mutex_t mutex;
pthread_cond_t cond; mysql_cond_t cond;
#endif #endif
} SORT_INFO; } SORT_INFO;
......
/* Copyright (C) 2000 MySQL AB /* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -75,7 +75,7 @@ typedef struct st_myrg_info ...@@ -75,7 +75,7 @@ typedef struct st_myrg_info
LIST open_list; LIST open_list;
QUEUE by_key; QUEUE by_key;
ulong *rec_per_key_part; /* for sql optimizing */ ulong *rec_per_key_part; /* for sql optimizing */
pthread_mutex_t mutex; mysql_mutex_t mutex;
} MYRG_INFO; } MYRG_INFO;
......
/* Copyright (C) 2000 MySQL AB /* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -26,12 +26,54 @@ ...@@ -26,12 +26,54 @@
#ifdef THREAD #ifdef THREAD
#include <my_pthread.h> #include <my_pthread.h>
#ifdef HAVE_PSI_INTERFACE
#if !defined(HAVE_PREAD) && !defined(_WIN32)
extern PSI_mutex_key key_my_file_info_mutex;
#endif /* !defined(HAVE_PREAD) && !defined(_WIN32) */
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
extern PSI_mutex_key key_LOCK_localtime_r;
#endif /* !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) */
#ifndef HAVE_GETHOSTBYNAME_R
extern PSI_mutex_key key_LOCK_gethostbyname_r;
#endif /* HAVE_GETHOSTBYNAME_R */
extern PSI_mutex_key key_BITMAP_mutex, key_IO_CACHE_append_buffer_lock,
key_IO_CACHE_SHARE_mutex, key_KEY_CACHE_cache_lock, key_LOCK_alarm,
key_my_thread_var_mutex, key_THR_LOCK_charset, key_THR_LOCK_heap,
key_THR_LOCK_isam, key_THR_LOCK_lock, key_THR_LOCK_malloc,
key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net,
key_THR_LOCK_open, key_THR_LOCK_threads, key_THR_LOCK_time,
key_TMPDIR_mutex;
extern PSI_cond_key key_COND_alarm, key_IO_CACHE_SHARE_cond,
key_IO_CACHE_SHARE_cond_writer, key_my_thread_var_suspend,
key_THR_COND_threads;
#ifdef USE_ALARM_THREAD
extern PSI_thread_key key_thread_alarm;
#endif /* USE_ALARM_THREAD */
#endif /* HAVE_PSI_INTERFACE */
extern pthread_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache; extern pthread_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache;
extern pthread_mutex_t THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_net; extern pthread_mutex_t THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_net;
extern pthread_mutex_t THR_LOCK_charset, THR_LOCK_time; extern pthread_mutex_t THR_LOCK_charset, THR_LOCK_time;
#else #else /* THREAD */
#include <my_no_pthread.h> #include <my_no_pthread.h>
#endif #endif /* THREAD */
#include <mysql/psi/mysql_file.h>
#ifdef HAVE_PSI_INTERFACE
#ifdef HUGETLB_USE_PROC_MEMINFO
extern PSI_file_key key_file_proc_meminfo;
#endif /* HUGETLB_USE_PROC_MEMINFO */
extern PSI_file_key key_file_charset, key_file_cnf;
#endif /* HAVE_PSI_INTERFACE */
/* /*
EDQUOT is used only in 3 C files only in mysys/. If it does not exist on EDQUOT is used only in 3 C files only in mysys/. If it does not exist on
......
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. /* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "sql_array.h" #include "sql_array.h"
#include "sql_plugin.h" #include "sql_plugin.h"
#include "scheduler.h" #include "scheduler.h"
#include <mysql/psi/mysql_file.h>
#ifndef __WIN__ #ifndef __WIN__
#include <netdb.h> #include <netdb.h>
#endif #endif
......
...@@ -1884,6 +1884,12 @@ public: ...@@ -1884,6 +1884,12 @@ public:
proc_info = msg; proc_info = msg;
return old_msg; return old_msg;
} }
inline const char* enter_cond(mysql_cond_t *cond, mysql_mutex_t *mutex,
const char *msg)
{
/* TO BE REMOVED: temporary helper, to help with merges */
return enter_cond(&cond->m_cond, &mutex->m_mutex, msg);
}
inline void exit_cond(const char* old_msg) inline void exit_cond(const char* old_msg)
{ {
/* /*
......
/* Copyright (C) 2003 MySQL AB /* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
*/ */
/* Variables for archive share methods */ /* Variables for archive share methods */
pthread_mutex_t archive_mutex; mysql_mutex_t archive_mutex;
static HASH archive_open_tables; static HASH archive_open_tables;
/* The file extension */ /* The file extension */
...@@ -145,6 +145,28 @@ static uchar* archive_get_key(ARCHIVE_SHARE *share, size_t *length, ...@@ -145,6 +145,28 @@ static uchar* archive_get_key(ARCHIVE_SHARE *share, size_t *length,
return (uchar*) share->table_name; return (uchar*) share->table_name;
} }
#ifdef HAVE_PSI_INTERFACE
PSI_mutex_key az_key_mutex_archive_mutex, az_key_mutex_ARCHIVE_SHARE_mutex;
static PSI_mutex_info all_archive_mutexes[]=
{
{ &az_key_mutex_archive_mutex, "archive_mutex", PSI_FLAG_GLOBAL},
{ &az_key_mutex_ARCHIVE_SHARE_mutex, "ARCHIVE_SHARE::mutex", 0}
};
static void init_archive_psi_keys(void)
{
const char* category= "archive";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_archive_mutexes);
PSI_server->register_mutex(category, all_archive_mutexes, count);
}
#endif /* HAVE_PSI_INTERFACE */
/* /*
Initialize the archive handler. Initialize the archive handler.
...@@ -163,6 +185,10 @@ int archive_db_init(void *p) ...@@ -163,6 +185,10 @@ int archive_db_init(void *p)
DBUG_ENTER("archive_db_init"); DBUG_ENTER("archive_db_init");
handlerton *archive_hton; handlerton *archive_hton;
#ifdef HAVE_PSI_INTERFACE
init_archive_psi_keys();
#endif
archive_hton= (handlerton *)p; archive_hton= (handlerton *)p;
archive_hton->state= SHOW_OPTION_YES; archive_hton->state= SHOW_OPTION_YES;
archive_hton->db_type= DB_TYPE_ARCHIVE_DB; archive_hton->db_type= DB_TYPE_ARCHIVE_DB;
...@@ -170,12 +196,13 @@ int archive_db_init(void *p) ...@@ -170,12 +196,13 @@ int archive_db_init(void *p)
archive_hton->flags= HTON_NO_FLAGS; archive_hton->flags= HTON_NO_FLAGS;
archive_hton->discover= archive_discover; archive_hton->discover= archive_discover;
if (pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST)) if (mysql_mutex_init(az_key_mutex_archive_mutex,
&archive_mutex, MY_MUTEX_INIT_FAST))
goto error; goto error;
if (my_hash_init(&archive_open_tables, table_alias_charset, 32, 0, 0, if (my_hash_init(&archive_open_tables, table_alias_charset, 32, 0, 0,
(my_hash_get_key) archive_get_key, 0, 0)) (my_hash_get_key) archive_get_key, 0, 0))
{ {
pthread_mutex_destroy(&archive_mutex); mysql_mutex_destroy(&archive_mutex);
} }
else else
{ {
...@@ -199,7 +226,7 @@ error: ...@@ -199,7 +226,7 @@ error:
int archive_db_done(void *p) int archive_db_done(void *p)
{ {
my_hash_free(&archive_open_tables); my_hash_free(&archive_open_tables);
pthread_mutex_destroy(&archive_mutex); mysql_mutex_destroy(&archive_mutex);
return 0; return 0;
} }
...@@ -313,7 +340,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc) ...@@ -313,7 +340,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
uint length; uint length;
DBUG_ENTER("ha_archive::get_share"); DBUG_ENTER("ha_archive::get_share");
pthread_mutex_lock(&archive_mutex); mysql_mutex_lock(&archive_mutex);
length=(uint) strlen(table_name); length=(uint) strlen(table_name);
if (!(share=(ARCHIVE_SHARE*) my_hash_search(&archive_open_tables, if (!(share=(ARCHIVE_SHARE*) my_hash_search(&archive_open_tables,
...@@ -328,7 +355,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc) ...@@ -328,7 +355,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
&tmp_name, length+1, &tmp_name, length+1,
NullS)) NullS))
{ {
pthread_mutex_unlock(&archive_mutex); mysql_mutex_unlock(&archive_mutex);
*rc= HA_ERR_OUT_OF_MEM; *rc= HA_ERR_OUT_OF_MEM;
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
...@@ -346,7 +373,8 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc) ...@@ -346,7 +373,8 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
/* /*
We will use this lock for rows. We will use this lock for rows.
*/ */
pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST); mysql_mutex_init(az_key_mutex_ARCHIVE_SHARE_mutex,
&share->mutex, MY_MUTEX_INIT_FAST);
/* /*
We read the meta file, but do not mark it dirty. Since we are not We read the meta file, but do not mark it dirty. Since we are not
...@@ -372,7 +400,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc) ...@@ -372,7 +400,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
share->use_count)); share->use_count));
if (share->crashed) if (share->crashed)
*rc= HA_ERR_CRASHED_ON_USAGE; *rc= HA_ERR_CRASHED_ON_USAGE;
pthread_mutex_unlock(&archive_mutex); mysql_mutex_unlock(&archive_mutex);
DBUG_RETURN(share); DBUG_RETURN(share);
} }
...@@ -391,12 +419,12 @@ int ha_archive::free_share() ...@@ -391,12 +419,12 @@ int ha_archive::free_share()
share->table_name_length, share->table_name, share->table_name_length, share->table_name,
share->use_count)); share->use_count));
pthread_mutex_lock(&archive_mutex); mysql_mutex_lock(&archive_mutex);
if (!--share->use_count) if (!--share->use_count)
{ {
my_hash_delete(&archive_open_tables, (uchar*) share); my_hash_delete(&archive_open_tables, (uchar*) share);
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex); mysql_mutex_destroy(&share->mutex);
/* /*
We need to make sure we don't reset the crashed state. We need to make sure we don't reset the crashed state.
If we open a crashed file, wee need to close it as crashed unless If we open a crashed file, wee need to close it as crashed unless
...@@ -411,7 +439,7 @@ int ha_archive::free_share() ...@@ -411,7 +439,7 @@ int ha_archive::free_share()
} }
my_free((uchar*) share, MYF(0)); my_free((uchar*) share, MYF(0));
} }
pthread_mutex_unlock(&archive_mutex); mysql_mutex_unlock(&archive_mutex);
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
...@@ -651,7 +679,7 @@ int ha_archive::create(const char *name, TABLE *table_arg, ...@@ -651,7 +679,7 @@ int ha_archive::create(const char *name, TABLE *table_arg,
*/ */
if ((frm_file= my_open(name_buff, O_RDONLY, MYF(0))) > 0) if ((frm_file= my_open(name_buff, O_RDONLY, MYF(0))) > 0)
{ {
if (!my_fstat(frm_file, &file_stat, MYF(MY_WME))) if (!mysql_file_fstat(frm_file, &file_stat, MYF(MY_WME)))
{ {
frm_ptr= (uchar *)my_malloc(sizeof(uchar) * file_stat.st_size, MYF(0)); frm_ptr= (uchar *)my_malloc(sizeof(uchar) * file_stat.st_size, MYF(0));
if (frm_ptr) if (frm_ptr)
...@@ -800,7 +828,7 @@ int ha_archive::write_row(uchar *buf) ...@@ -800,7 +828,7 @@ int ha_archive::write_row(uchar *buf)
ha_statistic_increment(&SSV::ha_write_count); ha_statistic_increment(&SSV::ha_write_count);
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT) if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
table->timestamp_field->set_time(); table->timestamp_field->set_time();
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
if (!share->archive_write_open) if (!share->archive_write_open)
if (init_archive_writer()) if (init_archive_writer())
...@@ -883,7 +911,7 @@ int ha_archive::write_row(uchar *buf) ...@@ -883,7 +911,7 @@ int ha_archive::write_row(uchar *buf)
share->rows_recorded++; share->rows_recorded++;
rc= real_write_row(buf, &(share->archive_write)); rc= real_write_row(buf, &(share->archive_write));
error: error:
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
if (read_buf) if (read_buf)
my_free((uchar*) read_buf, MYF(0)); my_free((uchar*) read_buf, MYF(0));
...@@ -1383,7 +1411,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) ...@@ -1383,7 +1411,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
azclose(&archive); azclose(&archive);
// make the file we just wrote be our data file // make the file we just wrote be our data file
rc = my_rename(writer_filename,share->data_file_name,MYF(0)); rc= my_rename(writer_filename, share->data_file_name, MYF(0));
DBUG_RETURN(rc); DBUG_RETURN(rc);
...@@ -1467,7 +1495,7 @@ int ha_archive::info(uint flag) ...@@ -1467,7 +1495,7 @@ int ha_archive::info(uint flag)
If dirty, we lock, and then reset/flush the data. If dirty, we lock, and then reset/flush the data.
I found that just calling azflush() doesn't always work. I found that just calling azflush() doesn't always work.
*/ */
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
if (share->dirty == TRUE) if (share->dirty == TRUE)
{ {
if (share->dirty == TRUE) if (share->dirty == TRUE)
...@@ -1483,7 +1511,7 @@ int ha_archive::info(uint flag) ...@@ -1483,7 +1511,7 @@ int ha_archive::info(uint flag)
cause the number to be inaccurate. cause the number to be inaccurate.
*/ */
stats.records= share->rows_recorded; stats.records= share->rows_recorded;
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
stats.deleted= 0; stats.deleted= 0;
...@@ -1508,9 +1536,9 @@ int ha_archive::info(uint flag) ...@@ -1508,9 +1536,9 @@ int ha_archive::info(uint flag)
if (flag & HA_STATUS_AUTO) if (flag & HA_STATUS_AUTO)
{ {
init_archive_reader(); init_archive_reader();
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
azflush(&archive, Z_SYNC_FLUSH); azflush(&archive, Z_SYNC_FLUSH);
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
stats.auto_increment_value= archive.auto_increment + 1; stats.auto_increment_value= archive.auto_increment + 1;
} }
...@@ -1578,9 +1606,9 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt) ...@@ -1578,9 +1606,9 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt)
old_proc_info= thd_proc_info(thd, "Checking table"); old_proc_info= thd_proc_info(thd, "Checking table");
/* Flush any waiting data */ /* Flush any waiting data */
pthread_mutex_lock(&share->mutex); mysql_mutex_lock(&share->mutex);
azflush(&(share->archive_write), Z_SYNC_FLUSH); azflush(&(share->archive_write), Z_SYNC_FLUSH);
pthread_mutex_unlock(&share->mutex); mysql_mutex_unlock(&share->mutex);
/* /*
Now we will rewind the archive file so that we are positioned at the Now we will rewind the archive file so that we are positioned at the
......
/* Copyright (C) 2003 MySQL AB /* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -36,7 +36,7 @@ typedef struct st_archive_share { ...@@ -36,7 +36,7 @@ typedef struct st_archive_share {
char *table_name; char *table_name;
char data_file_name[FN_REFLEN]; char data_file_name[FN_REFLEN];
uint table_name_length,use_count; uint table_name_length,use_count;
pthread_mutex_t mutex; mysql_mutex_t mutex;
THR_LOCK lock; THR_LOCK lock;
azio_stream archive_write; /* Archive file we are working with */ azio_stream archive_write; /* Archive file we are working with */
bool archive_write_open; bool archive_write_open;
......
/* Copyright 2005-2008 MySQL AB, 2008 Sun Microsystems, Inc. /* Copyright 2005-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -35,7 +35,7 @@ static handler *blackhole_create_handler(handlerton *hton, ...@@ -35,7 +35,7 @@ static handler *blackhole_create_handler(handlerton *hton,
/* Static declarations for shared structures */ /* Static declarations for shared structures */
static pthread_mutex_t blackhole_mutex; static mysql_mutex_t blackhole_mutex;
static HASH blackhole_open_tables; static HASH blackhole_open_tables;
static st_blackhole_share *get_share(const char *table_name); static st_blackhole_share *get_share(const char *table_name);
...@@ -317,7 +317,7 @@ static st_blackhole_share *get_share(const char *table_name) ...@@ -317,7 +317,7 @@ static st_blackhole_share *get_share(const char *table_name)
uint length; uint length;
length= (uint) strlen(table_name); length= (uint) strlen(table_name);
pthread_mutex_lock(&blackhole_mutex); mysql_mutex_lock(&blackhole_mutex);
if (!(share= (st_blackhole_share*) if (!(share= (st_blackhole_share*)
my_hash_search(&blackhole_open_tables, my_hash_search(&blackhole_open_tables,
...@@ -343,16 +343,16 @@ static st_blackhole_share *get_share(const char *table_name) ...@@ -343,16 +343,16 @@ static st_blackhole_share *get_share(const char *table_name)
share->use_count++; share->use_count++;
error: error:
pthread_mutex_unlock(&blackhole_mutex); mysql_mutex_unlock(&blackhole_mutex);
return share; return share;
} }
static void free_share(st_blackhole_share *share) static void free_share(st_blackhole_share *share)
{ {
pthread_mutex_lock(&blackhole_mutex); mysql_mutex_lock(&blackhole_mutex);
if (!--share->use_count) if (!--share->use_count)
my_hash_delete(&blackhole_open_tables, (uchar*) share); my_hash_delete(&blackhole_open_tables, (uchar*) share);
pthread_mutex_unlock(&blackhole_mutex); mysql_mutex_unlock(&blackhole_mutex);
} }
static void blackhole_free_key(st_blackhole_share *share) static void blackhole_free_key(st_blackhole_share *share)
...@@ -368,16 +368,43 @@ static uchar* blackhole_get_key(st_blackhole_share *share, size_t *length, ...@@ -368,16 +368,43 @@ static uchar* blackhole_get_key(st_blackhole_share *share, size_t *length,
return (uchar*) share->table_name; return (uchar*) share->table_name;
} }
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key bh_key_mutex_blackhole;
static PSI_mutex_info all_blackhole_mutexes[]=
{
{ &bh_key_mutex_blackhole, "blackhole", PSI_FLAG_GLOBAL}
};
void init_blackhole_psi_keys()
{
const char* category= "blackhole";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_blackhole_mutexes);
PSI_server->register_mutex(category, all_blackhole_mutexes, count);
}
#endif
static int blackhole_init(void *p) static int blackhole_init(void *p)
{ {
handlerton *blackhole_hton; handlerton *blackhole_hton;
#ifdef HAVE_PSI_INTERFACE
init_blackhole_psi_keys();
#endif
blackhole_hton= (handlerton *)p; blackhole_hton= (handlerton *)p;
blackhole_hton->state= SHOW_OPTION_YES; blackhole_hton->state= SHOW_OPTION_YES;
blackhole_hton->db_type= DB_TYPE_BLACKHOLE_DB; blackhole_hton->db_type= DB_TYPE_BLACKHOLE_DB;
blackhole_hton->create= blackhole_create_handler; blackhole_hton->create= blackhole_create_handler;
blackhole_hton->flags= HTON_CAN_RECREATE; blackhole_hton->flags= HTON_CAN_RECREATE;
pthread_mutex_init(&blackhole_mutex, MY_MUTEX_INIT_FAST); mysql_mutex_init(bh_key_mutex_blackhole,
&blackhole_mutex, MY_MUTEX_INIT_FAST);
(void) my_hash_init(&blackhole_open_tables, system_charset_info,32,0,0, (void) my_hash_init(&blackhole_open_tables, system_charset_info,32,0,0,
(my_hash_get_key) blackhole_get_key, (my_hash_get_key) blackhole_get_key,
(my_hash_free_key) blackhole_free_key, 0); (my_hash_free_key) blackhole_free_key, 0);
...@@ -388,7 +415,7 @@ static int blackhole_init(void *p) ...@@ -388,7 +415,7 @@ static int blackhole_init(void *p)
static int blackhole_fini(void *p) static int blackhole_fini(void *p)
{ {
my_hash_free(&blackhole_open_tables); my_hash_free(&blackhole_open_tables);
pthread_mutex_destroy(&blackhole_mutex); mysql_mutex_destroy(&blackhole_mutex);
return 0; return 0;
} }
......
This diff is collapsed.
/* Copyright (C) 2003 MySQL AB /* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -41,7 +41,7 @@ typedef struct st_tina_share { ...@@ -41,7 +41,7 @@ typedef struct st_tina_share {
share initialization. share initialization.
*/ */
my_off_t saved_data_file_length; my_off_t saved_data_file_length;
pthread_mutex_t mutex; mysql_mutex_t mutex;
THR_LOCK lock; THR_LOCK lock;
bool update_file_opened; bool update_file_opened;
bool tina_write_opened; bool tina_write_opened;
......
/* Copyright (C) 2003 MySQL AB /* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -35,9 +35,9 @@ void Transparent_file::init_buff(File filedes_arg) ...@@ -35,9 +35,9 @@ void Transparent_file::init_buff(File filedes_arg)
filedes= filedes_arg; filedes= filedes_arg;
/* read the beginning of the file */ /* read the beginning of the file */
lower_bound= 0; lower_bound= 0;
my_seek(filedes, 0, MY_SEEK_SET, MYF(0)); mysql_file_seek(filedes, 0, MY_SEEK_SET, MYF(0));
if (filedes && buff) if (filedes && buff)
upper_bound= my_read(filedes, buff, buff_size, MYF(0)); upper_bound= mysql_file_read(filedes, buff, buff_size, MYF(0));
} }
uchar *Transparent_file::ptr() uchar *Transparent_file::ptr()
...@@ -63,7 +63,8 @@ my_off_t Transparent_file::read_next() ...@@ -63,7 +63,8 @@ my_off_t Transparent_file::read_next()
No need to seek here, as the file managed by Transparent_file class No need to seek here, as the file managed by Transparent_file class
always points to upper_bound byte always points to upper_bound byte
*/ */
if ((bytes_read= my_read(filedes, buff, buff_size, MYF(0))) == MY_FILE_ERROR) if ((bytes_read= mysql_file_read(filedes, buff, buff_size, MYF(0)))
== MY_FILE_ERROR)
return (my_off_t) -1; return (my_off_t) -1;
/* end of file */ /* end of file */
...@@ -85,10 +86,10 @@ char Transparent_file::get_value(my_off_t offset) ...@@ -85,10 +86,10 @@ char Transparent_file::get_value(my_off_t offset)
if ((lower_bound <= offset) && (((my_off_t) offset) < upper_bound)) if ((lower_bound <= offset) && (((my_off_t) offset) < upper_bound))
return buff[offset - lower_bound]; return buff[offset - lower_bound];
my_seek(filedes, offset, MY_SEEK_SET, MYF(0)); mysql_file_seek(filedes, offset, MY_SEEK_SET, MYF(0));
/* read appropriate portion of the file */ /* read appropriate portion of the file */
if ((bytes_read= my_read(filedes, buff, buff_size, if ((bytes_read= mysql_file_read(filedes, buff, buff_size,
MYF(0))) == MY_FILE_ERROR) MYF(0))) == MY_FILE_ERROR)
return 0; return 0;
lower_bound= offset; lower_bound= offset;
......
...@@ -112,7 +112,7 @@ handlerton *example_hton; ...@@ -112,7 +112,7 @@ handlerton *example_hton;
static HASH example_open_tables; static HASH example_open_tables;
/* The mutex used to init the hash; variable for example share methods */ /* The mutex used to init the hash; variable for example share methods */
pthread_mutex_t example_mutex; mysql_mutex_t example_mutex;
/** /**
@brief @brief
...@@ -126,13 +126,39 @@ static uchar* example_get_key(EXAMPLE_SHARE *share, size_t *length, ...@@ -126,13 +126,39 @@ static uchar* example_get_key(EXAMPLE_SHARE *share, size_t *length,
return (uchar*) share->table_name; return (uchar*) share->table_name;
} }
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key ex_key_mutex_example, ex_key_mutex_EXAMPLE_SHARE_mutex;
static PSI_mutex_info all_example_mutexes[]=
{
{ &ex_key_mutex_example, "example", PSI_FLAG_GLOBAL},
{ &ex_key_mutex_EXAMPLE_SHARE_mutex, "EXAMPLE_SHARE::mutex", 0}
};
static void init_example_psi_keys()
{
const char* category= "example";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_example_mutexes);
PSI_server->register_mutex(category, all_example_mutexes, count);
}
#endif
static int example_init_func(void *p) static int example_init_func(void *p)
{ {
DBUG_ENTER("example_init_func"); DBUG_ENTER("example_init_func");
#ifdef HAVE_PSI_INTERFACE
init_example_psi_keys();
#endif
example_hton= (handlerton *)p; example_hton= (handlerton *)p;
pthread_mutex_init(&example_mutex,MY_MUTEX_INIT_FAST); mysql_mutex_init(ex_key_mutex_example, &example_mutex, MY_MUTEX_INIT_FAST);
(void) my_hash_init(&example_open_tables,system_charset_info,32,0,0, (void) my_hash_init(&example_open_tables,system_charset_info,32,0,0,
(my_hash_get_key) example_get_key,0,0); (my_hash_get_key) example_get_key,0,0);
...@@ -152,7 +178,7 @@ static int example_done_func(void *p) ...@@ -152,7 +178,7 @@ static int example_done_func(void *p)
if (example_open_tables.records) if (example_open_tables.records)
error= 1; error= 1;
my_hash_free(&example_open_tables); my_hash_free(&example_open_tables);
pthread_mutex_destroy(&example_mutex); mysql_mutex_destroy(&example_mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -172,7 +198,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table) ...@@ -172,7 +198,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
uint length; uint length;
char *tmp_name; char *tmp_name;
pthread_mutex_lock(&example_mutex); mysql_mutex_lock(&example_mutex);
length=(uint) strlen(table_name); length=(uint) strlen(table_name);
if (!(share=(EXAMPLE_SHARE*) my_hash_search(&example_open_tables, if (!(share=(EXAMPLE_SHARE*) my_hash_search(&example_open_tables,
...@@ -185,7 +211,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table) ...@@ -185,7 +211,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
&tmp_name, length+1, &tmp_name, length+1,
NullS))) NullS)))
{ {
pthread_mutex_unlock(&example_mutex); mysql_mutex_unlock(&example_mutex);
return NULL; return NULL;
} }
...@@ -196,15 +222,16 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table) ...@@ -196,15 +222,16 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
if (my_hash_insert(&example_open_tables, (uchar*) share)) if (my_hash_insert(&example_open_tables, (uchar*) share))
goto error; goto error;
thr_lock_init(&share->lock); thr_lock_init(&share->lock);
pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST); mysql_mutex_init(ex_key_mutex_EXAMPLE_SHARE_mutex,
&share->mutex, MY_MUTEX_INIT_FAST);
} }
share->use_count++; share->use_count++;
pthread_mutex_unlock(&example_mutex); mysql_mutex_unlock(&example_mutex);
return share; return share;
error: error:
pthread_mutex_destroy(&share->mutex); mysql_mutex_destroy(&share->mutex);
my_free(share, MYF(0)); my_free(share, MYF(0));
return NULL; return NULL;
...@@ -219,15 +246,15 @@ error: ...@@ -219,15 +246,15 @@ error:
static int free_share(EXAMPLE_SHARE *share) static int free_share(EXAMPLE_SHARE *share)
{ {
pthread_mutex_lock(&example_mutex); mysql_mutex_lock(&example_mutex);
if (!--share->use_count) if (!--share->use_count)
{ {
my_hash_delete(&example_open_tables, (uchar*) share); my_hash_delete(&example_open_tables, (uchar*) share);
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex); mysql_mutex_destroy(&share->mutex);
my_free(share, MYF(0)); my_free(share, MYF(0));
} }
pthread_mutex_unlock(&example_mutex); mysql_mutex_unlock(&example_mutex);
return 0; return 0;
} }
......
/* Copyright (C) 2003 MySQL AB /* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
typedef struct st_example_share { typedef struct st_example_share {
char *table_name; char *table_name;
uint table_name_length,use_count; uint table_name_length,use_count;
pthread_mutex_t mutex; mysql_mutex_t mutex;
THR_LOCK lock; THR_LOCK lock;
} EXAMPLE_SHARE; } EXAMPLE_SHARE;
......
/* Copyright (C) 2004 MySQL AB /* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -388,7 +388,7 @@ ...@@ -388,7 +388,7 @@
/* Variables for federated share methods */ /* Variables for federated share methods */
static HASH federated_open_tables; // To track open tables static HASH federated_open_tables; // To track open tables
pthread_mutex_t federated_mutex; // To init the hash mysql_mutex_t federated_mutex; // To init the hash
static char ident_quote_char= '`'; // Character for quoting static char ident_quote_char= '`'; // Character for quoting
// identifiers // identifiers
static char value_quote_char= '\''; // Character for quoting static char value_quote_char= '\''; // Character for quoting
...@@ -427,6 +427,28 @@ static uchar *federated_get_key(FEDERATED_SHARE *share, size_t *length, ...@@ -427,6 +427,28 @@ static uchar *federated_get_key(FEDERATED_SHARE *share, size_t *length,
return (uchar*) share->share_key; return (uchar*) share->share_key;
} }
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key fe_key_mutex_federated, fe_key_mutex_FEDERATED_SHARE_mutex;
static PSI_mutex_info all_federated_mutexes[]=
{
{ &fe_key_mutex_federated, "federated", PSI_FLAG_GLOBAL},
{ &fe_key_mutex_FEDERATED_SHARE_mutex, "FEDERATED_SHARE::mutex", 0}
};
static void init_federated_psi_keys(void)
{
const char* category= "federated";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_federated_mutexes);
PSI_server->register_mutex(category, all_federated_mutexes, count);
}
#endif /* HAVE_PSI_INTERFACE */
/* /*
Initialize the federated handler. Initialize the federated handler.
...@@ -442,6 +464,11 @@ static uchar *federated_get_key(FEDERATED_SHARE *share, size_t *length, ...@@ -442,6 +464,11 @@ static uchar *federated_get_key(FEDERATED_SHARE *share, size_t *length,
int federated_db_init(void *p) int federated_db_init(void *p)
{ {
DBUG_ENTER("federated_db_init"); DBUG_ENTER("federated_db_init");
#ifdef HAVE_PSI_INTERFACE
init_federated_psi_keys();
#endif /* HAVE_PSI_INTERFACE */
handlerton *federated_hton= (handlerton *)p; handlerton *federated_hton= (handlerton *)p;
federated_hton->state= SHOW_OPTION_YES; federated_hton->state= SHOW_OPTION_YES;
federated_hton->db_type= DB_TYPE_FEDERATED_DB; federated_hton->db_type= DB_TYPE_FEDERATED_DB;
...@@ -457,7 +484,8 @@ int federated_db_init(void *p) ...@@ -457,7 +484,8 @@ int federated_db_init(void *p)
federated_hton->commit= 0; federated_hton->commit= 0;
federated_hton->rollback= 0; federated_hton->rollback= 0;
if (pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST)) if (mysql_mutex_init(fe_key_mutex_federated,
&federated_mutex, MY_MUTEX_INIT_FAST))
goto error; goto error;
if (!my_hash_init(&federated_open_tables, &my_charset_bin, 32, 0, 0, if (!my_hash_init(&federated_open_tables, &my_charset_bin, 32, 0, 0,
(my_hash_get_key) federated_get_key, 0, 0)) (my_hash_get_key) federated_get_key, 0, 0))
...@@ -465,7 +493,7 @@ int federated_db_init(void *p) ...@@ -465,7 +493,7 @@ int federated_db_init(void *p)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
pthread_mutex_destroy(&federated_mutex); mysql_mutex_destroy(&federated_mutex);
error: error:
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
...@@ -484,7 +512,7 @@ error: ...@@ -484,7 +512,7 @@ error:
int federated_done(void *p) int federated_done(void *p)
{ {
my_hash_free(&federated_open_tables); my_hash_free(&federated_open_tables);
pthread_mutex_destroy(&federated_mutex); mysql_mutex_destroy(&federated_mutex);
return 0; return 0;
} }
...@@ -1487,7 +1515,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table) ...@@ -1487,7 +1515,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
init_alloc_root(&mem_root, 256, 0); init_alloc_root(&mem_root, 256, 0);
pthread_mutex_lock(&federated_mutex); mysql_mutex_lock(&federated_mutex);
tmp_share.share_key= table_name; tmp_share.share_key= table_name;
tmp_share.share_key_length= (uint) strlen(table_name); tmp_share.share_key_length= (uint) strlen(table_name);
...@@ -1529,18 +1557,19 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table) ...@@ -1529,18 +1557,19 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
if (my_hash_insert(&federated_open_tables, (uchar*) share)) if (my_hash_insert(&federated_open_tables, (uchar*) share))
goto error; goto error;
thr_lock_init(&share->lock); thr_lock_init(&share->lock);
pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST); mysql_mutex_init(fe_key_mutex_FEDERATED_SHARE_mutex,
&share->mutex, MY_MUTEX_INIT_FAST);
} }
else else
free_root(&mem_root, MYF(0)); /* prevents memory leak */ free_root(&mem_root, MYF(0)); /* prevents memory leak */
share->use_count++; share->use_count++;
pthread_mutex_unlock(&federated_mutex); mysql_mutex_unlock(&federated_mutex);
DBUG_RETURN(share); DBUG_RETURN(share);
error: error:
pthread_mutex_unlock(&federated_mutex); mysql_mutex_unlock(&federated_mutex);
free_root(&mem_root, MYF(0)); free_root(&mem_root, MYF(0));
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
...@@ -1557,15 +1586,15 @@ static int free_share(FEDERATED_SHARE *share) ...@@ -1557,15 +1586,15 @@ static int free_share(FEDERATED_SHARE *share)
MEM_ROOT mem_root= share->mem_root; MEM_ROOT mem_root= share->mem_root;
DBUG_ENTER("free_share"); DBUG_ENTER("free_share");
pthread_mutex_lock(&federated_mutex); mysql_mutex_lock(&federated_mutex);
if (!--share->use_count) if (!--share->use_count)
{ {
my_hash_delete(&federated_open_tables, (uchar*) share); my_hash_delete(&federated_open_tables, (uchar*) share);
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex); mysql_mutex_destroy(&share->mutex);
free_root(&mem_root, MYF(0)); free_root(&mem_root, MYF(0));
} }
pthread_mutex_unlock(&federated_mutex); mysql_mutex_unlock(&federated_mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
/* Copyright (C) 2003 MySQL AB /* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -71,7 +71,7 @@ typedef struct st_federated_share { ...@@ -71,7 +71,7 @@ typedef struct st_federated_share {
ushort port; ushort port;
size_t table_name_length, server_name_length, connect_string_length, use_count; size_t table_name_length, server_name_length, connect_string_length, use_count;
pthread_mutex_t mutex; mysql_mutex_t mutex;
THR_LOCK lock; THR_LOCK lock;
} FEDERATED_SHARE; } FEDERATED_SHARE;
......
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -39,6 +39,10 @@ int heap_init(void *p) ...@@ -39,6 +39,10 @@ int heap_init(void *p)
{ {
handlerton *heap_hton; handlerton *heap_hton;
#ifdef HAVE_PSI_INTERFACE
init_heap_psi_keys();
#endif
heap_hton= (handlerton *)p; heap_hton= (handlerton *)p;
heap_hton->state= SHOW_OPTION_YES; heap_hton->state= SHOW_OPTION_YES;
heap_hton->db_type= DB_TYPE_HEAP; heap_hton->db_type= DB_TYPE_HEAP;
...@@ -106,9 +110,9 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked) ...@@ -106,9 +110,9 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
if (!file) if (!file)
{ {
/* Couldn't open table; Remove the newly created table */ /* Couldn't open table; Remove the newly created table */
pthread_mutex_lock(&THR_LOCK_heap); mysql_mutex_lock(&THR_LOCK_heap);
hp_free(internal_share); hp_free(internal_share);
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
} }
implicit_emptied= 1; implicit_emptied= 1;
} }
......
/* Copyright (C) 2000-2002, 2004 MySQL AB /* Copyright (C) 2000-2002, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -103,9 +103,14 @@ extern void hp_clear_keys(HP_SHARE *info); ...@@ -103,9 +103,14 @@ extern void hp_clear_keys(HP_SHARE *info);
extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
key_part_map keypart_map); key_part_map keypart_map);
#ifdef THREAD #ifdef THREAD
extern pthread_mutex_t THR_LOCK_heap; extern mysql_mutex_t THR_LOCK_heap;
#else
#define pthread_mutex_lock(A)
#define pthread_mutex_unlock(A)
#endif #endif
#ifdef HAVE_PSI_INTERFACE
#ifdef THREAD
extern PSI_mutex_key hp_key_mutex_HP_SHARE_intern_lock;
#endif /* THREAD */
void init_heap_psi_keys();
#endif /* HAVE_PSI_INTERFACE */
C_MODE_END C_MODE_END
/* Copyright (C) 2000-2002 MySQL AB /* Copyright (C) 2000-2002 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -24,9 +24,9 @@ int heap_close(HP_INFO *info) ...@@ -24,9 +24,9 @@ int heap_close(HP_INFO *info)
{ {
int tmp; int tmp;
DBUG_ENTER("heap_close"); DBUG_ENTER("heap_close");
pthread_mutex_lock(&THR_LOCK_heap); mysql_mutex_lock(&THR_LOCK_heap);
tmp= hp_close(info); tmp= hp_close(info);
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(tmp); DBUG_RETURN(tmp);
} }
......
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -32,7 +32,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, ...@@ -32,7 +32,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
if (!create_info->internal_table) if (!create_info->internal_table)
{ {
pthread_mutex_lock(&THR_LOCK_heap); mysql_mutex_lock(&THR_LOCK_heap);
if ((share= hp_find_named_heap(name)) && share->open_count == 0) if ((share= hp_find_named_heap(name)) && share->open_count == 0)
{ {
hp_free(share); hp_free(share);
...@@ -194,7 +194,8 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, ...@@ -194,7 +194,8 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
} }
#ifdef THREAD #ifdef THREAD
thr_lock_init(&share->lock); thr_lock_init(&share->lock);
pthread_mutex_init(&share->intern_lock,MY_MUTEX_INIT_FAST); mysql_mutex_init(hp_key_mutex_HP_SHARE_intern_lock,
&share->intern_lock, MY_MUTEX_INIT_FAST);
#endif #endif
if (!create_info->internal_table) if (!create_info->internal_table)
{ {
...@@ -205,14 +206,14 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, ...@@ -205,14 +206,14 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
share->delete_on_close= 1; share->delete_on_close= 1;
} }
if (!create_info->internal_table) if (!create_info->internal_table)
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
*res= share; *res= share;
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
if (!create_info->internal_table) if (!create_info->internal_table)
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(1); DBUG_RETURN(1);
} /* heap_create */ } /* heap_create */
...@@ -266,7 +267,7 @@ int heap_delete_table(const char *name) ...@@ -266,7 +267,7 @@ int heap_delete_table(const char *name)
reg1 HP_SHARE *share; reg1 HP_SHARE *share;
DBUG_ENTER("heap_delete_table"); DBUG_ENTER("heap_delete_table");
pthread_mutex_lock(&THR_LOCK_heap); mysql_mutex_lock(&THR_LOCK_heap);
if ((share= hp_find_named_heap(name))) if ((share= hp_find_named_heap(name)))
{ {
heap_try_free(share); heap_try_free(share);
...@@ -276,7 +277,7 @@ int heap_delete_table(const char *name) ...@@ -276,7 +277,7 @@ int heap_delete_table(const char *name)
{ {
result= my_errno=ENOENT; result= my_errno=ENOENT;
} }
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(result); DBUG_RETURN(result);
} }
...@@ -284,9 +285,9 @@ int heap_delete_table(const char *name) ...@@ -284,9 +285,9 @@ int heap_delete_table(const char *name)
void heap_drop_table(HP_INFO *info) void heap_drop_table(HP_INFO *info)
{ {
DBUG_ENTER("heap_drop_table"); DBUG_ENTER("heap_drop_table");
pthread_mutex_lock(&THR_LOCK_heap); mysql_mutex_lock(&THR_LOCK_heap);
heap_try_free(info->s); heap_try_free(info->s);
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -298,7 +299,7 @@ void hp_free(HP_SHARE *share) ...@@ -298,7 +299,7 @@ void hp_free(HP_SHARE *share)
hp_clear(share); /* Remove blocks from memory */ hp_clear(share); /* Remove blocks from memory */
#ifdef THREAD #ifdef THREAD
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->intern_lock); mysql_mutex_destroy(&share->intern_lock);
#endif #endif
my_free((uchar*) share->name, MYF(0)); my_free((uchar*) share->name, MYF(0));
my_free((uchar*) share, MYF(0)); my_free((uchar*) share, MYF(0));
......
/* Copyright (C) 2000-2004, 2006 MySQL AB /* Copyright (C) 2000-2004, 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -69,13 +69,13 @@ HP_INFO *heap_open_from_share_and_register(HP_SHARE *share, int mode) ...@@ -69,13 +69,13 @@ HP_INFO *heap_open_from_share_and_register(HP_SHARE *share, int mode)
HP_INFO *info; HP_INFO *info;
DBUG_ENTER("heap_open_from_share_and_register"); DBUG_ENTER("heap_open_from_share_and_register");
pthread_mutex_lock(&THR_LOCK_heap); mysql_mutex_lock(&THR_LOCK_heap);
if ((info= heap_open_from_share(share, mode))) if ((info= heap_open_from_share(share, mode)))
{ {
info->open_list.data= (void*) info; info->open_list.data= (void*) info;
heap_open_list= list_add(heap_open_list,&info->open_list); heap_open_list= list_add(heap_open_list,&info->open_list);
} }
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(info); DBUG_RETURN(info);
} }
...@@ -94,11 +94,11 @@ HP_INFO *heap_open(const char *name, int mode) ...@@ -94,11 +94,11 @@ HP_INFO *heap_open(const char *name, int mode)
HP_SHARE *share; HP_SHARE *share;
DBUG_ENTER("heap_open"); DBUG_ENTER("heap_open");
pthread_mutex_lock(&THR_LOCK_heap); mysql_mutex_lock(&THR_LOCK_heap);
if (!(share= hp_find_named_heap(name))) if (!(share= hp_find_named_heap(name)))
{ {
my_errno= ENOENT; my_errno= ENOENT;
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if ((info= heap_open_from_share(share, mode))) if ((info= heap_open_from_share(share, mode)))
...@@ -106,7 +106,7 @@ HP_INFO *heap_open(const char *name, int mode) ...@@ -106,7 +106,7 @@ HP_INFO *heap_open(const char *name, int mode)
info->open_list.data= (void*) info; info->open_list.data= (void*) info;
heap_open_list= list_add(heap_open_list,&info->open_list); heap_open_list= list_add(heap_open_list,&info->open_list);
} }
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(info); DBUG_RETURN(info);
} }
......
/* Copyright (C) 2000-2002 MySQL AB /* Copyright (C) 2000-2002 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -23,7 +23,7 @@ int hp_panic(enum ha_panic_function flag) ...@@ -23,7 +23,7 @@ int hp_panic(enum ha_panic_function flag)
LIST *element,*next_open; LIST *element,*next_open;
DBUG_ENTER("hp_panic"); DBUG_ENTER("hp_panic");
pthread_mutex_lock(&THR_LOCK_heap); mysql_mutex_lock(&THR_LOCK_heap);
for (element=heap_open_list ; element ; element=next_open) for (element=heap_open_list ; element ; element=next_open)
{ {
HP_INFO *info=(HP_INFO*) element->data; HP_INFO *info=(HP_INFO*) element->data;
...@@ -51,6 +51,6 @@ int hp_panic(enum ha_panic_function flag) ...@@ -51,6 +51,6 @@ int hp_panic(enum ha_panic_function flag)
break; break;
} }
} }
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(0); DBUG_RETURN(0);
} /* hp_panic */ } /* hp_panic */
/* Copyright (C) 2000-2002 MySQL AB /* Copyright (C) 2000-2002 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -25,17 +25,17 @@ int heap_rename(const char *old_name, const char *new_name) ...@@ -25,17 +25,17 @@ int heap_rename(const char *old_name, const char *new_name)
char *name_buff; char *name_buff;
DBUG_ENTER("heap_rename"); DBUG_ENTER("heap_rename");
pthread_mutex_lock(&THR_LOCK_heap); mysql_mutex_lock(&THR_LOCK_heap);
if ((info = hp_find_named_heap(old_name))) if ((info = hp_find_named_heap(old_name)))
{ {
if (!(name_buff=(char*) my_strdup(new_name,MYF(MY_WME)))) if (!(name_buff=(char*) my_strdup(new_name,MYF(MY_WME))))
{ {
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
} }
my_free(info->name,MYF(0)); my_free(info->name,MYF(0));
info->name=name_buff; info->name=name_buff;
} }
pthread_mutex_unlock(&THR_LOCK_heap); mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/* Copyright (C) 2000-2001 MySQL AB /* Copyright (C) 2000-2001 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -23,3 +23,34 @@ ...@@ -23,3 +23,34 @@
#endif #endif
LIST *heap_open_list=0,*heap_share_list=0; LIST *heap_open_list=0,*heap_share_list=0;
#ifdef HAVE_PSI_INTERFACE
#ifdef THREAD
PSI_mutex_key hp_key_mutex_HP_SHARE_intern_lock;
static PSI_mutex_info all_heap_mutexes[]=
{
{ & hp_key_mutex_HP_SHARE_intern_lock, "HP_SHARE::intern_lock", 0}
/*
Note:
THR_LOCK_heap is part of mysys, not storage/heap.
*/
};
#endif /* THREAD */
void init_heap_psi_keys()
{
#ifdef THREAD
const char* category= "memory";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_heap_mutexes);
PSI_server->register_mutex(category, all_heap_mutexes, count);
#endif /* THREAD */
}
#endif /* HAVE_PSI_INTERFACE */
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -118,7 +118,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, ...@@ -118,7 +118,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
*/ */
#ifdef THREAD #ifdef THREAD
if (param->need_print_msg_lock) if (param->need_print_msg_lock)
pthread_mutex_lock(&param->print_msg_mutex); mysql_mutex_lock(&param->print_msg_mutex);
#endif #endif
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store(name, length, system_charset_info); protocol->store(name, length, system_charset_info);
...@@ -130,7 +130,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, ...@@ -130,7 +130,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
msgbuf); msgbuf);
#ifdef THREAD #ifdef THREAD
if (param->need_print_msg_lock) if (param->need_print_msg_lock)
pthread_mutex_unlock(&param->print_msg_mutex); mysql_mutex_unlock(&param->print_msg_mutex);
#endif #endif
return; return;
} }
...@@ -762,13 +762,13 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) ...@@ -762,13 +762,13 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
mi_is_crashed(file)) mi_is_crashed(file))
{ {
file->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; file->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
pthread_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED | share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR); STATE_CRASHED_ON_REPAIR);
if (!(table->db_stat & HA_READ_ONLY)) if (!(table->db_stat & HA_READ_ONLY))
error=update_state_info(&param,file,UPDATE_TIME | UPDATE_OPEN_COUNT | error=update_state_info(&param,file,UPDATE_TIME | UPDATE_OPEN_COUNT |
UPDATE_STAT); UPDATE_STAT);
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE | info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
HA_STATUS_CONST); HA_STATUS_CONST);
} }
...@@ -812,9 +812,9 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt) ...@@ -812,9 +812,9 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
error = chk_key(&param, file); error = chk_key(&param, file);
if (!error) if (!error)
{ {
pthread_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
error=update_state_info(&param,file,UPDATE_STAT); error=update_state_info(&param,file,UPDATE_STAT);
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
} }
else if (!mi_is_crashed(file) && !thd->killed) else if (!mi_is_crashed(file) && !thd->killed)
mi_mark_crashed(file); mi_mark_crashed(file);
...@@ -1926,6 +1926,10 @@ static int myisam_init(void *p) ...@@ -1926,6 +1926,10 @@ static int myisam_init(void *p)
{ {
handlerton *myisam_hton; handlerton *myisam_hton;
#ifdef HAVE_PSI_INTERFACE
init_myisam_psi_keys();
#endif
myisam_hton= (handlerton *)p; myisam_hton= (handlerton *)p;
myisam_hton->state= SHOW_OPTION_YES; myisam_hton->state= SHOW_OPTION_YES;
myisam_hton->db_type= DB_TYPE_MYISAM; myisam_hton->db_type= DB_TYPE_MYISAM;
......
/* 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 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 it under the terms of the GNU General Public License as published by
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
is set) - unread part is bzero'ed is set) - unread part is bzero'ed
Note: out-of-cache reads are enabled for shared IO_CACHE's too, Note: out-of-cache reads are enabled for shared IO_CACHE's too,
as these reads will be cached by OS cache (and my_pread is always atomic) as these reads will be cached by OS cache (and mysql_file_pread is always atomic)
*/ */
...@@ -49,7 +49,7 @@ int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length, ...@@ -49,7 +49,7 @@ int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length,
if ((my_off_t) read_length > (my_off_t) (info->pos_in_file-pos)) if ((my_off_t) read_length > (my_off_t) (info->pos_in_file-pos))
read_length=(uint) (info->pos_in_file-pos); read_length=(uint) (info->pos_in_file-pos);
info->seek_not_done=1; info->seek_not_done=1;
if (my_pread(info->file,buff,read_length,pos,MYF(MY_NABP))) if (mysql_file_pread(info->file, buff, read_length, pos, MYF(MY_NABP)))
DBUG_RETURN(1); DBUG_RETURN(1);
if (!(length-=read_length)) if (!(length-=read_length))
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -88,7 +88,8 @@ int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length, ...@@ -88,7 +88,8 @@ int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length,
else else
{ {
info->seek_not_done=1; info->seek_not_done=1;
if ((read_length=my_pread(info->file,buff,length,pos,MYF(0))) == length) if ((read_length= mysql_file_pread(info->file, buff, length, pos,
MYF(0))) == length)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (!(flag & READING_HEADER) || (int) read_length == -1 || if (!(flag & READING_HEADER) || (int) read_length == -1 ||
......
This diff is collapsed.
/* Copyright (C) 2000-2004 MySQL AB /* Copyright (C) 2000-2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -31,7 +31,7 @@ int mi_close(register MI_INFO *info) ...@@ -31,7 +31,7 @@ int mi_close(register MI_INFO *info)
(long) info, (uint) share->reopen, (long) info, (uint) share->reopen,
(uint) share->tot_locks)); (uint) share->tot_locks));
pthread_mutex_lock(&THR_LOCK_myisam); mysql_mutex_lock(&THR_LOCK_myisam);
if (info->lock_type == F_EXTRA_LCK) if (info->lock_type == F_EXTRA_LCK)
info->lock_type=F_UNLCK; /* HA_EXTRA_NO_USER_CHANGE */ info->lock_type=F_UNLCK; /* HA_EXTRA_NO_USER_CHANGE */
...@@ -40,7 +40,7 @@ int mi_close(register MI_INFO *info) ...@@ -40,7 +40,7 @@ int mi_close(register MI_INFO *info)
if (mi_lock_database(info,F_UNLCK)) if (mi_lock_database(info,F_UNLCK))
error=my_errno; error=my_errno;
} }
pthread_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
if (share->options & HA_OPTION_READ_ONLY_DATA) if (share->options & HA_OPTION_READ_ONLY_DATA)
{ {
...@@ -55,7 +55,7 @@ int mi_close(register MI_INFO *info) ...@@ -55,7 +55,7 @@ int mi_close(register MI_INFO *info)
} }
flag= !--share->reopen; flag= !--share->reopen;
myisam_open_list=list_delete(myisam_open_list,&info->open_list); myisam_open_list=list_delete(myisam_open_list,&info->open_list);
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR)); my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR));
if (flag) if (flag)
...@@ -79,7 +79,7 @@ int mi_close(register MI_INFO *info) ...@@ -79,7 +79,7 @@ int mi_close(register MI_INFO *info)
mi_state_info_write(share->kfile, &share->state, 1); mi_state_info_write(share->kfile, &share->state, 1);
/* Decrement open count must be last I/O on this file. */ /* Decrement open count must be last I/O on this file. */
_mi_decrement_open_count(info); _mi_decrement_open_count(info);
if (my_close(share->kfile,MYF(0))) if (mysql_file_close(share->kfile, MYF(0)))
error = my_errno; error = my_errno;
} }
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
...@@ -93,25 +93,25 @@ int mi_close(register MI_INFO *info) ...@@ -93,25 +93,25 @@ int mi_close(register MI_INFO *info)
} }
#ifdef THREAD #ifdef THREAD
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->intern_lock); mysql_mutex_destroy(&share->intern_lock);
{ {
int i,keys; int i,keys;
keys = share->state.header.keys; keys = share->state.header.keys;
(void) rwlock_destroy(&share->mmap_lock); mysql_rwlock_destroy(&share->mmap_lock);
for(i=0; i<keys; i++) { for(i=0; i<keys; i++) {
(void) rwlock_destroy(&share->key_root_lock[i]); mysql_rwlock_destroy(&share->key_root_lock[i]);
} }
} }
#endif #endif
my_free((uchar*) info->s,MYF(0)); my_free((uchar*) info->s,MYF(0));
} }
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
if (info->ftparser_param) if (info->ftparser_param)
{ {
my_free((uchar*)info->ftparser_param, MYF(0)); my_free((uchar*)info->ftparser_param, MYF(0));
info->ftparser_param= 0; info->ftparser_param= 0;
} }
if (info->dfile >= 0 && my_close(info->dfile,MYF(0))) if (info->dfile >= 0 && mysql_file_close(info->dfile, MYF(0)))
error = my_errno; error = my_errno;
myisam_log_command(MI_LOG_CLOSE,info,NULL,0,error); myisam_log_command(MI_LOG_CLOSE,info,NULL,0,error);
......
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -572,7 +572,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -572,7 +572,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
if (! (flags & HA_DONT_TOUCH_DATA)) if (! (flags & HA_DONT_TOUCH_DATA))
share.state.create_time= (long) time((time_t*) 0); share.state.create_time= (long) time((time_t*) 0);
pthread_mutex_lock(&THR_LOCK_myisam); mysql_mutex_lock(&THR_LOCK_myisam);
/* /*
NOTE: For test_if_reopen() we need a real path name. Hence we need NOTE: For test_if_reopen() we need a real path name. Hence we need
...@@ -638,8 +638,10 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -638,8 +638,10 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
goto err; goto err;
} }
if ((file= my_create_with_symlink(linkname_ptr, filename, 0, create_mode, if ((file= mysql_file_create_with_symlink(mi_key_file_kfile,
MYF(MY_WME | create_flag))) < 0) linkname_ptr, filename, 0,
create_mode,
MYF(MY_WME | create_flag))) < 0)
goto err; goto err;
errpos=1; errpos=1;
...@@ -694,8 +696,10 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -694,8 +696,10 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD; create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
} }
if ((dfile= if ((dfile=
my_create_with_symlink(linkname_ptr, filename, 0, create_mode, mysql_file_create_with_symlink(mi_key_file_dfile,
MYF(MY_WME | create_flag))) < 0) linkname_ptr, filename, 0,
create_mode,
MYF(MY_WME | create_flag))) < 0)
goto err; goto err;
} }
errpos=3; errpos=3;
...@@ -706,9 +710,9 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -706,9 +710,9 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
mi_base_info_write(file, &share.base)) mi_base_info_write(file, &share.base))
goto err; goto err;
#ifndef DBUG_OFF #ifndef DBUG_OFF
if ((uint) my_tell(file,MYF(0)) != base_pos+ MI_BASE_INFO_SIZE) if ((uint) mysql_file_tell(file, MYF(0)) != base_pos + MI_BASE_INFO_SIZE)
{ {
uint pos=(uint) my_tell(file,MYF(0)); uint pos=(uint) mysql_file_tell(file, MYF(0));
DBUG_PRINT("warning",("base_length: %d != used_length: %d", DBUG_PRINT("warning",("base_length: %d != used_length: %d",
base_pos+ MI_BASE_INFO_SIZE, pos)); base_pos+ MI_BASE_INFO_SIZE, pos));
} }
...@@ -803,9 +807,9 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -803,9 +807,9 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
goto err; goto err;
#ifndef DBUG_OFF #ifndef DBUG_OFF
if ((uint) my_tell(file,MYF(0)) != info_length) if ((uint) mysql_file_tell(file, MYF(0)) != info_length)
{ {
uint pos= (uint) my_tell(file,MYF(0)); uint pos= (uint) mysql_file_tell(file, MYF(0));
DBUG_PRINT("warning",("info_length: %d != used_length: %d", DBUG_PRINT("warning",("info_length: %d != used_length: %d",
info_length, pos)); info_length, pos));
} }
...@@ -813,46 +817,49 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -813,46 +817,49 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
/* Enlarge files */ /* Enlarge files */
DBUG_PRINT("info", ("enlarge to keystart: %lu", (ulong) share.base.keystart)); DBUG_PRINT("info", ("enlarge to keystart: %lu", (ulong) share.base.keystart));
if (my_chsize(file,(ulong) share.base.keystart,0,MYF(0))) if (mysql_file_chsize(file, (ulong) share.base.keystart, 0, MYF(0)))
goto err; goto err;
if (! (flags & HA_DONT_TOUCH_DATA)) if (! (flags & HA_DONT_TOUCH_DATA))
{ {
#ifdef USE_RELOC #ifdef USE_RELOC
if (my_chsize(dfile,share.base.min_pack_length*ci->reloc_rows,0,MYF(0))) if (mysql_file_chsize(dfile, share.base.min_pack_length*ci->reloc_rows,
0, MYF(0)))
goto err; goto err;
#endif #endif
errpos=2; errpos=2;
if (my_close(dfile,MYF(0))) if (mysql_file_close(dfile, MYF(0)))
goto err; goto err;
} }
errpos=0; errpos=0;
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
if (my_close(file,MYF(0))) if (mysql_file_close(file, MYF(0)))
goto err; goto err;
my_free((char*) rec_per_key_part,MYF(0)); my_free((char*) rec_per_key_part,MYF(0));
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
save_errno=my_errno; save_errno=my_errno;
switch (errpos) { switch (errpos) {
case 3: case 3:
(void) my_close(dfile,MYF(0)); (void) mysql_file_close(dfile, MYF(0));
/* fall through */ /* fall through */
case 2: case 2:
/* QQ: Tnu should add a call to my_raid_delete() here */ /* QQ: Tnu should add a call to my_raid_delete() here */
if (! (flags & HA_DONT_TOUCH_DATA)) if (! (flags & HA_DONT_TOUCH_DATA))
my_delete_with_symlink(fn_format(filename,name,"",MI_NAME_DEXT, mysql_file_delete_with_symlink(mi_key_file_dfile,
MY_UNPACK_FILENAME | MY_APPEND_EXT), fn_format(filename, name, "", MI_NAME_DEXT,
MYF(0)); MY_UNPACK_FILENAME | MY_APPEND_EXT),
MYF(0));
/* fall through */ /* fall through */
case 1: case 1:
(void) my_close(file,MYF(0)); (void) mysql_file_close(file, MYF(0));
if (! (flags & HA_DONT_TOUCH_DATA)) if (! (flags & HA_DONT_TOUCH_DATA))
my_delete_with_symlink(fn_format(filename,name,"",MI_NAME_IEXT, mysql_file_delete_with_symlink(mi_key_file_kfile,
MY_UNPACK_FILENAME | MY_APPEND_EXT), fn_format(filename, name, "", MI_NAME_IEXT,
MYF(0)); MY_UNPACK_FILENAME | MY_APPEND_EXT),
MYF(0));
} }
my_free((char*) rec_per_key_part, MYF(0)); my_free((char*) rec_per_key_part, MYF(0));
DBUG_RETURN(my_errno=save_errno); /* return the fatal errno */ DBUG_RETURN(my_errno=save_errno); /* return the fatal errno */
......
/* Copyright (C) 2000-2003, 2005 MySQL AB /* Copyright (C) 2000-2003, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -57,8 +57,8 @@ int mi_delete_all_rows(MI_INFO *info) ...@@ -57,8 +57,8 @@ int mi_delete_all_rows(MI_INFO *info)
if (share->file_map) if (share->file_map)
_mi_unmap_file(info); _mi_unmap_file(info);
#endif #endif
if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)) || if (mysql_file_chsize(info->dfile, 0, 0, MYF(MY_WME)) ||
my_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)) ) mysql_file_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)))
goto err; goto err;
(void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE); (void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
......
/* Copyright (C) 2000-2001, 2004, 2006 MySQL AB /* Copyright (C) 2000-2001, 2004, 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -58,12 +58,13 @@ int mi_delete_table(const char *name) ...@@ -58,12 +58,13 @@ int mi_delete_table(const char *name)
#endif /* USE_RAID */ #endif /* USE_RAID */
fn_format(from,name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(from,name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
if (my_delete_with_symlink(from, MYF(MY_WME))) if (mysql_file_delete_with_symlink(mi_key_file_kfile, from, MYF(MY_WME)))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
fn_format(from,name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(from,name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
#ifdef USE_RAID #ifdef USE_RAID
if (raid_type) if (raid_type)
DBUG_RETURN(my_raid_delete(from, raid_chunks, MYF(MY_WME)) ? my_errno : 0); DBUG_RETURN(my_raid_delete(from, raid_chunks, MYF(MY_WME)) ? my_errno : 0);
#endif #endif
DBUG_RETURN(my_delete_with_symlink(from, MYF(MY_WME)) ? my_errno : 0); DBUG_RETURN(mysql_file_delete_with_symlink(mi_key_file_dfile,
from, MYF(MY_WME)) ? my_errno : 0);
} }
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -143,7 +143,7 @@ size_t mi_mmap_pread(MI_INFO *info, uchar *Buffer, ...@@ -143,7 +143,7 @@ size_t mi_mmap_pread(MI_INFO *info, uchar *Buffer,
{ {
DBUG_PRINT("info", ("mi_read with mmap %d\n", info->dfile)); DBUG_PRINT("info", ("mi_read with mmap %d\n", info->dfile));
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_rdlock(&info->s->mmap_lock); mysql_rwlock_rdlock(&info->s->mmap_lock);
/* /*
The following test may fail in the following cases: The following test may fail in the following cases:
...@@ -156,24 +156,24 @@ size_t mi_mmap_pread(MI_INFO *info, uchar *Buffer, ...@@ -156,24 +156,24 @@ size_t mi_mmap_pread(MI_INFO *info, uchar *Buffer,
{ {
memcpy(Buffer, info->s->file_map + offset, Count); memcpy(Buffer, info->s->file_map + offset, Count);
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_unlock(&info->s->mmap_lock); mysql_rwlock_unlock(&info->s->mmap_lock);
return 0; return 0;
} }
else else
{ {
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_unlock(&info->s->mmap_lock); mysql_rwlock_unlock(&info->s->mmap_lock);
return my_pread(info->dfile, Buffer, Count, offset, MyFlags); return mysql_file_pread(info->dfile, Buffer, Count, offset, MyFlags);
} }
} }
/* wrapper for my_pread in case if mmap isn't used */ /* wrapper for mysql_file_pread in case if mmap isn't used */
size_t mi_nommap_pread(MI_INFO *info, uchar *Buffer, size_t mi_nommap_pread(MI_INFO *info, uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags) size_t Count, my_off_t offset, myf MyFlags)
{ {
return my_pread(info->dfile, Buffer, Count, offset, MyFlags); return mysql_file_pread(info->dfile, Buffer, Count, offset, MyFlags);
} }
...@@ -198,7 +198,7 @@ size_t mi_mmap_pwrite(MI_INFO *info, const uchar *Buffer, ...@@ -198,7 +198,7 @@ size_t mi_mmap_pwrite(MI_INFO *info, const uchar *Buffer,
{ {
DBUG_PRINT("info", ("mi_write with mmap %d\n", info->dfile)); DBUG_PRINT("info", ("mi_write with mmap %d\n", info->dfile));
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_rdlock(&info->s->mmap_lock); mysql_rwlock_rdlock(&info->s->mmap_lock);
/* /*
The following test may fail in the following cases: The following test may fail in the following cases:
...@@ -211,26 +211,26 @@ size_t mi_mmap_pwrite(MI_INFO *info, const uchar *Buffer, ...@@ -211,26 +211,26 @@ size_t mi_mmap_pwrite(MI_INFO *info, const uchar *Buffer,
{ {
memcpy(info->s->file_map + offset, Buffer, Count); memcpy(info->s->file_map + offset, Buffer, Count);
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_unlock(&info->s->mmap_lock); mysql_rwlock_unlock(&info->s->mmap_lock);
return 0; return 0;
} }
else else
{ {
info->s->nonmmaped_inserts++; info->s->nonmmaped_inserts++;
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_unlock(&info->s->mmap_lock); mysql_rwlock_unlock(&info->s->mmap_lock);
return my_pwrite(info->dfile, Buffer, Count, offset, MyFlags); return mysql_file_pwrite(info->dfile, Buffer, Count, offset, MyFlags);
} }
} }
/* wrapper for my_pwrite in case if mmap isn't used */ /* wrapper for mysql_file_pwrite in case if mmap isn't used */
size_t mi_nommap_pwrite(MI_INFO *info, const uchar *Buffer, size_t mi_nommap_pwrite(MI_INFO *info, const uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags) size_t Count, my_off_t offset, myf MyFlags)
{ {
return my_pwrite(info->dfile, Buffer, Count, offset, MyFlags); return mysql_file_pwrite(info->dfile, Buffer, Count, offset, MyFlags);
} }
...@@ -1642,7 +1642,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos, ...@@ -1642,7 +1642,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
while (length > IO_SIZE*2) while (length > IO_SIZE*2)
{ {
if (my_pread(file,temp_buff,next_length,filepos, MYF(MY_NABP)) || if (mysql_file_pread(file, temp_buff, next_length, filepos, MYF(MY_NABP)) ||
memcmp(buff, temp_buff, next_length)) memcmp(buff, temp_buff, next_length))
goto err; goto err;
filepos+=next_length; filepos+=next_length;
...@@ -1650,7 +1650,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos, ...@@ -1650,7 +1650,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
length-= next_length; length-= next_length;
next_length=IO_SIZE*2; next_length=IO_SIZE*2;
} }
if (my_pread(file,temp_buff,length,filepos,MYF(MY_NABP))) if (mysql_file_pread(file, temp_buff, length, filepos, MYF(MY_NABP)))
goto err; goto err;
DBUG_RETURN(memcmp(buff,temp_buff,length)); DBUG_RETURN(memcmp(buff,temp_buff,length));
err: err:
...@@ -1831,8 +1831,9 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, uchar *buf, ...@@ -1831,8 +1831,9 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, uchar *buf,
block_info.filepos + block_info.data_len && block_info.filepos + block_info.data_len &&
flush_io_cache(&info->rec_cache)) flush_io_cache(&info->rec_cache))
goto err; goto err;
/* my_seek(info->dfile,filepos,MY_SEEK_SET,MYF(0)); */ /* mysql_file_seek(info->dfile, filepos, MY_SEEK_SET, MYF(0)); */
if (my_read(info->dfile,(uchar*) to,block_info.data_len,MYF(MY_NABP))) if (mysql_file_read(info->dfile, (uchar*) to, block_info.data_len,
MYF(MY_NABP)))
{ {
if (my_errno == -1) if (my_errno == -1)
my_errno= HA_ERR_WRONG_IN_RECORD; /* Unexpected end of file */ my_errno= HA_ERR_WRONG_IN_RECORD; /* Unexpected end of file */
...@@ -1880,12 +1881,12 @@ uint _mi_get_block_info(MI_BLOCK_INFO *info, File file, my_off_t filepos) ...@@ -1880,12 +1881,12 @@ uint _mi_get_block_info(MI_BLOCK_INFO *info, File file, my_off_t filepos)
if (file >= 0) if (file >= 0)
{ {
/* /*
We do not use my_pread() here because we want to have the file We do not use mysql_file_pread() here because we want to have the file
pointer set to the end of the header after this function. pointer set to the end of the header after this function.
my_pread() may leave the file pointer untouched. mysql_file_pread() may leave the file pointer untouched.
*/ */
my_seek(file,filepos,MY_SEEK_SET,MYF(0)); mysql_file_seek(file, filepos, MY_SEEK_SET, MYF(0));
if (my_read(file, header, sizeof(info->header),MYF(0)) != if (mysql_file_read(file, header, sizeof(info->header), MYF(0)) !=
sizeof(info->header)) sizeof(info->header))
goto err; goto err;
} }
......
/* Copyright (C) 2000-2005 MySQL AB /* Copyright (C) 2000-2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -74,17 +74,17 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) ...@@ -74,17 +74,17 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) #if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
if ((share->options & HA_OPTION_COMPRESS_RECORD)) if ((share->options & HA_OPTION_COMPRESS_RECORD))
{ {
pthread_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
if (_mi_memmap_file(info)) if (_mi_memmap_file(info))
{ {
/* We don't nead MADV_SEQUENTIAL if small file */ /* We don't nead MADV_SEQUENTIAL if small file */
madvise((char*) share->file_map, share->state.state.data_file_length, madvise((char*) share->file_map, share->state.state.data_file_length,
share->state.state.data_file_length <= RECORD_CACHE_SIZE*16 ? share->state.state.data_file_length <= RECORD_CACHE_SIZE*16 ?
MADV_RANDOM : MADV_SEQUENTIAL); MADV_RANDOM : MADV_SEQUENTIAL);
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
break; break;
} }
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
} }
#endif #endif
if (info->opt_flag & WRITE_CACHE_USED) if (info->opt_flag & WRITE_CACHE_USED)
...@@ -252,16 +252,16 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) ...@@ -252,16 +252,16 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
} }
break; break;
case HA_EXTRA_FORCE_REOPEN: case HA_EXTRA_FORCE_REOPEN:
pthread_mutex_lock(&THR_LOCK_myisam); mysql_mutex_lock(&THR_LOCK_myisam);
share->last_version= 0L; /* Impossible version */ share->last_version= 0L; /* Impossible version */
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
break; break;
case HA_EXTRA_PREPARE_FOR_DROP: case HA_EXTRA_PREPARE_FOR_DROP:
pthread_mutex_lock(&THR_LOCK_myisam); mysql_mutex_lock(&THR_LOCK_myisam);
share->last_version= 0L; /* Impossible version */ share->last_version= 0L; /* Impossible version */
#ifdef __WIN__REMOVE_OBSOLETE_WORKAROUND #ifdef __WIN__REMOVE_OBSOLETE_WORKAROUND
/* Close the isam and data files as Win32 can't drop an open table */ /* Close the isam and data files as Win32 can't drop an open table */
pthread_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
if (flush_key_blocks(share->key_cache, share->kfile, if (flush_key_blocks(share->key_cache, share->kfile,
(function == HA_EXTRA_FORCE_REOPEN ? (function == HA_EXTRA_FORCE_REOPEN ?
FLUSH_RELEASE : FLUSH_IGNORE_CHANGED))) FLUSH_RELEASE : FLUSH_IGNORE_CHANGED)))
...@@ -285,7 +285,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) ...@@ -285,7 +285,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
} }
if (share->kfile >= 0) if (share->kfile >= 0)
_mi_decrement_open_count(info); _mi_decrement_open_count(info);
if (share->kfile >= 0 && my_close(share->kfile,MYF(0))) if (share->kfile >= 0 && mysql_file_close(share->kfile, MYF(0)))
error=my_errno; error=my_errno;
{ {
LIST *list_element ; LIST *list_element ;
...@@ -296,16 +296,16 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) ...@@ -296,16 +296,16 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
MI_INFO *tmpinfo=(MI_INFO*) list_element->data; MI_INFO *tmpinfo=(MI_INFO*) list_element->data;
if (tmpinfo->s == info->s) if (tmpinfo->s == info->s)
{ {
if (tmpinfo->dfile >= 0 && my_close(tmpinfo->dfile,MYF(0))) if (tmpinfo->dfile >= 0 && mysql_file_close(tmpinfo->dfile, MYF(0)))
error = my_errno; error = my_errno;
tmpinfo->dfile= -1; tmpinfo->dfile= -1;
} }
} }
} }
share->kfile= -1; /* Files aren't open anymore */ share->kfile= -1; /* Files aren't open anymore */
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
#endif #endif
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
break; break;
case HA_EXTRA_FLUSH: case HA_EXTRA_FLUSH:
if (!share->temporary) if (!share->temporary)
...@@ -316,9 +316,9 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) ...@@ -316,9 +316,9 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
if (share->not_flushed) if (share->not_flushed)
{ {
share->not_flushed=0; share->not_flushed=0;
if (my_sync(share->kfile, MYF(0))) if (mysql_file_sync(share->kfile, MYF(0)))
error= my_errno; error= my_errno;
if (my_sync(info->dfile, MYF(0))) if (mysql_file_sync(info->dfile, MYF(0)))
error= my_errno; error= my_errno;
if (error) if (error)
{ {
...@@ -349,7 +349,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) ...@@ -349,7 +349,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
break; break;
case HA_EXTRA_MMAP: case HA_EXTRA_MMAP:
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
pthread_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
/* /*
Memory map the data file if it is not already mapped. It is safe Memory map the data file if it is not already mapped. It is safe
to memory map a file while other threads are using file I/O on it. to memory map a file while other threads are using file I/O on it.
...@@ -370,13 +370,13 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) ...@@ -370,13 +370,13 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
share->file_write= mi_mmap_pwrite; share->file_write= mi_mmap_pwrite;
} }
} }
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
#endif #endif
break; break;
case HA_EXTRA_MARK_AS_LOG_TABLE: case HA_EXTRA_MARK_AS_LOG_TABLE:
pthread_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
share->is_log_table= TRUE; share->is_log_table= TRUE;
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
break; break;
case HA_EXTRA_KEY_CACHE: case HA_EXTRA_KEY_CACHE:
case HA_EXTRA_NO_KEY_CACHE: case HA_EXTRA_NO_KEY_CACHE:
......
/* Copyright (C) 2000-2001, 2003-2004 MySQL AB /* Copyright (C) 2000-2001, 2003-2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -42,10 +42,10 @@ int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint flag) ...@@ -42,10 +42,10 @@ int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint flag)
DBUG_RETURN(0); /* Compatible with ISAM */ DBUG_RETURN(0); /* Compatible with ISAM */
if (!(flag & HA_STATUS_NO_LOCK)) if (!(flag & HA_STATUS_NO_LOCK))
{ {
pthread_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
(void) _mi_readinfo(info,F_RDLCK,0); (void) _mi_readinfo(info,F_RDLCK,0);
fast_mi_writeinfo(info); fast_mi_writeinfo(info);
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
} }
if (flag & HA_STATUS_VARIABLE) if (flag & HA_STATUS_VARIABLE)
{ {
...@@ -85,7 +85,7 @@ int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint flag) ...@@ -85,7 +85,7 @@ int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint flag)
x->data_file_name = share->data_file_name; x->data_file_name = share->data_file_name;
x->index_file_name = share->index_file_name; x->index_file_name = share->index_file_name;
} }
if ((flag & HA_STATUS_TIME) && !my_fstat(info->dfile,&state,MYF(0))) if ((flag & HA_STATUS_TIME) && !mysql_file_fstat(info->dfile, &state, MYF(0)))
x->update_time=state.st_mtime; x->update_time=state.st_mtime;
else else
x->update_time=0; x->update_time=0;
......
/* Copyright (C) 2003 MySQL AB /* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -96,7 +96,7 @@ int mi_assign_to_key_cache(MI_INFO *info, ...@@ -96,7 +96,7 @@ int mi_assign_to_key_cache(MI_INFO *info,
ensure that setting the key cache and changing the multi_key_cache ensure that setting the key cache and changing the multi_key_cache
is done atomicly is done atomicly
*/ */
pthread_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
/* /*
Tell all threads to use the new key cache Tell all threads to use the new key cache
This should be seen at the lastes for the next call to an myisam function. This should be seen at the lastes for the next call to an myisam function.
...@@ -108,7 +108,7 @@ int mi_assign_to_key_cache(MI_INFO *info, ...@@ -108,7 +108,7 @@ int mi_assign_to_key_cache(MI_INFO *info,
share->unique_name_length, share->unique_name_length,
share->key_cache)) share->key_cache))
error= my_errno; error= my_errno;
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -143,7 +143,7 @@ void mi_change_key_cache(KEY_CACHE *old_key_cache, ...@@ -143,7 +143,7 @@ void mi_change_key_cache(KEY_CACHE *old_key_cache,
/* /*
Lock list to ensure that no one can close the table while we manipulate it Lock list to ensure that no one can close the table while we manipulate it
*/ */
pthread_mutex_lock(&THR_LOCK_myisam); mysql_mutex_lock(&THR_LOCK_myisam);
for (pos=myisam_open_list ; pos ; pos=pos->next) for (pos=myisam_open_list ; pos ; pos=pos->next)
{ {
MI_INFO *info= (MI_INFO*) pos->data; MI_INFO *info= (MI_INFO*) pos->data;
...@@ -158,6 +158,6 @@ void mi_change_key_cache(KEY_CACHE *old_key_cache, ...@@ -158,6 +158,6 @@ void mi_change_key_cache(KEY_CACHE *old_key_cache,
open a new table that will be associted with the old key cache open a new table that will be associted with the old key cache
*/ */
multi_key_cache_change(old_key_cache, new_key_cache); multi_key_cache_change(old_key_cache, new_key_cache);
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -49,7 +49,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) ...@@ -49,7 +49,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
} }
flag=error=0; flag=error=0;
pthread_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
if (share->kfile >= 0) /* May only be false on windows */ if (share->kfile >= 0) /* May only be false on windows */
{ {
switch (lock_type) { switch (lock_type) {
...@@ -88,11 +88,11 @@ int mi_lock_database(MI_INFO *info, int lock_type) ...@@ -88,11 +88,11 @@ int mi_lock_database(MI_INFO *info, int lock_type)
(info->s->nonmmaped_inserts > MAX_NONMAPPED_INSERTS)) (info->s->nonmmaped_inserts > MAX_NONMAPPED_INSERTS))
{ {
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_wrlock(&info->s->mmap_lock); mysql_rwlock_wrlock(&info->s->mmap_lock);
mi_remap_file(info, info->s->state.state.data_file_length); mi_remap_file(info, info->s->state.state.data_file_length);
info->s->nonmmaped_inserts= 0; info->s->nonmmaped_inserts= 0;
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_unlock(&info->s->mmap_lock); mysql_rwlock_unlock(&info->s->mmap_lock);
} }
#endif #endif
share->state.process= share->last_process=share->this_process; share->state.process= share->last_process=share->this_process;
...@@ -103,9 +103,9 @@ int mi_lock_database(MI_INFO *info, int lock_type) ...@@ -103,9 +103,9 @@ int mi_lock_database(MI_INFO *info, int lock_type)
share->changed=0; share->changed=0;
if (myisam_flush) if (myisam_flush)
{ {
if (my_sync(share->kfile, MYF(0))) if (mysql_file_sync(share->kfile, MYF(0)))
error= my_errno; error= my_errno;
if (my_sync(info->dfile, MYF(0))) if (mysql_file_sync(info->dfile, MYF(0)))
error= my_errno; error= my_errno;
} }
else else
...@@ -251,7 +251,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) ...@@ -251,7 +251,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
} }
} }
#endif #endif
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
#if defined(FULL_LOG) || defined(_lint) #if defined(FULL_LOG) || defined(_lint)
lock_type|=(int) (flag << 8); /* Set bit to set if real lock */ lock_type|=(int) (flag << 8); /* Set bit to set if real lock */
myisam_log_command(MI_LOG_LOCK,info,(uchar*) &lock_type,sizeof(lock_type), myisam_log_command(MI_LOG_LOCK,info,(uchar*) &lock_type,sizeof(lock_type),
...@@ -458,8 +458,8 @@ int _mi_writeinfo(register MI_INFO *info, uint operation) ...@@ -458,8 +458,8 @@ int _mi_writeinfo(register MI_INFO *info, uint operation)
#ifdef _WIN32 #ifdef _WIN32
if (myisam_flush) if (myisam_flush)
{ {
my_sync(share->kfile,0); mysql_file_sync(share->kfile, 0);
my_sync(info->dfile,0); mysql_file_sync(info->dfile, 0);
} }
#endif #endif
} }
...@@ -539,9 +539,9 @@ int _mi_mark_file_changed(MI_INFO *info) ...@@ -539,9 +539,9 @@ int _mi_mark_file_changed(MI_INFO *info)
{ {
mi_int2store(buff,share->state.open_count); mi_int2store(buff,share->state.open_count);
buff[2]=1; /* Mark that it's changed */ buff[2]=1; /* Mark that it's changed */
DBUG_RETURN(my_pwrite(share->kfile,buff,sizeof(buff), DBUG_RETURN(mysql_file_pwrite(share->kfile, buff, sizeof(buff),
sizeof(share->state.header), sizeof(share->state.header),
MYF(MY_NABP))); MYF(MY_NABP)));
} }
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -568,9 +568,9 @@ int _mi_decrement_open_count(MI_INFO *info) ...@@ -568,9 +568,9 @@ int _mi_decrement_open_count(MI_INFO *info)
{ {
share->state.open_count--; share->state.open_count--;
mi_int2store(buff,share->state.open_count); mi_int2store(buff,share->state.open_count);
write_error=my_pwrite(share->kfile,buff,sizeof(buff), write_error= mysql_file_pwrite(share->kfile, buff, sizeof(buff),
sizeof(share->state.header), sizeof(share->state.header),
MYF(MY_NABP)); MYF(MY_NABP));
} }
if (!lock_error) if (!lock_error)
lock_error=mi_lock_database(info,old_lock); lock_error=mi_lock_database(info,old_lock);
......
/* Copyright (C) 2000-2001, 2004 MySQL AB /* Copyright (C) 2000-2001, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -54,16 +54,19 @@ int mi_log(int activate_log) ...@@ -54,16 +54,19 @@ int mi_log(int activate_log)
myisam_pid=(ulong) getpid(); myisam_pid=(ulong) getpid();
if (myisam_log_file < 0) if (myisam_log_file < 0)
{ {
if ((myisam_log_file = my_create(fn_format(buff,myisam_log_filename, if ((myisam_log_file= mysql_file_create(mi_key_file_log,
"",".log",4), fn_format(buff,
0,(O_RDWR | O_BINARY | O_APPEND),MYF(0))) myisam_log_filename,
< 0) "", ".log", 4),
0,
(O_RDWR | O_BINARY | O_APPEND),
MYF(0))) < 0)
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
} }
} }
else if (myisam_log_file >= 0) else if (myisam_log_file >= 0)
{ {
error=my_close(myisam_log_file,MYF(0)) ? my_errno : 0 ; error= mysql_file_close(myisam_log_file, MYF(0)) ? my_errno : 0 ;
myisam_log_file= -1; myisam_log_file= -1;
} }
DBUG_RETURN(error); DBUG_RETURN(error);
...@@ -86,13 +89,13 @@ void _myisam_log(enum myisam_log_commands command, MI_INFO *info, ...@@ -86,13 +89,13 @@ void _myisam_log(enum myisam_log_commands command, MI_INFO *info,
mi_int4store(buff+3,pid); mi_int4store(buff+3,pid);
mi_int2store(buff+9,length); mi_int2store(buff+9,length);
pthread_mutex_lock(&THR_LOCK_myisam); mysql_mutex_lock(&THR_LOCK_myisam);
error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
(void) my_write(myisam_log_file,buff,sizeof(buff),MYF(0)); (void) mysql_file_write(myisam_log_file, buff, sizeof(buff), MYF(0));
(void) my_write(myisam_log_file,buffert,length,MYF(0)); (void) mysql_file_write(myisam_log_file, buffert, length, MYF(0));
if (!error) if (!error)
error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
my_errno=old_errno; my_errno=old_errno;
} }
...@@ -109,14 +112,14 @@ void _myisam_log_command(enum myisam_log_commands command, MI_INFO *info, ...@@ -109,14 +112,14 @@ void _myisam_log_command(enum myisam_log_commands command, MI_INFO *info,
mi_int2store(buff+1,info->dfile); mi_int2store(buff+1,info->dfile);
mi_int4store(buff+3,pid); mi_int4store(buff+3,pid);
mi_int2store(buff+7,result); mi_int2store(buff+7,result);
pthread_mutex_lock(&THR_LOCK_myisam); mysql_mutex_lock(&THR_LOCK_myisam);
error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
(void) my_write(myisam_log_file,buff,sizeof(buff),MYF(0)); (void) mysql_file_write(myisam_log_file, buff, sizeof(buff), MYF(0));
if (buffert) if (buffert)
(void) my_write(myisam_log_file,buffert,length,MYF(0)); (void) mysql_file_write(myisam_log_file, buffert, length, MYF(0));
if (!error) if (!error)
error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
my_errno=old_errno; my_errno=old_errno;
} }
...@@ -140,10 +143,10 @@ void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info, ...@@ -140,10 +143,10 @@ void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info,
mi_int2store(buff+7,result); mi_int2store(buff+7,result);
mi_sizestore(buff+9,filepos); mi_sizestore(buff+9,filepos);
mi_int4store(buff+17,length); mi_int4store(buff+17,length);
pthread_mutex_lock(&THR_LOCK_myisam); mysql_mutex_lock(&THR_LOCK_myisam);
error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
(void) my_write(myisam_log_file, buff,sizeof(buff),MYF(0)); (void) mysql_file_write(myisam_log_file, buff, sizeof(buff), MYF(0));
(void) my_write(myisam_log_file, record,info->s->base.reclength,MYF(0)); (void) mysql_file_write(myisam_log_file, record, info->s->base.reclength, MYF(0));
if (info->s->base.blobs) if (info->s->base.blobs)
{ {
MI_BLOB *blob,*end; MI_BLOB *blob,*end;
...@@ -154,11 +157,11 @@ void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info, ...@@ -154,11 +157,11 @@ void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info,
{ {
memcpy_fixed((uchar*) &pos, record+blob->offset+blob->pack_length, memcpy_fixed((uchar*) &pos, record+blob->offset+blob->pack_length,
sizeof(char*)); sizeof(char*));
(void) my_write(myisam_log_file,pos,blob->length,MYF(0)); (void) mysql_file_write(myisam_log_file, pos, blob->length, MYF(0));
} }
} }
if (!error) if (!error)
error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
my_errno=old_errno; my_errno=old_errno;
} }
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -103,7 +103,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -103,7 +103,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
DBUG_RETURN (NULL); DBUG_RETURN (NULL);
} }
pthread_mutex_lock(&THR_LOCK_myisam); mysql_mutex_lock(&THR_LOCK_myisam);
if (!(old_info=test_if_reopen(name_buff))) if (!(old_info=test_if_reopen(name_buff)))
{ {
share= &share_buff; share= &share_buff;
...@@ -120,17 +120,21 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -120,17 +120,21 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
my_errno= HA_ERR_CRASHED; my_errno= HA_ERR_CRASHED;
goto err; goto err;
}); });
if ((kfile=my_open(name_buff,(open_mode=O_RDWR) | O_SHARE,MYF(0))) < 0) if ((kfile= mysql_file_open(mi_key_file_kfile,
name_buff,
(open_mode= O_RDWR) | O_SHARE, MYF(0))) < 0)
{ {
if ((errno != EROFS && errno != EACCES) || if ((errno != EROFS && errno != EACCES) ||
mode != O_RDONLY || mode != O_RDONLY ||
(kfile=my_open(name_buff,(open_mode=O_RDONLY) | O_SHARE,MYF(0))) < 0) (kfile= mysql_file_open(mi_key_file_kfile,
name_buff,
(open_mode= O_RDONLY) | O_SHARE, MYF(0))) < 0)
goto err; goto err;
} }
share->mode=open_mode; share->mode=open_mode;
errpos=1; errpos=1;
if (my_read(kfile, share->state.header.file_version, head_length, if (mysql_file_read(kfile, share->state.header.file_version, head_length,
MYF(MY_NABP))) MYF(MY_NABP)))
{ {
my_errno= HA_ERR_NOT_A_TABLE; my_errno= HA_ERR_NOT_A_TABLE;
goto err; goto err;
...@@ -181,7 +185,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -181,7 +185,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
end_pos=disk_cache+info_length; end_pos=disk_cache+info_length;
errpos=2; errpos=2;
my_seek(kfile,0L,MY_SEEK_SET,MYF(0)); mysql_file_seek(kfile, 0L, MY_SEEK_SET, MYF(0));
if (!(open_flags & HA_OPEN_TMP_TABLE)) if (!(open_flags & HA_OPEN_TMP_TABLE))
{ {
if ((lock_error=my_lock(kfile,F_RDLCK,0L,F_TO_EOF, if ((lock_error=my_lock(kfile,F_RDLCK,0L,F_TO_EOF,
...@@ -191,7 +195,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -191,7 +195,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
goto err; goto err;
} }
errpos=3; errpos=3;
if (my_read(kfile,disk_cache,info_length,MYF(MY_NABP))) if (mysql_file_read(kfile, disk_cache, info_length, MYF(MY_NABP)))
{ {
my_errno=HA_ERR_CRASHED; my_errno=HA_ERR_CRASHED;
goto err; goto err;
...@@ -309,9 +313,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -309,9 +313,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
&share->state.key_del, &share->state.key_del,
(share->state.header.max_block_size_index*sizeof(my_off_t)), (share->state.header.max_block_size_index*sizeof(my_off_t)),
#ifdef THREAD #ifdef THREAD
&share->key_root_lock,sizeof(rw_lock_t)*keys, &share->key_root_lock, sizeof(mysql_rwlock_t)*keys,
#endif #endif
&share->mmap_lock,sizeof(rw_lock_t), &share->mmap_lock, sizeof(mysql_rwlock_t),
NullS)) NullS))
goto err; goto err;
errpos=4; errpos=4;
...@@ -522,10 +526,12 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -522,10 +526,12 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
share->is_log_table= FALSE; share->is_log_table= FALSE;
#ifdef THREAD #ifdef THREAD
thr_lock_init(&share->lock); thr_lock_init(&share->lock);
pthread_mutex_init(&share->intern_lock,MY_MUTEX_INIT_FAST); mysql_mutex_init(mi_key_mutex_MYISAM_SHARE_intern_lock,
&share->intern_lock, MY_MUTEX_INIT_FAST);
for (i=0; i<keys; i++) for (i=0; i<keys; i++)
(void) my_rwlock_init(&share->key_root_lock[i], NULL); mysql_rwlock_init(mi_key_rwlock_MYISAM_SHARE_key_root_lock,
(void) my_rwlock_init(&share->mmap_lock, NULL); &share->key_root_lock[i]);
mysql_rwlock_init(mi_key_rwlock_MYISAM_SHARE_mmap_lock, &share->mmap_lock);
if (!thr_lock_inited) if (!thr_lock_inited)
{ {
/* Probably a single threaded program; Don't use concurrent inserts */ /* Probably a single threaded program; Don't use concurrent inserts */
...@@ -611,7 +617,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -611,7 +617,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
info.ft1_to_ft2=0; info.ft1_to_ft2=0;
info.errkey= -1; info.errkey= -1;
info.page_changed=1; info.page_changed=1;
pthread_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
info.read_record=share->read_record; info.read_record=share->read_record;
share->reopen++; share->reopen++;
share->write_flag=MYF(MY_NABP | MY_WAIT_IF_FULL); share->write_flag=MYF(MY_NABP | MY_WAIT_IF_FULL);
...@@ -635,7 +641,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -635,7 +641,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
myisam_delay_key_write) myisam_delay_key_write)
share->delay_key_write=1; share->delay_key_write=1;
info.state= &share->state.state; /* Change global values by default */ info.state= &share->state.state; /* Change global values by default */
pthread_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
/* Allocate buffer for one record */ /* Allocate buffer for one record */
...@@ -651,7 +657,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -651,7 +657,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
m_info->open_list.data=(void*) m_info; m_info->open_list.data=(void*) m_info;
myisam_open_list=list_add(myisam_open_list,&m_info->open_list); myisam_open_list=list_add(myisam_open_list,&m_info->open_list);
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
if (myisam_log_file >= 0) if (myisam_log_file >= 0)
{ {
intern_filename(name_buff,share->index_file_name); intern_filename(name_buff,share->index_file_name);
...@@ -670,7 +676,7 @@ err: ...@@ -670,7 +676,7 @@ err:
my_free((uchar*) m_info,MYF(0)); my_free((uchar*) m_info,MYF(0));
/* fall through */ /* fall through */
case 5: case 5:
(void) my_close(info.dfile,MYF(0)); (void) mysql_file_close(info.dfile, MYF(0));
if (old_info) if (old_info)
break; /* Don't remove open table */ break; /* Don't remove open table */
/* fall through */ /* fall through */
...@@ -685,13 +691,13 @@ err: ...@@ -685,13 +691,13 @@ err:
my_afree(disk_cache); my_afree(disk_cache);
/* fall through */ /* fall through */
case 1: case 1:
(void) my_close(kfile,MYF(0)); (void) mysql_file_close(kfile, MYF(0));
/* fall through */ /* fall through */
case 0: case 0:
default: default:
break; break;
} }
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
my_errno=save_errno; my_errno=save_errno;
DBUG_RETURN (NULL); DBUG_RETURN (NULL);
} /* mi_open */ } /* mi_open */
...@@ -924,10 +930,10 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite) ...@@ -924,10 +930,10 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite)
} }
if (pWrite & 1) if (pWrite & 1)
DBUG_RETURN(my_pwrite(file, buff, (size_t) (ptr-buff), 0L, DBUG_RETURN(mysql_file_pwrite(file, buff, (size_t) (ptr-buff), 0L,
MYF(MY_NABP | MY_THREADSAFE)) != 0); MYF(MY_NABP | MY_THREADSAFE)) != 0);
DBUG_RETURN(my_write(file, buff, (size_t) (ptr-buff), DBUG_RETURN(mysql_file_write(file, buff, (size_t) (ptr-buff),
MYF(MY_NABP)) != 0); MYF(MY_NABP)) != 0);
} }
...@@ -992,10 +998,10 @@ uint mi_state_info_read_dsk(File file, MI_STATE_INFO *state, my_bool pRead) ...@@ -992,10 +998,10 @@ uint mi_state_info_read_dsk(File file, MI_STATE_INFO *state, my_bool pRead)
{ {
if (pRead) if (pRead)
{ {
if (my_pread(file, buff, state->state_length,0L, MYF(MY_NABP))) if (mysql_file_pread(file, buff, state->state_length, 0L, MYF(MY_NABP)))
return 1; return 1;
} }
else if (my_read(file, buff, state->state_length,MYF(MY_NABP))) else if (mysql_file_read(file, buff, state->state_length, MYF(MY_NABP)))
return 1; return 1;
mi_state_info_read(buff, state); mi_state_info_read(buff, state);
} }
...@@ -1038,7 +1044,7 @@ uint mi_base_info_write(File file, MI_BASE_INFO *base) ...@@ -1038,7 +1044,7 @@ uint mi_base_info_write(File file, MI_BASE_INFO *base)
mi_int2store(ptr,base->raid_chunks); ptr +=2; mi_int2store(ptr,base->raid_chunks); ptr +=2;
mi_int4store(ptr,base->raid_chunksize); ptr +=4; mi_int4store(ptr,base->raid_chunksize); ptr +=4;
bzero(ptr,6); ptr +=6; /* extra */ bzero(ptr,6); ptr +=6; /* extra */
return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
} }
...@@ -1098,7 +1104,7 @@ uint mi_keydef_write(File file, MI_KEYDEF *keydef) ...@@ -1098,7 +1104,7 @@ uint mi_keydef_write(File file, MI_KEYDEF *keydef)
mi_int2store(ptr,keydef->keylength); ptr +=2; mi_int2store(ptr,keydef->keylength); ptr +=2;
mi_int2store(ptr,keydef->minlength); ptr +=2; mi_int2store(ptr,keydef->minlength); ptr +=2;
mi_int2store(ptr,keydef->maxlength); ptr +=2; mi_int2store(ptr,keydef->maxlength); ptr +=2;
return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
} }
uchar *mi_keydef_read(uchar *ptr, MI_KEYDEF *keydef) uchar *mi_keydef_read(uchar *ptr, MI_KEYDEF *keydef)
...@@ -1142,7 +1148,7 @@ int mi_keyseg_write(File file, const HA_KEYSEG *keyseg) ...@@ -1142,7 +1148,7 @@ int mi_keyseg_write(File file, const HA_KEYSEG *keyseg)
mi_int4store(ptr, pos); mi_int4store(ptr, pos);
ptr+=4; ptr+=4;
return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
} }
...@@ -1184,7 +1190,7 @@ uint mi_uniquedef_write(File file, MI_UNIQUEDEF *def) ...@@ -1184,7 +1190,7 @@ uint mi_uniquedef_write(File file, MI_UNIQUEDEF *def)
*ptr++= (uchar) def->key; *ptr++= (uchar) def->key;
*ptr++ = (uchar) def->null_are_equal; *ptr++ = (uchar) def->null_are_equal;
return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
} }
uchar *mi_uniquedef_read(uchar *ptr, MI_UNIQUEDEF *def) uchar *mi_uniquedef_read(uchar *ptr, MI_UNIQUEDEF *def)
...@@ -1208,7 +1214,7 @@ uint mi_recinfo_write(File file, MI_COLUMNDEF *recinfo) ...@@ -1208,7 +1214,7 @@ uint mi_recinfo_write(File file, MI_COLUMNDEF *recinfo)
mi_int2store(ptr,recinfo->length); ptr +=2; mi_int2store(ptr,recinfo->length); ptr +=2;
*ptr++ = recinfo->null_bit; *ptr++ = recinfo->null_bit;
mi_int2store(ptr,recinfo->null_pos); ptr+= 2; mi_int2store(ptr,recinfo->null_pos); ptr+= 2;
return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
} }
uchar *mi_recinfo_read(uchar *ptr, MI_COLUMNDEF *recinfo) uchar *mi_recinfo_read(uchar *ptr, MI_COLUMNDEF *recinfo)
...@@ -1261,15 +1267,18 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, const char *org_name, ...@@ -1261,15 +1267,18 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, const char *org_name,
} }
else else
#endif #endif
info->dfile=my_open(data_name, share->mode | O_SHARE, MYF(MY_WME)); info->dfile= mysql_file_open(mi_key_file_dfile,
data_name, share->mode | O_SHARE, MYF(MY_WME));
return info->dfile >= 0 ? 0 : 1; return info->dfile >= 0 ? 0 : 1;
} }
int mi_open_keyfile(MYISAM_SHARE *share) int mi_open_keyfile(MYISAM_SHARE *share)
{ {
if ((share->kfile=my_open(share->unique_file_name, share->mode | O_SHARE, if ((share->kfile= mysql_file_open(mi_key_file_kfile,
MYF(MY_WME))) < 0) share->unique_file_name,
share->mode | O_SHARE,
MYF(MY_WME))) < 0)
return 1; return 1;
return 0; return 0;
} }
......
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -150,7 +150,7 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) ...@@ -150,7 +150,7 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
file=info->dfile; file=info->dfile;
my_errno=0; my_errno=0;
if (my_read(file,(uchar*) header,sizeof(header),MYF(MY_NABP))) if (mysql_file_read(file, (uchar*) header, sizeof(header), MYF(MY_NABP)))
{ {
if (!my_errno) if (!my_errno)
my_errno=HA_ERR_END_OF_FILE; my_errno=HA_ERR_END_OF_FILE;
...@@ -224,9 +224,9 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) ...@@ -224,9 +224,9 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
tmp_buff=share->decode_tables+length; tmp_buff=share->decode_tables+length;
disk_cache= (uchar*) (tmp_buff+OFFSET_TABLE_SIZE); disk_cache= (uchar*) (tmp_buff+OFFSET_TABLE_SIZE);
if (my_read(file,disk_cache, if (mysql_file_read(file, disk_cache,
(uint) (share->pack.header_length-sizeof(header)), (uint) (share->pack.header_length-sizeof(header)),
MYF(MY_NABP))) MYF(MY_NABP)))
goto err2; goto err2;
huff_tree_bits=max_bit(trees ? trees-1 : 0); huff_tree_bits=max_bit(trees ? trees-1 : 0);
...@@ -717,8 +717,8 @@ int _mi_read_pack_record(MI_INFO *info, my_off_t filepos, uchar *buf) ...@@ -717,8 +717,8 @@ int _mi_read_pack_record(MI_INFO *info, my_off_t filepos, uchar *buf)
if (_mi_pack_get_block_info(info, &info->bit_buff, &block_info, if (_mi_pack_get_block_info(info, &info->bit_buff, &block_info,
&info->rec_buff, file, filepos)) &info->rec_buff, file, filepos))
goto err; goto err;
if (my_read(file,(uchar*) info->rec_buff + block_info.offset , if (mysql_file_read(file, (uchar*) info->rec_buff + block_info.offset,
block_info.rec_len - block_info.offset, MYF(MY_NABP))) block_info.rec_len - block_info.offset, MYF(MY_NABP)))
goto panic; goto panic;
info->update|= HA_STATE_AKTIV; info->update|= HA_STATE_AKTIV;
DBUG_RETURN(_mi_pack_rec_unpack(info, &info->bit_buff, buf, DBUG_RETURN(_mi_pack_rec_unpack(info, &info->bit_buff, buf,
...@@ -1339,9 +1339,9 @@ int _mi_read_rnd_pack_record(MI_INFO *info, uchar *buf, ...@@ -1339,9 +1339,9 @@ int _mi_read_rnd_pack_record(MI_INFO *info, uchar *buf,
} }
else else
{ {
if (my_read(info->dfile,(uchar*) info->rec_buff + block_info.offset, if (mysql_file_read(info->dfile,
block_info.rec_len-block_info.offset, (uchar*) info->rec_buff + block_info.offset,
MYF(MY_NABP))) block_info.rec_len-block_info.offset, MYF(MY_NABP)))
goto err; goto err;
} }
info->packed_length=block_info.rec_len; info->packed_length=block_info.rec_len;
...@@ -1370,11 +1370,11 @@ uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff, ...@@ -1370,11 +1370,11 @@ uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff,
{ {
ref_length=myisam->s->pack.ref_length; ref_length=myisam->s->pack.ref_length;
/* /*
We can't use my_pread() here because mi_read_rnd_pack_record assumes We can't use mysql_file_pread() here because mi_read_rnd_pack_record assumes
position is ok position is ok
*/ */
my_seek(file,filepos,MY_SEEK_SET,MYF(0)); mysql_file_seek(file, filepos, MY_SEEK_SET, MYF(0));
if (my_read(file, header,ref_length,MYF(MY_NABP))) if (mysql_file_read(file, header, ref_length, MYF(MY_NABP)))
return BLOCK_FATAL_ERROR; return BLOCK_FATAL_ERROR;
DBUG_DUMP("header",(uchar*) header,ref_length); DBUG_DUMP("header",(uchar*) header,ref_length);
} }
...@@ -1496,7 +1496,7 @@ my_bool _mi_memmap_file(MI_INFO *info) ...@@ -1496,7 +1496,7 @@ my_bool _mi_memmap_file(MI_INFO *info)
if (!info->s->file_map) if (!info->s->file_map)
{ {
if (my_seek(info->dfile,0L,MY_SEEK_END,MYF(0)) < if (mysql_file_seek(info->dfile, 0L, MY_SEEK_END, MYF(0)) <
share->state.state.data_file_length+MEMMAP_EXTRA_MARGIN) share->state.state.data_file_length+MEMMAP_EXTRA_MARGIN)
{ {
DBUG_PRINT("warning",("File isn't extended for memmap")); DBUG_PRINT("warning",("File isn't extended for memmap"));
......
/* Copyright (C) 2000-2001, 2003 MySQL AB /* Copyright (C) 2000-2001, 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -30,17 +30,17 @@ int mi_panic(enum ha_panic_function flag) ...@@ -30,17 +30,17 @@ int mi_panic(enum ha_panic_function flag)
MI_INFO *info; MI_INFO *info;
DBUG_ENTER("mi_panic"); DBUG_ENTER("mi_panic");
pthread_mutex_lock(&THR_LOCK_myisam); mysql_mutex_lock(&THR_LOCK_myisam);
for (list_element=myisam_open_list ; list_element ; list_element=next_open) for (list_element=myisam_open_list ; list_element ; list_element=next_open)
{ {
next_open=list_element->next; /* Save if close */ next_open=list_element->next; /* Save if close */
info=(MI_INFO*) list_element->data; info=(MI_INFO*) list_element->data;
switch (flag) { switch (flag) {
case HA_PANIC_CLOSE: case HA_PANIC_CLOSE:
pthread_mutex_unlock(&THR_LOCK_myisam); /* Not exactly right... */ mysql_mutex_unlock(&THR_LOCK_myisam); /* Not exactly right... */
if (mi_close(info)) if (mi_close(info))
error=my_errno; error=my_errno;
pthread_mutex_lock(&THR_LOCK_myisam); mysql_mutex_lock(&THR_LOCK_myisam);
break; break;
case HA_PANIC_WRITE: /* Do this to free databases */ case HA_PANIC_WRITE: /* Do this to free databases */
#ifdef CANT_OPEN_FILES_TWICE #ifdef CANT_OPEN_FILES_TWICE
...@@ -66,9 +66,9 @@ int mi_panic(enum ha_panic_function flag) ...@@ -66,9 +66,9 @@ int mi_panic(enum ha_panic_function flag)
error=my_errno; error=my_errno;
} }
#ifdef CANT_OPEN_FILES_TWICE #ifdef CANT_OPEN_FILES_TWICE
if (info->s->kfile >= 0 && my_close(info->s->kfile,MYF(0))) if (info->s->kfile >= 0 && mysql_file_close(info->s->kfile, MYF(0)))
error = my_errno; error = my_errno;
if (info->dfile >= 0 && my_close(info->dfile,MYF(0))) if (info->dfile >= 0 && mysql_file_close(info->dfile, MYF(0)))
error = my_errno; error = my_errno;
info->s->kfile=info->dfile= -1; /* Files aren't open anymore */ info->s->kfile=info->dfile= -1; /* Files aren't open anymore */
break; break;
...@@ -78,15 +78,19 @@ int mi_panic(enum ha_panic_function flag) ...@@ -78,15 +78,19 @@ int mi_panic(enum ha_panic_function flag)
{ /* Open closed files */ { /* Open closed files */
char name_buff[FN_REFLEN]; char name_buff[FN_REFLEN];
if (info->s->kfile < 0) if (info->s->kfile < 0)
if ((info->s->kfile= my_open(fn_format(name_buff,info->filename,"", if ((info->s->kfile= mysql_file_open(mi_key_file_kfile,
N_NAME_IEXT,4),info->mode, fn_format(name_buff,
MYF(MY_WME))) < 0) info->filename, "",
N_NAME_IEXT, 4),
info->mode, MYF(MY_WME))) < 0)
error = my_errno; error = my_errno;
if (info->dfile < 0) if (info->dfile < 0)
{ {
if ((info->dfile= my_open(fn_format(name_buff,info->filename,"", if ((info->dfile= mysql_file_open(mi_key_file_dfile,
N_NAME_DEXT,4),info->mode, fn_format(name_buff,
MYF(MY_WME))) < 0) info->filename, "",
N_NAME_DEXT, 4),
info->mode, MYF(MY_WME))) < 0)
error = my_errno; error = my_errno;
info->rec_cache.file=info->dfile; info->rec_cache.file=info->dfile;
} }
...@@ -106,7 +110,7 @@ int mi_panic(enum ha_panic_function flag) ...@@ -106,7 +110,7 @@ int mi_panic(enum ha_panic_function flag)
(void) mi_log(0); /* Close log if neaded */ (void) mi_log(0); /* Close log if neaded */
ft_free_stopwords(); ft_free_stopwords();
} }
pthread_mutex_unlock(&THR_LOCK_myisam); mysql_mutex_unlock(&THR_LOCK_myisam);
if (!error) if (!error)
DBUG_RETURN(0); DBUG_RETURN(0);
DBUG_RETURN(my_errno=error); DBUG_RETURN(my_errno=error);
......
/* Copyright (C) 2003, 2005 MySQL AB /* Copyright (C) 2003, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -81,7 +81,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) ...@@ -81,7 +81,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
/* Read the next block of index file into the preload buffer */ /* Read the next block of index file into the preload buffer */
if ((my_off_t) length > (key_file_length-pos)) if ((my_off_t) length > (key_file_length-pos))
length= (ulong) (key_file_length-pos); length= (ulong) (key_file_length-pos);
if (my_pread(share->kfile, (uchar*) buff, length, pos, MYF(MY_FAE|MY_FNABP))) if (mysql_file_pread(share->kfile, (uchar*) buff, length, pos,
MYF(MY_FAE|MY_FNABP)))
goto err; goto err;
if (ignore_leaves) if (ignore_leaves)
......
/* Copyright (C) 2000-2004, 2006 MySQL AB /* Copyright (C) 2000-2004, 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -57,7 +57,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, ...@@ -57,7 +57,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx,
DBUG_RETURN(HA_POS_ERROR); DBUG_RETURN(HA_POS_ERROR);
info->update&= (HA_STATE_CHANGED+HA_STATE_ROW_CHANGED); info->update&= (HA_STATE_CHANGED+HA_STATE_ROW_CHANGED);
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_rdlock(&info->s->key_root_lock[inx]); mysql_rwlock_rdlock(&info->s->key_root_lock[inx]);
switch(info->s->keyinfo[inx].key_alg){ switch(info->s->keyinfo[inx].key_alg){
#ifdef HAVE_RTREE_KEYS #ifdef HAVE_RTREE_KEYS
...@@ -106,7 +106,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, ...@@ -106,7 +106,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx,
} }
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_unlock(&info->s->key_root_lock[inx]); mysql_rwlock_unlock(&info->s->key_root_lock[inx]);
fast_mi_writeinfo(info); fast_mi_writeinfo(info);
DBUG_PRINT("info",("records: %ld",(ulong) (res))); DBUG_PRINT("info",("records: %ld",(ulong) (res)));
......
/* Copyright (C) 2000-2001, 2004 MySQL AB /* Copyright (C) 2000-2001, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -47,7 +47,7 @@ int mi_rename(const char *old_name, const char *new_name) ...@@ -47,7 +47,7 @@ int mi_rename(const char *old_name, const char *new_name)
fn_format(from,old_name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(from,old_name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
fn_format(to,new_name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(to,new_name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
if (my_rename_with_symlink(from, to, MYF(MY_WME))) if (mysql_file_rename_with_symlink(mi_key_file_kfile, from, to, MYF(MY_WME)))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
fn_format(from,old_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(from,old_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
fn_format(to,new_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(to,new_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
...@@ -56,5 +56,7 @@ int mi_rename(const char *old_name, const char *new_name) ...@@ -56,5 +56,7 @@ int mi_rename(const char *old_name, const char *new_name)
DBUG_RETURN(my_raid_rename(from, to, raid_chunks, MYF(MY_WME)) ? my_errno : DBUG_RETURN(my_raid_rename(from, to, raid_chunks, MYF(MY_WME)) ? my_errno :
0); 0);
#endif #endif
DBUG_RETURN(my_rename_with_symlink(from, to,MYF(MY_WME)) ? my_errno : 0); DBUG_RETURN(mysql_file_rename_with_symlink(mi_key_file_dfile,
from, to,
MYF(MY_WME)) ? my_errno : 0);
} }
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -71,7 +71,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key, ...@@ -71,7 +71,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key,
goto err; goto err;
if (share->concurrent_insert) if (share->concurrent_insert)
rw_rdlock(&share->key_root_lock[inx]); mysql_rwlock_rdlock(&share->key_root_lock[inx]);
nextflag=myisam_read_vec[search_flag]; nextflag=myisam_read_vec[search_flag];
use_key_length=pack_key_length; use_key_length=pack_key_length;
...@@ -156,7 +156,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key, ...@@ -156,7 +156,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key,
} }
} }
if (share->concurrent_insert) if (share->concurrent_insert)
rw_unlock(&share->key_root_lock[inx]); mysql_rwlock_unlock(&share->key_root_lock[inx]);
/* Calculate length of the found key; Used by mi_rnext_same */ /* Calculate length of the found key; Used by mi_rnext_same */
if ((keyinfo->flag & HA_VAR_LENGTH_KEY) && last_used_keyseg && if ((keyinfo->flag & HA_VAR_LENGTH_KEY) && last_used_keyseg &&
......
/* Copyright (C) 2000-2004 MySQL AB /* Copyright (C) 2000-2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -39,7 +39,7 @@ int mi_rnext(MI_INFO *info, uchar *buf, int inx) ...@@ -39,7 +39,7 @@ int mi_rnext(MI_INFO *info, uchar *buf, int inx)
if (fast_mi_readinfo(info)) if (fast_mi_readinfo(info))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_rdlock(&info->s->key_root_lock[inx]); mysql_rwlock_rdlock(&info->s->key_root_lock[inx]);
changed=_mi_test_if_changed(info); changed=_mi_test_if_changed(info);
if (!flag) if (!flag)
{ {
...@@ -96,7 +96,7 @@ int mi_rnext(MI_INFO *info, uchar *buf, int inx) ...@@ -96,7 +96,7 @@ int mi_rnext(MI_INFO *info, uchar *buf, int inx)
break; break;
} }
} }
rw_unlock(&info->s->key_root_lock[inx]); mysql_rwlock_unlock(&info->s->key_root_lock[inx]);
} }
/* Don't clear if database-changed */ /* Don't clear if database-changed */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
......
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -38,7 +38,7 @@ int mi_rnext_same(MI_INFO *info, uchar *buf) ...@@ -38,7 +38,7 @@ int mi_rnext_same(MI_INFO *info, uchar *buf)
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_rdlock(&info->s->key_root_lock[inx]); mysql_rwlock_rdlock(&info->s->key_root_lock[inx]);
switch (keyinfo->key_alg) switch (keyinfo->key_alg)
{ {
...@@ -81,7 +81,7 @@ int mi_rnext_same(MI_INFO *info, uchar *buf) ...@@ -81,7 +81,7 @@ int mi_rnext_same(MI_INFO *info, uchar *buf)
} }
} }
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_unlock(&info->s->key_root_lock[inx]); mysql_rwlock_unlock(&info->s->key_root_lock[inx]);
/* Don't clear if database-changed */ /* Don't clear if database-changed */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->update|= HA_STATE_NEXT_FOUND | HA_STATE_RNEXT_SAME; info->update|= HA_STATE_NEXT_FOUND | HA_STATE_RNEXT_SAME;
......
/* Copyright (C) 2000-2001, 2004 MySQL AB /* Copyright (C) 2000-2001, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -39,7 +39,7 @@ int mi_rprev(MI_INFO *info, uchar *buf, int inx) ...@@ -39,7 +39,7 @@ int mi_rprev(MI_INFO *info, uchar *buf, int inx)
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
changed=_mi_test_if_changed(info); changed=_mi_test_if_changed(info);
if (share->concurrent_insert) if (share->concurrent_insert)
rw_rdlock(&share->key_root_lock[inx]); mysql_rwlock_rdlock(&share->key_root_lock[inx]);
if (!flag) if (!flag)
error=_mi_search_last(info, share->keyinfo+inx, error=_mi_search_last(info, share->keyinfo+inx,
share->state.key_root[inx]); share->state.key_root[inx]);
...@@ -65,7 +65,7 @@ int mi_rprev(MI_INFO *info, uchar *buf, int inx) ...@@ -65,7 +65,7 @@ int mi_rprev(MI_INFO *info, uchar *buf, int inx)
break; break;
} }
} }
rw_unlock(&share->key_root_lock[inx]); mysql_rwlock_unlock(&share->key_root_lock[inx]);
} }
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->update|= HA_STATE_PREV_FOUND; info->update|= HA_STATE_PREV_FOUND;
......
/* Copyright (C) 2000-2001, 2005 MySQL AB /* Copyright (C) 2000-2001, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -49,12 +49,12 @@ int mi_rsame(MI_INFO *info, uchar *record, int inx) ...@@ -49,12 +49,12 @@ int mi_rsame(MI_INFO *info, uchar *record, int inx)
info->lastkey_length=_mi_make_key(info,(uint) inx,info->lastkey,record, info->lastkey_length=_mi_make_key(info,(uint) inx,info->lastkey,record,
info->lastpos); info->lastpos);
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_rdlock(&info->s->key_root_lock[inx]); mysql_rwlock_rdlock(&info->s->key_root_lock[inx]);
(void) _mi_search(info,info->s->keyinfo+inx,info->lastkey, USE_WHOLE_KEY, (void) _mi_search(info,info->s->keyinfo+inx,info->lastkey, USE_WHOLE_KEY,
SEARCH_SAME, SEARCH_SAME,
info->s->state.key_root[inx]); info->s->state.key_root[inx]);
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_unlock(&info->s->key_root_lock[inx]); mysql_rwlock_unlock(&info->s->key_root_lock[inx]);
} }
if (!(*info->read_record)(info,info->lastpos,record)) if (!(*info->read_record)(info,info->lastpos,record))
......
/* Copyright (C) 2000-2002, 2004-2005 MySQL AB /* Copyright (C) 2000-2002, 2004-2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -68,3 +68,74 @@ uint NEAR myisam_readnext_vec[]= ...@@ -68,3 +68,74 @@ uint NEAR myisam_readnext_vec[]=
SEARCH_BIGGER, SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_BIGGER, SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_BIGGER, SEARCH_SMALLER,
SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_SMALLER SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_SMALLER
}; };
#ifdef HAVE_PSI_INTERFACE
PSI_mutex_key mi_key_mutex_MYISAM_SHARE_intern_lock,
mi_key_mutex_MI_SORT_INFO_mutex, mi_key_mutex_MI_CHECK_print_msg;
static PSI_mutex_info all_myisam_mutexes[]=
{
{ &mi_key_mutex_MI_SORT_INFO_mutex, "MI_SORT_INFO::mutex", 0},
{ &mi_key_mutex_MYISAM_SHARE_intern_lock, "MYISAM_SHARE::intern_lock", 0},
{ &mi_key_mutex_MI_CHECK_print_msg, "MI_CHECK::print_msg", 0}
};
PSI_rwlock_key mi_key_rwlock_MYISAM_SHARE_key_root_lock,
mi_key_rwlock_MYISAM_SHARE_mmap_lock;
static PSI_rwlock_info all_myisam_rwlocks[]=
{
{ &mi_key_rwlock_MYISAM_SHARE_key_root_lock, "MYISAM_SHARE::key_root_lock", 0},
{ &mi_key_rwlock_MYISAM_SHARE_mmap_lock, "MYISAM_SHARE::mmap_lock", 0}
};
PSI_cond_key mi_key_cond_MI_SORT_INFO_cond;
static PSI_cond_info all_myisam_conds[]=
{
{ &mi_key_cond_MI_SORT_INFO_cond, "MI_SORT_INFO::cond", 0}
};
PSI_file_key mi_key_file_datatmp, mi_key_file_dfile, mi_key_file_kfile,
mi_key_file_log;
static PSI_file_info all_myisam_files[]=
{
{ & mi_key_file_datatmp, "data_tmp", 0},
{ & mi_key_file_dfile, "dfile", 0},
{ & mi_key_file_kfile, "kfile", 0},
{ & mi_key_file_log, "log", 0}
};
PSI_thread_key mi_key_thread_find_all_keys;
static PSI_thread_info all_myisam_threads[]=
{
{ &mi_key_thread_find_all_keys, "find_all_keys", 0},
};
void init_myisam_psi_keys()
{
const char* category= "myisam";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_myisam_mutexes);
PSI_server->register_mutex(category, all_myisam_mutexes, count);
count= array_elements(all_myisam_rwlocks);
PSI_server->register_rwlock(category, all_myisam_rwlocks, count);
count= array_elements(all_myisam_conds);
PSI_server->register_cond(category, all_myisam_conds, count);
count= array_elements(all_myisam_files);
PSI_server->register_file(category, all_myisam_files, count);
count= array_elements(all_myisam_threads);
PSI_server->register_thread(category, all_myisam_threads, count);
}
#endif /* HAVE_PSI_INTERFACE */
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -107,7 +107,7 @@ int mi_write(MI_INFO *info, uchar *record) ...@@ -107,7 +107,7 @@ int mi_write(MI_INFO *info, uchar *record)
is_tree_inited(&info->bulk_insert[i]))); is_tree_inited(&info->bulk_insert[i])));
if (local_lock_tree) if (local_lock_tree)
{ {
rw_wrlock(&share->key_root_lock[i]); mysql_rwlock_wrlock(&share->key_root_lock[i]);
share->keyinfo[i].version++; share->keyinfo[i].version++;
} }
if (share->keyinfo[i].flag & HA_FULLTEXT ) if (share->keyinfo[i].flag & HA_FULLTEXT )
...@@ -115,7 +115,7 @@ int mi_write(MI_INFO *info, uchar *record) ...@@ -115,7 +115,7 @@ int mi_write(MI_INFO *info, uchar *record)
if (_mi_ft_add(info,i, buff, record, filepos)) if (_mi_ft_add(info,i, buff, record, filepos))
{ {
if (local_lock_tree) if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]); mysql_rwlock_unlock(&share->key_root_lock[i]);
DBUG_PRINT("error",("Got error: %d on write",my_errno)); DBUG_PRINT("error",("Got error: %d on write",my_errno));
goto err; goto err;
} }
...@@ -126,7 +126,7 @@ int mi_write(MI_INFO *info, uchar *record) ...@@ -126,7 +126,7 @@ int mi_write(MI_INFO *info, uchar *record)
_mi_make_key(info,i,buff,record,filepos))) _mi_make_key(info,i,buff,record,filepos)))
{ {
if (local_lock_tree) if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]); mysql_rwlock_unlock(&share->key_root_lock[i]);
DBUG_PRINT("error",("Got error: %d on write",my_errno)); DBUG_PRINT("error",("Got error: %d on write",my_errno));
goto err; goto err;
} }
...@@ -136,7 +136,7 @@ int mi_write(MI_INFO *info, uchar *record) ...@@ -136,7 +136,7 @@ int mi_write(MI_INFO *info, uchar *record)
info->update&= ~HA_STATE_RNEXT_SAME; info->update&= ~HA_STATE_RNEXT_SAME;
if (local_lock_tree) if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]); mysql_rwlock_unlock(&share->key_root_lock[i]);
} }
} }
if (share->calc_checksum) if (share->calc_checksum)
...@@ -197,13 +197,13 @@ err: ...@@ -197,13 +197,13 @@ err:
!(info->bulk_insert && !(info->bulk_insert &&
is_tree_inited(&info->bulk_insert[i]))); is_tree_inited(&info->bulk_insert[i])));
if (local_lock_tree) if (local_lock_tree)
rw_wrlock(&share->key_root_lock[i]); mysql_rwlock_wrlock(&share->key_root_lock[i]);
if (share->keyinfo[i].flag & HA_FULLTEXT) if (share->keyinfo[i].flag & HA_FULLTEXT)
{ {
if (_mi_ft_del(info,i, buff,record,filepos)) if (_mi_ft_del(info,i, buff,record,filepos))
{ {
if (local_lock_tree) if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]); mysql_rwlock_unlock(&share->key_root_lock[i]);
break; break;
} }
} }
...@@ -213,12 +213,12 @@ err: ...@@ -213,12 +213,12 @@ err:
if (_mi_ck_delete(info,i,buff,key_length)) if (_mi_ck_delete(info,i,buff,key_length))
{ {
if (local_lock_tree) if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]); mysql_rwlock_unlock(&share->key_root_lock[i]);
break; break;
} }
} }
if (local_lock_tree) if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]); mysql_rwlock_unlock(&share->key_root_lock[i]);
} }
} }
} }
...@@ -943,7 +943,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) ...@@ -943,7 +943,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
case free_init: case free_init:
if (param->info->s->concurrent_insert) if (param->info->s->concurrent_insert)
{ {
rw_wrlock(&param->info->s->key_root_lock[param->keynr]); mysql_rwlock_wrlock(&param->info->s->key_root_lock[param->keynr]);
param->info->s->keyinfo[param->keynr].version++; param->info->s->keyinfo[param->keynr].version++;
} }
return 0; return 0;
...@@ -955,7 +955,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) ...@@ -955,7 +955,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
keylen - param->info->s->rec_reflength); keylen - param->info->s->rec_reflength);
case free_end: case free_end:
if (param->info->s->concurrent_insert) if (param->info->s->concurrent_insert)
rw_unlock(&param->info->s->key_root_lock[param->keynr]); mysql_rwlock_unlock(&param->info->s->key_root_lock[param->keynr]);
return 0; return 0;
} }
return -1; return -1;
......
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#else #else
#include <my_no_pthread.h> #include <my_no_pthread.h>
#endif #endif
#include <mysql/psi/mysql_file.h>
#if defined(my_write) && !defined(MAP_TO_USE_RAID) #if defined(my_write) && !defined(MAP_TO_USE_RAID)
#undef my_write /* undef map from my_nosys; We need test-if-disk full */ #undef my_write /* undef map from my_nosys; We need test-if-disk full */
...@@ -213,13 +214,13 @@ typedef struct st_mi_isam_share { /* Shared between opens */ ...@@ -213,13 +214,13 @@ typedef struct st_mi_isam_share { /* Shared between opens */
concurrent_insert; concurrent_insert;
#ifdef THREAD #ifdef THREAD
THR_LOCK lock; THR_LOCK lock;
pthread_mutex_t intern_lock; /* Locking for use with _locking */ mysql_mutex_t intern_lock; /* Locking for use with _locking */
rw_lock_t *key_root_lock; mysql_rwlock_t *key_root_lock;
#endif #endif
my_off_t mmaped_length; my_off_t mmaped_length;
uint nonmmaped_inserts; /* counter of writing in non-mmaped uint nonmmaped_inserts; /* counter of writing in non-mmaped
area */ area */
rw_lock_t mmap_lock; mysql_rwlock_t mmap_lock;
} MYISAM_SHARE; } MYISAM_SHARE;
...@@ -460,12 +461,12 @@ typedef struct st_mi_sort_param ...@@ -460,12 +461,12 @@ typedef struct st_mi_sort_param
#define mi_unique_store(A,B) mi_int4store((A),(B)) #define mi_unique_store(A,B) mi_int4store((A),(B))
#ifdef THREAD #ifdef THREAD
extern pthread_mutex_t THR_LOCK_myisam; extern mysql_mutex_t THR_LOCK_myisam;
#endif #endif
#if !defined(THREAD) || defined(DONT_USE_RW_LOCKS) #if !defined(THREAD) || defined(DONT_USE_RW_LOCKS)
#define rw_wrlock(A) {} #define mysql_rwlock_wrlock(A) {}
#define rw_rdlock(A) {} #define mysql_rwlock_rdlock(A) {}
#define rw_unlock(A) {} #define mysql_rwlock_unlock(A) {}
#endif #endif
/* Some extern variables */ /* Some extern variables */
...@@ -785,3 +786,22 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong); ...@@ -785,3 +786,22 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong);
} }
#endif #endif
#ifdef HAVE_PSI_INTERFACE
C_MODE_START
extern PSI_mutex_key mi_key_mutex_MYISAM_SHARE_intern_lock,
mi_key_mutex_MI_SORT_INFO_mutex, mi_key_mutex_MI_CHECK_print_msg;
extern PSI_rwlock_key mi_key_rwlock_MYISAM_SHARE_key_root_lock,
mi_key_rwlock_MYISAM_SHARE_mmap_lock;
extern PSI_cond_key mi_key_cond_MI_SORT_INFO_cond;
extern PSI_file_key mi_key_file_datatmp, mi_key_file_dfile, mi_key_file_kfile,
mi_key_file_log;
extern PSI_thread_key mi_key_thread_find_all_keys;
void init_myisam_psi_keys();
C_MODE_END
#endif /* HAVE_PSI_INTERFACE */
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -478,10 +478,10 @@ ok: ...@@ -478,10 +478,10 @@ ok:
if (sort_param->read_cache.share) if (sort_param->read_cache.share)
remove_io_thread(&sort_param->read_cache); remove_io_thread(&sort_param->read_cache);
pthread_mutex_lock(&sort_param->sort_info->mutex); mysql_mutex_lock(&sort_param->sort_info->mutex);
if (!--sort_param->sort_info->threads_running) if (!--sort_param->sort_info->threads_running)
pthread_cond_signal(&sort_param->sort_info->cond); mysql_cond_signal(&sort_param->sort_info->cond);
pthread_mutex_unlock(&sort_param->sort_info->mutex); mysql_mutex_unlock(&sort_param->sort_info->mutex);
DBUG_PRINT("exit", ("======== ending thread ========")); DBUG_PRINT("exit", ("======== ending thread ========"));
} }
my_thread_end(); my_thread_end();
...@@ -824,8 +824,9 @@ static uint NEAR_F read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek, ...@@ -824,8 +824,9 @@ static uint NEAR_F read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count))) if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
{ {
if (my_pread(fromfile->file,(uchar*) buffpek->base, if (mysql_file_pread(fromfile->file, (uchar*) buffpek->base,
(length= sort_length*count),buffpek->file_pos,MYF_RW)) (length= sort_length*count),
buffpek->file_pos, MYF_RW))
return((uint) -1); /* purecov: inspected */ return((uint) -1); /* purecov: inspected */
buffpek->key=buffpek->base; buffpek->key=buffpek->base;
buffpek->file_pos+= length; /* New filepos */ buffpek->file_pos+= length; /* New filepos */
...@@ -849,12 +850,12 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek, ...@@ -849,12 +850,12 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
for (idx=1;idx<=count;idx++) for (idx=1;idx<=count;idx++)
{ {
if (my_pread(fromfile->file,(uchar*)&length_of_key,sizeof(length_of_key), if (mysql_file_pread(fromfile->file, (uchar*)&length_of_key,
buffpek->file_pos,MYF_RW)) sizeof(length_of_key), buffpek->file_pos, MYF_RW))
return((uint) -1); return((uint) -1);
buffpek->file_pos+=sizeof(length_of_key); buffpek->file_pos+=sizeof(length_of_key);
if (my_pread(fromfile->file,(uchar*) buffp,length_of_key, if (mysql_file_pread(fromfile->file, (uchar*) buffp,
buffpek->file_pos,MYF_RW)) length_of_key, buffpek->file_pos, MYF_RW))
return((uint) -1); return((uint) -1);
buffpek->file_pos+=length_of_key; buffpek->file_pos+=length_of_key;
buffp = buffp + sort_length; buffp = buffp + sort_length;
......
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -1040,7 +1040,7 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd, ...@@ -1040,7 +1040,7 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd,
pointers to the children. Use of a mutex here and in pointers to the children. Use of a mutex here and in
myrg_attach_children() forces consistent data. myrg_attach_children() forces consistent data.
*/ */
pthread_mutex_lock(&this->file->mutex); mysql_mutex_lock(&this->file->mutex);
/* /*
When MERGE table is open, but not yet attached, other threads When MERGE table is open, but not yet attached, other threads
...@@ -1061,7 +1061,7 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd, ...@@ -1061,7 +1061,7 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd,
} }
end: end:
pthread_mutex_unlock(&this->file->mutex); mysql_mutex_unlock(&this->file->mutex);
return to; return to;
} }
...@@ -1282,6 +1282,10 @@ static int myisammrg_init(void *p) ...@@ -1282,6 +1282,10 @@ static int myisammrg_init(void *p)
myisammrg_hton= (handlerton *)p; myisammrg_hton= (handlerton *)p;
#ifdef HAVE_PSI_INTERFACE
init_myisammrg_psi_keys();
#endif
myisammrg_hton->db_type= DB_TYPE_MRG_MYISAM; myisammrg_hton->db_type= DB_TYPE_MRG_MYISAM;
myisammrg_hton->create= myisammrg_create_handler; myisammrg_hton->create= myisammrg_create_handler;
myisammrg_hton->panic= myisammrg_panic; myisammrg_hton->panic= myisammrg_panic;
......
/* Copyright (C) 2000-2001 MySQL AB /* Copyright (C) 2000-2001 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -55,10 +55,10 @@ int myrg_close(MYRG_INFO *info) ...@@ -55,10 +55,10 @@ int myrg_close(MYRG_INFO *info)
else else
my_free((uchar*) info->rec_per_key_part, MYF(MY_ALLOW_ZERO_PTR)); my_free((uchar*) info->rec_per_key_part, MYF(MY_ALLOW_ZERO_PTR));
delete_queue(&info->by_key); delete_queue(&info->by_key);
pthread_mutex_lock(&THR_LOCK_open); mysql_mutex_lock(&THR_LOCK_open);
myrg_open_list=list_delete(myrg_open_list,&info->open_list); myrg_open_list=list_delete(myrg_open_list,&info->open_list);
pthread_mutex_unlock(&THR_LOCK_open); mysql_mutex_unlock(&THR_LOCK_open);
pthread_mutex_destroy(&info->mutex); mysql_mutex_destroy(&info->mutex);
my_free((uchar*) info,MYF(0)); my_free((uchar*) info,MYF(0));
if (error) if (error)
{ {
......
/* Copyright (C) 2000-2001, 2005 MySQL AB /* Copyright (C) 2000-2001, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -32,9 +32,10 @@ int myrg_create(const char *name, const char **table_names, ...@@ -32,9 +32,10 @@ int myrg_create(const char *name, const char **table_names,
DBUG_ENTER("myrg_create"); DBUG_ENTER("myrg_create");
errpos=0; errpos=0;
if ((file = my_create(fn_format(buff,name,"",MYRG_NAME_EXT, if ((file= mysql_file_create(rg_key_file_MRG,
MY_UNPACK_FILENAME|MY_APPEND_EXT),0, fn_format(buff, name, "", MYRG_NAME_EXT,
O_RDWR | O_EXCL | O_NOFOLLOW,MYF(MY_WME))) < 0) MY_UNPACK_FILENAME|MY_APPEND_EXT), 0,
O_RDWR | O_EXCL | O_NOFOLLOW, MYF(MY_WME))) < 0)
goto err; goto err;
errpos=1; errpos=1;
if (table_names) if (table_names)
...@@ -46,8 +47,8 @@ int myrg_create(const char *name, const char **table_names, ...@@ -46,8 +47,8 @@ int myrg_create(const char *name, const char **table_names,
fn_same(buff,name,4); fn_same(buff,name,4);
*(end=strend(buff))='\n'; *(end=strend(buff))='\n';
end[1]=0; end[1]=0;
if (my_write(file,(uchar*) buff,(uint) (end-buff+1), if (mysql_file_write(file, (uchar*) buff, (uint) (end-buff+1),
MYF(MY_WME | MY_NABP))) MYF(MY_WME | MY_NABP)))
goto err; goto err;
} }
} }
...@@ -55,10 +56,11 @@ int myrg_create(const char *name, const char **table_names, ...@@ -55,10 +56,11 @@ int myrg_create(const char *name, const char **table_names,
{ {
end=strxmov(buff,"#INSERT_METHOD=", end=strxmov(buff,"#INSERT_METHOD=",
get_type(&merge_insert_method,insert_method-1),"\n",NullS); get_type(&merge_insert_method,insert_method-1),"\n",NullS);
if (my_write(file, (uchar*) buff,(uint) (end-buff),MYF(MY_WME | MY_NABP))) if (mysql_file_write(file, (uchar*) buff, (uint) (end-buff),
MYF(MY_WME | MY_NABP)))
goto err; goto err;
} }
if (my_close(file,MYF(0))) if (mysql_file_close(file, MYF(0)))
goto err; goto err;
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -66,7 +68,7 @@ err: ...@@ -66,7 +68,7 @@ err:
save_errno=my_errno ? my_errno : -1; save_errno=my_errno ? my_errno : -1;
switch (errpos) { switch (errpos) {
case 1: case 1:
(void) my_close(file,MYF(0)); (void) mysql_file_close(file, MYF(0));
} }
DBUG_RETURN(my_errno=save_errno); DBUG_RETURN(my_errno=save_errno);
} /* myrg_create */ } /* myrg_create */
/* Copyright (C) 2000-2001, 2003 MySQL AB /* Copyright (C) 2000-2001, 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
extern LIST *myrg_open_list; extern LIST *myrg_open_list;
#ifdef THREAD #ifdef THREAD
extern pthread_mutex_t THR_LOCK_open; extern mysql_mutex_t THR_LOCK_open;
#endif #endif
int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag); int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag);
...@@ -33,3 +33,14 @@ int _myrg_mi_read_record(MI_INFO *info, uchar *buf); ...@@ -33,3 +33,14 @@ int _myrg_mi_read_record(MI_INFO *info, uchar *buf);
extern "C" extern "C"
#endif #endif
void myrg_print_wrong_table(const char *table_name); void myrg_print_wrong_table(const char *table_name);
#ifdef HAVE_PSI_INTERFACE
extern PSI_mutex_key rg_key_mutex_MYRG_INFO_mutex;
extern PSI_file_key rg_key_file_MRG;
C_MODE_START
void init_myisammrg_psi_keys();
C_MODE_END
#endif /* HAVE_PSI_INTERFACE */
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -50,9 +50,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -50,9 +50,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
DBUG_ENTER("myrg_open"); DBUG_ENTER("myrg_open");
bzero((char*) &file,sizeof(file)); bzero((char*) &file,sizeof(file));
if ((fd=my_open(fn_format(name_buff,name,"",MYRG_NAME_EXT, if ((fd= mysql_file_open(rg_key_file_MRG,
MY_UNPACK_FILENAME|MY_APPEND_EXT), fn_format(name_buff, name, "", MYRG_NAME_EXT,
O_RDONLY | O_SHARE,MYF(0))) < 0) MY_UNPACK_FILENAME|MY_APPEND_EXT),
O_RDONLY | O_SHARE, MYF(0))) < 0)
goto err; goto err;
errpos=1; errpos=1;
if (init_io_cache(&file, fd, 4*IO_SIZE, READ_CACHE, 0, 0, if (init_io_cache(&file, fd, 4*IO_SIZE, READ_CACHE, 0, 0,
...@@ -167,13 +168,14 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -167,13 +168,14 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
m_info->last_used_table=m_info->open_tables; m_info->last_used_table=m_info->open_tables;
m_info->children_attached= TRUE; m_info->children_attached= TRUE;
(void) my_close(fd,MYF(0)); (void) mysql_file_close(fd, MYF(0));
end_io_cache(&file); end_io_cache(&file);
pthread_mutex_init(&m_info->mutex, MY_MUTEX_INIT_FAST); mysql_mutex_init(rg_key_mutex_MYRG_INFO_mutex,
&m_info->mutex, MY_MUTEX_INIT_FAST);
m_info->open_list.data=(void*) m_info; m_info->open_list.data=(void*) m_info;
pthread_mutex_lock(&THR_LOCK_open); mysql_mutex_lock(&THR_LOCK_open);
myrg_open_list=list_add(myrg_open_list,&m_info->open_list); myrg_open_list=list_add(myrg_open_list,&m_info->open_list);
pthread_mutex_unlock(&THR_LOCK_open); mysql_mutex_unlock(&THR_LOCK_open);
DBUG_RETURN(m_info); DBUG_RETURN(m_info);
bad_children: bad_children:
...@@ -190,7 +192,7 @@ err: ...@@ -190,7 +192,7 @@ err:
end_io_cache(&file); end_io_cache(&file);
/* Fall through */ /* Fall through */
case 1: case 1:
(void) my_close(fd,MYF(0)); (void) mysql_file_close(fd, MYF(0));
} }
my_errno=save_errno; my_errno=save_errno;
DBUG_RETURN (NULL); DBUG_RETURN (NULL);
...@@ -241,9 +243,11 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, ...@@ -241,9 +243,11 @@ MYRG_INFO *myrg_parent_open(const char *parent_name,
bzero((char*) &file_cache, sizeof(file_cache)); bzero((char*) &file_cache, sizeof(file_cache));
/* Open MERGE meta file. */ /* Open MERGE meta file. */
if ((fd= my_open(fn_format(parent_name_buff, parent_name, "", MYRG_NAME_EXT, if ((fd= mysql_file_open(rg_key_file_MRG,
MY_UNPACK_FILENAME|MY_APPEND_EXT), fn_format(parent_name_buff, parent_name,
O_RDONLY | O_SHARE, MYF(0))) < 0) "", MYRG_NAME_EXT,
MY_UNPACK_FILENAME|MY_APPEND_EXT),
O_RDONLY | O_SHARE, MYF(0))) < 0)
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
errpos= 1; errpos= 1;
...@@ -327,13 +331,14 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, ...@@ -327,13 +331,14 @@ MYRG_INFO *myrg_parent_open(const char *parent_name,
} }
end_io_cache(&file_cache); end_io_cache(&file_cache);
(void) my_close(fd, MYF(0)); (void) mysql_file_close(fd, MYF(0));
pthread_mutex_init(&m_info->mutex, MY_MUTEX_INIT_FAST); mysql_mutex_init(rg_key_mutex_MYRG_INFO_mutex,
&m_info->mutex, MY_MUTEX_INIT_FAST);
m_info->open_list.data= (void*) m_info; m_info->open_list.data= (void*) m_info;
pthread_mutex_lock(&THR_LOCK_open); mysql_mutex_lock(&THR_LOCK_open);
myrg_open_list= list_add(myrg_open_list, &m_info->open_list); myrg_open_list= list_add(myrg_open_list, &m_info->open_list);
pthread_mutex_unlock(&THR_LOCK_open); mysql_mutex_unlock(&THR_LOCK_open);
DBUG_RETURN(m_info); DBUG_RETURN(m_info);
...@@ -348,7 +353,7 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, ...@@ -348,7 +353,7 @@ MYRG_INFO *myrg_parent_open(const char *parent_name,
end_io_cache(&file_cache); end_io_cache(&file_cache);
/* Fall through */ /* Fall through */
case 1: case 1:
(void) my_close(fd, MYF(0)); (void) mysql_file_close(fd, MYF(0));
} }
my_errno= save_errno; my_errno= save_errno;
DBUG_RETURN (NULL); DBUG_RETURN (NULL);
...@@ -405,7 +410,7 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, ...@@ -405,7 +410,7 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
'open_tables' has all the pointers to the children. Use of a mutex 'open_tables' has all the pointers to the children. Use of a mutex
here and in ha_myisammrg::store_lock() forces consistent data. here and in ha_myisammrg::store_lock() forces consistent data.
*/ */
pthread_mutex_lock(&m_info->mutex); mysql_mutex_lock(&m_info->mutex);
rc= 1; rc= 1;
errpos= 0; errpos= 0;
file_offset= 0; file_offset= 0;
...@@ -485,7 +490,7 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, ...@@ -485,7 +490,7 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
m_info->keys= min_keys; m_info->keys= min_keys;
m_info->last_used_table= m_info->open_tables; m_info->last_used_table= m_info->open_tables;
m_info->children_attached= TRUE; m_info->children_attached= TRUE;
pthread_mutex_unlock(&m_info->mutex); mysql_mutex_unlock(&m_info->mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
bad_children: bad_children:
...@@ -497,7 +502,7 @@ err: ...@@ -497,7 +502,7 @@ err:
my_free((char*) m_info->rec_per_key_part, MYF(0)); my_free((char*) m_info->rec_per_key_part, MYF(0));
m_info->rec_per_key_part= NULL; m_info->rec_per_key_part= NULL;
} }
pthread_mutex_unlock(&m_info->mutex); mysql_mutex_unlock(&m_info->mutex);
my_errno= save_errno; my_errno= save_errno;
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -520,7 +525,7 @@ int myrg_detach_children(MYRG_INFO *m_info) ...@@ -520,7 +525,7 @@ int myrg_detach_children(MYRG_INFO *m_info)
{ {
DBUG_ENTER("myrg_detach_children"); DBUG_ENTER("myrg_detach_children");
/* For symmetry with myrg_attach_children() we use the mutex here. */ /* For symmetry with myrg_attach_children() we use the mutex here. */
pthread_mutex_lock(&m_info->mutex); mysql_mutex_lock(&m_info->mutex);
if (m_info->tables) if (m_info->tables)
{ {
/* Do not attach/detach an empty child list. */ /* Do not attach/detach an empty child list. */
...@@ -531,7 +536,7 @@ int myrg_detach_children(MYRG_INFO *m_info) ...@@ -531,7 +536,7 @@ int myrg_detach_children(MYRG_INFO *m_info)
m_info->del= 0; m_info->del= 0;
m_info->data_file_length= 0; m_info->data_file_length= 0;
m_info->options= 0; m_info->options= 0;
pthread_mutex_unlock(&m_info->mutex); mysql_mutex_unlock(&m_info->mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/* Copyright (C) 2000-2001, 2004 MySQL AB /* Copyright (C) 2000-2001, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -27,3 +27,35 @@ static const char *merge_insert_methods[] = ...@@ -27,3 +27,35 @@ static const char *merge_insert_methods[] =
{ "FIRST", "LAST", NullS }; { "FIRST", "LAST", NullS };
TYPELIB merge_insert_method= { array_elements(merge_insert_methods)-1,"", TYPELIB merge_insert_method= { array_elements(merge_insert_methods)-1,"",
merge_insert_methods, 0}; merge_insert_methods, 0};
#ifdef HAVE_PSI_INTERFACE
PSI_mutex_key rg_key_mutex_MYRG_INFO_mutex;
static PSI_mutex_info all_myisammrg_mutexes[]=
{
{ &rg_key_mutex_MYRG_INFO_mutex, "MYRG_INFO::mutex", 0}
};
PSI_file_key rg_key_file_MRG;
static PSI_file_info all_myisammrg_files[]=
{
{ &rg_key_file_MRG, "MRG", 0}
};
void init_myisammrg_psi_keys()
{
const char* category= "myisammrg";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_myisammrg_mutexes);
PSI_server->register_mutex(category, all_myisammrg_mutexes, count);
count= array_elements(all_myisammrg_files);
PSI_server->register_file(category, all_myisammrg_files, count);
}
#endif /* HAVE_PSI_INTERFACE */
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