~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/statement_transform.cc

  • Committer: Lee Bieber
  • Date: 2011-02-23 23:22:48 UTC
  • mfrom: (2183.2.20 list2)
  • mto: This revision was merged to the branch mainline in revision 2197.
  • Revision ID: kalebral@gmail.com-20110223232248-ev4y8pyt16b806o0
Merge Olaf - Use List::size()

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
 
318
318
      sql_strings.push_back(destination);
319
319
    }
320
320
    break;
 
321
  case Statement::ALTER_SCHEMA:
 
322
    {
 
323
      assert(source.has_alter_schema_statement());
 
324
      string destination;
 
325
      error= transformAlterSchemaStatementToSql(source.alter_schema_statement(),
 
326
                                                destination,
 
327
                                                sql_variant);
 
328
      sql_strings.push_back(destination);
 
329
    }
 
330
    break;
321
331
  case Statement::SET_VARIABLE:
322
332
    {
323
333
      assert(source.has_set_variable_statement());
806
816
}
807
817
 
808
818
enum TransformSqlError
 
819
transformAlterSchemaStatementToSql(const AlterSchemaStatement &statement,
 
820
                                   string &destination,
 
821
                                   enum TransformSqlVariant sql_variant)
 
822
{
 
823
  const Schema &before= statement.before();
 
824
  const Schema &after= statement.after();
 
825
 
 
826
  /* Make sure we are given the before and after for the same object */
 
827
  if (before.uuid() != after.uuid())
 
828
    return UUID_MISMATCH;
 
829
 
 
830
  char quoted_identifier= '`';
 
831
  if (sql_variant == ANSI)
 
832
    quoted_identifier= '"';
 
833
 
 
834
  destination.append("ALTER SCHEMA ");
 
835
  destination.push_back(quoted_identifier);
 
836
  destination.append(before.name());
 
837
  destination.push_back(quoted_identifier);
 
838
 
 
839
  /*
 
840
   * Diff our schemas. Currently, only collation can change so a
 
841
   * diff of the two structures is not really necessary.
 
842
   */
 
843
  destination.append(" COLLATE = ");
 
844
  destination.append(after.collation());
 
845
 
 
846
  return NONE;
 
847
}
 
848
 
 
849
enum TransformSqlError
809
850
transformDropSchemaStatementToSql(const DropSchemaStatement &statement,
810
851
                                  string &destination,
811
852
                                  enum TransformSqlVariant sql_variant)
833
874
 
834
875
  const Schema &schema= statement.schema();
835
876
 
836
 
  destination.append("CREATE SCHEMA ", 14);
 
877
  destination.append("CREATE SCHEMA ");
837
878
  destination.push_back(quoted_identifier);
838
879
  destination.append(schema.name());
839
880
  destination.push_back(quoted_identifier);
840
881
 
841
882
  if (schema.has_collation())
842
883
  {
843
 
    destination.append(" COLLATE ", 9);
 
884
    destination.append(" COLLATE ");
844
885
    destination.append(schema.collation());
845
886
  }
846
887
 
 
888
  if (not message::is_replicated(schema))
 
889
  {
 
890
    destination.append(" REPLICATE = FALSE");
 
891
  }
 
892
 
847
893
  return NONE;
848
894
}
849
895
 
858
904
 
859
905
  const TableMetadata &table_metadata= statement.table_metadata();
860
906
 
861
 
  destination.append("DROP TABLE ", 11);
 
907
  destination.append("DROP TABLE ");
862
908
 
863
909
  /* Add the IF EXISTS clause if necessary */
864
910
  if (statement.has_if_exists_clause() &&
865
911
      statement.if_exists_clause() == true)
866
912
  {
867
 
    destination.append("IF EXISTS ", 10);
 
913
    destination.append("IF EXISTS ");
868
914
  }
869
915
 
870
916
  destination.push_back(quoted_identifier);
889
935
 
890
936
  const TableMetadata &table_metadata= statement.table_metadata();
891
937
 
892
 
  destination.append("TRUNCATE TABLE ", 15);
 
938
  destination.append("TRUNCATE TABLE ");
893
939
  destination.push_back(quoted_identifier);
894
940
  destination.append(table_metadata.schema_name());
895
941
  destination.push_back(quoted_identifier);
910
956
  const FieldMetadata &variable_metadata= statement.variable_metadata();
