summaryrefslogtreecommitdiff
path: root/storage/myisammrg
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2009-12-15 21:45:22 +0300
committerKonstantin Osipov <kostja@sun.com>2009-12-15 21:45:22 +0300
commitc9cd0f0b75b6dcaacef5db6eabd31e262ecd7be4 (patch)
treec5bdf39edfe6126050810bb9269e5bb4fc8cf16d /storage/myisammrg
parent6331ef3efd56d995fd7a82b7325a2615750766ad (diff)
parent6fd3866c6c104f8bc991d71583e627ae6fabe0ab (diff)
downloadmariadb-git-c9cd0f0b75b6dcaacef5db6eabd31e262ecd7be4.tar.gz
Merge next-mr -> next-4284.
Diffstat (limited to 'storage/myisammrg')
-rw-r--r--storage/myisammrg/ha_myisammrg.cc6
-rw-r--r--storage/myisammrg/myrg_close.c8
-rw-r--r--storage/myisammrg/myrg_create.c20
-rw-r--r--storage/myisammrg/myrg_def.h15
-rw-r--r--storage/myisammrg/myrg_open.c49
-rw-r--r--storage/myisammrg/myrg_static.c34
6 files changed, 93 insertions, 39 deletions
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 760639e2c6b..a34a52d8f9c 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -1,4 +1,4 @@
-/* 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
@@ -1513,6 +1513,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;
diff --git a/storage/myisammrg/myrg_close.c b/storage/myisammrg/myrg_close.c
index 6f641019a73..45e0a82913a 100644
--- a/storage/myisammrg/myrg_close.c
+++ b/storage/myisammrg/myrg_close.c
@@ -1,4 +1,4 @@
-/* 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)
{
diff --git a/storage/myisammrg/myrg_create.c b/storage/myisammrg/myrg_create.c
index b030340e743..5fbf8a44b8d 100644
--- a/storage/myisammrg/myrg_create.c
+++ b/storage/myisammrg/myrg_create.c
@@ -1,4 +1,4 @@
-/* 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 */
diff --git a/storage/myisammrg/myrg_def.h b/storage/myisammrg/myrg_def.h
index 9c69da1424d..b916243be21 100644
--- a/storage/myisammrg/myrg_def.h
+++ b/storage/myisammrg/myrg_def.h
@@ -1,4 +1,4 @@
-/* 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 */
+
diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c
index d6d1a68ca20..d782224a680 100644
--- a/storage/myisammrg/myrg_open.c
+++ b/storage/myisammrg/myrg_open.c
@@ -1,4 +1,4 @@
-/* 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);
}
diff --git a/storage/myisammrg/myrg_static.c b/storage/myisammrg/myrg_static.c
index c20d2be4396..b518a3d84c8 100644
--- a/storage/myisammrg/myrg_static.c
+++ b/storage/myisammrg/myrg_static.c
@@ -1,4 +1,4 @@
-/* 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 */
+