~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/statement_transform.h

Merge Stewart's dead code removal

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
4
 *  Copyright (C) 2009 Sun Microsystems
5
 
 *  Copyright (c) 2010 Jay Pipes <jayjpipes@gmail.com>
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
 
class TruncateTableStatement;
60
 
class CreateSchemaStatement;
61
 
class DropSchemaStatement;
62
53
class SetVariableStatement;
63
54
 
64
55
/** A Variation of SQL to be output during transformation */
95
86
enum TransformSqlError
96
87
transformStatementToSql(const Statement &source,
97
88
                        std::vector<std::string> &sql_strings,
98
 
                        enum TransformSqlVariant sql_variant= DRIZZLE,
99
 
                        bool already_in_transaction= false);
 
89
                        enum TransformSqlVariant sql_variant= DRIZZLE);
100
90
 
101
91
/**
102
92
 * This function looks at a supplied InsertHeader
123
113
enum TransformSqlError
124
114
transformInsertStatementToSql(const InsertHeader &header,
125
115
                              const InsertData &data,
126
 
                              std::string &destination,
 
116
                              std::string *destination,
127
117
                              enum TransformSqlVariant sql_variant= DRIZZLE);
128
118
 
129
119
/**
144
134
enum TransformSqlError
145
135
transformInsertRecordToSql(const InsertHeader &header,
146
136
                           const InsertRecord &record,
147
 
                           std::string &destination,
 
137
                           std::string *destination,
148
138
                           enum TransformSqlVariant sql_variant= DRIZZLE);
149
139
 
150
140
/**
162
152
 */
163
153
enum TransformSqlError
164
154
transformInsertHeaderToSql(const InsertHeader &header,
165
 
                           std::string &destination,
 
155
                           std::string *destination,
166
156
                           enum TransformSqlVariant sql_variant= DRIZZLE);
 
157
/**
 
158
 * This function looks at a supplied UpdateHeader
 
159
 * and UpdateData message and constructs a correctly-formatted SQL
 
160
 * statement to the supplied destination string.
 
161
 *
 
162
 * @note
 
163
 *
 
164
 * This function constructs a <strong>single SQL statement</strong>
 
165
 * that contains all the update keys represented in all records in 
 
166
 * the UpdateData message.
 
167
 *
 
168
 * @param UpdateHeader message to transform
 
169
 * @param UpdateData message to transform
 
170
 * @param Destination string to append SQL to
 
171
 * @param Variation of SQL to generate
 
172
 *
 
173
 * @retval
 
174
 *  NONE if successful transformation
 
175
 * @retval
 
176
 *  Error code (see enum TransformSqlError definition) if failure
 
177
 */
 
178
enum TransformSqlError
 
179
transformUpdateStatementToSql(const UpdateHeader &header,
 
180
                              const UpdateData &data,
 
181
                              std::string *destination,
 
182
                              enum TransformSqlVariant sql_variant= DRIZZLE);
167
183
 
168
184
/**
169
185
 * Helper function to construct the header portion of an UPDATE
180
196
 */
181
197
enum TransformSqlError
182
198
transformUpdateHeaderToSql(const UpdateHeader &header,
183
 
                           std::string &destination,
 
199
                           std::string *destination,
184
200
                           enum TransformSqlVariant sql_variant= DRIZZLE);
185
201
 
186
202
/**
201
217
enum TransformSqlError
202
218
transformUpdateRecordToSql(const UpdateHeader &header,
203
219
                           const UpdateRecord &record,
204
 
                           std::string &destination,
 
220
                           std::string *destination,
205
221
                           enum TransformSqlVariant sql_variant= DRIZZLE);
206
222
 
207
223
/**
227
243
enum TransformSqlError
228
244
transformDeleteStatementToSql(const DeleteHeader &header,
229
245
                              const DeleteData &data,
230
 
                              std::string &destination,
 
246
                              std::string *destination,
231
247
                              enum TransformSqlVariant sql_variant= DRIZZLE);
232
248
 
233
249
/**
248
264
enum TransformSqlError
249
265
transformDeleteRecordToSql(const DeleteHeader &header,
250
266
                           const DeleteRecord &record,
251
 
                           std::string &destination,
 
267
                           std::string *destination,
252
268
                           enum TransformSqlVariant sql_variant= DRIZZLE);
253
269
 
254
270
/**
266
282
 */
