1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Initial push of codership-wsrep API implementation for MariaDB.

Merge of:
lp:maria/5.5, #3334: http://bazaar.launchpad.net/~maria-captains/maria/5.5/revision/3334
lp:codership-mysql/5.5, #3725: http://bazaar.launchpad.net/~codership/codership-mysql/wsrep-5.5/revision/3725
This commit is contained in:
Seppo Jaakola
2012-04-13 01:33:24 +03:00
parent 51c77ec5d4
commit 2fc1ec4356
80 changed files with 7196 additions and 64 deletions

View File

@ -20,6 +20,32 @@
#define SQL_CLASS_INCLUDED
/* Classes in mysql */
#ifdef WITH_WSREP
#include "../wsrep/wsrep_api.h"
//#include "wsrep_mysqld.h"
enum wsrep_exec_mode {
LOCAL_STATE,
REPL_RECV,
TOTAL_ORDER,
LOCAL_COMMIT,
};
enum wsrep_query_state {
QUERY_IDLE,
QUERY_EXEC,
QUERY_COMMITTING,
QUERY_EXITING,
QUERY_ROLLINGBACK,
};
enum wsrep_conflict_state {
NO_CONFLICT,
MUST_ABORT,
ABORTING,
ABORTED,
MUST_REPLAY,
REPLAYING,
RETRY_AUTOCOMMIT,
};
#endif
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
@ -45,6 +71,15 @@
THR_LOCK_INFO */
#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
struct wsrep_thd_shadow {
ulonglong options;
enum wsrep_exec_mode wsrep_exec_mode;
Vio *vio;
ulong tx_isolation;
};
#endif
class Reprepare_observer;
class Relay_log_info;
@ -572,6 +607,11 @@ typedef struct system_variables
ulong wt_timeout_short, wt_deadlock_search_depth_short;
ulong wt_timeout_long, wt_deadlock_search_depth_long;
#ifdef WITH_WSREP
my_bool wsrep_on;
my_bool wsrep_causal_reads;
ulong wsrep_retry_autocommit;
#endif
double long_query_time_double;
} SV;
@ -965,6 +1005,9 @@ struct st_savepoint {
/** State of metadata locks before this savepoint was set. */
MDL_savepoint mdl_savepoint;
};
#ifdef WITH_WSREP
void wsrep_cleanup_transaction(THD *thd); // THD.transactions.cleanup calls it
#endif
enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED, XA_ROLLBACK_ONLY};
extern const char *xa_state_names[];
@ -1781,7 +1824,7 @@ public:
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;
return (WSREP_FORMAT((ulong)current_stmt_binlog_format) == BINLOG_FORMAT_ROW);
}
private:
@ -1839,7 +1882,11 @@ public:
*/
CHANGED_TABLE_LIST* changed_tables;
MEM_ROOT mem_root; // Transaction-life memory allocation pool
#ifdef WITH_WSREP
void cleanup(THD *thd)
#else
void cleanup()
#endif
{
changed_tables= 0;
savepoints= 0;
@ -1852,6 +1899,11 @@ public:
if (!xid_state.rm_error)
xid_state.xid.null();
free_root(&mem_root,MYF(MY_KEEP_PREALLOC));
#ifdef WITH_WSREP
// Todo: convert into a plugin method
// wsrep's post-commit. LOCAL_COMMIT designates wsrep's commit was ok
if (WSREP(thd)) wsrep_cleanup_transaction(thd);
#endif /* WITH_WSREP */
}
my_bool is_active()
{
@ -2314,6 +2366,31 @@ public:
query_id_t first_query_id;
} binlog_evt_union;
#ifdef WITH_WSREP
const bool wsrep_applier; /* dedicated slave applier thread */
bool wsrep_client_thread; /* to identify client threads*/
enum wsrep_exec_mode wsrep_exec_mode;
query_id_t wsrep_last_query_id;
enum wsrep_query_state wsrep_query_state;
enum wsrep_conflict_state wsrep_conflict_state;
mysql_mutex_t LOCK_wsrep_thd;
mysql_cond_t COND_wsrep_thd;
wsrep_seqno_t wsrep_trx_seqno;
uint32 wsrep_rand;
Relay_log_info* wsrep_rli;
bool wsrep_converted_lock_session;
wsrep_trx_handle_t wsrep_trx_handle;
bool wsrep_seqno_changed;
#ifdef WSREP_PROC_INFO
char wsrep_info[128]; /* string for dynamic proc info */
#endif /* WSREP_PROC_INFO */
ulong wsrep_retry_counter; // of autocommit
bool wsrep_PA_safe;
char* wsrep_retry_query;
size_t wsrep_retry_query_len;
enum enum_server_command wsrep_retry_command;
bool wsrep_consistency_check;
#endif /* WITH_WSREP */
/**
Internal parser state.
Note that since the parser is not re-entrant, we keep only one parser
@ -2345,7 +2422,11 @@ public:
/* Debug Sync facility. See debug_sync.cc. */
struct st_debug_sync_control *debug_sync_control;
#endif /* defined(ENABLED_DEBUG_SYNC) */
#ifdef WITH_WSREP
THD(bool is_applier = false);
#else
THD();
#endif
~THD();
void init(void);
@ -2741,7 +2822,7 @@ public:
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) &&
if ((WSREP_FORMAT(variables.binlog_format) == BINLOG_FORMAT_MIXED) &&
(in_sub_stmt == 0))
set_current_stmt_binlog_format_row();
@ -2783,7 +2864,7 @@ public:
show_system_thread(system_thread)));
if (in_sub_stmt == 0)
{
if (variables.binlog_format == BINLOG_FORMAT_ROW)
if (WSREP_FORMAT(variables.binlog_format) == BINLOG_FORMAT_ROW)
set_current_stmt_binlog_format_row();
else if (temporary_tables == NULL)
clear_current_stmt_binlog_format_row();