Commit 1f142262 authored by heikki@hundin.mysql.fi's avatar heikki@hundin.mysql.fi
Browse files

sql_show.cc, handler.h, handler.cc:

  Add foreign key defs to SHOW CREATE TABLE
parent e90a57aa
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -260,13 +260,13 @@ int ha_autocommit_or_rollback(THD *thd, int error)
/*
  This function is called when MySQL writes the log segment of a
  transaction to the binlog. It is called when the LOCK_log mutex is
  reserved. Here we communicate to transactional table handlers whta
  reserved. Here we communicate to transactional table handlers what
  binlog position corresponds to the current transaction. The handler
  can store it and in recovery print to the user, so that the user
  knows from what position in the binlog to start possible
  roll-forward, for example, if the crashed server was a slave in
  replication. This function also calls the commit of the table
  handler, because the order of trasnactions in the log of the table
  handler, because the order of transactions in the log of the table
  handler must be the same as in the binlog.

  arguments:
@@ -298,7 +298,6 @@ int ha_report_binlog_offset_and_commit(THD *thd,
  return error;
}


int ha_commit_trans(THD *thd, THD_TRANS* trans)
{
  int error=0;
+3 −1
Original line number Diff line number Diff line
@@ -294,7 +294,9 @@ class handler :public Sql_alloc
  virtual char *update_table_comment(const char * comment)
  { return (char*) comment;}
  virtual void append_create_info(String *packet) {}

  virtual char* get_foreign_key_create_info()
  { return(NULL);}  /* gets foreign key create string from InnoDB */
  virtual void free_foreign_key_create_info(char* str) {} 
  /* The following can be called without an open handler */
  virtual const char *table_type() const =0;
  virtual const char **bas_ext() const =0;
+13 −1
Original line number Diff line number Diff line
@@ -889,9 +889,21 @@ store_create_info(THD *thd, TABLE *table, String *packet)
    }
    packet->append(')');
  }
  packet->append("\n)", 2);

  handler *file = table->file;

  /* Get possible foreign key definitions stored in InnoDB and append them
  to the CREATE TABLE statement */

  char* for_str = file->get_foreign_key_create_info();

  if (for_str) {
  	packet->append(for_str, strlen(for_str));

  	file->free_foreign_key_create_info(for_str);
  }

  packet->append("\n)", 2);
  packet->append(" TYPE=", 6);
  packet->append(file->table_type());
  char buff[128];