summaryrefslogtreecommitdiff
path: root/storage/myisam
diff options
context:
space:
mode:
Diffstat (limited to 'storage/myisam')
-rw-r--r--[-rwxr-xr-x]storage/myisam/CMakeLists.txt14
-rw-r--r--storage/myisam/ft_boolean_search.c21
-rw-r--r--storage/myisam/ha_myisam.cc104
-rw-r--r--storage/myisam/ha_myisam.h1
-rw-r--r--storage/myisam/mi_close.c7
-rw-r--r--storage/myisam/mi_delete.c6
-rw-r--r--storage/myisam/mi_dynrec.c6
-rw-r--r--storage/myisam/mi_open.c3
-rw-r--r--storage/myisam/mi_packrec.c16
-rw-r--r--storage/myisam/mi_write.c9
-rw-r--r--storage/myisam/myisamchk.c12
11 files changed, 147 insertions, 52 deletions
diff --git a/storage/myisam/CMakeLists.txt b/storage/myisam/CMakeLists.txt
index f4449f445b2..1a667e271af 100755..100644
--- a/storage/myisam/CMakeLists.txt
+++ b/storage/myisam/CMakeLists.txt
@@ -12,16 +12,12 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
- ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/extra/yassl/include)
-
SET(MYISAM_SOURCES ft_boolean_search.c ft_nlq_search.c ft_parser.c ft_static.c ft_stem.c
ha_myisam.cc
ft_myisam.c
@@ -35,11 +31,9 @@ SET(MYISAM_SOURCES ft_boolean_search.c ft_nlq_search.c ft_parser.c ft_static.c
mi_unique.c mi_update.c mi_write.c rt_index.c rt_key.c rt_mbr.c
rt_split.c sort.c sp_key.c ft_eval.h myisamdef.h rt_index.h mi_rkey.c)
-IF(NOT SOURCE_SUBLIBS)
-
- ADD_LIBRARY(myisam ${MYISAM_SOURCES})
- ADD_DEPENDENCIES(myisam GenError)
+MYSQL_STORAGE_ENGINE(MYISAM)
+IF(NOT SOURCE_SUBLIBS)
ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c)
TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys debug dbug strings zlib wsock32)
@@ -67,6 +61,8 @@ IF(NOT SOURCE_SUBLIBS)
ADD_EXECUTABLE(rt_test rt_test.c)
TARGET_LINK_LIBRARIES(rt_test myisam mysys debug dbug strings zlib wsock32)
+ SET_TARGET_PROPERTIES(myisamchk myisampack PROPERTIES LINK_FLAGS "setargv.obj")
+
IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("myisam_ftdump" "asInvoker")
MYSQL_EMBED_MANIFEST("myisamchk" "asInvoker")
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c
index 274f91e2691..20ead971afd 100644
--- a/storage/myisam/ft_boolean_search.c
+++ b/storage/myisam/ft_boolean_search.c
@@ -335,7 +335,23 @@ static int _ftb_no_dupes_cmp(void* not_used __attribute__((unused)),
return CMP_NUM((*((my_off_t*)a)), (*((my_off_t*)b)));
}
-/* returns 1 if the search was finished (must-word wasn't found) */
+/*
+ When performing prefix search (a word with truncation operator), we
+ must preserve original prefix to ensure that characters which may be
+ expanded/contracted do not break the prefix. This is done by storing
+ newly found key immediatly after the original word in ftbw->word
+ buffer.
+
+ ftbw->word= LENGTH WORD [ LENGTH1 WORD1 ] WEIGHT REFERENCE
+ LENGTH - 1 byte, length of the WORD
+ WORD - LENGTH bytes, the word itself
+ LENGTH1 - 1 byte, length of the WORD1, present in case of prefix search
+ WORD1 - LENGTH bytes, the word itself, present in case of prefix search
+ WEIGHT - 4 bytes (HA_FT_WLEN), either weight or number of subkeys
+ REFERENCE - rec_reflength bytes, pointer to the record
+
+ returns 1 if the search was finished (must-word wasn't found)
+*/
static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search)
{
int r;
@@ -369,7 +385,8 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search)
if (ftbw->docid[0] < max_docid)
{
sflag|= SEARCH_SAME;
- _mi_dpointer(info, (uchar *)(ftbw->word + ftbw->len + HA_FT_WLEN),
+ _mi_dpointer(info, (uchar*) (lastkey_buf + HA_FT_WLEN +
+ (ftbw->off ? 0 : lastkey_buf[0] + 1)),
max_docid);
}
r=_mi_search(info, ftbw->keyinfo, (uchar*) lastkey_buf,
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 160e6dfed6c..ea9ba7012c3 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -43,6 +43,28 @@ TYPELIB myisam_stats_method_typelib= {
array_elements(myisam_stats_method_names) - 1, "",
myisam_stats_method_names, NULL};
+#ifndef DBUG_OFF
+/**
+ Causes the thread to wait in a spin lock for a query kill signal.
+ This function is used by the test frame work to identify race conditions.
+
+ The signal is caught and ignored and the thread is not killed.
+*/
+
+static void debug_wait_for_kill(const char *info)
+{
+ DBUG_ENTER("debug_wait_for_kill");
+ const char *prev_info;
+ THD *thd;
+ thd= current_thd;
+ prev_info= thd_proc_info(thd, info);
+ while(!thd->killed)
+ my_sleep(1000);
+ DBUG_PRINT("info", ("Exit debug_wait_for_kill"));
+ thd_proc_info(thd, prev_info);
+ DBUG_VOID_RETURN;
+}
+#endif
/*****************************************************************************
** MyISAM tables
@@ -73,7 +95,7 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type,
if (!thd->vio_ok())
{
- sql_print_error(msgbuf);
+ sql_print_error("%s", msgbuf);
return;
}
@@ -316,6 +338,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
t2_keys in Number of keys in second table
t2_recs in Number of records in second table
strict in Strict check switch
+ table in handle to the table object
DESCRIPTION
This function compares two MyISAM definitions. By intention it was done
@@ -331,6 +354,10 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
Otherwise 'strict' flag must be set to 1 and it is not required to pass
converted dot-frm definition as t1_*.
+ For compatibility reasons we relax some checks, specifically:
+ - 4.0 (and earlier versions) always set key_alg to 0.
+ - 4.0 (and earlier versions) have the same language for all keysegs.
+
RETURN VALUE
0 - Equal definitions.
1 - Different definitions.
@@ -345,10 +372,11 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
uint t1_keys, uint t1_recs,
MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo,
- uint t2_keys, uint t2_recs, bool strict)
+ uint t2_keys, uint t2_recs, bool strict, TABLE *table_arg)
{
uint i, j;
DBUG_ENTER("check_definition");
+ my_bool mysql_40_compat= table_arg && table_arg->s->frm_version < FRM_VER_TRUE_VARCHAR;
if ((strict ? t1_keys != t2_keys : t1_keys > t2_keys))
{
DBUG_PRINT("error", ("Number of keys differs: t1_keys=%u, t2_keys=%u",
@@ -387,8 +415,9 @@ int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
test(t2_keyinfo[i].flag & HA_SPATIAL)));
DBUG_RETURN(1);
}
- if (t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs ||
- t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg)
+ if ((!mysql_40_compat &&
+ t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg) ||
+ t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs)
{
DBUG_PRINT("error", ("Key %d has different definition", i));
DBUG_PRINT("error", ("t1_keysegs=%d, t1_key_alg=%d",
@@ -418,8 +447,9 @@ int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
t1_keysegs_j__type= HA_KEYTYPE_VARBINARY1; /* purecov: inspected */
}
- if (t1_keysegs_j__type != t2_keysegs[j].type ||
- t1_keysegs[j].language != t2_keysegs[j].language ||
+ if ((!mysql_40_compat &&
+ t1_keysegs[j].language != t2_keysegs[j].language) ||
+ t1_keysegs_j__type != t2_keysegs[j].type ||
t1_keysegs[j].null_bit != t2_keysegs[j].null_bit ||
t1_keysegs[j].length != t2_keysegs[j].length)
{
@@ -672,7 +702,8 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked)
}
if (check_definition(keyinfo, recinfo, table->s->keys, recs,
file->s->keyinfo, file->s->rec,
- file->s->base.keys, file->s->base.fields, true))
+ file->s->base.keys, file->s->base.fields,
+ true, table))
{
/* purecov: begin inspected */
my_errno= HA_ERR_CRASHED;
@@ -1103,6 +1134,9 @@ int ha_myisam::repair(THD *thd, HA_CHECK &param, bool do_optimize)
param.out_flag= 0;
strmov(fixed_name,file->filename);
+ // Release latches since this can take a long time
+ ha_release_temporary_latches(thd);
+
// Don't lock tables if we have used LOCK TABLE
if (!thd->locked_tables &&
mi_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK))
@@ -1408,6 +1442,9 @@ int ha_myisam::enable_indexes(uint mode)
{
int error;
+ DBUG_EXECUTE_IF("wait_in_enable_indexes",
+ debug_wait_for_kill("wait_in_enable_indexes"); );
+
if (mi_is_all_keys_active(file->s->state.key_map, file->s->base.keys))
{
/* All indexes are enabled already. */
@@ -1522,8 +1559,9 @@ void ha_myisam::start_bulk_insert(ha_rows rows)
/*
Only disable old index if the table was empty and we are inserting
a lot of rows.
- We should not do this for only a few rows as this is slower and
- we don't want to update the key statistics based of only a few rows.
+ Note that in end_bulk_insert() we may truncate the table if
+ enable_indexes() failed, thus it's essential that indexes are
+ disabled ONLY for an empty table.
*/
if (file->state->records == 0 && can_enable_indexes &&
(!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES))
@@ -1555,8 +1593,27 @@ int ha_myisam::end_bulk_insert(bool abort)
{
mi_end_bulk_insert(file);
int err=mi_extra(file, HA_EXTRA_NO_CACHE, 0);
- return (err || abort ? err : can_enable_indexes ?
- enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE) : 0);
+ if (!err && !abort)
+ {
+ if (can_enable_indexes)
+ {
+ /*
+ Truncate the table when enable index operation is killed.
+ After truncating the table we don't need to enable the
+ indexes, because the last repair operation is aborted after
+ setting the indexes as active and trying to recreate them.
+ */
+
+ if (((err= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE)) != 0) &&
+ current_thd->killed)
+ {
+ delete_all_rows();
+ /* not crashed, despite being killed during repair */
+ file->s->state.changed&= ~(STATE_CRASHED|STATE_CRASHED_ON_REPAIR);
+ }
+ }
+ }
+ return err;
}
@@ -1578,10 +1635,8 @@ bool ha_myisam::check_and_repair(THD *thd)
old_query= thd->query;
old_query_length= thd->query_length;
- pthread_mutex_lock(&LOCK_thread_count);
- thd->query= table->s->table_name.str;
- thd->query_length= (uint) table->s->table_name.length;
- pthread_mutex_unlock(&LOCK_thread_count);
+ thd->set_query(table->s->table_name.str,
+ (uint) table->s->table_name.length);
if ((marked_crashed= mi_is_crashed(file)) || check(thd, &check_opt))
{
@@ -1594,10 +1649,7 @@ bool ha_myisam::check_and_repair(THD *thd)
if (repair(thd, &check_opt))
error=1;
}
- pthread_mutex_lock(&LOCK_thread_count);
- thd->query= old_query;
- thd->query_length= old_query_length;
- pthread_mutex_unlock(&LOCK_thread_count);
+ thd->set_query(old_query, old_query_length);
DBUG_RETURN(error);
}
@@ -1759,7 +1811,7 @@ int ha_myisam::info(uint flag)
stats.data_file_length= misam_info.data_file_length;
stats.index_file_length= misam_info.index_file_length;
stats.delete_length= misam_info.delete_length;
- stats.check_time= misam_info.check_time;
+ stats.check_time= (ulong) misam_info.check_time;
stats.mean_rec_length= misam_info.mean_reclength;
}
if (flag & HA_STATUS_CONST)
@@ -1767,7 +1819,7 @@ int ha_myisam::info(uint flag)
TABLE_SHARE *share= table->s;
stats.max_data_file_length= misam_info.max_data_file_length;
stats.max_index_file_length= misam_info.max_index_file_length;
- stats.create_time= misam_info.create_time;
+ stats.create_time= (ulong) misam_info.create_time;
ref_length= misam_info.reflength;
share->db_options_in_use= misam_info.options;
stats.block_size= myisam_block_size; /* record block size */
@@ -1782,7 +1834,7 @@ int ha_myisam::info(uint flag)
if (share->key_parts)
memcpy((char*) table->key_info[0].rec_per_key,
(char*) misam_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0])*share->key_parts);
+ sizeof(table->key_info[0].rec_per_key[0])*share->key_parts);
if (share->tmp_table == NO_TMP_TABLE)
pthread_mutex_unlock(&share->mutex);
@@ -1806,7 +1858,7 @@ int ha_myisam::info(uint flag)
my_store_ptr(dup_ref, ref_length, misam_info.dupp_key_pos);
}
if (flag & HA_STATUS_TIME)
- stats.update_time = misam_info.update_time;
+ stats.update_time = (ulong) misam_info.update_time;
if (flag & HA_STATUS_AUTO)
stats.auto_increment_value= misam_info.auto_increment;
@@ -1842,6 +1894,12 @@ int ha_myisam::delete_all_rows()
return mi_delete_all_rows(file);
}
+int ha_myisam::reset_auto_increment(ulonglong value)
+{
+ file->s->state.auto_increment= value;
+ return 0;
+}
+
int ha_myisam::delete_table(const char *name)
{
return mi_delete_table(name);
diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h
index 62792a10a20..1b7e948b928 100644
--- a/storage/myisam/ha_myisam.h
+++ b/storage/myisam/ha_myisam.h
@@ -103,6 +103,7 @@ class ha_myisam: public handler
int reset(void);
int external_lock(THD *thd, int lock_type);
int delete_all_rows(void);
+ int reset_auto_increment(ulonglong value);
int disable_indexes(uint mode);
int enable_indexes(uint mode);
int indexes_are_disabled(void);
diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c
index 747555dbdfb..3d860bbead6 100644
--- a/storage/myisam/mi_close.c
+++ b/storage/myisam/mi_close.c
@@ -35,9 +35,6 @@ int mi_close(register MI_INFO *info)
if (info->lock_type == F_EXTRA_LCK)
info->lock_type=F_UNLCK; /* HA_EXTRA_NO_USER_CHANGE */
- if (share->reopen == 1 && share->kfile >= 0)
- _mi_decrement_open_count(info);
-
if (info->lock_type != F_UNLCK)
{
if (mi_lock_database(info,F_UNLCK))
@@ -63,6 +60,8 @@ int mi_close(register MI_INFO *info)
my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR));
if (flag)
{
+ DBUG_EXECUTE_IF("crash_before_flush_keys",
+ if (share->kfile >= 0) abort(););
if (share->kfile >= 0 &&
flush_key_blocks(share->key_cache, share->kfile,
share->temporary ? FLUSH_IGNORE_CHANGED :
@@ -79,6 +78,8 @@ int mi_close(register MI_INFO *info)
*/
if (share->mode != O_RDONLY && mi_is_crashed(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)))
error = my_errno;
}
diff --git a/storage/myisam/mi_delete.c b/storage/myisam/mi_delete.c
index 8ebdb477183..bda4b31064e 100644
--- a/storage/myisam/mi_delete.c
+++ b/storage/myisam/mi_delete.c
@@ -251,7 +251,11 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
if (info->ft1_to_ft2)
{
/* we're in ft1->ft2 conversion mode. Saving key data */
- insert_dynamic(info->ft1_to_ft2, (lastkey+off));
+ if (insert_dynamic(info->ft1_to_ft2, (lastkey+off)))
+ {
+ DBUG_PRINT("error",("Out of memory"));
+ DBUG_RETURN(-1);
+ }
}
else
{
diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c
index 3a5956abb7e..d2ff91a45f3 100644
--- a/storage/myisam/mi_dynrec.c
+++ b/storage/myisam/mi_dynrec.c
@@ -66,7 +66,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
my_bool mi_dynmap_file(MI_INFO *info, my_off_t size)
{
DBUG_ENTER("mi_dynmap_file");
- if (size > (my_off_t) (~((size_t) 0)) - MEMMAP_EXTRA_MARGIN)
+ if (size > (my_off_t) (~((size_t) 0)))
{
DBUG_PRINT("warning", ("File is too large for mmap"));
DBUG_RETURN(1);
@@ -80,7 +80,7 @@ my_bool mi_dynmap_file(MI_INFO *info, my_off_t size)
upon a write if no physical memory is available.
*/
info->s->file_map= (uchar*)
- my_mmap(0, (size_t)(size + MEMMAP_EXTRA_MARGIN),
+ my_mmap(0, (size_t) size,
info->s->mode==O_RDONLY ? PROT_READ :
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_NORESERVE,
@@ -113,7 +113,7 @@ void mi_remap_file(MI_INFO *info, my_off_t size)
if (info->s->file_map)
{
VOID(my_munmap((char*) info->s->file_map,
- (size_t) info->s->mmaped_length + MEMMAP_EXTRA_MARGIN));
+ (size_t) info->s->mmaped_length));
mi_dynmap_file(info, size);
}
}
diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c
index d569c7dd5c8..34bc67ee95b 100644
--- a/storage/myisam/mi_open.c
+++ b/storage/myisam/mi_open.c
@@ -1176,7 +1176,8 @@ uchar *mi_keyseg_read(uchar *ptr, HA_KEYSEG *keyseg)
keyseg->null_pos = mi_uint4korr(ptr); ptr +=4;
keyseg->charset=0; /* Will be filled in later */
if (keyseg->null_bit)
- keyseg->bit_pos= (uint16)(keyseg->null_pos + (keyseg->null_bit == 7));
+ /* We adjust bit_pos if null_bit is last in the byte */
+ keyseg->bit_pos= (uint16)(keyseg->null_pos + (keyseg->null_bit == (1 << 7)));
else
{
keyseg->bit_pos= (uint16)keyseg->null_pos;
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index f751efa280b..895ce2b8c85 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -210,10 +210,17 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
This segment will be reallocated after construction of the tables.
*/
length=(uint) (elements*2+trees*(1 << myisam_quick_table_bits));
+ /*
+ To keep some algorithms simpler, we accept that they access
+ bytes beyond the end of the input data. This can affect up to
+ one byte less than the "word size" size used in this file,
+ which is BITS_SAVED / 8. To avoid accessing non-allocated
+ 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) +
- (uint) (share->pack.header_length - sizeof(header)),
- MYF(MY_WME | MY_ZEROFILL))))
+ (uint) (share->pack.header_length - sizeof(header) +
+ (BITS_SAVED / 8) - 1), MYF(MY_WME | MY_ZEROFILL))))
goto err1;
tmp_buff=share->decode_tables+length;
disk_cache= (uchar*) (tmp_buff+OFFSET_TABLE_SIZE);
@@ -1432,6 +1439,7 @@ static void fill_buffer(MI_BIT_BUFF *bit_buff)
bit_buff->current_byte=0;
return;
}
+
#if BITS_SAVED == 64
bit_buff->current_byte= ((((uint) ((uchar) bit_buff->pos[7]))) +
(((uint) ((uchar) bit_buff->pos[6])) << 8) +
@@ -1495,7 +1503,9 @@ my_bool _mi_memmap_file(MI_INFO *info)
DBUG_PRINT("warning",("File isn't extended for memmap"));
DBUG_RETURN(0);
}
- if (mi_dynmap_file(info, share->state.state.data_file_length))
+ if (mi_dynmap_file(info,
+ share->state.state.data_file_length +
+ MEMMAP_EXTRA_MARGIN))
DBUG_RETURN(0);
}
info->opt_flag|= MEMMAP_USED;
diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c
index 6d9dea51177..4cea6bbba85 100644
--- a/storage/myisam/mi_write.c
+++ b/storage/myisam/mi_write.c
@@ -562,7 +562,14 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo,
we cannot easily dispatch an empty page here */
b+=blen+ft2len+2;
for (a=anc_buff+a_length ; b < a ; b+=ft2len+2)
- insert_dynamic(info->ft1_to_ft2, b);
+ {
+ if (insert_dynamic(info->ft1_to_ft2, b))
+ {
+ mi_print_error(info->s, HA_ERR_OUT_OF_MEM);
+ my_errno= HA_ERR_OUT_OF_MEM;
+ DBUG_RETURN(-1);
+ }
+ }
/* fixing the page's length - it contains only one key now */
mi_putint(anc_buff,2+blen+ft2len+2,0);
diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c
index 5edc2cf9828..446c3aa2464 100644
--- a/storage/myisam/myisamchk.c
+++ b/storage/myisam/myisamchk.c
@@ -284,8 +284,8 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{ "key_buffer_size", OPT_KEY_BUFFER_SIZE, "",
(uchar**) &check_param.use_buffers, (uchar**) &check_param.use_buffers, 0,
- GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD,
- (long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0},
+ GET_ULL, REQUIRED_ARG, USE_BUFFER_INIT, MALLOC_OVERHEAD,
+ SIZE_T_MAX, MALLOC_OVERHEAD, IO_SIZE, 0},
{ "key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, "",
(uchar**) &opt_key_cache_block_size,
(uchar**) &opt_key_cache_block_size, 0,
@@ -1099,7 +1099,7 @@ static int myisamchk(HA_CHECK *param, char * filename)
{
if (param->testflag & (T_EXTEND | T_MEDIUM))
VOID(init_key_cache(dflt_key_cache,opt_key_cache_block_size,
- param->use_buffers, 0, 0));
+ (size_t) param->use_buffers, 0, 0));
VOID(init_io_cache(&param->read_cache,datafile,
(uint) param->read_buffer_length,
READ_CACHE,
@@ -1303,7 +1303,7 @@ static void descript(HA_CHECK *param, register MI_INFO *info, char * name)
share->base.max_key_file_length != HA_OFFSET_ERROR)
printf("Max datafile length: %13s Max keyfile length: %13s\n",
llstr(share->base.max_data_file_length-1,llbuff),
- llstr(share->base.max_key_file_length-1,llbuff2));
+ ullstr(share->base.max_key_file_length - 1, llbuff2));
}
}
@@ -1522,8 +1522,8 @@ static int mi_sort_records(HA_CHECK *param,
if (share->state.key_root[sort_key] == HA_OFFSET_ERROR)
DBUG_RETURN(0); /* Nothing to do */
- init_key_cache(dflt_key_cache, opt_key_cache_block_size, param->use_buffers,
- 0, 0);
+ init_key_cache(dflt_key_cache, opt_key_cache_block_size,
+ (size_t) param->use_buffers, 0, 0);
if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length,
WRITE_CACHE,share->pack.header_length,1,
MYF(MY_WME | MY_WAIT_IF_FULL)))