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.
This commit is contained in:
unknown 2003-09-10 17:25:26 +05:00
parent af1c7280f4
commit fef3c15a05
3 changed files with 25 additions and 21 deletions

View File

@ -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)
{

View File

@ -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,

View File

@ -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
*/