80
80
* @param statement The statement to initialize
81
* @param in_session The session processing this statement
81
* @param session The Session object processing this statement
83
83
void finalizeStatementMessage(message::Statement &statement,
84
Session::reference session);
87
87
* Creates a new InsertRecord GPB message and pushes it to
90
* @param in_session Pointer to the Session which has inserted a record
91
* @param in_table Pointer to the Table containing insert information
90
* @param session Session object which has inserted a record
91
* @param table Table object containing insert information
93
93
* Grr, returning "true" here on error because of the cursor
94
94
* reversed bool return crap...fix that.
96
bool insertRecord(Session *in_session, Table *in_table);
96
bool insertRecord(Session::reference session, Table &in_table);
99
99
* Creates a new UpdateRecord GPB message and pushes it to
102
* @param in_session Pointer to the Session which has updated a record
103
* @param in_table Pointer to the Table containing update information
102
* @param session Session object which has updated a record
103
* @param table Table object containing update information
104
104
* @param old_record Pointer to the raw bytes representing the old record/row
105
105
* @param new_record Pointer to the raw bytes representing the new record/row
107
void updateRecord(Session *in_session,
107
void updateRecord(Session::reference session,
109
109
const unsigned char *old_record,
110
110
const unsigned char *new_record);
113
113
* Creates a new DeleteRecord GPB message and pushes it to
116
* @param in_session Pointer to the Session which has deleted a record
117
* @param in_table Pointer to the Table containing delete information
116
* @param session Session object which has deleted a record
117
* @param table Table object containing delete information
118
118
* @param use_update_record If true, uses the values from the update row instead
120
void deleteRecord(Session *in_session, Table *in_table, bool use_update_record= false);
120
void deleteRecord(Session::reference session,
122
bool use_update_record= false);
123
125
* Creates a CreateSchema Statement GPB message and adds it
124
126
* to the Session's active Transaction GPB message for pushing
125
127
* out to the replicator streams.
127
* @param[in] in_session Pointer to the Session which issued the statement
129
* @param[in] session Session object which issued the statement
128
130
* @param[in] schema message::Schema message describing new schema
130
void createSchema(Session *in_session, const message::Schema &schema);
132
void createSchema(Session::reference session, const message::Schema &schema);
133
135
* Creates a DropSchema Statement GPB message and adds it
134
136
* to the Session's active Transaction GPB message for pushing
135
137
* out to the replicator streams.
137
* @param[in] in_session Pointer to the Session which issued the statement
139
* @param[in] session Session object which issued the statement
138
140
* @param[in] identifier Identifier for the schema to drop
140
void dropSchema(Session *in_session, identifier::Schema::const_reference identifier);
142
void dropSchema(Session::reference session,
143
identifier::Schema::const_reference identifier);
143
146
* Creates an AlterSchema Statement GPB message and adds it
144
147
* to the Session's active Transaction GPB message for pushing
145
148
* out to the replicator streams.
147
* @param[in] in_session Pointer to the Session which issued the statement
150
* @param[in] session Session object which issued the statement
148
151
* @param[in] old_schema Original schema definition
149
152
* @param[in] new_schema New schema definition
151
void alterSchema(Session *in_session,
154
void alterSchema(Session::reference session,
152
155
const message::schema::shared_ptr &old_schema,
153
156
const message::Schema &new_schema);
157
160
* to the Session's active Transaction GPB message for pushing
158
161
* out to the replicator streams.
160
* @param[in] in_session Pointer to the Session which issued the statement
163
* @param[in] session Session object which issued the statement
161
164
* @param[in] table message::Table message describing new schema
163
void createTable(Session *in_session, const message::Table &table);
166
void createTable(Session::reference session, const message::Table &table);
166
169
* Creates a DropTable Statement GPB message and adds it
167
170
* to the Session's active Transaction GPB message for pushing
168
171
* out to the replicator streams.
170
* @param[in] in_session Pointer to the Session which issued the statement
173
* @param[in] session Session object which issued the statement
171
174
* @param[in] table Identifier for the table being dropped
172
175
* @param[in] if_exists Did the user specify an IF EXISTS clause?
174
void dropTable(Session *in_session,
177
void dropTable(Session::reference session,
175
178
const identifier::Table &table,
180
183
* to the Session's active Transaction GPB message for pushing
181
184
* out to the replicator streams.
183
* @param[in] in_session Pointer to the Session which issued the statement
184
* @param[in] in_table The Table being truncated
186
* @param[in] session Session object which issued the statement
187
* @param[in] table The Table being truncated
186
void truncateTable(Session *in_session, Table *in_table);
189
void truncateTable(Session::reference session, Table &table);
189
192
* Creates a new RawSql GPB message and pushes it to
194
197
* on the I_S, etc. Not sure what to do with administrative
195
198
* commands like CHECK TABLE, though..
197
* @param in_session Pointer to the Session which issued the statement
200
* @param session Session object which issued the statement
198
201
* @param query Query string
200
void rawStatement(Session *in_session, const std::string &query);
203
void rawStatement(Session::reference session, const std::string &query);
202
205
/* transactions: interface to plugin::StorageEngine functions */
203
int rollbackTransaction(Session *session, bool all);
205
/* transactions: these functions never call plugin::StorageEngine functions directly */
206
int commitTransaction(Session *session, bool all);
207
int autocommitOrRollback(Session *session, int error);
206
int rollbackTransaction(Session::reference session, bool all);
209
* Commit the current transaction.
212
* @retval 1 transaction was rolled back
213
* @retval 2 error during commit, data may be inconsistent
216
* Since we don't support nested statement transactions in 5.0,
217
* we can't commit or rollback stmt transactions while we are inside
218
* stored functions or triggers. So we simply do nothing now.
219
* This should be fixed in later ( >= 5.1) releases.
221
int commitTransaction(Session::reference session, bool all);
224
* This is used to commit or rollback a single statement depending on
225
* the value of error.
228
* Note that if the autocommit is on, then the following call inside
229
* InnoDB will commit or rollback the whole transaction (= the statement). The
230
* autocommit mechanism built into InnoDB is based on counting locks, but if
231
* the user has used LOCK TABLES then that mechanism does not know to do the
234
int autocommitOrRollback(Session::reference session, int error);
210
int rollbackToSavepoint(Session *session, NamedSavepoint &sv);
211
int setSavepoint(Session *session, NamedSavepoint &sv);
212
int releaseSavepoint(Session *session, NamedSavepoint &sv);
237
int rollbackToSavepoint(Session::reference session, NamedSavepoint &sv);
238
int setSavepoint(Session::reference session, NamedSavepoint &sv);
239
int releaseSavepoint(Session::reference session, NamedSavepoint &sv);
215
242
* Marks a storage engine as participating in a statement
225
252
* per statement, and therefore should not need to be idempotent.
226
253
* Put in assert()s to test this.
228
* @param[in] session Session pointer
255
* @param[in] session Session object
229
256
* @param[in] monitored Descriptor for the resource which will be participating
230
257
* @param[in] engine Pointer to the TransactionalStorageEngine resource
232
void registerResourceForStatement(Session *session,
259
void registerResourceForStatement(Session::reference session,
233
260
plugin::MonitoredInTransaction *monitored,
234
261
plugin::TransactionalStorageEngine *engine);
247
274
* per statement, and therefore should not need to be idempotent.
248
275
* Put in assert()s to test this.
250
* @param[in] session Session pointer
277
* @param[in] session Session object
251
278
* @param[in] monitored Descriptor for the resource which will be participating
252
279
* @param[in] engine Pointer to the TransactionalStorageEngine resource
253
280
* @param[in] resource_manager Pointer to the XaResourceManager resource manager
255
void registerResourceForStatement(Session *session,
282
void registerResourceForStatement(Session::reference session,
256
283
plugin::MonitoredInTransaction *monitored,
257
284
plugin::TransactionalStorageEngine *engine,
258
285
plugin::XaResourceManager *resource_manager);
281
308
* time when this method is called except from the
282
309
* TransactionServices::registerResourceForStatement method.
284
void registerResourceForTransaction(Session *session,
311
void registerResourceForTransaction(Session::reference session,
285
312
plugin::MonitoredInTransaction *monitored,
286
313
plugin::TransactionalStorageEngine *engine);
288
void registerResourceForTransaction(Session *session,
315
void registerResourceForTransaction(Session::reference session,
289
316
plugin::MonitoredInTransaction *monitored,
290
317
plugin::TransactionalStorageEngine *engine,
291
318
plugin::XaResourceManager *resource_manager);
300
327
* Send server startup event.
302
* @param session Session pointer
329
* @param session Session object
304
331
* @retval true Success
305
332
* @retval false Failure
307
bool sendStartupEvent(Session *session);
334
bool sendStartupEvent(Session::reference session);
310
337
* Send server shutdown event.
312
* @param session Session pointer
339
* @param session Session object
314
341
* @retval true Success
315
342
* @retval false Failure
317
bool sendShutdownEvent(Session *session);
344
bool sendShutdownEvent(Session::reference session);
326
353
* object (e.g., splitting up Transactions into smaller chunks). The
327
354
* should_inc_trx_id flag controls if we do this.
329
* @param in_session The session processing the transaction
356
* @param session The Session object processing the transaction
330
357
* @param should_inc_trx_id If true, increments the transaction id for a new trx
332
message::Transaction *getActiveTransactionMessage(Session *in_session,
359
message::Transaction *getActiveTransactionMessage(Session::reference session,
333
360
bool should_inc_trx_id= true);
338
365
* transaction information. This method also ensure the
339
366
* 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
368
* @param transaction The transaction message to initialize
369
* @param session The Session object processing this transaction
343
370
* @param should_inc_trx_id If true, increments the transaction id for a new trx
345
void initTransactionMessage(message::Transaction &in_transaction,
372
void initTransactionMessage(message::Transaction &transaction,
373
Session::reference session,
347
374
bool should_inc_trx_id);
350
377
* Helper method which initializes a Statement message
352
379
* @param statement The statement to initialize
353
* @param in_type The type of the statement
354
* @param in_session The session processing this statement
380
* @param type The type of the statement
381
* @param session The Session object processing this statement
356
383
void initStatementMessage(message::Statement &statement,
357
message::Statement::Type in_type,
358
Session *in_session);
384
message::Statement::Type type,
385
Session::const_reference session);
361
388
* Helper method which finalizes data members for the
362
389
* supplied transaction's context.
364
* @param in_transaction The transaction message to finalize
365
* @param in_session The Session processing this transaction
391
* @param transaction The transaction message to finalize
392
* @param session The Session object processing this transaction
367
void finalizeTransactionMessage(message::Transaction &in_transaction, Session *in_session);
394
void finalizeTransactionMessage(message::Transaction &transaction,
395
Session::const_reference session);
370
398
* Helper method which deletes transaction memory and
371
399
* unsets Session's transaction and statement messages.
373
void cleanupTransactionMessage(message::Transaction *in_transaction,
374
Session *in_session);
401
void cleanupTransactionMessage(message::Transaction *transaction,
402
Session::reference session);
376
404
/** Helper method which returns an initialized Statement message for methods
377
405
* 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
407
* @param[in] session Session object doing the processing
408
* @param[in] table Table object being inserted into
381
409
* @param[out] next_segment_id The next Statement segment id to be used
383
message::Statement &getInsertStatement(Session *in_session,
411
message::Statement &getInsertStatement(Session::reference session,
385
413
uint32_t *next_segment_id);
389
417
* insert operations.
391
419
* @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
420
* @param[in] session Session object doing the processing
421
* @param[in] table Table object being inserted into
395
423
void setInsertHeader(message::Statement &statement,
424
Session::const_reference session,
399
427
* Helper method which returns an initialized Statement
400
428
* 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
430
* @param[in] session Session object doing the processing
431
* @param[in] table Table object being updated
404
432
* @param[in] old_record Pointer to the old data in the record
405
433
* @param[in] new_record Pointer to the new data in the record
406
434
* @param[out] next_segment_id The next Statement segment id to be used
408
message::Statement &getUpdateStatement(Session *in_session,
436
message::Statement &getUpdateStatement(Session::reference session,
410
438
const unsigned char *old_record,
411
439
const unsigned char *new_record,
412
440
uint32_t *next_segment_id);
415
443
* update operations.
417
445
* @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
446
* @param[in] session Session object doing the processing
447
* @param[in] table Table object being updated
420
448
* @param[in] old_record Pointer to the old data in the record
421
449
* @param[in] new_record Pointer to the new data in the record
423
451
void setUpdateHeader(message::Statement &statement,
452
Session::const_reference session,
426
454
const unsigned char *old_record,
427
455
const unsigned char *new_record);
430
458
* Helper method which returns an initialized Statement
431
459
* 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
461
* @param[in] session Session object doing the processing
462
* @param[in] table Table object being deleted from
435
463
* @param[out] next_segment_id The next Statement segment id to be used
437
message::Statement &getDeleteStatement(Session *in_session,
465
message::Statement &getDeleteStatement(Session::reference session,
439
467
uint32_t *next_segment_id);
443
471
* insert operations.
445
473
* @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
474
* @param[in] session Session object doing the processing
475
* @param[in] table Table object being deleted from
449
477
void setDeleteHeader(message::Statement &statement,
478
Session::const_reference session,
454
482
* Commits a normal transaction (see above) and pushes the transaction
455
483
* message out to the replicators.
457
* @param in_session Pointer to the Session committing the transaction
485
* @param session Session object committing the transaction
459
int commitTransactionMessage(Session *in_session);
487
int commitTransactionMessage(Session::reference session);
462
490
* Marks the current active transaction message as being rolled back and
463
491
* pushes the transaction message out to replicators.
465
* @param in_session Pointer to the Session committing the transaction
493
* @param session Session object committing the transaction
467
void rollbackTransactionMessage(Session *in_session);
495
void rollbackTransactionMessage(Session::reference session);
470
498
* Rolls back the current statement, deleting the last Statement out of
471
499
* the current Transaction message.
501
* @param session Session object committing the transaction
473
503
* @note This depends on having clear statement boundaries (i.e., one
474
* Statement message per actual SQL statement.
504
* Statement message per actual SQL statement).
476
void rollbackStatementMessage(Session *in_session);
506
void rollbackStatementMessage(Session::reference session);
479
509
* Checks if a field has been updated
481
511
* @param current_field Pointer to the field to check if it is updated
482
* @param in_table Pointer to the Table containing update information
512
* @param table Table object containing update information
483
513
* @param old_record Pointer to the raw bytes representing the old record/row
484
514
* @param new_record Pointer to the raw bytes representing the new record/row
486
516
bool isFieldUpdated(Field *current_field,
488
518
const unsigned char *old_record,
489
519
const unsigned char *new_record);
495
525
* message associated with Session. We create a totally new message and
498
* @param session Session pointer
528
* @param session Session object
499
529
* @param event Event message to send
501
531
* @note Used by the public Events API.
503
533
* @returns Non-zero on error
505
int sendEvent(Session *session, const message::Event &event);
535
int sendEvent(Session::reference session, const message::Event &event);
508
538
* Makes a given Transaction message segmented.
511
541
* appropriately and a new Transaction message, containing the same
512
542
* transaction ID as the supplied Transaction, and is created.
514
* @param in_session Session pointer
515
* @param transaction Pointer to the Transaction message to segment.
544
* @param session Session object
545
* @param transaction Transaction message to segment.
517
547
* @returns Returns a pointer to a new Transaction message ready for use.
519
message::Transaction *segmentTransactionMessage(Session *in_session,
549
message::Transaction *segmentTransactionMessage(Session::reference session,
520
550
message::Transaction *transaction);
522
int commitPhaseOne(Session *session, bool all);
552
int commitPhaseOne(Session::reference session, bool all);
524
uint64_t getCurrentTransactionId(Session *session);
554
uint64_t getCurrentTransactionId(Session::reference session);
526
556
plugin::XaStorageEngine *xa_storage_engine;