911
957
  bool should_quote_field_value= shouldQuoteFieldValue(variable_metadata.type());
912
958
 
913
 
  destination.append("SET GLOBAL ", 11); /* Only global variables are replicated */
 
959
  destination.append("SET GLOBAL "); /* Only global variables are replicated */
914
960
  destination.append(variable_metadata.name());
915
961
  destination.push_back('=');
916
962
 
942
988
  if (sql_variant == ANSI)
943
989
    quoted_identifier= '"';
944
990
 
945
 
  destination.append("CREATE ", 7);
 
991
  destination.append("CREATE ");
946
992
 
947
993
  if (table.type() == Table::TEMPORARY)
948
 
    destination.append("TEMPORARY ", 10);
 
994
    destination.append("TEMPORARY ");
949
995
  
950
 
  destination.append("TABLE ", 6);
 
996
  destination.append("TABLE ");
951
997
  if (with_schema)
952
998
  {
953
999
    append_escaped_string(&destination, table.schema(), quoted_identifier);
954
1000
    destination.push_back('.');
955
1001
  }
956
1002
  append_escaped_string(&destination, table.name(), quoted_identifier);
957
 
  destination.append(" (\n", 3);
 
1003
  destination.append(" (\n");
958
1004
 
959
1005
  enum TransformSqlError result= NONE;
960
1006
  size_t num_fields= table.field_size();
963
1009
    const Table::Field &field= table.field(x);
964
1010
 
965
1011
    if (x != 0)
966
 
      destination.append(",\n", 2);
 
1012
      destination.append(",\n");
967
1013
 
968
1014
    destination.append("  ");
969
1015
 
976
1022
  size_t num_indexes= table.indexes_size();
977
1023
  
978
1024
  if (num_indexes > 0)
979
 
    destination.append(",\n", 2);
 
1025
    destination.append(",\n");
980
1026
 
981
1027
  for (size_t x= 0; x < num_indexes; ++x)
982
1028
  {
983
1029
    const message::Table::Index &index= table.indexes(x);
984
1030
 
985
1031
    if (x != 0)
986
 
      destination.append(",\n", 2);
 
1032
      destination.append(",\n");
987
1033
 
988
1034
    result= transformIndexDefinitionToSql(index, table, destination, sql_variant);
989
1035
    
994
1040
  size_t num_foreign_keys= table.fk_constraint_size();
995
1041
 
996
1042
  if (num_foreign_keys > 0)
997
 
    destination.append(",\n", 2);
 
1043
    destination.append(",\n");
998
1044
 
999
1045
  for (size_t x= 0; x < num_foreign_keys; ++x)
1000
1046
  {
1001
1047
    const message::Table::ForeignKeyConstraint &fkey= table.fk_constraint(x);
1002
1048
 
1003
1049
    if (x != 0)
1004
 
      destination.append(",\n", 2);
 
1050
      destination.append(",\n");
1005
1051
 
1006
1052
    result= transformForeignKeyConstraintDefinitionToSql(fkey, table, destination, sql_variant);
1007
1053
 
1009
1055
      return result;
1010
1056
  }
1011
1057
 
1012
 
  destination.append("\n)", 2);
 
1058
  destination.append("\n)");
1013
1059
 
1014
1060
  /* Add ENGINE = " clause */
1015
1061
  if (table.has_engine())
1016
1062
  {
1017
 
    destination.append(" ENGINE=", 8);
 
1063
    destination.append(" ENGINE=");
1018
1064
    destination.append(table.engine().name());
1019
1065
 
1020
1066
    size_t num_engine_options= table.engine().options_size();
1024
1070
    {
1025
1071
      const Engine::Option &option= table.engine().options(x);
1026
1072
      destination.append(option.name());
1027
 
      destination.append("='", 2);
 
1073
      destination.append("='");
1028
1074
      destination.append(option.state());
1029
 
      destination.append("'", 1);
1030
 
      if(x != num_engine_options-1)
1031
 
        destination.append(", ", 2);
 
1075
      destination.append("'");
 
1076
      if (x != num_engine_options-1)
 
1077
      {
 
1078
        destination.append(", ");
 
1079
      }
1032
1080
    }
1033
1081
  }
1034
1082
 
1035
1083
  if (table.has_options())
1036
1084
    (void) transformTableOptionsToSql(table.options(), destination, sql_variant);
1037
1085
 
 
1086
  if (not message::is_replicated(table))
 
1087
  {
 
1088
    destination.append(" REPLICATE = FALSE");
 
1089
  }
 
1090
 
1038
1091
  return NONE;
1039
1092
}
1040
1093
 
