diff options
author | unknown <serg@serg.mylan> | 2005-01-16 13:16:23 +0100 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2005-01-16 13:16:23 +0100 |
commit | 88bd301d36dd00735f6380d37a93594cc8539fe1 (patch) | |
tree | 58ca68b7179b2df96e7b2f14a1da686cc9d2b959 /sql/sql_class.h | |
parent | 83e58bc0eaa2856e54b08c84417192b07db68a86 (diff) | |
download | mariadb-git-88bd301d36dd00735f6380d37a93594cc8539fe1.tar.gz |
XA (not completely polished out yet)
include/my_pthread.h:
cleanup. don't use gcc extensions
innobase/include/trx0sys.ic:
Jan's fix for innobase_xa_prepare
innobase/read/read0read.c:
Jan's fix for innobase_xa_prepare
innobase/trx/trx0trx.c:
Jan's fix for innobase_xa_prepare
mysql-test/include/varchar.inc:
test fix
mysql-test/r/ctype_ucs.result:
new log event - all binlog positions are changed :(
mysql-test/r/drop_temp_table.result:
new log event - all binlog positions are changed :(
mysql-test/r/insert_select.result:
new log event - all binlog positions are changed :(
mysql-test/r/mix_innodb_myisam_binlog.result:
new log event - all binlog positions are changed :(
mysql-test/r/myisam.result:
test fix
mysql-test/r/rpl000015.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_change_master.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_charset.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_error_ignored_table.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_flush_log_loop.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_flush_tables.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_loaddata.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_loaddata_rule_m.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_loaddata_rule_s.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_log.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_log_pos.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_max_relay_size.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_relayrotate.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_replicate_do.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_reset_slave.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_rotate_logs.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_server_id1.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_server_id2.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_temporary.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_timezone.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_until.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_user_variables.result:
new log event - all binlog positions are changed :(
mysql-test/r/user_var.result:
new log event - all binlog positions are changed :(
mysql-test/t/ctype_ucs.test:
new log event - all binlog positions are changed :(
mysql-test/t/mix_innodb_myisam_binlog.test:
new log event - all binlog positions are changed :(
mysql-test/t/mysqlbinlog.test:
new log event - all binlog positions are changed :(
mysql-test/t/mysqlbinlog2.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_charset.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_error_ignored_table.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_loaddata_rule_m.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_loaddata_rule_s.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_log.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_log_pos.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_user_variables.test:
new log event - all binlog positions are changed :(
mysql-test/t/user_var.test:
new log event - all binlog positions are changed :(
mysys/hash.c:
typo fixed
sql/ha_berkeley.cc:
handlerton framework
sql/ha_berkeley.h:
handlerton framework
sql/ha_innodb.cc:
handlerton framework
sql/ha_innodb.h:
handlerton framework
sql/handler.cc:
new transaction handling, handlerton framework, two-phase commit, XA support
sql/handler.h:
new transaction handling, handlerton framework, two-phase commit, XA support
sql/lex.h:
XA commands
sql/log.cc:
new transaction handling, handlerton framework, two-phase commit,
XA support, tc-logging, TC_LOG_MMAP class
sql/log_event.cc:
Xid_log_event
sql/log_event.h:
Xid_log_event, LOG_EVENT_BINLOG_CLOSED_F flag
sql/mysql_priv.h:
wrapper for query_id++
sql/mysqld.cc:
new command-line options --log-tc, --log-tc-size, --tc-heuristic-recover,
new status variables Tc_log_page_size, Tc_log_max_pages_used, Tc_log_page_waits.
init/stop tc logging
sql/set_var.h:
warning fixed
sql/share/errmsg.txt:
XA error messages
sql/sp_head.cc:
s/query_id++/next_query_id()/
sql/sql_base.cc:
typo fixed. new transaction handling.
sql/sql_class.cc:
cleanup of THD.transaction
sql/sql_class.h:
TC_LOG classes, new status variables, new savepoint handling, XA support
sql/sql_insert.cc:
comments
sql/sql_lex.cc:
s/found_colon/found_semicolon/
sql/sql_lex.h:
SQLCOM_XA_xxx, XA related changes in Lex
sql/sql_parse.cc:
cleanup, XA commands, new savepoint handling
sql/sql_repl.cc:
two functions moved to log.cc
sql/sql_repl.h:
two functions moved to log.cc
sql/sql_trigger.cc:
s/lex.name_and_length/lex.ident/
sql/sql_yacc.yy:
XA commands, cleanup
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 170 |
1 files changed, 151 insertions, 19 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 6cec2c2c787..8c8880799b1 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -43,6 +43,101 @@ enum enum_check_fields { CHECK_FIELD_IGNORE, CHECK_FIELD_WARN, extern char internal_table_name[2]; extern const char **errmesg; +#define TC_LOG_PAGE_SIZE 8192 +#define TC_LOG_MIN_SIZE (3*TC_LOG_PAGE_SIZE) +extern uint opt_tc_log_size; +extern uint tc_log_max_pages_used; +extern uint tc_log_page_size; +extern uint tc_log_page_waits; + +#define TC_HEURISTIC_RECOVER_COMMIT 1 +#define TC_HEURISTIC_RECOVER_ROLLBACK 2 +extern uint tc_heuristic_recover; + +/* + Transaction Coordinator log - a base abstract class + for two different implementations +*/ +class TC_LOG +{ + public: + int using_heuristic_recover(); + TC_LOG() {} + virtual ~TC_LOG() {} + + virtual int open(const char *opt_name)=0; + virtual void close()=0; + virtual int log(THD *thd, my_xid xid)=0; + virtual void unlog(ulong cookie, my_xid xid)=0; +}; + +class TC_LOG_DUMMY: public TC_LOG // use it to disable the logging +{ + public: + int open(const char *opt_name) { return 0; } + void close() { } + int log(THD *thd, my_xid xid) { return 1; } + void unlog(ulong cookie, my_xid xid) { } +}; + +class TC_LOG_MMAP: public TC_LOG +{ + private: + + typedef enum { + POOL, // page is in pool + ERROR, // last sync failed + DIRTY // new xids added since last sync + } PAGE_STATE; + + typedef struct st_page { + struct st_page *next; // page a linked in a fifo queue + my_xid *start, *end; // usable area of a page + my_xid *ptr; // next xid will be written here + int size, free; // max and current number of free xid slots on the page + int waiters; // number of waiters on condition + PAGE_STATE state; // see above + pthread_mutex_t lock; // to access page data or control structure + pthread_cond_t cond; // to wait for a sync + } PAGE; + + char logname[FN_REFLEN]; + File fd; + uint file_length, npages, inited; + uchar *data; + struct st_page *pages, *in_sync, *active, *pool, *pool_last; + pthread_mutex_t LOCK_active, LOCK_pool, LOCK_sync; + pthread_cond_t COND_pool, COND_active; + + public: + TC_LOG_MMAP(): inited(0) {} + int open(const char *opt_name); + void close(); + int log(THD *thd, my_xid xid); + void unlog(ulong cookie, my_xid xid); + int recover(); + + private: + void get_active_from_pool(); + int sync(); + int overflow(); + void compact_active(); + void lock_queue(pthread_mutex_t *lock) + { + if (in_sync) + pthread_mutex_lock(lock); + } + void unlock_queue(pthread_mutex_t *lock) + { + if (in_sync) + pthread_mutex_unlock(lock); + } +}; + +extern TC_LOG *tc_log; +extern TC_LOG_MMAP tc_log_mmap; +extern TC_LOG_DUMMY tc_log_dummy; + /* log info errors */ #define LOG_INFO_EOF -1 #define LOG_INFO_IO -2 @@ -81,8 +176,18 @@ typedef struct st_user_var_events class Log_event; -class MYSQL_LOG - { +/* + TODO split MYSQL_LOG into base MYSQL_LOG and + MYSQL_QUERY_LOG, MYSQL_SLOW_LOG, MYSQL_BIN_LOG + most of the code from MYSQL_LOG should be in the MYSQL_BIN_LOG + only (TC_LOG included) + + TODO use mmap instead of IO_CACHE for binlog + (mmap+fsync is two times faster than write+fsync) +*/ + +class MYSQL_LOG: public TC_LOG +{ private: /* LOCK_log and LOCK_index are inited by init_pthread_objects() */ pthread_mutex_t LOCK_log, LOCK_index; @@ -108,8 +213,8 @@ class MYSQL_LOG etc. So in 4.x this is 1 for relay logs, 0 for binlogs. In 5.0 it's 0 for relay logs too! */ - bool no_auto_events; - /* + bool no_auto_events; + /* The max size before rotation (usable only if log_type == LOG_BIN: binary logs and relay logs). For a binlog, max_size should be max_binlog_size. @@ -117,16 +222,26 @@ class MYSQL_LOG max_binlog_size otherwise. max_size is set in init(), and dynamically changed (when one does SET GLOBAL MAX_BINLOG_SIZE|MAX_RELAY_LOG_SIZE) by fix_max_binlog_size and - fix_max_relay_log_size). + fix_max_relay_log_size). */ ulong max_size; + + ulong prepared_xids; /* for tc log - number of xids to remember */ + pthread_mutex_t LOCK_prep_xids; + pthread_cond_t COND_prep_xids; friend class Log_event; public: MYSQL_LOG(); ~MYSQL_LOG(); - /* + int open(const char *opt_name); + void close(); + int log(THD *thd, my_xid xid); + void unlog(ulong cookie, my_xid xid); + int recover(IO_CACHE *log, Format_description_log_event *fdle); + + /* These describe the log's format. This is used only for relay logs. _for_exec is used by the SQL thread, _for_queue by the I/O thread. It's necessary to have 2 distinct objects, because the I/O thread may be reading @@ -193,8 +308,6 @@ public: int purge_first_log(struct st_relay_log_info* rli, bool included); bool reset_logs(THD* thd); void close(uint exiting); - bool cut_spurious_tail(); - void report_pos_in_innodb(); // iterating through the log index file int find_log_pos(LOG_INFO* linfo, const char* log_name, @@ -479,6 +592,10 @@ typedef struct system_status_var ulong ha_rollback_count; ulong ha_update_count; ulong ha_write_count; + ulong ha_prepare_count; + ulong ha_discover_count; + ulong ha_savepoint_count; + ulong ha_savepoint_rollback_count; /* KEY_CACHE parts. These are copies of the original */ ulong key_blocks_changed; @@ -757,6 +874,13 @@ private: Statement *last_found_statement; }; +struct st_savepoint { + struct st_savepoint *prev; + char *name; + uint length, nht; +}; + +enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED}; /* A registry for item tree transformations performed during @@ -899,15 +1023,15 @@ public: thr_lock_type update_lock_default; delayed_insert *di; my_bool tablespace_op; /* This is TRUE in DISCARD/IMPORT TABLESPACE */ + /* container for handler's private per-connection data */ + void *ha_data[MAX_HA]; struct st_transactions { - IO_CACHE trans_log; // Inited ONLY if binlog is open ! + SAVEPOINT *savepoints; THD_TRANS all; // Trans since BEGIN WORK THD_TRANS stmt; // Trans for current statement - uint bdb_lock_count; -#ifdef HAVE_NDBCLUSTER_DB - void* thd_ndb; -#endif bool on; + XID xid; + enum xa_states xa_state; /* Tables changed in transaction (that must be invalidated in query cache). List contain only transactional tables, that not invalidated in query @@ -918,8 +1042,18 @@ public: void cleanup() { changed_tables = 0; +#ifdef USING_TRANSACTIONS free_root(&mem_root,MYF(MY_KEEP_PREALLOC)); +#endif } +#ifdef USING_TRANSACTIONS + st_transactions() + { + bzero((char*)this, sizeof(*this)); + xid.null(); + init_sql_alloc(&mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0); + } +#endif } transaction; Field *dupp_field; #ifndef __WIN__ @@ -1115,7 +1249,7 @@ public: inline ulonglong insert_id(void) { if (!last_insert_id_used) - { + { last_insert_id_used=1; current_insert_id=last_insert_id; } @@ -1124,13 +1258,11 @@ public: inline ulonglong found_rows(void) { return limit_found_rows; - } + } inline bool active_transaction() { -#ifdef USING_TRANSACTIONS - return (transaction.all.bdb_tid != 0 || - transaction.all.innodb_active_trans != 0 || - transaction.all.ndb_tid != 0); +#ifdef USING_TRANSACTIONS + return server_status & SERVER_STATUS_IN_TRANS; #else return 0; #endif |