~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/statement_transform.h

This patch completes the first step in the splitting of
the XA resource manager API from the storage engine API,
as outlined in the specification here:

http://drizzle.org/wiki/XaStorageEngine

* Splits plugin::StorageEngine into a base StorageEngine
  class and two derived classes, TransactionalStorageEngine
  and XaStorageEngine.  XaStorageEngine derives from
  TransactionalStorageEngine and creates the XA Resource
  Manager API for storage engines.

  - The methods moved from StorageEngine to TransactionalStorageEngine
    include releaseTemporaryLatches(), startConsistentSnapshot(), 
    commit(), rollback(), setSavepoint(), releaseSavepoint(),
    rollbackToSavepoint() and hasTwoPhaseCommit()
  - The methods moved from StorageEngine to XaStorageEngine
    include recover(), commitXid(), rollbackXid(), and prepare()

* Places all static "EngineVector"s into their proper
  namespaces (typedefs belong in header files, not implementation files)
  and places all static methods corresponding
  to either only transactional engines or only XA engines
  into their respective files in /drizzled/plugin/

* Modifies the InnoDB "handler" files to extend plugin::XaStorageEngine
  and not plugin::StorageEngine

The next step, as outlined in the wiki spec page above, is to isolate
the XA Resource Manager API into its own plugin class and modify
plugin::XaStorageEngine to implement plugin::XaResourceManager via
composition.  This is necessary to enable building plugins which can
participate in an XA transaction *without having to have that plugin
implement the entire storage engine API*

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems, Inc.
5
 
 *  Copyright (C) 2010 Jay Pipes <jaypipes@gmail.com>
 
4
 *  Copyright (C) 2009 Sun Microsystems
6
5
 *
7
6
 *  Authors:
8
7
 *
9
 
 *    Jay Pipes <jaypipes@gmail.com>
 
8
 *    Jay Pipes <joinfu@sun.com>
10
9
 *
11
10
 *  This program is free software; you can redistribute it and/or modify
12
11
 *  it under the terms of the GNU General Public License as published by
36
35
#include <string>
37
36
#include <vector>
38
37
 
39
 
