348
349
the database name: for example, in 'mysql/data/test'
349
350
the database name is 'test' */
351
/*********************************************************************
352
Creates an InnoDB transaction struct for the session if it does not yet have one.
353
Starts a new InnoDB transaction if a transaction is not yet started. And
354
assigns a new snapshot for a consistent read if the transaction does not yet
358
doStartConsistentSnapshot(
359
/*====================================*/
361
Session* session); /* in: MySQL thread handle of the user for whom
362
the transaction should be committed */
363
352
/********************************************************************
364
353
Flushes InnoDB logs to disk and makes a checkpoint. Really, a commit flushes
365
354
the logs, and the name of this function should be innobase_checkpoint. */
1506
1495
update_session(session);
1509
/*********************************************************************//**
1510
Registers an InnoDB transaction in MySQL, so that the MySQL XA code knows
1511
to call the InnoDB prepare and commit, or rollback for the transaction. This
1512
MUST be called for every transaction for which the user may call commit or
1513
rollback. Calling this several times to register the same transaction is
1515
This function also registers the current SQL statement. */
1518
innobase_register_trx_and_stmt(
1519
/*===========================*/
1520
plugin::TransactionalStorageEngine *engine, /*!< in: Innobase StorageEngine */
1521
Session* session) /*!< in: MySQL thd (connection) object */
1523
if (session_test_options(session, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
1524
/* No autocommit mode, register for a transaction */
1525
TransactionServices &transaction_services= TransactionServices::singleton();
1526
transaction_services.trans_register_ha(session, engine);
1530
1498
/*****************************************************************//**
1531
1499
Convert an SQL identifier to the MySQL system_charset_info (UTF-8)
1532
1500
and quote it if needed.
2092
InnobaseEngine::doStartConsistentSnapshot(
2060
InnobaseEngine::doStartTransaction(
2093
2061
/*====================================*/
2094
Session* session) /*!< in: MySQL thread handle of the user for whom
2095
the transaction should be committed */
2062
Session* session, /*!< in: MySQL thread handle of the user for whom
2063
the transaction should be committed */
2064
start_transaction_option_t options)
2099
2066
assert(this == innodb_engine_ptr);
2101
2068
/* Create a new trx struct for session, if it does not yet have one */
2103
trx = check_trx_exists(session);
2069
trx_t *trx = check_trx_exists(session);
2105
2071
/* This is just to play safe: release a possible FIFO ticket and
2106
2072
search latch. Since we will reserve the kernel mutex, we have to
2107
2073
release the search system latch first to obey the latching order. */
2109
2074
innobase_release_stat_resources(trx);
2111
2076
/* If the transaction is not started yet, start it */
2113
2077
trx_start_if_not_started(trx);
2115
2079
/* Assign a read view if the transaction does not have it yet */
2117
trx_assign_read_view(trx);
2119
/* Set the MySQL flag to mark that there is an active transaction */
2080
if (options == START_TRANS_OPT_WITH_CONS_SNAPSHOT)
2081
trx_assign_read_view(trx);
2083
/* Set the Drizzle flag to mark that there is an active transaction */
2121
2084
if (trx->active_trans == 0) {
2122
innobase_register_trx_and_stmt(this, current_session);
2123
trx->active_trans = 1;
2085
trx->active_trans= 1;
2129
2091
/*****************************************************************//**
2154
2116
/* The flag trx->active_trans is set to 1 in
2156
1. ::external_lock(),
2157
4. InnobaseEngine::setSavepoint(),
2158
6. InnobaseEngine::doStartConsistentSnapshot(),
2118
1. ::external_lock()
2119
2 InnobaseEngine::doStartStatement()
2120
3. InnobaseEngine::setSavepoint()
2121
4. InnobaseEngine::doStartTransaction()
2160
2123
and it is only set to 0 in a commit or a rollback. If it is 0 we know
2161
2124
there cannot be resources to be freed and we could return immediately.