~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/statement_transform.cc

  • Committer: Lee Bieber
  • Date: 2011-03-29 22:31:41 UTC
  • mfrom: (2257.1.3 build)
  • Revision ID: kalebral@gmail.com-20110329223141-yxc22h3l2he58sk0
Merge Andrew - 743842: Build failure using GCC 4.6
Merge Stewart - 738022: CachedDirectory silently fails to add entries if stat() fails
Merge Olaf - Common fwd: add copyright, add more declaration

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 * Statement messages to other formats, including SQL strings.
30
30
 */
31
31
 
32
 
#include "config.h"
 
32
#include <config.h>
33
33
 
34
34
#include <boost/lexical_cast.hpp>
35
 
#include "drizzled/message/statement_transform.h"
36
 
#include "drizzled/message/transaction.pb.h"
37
 
#include "drizzled/message/table.pb.h"
38
 
#include "drizzled/charset.h"
39
 
#include "drizzled/charset_info.h"
40
 
#include "drizzled/global_charset_info.h"
 
35
 
 
36
#include <drizzled/charset.h>
 
37
#include <drizzled/charset_info.h>
 
38
#include <drizzled/global_charset_info.h>
 
39
#include <drizzled/message.h>
 
40
#include <drizzled/message/statement_transform.h>
 
41
#include <drizzled/message/transaction.pb.h>
41
42
 
42
43
#include <string>
43
44
#include <vector>
152
153
      const InsertHeader &insert_header= source.insert_header();
153
154
      const InsertData &insert_data= source.insert_data();
154
155
      size_t num_keys= insert_data.record_size();
155
 
      size_t x;
156
156
 
157
157
      if (num_keys > 1 && ! already_in_transaction)
158
158
        sql_strings.push_back("START TRANSACTION");
159
159
 
160
 
      for (x= 0; x < num_keys; ++x)
 
160
      for (size_t x= 0; x < num_keys; ++x)
161
161
      {
162
162
        string destination;
163
163
 
339
339
    }
340
340
    break;
341
341
  case Statement::RAW_SQL:
 
342
    {
 
343
      if (source.has_raw_sql_schema())
 
344
      {
 
345
        string destination("USE ");
 
346
        destination.append(source.raw_sql_schema());
 
347
        sql_strings.push_back(destination);
 
348
      }
 
349
      sql_strings.push_back(source.sql());
 
350
    }
 
351
    break;
342
352
  default:
343
353
    sql_strings.push_back(source.sql());
344
354
    break;
393
403
                                                           destination,
394
404
                                                           sql_variant);
395
405
 
396
 
  char quoted_identifier= '`';
397
 
  if (sql_variant == ANSI)
398
 
    quoted_identifier= '"';
399
 
 
400
406
  destination.append(") VALUES (");
401
407
 
402
408
  /* Add insert values */
466
472
                                                           destination,
467
473
                                                           sql_variant);
468
474
 
469
 
  char quoted_identifier= '`';
470
 
  if (sql_variant == ANSI)
471
 
    quoted_identifier= '"';
472
 
 
473
475
  destination.append(") VALUES (", 10);
474
476
 
475
477
  /* Add insert values */
885
887
    destination.append(schema.collation());
886
888
  }
887
889
 
 
890
  if (not message::is_replicated(schema))
 
891
  {
 
892
    destination.append(" REPLICATE = FALSE");
 
893
  }
 
894
 
888
895
  return NONE;
889
896
}
890
897
 
1078
1085
  if (table.has_options())
1079
1086
    (void) transformTableOptionsToSql(table.options(), destination, sql_variant);
1080
1087
 
 
1088
  if (not message::is_replicated(table))
 
1089
  {
 
1090
    destination.append(" REPLICATE = FALSE");
 
1091
  }
 
1092
 
1081
1093
  return NONE;
1082
1094
}
1083
1095
 
1140
1152
    destination.append(boost::lexical_cast<string>(options.avg_row_length()));
1141
1153
  }
1142
1154
 
1143
 
  if (options.has_checksum() &&
1144
 
      options.checksum())
 
1155
  if (options.has_checksum() && options.checksum())
1145
1156
    destination.append("\nCHECKSUM = TRUE");
1146
 
  if (options.has_page_checksum() &&
1147
 
      options.page_checksum())
 
1157
 
 
1158
  if (options.has_page_checksum() && options.page_checksum())
1148
1159
    destination.append("\nPAGE_CHECKSUM = TRUE");
1149
1160
 
1150
1161
  return NONE;