diff options
author | bar@bar.mysql.r18.ru <> | 2003-09-10 17:25:26 +0500 |
---|---|---|
committer | bar@bar.mysql.r18.ru <> | 2003-09-10 17:25:26 +0500 |
commit | 6fa45cec53bc395cc606bb9bfcae254965c2b3ce (patch) | |
tree | e1c0456f893a157e9537bb89cf9b3d20b3635c4d | |
parent | d9ef1585d1db58a98dd33ad37ac60befb47b99d1 (diff) | |
download | mariadb-git-6fa45cec53bc395cc606bb9bfcae254965c2b3ce.tar.gz |
mysql_create_table now accepts field lengths in CREATE form, not in internal form.
This is to simplify fixing indexes to mean number of chars rather than bytes too.
-rw-r--r-- | sql/field.cc | 21 | ||||
-rw-r--r-- | sql/sql_parse.cc | 8 | ||||
-rw-r--r-- | sql/sql_table.cc | 17 |
3 files changed, 25 insertions, 21 deletions
diff --git a/sql/field.cc b/sql/field.cc index 051a4fa8057..441dc1ddb60 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5480,6 +5480,27 @@ create_field::create_field(Field *old_field,Field *orig_field) if (flags & BLOB_FLAG) pack_length= (pack_length- old_field->table->blob_ptr_size + portable_sizeof_char_ptr); + + switch (sql_type) + { + case FIELD_TYPE_BLOB: + switch (pack_length - portable_sizeof_char_ptr) + { + case 1: sql_type= FIELD_TYPE_TINY_BLOB; break; + case 2: sql_type= FIELD_TYPE_BLOB; break; + case 3: sql_type= FIELD_TYPE_MEDIUM_BLOB; break; + default: sql_type= FIELD_TYPE_LONG_BLOB; break; + } + length /= charset->mbmaxlen; + break; + case FIELD_TYPE_STRING: + case FIELD_TYPE_VAR_STRING: + length /= charset->mbmaxlen; + break; + default: + break; + } + decimals= old_field->decimals(); if (sql_type == FIELD_TYPE_STRING) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ff66892262d..fc533f9619b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2050,14 +2050,6 @@ mysql_execute_command(THD *thd) (Table_ident *)lex->name); else { - List_iterator<create_field> fields(lex->create_list); - create_field *field; - while ((field= fields++)) - { - if (!field->charset) - field->charset= lex->create_info.table_charset; - field->create_length_to_internal_length(); - } res= mysql_create_table(thd,tables->db ? tables->db : thd->db, tables->real_name, &lex->create_info, lex->create_list, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6ea7003eba6..571ee371721 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -422,6 +422,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, for (field_no=0; (sql_field=it++) ; field_no++) { + if (!sql_field->charset) + sql_field->charset= create_info->table_charset; + sql_field->create_length_to_internal_length(); + /* Don't pack keys in old tables if the user has requested this */ if ((sql_field->flags & BLOB_FLAG) || sql_field->sql_type == FIELD_TYPE_VAR_STRING && @@ -1916,19 +1920,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, List<Key> key_list; // Add new keys here create_field *def; - /* - For each column set charset to the table - default if the column charset hasn't been specified - explicitely. Change CREATE length into internal length - */ - def_it.rewind(); - while ((def= def_it++)) - { - if (!def->charset) - def->charset= create_info->table_charset; - def->create_length_to_internal_length(); - } - /* First collect all fields from table which isn't in drop_list */ |