~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Stewart Smith
  • Date: 2010-07-13 01:12:39 UTC
  • mto: (1638.10.46)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: stewart@flamingspork.com-20100713011239-nwgjq3r0oxtaax0w
use the ENUM in the table proto instead of duplicating it for Foreign key options and match option. A move in the direction of just having foreign keys in the proto

Show diffs side-by-side

added added

removed removed

Lines of Context:
574
574
  return 0;
575
575
}
576
576
 
577
 
static message::Table::ForeignKeyConstraint::ForeignKeyOption fk_option_to_proto_option(uint32_t option)
578
 
{
579
 
  switch (option)
580
 
  {
581
 
  case Foreign_key::FK_OPTION_UNDEF:
582
 
    return message::Table::ForeignKeyConstraint::OPTION_UNDEF;
583
 
  case Foreign_key::FK_OPTION_RESTRICT:
584
 
    return message::Table::ForeignKeyConstraint::OPTION_RESTRICT;
585
 
  case Foreign_key::FK_OPTION_CASCADE:
586
 
    return message::Table::ForeignKeyConstraint::OPTION_CASCADE;
587
 
  case Foreign_key::FK_OPTION_SET_NULL:
588
 
    return message::Table::ForeignKeyConstraint::OPTION_SET_NULL;
589
 
  case Foreign_key::FK_OPTION_NO_ACTION:
590
 
    return message::Table::ForeignKeyConstraint::OPTION_NO_ACTION;
591
 
  case Foreign_key::FK_OPTION_DEFAULT:
592
 
    return message::Table::ForeignKeyConstraint::OPTION_DEFAULT;
593
 
  }
594
 
 
595
 
  assert(false);
596
 
 
597
 
  return message::Table::ForeignKeyConstraint::OPTION_UNDEF;
598
 
}
599
 
 
600
577
static int mysql_prepare_create_table(Session *session,
601
578
                                      HA_CREATE_INFO *create_info,
602
579
                                      message::Table &create_proto,
915
892
      message::Table::ForeignKeyConstraint *pfkey= create_proto.add_fk_constraint();
916
893
      if (fk_key->name.str)
917
894
        pfkey->set_name(fk_key->name.str);
918
 
      switch (fk_key->match_opt)
919
 
      {
920
 
      case Foreign_key::FK_MATCH_UNDEF:
921
 
        pfkey->set_match(message::Table::ForeignKeyConstraint::MATCH_UNDEFINED);
922
 
        break;
923
 
      case Foreign_key::FK_MATCH_FULL:
924
 
        pfkey->set_match(message::Table::ForeignKeyConstraint::MATCH_FULL);
925
 
        break;
926
 
      case Foreign_key::FK_MATCH_PARTIAL:
927
 
        pfkey->set_match(message::Table::ForeignKeyConstraint::MATCH_PARTIAL);
928
 
        break;
929
 
      case Foreign_key::FK_MATCH_SIMPLE:
930
 
        pfkey->set_match(message::Table::ForeignKeyConstraint::MATCH_SIMPLE);
931
 
        break;
932
 
      }
933
 
      pfkey->set_update_option(fk_option_to_proto_option(fk_key->update_opt));
934
 
      pfkey->set_delete_option(fk_option_to_proto_option(fk_key->delete_opt));
 
895
 
 
896
      pfkey->set_match(fk_key->match_opt);
 
897
      pfkey->set_update_option(fk_key->update_opt);
 
898
      pfkey->set_delete_option(fk_key->delete_opt);
935
899
 
936
900
      pfkey->set_references_table_name(fk_key->ref_table->table.str);
937
901