#include <transaction_services.h>
|
| static bool | shouldConstructMessages () |
| static void | finalizeStatementMessage (message::Statement &, Session &) |
| static bool | insertRecord (Session &, Table &in_table) |
| static void | updateRecord (Session &, Table &, const unsigned char *old_record, const unsigned char *new_record) |
| static void | deleteRecord (Session &, Table &, bool use_update_record=false) |
| static void | createSchema (Session &, const message::Schema &schema) |
| static void | dropSchema (Session &, const identifier::Schema &identifier, message::schema::const_reference schema) |
| static void | alterSchema (Session &, const message::Schema &old_schema, const message::Schema &new_schema) |
| static void | createTable (Session &, const message::Table &) |
| static void | dropTable (Session &, const identifier::Table &identifier, message::table::const_reference table, bool if_exists) |
| static void | truncateTable (Session &, Table &) |
| static void | rawStatement (Session &, const std::string &query, const std::string &schema) |
| static void | rawStatement (Session &session, const std::string &query) |
| static int | rollbackTransaction (Session &, bool all) |
| static int | commitTransaction (Session &, bool all) |
| static int | autocommitOrRollback (Session &, int error) |
| static int | rollbackToSavepoint (Session &, NamedSavepoint &sv) |
| static int | setSavepoint (Session &, NamedSavepoint &sv) |
| static int | releaseSavepoint (Session &, NamedSavepoint &sv) |
| static void | registerResourceForStatement (Session &, plugin::MonitoredInTransaction *, plugin::TransactionalStorageEngine *) |
| static void | registerResourceForStatement (Session &, plugin::MonitoredInTransaction *monitored, plugin::TransactionalStorageEngine *engine, plugin::XaResourceManager *resource_manager) |
| static void | registerResourceForTransaction (Session &, plugin::MonitoredInTransaction *, plugin::TransactionalStorageEngine *) |
| static void | registerResourceForTransaction (Session &, plugin::MonitoredInTransaction *, plugin::TransactionalStorageEngine *, plugin::XaResourceManager *) |
| static void | allocateNewTransactionId () |
| static bool | sendStartupEvent (Session &) |
| static bool | sendShutdownEvent (Session &) |
|
| static message::Transaction * | getActiveTransactionMessage (Session &, bool should_inc_trx_id=true) |
| static void | initTransactionMessage (message::Transaction &, Session &, bool should_inc_trx_id) |
| static void | initStatementMessage (message::Statement &, message::Statement::Type type, const Session &) |
| static void | finalizeTransactionMessage (message::Transaction &, const Session &) |
| static void | cleanupTransactionMessage (message::Transaction *transaction, Session &) |
| static message::Statement & | getInsertStatement (Session &, Table &, uint32_t *next_segment_id) |
| static void | setInsertHeader (message::Statement &, const Session &, Table &) |
| static message::Statement & | getUpdateStatement (Session &, Table &, const unsigned char *old_record, const unsigned char *new_record, uint32_t *next_segment_id) |
| static void | setUpdateHeader (message::Statement &, const Session &, Table &, const unsigned char *old_record, const unsigned char *new_record) |
| static message::Statement & | getDeleteStatement (Session &, Table &, uint32_t *next_segment_id) |
| static void | setDeleteHeader (message::Statement &, const Session &, Table &) |
| static int | commitTransactionMessage (Session &) |
| static void | rollbackTransactionMessage (Session &) |
| static void | rollbackStatementMessage (Session &) |
| static bool | isFieldUpdated (Field *current_field, Table &, const unsigned char *old_record, const unsigned char *new_record) |
| static int | sendEvent (Session &, const message::Event &event) |
| static message::Transaction * | segmentTransactionMessage (Session &, message::Transaction *) |
| static int | commitPhaseOne (Session &, bool all) |
| static uint64_t | getCurrentTransactionId (Session &) |
This is a class which manages the XA transaction processing in the server
Definition at line 42 of file transaction_services.h.
◆ allocateNewTransactionId()
| void drizzled::TransactionServices::allocateNewTransactionId |
( |
| ) |
|
|
static |
◆ alterSchema()
| void drizzled::TransactionServices::alterSchema |
( |
Session & | session, |
|
|
const message::Schema & | old_schema, |
|
|
const message::Schema & | new_schema ) |
|
static |
Creates an AlterSchema Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
- Parameters
-
| [in] | session | Session object which issued the statement |
| [in] | old_schema | Original schema definition |
| [in] | new_schema | New schema definition |
Definition at line 1930 of file transaction_services.cc.
◆ autocommitOrRollback()
| int drizzled::TransactionServices::autocommitOrRollback |
( |
Session & | session, |
|
|
int | error ) |
|
static |
This is used to commit or rollback a single statement depending on the value of error.
- Note
- Note that if the autocommit is on, then the following call inside InnoDB will commit or rollback the whole transaction (= the statement). The autocommit mechanism built into InnoDB is based on counting locks, but if the user has used LOCK TABLES then that mechanism does not know to do the commit.
Definition at line 699 of file transaction_services.cc.
◆ cleanupTransactionMessage()
| void drizzled::TransactionServices::cleanupTransactionMessage |
( |
message::Transaction * | transaction, |
|
|
Session & | session ) |
|
staticprivate |
◆ commitPhaseOne()
| int drizzled::TransactionServices::commitPhaseOne |
( |
Session & | session, |
|
|
bool | normal_transaction ) |
|
staticprivate |
◆ commitTransaction()
| int drizzled::TransactionServices::commitTransaction |
( |
Session & | session, |
|
|
bool | all ) |
|
static |
Commit the current transaction.
- Return values
-
| 0 | ok |
| 1 | transaction was rolled back |
| 2 | error during commit, data may be inconsistent |
- Todo
- Since we don't support nested statement transactions in 5.0, we can't commit or rollback stmt transactions while we are inside stored functions or triggers. So we simply do nothing now. This should be fixed in later ( >= 5.1) releases.
Definition at line 459 of file transaction_services.cc.
◆ commitTransactionMessage()
| int drizzled::TransactionServices::commitTransactionMessage |
( |
Session & | session | ) |
|
|
staticprivate |
Commits a normal transaction (see above) and pushes the transaction message out to the replicators.
- Parameters
-
| session | Session object committing the transaction |
Definition at line 1003 of file transaction_services.cc.
◆ createSchema()
| void drizzled::TransactionServices::createSchema |
( |
Session & | session, |
|
|
const message::Schema & | schema ) |
|
static |
Creates a CreateSchema Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
- Parameters
-
| [in] | session | Session object which issued the statement |
| [in] | schema | message::Schema message describing new schema |
Definition at line 1866 of file transaction_services.cc.
◆ createTable()
| void drizzled::TransactionServices::createTable |
( |
Session & | session, |
|
|
const message::Table & | table ) |
|
static |
Creates a CreateTable Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
- Parameters
-
| [in] | session | Session object which issued the statement |
| [in] | table | message::Table message describing new schema |
Definition at line 1834 of file transaction_services.cc.
◆ deleteRecord()
| void drizzled::TransactionServices::deleteRecord |
( |
Session & | session, |
|
|
Table & | table, |
|
|
bool | use_update_record = false ) |
|
static |
Creates a new DeleteRecord GPB message and pushes it to replicators.
- Parameters
-
| session | Session object which has deleted a record |
| table | Table object containing delete information |
| use_update_record | If true, uses the values from the update row instead |
@TODO Store optional old record value in the before data member
Definition at line 1775 of file transaction_services.cc.
◆ dropSchema()
| void drizzled::TransactionServices::dropSchema |
( |
Session & | session, |
|
|
const identifier::Schema & | identifier, |
|
|
message::schema::const_reference | schema ) |
|
static |
Creates a DropSchema Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
- Parameters
-
| [in] | session | Session object which issued the statement |
| [in] | identifier | Identifier for the schema to drop |
Definition at line 1898 of file transaction_services.cc.
◆ dropTable()
| void drizzled::TransactionServices::dropTable |
( |
Session & | session, |
|
|
const identifier::Table & | identifier, |
|
|
message::table::const_reference | table, |
|
|
bool | if_exists ) |
|
static |
Creates a DropTable Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
- Parameters
-
| [in] | session | Session object which issued the statement |
| [in] | table | Identifier for the table being dropped |
| [in] | if_exists | Did the user specify an IF EXISTS clause? |
Definition at line 1966 of file transaction_services.cc.
◆ finalizeStatementMessage()
| void drizzled::TransactionServices::finalizeStatementMessage |
( |
message::Statement & | statement, |
|
|
Session & | session ) |
|
static |
Finalizes a Statement message and sets the Session's statement message to NULL.
- Parameters
-
| statement | The statement to initialize |
| session | The Session object processing this statement |
Definition at line 1057 of file transaction_services.cc.
◆ finalizeTransactionMessage()
| void drizzled::TransactionServices::finalizeTransactionMessage |
( |
message::Transaction & | transaction, |
|
|
const Session & | session ) |
|
staticprivate |
Helper method which finalizes data members for the supplied transaction's context.
- Parameters
-
| transaction | The transaction message to finalize |
| session | The Session object processing this transaction |
Definition at line 987 of file transaction_services.cc.
◆ getActiveTransactionMessage()
| message::Transaction * drizzled::TransactionServices::getActiveTransactionMessage |
( |
Session & | session, |
|
|
bool | should_inc_trx_id = true ) |
|
staticprivate |
Method which returns the active Transaction message for the supplied Session. If one is not found, a new Transaction message is allocated, initialized, and returned. It is possible that we may want to NOT increment the transaction id for a new Transaction object (e.g., splitting up Transactions into smaller chunks). The should_inc_trx_id flag controls if we do this.
- Parameters
-
| session | The Session object processing the transaction |
| should_inc_trx_id | If true, increments the transaction id for a new trx |
Definition at line 943 of file transaction_services.cc.
◆ getCurrentTransactionId()
| uint64_t drizzled::TransactionServices::getCurrentTransactionId |
( |
Session & | session | ) |
|
|
staticprivate |
◆ getDeleteStatement()
| message::Statement & drizzled::TransactionServices::getDeleteStatement |
( |
Session & | session, |
|
|
Table & | table, |
|
|
uint32_t * | next_segment_id ) |
|
staticprivate |
Helper method which returns an initialized Statement message for methods doing deletion of data.
- Parameters
-
| [in] | session | Session object doing the processing |
| [in] | table | Table object being deleted from |
| [out] | next_segment_id | The next Statement segment id to be used |
Definition at line 1650 of file transaction_services.cc.
◆ getInsertStatement()
| message::Statement & drizzled::TransactionServices::getInsertStatement |
( |
Session & | session, |
|
|
Table & | table, |
|
|
uint32_t * | next_segment_id ) |
|
staticprivate |
Helper method which returns an initialized Statement message for methods doing insertion of data.
- Parameters
-
| [in] | session | Session object doing the processing |
| [in] | table | Table object being inserted into |
| [out] | next_segment_id | The next Statement segment id to be used |
Definition at line 1202 of file transaction_services.cc.
◆ getUpdateStatement()
| message::Statement & drizzled::TransactionServices::getUpdateStatement |
( |
Session & | session, |
|
|
Table & | table, |
|
|
const unsigned char * | old_record, |
|
|
const unsigned char * | new_record, |
|
|
uint32_t * | next_segment_id ) |
|
staticprivate |
Helper method which returns an initialized Statement message for methods doing updates of data.
- Parameters
-
| [in] | session | Session object doing the processing |
| [in] | table | Table object being updated |
| [in] | old_record | Pointer to the old data in the record |
| [in] | new_record | Pointer to the new data in the record |
| [out] | next_segment_id | The next Statement segment id to be used |
Definition at line 1380 of file transaction_services.cc.
◆ initStatementMessage()
| void drizzled::TransactionServices::initStatementMessage |
( |
message::Statement & | statement, |
|
|
message::Statement::Type | type, |
|
|
const Session & | session ) |
|
staticprivate |
Helper method which initializes a Statement message
- Parameters
-
| statement | The statement to initialize |
| type | The type of the statement |
| session | The Session object processing this statement |
Definition at line 1046 of file transaction_services.cc.
◆ initTransactionMessage()
| void drizzled::TransactionServices::initTransactionMessage |
( |
message::Transaction & | transaction, |
|
|
Session & | session, |
|
|
bool | should_inc_trx_id ) |
|
staticprivate |
Method which attaches a transaction context the supplied transaction based on the supplied Session's transaction information. This method also ensure the transaction message is attached properly to the Session object
- Parameters
-
| transaction | The transaction message to initialize |
| session | The Session object processing this transaction |
| should_inc_trx_id | If true, increments the transaction id for a new trx |
Definition at line 962 of file transaction_services.cc.
◆ insertRecord()
| bool drizzled::TransactionServices::insertRecord |
( |
Session & | session, |
|
|
Table & | in_table ) |
|
static |
Creates a new InsertRecord GPB message and pushes it to replicators.
- Parameters
-
| session | Session object which has inserted a record |
| table | Table object containing insert information |
Grr, returning "true" here on error because of the cursor reversed bool return crap...fix that.
We do this check here because we don't want to even create a statement if there isn't a primary key on the table...
- Todo
Multi-column primary keys are handled how exactly?
Definition at line 1322 of file transaction_services.cc.
◆ isFieldUpdated()
| bool drizzled::TransactionServices::isFieldUpdated |
( |
Field * | current_field, |
|
|
Table & | table, |
|
|
const unsigned char * | old_record, |
|
|
const unsigned char * | new_record ) |
|
staticprivate |
Checks if a field has been updated
- Parameters
-
| current_field | Pointer to the field to check if it is updated |
| table | Table object containing update information |
| old_record | Pointer to the raw bytes representing the old record/row |
| new_record | Pointer to the raw bytes representing the new record/row |
@TODO This isn't always correct...check varchar diffs.
Definition at line 1609 of file transaction_services.cc.
◆ rawStatement() [1/2]
| void drizzled::TransactionServices::rawStatement |
( |
Session & | session, |
|
|
const std::string & | query, |
|
|
const std::string & | schema ) |
|
static |
Creates a new RawSql GPB message and pushes it to replicators.
@TODO With a real data dictionary, this really shouldn't be needed. CREATE TABLE would map to insertRecord call on the I_S, etc. Not sure what to do with administrative commands like CHECK TABLE, though..
- Parameters
-
| session | Session object which issued the statement |
| query | Query string |
| schema | Schema for the table affected by the raw SQL. |
Definition at line 2036 of file transaction_services.cc.
◆ rawStatement() [2/2]
| void drizzled::TransactionServices::rawStatement |
( |
Session & | session, |
|
|
const std::string & | query ) |
|
inlinestatic |
◆ registerResourceForStatement() [1/2]
Marks a storage engine as participating in a statement transaction.
- Note
This method is idempotent
- Todo
This method should not be called more than once per resource per statement, and therefore should not need to be idempotent. Put in assert()s to test this.
- Parameters
-
| [in] | session | Session object |
| [in] | monitored | Descriptor for the resource which will be participating |
| [in] | engine | Pointer to the TransactionalStorageEngine resource |
Definition at line 313 of file transaction_services.cc.
◆ registerResourceForStatement() [2/2]
Marks an XA storage engine as participating in a statement transaction.
- Note
This method is idempotent
- Todo
This method should not be called more than once per resource per statement, and therefore should not need to be idempotent. Put in assert()s to test this.
- Parameters
-
| [in] | session | Session object |
| [in] | monitored | Descriptor for the resource which will be participating |
| [in] | engine | Pointer to the TransactionalStorageEngine resource |
| [in] | resource_manager | Pointer to the XaResourceManager resource manager |
Definition at line 344 of file transaction_services.cc.
◆ registerResourceForTransaction() [1/2]
Registers a resource manager in the "normal" transaction.
- Note
This method is idempotent and must be idempotent because it can be called both by the above TransactionServices::registerResourceForStatement(), which occurs at the beginning of each SQL statement, and also manually when a BEGIN WORK/START TRANSACTION statement is executed. If the latter case (BEGIN WORK) is called, then subsequent contained statement transactions will call this method as well.
- Note
This method checks to see if the supplied resource is also registered in the statement transaction, and if not, registers the resource in the statement transaction. This happens ONLY when the user has called BEGIN WORK/START TRANSACTION, which is the only time when this method is called except from the TransactionServices::registerResourceForStatement method.
Definition at line 376 of file transaction_services.cc.
◆ registerResourceForTransaction() [2/2]
◆ releaseSavepoint()
◆ rollbackStatementMessage()
| void drizzled::TransactionServices::rollbackStatementMessage |
( |
Session & | session | ) |
|
|
staticprivate |
Rolls back the current statement, deleting the last Statement out of the current Transaction message.
- Parameters
-
| session | Session object committing the transaction |
- Note
- This depends on having clear statement boundaries (i.e., one Statement message per actual SQL statement).
Definition at line 1119 of file transaction_services.cc.
◆ rollbackToSavepoint()
◆ rollbackTransaction()
| int drizzled::TransactionServices::rollbackTransaction |
( |
Session & | session, |
|
|
bool | all ) |
|
static |
◆ rollbackTransactionMessage()
| void drizzled::TransactionServices::rollbackTransactionMessage |
( |
Session & | session | ) |
|
|
staticprivate |
Marks the current active transaction message as being rolled back and pushes the transaction message out to replicators.
- Parameters
-
| session | Session object committing the transaction |
Definition at line 1064 of file transaction_services.cc.
◆ segmentTransactionMessage()
| message::Transaction * drizzled::TransactionServices::segmentTransactionMessage |
( |
Session & | session, |
|
|
message::Transaction * | transaction ) |
|
staticprivate |
Makes a given Transaction message segmented.
The given Transaction message will have its segment information set appropriately and a new Transaction message, containing the same transaction ID as the supplied Transaction, and is created.
- Parameters
-
| session | Session object |
| transaction | Transaction message to segment. |
- Returns
- Returns a pointer to a new Transaction message ready for use.
Definition at line 1184 of file transaction_services.cc.
◆ sendEvent()
| int drizzled::TransactionServices::sendEvent |
( |
Session & | session, |
|
|
const message::Event & | event ) |
|
staticprivate |
Create a Transaction that contains event information and send it off.
This differs from other uses of Transaction in that we don't use the message associated with Session. We create a totally new message and use it.
- Parameters
-
| session | Session object |
| event | Event message to send |
- Note
- Used by the public Events API.
- Returns
- Non-zero on error
Definition at line 2059 of file transaction_services.cc.
◆ sendShutdownEvent()
| bool drizzled::TransactionServices::sendShutdownEvent |
( |
Session & | session | ) |
|
|
static |
◆ sendStartupEvent()
| bool drizzled::TransactionServices::sendStartupEvent |
( |
Session & | session | ) |
|
|
static |
◆ setDeleteHeader()
| void drizzled::TransactionServices::setDeleteHeader |
( |
message::Statement & | statement, |
|
|
const Session & | session, |
|
|
Table & | table ) |
|
staticprivate |
Helper method which initializes the header message for insert operations.
- Parameters
-
| [in,out] | statement | Statement message container to modify |
| [in] | session | Session object doing the processing |
| [in] | table | Table object being deleted from |
Definition at line 1738 of file transaction_services.cc.
◆ setInsertHeader()
| void drizzled::TransactionServices::setInsertHeader |
( |
message::Statement & | statement, |
|
|
const Session & | session, |
|
|
Table & | table ) |
|
staticprivate |
Helper method which initializes the header message for insert operations.
- Parameters
-
| [in,out] | statement | Statement message container to modify |
| [in] | session | Session object doing the processing |
| [in] | table | Table object being inserted into |
Definition at line 1290 of file transaction_services.cc.
◆ setSavepoint()
- Note
- according to the sql standard (ISO/IEC 9075-2:2003) section "4.33.4 SQL-statements and transaction states", NamedSavepoint is not transaction-initiating SQL-statement
Definition at line 867 of file transaction_services.cc.
◆ setUpdateHeader()
| void drizzled::TransactionServices::setUpdateHeader |
( |
message::Statement & | statement, |
|
|
const Session & | session, |
|
|
Table & | table, |
|
|
const unsigned char * | old_record, |
|
|
const unsigned char * | new_record ) |
|
staticprivate |
Helper method which initializes the header message for update operations.
- Parameters
-
| [in,out] | statement | Statement message container to modify |
| [in] | session | Session object doing the processing |
| [in] | table | Table object being updated |
| [in] | old_record | Pointer to the old data in the record |
| [in] | new_record | Pointer to the new data in the record |
Definition at line 1470 of file transaction_services.cc.
◆ shouldConstructMessages()
| bool drizzled::TransactionServices::shouldConstructMessages |
( |
| ) |
|
|
static |
Returns true if the transaction manager should construct Transaction and Statement messages, false otherwise.
Definition at line 938 of file transaction_services.cc.
◆ truncateTable()
| void drizzled::TransactionServices::truncateTable |
( |
Session & | session, |
|
|
Table & | table ) |
|
static |
Creates a TruncateTable Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
- Parameters
-
| [in] | session | Session object which issued the statement |
| [in] | table | The Table being truncated |
Definition at line 2004 of file transaction_services.cc.
◆ updateRecord()
| void drizzled::TransactionServices::updateRecord |
( |
Session & | session, |
|
|
Table & | table, |
|
|
const unsigned char * | old_record, |
|
|
const unsigned char * | new_record ) |
|
static |
Creates a new UpdateRecord GPB message and pushes it to replicators.
- Parameters
-
| session | Session object which has updated a record |
| table | Table object containing update information |
| old_record | Pointer to the raw bytes representing the old record/row |
| new_record | Pointer to the raw bytes representing the new record/row |
To say the below is ugly is an understatement. But it works.
- Todo
- Move this crap into a real Record API.
Definition at line 1520 of file transaction_services.cc.
◆ DEFAULT_RECORD_SIZE
| const size_t drizzled::TransactionServices::DEFAULT_RECORD_SIZE = 100 |
|
static |
The documentation for this class was generated from the following files: