/* The transaction handle; every session has a trx object which is freed only
when the session is freed; in addition there may be session-less transactions
rolling back after a database recovery */
typedef struct trx_struct trx_t;
struct trx_struct{
    ulint        magic_n;

    /* These fields are not protected by any mutex. */
    const char*    op_info;    /*!< English text describing the
                    current operation, or an empty
                    string */
    ulint        conc_state;    /*!< state of the trx from the point
                    of view of concurrency control:
                    TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY,
                    ... */
    /*------------------------------*/
    /* MySQL has a transaction coordinator to coordinate two phase
           commit between multiple storage engines and the binary log. When
           an engine participates in a transaction, it's responsible for
           registering itself using the trans_register_ha() API. */
    unsigned    is_registered:;/* This flag is set to 1 after the
                           transaction has been registered with
                           the coordinator using the XA API, and
                           is set to 0 after commit or rollback. */
    unsigned    owns_prepare_mutex:;/* 1 if owns prepare mutex, if
                    this is set to 1 then registered should
                    also be set to 1. This is used in the
                    XA code */
    /*------------------------------*/
    ulint        isolation_level;/* TRX_ISO_REPEATABLE_READ, ... */
    ulint        check_foreigns;    /* normally TRUE, but if the user
                    wants to suppress foreign key checks,
                    (in table imports, for example) we
                    set this FALSE */
    ulint        check_unique_secondary;
                    /* normally TRUE, but if the user
                    wants to speed up inserts by
                    suppressing unique key checks
                    for secondary indexes when we decide
                    if we can use the insert buffer for
                    them, we set this FALSE */
    ulint        support_xa;    /*!< normally we do the XA two-phase
                    commit steps, but by setting this to
                    FALSE, one can save CPU time and about
                    150 bytes in the undo log size as then
                    we skip XA steps */
    ulint        flush_log_later;/* In 2PC, we hold the
                    prepare_commit mutex across
                    both phases. In that case, we
                    defer flush of the logs to disk
                    until after we release the
                    mutex. */
    ulint        must_flush_log_later;/* this flag is set to TRUE in
                    trx_commit_off_kernel() if
                    flush_log_later was TRUE, and there
                    were modifications by the transaction;
                    in that case we must flush the log
                    in trx_commit_complete_for_mysql() */
    ulint        duplicates;    /*!< TRX_DUP_IGNORE | TRX_DUP_REPLACE */
    ulint        has_search_latch;
                    /* TRUE if this trx has latched the
                    search system latch in S-mode */
    ulint        deadlock_mark;    /*!< a mark field used in deadlock
                    checking algorithm.  */
    trx_dict_op_t    dict_operation;    /**< @see enum trx_dict_op */

    /* Fields protected by the srv_conc_mutex. */
    ulint        declared_to_be_inside_innodb;
                    /* this is TRUE if we have declared
                    this transaction in
                    srv_conc_enter_innodb to be inside the
                    InnoDB engine */

    /* Fields protected by dict_operation_lock. The very latch
    it is used to track. */
    ulint        dict_operation_lock_mode;
                    /*!< 0, RW_S_LATCH, or RW_X_LATCH:
                    the latch mode trx currently holds
                    on dict_operation_lock */

