~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/statement_transform.h

Merge trunk

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>
5
6
 *
6
7
 *  Authors:
7
8
 *
8
 
 *    Jay Pipes <joinfu@sun.com>
 
9
 *    Jay Pipes <jaypipes@gmail.com>
9
10
 *
10
11
 *  This program is free software; you can redistribute it and/or modify
11
12
 *  it under the terms of the GNU General Public License as published by
52
53
class DeleteHeader;
53
54
class DeleteData;
54
55
class DeleteRecord;
 
56
class DropTableStatement;
 
57
class CreateTableStatement;
55
58
class TruncateTableStatement;
 
59
class CreateSchemaStatement;
 
60
class DropSchemaStatement;
56
61
class SetVariableStatement;
57
62
 
58
63
/** A Variation of SQL to be output during transformation */
117
122
enum TransformSqlError
118
123
transformInsertStatementToSql(const InsertHeader &header,
119
124
                              const InsertData &data,
120
 
                              std::string *destination,
 
125
                              std::string &destination,
121
126
                              enum TransformSqlVariant sql_variant= DRIZZLE);
122
127
 
123
128
/**
138
143
enum TransformSqlError
139
144
transformInsertRecordToSql(const InsertHeader &header,
140
145
                           const InsertRecord &record,
141
 
                           std::string *destination,
 
146
                           std::string &destination,
142
147
                           enum TransformSqlVariant sql_variant= DRIZZLE);
143
148
 
144
149
/**
156
161
 */
157
162
enum TransformSqlError
158
163
transformInsertHeaderToSql(const InsertHeader &header,
159
 
                           std::string *destination,
 
164
                           std::string &destination,
160
165
                           enum TransformSqlVariant sql_variant= DRIZZLE);
161
166
 
162
167
/**
174
179
 */
175
180
enum TransformSqlError
176
181
transformUpdateHeaderToSql(const UpdateHeader &header,
177
 
                           std::string *destination,
 
182
                           std::string &destination,
178
183
                           enum TransformSqlVariant sql_variant= DRIZZLE);
179
184
 
180
185
/**
195
200
enum TransformSqlError
196
201
transformUpdateRecordToSql(const UpdateHeader &header,
197
202
                           const UpdateRecord &record,
198
 
                           std::string *destination,
 
203
                           std::string &destination,
199
204
                           enum TransformSqlVariant sql_variant= DRIZZLE);
200
205
 
201
206
/**
221
226
enum TransformSqlError
222
227
transformDeleteStatementToSql(const DeleteHeader &header,
223
228
                              const DeleteData &data,
224
 
                              std::string *destination,
 
229
                              std::string &destination,
225
230
                              enum TransformSqlVariant sql_variant= DRIZZLE);
226
231
 
227
232
/**
242
247
enum TransformSqlError
243
248
transformDeleteRecordToSql(const DeleteHeader &header,
244
249
                           const DeleteRecord &record,
245
 
                           std::string *destination,
 
250
                           std::string &destination,
246
251
                           enum TransformSqlVariant sql_variant= DRIZZLE);
247
252
 
248
253
/**
260
265
 */
261
266
enum TransformSqlError
262
267
transformDeleteHeaderToSql(const DeleteHeader &header,
263
 
                           std::string *destination,
 
268
                           std::string &destination,
264
269
                           enum TransformSqlVariant sql_variant= DRIZZLE);
265
270
 
266
271
/**
 
272
 * This function looks at a supplied DropTableStatement
 
273
 * and constructs a correctly-formatted SQL
 
274
 * statement to the supplied destination string.
 
275
 *
 
276
 * @param DropTableStatement message to transform
 
277
 * @param Destination string to append SQL to
 
278
 * @param Variation of SQL to generate
 
279
 *
 
280
 * @retval
 
281
 *  NONE if successful transformation
 
282
 * @retval
 
283
 *  Error code (see enum TransformSqlError definition) if failure
 
284
 */
 
285
enum TransformSqlError
 
286
transformDropTableStatementToSql(const DropTableStatement &statement,
 
287
                                  std::string &destination,
 
288
                                  enum TransformSqlVariant sql_variant= DRIZZLE);
 
289
 
 
290
/**
267
291
 * This function looks at a supplied TruncateTableStatement
268
292
 * and constructs a correctly-formatted SQL
269
293
 * statement to the supplied destination string.
279
303
 */
280
304
enum TransformSqlError
281
305
transformTruncateTableStatementToSql(const TruncateTableStatement &statement,
282
 
                                     std::string *destination,
 
306
                                     std::string &destination,
283
307
                                     enum TransformSqlVariant sql_variant= DRIZZLE);
284
308
 
285
309
/**
 
310
 * This function looks at a supplied CreateSchemaStatement
 
311
 * and constructs a correctly-formatted SQL
 
312
 * statement to the supplied destination string.
 
313
 *
 
314
 * @param CreateSchemaStatement message to transform
 
315
 * @param Destination string to append SQL to
 
316
 * @param Variation of SQL to generate
 
317
 *
 
318
 * @retval
 
319
 *  NONE if successful transformation
 
320
 * @retval
 
321
 *  Error code (see enum TransformSqlError definition) if failure
 
322
 */
 
