summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
diff options
context:
space:
mode:
authorMagnus Blåudd <magnus.blaudd@oracle.com>2011-03-04 09:41:29 +0100
committerMagnus Blåudd <magnus.blaudd@oracle.com>2011-03-04 09:41:29 +0100
commit6c85d6535781870e9d35a0f00ace9ef42edf3e90 (patch)
tree91078f8e09a7d3bf446e8c6c1896bde1a0a20ad7 /sql/unireg.cc
parent44b41979bd4767ccffa6450ccfcf331d3bad7b9b (diff)
downloadmariadb-git-6c85d6535781870e9d35a0f00ace9ef42edf3e90.tar.gz
Bug#60111 storage type for table not saved in .frm
- Add new "format section" in extra data segment with additional table and column properties. This was originally introduced in 5.1.20 based MySQL Cluster - Remove hardcoded STORAGE DISK for table and instead output the real storage format used. Keep both TABLESPACE and STORAGE inside same version guard. - Implement default version of handler::get_tablespace_name() since tablespace is now available in share and it's unnecessary for each handler to implement. (the function could actually be removed totally now). - Add test for combinations of TABLESPACE and STORAGE with CREATE TABLE and ALTER TABLE - Add test to show that 5.5 now can read a .frm file created by MySQL Cluster 7.0.22. Although it does not yet show the column level attributes, they are read.
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r--sql/unireg.cc64
1 files changed, 64 insertions, 0 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 6433b8bc7c2..5a44c5e68f5 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -124,6 +124,9 @@ bool mysql_create_frm(THD *thd, const char *file_name,
#endif
Pack_header_error_handler pack_header_error_handler;
int error;
+ const uint format_section_header_size= 8;
+ uint format_section_length;
+ uint tablespace_length= 0;
DBUG_ENTER("mysql_create_frm");
DBUG_ASSERT(*fn_rext((char*)file_name)); // Check .frm extension
@@ -256,6 +259,18 @@ bool mysql_create_frm(THD *thd, const char *file_name,
forminfo[46]=(uchar) create_info->comment.length;
}
+ /*
+ Add room in extra segment for "format section" with additional
+ table and column properties
+ */
+ if (create_info->tablespace)
+ tablespace_length= strlen(create_info->tablespace);
+ format_section_length=
+ format_section_header_size +
+ tablespace_length + 1 +
+ create_fields.elements;
+ create_info->extra_size+= format_section_length;
+
if ((file=create_frm(thd, file_name, db, table, reclength, fileinfo,
create_info, keys, key_info)) < 0)
{
@@ -353,6 +368,55 @@ bool mysql_create_frm(THD *thd, const char *file_name,
goto err;
}
+ /* "Format section" with additional table and column properties */
+ {
+ uchar *ptr, *format_section_buff;
+ if (!(format_section_buff=(uchar*) my_malloc(format_section_length,
+ MYF(MY_WME))))
+ goto err;
+ ptr= format_section_buff;
+
+ /* header */
+ const uint format_section_flags=
+ create_info->storage_media; // 3 bits
+ const uint format_section_unused= 0;
+ int2store(ptr+0, format_section_length);
+ int4store(ptr+2, format_section_flags);
+ int2store(ptr+6, format_section_unused);
+ ptr+= format_section_header_size;
+
+ /* tablespace name */
+ if (tablespace_length > 0)
+ memcpy(ptr, create_info->tablespace, tablespace_length);
+ ptr+= tablespace_length;
+ *ptr= 0; /* tablespace string terminating zero */
+ ptr++;
+
+ /* column properties */
+ Create_field *field;
+ List_iterator<Create_field> it(create_fields);
+ while ((field=it++))
+ {
+ const uchar field_storage= 0; /* Used in MySQL Cluster */
+ const uchar field_column_format= 0; /* Used in MySQL Cluster */
+ const uchar field_flags=
+ field_storage + (field_column_format << COLUMN_FORMAT_SHIFT);
+ *ptr= field_flags;
+ ptr++;
+ }
+ DBUG_ASSERT(format_section_buff + format_section_length == ptr);
+
+ if (mysql_file_write(file, format_section_buff,
+ format_section_length, MYF_RW))
+ {
+ my_free(format_section_buff);
+ goto err;
+ }
+ DBUG_PRINT("info", ("wrote format section, length: %u",
+ format_section_length));
+ my_free(format_section_buff);
+ }
+
mysql_file_seek(file, filepos, MY_SEEK_SET, MYF(0));
if (mysql_file_write(file, forminfo, 288, MYF_RW) ||
mysql_file_write(file, screen_buff, info_length, MYF_RW) ||