Commit 57fd1178 authored by Marc Alff's avatar Marc Alff

WL#2360 Performance schema

Part II, engines instrumentation
parent 34436edb
/* 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
it under the terms of the GNU General Public License as published by
......@@ -148,7 +148,7 @@ typedef struct st_heap_share
char * name; /* Name of "memory-file" */
#ifdef THREAD
THR_LOCK lock;
pthread_mutex_t intern_lock; /* Locking for use with _locking */
mysql_mutex_t intern_lock; /* Locking for use with _locking */
#endif
my_bool delete_on_close;
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
it under the terms of the GNU General Public License as published by
......@@ -433,7 +433,7 @@ typedef struct st_mi_check_param
const char *op_name;
enum_mi_stats_method stats_method;
#ifdef THREAD
pthread_mutex_t print_msg_mutex;
mysql_mutex_t print_msg_mutex;
my_bool need_print_msg_lock;
#endif
} MI_CHECK;
......@@ -460,8 +460,8 @@ typedef struct st_sort_info
/* sync things */
uint got_error, threads_running;
#ifdef THREAD
pthread_mutex_t mutex;
pthread_cond_t cond;
mysql_mutex_t mutex;
mysql_cond_t cond;
#endif
} 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
it under the terms of the GNU General Public License as published by
......@@ -75,7 +75,7 @@ typedef struct st_myrg_info
LIST open_list;
QUEUE by_key;
ulong *rec_per_key_part; /* for sql optimizing */
pthread_mutex_t mutex;
mysql_mutex_t mutex;
} 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
it under the terms of the GNU General Public License as published by
......@@ -26,12 +26,54 @@
#ifdef THREAD
#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_lock, THR_LOCK_isam, THR_LOCK_net;
extern pthread_mutex_t THR_LOCK_charset, THR_LOCK_time;
#else
#else /* THREAD */
#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
......
/* 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
it under the terms of the GNU General Public License as published by
......@@ -53,6 +53,7 @@
#include "sql_array.h"
#include "sql_plugin.h"
#include "scheduler.h"
#include <mysql/psi/mysql_file.h>
#ifndef __WIN__
#include <netdb.h>
#endif
......
......@@ -1884,6 +1884,12 @@ public:
proc_info = 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)
{
/*
......
/* 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
it under the terms of the GNU General Public License as published by
......@@ -95,7 +95,7 @@
*/
/* Variables for archive share methods */
pthread_mutex_t archive_mutex;
mysql_mutex_t archive_mutex;
static HASH archive_open_tables;
/* The file extension */
......@@ -145,6 +145,28 @@ static uchar* archive_get_key(ARCHIVE_SHARE *share, size_t *length,
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.
......@@ -163,6 +185,10 @@ int archive_db_init(void *p)
DBUG_ENTER("archive_db_init");
handlerton *archive_hton;
#ifdef HAVE_PSI_INTERFACE
init_archive_psi_keys();
#endif
archive_hton= (handlerton *)p;
archive_hton->state= SHOW_OPTION_YES;
archive_hton->db_type= DB_TYPE_ARCHIVE_DB;
......@@ -170,12 +196,13 @@ int archive_db_init(void *p)
archive_hton->flags= HTON_NO_FLAGS;
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;
if (my_hash_init(&archive_open_tables, table_alias_charset, 32, 0, 0,
(my_hash_get_key) archive_get_key, 0, 0))
{
pthread_mutex_destroy(&archive_mutex);
mysql_mutex_destroy(&archive_mutex);
}
else
{
......@@ -199,7 +226,7 @@ error:
int archive_db_done(void *p)
{
my_hash_free(&archive_open_tables);
pthread_mutex_destroy(&archive_mutex);
mysql_mutex_destroy(&archive_mutex);
return 0;
}
......@@ -313,7 +340,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
uint length;
DBUG_ENTER("ha_archive::get_share");
pthread_mutex_lock(&archive_mutex);
mysql_mutex_lock(&archive_mutex);
length=(uint) strlen(table_name);
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)
&tmp_name, length+1,
NullS))
{
pthread_mutex_unlock(&archive_mutex);
mysql_mutex_unlock(&archive_mutex);
*rc= HA_ERR_OUT_OF_MEM;
DBUG_RETURN(NULL);
}
......@@ -346,7 +373,8 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
/*
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
......@@ -372,7 +400,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
share->use_count));
if (share->crashed)
*rc= HA_ERR_CRASHED_ON_USAGE;
pthread_mutex_unlock(&archive_mutex);
mysql_mutex_unlock(&archive_mutex);
DBUG_RETURN(share);
}
......@@ -391,12 +419,12 @@ int ha_archive::free_share()
share->table_name_length, share->table_name,
share->use_count));
pthread_mutex_lock(&archive_mutex);
mysql_mutex_lock(&archive_mutex);
if (!--share->use_count)
{
my_hash_delete(&archive_open_tables, (uchar*) share);
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.
If we open a crashed file, wee need to close it as crashed unless
......@@ -411,7 +439,7 @@ int ha_archive::free_share()
}
my_free((uchar*) share, MYF(0));
}
pthread_mutex_unlock(&archive_mutex);
mysql_mutex_unlock(&archive_mutex);
DBUG_RETURN(rc);
}
......@@ -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 (!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));
if (frm_ptr)
......@@ -800,7 +828,7 @@ int ha_archive::write_row(uchar *buf)
ha_statistic_increment(&SSV::ha_write_count);
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
table->timestamp_field->set_time();
pthread_mutex_lock(&share->mutex);
mysql_mutex_lock(&share->mutex);
if (!share->archive_write_open)
if (init_archive_writer())
......@@ -883,7 +911,7 @@ int ha_archive::write_row(uchar *buf)
share->rows_recorded++;
rc= real_write_row(buf, &(share->archive_write));
error:
pthread_mutex_unlock(&share->mutex);
mysql_mutex_unlock(&share->mutex);
if (read_buf)
my_free((uchar*) read_buf, MYF(0));
......@@ -1383,7 +1411,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
azclose(&archive);
// 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);
......@@ -1467,7 +1495,7 @@ int ha_archive::info(uint flag)
If dirty, we lock, and then reset/flush the data.
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)
......@@ -1483,7 +1511,7 @@ int ha_archive::info(uint flag)
cause the number to be inaccurate.
*/
stats.records= share->rows_recorded;
pthread_mutex_unlock(&share->mutex);
mysql_mutex_unlock(&share->mutex);
stats.deleted= 0;
......@@ -1508,9 +1536,9 @@ int ha_archive::info(uint flag)
if (flag & HA_STATUS_AUTO)
{
init_archive_reader();
pthread_mutex_lock(&share->mutex);
mysql_mutex_lock(&share->mutex);
azflush(&archive, Z_SYNC_FLUSH);
pthread_mutex_unlock(&share->mutex);
mysql_mutex_unlock(&share->mutex);
stats.auto_increment_value= archive.auto_increment + 1;
}
......@@ -1578,9 +1606,9 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt)
old_proc_info= thd_proc_info(thd, "Checking table");
/* Flush any waiting data */
pthread_mutex_lock(&share->mutex);
mysql_mutex_lock(&share->mutex);
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
......
/* 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
it under the terms of the GNU General Public License as published by
......@@ -36,7 +36,7 @@ typedef struct st_archive_share {
char *table_name;
char data_file_name[FN_REFLEN];
uint table_name_length,use_count;
pthread_mutex_t mutex;
mysql_mutex_t mutex;
THR_LOCK lock;
azio_stream archive_write; /* Archive file we are working with */
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
it under the terms of the GNU General Public License as published by
......@@ -35,7 +35,7 @@ static handler *blackhole_create_handler(handlerton *hton,
/* Static declarations for shared structures */
static pthread_mutex_t blackhole_mutex;
static mysql_mutex_t blackhole_mutex;
static HASH blackhole_open_tables;
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;
length= (uint) strlen(table_name);
pthread_mutex_lock(&blackhole_mutex);
mysql_mutex_lock(&blackhole_mutex);
if (!(share= (st_blackhole_share*)
my_hash_search(&blackhole_open_tables,
......@@ -343,16 +343,16 @@ static st_blackhole_share *get_share(const char *table_name)
share->use_count++;
error:
pthread_mutex_unlock(&blackhole_mutex);
mysql_mutex_unlock(&blackhole_mutex);
return share;
}
static void free_share(st_blackhole_share *share)
{
pthread_mutex_lock(&blackhole_mutex);
mysql_mutex_lock(&blackhole_mutex);
if (!--share->use_count)
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)
......@@ -368,16 +368,43 @@ static uchar* blackhole_get_key(st_blackhole_share *share, size_t *length,
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)
{
handlerton *blackhole_hton;
#ifdef HAVE_PSI_INTERFACE
init_blackhole_psi_keys();
#endif
blackhole_hton= (handlerton *)p;
blackhole_hton->state= SHOW_OPTION_YES;
blackhole_hton->db_type= DB_TYPE_BLACKHOLE_DB;
blackhole_hton->create= blackhole_create_handler;
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,
(my_hash_get_key) blackhole_get_key,
(my_hash_free_key) blackhole_free_key, 0);
......@@ -388,7 +415,7 @@ static int blackhole_init(void *p)
static int blackhole_fini(void *p)
{
my_hash_free(&blackhole_open_tables);
pthread_mutex_destroy(&blackhole_mutex);
mysql_mutex_destroy(&blackhole_mutex);
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
it under the terms of the GNU General Public License as published by
......@@ -75,7 +75,7 @@ extern "C" void tina_update_status(void* param);
extern "C" my_bool tina_check_status(void* param);
/* Stuff for shares */
pthread_mutex_t tina_mutex;
mysql_mutex_t tina_mutex;
static HASH tina_open_tables;
static handler *tina_create_handler(handlerton *hton,
TABLE_SHARE *table,
......@@ -105,12 +105,52 @@ static uchar* tina_get_key(TINA_SHARE *share, size_t *length,
return (uchar*) share->table_name;
}
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key csv_key_mutex_tina, csv_key_mutex_TINA_SHARE_mutex;
static PSI_mutex_info all_tina_mutexes[]=
{
{ &csv_key_mutex_tina, "tina", PSI_FLAG_GLOBAL},
{ &csv_key_mutex_TINA_SHARE_mutex, "TINA_SHARE::mutex", 0}
};
static PSI_file_key csv_key_file_metadata, csv_key_file_data,
csv_key_file_update;
static PSI_file_info all_tina_files[]=
{
{ &csv_key_file_metadata, "metadata", 0},
{ &csv_key_file_data, "data", 0},
{ &csv_key_file_update, "update", 0}
};
static void init_tina_psi_keys(void)
{
const char* category= "csv";
int count;
if (PSI_server == NULL)
return;
count= array_elements(all_tina_mutexes);
PSI_server->register_mutex(category, all_tina_mutexes, count);
count= array_elements(all_tina_files);
PSI_server->register_file(category, all_tina_files, count);
}
#endif /* HAVE_PSI_INTERFACE */
static int tina_init_func(void *p)
{
handlerton *tina_hton;
#ifdef HAVE_PSI_INTERFACE
init_tina_psi_keys();
#endif
tina_hton= (handlerton *)p;
pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST);
mysql_mutex_init(csv_key_mutex_tina, &tina_mutex, MY_MUTEX_INIT_FAST);
(void) my_hash_init(&tina_open_tables,system_charset_info,32,0,0,
(my_hash_get_key) tina_get_key,0,0);
tina_hton->state= SHOW_OPTION_YES;
......@@ -124,7 +164,7 @@ static int tina_init_func(void *p)
static int tina_done_func(void *p)
{
my_hash_free(&tina_open_tables);
pthread_mutex_destroy(&tina_mutex);
mysql_mutex_destroy(&tina_mutex);
return 0;
}
......@@ -141,7 +181,7 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table)
char *tmp_name;
uint length;
pthread_mutex_lock(&tina_mutex);
mysql_mutex_lock(&tina_mutex);
length=(uint) strlen(table_name);
/*
......@@ -157,7 +197,7 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table)
&tmp_name, length+1,
NullS))
{
pthread_mutex_unlock(&tina_mutex);
mysql_mutex_unlock(&tina_mutex);
return NULL;
}
......@@ -176,14 +216,16 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table)
fn_format(meta_file_name, table_name, "", CSM_EXT,
MY_REPLACE_EXT|MY_UNPACK_FILENAME);
if (my_stat(share->data_file_name, &file_stat, MYF(MY_WME)) == NULL)
if (mysql_file_stat(csv_key_file_data,
share->data_file_name, &file_stat, MYF(MY_WME)) == NULL)
goto error;
share->saved_data_file_length= file_stat.st_size;
if (my_hash_insert(&tina_open_tables, (uchar*) share))
goto error;
thr_lock_init(&share->lock);
pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST);
mysql_mutex_init(csv_key_mutex_TINA_SHARE_mutex,
&share->mutex, MY_MUTEX_INIT_FAST);
/*
Open or create the meta file. In the latter case, we'll get
......@@ -191,19 +233,21 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table)
Usually this will result in auto-repair, and we will get a good
meta-file in the end.
*/
if (((share->meta_file= my_open(meta_file_name,
O_RDWR|O_CREAT, MYF(MY_WME))) == -1) ||
if (((share->meta_file= mysql_file_open(csv_key_file_metadata,
meta_file_name,
O_RDWR|O_CREAT,
MYF(MY_WME))) == -1) ||
read_meta_file(share->meta_file, &share->rows_recorded))
share->crashed= TRUE;
}
share->use_count++;
pthread_mutex_unlock(&tina_mutex);
mysql_mutex_unlock(&tina_mutex);
return share;
error:
pthread_mutex_unlock(&tina_mutex);
mysql_mutex_unlock(&tina_mutex);
my_free((uchar*) share, MYF(0));
return NULL;
......@@ -236,8 +280,8 @@ static int read_meta_file(File meta_file, ha_rows *rows)
DBUG_ENTER("ha_tina::read_meta_file");
my_seek(meta_file, 0, MY_SEEK_SET, MYF(0));
if (my_read(meta_file, (uchar*)meta_buffer, META_BUFFER_SIZE, 0)
mysql_file_seek(meta_file, 0, MY_SEEK_SET, MYF(0));
if (mysql_file_read(meta_file, (uchar*)meta_buffer, META_BUFFER_SIZE, 0)
!= META_BUFFER_SIZE)
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
......@@ -259,7 +303,7 @@ static int read_meta_file(File meta_file, ha_rows *rows)
((bool)(*ptr)== TRUE))
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
my_sync(meta_file, MYF(MY_WME));
mysql_file_sync(meta_file, MYF(MY_WME));
DBUG_RETURN(0);
}
......@@ -305,12 +349,12 @@ static int write_meta_file(File meta_file, ha_rows rows, bool dirty)
ptr+= 3*sizeof(ulonglong);
*ptr= (uchar)dirty;
my_seek(meta_file, 0, MY_SEEK_SET, MYF(0));
if (my_write(meta_file, (uchar *)meta_buffer, META_BUFFER_SIZE, 0)
mysql_file_seek(meta_file, 0, MY_SEEK_SET, MYF(0));
if (mysql_file_write(meta_file, (uchar *)meta_buffer, META_BUFFER_SIZE, 0)
!= META_BUFFER_SIZE)
DBUG_RETURN(-1);
my_sync(meta_file, MYF(MY_WME));
mysql_file_sync(meta_file, MYF(MY_WME));
DBUG_RETURN(0);
}
......@@ -338,7 +382,9 @@ int ha_tina::init_tina_writer()
(void)write_meta_file(share->meta_file, share->rows_recorded, TRUE);
if ((share->tina_write_filedes=
my_open(share->data_file_name, O_RDWR|O_APPEND, MYF(MY_WME))) == -1)
mysql_file_open(csv_key_file_data,
share->data_file_name, O_RDWR|O_APPEND,
MYF(MY_WME))) == -1)
{
DBUG_PRINT("info", ("Could not open tina file writes"));
share->crashed= TRUE;
......@@ -362,27 +408,27 @@ bool ha_tina::is_crashed() const
static int free_share(TINA_SHARE *share)
{
DBUG_ENTER("ha_tina::free_share");
pthread_mutex_lock(&tina_mutex);
mysql_mutex_lock(&tina_mutex);
int result_code= 0;
if (!--share->use_count){
/* Write the meta file. Mark it as crashed if needed. */
(void)write_meta_file(share->meta_file, share->rows_recorded,
share->crashed ? TRUE :FALSE);
if (my_close(share->meta_file, MYF(0)))
if (mysql_file_close(share->meta_file, MYF(0)))
result_code= 1;
if (share->tina_write_opened)
{
if (my_close(share->tina_write_filedes, MYF(0)))
if (mysql_file_close(share->tina_write_filedes, MYF(0)))
result_code= 1;
share->tina_write_opened= FALSE;
}
my_hash_delete(&tina_open_tables, (uchar*) share);
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex);
mysql_mutex_destroy(&share->mutex);
my_free((uchar*) share, MYF(0));
}
pthread_mutex_unlock(&tina_mutex);
mysql_mutex_unlock(&tina_mutex);
DBUG_RETURN(result_code);
}
......@@ -769,9 +815,9 @@ void ha_tina::get_status()
We have to use mutex to follow pthreads memory visibility
rules for share->saved_data_file_length
*/
pthread_mutex_lock(&share->mutex);
mysql_mutex_lock(&share->mutex);
local_saved_data_file_length= share->saved_data_file_length;
pthread_mutex_unlock(&share->mutex);
mysql_mutex_unlock(&share->mutex);
return;
}
local_saved_data_file_length= share->saved_data_file_length;
......@@ -825,8 +871,9 @@ int ha_tina::open(const char *name, int mode, uint open_options)
}
local_data_file_version= share->data_file_version;
if ((data_file= my_open(share->data_file_name,
O_RDONLY, MYF(MY_WME))) == -1)
if ((data_file= mysql_file_open(csv_key_file_data,
share->data_file_name,
O_RDONLY, MYF(MY_WME))) == -1)
{
free_share(share);
DBUG_RETURN(my_errno ? my_errno : -1);
......@@ -856,7 +903,7 @@ int ha_tina::close(void)
{
int rc= 0;
DBUG_ENTER("ha_tina::close");
rc= my_close(data_file, MYF(0));
rc= mysql_file_close(data_file, MYF(0));
DBUG_RETURN(free_share(share) || rc);
}
......@@ -885,20 +932,20 @@ int ha_tina::write_row(uchar * buf)
DBUG_RETURN(-1);
/* use pwrite, as concurrent reader could have changed the position */
if (my_write(share->tina_write_filedes, (uchar*)buffer.ptr(), size,
MYF(MY_WME | MY_NABP)))
if (mysql_file_write(share->tina_write_filedes, (uchar*)buffer.ptr(), size,
MYF(MY_WME | MY_NABP)))
DBUG_RETURN(-1);
/* update local copy of the max position to see our own changes */
local_saved_data_file_length+= size;
/* update shared info */
pthread_mutex_lock(&share->mutex);
mysql_mutex_lock(&share->mutex);
share->rows_recorded++;
/* update status for the log tables */
if (share->is_log_table)
update_status();
pthread_mutex_unlock(&share->mutex);
mysql_mutex_unlock(&share->mutex);
stats.records++;
DBUG_RETURN(0);
......@@ -912,10 +959,11 @@ int ha_tina::open_update_temp_file_if_needed()
if (!share->update_file_opened)
{
if ((update_temp_file=
my_create(fn_format(updated_fname, share->table_name,
"", CSN_EXT,
MY_REPLACE_EXT | MY_UNPACK_FILENAME),
0, O_RDWR | O_TRUNC, MYF(MY_WME))) < 0)
mysql_file_create(csv_key_file_update,
fn_format(updated_fname, share->table_name,
"", CSN_EXT,
MY_REPLACE_EXT | MY_UNPACK_FILENAME),
0, O_RDWR | O_TRUNC, MYF(MY_WME))) < 0)
return 1;
share->update_file_opened= TRUE;
temp_file_length= 0;
......@@ -957,8 +1005,8 @@ int ha_tina::update_row(const uchar * old_data, uchar * new_data)
if (open_update_temp_file_if_needed())
goto err;
if (my_write(update_temp_file, (uchar*)buffer.ptr(), size,
MYF(MY_WME | MY_NABP)))
if (mysql_file_write(update_temp_file, (uchar*)buffer.ptr(), size,
MYF(MY_WME | MY_NABP)))
goto err;
temp_file_length+= size;
rc= 0;
......@@ -992,9 +1040,9 @@ int ha_tina::delete_row(const uchar * buf)
stats.records--;
/* Update shared info */
DBUG_ASSERT(share->rows_recorded);
pthread_mutex_lock(&share->mutex);
mysql_mutex_lock(&share->mutex);
share->rows_recorded--;
pthread_mutex_unlock(&share->mutex);
mysql_mutex_unlock(&share->mutex);
/* DELETE should never happen on the log table */
DBUG_ASSERT(!share->is_log_table);
......@@ -1021,8 +1069,10 @@ int ha_tina::init_data_file()
if (local_data_file_version != share->data_file_version)
{
local_data_file_version= share->data_file_version;
if (my_close(data_file, MYF(0)) ||
(data_file= my_open(share->data_file_name, O_RDONLY, MYF(MY_WME))) == -1)
if (mysql_file_close(data_file, MYF(0)) ||
(data_file= mysql_file_open(csv_key_file_data,
share->data_file_name, O_RDONLY,
MYF(MY_WME))) == -1)
return my_errno ? my_errno : -1;
}
file_buff->init_buff(data_file);
......@@ -1184,9 +1234,9 @@ int ha_tina::extra(enum ha_extra_function operation)
DBUG_ENTER("ha_tina::extra");
if (operation == HA_EXTRA_MARK_AS_LOG_TABLE)
{
pthread_mutex_lock(&share->mutex);
mysql_mutex_lock(&share->mutex);
share->is_log_table= TRUE;
pthread_mutex_unlock(&share->mutex);
mysql_mutex_unlock(&share->mutex);
}
DBUG_RETURN(0);
}
......@@ -1255,10 +1305,10 @@ int ha_tina::rnd_end()
/* if there is something to write, write it */
if (write_length)
{
if (my_write(update_temp_file,
(uchar*) (file_buff->ptr() +
(write_begin - file_buff->start())),
(size_t)write_length, MYF_RW))
if (mysql_file_write(update_temp_file,
(uchar*) (file_buff->ptr() +
(write_begin - file_buff->start())),
(size_t)write_length, MYF_RW))
goto error;
temp_file_length+= write_length;
}
......@@ -1279,15 +1329,15 @@ int ha_tina::rnd_end()
}
if (my_sync(update_temp_file, MYF(MY_WME)) ||
my_close(update_temp_file, MYF(0)))
if (mysql_file_sync(update_temp_file, MYF(MY_WME)) ||
mysql_file_close(update_temp_file, MYF(0)))
DBUG_RETURN(-1);
share->update_file_opened= FALSE;
if (share->tina_write_opened)
{
if (my_close(share->tina_write_filedes, MYF(0)))
if (mysql_file_close(share->tina_write_filedes, MYF(0)))
DBUG_RETURN(-1);
/*
Mark that the writer fd is closed, so that init_tina_writer()
......@@ -1300,15 +1350,18 @@ int ha_tina::rnd_end()
Close opened fildes's. Then move updated file in place
of the old datafile.
*/
if (my_close(data_file, MYF(0)) ||
my_rename(fn_format(updated_fname, share->table_name, "", CSN_EXT,
MY_REPLACE_EXT | MY_UNPACK_FILENAME),
share->data_file_name, MYF(0)))
if (mysql_file_close(data_file, MYF(0)) ||
mysql_file_rename(csv_key_file_data,
fn_format(updated_fname, share->table_name,
"", CSN_EXT,
MY_REPLACE_EXT | MY_UNPACK_FILENAME),
share->data_file_name, MYF(0)))
DBUG_RETURN(-1);
/* Open the file again */
if (((data_file= my_open(share->data_file_name,
O_RDONLY, MYF(MY_WME))) == -1))
if (((data_file= mysql_file_open(csv_key_file_data,
share->data_file_name,
O_RDONLY, MYF(MY_WME))) == -1))
DBUG_RETURN(my_errno ? my_errno : -1);
/*
As we reopened the data file, increase share->data_file_version
......@@ -1335,7 +1388,7 @@ int ha_tina::rnd_end()
DBUG_RETURN(0);
error:
my_close(update_temp_file, MYF(0));
mysql_file_close(update_temp_file, MYF(0));
share->update_file_opened= FALSE;
DBUG_RETURN(-1);
}
......@@ -1421,10 +1474,12 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
Otherwise we've encountered a bad row => repair is needed.
Let us create a temporary file.
*/
if ((repair_file= my_create(fn_format(repaired_fname, share->table_name,
"", CSN_EXT,
MY_REPLACE_EXT|MY_UNPACK_FILENAME),
0, O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
if ((repair_file= mysql_file_create(csv_key_file_update,
fn_format(repaired_fname,
share->table_name,
"", CSN_EXT,
MY_REPLACE_EXT|MY_UNPACK_FILENAME),
0, O_RDWR | O_TRUNC, MYF(MY_WME))) < 0)
DBUG_RETURN(HA_ERR_CRASHED_ON_REPAIR);
file_buff->init_buff(data_file);
......@@ -1438,8 +1493,8 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
{
write_end= min(file_buff->end(), current_position);
if ((write_end - write_begin) &&
(my_write(repair_file, (uchar*)file_buff->ptr(),
(size_t) (write_end - write_begin), MYF_RW)))
(mysql_file_write(repair_file, (uchar*)file_buff->ptr(),
(size_t) (write_end - write_begin), MYF_RW)))
DBUG_RETURN(-1);
write_begin= write_end;
......@@ -1453,7 +1508,7 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
Close the files and rename repaired file to the datafile.
We have to close the files, as on Windows one cannot rename
a file, which descriptor is still open. EACCES will be returned
when trying to delete the "to"-file in my_rename().
when trying to delete the "to"-file in mysql_file_rename().
*/
if (share->tina_write_opened)
{
......@@ -1462,17 +1517,20 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
during write_row execution. We need to close both instances
to satisfy Win.
*/
if (my_close(share->tina_write_filedes, MYF(0)))
if (mysql_file_close(share->tina_write_filedes, MYF(0)))
DBUG_RETURN(my_errno ? my_errno : -1);
share->tina_write_opened= FALSE;
}
if (my_close(data_file,MYF(0)) || my_close(repair_file, MYF(0)) ||
my_rename(repaired_fname, share->data_file_name, MYF(0)))
if (mysql_file_close(data_file, MYF(0)) ||
mysql_file_close(repair_file, MYF(0)) ||
mysql_file_rename(csv_key_file_data,
repaired_fname, share->data_file_name, MYF(0)))
DBUG_RETURN(-1);
/* Open the file again, it should now be repaired */
if ((data_file= my_open(share->data_file_name, O_RDWR|O_APPEND,
MYF(MY_WME))) == -1)
if ((data_file= mysql_file_open(csv_key_file_data,
share->data_file_name, O_RDWR|O_APPEND,
MYF(MY_WME))) == -1)
DBUG_RETURN(my_errno ? my_errno : -1);
/* Set new file size. The file size will be updated by ::update_status() */
......@@ -1500,13 +1558,13 @@ int ha_tina::delete_all_rows()
DBUG_RETURN(-1);
/* Truncate the file to zero size */
rc= my_chsize(share->tina_write_filedes, 0, 0, MYF(MY_WME));
rc= mysql_file_chsize(share->tina_write_filedes, 0, 0, MYF(MY_WME));
stats.records=0;
/* Update shared info */
pthread_mutex_lock(&share->mutex);
mysql_mutex_lock(&share->mutex);
share->rows_recorded= 0;
pthread_mutex_unlock(&share->mutex);
mysql_mutex_unlock(&share->mutex);
local_saved_data_file_length= 0;
DBUG_RETURN(rc);
}
......@@ -1550,20 +1608,22 @@ int ha_tina::create(const char *name, TABLE *table_arg,
}
if ((create_file= my_create(fn_format(name_buff, name, "", CSM_EXT,
MY_REPLACE_EXT|MY_UNPACK_FILENAME), 0,
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
if ((create_file= mysql_file_create(csv_key_file_metadata,
fn_format(name_buff, name, "", CSM_EXT,
MY_REPLACE_EXT|MY_UNPACK_FILENAME),
0, O_RDWR | O_TRUNC, MYF(MY_WME))) < 0)
DBUG_RETURN(-1);
write_meta_file(create_file, 0, FALSE);
my_close(create_file, MYF(0));
mysql_file_close(create_file, MYF(0));
if ((create_file= my_create(fn_format(name_buff, name, "", CSV_EXT,
MY_REPLACE_EXT|MY_UNPACK_FILENAME),0,
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
if ((create_file= mysql_file_create(csv_key_file_data,
fn_format(name_buff, name, "", CSV_EXT,
MY_REPLACE_EXT|MY_UNPACK_FILENAME),
0, O_RDWR | O_TRUNC, MYF(MY_WME))) < 0)
DBUG_RETURN(-1);
my_close(create_file, MYF(0));
mysql_file_close(create_file, MYF(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
it under the terms of the GNU General Public License as published by
......@@ -41,7 +41,7 @@ typedef struct st_tina_share {
share initialization.
*/
my_off_t saved_data_file_length;
pthread_mutex_t mutex;
mysql_mutex_t mutex;
THR_LOCK lock;
bool update_file_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
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)
filedes= filedes_arg;
/* read the beginning of the file */
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)
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()
......@@ -63,7 +63,8 @@ my_off_t Transparent_file::read_next()
No need to seek here, as the file managed by Transparent_file class
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;
/* end of file */
......@@ -85,10 +86,10 @@ char Transparent_file::get_value(my_off_t offset)
if ((lower_bound <= offset) && (((my_off_t) offset) < upper_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 */
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 0;
lower_bound= offset;
......
......@@ -112,7 +112,7 @@ handlerton *example_hton;
static HASH example_open_tables;
/* The mutex used to init the hash; variable for example share methods */
pthread_mutex_t example_mutex;
mysql_mutex_t example_mutex;
/**
@brief
......@@ -126,13 +126,39 @@ static uchar* example_get_key(EXAMPLE_SHARE *share, size_t *length,
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)
{
DBUG_ENTER("example_init_func");
#ifdef HAVE_PSI_INTERFACE
init_example_psi_keys();
#endif
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,
(my_hash_get_key) example_get_key,0,0);
......@@ -152,7 +178,7 @@ static int example_done_func(void *p)
if (example_open_tables.records)
error= 1;
my_hash_free(&example_open_tables);
pthread_mutex_destroy(&example_mutex);
mysql_mutex_destroy(&example_mutex);
DBUG_RETURN(0);
}
......@@ -172,7 +198,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
uint length;
char *tmp_name;
pthread_mutex_lock(&example_mutex);
mysql_mutex_lock(&example_mutex);
length=(uint) strlen(table_name);
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)
&tmp_name, length+1,
NullS)))
{
pthread_mutex_unlock(&example_mutex);
mysql_mutex_unlock(&example_mutex);
return NULL;
}
......@@ -196,15 +222,16 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
if (my_hash_insert(&example_open_tables, (uchar*) share))
goto error;
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++;
pthread_mutex_unlock(&example_mutex);
mysql_mutex_unlock(&example_mutex);
return share;
error:
pthread_mutex_destroy(&share->mutex);
mysql_mutex_destroy(&share->mutex);
my_free(share, MYF(0));
return NULL;
......@@ -219,15 +246,15 @@ error:
static int free_share(EXAMPLE_SHARE *share)
{
pthread_mutex_lock(&example_mutex);
mysql_mutex_lock(&example_mutex);
if (!--share->use_count)
{
my_hash_delete(&example_open_tables, (uchar*) share);
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex);
mysql_mutex_destroy(&share->mutex);
my_free(share, MYF(0));
}
pthread_mutex_unlock(&example_mutex);
mysql_mutex_unlock(&example_mutex);
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
it under the terms of the GNU General Public License as published by
......@@ -42,7 +42,7 @@
typedef struct st_example_share {
char *table_name;
uint table_name_length,use_count;
pthread_mutex_t mutex;
mysql_mutex_t mutex;
THR_LOCK lock;
} 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
it under the terms of the GNU General Public License as published by
......@@ -388,7 +388,7 @@
/* Variables for federated share methods */
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
// identifiers
static char value_quote_char= '\''; // Character for quoting
......@@ -427,6 +427,28 @@ static uchar *federated_get_key(FEDERATED_SHARE *share, size_t *length,
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.
......@@ -442,6 +464,11 @@ static uchar *federated_get_key(FEDERATED_SHARE *share, size_t *length,
int federated_db_init(void *p)
{
DBUG_ENTER("federated_db_init");
#ifdef HAVE_PSI_INTERFACE
init_federated_psi_keys();
#endif /* HAVE_PSI_INTERFACE */
handlerton *federated_hton= (handlerton *)p;
federated_hton->state= SHOW_OPTION_YES;
federated_hton->db_type= DB_TYPE_FEDERATED_DB;
......@@ -457,7 +484,8 @@ int federated_db_init(void *p)
federated_hton->commit= 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;
if (!my_hash_init(&federated_open_tables, &my_charset_bin, 32, 0, 0,
(my_hash_get_key) federated_get_key, 0, 0))
......@@ -465,7 +493,7 @@ int federated_db_init(void *p)
DBUG_RETURN(FALSE);
}
pthread_mutex_destroy(&federated_mutex);
mysql_mutex_destroy(&federated_mutex);
error:
DBUG_RETURN(TRUE);
}
......@@ -484,7 +512,7 @@ error:
int federated_done(void *p)
{
my_hash_free(&federated_open_tables);
pthread_mutex_destroy(&federated_mutex);
mysql_mutex_destroy(&federated_mutex);
return 0;
}
......@@ -1487,7 +1515,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
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_length= (uint) strlen(table_name);
......@@ -1529,18 +1557,19 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
if (my_hash_insert(&federated_open_tables, (uchar*) share))
goto error;
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
free_root(&mem_root, MYF(0)); /* prevents memory leak */
share->use_count++;
pthread_mutex_unlock(&federated_mutex);
mysql_mutex_unlock(&federated_mutex);
DBUG_RETURN(share);
error:
pthread_mutex_unlock(&federated_mutex);
mysql_mutex_unlock(&federated_mutex);
free_root(&mem_root, MYF(0));
DBUG_RETURN(NULL);
}
......@@ -1557,15 +1586,15 @@ static int free_share(FEDERATED_SHARE *share)
MEM_ROOT mem_root= share->mem_root;
DBUG_ENTER("free_share");
pthread_mutex_lock(&federated_mutex);
mysql_mutex_lock(&federated_mutex);
if (!--share->use_count)
{
my_hash_delete(&federated_open_tables, (uchar*) share);
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex);
mysql_mutex_destroy(&share->mutex);
free_root(&mem_root, MYF(0));
}
pthread_mutex_unlock(&federated_mutex);
mysql_mutex_unlock(&federated_mutex);
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
it under the terms of the GNU General Public License as published by
......@@ -71,7 +71,7 @@ typedef struct st_federated_share {
ushort port;
size_t table_name_length, server_name_length, connect_string_length, use_count;
pthread_mutex_t mutex;
mysql_mutex_t mutex;
THR_LOCK lock;
} 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
it under the terms of the GNU General Public License as published by
......@@ -39,6 +39,10 @@ int heap_init(void *p)
{
handlerton *heap_hton;
#ifdef HAVE_PSI_INTERFACE
init_heap_psi_keys();
#endif
heap_hton= (handlerton *)p;
heap_hton->state= SHOW_OPTION_YES;
heap_hton->db_type= DB_TYPE_HEAP;
......@@ -106,9 +110,9 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
if (!file)
{
/* 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);
pthread_mutex_unlock(&THR_LOCK_heap);
mysql_mutex_unlock(&THR_LOCK_heap);
}
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
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);
extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
key_part_map keypart_map);
#ifdef THREAD
extern pthread_mutex_t THR_LOCK_heap;
#else
#define pthread_mutex_lock(A)
#define pthread_mutex_unlock(A)
extern mysql_mutex_t THR_LOCK_heap;
#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
/* 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
it under the terms of the GNU General Public License as published by
......@@ -24,9 +24,9 @@ int heap_close(HP_INFO *info)
{
int tmp;
DBUG_ENTER("heap_close");
pthread_mutex_lock(&THR_LOCK_heap);
mysql_mutex_lock(&THR_LOCK_heap);
tmp= hp_close(info);
pthread_mutex_unlock(&THR_LOCK_heap);
mysql_mutex_unlock(&THR_LOCK_heap);
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
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,
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)
{
hp_free(share);
......@@ -194,7 +194,8 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
}
#ifdef THREAD
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
if (!create_info->internal_table)
{
......@@ -205,14 +206,14 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
share->delete_on_close= 1;
}
if (!create_info->internal_table)
pthread_mutex_unlock(&THR_LOCK_heap);
mysql_mutex_unlock(&THR_LOCK_heap);
*res= share;
DBUG_RETURN(0);
err:
if (!create_info->internal_table)
pthread_mutex_unlock(&THR_LOCK_heap);
mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(1);
} /* heap_create */
......@@ -266,7 +267,7 @@ int heap_delete_table(const char *name)
reg1 HP_SHARE *share;
DBUG_ENTER("heap_delete_table");
pthread_mutex_lock(&THR_LOCK_heap);
mysql_mutex_lock(&THR_LOCK_heap);
if ((share= hp_find_named_heap(name)))
{
heap_try_free(share);
......@@ -276,7 +277,7 @@ int heap_delete_table(const char *name)
{
result= my_errno=ENOENT;
}
pthread_mutex_unlock(&THR_LOCK_heap);
mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(result);
}
......@@ -284,9 +285,9 @@ int heap_delete_table(const char *name)
void heap_drop_table(HP_INFO *info)
{
DBUG_ENTER("heap_drop_table");
pthread_mutex_lock(&THR_LOCK_heap);
mysql_mutex_lock(&THR_LOCK_heap);
heap_try_free(info->s);
pthread_mutex_unlock(&THR_LOCK_heap);
mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_VOID_RETURN;
}
......@@ -298,7 +299,7 @@ void hp_free(HP_SHARE *share)
hp_clear(share); /* Remove blocks from memory */
#ifdef THREAD
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->intern_lock);
mysql_mutex_destroy(&share->intern_lock);
#endif
my_free((uchar*) share->name, 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
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)
HP_INFO *info;
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)))
{
info->open_list.data= (void*) info;
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);
}
......@@ -94,11 +94,11 @@ HP_INFO *heap_open(const char *name, int mode)
HP_SHARE *share;
DBUG_ENTER("heap_open");
pthread_mutex_lock(&THR_LOCK_heap);
mysql_mutex_lock(&THR_LOCK_heap);
if (!(share= hp_find_named_heap(name)))
{
my_errno= ENOENT;
pthread_mutex_unlock(&THR_LOCK_heap);
mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(0);
}
if ((info= heap_open_from_share(share, mode)))
......@@ -106,7 +106,7 @@ HP_INFO *heap_open(const char *name, int mode)
info->open_list.data= (void*) info;
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);
}
......
/* 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
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)
LIST *element,*next_open;
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)
{
HP_INFO *info=(HP_INFO*) element->data;
......@@ -51,6 +51,6 @@ int hp_panic(enum ha_panic_function flag)
break;
}
}
pthread_mutex_unlock(&THR_LOCK_heap);
mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(0);
} /* 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
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)
char *name_buff;
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 (!(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);
}
my_free(info->name,MYF(0));
info->name=name_buff;
}
pthread_mutex_unlock(&THR_LOCK_heap);
mysql_mutex_unlock(&THR_LOCK_heap);
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
it under the terms of the GNU General Public License as published by
......@@ -23,3 +23,34 @@
#endif
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
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,
*/
#ifdef THREAD
if (param->need_print_msg_lock)
pthread_mutex_lock(&param->print_msg_mutex);
mysql_mutex_lock(&param->print_msg_mutex);
#endif
protocol->prepare_for_resend();
protocol->store(name, length, system_charset_info);
......@@ -130,7 +130,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
msgbuf);
#ifdef THREAD
if (param->need_print_msg_lock)
pthread_mutex_unlock(&param->print_msg_mutex);
mysql_mutex_unlock(&param->print_msg_mutex);
#endif
return;
}
......@@ -762,13 +762,13 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
mi_is_crashed(file))
{
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 |
STATE_CRASHED_ON_REPAIR);
if (!(table->db_stat & HA_READ_ONLY))
error=update_state_info(&param,file,UPDATE_TIME | UPDATE_OPEN_COUNT |
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 |
HA_STATUS_CONST);
}
......@@ -812,9 +812,9 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
error = chk_key(&param, file);
if (!error)
{
pthread_mutex_lock(&share->intern_lock);
mysql_mutex_lock(&share->intern_lock);
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)
mi_mark_crashed(file);
......@@ -1926,6 +1926,10 @@ static int myisam_init(void *p)
{
handlerton *myisam_hton;
#ifdef HAVE_PSI_INTERFACE
init_myisam_psi_keys();
#endif
myisam_hton= (handlerton *)p;
myisam_hton->state= SHOW_OPTION_YES;
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
it under the terms of the GNU General Public License as published by
......@@ -29,7 +29,7 @@
is set) - unread part is bzero'ed
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,
if ((my_off_t) read_length > (my_off_t) (info->pos_in_file-pos))
read_length=(uint) (info->pos_in_file-pos);
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);
if (!(length-=read_length))
DBUG_RETURN(0);
......@@ -88,7 +88,8 @@ int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length,
else
{
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);
}
if (!(flag & READING_HEADER) || (int) read_length == -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
it under the terms of the GNU General Public License as published by
......@@ -53,8 +53,8 @@
#include "rt_index.h"
#ifndef USE_RAID
#define my_raid_create(A,B,C,D,E,F,G) my_create(A,B,C,G)
#define my_raid_delete(A,B,C) my_delete(A,B)
#define my_raid_create(K, A, B, C, D, E, F, G) mysql_file_create(K, A, B, C, G)
#define my_raid_delete(K, A, B, C) mysql_file_delete(K, A, B)
#endif
/* Functions defined in this file */
......@@ -175,8 +175,8 @@ int chk_del(MI_CHECK *param, register MI_INFO *info, uint test_flag)
printf(" %9s",llstr(next_link,buff));
if (next_link >= info->state->data_file_length)
goto wrong;
if (my_pread(info->dfile, (uchar*) buff,delete_link_length,
next_link,MYF(MY_NABP)))
if (mysql_file_pread(info->dfile, (uchar*) buff, delete_link_length,
next_link, MYF(MY_NABP)))
{
if (test_flag & T_VERBOSE) puts("");
mi_check_print_error(param,"Can't read delete-link at filepos: %s",
......@@ -338,7 +338,7 @@ int chk_size(MI_CHECK *param, register MI_INFO *info)
flush_key_blocks(info->s->key_cache,
info->s->kfile, FLUSH_FORCE_WRITE);
size= my_seek(info->s->kfile, 0L, MY_SEEK_END, MYF(MY_THREADSAFE));
size= mysql_file_seek(info->s->kfile, 0L, MY_SEEK_END, MYF(MY_THREADSAFE));
if ((skr=(my_off_t) info->state->key_file_length) != size)
{
/* Don't give error if file generated by myisampack */
......@@ -362,7 +362,7 @@ int chk_size(MI_CHECK *param, register MI_INFO *info)
llstr(info->state->key_file_length,buff),
llstr(info->s->base.max_key_file_length-1,buff));
size=my_seek(info->dfile,0L,MY_SEEK_END,MYF(0));
size= mysql_file_seek(info->dfile, 0L, MY_SEEK_END, MYF(0));
skr=(my_off_t) info->state->data_file_length;
if (info->s->options & HA_OPTION_COMPRESS_RECORD)
skr+= MEMMAP_EXTRA_MARGIN;
......@@ -598,8 +598,8 @@ static int chk_index_down(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
{
/* purecov: begin tested */
/* Give it a chance to fit in the real file size. */
my_off_t max_length= my_seek(info->s->kfile, 0L, MY_SEEK_END,
MYF(MY_THREADSAFE));
my_off_t max_length= mysql_file_seek(info->s->kfile, 0L, MY_SEEK_END,
MYF(MY_THREADSAFE));
mi_check_print_error(param, "Invalid key block position: %s "
"key block size: %u file_length: %s",
llstr(page, llbuff), keyinfo->block_length,
......@@ -1577,14 +1577,15 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
if (!rep_quick)
{
/* Get real path for data file */
if ((new_file=my_raid_create(fn_format(param->temp_filename,
share->data_file_name, "",
DATA_TMP_EXT, 2+4),
0,param->tmpfile_createflag,
share->base.raid_type,
share->base.raid_chunks,
share->base.raid_chunksize,
MYF(0))) < 0)
if ((new_file= my_raid_create(mi_key_file_datatmp,
fn_format(param->temp_filename,
share->data_file_name, "",
DATA_TMP_EXT, 2+4),
0, param->tmpfile_createflag,
share->base.raid_type,
share->base.raid_chunks,
share->base.raid_chunksize,
MYF(0))) < 0)
{
mi_check_print_error(param,"Can't create new tempfile: '%s'",
param->temp_filename);
......@@ -1608,7 +1609,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
sort_param.pos=sort_param.max_pos=share->pack.header_length;
sort_param.filepos=new_header_length;
param->read_cache.end_of_file=sort_info.filelength=
my_seek(info->dfile,0L,MY_SEEK_END,MYF(0));
mysql_file_seek(info->dfile, 0L, MY_SEEK_END, MYF(0));
sort_info.dupp=0;
sort_param.fix_datafile= (my_bool) (! rep_quick);
sort_param.master=1;
......@@ -1670,7 +1671,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
{
(void) fputs(" \r",stdout); (void) fflush(stdout);
}
if (my_chsize(share->kfile,info->state->key_file_length,0,MYF(0)))
if (mysql_file_chsize(share->kfile, info->state->key_file_length, 0, MYF(0)))
{
mi_check_print_warning(param,
"Can't change size of indexfile, error: %d",
......@@ -1700,7 +1701,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
if (!rep_quick)
{
my_close(info->dfile,MYF(0));
mysql_file_close(info->dfile, MYF(0));
info->dfile=new_file;
info->state->data_file_length=sort_param.filepos;
share->state.version=(ulong) time((time_t*) 0); /* Force reopen */
......@@ -1733,7 +1734,7 @@ err:
/* Replace the actual file with the temporary file */
if (new_file >= 0)
{
my_close(new_file,MYF(0));
mysql_file_close(new_file, MYF(0));
info->dfile=new_file= -1;
if (change_to_newfile(share->data_file_name,MI_NAME_DEXT,
DATA_TMP_EXT, share->base.raid_chunks,
......@@ -1750,9 +1751,10 @@ err:
llstr(sort_param.start_recpos,llbuff));
if (new_file >= 0)
{
(void) my_close(new_file,MYF(0));
(void) my_raid_delete(param->temp_filename,info->s->base.raid_chunks,
MYF(MY_WME));
(void) mysql_file_close(new_file, MYF(0));
(void) my_raid_delete(mi_key_file_datatmp,
param->temp_filename, info->s->base.raid_chunks,
MYF(MY_WME));
info->rec_cache.file=-1; /* don't flush data to new_file, it's closed */
}
mi_mark_crashed_on_repair(info);
......@@ -1949,9 +1951,11 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name)
/* Get real path for index file */
fn_format(param->temp_filename,name,"", MI_NAME_IEXT,2+4+32);
if ((new_file=my_create(fn_format(param->temp_filename,param->temp_filename,
"", INDEX_TMP_EXT,2+4),
0,param->tmpfile_createflag,MYF(0))) <= 0)
if ((new_file= mysql_file_create(mi_key_file_datatmp,
fn_format(param->temp_filename,
param->temp_filename,
"", INDEX_TMP_EXT, 2+4),
0, param->tmpfile_createflag, MYF(0))) <= 0)
{
mi_check_print_error(param,"Can't create new tempfile: '%s'",
param->temp_filename);
......@@ -1991,9 +1995,9 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name)
/* Put same locks as old file */
share->r_locks= share->w_locks= share->tot_locks= 0;
(void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
(void) my_close(share->kfile,MYF(MY_WME));
(void) mysql_file_close(share->kfile, MYF(MY_WME));
share->kfile = -1;
(void) my_close(new_file,MYF(MY_WME));
(void) mysql_file_close(new_file, MYF(MY_WME));
if (change_to_newfile(share->index_file_name,MI_NAME_IEXT,INDEX_TMP_EXT,0,
MYF(0)) ||
mi_open_keyfile(share))
......@@ -2017,9 +2021,10 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name)
DBUG_RETURN(0);
err:
(void) my_close(new_file,MYF(MY_WME));
(void) mysql_file_close(new_file, MYF(MY_WME));
err2:
(void) my_delete(param->temp_filename,MYF(MY_WME));
(void) mysql_file_delete(mi_key_file_datatmp,
param->temp_filename, MYF(MY_WME));
DBUG_RETURN(-1);
} /* mi_sort_index */
......@@ -2099,8 +2104,8 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
/* Fill block with zero and write it to the new index file */
length=mi_getint(buff);
bzero((uchar*) buff+length,keyinfo->block_length-length);
if (my_pwrite(new_file,(uchar*) buff,(uint) keyinfo->block_length,
new_page_pos,MYF(MY_NABP | MY_WAIT_IF_FULL)))
if (mysql_file_pwrite(new_file, (uchar*) buff, (uint) keyinfo->block_length,
new_page_pos, MYF(MY_NABP | MY_WAIT_IF_FULL)))
{
mi_check_print_error(param,"Can't write indexblock, error: %d",my_errno);
goto err;
......@@ -2176,16 +2181,16 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
buff=tmp_buff; buff_length=IO_SIZE;
}
my_seek(from,start,MY_SEEK_SET,MYF(0));
mysql_file_seek(from, start, MY_SEEK_SET, MYF(0));
while (length > buff_length)
{
if (my_read(from,(uchar*) buff,buff_length,MYF(MY_NABP)) ||
my_write(to,(uchar*) buff,buff_length,param->myf_rw))
if (mysql_file_read(from, (uchar*) buff, buff_length, MYF(MY_NABP)) ||
mysql_file_write(to, (uchar*) buff, buff_length, param->myf_rw))
goto err;
length-= buff_length;
}
if (my_read(from,(uchar*) buff,(uint) length,MYF(MY_NABP)) ||
my_write(to,(uchar*) buff,(uint) length,param->myf_rw))
if (mysql_file_read(from, (uchar*) buff, (uint) length, MYF(MY_NABP)) ||
mysql_file_write(to, (uchar*) buff, (uint) length, param->myf_rw))
goto err;
if (buff != tmp_buff)
my_free(buff,MYF(0));
......@@ -2275,14 +2280,15 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
if (!rep_quick)
{
/* Get real path for data file */
if ((new_file=my_raid_create(fn_format(param->temp_filename,
share->data_file_name, "",
DATA_TMP_EXT, 2+4),
0,param->tmpfile_createflag,
share->base.raid_type,
share->base.raid_chunks,
share->base.raid_chunksize,
MYF(0))) < 0)
if ((new_file= my_raid_create(mi_key_file_datatmp,
fn_format(param->temp_filename,
share->data_file_name, "",
DATA_TMP_EXT, 2+4),
0, param->tmpfile_createflag,
share->base.raid_type,
share->base.raid_chunks,
share->base.raid_chunksize,
MYF(0))) < 0)
{
mi_check_print_error(param,"Can't create new tempfile: '%s'",
param->temp_filename);
......@@ -2320,7 +2326,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
sort_info.dupp=0;
sort_info.buff=0;
param->read_cache.end_of_file=sort_info.filelength=
my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
mysql_file_seek(param->read_cache.file, 0L, MY_SEEK_END, MYF(0));
sort_param.wordlist=NULL;
init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
......@@ -2470,7 +2476,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
sort_param.filepos;
/* Only whole records */
share->state.version=(ulong) time((time_t*) 0);
my_close(info->dfile,MYF(0));
mysql_file_close(info->dfile, MYF(0));
info->dfile=new_file;
share->data_file_type=sort_info.new_data_file_type;
share->pack.header_length=(ulong) new_header_length;
......@@ -2510,7 +2516,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
skr=share->base.reloc*share->base.min_pack_length;
#endif
if (skr != sort_info.filelength && !info->s->base.raid_type)
if (my_chsize(info->dfile,skr,0,MYF(0)))
if (mysql_file_chsize(info->dfile, skr, 0, MYF(0)))
mi_check_print_warning(param,
"Can't change size of datafile, error: %d",
my_errno);
......@@ -2518,7 +2524,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
if (param->testflag & T_CALC_CHECKSUM)
info->state->checksum=param->glob_crc;
if (my_chsize(share->kfile,info->state->key_file_length,0,MYF(0)))
if (mysql_file_chsize(share->kfile, info->state->key_file_length, 0, MYF(0)))
mi_check_print_warning(param,
"Can't change size of indexfile, error: %d",
my_errno);
......@@ -2545,7 +2551,7 @@ err:
/* Replace the actual file with the temporary file */
if (new_file >= 0)
{
my_close(new_file,MYF(0));
mysql_file_close(new_file, MYF(0));
info->dfile=new_file= -1;
if (change_to_newfile(share->data_file_name,MI_NAME_DEXT,
DATA_TMP_EXT, share->base.raid_chunks,
......@@ -2561,9 +2567,10 @@ err:
mi_check_print_error(param,"%d when fixing table",my_errno);
if (new_file >= 0)
{
(void) my_close(new_file,MYF(0));
(void) my_raid_delete(param->temp_filename,share->base.raid_chunks,
MYF(MY_WME));
(void) mysql_file_close(new_file, MYF(0));
(void) my_raid_delete(mi_key_file_datatmp,
param->temp_filename, share->base.raid_chunks,
MYF(MY_WME));
if (info->dfile == new_file) /* Retry with key cache */
if (unlikely(mi_open_datafile(info, share, name, -1)))
param->retry_repair= 0; /* Safety */
......@@ -2704,9 +2711,11 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
DBUG_PRINT("info", ("is quick repair: %d", rep_quick));
bzero((char*)&sort_info,sizeof(sort_info));
/* Initialize pthread structures before goto err. */
pthread_mutex_init(&sort_info.mutex, MY_MUTEX_INIT_FAST);
pthread_cond_init(&sort_info.cond, 0);
pthread_mutex_init(&param->print_msg_mutex, MY_MUTEX_INIT_FAST);
mysql_mutex_init(mi_key_mutex_MI_SORT_INFO_mutex,
&sort_info.mutex, MY_MUTEX_INIT_FAST);
mysql_cond_init(mi_key_cond_MI_SORT_INFO_cond, &sort_info.cond, 0);
mysql_mutex_init(mi_key_mutex_MI_CHECK_print_msg,
&param->print_msg_mutex, MY_MUTEX_INIT_FAST);
param->need_print_msg_lock= 1;
if (!(sort_info.key_block=
......@@ -2732,15 +2741,16 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
if (!rep_quick)
{
/* Get real path for data file */
if ((new_file=my_raid_create(fn_format(param->temp_filename,
share->data_file_name, "",
DATA_TMP_EXT,
2+4),
0,param->tmpfile_createflag,
share->base.raid_type,
share->base.raid_chunks,
share->base.raid_chunksize,
MYF(0))) < 0)
if ((new_file= my_raid_create(mi_key_file_datatmp,
fn_format(param->temp_filename,
share->data_file_name, "",
DATA_TMP_EXT,
2+4),
0, param->tmpfile_createflag,
share->base.raid_type,
share->base.raid_chunks,
share->base.raid_chunksize,
MYF(0))) < 0)
{
mi_check_print_error(param,"Can't create new tempfile: '%s'",
param->temp_filename);
......@@ -2777,7 +2787,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
sort_info.dupp=0;
sort_info.buff=0;
param->read_cache.end_of_file=sort_info.filelength=
my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
mysql_file_seek(param->read_cache.file, 0L, MY_SEEK_END, MYF(0));
if (share->data_file_type == DYNAMIC_RECORD)
rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
......@@ -2903,7 +2913,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
goto err;
sort_info.got_error=0;
pthread_mutex_lock(&sort_info.mutex);
mysql_mutex_lock(&sort_info.mutex);
/*
Initialize the I/O cache share for use with the read caches and, in
......@@ -2951,9 +2961,10 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
#else
param->sort_buffer_length*sort_param[i].key_length/total_key_length;
#endif
if (pthread_create(&sort_param[i].thr, &thr_attr,
thr_find_all_keys,
(void *) (sort_param+i)))
if (mysql_thread_create(mi_key_thread_find_all_keys,
&sort_param[i].thr, &thr_attr,
thr_find_all_keys,
(void *) (sort_param+i)))
{
mi_check_print_error(param,"Cannot start a repair thread");
/* Cleanup: Detach from the share. Avoid others to be blocked. */
......@@ -2969,8 +2980,8 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
/* waiting for all threads to finish */
while (sort_info.threads_running)
pthread_cond_wait(&sort_info.cond, &sort_info.mutex);
pthread_mutex_unlock(&sort_info.mutex);
mysql_cond_wait(&sort_info.cond, &sort_info.mutex);
mysql_mutex_unlock(&sort_info.mutex);
if ((got_error= thr_write_keys(sort_param)))
{
......@@ -3006,7 +3017,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
Exchange the data file descriptor of the table, so that we use the
new file from now on.
*/
my_close(info->dfile,MYF(0));
mysql_file_close(info->dfile, MYF(0));
info->dfile=new_file;
share->data_file_type=sort_info.new_data_file_type;
......@@ -3035,7 +3046,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
skr=share->base.reloc*share->base.min_pack_length;
#endif
if (skr != sort_info.filelength && !info->s->base.raid_type)
if (my_chsize(info->dfile,skr,0,MYF(0)))
if (mysql_file_chsize(info->dfile, skr, 0, MYF(0)))
mi_check_print_warning(param,
"Can't change size of datafile, error: %d",
my_errno);
......@@ -3043,7 +3054,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
if (param->testflag & T_CALC_CHECKSUM)
info->state->checksum=param->glob_crc;
if (my_chsize(share->kfile,info->state->key_file_length,0,MYF(0)))
if (mysql_file_chsize(share->kfile, info->state->key_file_length, 0, MYF(0)))
mi_check_print_warning(param,
"Can't change size of indexfile, error: %d", my_errno);
......@@ -3082,7 +3093,7 @@ err:
/* Replace the actual file with the temporary file */
if (new_file >= 0)
{
my_close(new_file,MYF(0));
mysql_file_close(new_file, MYF(0));
info->dfile=new_file= -1;
if (change_to_newfile(share->data_file_name,MI_NAME_DEXT,
DATA_TMP_EXT, share->base.raid_chunks,
......@@ -3098,9 +3109,10 @@ err:
mi_check_print_error(param,"%d when fixing table",my_errno);
if (new_file >= 0)
{
(void) my_close(new_file,MYF(0));
(void) my_raid_delete(param->temp_filename,share->base.raid_chunks,
MYF(MY_WME));
(void) mysql_file_close(new_file, MYF(0));
(void) my_raid_delete(mi_key_file_datatmp,
param->temp_filename, share->base.raid_chunks,
MYF(MY_WME));
if (info->dfile == new_file) /* Retry with key cache */
if (unlikely(mi_open_datafile(info, share, name, -1)))
param->retry_repair= 0; /* Safety */
......@@ -3111,9 +3123,9 @@ err:
share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS;
share->state.changed|=STATE_NOT_SORTED_PAGES;
pthread_cond_destroy (&sort_info.cond);
pthread_mutex_destroy(&sort_info.mutex);
pthread_mutex_destroy(&param->print_msg_mutex);
mysql_cond_destroy(&sort_info.cond);
mysql_mutex_destroy(&sort_info.mutex);
mysql_mutex_destroy(&param->print_msg_mutex);
param->need_print_msg_lock= 0;
my_free((uchar*) sort_info.ft_buf, MYF(MY_ALLOW_ZERO_PTR));
......@@ -4067,8 +4079,9 @@ static int sort_insert_key(MI_SORT_PARAM *sort_param,
if (_mi_write_keypage(info, keyinfo, filepos, DFLT_INIT_HITS, anc_buff))
DBUG_RETURN(1);
}
else if (my_pwrite(info->s->kfile,(uchar*) anc_buff,
(uint) keyinfo->block_length,filepos, param->myf_rw))
else if (mysql_file_pwrite(info->s->kfile, (uchar*) anc_buff,
(uint) keyinfo->block_length, filepos,
param->myf_rw))
DBUG_RETURN(1);
DBUG_DUMP("buff",(uchar*) anc_buff,mi_getint(anc_buff));
......@@ -4172,8 +4185,8 @@ int flush_pending_blocks(MI_SORT_PARAM *sort_param)
DFLT_INIT_HITS, key_block->buff))
DBUG_RETURN(1);
}
else if (my_pwrite(info->s->kfile,(uchar*) key_block->buff,
(uint) keyinfo->block_length,filepos, myf_rw))
else if (mysql_file_pwrite(info->s->kfile, (uchar*) key_block->buff,
(uint) keyinfo->block_length, filepos, myf_rw))
DBUG_RETURN(1);
DBUG_DUMP("buff",(uchar*) key_block->buff,length);
nod_flag=1;
......@@ -4213,9 +4226,11 @@ int test_if_almost_full(MI_INFO *info)
{
if (info->s->options & HA_OPTION_COMPRESS_RECORD)
return 0;
return my_seek(info->s->kfile, 0L, MY_SEEK_END, MYF(MY_THREADSAFE)) / 10 * 9 >
return mysql_file_seek(info->s->kfile, 0L, MY_SEEK_END,
MYF(MY_THREADSAFE)) / 10 * 9 >
(my_off_t) info->s->base.max_key_file_length ||
my_seek(info->dfile, 0L, MY_SEEK_END, MYF(0)) / 10 * 9 >
mysql_file_seek(info->dfile, 0L, MY_SEEK_END,
MYF(0)) / 10 * 9 >
(my_off_t) info->s->base.max_data_file_length;
}
......@@ -4313,7 +4328,8 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename)
if (share.options & HA_OPTION_COMPRESS_RECORD)
share.base.records=max_records=info.state->records;
else if (share.base.min_pack_length)
max_records=(ha_rows) (my_seek(info.dfile,0L,MY_SEEK_END,MYF(0)) /
max_records=(ha_rows) (mysql_file_seek(info.dfile, 0L, MY_SEEK_END,
MYF(0)) /
(ulong) share.base.min_pack_length);
else
max_records=0;
......@@ -4321,7 +4337,7 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename)
(param->testflag & T_UNPACK);
share.options&= ~HA_OPTION_TEMP_COMPRESS_RECORD;
file_length=(ulonglong) my_seek(info.dfile,0L,MY_SEEK_END,MYF(0));
file_length=(ulonglong) mysql_file_seek(info.dfile, 0L, MY_SEEK_END, MYF(0));
tmp_length= file_length+file_length/10;
set_if_bigger(file_length,param->max_data_file_length);
set_if_bigger(file_length,tmp_length);
......
/* 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
it under the terms of the GNU General Public License as published by
......@@ -31,7 +31,7 @@ int mi_close(register MI_INFO *info)
(long) info, (uint) share->reopen,
(uint) share->tot_locks));
pthread_mutex_lock(&THR_LOCK_myisam);
mysql_mutex_lock(&THR_LOCK_myisam);
if (info->lock_type == F_EXTRA_LCK)
info->lock_type=F_UNLCK; /* HA_EXTRA_NO_USER_CHANGE */
......@@ -40,7 +40,7 @@ int mi_close(register MI_INFO *info)
if (mi_lock_database(info,F_UNLCK))
error=my_errno;
}
pthread_mutex_lock(&share->intern_lock);
mysql_mutex_lock(&share->intern_lock);
if (share->options & HA_OPTION_READ_ONLY_DATA)
{
......@@ -55,7 +55,7 @@ int mi_close(register MI_INFO *info)
}
flag= !--share->reopen;
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));
if (flag)
......@@ -79,7 +79,7 @@ int mi_close(register MI_INFO *info)
mi_state_info_write(share->kfile, &share->state, 1);
/* Decrement open count must be last I/O on this file. */
_mi_decrement_open_count(info);
if (my_close(share->kfile,MYF(0)))
if (mysql_file_close(share->kfile, MYF(0)))
error = my_errno;
}
#ifdef HAVE_MMAP
......@@ -93,25 +93,25 @@ int mi_close(register MI_INFO *info)
}
#ifdef THREAD
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->intern_lock);
mysql_mutex_destroy(&share->intern_lock);
{
int i,keys;
keys = share->state.header.keys;
(void) rwlock_destroy(&share->mmap_lock);
mysql_rwlock_destroy(&share->mmap_lock);
for(i=0; i<keys; i++) {
(void) rwlock_destroy(&share->key_root_lock[i]);
mysql_rwlock_destroy(&share->key_root_lock[i]);
}
}
#endif
my_free((uchar*) info->s,MYF(0));
}
pthread_mutex_unlock(&THR_LOCK_myisam);
mysql_mutex_unlock(&THR_LOCK_myisam);
if (info->ftparser_param)
{
my_free((uchar*)info->ftparser_param, MYF(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;
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
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,
if (! (flags & HA_DONT_TOUCH_DATA))
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
......@@ -638,8 +638,10 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
goto err;
}
if ((file= my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
MYF(MY_WME | create_flag))) < 0)
if ((file= mysql_file_create_with_symlink(mi_key_file_kfile,
linkname_ptr, filename, 0,
create_mode,
MYF(MY_WME | create_flag))) < 0)
goto err;
errpos=1;
......@@ -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;
}
if ((dfile=
my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
MYF(MY_WME | create_flag))) < 0)
mysql_file_create_with_symlink(mi_key_file_dfile,
linkname_ptr, filename, 0,
create_mode,
MYF(MY_WME | create_flag))) < 0)
goto err;
}
errpos=3;
......@@ -706,9 +710,9 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
mi_base_info_write(file, &share.base))
goto err;
#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",
base_pos+ MI_BASE_INFO_SIZE, pos));
}
......@@ -803,9 +807,9 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
goto err;
#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",
info_length, pos));
}
......@@ -813,46 +817,49 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
/* Enlarge files */
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;
if (! (flags & HA_DONT_TOUCH_DATA))
{
#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;
#endif
errpos=2;
if (my_close(dfile,MYF(0)))
if (mysql_file_close(dfile, MYF(0)))
goto err;
}
errpos=0;
pthread_mutex_unlock(&THR_LOCK_myisam);
if (my_close(file,MYF(0)))
mysql_mutex_unlock(&THR_LOCK_myisam);
if (mysql_file_close(file, MYF(0)))
goto err;
my_free((char*) rec_per_key_part,MYF(0));
DBUG_RETURN(0);
err:
pthread_mutex_unlock(&THR_LOCK_myisam);
mysql_mutex_unlock(&THR_LOCK_myisam);
save_errno=my_errno;
switch (errpos) {
case 3:
(void) my_close(dfile,MYF(0));
(void) mysql_file_close(dfile, MYF(0));
/* fall through */
case 2:
/* QQ: Tnu should add a call to my_raid_delete() here */
if (! (flags & HA_DONT_TOUCH_DATA))
my_delete_with_symlink(fn_format(filename,name,"",MI_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT),
MYF(0));
mysql_file_delete_with_symlink(mi_key_file_dfile,
fn_format(filename, name, "", MI_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT),
MYF(0));
/* fall through */
case 1:
(void) my_close(file,MYF(0));
(void) mysql_file_close(file, MYF(0));
if (! (flags & HA_DONT_TOUCH_DATA))
my_delete_with_symlink(fn_format(filename,name,"",MI_NAME_IEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT),
MYF(0));
mysql_file_delete_with_symlink(mi_key_file_kfile,
fn_format(filename, name, "", MI_NAME_IEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT),
MYF(0));
}
my_free((char*) rec_per_key_part, MYF(0));
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
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)
if (share->file_map)
_mi_unmap_file(info);
#endif
if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)) ||
my_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)) )
if (mysql_file_chsize(info->dfile, 0, 0, MYF(MY_WME)) ||
mysql_file_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)))
goto err;
(void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
#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
it under the terms of the GNU General Public License as published by
......@@ -58,12 +58,13 @@ int mi_delete_table(const char *name)
#endif /* USE_RAID */
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);
fn_format(from,name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
#ifdef USE_RAID
if (raid_type)
DBUG_RETURN(my_raid_delete(from, raid_chunks, MYF(MY_WME)) ? my_errno : 0);
#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
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,
{
DBUG_PRINT("info", ("mi_read with mmap %d\n", info->dfile));
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:
......@@ -156,24 +156,24 @@ size_t mi_mmap_pread(MI_INFO *info, uchar *Buffer,
{
memcpy(Buffer, info->s->file_map + offset, Count);
if (info->s->concurrent_insert)
rw_unlock(&info->s->mmap_lock);
mysql_rwlock_unlock(&info->s->mmap_lock);
return 0;
}
else
{
if (info->s->concurrent_insert)
rw_unlock(&info->s->mmap_lock);
return my_pread(info->dfile, Buffer, Count, offset, MyFlags);
mysql_rwlock_unlock(&info->s->mmap_lock);
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 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,
{
DBUG_PRINT("info", ("mi_write with mmap %d\n", info->dfile));
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:
......@@ -211,26 +211,26 @@ size_t mi_mmap_pwrite(MI_INFO *info, const uchar *Buffer,
{
memcpy(info->s->file_map + offset, Buffer, Count);
if (info->s->concurrent_insert)
rw_unlock(&info->s->mmap_lock);
mysql_rwlock_unlock(&info->s->mmap_lock);
return 0;
}
else
{
info->s->nonmmaped_inserts++;
if (info->s->concurrent_insert)
rw_unlock(&info->s->mmap_lock);
return my_pwrite(info->dfile, Buffer, Count, offset, MyFlags);
mysql_rwlock_unlock(&info->s->mmap_lock);
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 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,
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))
goto err;
filepos+=next_length;
......@@ -1650,7 +1650,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
length-= next_length;
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;
DBUG_RETURN(memcmp(buff,temp_buff,length));
err:
......@@ -1831,8 +1831,9 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, uchar *buf,
block_info.filepos + block_info.data_len &&
flush_io_cache(&info->rec_cache))
goto err;
/* my_seek(info->dfile,filepos,MY_SEEK_SET,MYF(0)); */
if (my_read(info->dfile,(uchar*) to,block_info.data_len,MYF(MY_NABP)))
/* mysql_file_seek(info->dfile, filepos, MY_SEEK_SET, MYF(0)); */
if (mysql_file_read(info->dfile, (uchar*) to, block_info.data_len,
MYF(MY_NABP)))
{
if (my_errno == -1)
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)
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.
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));
if (my_read(file, header, sizeof(info->header),MYF(0)) !=
mysql_file_seek(file, filepos, MY_SEEK_SET, MYF(0));
if (mysql_file_read(file, header, sizeof(info->header), MYF(0)) !=
sizeof(info->header))
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
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)
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
if ((share->options & HA_OPTION_COMPRESS_RECORD))
{
pthread_mutex_lock(&share->intern_lock);
mysql_mutex_lock(&share->intern_lock);
if (_mi_memmap_file(info))
{
/* We don't nead MADV_SEQUENTIAL if small file */
madvise((char*) share->file_map, share->state.state.data_file_length,
share->state.state.data_file_length <= RECORD_CACHE_SIZE*16 ?
MADV_RANDOM : MADV_SEQUENTIAL);
pthread_mutex_unlock(&share->intern_lock);
mysql_mutex_unlock(&share->intern_lock);
break;
}
pthread_mutex_unlock(&share->intern_lock);
mysql_mutex_unlock(&share->intern_lock);
}
#endif
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)
}
break;
case HA_EXTRA_FORCE_REOPEN:
pthread_mutex_lock(&THR_LOCK_myisam);
mysql_mutex_lock(&THR_LOCK_myisam);
share->last_version= 0L; /* Impossible version */
pthread_mutex_unlock(&THR_LOCK_myisam);
mysql_mutex_unlock(&THR_LOCK_myisam);
break;
case HA_EXTRA_PREPARE_FOR_DROP:
pthread_mutex_lock(&THR_LOCK_myisam);
mysql_mutex_lock(&THR_LOCK_myisam);
share->last_version= 0L; /* Impossible version */
#ifdef __WIN__REMOVE_OBSOLETE_WORKAROUND
/* 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,
(function == HA_EXTRA_FORCE_REOPEN ?
FLUSH_RELEASE : FLUSH_IGNORE_CHANGED)))
......@@ -285,7 +285,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
}
if (share->kfile >= 0)
_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;
{
LIST *list_element ;
......@@ -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;
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;
tmpinfo->dfile= -1;
}
}
}
share->kfile= -1; /* Files aren't open anymore */
pthread_mutex_unlock(&share->intern_lock);
mysql_mutex_unlock(&share->intern_lock);
#endif
pthread_mutex_unlock(&THR_LOCK_myisam);
mysql_mutex_unlock(&THR_LOCK_myisam);
break;
case HA_EXTRA_FLUSH:
if (!share->temporary)
......@@ -316,9 +316,9 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
if (share->not_flushed)
{
share->not_flushed=0;
if (my_sync(share->kfile, MYF(0)))
if (mysql_file_sync(share->kfile, MYF(0)))
error= my_errno;
if (my_sync(info->dfile, MYF(0)))
if (mysql_file_sync(info->dfile, MYF(0)))
error= my_errno;
if (error)
{
......@@ -349,7 +349,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
break;
case HA_EXTRA_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
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)
share->file_write= mi_mmap_pwrite;
}
}
pthread_mutex_unlock(&share->intern_lock);
mysql_mutex_unlock(&share->intern_lock);
#endif
break;
case HA_EXTRA_MARK_AS_LOG_TABLE:
pthread_mutex_lock(&share->intern_lock);
mysql_mutex_lock(&share->intern_lock);
share->is_log_table= TRUE;
pthread_mutex_unlock(&share->intern_lock);
mysql_mutex_unlock(&share->intern_lock);
break;
case HA_EXTRA_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
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)
DBUG_RETURN(0); /* Compatible with ISAM */
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);
fast_mi_writeinfo(info);
pthread_mutex_unlock(&share->intern_lock);
mysql_mutex_unlock(&share->intern_lock);
}
if (flag & HA_STATUS_VARIABLE)
{
......@@ -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->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;
else
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
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,
ensure that setting the key cache and changing the multi_key_cache
is done atomicly
*/
pthread_mutex_lock(&share->intern_lock);
mysql_mutex_lock(&share->intern_lock);
/*
Tell all threads to use the new key cache
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,
share->unique_name_length,
share->key_cache))
error= my_errno;
pthread_mutex_unlock(&share->intern_lock);
mysql_mutex_unlock(&share->intern_lock);
DBUG_RETURN(error);
}
......@@ -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
*/
pthread_mutex_lock(&THR_LOCK_myisam);
mysql_mutex_lock(&THR_LOCK_myisam);
for (pos=myisam_open_list ; pos ; pos=pos->next)
{
MI_INFO *info= (MI_INFO*) pos->data;
......@@ -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
*/
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;
}
/* 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
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)
}
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 */
{
switch (lock_type) {
......@@ -88,11 +88,11 @@ int mi_lock_database(MI_INFO *info, int lock_type)
(info->s->nonmmaped_inserts > MAX_NONMAPPED_INSERTS))
{
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);
info->s->nonmmaped_inserts= 0;
if (info->s->concurrent_insert)
rw_unlock(&info->s->mmap_lock);
mysql_rwlock_unlock(&info->s->mmap_lock);
}
#endif
share->state.process= share->last_process=share->this_process;
......@@ -103,9 +103,9 @@ int mi_lock_database(MI_INFO *info, int lock_type)
share->changed=0;
if (myisam_flush)
{
if (my_sync(share->kfile, MYF(0)))
if (mysql_file_sync(share->kfile, MYF(0)))
error= my_errno;
if (my_sync(info->dfile, MYF(0)))
if (mysql_file_sync(info->dfile, MYF(0)))
error= my_errno;
}
else
......@@ -251,7 +251,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
}
}
#endif
pthread_mutex_unlock(&share->intern_lock);
mysql_mutex_unlock(&share->intern_lock);
#if defined(FULL_LOG) || defined(_lint)
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),
......@@ -458,8 +458,8 @@ int _mi_writeinfo(register MI_INFO *info, uint operation)
#ifdef _WIN32
if (myisam_flush)
{
my_sync(share->kfile,0);
my_sync(info->dfile,0);
mysql_file_sync(share->kfile, 0);
mysql_file_sync(info->dfile, 0);
}
#endif
}
......@@ -539,9 +539,9 @@ int _mi_mark_file_changed(MI_INFO *info)
{
mi_int2store(buff,share->state.open_count);
buff[2]=1; /* Mark that it's changed */
DBUG_RETURN(my_pwrite(share->kfile,buff,sizeof(buff),
sizeof(share->state.header),
MYF(MY_NABP)));
DBUG_RETURN(mysql_file_pwrite(share->kfile, buff, sizeof(buff),
sizeof(share->state.header),
MYF(MY_NABP)));
}
}
DBUG_RETURN(0);
......@@ -568,9 +568,9 @@ int _mi_decrement_open_count(MI_INFO *info)
{
share->state.open_count--;
mi_int2store(buff,share->state.open_count);
write_error=my_pwrite(share->kfile,buff,sizeof(buff),
sizeof(share->state.header),
MYF(MY_NABP));
write_error= mysql_file_pwrite(share->kfile, buff, sizeof(buff),
sizeof(share->state.header),
MYF(MY_NABP));
}
if (!lock_error)
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
it under the terms of the GNU General Public License as published by
......@@ -54,16 +54,19 @@ int mi_log(int activate_log)
myisam_pid=(ulong) getpid();
if (myisam_log_file < 0)
{
if ((myisam_log_file = my_create(fn_format(buff,myisam_log_filename,
"",".log",4),
0,(O_RDWR | O_BINARY | O_APPEND),MYF(0)))
< 0)
if ((myisam_log_file= mysql_file_create(mi_key_file_log,
fn_format(buff,
myisam_log_filename,
"", ".log", 4),
0,
(O_RDWR | O_BINARY | O_APPEND),
MYF(0))) < 0)
DBUG_RETURN(my_errno);
}
}
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;
}
DBUG_RETURN(error);
......@@ -86,13 +89,13 @@ void _myisam_log(enum myisam_log_commands command, MI_INFO *info,
mi_int4store(buff+3,pid);
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));
(void) my_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, buff, sizeof(buff), MYF(0));
(void) mysql_file_write(myisam_log_file, buffert, length, MYF(0));
if (!error)
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;
}
......@@ -109,14 +112,14 @@ void _myisam_log_command(enum myisam_log_commands command, MI_INFO *info,
mi_int2store(buff+1,info->dfile);
mi_int4store(buff+3,pid);
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));
(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)
(void) my_write(myisam_log_file,buffert,length,MYF(0));
(void) mysql_file_write(myisam_log_file, buffert, length, MYF(0));
if (!error)
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;
}
......@@ -140,10 +143,10 @@ void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info,
mi_int2store(buff+7,result);
mi_sizestore(buff+9,filepos);
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));
(void) my_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, buff, sizeof(buff), MYF(0));
(void) mysql_file_write(myisam_log_file, record, info->s->base.reclength, MYF(0));
if (info->s->base.blobs)
{
MI_BLOB *blob,*end;
......@@ -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,
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)
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;
}
/* 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
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)
DBUG_RETURN (NULL);
}
pthread_mutex_lock(&THR_LOCK_myisam);
mysql_mutex_lock(&THR_LOCK_myisam);
if (!(old_info=test_if_reopen(name_buff)))
{
share= &share_buff;
......@@ -120,17 +120,21 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
my_errno= HA_ERR_CRASHED;
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) ||
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;
}
share->mode=open_mode;
errpos=1;
if (my_read(kfile, share->state.header.file_version, head_length,
MYF(MY_NABP)))
if (mysql_file_read(kfile, share->state.header.file_version, head_length,
MYF(MY_NABP)))
{
my_errno= HA_ERR_NOT_A_TABLE;
goto err;
......@@ -181,7 +185,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
end_pos=disk_cache+info_length;
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 ((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)
goto err;
}
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;
goto err;
......@@ -309,9 +313,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
&share->state.key_del,
(share->state.header.max_block_size_index*sizeof(my_off_t)),
#ifdef THREAD
&share->key_root_lock,sizeof(rw_lock_t)*keys,
&share->key_root_lock, sizeof(mysql_rwlock_t)*keys,
#endif
&share->mmap_lock,sizeof(rw_lock_t),
&share->mmap_lock, sizeof(mysql_rwlock_t),
NullS))
goto err;
errpos=4;
......@@ -522,10 +526,12 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
share->is_log_table= FALSE;
#ifdef THREAD
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++)
(void) my_rwlock_init(&share->key_root_lock[i], NULL);
(void) my_rwlock_init(&share->mmap_lock, NULL);
mysql_rwlock_init(mi_key_rwlock_MYISAM_SHARE_key_root_lock,
&share->key_root_lock[i]);
mysql_rwlock_init(mi_key_rwlock_MYISAM_SHARE_mmap_lock, &share->mmap_lock);
if (!thr_lock_inited)
{
/* 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)
info.ft1_to_ft2=0;
info.errkey= -1;
info.page_changed=1;
pthread_mutex_lock(&share->intern_lock);
mysql_mutex_lock(&share->intern_lock);
info.read_record=share->read_record;
share->reopen++;
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)
myisam_delay_key_write)
share->delay_key_write=1;
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 */
......@@ -651,7 +657,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
m_info->open_list.data=(void*) m_info;
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)
{
intern_filename(name_buff,share->index_file_name);
......@@ -670,7 +676,7 @@ err:
my_free((uchar*) m_info,MYF(0));
/* fall through */
case 5:
(void) my_close(info.dfile,MYF(0));
(void) mysql_file_close(info.dfile, MYF(0));
if (old_info)
break; /* Don't remove open table */
/* fall through */
......@@ -685,13 +691,13 @@ err:
my_afree(disk_cache);
/* fall through */
case 1:
(void) my_close(kfile,MYF(0));
(void) mysql_file_close(kfile, MYF(0));
/* fall through */
case 0:
default:
break;
}
pthread_mutex_unlock(&THR_LOCK_myisam);
mysql_mutex_unlock(&THR_LOCK_myisam);
my_errno=save_errno;
DBUG_RETURN (NULL);
} /* mi_open */
......@@ -924,10 +930,10 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite)
}
if (pWrite & 1)
DBUG_RETURN(my_pwrite(file, buff, (size_t) (ptr-buff), 0L,
MYF(MY_NABP | MY_THREADSAFE)) != 0);
DBUG_RETURN(my_write(file, buff, (size_t) (ptr-buff),
MYF(MY_NABP)) != 0);
DBUG_RETURN(mysql_file_pwrite(file, buff, (size_t) (ptr-buff), 0L,
MYF(MY_NABP | MY_THREADSAFE)) != 0);
DBUG_RETURN(mysql_file_write(file, buff, (size_t) (ptr-buff),
MYF(MY_NABP)) != 0);
}
......@@ -992,10 +998,10 @@ uint mi_state_info_read_dsk(File file, MI_STATE_INFO *state, my_bool 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;
}
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;
mi_state_info_read(buff, state);
}
......@@ -1038,7 +1044,7 @@ uint mi_base_info_write(File file, MI_BASE_INFO *base)
mi_int2store(ptr,base->raid_chunks); ptr +=2;
mi_int4store(ptr,base->raid_chunksize); ptr +=4;
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)
mi_int2store(ptr,keydef->keylength); ptr +=2;
mi_int2store(ptr,keydef->minlength); 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)
......@@ -1142,7 +1148,7 @@ int mi_keyseg_write(File file, const HA_KEYSEG *keyseg)
mi_int4store(ptr, pos);
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)
*ptr++= (uchar) def->key;
*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)
......@@ -1208,7 +1214,7 @@ uint mi_recinfo_write(File file, MI_COLUMNDEF *recinfo)
mi_int2store(ptr,recinfo->length); ptr +=2;
*ptr++ = recinfo->null_bit;
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)
......@@ -1261,15 +1267,18 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, const char *org_name,
}
else
#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;
}
int mi_open_keyfile(MYISAM_SHARE *share)
{
if ((share->kfile=my_open(share->unique_file_name, share->mode | O_SHARE,
MYF(MY_WME))) < 0)
if ((share->kfile= mysql_file_open(mi_key_file_kfile,
share->unique_file_name,
share->mode | O_SHARE,
MYF(MY_WME))) < 0)
return 1;
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
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)
file=info->dfile;
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)
my_errno=HA_ERR_END_OF_FILE;
......@@ -224,9 +224,9 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
tmp_buff=share->decode_tables+length;
disk_cache= (uchar*) (tmp_buff+OFFSET_TABLE_SIZE);
if (my_read(file,disk_cache,
(uint) (share->pack.header_length-sizeof(header)),
MYF(MY_NABP)))
if (mysql_file_read(file, disk_cache,
(uint) (share->pack.header_length-sizeof(header)),
MYF(MY_NABP)))
goto err2;
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)
if (_mi_pack_get_block_info(info, &info->bit_buff, &block_info,
&info->rec_buff, file, filepos))
goto err;
if (my_read(file,(uchar*) info->rec_buff + block_info.offset ,
block_info.rec_len - block_info.offset, MYF(MY_NABP)))
if (mysql_file_read(file, (uchar*) info->rec_buff + block_info.offset,
block_info.rec_len - block_info.offset, MYF(MY_NABP)))
goto panic;
info->update|= HA_STATE_AKTIV;
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,
}
else
{
if (my_read(info->dfile,(uchar*) info->rec_buff + block_info.offset,
block_info.rec_len-block_info.offset,
MYF(MY_NABP)))
if (mysql_file_read(info->dfile,
(uchar*) info->rec_buff + block_info.offset,
block_info.rec_len-block_info.offset, MYF(MY_NABP)))
goto err;
}
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,
{
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
*/
my_seek(file,filepos,MY_SEEK_SET,MYF(0));
if (my_read(file, header,ref_length,MYF(MY_NABP)))
mysql_file_seek(file, filepos, MY_SEEK_SET, MYF(0));
if (mysql_file_read(file, header, ref_length, MYF(MY_NABP)))
return BLOCK_FATAL_ERROR;
DBUG_DUMP("header",(uchar*) header,ref_length);
}
......@@ -1496,7 +1496,7 @@ my_bool _mi_memmap_file(MI_INFO *info)
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)
{
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
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)
MI_INFO *info;
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)
{
next_open=list_element->next; /* Save if close */
info=(MI_INFO*) list_element->data;
switch (flag) {
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))
error=my_errno;
pthread_mutex_lock(&THR_LOCK_myisam);
mysql_mutex_lock(&THR_LOCK_myisam);
break;
case HA_PANIC_WRITE: /* Do this to free databases */
#ifdef CANT_OPEN_FILES_TWICE
......@@ -66,9 +66,9 @@ int mi_panic(enum ha_panic_function flag)
error=my_errno;
}
#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;
if (info->dfile >= 0 && my_close(info->dfile,MYF(0)))
if (info->dfile >= 0 && mysql_file_close(info->dfile, MYF(0)))
error = my_errno;
info->s->kfile=info->dfile= -1; /* Files aren't open anymore */
break;
......@@ -78,15 +78,19 @@ int mi_panic(enum ha_panic_function flag)
{ /* Open closed files */
char name_buff[FN_REFLEN];
if (info->s->kfile < 0)
if ((info->s->kfile= my_open(fn_format(name_buff,info->filename,"",
N_NAME_IEXT,4),info->mode,
MYF(MY_WME))) < 0)
if ((info->s->kfile= mysql_file_open(mi_key_file_kfile,
fn_format(name_buff,
info->filename, "",
N_NAME_IEXT, 4),
info->mode, MYF(MY_WME))) < 0)
error = my_errno;
if (info->dfile < 0)
{
if ((info->dfile= my_open(fn_format(name_buff,info->filename,"",
N_NAME_DEXT,4),info->mode,
MYF(MY_WME))) < 0)
if ((info->dfile= mysql_file_open(mi_key_file_dfile,
fn_format(name_buff,
info->filename, "",
N_NAME_DEXT, 4),
info->mode, MYF(MY_WME))) < 0)
error = my_errno;
info->rec_cache.file=info->dfile;
}
......@@ -106,7 +110,7 @@ int mi_panic(enum ha_panic_function flag)
(void) mi_log(0); /* Close log if neaded */
ft_free_stopwords();
}
pthread_mutex_unlock(&THR_LOCK_myisam);
mysql_mutex_unlock(&THR_LOCK_myisam);
if (!error)
DBUG_RETURN(0);
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
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)
/* Read the next block of index file into the preload buffer */
if ((my_off_t) length > (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;
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
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,
DBUG_RETURN(HA_POS_ERROR);
info->update&= (HA_STATE_CHANGED+HA_STATE_ROW_CHANGED);
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){
#ifdef HAVE_RTREE_KEYS
......@@ -106,7 +106,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx,
}
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);
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
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)
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);
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);
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);
......@@ -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 :
0);
#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
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,
goto err;
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];
use_key_length=pack_key_length;
......@@ -156,7 +156,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key,
}
}
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 */
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
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)
if (fast_mi_readinfo(info))
DBUG_RETURN(my_errno);
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);
if (!flag)
{
......@@ -96,7 +96,7 @@ int mi_rnext(MI_INFO *info, uchar *buf, int inx)
break;
}
}
rw_unlock(&info->s->key_root_lock[inx]);
mysql_rwlock_unlock(&info->s->key_root_lock[inx]);
}
/* Don't clear if database-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
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)
DBUG_RETURN(my_errno);
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)
{
......@@ -81,7 +81,7 @@ int mi_rnext_same(MI_INFO *info, uchar *buf)
}
}
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 */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
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
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)
DBUG_RETURN(my_errno);
changed=_mi_test_if_changed(info);
if (share->concurrent_insert)
rw_rdlock(&share->key_root_lock[inx]);
mysql_rwlock_rdlock(&share->key_root_lock[inx]);
if (!flag)
error=_mi_search_last(info, share->keyinfo+inx,
share->state.key_root[inx]);
......@@ -65,7 +65,7 @@ int mi_rprev(MI_INFO *info, uchar *buf, int inx)
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_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
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)
info->lastkey_length=_mi_make_key(info,(uint) inx,info->lastkey,record,
info->lastpos);
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,
SEARCH_SAME,
info->s->state.key_root[inx]);
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))
......
/* 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
it under the terms of the GNU General Public License as published by
......@@ -68,3 +68,74 @@ uint NEAR myisam_readnext_vec[]=
SEARCH_BIGGER, SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_BIGGER, 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
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)
is_tree_inited(&info->bulk_insert[i])));
if (local_lock_tree)
{
rw_wrlock(&share->key_root_lock[i]);
mysql_rwlock_wrlock(&share->key_root_lock[i]);
share->keyinfo[i].version++;
}
if (share->keyinfo[i].flag & HA_FULLTEXT )
......@@ -115,7 +115,7 @@ int mi_write(MI_INFO *info, uchar *record)
if (_mi_ft_add(info,i, buff, record, filepos))
{
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));
goto err;
}
......@@ -126,7 +126,7 @@ int mi_write(MI_INFO *info, uchar *record)
_mi_make_key(info,i,buff,record,filepos)))
{
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));
goto err;
}
......@@ -136,7 +136,7 @@ int mi_write(MI_INFO *info, uchar *record)
info->update&= ~HA_STATE_RNEXT_SAME;
if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]);
mysql_rwlock_unlock(&share->key_root_lock[i]);
}
}
if (share->calc_checksum)
......@@ -197,13 +197,13 @@ err:
!(info->bulk_insert &&
is_tree_inited(&info->bulk_insert[i])));
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 (_mi_ft_del(info,i, buff,record,filepos))
{
if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]);
mysql_rwlock_unlock(&share->key_root_lock[i]);
break;
}
}
......@@ -213,12 +213,12 @@ err:
if (_mi_ck_delete(info,i,buff,key_length))
{
if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]);
mysql_rwlock_unlock(&share->key_root_lock[i]);
break;
}
}
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)
case free_init:
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++;
}
return 0;
......@@ -955,7 +955,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
keylen - param->info->s->rec_reflength);
case free_end:
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 -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
it under the terms of the GNU General Public License as published by
......@@ -24,6 +24,7 @@
#else
#include <my_no_pthread.h>
#endif
#include <mysql/psi/mysql_file.h>
#if defined(my_write) && !defined(MAP_TO_USE_RAID)
#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 */
concurrent_insert;
#ifdef THREAD
THR_LOCK lock;
pthread_mutex_t intern_lock; /* Locking for use with _locking */
rw_lock_t *key_root_lock;
mysql_mutex_t intern_lock; /* Locking for use with _locking */
mysql_rwlock_t *key_root_lock;
#endif
my_off_t mmaped_length;
uint nonmmaped_inserts; /* counter of writing in non-mmaped
area */
rw_lock_t mmap_lock;
mysql_rwlock_t mmap_lock;
} MYISAM_SHARE;
......@@ -460,12 +461,12 @@ typedef struct st_mi_sort_param
#define mi_unique_store(A,B) mi_int4store((A),(B))
#ifdef THREAD
extern pthread_mutex_t THR_LOCK_myisam;
extern mysql_mutex_t THR_LOCK_myisam;
#endif
#if !defined(THREAD) || defined(DONT_USE_RW_LOCKS)
#define rw_wrlock(A) {}
#define rw_rdlock(A) {}
#define rw_unlock(A) {}
#define mysql_rwlock_wrlock(A) {}
#define mysql_rwlock_rdlock(A) {}
#define mysql_rwlock_unlock(A) {}
#endif
/* Some extern variables */
......@@ -785,3 +786,22 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong);
}
#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
it under the terms of the GNU General Public License as published by
......@@ -478,10 +478,10 @@ ok:
if (sort_param->read_cache.share)
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)
pthread_cond_signal(&sort_param->sort_info->cond);
pthread_mutex_unlock(&sort_param->sort_info->mutex);
mysql_cond_signal(&sort_param->sort_info->cond);
mysql_mutex_unlock(&sort_param->sort_info->mutex);
DBUG_PRINT("exit", ("======== ending thread ========"));
}
my_thread_end();
......@@ -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 (my_pread(fromfile->file,(uchar*) buffpek->base,
(length= sort_length*count),buffpek->file_pos,MYF_RW))
if (mysql_file_pread(fromfile->file, (uchar*) buffpek->base,
(length= sort_length*count),
buffpek->file_pos, MYF_RW))
return((uint) -1); /* purecov: inspected */
buffpek->key=buffpek->base;
buffpek->file_pos+= length; /* New filepos */
......@@ -849,12 +850,12 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
for (idx=1;idx<=count;idx++)
{
if (my_pread(fromfile->file,(uchar*)&length_of_key,sizeof(length_of_key),
buffpek->file_pos,MYF_RW))
if (mysql_file_pread(fromfile->file, (uchar*)&length_of_key,
sizeof(length_of_key), buffpek->file_pos, MYF_RW))
return((uint) -1);
buffpek->file_pos+=sizeof(length_of_key);
if (my_pread(fromfile->file,(uchar*) buffp,length_of_key,
buffpek->file_pos,MYF_RW))
if (mysql_file_pread(fromfile->file, (uchar*) buffp,
length_of_key, buffpek->file_pos, MYF_RW))
return((uint) -1);
buffpek->file_pos+=length_of_key;
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
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,
pointers to the children. Use of a mutex here and in
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
......@@ -1061,7 +1061,7 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd,
}
end:
pthread_mutex_unlock(&this->file->mutex);
mysql_mutex_unlock(&this->file->mutex);
return to;
}
......@@ -1282,6 +1282,10 @@ static int myisammrg_init(void *p)
myisammrg_hton= (handlerton *)p;
#ifdef HAVE_PSI_INTERFACE
init_myisammrg_psi_keys();
#endif
myisammrg_hton->db_type= DB_TYPE_MRG_MYISAM;
myisammrg_hton->create= myisammrg_create_handler;
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
it under the terms of the GNU General Public License as published by
......@@ -55,10 +55,10 @@ int myrg_close(MYRG_INFO *info)
else
my_free((uchar*) info->rec_per_key_part, MYF(MY_ALLOW_ZERO_PTR));
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);
pthread_mutex_unlock(&THR_LOCK_open);
pthread_mutex_destroy(&info->mutex);
mysql_mutex_unlock(&THR_LOCK_open);
mysql_mutex_destroy(&info->mutex);
my_free((uchar*) info,MYF(0));
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
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,
DBUG_ENTER("myrg_create");
errpos=0;
if ((file = my_create(fn_format(buff,name,"",MYRG_NAME_EXT,
MY_UNPACK_FILENAME|MY_APPEND_EXT),0,
O_RDWR | O_EXCL | O_NOFOLLOW,MYF(MY_WME))) < 0)
if ((file= mysql_file_create(rg_key_file_MRG,
fn_format(buff, name, "", MYRG_NAME_EXT,
MY_UNPACK_FILENAME|MY_APPEND_EXT), 0,
O_RDWR | O_EXCL | O_NOFOLLOW, MYF(MY_WME))) < 0)
goto err;
errpos=1;
if (table_names)
......@@ -46,8 +47,8 @@ int myrg_create(const char *name, const char **table_names,
fn_same(buff,name,4);
*(end=strend(buff))='\n';
end[1]=0;
if (my_write(file,(uchar*) buff,(uint) (end-buff+1),
MYF(MY_WME | MY_NABP)))
if (mysql_file_write(file, (uchar*) buff, (uint) (end-buff+1),
MYF(MY_WME | MY_NABP)))
goto err;
}
}
......@@ -55,10 +56,11 @@ int myrg_create(const char *name, const char **table_names,
{
end=strxmov(buff,"#INSERT_METHOD=",
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;
}
if (my_close(file,MYF(0)))
if (mysql_file_close(file, MYF(0)))
goto err;
DBUG_RETURN(0);
......@@ -66,7 +68,7 @@ err:
save_errno=my_errno ? my_errno : -1;
switch (errpos) {
case 1:
(void) my_close(file,MYF(0));
(void) mysql_file_close(file, MYF(0));
}
DBUG_RETURN(my_errno=save_errno);
} /* 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
it under the terms of the GNU General Public License as published by
......@@ -24,7 +24,7 @@
extern LIST *myrg_open_list;
#ifdef THREAD
extern pthread_mutex_t THR_LOCK_open;
extern mysql_mutex_t THR_LOCK_open;
#endif
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);
extern "C"
#endif
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
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)
DBUG_ENTER("myrg_open");
bzero((char*) &file,sizeof(file));
if ((fd=my_open(fn_format(name_buff,name,"",MYRG_NAME_EXT,
MY_UNPACK_FILENAME|MY_APPEND_EXT),
O_RDONLY | O_SHARE,MYF(0))) < 0)
if ((fd= mysql_file_open(rg_key_file_MRG,
fn_format(name_buff, name, "", MYRG_NAME_EXT,
MY_UNPACK_FILENAME|MY_APPEND_EXT),
O_RDONLY | O_SHARE, MYF(0))) < 0)
goto err;
errpos=1;
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)
m_info->last_used_table=m_info->open_tables;
m_info->children_attached= TRUE;
(void) my_close(fd,MYF(0));
(void) mysql_file_close(fd, MYF(0));
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;
pthread_mutex_lock(&THR_LOCK_open);
mysql_mutex_lock(&THR_LOCK_open);
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);
bad_children:
......@@ -190,7 +192,7 @@ err:
end_io_cache(&file);
/* Fall through */
case 1:
(void) my_close(fd,MYF(0));
(void) mysql_file_close(fd, MYF(0));
}
my_errno=save_errno;
DBUG_RETURN (NULL);
......@@ -241,9 +243,11 @@ MYRG_INFO *myrg_parent_open(const char *parent_name,
bzero((char*) &file_cache, sizeof(file_cache));
/* Open MERGE meta file. */
if ((fd= my_open(fn_format(parent_name_buff, parent_name, "", MYRG_NAME_EXT,
MY_UNPACK_FILENAME|MY_APPEND_EXT),
O_RDONLY | O_SHARE, MYF(0))) < 0)
if ((fd= mysql_file_open(rg_key_file_MRG,
fn_format(parent_name_buff, parent_name,
"", MYRG_NAME_EXT,
MY_UNPACK_FILENAME|MY_APPEND_EXT),
O_RDONLY | O_SHARE, MYF(0))) < 0)
goto err; /* purecov: inspected */
errpos= 1;
......@@ -327,13 +331,14 @@ MYRG_INFO *myrg_parent_open(const char *parent_name,
}
end_io_cache(&file_cache);
(void) my_close(fd, MYF(0));
pthread_mutex_init(&m_info->mutex, MY_MUTEX_INIT_FAST);
(void) mysql_file_close(fd, MYF(0));
mysql_mutex_init(rg_key_mutex_MYRG_INFO_mutex,
&m_info->mutex, MY_MUTEX_INIT_FAST);
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);
pthread_mutex_unlock(&THR_LOCK_open);
mysql_mutex_unlock(&THR_LOCK_open);
DBUG_RETURN(m_info);
......@@ -348,7 +353,7 @@ MYRG_INFO *myrg_parent_open(const char *parent_name,
end_io_cache(&file_cache);
/* Fall through */
case 1:
(void) my_close(fd, MYF(0));
(void) mysql_file_close(fd, MYF(0));
}
my_errno= save_errno;
DBUG_RETURN (NULL);
......@@ -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
here and in ha_myisammrg::store_lock() forces consistent data.
*/
pthread_mutex_lock(&m_info->mutex);
mysql_mutex_lock(&m_info->mutex);
rc= 1;
errpos= 0;
file_offset= 0;
......@@ -485,7 +490,7 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
m_info->keys= min_keys;
m_info->last_used_table= m_info->open_tables;
m_info->children_attached= TRUE;
pthread_mutex_unlock(&m_info->mutex);
mysql_mutex_unlock(&m_info->mutex);
DBUG_RETURN(0);
bad_children:
......@@ -497,7 +502,7 @@ err:
my_free((char*) m_info->rec_per_key_part, MYF(0));
m_info->rec_per_key_part= NULL;
}
pthread_mutex_unlock(&m_info->mutex);
mysql_mutex_unlock(&m_info->mutex);
my_errno= save_errno;
DBUG_RETURN(1);
}
......@@ -520,7 +525,7 @@ int myrg_detach_children(MYRG_INFO *m_info)
{
DBUG_ENTER("myrg_detach_children");
/* 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)
{
/* Do not attach/detach an empty child list. */
......@@ -531,7 +536,7 @@ int myrg_detach_children(MYRG_INFO *m_info)
m_info->del= 0;
m_info->data_file_length= 0;
m_info->options= 0;
pthread_mutex_unlock(&m_info->mutex);
mysql_mutex_unlock(&m_info->mutex);
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
it under the terms of the GNU General Public License as published by
......@@ -27,3 +27,35 @@ static const char *merge_insert_methods[] =
{ "FIRST", "LAST", NullS };
TYPELIB merge_insert_method= { array_elements(merge_insert_methods)-1,"",
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