60
71
static TransactionServices transaction_services;
61
72
return transaction_services;
76
* Returns true if the transaction manager should construct
77
* Transaction and Statement messages, false otherwise.
79
bool shouldConstructMessages();
81
* Method which returns the active Transaction message
82
* for the supplied Session. If one is not found, a new Transaction
83
* message is allocated, initialized, and returned.
85
* @param The session processing the transaction
87
message::Transaction *getActiveTransactionMessage(Session *in_session);
89
* Method which attaches a transaction context
90
* the supplied transaction based on the supplied Session's
91
* transaction information. This method also ensure the
92
* transaction message is attached properly to the Session object
94
* @param The transaction message to initialize
95
* @param The Session processing this transaction
97
void initTransactionMessage(message::Transaction &in_transaction, Session *in_session);
99
* Helper method which finalizes data members for the
100
* supplied transaction's context.
102
* @param The transaction message to finalize
103
* @param The Session processing this transaction
105
void finalizeTransactionMessage(message::Transaction &in_transaction, Session *in_session);
107
* Helper method which deletes transaction memory and
108
* unsets Session's transaction and statement messages.
110
void cleanupTransactionMessage(message::Transaction *in_transaction,
111
Session *in_session);
113
* Helper method which initializes a Statement message
115
* @param The statement to initialize
116
* @param The type of the statement
117
* @param The session processing this statement
119
void initStatementMessage(message::Statement &statement,
120
message::Statement::Type in_type,
121
Session *in_session);
123
* Finalizes a Statement message and sets the Session's statement
126
* @param The statement to initialize
127
* @param The session processing this statement
129
void finalizeStatementMessage(message::Statement &statement,
130
Session *in_session);
131
/** Helper method which returns an initialized Statement message for methods
132
* doing insertion of data.
134
* @param[in] Pointer to the Session doing the processing
135
* @param[in] Pointer to the Table object being inserted into
137
message::Statement &getInsertStatement(Session *in_session,
141
* Helper method which initializes the header message for
144
* @param[inout] Statement message container to modify
145
* @param[in] Pointer to the Session doing the processing
146
* @param[in] Pointer to the Table being inserted into
148
void setInsertHeader(message::Statement &statement,
152
* Helper method which returns an initialized Statement
153
* message for methods doing updates of data.
155
* @param[in] Pointer to the Session doing the processing
156
* @param[in] Pointer to the Table object being updated
157
* @param[in] Pointer to the old data in the record
158
* @param[in] Pointer to the new data in the record
160
message::Statement &getUpdateStatement(Session *in_session,
162
const unsigned char *old_record,
163
const unsigned char *new_record);
165
* Helper method which initializes the header message for
168
* @param[inout] Statement message container to modify
169
* @param[in] Pointer to the Session doing the processing
170
* @param[in] Pointer to the Table being updated
171
* @param[in] Pointer to the old data in the record
172
* @param[in] Pointer to the new data in the record
174
void setUpdateHeader(message::Statement &statement,
177
const unsigned char *old_record,
178
const unsigned char *new_record);
180
* Helper method which returns an initialized Statement
181
* message for methods doing deletion of data.
183
* @param[in] Pointer to the Session doing the processing
184
* @param[in] Pointer to the Table object being deleted from
186
message::Statement &getDeleteStatement(Session *in_session,
190
* Helper method which initializes the header message for
193
* @param[inout] Statement message container to modify
194
* @param[in] Pointer to the Session doing the processing
195
* @param[in] Pointer to the Table being deleted from
197
void setDeleteHeader(message::Statement &statement,
201
* Commits a normal transaction (see above) and pushes the transaction
202
* message out to the replicators.
204
* @param Pointer to the Session committing the transaction
206
int commitTransactionMessage(Session *in_session);
208
* Marks the current active transaction message as being rolled back and
209
* pushes the transaction message out to replicators.
211
* @param Pointer to the Session committing the transaction
213
void rollbackTransactionMessage(Session *in_session);
215
* Creates a new InsertRecord GPB message and pushes it to
218
* @param Pointer to the Session which has inserted a record
219
* @param Pointer to the Table containing insert information
221
* Grr, returning "true" here on error because of the cursor
222
* reversed bool return crap...fix that.
224
bool insertRecord(Session *in_session, Table *in_table);
226
* Creates a new UpdateRecord GPB message and pushes it to
229
* @param Pointer to the Session which has updated a record
230
* @param Pointer to the Table containing update information
231
* @param Pointer to the raw bytes representing the old record/row
232
* @param Pointer to the raw bytes representing the new record/row
234
void updateRecord(Session *in_session,
236
const unsigned char *old_record,
237
const unsigned char *new_record);
239
* Creates a new DeleteRecord GPB message and pushes it to
242
* @param Pointer to the Session which has deleted a record
243
* @param Pointer to the Table containing delete information
245
void deleteRecord(Session *in_session, Table *in_table);
247
* Creates a CreateSchema Statement GPB message and adds it
248
* to the Session's active Transaction GPB message for pushing
249
* out to the replicator streams.
251
* @param[in] Pointer to the Session which issued the statement
252
* @param[in] message::Schema message describing new schema
254
void createSchema(Session *in_session, const message::Schema &schema);
256
* Creates a DropSchema Statement GPB message and adds it
257
* to the Session's active Transaction GPB message for pushing
258
* out to the replicator streams.
260
* @param[in] Pointer to the Session which issued the statement
261
* @param[in] message::Schema message describing new schema
263
void dropSchema(Session *in_session, const std::string &schema_name);
265
* Creates a CreateTable Statement GPB message and adds it
266
* to the Session's active Transaction GPB message for pushing
267
* out to the replicator streams.
269
* @param[in] Pointer to the Session which issued the statement
270
* @param[in] message::Table message describing new schema
272
void createTable(Session *in_session, const message::Table &table);
274
* Creates a DropTable Statement GPB message and adds it
275
* to the Session's active Transaction GPB message for pushing
276
* out to the replicator streams.
278
* @param[in] Pointer to the Session which issued the statement
279
* @param[in] The schema of the table being dropped
280
* @param[in] The table name of the table being dropped
281
* @param[in] Did the user specify an IF EXISTS clause?
283
void dropTable(Session *in_session,
284
const std::string &schema_name,
285
const std::string &table_name,
288
* Creates a TruncateTable Statement GPB message and adds it
289
* to the Session's active Transaction GPB message for pushing
290
* out to the replicator streams.
292
* @param[in] Pointer to the Session which issued the statement
293
* @param[in] The Table being truncated
295
void truncateTable(Session *in_session, Table *in_table);
297
* Creates a new RawSql GPB message and pushes it to
300
* @TODO With a real data dictionary, this really shouldn't
301
* be needed. CREATE TABLE would map to insertRecord call
302
* on the I_S, etc. Not sure what to do with administrative
303
* commands like CHECK TABLE, though..
305
* @param Pointer to the Session which issued the statement
306
* @param Query string
308
void rawStatement(Session *in_session, const std::string &query);
63
309
/* transactions: interface to plugin::StorageEngine functions */
64
int ha_commit_one_phase(Session *session, bool all);
65
int ha_rollback_trans(Session *session, bool all);
310
int commitPhaseOne(Session *session, bool all);
311
int rollbackTransaction(Session *session, bool all);
67
313
/* transactions: these functions never call plugin::StorageEngine functions directly */
68
int ha_commit_trans(Session *session, bool all);
69
int ha_autocommit_or_rollback(Session *session, int error);
314
int commitTransaction(Session *session, bool all);
315
int autocommitOrRollback(Session *session, int error);
72
int ha_rollback_to_savepoint(Session *session, NamedSavepoint &sv);
73
int ha_savepoint(Session *session, NamedSavepoint &sv);
74
int ha_release_savepoint(Session *session, NamedSavepoint &sv);
75
bool mysql_xa_recover(Session *session);
318
int rollbackToSavepoint(Session *session, NamedSavepoint &sv);
319
int setSavepoint(Session *session, NamedSavepoint &sv);
320
int releaseSavepoint(Session *session, NamedSavepoint &sv);
78
323
* Marks a storage engine as participating in a statement