Commit 7004ef20 authored by unknown's avatar unknown

Logical merge of changes in myisam to maria.

parent 20b6ddeb
...@@ -557,7 +557,25 @@ int maria_check_definition(MARIA_KEYDEF *t1_keyinfo, ...@@ -557,7 +557,25 @@ int maria_check_definition(MARIA_KEYDEF *t1_keyinfo,
} }
for (j= t1_keyinfo[i].keysegs; j--;) for (j= t1_keyinfo[i].keysegs; j--;)
{ {
if (t1_keysegs[j].type != t2_keysegs[j].type || uint8 t1_keysegs_j__type= t1_keysegs[j].type;
/*
Table migration from 4.1 to 5.1. In 5.1 a *TEXT key part is
always HA_KEYTYPE_VARTEXT2. In 4.1 we had only the equivalent of
HA_KEYTYPE_VARTEXT1. Since we treat both the same on MyISAM
level, we can ignore a mismatch between these types.
*/
if ((t1_keysegs[j].flag & HA_BLOB_PART) &&
(t2_keysegs[j].flag & HA_BLOB_PART))
{
if ((t1_keysegs_j__type == HA_KEYTYPE_VARTEXT2) &&
(t2_keysegs[j].type == HA_KEYTYPE_VARTEXT1))
t1_keysegs_j__type= HA_KEYTYPE_VARTEXT1; /* purecov: tested */
else if ((t1_keysegs_j__type == HA_KEYTYPE_VARBINARY2) &&
(t2_keysegs[j].type == HA_KEYTYPE_VARBINARY1))
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 || t1_keysegs[j].language != t2_keysegs[j].language ||
t1_keysegs[j].null_bit != t2_keysegs[j].null_bit || t1_keysegs[j].null_bit != t2_keysegs[j].null_bit ||
t1_keysegs[j].length != t2_keysegs[j].length) t1_keysegs[j].length != t2_keysegs[j].length)
...@@ -2433,6 +2451,7 @@ int ha_maria::create(const char *name, register TABLE *table_arg, ...@@ -2433,6 +2451,7 @@ int ha_maria::create(const char *name, register TABLE *table_arg,
share->avg_row_length); share->avg_row_length);
create_info.data_file_name= ha_create_info->data_file_name; create_info.data_file_name= ha_create_info->data_file_name;
create_info.index_file_name= ha_create_info->index_file_name; create_info.index_file_name= ha_create_info->index_file_name;
create_info.language= share->table_charset->number;
/* /*
Table is transactional: Table is transactional:
...@@ -2812,8 +2831,7 @@ my_bool ha_maria::register_query_cache_table(THD *thd, char *table_name, ...@@ -2812,8 +2831,7 @@ my_bool ha_maria::register_query_cache_table(THD *thd, char *table_name,
*engine_callback, *engine_callback,
ulonglong *engine_data) ulonglong *engine_data)
{ {
ulonglong actual_data_file_length; DBUG_ENTER("ha_maria::register_query_cache_table");
ulonglong current_data_file_length;
/* /*
No call back function is needed to determine if a cached statement No call back function is needed to determine if a cached statement
...@@ -2826,15 +2844,25 @@ my_bool ha_maria::register_query_cache_table(THD *thd, char *table_name, ...@@ -2826,15 +2844,25 @@ my_bool ha_maria::register_query_cache_table(THD *thd, char *table_name,
*/ */
*engine_data= 0; *engine_data= 0;
if (file->s->concurrent_insert)
{
/* /*
If a concurrent INSERT has happened just before the currently processed If a concurrent INSERT has happened just before the currently
SELECT statement, the total size of the table is unknown. processed SELECT statement, the total size of the table is
unknown.
To determine if the table size is known, the current thread's snap shot of To determine if the table size is known, the current thread's snap
the table size with the actual table size are compared. shot of the table size with the actual table size are compared.
If the table size is unknown the SELECT statement can't be cached. If the table size is unknown the SELECT statement can't be cached.
When concurrent inserts are disabled at table open, mi_open()
does not assign a get_status() function. In this case the local
("current") status is never updated. We would wrongly think that
we cannot cache the statement.
*/ */
ulonglong actual_data_file_length;
ulonglong current_data_file_length;
/* /*
POSIX visibility rules specify that "2. Whatever memory values a POSIX visibility rules specify that "2. Whatever memory values a
...@@ -2854,11 +2882,12 @@ my_bool ha_maria::register_query_cache_table(THD *thd, char *table_name, ...@@ -2854,11 +2882,12 @@ my_bool ha_maria::register_query_cache_table(THD *thd, char *table_name,
current_data_file_length != actual_data_file_length) current_data_file_length != actual_data_file_length)
{ {
/* Don't cache current statement. */ /* Don't cache current statement. */
return FALSE; DBUG_RETURN(FALSE);
}
} }
/* It is ok to try to cache current statement. */ /* It is ok to try to cache current statement. */
return TRUE; DBUG_RETURN(TRUE);
} }
#endif #endif
......
...@@ -88,6 +88,12 @@ int maria_delete_all_rows(MARIA_HA *info) ...@@ -88,6 +88,12 @@ int maria_delete_all_rows(MARIA_HA *info)
there may be data blocks there. We need to throw them away or they may there may be data blocks there. We need to throw them away or they may
re-enter the emptied table or another table later. re-enter the emptied table or another table later.
*/ */
#ifdef HAVE_MMAP
if (share->file_map)
_mi_unmap_file(info);
#endif
if (_ma_flush_table_files(info, MARIA_FLUSH_DATA|MARIA_FLUSH_INDEX, if (_ma_flush_table_files(info, MARIA_FLUSH_DATA|MARIA_FLUSH_INDEX,
FLUSH_IGNORE_CHANGED, FLUSH_IGNORE_CHANGED) || FLUSH_IGNORE_CHANGED, FLUSH_IGNORE_CHANGED) ||
my_chsize(info->dfile.file, 0, 0, MYF(MY_WME)) || my_chsize(info->dfile.file, 0, 0, MYF(MY_WME)) ||
...@@ -119,10 +125,9 @@ int maria_delete_all_rows(MARIA_HA *info) ...@@ -119,10 +125,9 @@ int maria_delete_all_rows(MARIA_HA *info)
VOID(_ma_writeinfo(info,WRITEINFO_UPDATE_KEYFILE)); VOID(_ma_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
/* Resize mmaped area */ /* Map again */
rw_wrlock(&info->s->mmap_lock); if (share->file_map)
_ma_remap_file(info, (my_off_t)0); _ma_dynmap_file(info, (my_off_t) 0);
rw_unlock(&info->s->mmap_lock);
#endif #endif
allow_break(); /* Allow SIGHUP & SIGINT */ allow_break(); /* Allow SIGHUP & SIGINT */
DBUG_RETURN(0); DBUG_RETURN(0);
......
...@@ -1017,12 +1017,12 @@ uint _ma_rec_pack(MARIA_HA *info, register uchar *to, ...@@ -1017,12 +1017,12 @@ uint _ma_rec_pack(MARIA_HA *info, register uchar *to,
{ {
if (column->length > 255 && new_length > 127) if (column->length > 255 && new_length > 127)
{ {
to[0]=(char) ((new_length & 127)+128); to[0]= (uchar) ((new_length & 127) + 128);
to[1]=(char) (new_length >> 7); to[1]= (uchar) (new_length >> 7);
to+=2; to+=2;
} }
else else
*to++= (char) new_length; *to++= (uchar) new_length;
memcpy((uchar*) to,pos,(size_t) new_length); to+=new_length; memcpy((uchar*) to,pos,(size_t) new_length); to+=new_length;
flag|=bit; flag|=bit;
} }
...@@ -1056,7 +1056,7 @@ uint _ma_rec_pack(MARIA_HA *info, register uchar *to, ...@@ -1056,7 +1056,7 @@ uint _ma_rec_pack(MARIA_HA *info, register uchar *to,
} }
if ((bit= bit << 1) >= 256) if ((bit= bit << 1) >= 256)
{ {
*packpos++ = (char) (uchar) flag; *packpos++ = (uchar) flag;
bit=1; flag=0; bit=1; flag=0;
} }
} }
...@@ -1066,7 +1066,7 @@ uint _ma_rec_pack(MARIA_HA *info, register uchar *to, ...@@ -1066,7 +1066,7 @@ uint _ma_rec_pack(MARIA_HA *info, register uchar *to,
} }
} }
if (bit != 1) if (bit != 1)
*packpos= (char) (uchar) flag; *packpos= (uchar) flag;
if (info->s->calc_checksum) if (info->s->calc_checksum)
*to++= (uchar) info->cur_row.checksum; *to++= (uchar) info->cur_row.checksum;
DBUG_PRINT("exit",("packed length: %d",(int) (to-startpos))); DBUG_PRINT("exit",("packed length: %d",(int) (to-startpos)));
...@@ -1143,12 +1143,14 @@ my_bool _ma_rec_check(MARIA_HA *info,const uchar *record, uchar *rec_buff, ...@@ -1143,12 +1143,14 @@ my_bool _ma_rec_check(MARIA_HA *info,const uchar *record, uchar *rec_buff,
goto err; goto err;
if (column->length > 255 && new_length > 127) if (column->length > 255 && new_length > 127)
{ {
if (to[0] != (char) ((new_length & 127)+128) || /* purecov: begin inspected */
to[1] != (char) (new_length >> 7)) if (to[0] != (uchar) ((new_length & 127) + 128) ||
to[1] != (uchar) (new_length >> 7))
goto err; goto err;
to+=2; to+=2;
/* purecov: end */
} }
else if (*to++ != (char) new_length) else if (*to++ != (uchar) new_length)
goto err; goto err;
to+=new_length; to+=new_length;
} }
......
...@@ -714,7 +714,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -714,7 +714,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
if (share->columndef[i].type == FIELD_BLOB) if (share->columndef[i].type == FIELD_BLOB)
{ {
share->blobs[j].pack_length= share->blobs[j].pack_length=
share->columndef[i].length-portable_sizeof_char_ptr;; share->columndef[i].length-portable_sizeof_char_ptr;
share->blobs[j].offset= share->columndef[i].offset; share->blobs[j].offset= share->columndef[i].offset;
j++; j++;
} }
...@@ -1028,6 +1028,14 @@ static void setup_key_functions(register MARIA_KEYDEF *keyinfo) ...@@ -1028,6 +1028,14 @@ static void setup_key_functions(register MARIA_KEYDEF *keyinfo)
keyinfo->get_key= _ma_get_pack_key; keyinfo->get_key= _ma_get_pack_key;
if (keyinfo->seg[0].flag & HA_PACK_KEY) if (keyinfo->seg[0].flag & HA_PACK_KEY)
{ /* Prefix compression */ { /* Prefix compression */
/*
_ma_prefix_search() compares end-space against ASCII blank (' ').
It cannot be used for character sets, that do not encode the
blank character like ASCII does. UCS2 is an example. All
character sets with a fixed width > 1 or a mimimum width > 1
cannot represent blank like ASCII does. In these cases we have
to use _ma_seq_search() for the search.
*/
if (!keyinfo->seg->charset || use_strnxfrm(keyinfo->seg->charset) || if (!keyinfo->seg->charset || use_strnxfrm(keyinfo->seg->charset) ||
(keyinfo->seg->flag & HA_NULL_PART) || (keyinfo->seg->flag & HA_NULL_PART) ||
keyinfo->seg->charset->mbminlen > 1) keyinfo->seg->charset->mbminlen > 1)
......
...@@ -147,7 +147,7 @@ static ha_rows _ma_record_pos(MARIA_HA *info, const uchar *key, ...@@ -147,7 +147,7 @@ static ha_rows _ma_record_pos(MARIA_HA *info, const uchar *key,
key_len=USE_WHOLE_KEY; key_len=USE_WHOLE_KEY;
/* /*
my_handler.c:mi_compare_text() has a flag 'skip_end_space'. my_handler.c:ha_compare_text() has a flag 'skip_end_space'.
This is set in my_handler.c:ha_key_cmp() in dependence on the This is set in my_handler.c:ha_key_cmp() in dependence on the
compare flags 'nextflag' and the column type. compare flags 'nextflag' and the column type.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment