summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-03-22 15:48:06 +0200
committerunknown <monty@mysql.com>2005-03-22 15:48:06 +0200
commita99cb51c9d93d34eedbc08a9fca793855e3b9e05 (patch)
treec6c0d1b66f3806c56a502e647603e7e2566f6604 /sql
parent3e13c80a20379bb9c3d1d2005e8a408ed8ac5225 (diff)
downloadmariadb-git-a99cb51c9d93d34eedbc08a9fca793855e3b9e05.tar.gz
Hack to ensure that CHAR's created in 5.0 are not converted to VARCHAR even if the row type is dynamic
(For 4.1 tables old 'VARCHAR' fields are converted to true VARCHAR in the next ALTER TABLE) This ensures that one can use MySQL 5.0 privilege tables with MySQL 4.1 mysql-test/r/information_schema.result: Update results (for .frm version number change) mysql-test/r/ndb_autodiscover.result: Update results (for .frm version number change) mysql-test/r/ps_1general.result: Update results (for .frm version number change) mysql-test/r/show_check.result: Update results (for .frm version number change) mysql-test/r/view.result: Update results (for .frm version number change) scripts/fill_func_tables.sh: Ensure that no privilege tables that is used in 4.1 uses VARCHAR scripts/mysql_create_system_tables.sh: Ensure that no privilege tables that is used in 4.1 uses VARCHAR scripts/mysql_fix_privilege_tables.sh: Fixed bug that made it impossible to run the script from the mysql source dist scripts/mysql_fix_privilege_tables.sql: Ensure that no privilege tables that is used in 4.1 uses VARCHAR sql/sql_table.cc: Only set create_info->varchar if we are using the new VARCHAR field sql/table.cc: Hack to ensure that CHAR's created in 5.0 are not converted to VARCHAR even if the row type is dynamic (For 4.1 tables old 'VARCHAR' fields are converted to true VARCHAR in the next ALTER TABLE)
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_table.cc9
-rw-r--r--sql/table.cc10
2 files changed, 12 insertions, 7 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 82d887891cf..b125eeaf03a 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -613,7 +613,7 @@ int prepare_create_field(create_field *sql_field,
Prepares the table and key structures for table creation.
NOTES
- sets create_info->varchar if the table has a varchar or blob.
+ sets create_info->varchar if the table has a varchar
RETURN VALUES
0 ok
@@ -862,12 +862,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
&timestamps, &timestamps_with_niladic,
file->table_flags()))
DBUG_RETURN(-1);
- if (sql_field->sql_type == FIELD_TYPE_BLOB ||
- sql_field->sql_type == FIELD_TYPE_MEDIUM_BLOB ||
- sql_field->sql_type == FIELD_TYPE_TINY_BLOB ||
- sql_field->sql_type == FIELD_TYPE_LONG_BLOB ||
- sql_field->sql_type == FIELD_TYPE_GEOMETRY ||
- sql_field->sql_type == MYSQL_TYPE_VARCHAR)
+ if (sql_field->sql_type == MYSQL_TYPE_VARCHAR)
create_info->varchar= 1;
sql_field->offset= pos;
if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER)
diff --git a/sql/table.cc b/sql/table.cc
index 939690395d4..9238d8aa68e 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -149,6 +149,15 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
*fn_ext(index_file)='\0'; // Remove .frm extension
share->frm_version= head[2];
+ /*
+ Check if .frm file created by MySQL 5.0. In this case we want to
+ display CHAR fields as CHAR and not as VARCHAR.
+ We do it this way as we want to keep the old frm version to enable
+ MySQL 4.1 to read these files.
+ */
+ if (share->frm_version == FRM_VER_TRUE_VARCHAR -1 && head[33] == 5)
+ share->frm_version= FRM_VER_TRUE_VARCHAR;
+
share->db_type= ha_checktype((enum db_type) (uint) *(head+3));
share->db_create_options= db_create_options=uint2korr(head+30);
share->db_options_in_use= share->db_create_options;
@@ -1317,6 +1326,7 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo,
create_info->table_options|=HA_OPTION_LONG_BLOB_PTR; // Use portable blob pointers
int2store(fileinfo+30,create_info->table_options);
fileinfo[32]=0; // No filename anymore
+ fileinfo[33]=5; // Mark for 5.0 frm file
int4store(fileinfo+34,create_info->avg_row_length);
fileinfo[38]= (create_info->default_table_charset ?
create_info->default_table_charset->number : 0);