    /* All the next fields are protected by the kernel mutex, except the
    undo logs which are protected by undo_mutex */
    ulint        is_purge;    /*!< 0=user transaction, 1=purge */
    ulint        is_recovered;    /*!< 0=normal transaction,
                    1=recovered, must be rolled back */
    ulint        que_state;    /*!< valid when conc_state
                    == TRX_ACTIVE: TRX_QUE_RUNNING,
                    TRX_QUE_LOCK_WAIT, ... */
    ulint        handling_signals;/* this is TRUE as long as the trx
                    is handling signals */
    time_t        start_time;    /*!< time the trx object was created
                    or the state last time became
                    TRX_ACTIVE */
    trx_id_t    id;        /*!< transaction id */
    XID        xid;        /*!< X/Open XA transaction
                    identification to identify a
                    transaction branch */
    trx_id_t    no;        /*!< transaction serialization number ==
                    max trx id when the transaction is
                    moved to COMMITTED_IN_MEMORY state */
    ib_uint64_t    commit_lsn;    /*!< lsn at the time of the commit */
    table_id_t    table_id;    /*!< Table to drop iff dict_operation
                    is TRUE, or 0. */
    /*------------------------------*/
    void*        mysql_thd;    /*!< MySQL thread handle corresponding
                    to this trx, or NULL */
    const char*    mysql_log_file_name;
                    /* if MySQL binlog is used, this field
                    contains a pointer to the latest file
                    name; this is NULL if binlog is not
                    used */
    ib_int64_t    mysql_log_offset;/* if MySQL binlog is used, this field
                    contains the end offset of the binlog
                    entry */
    /*------------------------------*/
    ulint        n_mysql_tables_in_use; /* number of Innobase tables
                    used in the processing of the current
                    SQL statement in MySQL */
    ulint        mysql_n_tables_locked;
                    /* how many tables the current SQL
                    statement uses, except those
                    in consistent read */
    ulint        search_latch_timeout;
                    /* If we notice that someone is
                    waiting for our S-lock on the search
                    latch to be released, we wait in
                    row0sel.c for BTR_SEA_TIMEOUT new
                    searches until we try to keep
                    the search latch again over
                    calls from MySQL; this is intended
                    to reduce contention on the search
                    latch */
    /*------------------------------*/
    ulint        n_tickets_to_enter_innodb;
                    /* this can be > 0 only when
                    declared_to_... is TRUE; when we come
                    to srv_conc_innodb_enter, if the value
                    here is > 0, we decrement this by 1 */
    /*------------------------------*/
    UT_LIST_NODE_T(trx_t)
            trx_list;    /*!< list of transactions */
    UT_LIST_NODE_T(trx_t)
            mysql_trx_list;    /*!< list of transactions created for
                    MySQL */
    /*------------------------------*/
    ulint        error_state;    /*!< 0 if no error, otherwise error
                    number; NOTE That ONLY the thread
                    doing the transaction is allowed to
                    set this field: this is NOT protected
                    by the kernel mutex */
    const dict_index_t*error_info;    /*!< if the error number indicates a
                    duplicate key error, a pointer to
                    the problematic index is stored here */
    ulint        error_key_num;    /*!< if the index creation fails to a
                    duplicate key error, a mysql key
                    number of that index is stored here */
    sess_t*        sess;        /*!< session of the trx, NULL if none */
    que_t*        graph;        /*!< query currently run in the session,
                    or NULL if none; NOTE that the query
                    belongs to the session, and it can
                    survive over a transaction commit, if
                    it is a stored procedure with a COMMIT
                    WORK statement, for instance */
    ulint        n_active_thrs;    /*!< number of active query threads */
    que_t*        graph_before_signal_handling;
                    /* value of graph when signal handling
                    for this trx started: this is used to
                    return control to the original query
                    graph for error processing */
    trx_sig_t    sig;        /*!< one signal object can be allocated
                    in this space, avoiding mem_alloc */
    UT_LIST_BASE_NODE_T(trx_sig_t)
            signals;    /*!< queue of processed or pending
                    signals to the trx */
    UT_LIST_BASE_NODE_T(trx_sig_t)
            reply_signals;    /*!< list of signals sent by the query
                    threads of this trx for which a thread
                    is waiting for a reply; if this trx is
                    killed, the reply requests in the list
                    must be canceled */
    /*------------------------------*/
    lock_t*        wait_lock;    /*!< if trx execution state is
                    TRX_QUE_LOCK_WAIT, this points to
                    the lock request, otherwise this is
                    NULL */
    ibool        was_chosen_as_deadlock_victim;
                    /* when the transaction decides to wait
                    for a lock, it sets this to FALSE;
                    if another transaction chooses this
                    transaction as a victim in deadlock
                    resolution, it sets this to TRUE */
    time_t        wait_started;    /*!< lock wait started at this time */
    UT_LIST_BASE_NODE_T(que_thr_t)
            wait_thrs;    /*!< query threads belonging to this
                    trx that are in the QUE_THR_LOCK_WAIT
                    state */
    /*------------------------------*/
    mem_heap_t*    lock_heap;    /*!< memory heap for the locks of the
                    transaction */
    UT_LIST_BASE_NODE_T(lock_t)
            trx_locks;    /*!< locks reserved by the transaction */
    /*------------------------------*/
    mem_heap_t*    global_read_view_heap;
                    /* memory heap for the global read
                    view */
    read_view_t*    global_read_view;
                    /* consistent read view associated
                    to a transaction or NULL */
    read_view_t*    read_view;    /*!< consistent read view used in the
                    transaction or NULL, this read view
                    if defined can be normal read view
                    associated to a transaction (i.e.
                    same as global_read_view) or read view
                    associated to a cursor */
    /*------------------------------*/
    UT_LIST_BASE_NODE_T(trx_named_savept_t)
            trx_savepoints;    /*!< savepoints set with SAVEPOINT ...,
                    oldest first */
    /*------------------------------*/
    mutex_t        undo_mutex;    /*!< mutex protecting the fields in this
                    section (down to undo_no_arr), EXCEPT
                    last_sql_stat_start, which can be
                    accessed only when we know that there
                    cannot be any activity in the undo
                    logs! */
    undo_no_t    undo_no;    /*!< next undo log record number to
                    assign; since the undo log is
                    private for a transaction, this
                    is a simple ascending sequence
                    with no gaps; thus it represents
                    the number of modified/inserted
                    rows in a transaction */
    trx_savept_t    last_sql_stat_start;
                    /* undo_no when the last sql statement
                    was started: in case of an error, trx
                    is rolled back down to this undo
                    number; see note at undo_mutex! */
    trx_rseg_t*    rseg;        /*!< rollback segment assigned to the
                    transaction, or NULL if not assigned
                    yet */
    trx_undo_t*    insert_undo;    /*!< pointer to the insert undo log, or
                    NULL if no inserts performed yet */
    trx_undo_t*    update_undo;    /*!< pointer to the update undo log, or
                    NULL if no update performed yet */
    undo_no_t    roll_limit;    /*!< least undo number to undo during
                    a rollback */
    ulint        pages_undone;    /*!< number of undo log pages undone
                    since the last undo log truncation */
    trx_undo_arr_t*    undo_no_arr;    /*!< array of undo numbers of undo log
                    records which are currently processed
                    by a rollback operation */
    /*------------------------------*/
    ulint        n_autoinc_rows;    /*!< no. of AUTO-INC rows required for
                    an SQL statement. This is useful for
                    multi-row INSERTs */
    ib_vector_t*    autoinc_locks;  /* AUTOINC locks held by this
                    transaction. Note that these are
                    also in the lock list trx_locks. This
                    vector needs to be freed explicitly
                    when the trx_t instance is desrtoyed */
    /*------------------------------*/
    ];    /*!< detailed error message for last
                    error, or empty. */
};

