#include <transaction_services.h>
This is a class which manages the XA transaction processing in the server
Definition at line 56 of file transaction_services.h.
void drizzled::TransactionServices::alterSchema | ( | Session::reference | session, |
const message::Schema & | old_schema, | ||
const message::Schema & | new_schema | ||
) |
Creates an AlterSchema Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
[in] | session | Session object which issued the statement |
[in] | old_schema | Original schema definition |
[in] | new_schema | New schema definition |
Definition at line 2008 of file transaction_services.cc.
References drizzled::ReplicationServices::isActive(), and drizzled::ReplicationServices::pushTransactionMessage().
int drizzled::TransactionServices::autocommitOrRollback | ( | Session::reference | session, |
int | error | ||
) |
This is used to commit or rollback a single statement depending on the value of error.
Definition at line 719 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), drizzled::ResourceContext::getTransactionalStorageEngine(), drizzled::session::Transactions::stmt, drizzled::Session::transaction_rollback_request, and drizzled::Session::variables.
Referenced by drizzled::Session::close_thread_tables(), and drizzled::dispatch_command().
void drizzled::TransactionServices::cleanupTransactionMessage | ( | message::Transaction * | transaction, |
Session::reference | session | ||
) | [private] |
Helper method which deletes transaction memory and unsets Session's transaction and statement messages.
Definition at line 1041 of file transaction_services.cc.
References drizzled::Session::setStatementMessage(), and drizzled::Session::setTransactionMessage().
int drizzled::TransactionServices::commitPhaseOne | ( | Session::reference | session, |
bool | normal_transaction | ||
) | [private] |
Definition at line 559 of file transaction_services.cc.
References drizzled::session::Transactions::all, drizzled::ResourceContext::getMonitored(), drizzled::ResourceContext::getTransactionalStorageEngine(), drizzled::ResourceContext::getXaResourceManager(), drizzled::plugin::MonitoredInTransaction::participatesInSqlTransaction(), drizzled::plugin::MonitoredInTransaction::participatesInXaTransaction(), drizzled::ResourceContext::reset(), drizzled::Session::status_var, drizzled::session::Transactions::stmt, and drizzled::Session::variables.
int drizzled::TransactionServices::commitTransaction | ( | Session::reference | session, |
bool | all | ||
) |
Commit the current transaction.
0 | ok |
1 | transaction was rolled back |
2 | error during commit, data may be inconsistent |
Definition at line 466 of file transaction_services.cc.
References drizzled::session::Transactions::all, drizzled::ResourceContext::getMonitored(), drizzled::ResourceContext::getXaResourceManager(), drizzled::ResourceContext::hasModifiedData(), drizzled::plugin::MonitoredInTransaction::participatesInXaTransaction(), drizzled::Session::status_var, and drizzled::session::Transactions::stmt.
Referenced by drizzled::Session::endTransaction().
int drizzled::TransactionServices::commitTransactionMessage | ( | Session::reference | session | ) | [private] |
Commits a normal transaction (see above) and pushes the transaction message out to the replicators.
session | Session object committing the transaction |
Definition at line 1050 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), drizzled::Session::getTransactionMessage(), drizzled::ReplicationServices::isActive(), and drizzled::ReplicationServices::pushTransactionMessage().
void drizzled::TransactionServices::createSchema | ( | Session::reference | session, |
const message::Schema & | schema | ||
) |
Creates a CreateSchema Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
[in] | session | Session object which issued the statement |
[in] | schema | message::Schema message describing new schema |
Definition at line 1942 of file transaction_services.cc.
References drizzled::ReplicationServices::isActive(), and drizzled::ReplicationServices::pushTransactionMessage().
void drizzled::TransactionServices::createTable | ( | Session::reference | session, |
const message::Table & | table | ||
) |
Creates a CreateTable Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
[in] | session | Session object which issued the statement |
[in] | table | message::Table message describing new schema |
Definition at line 1909 of file transaction_services.cc.
References drizzled::ReplicationServices::isActive(), and drizzled::ReplicationServices::pushTransactionMessage().
void drizzled::TransactionServices::deleteRecord | ( | Session::reference | session, |
Table & | table, | ||
bool | use_update_record = false |
||
) |
Creates a new DeleteRecord GPB message and pushes it to replicators.
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 |
Store optional old record value in the before data member
Definition at line 1849 of file transaction_services.cc.
References drizzled::TableShare::fieldInPrimaryKey(), drizzled::ReplicationServices::isActive(), drizzled::Session::mem_root, and drizzled::Field::ptr.
Referenced by drizzled::log_row_for_replication().
void drizzled::TransactionServices::dropSchema | ( | Session::reference | session, |
identifier::Schema::const_reference | identifier, | ||
message::schema::const_reference | schema | ||
) |
Creates a DropSchema Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
[in] | session | Session object which issued the statement |
[in] | identifier | Identifier for the schema to drop |
Definition at line 255 of file schema_engine.cc.
References drizzled::Session::clear_error(), drizzled::Open_tables_state::drop_temporary_table(), dropSchema(), drizzled::Session::my_ok(), and singleton().
Referenced by dropSchema().
void drizzled::TransactionServices::dropTable | ( | Session::reference | session, |
identifier::Table::const_reference | identifier, | ||
message::table::const_reference | table, | ||
bool | if_exists | ||
) |
Creates a DropTable Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
[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 2045 of file transaction_services.cc.
References drizzled::ReplicationServices::isActive(), and drizzled::ReplicationServices::pushTransactionMessage().
void drizzled::TransactionServices::finalizeStatementMessage | ( | message::Statement & | statement, |
Session::reference | session | ||
) |
Finalizes a Statement message and sets the Session's statement message to NULL.
statement | The statement to initialize |
session | The Session object processing this statement |
Definition at line 1105 of file transaction_services.cc.
References drizzled::Session::getCurrentTimestamp(), and drizzled::Session::setStatementMessage().
Referenced by drizzled::log_row_for_replication().
void drizzled::TransactionServices::finalizeTransactionMessage | ( | message::Transaction & | transaction, |
Session::const_reference | session | ||
) | [private] |
Helper method which finalizes data members for the supplied transaction's context.
transaction | The transaction message to finalize |
session | The Session object processing this transaction |
Definition at line 1034 of file transaction_services.cc.
References drizzled::Session::getCurrentTimestamp().
message::Transaction * drizzled::TransactionServices::getActiveTransactionMessage | ( | Session::reference | session, |
bool | should_inc_trx_id = true |
||
) | [private] |
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.
session | The Session object processing the transaction |
should_inc_trx_id | If true, increments the transaction id for a new trx |
Definition at line 988 of file transaction_services.cc.
References drizzled::Session::getTransactionMessage(), and drizzled::Session::setTransactionMessage().
message::Statement & drizzled::TransactionServices::getDeleteStatement | ( | Session::reference | session, |
Table & | table, | ||
uint32_t * | next_segment_id | ||
) | [private] |
Helper method which returns an initialized Statement message for methods doing deletion of data.
[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 1717 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), and drizzled::Session::setStatementMessage().
message::Statement & drizzled::TransactionServices::getInsertStatement | ( | Session::reference | session, |
Table & | table, | ||
uint32_t * | next_segment_id | ||
) | [private] |
Helper method which returns an initialized Statement message for methods doing insertion of data.
[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 1252 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), and drizzled::Session::setStatementMessage().
message::Statement & drizzled::TransactionServices::getUpdateStatement | ( | Session::reference | session, |
Table & | table, | ||
const unsigned char * | old_record, | ||
const unsigned char * | new_record, | ||
uint32_t * | next_segment_id | ||
) | [private] |
Helper method which returns an initialized Statement message for methods doing updates of data.
[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 1439 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), and drizzled::Session::setStatementMessage().
void drizzled::TransactionServices::initStatementMessage | ( | message::Statement & | statement, |
message::Statement::Type | type, | ||
Session::const_reference | session | ||
) | [private] |
Helper method which initializes a Statement message
statement | The statement to initialize |
type | The type of the statement |
session | The Session object processing this statement |
Definition at line 1094 of file transaction_services.cc.
References drizzled::Session::getCurrentTimestamp(), and drizzled::Session::variables.
void drizzled::TransactionServices::initTransactionMessage | ( | message::Transaction & | transaction, |
Session::reference | session, | ||
bool | should_inc_trx_id | ||
) | [private] |
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
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 1009 of file transaction_services.cc.
References drizzled::Session::getCurrentTimestamp(), and drizzled::Session::getServerId().
bool drizzled::TransactionServices::insertRecord | ( | Session::reference | session, |
Table & | in_table | ||
) |
Creates a new InsertRecord GPB message and pushes it to replicators.
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...
Multi-column primary keys are handled how exactly?
Definition at line 1380 of file transaction_services.cc.
References drizzled::ReplicationServices::isActive(), and drizzled::Session::mem_root.
Referenced by drizzled::log_row_for_replication().
bool drizzled::TransactionServices::isFieldUpdated | ( | Field * | current_field, |
Table & | table, | ||
const unsigned char * | old_record, | ||
const unsigned char * | new_record | ||
) | [private] |
Checks if a field has been updated
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 |
This isn't always correct...check varchar diffs.
Definition at line 1676 of file transaction_services.cc.
References drizzled::Field::pack_length(), and drizzled::Field::ptr.
void drizzled::TransactionServices::rawStatement | ( | Session::reference | session, |
const std::string & | query, | ||
const std::string & | schema | ||
) |
Creates a new RawSql GPB message and pushes it to replicators.
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..
session | Session object which issued the statement |
query | Query string |
schema | Schema for the table affected by the raw SQL. |
Referenced by drizzled::internal_alter_table().
void drizzled::TransactionServices::registerResourceForStatement | ( | Session::reference | session, |
plugin::MonitoredInTransaction * | monitored, | ||
plugin::TransactionalStorageEngine * | engine, | ||
plugin::XaResourceManager * | resource_manager | ||
) |
Marks an XA storage engine as participating in a statement transaction.
This method is idempotent
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.
[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 348 of file transaction_services.cc.
References drizzled::ResourceContext::isStarted(), drizzled::plugin::MonitoredInTransaction::participatesInSqlTransaction(), drizzled::plugin::MonitoredInTransaction::participatesInXaTransaction(), drizzled::TransactionContext::registerResource(), drizzled::ResourceContext::setMonitored(), drizzled::ResourceContext::setTransactionalStorageEngine(), drizzled::ResourceContext::setXaResourceManager(), and drizzled::session::Transactions::stmt.
void drizzled::TransactionServices::registerResourceForStatement | ( | Session::reference | session, |
plugin::MonitoredInTransaction * | monitored, | ||
plugin::TransactionalStorageEngine * | engine | ||
) |
Marks a storage engine as participating in a statement transaction.
This method is idempotent
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.
[in] | session | Session object |
[in] | monitored | Descriptor for the resource which will be participating |
[in] | engine | Pointer to the TransactionalStorageEngine resource |
Definition at line 316 of file transaction_services.cc.
References drizzled::ResourceContext::isStarted(), drizzled::plugin::MonitoredInTransaction::participatesInSqlTransaction(), drizzled::plugin::MonitoredInTransaction::participatesInXaTransaction(), drizzled::TransactionContext::registerResource(), drizzled::ResourceContext::setMonitored(), drizzled::ResourceContext::setTransactionalStorageEngine(), and drizzled::session::Transactions::stmt.
void drizzled::TransactionServices::registerResourceForTransaction | ( | Session::reference | session, |
plugin::MonitoredInTransaction * | monitored, | ||
plugin::TransactionalStorageEngine * | engine | ||
) |
Registers a resource manager in the "normal" transaction.
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.
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 382 of file transaction_services.cc.
References drizzled::session::Transactions::all, drizzled::Session::getQueryId(), drizzled::ResourceContext::isStarted(), drizzled::plugin::MonitoredInTransaction::participatesInSqlTransaction(), drizzled::plugin::MonitoredInTransaction::participatesInXaTransaction(), drizzled::TransactionContext::registerResource(), drizzled::ResourceContext::setMonitored(), and drizzled::ResourceContext::setTransactionalStorageEngine().
void drizzled::TransactionServices::rollbackStatementMessage | ( | Session::reference | session | ) | [private] |
Rolls back the current statement, deleting the last Statement out of the current Transaction message.
session | Session object committing the transaction |
Definition at line 1168 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), drizzled::ReplicationServices::isActive(), and drizzled::Session::setStatementMessage().
void drizzled::TransactionServices::rollbackTransactionMessage | ( | Session::reference | session | ) | [private] |
Marks the current active transaction message as being rolled back and pushes the transaction message out to replicators.
session | Session object committing the transaction |
Definition at line 1112 of file transaction_services.cc.
References drizzled::ReplicationServices::isActive(), and drizzled::ReplicationServices::pushTransactionMessage().
message::Transaction * drizzled::TransactionServices::segmentTransactionMessage | ( | Session::reference | session, |
message::Transaction * | transaction | ||
) | [private] |
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.
session | Session object |
transaction | Transaction message to segment. |
Definition at line 1234 of file transaction_services.cc.
int drizzled::TransactionServices::sendEvent | ( | Session::reference | session, |
const message::Event & | event | ||
) | [private] |
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.
session | Session object |
event | Event message to send |
Definition at line 2148 of file transaction_services.cc.
References drizzled::ReplicationServices::isActive(), and drizzled::ReplicationServices::pushTransactionMessage().
bool drizzled::TransactionServices::sendShutdownEvent | ( | Session::reference | session | ) |
Send server shutdown event.
session | Session object |
true | Success |
false | Failure |
Definition at line 2183 of file transaction_services.cc.
bool drizzled::TransactionServices::sendStartupEvent | ( | Session::reference | session | ) |
Send server startup event.
session | Session object |
true | Success |
false | Failure |
Definition at line 2174 of file transaction_services.cc.
void drizzled::TransactionServices::setDeleteHeader | ( | message::Statement & | statement, |
Session::const_reference | session, | ||
Table & | table | ||
) | [private] |
Helper method which initializes the header message for insert operations.
[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 1807 of file transaction_services.cc.
References drizzled::Field::field_name, and drizzled::TableShare::fieldInPrimaryKey().
void drizzled::TransactionServices::setInsertHeader | ( | message::Statement & | statement, |
Session::const_reference | session, | ||
Table & | table | ||
) | [private] |
Helper method which initializes the header message for insert operations.
[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 1342 of file transaction_services.cc.
References drizzled::Field::field_name.
int drizzled::TransactionServices::setSavepoint | ( | Session::reference | session, |
NamedSavepoint & | sv | ||
) |
Definition at line 901 of file transaction_services.cc.
References drizzled::session::Transactions::all, drizzled::ResourceContext::getMonitored(), drizzled::ResourceContext::getTransactionalStorageEngine(), drizzled::Session::getTransactionMessage(), drizzled::plugin::MonitoredInTransaction::participatesInSqlTransaction(), and drizzled::Session::status_var.
Referenced by drizzled::statement::Savepoint::execute().
void drizzled::TransactionServices::setUpdateHeader | ( | message::Statement & | statement, |
Session::const_reference | session, | ||
Table & | table, | ||
const unsigned char * | old_record, | ||
const unsigned char * | new_record | ||
) | [private] |
Helper method which initializes the header message for update operations.
[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 1531 of file transaction_services.cc.
References drizzled::Field::field_name, and drizzled::TableShare::fieldInPrimaryKey().
bool drizzled::TransactionServices::shouldConstructMessages | ( | ) |
Returns true if the transaction manager should construct Transaction and Statement messages, false otherwise.
Definition at line 982 of file transaction_services.cc.
References drizzled::ReplicationServices::isActive().
Referenced by drizzled::log_row_for_replication().
static TransactionServices& drizzled::TransactionServices::singleton | ( | ) | [inline, static] |
Singleton method Returns the singleton instance of TransactionServices
Definition at line 67 of file transaction_services.h.
Referenced by drizzled::Session::close_thread_tables(), dropSchema(), drizzled::Session::endTransaction(), drizzled::Cursor::ha_delete_all_rows(), drizzled::internal_alter_table(), and drizzled::log_row_for_replication().
void drizzled::TransactionServices::truncateTable | ( | Session::reference | session, |
Table & | table | ||
) |
Creates a TruncateTable Statement GPB message and adds it to the Session's active Transaction GPB message for pushing out to the replicator streams.
Definition at line 2084 of file transaction_services.cc.
References drizzled::ReplicationServices::isActive(), and drizzled::ReplicationServices::pushTransactionMessage().
Referenced by drizzled::Cursor::ha_delete_all_rows().
void drizzled::TransactionServices::updateRecord | ( | Session::reference | session, |
Table & | table, | ||
const unsigned char * | old_record, | ||
const unsigned char * | new_record | ||
) |
Creates a new UpdateRecord GPB message and pushes it to replicators.
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.
Definition at line 1586 of file transaction_services.cc.
References drizzled::TableShare::fieldInPrimaryKey(), drizzled::ReplicationServices::isActive(), and drizzled::Session::mem_root.
Referenced by drizzled::log_row_for_replication().