#include <drizzled/common.h>
40
 
 
41
38
namespace drizzled
42
39
{
43
40
namespace message
44
41
{
45
42
/* some forward declarations */
46
 
class Transaction;
47
43
class Statement;
48
44
class InsertHeader;
49
45
class InsertData;
54
50
class DeleteHeader;
55
51
class DeleteData;
56
52
class DeleteRecord;
57
 
class DropTableStatement;
58
 
class CreateTableStatement;
59
53
class TruncateTableStatement;
60
 
class CreateSchemaStatement;
61
 
class DropSchemaStatement;
62
 
class AlterSchemaStatement;
63
54
class SetVariableStatement;
64
55
 
65
56
/** A Variation of SQL to be output during transformation */
76
67
{
77
68
  NONE= 0,
78
69
  MISSING_HEADER= 1, /* A data segment without a header segment was found */
79
 
  MISSING_DATA= 2,   /* A header segment without a data segment was found */
80
 
  UUID_MISMATCH= 3
 
70
  MISSING_DATA= 2 /* A header segment without a data segment was found */
81
71
};
82
72
 
83
73
/**
125
115
enum TransformSqlError
126
116
transformInsertStatementToSql(const InsertHeader &header,
127
117
                              const InsertData &data,
128
 
                              std::string &destination,
 
118
                              std::string *destination,
129
119
                              enum TransformSqlVariant sql_variant= DRIZZLE);
130
120
 
131
121
/**
146
136
enum TransformSqlError
147
137
transformInsertRecordToSql(const InsertHeader &header,
148
138
                           const InsertRecord &record,
149
 
                           std::string &destination,
 
139
                           std::string *destination,
150
140
                           enum TransformSqlVariant sql_variant= DRIZZLE);
151
141
 
152
142
/**
164
154
 */
165
155
enum TransformSqlError
166
156
transformInsertHeaderToSql(const InsertHeader &header,
167
 
                           std::string &destination,
 
157
                           std::string *destination,
168
158
                           enum TransformSqlVariant sql_variant= DRIZZLE);
169
159
 
170
160
/**
182
172
 */
183
173
enum TransformSqlError
184
174
transformUpdateHeaderToSql(const UpdateHeader &header,
185
 
                           std::string &destination,
 
175
                           std::string *destination,
186
176
                           enum TransformSqlVariant sql_variant= DRIZZLE);
187
177
 
188
178
/**
203
193
enum TransformSqlError
204
194
transformUpdateRecordToSql(const UpdateHeader &header,
205
195
                           const UpdateRecord &record,
206
 
                           std::string &destination,
 
196
                           std::string *destination,
207
197
                           enum TransformSqlVariant sql_variant= DRIZZLE);
208
198
 
209
199
/**
229
219
enum TransformSqlError
230
220
transformDeleteStatementToSql(const DeleteHeader &header,
231
221
                              const DeleteData &data,
232
 
                              std::string &destination,
 
222
                              std::string *destination,
233
223
                              enum TransformSqlVariant sql_variant= DRIZZLE);
234
224
 
235
225
/**
250
240
enum TransformSqlError
251
241
transformDeleteRecordToSql(const DeleteHeader &header,
252
242
                           const DeleteRecord &record,
253
 
                           std::string &destination,
 
243
                           std::string *destination,
254
244
                           enum TransformSqlVariant sql_variant= DRIZZLE);
255
245
 
256
246
/**
268
258
 */
269
259
enum TransformSqlError
270
260
transformDeleteHeaderToSql(const DeleteHeader &header,
271
 
                           std::string &destination,
 
261
                           std::string *destination,
272
262
                           enum TransformSqlVariant sql_variant= DRIZZLE);
273
263
 
274
264
/**
275
 
 * This function looks at a supplied DropTableStatement
276
 
 * and constructs a correctly-formatted SQL
277
 
 * statement to the supplied destination string.
278
 
 *
279
 
 * @param DropTableStatement message to transform
280
 
 * @param Destination string to append SQL to
281
 
 * @param Variation of SQL to generate
282
 
 *
283
 
 * @retval
284
 
 *  NONE if successful transformation
285
 
 * @retval
286
 
 *  Error code (see enum TransformSqlError definition) if failure
287
 
 */
288
 
enum TransformSqlError
289
 
transformDropTableStatementToSql(const DropTableStatement &statement,
290
 
                                  std::string &destination,
291
 
                                  enum TransformSqlVariant sql_variant= DRIZZLE);
292
 
 
293
 
/**
294
265
 * This function looks at a supplied TruncateTableStatement
295
266
 * and constructs a correctly-formatted SQL
296
267
 * statement to the supplied destination string.
306
277
 */
307
278
enum TransformSqlError
308
279
transformTruncateTableStatementToSql(const TruncateTableStatement &statement,
309
 
                                     std::string &destination,
 
280
                                     std::string *destination,
310
281
                                     enum TransformSqlVariant sql_variant= DRIZZLE);
311
282
 
312
283
/**
313
 
 * This function looks at a supplied CreateSchemaStatement
314
 
 * and constructs a correctly-formatted SQL
315
 
 * statement to the supplied destination string.
316
 
 *
317
 
 * @param CreateSchemaStatement message to transform
318
 
 * @param Destination string to append SQL to
319
 
 * @param Variation of SQL to generate
320
 
 *
321
 
 * @retval
322
 
 *  NONE if successful transformation
323
 
 * @retval
324
 
 *  Error code (see enum TransformSqlError definition) if failure
325
 
 */
326
 
enum TransformSqlError
327
 
transformCreateSchemaStatementToSql(const CreateSchemaStatement &statement,
328
 
                                    std::string &destination,
329
 
                                    enum TransformSqlVariant sql_variant= DRIZZLE);
330
 
 
331
 
/**
332
 
 * This function looks at a supplied DropSchemaStatement
333
 
 * and constructs a correctly-formatted SQL
334
 
 * statement to the supplied destination string.
335
 
 *
336
 
 * @param DropSchemaStatement message to transform
337
 
 * @param Destination string to append SQL to
338
 
 * @param Variation of SQL to generate
339
 
 *
340
 
 * @retval
341
 
 *  NONE if successful transformation
342
 
 * @retval
343
 
 *  Error code (see enum TransformSqlError definition) if failure
344
 
 */
345
 
enum TransformSqlError
346
 
transformDropSchemaStatementToSql(const DropSchemaStatement &statement,
347
 
                                  std::string &destination,
348
 
                                  enum TransformSqlVariant sql_variant= DRIZZLE);
349
 
 
350
 
/**
351
 
 * This function looks at a supplied AlterSchemaStatement
352
 
 * and constructs a correctly-formatted SQL
353
 
 * statement to the supplied destination string.
354
 
 *
355
 
 * @param AlterSchemaStatement message to transform
356
 
 * @param Destination string to append SQL to
357
 
 * @param Variation of SQL to generate
358
 
 *
359
 
 * @retval
360
 
 *  NONE if successful transformation
361
 
 * @retval
362
 
 *  Error code (see enum TransformSqlError definition) if failure
363
 
 */
364
 
enum TransformSqlError
365
 
transformAlterSchemaStatementToSql(const AlterSchemaStatement &statement,
366
 
                                   std::string &destination,
367
 
                                   enum TransformSqlVariant sql_variant= DRIZZLE);
368
 
 
369
 
/**
370
284
 * This function looks at a supplied SetVariableStatement
371
285
 * and constructs a correctly-formatted SQL
372
286
 * statement to the supplied destination string.
382
296
 */
383
297
enum TransformSqlError
384
298
transformSetVariableStatementToSql(const SetVariableStatement &statement,
385
 
                                   std::string &destination,
386
 
                                   enum TransformSqlVariant sql_variant= DRIZZLE);
387
 
 
388
 
/**
389
 
 * Appends to supplied string an SQL expression
390
 
 * containing the supplied CreateTableStatement's
391
 
 * appropriate CREATE TABLE SQL statement.
392
 
 */
393
 
enum TransformSqlError
394
 
transformCreateTableStatementToSql(const CreateTableStatement &statement,
395
 
                                   std::string &destination,
396
 
                                   enum TransformSqlVariant sql_variant= DRIZZLE);
397
 
 
398
 
/**
399
 
 * Appends to the supplied string an SQL expression
400
 
 * representing the table for a CREATE TABLE expression.
401
 
 *
402
 
 * @param[in]   Table message
403
 
 * @param[out]  String to append to
404
 
 *
405
 
 * @retval
406
 
 *  NONE if successful transformation
407
 
 * @retval
408
 
 *  Error code (see enum TransformSqlError definition) if failure
409
 
 */
410
 
enum TransformSqlError
411
 
transformTableDefinitionToSql(const Table &table,
412
 
                              std::string &destination,
413
 
                              enum TransformSqlVariant sql_variant= DRIZZLE,
414
 
                              bool with_schema= true);
415
 
 
416
 
/**
417
 
 * Appends to the supplied string an SQL expression
418
 
 * representing the table's optional attributes.
419
 
 *
420
 
 * @note
421
 
 *
422
 
 * This function will eventually be a much simpler
423
 
 * listing of key/value pairs.
424
 
 *
425
 
 * @param[in]   TableOptions message
426
 
 * @param[out]  String to append to
427
 
 *
428
 
 * @retval
429
 
 *  NONE if successful transformation
430
 
 * @retval
431
 
 *  Error code (see enum TransformSqlError definition) if failure
432
 
 */
433
 
enum TransformSqlError
434
 
transformTableOptionsToSql(const Table::TableOptions &table_options,
435
 
                           std::string &destination,
436
 
                           enum TransformSqlVariant sql_variant= DRIZZLE);
437
 
 
438
 
/**
439
 
 * Appends to the supplied string an SQL expression
440
 
 * representing the index's attributes.  The built string
441
 
 * corresponds to the SQL in a CREATE INDEX statement.
442
 
 *
443
 
 * @param[in]   Index message
444
 
 * @param[in]   Table containing this index (used to get field names...)
445
 
 * @param[out]  String to append to
446
 
 *
447
 
 * @retval
448
 
 *  NONE if successful transformation
449
 
 * @retval
450
 
 *  Error code (see enum TransformSqlError definition) if failure
451
 
 */
452
 
enum TransformSqlError
453
 
transformIndexDefinitionToSql(const Table::Index &index,
454
 
                              const Table &table,
455
 
                              std::string &destination,
456
 
                              enum TransformSqlVariant sql_variant= DRIZZLE);
457
 
 
458
 
/**
459
 
 * Appends to the supplied string an SQL expression
460
 
 * representing the foreign key attributes.  The built string
461
 
 * corresponds to the SQL in a CREATE TABLE statement.
462
 
 *
463
 
 * @param[in]   Foreign Key Constraint message
464
 
 * @param[in]   Table containing this foregin key (used to get field names...)
465
 
 * @param[out]  String to append to
466
 
 *
467
 
 * @retval
468
 
 *  NONE if successful transformation
469
 
 * @retval
470
 
 *  Error code (see enum TransformSqlError definition) if failure
471
 
 */
472
 
enum TransformSqlError
473
 
transformForeignKeyConstraintDefinitionToSql(const Table::ForeignKeyConstraint &fkey,
474
 
                                             const Table &table,
475
 
                                             std::string &destination,
476
 
                                             enum TransformSqlVariant sql_variant = DRIZZLE);
477
 
 
478
 
/**
479
 
 * Appends to the supplied string an SQL expression
480
 
 * representing the field's attributes.  The built string
481
 
 * corresponds to the SQL in a CREATE TABLE statement.
482
 
 *
483
 
 * @param[in]   Field message
484
 
 * @param[out]  String to append to
485
 
 *
486
 
 * @retval
487
 
 *  NONE if successful transformation
488
 
 * @retval
489
 
 *  Error code (see enum TransformSqlError definition) if failure
490
 
 */
491
 
enum TransformSqlError
492
 
transformFieldDefinitionToSql(const Table::Field &field,
493
 
                              std::string &destination,
494
 
                              enum TransformSqlVariant sql_variant= DRIZZLE);
 
299
                                   std::string *destination,
 
300
                                   enum TransformSqlVariant sql_variant= DRIZZLE);
 
301
 
495
302
 
496
303
/**
497
304
 * Returns true if the supplied message::Table::Field::FieldType
501
308
 */
502
309
bool shouldQuoteFieldValue(Table::Field::FieldType in_type);
503
310
 
504
 
drizzled::message::Table::Field::FieldType internalFieldTypeToFieldProtoType(enum enum_field_types type);
505
 
 
506
 
/**
507
 
 * Returns true if the transaction contains any Statement
508
 
 * messages which are not end segments (i.e. a bulk statement has
509
 
 * previously been sent to replicators).
510
 
 *
511
 
 * @param The transaction to check
512
 
 */
513
 
bool transactionContainsBulkSegment(const Transaction &transaction);
514
 
 
515
311
} /* namespace message */
516
312
} /* namespace drizzled */
517
313