summaryrefslogtreecommitdiff
path: root/storage/csv
diff options
context:
space:
mode:
Diffstat (limited to 'storage/csv')
-rw-r--r--storage/csv/ha_tina.cc62
-rw-r--r--storage/csv/ha_tina.h2
-rw-r--r--storage/csv/transparent_file.cc5
-rw-r--r--storage/csv/transparent_file.h1
4 files changed, 47 insertions, 23 deletions
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index badb515c2b2..4983236d840 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -112,6 +112,11 @@ static uchar* tina_get_key(TINA_SHARE *share, size_t *length,
return (uchar*) share->table_name;
}
+static PSI_memory_key csv_key_memory_tina_share;
+static PSI_memory_key csv_key_memory_blobroot;
+static PSI_memory_key csv_key_memory_tina_set;
+static PSI_memory_key csv_key_memory_row;
+
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key csv_key_mutex_tina, csv_key_mutex_TINA_SHARE_mutex;
@@ -132,6 +137,15 @@ static PSI_file_info all_tina_files[]=
{ &csv_key_file_update, "update", 0}
};
+static PSI_memory_info all_tina_memory[]=
+{
+ { &csv_key_memory_tina_share, "TINA_SHARE", PSI_FLAG_GLOBAL},
+ { &csv_key_memory_blobroot, "blobroot", 0},
+ { &csv_key_memory_tina_set, "tina_set", 0},
+ { &csv_key_memory_row, "row", 0},
+ { &csv_key_memory_Transparent_file, "Transparent_file", 0}
+};
+
static void init_tina_psi_keys(void)
{
const char* category= "csv";
@@ -142,6 +156,9 @@ static void init_tina_psi_keys(void)
count= array_elements(all_tina_files);
mysql_file_register(category, all_tina_files, count);
+
+ count= array_elements(all_tina_memory);
+ mysql_memory_register(category, all_tina_memory, count);
}
#endif /* HAVE_PSI_INTERFACE */
@@ -166,9 +183,9 @@ static int tina_init_func(void *p)
tina_hton= (handlerton *)p;
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;
+ (void) my_hash_init(csv_key_memory_tina_share, &tina_open_tables,
+ system_charset_info, 32, 0, 0, (my_hash_get_key)
+ tina_get_key, 0, 0);
tina_hton->db_type= DB_TYPE_CSV_DB;
tina_hton->create= tina_create_handler;
tina_hton->flags= (HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES |
@@ -205,14 +222,11 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table)
If share is not present in the hash, create a new share and
initialize its members.
*/
- if (!(share=(TINA_SHARE*) my_hash_search(&tina_open_tables,
- (uchar*) table_name,
- length)))
+ if (!(share=(TINA_SHARE*) my_hash_search(&tina_open_tables, (uchar*)
+ table_name, length)))
{
- if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
- &share, sizeof(*share),
- &tmp_name, length+1,
- NullS))
+ if (!my_multi_malloc(csv_key_memory_tina_share, MYF(MY_WME | MY_ZEROFILL),
+ &share, sizeof(*share), &tmp_name, length+1, NullS))
{
mysql_mutex_unlock(&tina_mutex);
return NULL;
@@ -514,7 +528,8 @@ ha_tina::ha_tina(handlerton *hton, TABLE_SHARE *table_arg)
buffer.set((char*)byte_buffer, IO_SIZE, &my_charset_bin);
chain= chain_buffer;
file_buff= new Transparent_file();
- init_alloc_root(&blobroot, "ha_tina", BLOB_MEMROOT_ALLOC_SIZE, 0, MYF(0));
+ init_alloc_root(csv_key_memory_blobroot, &blobroot, BLOB_MEMROOT_ALLOC_SIZE,
+ 0, MYF(0));
}
@@ -628,14 +643,15 @@ int ha_tina::chain_append()
chain_size += DEFAULT_CHAIN_LENGTH;
if (chain_alloced)
{
- /* Must cast since my_malloc unlike malloc doesn't have a void ptr */
- if ((chain= (tina_set *) my_realloc((uchar*)chain,
- chain_size, MYF(MY_WME))) == NULL)
+ if ((chain= (tina_set *) my_realloc(csv_key_memory_tina_set,
+ (uchar*)chain, chain_size,
+ MYF(MY_WME))) == NULL)
return -1;
}
else
{
- tina_set *ptr= (tina_set *) my_malloc(chain_size * sizeof(tina_set),
+ tina_set *ptr= (tina_set *) my_malloc(csv_key_memory_tina_set,
+ chain_size * sizeof(tina_set),
MYF(MY_WME));
memcpy(ptr, chain, DEFAULT_CHAIN_LENGTH * sizeof(tina_set));
chain= ptr;
@@ -829,8 +845,8 @@ int ha_tina::find_current_row(uchar *buf)
Thus, for enums we silence the warning, as it doesn't really mean
an invalid value.
*/
- if ((*field)->store(buffer.ptr(), buffer.length(), buffer.charset(),
- is_enum ? CHECK_FIELD_IGNORE : CHECK_FIELD_WARN))
+ if ((*field)->store_text(buffer.ptr(), buffer.length(), buffer.charset(),
+ is_enum ? CHECK_FIELD_IGNORE : CHECK_FIELD_WARN))
{
if (!is_enum)
goto err;
@@ -867,10 +883,11 @@ err:
for CSV engine. For more details see mysys/thr_lock.c
*/
-void tina_get_status(void* param, my_bool concurrent_insert)
+my_bool tina_get_status(void* param, my_bool concurrent_insert)
{
ha_tina *tina= (ha_tina*) param;
tina->get_status();
+ return 0;
}
void tina_update_status(void* param)
@@ -976,7 +993,8 @@ int ha_tina::open(const char *name, int mode, uint open_options)
*/
thr_lock_data_init(&share->lock, &lock, (void*) this);
ref_length= sizeof(my_off_t);
- init_alloc_root(&blobroot, "ha_tina", BLOB_MEMROOT_ALLOC_SIZE, 0, MYF(0));
+ init_alloc_root(csv_key_memory_blobroot, &blobroot, BLOB_MEMROOT_ALLOC_SIZE,
+ 0, MYF(0));
share->lock.get_status= tina_get_status;
share->lock.update_status= tina_update_status;
@@ -1529,7 +1547,8 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
if (init_data_file())
DBUG_RETURN(HA_ERR_CRASHED_ON_REPAIR);
- if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME))))
+ if (!(buf= (uchar*) my_malloc(csv_key_memory_row, table->s->reclength,
+ MYF(MY_WME))))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
/*
Local_saved_data_file_length is initialized during the lock phase.
@@ -1743,7 +1762,8 @@ int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt)
if (init_data_file())
DBUG_RETURN(HA_ERR_CRASHED);
- if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME))))
+ if (!(buf= (uchar*) my_malloc(csv_key_memory_row, table->s->reclength,
+ MYF(MY_WME))))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
/*
diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h
index aae535c271e..043183444da 100644
--- a/storage/csv/ha_tina.h
+++ b/storage/csv/ha_tina.h
@@ -57,7 +57,7 @@ struct tina_set {
my_off_t end;
};
-class ha_tina: public handler
+class ha_tina final : public handler
{
THR_LOCK_DATA lock; /* MySQL lock */
TINA_SHARE *share; /* Shared lock info */
diff --git a/storage/csv/transparent_file.cc b/storage/csv/transparent_file.cc
index 47d63f2caaf..443e61d08d8 100644
--- a/storage/csv/transparent_file.cc
+++ b/storage/csv/transparent_file.cc
@@ -23,9 +23,12 @@
#include "transparent_file.h"
#include "my_sys.h" // MY_WME, MY_ALLOW_ZERO_PTR, MY_SEEK_SET
+PSI_memory_key csv_key_memory_Transparent_file;
+
Transparent_file::Transparent_file() : lower_bound(0), buff_size(IO_SIZE)
{
- buff= (uchar *) my_malloc(buff_size*sizeof(uchar), MYF(MY_WME));
+ buff= (uchar *) my_malloc(csv_key_memory_Transparent_file,
+ buff_size*sizeof(uchar), MYF(MY_WME));
}
Transparent_file::~Transparent_file()
diff --git a/storage/csv/transparent_file.h b/storage/csv/transparent_file.h
index 024fc0e3a38..545643d0f17 100644
--- a/storage/csv/transparent_file.h
+++ b/storage/csv/transparent_file.h
@@ -18,6 +18,7 @@
#include <sys/stat.h>
#include <my_dir.h>
+extern PSI_memory_key csv_key_memory_Transparent_file;
class Transparent_file
{