Commit 4fc3e7a2 authored by unknown's avatar unknown

sql_show.cc SHOW CREATE now return nicely formatted statement


sql/sql_show.cc:
  SHOW CREATE now return nicely formatted statement
parent b1e54642
......@@ -680,17 +680,18 @@ store_create_info(THD *thd, TABLE *table, String* packet)
List<Item> field_list;
char tmp[MAX_FIELD_WIDTH];
String type(tmp, sizeof(tmp));
packet->append("create table ", 13);
packet->append("CREATE TABLE ", 13);
packet->append(table->real_name);
packet->append('(');
packet->append(" (\n", 3);
Field **ptr,*field;
for (ptr=table->field ; (field= *ptr); ptr++)
{
if(ptr != table->field)
packet->append(',');
packet->append(",\n", 2);
uint flags = field->flags;
packet->append(" ", 2);
packet->append(field->field_name);
packet->append(' ');
// check for surprises from the previous call to Field::sql_type()
......@@ -705,8 +706,7 @@ store_create_info(THD *thd, TABLE *table, String* packet)
bool has_default = (field->type() != FIELD_TYPE_BLOB);
if((flags & NOT_NULL_FLAG) && !null_default_value)
packet->append(" not null", 9);
packet->append(" NOT NULL", 9);
if(has_default)
{
......@@ -727,8 +727,6 @@ store_create_info(THD *thd, TABLE *table, String* packet)
if (field->unireg_check == Field::NEXT_NUMBER)
packet->append(" auto_increment", 15 );
}
KEY *key_info=table->key_info;
......@@ -737,16 +735,16 @@ store_create_info(THD *thd, TABLE *table, String* packet)
for (uint i=0 ; i < table->keys ; i++,key_info++)
{
packet->append(',');
packet->append(",\n ", 4);
KEY_PART_INFO *key_part= key_info->key_part;
if(i == primary_key)
packet->append("primary", 7);
packet->append("PRIMARY ", 8);
else if(key_info->flags & HA_NOSAME)
packet->append("unique", 6);
packet->append("UNIQUE ", 7);
else if(key_info->flags & HA_FULLTEXT)
packet->append("fulltext", 8);
packet->append(" key ", 5);
packet->append("FULLTEXT ", 9);
packet->append("KEY ", 4);
if(i != primary_key)
packet->append(key_info->name);
......@@ -774,40 +772,38 @@ store_create_info(THD *thd, TABLE *table, String* packet)
packet->append(buff,(uint) (end-buff));
}
}
packet->append(')');
}
packet->append(')');
packet->append("\n)", 2);
handler *file = table->file;
packet->append(" type=", 6);
packet->append(" TYPE=", 6);
packet->append(file->table_type());
char buff[128];
char* p;
if(table->min_rows)
{
packet->append(" min_rows=");
packet->append(" MIN_ROWS=");
p = longlong10_to_str(table->min_rows, buff, 10);
packet->append(buff, (uint) (p - buff));
}
if(table->max_rows)
{
packet->append(" max_rows=");
packet->append(" MAX_ROWS=");
p = longlong10_to_str(table->max_rows, buff, 10);
packet->append(buff, (uint) (p - buff));
}
if (table->db_create_options & HA_OPTION_PACK_KEYS)
packet->append(" pack_keys=1", 12);
packet->append(" PACK_KEYS=1", 12);
if (table->db_create_options & HA_OPTION_NO_PACK_KEYS)
packet->append(" pack_keys=0", 12);
packet->append(" PACK_KEYS=0", 12);
if (table->db_create_options & HA_OPTION_CHECKSUM)
packet->append(" checksum=1", 11);
packet->append(" CHECKSUM=1", 11);
if (table->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
packet->append(" delay_key_write=1",18);
packet->append(" DELAY_KEY_WRITE=1",18);
DBUG_RETURN(0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment