mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
Fixed core dump bug in str LIKE "%other_str%" where strings contained characters >= 128.
Fixed problem with replication LOAD DATA INFILE when using --old-rpl-compat. When executing on master LOAD DATA and InnoDB failed with 'table full' error the binary log was corrupted. sql/item_cmpfunc.cc: Fixed core dump bug in str LIKE "%other_str%" where strings contained characters >= 128. sql/log_event.cc: Fixed problem with replication LOAD DATA INFILE when using --old-rpl-compat sql/sql_load.cc: When executing on master LOAD DATA and InnoDB failed with 'table full' error the binary log was corrupted.
This commit is contained in:
parent
afbd3fc503
commit
da1ff072c2
3 changed files with 43 additions and 24 deletions
|
@ -1538,12 +1538,12 @@ Item_func_regex::~Item_func_regex()
|
||||||
Precomputation dependent only on pattern_len.
|
Precomputation dependent only on pattern_len.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
void Item_func_like::turboBM_compute_suffixes(int* suff)
|
void Item_func_like::turboBM_compute_suffixes(int *suff)
|
||||||
{
|
{
|
||||||
const int plm1 = pattern_len - 1;
|
const int plm1 = pattern_len - 1;
|
||||||
int f = 0;
|
int f = 0;
|
||||||
int g = plm1;
|
int g = plm1;
|
||||||
int* const splm1 = suff + plm1;
|
int *const splm1 = suff + plm1;
|
||||||
|
|
||||||
*splm1 = pattern_len;
|
*splm1 = pattern_len;
|
||||||
|
|
||||||
|
@ -1579,7 +1579,8 @@ void Item_func_like::turboBM_compute_suffixes(int* suff)
|
||||||
if (i < g)
|
if (i < g)
|
||||||
g = i; // g = min(i, g)
|
g = i; // g = min(i, g)
|
||||||
f = i;
|
f = i;
|
||||||
while (g >= 0 && likeconv(pattern[g]) == likeconv(pattern[g + plm1 - f]))
|
while (g >= 0 &&
|
||||||
|
likeconv(pattern[g]) == likeconv(pattern[g + plm1 - f]))
|
||||||
g--;
|
g--;
|
||||||
suff[i] = f - g;
|
suff[i] = f - g;
|
||||||
}
|
}
|
||||||
|
@ -1593,12 +1594,12 @@ void Item_func_like::turboBM_compute_suffixes(int* suff)
|
||||||
Precomputation dependent only on pattern_len.
|
Precomputation dependent only on pattern_len.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
void Item_func_like::turboBM_compute_good_suffix_shifts(int* suff)
|
void Item_func_like::turboBM_compute_good_suffix_shifts(int *suff)
|
||||||
{
|
{
|
||||||
turboBM_compute_suffixes(suff);
|
turboBM_compute_suffixes(suff);
|
||||||
|
|
||||||
int* end = bmGs + pattern_len;
|
int *end = bmGs + pattern_len;
|
||||||
int* k;
|
int *k;
|
||||||
for (k = bmGs; k < end; k++)
|
for (k = bmGs; k < end; k++)
|
||||||
*k = pattern_len;
|
*k = pattern_len;
|
||||||
|
|
||||||
|
@ -1612,14 +1613,14 @@ void Item_func_like::turboBM_compute_good_suffix_shifts(int* suff)
|
||||||
{
|
{
|
||||||
for (tmp = plm1 - i; j < tmp; j++)
|
for (tmp = plm1 - i; j < tmp; j++)
|
||||||
{
|
{
|
||||||
int* tmp2 = bmGs + j;
|
int *tmp2 = bmGs + j;
|
||||||
if (*tmp2 == pattern_len)
|
if (*tmp2 == pattern_len)
|
||||||
*tmp2 = tmp;
|
*tmp2 = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int* tmp2;
|
int *tmp2;
|
||||||
for (tmp = plm1 - i; j < tmp; j++)
|
for (tmp = plm1 - i; j < tmp; j++)
|
||||||
{
|
{
|
||||||
tmp2 = bmGs + j;
|
tmp2 = bmGs + j;
|
||||||
|
@ -1640,19 +1641,23 @@ void Item_func_like::turboBM_compute_good_suffix_shifts(int* suff)
|
||||||
|
|
||||||
void Item_func_like::turboBM_compute_bad_character_shifts()
|
void Item_func_like::turboBM_compute_bad_character_shifts()
|
||||||
{
|
{
|
||||||
int* i;
|
int *i;
|
||||||
int* end = bmBc + alphabet_size;
|
int *end = bmBc + alphabet_size;
|
||||||
for (i = bmBc; i < end; i++)
|
for (i = bmBc; i < end; i++)
|
||||||
*i = pattern_len;
|
*i = pattern_len;
|
||||||
|
|
||||||
int j;
|
int j;
|
||||||
const int plm1 = pattern_len - 1;
|
const int plm1 = pattern_len - 1;
|
||||||
if (binary)
|
if (binary)
|
||||||
|
{
|
||||||
for (j = 0; j < plm1; j++)
|
for (j = 0; j < plm1; j++)
|
||||||
bmBc[pattern[j]] = plm1 - j;
|
bmBc[(uint) (uchar) pattern[j]] = plm1 - j;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
for (j = 0; j < plm1; j++)
|
for (j = 0; j < plm1; j++)
|
||||||
bmBc[likeconv(pattern[j])] = plm1 - j;
|
bmBc[(uint) likeconv(pattern[j])] = plm1 - j;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1669,27 +1674,27 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
|
||||||
int j = 0;
|
int j = 0;
|
||||||
int u = 0;
|
int u = 0;
|
||||||
|
|
||||||
const int plm1 = pattern_len - 1;
|
const int plm1= pattern_len - 1;
|
||||||
const int tlmpl = text_len - pattern_len;
|
const int tlmpl= text_len - pattern_len;
|
||||||
|
|
||||||
/* Searching */
|
/* Searching */
|
||||||
if (binary)
|
if (binary)
|
||||||
{
|
{
|
||||||
while (j <= tlmpl)
|
while (j <= tlmpl)
|
||||||
{
|
{
|
||||||
register int i = plm1;
|
register int i= plm1;
|
||||||
while (i >= 0 && pattern[i] == text[i + j])
|
while (i >= 0 && pattern[i] == text[i + j])
|
||||||
{
|
{
|
||||||
i--;
|
i--;
|
||||||
if (i == plm1 - shift)
|
if (i == plm1 - shift)
|
||||||
i -= u;
|
i-= u;
|
||||||
}
|
}
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
register const int v = plm1 - i;
|
register const int v = plm1 - i;
|
||||||
turboShift = u - v;
|
turboShift = u - v;
|
||||||
bcShift = bmBc[text[i + j]] - plm1 + i;
|
bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
|
||||||
shift = max(turboShift, bcShift);
|
shift = max(turboShift, bcShift);
|
||||||
shift = max(shift, bmGs[i]);
|
shift = max(shift, bmGs[i]);
|
||||||
if (shift == bmGs[i])
|
if (shift == bmGs[i])
|
||||||
|
@ -1700,7 +1705,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
|
||||||
shift = max(shift, u + 1);
|
shift = max(shift, u + 1);
|
||||||
u = 0;
|
u = 0;
|
||||||
}
|
}
|
||||||
j += shift;
|
j+= shift;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1713,14 +1718,14 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
|
||||||
{
|
{
|
||||||
i--;
|
i--;
|
||||||
if (i == plm1 - shift)
|
if (i == plm1 - shift)
|
||||||
i -= u;
|
i-= u;
|
||||||
}
|
}
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
register const int v = plm1 - i;
|
register const int v = plm1 - i;
|
||||||
turboShift = u - v;
|
turboShift = u - v;
|
||||||
bcShift = bmBc[likeconv(text[i + j])] - plm1 + i;
|
bcShift = bmBc[(uint) likeconv(text[i + j])] - plm1 + i;
|
||||||
shift = max(turboShift, bcShift);
|
shift = max(turboShift, bcShift);
|
||||||
shift = max(shift, bmGs[i]);
|
shift = max(shift, bmGs[i]);
|
||||||
if (shift == bmGs[i])
|
if (shift == bmGs[i])
|
||||||
|
@ -1731,7 +1736,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
|
||||||
shift = max(shift, u + 1);
|
shift = max(shift, u + 1);
|
||||||
u = 0;
|
u = 0;
|
||||||
}
|
}
|
||||||
j += shift;
|
j+= shift;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1202,8 +1202,8 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len,
|
||||||
{
|
{
|
||||||
uint data_len;
|
uint data_len;
|
||||||
char* buf_end = (char*)buf + event_len;
|
char* buf_end = (char*)buf + event_len;
|
||||||
const char* data_head = buf + ((old_format) ?
|
uint header_len= old_format ? OLD_HEADER_LEN : LOG_EVENT_HEADER_LEN;
|
||||||
OLD_HEADER_LEN : LOG_EVENT_HEADER_LEN);
|
const char* data_head = buf + header_len;
|
||||||
thread_id = uint4korr(data_head + L_THREAD_ID_OFFSET);
|
thread_id = uint4korr(data_head + L_THREAD_ID_OFFSET);
|
||||||
exec_time = uint4korr(data_head + L_EXEC_TIME_OFFSET);
|
exec_time = uint4korr(data_head + L_EXEC_TIME_OFFSET);
|
||||||
skip_lines = uint4korr(data_head + L_SKIP_LINES_OFFSET);
|
skip_lines = uint4korr(data_head + L_SKIP_LINES_OFFSET);
|
||||||
|
@ -1212,7 +1212,7 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len,
|
||||||
num_fields = uint4korr(data_head + L_NUM_FIELDS_OFFSET);
|
num_fields = uint4korr(data_head + L_NUM_FIELDS_OFFSET);
|
||||||
|
|
||||||
int body_offset = ((buf[EVENT_TYPE_OFFSET] == LOAD_EVENT) ?
|
int body_offset = ((buf[EVENT_TYPE_OFFSET] == LOAD_EVENT) ?
|
||||||
LOAD_HEADER_LEN + OLD_HEADER_LEN :
|
LOAD_HEADER_LEN + header_len :
|
||||||
get_data_body_offset());
|
get_data_body_offset());
|
||||||
|
|
||||||
if ((int) event_len < body_offset)
|
if ((int) event_len < body_offset)
|
||||||
|
|
|
@ -283,6 +283,20 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
||||||
{
|
{
|
||||||
if (lf_info.wrote_create_file)
|
if (lf_info.wrote_create_file)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
Make sure last block (the one which caused the error) gets logged.
|
||||||
|
This is needed because otherwise after write of
|
||||||
|
(to the binlog, not to read_info (which is a cache))
|
||||||
|
Delete_file_log_event the bad block will remain in read_info.
|
||||||
|
At the end of mysql_load(), the destructor of read_info will call
|
||||||
|
end_io_cache() which will flush read_info, so we will finally have
|
||||||
|
this in the binlog:
|
||||||
|
Append_block # The last successfull block
|
||||||
|
Delete_file
|
||||||
|
Append_block # The failing block
|
||||||
|
which is nonsense.
|
||||||
|
*/
|
||||||
|
read_info.end_io_cache();
|
||||||
Delete_file_log_event d(thd, log_delayed);
|
Delete_file_log_event d(thd, log_delayed);
|
||||||
mysql_bin_log.write(&d);
|
mysql_bin_log.write(&d);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue