~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/foreign_key.cc

  • Committer: Stewart Smith
  • Date: 2010-07-27 00:49:32 UTC
  • mto: (1720.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 1721.
  • Revision ID: stewart@flamingspork.com-20100727004932-basq3vx9szmmbswm
fix storing and manipulating foreign keys in the proto around ALTER TABLE, CREATE TABLE and ALTER TABLE ADD/DROP FOREIGN KEY. We also (mostly) emulate the naming of innodb foreign keys in the upper layer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
  message::Table::ForeignKeyConstraint *pfkey= table_message->add_fk_constraint();
46
46
  if (fkey_name)
47
47
    pfkey->set_name(fkey_name);
 
48
  else if (table_message->has_name())
 
49
  {
 
50
    std::string name(table_message->name());
 
51
    char number[20];
 
52
 
 
53
    name.append("_ibfk_");
 
54
    snprintf(number, sizeof(number), "%d", table_message->fk_constraint_size());
 
55
    name.append(number);
 
56
 
 
57
    pfkey->set_name(name);
 
58
  }
48
59
 
49
60
  pfkey->set_match(match_opt_arg);
50
61
  pfkey->set_update_option(update_opt_arg);