summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-12-07 15:47:00 +0200
committerunknown <monty@mysql.com>2004-12-07 15:47:00 +0200
commit9ca50fe1446e3fa955ea0adeefc077b674f36112 (patch)
treeb1c918186908fb490aa860c35dc9e2154aa633c8 /sql
parent8379b61efb053da778846416baf23812a26e8f86 (diff)
downloadmariadb-git-9ca50fe1446e3fa955ea0adeefc077b674f36112.tar.gz
Update results for new varchar handling
Fixed compiler warnings String results in CREATE ... SELECT are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length myisam/myisampack.c: Indentation cleanup mysql-test/r/analyse.result: Update results for new varchar handling mysql-test/r/case.result: Update results for new varchar handling mysql-test/r/cast.result: Update results for new varchar handling mysql-test/r/create.result: Update results for new varchar handling mysql-test/r/ctype_mb.result: Update results for new varchar handling mysql-test/r/ctype_ucs.result: Update results for new varchar handling mysql-test/r/ctype_utf8.result: Update results for new varchar handling mysql-test/r/func_group.result: Update results for new varchar handling mysql-test/r/func_str.result: Update results for new varchar handling mysql-test/r/func_system.result: Update results for new varchar handling mysql-test/r/heap.result: Update results for new varchar handling mysql-test/r/heap_hash.result: Update results for new varchar handling mysql-test/r/information_schema.result: Update results for new varchar handling mysql-test/r/metadata.result: Update results for new varchar handling mysql-test/r/null.result: Update results for new varchar handling mysql-test/r/ps_2myisam.result: Update results for new varchar handling mysql-test/r/ps_3innodb.result: Update results for new varchar handling mysql-test/r/ps_4heap.result: Update results for new varchar handling mysql-test/r/ps_5merge.result: Update results for new varchar handling mysql-test/r/ps_6bdb.result: Update results for new varchar handling mysql-test/r/subselect.result: Update results for new varchar handling mysql-test/r/type_ranges.result: Update results for new varchar handling mysql-test/r/union.result: Update results for new varchar handling mysql-test/t/heap.test: Update results for new varchar handling mysql-test/t/type_ranges.test: Added extra test to test generated type for string functions sql/field.cc: Update results for new varchar handling sql/field.h: Update results for new varchar handling We have to use orig_table instead of table as 'table' may point to a new field in the created table sql/field_conv.cc: Update results for new varchar handling sql/ha_heap.cc: Indentation fixes sql/ha_innodb.cc: Update results for new varchar handling sql/item.cc: Update results for new varchar handling Remove compiler warnings String results in CREATE ... SELECT are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length sql/item.h: Update results for new varchar handling sql/item_func.cc: Update results for new varchar handling String results in CREATE ... SELECT are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length sql/item_func.h: ANALYZE now return VARCHAR columns sql/procedure.h: Update results for new varchar handling sql/sql_acl.cc: After merge fixes sql/sql_select.cc: Update results for new varchar handling String results in temporary tables are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length sql/sql_show.cc: After merge fixes sql/sql_table.cc: After merge fixes strings/ctype-tis620.c: After merge fixes tests/client_test.c: Fixed results, as in MySQL 5.0 strings in CREATE ... SELECT are creates VARCHAR columns
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc8
-rw-r--r--sql/field.h6
-rw-r--r--sql/field_conv.cc3
-rw-r--r--sql/ha_heap.cc5
-rw-r--r--sql/ha_innodb.cc4
-rw-r--r--sql/item.cc67
-rw-r--r--sql/item.h5
-rw-r--r--sql/item_func.cc10
-rw-r--r--sql/item_func.h2
-rw-r--r--sql/procedure.h2
-rw-r--r--sql/sql_acl.cc3
-rw-r--r--sql/sql_select.cc37
-rw-r--r--sql/sql_show.cc22
-rw-r--r--sql/sql_table.cc22
14 files changed, 104 insertions, 92 deletions
diff --git a/sql/field.cc b/sql/field.cc
index c06b7006a2b..73f442a868e 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -429,7 +429,9 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
copy->length-=table->blob_ptr_size;
return copy->length;
}
- else if (!zero_pack() && (type() == FIELD_TYPE_STRING && copy->length >= 4))
+ else if (!zero_pack() &&
+ (type() == MYSQL_TYPE_STRING && copy->length >= 4 &&
+ copy->length < 256))
copy->strip=1; /* Remove end space */
else
copy->strip=0;
@@ -6075,7 +6077,7 @@ uint32 calc_pack_length(enum_field_types type,uint32 length)
{
switch (type) {
case MYSQL_TYPE_VAR_STRING:
- case FIELD_TYPE_STRING:
+ case MYSQL_TYPE_STRING:
case FIELD_TYPE_DECIMAL: return (length);
case MYSQL_TYPE_VARCHAR: return (length+HA_KEY_BLOB_LENGTH);
case FIELD_TYPE_YEAR:
@@ -6294,7 +6296,7 @@ create_field::create_field(Field *old_field,Field *orig_field)
length=(length+charset->mbmaxlen-1) / charset->mbmaxlen;
key_length/= charset->mbmaxlen;
break;
- case FIELD_TYPE_STRING:
+ case MYSQL_TYPE_STRING:
/* Change CHAR -> VARCHAR if dynamic record length */
if (old_field->type() == MYSQL_TYPE_VAR_STRING)
sql_type= MYSQL_TYPE_VARCHAR;
diff --git a/sql/field.h b/sql/field.h
index 058c386954f..4353780f9a4 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -888,8 +888,10 @@ public:
enum_field_types type() const
{
- return ((table && table->db_create_options & HA_OPTION_PACK_RECORD &&
- field_length >= 4) && table->frm_version < FRM_VER_TRUE_VARCHAR ?
+ return ((orig_table &&
+ orig_table->db_create_options & HA_OPTION_PACK_RECORD &&
+ field_length >= 4) &&
+ orig_table->frm_version < FRM_VER_TRUE_VARCHAR ?
MYSQL_TYPE_VAR_STRING : MYSQL_TYPE_STRING);
}
enum ha_base_keytype key_type() const
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index c4dbb9ab647..f6cc851639a 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -572,7 +572,8 @@ void field_conv(Field *to,Field *from)
Field_blob *blob=(Field_blob*) to;
from->val_str(&blob->value);
if (!blob->value.is_alloced() &&
- from->real_type() != FIELD_TYPE_STRING)
+ from->real_type() != MYSQL_TYPE_STRING &&
+ from->real_type() != MYSQL_TYPE_VARCHAR)
blob->value.copy();
blob->store(blob->value.ptr(),blob->value.length(),from->charset());
return;
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index 29508207a70..60555d51402 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -98,6 +98,7 @@ void ha_heap::set_keys_for_scanning(void)
}
}
+
void ha_heap::update_key_stats()
{
for (uint i= 0; i < table->keys; i++)
@@ -113,6 +114,7 @@ void ha_heap::update_key_stats()
records_changed= 0;
}
+
int ha_heap::write_row(byte * buf)
{
int res;
@@ -439,8 +441,7 @@ ha_rows ha_heap::records_in_range(uint inx, key_range *min_key,
min_key->flag != HA_READ_KEY_EXACT ||
max_key->flag != HA_READ_AFTER_KEY)
return HA_POS_ERROR; // Can only use exact keys
- else
- return key->rec_per_key[key->key_parts-1];
+ return key->rec_per_key[key->key_parts-1];
}
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index f387b79ac2d..0c7fc23ee49 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -2009,7 +2009,7 @@ innobase_mysql_cmp(
switch (mysql_tp) {
- case FIELD_TYPE_STRING:
+ case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_MEDIUM_BLOB:
@@ -2085,7 +2085,7 @@ get_innobase_type_from_mysql_type(
} else {
return(DATA_VARMYSQL);
}
- case FIELD_TYPE_STRING: if (field->binary()) {
+ case MYSQL_TYPE_STRING: if (field->binary()) {
return(DATA_FIXBINARY);
} else if (strcmp(
diff --git a/sql/item.cc b/sql/item.cc
index d40721e9ae2..f00a35fe628 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -161,24 +161,27 @@ void Item::rename(char *new_name)
Item_ident::Item_ident(const char *db_name_par,const char *table_name_par,
const char *field_name_par)
:orig_db_name(db_name_par), orig_table_name(table_name_par),
- orig_field_name(field_name_par), alias_name_used(FALSE),
- db_name(db_name_par), table_name(table_name_par),
- field_name(field_name_par), cached_field_index(NO_CACHED_FIELD_INDEX),
+ orig_field_name(field_name_par),
+ db_name(db_name_par), table_name(table_name_par),
+ field_name(field_name_par),
+ alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),
cached_table(0), depended_from(0)
{
name = (char*) field_name_par;
}
-// Constructor used by Item_field & Item_ref (see Item comment)
+
+/* Constructor used by Item_field & Item_ref (see Item comment) */
+
Item_ident::Item_ident(THD *thd, Item_ident *item)
:Item(thd, item),
orig_db_name(item->orig_db_name),
orig_table_name(item->orig_table_name),
orig_field_name(item->orig_field_name),
- alias_name_used(item->alias_name_used),
db_name(item->db_name),
table_name(item->table_name),
field_name(item->field_name),
+ alias_name_used(item->alias_name_used),
cached_field_index(item->cached_field_index),
cached_table(item->cached_table),
depended_from(item->depended_from)
@@ -979,12 +982,13 @@ default_set_param_func(Item_param *param,
param->set_null();
}
+
Item_param::Item_param(unsigned pos_in_query_arg) :
state(NO_VALUE),
item_result_type(STRING_RESULT),
/* Don't pretend to be a literal unless value for this item is set. */
item_type(PARAM_ITEM),
- param_type(MYSQL_TYPE_STRING),
+ param_type(MYSQL_TYPE_VARCHAR),
pos_in_query(pos_in_query_arg),
set_param_func(default_set_param_func)
{
@@ -997,6 +1001,7 @@ Item_param::Item_param(unsigned pos_in_query_arg) :
maybe_null= 1;
}
+
void Item_param::set_null()
{
DBUG_ENTER("Item_param::set_null");
@@ -2249,6 +2254,33 @@ enum_field_types Item::field_type() const
/*
+ Create a field to hold a string value from an item
+
+ SYNOPSIS
+ make_string_field()
+ table Table for which the field is created
+
+ IMPLEMENTATION
+ If max_length > CONVERT_IF_BIGGER_TO_BLOB create a blob
+ If max_length > 0 create a varchar
+ If max_length == 0 create a CHAR(0)
+*/
+
+
+Field *Item::make_string_field(TABLE *table)
+{
+ if (max_length > CONVERT_IF_BIGGER_TO_BLOB)
+ return new Field_blob(max_length, maybe_null, name, table,
+ collation.collation);
+ if (max_length > 0)
+ return new Field_varstring(max_length, maybe_null, name, table,
+ collation.collation);
+ return new Field_string(max_length, maybe_null, name, table,
+ collation.collation);
+}
+
+
+/*
Create a field based on field_type of argument
For now, this is only used to create a field for
@@ -2308,37 +2340,24 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table)
return new Field_year((char*) 0, max_length, null_ptr, 0, Field::NONE,
name, table);
default:
- /* This case should never be choosen */
+ /* This case should never be chosen */
DBUG_ASSERT(0);
/* If something goes awfully wrong, it's better to get a string than die */
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
+ case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
- if (max_length > MAX_FIELD_CHARLENGTH)
- break; // convert to blob
- return new Field_varstring(max_length, maybe_null, name, table,
- collation.collation);
case MYSQL_TYPE_VARCHAR:
- if (max_length > CONVERT_IF_BIGGER_TO_BLOB)
- break; // convert to blob
- return new Field_varstring(max_length, maybe_null, name, table,
- collation.collation);
- case MYSQL_TYPE_STRING:
- if (max_length > MAX_FIELD_CHARLENGTH) // If blob
- break;
- return new Field_string(max_length, maybe_null, name, table,
- collation.collation);
+ return make_string_field(table);
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_GEOMETRY:
+ return new Field_blob(max_length, maybe_null, name, table,
+ collation.collation);
break; // Blob handled outside of case
}
-
- /* blob is special as it's generated for both blobs and long strings */
- return new Field_blob(max_length, maybe_null, name, table,
- collation.collation);
}
diff --git a/sql/item.h b/sql/item.h
index 973039f9127..cf3dc8896a5 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -173,6 +173,7 @@ public:
void init_make_field(Send_field *tmp_field,enum enum_field_types type);
virtual void cleanup();
virtual void make_field(Send_field *field);
+ Field *make_string_field(TABLE *table);
virtual bool fix_fields(THD *, struct st_table_list *, Item **);
/*
should be used in case where we are sure that we do not need
@@ -894,7 +895,7 @@ public:
}
int save_in_field(Field *field, bool no_conversions);
enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_STRING; }
+ enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
bool basic_const_item() const { return 1; }
bool eq(const Item *item, bool binary_cmp) const;
Item *new_item()
@@ -970,7 +971,7 @@ public:
String *val_str(String*) { DBUG_ASSERT(fixed == 1); return &str_value; }
int save_in_field(Field *field, bool no_conversions);
enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_STRING; }
+ enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
// to prevent drop fixed flag (no need parent cleanup call)
void cleanup() {}
};
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 8fefb355efe..aba53b9b397 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -481,6 +481,7 @@ bool Item_func::eq(const Item *item, bool binary_cmp) const
return 1;
}
+
Field *Item_func::tmp_table_field(TABLE *t_arg)
{
Field *res;
@@ -499,10 +500,7 @@ Field *Item_func::tmp_table_field(TABLE *t_arg)
res= new Field_double(max_length, maybe_null, name, t_arg, decimals);
break;
case STRING_RESULT:
- if (max_length > 255)
- res= new Field_blob(max_length, maybe_null, name, t_arg, collation.collation);
- else
- res= new Field_string(max_length, maybe_null, name, t_arg, collation.collation);
+ res= make_string_field(t_arg);
break;
case ROW_RESULT:
default:
@@ -3565,6 +3563,7 @@ Item_func_sp::execute(Item **itp)
DBUG_RETURN(res);
}
+
enum enum_field_types
Item_func_sp::field_type() const
{
@@ -3578,9 +3577,10 @@ Item_func_sp::field_type() const
DBUG_RETURN(m_sp->m_returns);
}
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", m_name->m_qname.str);
- DBUG_RETURN(MYSQL_TYPE_STRING);
+ DBUG_RETURN(MYSQL_TYPE_VARCHAR);
}
+
Item_result
Item_func_sp::result_type() const
{
diff --git a/sql/item_func.h b/sql/item_func.h
index 241240a49ca..4657ee81dfb 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -986,7 +986,7 @@ public:
We must always return variables as strings to guard against selects of type
select @t1:=1,@t1,@t:="hello",@t from foo where (@t1:= t2.b)
*/
- enum_field_types field_type() const { return MYSQL_TYPE_STRING; }
+ enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
const char *func_name() const { return "get_user_var"; }
bool const_item() const;
table_map used_tables() const
diff --git a/sql/procedure.h b/sql/procedure.h
index 160777967ff..4212a9246a5 100644
--- a/sql/procedure.h
+++ b/sql/procedure.h
@@ -91,7 +91,7 @@ public:
Item_proc_string(const char *name_par,uint length) :Item_proc(name_par)
{ this->max_length=length; }
enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_STRING; }
+ enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
void set(double nr) { str_value.set(nr, 2, default_charset()); }
void set(longlong nr) { str_value.set(nr, default_charset()); }
void set(const char *str, uint length, CHARSET_INFO *cs)
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 17007cbcc5d..8be915b89e2 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -3731,8 +3731,6 @@ static int modify_grant_table(TABLE *table, Field *host_field,
Field *user_field, LEX_USER *user_to)
{
int error;
- TABLE *table;
- byte user_key[MAX_KEY_LENGTH];
DBUG_ENTER("modify_grant_table");
if (user_to)
@@ -3800,6 +3798,7 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop,
char *user_str= user_from->user.str;
const char *host;
const char *user;
+ byte user_key[MAX_KEY_LENGTH];
uint key_prefix_length;
DBUG_ENTER("handle_grant_table");
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index e8f5c6585df..ed3606856a0 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -7584,7 +7584,8 @@ static Field* create_tmp_field_from_field(THD *thd, Field* org_field,
0 on error
new_created field
*/
-static Field* create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
+
+static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
Item ***copy_func, bool modify_item,
uint convert_blob_length)
{
@@ -7602,19 +7603,12 @@ static Field* create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
item->name, table, item->unsigned_flag);
break;
case STRING_RESULT:
- if (item->max_length > 255)
- {
- if (convert_blob_length)
- new_field= new Field_varstring(convert_blob_length, maybe_null,
- item->name, table,
- item->collation.collation);
- else
- new_field= new Field_blob(item->max_length, maybe_null, item->name,
- table, item->collation.collation);
- }
+ if (item->max_length > 255 && convert_blob_length)
+ new_field= new Field_varstring(convert_blob_length, maybe_null,
+ item->name, table,
+ item->collation.collation);
else
- new_field= new Field_string(item->max_length, maybe_null, item->name,
- table, item->collation.collation);
+ new_field= item->make_string_field(table);
break;
case ROW_RESULT:
default:
@@ -7695,18 +7689,11 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
return new Field_longlong(item_sum->max_length,maybe_null,
item->name,table,item->unsigned_flag);
case STRING_RESULT:
- if (item_sum->max_length > 255)
- {
- if (convert_blob_length)
- return new Field_varstring(convert_blob_length, maybe_null,
- item->name, table,
- item->collation.collation);
- else
- return new Field_blob(item_sum->max_length, maybe_null, item->name,
- table, item->collation.collation);
- }
- return new Field_string(item_sum->max_length,maybe_null,
- item->name,table,item->collation.collation);
+ if (item_sum->max_length > 255 && convert_blob_length)
+ return new Field_varstring(convert_blob_length, maybe_null,
+ item->name, table,
+ item->collation.collation);
+ return item_sum->make_string_field(table);
case ROW_RESULT:
default:
// This case should never be choosen
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index f30eeb2d206..7acbe564f58 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1859,9 +1859,10 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
Item **child;
Item **item_end= (item_func->arguments()) + item_func->argument_count();
for (child= item_func->arguments(); child != item_end; child++)
+ {
if (!uses_only_table_name_fields(*child, table))
return 0;
- return 1;
+ }
}
else if (item->type() == Item::FIELD_ITEM)
{
@@ -1871,19 +1872,16 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
ST_FIELD_INFO *field_info= schema_table->fields_info;
const char *field_name1= field_info[schema_table->idx_field1].field_name;
const char *field_name2= field_info[schema_table->idx_field2].field_name;
- if(table->table != item_field->field->table ||
- (cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
- (uchar *) item_field->field_name,
- strlen(item_field->field_name)) &&
- cs->coll->strnncollsp(cs, (uchar *) field_name2, strlen(field_name2),
- (uchar *) item_field->field_name,
- strlen(item_field->field_name))))
+ if (table->table != item_field->field->table ||
+ (cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
+ (uchar *) item_field->field_name,
+ strlen(item_field->field_name), 0) &&
+ cs->coll->strnncollsp(cs, (uchar *) field_name2, strlen(field_name2),
+ (uchar *) item_field->field_name,
+ strlen(item_field->field_name), 0)))
return 0;
- else
- return 1;
}
- else
- return 1;
+ return 1;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 29a92e901c8..56605d1c6e0 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -540,6 +540,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
if (sql_field->sql_type == FIELD_TYPE_SET)
{
+ uint32 field_length;
if (sql_field->def)
{
char *not_used;
@@ -555,11 +556,12 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN(-1);
}
}
- calculate_interval_lengths(cs, interval, &dummy, &sql_field->length);
- sql_field->length+= (interval->count - 1);
+ calculate_interval_lengths(cs, interval, &dummy, &field_length);
+ sql_field->length= field_length + (interval->count - 1);
}
else /* FIELD_TYPE_ENUM */
{
+ uint32 field_length;
if (sql_field->def)
{
String str, *def= sql_field->def->val_str(&str);
@@ -570,7 +572,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN(-1);
}
}
- calculate_interval_lengths(cs, interval, &sql_field->length, &dummy);
+ calculate_interval_lengths(cs, interval, &field_length, &dummy);
+ sql_field->length= field_length;
}
set_if_smaller(sql_field->length, MAX_FIELD_WIDTH-1);
}
@@ -608,13 +611,6 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->length= 0; // Probably from an item
}
- /* Don't pack rows in old tables if the user has requested this */
- if ((sql_field->flags & BLOB_FLAG) ||
- sql_field->sql_type == MYSQL_TYPE_VARCHAR &&
- create_info->row_type != ROW_TYPE_FIXED)
- {
- db_options|=HA_OPTION_PACK_RECORD;
- }
if (!(sql_field->flags & NOT_NULL_FLAG))
null_fields++;
@@ -649,6 +645,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
create_info->default_table_charset);
sql_field->length= dup_field->length;
sql_field->pack_length= dup_field->pack_length;
+ sql_field->key_length= dup_field->key_length;
sql_field->create_length_to_internal_length();
sql_field->decimals= dup_field->decimals;
sql_field->flags= dup_field->flags;
@@ -659,6 +656,11 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
}
}
+ /* Don't pack rows in old tables if the user has requested this */
+ if ((sql_field->flags & BLOB_FLAG) ||
+ sql_field->sql_type == MYSQL_TYPE_VARCHAR &&
+ create_info->row_type != ROW_TYPE_FIXED)
+ db_options|= HA_OPTION_PACK_RECORD;
it2.rewind();
}
/* If fixed row records, we need one bit to check for deleted rows */