72
72
* Transaction and Statement messages, false otherwise.
74
74
bool shouldConstructMessages();
76
* Method which returns the active Transaction message
77
* for the supplied Session. If one is not found, a new Transaction
78
* message is allocated, initialized, and returned. It is possible that
79
* we may want to NOT increment the transaction id for a new Transaction
80
* object (e.g., splitting up Transactions into smaller chunks). The
81
* should_inc_trx_id flag controls if we do this.
83
* @param in_session The session processing the transaction
84
* @param should_inc_trx_id If true, increments the transaction id for a new trx
86
message::Transaction *getActiveTransactionMessage(Session *in_session,
87
bool should_inc_trx_id= true);
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 in_transaction The transaction message to initialize
95
* @param in_session The Session processing this transaction
96
* @param should_inc_trx_id If true, increments the transaction id for a new trx
98
void initTransactionMessage(message::Transaction &in_transaction,
100
bool should_inc_trx_id);
102
* Helper method which finalizes data members for the
103
* supplied transaction's context.
105
* @param in_transaction The transaction message to finalize
106
* @param in_session The Session processing this transaction
108
void finalizeTransactionMessage(message::Transaction &in_transaction, Session *in_session);
110
* Helper method which deletes transaction memory and
111
* unsets Session's transaction and statement messages.
113
void cleanupTransactionMessage(message::Transaction *in_transaction,
114
Session *in_session);
117
* Helper method which initializes a Statement message
119
* @param statement The statement to initialize
120
* @param in_type The type of the statement
121
* @param in_session The session processing this statement
123
void initStatementMessage(message::Statement &statement,
124
message::Statement::Type in_type,
125
Session *in_session);
127
77
* Finalizes a Statement message and sets the Session's statement
128
78
* message to NULL.
133
83
void finalizeStatementMessage(message::Statement &statement,
134
84
Session *in_session);
135
/** Helper method which returns an initialized Statement message for methods
136
* doing insertion of data.
138
* @param[in] in_session Pointer to the Session doing the processing
139
* @param[in] in_table Pointer to the Table object being inserted into
140
* @param[out] next_segment_id The next Statement segment id to be used
142
message::Statement &getInsertStatement(Session *in_session,
144
uint32_t *next_segment_id);
147
* Helper method which initializes the header message for
150
* @param[in,out] statement Statement message container to modify
151
* @param[in] in_session Pointer to the Session doing the processing
152
* @param[in] in_table Pointer to the Table being inserted into
154
void setInsertHeader(message::Statement &statement,
158
* Helper method which returns an initialized Statement
159
* message for methods doing updates of data.
161
* @param[in] in_session Pointer to the Session doing the processing
162
* @param[in] in_table Pointer to the Table object being updated
163
* @param[in] old_record Pointer to the old data in the record
164
* @param[in] new_record Pointer to the new data in the record
165
* @param[out] next_segment_id The next Statement segment id to be used
167
message::Statement &getUpdateStatement(Session *in_session,
169
const unsigned char *old_record,
170
const unsigned char *new_record,
171
uint32_t *next_segment_id);
173
* Helper method which initializes the header message for
176
* @param[in,out] statement Statement message container to modify
177
* @param[in] in_session Pointer to the Session doing the processing
178
* @param[in] in_table Pointer to the Table being updated
179
* @param[in] old_record Pointer to the old data in the record
180
* @param[in] new_record Pointer to the new data in the record
182
void setUpdateHeader(message::Statement &statement,
185
const unsigned char *old_record,
186
const unsigned char *new_record);
188
* Helper method which returns an initialized Statement
189
* message for methods doing deletion of data.
191
* @param[in] in_session Pointer to the Session doing the processing
192
* @param[in] in_table Pointer to the Table object being deleted from
193
* @param[out] next_segment_id The next Statement segment id to be used
195
message::Statement &getDeleteStatement(Session *in_session,
197
uint32_t *next_segment_id);
200
* Helper method which initializes the header message for
203
* @param[in,out] statement Statement message container to modify
204
* @param[in] in_session Pointer to the Session doing the processing
205
* @param[in] in_table Pointer to the Table being deleted from
207
void setDeleteHeader(message::Statement &statement,
211
* Commits a normal transaction (see above) and pushes the transaction
212
* message out to the replicators.
214
* @param in_session Pointer to the Session committing the transaction
216
int commitTransactionMessage(Session *in_session);
218
* Marks the current active transaction message as being rolled back and
219
* pushes the transaction message out to replicators.
221
* @param in_session Pointer to the Session committing the transaction
223
void rollbackTransactionMessage(Session *in_session);
225
* Rolls back the current statement, deleting the last Statement out of
226
* the current Transaction message.
228
* @note This depends on having clear statement boundaries (i.e., one
229
* Statement message per actual SQL statement.
231
void rollbackStatementMessage(Session *in_session);
233
87
* Creates a new InsertRecord GPB message and pushes it to
264
120
void deleteRecord(Session *in_session, Table *in_table, bool use_update_record= false);
267
* Used to undo effects of a failed statement.
269
* An SQL statement, like an UPDATE, that affects multiple rows could
270
* potentially fail mid-way through processing the rows. In such a case,
271
* the successfully modified rows that preceeded the failing row would
272
* have been added to the Statement message. This method is used for
273
* rolling back that change.
276
* This particular failure is seen on column constraint violations
277
* during a multi-row UPDATE and a multi-row INSERT..SELECT.
279
* @param in_session Pointer to the Session containing the Statement
280
* @param count The number of records to remove from Statement.
282
* @retval true Successfully removed 'count' records
283
* @retval false Failure
285
bool removeStatementRecords(Session *in_session, uint32_t count);
288
123
* Creates a CreateSchema Statement GPB message and adds it
289
124
* to the Session's active Transaction GPB message for pushing
290
125
* out to the replicator streams.
322
* Method which returns the active Transaction message
323
* for the supplied Session. If one is not found, a new Transaction
324
* message is allocated, initialized, and returned. It is possible that
325
* we may want to NOT increment the transaction id for a new Transaction
326
* object (e.g., splitting up Transactions into smaller chunks). The
327
* should_inc_trx_id flag controls if we do this.
329
* @param in_session The session processing the transaction
330
* @param should_inc_trx_id If true, increments the transaction id for a new trx
332
message::Transaction *getActiveTransactionMessage(Session *in_session,
333
bool should_inc_trx_id= true);
336
* Method which attaches a transaction context
337
* the supplied transaction based on the supplied Session's
338
* transaction information. This method also ensure the
339
* transaction message is attached properly to the Session object
341
* @param in_transaction The transaction message to initialize
342
* @param in_session The Session processing this transaction
343
* @param should_inc_trx_id If true, increments the transaction id for a new trx
345
void initTransactionMessage(message::Transaction &in_transaction,
347
bool should_inc_trx_id);
350
* Helper method which initializes a Statement message
352
* @param statement The statement to initialize
353
* @param in_type The type of the statement
354
* @param in_session The session processing this statement
356
void initStatementMessage(message::Statement &statement,
357
message::Statement::Type in_type,
358
Session *in_session);
361
* Helper method which finalizes data members for the
362
* supplied transaction's context.
364
* @param in_transaction The transaction message to finalize
365
* @param in_session The Session processing this transaction
367
void finalizeTransactionMessage(message::Transaction &in_transaction, Session *in_session);
370
* Helper method which deletes transaction memory and
371
* unsets Session's transaction and statement messages.
373
void cleanupTransactionMessage(message::Transaction *in_transaction,
374
Session *in_session);
376
/** Helper method which returns an initialized Statement message for methods
377
* doing insertion of data.
379
* @param[in] in_session Pointer to the Session doing the processing
380
* @param[in] in_table Pointer to the Table object being inserted into
381
* @param[out] next_segment_id The next Statement segment id to be used
383
message::Statement &getInsertStatement(Session *in_session,
385
uint32_t *next_segment_id);
388
* Helper method which initializes the header message for
391
* @param[in,out] statement Statement message container to modify
392
* @param[in] in_session Pointer to the Session doing the processing
393
* @param[in] in_table Pointer to the Table being inserted into
395
void setInsertHeader(message::Statement &statement,
399
* Helper method which returns an initialized Statement
400
* message for methods doing updates of data.
402
* @param[in] in_session Pointer to the Session doing the processing
403
* @param[in] in_table Pointer to the Table object being updated
404
* @param[in] old_record Pointer to the old data in the record
405
* @param[in] new_record Pointer to the new data in the record
406
* @param[out] next_segment_id The next Statement segment id to be used
408
message::Statement &getUpdateStatement(Session *in_session,
410
const unsigned char *old_record,
411
const unsigned char *new_record,
412
uint32_t *next_segment_id);
414
* Helper method which initializes the header message for
417
* @param[in,out] statement Statement message container to modify
418
* @param[in] in_session Pointer to the Session doing the processing
419
* @param[in] in_table Pointer to the Table being updated
420
* @param[in] old_record Pointer to the old data in the record
421
* @param[in] new_record Pointer to the new data in the record
423
void setUpdateHeader(message::Statement &statement,
426
const unsigned char *old_record,
427
const unsigned char *new_record);
430
* Helper method which returns an initialized Statement
431
* message for methods doing deletion of data.
433
* @param[in] in_session Pointer to the Session doing the processing
434
* @param[in] in_table Pointer to the Table object being deleted from
435
* @param[out] next_segment_id The next Statement segment id to be used
437
message::Statement &getDeleteStatement(Session *in_session,
439
uint32_t *next_segment_id);
442
* Helper method which initializes the header message for
445
* @param[in,out] statement Statement message container to modify
446
* @param[in] in_session Pointer to the Session doing the processing
447
* @param[in] in_table Pointer to the Table being deleted from
449
void setDeleteHeader(message::Statement &statement,
454
* Commits a normal transaction (see above) and pushes the transaction
455
* message out to the replicators.
457
* @param in_session Pointer to the Session committing the transaction
459
int commitTransactionMessage(Session *in_session);
462
* Marks the current active transaction message as being rolled back and
463
* pushes the transaction message out to replicators.
465
* @param in_session Pointer to the Session committing the transaction
467
void rollbackTransactionMessage(Session *in_session);
470
* Rolls back the current statement, deleting the last Statement out of
471
* the current Transaction message.
473
* @note This depends on having clear statement boundaries (i.e., one
474
* Statement message per actual SQL statement.
476
void rollbackStatementMessage(Session *in_session);
485
479
* Checks if a field has been updated
487
481
* @param current_field Pointer to the field to check if it is updated
488
* @in_table Pointer to the Table containing update information
482
* @param in_table Pointer to the Table containing update information
489
483
* @param old_record Pointer to the raw bytes representing the old record/row
490
484
* @param new_record Pointer to the raw bytes representing the new record/row