summaryrefslogtreecommitdiff
path: root/storage/myisam
diff options
context:
space:
mode:
Diffstat (limited to 'storage/myisam')
-rw-r--r--storage/myisam/ft_boolean_search.c4
-rw-r--r--storage/myisam/ft_nlq_search.c2
-rw-r--r--storage/myisam/ft_parser.c16
-rw-r--r--storage/myisam/ft_stopwords.c9
-rw-r--r--storage/myisam/ha_myisam.cc48
-rw-r--r--storage/myisam/ha_myisam.h5
-rw-r--r--storage/myisam/mi_check.c23
-rw-r--r--storage/myisam/mi_create.c4
-rw-r--r--storage/myisam/mi_delete_table.c12
-rw-r--r--storage/myisam/mi_dynrec.c2
-rw-r--r--storage/myisam/mi_key.c16
-rw-r--r--storage/myisam/mi_locking.c4
-rw-r--r--storage/myisam/mi_open.c9
-rw-r--r--storage/myisam/mi_packrec.c42
-rw-r--r--storage/myisam/mi_preload.c3
-rw-r--r--storage/myisam/mi_range.c29
-rw-r--r--storage/myisam/mi_static.c50
-rw-r--r--storage/myisam/mi_test1.c17
-rw-r--r--storage/myisam/mi_test2.c9
-rw-r--r--storage/myisam/mi_unique.c7
-rw-r--r--storage/myisam/mi_write.c9
-rw-r--r--storage/myisam/myisam_ftdump.c9
-rw-r--r--storage/myisam/myisamchk.c24
-rw-r--r--storage/myisam/myisamdef.h53
-rw-r--r--storage/myisam/myisamlog.c8
-rw-r--r--storage/myisam/myisampack.c26
-rw-r--r--storage/myisam/rt_index.c7
-rw-r--r--storage/myisam/rt_test.c3
-rw-r--r--storage/myisam/sort.c18
-rw-r--r--storage/myisam/sp_test.c3
30 files changed, 307 insertions, 164 deletions
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c
index 406a9bbc951..a91467c5b8d 100644
--- a/storage/myisam/ft_boolean_search.c
+++ b/storage/myisam/ft_boolean_search.c
@@ -566,7 +566,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query,
FTB_EXPR *ftbe;
FTB_WORD *ftbw;
- if (!(ftb=(FTB *)my_malloc(sizeof(FTB), MYF(MY_WME))))
+ if (!(ftb=(FTB *)my_malloc(mi_key_memory_FTB, sizeof(FTB), MYF(MY_WME))))
return 0;
ftb->please= (struct _ft_vft *) & _ft_vft_boolean;
ftb->state=UNINITIALIZED;
@@ -579,7 +579,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query,
bzero(& ftb->no_dupes, sizeof(TREE));
ftb->last_word= 0;
- init_alloc_root(&ftb->mem_root, "fulltext", 1024, 1024, MYF(0));
+ init_alloc_root(mi_key_memory_FTB, &ftb->mem_root, 1024, 1024, MYF(0));
ftb->queue.max_elements= 0;
if (!(ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR))))
goto err;
diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c
index 3e433b71761..eb95d1e0b94 100644
--- a/storage/myisam/ft_nlq_search.c
+++ b/storage/myisam/ft_nlq_search.c
@@ -287,7 +287,7 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, uchar *query,
If ndocs == 0, this will not allocate RAM for FT_INFO.doc[],
so if ndocs == 0, FT_INFO.doc[] must not be accessed.
*/
- dlist=(FT_INFO *)my_malloc(sizeof(FT_INFO)+
+ dlist=(FT_INFO *)my_malloc(mi_key_memory_FT_INFO, sizeof(FT_INFO)+
sizeof(FT_DOC)*
(int)(aio.dtree.elements_in_tree-1),
MYF(0));
diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c
index b400990d934..4584dbd4b91 100644
--- a/storage/myisam/ft_parser.c
+++ b/storage/myisam/ft_parser.c
@@ -1,4 +1,5 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2020, MariaDB Corporation.
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
@@ -122,7 +123,7 @@ uchar ft_get_word(CHARSET_INFO *cs, const uchar **start, const uchar *end,
{
for (; doc < end; doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1)))
{
- mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
+ mbl= my_ci_ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
if (true_word_char(ctype, *doc))
break;
if (*doc == FTB_RQUOT && param->quot)
@@ -161,7 +162,7 @@ uchar ft_get_word(CHARSET_INFO *cs, const uchar **start, const uchar *end,
for (word->pos= doc; doc < end; length++,
doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1)))
{
- mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
+ mbl= my_ci_ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
if (true_word_char(ctype, *doc))
mwc=0;
else if (!misc_word_char(*doc) || mwc)
@@ -214,7 +215,7 @@ uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end,
{
if (doc >= end)
DBUG_RETURN(0);
- mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
+ mbl= my_ci_ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
if (true_word_char(ctype, *doc))
break;
}
@@ -223,7 +224,7 @@ uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end,
for (word->pos= doc; doc < end; length++,
doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1)))
{
- mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
+ mbl= my_ci_ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
if (true_word_char(ctype, *doc))
mwc= 0;
else if (!misc_word_char(*doc) || mwc)
@@ -340,9 +341,10 @@ MYSQL_FTPARSER_PARAM* ftparser_alloc_param(MI_INFO *info)
(ftb_check_phrase_internal, ftb_phrase_add_word). Thus MAX_PARAM_NR=2.
*/
info->ftparser_param= (MYSQL_FTPARSER_PARAM *)
- my_malloc(MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) *
- info->s->ftkeys, MYF(MY_WME | MY_ZEROFILL));
- init_alloc_root(&info->ft_memroot, "fulltext_parser",
+ my_malloc(mi_key_memory_FTPARSER_PARAM,
+ MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) * info->s->ftkeys,
+ MYF(MY_WME | MY_ZEROFILL));
+ init_alloc_root(mi_key_memory_ft_memroot, &info->ft_memroot,
FTPARSER_MEMROOT_ALLOC_SIZE, 0, MYF(0));
}
return info->ftparser_param;
diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c
index 3422a82a111..34c445cc163 100644
--- a/storage/myisam/ft_stopwords.c
+++ b/storage/myisam/ft_stopwords.c
@@ -59,7 +59,8 @@ int ft_init_stopwords()
DBUG_ENTER("ft_init_stopwords");
if (!stopwords3)
{
- if (!(stopwords3=(TREE *)my_malloc(sizeof(TREE),MYF(0))))
+ if (!(stopwords3=(TREE *)my_malloc(mi_key_memory_ft_stopwords,
+ sizeof(TREE), MYF(0))))
DBUG_RETURN(-1);
init_tree(stopwords3,0,0,sizeof(FT_STOPWORD),(qsort_cmp2)&FT_STOPWORD_cmp,
(ft_stopword_file ? (tree_element_free)&FT_STOPWORD_free : 0),
@@ -89,13 +90,15 @@ int ft_init_stopwords()
DBUG_RETURN(-1);
len=(size_t)my_seek(fd, 0L, MY_SEEK_END, MYF(0));
my_seek(fd, 0L, MY_SEEK_SET, MYF(0));
- if (!(start=buffer=my_malloc(len+1, MYF(MY_WME))))
+ if (!(start= buffer= my_malloc(mi_key_memory_ft_stopwords, len+1,
+ MYF(MY_WME))))
goto err0;
len=my_read(fd, buffer, len, MYF(MY_WME));
end=start+len;
while (ft_simple_get_word(ft_stopword_cs, &start, end, &w, TRUE))
{
- if (ft_add_stopword(my_strndup((char*) w.pos, w.len, MYF(0))))
+ if (ft_add_stopword(my_strndup(mi_key_memory_ft_stopwords,
+ (char*) w.pos, w.len, MYF(0))))
goto err1;
}
error=0;
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index f0df75aa578..b3f84f5eefa 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -254,7 +254,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
TABLE_SHARE *share= table_arg->s;
uint options= share->db_options_in_use;
DBUG_ENTER("table2myisam");
- if (!(my_multi_malloc(MYF(MY_WME),
+ if (!(my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
recinfo_out, (share->fields * 2 + 2) * sizeof(MI_COLUMNDEF),
keydef_out, share->keys * sizeof(MI_KEYDEF),
&keyseg,
@@ -1734,7 +1734,7 @@ void ha_myisam::start_bulk_insert(ha_rows rows, uint flags)
(ulong) rows, size));
/* don't enable row cache if too few rows */
- if (! rows || (rows > MI_MIN_ROWS_TO_USE_WRITE_CACHE))
+ if ((!rows || rows > MI_MIN_ROWS_TO_USE_WRITE_CACHE) && !has_long_unique())
mi_extra(file, HA_EXTRA_WRITE_CACHE, (void*) &size);
can_enable_indexes= mi_is_all_keys_active(file->s->state.key_map,
@@ -2102,7 +2102,8 @@ int ha_myisam::info(uint flag)
ref_length= misam_info.reflength;
share->db_options_in_use= misam_info.options;
- stats.block_size= myisam_block_size; /* record block size */
+ /* record block size. We adjust with IO_SIZE to not make it too small */
+ stats.block_size= MY_MAX(myisam_block_size, IO_SIZE);
if (table_share->tmp_table == NO_TMP_TABLE)
mysql_mutex_lock(&table_share->LOCK_share);
@@ -2133,7 +2134,8 @@ int ha_myisam::info(uint flag)
int ha_myisam::extra(enum ha_extra_function operation)
{
- if (operation == HA_EXTRA_MMAP && !opt_myisam_use_mmap)
+ if ((operation == HA_EXTRA_MMAP && !opt_myisam_use_mmap) ||
+ (operation == HA_EXTRA_WRITE_CACHE && has_long_unique()))
return 0;
return mi_extra(file, operation, 0);
}
@@ -2349,6 +2351,8 @@ void ha_myisam::get_auto_increment(ulonglong offset, ulonglong increment,
inx Index to use
min_key Start of range. Null pointer if from first key
max_key End of range. Null pointer if to last key
+ pages Store first and last page for the range in case of
+ b-trees. In other cases it's not touched.
NOTES
min_key.flag can have one of the following values:
@@ -2366,10 +2370,12 @@ void ha_myisam::get_auto_increment(ulonglong offset, ulonglong increment,
the range.
*/
-ha_rows ha_myisam::records_in_range(uint inx, key_range *min_key,
- key_range *max_key)
+ha_rows ha_myisam::records_in_range(uint inx, const key_range *min_key,
+ const key_range *max_key,
+ page_range *pages)
{
- return (ha_rows) mi_records_in_range(file, (int) inx, min_key, max_key);
+ return (ha_rows) mi_records_in_range(file, (int) inx, min_key, max_key,
+ pages);
}
@@ -2519,13 +2525,16 @@ int myisam_panic(handlerton *hton, ha_panic_function flag)
return mi_panic(flag);
}
+static int myisam_drop_table(handlerton *hton, const char *path)
+{
+ return mi_delete_table(path);
+}
+
static int myisam_init(void *p)
{
handlerton *hton;
-#ifdef HAVE_PSI_INTERFACE
init_myisam_psi_keys();
-#endif
/* Set global variables based on startup options */
if (myisam_recover_options && myisam_recover_options != HA_RECOVER_OFF)
@@ -2533,12 +2542,12 @@ static int myisam_init(void *p)
else
myisam_recover_options= HA_RECOVER_OFF;
- myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size);
+ myisam_block_size=(uint) 1 << my_bit_log2_uint64(opt_myisam_block_size);
hton= (handlerton *)p;
- hton->state= SHOW_OPTION_YES;
hton->db_type= DB_TYPE_MYISAM;
hton->create= myisam_create_handler;
+ hton->drop_table= myisam_drop_table;
hton->panic= myisam_panic;
hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES;
hton->tablefile_extensions= ha_myisam_exts;
@@ -2652,23 +2661,6 @@ bool ha_myisam::rowid_filter_push(Rowid_filter* rowid_filter)
struct st_mysql_storage_engine myisam_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
-mysql_declare_plugin(myisam)
-{
- MYSQL_STORAGE_ENGINE_PLUGIN,
- &myisam_storage_engine,
- "MyISAM",
- "MySQL AB",
- "MyISAM storage engine",
- PLUGIN_LICENSE_GPL,
- myisam_init, /* Plugin Init */
- NULL, /* Plugin Deinit */
- 0x0100, /* 1.0 */
- NULL, /* status variables */
- myisam_sysvars, /* system variables */
- NULL,
- 0,
-}
-mysql_declare_plugin_end;
maria_declare_plugin(myisam)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h
index 70c99a617f6..3843004cc6e 100644
--- a/storage/myisam/ha_myisam.h
+++ b/storage/myisam/ha_myisam.h
@@ -41,7 +41,7 @@ C_MODE_START
check_result_t index_cond_func_myisam(void *arg);
C_MODE_END
-class ha_myisam: public handler
+class ha_myisam final : public handler
{
MI_INFO *file;
ulonglong int_table_flags;
@@ -114,7 +114,8 @@ class ha_myisam: public handler
int indexes_are_disabled(void);
void start_bulk_insert(ha_rows rows, uint flags);
int end_bulk_insert();
- ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
+ ha_rows records_in_range(uint inx, const key_range *min_key,
+ const key_range *max_key, page_range *pages);
void update_create_info(HA_CREATE_INFO *create_info);
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index a0cdd37b302..b97c9656ab1 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -1175,6 +1175,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend)
if (_mi_read_cache(&param->read_cache,(uchar*) info->rec_buff,
block_info.filepos, block_info.rec_len, READING_NEXT))
goto err;
+ info->rec_buff[block_info.rec_len]= 0; /* Keep valgrind happy */
if (_mi_pack_rec_unpack(info, &info->bit_buff, record,
info->rec_buff, block_info.rec_len))
{
@@ -2141,7 +2142,7 @@ int filecopy(HA_CHECK *param, File to,File from,my_off_t start,
DBUG_ENTER("filecopy");
buff_length=(ulong) MY_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
+ if (!(buff=my_malloc(mi_key_memory_filecopy, buff_length, MYF(0))))
{
buff=tmp_buff; buff_length=IO_SIZE;
}
@@ -2298,8 +2299,8 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
info->state->data_file_length= sort_info.filelength;
sort_param.wordlist=NULL;
- init_alloc_root(&sort_param.wordroot, "sort", FTPARSER_MEMROOT_ALLOC_SIZE, 0,
- MYF(param->malloc_flags));
+ init_alloc_root(mi_key_memory_MI_SORT_PARAM_wordroot, &sort_param.wordroot,
+ FTPARSER_MEMROOT_ALLOC_SIZE, 0, MYF(param->malloc_flags));
if (share->data_file_type == DYNAMIC_RECORD)
length=MY_MAX(share->base.min_pack_length+1,share->base.min_block_length);
@@ -2795,7 +2796,7 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
if (share->options & HA_OPTION_COMPRESS_RECORD)
set_if_bigger(max_pack_reclength, share->max_pack_length);
if (!(sort_param=(MI_SORT_PARAM *)
- my_malloc((uint) share->base.keys *
+ my_malloc(mi_key_memory_MI_SORT_PARAM, (uint) share->base.keys *
(sizeof(MI_SORT_PARAM) + max_pack_reclength),
MYF(MY_ZEROFILL))))
{
@@ -2878,8 +2879,8 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
sort_param[i].keyinfo->seg->charset->mbmaxlen;
sort_param[i].key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
- init_alloc_root(&sort_param[i].wordroot, "sort",
- FTPARSER_MEMROOT_ALLOC_SIZE, 0,
+ init_alloc_root(mi_key_memory_MI_SORT_PARAM_wordroot,
+ &sort_param[i].wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0,
MYF(param->malloc_flags));
}
}
@@ -3632,6 +3633,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
llstr(sort_param->pos,llbuff));
continue;
}
+ sort_param->rec_buff[block_info.rec_len]= 0; /* Keep valgrind happy */
if (_mi_pack_rec_unpack(info, &sort_param->bit_buff, sort_param->record,
sort_param->rec_buff, block_info.rec_len))
{
@@ -3723,7 +3725,8 @@ int sort_write_record(MI_SORT_PARAM *sort_param)
MI_DYN_DELETE_BLOCK_HEADER;
if (sort_info->buff_length < reclength)
{
- if (!(sort_info->buff=my_realloc(sort_info->buff, (uint) reclength,
+ if (!(sort_info->buff=my_realloc(mi_key_memory_SORT_INFO_buffer,
+ sort_info->buff, (uint) reclength,
MYF(MY_FREE_ON_ERROR | MY_WME |
MY_ALLOW_ZERO_PTR))))
DBUG_RETURN(1);
@@ -3940,7 +3943,8 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a)
sort_info->info->s->rec_reflength) &&
(sort_info->info->s->options &
(HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)))
- ft_buf=(SORT_FT_BUF *)my_malloc(sort_param->keyinfo->block_length +
+ ft_buf=(SORT_FT_BUF *)my_malloc(mi_key_memory_SORT_FT_BUF,
+ sort_param->keyinfo->block_length +
sizeof(SORT_FT_BUF), MYF(MY_WME));
if (!ft_buf)
@@ -4211,7 +4215,8 @@ static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks,
SORT_KEY_BLOCKS *block;
DBUG_ENTER("alloc_key_blocks");
- if (!(block=(SORT_KEY_BLOCKS*) my_malloc((sizeof(SORT_KEY_BLOCKS)+
+ if (!(block=(SORT_KEY_BLOCKS*) my_malloc(mi_key_memory_SORT_KEY_BLOCKS,
+ (sizeof(SORT_KEY_BLOCKS)+
buffer_length+IO_SIZE)*blocks,
MYF(0))))
{
diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c
index de516d9fb6a..51354e0e8b5 100644
--- a/storage/myisam/mi_create.c
+++ b/storage/myisam/mi_create.c
@@ -94,7 +94,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
ci->reloc_rows=ci->max_rows; /* Check if wrong parameter */
if (!(rec_per_key_part=
- (ulong*) my_malloc((keys + uniques)*HA_MAX_KEY_SEG*sizeof(long),
+ (ulong*) my_malloc(mi_key_memory_MYISAM_SHARE,
+ (keys + uniques) * HA_MAX_KEY_SEG * sizeof(long),
MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(my_errno);
@@ -622,6 +623,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
fn_format(kfilename, name, "", MI_NAME_IEXT, MY_UNPACK_FILENAME |
(internal_table ? 0 : MY_RETURN_REAL_PATH) |
(have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
+ klinkname_ptr= 0;
/* Replace the current file */
create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
}
diff --git a/storage/myisam/mi_delete_table.c b/storage/myisam/mi_delete_table.c
index 7990c3e8a80..d318b44720a 100644
--- a/storage/myisam/mi_delete_table.c
+++ b/storage/myisam/mi_delete_table.c
@@ -28,19 +28,23 @@
int mi_delete_table(const char *name)
{
+ int error= 0;
DBUG_ENTER("mi_delete_table");
#ifdef EXTRA_DEBUG
check_table_is_closed(name,"delete");
#endif
- if (mysql_file_delete_with_symlink(mi_key_file_kfile, name, MI_NAME_IEXT, MYF(MY_WME)) ||
- mysql_file_delete_with_symlink(mi_key_file_dfile, name, MI_NAME_DEXT, MYF(MY_WME)))
- DBUG_RETURN(my_errno);
+ if (mysql_file_delete_with_symlink(mi_key_file_kfile, name, MI_NAME_IEXT,
+ MYF(MY_WME)))
+ error= my_errno;
+ if (mysql_file_delete_with_symlink(mi_key_file_dfile, name, MI_NAME_DEXT,
+ MYF(MY_WME)))
+ error= my_errno;
// optionally present:
mysql_file_delete_with_symlink(mi_key_file_dfile, name, ".OLD", MYF(0));
mysql_file_delete_with_symlink(mi_key_file_dfile, name, ".TMD", MYF(0));
- DBUG_RETURN(0);
+ DBUG_RETURN(error);
}
diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c
index 69c13ab96cf..09c10040f9c 100644
--- a/storage/myisam/mi_dynrec.c
+++ b/storage/myisam/mi_dynrec.c
@@ -43,7 +43,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
/* Play it safe; We have a small stack when using threads */
#undef my_alloca
#undef my_afree
-#define my_alloca(A) my_malloc((A),MYF(0))
+#define my_alloca(A) my_malloc(PSI_NOT_INSTRUMENTED, (A),MYF(0))
#define my_afree(A) my_free((A))
/* Interface function from MI_INFO */
diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c
index 7d263d9fc7b..087eb59c7c0 100644
--- a/storage/myisam/mi_key.c
+++ b/storage/myisam/mi_key.c
@@ -1,4 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2020, MariaDB Corporation.
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,7 +28,9 @@
#define FIX_LENGTH(cs, pos, length, char_length) \
do { \
if (length > char_length) \
- char_length= my_charpos(cs, pos, pos+length, char_length); \
+ char_length= my_ci_charpos(cs, (const char *) pos, \
+ (const char *) pos+length, \
+ char_length); \
set_if_smaller(char_length,length); \
} while(0)
@@ -109,7 +112,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
{
if (type != HA_KEYTYPE_NUM)
{
- length= cs->cset->lengthsp(cs, (char*) pos, length);
+ length= my_ci_lengthsp(cs, (char*) pos, length);
}
else
{
@@ -186,7 +189,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
FIX_LENGTH(cs, pos, length, char_length);
memcpy((uchar*) key, pos, char_length);
if (length > char_length)
- cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' ');
+ my_ci_fill(cs, (char*) key+char_length, length-char_length, ' ');
key+= length;
}
_mi_dpointer(info,key,filepos);
@@ -264,7 +267,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
}
else if (type != HA_KEYTYPE_BINARY)
{
- length= cs->cset->lengthsp(cs, (char*) pos, length);
+ length= my_ci_lengthsp(cs, (char*) pos, length);
}
FIX_LENGTH(cs, pos, length, char_length);
store_key_length_inc(key,char_length);
@@ -295,7 +298,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
FIX_LENGTH(cs, pos, length, char_length);
memcpy((uchar*) key, pos, char_length);
if (length > char_length)
- cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' ');
+ my_ci_fill(cs, (char*) key+char_length, length-char_length, ' ');
key+= length;
}
if (last_used_keyseg)
@@ -383,8 +386,7 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr,
if (keyseg->type != (int) HA_KEYTYPE_NUM)
{
memcpy(pos,key,(size_t) length);
- keyseg->charset->cset->fill(keyseg->charset,
- (char*) pos + length,
+ my_ci_fill(keyseg->charset, (char*) pos + length,
keyseg->length - length,
' ');
}
diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c
index 713ba0a3851..67b253761bc 100644
--- a/storage/myisam/mi_locking.c
+++ b/storage/myisam/mi_locking.c
@@ -284,7 +284,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
(THR_WRITE_CONCURRENT_INSERT was used)
*/
-void mi_get_status(void* param, my_bool concurrent_insert)
+my_bool mi_get_status(void* param, my_bool concurrent_insert)
{
MI_INFO *info=(MI_INFO*) param;
DBUG_ENTER("mi_get_status");
@@ -306,7 +306,7 @@ void mi_get_status(void* param, my_bool concurrent_insert)
info->append_insert_at_end= concurrent_insert;
if (concurrent_insert)
info->s->state.state.uncacheable= TRUE;
- DBUG_VOID_RETURN;
+ DBUG_RETURN(0);
}
diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c
index 4d3c227dcc3..cca2afa0b03 100644
--- a/storage/myisam/mi_open.c
+++ b/storage/myisam/mi_open.c
@@ -310,7 +310,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
/* Add space for node pointer */
share->base.max_key_length+= share->base.key_reflength;
- if (!my_multi_malloc(MY_WME,
+ if (!my_multi_malloc(mi_key_memory_MYISAM_SHARE, MYF(MY_WME),
&share,sizeof(*share),
&share->state.rec_per_key_part,
sizeof(long)*base_key_parts,
@@ -599,7 +599,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
}
/* alloc and set up private structure parts */
- if (!my_multi_malloc(MY_WME,
+ if (!my_multi_malloc(mi_key_memory_MI_INFO, MYF(MY_WME),
&m_info,sizeof(MI_INFO),
&info.blobs,sizeof(MI_BLOB)*share->base.blobs,
&info.buff,(share->base.max_key_block_length*2+
@@ -759,7 +759,8 @@ uchar *mi_alloc_rec_buff(MI_INFO *info, ulong length, uchar **buf)
MI_REC_BUFF_OFFSET : 0);
if (extra && newptr)
newptr-= MI_REC_BUFF_OFFSET;
- if (!(newptr=(uchar*) my_realloc((uchar*)newptr, length+extra+8,
+ if (!(newptr=(uchar*) my_realloc(mi_key_memory_record_buffer,
+ (uchar*)newptr, length + extra + 8,
MYF(MY_ALLOW_ZERO_PTR))))
return NULL;
*((uint32 *) newptr)= (uint32) length;
@@ -1004,7 +1005,7 @@ uchar *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state)
if (!state->rec_per_key_part)
{
- if (!my_multi_malloc(MY_WME,
+ if (!my_multi_malloc(mi_key_memory_MYISAM_SHARE, MYF(MY_WME),
&state->rec_per_key_part,sizeof(long)*key_parts,
&state->key_root, keys*sizeof(my_off_t),
&state->key_del, key_blocks*sizeof(my_off_t),
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index 6197c083c52..ca8a8ef06c7 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -196,8 +196,8 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
- Distinct column values
*/
if (!(share->decode_trees=(MI_DECODE_TREE*)
- my_malloc((uint) (trees*sizeof(MI_DECODE_TREE)+
- intervall_length*sizeof(uchar)),
+ my_malloc(mi_key_memory_MI_DECODE_TREE,
+ trees*sizeof(MI_DECODE_TREE) + intervall_length*sizeof(uchar),
MYF(MY_WME))))
goto err0;
intervall_buff=(uchar*) (share->decode_trees+trees);
@@ -219,7 +219,8 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
data, we add (BITS_SAVED / 8) - 1 bytes to the buffer size.
*/
if (!(share->decode_tables=(uint16*)
- my_malloc((length + OFFSET_TABLE_SIZE) * sizeof(uint16) +
+ my_malloc(mi_key_memory_MYISAM_SHARE_decode_tables,
+ (length + OFFSET_TABLE_SIZE) * sizeof(uint16) +
(uint) (share->pack.header_length - sizeof(header) +
(BITS_SAVED / 8) - 1), MYF(MY_WME | MY_ZEROFILL))))
goto err1;
@@ -259,9 +260,10 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
goto err3;
/* Reallocate the decoding tables to the used size. */
decode_table=(uint16*)
- my_realloc((uchar*) share->decode_tables,
+ my_realloc(mi_key_memory_MYISAM_SHARE_decode_tables,
+ (uchar*) share->decode_tables,
(uint) ((uchar*) decode_table - (uchar*) share->decode_tables),
- MYF(MY_HOLD_ON_ERROR));
+ MYF(0));
/* Fix the table addresses in the tree heads. */
{
my_ptrdiff_t diff=PTR_BYTE_DIFF(decode_table,share->decode_tables);
@@ -723,6 +725,8 @@ int _mi_read_pack_record(MI_INFO *info, my_off_t filepos, uchar *buf)
block_info.rec_len - block_info.offset, MYF(MY_NABP)))
goto panic;
info->update|= HA_STATE_AKTIV;
+
+ info->rec_buff[block_info.rec_len]= 0; /* Keep valgrind happy */
DBUG_RETURN(_mi_pack_rec_unpack(info, &info->bit_buff, buf,
info->rec_buff, block_info.rec_len));
panic:
@@ -1350,8 +1354,9 @@ int _mi_read_rnd_pack_record(MI_INFO *info, uchar *buf,
info->nextpos=block_info.filepos+block_info.rec_len;
info->update|= HA_STATE_AKTIV | HA_STATE_KEY_CHANGED;
- DBUG_RETURN (_mi_pack_rec_unpack(info, &info->bit_buff, buf,
- info->rec_buff, block_info.rec_len));
+ info->rec_buff[block_info.rec_len]= 0; /* Keep valgrind happy */
+ DBUG_RETURN(_mi_pack_rec_unpack(info, &info->bit_buff, buf,
+ info->rec_buff, block_info.rec_len));
err:
DBUG_RETURN(my_errno);
}
@@ -1370,8 +1375,8 @@ 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 mysql_file_pread() here because mi_read_rnd_pack_record assumes
- position is ok
+ We can't use mysql_file_pread() here because mi_read_rnd_pack_record
+ assumes position is ok
*/
mysql_file_seek(file, filepos, MY_SEEK_SET, MYF(0));
if (mysql_file_read(file, header, ref_length, MYF(MY_NABP)))
@@ -1406,15 +1411,17 @@ uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff,
}
- /* rutines for bit buffer */
- /* Note buffer must be 6 byte bigger than longest row */
+/*
+ Rutines for bit buffer
+ Note: buffer must be 6 byte bigger than longest row
+*/
static void init_bit_buffer(MI_BIT_BUFF *bit_buff, uchar *buffer, uint length)
{
bit_buff->pos=buffer;
bit_buff->end=buffer+length;
bit_buff->bits=bit_buff->error=0;
- bit_buff->current_byte=0; /* Avoid purify errors */
+ bit_buff->current_byte=0; /* Avoid valgrind errors */
}
static uint fill_and_get_bits(MI_BIT_BUFF *bit_buff, uint count)
@@ -1560,9 +1567,11 @@ void _mi_unmap_file(MI_INFO *info)
}
-static uchar *_mi_mempack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff,
- MI_BLOCK_INFO *info, uchar **rec_buff_p,
- uchar *header)
+static uchar *_mi_mempack_get_block_info(MI_INFO *myisam,
+ MI_BIT_BUFF *bit_buff,
+ MI_BLOCK_INFO *info,
+ uchar **rec_buff_p,
+ uchar *header)
{
header+= read_pack_length((uint) myisam->s->pack.version, header,
&info->rec_len);
@@ -1571,7 +1580,7 @@ static uchar *_mi_mempack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff,
header+= read_pack_length((uint) myisam->s->pack.version, header,
&info->blob_len);
/* mi_alloc_rec_buff sets my_errno on error */
- if (!(mi_alloc_rec_buff(myisam, info->blob_len,
+ if (!(mi_alloc_rec_buff(myisam, info->blob_len ,
rec_buff_p)))
return 0; /* not enough memory */
bit_buff->blob_pos= (uchar*) *rec_buff_p;
@@ -1596,6 +1605,7 @@ static int _mi_read_mempack_record(MI_INFO *info, my_off_t filepos, uchar *buf)
(uchar*) share->file_map+
filepos)))
DBUG_RETURN(-1);
+ /* No need to end-zero pos here for valgrind as data is memory mapped */
DBUG_RETURN(_mi_pack_rec_unpack(info, &info->bit_buff, buf,
pos, block_info.rec_len));
}
diff --git a/storage/myisam/mi_preload.c b/storage/myisam/mi_preload.c
index d52a2ea46ea..5f9132abe14 100644
--- a/storage/myisam/mi_preload.c
+++ b/storage/myisam/mi_preload.c
@@ -73,7 +73,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
length= info->preload_buff_size/block_length * block_length;
set_if_bigger(length, block_length);
- if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME))))
+ if (!(buff= (uchar *) my_malloc(mi_key_memory_preload_buffer, length,
+ MYF(MY_WME))))
DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM);
if (flush_key_blocks(share->key_cache, share->kfile, &share->dirty_part_map,
diff --git a/storage/myisam/mi_range.c b/storage/myisam/mi_range.c
index 7292f3c83b8..54350f7a111 100644
--- a/storage/myisam/mi_range.c
+++ b/storage/myisam/mi_range.c
@@ -24,9 +24,9 @@
#include "rt_index.h"
static double _mi_record_pos(MI_INFO *, const uchar *, key_part_map,
- enum ha_rkey_function);
+ enum ha_rkey_function, ulonglong *);
static double _mi_search_pos(MI_INFO *,MI_KEYDEF *,uchar *, uint,uint,
- my_off_t,my_bool);
+ my_off_t,my_bool, ulonglong *);
static uint _mi_keynr(MI_INFO *info,MI_KEYDEF *,uchar *, uchar *,uint *);
/*
@@ -48,7 +48,8 @@ static uint _mi_keynr(MI_INFO *info,MI_KEYDEF *,uchar *, uchar *,uint *);
*/
ha_rows mi_records_in_range(MI_INFO *info, int inx,
- key_range *min_key, key_range *max_key)
+ const key_range *min_key, const key_range *max_key,
+ page_range *pages)
{
ha_rows res;
double start_pos,end_pos,diff;
@@ -98,10 +99,12 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx,
case HA_KEY_ALG_BTREE:
default:
start_pos= (min_key ?_mi_record_pos(info, min_key->key,
- min_key->keypart_map, min_key->flag)
+ min_key->keypart_map, min_key->flag,
+ &pages->first_page)
: (double) 0);
end_pos= (max_key ? _mi_record_pos(info, max_key->key,
- max_key->keypart_map, max_key->flag)
+ max_key->keypart_map, max_key->flag,
+ &pages->last_page)
: (double) info->state->records);
res= (end_pos < start_pos ? (ha_rows) 0 :
(end_pos == start_pos ? (ha_rows) 1 : (ha_rows) (end_pos-start_pos)));
@@ -147,7 +150,8 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx,
static double _mi_record_pos(MI_INFO *info, const uchar *key,
key_part_map keypart_map,
- enum ha_rkey_function search_flag)
+ enum ha_rkey_function search_flag,
+ ulonglong *final_page)
{
uint inx=(uint) info->lastinx, nextflag, key_len;
MI_KEYDEF *keyinfo=info->s->keyinfo+inx;
@@ -203,7 +207,8 @@ static double _mi_record_pos(MI_INFO *info, const uchar *key,
*/
pos=_mi_search_pos(info,keyinfo,key_buff,key_len,
nextflag | SEARCH_SAVE_BUFF | SEARCH_UPDATE,
- info->s->state.key_root[inx], TRUE);
+ info->s->state.key_root[inx], TRUE,
+ final_page);
if (pos >= 0.0)
{
DBUG_PRINT("exit",("pos: %g",(pos*info->state->records)));
@@ -219,7 +224,8 @@ static double _mi_record_pos(MI_INFO *info, const uchar *key,
static double _mi_search_pos(register MI_INFO *info,
register MI_KEYDEF *keyinfo,
uchar *key, uint key_len, uint nextflag,
- register my_off_t pos, my_bool last_in_level)
+ register my_off_t pos, my_bool last_in_level,
+ ulonglong *final_page)
{
int flag;
uint nod_flag,keynr,UNINIT_VAR(max_keynr);
@@ -233,6 +239,7 @@ static double _mi_search_pos(register MI_INFO *info,
if (!(buff=_mi_fetch_keypage(info,keyinfo,pos,DFLT_INIT_HITS,info->buff,1)))
goto err;
+ *final_page= pos;
flag=(*keyinfo->bin_search)(info,keyinfo,buff,key,key_len,nextflag,
&keypos,info->lastkey, &after_key);
nod_flag=mi_test_if_nod(buff);
@@ -251,7 +258,8 @@ static double _mi_search_pos(register MI_INFO *info,
offset= 1.0;
else if ((offset=_mi_search_pos(info,keyinfo,key,key_len,nextflag,
_mi_kpos(nod_flag,keypos),
- last_in_level && after_key)) < 0)
+ last_in_level && after_key,
+ final_page)) < 0)
DBUG_RETURN(offset);
}
else
@@ -271,7 +279,8 @@ static double _mi_search_pos(register MI_INFO *info,
*/
if ((offset=_mi_search_pos(info,keyinfo,key,key_len,SEARCH_FIND,
_mi_kpos(nod_flag,keypos),
- last_in_level && after_key)) < 0)
+ last_in_level && after_key,
+ final_page)) < 0)
DBUG_RETURN(offset); /* Read error */
}
}
diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c
index 3679ea4a329..d0c3995d9de 100644
--- a/storage/myisam/mi_static.c
+++ b/storage/myisam/mi_static.c
@@ -61,6 +61,28 @@ uint myisam_readnext_vec[]=
SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_SMALLER
};
+PSI_memory_key mi_key_memory_MYISAM_SHARE;
+PSI_memory_key mi_key_memory_MI_INFO;
+PSI_memory_key mi_key_memory_MI_INFO_ft1_to_ft2;
+PSI_memory_key mi_key_memory_MI_INFO_bulk_insert;
+PSI_memory_key mi_key_memory_record_buffer;
+PSI_memory_key mi_key_memory_FTB;
+PSI_memory_key mi_key_memory_FT_INFO;
+PSI_memory_key mi_key_memory_FTPARSER_PARAM;
+PSI_memory_key mi_key_memory_ft_memroot;
+PSI_memory_key mi_key_memory_ft_stopwords;
+PSI_memory_key mi_key_memory_MI_SORT_PARAM;
+PSI_memory_key mi_key_memory_MI_SORT_PARAM_wordroot;
+PSI_memory_key mi_key_memory_SORT_FT_BUF;
+PSI_memory_key mi_key_memory_SORT_KEY_BLOCKS;
+PSI_memory_key mi_key_memory_filecopy;
+PSI_memory_key mi_key_memory_SORT_INFO_buffer;
+PSI_memory_key mi_key_memory_MI_DECODE_TREE;
+PSI_memory_key mi_key_memory_MYISAM_SHARE_decode_tables;
+PSI_memory_key mi_key_memory_preload_buffer;
+PSI_memory_key mi_key_memory_stPageList_pages;
+PSI_memory_key mi_key_memory_keycache_thread_var;
+
#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;
@@ -106,6 +128,31 @@ static PSI_thread_info all_myisam_threads[]=
{ &mi_key_thread_find_all_keys, "find_all_keys", 0},
};
+static PSI_memory_info all_myisam_memory[]=
+{
+ { &mi_key_memory_MYISAM_SHARE, "MYISAM_SHARE", 0},
+ { &mi_key_memory_MI_INFO, "MI_INFO", 0},
+ { &mi_key_memory_MI_INFO_ft1_to_ft2, "MI_INFO::ft1_to_ft2", 0},
+ { &mi_key_memory_MI_INFO_bulk_insert, "MI_INFO::bulk_insert", 0},
+ { &mi_key_memory_record_buffer, "record_buffer", 0},
+ { &mi_key_memory_FTB, "FTB", 0},
+ { &mi_key_memory_FT_INFO, "FT_INFO", 0},
+ { &mi_key_memory_FTPARSER_PARAM, "FTPARSER_PARAM", 0},
+ { &mi_key_memory_ft_memroot, "ft_memroot", 0},
+ { &mi_key_memory_ft_stopwords, "ft_stopwords", 0},
+ { &mi_key_memory_MI_SORT_PARAM, "MI_SORT_PARAM", 0},
+ { &mi_key_memory_MI_SORT_PARAM_wordroot, "MI_SORT_PARAM::wordroot", 0},
+ { &mi_key_memory_SORT_FT_BUF, "SORT_FT_BUF", 0},
+ { &mi_key_memory_SORT_KEY_BLOCKS, "SORT_KEY_BLOCKS", 0},
+ { &mi_key_memory_filecopy, "filecopy", 0},
+ { &mi_key_memory_SORT_INFO_buffer, "SORT_INFO::buffer", 0},
+ { &mi_key_memory_MI_DECODE_TREE, "MI_DECODE_TREE", 0},
+ { &mi_key_memory_MYISAM_SHARE_decode_tables, "MYISAM_SHARE::decode_tables", 0},
+ { &mi_key_memory_preload_buffer, "preload_buffer", 0},
+ { &mi_key_memory_stPageList_pages, "stPageList::pages", 0},
+ { &mi_key_memory_keycache_thread_var, "keycache_thread_var", 0}
+};
+
void init_myisam_psi_keys()
{
const char* category= "myisam";
@@ -125,6 +172,9 @@ void init_myisam_psi_keys()
count= array_elements(all_myisam_threads);
mysql_thread_register(category, all_myisam_threads, count);
+
+ count= array_elements(all_myisam_memory);
+ mysql_memory_register(category, all_myisam_memory, count);
}
#endif /* HAVE_PSI_INTERFACE */
diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c
index 6e1cbb716ba..92a9c65b232 100644
--- a/storage/myisam/mi_test1.c
+++ b/storage/myisam/mi_test1.c
@@ -1,5 +1,6 @@
/*
Copyright (c) 2000, 2011, Oracle and/or its affiliates
+ Copyright (c) 2020, MariaDB Corporation.
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
@@ -479,8 +480,7 @@ static void update_record(uchar *record)
ptr=blob_key;
memcpy(pos+4, &ptr, sizeof(char*)); /* Store pointer to new key */
if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM)
- default_charset_info->cset->casedn(default_charset_info,
- (char*) blob_key, length,
+ my_ci_casedn(default_charset_info, (char*) blob_key, length,
(char*) blob_key, length);
pos+=recinfo[1].length;
}
@@ -488,16 +488,14 @@ static void update_record(uchar *record)
{
uint pack_length= HA_VARCHAR_PACKLENGTH(recinfo[1].length-1);
uint length= pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos);
- default_charset_info->cset->casedn(default_charset_info,
- (char*) pos + pack_length, length,
+ my_ci_casedn(default_charset_info, (char*) pos + pack_length, length,
(char*) pos + pack_length, length);
pos+=recinfo[1].length;
}
else
{
if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM)
- default_charset_info->cset->casedn(default_charset_info,
- (char*) pos, keyinfo[0].seg[0].length,
+ my_ci_casedn(default_charset_info, (char*) pos, keyinfo[0].seg[0].length,
(char*) pos, keyinfo[0].seg[0].length);
pos+=recinfo[1].length;
}
@@ -590,10 +588,11 @@ static struct my_option my_long_options[] =
static my_bool
-get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
- char *argument __attribute__((unused)))
+get_one_option(const struct my_option *opt,
+ char *argument __attribute__((unused)),
+ const char *filename __attribute__((unused)))
{
- switch(optid) {
+ switch(opt->id) {
case 'a':
key_type= HA_KEYTYPE_TEXT;
break;
diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c
index 48a091e80de..4b5039eea5b 100644
--- a/storage/myisam/mi_test2.c
+++ b/storage/myisam/mi_test2.c
@@ -67,6 +67,7 @@ int main(int argc, char *argv[])
const char *filename;
char *blob_buffer;
MI_CREATE_INFO create_info;
+ page_range pages;
MY_INIT(argv[0]);
filename= "test2";
@@ -622,7 +623,8 @@ int main(int argc, char *argv[])
max_key.keypart_map= HA_WHOLE_KEY;
max_key.flag= HA_READ_AFTER_KEY;
- range_records= mi_records_in_range(file,(int) i, &min_key, &max_key);
+ range_records= mi_records_in_range(file,(int) i, &min_key, &max_key,
+ &pages);
if (range_records < info.records*8/10 ||
range_records > info.records*12/10)
{
@@ -645,6 +647,7 @@ int main(int argc, char *argv[])
if (j != 0 && k != 0)
{
key_range min_key, max_key;
+ page_range pages;
if (j > k)
swap_variables(int, j, k);
sprintf((char*) key,"%6d",j);
@@ -656,7 +659,7 @@ int main(int argc, char *argv[])
max_key.key= key2;
max_key.keypart_map= HA_WHOLE_KEY;
max_key.flag= HA_READ_BEFORE_KEY;
- range_records= mi_records_in_range(file, 0, &min_key, &max_key);
+ range_records= mi_records_in_range(file, 0, &min_key, &max_key, &pages);
records=0;
for (j++ ; j < k ; j++)
records+=key1[j];
@@ -1021,7 +1024,7 @@ static void put_blob_in_record(uchar *blob_pos, char **blob_buffer)
if (rnd(10) == 0)
{
if (! *blob_buffer &&
- !(*blob_buffer=my_malloc((uint) use_blob,MYF(MY_WME))))
+ !(*blob_buffer=my_malloc(PSI_NOT_INSTRUMENTED, use_blob,MYF(MY_WME))))
{
use_blob=0;
return;
diff --git a/storage/myisam/mi_unique.c b/storage/myisam/mi_unique.c
index 5d16efb96a1..e1d7aeaa711 100644
--- a/storage/myisam/mi_unique.c
+++ b/storage/myisam/mi_unique.c
@@ -1,5 +1,6 @@
/*
Copyright (c) 2000, 2010, Oracle and/or its affiliates
+ Copyright (c) 2020, MariaDB Corporation.
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
@@ -121,9 +122,9 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const uchar *record)
if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT1 ||
type == HA_KEYTYPE_VARTEXT2)
{
- keyseg->charset->coll->hash_sort(keyseg->charset,
- (const uchar*) pos, length, &seed1,
- &seed2);
+ my_ci_hash_sort(keyseg->charset,
+ (const uchar*) pos, length,
+ &seed1, &seed2);
crc^= seed1;
}
else
diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c
index 7345ab1604d..7d489908725 100644
--- a/storage/myisam/mi_write.c
+++ b/storage/myisam/mi_write.c
@@ -546,8 +546,10 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo,
{
/* yup. converting */
info->ft1_to_ft2=(DYNAMIC_ARRAY *)
- my_malloc(sizeof(DYNAMIC_ARRAY), MYF(MY_WME));
- my_init_dynamic_array(info->ft1_to_ft2, ft2len, 300, 50, MYF(0));
+ my_malloc(mi_key_memory_MI_INFO_ft1_to_ft2,
+ sizeof(DYNAMIC_ARRAY), MYF(MY_WME));
+ my_init_dynamic_array(mi_key_memory_MI_INFO_ft1_to_ft2,
+ info->ft1_to_ft2, ft2len, 300, 50, MYF(0));
/*
now, adding all keys from the page to dynarray
@@ -998,7 +1000,8 @@ int mi_init_bulk_insert(MI_INFO *info, size_t cache_size, ha_rows rows)
cache_size/=total_keylength*16;
info->bulk_insert=(TREE *)
- my_malloc((sizeof(TREE)*share->base.keys+
+ my_malloc(mi_key_memory_MI_INFO_bulk_insert,
+ (sizeof(TREE)*share->base.keys+
sizeof(bulk_insert_param)*num_keys),MYF(0));
if (!info->bulk_insert)
diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c
index 7ced701ed5b..63f40daad5c 100644
--- a/storage/myisam/myisam_ftdump.c
+++ b/storage/myisam/myisam_ftdump.c
@@ -22,7 +22,7 @@
static void usage();
static void complain(int val);
-static my_bool get_one_option(int, const struct my_option *, char *);
+static my_bool get_one_option(const struct my_option *, char *, const char *);
static int count=0, stats=0, dump=0, lstats=0;
static my_bool verbose;
@@ -228,10 +228,11 @@ err:
static my_bool
-get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
- char *argument __attribute__((unused)))
+get_one_option(const struct my_option *opt,
+ char *argument __attribute__((unused)),
+ const char *filename __attribute__((unused)))
{
- switch(optid) {
+ switch(opt->id) {
case 'd':
dump=1;
complain(count || query);
diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c
index f616a9f9b1a..10d4987e1cb 100644
--- a/storage/myisam/myisamchk.c
+++ b/storage/myisam/myisamchk.c
@@ -470,11 +470,10 @@ TYPELIB myisam_stats_method_typelib= {
/* Read options */
static my_bool
-get_one_option(int optid,
- const struct my_option *opt __attribute__((unused)),
- char *argument)
+get_one_option(const struct my_option *opt,
+ char *argument, const char *filename __attribute__((unused)))
{
- switch (optid) {
+ switch (opt->id) {
case 'a':
if (argument == disabled_my_option)
check_param.testflag&= ~T_STATISTICS;
@@ -798,7 +797,7 @@ static void get_options(register int *argc,register char ***argv)
MYF(MY_WME))))
exit(1);
- myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size);
+ myisam_block_size=(uint) 1 << my_bit_log2_uint64(opt_myisam_block_size);
return;
} /* get options */
@@ -1428,20 +1427,25 @@ static void descript(HA_CHECK *param, register MI_INFO *info, char * name)
else
type=(enum en_fieldtype) share->rec[field].type;
end=strmov(buff,field_pack[type]);
+ if (end != buff)
+ {
+ *(end++)=',';
+ *(end++)=' ';
+ }
if (share->options & HA_OPTION_COMPRESS_RECORD)
{
if (share->rec[field].pack_type & PACK_TYPE_SELECTED)
- end=strmov(end,", not_always");
+ end=strmov(end,"not_always, ");
if (share->rec[field].pack_type & PACK_TYPE_SPACE_FIELDS)
- end=strmov(end,", no empty");
+ end=strmov(end,"no empty, ");
if (share->rec[field].pack_type & PACK_TYPE_ZERO_FILL)
{
- sprintf(end,", zerofill(%d)",share->rec[field].space_length_bits);
+ sprintf(end,"zerofill(%d), ",share->rec[field].space_length_bits);
end=strend(end);
}
}
- if (buff[0] == ',')
- strmov(buff,buff+2);
+ if (end != buff)
+ end[-2]= 0; /* Remove ", " */
int10_to_str((long) share->rec[field].length,length,10);
null_bit[0]=null_pos[0]=0;
if (share->rec[field].null_bit)
diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h
index 06de992d6de..f48d1078000 100644
--- a/storage/myisam/myisamdef.h
+++ b/storage/myisam/myisamdef.h
@@ -234,11 +234,11 @@ typedef struct st_mi_isam_share
struct st_myisam_info
{
- MYISAM_SHARE *s; /* Shared between open:s */
+ MYISAM_SHARE *s; /* Shared between opens */
MI_STATUS_INFO *state, save_state;
MI_BLOB *blobs; /* Pointer to blobs */
MI_BIT_BUFF bit_buff;
- /* accumulate indexfile changes between write's */
+ /* accumulate indexfile changes between writes */
TREE *bulk_insert;
DYNAMIC_ARRAY *ft1_to_ft2; /* used only in ft1->ft2 conversion */
MEM_ROOT ft_memroot; /* used by the parser */
@@ -256,7 +256,7 @@ struct st_myisam_info
uint32 int_keytree_version; /* -""- */
int (*read_record)(struct st_myisam_info*, my_off_t, uchar*);
invalidator_by_filename invalidator; /* query cache invalidator */
- ulong this_unique; /* uniq filenumber or thread */
+ ulong this_unique; /* unique filenumber or thread */
ulong last_unique; /* last unique number */
ulong this_loop; /* counter for this open */
ulong last_loop; /* last used counter */
@@ -269,7 +269,7 @@ struct st_myisam_info
my_off_t dupp_key_pos;
ha_checksum checksum; /* Temp storage for row checksum */
/*
- QQ: the folloing two xxx_length fields should be removed,
+ QQ: the following two xxx_length fields should be removed,
as they are not compatible with parallel repair
*/
ulong packed_length, blob_length; /* Length of found, packed record */
@@ -612,7 +612,24 @@ typedef struct st_mi_block_info /* Parameter to _mi_get_block_info */
uint offset;
} MI_BLOCK_INFO;
- /* bits in return from _mi_get_block_info */
+
+typedef struct st_sort_key_blocks /* Used when sorting */
+{
+ uchar *buff, *end_pos;
+ uchar lastkey[HA_MAX_POSSIBLE_KEY_BUFF];
+ uint last_length;
+ int inited;
+} SORT_KEY_BLOCKS;
+
+
+typedef struct st_sort_ftbuf
+{
+ uchar *buf, *end;
+ int count;
+ uchar lastkey[HA_MAX_KEY_BUFF];
+} SORT_FT_BUF;
+
+/* bits in return from _mi_get_block_info */
#define BLOCK_FIRST 1U
#define BLOCK_LAST 2U
@@ -709,7 +726,7 @@ int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def,
const uchar *record, my_off_t pos);
int mi_unique_comp(MI_UNIQUEDEF *def, const uchar *a, const uchar *b,
my_bool null_are_equal);
-void mi_get_status(void *param, my_bool concurrent_insert);
+my_bool mi_get_status(void *param, my_bool concurrent_insert);
void mi_update_status(void *param);
void mi_restore_status(void *param);
void mi_copy_status(void *to, void *from);
@@ -757,6 +774,30 @@ extern PSI_file_key mi_key_file_datatmp, mi_key_file_dfile, mi_key_file_kfile,
extern PSI_thread_key mi_key_thread_find_all_keys;
void init_myisam_psi_keys();
+#else
+#define init_myisam_psi_keys() do { } while(0)
#endif /* HAVE_PSI_INTERFACE */
+extern PSI_memory_key mi_key_memory_MYISAM_SHARE;
+extern PSI_memory_key mi_key_memory_MI_INFO;
+extern PSI_memory_key mi_key_memory_MI_INFO_ft1_to_ft2;
+extern PSI_memory_key mi_key_memory_MI_INFO_bulk_insert;
+extern PSI_memory_key mi_key_memory_record_buffer;
+extern PSI_memory_key mi_key_memory_FTB;
+extern PSI_memory_key mi_key_memory_FT_INFO;
+extern PSI_memory_key mi_key_memory_FTPARSER_PARAM;
+extern PSI_memory_key mi_key_memory_ft_memroot;
+extern PSI_memory_key mi_key_memory_ft_stopwords;
+extern PSI_memory_key mi_key_memory_MI_SORT_PARAM;
+extern PSI_memory_key mi_key_memory_MI_SORT_PARAM_wordroot;
+extern PSI_memory_key mi_key_memory_SORT_FT_BUF;
+extern PSI_memory_key mi_key_memory_SORT_KEY_BLOCKS;
+extern PSI_memory_key mi_key_memory_filecopy;
+extern PSI_memory_key mi_key_memory_SORT_INFO_buffer;
+extern PSI_memory_key mi_key_memory_MI_DECODE_TREE;
+extern PSI_memory_key mi_key_memory_MYISAM_SHARE_decode_tables;
+extern PSI_memory_key mi_key_memory_preload_buffer;
+extern PSI_memory_key mi_key_memory_stPageList_pages;
+extern PSI_memory_key mi_key_memory_keycache_thread_var;
+
C_MODE_END
diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c
index 9bef2be929f..40d473dc532 100644
--- a/storage/myisam/myisamlog.c
+++ b/storage/myisam/myisamlog.c
@@ -422,7 +422,7 @@ static int examine_log(char * file_name, char **table_names)
* The additional space is needed for the sprintf commands two lines
* below.
*/
- file_info.show_name=my_memdup(isam_file_name,
+ file_info.show_name=my_memdup(PSI_NOT_INSTRUMENTED, isam_file_name,
(uint) strlen(isam_file_name)+10,
MYF(MY_WME));
if (file_info.id > 1)
@@ -451,8 +451,8 @@ static int examine_log(char * file_name, char **table_names)
if (!(file_info.isam= mi_open(isam_file_name,O_RDWR,
HA_OPEN_WAIT_IF_LOCKED)))
goto com_err;
- if (!(file_info.record=my_malloc(file_info.isam->s->base.reclength,
- MYF(MY_WME))))
+ if (!(file_info.record=my_malloc(PSI_NOT_INSTRUMENTED,
+ file_info.isam->s->base.reclength, MYF(MY_WME))))
goto end;
files_open++;
file_info.closed=0;
@@ -683,7 +683,7 @@ static int read_string(IO_CACHE *file, register uchar* *to, register uint length
if (*to)
my_free(*to);
- if (!(*to= (uchar*) my_malloc(length+1,MYF(MY_WME))) ||
+ if (!(*to= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, length+1,MYF(MY_WME))) ||
my_b_read(file,(uchar*) *to,length))
{
if (*to)
diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c
index ba6744ae815..1267ddc724d 100644
--- a/storage/myisam/myisampack.c
+++ b/storage/myisam/myisampack.c
@@ -316,12 +316,12 @@ static void usage(void)
static my_bool
-get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
- char *argument)
+get_one_option(const struct my_option *opt,
+ char *argument, const char *filename __attribute__((unused)))
{
uint length;
- switch(optid) {
+ switch(opt->id) {
case 'f':
force_pack= 1;
tmpfile_createflag= O_RDWR | O_TRUNC;
@@ -439,7 +439,7 @@ static my_bool open_isam_files(PACK_MRG_INFO *mrg, char **names, uint count)
uint i,j;
mrg->count=0;
mrg->current=0;
- mrg->file=(MI_INFO**) my_malloc(sizeof(MI_INFO*)*count,MYF(MY_FAE));
+ mrg->file=(MI_INFO**) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(MI_INFO*)*count,MYF(MY_FAE));
mrg->free_file=1;
mrg->src_file_has_indexes_disabled= 0;
for (i=0; i < count ; i++)
@@ -518,7 +518,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
< 0)
goto err;
length=(uint) share->base.keystart;
- if (!(buff= (uchar*) my_malloc(length,MYF(MY_WME))))
+ if (!(buff= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, length,MYF(MY_WME))))
goto err;
if (my_pread(share->kfile,buff,length,0L,MYF(MY_WME | MY_NABP)) ||
my_write(join_isam_file,buff,length,
@@ -798,7 +798,7 @@ static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records)
{
reg2 uint i;
reg1 HUFF_COUNTS *count;
- if ((count = (HUFF_COUNTS*) my_malloc(info->s->base.fields*
+ if ((count = (HUFF_COUNTS*) my_malloc(PSI_NOT_INSTRUMENTED, info->s->base.fields*
sizeof(HUFF_COUNTS),
MYF(MY_ZEROFILL | MY_WME))))
{
@@ -825,7 +825,7 @@ static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records)
NULL, MYF(0));
if (records && type != FIELD_BLOB && type != FIELD_VARCHAR)
count[i].tree_pos=count[i].tree_buff =
- my_malloc(count[i].field_length > 1 ? tree_buff_length : 2,
+ my_malloc(PSI_NOT_INSTRUMENTED, count[i].field_length > 1 ? tree_buff_length : 2,
MYF(MY_WME));
}
}
@@ -1476,7 +1476,7 @@ static HUFF_TREE* make_huff_trees(HUFF_COUNTS *huff_counts, uint trees)
HUFF_TREE *huff_tree;
DBUG_ENTER("make_huff_trees");
- if (!(huff_tree=(HUFF_TREE*) my_malloc(trees*sizeof(HUFF_TREE),
+ if (!(huff_tree=(HUFF_TREE*) my_malloc(PSI_NOT_INSTRUMENTED, trees*sizeof(HUFF_TREE),
MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(0);
@@ -1554,14 +1554,14 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts)
if (!huff_tree->element_buffer)
{
if (!(huff_tree->element_buffer=
- (HUFF_ELEMENT*) my_malloc(found*2*sizeof(HUFF_ELEMENT),MYF(MY_WME))))
+ (HUFF_ELEMENT*) my_malloc(PSI_NOT_INSTRUMENTED, found*2*sizeof(HUFF_ELEMENT),MYF(MY_WME))))
return 1;
}
else
{
HUFF_ELEMENT *temp;
if (!(temp=
- (HUFF_ELEMENT*) my_realloc((uchar*) huff_tree->element_buffer,
+ (HUFF_ELEMENT*) my_realloc(PSI_NOT_INSTRUMENTED, (uchar*) huff_tree->element_buffer,
found*2*sizeof(HUFF_ELEMENT),
MYF(MY_WME))))
return 1;
@@ -1930,7 +1930,7 @@ static int make_huff_decode_table(HUFF_TREE *huff_tree, uint trees)
{
elements=huff_tree->counts->tree_buff ? huff_tree->elements : 256;
if (!(huff_tree->code =
- (ulonglong*) my_malloc(elements*
+ (ulonglong*) my_malloc(PSI_NOT_INSTRUMENTED, elements*
(sizeof(ulonglong) + sizeof(uchar)),
MYF(MY_WME | MY_ZEROFILL))))
return 1;
@@ -2823,7 +2823,7 @@ static char *make_old_name(char *new_name, char *old_name)
static void init_file_buffer(File file, pbool read_buffer)
{
file_buffer.file=file;
- file_buffer.buffer= (uchar*) my_malloc(ALIGN_SIZE(RECORD_CACHE_SIZE),
+ file_buffer.buffer= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, ALIGN_SIZE(RECORD_CACHE_SIZE),
MYF(MY_WME));
file_buffer.end=file_buffer.buffer+ALIGN_SIZE(RECORD_CACHE_SIZE)-8;
file_buffer.pos_in_file=0;
@@ -2880,7 +2880,7 @@ static int flush_buffer(ulong neaded_length)
{
char *tmp;
neaded_length+=256; /* some margin */
- tmp= my_realloc((char*) file_buffer.buffer, neaded_length,MYF(MY_WME));
+ tmp= my_realloc(PSI_NOT_INSTRUMENTED, (char*) file_buffer.buffer, neaded_length,MYF(MY_WME));
if (!tmp)
return 1;
file_buffer.pos= ((uchar*) tmp +
diff --git a/storage/myisam/rt_index.c b/storage/myisam/rt_index.c
index 08543ec2b22..651e2e79478 100644
--- a/storage/myisam/rt_index.c
+++ b/storage/myisam/rt_index.c
@@ -733,8 +733,11 @@ static int rtree_fill_reinsert_list(stPageList *ReinsertList, my_off_t page,
if (ReinsertList->n_pages == ReinsertList->m_pages)
{
ReinsertList->m_pages += REINSERT_BUFFER_INC;
- if (!(ReinsertList->pages = (stPageLevel*)my_realloc((uchar*)ReinsertList->pages,
- ReinsertList->m_pages * sizeof(stPageLevel), MYF(MY_ALLOW_ZERO_PTR))))
+ if (!(ReinsertList->pages = (stPageLevel*)
+ my_realloc(mi_key_memory_stPageList_pages,
+ (uchar*)ReinsertList->pages,
+ ReinsertList->m_pages * sizeof(stPageLevel),
+ MYF(MY_ALLOW_ZERO_PTR))))
goto err1;
}
/* save page to ReinsertList */
diff --git a/storage/myisam/rt_test.c b/storage/myisam/rt_test.c
index 353e20951cd..11e824a8893 100644
--- a/storage/myisam/rt_test.c
+++ b/storage/myisam/rt_test.c
@@ -113,6 +113,7 @@ static int run_test(const char *filename)
uchar read_record[MAX_REC_LENGTH];
int upd= 10;
ha_rows hrows;
+ page_range pages;
bzero(&uniquedef, sizeof(uniquedef));
bzero(&create_info, sizeof(create_info));
@@ -335,7 +336,7 @@ static int run_test(const char *filename)
range.key= record+1;
range.length= 1000; /* Big enough */
range.flag= HA_READ_MBR_INTERSECT;
- hrows= mi_records_in_range(file, 0, &range, (key_range*) 0);
+ hrows= mi_records_in_range(file, 0, &range, (key_range*) 0, &pages);
printf(" %ld rows\n", (long) hrows);
if (mi_close(file)) goto err;
diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c
index e586543363b..6fe38a3fd04 100644
--- a/storage/myisam/sort.c
+++ b/storage/myisam/sort.c
@@ -190,11 +190,12 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
}
if ((sort_keys= ((uchar **)
- my_malloc((size_t) (keys*(sort_length+sizeof(char*))+
+ my_malloc(PSI_INSTRUMENT_ME,
+ (size_t) (keys*(sort_length+sizeof(char*))+
HA_FT_MAXBYTELEN), MYF(0)))))
{
- if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer,
- MY_MIN(maxbuffer/2, 1000), MYF(0)))
+ if (my_init_dynamic_array(PSI_INSTRUMENT_ME, &buffpek, sizeof(BUFFPEK),
+ maxbuffer, MY_MIN(maxbuffer/2, 1000), MYF(0)))
{
my_free(sort_keys);
sort_keys= 0;
@@ -406,12 +407,14 @@ static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param)
}
while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org);
}
- if ((sort_keys= (uchar**) my_malloc((size_t)(keys * (sort_length + sizeof(char*)) +
+ if ((sort_keys= (uchar**) my_malloc(PSI_INSTRUMENT_ME,
+ (size_t)(keys * (sort_length + sizeof(char*)) +
((sort_param->keyinfo->flag & HA_FULLTEXT) ?
HA_FT_MAXBYTELEN : 0)), MYF(0))))
{
- if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
- maxbuffer, MY_MIN(maxbuffer / 2, 1000), MYF(0)))
+ if (my_init_dynamic_array(PSI_INSTRUMENT_ME, &sort_param->buffpek,
+ sizeof(BUFFPEK), maxbuffer,
+ MY_MIN(maxbuffer / 2, 1000), MYF(0)))
{
my_free(sort_keys);
sort_keys= NULL; /* Safety against double free on error. */
@@ -607,7 +610,8 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
length=param->sort_buffer_length;
while (length >= MIN_SORT_BUFFER)
{
- if ((mergebuf= my_malloc((size_t) length, MYF(0))))
+ if ((mergebuf= my_malloc(PSI_INSTRUMENT_ME,
+ (size_t) length, MYF(0))))
break;
length=length*3/4;
}
diff --git a/storage/myisam/sp_test.c b/storage/myisam/sp_test.c
index 368c9dc2d5a..a33a6c8e743 100644
--- a/storage/myisam/sp_test.c
+++ b/storage/myisam/sp_test.c
@@ -70,6 +70,7 @@ int run_test(const char *filename)
uchar read_record[MAX_REC_LENGTH];
int upd=10;
ha_rows hrows;
+ page_range pages;
/* Define a column for NULLs and DEL markers*/
@@ -256,7 +257,7 @@ int run_test(const char *filename)
max_range.key= record+1;
max_range.length= 1000; /* Big enough */
max_range.flag= HA_READ_KEY_EXACT;
- hrows= mi_records_in_range(file, 0, &min_range, &max_range);
+ hrows= mi_records_in_range(file, 0, &min_range, &max_range, &pages);
printf(" %ld rows\n", (long) hrows);
if (mi_close(file)) goto err;