~ubuntu-branches/ubuntu/lucid/mysql-dfsg-5.1/lucid-security

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/include/trx0trx.h

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 22:33:55 UTC
  • mto: (1.2.1) (37.1.1 lucid-security)
  • mto: This revision was merged to the branch mainline in revision 36.
  • Revision ID: package-import@ubuntu.com-20120222223355-ku1tb4r70osci6v2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
44
44
/** Number of transactions currently allocated for MySQL: protected by
45
45
the kernel mutex */
46
46
extern ulint    trx_n_mysql_transactions;
 
47
/** Number of transactions currently in the XA PREPARED state: protected by
 
48
the kernel mutex */
 
49
extern ulint    trx_n_prepared;
47
50
 
48
51
/********************************************************************//**
49
52
Releases the search latch if trx has reserved it. */
108
111
/*=====*/
109
112
        trx_t*  trx);   /*!< in, own: trx object */
110
113
/********************************************************************//**
 
114
At shutdown, frees a transaction object that is in the PREPARED state. */
 
115
UNIV_INTERN
 
116
void
 
117
trx_free_prepared(
 
118
/*==============*/
 
119
        trx_t*  trx)    /*!< in, own: trx object */
 
120
        __attribute__((nonnull));
 
121
/********************************************************************//**
111
122
Frees a transaction object for MySQL. */
112
123
UNIV_INTERN
113
124
void
214
225
/*******************************************************************//**
215
226
This function is used to find one X/Open XA distributed transaction
216
227
which is in the prepared state
217
 
@return trx or NULL */
 
228
@return trx or NULL; on match, the trx->xid will be invalidated */
218
229
UNIV_INTERN
219
230
trx_t *
220
231
trx_get_trx_by_xid(
221
232
/*===============*/
222
 
        XID*    xid);   /*!< in: X/Open XA transaction identification */
 
233
        const XID*      xid);   /*!< in: X/Open XA transaction identifier */
223
234
/**********************************************************************//**
224
235
If required, flushes the log to disk if we called trx_commit_for_mysql()
225
236
with trx->flush_log_later == TRUE.
338
349
 
339
350
/**********************************************************************//**
340
351
Prints info about a transaction to the given file. The caller must own the
341
 
kernel mutex and must have called
342
 
innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL
343
 
or InnoDB cannot meanwhile change the info printed here. */
 
352
kernel mutex. */
344
353
UNIV_INTERN
345
354
void
346
355
trx_print(
351
360
                                   use the default max length */
352
361
 
353
362
/** Type of data dictionary operation */
354
 
enum trx_dict_op {
 
363
typedef enum trx_dict_op {
355
364
        /** The transaction is not modifying the data dictionary. */
356
365
        TRX_DICT_OP_NONE = 0,
357
366
        /** The transaction is creating a table or an index, or
363
372
        existing table.  In crash recovery, the data dictionary
364
373
        must be locked, but the table must not be dropped. */
365
374
        TRX_DICT_OP_INDEX = 2
366
 
};
 
375
} trx_dict_op_t;
367
376
 
368
377
/**********************************************************************//**
369
378
Determine if a transaction is a dictionary operation.
393
402
trx_is_interrupted(
394
403
/*===============*/
395
404
        trx_t*  trx);   /*!< in: transaction */
 
405
/**********************************************************************//**
 
406
Determines if the currently running transaction is in strict mode.
 
407
@return TRUE if strict */
 
408
UNIV_INTERN
 
409
ibool
 
410
trx_is_strict(
 
411
/*==========*/
 
412
        trx_t*  trx);   /*!< in: transaction */
396
413
#else /* !UNIV_HOTBACKUP */
397
414
#define trx_is_interrupted(trx) FALSE
398
415
#endif /* !UNIV_HOTBACKUP */
465
482
 
466
483
struct trx_struct{
467
484
        ulint           magic_n;
468
 
        /* All the next fields are protected by the kernel mutex, except the
469
 
        undo logs which are protected by undo_mutex */
 
485
 
 
486
        /* These fields are not protected by any mutex. */
470
487
        const char*     op_info;        /*!< English text describing the
471
488
                                        current operation, or an empty
472
489
                                        string */
473
 
        unsigned        is_purge:1;     /*!< 0=user transaction, 1=purge */
474
 
        unsigned        is_recovered:1; /*!< 0=normal transaction,
475
 
                                        1=recovered, must be rolled back */
476
 
        unsigned        conc_state:2;   /*!< state of the trx from the point
 
490
        ulint           conc_state;     /*!< state of the trx from the point
477
491
                                        of view of concurrency control:
478
492
                                        TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY,
479
493
                                        ... */
480
 
        unsigned        que_state:2;    /*!< valid when conc_state == TRX_ACTIVE:
481
 
                                        TRX_QUE_RUNNING, TRX_QUE_LOCK_WAIT,
482
 
                                        ... */
483
 
        unsigned        isolation_level:2;/* TRX_ISO_REPEATABLE_READ, ... */
484
 
        unsigned        check_foreigns:1;/* normally TRUE, but if the user
 
494
        ulint           isolation_level;/* TRX_ISO_REPEATABLE_READ, ... */
 
495
        ulint           check_foreigns; /* normally TRUE, but if the user
485
496
                                        wants to suppress foreign key checks,
486
497
                                        (in table imports, for example) we
487
498
                                        set this FALSE */
488
 