typedef struct trx_struct trx_t;的更多相关文章

  1. [转载]彻底弄清struct和typedef struct

    struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int ...

  2. struct和typedef struct彻底明白了

    struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int ...

  3. [C语言]关于struct和typedef struct

    在C中定义一个结构体类型要用typedef: *************************************************************************** t ...

  4. struct和typedef struct用法

    参考:http://www.cnblogs.com/qyaizs/articles/2039101.html C语言: typedef struct Student{ int score; }Stu; ...

  5. struct和typedef struct

    转自:http://www.cnblogs.com/qyaizs/articles/2039101.html struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++ ...

  6. typedef struct 结构体

    typedef struct _TTTT_ {   int    i;  }TT_TT; 定义变量如下: struct _TTTT_  NewTT;方法1 TT_TT NewTT;方法2 是声明和定义 ...

  7. C语言中的struct和typedef struct<转载>

    原文:http://www.nowamagic.net/librarys/veda/detail/1785 typedef为C语言的关键字,作用是为一种数据类型定义一个新名字.这里的数据类型包括内部数 ...

  8. C/C++语法知识:typedef struct 用法详解

    第一篇:typedef struct与struct的区别 1. 基本解释 typedef为C语言的关键字,作用是为一种数据类型定义一个新名字.这里的数据类型包括内部数据类型(int,char等)和自定 ...

  9. struct和typedef struct的区别

    当typedef与结构结合使用时,会有一些比较复杂的情况,而且在C语言和C++里面有略有差别,因此从网上摘录了一些资料. 1 首先:      在C中定义一个结构体类型要用typedef:       ...

随机推荐

  1. 在C#中调用VBScript和JavaScript等脚本的实现

    在C#中调用VBScript.JavaScript等脚本的实现 作者:郑佐 2004-04-26 以前在做工作流(workflow)项目的时候,里面有一项就是在用户制定流程定义时可以编写脚本来控制活动 ...

  2. jquery的ajax同步和异步的理解及示例

    之前一直在写JQUERY代码的时候遇到AJAX加载数据都需要考虑代码运行顺序问题.最近的项目用了到AJAX同步.这个同步的意思是当JS代码加载到当前AJAX的时候会把页面里所有的代码停止加载,页面出去 ...

  3. IT架构之IT架构标准——思维导图

    参考: [日] 野村综合研究所系统咨询事业本部. 图解CIO工作指南. 周自恒译 人民邮电出版社,2014

  4. iOS第三方语音-讯飞语音

    官方网站:http://www.xfyun.cn/ 注册还要绑定微信,坑啊,识别率感觉没得微信语音好,但是微信语音审核一直不过,研究下这个 1.下载sdk,主要就下面几个文件,我主要用的是语音识别

  5. POJ 1316

    #include<iostream> using namespace std; #define NUM 10000 int main(){ }; int i; ; int j; ;i< ...

  6. 十大技巧优化Android App性能

    无论锤子还是茄子手机的不断冒出,Android系统的手机市场占有率目前来说还是最大的,因此基于Android开发的App数量也是很庞大的. 那么,如何能开发出更高性能的Android App?相信是软 ...

  7. 数据库(.udl)简单测试连接

    当我们烦于打开数据库进行连接的时候,我们可以用udl进行测试连接,并可以获得连接字符串. 1.新建一个txt文件,然后将后缀改成udl保存. 2.双击打开udl文件. 3.进行数据库连接测试. 4.用 ...

  8. 百度面试题——top K算法

    需求 从一亿个数据中,找出其中最小的10个数. 分析 最笨的方法就是将这一亿个数据,按从小到大进行排序,然后取前10个.这样的话,即使使用时间复杂度为nlogn的快排或堆排,由于元素会频繁的移动,效率 ...

  9. centOS学习part2:安装JDK及tomcat

    0 上一篇(http://www.cnblogs.com/souvenir/p/3875424.html)给大家介绍了centOS操作系统的安装,接下来我们来介绍centOS常用软件的安装以及配置,希 ...

  10. C# Socket 入门1(转)

    1.   服务端程序  1 using System;  2 using System.Collections.Generic;  3 using System.Text;  4 using Syst ...