459
352
for (x= 0; x < num_set_fields; ++x)
461
const FieldMetadata &field_metadata= header.set_field_metadata(x);
354
const message::FieldMetadata &field_metadata= header.set_field_metadata(x);
463
destination.push_back(',');
356
destination->push_back(',');
465
destination.push_back(quoted_identifier);
466
destination.append(field_metadata.name());
467
destination.push_back(quoted_identifier);
468
destination.push_back('=');
470
should_quote_field_value= shouldQuoteFieldValue(field_metadata.type());
472
if (should_quote_field_value)
473
destination.push_back('\'');
475
if (field_metadata.type() == Table::Field::BLOB)
478
* We do this here because BLOB data is returned
479
* in a string correctly, but calling append()
480
* without a length will result in only the string
481
* up to a \0 being output here.
483
string raw_data(record.after_value(x));
484
destination.append(raw_data.c_str(), raw_data.size());
488
destination.append(record.after_value(x));
491
if (should_quote_field_value)
492
destination.push_back('\'');
358
destination->push_back(quoted_identifier);
359
destination->append(field_metadata.name());
360
destination->push_back(quoted_identifier);
361
destination->push_back('=');
363
should_quote_field_value= message::shouldQuoteFieldValue(field_metadata.type());
365
if (should_quote_field_value)
366
destination->push_back('\'');
368
destination->append(header.set_value(x));
370
if (should_quote_field_value)
371
destination->push_back('\'');
377
enum message::TransformSqlError
378
message::transformUpdateRecordToSql(const message::UpdateHeader &header,
379
const message::UpdateRecord &record,
380
std::string *destination,
381
enum message::TransformSqlVariant sql_variant)
383
enum message::TransformSqlError error= transformUpdateHeaderToSql(header,
387
char quoted_identifier= '`';
388
if (sql_variant == ANSI)
389
quoted_identifier= '"';
495
391
size_t num_key_fields= header.key_field_metadata_size();
393
bool should_quote_field_value= false;
497
destination.append(" WHERE ", 7);
395
destination->append(" WHERE ");
498
396
for (x= 0; x < num_key_fields; ++x)
500
const FieldMetadata &field_metadata= header.key_field_metadata(x);
398
const message::FieldMetadata &field_metadata= header.key_field_metadata(x);
503
destination.append(" AND ", 5); /* Always AND condition with a multi-column PK */
505
destination.push_back(quoted_identifier);
506
destination.append(field_metadata.name());
507
destination.push_back(quoted_identifier);
509
destination.push_back('=');
511
should_quote_field_value= shouldQuoteFieldValue(field_metadata.type());
513
if (should_quote_field_value)
514
destination.push_back('\'');
516
if (field_metadata.type() == Table::Field::BLOB)
519
* We do this here because BLOB data is returned
520
* in a string correctly, but calling append()
521
* without a length will result in only the string
522
* up to a \0 being output here.
524
string raw_data(record.key_value(x));
525
destination.append(raw_data.c_str(), raw_data.size());
529
destination.append(record.key_value(x));
532
if (should_quote_field_value)
533
destination.push_back('\'');
539
enum TransformSqlError
540
transformDeleteHeaderToSql(const DeleteHeader &header,
542
enum TransformSqlVariant sql_variant)
544
char quoted_identifier= '`';
545
if (sql_variant == ANSI)
546
quoted_identifier= '"';
548
destination.assign("DELETE FROM ", 12);
549
destination.push_back(quoted_identifier);
550
destination.append(header.table_metadata().schema_name());
551
destination.push_back(quoted_identifier);
552
destination.push_back('.');
553
destination.push_back(quoted_identifier);
554
destination.append(header.table_metadata().table_name());
555
destination.push_back(quoted_identifier);
401
destination->append(" AND "); /* Always AND condition with a multi-column PK */
403
destination->push_back(quoted_identifier);
404
destination->append(field_metadata.name());
405
destination->push_back(quoted_identifier);
407
destination->push_back('=');
409
should_quote_field_value= message::shouldQuoteFieldValue(field_metadata.type());
411
if (should_quote_field_value)
412
destination->push_back('\'');
414
destination->append(record.key_value(x));
416
if (should_quote_field_value)
417
destination->push_back('\'');
419
if (num_key_fields > 1)
420
destination->push_back(')');
425
enum message::TransformSqlError
426
message::transformUpdateStatementToSql(const message::UpdateHeader &header,
427
const message::UpdateData &data,
428
std::string *destination,
429
enum message::TransformSqlVariant sql_variant)
431
enum message::TransformSqlError error= transformUpdateHeaderToSql(header,
435
char quoted_identifier= '`';
436
if (sql_variant == ANSI)
437
quoted_identifier= '"';
439
/* Add WHERE clause to SQL string... */
440
size_t num_key_fields= header.key_field_metadata_size();
441
size_t num_key_records= data.record_size();
443
bool should_quote_field_value= false;
445
destination->append(" WHERE ");
446
for (x= 0; x < num_key_records; ++x)
449
destination->append(" OR "); /* Always OR condition for multiple key records */
451
if (num_key_fields > 1)
452
destination->push_back('(');
454
for (y= 0; y < num_key_fields; ++y)
456
const message::FieldMetadata &field_metadata= header.key_field_metadata(y);
459
destination->append(" AND "); /* Always AND condition with a multi-column PK */
461
destination->push_back(quoted_identifier);
462
destination->append(field_metadata.name());
463
destination->push_back(quoted_identifier);
465
destination->push_back('=');
467
should_quote_field_value= message::shouldQuoteFieldValue(field_metadata.type());
469
if (should_quote_field_value)
470
destination->push_back('\'');
472
destination->append(data.record(x).key_value(y));
474
if (should_quote_field_value)
475
destination->push_back('\'');
477
if (num_key_fields > 1)
478
destination->push_back(')');
483
enum message::TransformSqlError
484
message::transformDeleteHeaderToSql(const message::DeleteHeader &header,
485
std::string *destination,
486
enum message::TransformSqlVariant sql_variant)
488
char quoted_identifier= '`';
489
if (sql_variant == ANSI)
490
quoted_identifier= '"';
492
destination->assign("DELETE FROM ");
493
destination->push_back(quoted_identifier);
494
destination->append(header.table_metadata().schema_name());
495
destination->push_back(quoted_identifier);
496
destination->push_back('.');
497
destination->push_back(quoted_identifier);
498
destination->append(header.table_metadata().table_name());
499
destination->push_back(quoted_identifier);
560
enum TransformSqlError
561
transformDeleteRecordToSql(const DeleteHeader &header,
562
const DeleteRecord &record,
564
enum TransformSqlVariant sql_variant)
504
enum message::TransformSqlError
505
message::transformDeleteRecordToSql(const message::DeleteHeader &header,
506
const message::DeleteRecord &record,
507
std::string *destination,
508
enum message::TransformSqlVariant sql_variant)
566
enum TransformSqlError error= transformDeleteHeaderToSql(header,
510
enum message::TransformSqlError error= transformDeleteHeaderToSql(header,
569
513
char quoted_identifier= '`';
570
514
if (sql_variant == ANSI)
571
515
quoted_identifier= '"';
637
569
bool should_quote_field_value= false;
639
destination.append(" WHERE ", 7);
571
destination->append(" WHERE ");
640
572
for (x= 0; x < num_key_records; ++x)
643
destination.append(" OR ", 4); /* Always OR condition for multiple key records */
575
destination->append(" OR "); /* Always OR condition for multiple key records */
645
577
if (num_key_fields > 1)
646
destination.push_back('(');
578
destination->push_back('(');
648
580
for (y= 0; y < num_key_fields; ++y)
650
const FieldMetadata &field_metadata= header.key_field_metadata(y);
582
const message::FieldMetadata &field_metadata= header.key_field_metadata(y);
653
destination.append(" AND ", 5); /* Always AND condition with a multi-column PK */
655
destination.push_back(quoted_identifier);
656
destination.append(field_metadata.name());
657
destination.push_back(quoted_identifier);
659
destination.push_back('=');
661
should_quote_field_value= shouldQuoteFieldValue(field_metadata.type());
663
if (should_quote_field_value)
664
destination.push_back('\'');
666
if (field_metadata.type() == Table::Field::BLOB)
669
* We do this here because BLOB data is returned
670
* in a string correctly, but calling append()
671
* without a length will result in only the string
672
* up to a \0 being output here.
674
string raw_data(data.record(x).key_value(y));
675
destination.append(raw_data.c_str(), raw_data.size());
679
destination.append(data.record(x).key_value(y));
682
if (should_quote_field_value)
683
destination.push_back('\'');
585
destination->append(" AND "); /* Always AND condition with a multi-column PK */
587
destination->push_back(quoted_identifier);
588
destination->append(field_metadata.name());
589
destination->push_back(quoted_identifier);
591
destination->push_back('=');
593
should_quote_field_value= message::shouldQuoteFieldValue(field_metadata.type());
595
if (should_quote_field_value)
596
destination->push_back('\'');
598
destination->append(data.record(x).key_value(y));
600
if (should_quote_field_value)
601
destination->push_back('\'');
685
603
if (num_key_fields > 1)
686
destination.push_back(')');
604
destination->push_back(')');
691
enum TransformSqlError
692
transformDropSchemaStatementToSql(const DropSchemaStatement &statement,
694
enum TransformSqlVariant sql_variant)
696
char quoted_identifier= '`';
697
if (sql_variant == ANSI)
698
quoted_identifier= '"';
700
destination.append("DROP SCHEMA ", 12);
701
destination.push_back(quoted_identifier);
702
destination.append(statement.schema_name());
703
destination.push_back(quoted_identifier);
708
enum TransformSqlError
709
transformCreateSchemaStatementToSql(const CreateSchemaStatement &statement,
711
enum TransformSqlVariant sql_variant)
713
char quoted_identifier= '`';
714
if (sql_variant == ANSI)
715
quoted_identifier= '"';
717
const Schema &schema= statement.schema();
719
destination.append("CREATE SCHEMA ", 14);
720
destination.push_back(quoted_identifier);
721
destination.append(schema.name());
722
destination.push_back(quoted_identifier);
724
if (schema.has_collation())
726
destination.append(" COLLATE ", 9);
727
destination.append(schema.collation());
733
enum TransformSqlError
734
transformDropTableStatementToSql(const DropTableStatement &statement,
736
enum TransformSqlVariant sql_variant)
738
char quoted_identifier= '`';
739
if (sql_variant == ANSI)
740
quoted_identifier= '"';
742
const TableMetadata &table_metadata= statement.table_metadata();
744
destination.append("DROP TABLE ", 11);
746
/* Add the IF EXISTS clause if necessary */
747
if (statement.has_if_exists_clause() &&
748
statement.if_exists_clause() == true)
750
destination.append("IF EXISTS ", 10);
753
destination.push_back(quoted_identifier);
754
destination.append(table_metadata.schema_name());
755
destination.push_back(quoted_identifier);
756
destination.push_back('.');
757
destination.push_back(quoted_identifier);
758
destination.append(table_metadata.table_name());
759
destination.push_back(quoted_identifier);
764
enum TransformSqlError
765
transformTruncateTableStatementToSql(const TruncateTableStatement &statement,
767
enum TransformSqlVariant sql_variant)
769
char quoted_identifier= '`';
770
if (sql_variant == ANSI)
771
quoted_identifier= '"';
773
const TableMetadata &table_metadata= statement.table_metadata();
775
destination.append("TRUNCATE TABLE ", 15);
776
destination.push_back(quoted_identifier);
777
destination.append(table_metadata.schema_name());
778
destination.push_back(quoted_identifier);
779
destination.push_back('.');
780
destination.push_back(quoted_identifier);
781
destination.append(table_metadata.table_name());
782
destination.push_back(quoted_identifier);
787
enum TransformSqlError
788
transformSetVariableStatementToSql(const SetVariableStatement &statement,
790
enum TransformSqlVariant sql_variant)
609
enum message::TransformSqlError
610
message::transformSetVariableStatementToSql(const message::SetVariableStatement &statement,
611
std::string *destination,
612
enum message::TransformSqlVariant sql_variant)
792
614
(void) sql_variant;
793
const FieldMetadata &variable_metadata= statement.variable_metadata();
794
bool should_quote_field_value= shouldQuoteFieldValue(variable_metadata.type());
796
destination.append("SET GLOBAL ", 11); /* Only global variables are replicated */
797
destination.append(variable_metadata.name());
798
destination.push_back('=');
800
if (should_quote_field_value)
801
destination.push_back('\'');
803
destination.append(statement.variable_value());
805
if (should_quote_field_value)
806
destination.push_back('\'');
811
enum TransformSqlError
812
transformCreateTableStatementToSql(const CreateTableStatement &statement,
814
enum TransformSqlVariant sql_variant)
816
return transformTableDefinitionToSql(statement.table(), destination, sql_variant);
819
enum TransformSqlError
820
transformTableDefinitionToSql(const Table &table,
822
enum TransformSqlVariant sql_variant, bool with_schema)
824
char quoted_identifier= '`';
825
if (sql_variant == ANSI)
826
quoted_identifier= '"';
828
destination.append("CREATE ", 7);
830
if (table.type() == Table::TEMPORARY)
831
destination.append("TEMPORARY ", 10);
833
destination.append("TABLE ", 6);
836
destination.push_back(quoted_identifier);
837
destination.append(table.schema());
838
destination.push_back(quoted_identifier);
839
destination.push_back('.');
841
destination.push_back(quoted_identifier);
842
destination.append(table.name());
843
destination.push_back(quoted_identifier);
844
destination.append(" (\n", 3);
846
enum TransformSqlError result= NONE;
847
size_t num_fields= table.field_size();
848
for (size_t x= 0; x < num_fields; ++x)
850
const Table::Field &field= table.field(x);
853
destination.append(",\n", 2);
855
result= transformFieldDefinitionToSql(field, destination, sql_variant);
861
size_t num_indexes= table.indexes_size();
864
destination.append(",\n", 2);
866
for (size_t x= 0; x < num_indexes; ++x)
868
const message::Table::Index &index= table.indexes(x);
871
destination.append(",\n", 2);
873
result= transformIndexDefinitionToSql(index, table, destination, sql_variant);
878
destination.append("\n)", 2);
880
/* Add ENGINE = " clause */
881
if (table.has_engine())
883
const Table::StorageEngine &engine= table.engine();
884
destination.append("\nENGINE = ", 10);
885
destination.append(engine.name());
887
size_t num_engine_options= engine.option_size();
888
for (size_t x= 0; x < num_engine_options; ++x)
890
const Table::StorageEngine::EngineOption &option= engine.option(x);
891
destination.push_back('\n');
892
destination.append(option.option_name());
893
destination.append(" = ", 3);
894
destination.append(option.option_value());
895
destination.push_back('\n');
899
if (table.has_options())
900
(void) transformTableOptionsToSql(table.options(), destination, sql_variant);
905
enum TransformSqlError
906
transformTableOptionsToSql(const Table::TableOptions &options,
908
enum TransformSqlVariant sql_variant)
910
if (sql_variant == ANSI)
911
return NONE; /* ANSI does not support table options... */
915
if (options.has_comment())
917
destination.append("\nCOMMENT = '", 12);
918
destination.append(options.comment());
919
destination.push_back('\'');
922
if (options.has_collation())
924
destination.append("\nCOLLATE = ", 11);
925
destination.append(options.collation());
928
if (options.has_auto_increment())
930
ss << options.auto_increment();
931
destination.append("\nAUTOINCREMENT_OFFSET = ", 24);
932
destination.append(ss.str());
936
if (options.has_row_type())
938
ss << options.row_type();
939
destination.append("\nROW_TYPE = ", 12);
940
destination.append(ss.str());
944
if (options.has_data_file_name())
946
destination.append("\nDATA_FILE_NAME = '", 19);
947
destination.append(options.data_file_name());
948
destination.push_back('\'');
951
if (options.has_index_file_name())
953
destination.append("\nINDEX_FILE_NAME = '", 20);
954
destination.append(options.index_file_name());
955
destination.push_back('\'');
958
if (options.has_max_rows())
960
ss << options.max_rows();
961
destination.append("\nMAX_ROWS = ", 12);
962
destination.append(ss.str());
966
if (options.has_min_rows())
968
ss << options.min_rows();
969
destination.append("\nMIN_ROWS = ", 12);
970
destination.append(ss.str());
974
if (options.has_auto_increment_value())
976
ss << options.auto_increment_value();
977
destination.append("\nAUTO_INCREMENT = ", 18);
978
destination.append(ss.str());
982
if (options.has_avg_row_length())
984
ss << options.avg_row_length();
985
destination.append("\nAVG_ROW_LENGTH = ", 18);
986
destination.append(ss.str());
990
if (options.has_key_block_size())
992
ss << options.key_block_size();
993
destination.append("\nKEY_BLOCK_SIZE = ", 18);
994
destination.append(ss.str());
998
if (options.has_block_size())
1000
ss << options.block_size();
1001
destination.append("\nBLOCK_SIZE = ", 14);
1002
destination.append(ss.str());
1006
if (options.has_pack_keys() &&
1007
options.pack_keys())
1008
destination.append("\nPACK_KEYS = TRUE", 17);
1009
if (options.has_pack_record() &&
1010
options.pack_record())
1011
destination.append("\nPACK_RECORD = TRUE", 19);
1012
if (options.has_checksum() &&
1014
destination.append("\nCHECKSUM = TRUE", 16);
1015
if (options.has_page_checksum() &&
1016
options.page_checksum())
1017
destination.append("\nPAGE_CHECKSUM = TRUE", 21);
1022
enum TransformSqlError
1023
transformIndexDefinitionToSql(const Table::Index &index,
1025
string &destination,
1026
enum TransformSqlVariant sql_variant)
1028
char quoted_identifier= '`';
1029
if (sql_variant == ANSI)
1030
quoted_identifier= '"';
1032
if (index.is_primary())
1033
destination.append("PRIMARY ", 8);
1034
else if (index.is_unique())
1035
destination.append("UNIQUE ", 7);
1037
destination.append("KEY ", 4);
1038
destination.push_back(quoted_identifier);
1039
destination.append(index.name());
1040
destination.push_back(quoted_identifier);
1041
destination.append(" (", 2);
1043
size_t num_parts= index.index_part_size();
1044
for (size_t x= 0; x < num_parts; ++x)
1046
const Table::Index::IndexPart &part= index.index_part(x);
1047
const Table::Field &field= table.field(part.fieldnr());
1050
destination.push_back(',');
1052
destination.push_back(quoted_identifier);
1053
destination.append(field.name());
1054
destination.push_back(quoted_identifier);
1057
* If the index part's field type is VARCHAR or TEXT
1058
* then check for a prefix length then is different
1059
* from the field's full length...
1061
if (field.type() == Table::Field::VARCHAR ||
1062
field.type() == Table::Field::BLOB)
1064
if (part.has_compare_length())
1066
size_t compare_length_in_chars= part.compare_length();
1068
/* hack: compare_length() is bytes, not chars, but
1069
* only for VARCHAR. Ass. */
1070
if (field.type() == Table::Field::VARCHAR)
1071
compare_length_in_chars/= 4;
1073
if (compare_length_in_chars != field.string_options().length())
1076
destination.push_back('(');
1077
ss << compare_length_in_chars;
1078
destination.append(ss.str());
1079
destination.push_back(')');
1084
destination.push_back(')');
1089
enum TransformSqlError
1090
transformFieldDefinitionToSql(const Table::Field &field,
1091
string &destination,
1092
enum TransformSqlVariant sql_variant)
1094
char quoted_identifier= '`';
1095
if (sql_variant == ANSI)
1096
quoted_identifier= '"';
1098
destination.push_back(quoted_identifier);
1099
destination.append(field.name());
1100
destination.push_back(quoted_identifier);
1102
Table::Field::FieldType field_type= field.type();
1106
case Table::Field::DOUBLE:
1107
destination.append(" DOUBLE", 7);
1109
case Table::Field::VARCHAR:
1111
destination.append(" VARCHAR(", 9);
1113
ss << field.string_options().length() << ")";
1114
destination.append(ss.str());
1117
case Table::Field::BLOB:
1118
destination.append(" BLOB", 5);
1120
case Table::Field::ENUM:
1122
size_t num_field_values= field.enumeration_values().field_value_size();
1123
destination.append(" ENUM(", 6);
1124
for (size_t x= 0; x < num_field_values; ++x)
1126
const string &type= field.enumeration_values().field_value(x);
1129
destination.push_back(',');
1131
destination.push_back('\'');
1132
destination.append(type);
1133
destination.push_back('\'');
1135
destination.push_back(')');
1138
case Table::Field::INTEGER:
1139
destination.append(" INT", 4);
1141
case Table::Field::BIGINT:
1142
destination.append(" BIGINT", 7);
1144
case Table::Field::DECIMAL:
1146
destination.append(" DECIMAL(", 9);
1148
ss << field.numeric_options().precision() << ",";
1149
ss << field.numeric_options().scale() << ")";
1150
destination.append(ss.str());
1153
case Table::Field::DATE:
1154
destination.append(" DATE", 5);
1156
case Table::Field::TIMESTAMP:
1157
destination.append(" TIMESTAMP", 10);
1159
case Table::Field::DATETIME:
1160
destination.append(" DATETIME", 9);
1164
if (field.type() == Table::Field::INTEGER ||
1165
field.type() == Table::Field::BIGINT)
1167
if (field.has_constraints() &&
1168
field.constraints().has_is_unsigned() &&
1169
field.constraints().is_unsigned())
1171
destination.append(" UNSIGNED", 9);
1176
if (! (field.has_constraints() &&
1177
field.constraints().is_nullable()))
1179
destination.append(" NOT", 4);
1181
destination.append(" NULL", 5);
1183
if (field.type() == Table::Field::INTEGER ||
1184
field.type() == Table::Field::BIGINT)
1186
/* AUTO_INCREMENT must be after NOT NULL */
1187
if (field.has_numeric_options() &&
1188
field.numeric_options().is_autoincrement())
1190
destination.append(" AUTO_INCREMENT", 15);
1194
if (field.type() == Table::Field::BLOB ||
1195
field.type() == Table::Field::VARCHAR)
1197
if (field.string_options().has_collation())
1199
destination.append(" COLLATE ", 9);
1200
destination.append(field.string_options().collation());
1204
if (field.options().has_default_value())
1206
destination.append(" DEFAULT ", 9);
1207
destination.push_back(quoted_identifier);
1208
destination.append(field.options().default_value());
1209
destination.push_back(quoted_identifier);
1212
if (field.options().has_default_bin_value())
1214
const string &v= field.options().default_bin_value();
1215
destination.append(" DEFAULT 0x", 11);
1216
for (size_t x= 0; x < v.length(); x++)
1218
printf("%.2x", *(v.c_str() + x));
1222
if (field.type() == Table::Field::TIMESTAMP)
1223
if (field.timestamp_options().has_auto_updates() &&
1224
field.timestamp_options().auto_updates())
1225
destination.append(" ON UPDATE CURRENT_TIMESTAMP", 28);
1227
if (field.has_comment())
1229
destination.append(" COMMENT ", 9);
1230
destination.push_back(quoted_identifier);
1231
destination.append(field.comment());
1232
destination.push_back(quoted_identifier);
1237
bool shouldQuoteFieldValue(Table::Field::FieldType in_type)
615
const message::FieldMetadata &variable_metadata= statement.variable_metadata();
616
bool should_quote_field_value= message::shouldQuoteFieldValue(variable_metadata.type());
618
destination->append("SET GLOBAL "); /* Only global variables are replicated */
619
destination->append(variable_metadata.name());
620
destination->push_back('=');
622
if (should_quote_field_value)
623
destination->push_back('\'');
625
destination->append(statement.variable_value());
627
if (should_quote_field_value)
628
destination->push_back('\'');
633
bool message::shouldQuoteFieldValue(message::Table::Field::FieldType in_type)
1239
635
switch (in_type)
1241
case Table::Field::DOUBLE:
1242
case Table::Field::DECIMAL:
1243
case Table::Field::INTEGER:
1244
case Table::Field::BIGINT:
1245
case Table::Field::ENUM:
637
case message::Table::Field::DOUBLE:
638
case message::Table::Field::DECIMAL:
639
case message::Table::Field::INTEGER:
640
case message::Table::Field::BIGINT:
641
case message::Table::Field::ENUM:
1252
Table::Field::FieldType internalFieldTypeToFieldProtoType(enum enum_field_types type)
1255
case DRIZZLE_TYPE_LONG:
1256
return Table::Field::INTEGER;
1257
case DRIZZLE_TYPE_DOUBLE:
1258
return Table::Field::DOUBLE;
1259
case DRIZZLE_TYPE_NULL:
1260
assert(false); /* Not a user definable type */
1261
return Table::Field::INTEGER; /* unreachable */
1262
case DRIZZLE_TYPE_TIMESTAMP:
1263
return Table::Field::TIMESTAMP;
1264
case DRIZZLE_TYPE_LONGLONG:
1265
return Table::Field::BIGINT;
1266
case DRIZZLE_TYPE_DATETIME:
1267
return Table::Field::DATETIME;
1268
case DRIZZLE_TYPE_DATE:
1269
return Table::Field::DATE;
1270
case DRIZZLE_TYPE_VARCHAR:
1271
return Table::Field::VARCHAR;
1272
case DRIZZLE_TYPE_DECIMAL:
1273
return Table::Field::DECIMAL;
1274
case DRIZZLE_TYPE_ENUM:
1275
return Table::Field::ENUM;
1276
case DRIZZLE_TYPE_BLOB:
1277
return Table::Field::BLOB;
1281
return Table::Field::INTEGER; /* unreachable */
1284
bool transactionContainsBulkSegment(const Transaction &transaction)
1286
size_t num_statements= transaction.statement_size();
1287
if (num_statements == 0)
1291
* Only INSERT, UPDATE, and DELETE statements can possibly
1292
* have bulk segments. So, we loop through the statements
1293
* checking for segment_id > 1 in those specific submessages.
1296
for (x= 0; x < num_statements; ++x)
1298
const Statement &statement= transaction.statement(x);
1299
Statement::Type type= statement.type();
1303
case Statement::INSERT:
1304
if (statement.insert_data().segment_id() > 1)
1307
case Statement::UPDATE:
1308
if (statement.update_data().segment_id() > 1)
1311
case Statement::DELETE:
1312
if (statement.delete_data().segment_id() > 1)
1322
} /* namespace message */
1323
} /* namespace drizzled */