1048
1101
 
1049
1102
  if (options.has_comment())
1050
1103
  {
1051
 
    destination.append(" COMMENT=", 9);
 
1104
    destination.append(" COMMENT=");
1052
1105
    append_escaped_string(&destination, options.comment());
1053
1106
  }
1054
1107
 
1055
1108
  if (options.has_collation())
1056
1109
  {
1057
 
    destination.append(" COLLATE = ", 11);
 
1110
    destination.append(" COLLATE = ");
1058
1111
    destination.append(options.collation());
1059
1112
  }
1060
1113
 
1061
1114
  if (options.has_data_file_name())
1062
1115
  {
1063
 
    destination.append("\nDATA_FILE_NAME = '", 19);
 
1116
    destination.append("\nDATA_FILE_NAME = '");
1064
1117
    destination.append(options.data_file_name());
1065
1118
    destination.push_back('\'');
1066
1119
  }
1067
1120
 
1068
1121
  if (options.has_index_file_name())
1069
1122
  {
1070
 
    destination.append("\nINDEX_FILE_NAME = '", 20);
 
1123
    destination.append("\nINDEX_FILE_NAME = '");
1071
1124
    destination.append(options.index_file_name());
1072
1125
    destination.push_back('\'');
1073
1126
  }
1074
1127
 
1075
1128
  if (options.has_max_rows())
1076
1129
  {
1077
 
    destination.append("\nMAX_ROWS = ", 12);
 
1130
    destination.append("\nMAX_ROWS = ");
1078
1131
    destination.append(boost::lexical_cast<string>(options.max_rows()));
1079
1132
  }
1080
1133
 
1081
1134
  if (options.has_min_rows())
1082
1135
  {
1083
 
    destination.append("\nMIN_ROWS = ", 12);
 
1136
    destination.append("\nMIN_ROWS = ");
1084
1137
    destination.append(boost::lexical_cast<string>(options.min_rows()));
1085
1138
  }
1086
1139
 
1087
1140
  if (options.has_user_set_auto_increment_value()
1088
1141
      && options.has_auto_increment_value())
1089
1142
  {
1090
 
    destination.append(" AUTO_INCREMENT=", 16);
 
1143
    destination.append(" AUTO_INCREMENT=");
1091
1144
    destination.append(boost::lexical_cast<string>(options.auto_increment_value()));
1092
1145
  }
1093
1146
 
1094
1147
  if (options.has_avg_row_length())
1095
1148
  {
1096
 
    destination.append("\nAVG_ROW_LENGTH = ", 18);
 
1149
    destination.append("\nAVG_ROW_LENGTH = ");
1097
1150
    destination.append(boost::lexical_cast<string>(options.avg_row_length()));
1098
1151
  }
1099
1152
 
1100
 
  if (options.has_checksum() &&
1101
 
      options.checksum())
1102
 
    destination.append("\nCHECKSUM = TRUE", 16);
1103
 
  if (options.has_page_checksum() &&
1104
 
      options.page_checksum())
1105
 
    destination.append("\nPAGE_CHECKSUM = TRUE", 21);
 
1153
  if (options.has_checksum() && options.checksum())
 
1154
    destination.append("\nCHECKSUM = TRUE");
 
1155
 
 
1156
  if (options.has_page_checksum() && options.page_checksum())
 
1157
    destination.append("\nPAGE_CHECKSUM = TRUE");
1106
1158
 
1107
1159
  return NONE;
1108
1160
}
1120
1172
  destination.append("  ", 2);
1121
1173
 
1122
1174
  if (index.is_primary())
1123
 
    destination.append("PRIMARY ", 8);
 
1175
    destination.append("PRIMARY ");
1124
1176
  else if (index.is_unique())
1125
 
    destination.append("UNIQUE ", 7);
 
1177
    destination.append("UNIQUE ");
1126
1178
 
1127
1179
  destination.append("KEY ", 4);
1128
1180
  if (! (index.is_primary() && index.name().compare("PRIMARY")==0))
1174
1226
  case Table::Index::UNKNOWN_INDEX:
1175
1227
    break;
1176
1228
  case Table::Index::BTREE:
