summaryrefslogtreecommitdiff
path: root/storage/maria
diff options
context:
space:
mode:
Diffstat (limited to 'storage/maria')
-rw-r--r--storage/maria/ha_maria.cc30
-rw-r--r--storage/maria/ma_bitmap.c2
-rw-r--r--storage/maria/ma_checkpoint.c7
-rw-r--r--storage/maria/ma_dbug.c2
-rw-r--r--storage/maria/ma_info.c2
-rw-r--r--storage/maria/ma_key_recover.c2
-rw-r--r--storage/maria/ma_open.c22
-rw-r--r--storage/maria/ma_recovery.c8
-rw-r--r--storage/maria/ma_search.c4
-rw-r--r--storage/maria/ma_write.c2
10 files changed, 49 insertions, 32 deletions
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 92b2a965706..41e79187409 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -923,8 +923,11 @@ double ha_maria::scan_time()
splitting algorithms depends on this. (With only one key on a page
we also can't use any compression, which may make the index file much
larger)
- We use HA_MAX_KEY_BUFF as this is a stack restriction imposed by the
- handler interface.
+ We use HA_MAX_KEY_LENGTH as this is a stack restriction imposed by the
+ handler interface. If we want to increase this, we have also to
+ increase HA_MARIA_KEY_BUFF and MARIA_MAX_KEY_BUFF as the buffer needs
+ to take be able to store the extra lenght bytes that is part of the stored
+ key.
We also need to reserve place for a record pointer (8) and 3 bytes
per key segment to store the length of the segment + possible null bytes.
@@ -2243,21 +2246,6 @@ int ha_maria::delete_row(const uchar * buf)
return maria_delete(file, buf);
}
-C_MODE_START
-
-ICP_RESULT index_cond_func_maria(void *arg)
-{
- ha_maria *h= (ha_maria*)arg;
- if (h->end_range)
- {
- if (h->compare_key2(h->end_range) > 0)
- return ICP_OUT_OF_RANGE; /* caller should return HA_ERR_END_OF_FILE already */
- }
- return h->pushed_idx_cond->val_int() ? ICP_MATCH : ICP_NO_MATCH;
-}
-
-C_MODE_END
-
int ha_maria::index_read_map(uchar * buf, const uchar * key,
key_part_map keypart_map,
enum ha_rkey_function find_flag)
@@ -2277,7 +2265,7 @@ int ha_maria::index_read_idx_map(uchar * buf, uint index, const uchar * key,
/* Use the pushed index condition if it matches the index we're scanning */
end_range= NULL;
if (index == pushed_idx_cond_keyno)
- ma_set_index_cond_func(file, index_cond_func_maria, this);
+ ma_set_index_cond_func(file, handler_index_cond_check, this);
error= maria_rkey(file, buf, index, key, keypart_map, find_flag);
@@ -2358,7 +2346,7 @@ int ha_maria::index_init(uint idx, bool sorted)
{
active_index=idx;
if (pushed_idx_cond_keyno == idx)
- ma_set_index_cond_func(file, index_cond_func_maria, this);
+ ma_set_index_cond_func(file, handler_index_cond_check, this);
return 0;
}
@@ -3086,7 +3074,7 @@ void ha_maria::get_auto_increment(ulonglong offset, ulonglong increment,
{
ulonglong nr;
int error;
- uchar key[HA_MAX_KEY_LENGTH];
+ uchar key[MARIA_MAX_KEY_BUFF];
if (!table->s->next_number_key_offset)
{ // Autoincrement at key-start
@@ -3791,7 +3779,7 @@ Item *ha_maria::idx_cond_push(uint keyno_arg, Item* idx_cond_arg)
pushed_idx_cond= idx_cond_arg;
in_range_check_pushed_down= TRUE;
if (active_index == pushed_idx_cond_keyno)
- ma_set_index_cond_func(file, index_cond_func_maria, this);
+ ma_set_index_cond_func(file, handler_index_cond_check, this);
return NULL;
}
diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c
index 25ab5c6531e..f5cfa1ce23f 100644
--- a/storage/maria/ma_bitmap.c
+++ b/storage/maria/ma_bitmap.c
@@ -368,7 +368,7 @@ static inline void _ma_bitmap_mark_file_changed(MARIA_SHARE *share,
if (flush_translog && share->now_transactional)
(void) translog_flush(share->state.logrec_file_id);
- _ma_mark_file_changed(share);
+ _ma_mark_file_changed_now(share);
pthread_mutex_lock(&share->bitmap.bitmap_lock);
/* purecov: end */
}
diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c
index 602e5da3065..e11a21581aa 100644
--- a/storage/maria/ma_checkpoint.c
+++ b/storage/maria/ma_checkpoint.c
@@ -916,6 +916,9 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
*/
}
translog_unlock();
+ if (state_copy == state_copies)
+ break; /* Nothing to do */
+
/**
We are going to flush these states.
Before, all records describing how to undo such state must be
@@ -940,13 +943,13 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
if (translog_flush(state_copies_horizon))
goto err;
/* now we have cached states and they are WAL-safe*/
- state_copies_end= state_copy;
+ state_copies_end= state_copy-1;
state_copy= state_copies;
}
/* locate our state among these cached ones */
for ( ; state_copy->index != i; state_copy++)
- DBUG_ASSERT(state_copy < state_copies_end);
+ DBUG_ASSERT(state_copy <= state_copies_end);
/* OS file descriptors are ints which we stored in 4 bytes */
compile_time_assert(sizeof(int) <= 4);
diff --git a/storage/maria/ma_dbug.c b/storage/maria/ma_dbug.c
index af90a108e2a..8391f1a9d9d 100644
--- a/storage/maria/ma_dbug.c
+++ b/storage/maria/ma_dbug.c
@@ -186,7 +186,7 @@ my_bool _ma_check_table_is_closed(const char *name, const char *where)
MARIA_SHARE *share= info->s;
if (!strcmp(share->unique_file_name.str, filename))
{
- if (share->last_version)
+ if (share->last_version > 1)
{
fprintf(stderr,"Warning: Table: %s is open on %s\n", name,where);
DBUG_PRINT("warning",("Table: %s is open on %s", name,where));
diff --git a/storage/maria/ma_info.c b/storage/maria/ma_info.c
index af0e46ee239..b5d9b2489b7 100644
--- a/storage/maria/ma_info.c
+++ b/storage/maria/ma_info.c
@@ -31,7 +31,7 @@ MARIA_RECORD_POS maria_position(MARIA_HA *info)
uint maria_max_key_length()
{
uint tmp= (_ma_max_key_length() - 8 - HA_MAX_KEY_SEG*3);
- return min(HA_MAX_KEY_BUFF, tmp);
+ return min(HA_MAX_KEY_LENGTH, tmp);
}
/* Get information about the table */
diff --git a/storage/maria/ma_key_recover.c b/storage/maria/ma_key_recover.c
index c0d906117b6..16ecfa292a9 100644
--- a/storage/maria/ma_key_recover.c
+++ b/storage/maria/ma_key_recover.c
@@ -1107,7 +1107,7 @@ uint _ma_apply_redo_index(MARIA_HA *info,
DBUG_PRINT("redo", ("org_page_length: %u new_page_length: %u",
uint2korr(header), uint2korr(header+2)));
DBUG_ASSERT(uint2korr(header) == page_length);
- new_page_length= uint2korr(header+2);
+ new_page_length= min(uint2korr(header+2), max_page_size);
header+= 4;
break;
case KEY_OP_MAX_PAGELENGTH:
diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c
index 0b5ee2feb85..84da4f12f65 100644
--- a/storage/maria/ma_open.c
+++ b/storage/maria/ma_open.c
@@ -62,7 +62,8 @@ MARIA_HA *_ma_test_if_reopen(const char *filename)
{
MARIA_HA *info=(MARIA_HA*) pos->data;
MARIA_SHARE *share= info->s;
- if (!strcmp(share->unique_file_name.str,filename) && share->last_version)
+ if (!strcmp(share->unique_file_name.str,filename) &&
+ share->last_version > 1)
return info;
}
return 0;
@@ -840,7 +841,12 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
share->base.key_parts=key_parts;
share->base.all_key_parts=key_parts+unique_key_parts;
if (!(share->last_version=share->state.version))
- share->last_version=1; /* Safety */
+ share->last_version= 2; /* Safety */
+ if (open_flags & HA_OPEN_FOR_STATUS)
+ {
+ share->last_version= 1; /* Not reusable version */
+ share->options|= HA_OPTION_READ_ONLY_DATA;
+ }
share->rec_reflength=share->base.rec_reflength; /* May be changed */
share->base.margin_key_file_length=(share->base.max_key_file_length -
(keys ? MARIA_INDEX_BLOCK_MARGIN *
@@ -1714,9 +1720,11 @@ my_bool _ma_columndef_write(File file, MARIA_COLUMNDEF *columndef)
{
uchar buff[MARIA_COLUMNDEF_SIZE];
uchar *ptr=buff;
+ uint low_offset= (uint) (columndef->offset & 0xffff);
+ uint high_offset= (uint) (columndef->offset >> 16);
mi_int2store(ptr,(ulong) columndef->column_nr); ptr+= 2;
- mi_int2store(ptr,(ulong) columndef->offset); ptr+= 2;
+ mi_int2store(ptr, low_offset); ptr+= 2;
mi_int2store(ptr,columndef->type); ptr+= 2;
mi_int2store(ptr,columndef->length); ptr+= 2;
mi_int2store(ptr,columndef->fill_length); ptr+= 2;
@@ -1725,12 +1733,14 @@ my_bool _ma_columndef_write(File file, MARIA_COLUMNDEF *columndef)
(*ptr++)= columndef->null_bit;
(*ptr++)= columndef->empty_bit;
- ptr[0]= ptr[1]= ptr[2]= ptr[3]= 0; ptr+= 4; /* For future */
+ mi_int2store(ptr, high_offset); ptr+= 2;
+ ptr[0]= ptr[1]= 0; ptr+= 2; /* For future */
return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
}
uchar *_ma_columndef_read(uchar *ptr, MARIA_COLUMNDEF *columndef)
{
+ uint high_offset;
columndef->column_nr= mi_uint2korr(ptr); ptr+= 2;
columndef->offset= mi_uint2korr(ptr); ptr+= 2;
columndef->type= mi_sint2korr(ptr); ptr+= 2;
@@ -1740,7 +1750,9 @@ uchar *_ma_columndef_read(uchar *ptr, MARIA_COLUMNDEF *columndef)
columndef->empty_pos= mi_uint2korr(ptr); ptr+= 2;
columndef->null_bit= (uint8) *ptr++;
columndef->empty_bit= (uint8) *ptr++;
- ptr+= 4;
+ high_offset= mi_uint2korr(ptr); ptr+= 2;
+ columndef->offset|= ((ulong) high_offset << 16);
+ ptr+= 2;
return ptr;
}
diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c
index 37def17c4c3..77091c4747b 100644
--- a/storage/maria/ma_recovery.c
+++ b/storage/maria/ma_recovery.c
@@ -665,11 +665,13 @@ prototype_redo_exec_hook_dummy(INCOMPLETE_GROUP)
prototype_redo_exec_hook(INCOMPLETE_LOG)
{
MARIA_HA *info;
+
if (skip_DDLs)
{
tprint(tracef, "we skip DDLs\n");
return 0;
}
+
if ((info= get_MARIA_HA_from_REDO_record(rec)) == NULL)
{
/* no such table, don't need to warn */
@@ -1479,7 +1481,13 @@ end:
if (error)
{
if (info != NULL)
+ {
+ /* let maria_close() mark the table properly closed */
+ info->s->state.open_count= 1;
+ info->s->global_changed= 1;
+ info->s->changed= 1;
maria_close(info);
+ }
if (error == -1)
error= 0;
}
diff --git a/storage/maria/ma_search.c b/storage/maria/ma_search.c
index 84123fec93a..78672cd2094 100644
--- a/storage/maria/ma_search.c
+++ b/storage/maria/ma_search.c
@@ -1389,6 +1389,10 @@ uint _ma_get_binary_pack_key(MARIA_KEY *int_key, uint page_flag, uint nod_flag,
memcpy(key, from, length + nod_flag);
*page_pos= from + length + nod_flag;
+#ifdef USEFUL_FOR_DEBUGGING
+ DBUG_DUMP("key", int_key->data,
+ (uint) (int_key->data_length + int_key->ref_length));
+#endif
DBUG_RETURN(int_key->data_length + int_key->ref_length);
}
diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c
index 27d1598fd62..87de79b2eae 100644
--- a/storage/maria/ma_write.c
+++ b/storage/maria/ma_write.c
@@ -726,6 +726,8 @@ static int w_search(register MARIA_HA *info, uint32 comp_flag, MARIA_KEY *key,
{
error= _ma_insert(info, key, &page, keypos, keybuff,
father_page, father_keypos, insert_last);
+ if (error < 0)
+ goto err;
page_mark_changed(info, &page);
if (_ma_write_keypage(&page, PAGECACHE_LOCK_LEFT_WRITELOCKED,
DFLT_INIT_HITS))