~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/trx/trx0roll.c

  • Committer: Barry.Leslie at PrimeBase
  • Date: 2010-10-20 20:41:00 UTC
  • mfrom: (1863 staging)
  • mto: This revision was merged to the branch mainline in revision 1871.
  • Revision ID: barry.leslie@primebase.com-20101020204100-oyj6p5cfssjw3p62
Merged with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
trx_general_rollback_for_mysql(
67
67
/*===========================*/
68
68
        trx_t*          trx,    /*!< in: transaction handle */
69
 
        ibool           partial,/*!< in: TRUE if partial rollback requested */
70
69
        trx_savept_t*   savept) /*!< in: pointer to savepoint undo number, if
71
 
                                partial rollback requested */
 
70
                                partial rollback requested, or NULL for
 
71
                                complete rollback */
72
72
{
73
73
        mem_heap_t*     heap;
74
74
        que_thr_t*      thr;
85
85
 
86
86
        roll_node = roll_node_create(heap);
87
87
 
88
 
        roll_node->partial = partial;
89
 
 
90
 
        if (partial) {
 
88
        if (savept) {
 
89
                roll_node->partial = TRUE;
91
90
                roll_node->savept = *savept;
92
91
        }
93
92
 
145
144
        the transaction object does not have an InnoDB session object, and we
146
145
        set a dummy session that we use for all MySQL transactions. */
147
146
 
148
 
        err = trx_general_rollback_for_mysql(trx, FALSE, NULL);
 
147
        err = trx_general_rollback_for_mysql(trx, NULL);
149
148
 
150
149
        trx->op_info = "";
151
150
 
170
169
 
171
170
        trx->op_info = "rollback of SQL statement";
172
171
 
173
 
        err = trx_general_rollback_for_mysql(trx, TRUE,
174
 
                                             &(trx->last_sql_stat_start));
 
172
        err = trx_general_rollback_for_mysql(trx, &trx->last_sql_stat_start);
175
173
        /* The following call should not be needed, but we play safe: */
176
174
        trx_mark_sql_stat_end(trx);
177
175
 
282
280
 
283
281
        trx->op_info = "rollback to a savepoint";
284
282
 
285
 
        err = trx_general_rollback_for_mysql(trx, TRUE, &(savep->savept));
 
283
        err = trx_general_rollback_for_mysql(trx, &savep->savept);
286
284
 
287
285
        /* Store the current undo_no of the transaction so that we know where
288
286
        to roll back if we have to roll back the next SQL statement: */
534
532
Rollback or clean up any incomplete transactions which were
535
533
encountered in crash recovery.  If the transaction already was
536
534
committed, then we clean up a possible insert undo log. If the
537
 
transaction was not yet committed, then we roll it back.
538
 
Note: this is done in a background thread.
539
 
@return a dummy parameter */
 
535
transaction was not yet committed, then we roll it back. */
540
536
UNIV_INTERN
541
 
os_thread_ret_t
542
 
trx_rollback_or_clean_all_recovered(
543
 
/*================================*/
544
 
        void*   arg __attribute__((unused)))
545
 
                        /*!< in: a dummy parameter required by
546
 
                        os_thread_create */
 
537
void
 
538
trx_rollback_or_clean_recovered(
 
539
/*============================*/
 
540
        ibool   all)    /*!< in: FALSE=roll back dictionary transactions;
 
541
                        TRUE=roll back all non-PREPARED transactions */
547
542
{
548
543
        trx_t*  trx;
549
544
 
550
545
        mutex_enter(&kernel_mutex);
551
546
 
552
 
        if (UT_LIST_GET_FIRST(trx_sys->trx_list)) {
 
547
        if (!UT_LIST_GET_FIRST(trx_sys->trx_list)) {
 
548
                goto leave_function;
 
549
        }
553
550
 
 
551
        if (all) {
554
552
                fprintf(stderr,
555
553
                        "InnoDB: Starting in background the rollback"
556
554
                        " of uncommitted transactions\n");
557
 
        } else {
558
 
                goto leave_function;
559
555
        }
560
556
 
561
557
        mutex_exit(&kernel_mutex);
584
580
                        goto loop;
585
581
 
586
582
                case TRX_ACTIVE:
587
 
                        mutex_exit(&kernel_mutex);
588
 
                        trx_rollback_active(trx);
589
 
                        goto loop;
 
583
                        if (all || trx_get_dict_operation(trx)
 
584
                            != TRX_DICT_OP_NONE) {
 
585
                                mutex_exit(&kernel_mutex);
 
586
                                trx_rollback_active(trx);
 
587
                                goto loop;
 
588
                        }
590
589
                }
591
590
        }
592
591
 
593
 
        ut_print_timestamp(stderr);
594
 
        fprintf(stderr,
595
 
                "  InnoDB: Rollback of non-prepared transactions completed\n");
 
592
        if (all) {
 
593
                ut_print_timestamp(stderr);
 
594
                fprintf(stderr,
 
595
                        "  InnoDB: Rollback of non-prepared"
 
596
                        " transactions completed\n");
 
597
        }
596
598
 
597
599
leave_function:
598
600
        mutex_exit(&kernel_mutex);
 
601
}
 
602
 
 
603
/*******************************************************************//**
 
604
Rollback or clean up any incomplete transactions which were
 
605
encountered in crash recovery.  If the transaction already was
 
606
committed, then we clean up a possible insert undo log. If the
 
607
transaction was not yet committed, then we roll it back.
 
608
Note: this is done in a background thread.
 
609
@return a dummy parameter */
 
610
UNIV_INTERN
 
611
os_thread_ret_t
 
612
trx_rollback_or_clean_all_recovered(
 
613
/*================================*/
 
614
        void*   arg __attribute__((unused)))
 
615
                        /*!< in: a dummy parameter required by
 
616
                        os_thread_create */
 
617
{
 
618
        trx_rollback_or_clean_recovered(TRUE);
599
619
 
600
620
        /* We count the number of threads in os_thread_exit(). A created
601
621
        thread should always use that to exit and not use return() to exit. */