summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2003-08-23 12:25:39 +0300
committerunknown <monty@narttu.mysql.fi>2003-08-23 12:25:39 +0300
commitaf9b771a32e232788c82f34590c47037c194e177 (patch)
treea50d865d5c9b01effa00055eeb1048f1bfa5095f
parente3ceec7136aeac433a074dd923cc790af13b9546 (diff)
downloadmariadb-git-af9b771a32e232788c82f34590c47037c194e177.tar.gz
show symlinked directories in SHOW CREATE TABLE
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/mysqld.cc8
-rw-r--r--sql/sql_show.cc92
-rw-r--r--sql/sql_table.cc3
4 files changed, 65 insertions, 39 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index e31038d7fee..5e079c40974 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -194,6 +194,7 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
#define MODE_SERIALIZABLE 16
#define MODE_ONLY_FULL_GROUP_BY 32
#define MODE_NO_UNSIGNED_SUBTRACTION 64
+#define MODE_NO_DIR_IN_CREATE 128
#define RAID_BLOCK_SIZE 1024
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index ae5b46671a5..eaecb6e1aa3 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -433,8 +433,12 @@ time_t start_time;
ulong opt_sql_mode = 0L;
const char *sql_mode_names[] =
-{ "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
- "SERIALIZE","ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",NullS };
+{
+ "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
+ "SERIALIZE","ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",
+ "NO_DIR_IN_CREATE",
+ NullS
+};
TYPELIB sql_mode_typelib= {array_elements(sql_mode_names)-1,"",
sql_mode_names};
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 515c5da0422..6e7fe650247 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -27,8 +27,6 @@
#include "ha_berkeley.h" // For berkeley_show_logs
#endif
-/* extern "C" pthread_mutex_t THR_LOCK_keycache; */
-
static const char *grant_names[]={
"select","insert","update","delete","create","drop","reload","shutdown",
"process","file","grant","references","index","alter"};
@@ -817,17 +815,40 @@ append_identifier(THD *thd, String *packet, const char *name)
}
}
+
+/* Append directory name (if exists) to CREATE INFO */
+
+static void append_directory(THD *thd, String *packet, const char *dir_type,
+ const char *filename)
+{
+ uint length;
+ if (filename && !(thd->sql_mode & MODE_NO_DIR_IN_CREATE))
+ {
+ length= dirname_length(filename);
+ packet->append(' ');
+ packet->append(dir_type);
+ packet->append(" DIRECTORY='", 12);
+ packet->append(filename, length);
+ packet->append('\'');
+ }
+}
+
+
static int
store_create_info(THD *thd, TABLE *table, String *packet)
{
+ List<Item> field_list;
+ char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], *end;
+ String type(tmp, sizeof(tmp));
+ Field **ptr,*field;
+ uint primary_key;
+ KEY *key_info;
+ handler *file= table->file;
+ HA_CREATE_INFO create_info;
DBUG_ENTER("store_create_info");
DBUG_PRINT("enter",("table: %s",table->real_name));
restore_record(table,2); // Get empty record
-
- List<Item> field_list;
- char tmp[MAX_FIELD_WIDTH];
- String type(tmp, sizeof(tmp));
if (table->tmp_table)
packet->append("CREATE TEMPORARY TABLE ", 23);
else
@@ -835,13 +856,13 @@ store_create_info(THD *thd, TABLE *table, String *packet)
append_identifier(thd,packet,table->real_name);
packet->append(" (\n", 3);
- Field **ptr,*field;
for (ptr=table->field ; (field= *ptr); ptr++)
{
+ bool has_default;
+ uint flags = field->flags;
+
if (ptr != table->field)
packet->append(",\n", 2);
-
- uint flags = field->flags;
packet->append(" ", 2);
append_identifier(thd,packet,field->field_name);
packet->append(' ');
@@ -852,9 +873,9 @@ store_create_info(THD *thd, TABLE *table, String *packet)
field->sql_type(type);
packet->append(type.ptr(),type.length());
- bool has_default = (field->type() != FIELD_TYPE_BLOB &&
- field->type() != FIELD_TYPE_TIMESTAMP &&
- field->unireg_check != Field::NEXT_NUMBER);
+ has_default= (field->type() != FIELD_TYPE_BLOB &&
+ field->type() != FIELD_TYPE_TIMESTAMP &&
+ field->unireg_check != Field::NEXT_NUMBER);
if (flags & NOT_NULL_FLAG)
packet->append(" NOT NULL", 9);
@@ -880,9 +901,10 @@ store_create_info(THD *thd, TABLE *table, String *packet)
packet->append(" auto_increment", 15 );
}
- KEY *key_info=table->key_info;
- table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME);
- uint primary_key = table->primary_key;
+ key_info= table->key_info;
+ file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME);
+ file->update_create_info(&create_info);
+ primary_key= table->primary_key;
for (uint i=0 ; i < table->keys ; i++,key_info++)
{
@@ -918,7 +940,6 @@ store_create_info(THD *thd, TABLE *table, String *packet)
table->field[key_part->fieldnr-1]->key_length() &&
!(key_info->flags & HA_FULLTEXT)))
{
- char buff[64];
buff[0] = '(';
char* end=int10_to_str((long) key_part->length, buff + 1,10);
*end++ = ')';
@@ -928,43 +949,38 @@ store_create_info(THD *thd, TABLE *table, String *packet)
packet->append(')');
}
- 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));
+ /*
+ Get possible foreign key definitions stored in InnoDB and append them
+ to the CREATE TABLE statement
+ */
- file->free_foreign_key_create_info(for_str);
+ if ((for_str= file->get_foreign_key_create_info()))
+ {
+ 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];
- char* p;
if (table->min_rows)
{
packet->append(" MIN_ROWS=");
- p = longlong10_to_str(table->min_rows, buff, 10);
- packet->append(buff, (uint) (p - buff));
+ end= longlong10_to_str(table->min_rows, buff, 10);
+ packet->append(buff, (uint) (end- buff));
}
-
if (table->max_rows)
{
packet->append(" MAX_ROWS=");
- p = longlong10_to_str(table->max_rows, buff, 10);
- packet->append(buff, (uint) (p - buff));
+ end= longlong10_to_str(table->max_rows, buff, 10);
+ packet->append(buff, (uint) (end - buff));
}
if (table->avg_row_length)
{
packet->append(" AVG_ROW_LENGTH=");
- p=longlong10_to_str(table->avg_row_length, buff,10);
- packet->append(buff, (uint) (p - buff));
+ end= longlong10_to_str(table->avg_row_length, buff,10);
+ packet->append(buff, (uint) (end - buff));
}
if (table->db_create_options & HA_OPTION_PACK_KEYS)
@@ -989,11 +1005,13 @@ store_create_info(THD *thd, TABLE *table, String *packet)
}
if (file->raid_type)
{
- char buff[100];
sprintf(buff," RAID_TYPE=%s RAID_CHUNKS=%d RAID_CHUNKSIZE=%ld",
- my_raid_type(file->raid_type), file->raid_chunks, file->raid_chunksize/RAID_BLOCK_SIZE);
+ my_raid_type(file->raid_type), file->raid_chunks,
+ file->raid_chunksize/RAID_BLOCK_SIZE);
packet->append(buff);
}
+ append_directory(thd, packet, "DATA", create_info.data_file_name);
+ append_directory(thd, packet, "INDEX", create_info.index_file_name);
DBUG_RETURN(0);
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index c55015f7aa5..79105a94dec 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -747,7 +747,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
thd->proc_info="creating table";
+ if (thd->sql_mode & MODE_NO_DIR_IN_CREATE)
+ create_info->data_file_name= create_info->index_file_name= 0;
create_info->table_options=db_options;
+
if (rea_create_table(path, create_info, fields, key_count,
key_info_buffer))
{