~ubuntu-branches/ubuntu/quantal/drizzle/quantal

1 by Monty Taylor
Import upstream version 2010.03.1347
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1.2.4 by Monty Taylor
Import upstream version 2010.12.06
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
 *  Copyright (C) 2010 Jay Pipes <jaypipes@gmail.com>
1 by Monty Taylor
Import upstream version 2010.03.1347
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; version 2 of the License.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 */
20
21
/**
22
 * @file Transaction processing code
23
 */
24
1.2.10 by Monty Taylor
Import upstream version 2011.03.13
25
#pragma once
1 by Monty Taylor
Import upstream version 2010.03.1347
26
1.2.8 by Monty Taylor
Import upstream version 2011.02.10
27
#include <drizzled/atomics.h>
28
#include <drizzled/message/transaction.pb.h>
29
#include <drizzled/identifier/table.h>
1.2.9 by Monty Taylor
Import upstream version 2011.03.11
30
#include <drizzled/identifier/schema.h>
1.2.8 by Monty Taylor
Import upstream version 2011.02.10
31
#include <drizzled/message/schema.h>
32
#include <drizzled/session.h>
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
33
1.2.9 by Monty Taylor
Import upstream version 2011.03.11
34
#include <drizzled/visibility.h>
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
35
1 by Monty Taylor
Import upstream version 2010.03.1347
36
namespace drizzled
37
{
38
39
/* some forward declarations needed */
40
namespace plugin
41
{
42
  class MonitoredInTransaction;
43
  class XaResourceManager;
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
44
  class XaStorageEngine;
1 by Monty Taylor
Import upstream version 2010.03.1347
45
  class TransactionalStorageEngine;
46
}
47
1.2.8 by Monty Taylor
Import upstream version 2011.02.10
48
class Session;
1 by Monty Taylor
Import upstream version 2010.03.1347
49
class NamedSavepoint;
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
50
class Field;
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
51
1 by Monty Taylor
Import upstream version 2010.03.1347
52
/**
53
 * This is a class which manages the XA transaction processing
54
 * in the server
55
 */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
56
class DRIZZLED_API TransactionServices
1 by Monty Taylor
Import upstream version 2010.03.1347
57
{
58
public:
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
59
  static const size_t DEFAULT_RECORD_SIZE= 100;
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
60
  
61
  TransactionServices();
1 by Monty Taylor
Import upstream version 2010.03.1347
62
63
  /**
64
   * Singleton method
65
   * Returns the singleton instance of TransactionServices
66
   */
67
  static inline TransactionServices &singleton()
68
  {
69
    static TransactionServices transaction_services;
70
    return transaction_services;
71
  }
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
72
73
  /**
74
   * Returns true if the transaction manager should construct
75
   * Transaction and Statement messages, false otherwise.
76
   */
77
  bool shouldConstructMessages();
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
78
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
79
  /**
80
   * Finalizes a Statement message and sets the Session's statement
81
   * message to NULL.
82
   *
83
   * @param statement The statement to initialize
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
84
   * @param session The Session object processing this statement
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
85
   */
86
  void finalizeStatementMessage(message::Statement &statement,
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
87
                                Session::reference session);
88
1.2.4 by Monty Taylor
Import upstream version 2010.12.06
89
  /**
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
90
   * Creates a new InsertRecord GPB message and pushes it to
91
   * replicators.
92
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
93
   * @param session Session object which has inserted a record
94
   * @param table Table object containing insert information
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
95
   *
96
   * Grr, returning "true" here on error because of the cursor
97
   * reversed bool return crap...fix that.
98
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
99
  bool insertRecord(Session::reference session, Table &in_table);
100
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
101
  /**
102
   * Creates a new UpdateRecord GPB message and pushes it to
103
   * replicators.
104
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
105
   * @param session Session object which has updated a record
106
   * @param table Table object containing update information
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
107
   * @param old_record Pointer to the raw bytes representing the old record/row
108
   * @param new_record Pointer to the raw bytes representing the new record/row 
109
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
110
  void updateRecord(Session::reference session, 
111
                    Table &table, 
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
112
                    const unsigned char *old_record, 
113
                    const unsigned char *new_record);
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
114
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
115
  /**
116
   * Creates a new DeleteRecord GPB message and pushes it to
117
   * replicators.
118
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
119
   * @param session Session object which has deleted a record
120
   * @param table Table object containing delete information
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
121
   * @param use_update_record If true, uses the values from the update row instead
122
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
123
  void deleteRecord(Session::reference session,
124
                    Table &table,
125
                    bool use_update_record= false);
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
126
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
127
  /**
128
   * Creates a CreateSchema Statement GPB message and adds it
129
   * to the Session's active Transaction GPB message for pushing
130
   * out to the replicator streams.
131
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
132
   * @param[in] session Session object which issued the statement
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
133
   * @param[in] schema message::Schema message describing new schema
134
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
135
  void createSchema(Session::reference session, const message::Schema &schema);
1.2.5 by Monty Taylor
Import upstream version 2011.01.07
136
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
137
  /**
138
   * Creates a DropSchema Statement GPB message and adds it
139
   * to the Session's active Transaction GPB message for pushing
140
   * out to the replicator streams.
141
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
142
   * @param[in] session Session object which issued the statement
143
   * @param[in] identifier Identifier for the schema to drop
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
144
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
145
  void dropSchema(Session::reference session,
1.2.9 by Monty Taylor
Import upstream version 2011.03.11
146
                  identifier::Schema::const_reference identifier,
147
                  message::schema::const_reference schema);
1.2.6 by Monty Taylor
Import upstream version 2011.01.08
148
149
  /**
150
   * Creates an AlterSchema Statement GPB message and adds it
151
   * to the Session's active Transaction GPB message for pushing
152
   * out to the replicator streams.
153
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
154
   * @param[in] session Session object which issued the statement
1.2.6 by Monty Taylor
Import upstream version 2011.01.08
155
   * @param[in] old_schema Original schema definition
156
   * @param[in] new_schema New schema definition
157
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
158
  void alterSchema(Session::reference session,
1.2.9 by Monty Taylor
Import upstream version 2011.03.11
159
                   const message::Schema &old_schema,
1.2.6 by Monty Taylor
Import upstream version 2011.01.08
160
                   const message::Schema &new_schema);
1.2.5 by Monty Taylor
Import upstream version 2011.01.07
161
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
162
  /**
163
   * Creates a CreateTable Statement GPB message and adds it
164
   * to the Session's active Transaction GPB message for pushing
165
   * out to the replicator streams.
166
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
167
   * @param[in] session Session object which issued the statement
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
168
   * @param[in] table message::Table message describing new schema
169
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
170
  void createTable(Session::reference session, const message::Table &table);
171
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
172
  /**
173
   * Creates a DropTable Statement GPB message and adds it
174
   * to the Session's active Transaction GPB message for pushing
175
   * out to the replicator streams.
176
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
177
   * @param[in] session Session object which issued the statement
1.2.5 by Monty Taylor
Import upstream version 2011.01.07
178
   * @param[in] table Identifier for the table being dropped
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
179
   * @param[in] if_exists Did the user specify an IF EXISTS clause?
180
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
181
  void dropTable(Session::reference session,
1.2.9 by Monty Taylor
Import upstream version 2011.03.11
182
                 identifier::Table::const_reference identifier,
183
                 message::table::const_reference table,
1.2.5 by Monty Taylor
Import upstream version 2011.01.07
184
                 bool if_exists);
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
185
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
186
  /**
187
   * Creates a TruncateTable Statement GPB message and adds it
188
   * to the Session's active Transaction GPB message for pushing
189
   * out to the replicator streams.
190
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
191
   * @param[in] session Session object which issued the statement
192
   * @param[in] table The Table being truncated
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
193
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
194
  void truncateTable(Session::reference session, Table &table);
195
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
196
  /**
197
   * Creates a new RawSql GPB message and pushes it to 
198
   * replicators.
199
   *
200
   * @TODO With a real data dictionary, this really shouldn't
201
   * be needed.  CREATE TABLE would map to insertRecord call
202
   * on the I_S, etc.  Not sure what to do with administrative
203
   * commands like CHECK TABLE, though..
204
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
205
   * @param session Session object which issued the statement
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
206
   * @param query Query string
1.2.10 by Monty Taylor
Import upstream version 2011.03.13
207
   * @param schema Schema for the table affected by the raw SQL.
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
208
   */
1.2.10 by Monty Taylor
Import upstream version 2011.03.13
209
  void rawStatement(Session::reference session,
210
                    const std::string &query,
211
                    const std::string &schema);
212
213
  void rawStatement(Session::reference session, const std::string &query)
214
  {
215
    rawStatement(session, query, "");
216
  }
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
217
1 by Monty Taylor
Import upstream version 2010.03.1347
218
  /* transactions: interface to plugin::StorageEngine functions */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
219
  int rollbackTransaction(Session::reference session, bool all);
220
221
  /**
222
   * Commit the current transaction.
223
   *
224
   * @retval 0 ok
225
   * @retval 1 transaction was rolled back
226
   * @retval 2 error during commit, data may be inconsistent
227
   *
228
   * @todo
229
   * Since we don't support nested statement transactions in 5.0,
230
   * we can't commit or rollback stmt transactions while we are inside
231
   * stored functions or triggers. So we simply do nothing now.
232
   * This should be fixed in later ( >= 5.1) releases.
233
   */
234
  int commitTransaction(Session::reference session, bool all);
235
236
  /**
237
   * This is used to commit or rollback a single statement depending on
238
   * the value of error.
239
   *
240
   * @note
241
   * Note that if the autocommit is on, then the following call inside
242
   * InnoDB will commit or rollback the whole transaction (= the statement). The
243
   * autocommit mechanism built into InnoDB is based on counting locks, but if
244
   * the user has used LOCK TABLES then that mechanism does not know to do the
245
   * commit.
246
   */
247
  int autocommitOrRollback(Session::reference session, int error);
1 by Monty Taylor
Import upstream version 2010.03.1347
248
249
  /* savepoints */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
250
  int rollbackToSavepoint(Session::reference session, NamedSavepoint &sv);
251
  int setSavepoint(Session::reference session, NamedSavepoint &sv);
252
  int releaseSavepoint(Session::reference session, NamedSavepoint &sv);
1 by Monty Taylor
Import upstream version 2010.03.1347
253
254
  /**
255
   * Marks a storage engine as participating in a statement
256
   * transaction.
257
   *
258
   * @note
259
   * 
260
   * This method is idempotent
261
   *
262
   * @todo
263
   *
264
   * This method should not be called more than once per resource
265
   * per statement, and therefore should not need to be idempotent.
266
   * Put in assert()s to test this.
267
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
268
   * @param[in] session Session object
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
269
   * @param[in] monitored Descriptor for the resource which will be participating
270
   * @param[in] engine Pointer to the TransactionalStorageEngine resource
1 by Monty Taylor
Import upstream version 2010.03.1347
271
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
272
  void registerResourceForStatement(Session::reference session,
1 by Monty Taylor
Import upstream version 2010.03.1347
273
                                    plugin::MonitoredInTransaction *monitored,
274
                                    plugin::TransactionalStorageEngine *engine);
275
276
  /**
277
   * Marks an XA storage engine as participating in a statement
278
   * transaction.
279
   *
280
   * @note
281
   * 
282
   * This method is idempotent
283
   *
284
   * @todo
285
   *
286
   * This method should not be called more than once per resource
287
   * per statement, and therefore should not need to be idempotent.
288
   * Put in assert()s to test this.
289
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
290
   * @param[in] session Session object
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
291
   * @param[in] monitored Descriptor for the resource which will be participating
292
   * @param[in] engine Pointer to the TransactionalStorageEngine resource
293
   * @param[in] resource_manager Pointer to the XaResourceManager resource manager
1 by Monty Taylor
Import upstream version 2010.03.1347
294
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
295
  void registerResourceForStatement(Session::reference session,
1 by Monty Taylor
Import upstream version 2010.03.1347
296
                                    plugin::MonitoredInTransaction *monitored,
297
                                    plugin::TransactionalStorageEngine *engine,
298
                                    plugin::XaResourceManager *resource_manager);
299
300
  /**
301
   * Registers a resource manager in the "normal" transaction.
302
   *
303
   * @note
304
   *
305
   * This method is idempotent and must be idempotent
306
   * because it can be called both by the above 
307
   * TransactionServices::registerResourceForStatement(),
308
   * which occurs at the beginning of each SQL statement,
309
   * and also manually when a BEGIN WORK/START TRANSACTION
310
   * statement is executed. If the latter case (BEGIN WORK)
311
   * is called, then subsequent contained statement transactions
312
   * will call this method as well.
313
   *
314
   * @note
315
   *
316
   * This method checks to see if the supplied resource
317
   * is also registered in the statement transaction, and
318
   * if not, registers the resource in the statement
319
   * transaction.  This happens ONLY when the user has
320
   * called BEGIN WORK/START TRANSACTION, which is the only
321
   * time when this method is called except from the
322
   * TransactionServices::registerResourceForStatement method.
323
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
324
  void registerResourceForTransaction(Session::reference session,
1 by Monty Taylor
Import upstream version 2010.03.1347
325
                                      plugin::MonitoredInTransaction *monitored,
326
                                      plugin::TransactionalStorageEngine *engine);
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
327
328
  void registerResourceForTransaction(Session::reference session,
1 by Monty Taylor
Import upstream version 2010.03.1347
329
                                      plugin::MonitoredInTransaction *monitored,
330
                                      plugin::TransactionalStorageEngine *engine,
331
                                      plugin::XaResourceManager *resource_manager);
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
332
333
  void allocateNewTransactionId();
334
 
335
  /**************
336
   * Events API
337
   **************/
338
339
  /**
340
   * Send server startup event.
341
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
342
   * @param session Session object
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
343
   *
344
   * @retval true Success
345
   * @retval false Failure
346
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
347
  bool sendStartupEvent(Session::reference session);
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
348
349
  /**
350
   * Send server shutdown event.
351
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
352
   * @param session Session object
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
353
   *
354
   * @retval true Success
355
   * @retval false Failure
356
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
357
  bool sendShutdownEvent(Session::reference session);
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
358
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
359
private:
360
361
  /**
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
362
   * Method which returns the active Transaction message
363
   * for the supplied Session.  If one is not found, a new Transaction
364
   * message is allocated, initialized, and returned. It is possible that
365
   * we may want to NOT increment the transaction id for a new Transaction
366
   * object (e.g., splitting up Transactions into smaller chunks). The
367
   * should_inc_trx_id flag controls if we do this.
368
   *
369
   * @param session The Session object processing the transaction
370
   * @param should_inc_trx_id If true, increments the transaction id for a new trx
371
   */
372
  message::Transaction *getActiveTransactionMessage(Session::reference session,
373
                                                    bool should_inc_trx_id= true);
374
375
  /** 
376
   * Method which attaches a transaction context
377
   * the supplied transaction based on the supplied Session's
378
   * transaction information.  This method also ensure the
379
   * transaction message is attached properly to the Session object
380
   *
381
   * @param transaction The transaction message to initialize
382
   * @param session The Session object processing this transaction
383
   * @param should_inc_trx_id If true, increments the transaction id for a new trx
384
   */
385
  void initTransactionMessage(message::Transaction &transaction,
386
                              Session::reference session,
387
                              bool should_inc_trx_id);
388
  
389
  /**
390
   * Helper method which initializes a Statement message
391
   *
392
   * @param statement The statement to initialize
393
   * @param type The type of the statement
394
   * @param session The Session object processing this statement
395
   */
396
  void initStatementMessage(message::Statement &statement,
397
                            message::Statement::Type type,
398
                            Session::const_reference session);
399
400
  /** 
401
   * Helper method which finalizes data members for the 
402
   * supplied transaction's context.
403
   *
404
   * @param transaction The transaction message to finalize 
405
   * @param session The Session object processing this transaction
406
   */
407
  void finalizeTransactionMessage(message::Transaction &transaction,
408
                                  Session::const_reference session);
409
410
  /**
411
   * Helper method which deletes transaction memory and
412
   * unsets Session's transaction and statement messages.
413
   */
414
  void cleanupTransactionMessage(message::Transaction *transaction,
415
                                 Session::reference session);
416
  
417
  /** Helper method which returns an initialized Statement message for methods
418
   * doing insertion of data.
419
   *
420
   * @param[in] session Session object doing the processing
421
   * @param[in] table Table object being inserted into
422
   * @param[out] next_segment_id The next Statement segment id to be used
423
   */
424
  message::Statement &getInsertStatement(Session::reference session,
425
                                         Table &table,
426
                                         uint32_t *next_segment_id);
427
  
428
  /**
429
   * Helper method which initializes the header message for
430
   * insert operations.
431
   *
432
   * @param[in,out] statement Statement message container to modify
433
   * @param[in] session Session object doing the processing
434
   * @param[in] table Table object being inserted into
435
   */
436
  void setInsertHeader(message::Statement &statement,
437
                       Session::const_reference session,
438
                       Table &table);
439
  /**
440
   * Helper method which returns an initialized Statement
441
   * message for methods doing updates of data.
442
   *
443
   * @param[in] session Session object doing the processing
444
   * @param[in] table Table object being updated
445
   * @param[in] old_record Pointer to the old data in the record
446
   * @param[in] new_record Pointer to the new data in the record
447
   * @param[out] next_segment_id The next Statement segment id to be used
448
   */
449
  message::Statement &getUpdateStatement(Session::reference session,
450
                                         Table &table,
451
                                         const unsigned char *old_record, 
452
                                         const unsigned char *new_record,
453
                                         uint32_t *next_segment_id);
454
  /**
455
   * Helper method which initializes the header message for
456
   * update operations.
457
   *
458
   * @param[in,out] statement Statement message container to modify
459
   * @param[in] session Session object doing the processing
460
   * @param[in] table Table object being updated
461
   * @param[in] old_record Pointer to the old data in the record
462
   * @param[in] new_record Pointer to the new data in the record
463
   */
464
  void setUpdateHeader(message::Statement &statement,
465
                       Session::const_reference session,
466
                       Table &table,
467
                       const unsigned char *old_record, 
468
                       const unsigned char *new_record);
469
470
  /**
471
   * Helper method which returns an initialized Statement
472
   * message for methods doing deletion of data.
473
   *
474
   * @param[in] session Session object doing the processing
475
   * @param[in] table Table object being deleted from
476
   * @param[out] next_segment_id The next Statement segment id to be used
477
   */
478
  message::Statement &getDeleteStatement(Session::reference session,
479
                                         Table &table,
480
                                         uint32_t *next_segment_id);
481
  
482
  /**
483
   * Helper method which initializes the header message for
484
   * insert operations.
485
   *
486
   * @param[in,out] statement Statement message container to modify
487
   * @param[in] session Session object doing the processing
488
   * @param[in] table Table object being deleted from
489
   */
490
  void setDeleteHeader(message::Statement &statement,
491
                       Session::const_reference session,
492
                       Table &table);
493
494
  /** 
495
   * Commits a normal transaction (see above) and pushes the transaction
496
   * message out to the replicators.
497
   *
498
   * @param session Session object committing the transaction
499
   */
500
  int commitTransactionMessage(Session::reference session);
501
502
  /** 
503
   * Marks the current active transaction message as being rolled back and
504
   * pushes the transaction message out to replicators.
505
   *
506
   * @param session Session object committing the transaction
507
   */
508
  void rollbackTransactionMessage(Session::reference session);
509
510
  /**
511
   * Rolls back the current statement, deleting the last Statement out of
512
   * the current Transaction message.
513
   *
514
   * @param session Session object committing the transaction
515
   *
516
   * @note This depends on having clear statement boundaries (i.e., one
517
   * Statement message per actual SQL statement).
518
   */
519
  void rollbackStatementMessage(Session::reference session);
520
521
  /**
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
522
   * Checks if a field has been updated 
523
   *
524
   * @param current_field Pointer to the field to check if it is updated 
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
525
   * @param table Table object containing update information
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
526
   * @param old_record Pointer to the raw bytes representing the old record/row
527
   * @param new_record Pointer to the raw bytes representing the new record/row
528
   */
529
  bool isFieldUpdated(Field *current_field,
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
530
                      Table &table,
1.1.1 by Monty Taylor
Import upstream version 2010.09.1802
531
                      const unsigned char *old_record,
532
                      const unsigned char *new_record);
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
533
534
  /**
535
   * Create a Transaction that contains event information and send it off.
536
   *
537
   * This differs from other uses of Transaction in that we don't use the
538
   * message associated with Session. We create a totally new message and
539
   * use it.
540
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
541
   * @param session Session object
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
542
   * @param event Event message to send
543
   *
544
   * @note Used by the public Events API.
545
   *
546
   * @returns Non-zero on error
547
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
548
  int sendEvent(Session::reference session, const message::Event &event);
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
549
550
  /**
1.2.6 by Monty Taylor
Import upstream version 2011.01.08
551
   * Makes a given Transaction message segmented.
552
   *
553
   * The given Transaction message will have its segment information set
554
   * appropriately and a new Transaction message, containing the same
555
   * transaction ID as the supplied Transaction, and is created.
556
   *
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
557
   * @param session Session object
558
   * @param transaction Transaction message to segment.
1.2.6 by Monty Taylor
Import upstream version 2011.01.08
559
   *
560
   * @returns Returns a pointer to a new Transaction message ready for use.
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
561
   */
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
562
  message::Transaction *segmentTransactionMessage(Session::reference session,
1.2.6 by Monty Taylor
Import upstream version 2011.01.08
563
                                                  message::Transaction *transaction);
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
564
1.2.7 by Monty Taylor
Import upstream version 2011.02.09
565
  int commitPhaseOne(Session::reference session, bool all);
566
567
  uint64_t getCurrentTransactionId(Session::reference session);
568
1.2.1 by Monty Taylor
Import upstream version 2010.11.03
569
  plugin::XaStorageEngine *xa_storage_engine;
1 by Monty Taylor
Import upstream version 2010.03.1347
570
};
571
572
} /* namespace drizzled */
573