1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge 10.5 into 10.6

This commit is contained in:
Marko Mäkelä
2024-01-17 13:35:05 +02:00
51 changed files with 976 additions and 267 deletions

View File

@@ -4218,11 +4218,16 @@ bool XA_prepare_log_event::write()
#if defined(HAVE_REPLICATION)
static bool
user_var_append_name_part(THD *thd, String *buf,
const char *name, size_t name_len)
const char *name, size_t name_len,
const LEX_CSTRING &data_type_name)
{
return buf->append('@') ||
append_identifier(thd, buf, name, name_len) ||
buf->append('=');
buf->append('=') ||
(data_type_name.length &&
(buf->append(STRING_WITH_LEN("/*")) ||
buf->append(data_type_name.str, data_type_name.length) ||
buf->append(STRING_WITH_LEN("*/"))));
}
void User_var_log_event::pack_info(Protocol* protocol)
@@ -4232,14 +4237,15 @@ void User_var_log_event::pack_info(Protocol* protocol)
char buf_mem[FN_REFLEN+7];
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
buf.length(0);
if (user_var_append_name_part(protocol->thd, &buf, name, name_len) ||
if (user_var_append_name_part(protocol->thd, &buf, name, name_len,
m_data_type_name) ||
buf.append(NULL_clex_str))
return;
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
}
else
{
switch (type) {
switch (m_type) {
case REAL_RESULT:
{
double real_val;
@@ -4248,7 +4254,8 @@ void User_var_log_event::pack_info(Protocol* protocol)
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
float8get(real_val, val);
buf.length(0);
if (user_var_append_name_part(protocol->thd, &buf, name, name_len) ||
if (user_var_append_name_part(protocol->thd, &buf, name, name_len,
m_data_type_name) ||
buf.append(buf2, my_gcvt(real_val, MY_GCVT_ARG_DOUBLE,
MY_GCVT_MAX_FIELD_WIDTH, buf2, NULL)))
return;
@@ -4261,10 +4268,11 @@ void User_var_log_event::pack_info(Protocol* protocol)
char buf_mem[FN_REFLEN + 22];
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
buf.length(0);
if (user_var_append_name_part(protocol->thd, &buf, name, name_len) ||
if (user_var_append_name_part(protocol->thd, &buf, name, name_len,
m_data_type_name) ||
buf.append(buf2,
longlong10_to_str(uint8korr(val), buf2,
((flags & User_var_log_event::UNSIGNED_F) ? 10 : -10))-buf2))
(is_unsigned() ? 10 : -10))-buf2))
return;
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
break;
@@ -4277,7 +4285,8 @@ void User_var_log_event::pack_info(Protocol* protocol)
String str(buf2, sizeof(buf2), &my_charset_bin);
buf.length(0);
my_decimal((const uchar *) (val + 2), val[0], val[1]).to_string(&str);
if (user_var_append_name_part(protocol->thd, &buf, name, name_len) ||
if (user_var_append_name_part(protocol->thd, &buf, name, name_len,
m_data_type_name) ||
buf.append(str))
return;
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
@@ -4291,7 +4300,7 @@ void User_var_log_event::pack_info(Protocol* protocol)
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
CHARSET_INFO *cs;
buf.length(0);
if (!(cs= get_charset(charset_number, MYF(0))))
if (!(cs= get_charset(m_charset_number, MYF(0))))
{
if (buf.append(STRING_WITH_LEN("???")))
return;
@@ -4300,7 +4309,8 @@ void User_var_log_event::pack_info(Protocol* protocol)
{
size_t old_len;
char *beg, *end;
if (user_var_append_name_part(protocol->thd, &buf, name, name_len) ||
if (user_var_append_name_part(protocol->thd, &buf, name, name_len,
m_data_type_name) ||
buf.append('_') ||
buf.append(cs->cs_name) ||
buf.append(' '))
@@ -4348,10 +4358,10 @@ bool User_var_log_event::write()
}
else
{
buf1[1]= type;
int4store(buf1 + 2, charset_number);
buf1[1]= m_type;
int4store(buf1 + 2, m_charset_number);
switch (type) {
switch (m_type) {
case REAL_RESULT:
float8store(buf2, *(double*) val);
break;
@@ -4381,15 +4391,28 @@ bool User_var_log_event::write()
buf1_length= 10;
}
/* Length of the whole event */
event_length= sizeof(buf)+ name_len + buf1_length + val_len + unsigned_len;
uchar data_type_name_chunk_signature= (uchar) CHUNK_DATA_TYPE_NAME;
uint data_type_name_chunk_signature_length= m_data_type_name.length ? 1 : 0;
uchar data_type_name_length_length= m_data_type_name.length ? 1 : 0;
/* Length of the whole event */
event_length= sizeof(buf)+ name_len + buf1_length + val_len + unsigned_len +
data_type_name_chunk_signature_length +
data_type_name_length_length +
(uint) m_data_type_name.length;
uchar unsig= m_is_unsigned ? CHUNK_UNSIGNED : CHUNK_SIGNED;
uchar data_type_name_length= (uchar) m_data_type_name.length;
return write_header(event_length) ||
write_data(buf, sizeof(buf)) ||
write_data(name, name_len) ||
write_data(buf1, buf1_length) ||
write_data(pos, val_len) ||
write_data(&flags, unsigned_len) ||
write_data(&unsig, unsigned_len) ||
write_data(&data_type_name_chunk_signature,
data_type_name_chunk_signature_length) ||
write_data(&data_type_name_length, data_type_name_length_length) ||
write_data(m_data_type_name.str, (uint) m_data_type_name.length) ||
write_footer();
}
@@ -4413,7 +4436,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
current_thd->query_id= query_id; /* recreating original time context */
}
if (!(charset= get_charset(charset_number, MYF(MY_WME))))
if (!(charset= get_charset(m_charset_number, MYF(MY_WME))))
{
rgi->rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
ER_THD(thd, ER_SLAVE_FATAL_ERROR),
@@ -4432,7 +4455,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
}
else
{
switch (type) {
switch (m_type) {
case REAL_RESULT:
if (val_len != 8)
{
@@ -4496,13 +4519,10 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
if (e->fix_fields(thd, 0))
DBUG_RETURN(1);
/*
A variable can just be considered as a table with
a single record and with a single column. Thus, like
a column value, it could always have IMPLICIT derivation.
*/
e->update_hash((void*) val, val_len, type, charset,
(flags & User_var_log_event::UNSIGNED_F));
const Type_handler *th= Type_handler::handler_by_log_event_data_type(thd,
*this);
e->update_hash((void*) val, val_len, th, charset);
if (!is_deferred())
free_root(thd->mem_root, 0);
else