1177
 
    destination.append(" USING BTREE", 12);
 
1229
    destination.append(" USING BTREE");
1178
1230
    break;
1179
1231
  case Table::Index::RTREE:
1180
 
    destination.append(" USING RTREE", 12);
 
1232
    destination.append(" USING RTREE");
1181
1233
    break;
1182
1234
  case Table::Index::HASH:
1183
 
    destination.append(" USING HASH", 11);
 
1235
    destination.append(" USING HASH");
1184
1236
    break;
1185
1237
  case Table::Index::FULLTEXT:
1186
 
    destination.append(" USING FULLTEXT", 15);
 
1238
    destination.append(" USING FULLTEXT");
1187
1239
    break;
1188
1240
  }
1189
1241
 
1190
1242
  if (index.has_comment())
1191
1243
  {
1192
 
    destination.append(" COMMENT ", 9);
 
1244
    destination.append(" COMMENT ");
1193
1245
    append_escaped_string(&destination, index.comment());
1194
1246
  }
1195
1247
 
1229
1281
  if (sql_variant == ANSI)
1230
1282
    quoted_identifier= '"';
1231
1283
 
1232
 
  destination.append("  ", 2);
 
1284
  destination.append("  ");
1233
1285
 
1234
1286
  if (fkey.has_name())
1235
1287
  {
1236
 
    destination.append("CONSTRAINT ", 11);
 
1288
    destination.append("CONSTRAINT ");
1237
1289
    append_escaped_string(&destination, fkey.name(), quoted_identifier);
1238
1290
    destination.append(" ", 1);
1239
1291
  }
1240
1292
 
1241
 
  destination.append("FOREIGN KEY (", 13);
 
1293
  destination.append("FOREIGN KEY (");
1242
1294
 
1243
1295
  for (ssize_t x= 0; x < fkey.column_names_size(); ++x)
1244
1296
  {
1249
1301
                          quoted_identifier);
1250
1302
  }
1251
1303
 
1252
 
  destination.append(") REFERENCES ", 13);
 
1304
  destination.append(") REFERENCES ");
1253
1305
 
1254
1306
  append_escaped_string(&destination, fkey.references_table_name(),
1255
1307
                        quoted_identifier);
1256
 
  destination.append(" (", 2);
 
1308
  destination.append(" (");
1257
1309
 
1258
1310
  for (ssize_t x= 0; x < fkey.references_columns_size(); ++x)