        unsigned        check_unique_secondary:1;
 
499
        ulint           check_unique_secondary;
489
500
                                        /* normally TRUE, but if the user
490
501
                                        wants to speed up inserts by
491
502
                                        suppressing unique key checks
492
503
                                        for secondary indexes when we decide
493
504
                                        if we can use the insert buffer for
494
505
                                        them, we set this FALSE */
495
 
        unsigned        support_xa:1;   /*!< normally we do the XA two-phase
 
506
        ulint           support_xa;     /*!< normally we do the XA two-phase
496
507
                                        commit steps, but by setting this to
497
508
                                        FALSE, one can save CPU time and about
498
509
                                        150 bytes in the undo log size as then
499
510
                                        we skip XA steps */
500
 
        unsigned        flush_log_later:1;/* In 2PC, we hold the
 
511
        ulint           flush_log_later;/* In 2PC, we hold the
501
512
                                        prepare_commit mutex across
502
513
                                        both phases. In that case, we
503
514
                                        defer flush of the logs to disk
504
515
                                        until after we release the
505
516
                                        mutex. */
506
 
        unsigned        must_flush_log_later:1;/* this flag is set to TRUE in
 
517
        ulint           must_flush_log_later;/* this flag is set to TRUE in
507
518
                                        trx_commit_off_kernel() if
508
519
                                        flush_log_later was TRUE, and there
509
520
                                        were modifications by the transaction;
510
521
                                        in that case we must flush the log
511
522
                                        in trx_commit_complete_for_mysql() */
512
 
        unsigned        dict_operation:2;/**< @see enum trx_dict_op */
513
 
        unsigned        duplicates:2;   /*!< TRX_DUP_IGNORE | TRX_DUP_REPLACE */
514
 
        unsigned        active_trans:2; /*!< 1 - if a transaction in MySQL
 
523
        ulint           duplicates;     /*!< TRX_DUP_IGNORE | TRX_DUP_REPLACE */
 
524
        ulint           active_trans;   /*!< 1 - if a transaction in MySQL
515
525
                                        is active. 2 - if prepare_commit_mutex
516
526
                                        was taken */
517
 
        unsigned        has_search_latch:1;
 
527
        ulint           has_search_latch;
518
528
                                        /* TRUE if this trx has latched the
519
529
                                        search system latch in S-mode */
520
 
        unsigned        declared_to_be_inside_innodb:1;
 
530
        ulint           deadlock_mark;  /*!< a mark field used in deadlock
 
531
                                        checking algorithm.  */
 
532
        trx_dict_op_t   dict_operation; /**< @see enum trx_dict_op */
 
533
 
 
534
        /* Fields protected by the srv_conc_mutex. */
 
535
        ulint           declared_to_be_inside_innodb;
521
536
                                        /* this is TRUE if we have declared
522
537
                                        this transaction in
523
538
                                        srv_conc_enter_innodb to be inside the
524
539
                                        InnoDB engine */
525
 
        unsigned        handling_signals:1;/* this is TRUE as long as the trx
526
 
                                        is handling signals */
527
 
        unsigned        dict_operation_lock_mode:2;
528
 
                                        /* 0, RW_S_LATCH, or RW_X_LATCH:
 
540
 
 
541
        /* Fields protected by dict_operation_lock. The very latch
 
542
        it is used to track. */
 
543
        ulint           dict_operation_lock_mode;
 
544
                                        /*!< 0, RW_S_LATCH, or RW_X_LATCH:
529
545
                                        the latch mode trx currently holds
530
546
                                        on dict_operation_lock */
 
547
 
 
548
        /* All the next fields are protected by the kernel mutex, except the
 
549
        undo logs which are protected by undo_mutex */
 
550
        ulint           is_purge;       /*!< 0=user transaction, 1=purge */
 
551
        ulint           is_recovered;   /*!< 0=normal transaction,
 
552
                                        1=recovered, must be rolled back */
 
553
        ulint           que_state;      /*!< valid when conc_state
 
554
                                        == TRX_ACTIVE: TRX_QUE_RUNNING,
 
555
                                        TRX_QUE_LOCK_WAIT, ... */
 
556
        ulint           handling_signals;/* this is TRUE as long as the trx
 
557
                                        is handling signals */
531
558
        time_t          start_time;     /*!< time the trx object was created
532
559
                                        or the state last time became
533
560
                                        TRX_ACTIVE */
544
571
        /*------------------------------*/
545
572
        void*           mysql_thd;      /*!< MySQL thread handle corresponding
546
573
                                        to this trx, or NULL */
547
 
        char**          mysql_query_str;/* pointer to the field in mysqld_thd
548
 
                                        which contains the pointer to the
549
 
                                        current SQL query string */
550
574
        const char*     mysql_log_file_name;
551
575
                                        /* if MySQL binlog is used, this field
552
576
                                        contains a pointer to the latest file
642
666
                        wait_thrs;      /*!< query threads belonging to this
643
667
                                        trx that are in the QUE_THR_LOCK_WAIT
644
668
                                        state */
645
 
        ulint           deadlock_mark;  /*!< a mark field used in deadlock
646
 
                                        checking algorithm.  This must be
647
 
                                        in its own machine word, because
648
 
                                        it can be changed by other
649
 
                                        threads while holding kernel_mutex. */
650
669
        /*------------------------------*/
651
670
        mem_heap_t*     lock_heap;      /*!< memory heap for the locks of the
652
671
                                        transaction */