#include <transaction_services.h>
Static Public Member Functions | |
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 Public Attributes | |
static const size_t | DEFAULT_RECORD_SIZE = 100 |
Static Private Member Functions | |
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.
|
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.
[in] | session | Session object which issued the statement |
[in] | old_schema | Original schema definition |
[in] | new_schema | New schema definition |
Definition at line 1936 of file transaction_services.cc.
|
static |
This is used to commit or rollback a single statement depending on the value of error.
Definition at line 699 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), drizzled::session::Transactions::stmt, drizzled::Session::transaction_rollback_request, and drizzled::Session::variables.
Referenced by drizzled::Session::close_thread_tables().
|
staticprivate |
Helper method which deletes transaction memory and unsets Session's transaction and statement messages.
Definition at line 994 of file transaction_services.cc.
References drizzled::Session::setStatementMessage(), and drizzled::Session::setTransactionMessage().
|
staticprivate |
Definition at line 550 of file transaction_services.cc.
References drizzled::session::Transactions::all, drizzled::plugin::MonitoredInTransaction::participatesInSqlTransaction(), drizzled::plugin::MonitoredInTransaction::participatesInXaTransaction(), drizzled::session::Transactions::stmt, and drizzled::Session::variables.
|
static |
Commit the current transaction.
0 | ok |
1 | transaction was rolled back |
2 | error during commit, data may be inconsistent |
Definition at line 459 of file transaction_services.cc.
References drizzled::session::Transactions::all, drizzled::plugin::MonitoredInTransaction::participatesInXaTransaction(), and drizzled::session::Transactions::stmt.
Referenced by drizzled::Session::endTransaction().
|
staticprivate |
Commits a normal transaction (see above) and pushes the transaction message out to the replicators.
session | Session object committing the transaction |
Definition at line 1003 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), and drizzled::Session::getTransactionMessage().
|
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.
[in] | session | Session object which issued the statement |
[in] | schema | message::Schema message describing new schema |
Definition at line 1872 of file transaction_services.cc.
|
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.
[in] | session | Session object which issued the statement |
[in] | table | message::Table message describing new schema |
Definition at line 1840 of file transaction_services.cc.
|
static |
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 1781 of file transaction_services.cc.
References drizzled::TableShare::fieldInPrimaryKey(), drizzled::Session::mem_root, and drizzled::Field::ptr.
|
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.
[in] | session | Session object which issued the statement |
[in] | identifier | Identifier for the schema to drop |
Definition at line 1904 of file transaction_services.cc.
|
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.
[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 1972 of file transaction_services.cc.
|
static |
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 1057 of file transaction_services.cc.
References drizzled::Session::setStatementMessage().
|
staticprivate |
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 987 of file transaction_services.cc.
|
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.
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.
References drizzled::Session::getTransactionMessage(), and drizzled::Session::setTransactionMessage().
|
staticprivate |
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 1654 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), and drizzled::Session::setStatementMessage().
|
staticprivate |
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 1202 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), and drizzled::Session::setStatementMessage().
|
staticprivate |
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 1382 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), and drizzled::Session::setStatementMessage().
|
staticprivate |
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 1046 of file transaction_services.cc.
References drizzled::Session::variables.
|
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
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.
References drizzled::Session::getServerId().
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 1324 of file transaction_services.cc.
References drizzled::Session::mem_root.
|
staticprivate |
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 1613 of file transaction_services.cc.
References drizzled::Field::pack_length(), and drizzled::Field::ptr.
|
static |
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().
|
static |
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 313 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.
|
static |
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 344 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.
|
static |
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 376 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().
|
staticprivate |
Rolls back the current statement, deleting the last Statement out of the current Transaction message.
session | Session object committing the transaction |
Definition at line 1119 of file transaction_services.cc.
References drizzled::Session::getStatementMessage(), and drizzled::Session::setStatementMessage().
|
staticprivate |
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 1064 of file transaction_services.cc.
|
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.
session | Session object |
transaction | Transaction message to segment. |
Definition at line 1184 of file transaction_services.cc.
|
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.
session | Session object |
event | Event message to send |
Definition at line 2065 of file transaction_services.cc.
|
static |
Send server shutdown event.
session | Session object |
true | Success |
false | Failure |
Definition at line 2090 of file transaction_services.cc.
|
static |
Send server startup event.
session | Session object |
true | Success |
false | Failure |
Definition at line 2083 of file transaction_services.cc.
|
staticprivate |
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 1744 of file transaction_services.cc.
References drizzled::Field::field_name, and drizzled::TableShare::fieldInPrimaryKey().
|
staticprivate |
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 1292 of file transaction_services.cc.
|
static |
Definition at line 867 of file transaction_services.cc.
References drizzled::session::Transactions::all, drizzled::Session::getTransactionMessage(), and drizzled::plugin::MonitoredInTransaction::participatesInSqlTransaction().
|
staticprivate |
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 1474 of file transaction_services.cc.
References drizzled::Field::field_name, and drizzled::TableShare::fieldInPrimaryKey().
|
static |
Returns true if the transaction manager should construct Transaction and Statement messages, false otherwise.
Definition at line 938 of file transaction_services.cc.
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 2010 of file transaction_services.cc.
|
static |
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 1524 of file transaction_services.cc.
References drizzled::TableShare::fieldInPrimaryKey(), and drizzled::Session::mem_root.