mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
merge mysql-5.1-rep+3 --> mysql-5.1-rep+2-delivery1
This commit is contained in:
166
sql/sql_class.h
166
sql/sql_class.h
@ -1288,6 +1288,7 @@ public:
|
||||
/* Used to execute base64 coded binlog events in MySQL server */
|
||||
Relay_log_info* rli_fake;
|
||||
|
||||
void reset_for_next_command();
|
||||
/*
|
||||
Constant for THD::where initialization in the beginning of every query.
|
||||
|
||||
@ -1462,32 +1463,81 @@ public:
|
||||
size_t needed,
|
||||
bool is_transactional,
|
||||
RowsEventT* hint);
|
||||
Rows_log_event* binlog_get_pending_rows_event() const;
|
||||
void binlog_set_pending_rows_event(Rows_log_event* ev);
|
||||
int binlog_flush_pending_rows_event(bool stmt_end);
|
||||
int binlog_remove_pending_rows_event(bool clear_maps);
|
||||
Rows_log_event* binlog_get_pending_rows_event(bool is_transactional) const;
|
||||
void binlog_set_pending_rows_event(Rows_log_event* ev, bool is_transactional);
|
||||
inline int binlog_flush_pending_rows_event(bool stmt_end)
|
||||
{
|
||||
return (binlog_flush_pending_rows_event(stmt_end, FALSE) ||
|
||||
binlog_flush_pending_rows_event(stmt_end, TRUE));
|
||||
}
|
||||
int binlog_flush_pending_rows_event(bool stmt_end, bool is_transactional);
|
||||
int binlog_remove_pending_rows_event(bool clear_maps, bool is_transactional);
|
||||
|
||||
/**
|
||||
Determine the binlog format of the current statement.
|
||||
|
||||
@retval 0 if the current statement will be logged in statement
|
||||
format.
|
||||
@retval nonzero if the current statement will be logged in row
|
||||
format.
|
||||
*/
|
||||
int is_current_stmt_binlog_format_row() const {
|
||||
DBUG_ASSERT(current_stmt_binlog_format == BINLOG_FORMAT_STMT ||
|
||||
current_stmt_binlog_format == BINLOG_FORMAT_ROW);
|
||||
return current_stmt_binlog_format == BINLOG_FORMAT_ROW;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
Indicates the format in which the current statement will be
|
||||
logged. This can only be set from @c decide_logging_format().
|
||||
*/
|
||||
enum_binlog_format current_stmt_binlog_format;
|
||||
|
||||
/**
|
||||
Bit field for the state of binlog warnings.
|
||||
|
||||
There are two groups of bits:
|
||||
|
||||
- The first Lex::BINLOG_STMT_UNSAFE_COUNT bits list all types of
|
||||
unsafeness that the current statement has.
|
||||
|
||||
- The following Lex::BINLOG_STMT_UNSAFE_COUNT bits list all types
|
||||
of unsafeness that the current statement has issued warnings
|
||||
for.
|
||||
|
||||
Hence, this variable must be big enough to hold
|
||||
2*Lex::BINLOG_STMT_UNSAFE_COUNT bits. This is asserted in @c
|
||||
issue_unsafe_warnings().
|
||||
|
||||
The first and second groups of bits are set by @c
|
||||
decide_logging_format() when it detects that a warning should be
|
||||
issued. The third group of bits is set from @c binlog_query()
|
||||
when a warning is issued. All bits are cleared at the end of the
|
||||
top-level statement.
|
||||
|
||||
This must be a member of THD and not of LEX, because warnings are
|
||||
detected and issued in different places (@c
|
||||
decide_logging_format() and @c binlog_query(), respectively).
|
||||
Between these calls, the THD->lex object may change; e.g., if a
|
||||
stored routine is invoked. Only THD persists between the calls.
|
||||
*/
|
||||
uint32 binlog_unsafe_warning_flags;
|
||||
|
||||
void issue_unsafe_warnings();
|
||||
|
||||
/*
|
||||
Number of outstanding table maps, i.e., table maps in the
|
||||
transaction cache.
|
||||
*/
|
||||
uint binlog_table_maps;
|
||||
|
||||
enum enum_binlog_flag {
|
||||
BINLOG_FLAG_UNSAFE_STMT_PRINTED,
|
||||
BINLOG_FLAG_COUNT
|
||||
};
|
||||
|
||||
/**
|
||||
Flags with per-thread information regarding the status of the
|
||||
binary log.
|
||||
*/
|
||||
uint32 binlog_flags;
|
||||
public:
|
||||
uint get_binlog_table_maps() const {
|
||||
return binlog_table_maps;
|
||||
}
|
||||
void clear_binlog_table_maps() {
|
||||
binlog_table_maps= 0;
|
||||
}
|
||||
#endif /* MYSQL_CLIENT */
|
||||
|
||||
public:
|
||||
@ -1792,8 +1842,6 @@ public:
|
||||
char scramble[SCRAMBLE_LENGTH+1];
|
||||
|
||||
bool slave_thread, one_shot_set;
|
||||
/* tells if current statement should binlog row-based(1) or stmt-based(0) */
|
||||
bool current_stmt_binlog_row_based;
|
||||
bool locked, some_tables_deleted;
|
||||
bool last_cuted_field;
|
||||
bool no_errors, password;
|
||||
@ -1950,27 +1998,18 @@ public:
|
||||
|
||||
#ifndef MYSQL_CLIENT
|
||||
enum enum_binlog_query_type {
|
||||
/*
|
||||
The query can be logged row-based or statement-based
|
||||
*/
|
||||
/* The query can be logged in row format or in statement format. */
|
||||
ROW_QUERY_TYPE,
|
||||
|
||||
/*
|
||||
The query has to be logged statement-based
|
||||
*/
|
||||
/* The query has to be logged in statement format. */
|
||||
STMT_QUERY_TYPE,
|
||||
|
||||
/*
|
||||
The query represents a change to a table in the "mysql"
|
||||
database and is currently mapped to ROW_QUERY_TYPE.
|
||||
*/
|
||||
MYSQL_QUERY_TYPE,
|
||||
QUERY_TYPE_COUNT
|
||||
};
|
||||
|
||||
int binlog_query(enum_binlog_query_type qtype,
|
||||
char const *query, ulong query_len,
|
||||
bool is_trans, bool suppress_use,
|
||||
char const *query, ulong query_len, bool is_trans,
|
||||
bool direct, bool suppress_use,
|
||||
int errcode);
|
||||
#endif
|
||||
|
||||
@ -2019,6 +2058,21 @@ public:
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
/**
|
||||
Returns TRUE if session is in a multi-statement transaction mode.
|
||||
|
||||
OPTION_NOT_AUTOCOMMIT: When autocommit is off, a multi-statement
|
||||
transaction is implicitly started on the first statement after a
|
||||
previous transaction has been ended.
|
||||
|
||||
OPTION_BEGIN: Regardless of the autocommit status, a multi-statement
|
||||
transaction can be explicitly started with the statements "START
|
||||
TRANSACTION", "BEGIN [WORK]", "[COMMIT | ROLLBACK] AND CHAIN", etc.
|
||||
*/
|
||||
inline bool in_multi_stmt_transaction()
|
||||
{
|
||||
return options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN);
|
||||
}
|
||||
inline bool fill_derived_tables()
|
||||
{
|
||||
return !stmt_arena->is_stmt_prepare() && !lex->only_view_structure();
|
||||
@ -2156,31 +2210,51 @@ public:
|
||||
void set_n_backup_active_arena(Query_arena *set, Query_arena *backup);
|
||||
void restore_active_arena(Query_arena *set, Query_arena *backup);
|
||||
|
||||
inline void set_current_stmt_binlog_row_based_if_mixed()
|
||||
/*
|
||||
@todo Make these methods private or remove them completely. Only
|
||||
decide_logging_format should call them. /Sven
|
||||
*/
|
||||
inline void set_current_stmt_binlog_format_row_if_mixed()
|
||||
{
|
||||
DBUG_ENTER("set_current_stmt_binlog_format_row_if_mixed");
|
||||
/*
|
||||
This should only be called from decide_logging_format.
|
||||
|
||||
@todo Once we have ensured this, uncomment the following
|
||||
statement, remove the big comment below that, and remove the
|
||||
in_sub_stmt==0 condition from the following 'if'.
|
||||
*/
|
||||
/* DBUG_ASSERT(in_sub_stmt == 0); */
|
||||
/*
|
||||
If in a stored/function trigger, the caller should already have done the
|
||||
change. We test in_sub_stmt to prevent introducing bugs where people
|
||||
wouldn't ensure that, and would switch to row-based mode in the middle
|
||||
of executing a stored function/trigger (which is too late, see also
|
||||
reset_current_stmt_binlog_row_based()); this condition will make their
|
||||
reset_current_stmt_binlog_format_row()); this condition will make their
|
||||
tests fail and so force them to propagate the
|
||||
lex->binlog_row_based_if_mixed upwards to the caller.
|
||||
*/
|
||||
if ((variables.binlog_format == BINLOG_FORMAT_MIXED) &&
|
||||
(in_sub_stmt == 0))
|
||||
current_stmt_binlog_row_based= TRUE;
|
||||
set_current_stmt_binlog_format_row();
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
inline void set_current_stmt_binlog_row_based()
|
||||
inline void set_current_stmt_binlog_format_row()
|
||||
{
|
||||
current_stmt_binlog_row_based= TRUE;
|
||||
DBUG_ENTER("set_current_stmt_binlog_format_row");
|
||||
current_stmt_binlog_format= BINLOG_FORMAT_ROW;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
inline void clear_current_stmt_binlog_row_based()
|
||||
inline void clear_current_stmt_binlog_format_row()
|
||||
{
|
||||
current_stmt_binlog_row_based= FALSE;
|
||||
DBUG_ENTER("clear_current_stmt_binlog_format_row");
|
||||
current_stmt_binlog_format= BINLOG_FORMAT_STMT;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
inline void reset_current_stmt_binlog_row_based()
|
||||
inline void reset_current_stmt_binlog_format_row()
|
||||
{
|
||||
DBUG_ENTER("reset_current_stmt_binlog_format_row");
|
||||
/*
|
||||
If there are temporary tables, don't reset back to
|
||||
statement-based. Indeed it could be that:
|
||||
@ -2195,19 +2269,19 @@ public:
|
||||
or trigger is decided when it starts executing, depending for example on
|
||||
the caller (for a stored function: if caller is SELECT or
|
||||
INSERT/UPDATE/DELETE...).
|
||||
|
||||
Don't reset binlog format for NDB binlog injector thread.
|
||||
*/
|
||||
DBUG_PRINT("debug",
|
||||
("temporary_tables: %s, in_sub_stmt: %s, system_thread: %s",
|
||||
YESNO(temporary_tables), YESNO(in_sub_stmt),
|
||||
show_system_thread(system_thread)));
|
||||
if ((temporary_tables == NULL) && (in_sub_stmt == 0) &&
|
||||
(system_thread != SYSTEM_THREAD_NDBCLUSTER_BINLOG))
|
||||
if ((temporary_tables == NULL) && (in_sub_stmt == 0))
|
||||
{
|
||||
current_stmt_binlog_row_based=
|
||||
test(variables.binlog_format == BINLOG_FORMAT_ROW);
|
||||
if (variables.binlog_format == BINLOG_FORMAT_ROW)
|
||||
set_current_stmt_binlog_format_row();
|
||||
else
|
||||
clear_current_stmt_binlog_format_row();
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2311,7 +2385,11 @@ public:
|
||||
Protected with LOCK_thd_data mutex.
|
||||
*/
|
||||
void set_query(char *query_arg, uint32 query_length_arg);
|
||||
|
||||
int decide_logging_format(TABLE_LIST *tables);
|
||||
|
||||
private:
|
||||
|
||||
/** The current internal error handler for this thread, or NULL. */
|
||||
Internal_error_handler *m_internal_handler;
|
||||
/**
|
||||
|
Reference in New Issue
Block a user