mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge 10.4 into 10.5
This commit is contained in:
104
sql/sql_class.cc
104
sql/sql_class.cc
@ -49,7 +49,7 @@
|
||||
#include <m_ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <thr_alarm.h>
|
||||
#ifdef __WIN__
|
||||
#ifdef __WIN__0
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <mysys_err.h>
|
||||
@ -5848,17 +5848,33 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
Get the capabilities vector for all involved storage engines and
|
||||
mask out the flags for the binary log.
|
||||
*/
|
||||
for (TABLE_LIST *table= tables; table; table= table->next_global)
|
||||
for (TABLE_LIST *tbl= tables; tbl; tbl= tbl->next_global)
|
||||
{
|
||||
if (table->placeholder())
|
||||
TABLE *table;
|
||||
TABLE_SHARE *share;
|
||||
handler::Table_flags flags;
|
||||
if (tbl->placeholder())
|
||||
continue;
|
||||
|
||||
handler::Table_flags const flags= table->table->file->ha_table_flags();
|
||||
table= tbl->table;
|
||||
share= table->s;
|
||||
flags= table->file->ha_table_flags();
|
||||
if (!share->table_creation_was_logged)
|
||||
{
|
||||
/*
|
||||
This is a temporary table which was not logged in the binary log.
|
||||
Disable statement logging to enforce row level logging.
|
||||
*/
|
||||
DBUG_ASSERT(share->tmp_table);
|
||||
flags&= ~HA_BINLOG_STMT_CAPABLE;
|
||||
/* We can only use row logging */
|
||||
set_current_stmt_binlog_format_row();
|
||||
}
|
||||
|
||||
DBUG_PRINT("info", ("table: %s; ha_table_flags: 0x%llx",
|
||||
table->table_name.str, flags));
|
||||
tbl->table_name.str, flags));
|
||||
|
||||
if (table->table->s->no_replicate)
|
||||
if (share->no_replicate)
|
||||
{
|
||||
/*
|
||||
The statement uses a table that is not replicated.
|
||||
@ -5876,44 +5892,44 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
*/
|
||||
lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_TABLE);
|
||||
|
||||
if (table->lock_type >= TL_WRITE_ALLOW_WRITE)
|
||||
if (tbl->lock_type >= TL_WRITE_ALLOW_WRITE)
|
||||
{
|
||||
non_replicated_tables_count++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (table == lex->first_not_own_table())
|
||||
if (tbl == lex->first_not_own_table())
|
||||
found_first_not_own_table= true;
|
||||
|
||||
replicated_tables_count++;
|
||||
|
||||
if (table->prelocking_placeholder != TABLE_LIST::PRELOCK_FK)
|
||||
if (tbl->prelocking_placeholder != TABLE_LIST::PRELOCK_FK)
|
||||
{
|
||||
if (table->lock_type <= TL_READ_NO_INSERT)
|
||||
if (tbl->lock_type <= TL_READ_NO_INSERT)
|
||||
has_read_tables= true;
|
||||
else if (table->table->found_next_number_field &&
|
||||
(table->lock_type >= TL_WRITE_ALLOW_WRITE))
|
||||
else if (table->found_next_number_field &&
|
||||
(tbl->lock_type >= TL_WRITE_ALLOW_WRITE))
|
||||
{
|
||||
has_auto_increment_write_tables= true;
|
||||
has_auto_increment_write_tables_not_first= found_first_not_own_table;
|
||||
if (table->table->s->next_number_keypart != 0)
|
||||
if (share->next_number_keypart != 0)
|
||||
has_write_table_auto_increment_not_first_in_pk= true;
|
||||
}
|
||||
}
|
||||
|
||||
if (table->lock_type >= TL_WRITE_ALLOW_WRITE)
|
||||
if (tbl->lock_type >= TL_WRITE_ALLOW_WRITE)
|
||||
{
|
||||
bool trans;
|
||||
if (prev_write_table && prev_write_table->file->ht !=
|
||||
table->table->file->ht)
|
||||
table->file->ht)
|
||||
multi_write_engine= TRUE;
|
||||
if (table->table->s->non_determinstic_insert &&
|
||||
if (share->non_determinstic_insert &&
|
||||
!(sql_command_flags[lex->sql_command] & CF_SCHEMA_CHANGE))
|
||||
has_write_tables_with_unsafe_statements= true;
|
||||
|
||||
trans= table->table->file->has_transactions();
|
||||
trans= table->file->has_transactions();
|
||||
|
||||
if (table->table->s->tmp_table)
|
||||
if (share->tmp_table)
|
||||
lex->set_stmt_accessed_table(trans ? LEX::STMT_WRITES_TEMP_TRANS_TABLE :
|
||||
LEX::STMT_WRITES_TEMP_NON_TRANS_TABLE);
|
||||
else
|
||||
@ -5924,17 +5940,16 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
flags_write_some_set |= flags;
|
||||
is_write= TRUE;
|
||||
|
||||
prev_write_table= table->table;
|
||||
prev_write_table= table;
|
||||
|
||||
}
|
||||
flags_access_some_set |= flags;
|
||||
|
||||
if (lex->sql_command != SQLCOM_CREATE_TABLE ||
|
||||
(lex->sql_command == SQLCOM_CREATE_TABLE && lex->tmp_table()))
|
||||
if (lex->sql_command != SQLCOM_CREATE_TABLE || lex->tmp_table())
|
||||
{
|
||||
my_bool trans= table->table->file->has_transactions();
|
||||
my_bool trans= table->file->has_transactions();
|
||||
|
||||
if (table->table->s->tmp_table)
|
||||
if (share->tmp_table)
|
||||
lex->set_stmt_accessed_table(trans ? LEX::STMT_READS_TEMP_TRANS_TABLE :
|
||||
LEX::STMT_READS_TEMP_NON_TRANS_TABLE);
|
||||
else
|
||||
@ -5943,10 +5958,10 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
}
|
||||
|
||||
if (prev_access_table && prev_access_table->file->ht !=
|
||||
table->table->file->ht)
|
||||
table->file->ht)
|
||||
multi_access_engine= TRUE;
|
||||
|
||||
prev_access_table= table->table;
|
||||
prev_access_table= table;
|
||||
}
|
||||
|
||||
if (wsrep_binlog_format() != BINLOG_FORMAT_ROW)
|
||||
@ -6075,10 +6090,17 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
{
|
||||
/*
|
||||
5. Error: Cannot modify table that uses a storage engine
|
||||
limited to row-logging when binlog_format = STATEMENT
|
||||
limited to row-logging when binlog_format = STATEMENT, except
|
||||
if all tables that are updated are temporary tables
|
||||
*/
|
||||
if (IF_WSREP((!WSREP_NNULL(this) ||
|
||||
wsrep_cs().mode() == wsrep::client_state::m_local),1))
|
||||
if (!lex->stmt_writes_to_non_temp_table())
|
||||
{
|
||||
/* As all updated tables are temporary, nothing will be logged */
|
||||
set_current_stmt_binlog_format_row();
|
||||
}
|
||||
else if (IF_WSREP((!WSREP(this) ||
|
||||
wsrep_cs().mode() ==
|
||||
wsrep::client_state::m_local),1))
|
||||
{
|
||||
my_error((error= ER_BINLOG_STMT_MODE_AND_ROW_ENGINE), MYF(0), "");
|
||||
}
|
||||
@ -6147,10 +6169,8 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
"ROW" : "STATEMENT"));
|
||||
|
||||
if (variables.binlog_format == BINLOG_FORMAT_ROW &&
|
||||
(lex->sql_command == SQLCOM_UPDATE ||
|
||||
lex->sql_command == SQLCOM_UPDATE_MULTI ||
|
||||
lex->sql_command == SQLCOM_DELETE ||
|
||||
lex->sql_command == SQLCOM_DELETE_MULTI))
|
||||
(sql_command_flags[lex->sql_command] &
|
||||
(CF_UPDATES_DATA | CF_DELETES_DATA)))
|
||||
{
|
||||
String table_names;
|
||||
/*
|
||||
@ -6170,8 +6190,8 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
}
|
||||
if (!table_names.is_empty())
|
||||
{
|
||||
bool is_update= (lex->sql_command == SQLCOM_UPDATE ||
|
||||
lex->sql_command == SQLCOM_UPDATE_MULTI);
|
||||
bool is_update= MY_TEST(sql_command_flags[lex->sql_command] &
|
||||
CF_UPDATES_DATA);
|
||||
/*
|
||||
Replace the last ',' with '.' for table_names
|
||||
*/
|
||||
@ -7008,11 +7028,12 @@ void THD::issue_unsafe_warnings()
|
||||
|
||||
@see decide_logging_format
|
||||
|
||||
@retval < 0 No logging of query (ok)
|
||||
@retval 0 Success
|
||||
|
||||
@retval nonzero If there is a failure when writing the query (e.g.,
|
||||
write failure), then the error code is returned.
|
||||
@retval > 0 If there is a failure when writing the query (e.g.,
|
||||
write failure), then the error code is returned.
|
||||
*/
|
||||
|
||||
int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
|
||||
ulong query_len, bool is_trans, bool direct,
|
||||
bool suppress_use, int errcode)
|
||||
@ -7038,7 +7059,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
|
||||
The current statement is to be ignored, and not written to
|
||||
the binlog. Do not call issue_unsafe_warnings().
|
||||
*/
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -7054,7 +7075,10 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
|
||||
{
|
||||
int error;
|
||||
if (unlikely(error= binlog_flush_pending_rows_event(TRUE, is_trans)))
|
||||
{
|
||||
DBUG_ASSERT(error > 0);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -7097,7 +7121,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
|
||||
("is_current_stmt_binlog_format_row: %d",
|
||||
is_current_stmt_binlog_format_row()));
|
||||
if (is_current_stmt_binlog_format_row())
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(-1);
|
||||
/* Fall through */
|
||||
|
||||
/*
|
||||
@ -7138,7 +7162,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
|
||||
}
|
||||
|
||||
binlog_table_maps= 0;
|
||||
DBUG_RETURN(error);
|
||||
DBUG_RETURN(error >= 0 ? error : 1);
|
||||
}
|
||||
|
||||
case THD::QUERY_TYPE_COUNT:
|
||||
|
Reference in New Issue
Block a user