267
283
enum TransformSqlError
268
284
transformDeleteHeaderToSql(const DeleteHeader &header,
269
 
                           std::string &destination,
 
285
                           std::string *destination,
270
286
                           enum TransformSqlVariant sql_variant= DRIZZLE);
271
287
 
272
288
/**
273
 
 * This function looks at a supplied DropTableStatement
274
 
 * and constructs a correctly-formatted SQL
275
 
 * statement to the supplied destination string.
276
 
 *
277
 
 * @param DropTableStatement message to transform
278
 
 * @param Destination string to append SQL to
279
 
 * @param Variation of SQL to generate
280
 
 *
281
 
 * @retval
282
 
 *  NONE if successful transformation
283
 
 * @retval
284
 
 *  Error code (see enum TransformSqlError definition) if failure
285
 
 */
286
 
enum TransformSqlError
287
 
transformDropTableStatementToSql(const DropTableStatement &statement,
288
 
                                  std::string &destination,
289
 
                                  enum TransformSqlVariant sql_variant= DRIZZLE);
290
 
 
291
 
/**
292
 
 * This function looks at a supplied TruncateTableStatement
293
 
 * and constructs a correctly-formatted SQL
294
 
 * statement to the supplied destination string.
295
 
 *
296
 
 * @param TruncateTableStatement message to transform
297
 
 * @param Destination string to append SQL to
298
 
 * @param Variation of SQL to generate
299
 
 *
300
 
 * @retval
301
 
 *  NONE if successful transformation
302
 
 * @retval
303
 
 *  Error code (see enum TransformSqlError definition) if failure
304
 
 */
305
 
enum TransformSqlError
306
 
transformTruncateTableStatementToSql(const TruncateTableStatement &statement,
307
 
                                     std::string &destination,
308
 
                                     enum TransformSqlVariant sql_variant= DRIZZLE);
309
 
 
310
 
/**
311
 
 * This function looks at a supplied CreateSchemaStatement
312
 
 * and constructs a correctly-formatted SQL
313
 
 * statement to the supplied destination string.
314
 
 *
315
 
 * @param CreateSchemaStatement message to transform
316
 
 * @param Destination string to append SQL to
317
 
 * @param Variation of SQL to generate
318
 
 *
319
 
 * @retval
320
 
 *  NONE if successful transformation
321
 
 * @retval
322
 
 *  Error code (see enum TransformSqlError definition) if failure
323
 
 */
324
 
enum TransformSqlError
325
 
transformCreateSchemaStatementToSql(const CreateSchemaStatement &statement,
326
 
                                    std::string &destination,
327
 
                                    enum TransformSqlVariant sql_variant= DRIZZLE);
328
 
 
329
 
/**
330
 
 * This function looks at a supplied DropSchemaStatement
331
 
 * and constructs a correctly-formatted SQL
332
 
 * statement to the supplied destination string.
333
 
 *
334
 
 * @param DropSchemaStatement message to transform
335
 
 * @param Destination string to append SQL to
336
 
 * @param Variation of SQL to generate
337
 
 *
338
 
 * @retval
339
 
 *  NONE if successful transformation
340
 
 * @retval
341
 
 *  Error code (see enum TransformSqlError definition) if failure
342
 
 */
343
 
enum TransformSqlError
344
 
transformDropSchemaStatementToSql(const DropSchemaStatement &statement,
345
 
                                  std::string &destination,
346
 
                                  enum TransformSqlVariant sql_variant= DRIZZLE);
347
 
 
348
 
/**
349
289
 * This function looks at a supplied SetVariableStatement
350
290
 * and constructs a correctly-formatted SQL
351
291
 * statement to the supplied destination string.
361
301
 */
362
302
enum TransformSqlError
363
303
transformSetVariableStatementToSql(const SetVariableStatement &statement,
364
 
                                   std::string &destination,
365
 
                                   enum TransformSqlVariant sql_variant= DRIZZLE);
366
 
 
367
 
/**
368
 
 * Appends to supplied string an SQL expression
369
 
 * containing the supplied CreateTableStatement's
370
 
 * appropriate CREATE TABLE SQL statement.
371
 
 */
372
 
enum TransformSqlError
373
 
