"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "sql/sql_binlog.cc" between
mariadb-10.2.21.tar.gz and mariadb-10.2.22.tar.gz

About: MariaDB is a relational database management system (a drop-in replacement for MySQL). Stable (GA) release (10.2).

sql_binlog.cc  (mariadb-10.2.21):sql_binlog.cc  (mariadb-10.2.22)
skipping to change at line 112 skipping to change at line 112
is not allowed to call by other threads than the slave SQL is not allowed to call by other threads than the slave SQL
thread when the slave SQL thread is running. thread when the slave SQL thread is running.
*/ */
my_error(ER_ONLY_FD_AND_RBR_EVENTS_ALLOWED_IN_BINLOG_STATEMENT, my_error(ER_ONLY_FD_AND_RBR_EVENTS_ALLOWED_IN_BINLOG_STATEMENT,
MYF(0), Log_event::get_type_str((Log_event_type)type)); MYF(0), Log_event::get_type_str((Log_event_type)type));
return 1; return 1;
} }
} }
/** /**
Copy fragments into the standard placeholder thd->lex->comment.str.
Compute the size of the (still) encoded total,
allocate and then copy fragments one after another.
The size can exceed max(max_allowed_packet) which is not a
problem as no String instance is created off this char array.
@param thd THD handle
@return
0 at success,
-1 otherwise.
*/
int binlog_defragment(THD *thd)
{
user_var_entry *entry[2];
LEX_STRING name[2]= { thd->lex->comment, thd->lex->ident };
/* compute the total size */
thd->lex->comment.str= NULL;
thd->lex->comment.length= 0;
for (uint k= 0; k < 2; k++)
{
entry[k]=
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name[k].str,
name[k].length);
if (!entry[k] || entry[k]->type != STRING_RESULT)
{
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), name[k].str);
return -1;
}
thd->lex->comment.length += entry[k]->length;
}
thd->lex->comment.str= // to be freed by the caller
(char *) my_malloc(thd->lex->comment.length, MYF(MY_WME));
if (!thd->lex->comment.str)
{
my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), 1);
return -1;
}
/* fragments are merged into allocated buf while the user var:s get reset */
size_t gathered_length= 0;
for (uint k=0; k < 2; k++)
{
memcpy(thd->lex->comment.str + gathered_length, entry[k]->value,
entry[k]->length);
gathered_length += entry[k]->length;
update_hash(entry[k], true, NULL, 0, STRING_RESULT, &my_charset_bin, 0);
}
DBUG_ASSERT(gathered_length == thd->lex->comment.length);
return 0;
}
/**
Execute a BINLOG statement. Execute a BINLOG statement.
To execute the BINLOG command properly the server needs to know To execute the BINLOG command properly the server needs to know
which format the BINLOG command's event is in. Therefore, the first which format the BINLOG command's event is in. Therefore, the first
BINLOG statement seen must be a base64 encoding of the BINLOG statement seen must be a base64 encoding of the
Format_description_log_event, as outputted by mysqlbinlog. This Format_description_log_event, as outputted by mysqlbinlog. This
Format_description_log_event is cached in Format_description_log_event is cached in
rli->description_event_for_exec. rli->description_event_for_exec.
@param thd Pointer to THD object for the client thread executing the @param thd Pointer to THD object for the client thread executing the
skipping to change at line 136 skipping to change at line 193
{ {
DBUG_ENTER("mysql_client_binlog_statement"); DBUG_ENTER("mysql_client_binlog_statement");
DBUG_PRINT("info",("binlog base64: '%*s'", DBUG_PRINT("info",("binlog base64: '%*s'",
(int) (thd->lex->comment.length < 2048 ? (int) (thd->lex->comment.length < 2048 ?
thd->lex->comment.length : 2048), thd->lex->comment.length : 2048),
thd->lex->comment.str)); thd->lex->comment.str));
if (check_global_access(thd, SUPER_ACL)) if (check_global_access(thd, SUPER_ACL))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
size_t coded_len= thd->lex->comment.length;
if (!coded_len)
{
my_error(ER_SYNTAX_ERROR, MYF(0));
DBUG_VOID_RETURN;
}
size_t decoded_len= my_base64_needed_decoded_length(coded_len);
/* /*
option_bits will be changed when applying the event. But we don't expect option_bits will be changed when applying the event. But we don't expect
it be changed permanently after BINLOG statement, so backup it first. it be changed permanently after BINLOG statement, so backup it first.
It will be restored at the end of this function. It will be restored at the end of this function.
*/ */
ulonglong thd_options= thd->variables.option_bits; ulonglong thd_options= thd->variables.option_bits;
/* /*
Allocation Allocation
*/ */
int err; int err;
Relay_log_info *rli; Relay_log_info *rli;
rpl_group_info *rgi; rpl_group_info *rgi;
char *buf= NULL;
size_t coded_len= 0, decoded_len= 0;
rli= thd->rli_fake; rli= thd->rli_fake;
if (!rli && (rli= thd->rli_fake= new Relay_log_info(FALSE))) if (!rli && (rli= thd->rli_fake= new Relay_log_info(FALSE)))
rli->sql_driver_thd= thd; rli->sql_driver_thd= thd;
if (!(rgi= thd->rgi_fake)) if (!(rgi= thd->rgi_fake))
rgi= thd->rgi_fake= new rpl_group_info(rli); rgi= thd->rgi_fake= new rpl_group_info(rli);
rgi->thd= thd; rgi->thd= thd;
const char *error= 0; const char *error= 0;
char *buf= (char *) my_malloc(decoded_len, MYF(MY_WME));
Log_event *ev = 0; Log_event *ev = 0;
my_bool is_fragmented= FALSE;
/* /*
Out of memory check Out of memory check
*/ */
if (!(rli && buf)) if (!(rli))
{ {
my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), 1); /* needed 1 bytes */ my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), 1); /* needed 1 bytes */
goto end; goto end;
} }
DBUG_ASSERT(rli->belongs_to_client()); DBUG_ASSERT(rli->belongs_to_client());
if (unlikely(is_fragmented= thd->lex->comment.str && thd->lex->ident.str))
if (binlog_defragment(thd))
goto end;
if (!(coded_len= thd->lex->comment.length))
{
my_error(ER_SYNTAX_ERROR, MYF(0));
goto end;
}
decoded_len= my_base64_needed_decoded_length(coded_len);
if (!(buf= (char *) my_malloc(decoded_len, MYF(MY_WME))))
{
my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), 1);
goto end;
}
for (char const *strptr= thd->lex->comment.str ; for (char const *strptr= thd->lex->comment.str ;
strptr < thd->lex->comment.str + thd->lex->comment.length ; ) strptr < thd->lex->comment.str + thd->lex->comment.length ; )
{ {
char const *endptr= 0; char const *endptr= 0;
int bytes_decoded= my_base64_decode(strptr, coded_len, buf, &endptr, int bytes_decoded= my_base64_decode(strptr, coded_len, buf, &endptr,
MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS); MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS);
#ifndef HAVE_valgrind #ifndef HAVE_valgrind
/* /*
This debug printout should not be used for valgrind builds This debug printout should not be used for valgrind builds
skipping to change at line 318 skipping to change at line 386
my_error(ER_UNKNOWN_ERROR, MYF(0)); my_error(ER_UNKNOWN_ERROR, MYF(0));
goto end; goto end;
} }
} }
} }
DBUG_PRINT("info",("binlog base64 execution finished successfully")); DBUG_PRINT("info",("binlog base64 execution finished successfully"));
my_ok(thd); my_ok(thd);
end: end:
if (unlikely(is_fragmented))
my_free(thd->lex->comment.str);
thd->variables.option_bits= thd_options; thd->variables.option_bits= thd_options;
rgi->slave_close_thread_tables(thd); rgi->slave_close_thread_tables(thd);
my_free(buf); my_free(buf);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
 End of changes. 8 change blocks. 
10 lines changed or deleted 80 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)