323
enum TransformSqlError
 
324
transformCreateSchemaStatementToSql(const CreateSchemaStatement &statement,
 
325
                                    std::string &destination,
 
326
                                    enum TransformSqlVariant sql_variant= DRIZZLE);
 
327
 
 
328
/**
 
329
 * This function looks at a supplied DropSchemaStatement
 
330
 * and constructs a correctly-formatted SQL
 
331
 * statement to the supplied destination string.
 
332
 *
 
333
 * @param DropSchemaStatement message to transform
 
334
 * @param Destination string to append SQL to
 
335
 * @param Variation of SQL to generate
 
336
 *
 
337
 * @retval
 
338
 *  NONE if successful transformation
 
339
 * @retval
 
340
 *  Error code (see enum TransformSqlError definition) if failure
 
341
 */
 
342
enum TransformSqlError
 
343
transformDropSchemaStatementToSql(const DropSchemaStatement &statement,
 
344
                                  std::string &destination,
 
345
                                  enum TransformSqlVariant sql_variant= DRIZZLE);
 
346
 
 
347
/**
286
348
 * This function looks at a supplied SetVariableStatement
287
349
 * and constructs a correctly-formatted SQL
288
350
 * statement to the supplied destination string.
298
360
 */
299
361
enum TransformSqlError
300
362
transformSetVariableStatementToSql(const SetVariableStatement &statement,
301
 
                                   std::string *destination,
302
 
                                   enum TransformSqlVariant sql_variant= DRIZZLE);
303
 
 
 
363
                                   std::string &destination,
 
364
                                   enum TransformSqlVariant sql_variant= DRIZZLE);
 
365
 
 
366
/**
 
367
 * Appends to supplied string an SQL expression
 
368
 * containing the supplied CreateTableStatement's
 
369
 * appropriate CREATE TABLE SQL statement.
 
370
 */
 
371
enum TransformSqlError
 
372
transformCreateTableStatementToSql(const CreateTableStatement &statement,
 
373
                                   std::string &destination,
 
374
                                   enum TransformSqlVariant sql_variant= DRIZZLE);
 
375
 
 
376
/**
 
377
 * Appends to the supplied string an SQL expression
 
378
 * representing the table for a CREATE TABLE expression.
 
379
 *
 
380
 * @param[in]   Table message
 
381
 * @param[out]  String to append to
 
382
 *
 
383
 * @retval
 
384
 *  NONE if successful transformation
 
385
 * @retval
 
386
 *  Error code (see enum TransformSqlError definition) if failure
 
387
 */
 
388
enum TransformSqlError
 
389
transformTableDefinitionToSql(const Table &table,
 
390
                              std::string &destination,
 
391
                              enum TransformSqlVariant sql_variant= DRIZZLE);
 
392
 
 
393
/**
 
394
 * Appends to the supplied string an SQL expression
 
395
 * representing the table's optional attributes.
 
396
 *
 
397
 * @note
 
398
 *
 
399
 * This function will eventually be a much simpler
 
400
 * listing of key/value pairs.
 
401
 *
 
402
 * @param[in]   TableOptions 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
transformTableOptionsToSql(const Table::TableOptions &table_options,
 
412
                           std::string &destination,
 
413
                           enum TransformSqlVariant sql_variant= DRIZZLE);
 
414
 
 
415
/**
 
416
 * Appends to the supplied string an SQL expression
 
417
 * representing the index's attributes.  The built string
 
418
 * corresponds to the SQL in a CREATE INDEX statement.
 
419
 *
 
420
 * @param[in]   Index message
 
421
 * @param[in]   Table containing this index (used to get field names...)
 
422
 * @param[out]  String to append to
 
423
 *
 
424
 * @retval
 
425
 *  NONE if successful transformation
 
426
 * @retval
 
427
 *  Error code (see enum TransformSqlError definition) if failure
 
428
 */
 
429
enum TransformSqlError
 
430
transformIndexDefinitionToSql(const Table::Index &index,
 
431
                              const Table &table,
 
432
                              std::string &destination,
 
433
                              enum TransformSqlVariant sql_variant= DRIZZLE);
 
434
 
 
435
/**
 
436
 * Appends to the supplied string an SQL expression
 
437
 * representing the field's attributes.  The built string
 
438
 * corresponds to the SQL in a CREATE TABLE statement.
 
439
 *
 
440
 * @param[in]   Field message
 
441
 * @param[out]  String to append to
 
442
 *
 
443
 * @retval
 
444
 *  NONE if successful transformation
 
445
 * @retval
 
446
 *  Error code (see enum TransformSqlError definition) if failure
 
447
 */
 
448
enum TransformSqlError
 
449
transformFieldDefinitionToSql(const Table::Field &field,
 
450
                              std::string &destination,
 
451
                              enum TransformSqlVariant sql_variant= DRIZZLE);
304
452
 
305
453
/**
306
454
 * Returns true if the supplied message::Table::Field::FieldType