transformCreateTableStatementToSql(const CreateTableStatement &statement,
374
 
                                   std::string &destination,
375
 
                                   enum TransformSqlVariant sql_variant= DRIZZLE);
376
 
 
377
 
/**
378
 
 * Appends to the supplied string an SQL expression
379
 
 * representing the table for a CREATE TABLE expression.
380
 
 *
381
 
 * @param[in]   Table message
382
 
 * @param[out]  String to append to
383
 
 *
384
 
 * @retval
385
 
 *  NONE if successful transformation
386
 
 * @retval
387
 
 *  Error code (see enum TransformSqlError definition) if failure
388
 
 */
389
 
enum TransformSqlError
390
 
transformTableDefinitionToSql(const Table &table,
391
 
                              std::string &destination,
392
 
                              enum TransformSqlVariant sql_variant= DRIZZLE,
393
 
                              bool with_schema= false);
394
 
 
395
 
/**
396
 
 * Appends to the supplied string an SQL expression
397
 
 * representing the table's optional attributes.
398
 
 *
399
 
 * @note
400
 
 *
401
 
 * This function will eventually be a much simpler
402
 
 * listing of key/value pairs.
403
 
 *
404
 
 * @param[in]   TableOptions message
405
 
 * @param[out]  String to append to
406
 
 *
407
 
 * @retval
408
 
 *  NONE if successful transformation
409
 
 * @retval
410
 
 *  Error code (see enum TransformSqlError definition) if failure
411
 
 */
412
 
enum TransformSqlError
413
 
transformTableOptionsToSql(const Table::TableOptions &table_options,
414
 
                           std::string &destination,
415
 
                           enum TransformSqlVariant sql_variant= DRIZZLE);
416
 
 
417
 
/**
418
 
 * Appends to the supplied string an SQL expression
419
 
 * representing the index's attributes.  The built string
420
 
 * corresponds to the SQL in a CREATE INDEX statement.
421
 
 *
422
 
 * @param[in]   Index message
423
 
 * @param[in]   Table containing this index (used to get field names...)
424
 
 * @param[out]  String to append to
425
 
 *
426
 
 * @retval
427
 
 *  NONE if successful transformation
428
 
 * @retval
429
 
 *  Error code (see enum TransformSqlError definition) if failure
430
 
 */
431
 
enum TransformSqlError
432
 
transformIndexDefinitionToSql(const Table::Index &index,
433
 
                              const Table &table,
434
 
                              std::string &destination,
435
 
                              enum TransformSqlVariant sql_variant= DRIZZLE);
436
 
 
437
 
/**
438
 
 * Appends to the supplied string an SQL expression
439
 
 * representing the field's attributes.  The built string
440
 
 * corresponds to the SQL in a CREATE TABLE statement.
441
 
 *
442
 
 * @param[in]   Field message
443
 
 * @param[out]  String to append to
444
 
 *
445
 
 * @retval
446
 
 *  NONE if successful transformation
447
 
 * @retval
448
 
 *  Error code (see enum TransformSqlError definition) if failure
449
 
 */
450
 
enum TransformSqlError
451
 
transformFieldDefinitionToSql(const Table::Field &field,
452
 
                              std::string &destination,
453
 
                              enum TransformSqlVariant sql_variant= DRIZZLE);
 
304
                                   std::string *destination,
 
305
                                   enum TransformSqlVariant sql_variant= DRIZZLE);
 
306
 
454
307
 
455
308
/**
456
309
 * Returns true if the supplied message::Table::Field::FieldType
460
313
 */
461
314
bool shouldQuoteFieldValue(Table::Field::FieldType in_type);
462
315
 
463
 
drizzled::message::Table::Field::FieldType internalFieldTypeToFieldProtoType(enum enum_field_types type);
464
 
 
465
 
/**
466
 
 * Returns true if the transaction contains any Statement
467
 
 * messages which are not end segments (i.e. a bulk statement has
468
 
 * previously been sent to replicators).
469
 
 *
470
 
 * @param The transaction to check
471
 
 */
472
 
bool transactionContainsBulkSegment(const Transaction &transaction);
473
 
 
474
 
} /* namespace message */
475
 
} /* namespace drizzled */
 
316
} /* end namespace drizzled::message */
 
317
} /* end namespace drizzled */
476
318
 
477
319
#endif /* DRIZZLED_MESSAGE_STATEMENT_TRANSFORM_H */