1259
1311
  {
1268
1320
 
1269
1321
  if (fkey.has_update_option() and fkey.update_option() != Table::ForeignKeyConstraint::OPTION_UNDEF)
1270
1322
  {
1271
 
    destination.append(" ON UPDATE ", 11);
 
1323
    destination.append(" ON UPDATE ");
1272
1324
    transformForeignKeyOptionToSql(fkey.update_option(), destination);
1273
1325
  }
1274
1326
 
1275
1327
  if (fkey.has_delete_option() and fkey.delete_option() != Table::ForeignKeyConstraint::OPTION_UNDEF)
1276
1328
  {
1277
 
    destination.append(" ON DELETE ", 11);
 
1329
    destination.append(" ON DELETE ");
1278
1330
    transformForeignKeyOptionToSql(fkey.delete_option(), destination);
1279
1331
  }
1280
1332
 
1304
1356
  switch (field_type)
1305
1357
  {
1306
1358
    case Table::Field::DOUBLE:
1307
 
    destination.append(" DOUBLE", 7);
 
1359
    destination.append(" DOUBLE");
1308
1360
    if (field.has_numeric_options()
1309
1361
        && field.numeric_options().has_precision())
1310
1362
    {
1318
1370
    {
1319
1371
      if (field.string_options().has_collation()
1320
1372
          && field.string_options().collation().compare("binary") == 0)
1321
 
        destination.append(" VARBINARY(", 11);
 
1373
        destination.append(" VARBINARY(");
1322
1374
      else
1323
 
        destination.append(" VARCHAR(", 9);
 
1375
        destination.append(" VARCHAR(");
1324
1376
 
1325
1377
      destination.append(boost::lexical_cast<string>(field.string_options().length()));
1326
1378
      destination.append(")");
1330
1382
    {
1331
1383
      if (field.string_options().has_collation()
1332
1384
          && field.string_options().collation().compare("binary") == 0)
1333
 
        destination.append(" BLOB", 5);
 
1385
        destination.append(" BLOB");
1334
1386
      else
1335
 
        destination.append(" TEXT", 5);
 
1387
        destination.append(" TEXT");
1336
1388
    }
1337
1389
    break;
1338
1390
  case Table::Field::ENUM:
1339
1391
    {
1340
1392
      size_t num_field_values= field.enumeration_values().field_value_size();
1341
 
      destination.append(" ENUM(", 6);
 
1393
      destination.append(" ENUM(");
1342
1394
      for (size_t x= 0; x < num_field_values; ++x)
1343
1395
      {
1344
1396
        const string &type= field.enumeration_values().field_value(x);
1354
1406
      break;
1355
1407
    }
1356
1408
  case Table::Field::UUID:
1357
 
    destination.append(" UUID", 5);
 
1409
    destination.append(" UUID");
 
1410
    break;
 
1411
  case Table::Field::BOOLEAN:
 
1412
    destination.append(" BOOLEAN");
1358
1413
    break;
1359
1414
  case Table::Field::INTEGER:
1360
 
    destination.append(" INT", 4);
 
1415
    destination.append(" INT");
1361
1416
    break;
1362
1417
  case Table::Field::BIGINT:
1363
 
    destination.append(" BIGINT", 7);
 
1418
    if (field.has_constraints() and
 
1419
        field.constraints().is_unsigned())
 
1420
    {
 
1421
      destination.append(" BIGINT UNSIGNED");
 
1422
    }
 
1423
    else
 
1424
    {
 
1425
      destination.append(" BIGINT");
 
1426
    }
1364
1427
    break;
1365
1428
  case Table::Field::DECIMAL:
1366
1429
    {
1367
 
      destination.append(" DECIMAL(", 9);
 
1430
      destination.append(" DECIMAL(");
1368
1431
      stringstream ss;
1369
1432
      ss << field.numeric_options().precision() << ",";
1370
1433
      ss << field.numeric_options().scale() << ")";
1372
1435
    }
1373
1436
    break;
1374
1437
  case Table::Field::DATE:
1375
 
    destination.append(" DATE", 5);
1376
 
    break;
1377
 
  case Table::Field::TIMESTAMP:
1378
 
    destination.append(" TIMESTAMP",  10);
1379
 
    break;
 
1438
    destination.append(" DATE");
 
1439
    break;
 
1440
 
 
1441
  case Table::Field::EPOCH:
 
1442
    if (field.time_options().microseconds())
 
1443
    {
 
1444
      destination.append(" TIMESTAMP(6)");
 
1445
    }
 
1446
    else
 
1447
    {
 
1448
      destination.append(" TIMESTAMP");
 
1449
    }
 
1450
    break;
 
1451
 
1380
1452
  case Table::Field::DATETIME:
1381
 
    destination.append(" DATETIME",  9);
1382
 
    break;
1383
 
  }
1384
 
 
1385
 
  if (field.type() == Table::Field::INTEGER || 
1386
 
      field.type() == Table::Field::BIGINT)
1387
 
  {
1388
 
    if (field.has_constraints() &&
1389
 
        field.constraints().has_is_unsigned() &&
1390
 
        field.constraints().is_unsigned())
1391
 
    {
1392
 
      destination.append(" UNSIGNED", 9);
1393
 
    }
 
1453
    destination.append(" DATETIME");
 
1454
    break;
 
1455
  case Table::Field::TIME:
 
1456
    destination.append(" TIME");
 
1457
    break;
1394
1458
  }
1395
1459
 
1396
1460
  if (field.type() == Table::Field::BLOB ||
1399
1463
    if (field.string_options().has_collation()
1400
1464
        && field.string_options().collation().compare("binary"))
1401
1465
    {
1402
 
      destination.append(" COLLATE ", 9);
 
1466
      destination.append(" COLLATE ");
1403
1467
      destination.append(field.string_options().collation());
1404
1468
    }
1405
1469
  }
1406
1470
 
1407
 
  if (field.has_constraints() &&
1408
 
      ! field.constraints().is_nullable())
1409
 
  {
1410
 
    destination.append(" NOT NULL", 9);
1411
 
  }
1412
 
  else if (field.type() == Table::Field::TIMESTAMP)
1413
 
    destination.append(" NULL", 5);
 
1471
  if (field.has_constraints() and field.constraints().is_unique())
 
1472
  {
 
1473
    destination.append(" UNIQUE");
 
1474
  }
 
1475
 
 
1476
  if (field.has_constraints() && field.constraints().is_notnull())
 
1477
  {
 
1478
    destination.append(" NOT NULL");
 
1479
  }
 
1480
  else if (field.type() == Table::Field::EPOCH)
 
1481
  {
 
1482
    destination.append(" NULL");
 
1483
  }
1414
1484
 
1415
1485
  if (field.type() == Table::Field::INTEGER || 
1416
1486
      field.type() == Table::Field::BIGINT)
1419
1489
    if (field.has_numeric_options() &&
1420
1490
        field.numeric_options().is_autoincrement())
1421
1491
    {
1422
 
      destination.append(" AUTO_INCREMENT", 15);
 
1492
      destination.append(" AUTO_INCREMENT");
1423
1493
    }
1424
1494
  }
1425
1495
 
1426
1496
  if (field.options().has_default_value())
1427
1497
  {
1428
 
    destination.append(" DEFAULT ", 9);
 
1498
    destination.append(" DEFAULT ");
1429
1499
    append_escaped_string(&destination, field.options().default_value());
1430
1500
  }
1431
1501
  else if (field.options().has_default_expression())
1432
1502
  {
1433
 
    destination.append(" DEFAULT ", 9);
 
1503
    destination.append(" DEFAULT ");
1434
1504
    destination.append(field.options().default_expression());
1435
1505
  }
1436
1506
  else if (field.options().has_default_bin_value())
1437
1507
  {
1438
1508
    const string &v= field.options().default_bin_value();
1439
1509
    if (v.length() == 0)
1440
 
      destination.append(" DEFAULT ''", 11);
 
1510
    {
 
1511
      destination.append(" DEFAULT ''");
 
1512
    }
1441
1513
    else
1442
1514
    {
1443
 
      destination.append(" DEFAULT 0x", 11);
 
1515
      destination.append(" DEFAULT 0x");
1444
1516
      for (size_t x= 0; x < v.length(); x++)
1445
1517
      {
1446
1518
        char hex[3];
1453
1525
           && field.options().default_null()
1454
1526
           && field.type() != Table::Field::BLOB)
1455
1527
  {
1456
 
    destination.append(" DEFAULT NULL", 13);
 
1528
    destination.append(" DEFAULT NULL");
1457
1529
  }
1458
1530
 
1459
1531
  if (field.has_options() && field.options().has_update_expression())
1460
1532
  {
1461
 
    destination.append(" ON UPDATE ", 11);
 
1533
    destination.append(" ON UPDATE ");
1462
1534
    destination.append(field.options().update_expression());
1463
1535
  }
1464
1536
 
1465
1537
  if (field.has_comment())
1466
1538
  {
1467
 
    destination.append(" COMMENT ", 9);
 
1539
    destination.append(" COMMENT ");
1468
1540
    append_escaped_string(&destination, field.comment(), quoted_default);
1469
1541
  }
1470
1542
  return NONE;
1494
1566
  case DRIZZLE_TYPE_NULL:
1495
1567
    assert(false); /* Not a user definable type */
1496
1568
    return Table::Field::INTEGER; /* unreachable */
 
1569
  case DRIZZLE_TYPE_MICROTIME:
1497
1570
  case DRIZZLE_TYPE_TIMESTAMP:
1498
 
    return Table::Field::TIMESTAMP;
 
1571
    return Table::Field::EPOCH;
1499
1572
  case DRIZZLE_TYPE_LONGLONG:
1500
1573
    return Table::Field::BIGINT;
1501
1574
  case DRIZZLE_TYPE_DATETIME:
1502
1575
    return Table::Field::DATETIME;
 
1576
  case DRIZZLE_TYPE_TIME:
 
1577
    return Table::Field::TIME;
1503
1578
  case DRIZZLE_TYPE_DATE:
1504
1579
    return Table::Field::DATE;
1505
1580
  case DRIZZLE_TYPE_VARCHAR:
1512
1587
    return Table::Field::BLOB;
1513
1588
  case DRIZZLE_TYPE_UUID:
1514
1589
    return Table::Field::UUID;
 
1590
  case DRIZZLE_TYPE_BOOLEAN:
 
1591
    return Table::Field::BOOLEAN;
1515
1592
  }
1516
1593
 
1517
1594
  assert(false);