60
72
static TransactionServices transaction_services;
61
73
return transaction_services;
77
* Returns true if the transaction manager should construct
78
* Transaction and Statement messages, false otherwise.
80
bool shouldConstructMessages();
82
* Method which returns the active Transaction message
83
* for the supplied Session. If one is not found, a new Transaction
84
* message is allocated, initialized, and returned. It is possible that
85
* we may want to NOT increment the transaction id for a new Transaction
86
* object (e.g., splitting up Transactions into smaller chunks). The
87
* should_inc_trx_id flag controls if we do this.
89
* @param in_session The session processing the transaction
90
* @param should_inc_trx_id If true, increments the transaction id for a new trx
92
message::Transaction *getActiveTransactionMessage(Session *in_session,
93
bool should_inc_trx_id= true);
95
* Method which attaches a transaction context
96
* the supplied transaction based on the supplied Session's
97
* transaction information. This method also ensure the
98
* transaction message is attached properly to the Session object
100
* @param in_transaction The transaction message to initialize
101
* @param in_session The Session processing this transaction
102
* @param should_inc_trx_id If true, increments the transaction id for a new trx
104
void initTransactionMessage(message::Transaction &in_transaction,
106
bool should_inc_trx_id);
108
* Helper method which finalizes data members for the
109
* supplied transaction's context.
111
* @param in_transaction The transaction message to finalize
112
* @param in_session The Session processing this transaction
114
void finalizeTransactionMessage(message::Transaction &in_transaction, Session *in_session);
116
* Helper method which deletes transaction memory and
117
* unsets Session's transaction and statement messages.
119
void cleanupTransactionMessage(message::Transaction *in_transaction,
120
Session *in_session);
122
* Helper method which initializes a Statement message
124
* @param statement The statement to initialize
125
* @param in_type The type of the statement
126
* @param in_session The session processing this statement
128
void initStatementMessage(message::Statement &statement,
129
message::Statement::Type in_type,
130
Session *in_session);
132
* Finalizes a Statement message and sets the Session's statement
135
* @param statement The statement to initialize
136
* @param in_session The session processing this statement
138
void finalizeStatementMessage(message::Statement &statement,
139
Session *in_session);
140
/** Helper method which returns an initialized Statement message for methods
141
* doing insertion of data.
143
* @param[in] in_session Pointer to the Session doing the processing
144
* @param[in] in_table Pointer to the Table object being inserted into
145
* @param[out] next_segment_id The next Statement segment id to be used
147
message::Statement &getInsertStatement(Session *in_session,
149
uint32_t *next_segment_id);
152
* Helper method which initializes the header message for
155
* @param[in,out] statement Statement message container to modify
156
* @param[in] in_session Pointer to the Session doing the processing
157
* @param[in] in_table Pointer to the Table being inserted into
159
void setInsertHeader(message::Statement &statement,
163
* Helper method which returns an initialized Statement
164
* message for methods doing updates of data.
166
* @param[in] in_session Pointer to the Session doing the processing
167
* @param[in] in_table Pointer to the Table object being updated
168
* @param[in] old_record Pointer to the old data in the record
169
* @param[in] new_record Pointer to the new data in the record
170
* @param[out] next_segment_id The next Statement segment id to be used
172
message::Statement &getUpdateStatement(Session *in_session,
174
const unsigned char *old_record,
175
const unsigned char *new_record,
176
uint32_t *next_segment_id);
178
* Helper method which initializes the header message for
181
* @param[in,out] statement Statement message container to modify
182
* @param[in] in_session Pointer to the Session doing the processing
183
* @param[in] in_table Pointer to the Table being updated
184
* @param[in] old_record Pointer to the old data in the record
185
* @param[in] new_record Pointer to the new data in the record
187
void setUpdateHeader(message::Statement &statement,
190
const unsigned char *old_record,
191
const unsigned char *new_record);
193
* Helper method which returns an initialized Statement
194
* message for methods doing deletion of data.
196
* @param[in] in_session Pointer to the Session doing the processing
197
* @param[in] in_table Pointer to the Table object being deleted from
198
* @param[out] next_segment_id The next Statement segment id to be used
200
message::Statement &getDeleteStatement(Session *in_session,
202
uint32_t *next_segment_id);
205
* Helper method which initializes the header message for
208
* @param[in,out] statement Statement message container to modify
209
* @param[in] in_session Pointer to the Session doing the processing
210
* @param[in] in_table Pointer to the Table being deleted from
212
void setDeleteHeader(message::Statement &statement,
216
* Commits a normal transaction (see above) and pushes the transaction
217
* message out to the replicators.
219
* @param in_session Pointer to the Session committing the transaction
221
int commitTransactionMessage(Session *in_session);
223
* Marks the current active transaction message as being rolled back and
224
* pushes the transaction message out to replicators.
226
* @param in_session Pointer to the Session committing the transaction
228
void rollbackTransactionMessage(Session *in_session);
230
* Creates a new InsertRecord GPB message and pushes it to
233
* @param in_session Pointer to the Session which has inserted a record
234
* @param in_table Pointer to the Table containing insert information
236
* Grr, returning "true" here on error because of the cursor
237
* reversed bool return crap...fix that.
239
bool insertRecord(Session *in_session, Table *in_table);
241
* Creates a new UpdateRecord GPB message and pushes it to
244
* @param in_session Pointer to the Session which has updated a record
245
* @param in_table Pointer to the Table containing update information
246
* @param old_record Pointer to the raw bytes representing the old record/row
247
* @param new_record Pointer to the raw bytes representing the new record/row
249
void updateRecord(Session *in_session,
251
const unsigned char *old_record,
252
const unsigned char *new_record);
254
* Creates a new DeleteRecord GPB message and pushes it to
257
* @param in_session Pointer to the Session which has deleted a record
258
* @param in_table Pointer to the Table containing delete information
259
* @param use_update_record If true, uses the values from the update row instead
261
void deleteRecord(Session *in_session, Table *in_table, bool use_update_record= false);
263
* Creates a CreateSchema Statement GPB message and adds it
264
* to the Session's active Transaction GPB message for pushing
265
* out to the replicator streams.
267
* @param[in] in_session Pointer to the Session which issued the statement
268
* @param[in] schema message::Schema message describing new schema
270
void createSchema(Session *in_session, const message::Schema &schema);
272
* Creates a DropSchema Statement GPB message and adds it
273
* to the Session's active Transaction GPB message for pushing
274
* out to the replicator streams.
276
* @param[in] in_session Pointer to the Session which issued the statement
277
* @param[in] schema_name message::Schema message describing new schema
279
void dropSchema(Session *in_session, const std::string &schema_name);
281
* Creates a CreateTable Statement GPB message and adds it
282
* to the Session's active Transaction GPB message for pushing
283
* out to the replicator streams.
285
* @param[in] in_session Pointer to the Session which issued the statement
286
* @param[in] table message::Table message describing new schema
288
void createTable(Session *in_session, const message::Table &table);
290
* Creates a DropTable Statement GPB message and adds it
291
* to the Session's active Transaction GPB message for pushing
292
* out to the replicator streams.
294
* @param[in] in_session Pointer to the Session which issued the statement
295
* @param[in] schema_name The schema of the table being dropped
296
* @param[in] table_name The table name of the table being dropped
297
* @param[in] if_exists Did the user specify an IF EXISTS clause?
299
void dropTable(Session *in_session,
300
const std::string &schema_name,
301
const std::string &table_name,
304
* Creates a TruncateTable Statement GPB message and adds it
305
* to the Session's active Transaction GPB message for pushing
306
* out to the replicator streams.
308
* @param[in] in_session Pointer to the Session which issued the statement
309
* @param[in] in_table The Table being truncated
311
void truncateTable(Session *in_session, Table *in_table);
313
* Creates a new RawSql GPB message and pushes it to
316
* @TODO With a real data dictionary, this really shouldn't
317
* be needed. CREATE TABLE would map to insertRecord call
318
* on the I_S, etc. Not sure what to do with administrative
319
* commands like CHECK TABLE, though..
321
* @param in_session Pointer to the Session which issued the statement
322
* @param query Query string
324
void rawStatement(Session *in_session, const std::string &query);
63
325
/* 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);
326
int commitPhaseOne(Session *session, bool all);
327
int rollbackTransaction(Session *session, bool all);
67
329
/* 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);
330
int commitTransaction(Session *session, bool all);
331
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);
334
int rollbackToSavepoint(Session *session, NamedSavepoint &sv);
335
int setSavepoint(Session *session, NamedSavepoint &sv);
336
int releaseSavepoint(Session *session, NamedSavepoint &sv);
78
339
* Marks a storage engine as participating in a statement