~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/statement_transform.cc

  • Committer: Monty Taylor
  • Date: 2010-09-28 07:45:44 UTC
  • mto: (1799.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1800.
  • Revision ID: mordred@inaugust.com-20100928074544-s3ujnv6s8wro74l2
Added BSD copying file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
#include "config.h"
33
33
 
34
 
#include <boost/lexical_cast.hpp>
35
34
#include "drizzled/message/statement_transform.h"
36
35
#include "drizzled/message/transaction.pb.h"
37
36
#include "drizzled/message/table.pb.h"
127
126
 
128
127
  switch (source.type())
129
128
  {
130
 
  case Statement::ROLLBACK_STATEMENT:
131
 
    {
132
 
      break;
133
 
    }
134
 
  case Statement::ROLLBACK:
135
 
    {
136
 
      sql_strings.push_back("ROLLBACK");
137
 
      break;
138
 
    }
139
129
  case Statement::INSERT:
140
130
    {
141
131
      if (! source.has_insert_header())
1046
1036
  if (sql_variant == ANSI)
1047
1037
    return NONE; /* ANSI does not support table options... */
1048
1038
 
 
1039
  stringstream ss;
 
1040
 
1049
1041
  if (options.has_comment())
1050
1042
  {
1051
1043
    destination.append(" COMMENT=", 9);
1074
1066
 
1075
1067
  if (options.has_max_rows())
1076
1068
  {
 
1069
    ss << options.max_rows();
1077
1070
    destination.append("\nMAX_ROWS = ", 12);
1078
 
    destination.append(boost::lexical_cast<string>(options.max_rows()));
 
1071
    destination.append(ss.str());
 
1072
    ss.clear();
1079
1073
  }
1080
1074
 
1081
1075
  if (options.has_min_rows())
1082
1076
  {
 
1077
    ss << options.min_rows();
1083
1078
    destination.append("\nMIN_ROWS = ", 12);
1084
 
    destination.append(boost::lexical_cast<string>(options.min_rows()));
 
1079
    destination.append(ss.str());
 
1080
    ss.clear();
1085
1081
  }
1086
1082
 
1087
1083
  if (options.has_user_set_auto_increment_value()
1088
1084
      && options.has_auto_increment_value())
1089
1085
  {
 
1086
    ss << options.auto_increment_value();
1090
1087
    destination.append(" AUTO_INCREMENT=", 16);
1091
 
    destination.append(boost::lexical_cast<string>(options.auto_increment_value()));
 
1088
    destination.append(ss.str());
 
1089
    ss.clear();
1092
1090
  }
1093
1091
 
1094
1092
  if (options.has_avg_row_length())
1095
1093
  {
 
1094
    ss << options.avg_row_length();
1096
1095
    destination.append("\nAVG_ROW_LENGTH = ", 18);
1097
 
    destination.append(boost::lexical_cast<string>(options.avg_row_length()));
 
1096
    destination.append(ss.str());
 
1097
    ss.clear();
1098
1098
  }
1099
1099
 
1100
1100
  if (options.has_checksum() &&
1160
1160
      {
1161
1161
        if (part.compare_length() != field.string_options().length())
1162
1162
        {
 
1163
          stringstream ss;
1163
1164
          destination.push_back('(');
1164
 
          destination.append(boost::lexical_cast<string>(part.compare_length()));
 
1165
          ss << part.compare_length();
 
1166
          destination.append(ss.str());
1165
1167
          destination.push_back(')');
1166
1168
        }
1167
1169
      }
1200
1202
{
1201
1203
  switch (opt)
1202
1204
  {
 
1205
  case Table::ForeignKeyConstraint::OPTION_UNDEF:
 
1206
    break;
1203
1207
  case Table::ForeignKeyConstraint::OPTION_RESTRICT:
1204
1208
    destination.append("RESTRICT");
1205
1209
    break;
1209
1213
  case Table::ForeignKeyConstraint::OPTION_SET_NULL:
1210
1214
    destination.append("SET NULL");
1211
1215
    break;
1212
 
  case Table::ForeignKeyConstraint::OPTION_UNDEF:
1213
1216
  case Table::ForeignKeyConstraint::OPTION_NO_ACTION:
1214
1217
    destination.append("NO ACTION");
1215
1218
    break;
1216
 
  case Table::ForeignKeyConstraint::OPTION_SET_DEFAULT:
 
1219
  case Table::ForeignKeyConstraint::OPTION_DEFAULT:
1217
1220
    destination.append("SET DEFAULT");
1218
1221
    break;
1219
1222
  }
1266
1269
 
1267
1270
  destination.push_back(')');
1268
1271
 
1269
 
  if (fkey.has_update_option() and fkey.update_option() != Table::ForeignKeyConstraint::OPTION_UNDEF)
 
1272
  if (fkey.update_option() != Table::ForeignKeyConstraint::OPTION_UNDEF)
1270
1273
  {
1271
1274
    destination.append(" ON UPDATE ", 11);
1272
1275
    transformForeignKeyOptionToSql(fkey.update_option(), destination);
1273
1276
  }
1274
1277
 
1275
 
  if (fkey.has_delete_option() and fkey.delete_option() != Table::ForeignKeyConstraint::OPTION_UNDEF)
 
1278
  if (fkey.delete_option() != Table::ForeignKeyConstraint::OPTION_UNDEF)
1276
1279
  {
1277
1280
    destination.append(" ON DELETE ", 11);
1278
1281
    transformForeignKeyOptionToSql(fkey.delete_option(), destination);
1322
1325
      else
1323
1326
        destination.append(" VARCHAR(", 9);
1324
1327
 
1325
 
      destination.append(boost::lexical_cast<string>(field.string_options().length()));
1326
 
      destination.append(")");
 
1328
      stringstream ss;
 
1329
      ss << field.string_options().length() << ")";
 
1330
      destination.append(ss.str());
1327
1331
    }
1328
1332
    break;
1329
1333
  case Table::Field::BLOB:
1353
1357
      destination.push_back(')');
1354
1358
      break;
1355
1359
    }
1356
 
  case Table::Field::UUID:
1357
 
    destination.append(" UUID", 5);
1358
 
    break;
1359
1360
  case Table::Field::INTEGER:
1360
1361
    destination.append(" INT", 4);
1361
1362
    break;
1510
1511
    return Table::Field::ENUM;
1511
1512
  case DRIZZLE_TYPE_BLOB:
1512
1513
    return Table::Field::BLOB;
1513
 
  case DRIZZLE_TYPE_UUID:
1514
 
    return Table::Field::UUID;
1515
1514
  }
1516
1515
 
1517
1516
  assert(false);