Merge weblab.(none):/home/marcsql/TREE/mysql-5.1-base

into  weblab.(none):/home/marcsql/TREE/mysql-5.1-rt-merge


sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/item.h:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
This commit is contained in:
unknown 2007-06-11 15:57:59 -06:00
commit 9ab7ce8dcb
24 changed files with 264 additions and 210 deletions

View File

@ -326,6 +326,8 @@ end:
delete event; delete event;
deinit_event_thread(thd); deinit_event_thread(thd);
DBUG_VOID_RETURN;
} }

View File

@ -38,8 +38,8 @@
*****************************************************************************/ *****************************************************************************/
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class List<create_field>; template class List<Create_field>;
template class List_iterator<create_field>; template class List_iterator<Create_field>;
#endif #endif
uchar Field_null::null[1]={1}; uchar Field_null::null[1]={1};
@ -2631,7 +2631,7 @@ void Field_new_decimal::sql_type(String &str) const
} }
uint Field_new_decimal::is_equal(create_field *new_field) uint Field_new_decimal::is_equal(Create_field *new_field)
{ {
return ((new_field->sql_type == real_type()) && return ((new_field->sql_type == real_type()) &&
((new_field->flags & UNSIGNED_FLAG) == ((new_field->flags & UNSIGNED_FLAG) ==
@ -4366,7 +4366,7 @@ Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg,
const char *field_name_arg, const char *field_name_arg,
TABLE_SHARE *share, TABLE_SHARE *share,
CHARSET_INFO *cs) CHARSET_INFO *cs)
:Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg, :Field_str(ptr_arg, MAX_DATETIME_WIDTH, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, cs) unireg_check_arg, field_name_arg, cs)
{ {
/* For 4.0 MYD and 4.0 InnoDB compatibility */ /* For 4.0 MYD and 4.0 InnoDB compatibility */
@ -4383,7 +4383,8 @@ Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg,
Field_timestamp::Field_timestamp(bool maybe_null_arg, Field_timestamp::Field_timestamp(bool maybe_null_arg,
const char *field_name_arg, const char *field_name_arg,
CHARSET_INFO *cs) CHARSET_INFO *cs)
:Field_str((uchar*) 0, 19, maybe_null_arg ? (uchar*) "": 0, 0, :Field_str((uchar*) 0, MAX_DATETIME_WIDTH,
maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs) NONE, field_name_arg, cs)
{ {
/* For 4.0 MYD and 4.0 InnoDB compatibility */ /* For 4.0 MYD and 4.0 InnoDB compatibility */
@ -4916,7 +4917,7 @@ String *Field_time::val_str(String *val_buffer,
{ {
ASSERT_COLUMN_MARKED_FOR_READ; ASSERT_COLUMN_MARKED_FOR_READ;
MYSQL_TIME ltime; MYSQL_TIME ltime;
val_buffer->alloc(19); val_buffer->alloc(MAX_DATE_STRING_REP_LENGTH);
long tmp=(long) sint3korr(ptr); long tmp=(long) sint3korr(ptr);
ltime.neg= 0; ltime.neg= 0;
if (tmp < 0) if (tmp < 0)
@ -5464,7 +5465,7 @@ int Field_newdate::store_time(MYSQL_TIME *ltime,timestamp_type time_type)
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
MODE_INVALID_DATES))), &error)) MODE_INVALID_DATES))), &error))
{ {
char buff[12]; char buff[MAX_DATE_STRING_REP_LENGTH];
String str(buff, sizeof(buff), &my_charset_latin1); String str(buff, sizeof(buff), &my_charset_latin1);
make_date((DATE_TIME_FORMAT *) 0, ltime, &str); make_date((DATE_TIME_FORMAT *) 0, ltime, &str);
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
@ -5695,7 +5696,7 @@ int Field_datetime::store_time(MYSQL_TIME *ltime,timestamp_type time_type)
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
MODE_INVALID_DATES))), &error)) MODE_INVALID_DATES))), &error))
{ {
char buff[19]; char buff[MAX_DATE_STRING_REP_LENGTH];
String str(buff, sizeof(buff), &my_charset_latin1); String str(buff, sizeof(buff), &my_charset_latin1);
make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str); make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str);
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
@ -5771,7 +5772,7 @@ String *Field_datetime::val_str(String *val_buffer,
part1=(long) (tmp/LL(1000000)); part1=(long) (tmp/LL(1000000));
part2=(long) (tmp - (ulonglong) part1*LL(1000000)); part2=(long) (tmp - (ulonglong) part1*LL(1000000));
pos=(char*) val_buffer->ptr()+19; pos=(char*) val_buffer->ptr() + MAX_DATETIME_WIDTH;
*pos--=0; *pos--=0;
*pos--= (char) ('0'+(char) (part2%10)); part2/=10; *pos--= (char) ('0'+(char) (part2%10)); part2/=10;
*pos--= (char) ('0'+(char) (part2%10)); part3= (int) (part2 / 10); *pos--= (char) ('0'+(char) (part2%10)); part3= (int) (part2 / 10);
@ -6069,7 +6070,7 @@ int Field_str::store(double nr)
} }
uint Field::is_equal(create_field *new_field) uint Field::is_equal(Create_field *new_field)
{ {
return (new_field->sql_type == real_type()); return (new_field->sql_type == real_type());
} }
@ -6077,7 +6078,7 @@ uint Field::is_equal(create_field *new_field)
/* If one of the fields is binary and the other one isn't return 1 else 0 */ /* If one of the fields is binary and the other one isn't return 1 else 0 */
bool Field_str::compare_str_field_flags(create_field *new_field, uint32 flags) bool Field_str::compare_str_field_flags(Create_field *new_field, uint32 flags)
{ {
return (((new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) && return (((new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) &&
!(flags & (BINCMP_FLAG | BINARY_FLAG))) || !(flags & (BINCMP_FLAG | BINARY_FLAG))) ||
@ -6086,7 +6087,7 @@ bool Field_str::compare_str_field_flags(create_field *new_field, uint32 flags)
} }
uint Field_str::is_equal(create_field *new_field) uint Field_str::is_equal(Create_field *new_field)
{ {
if (compare_str_field_flags(new_field, flags)) if (compare_str_field_flags(new_field, flags))
return 0; return 0;
@ -6938,7 +6939,7 @@ Field *Field_varstring::new_key_field(MEM_ROOT *root,
} }
uint Field_varstring::is_equal(create_field *new_field) uint Field_varstring::is_equal(Create_field *new_field)
{ {
if (new_field->sql_type == real_type() && if (new_field->sql_type == real_type() &&
new_field->charset == field_charset) new_field->charset == field_charset)
@ -7620,7 +7621,7 @@ uint Field_blob::max_packed_col_length(uint max_length)
} }
uint Field_blob::is_equal(create_field *new_field) uint Field_blob::is_equal(Create_field *new_field)
{ {
if (compare_str_field_flags(new_field, flags)) if (compare_str_field_flags(new_field, flags))
return 0; return 0;
@ -8158,7 +8159,7 @@ bool Field_num::eq_def(Field *field)
} }
uint Field_num::is_equal(create_field *new_field) uint Field_num::is_equal(Create_field *new_field)
{ {
return ((new_field->sql_type == real_type()) && return ((new_field->sql_type == real_type()) &&
((new_field->flags & UNSIGNED_FLAG) == (uint) (flags & ((new_field->flags & UNSIGNED_FLAG) == (uint) (flags &
@ -8594,20 +8595,20 @@ void Field_bit_as_char::sql_type(String &res) const
/***************************************************************************** /*****************************************************************************
Handling of field and create_field Handling of field and Create_field
*****************************************************************************/ *****************************************************************************/
/* /*
Convert create_field::length from number of characters to number of bytes Convert Create_field::length from number of characters to number of bytes
SYNOPSIS SYNOPSIS
create_field::create_length_to_internal_length() Create_field::create_length_to_internal_length()
DESCRIPTION DESCRIPTION
Convert create_field::length from number of characters to number of bytes. Convert Create_field::length from number of characters to number of bytes.
*/ */
void create_field::create_length_to_internal_length(void) void Create_field::create_length_to_internal_length(void)
{ {
switch (sql_type) { switch (sql_type) {
case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_TINY_BLOB:
@ -8654,7 +8655,7 @@ void create_field::create_length_to_internal_length(void)
} }
void create_field::init_for_tmp_table(enum_field_types sql_type_arg, void Create_field::init_for_tmp_table(enum_field_types sql_type_arg,
uint32 length_arg, uint32 decimals_arg, uint32 length_arg, uint32 decimals_arg,
bool maybe_null, bool is_unsigned) bool maybe_null, bool is_unsigned)
{ {
@ -8695,7 +8696,7 @@ void create_field::init_for_tmp_table(enum_field_types sql_type_arg,
TRUE on error TRUE on error
*/ */
bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
char *fld_length, char *fld_decimals, char *fld_length, char *fld_decimals,
uint fld_type_modifier, Item *fld_default_value, uint fld_type_modifier, Item *fld_default_value,
Item *fld_on_update_value, LEX_STRING *fld_comment, Item *fld_on_update_value, LEX_STRING *fld_comment,
@ -8705,7 +8706,7 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
uint sign_len, allowed_type_modifier= 0; uint sign_len, allowed_type_modifier= 0;
ulong max_field_charlength= MAX_FIELD_CHARLENGTH; ulong max_field_charlength= MAX_FIELD_CHARLENGTH;
DBUG_ENTER("create_field::init()"); DBUG_ENTER("Create_field::init()");
field= 0; field= 0;
field_name= fld_name; field_name= fld_name;
@ -8889,15 +8890,18 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
break; break;
case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
if (!fld_length) if (!fld_length)
length= 14; /* Full date YYYYMMDDHHMMSS */ {
else if (length != 19) /* Compressed date YYYYMMDDHHMMSS */
length= MAX_DATETIME_COMPRESSED_WIDTH;
}
else if (length != MAX_DATETIME_WIDTH)
{ {
/* /*
We support only even TIMESTAMP lengths less or equal than 14 We support only even TIMESTAMP lengths less or equal than 14
and 19 as length of 4.1 compatible representation. and 19 as length of 4.1 compatible representation.
*/ */
length= ((length+1)/2)*2; /* purecov: inspected */ length= ((length+1)/2)*2; /* purecov: inspected */
length= min(length,14); /* purecov: inspected */ length= min(length, MAX_DATETIME_COMPRESSED_WIDTH); /* purecov: inspected */
} }
flags|= ZEROFILL_FLAG | UNSIGNED_FLAG; flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
if (fld_default_value) if (fld_default_value)
@ -8950,7 +8954,7 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
length= 10; length= 10;
break; break;
case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_DATETIME:
length= 19; length= MAX_DATETIME_WIDTH;
break; break;
case MYSQL_TYPE_SET: case MYSQL_TYPE_SET:
{ {
@ -9278,7 +9282,7 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length,
/* Create a field suitable for create of table */ /* Create a field suitable for create of table */
create_field::create_field(Field *old_field,Field *orig_field) Create_field::Create_field(Field *old_field,Field *orig_field)
{ {
field= old_field; field= old_field;
field_name=change=old_field->field_name; field_name=change=old_field->field_name;

View File

@ -28,7 +28,7 @@
class Send_field; class Send_field;
class Protocol; class Protocol;
class create_field; class Create_field;
struct st_cache_field; struct st_cache_field;
int field_conv(Field *to,Field *from); int field_conv(Field *to,Field *from);
@ -413,7 +413,7 @@ public:
/* maximum possible display length */ /* maximum possible display length */
virtual uint32 max_display_length()= 0; virtual uint32 max_display_length()= 0;
virtual uint is_equal(create_field *new_field); virtual uint is_equal(Create_field *new_field);
/* convert decimal to longlong with overflow check */ /* convert decimal to longlong with overflow check */
longlong convert_decimal2longlong(const my_decimal *val, bool unsigned_flag, longlong convert_decimal2longlong(const my_decimal *val, bool unsigned_flag,
int *err); int *err);
@ -468,14 +468,14 @@ public:
Item_result result_type () const { return REAL_RESULT; } Item_result result_type () const { return REAL_RESULT; }
void prepend_zeros(String *value); void prepend_zeros(String *value);
void add_zerofill_and_unsigned(String &res) const; void add_zerofill_and_unsigned(String &res) const;
friend class create_field; friend class Create_field;
void make_field(Send_field *); void make_field(Send_field *);
uint decimals() const { return (uint) dec; } uint decimals() const { return (uint) dec; }
uint size_of() const { return sizeof(*this); } uint size_of() const { return sizeof(*this); }
bool eq_def(Field *field); bool eq_def(Field *field);
int store_decimal(const my_decimal *); int store_decimal(const my_decimal *);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
uint is_equal(create_field *new_field); uint is_equal(Create_field *new_field);
int check_int(CHARSET_INFO *cs, const char *str, int length, int check_int(CHARSET_INFO *cs, const char *str, int length,
const char *int_end, int error); const char *int_end, int error);
bool get_int(CHARSET_INFO *cs, const char *from, uint len, bool get_int(CHARSET_INFO *cs, const char *from, uint len,
@ -506,11 +506,11 @@ public:
{ field_derivation= derivation_arg; } { field_derivation= derivation_arg; }
bool binary() const { return field_charset == &my_charset_bin; } bool binary() const { return field_charset == &my_charset_bin; }
uint32 max_display_length() { return field_length; } uint32 max_display_length() { return field_length; }
friend class create_field; friend class Create_field;
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
virtual bool str_needs_quotes() { return TRUE; } virtual bool str_needs_quotes() { return TRUE; }
bool compare_str_field_flags(create_field *new_field, uint32 flags); bool compare_str_field_flags(Create_field *new_field, uint32 flags);
uint is_equal(create_field *new_field); uint is_equal(Create_field *new_field);
}; };
@ -619,7 +619,7 @@ public:
uint32 max_display_length() { return field_length; } uint32 max_display_length() { return field_length; }
uint size_of() const { return sizeof(*this); } uint size_of() const { return sizeof(*this); }
uint32 pack_length() const { return (uint32) bin_size; } uint32 pack_length() const { return (uint32) bin_size; }
uint is_equal(create_field *new_field); uint is_equal(Create_field *new_field);
}; };
@ -1251,7 +1251,7 @@ public:
Field *new_key_field(MEM_ROOT *root, struct st_table *new_table, Field *new_key_field(MEM_ROOT *root, struct st_table *new_table,
uchar *new_ptr, uchar *new_null_ptr, uchar *new_ptr, uchar *new_null_ptr,
uint new_null_bit); uint new_null_bit);
uint is_equal(create_field *new_field); uint is_equal(Create_field *new_field);
void hash(ulong *nr, ulong *nr2); void hash(ulong *nr, ulong *nr2);
}; };
@ -1385,7 +1385,7 @@ public:
bool has_charset(void) const bool has_charset(void) const
{ return charset() == &my_charset_bin ? FALSE : TRUE; } { return charset() == &my_charset_bin ? FALSE : TRUE; }
uint32 max_display_length(); uint32 max_display_length();
uint is_equal(create_field *new_field); uint is_equal(Create_field *new_field);
}; };
@ -1601,7 +1601,7 @@ public:
Create field class for CREATE TABLE Create field class for CREATE TABLE
*/ */
class create_field :public Sql_alloc class Create_field :public Sql_alloc
{ {
public: public:
const char *field_name; const char *field_name;
@ -1632,11 +1632,11 @@ public:
uint8 row,col,sc_length,interval_id; // For rea_create_table uint8 row,col,sc_length,interval_id; // For rea_create_table
uint offset,pack_flag; uint offset,pack_flag;
create_field() :after(0) {} Create_field() :after(0) {}
create_field(Field *field, Field *orig_field); Create_field(Field *field, Field *orig_field);
/* Used to make a clone of this object for ALTER/CREATE TABLE */ /* Used to make a clone of this object for ALTER/CREATE TABLE */
create_field *clone(MEM_ROOT *mem_root) const Create_field *clone(MEM_ROOT *mem_root) const
{ return new (mem_root) create_field(*this); } { return new (mem_root) Create_field(*this); }
void create_length_to_internal_length(void); void create_length_to_internal_length(void);
/* Init for a tmp table field. To be extended if need be. */ /* Init for a tmp table field. To be extended if need be. */

View File

@ -1763,7 +1763,7 @@ public:
We have to have a different max_length than 'length' here to We have to have a different max_length than 'length' here to
ensure that we get the right length if we do use the item ensure that we get the right length if we do use the item
to create a new table. In this case max_length must be the maximum to create a new table. In this case max_length must be the maximum
number of chars for a string of this type because we in create_field:: number of chars for a string of this type because we in Create_field::
divide the max_length with mbmaxlen). divide the max_length with mbmaxlen).
*/ */
max_length= str_value.numchars()*cs->mbmaxlen; max_length= str_value.numchars()*cs->mbmaxlen;

View File

@ -912,8 +912,8 @@ void Item_sum_distinct::fix_length_and_dec()
bool Item_sum_distinct::setup(THD *thd) bool Item_sum_distinct::setup(THD *thd)
{ {
List<create_field> field_list; List<Create_field> field_list;
create_field field_def; /* field definition */ Create_field field_def; /* field definition */
DBUG_ENTER("Item_sum_distinct::setup"); DBUG_ENTER("Item_sum_distinct::setup");
DBUG_ASSERT(tree == 0); DBUG_ASSERT(tree == 0);

View File

@ -51,7 +51,7 @@ static bool make_datetime(date_time_format_types format, MYSQL_TIME *ltime,
{ {
char *buff; char *buff;
CHARSET_INFO *cs= &my_charset_bin; CHARSET_INFO *cs= &my_charset_bin;
uint length= 30; uint length= MAX_DATE_STRING_REP_LENGTH;
if (str->alloc(length)) if (str->alloc(length))
return 1; return 1;
@ -1379,7 +1379,7 @@ String *Item_date::val_str(String *str)
MYSQL_TIME ltime; MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE)) if (get_date(&ltime, TIME_FUZZY_DATE))
return (String *) 0; return (String *) 0;
if (str->alloc(11)) if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
{ {
null_value= 1; null_value= 1;
return (String *) 0; return (String *) 0;
@ -1428,7 +1428,7 @@ void Item_func_curdate::fix_length_and_dec()
String *Item_func_curdate::val_str(String *str) String *Item_func_curdate::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
if (str->alloc(11)) if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
{ {
null_value= 1; null_value= 1;
return (String *) 0; return (String *) 0;
@ -1657,7 +1657,8 @@ String *Item_func_sec_to_time::val_str(String *str)
MYSQL_TIME ltime; MYSQL_TIME ltime;
longlong arg_val= args[0]->val_int(); longlong arg_val= args[0]->val_int();
if ((null_value=args[0]->null_value) || str->alloc(19)) if ((null_value=args[0]->null_value) ||
str->alloc(MAX_DATE_STRING_REP_LENGTH))
{ {
null_value= 1; null_value= 1;
return (String*) 0; return (String*) 0;
@ -1842,6 +1843,10 @@ String *Item_func_date_format::val_str(String *str)
size=max_length; size=max_length;
else else
size=format_length(format); size=format_length(format);
if (size < MAX_DATE_STRING_REP_LENGTH)
size= MAX_DATE_STRING_REP_LENGTH;
if (format == str) if (format == str)
str= &value; // Save result here str= &value; // Save result here
if (str->alloc(size)) if (str->alloc(size))
@ -1885,13 +1890,14 @@ String *Item_func_from_unixtime::val_str(String *str)
if (get_date(&time_tmp, 0)) if (get_date(&time_tmp, 0))
return 0; return 0;
if (str->alloc(20*MY_CHARSET_BIN_MB_MAXLEN)) if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
{ {
null_value= 1; null_value= 1;
return 0; return 0;
} }
make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str); make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str);
return str; return str;
} }
@ -1941,13 +1947,14 @@ String *Item_func_convert_tz::val_str(String *str)
if (get_date(&time_tmp, 0)) if (get_date(&time_tmp, 0))
return 0; return 0;
if (str->alloc(20*MY_CHARSET_BIN_MB_MAXLEN)) if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
{ {
null_value= 1; null_value= 1;
return 0; return 0;
} }
make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str); make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str);
return str; return str;
} }
@ -2433,6 +2440,7 @@ String *Item_datetime_typecast::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime; MYSQL_TIME ltime;
if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) && if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) &&
!make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME, !make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME,
&ltime, str)) &ltime, str))
@ -2511,7 +2519,8 @@ String *Item_date_typecast::val_str(String *str)
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime; MYSQL_TIME ltime;
if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) && !str->alloc(11)) if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) &&
!str->alloc(MAX_DATE_STRING_REP_LENGTH))
{ {
make_date((DATE_TIME_FORMAT *) 0, &ltime, str); make_date((DATE_TIME_FORMAT *) 0, &ltime, str);
return str; return str;
@ -2564,7 +2573,7 @@ String *Item_func_makedate::val_str(String *str)
{ {
null_value=0; null_value=0;
get_date_from_daynr(days,&l_time.year,&l_time.month,&l_time.day); get_date_from_daynr(days,&l_time.year,&l_time.month,&l_time.day);
if (str->alloc(11)) if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
goto err; goto err;
make_date((DATE_TIME_FORMAT *) 0, &l_time, str); make_date((DATE_TIME_FORMAT *) 0, &l_time, str);
return str; return str;
@ -2700,6 +2709,7 @@ String *Item_func_add_time::val_str(String *str)
days= (long)(seconds/86400L); days= (long)(seconds/86400L);
calc_time_from_sec(&l_time3, (long)(seconds%86400L), microseconds); calc_time_from_sec(&l_time3, (long)(seconds%86400L), microseconds);
if (!is_time) if (!is_time)
{ {
get_date_from_daynr(days,&l_time3.year,&l_time3.month,&l_time3.day); get_date_from_daynr(days,&l_time3.year,&l_time3.month,&l_time3.day);
@ -2815,7 +2825,7 @@ String *Item_func_maketime::val_str(String *str)
args[2]->null_value || args[2]->null_value ||
minute < 0 || minute > 59 || minute < 0 || minute > 59 ||
second < 0 || second > 59 || second < 0 || second > 59 ||
str->alloc(19)))) str->alloc(MAX_DATE_STRING_REP_LENGTH))))
return 0; return 0;
bzero((char *)&ltime, sizeof(ltime)); bzero((char *)&ltime, sizeof(ltime));

View File

@ -908,7 +908,7 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list,
bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list); bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list);
int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache, int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache,
KEY_CACHE *dst_cache); KEY_CACHE *dst_cache);
TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list); TABLE *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list);
bool mysql_xa_recover(THD *thd); bool mysql_xa_recover(THD *thd);
@ -952,8 +952,8 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
bool table_cant_handle_bit_fields, bool table_cant_handle_bit_fields,
bool make_copy_field, bool make_copy_field,
uint convert_blob_length); uint convert_blob_length);
void sp_prepare_create_field(THD *thd, create_field *sql_field); void sp_prepare_create_field(THD *thd, Create_field *sql_field);
int prepare_create_field(create_field *sql_field, int prepare_create_field(Create_field *sql_field,
uint *blob_columns, uint *blob_columns,
int *timestamps, int *timestamps_with_niladic, int *timestamps, int *timestamps_with_niladic,
longlong table_flags); longlong table_flags);
@ -1178,7 +1178,7 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types t
char *change, List<String> *interval_list, char *change, List<String> *interval_list,
CHARSET_INFO *cs, CHARSET_INFO *cs,
uint uint_geom_type); uint uint_geom_type);
create_field * new_create_field(THD *thd, char *field_name, enum_field_types type, Create_field * new_create_field(THD *thd, char *field_name, enum_field_types type,
char *length, char *decimals, char *length, char *decimals,
uint type_modifier, uint type_modifier,
Item *default_value, Item *on_update_value, Item *default_value, Item *on_update_value,
@ -1803,12 +1803,12 @@ void unireg_end(void) __attribute__((noreturn));
bool mysql_create_frm(THD *thd, const char *file_name, bool mysql_create_frm(THD *thd, const char *file_name,
const char *db, const char *table, const char *db, const char *table,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &create_field, List<Create_field> &create_field,
uint key_count,KEY *key_info,handler *db_type); uint key_count,KEY *key_info,handler *db_type);
int rea_create_table(THD *thd, const char *path, int rea_create_table(THD *thd, const char *path,
const char *db, const char *table_name, const char *db, const char *table_name,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &create_field, List<Create_field> &create_field,
uint key_count,KEY *key_info, uint key_count,KEY *key_info,
handler *file); handler *file);
int format_number(uint inputflag,uint max_length,char * pos,uint length, int format_number(uint inputflag,uint max_length,char * pos,uint length,

View File

@ -581,7 +581,7 @@ sp_head::init_strings(THD *thd, LEX *lex)
static TYPELIB * static TYPELIB *
create_typelib(MEM_ROOT *mem_root, create_field *field_def, List<String> *src) create_typelib(MEM_ROOT *mem_root, Create_field *field_def, List<String> *src)
{ {
TYPELIB *result= NULL; TYPELIB *result= NULL;
CHARSET_INFO *cs= field_def->charset; CHARSET_INFO *cs= field_def->charset;
@ -1908,7 +1908,7 @@ sp_head::backpatch(sp_label_t *lab)
} }
/* /*
Prepare an instance of create_field for field creation (fill all necessary Prepare an instance of Create_field for field creation (fill all necessary
attributes). attributes).
SYNOPSIS SYNOPSIS
@ -1916,7 +1916,7 @@ sp_head::backpatch(sp_label_t *lab)
thd [IN] Thread handle thd [IN] Thread handle
lex [IN] Yacc parsing context lex [IN] Yacc parsing context
field_type [IN] Field type field_type [IN] Field type
field_def [OUT] An instance of create_field to be filled field_def [OUT] An instance of Create_field to be filled
RETURN RETURN
FALSE on success FALSE on success
@ -1926,7 +1926,7 @@ sp_head::backpatch(sp_label_t *lab)
bool bool
sp_head::fill_field_definition(THD *thd, LEX *lex, sp_head::fill_field_definition(THD *thd, LEX *lex,
enum enum_field_types field_type, enum enum_field_types field_type,
create_field *field_def) Create_field *field_def)
{ {
HA_CREATE_INFO sp_db_info; HA_CREATE_INFO sp_db_info;
LEX_STRING cmt = { 0, 0 }; LEX_STRING cmt = { 0, 0 };

View File

@ -126,7 +126,7 @@ public:
int m_type; int m_type;
uint m_flags; // Boolean attributes of a stored routine uint m_flags; // Boolean attributes of a stored routine
create_field m_return_field_def; /* This is used for FUNCTIONs only. */ Create_field m_return_field_def; /* This is used for FUNCTIONs only. */
const char *m_tmp_query; // Temporary pointer to sub query string const char *m_tmp_query; // Temporary pointer to sub query string
st_sp_chistics *m_chistics; st_sp_chistics *m_chistics;
@ -290,7 +290,7 @@ public:
bool fill_field_definition(THD *thd, LEX *lex, bool fill_field_definition(THD *thd, LEX *lex,
enum enum_field_types field_type, enum enum_field_types field_type,
create_field *field_def); Create_field *field_def);
void set_info(longlong created, longlong modified, void set_info(longlong created, longlong modified,
st_sp_chistics *chistics, ulong sql_mode); st_sp_chistics *chistics, ulong sql_mode);

View File

@ -422,7 +422,7 @@ sp_pcontext::find_cursor(LEX_STRING *name, uint *poff, my_bool scoped)
void void
sp_pcontext::retrieve_field_definitions(List<create_field> *field_def_lst) sp_pcontext::retrieve_field_definitions(List<Create_field> *field_def_lst)
{ {
/* Put local/context fields in the result list. */ /* Put local/context fields in the result list. */

View File

@ -43,7 +43,7 @@ typedef struct sp_variable
uint offset; uint offset;
Item *dflt; Item *dflt;
create_field field_def; Create_field field_def;
} sp_variable_t; } sp_variable_t;
@ -234,7 +234,7 @@ public:
children. children.
*/ */
void void
retrieve_field_definitions(List<create_field> *field_def_lst); retrieve_field_definitions(List<Create_field> *field_def_lst);
// Find by name // Find by name
sp_variable_t * sp_variable_t *

View File

@ -102,7 +102,7 @@ bool sp_rcontext::init(THD *thd)
bool bool
sp_rcontext::init_var_table(THD *thd) sp_rcontext::init_var_table(THD *thd)
{ {
List<create_field> field_def_lst; List<Create_field> field_def_lst;
if (!m_root_parsing_ctx->max_var_index()) if (!m_root_parsing_ctx->max_var_index())
return FALSE; return FALSE;

View File

@ -59,8 +59,8 @@ const char * const THD::DEFAULT_WHERE= "field list";
/* Used templates */ /* Used templates */
template class List<Key>; template class List<Key>;
template class List_iterator<Key>; template class List_iterator<Key>;
template class List<key_part_spec>; template class List<Key_part_spec>;
template class List_iterator<key_part_spec>; template class List_iterator<Key_part_spec>;
template class List<Alter_drop>; template class List<Alter_drop>;
template class List_iterator<Alter_drop>; template class List_iterator<Alter_drop>;
template class List<Alter_column>; template class List<Alter_column>;
@ -86,7 +86,7 @@ extern "C" void free_user_var(user_var_entry *entry)
my_free((char*) entry,MYF(0)); my_free((char*) entry,MYF(0));
} }
bool key_part_spec::operator==(const key_part_spec& other) const bool Key_part_spec::operator==(const Key_part_spec& other) const
{ {
return length == other.length && !strcmp(field_name, other.field_name); return length == other.length && !strcmp(field_name, other.field_name);
} }
@ -115,7 +115,7 @@ Key::Key(const Key &rhs, MEM_ROOT *mem_root)
in THD. in THD.
*/ */
foreign_key::foreign_key(const foreign_key &rhs, MEM_ROOT *mem_root) Foreign_key::Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root)
:Key(rhs), :Key(rhs),
ref_table(rhs.ref_table), ref_table(rhs.ref_table),
ref_columns(rhs.ref_columns), ref_columns(rhs.ref_columns),
@ -160,9 +160,9 @@ bool foreign_key_prefix(Key *a, Key *b)
if (a->columns.elements > b->columns.elements) if (a->columns.elements > b->columns.elements)
return TRUE; // Can't be prefix return TRUE; // Can't be prefix
List_iterator<key_part_spec> col_it1(a->columns); List_iterator<Key_part_spec> col_it1(a->columns);
List_iterator<key_part_spec> col_it2(b->columns); List_iterator<Key_part_spec> col_it2(b->columns);
const key_part_spec *col1, *col2; const Key_part_spec *col1, *col2;
#ifdef ENABLE_WHEN_INNODB_CAN_HANDLE_SWAPED_FOREIGN_KEY_COLUMNS #ifdef ENABLE_WHEN_INNODB_CAN_HANDLE_SWAPED_FOREIGN_KEY_COLUMNS
while ((col1= col_it1++)) while ((col1= col_it1++))

View File

@ -84,14 +84,14 @@ typedef struct st_copy_info {
} COPY_INFO; } COPY_INFO;
class key_part_spec :public Sql_alloc { class Key_part_spec :public Sql_alloc {
public: public:
const char *field_name; const char *field_name;
uint length; uint length;
key_part_spec(const char *name,uint len=0) :field_name(name), length(len) {} Key_part_spec(const char *name,uint len=0) :field_name(name), length(len) {}
bool operator==(const key_part_spec& other) const; bool operator==(const Key_part_spec& other) const;
/** /**
Construct a copy of this key_part_spec. field_name is copied Construct a copy of this Key_part_spec. field_name is copied
by-pointer as it is known to never change. At the same time by-pointer as it is known to never change. At the same time
'length' may be reset in mysql_prepare_create_table, and this 'length' may be reset in mysql_prepare_create_table, and this
is why we supply it with a copy. is why we supply it with a copy.
@ -99,8 +99,8 @@ public:
@return If out of memory, 0 is returned and an error is set in @return If out of memory, 0 is returned and an error is set in
THD. THD.
*/ */
key_part_spec *clone(MEM_ROOT *mem_root) const Key_part_spec *clone(MEM_ROOT *mem_root) const
{ return new (mem_root) key_part_spec(*this); } { return new (mem_root) Key_part_spec(*this); }
}; };
@ -113,7 +113,7 @@ public:
:name(par_name), type(par_type) {} :name(par_name), type(par_type) {}
/** /**
Used to make a clone of this object for ALTER/CREATE TABLE Used to make a clone of this object for ALTER/CREATE TABLE
@sa comment for key_part_spec::clone @sa comment for Key_part_spec::clone
*/ */
Alter_drop *clone(MEM_ROOT *mem_root) const Alter_drop *clone(MEM_ROOT *mem_root) const
{ return new (mem_root) Alter_drop(*this); } { return new (mem_root) Alter_drop(*this); }
@ -128,7 +128,7 @@ public:
:name(par_name), def(literal) {} :name(par_name), def(literal) {}
/** /**
Used to make a clone of this object for ALTER/CREATE TABLE Used to make a clone of this object for ALTER/CREATE TABLE
@sa comment for key_part_spec::clone @sa comment for Key_part_spec::clone
*/ */
Alter_column *clone(MEM_ROOT *mem_root) const Alter_column *clone(MEM_ROOT *mem_root) const
{ return new (mem_root) Alter_column(*this); } { return new (mem_root) Alter_column(*this); }
@ -140,13 +140,13 @@ public:
enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FULLTEXT, SPATIAL, FOREIGN_KEY}; enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FULLTEXT, SPATIAL, FOREIGN_KEY};
enum Keytype type; enum Keytype type;
KEY_CREATE_INFO key_create_info; KEY_CREATE_INFO key_create_info;
List<key_part_spec> columns; List<Key_part_spec> columns;
const char *name; const char *name;
bool generated; bool generated;
Key(enum Keytype type_par, const char *name_arg, Key(enum Keytype type_par, const char *name_arg,
KEY_CREATE_INFO *key_info_arg, KEY_CREATE_INFO *key_info_arg,
bool generated_arg, List<key_part_spec> &cols) bool generated_arg, List<Key_part_spec> &cols)
:type(type_par), key_create_info(*key_info_arg), columns(cols), :type(type_par), key_create_info(*key_info_arg), columns(cols),
name(name_arg), generated(generated_arg) name(name_arg), generated(generated_arg)
{} {}
@ -156,7 +156,7 @@ public:
friend bool foreign_key_prefix(Key *a, Key *b); friend bool foreign_key_prefix(Key *a, Key *b);
/** /**
Used to make a clone of this object for ALTER/CREATE TABLE Used to make a clone of this object for ALTER/CREATE TABLE
@sa comment for key_part_spec::clone @sa comment for Key_part_spec::clone
*/ */
virtual Key *clone(MEM_ROOT *mem_root) const virtual Key *clone(MEM_ROOT *mem_root) const
{ return new (mem_root) Key(*this, mem_root); } { return new (mem_root) Key(*this, mem_root); }
@ -164,7 +164,7 @@ public:
class Table_ident; class Table_ident;
class foreign_key: public Key { class Foreign_key: public Key {
public: public:
enum fk_match_opt { FK_MATCH_UNDEF, FK_MATCH_FULL, enum fk_match_opt { FK_MATCH_UNDEF, FK_MATCH_FULL,
FK_MATCH_PARTIAL, FK_MATCH_SIMPLE}; FK_MATCH_PARTIAL, FK_MATCH_SIMPLE};
@ -172,23 +172,23 @@ public:
FK_OPTION_SET_NULL, FK_OPTION_NO_ACTION, FK_OPTION_DEFAULT}; FK_OPTION_SET_NULL, FK_OPTION_NO_ACTION, FK_OPTION_DEFAULT};
Table_ident *ref_table; Table_ident *ref_table;
List<key_part_spec> ref_columns; List<Key_part_spec> ref_columns;
uint delete_opt, update_opt, match_opt; uint delete_opt, update_opt, match_opt;
foreign_key(const char *name_arg, List<key_part_spec> &cols, Foreign_key(const char *name_arg, List<Key_part_spec> &cols,
Table_ident *table, List<key_part_spec> &ref_cols, Table_ident *table, List<Key_part_spec> &ref_cols,
uint delete_opt_arg, uint update_opt_arg, uint match_opt_arg) uint delete_opt_arg, uint update_opt_arg, uint match_opt_arg)
:Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols), :Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols),
ref_table(table), ref_columns(cols), ref_table(table), ref_columns(cols),
delete_opt(delete_opt_arg), update_opt(update_opt_arg), delete_opt(delete_opt_arg), update_opt(update_opt_arg),
match_opt(match_opt_arg) match_opt(match_opt_arg)
{} {}
foreign_key(const foreign_key &rhs, MEM_ROOT *mem_root); Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root);
/** /**
Used to make a clone of this object for ALTER/CREATE TABLE Used to make a clone of this object for ALTER/CREATE TABLE
@sa comment for key_part_spec::clone @sa comment for Key_part_spec::clone
*/ */
virtual Key *clone(MEM_ROOT *mem_root) const virtual Key *clone(MEM_ROOT *mem_root) const
{ return new (mem_root) foreign_key(*this, mem_root); } { return new (mem_root) Foreign_key(*this, mem_root); }
}; };
typedef struct st_mysql_lock typedef struct st_mysql_lock

View File

@ -3201,7 +3201,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
MYSQL_LOCK **lock, MYSQL_LOCK **lock,
TABLEOP_HOOKS *hooks) TABLEOP_HOOKS *hooks)
{ {
TABLE tmp_table; // Used during 'create_field()' TABLE tmp_table; // Used during 'Create_field()'
TABLE_SHARE share; TABLE_SHARE share;
TABLE *table= 0; TABLE *table= 0;
uint select_field_count= items->elements; uint select_field_count= items->elements;
@ -3245,7 +3245,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
while ((item=it++)) while ((item=it++))
{ {
create_field *cr_field; Create_field *cr_field;
Field *field, *def_field; Field *field, *def_field;
if (item->type() == Item::FUNC_ITEM) if (item->type() == Item::FUNC_ITEM)
field= item->tmp_table_field(&tmp_table); field= item->tmp_table_field(&tmp_table);
@ -3254,7 +3254,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
(Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0, (Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0,
0); 0);
if (!field || if (!field ||
!(cr_field=new create_field(field,(item->type() == Item::FIELD_ITEM ? !(cr_field=new Create_field(field,(item->type() == Item::FIELD_ITEM ?
((Item_field *)item)->field : ((Item_field *)item)->field :
(Field*) 0)))) (Field*) 0))))
DBUG_RETURN(0); DBUG_RETURN(0);

View File

@ -1135,7 +1135,7 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root)
/* /*
Make deep copies of used objects. Make deep copies of used objects.
This is not a fully deep copy - clone() implementations This is not a fully deep copy - clone() implementations
of Alter_drop, Alter_column, Key, foreign_key, key_part_spec of Alter_drop, Alter_column, Key, foreign_key, Key_part_spec
do not copy string constants. At the same length the only do not copy string constants. At the same length the only
reason we make a copy currently is that ALTER/CREATE TABLE reason we make a copy currently is that ALTER/CREATE TABLE
code changes input Alter_info definitions, but string code changes input Alter_info definitions, but string

View File

@ -830,13 +830,6 @@ inline bool st_select_lex_unit::is_union ()
#define ALTER_REMOVE_PARTITIONING (1L << 25) #define ALTER_REMOVE_PARTITIONING (1L << 25)
#define ALTER_FOREIGN_KEY (1L << 26) #define ALTER_FOREIGN_KEY (1L << 26)
enum enum_alter_table_change_level
{
ALTER_TABLE_METADATA_ONLY= 0,
ALTER_TABLE_DATA_CHANGED= 1,
ALTER_TABLE_INDEX_CHANGED= 2
};
/** /**
@brief Parsing data for CREATE or ALTER TABLE. @brief Parsing data for CREATE or ALTER TABLE.
@ -847,28 +840,21 @@ enum enum_alter_table_change_level
class Alter_info class Alter_info
{ {
public: public:
List<Alter_drop> drop_list; List<Alter_drop> drop_list;
List<Alter_column> alter_list; List<Alter_column> alter_list;
List<Key> key_list; List<Key> key_list;
List<create_field> create_list; List<Create_field> create_list;
uint flags; uint flags;
enum enum_enable_or_disable keys_onoff; enum enum_enable_or_disable keys_onoff;
enum tablespace_op_type tablespace_op; enum tablespace_op_type tablespace_op;
List<char> partition_names; List<char> partition_names;
uint no_parts; uint no_parts;
enum_alter_table_change_level change_level;
create_field *datetime_field;
bool error_if_not_empty;
Alter_info() : Alter_info() :
flags(0), flags(0),
keys_onoff(LEAVE_AS_IS), keys_onoff(LEAVE_AS_IS),
tablespace_op(NO_TABLESPACE_OP), tablespace_op(NO_TABLESPACE_OP),
no_parts(0), no_parts(0)
change_level(ALTER_TABLE_METADATA_ONLY),
datetime_field(NULL),
error_if_not_empty(FALSE)
{} {}
void reset() void reset()
@ -882,9 +868,6 @@ public:
tablespace_op= NO_TABLESPACE_OP; tablespace_op= NO_TABLESPACE_OP;
no_parts= 0; no_parts= 0;
partition_names.empty(); partition_names.empty();
change_level= ALTER_TABLE_METADATA_ONLY;
datetime_field= 0;
error_if_not_empty= FALSE;
} }
/** /**
Construct a copy of this object to be used for mysql_alter_table Construct a copy of this object to be used for mysql_alter_table
@ -1149,8 +1132,8 @@ typedef struct st_lex : public Query_tables_list
*/ */
LEX_USER *definer; LEX_USER *definer;
List<key_part_spec> col_list; List<Key_part_spec> col_list;
List<key_part_spec> ref_list; List<Key_part_spec> ref_list;
List<String> interval_list; List<String> interval_list;
List<LEX_USER> users_list; List<LEX_USER> users_list;
List<LEX_COLUMN> columns; List<LEX_COLUMN> columns;
@ -1176,7 +1159,7 @@ typedef struct st_lex : public Query_tables_list
List<LEX_STRING> db_list; List<LEX_STRING> db_list;
SQL_LIST proc_list, auxiliary_table_list, save_list; SQL_LIST proc_list, auxiliary_table_list, save_list;
create_field *last_field; Create_field *last_field;
Item_sum *in_sum_func; Item_sum *in_sum_func;
udf_func udf; udf_func udf;
HA_CHECK_OPT check_opt; // check/repair options HA_CHECK_OPT check_opt; // check/repair options

View File

@ -5456,7 +5456,7 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
List<String> *interval_list, CHARSET_INFO *cs, List<String> *interval_list, CHARSET_INFO *cs,
uint uint_geom_type) uint uint_geom_type)
{ {
register create_field *new_field; register Create_field *new_field;
LEX *lex= thd->lex; LEX *lex= thd->lex;
DBUG_ENTER("add_field_to_list"); DBUG_ENTER("add_field_to_list");
@ -5469,7 +5469,7 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
if (type_modifier & PRI_KEY_FLAG) if (type_modifier & PRI_KEY_FLAG)
{ {
Key *key; Key *key;
lex->col_list.push_back(new key_part_spec(field_name->str, 0)); lex->col_list.push_back(new Key_part_spec(field_name->str, 0));
key= new Key(Key::PRIMARY, NullS, key= new Key(Key::PRIMARY, NullS,
&default_key_create_info, &default_key_create_info,
0, lex->col_list); 0, lex->col_list);
@ -5479,7 +5479,7 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
if (type_modifier & (UNIQUE_FLAG | UNIQUE_KEY_FLAG)) if (type_modifier & (UNIQUE_FLAG | UNIQUE_KEY_FLAG))
{ {
Key *key; Key *key;
lex->col_list.push_back(new key_part_spec(field_name->str, 0)); lex->col_list.push_back(new Key_part_spec(field_name->str, 0));
key= new Key(Key::UNIQUE, NullS, key= new Key(Key::UNIQUE, NullS,
&default_key_create_info, 0, &default_key_create_info, 0,
lex->col_list); lex->col_list);
@ -5537,7 +5537,7 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
WARN_DEPRECATED(thd, "5.2", buf, "'TIMESTAMP'"); WARN_DEPRECATED(thd, "5.2", buf, "'TIMESTAMP'");
} }
if (!(new_field= new create_field()) || if (!(new_field= new Create_field()) ||
new_field->init(thd, field_name->str, type, length, decimals, type_modifier, new_field->init(thd, field_name->str, type, length, decimals, type_modifier,
default_value, on_update_value, comment, change, default_value, on_update_value, comment, change,
interval_list, cs, uint_geom_type)) interval_list, cs, uint_geom_type))

View File

@ -10080,12 +10080,12 @@ err:
0 if out of memory, TABLE object in case of success 0 if out of memory, TABLE object in case of success
*/ */
TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list) TABLE *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list)
{ {
uint field_count= field_list.elements; uint field_count= field_list.elements;
uint blob_count= 0; uint blob_count= 0;
Field **field; Field **field;
create_field *cdef; /* column definition */ Create_field *cdef; /* column definition */
uint record_length= 0; uint record_length= 0;
uint null_count= 0; /* number of columns which may be null */ uint null_count= 0; /* number of columns which may be null */
uint null_pack_length; /* NULL representation array length */ uint null_pack_length; /* NULL representation array length */
@ -10113,7 +10113,7 @@ TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list)
setup_tmp_table_column_bitmaps(table, bitmaps); setup_tmp_table_column_bitmaps(table, bitmaps);
/* Create all fields and calculate the total length of record */ /* Create all fields and calculate the total length of record */
List_iterator_fast<create_field> it(field_list); List_iterator_fast<Create_field> it(field_list);
while ((cdef= it++)) while ((cdef= it++))
{ {
*field= make_field(share, 0, cdef->length, *field= make_field(share, 0, cdef->length,

View File

@ -34,13 +34,13 @@ const char *primary_key_name="PRIMARY";
static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end); static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end);
static char *make_unique_key_name(const char *field_name,KEY *start,KEY *end); static char *make_unique_key_name(const char *field_name,KEY *start,KEY *end);
static int copy_data_between_tables(TABLE *from,TABLE *to, static int copy_data_between_tables(TABLE *from,TABLE *to,
List<create_field> &create, bool ignore, List<Create_field> &create, bool ignore,
uint order_num, ORDER *order, uint order_num, ORDER *order,
ha_rows *copied,ha_rows *deleted, ha_rows *copied,ha_rows *deleted,
enum enum_enable_or_disable keys_onoff, enum enum_enable_or_disable keys_onoff,
bool error_if_not_empty); bool error_if_not_empty);
static bool prepare_blob_field(THD *thd, create_field *sql_field); static bool prepare_blob_field(THD *thd, Create_field *sql_field);
static bool check_engine(THD *, const char *, HA_CREATE_INFO *); static bool check_engine(THD *, const char *, HA_CREATE_INFO *);
static bool static bool
mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
@ -1909,7 +1909,7 @@ void calculate_interval_lengths(CHARSET_INFO *cs, TYPELIB *interval,
table_flags table flags table_flags table flags
DESCRIPTION DESCRIPTION
This function prepares a create_field instance. This function prepares a Create_field instance.
Fields such as pack_flag are valid after this call. Fields such as pack_flag are valid after this call.
RETURN VALUES RETURN VALUES
@ -1917,7 +1917,7 @@ void calculate_interval_lengths(CHARSET_INFO *cs, TYPELIB *interval,
1 Error 1 Error
*/ */
int prepare_create_field(create_field *sql_field, int prepare_create_field(Create_field *sql_field,
uint *blob_columns, uint *blob_columns,
int *timestamps, int *timestamps_with_niladic, int *timestamps, int *timestamps_with_niladic,
longlong table_flags) longlong table_flags)
@ -2108,7 +2108,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
uint *key_count, int select_field_count) uint *key_count, int select_field_count)
{ {
const char *key_name; const char *key_name;
create_field *sql_field,*dup_field; Create_field *sql_field,*dup_field;
uint field,null_fields,blob_columns,max_key_length; uint field,null_fields,blob_columns,max_key_length;
ulong record_offset= 0; ulong record_offset= 0;
KEY *key_info; KEY *key_info;
@ -2116,8 +2116,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
int timestamps= 0, timestamps_with_niladic= 0; int timestamps= 0, timestamps_with_niladic= 0;
int field_no,dup_no; int field_no,dup_no;
int select_field_pos,auto_increment=0; int select_field_pos,auto_increment=0;
List_iterator<create_field> it(alter_info->create_list); List_iterator<Create_field> it(alter_info->create_list);
List_iterator<create_field> it2(alter_info->create_list); List_iterator<Create_field> it2(alter_info->create_list);
uint total_uneven_bit_length= 0; uint total_uneven_bit_length= 0;
DBUG_ENTER("mysql_prepare_create_table"); DBUG_ENTER("mysql_prepare_create_table");
@ -2171,7 +2171,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->sql_type == MYSQL_TYPE_ENUM)) sql_field->sql_type == MYSQL_TYPE_ENUM))
{ {
/* /*
Starting from 5.1 we work here with a copy of create_field Starting from 5.1 we work here with a copy of Create_field
created by the caller, not with the instance that was created by the caller, not with the instance that was
originally created during parsing. It's OK to create originally created during parsing. It's OK to create
a temporary item and initialize with it a member of the a temporary item and initialize with it a member of the
@ -2462,7 +2462,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (key->type == Key::FOREIGN_KEY) if (key->type == Key::FOREIGN_KEY)
{ {
fk_key_count++; fk_key_count++;
foreign_key *fk_key= (foreign_key*) key; Foreign_key *fk_key= (Foreign_key*) key;
if (fk_key->ref_columns.elements && if (fk_key->ref_columns.elements &&
fk_key->ref_columns.elements != fk_key->columns.elements) fk_key->ref_columns.elements != fk_key->columns.elements)
{ {
@ -2546,7 +2546,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
for (; (key=key_iterator++) ; key_number++) for (; (key=key_iterator++) ; key_number++)
{ {
uint key_length=0; uint key_length=0;
key_part_spec *column; Key_part_spec *column;
if (key->name == ignore_key) if (key->name == ignore_key)
{ {
@ -2655,12 +2655,12 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (key_info->block_size) if (key_info->block_size)
key_info->flags|= HA_USES_BLOCK_SIZE; key_info->flags|= HA_USES_BLOCK_SIZE;
List_iterator<key_part_spec> cols(key->columns), cols2(key->columns); List_iterator<Key_part_spec> cols(key->columns), cols2(key->columns);
CHARSET_INFO *ft_key_charset=0; // for FULLTEXT CHARSET_INFO *ft_key_charset=0; // for FULLTEXT
for (uint column_nr=0 ; (column=cols++) ; column_nr++) for (uint column_nr=0 ; (column=cols++) ; column_nr++)
{ {
uint length; uint length;
key_part_spec *dup_column; Key_part_spec *dup_column;
it.rewind(); it.rewind();
field=0; field=0;
@ -2970,7 +2970,7 @@ static void set_table_default_charset(THD *thd,
In this case the error is given In this case the error is given
*/ */
static bool prepare_blob_field(THD *thd, create_field *sql_field) static bool prepare_blob_field(THD *thd, Create_field *sql_field)
{ {
DBUG_ENTER("prepare_blob_field"); DBUG_ENTER("prepare_blob_field");
@ -3011,7 +3011,7 @@ static bool prepare_blob_field(THD *thd, create_field *sql_field)
/* /*
Preparation of create_field for SP function return values. Preparation of Create_field for SP function return values.
Based on code used in the inner loop of mysql_prepare_create_table() Based on code used in the inner loop of mysql_prepare_create_table()
above. above.
@ -3025,7 +3025,7 @@ static bool prepare_blob_field(THD *thd, create_field *sql_field)
*/ */
void sp_prepare_create_field(THD *thd, create_field *sql_field) void sp_prepare_create_field(THD *thd, Create_field *sql_field)
{ {
if (sql_field->sql_type == MYSQL_TYPE_SET || if (sql_field->sql_type == MYSQL_TYPE_SET ||
sql_field->sql_type == MYSQL_TYPE_ENUM) sql_field->sql_type == MYSQL_TYPE_ENUM)
@ -4917,8 +4917,8 @@ compare_tables(TABLE *table,
Field **f_ptr, *field; Field **f_ptr, *field;
uint changes= 0, tmp; uint changes= 0, tmp;
uint key_count; uint key_count;
List_iterator_fast<create_field> new_field_it(alter_info->create_list); List_iterator_fast<Create_field> new_field_it(alter_info->create_list);
create_field *new_field; Create_field *new_field;
KEY_PART_INFO *key_part; KEY_PART_INFO *key_part;
KEY_PART_INFO *end; KEY_PART_INFO *end;
/* /*
@ -5265,16 +5265,16 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
Alter_info *alter_info) Alter_info *alter_info)
{ {
/* New column definitions are added here */ /* New column definitions are added here */
List<create_field> new_create_list; List<Create_field> new_create_list;
/* New key definitions are added here */ /* New key definitions are added here */
List<Key> new_key_list; List<Key> new_key_list;
List_iterator<Alter_drop> drop_it(alter_info->drop_list); List_iterator<Alter_drop> drop_it(alter_info->drop_list);
List_iterator<create_field> def_it(alter_info->create_list); List_iterator<Create_field> def_it(alter_info->create_list);
List_iterator<Alter_column> alter_it(alter_info->alter_list); List_iterator<Alter_column> alter_it(alter_info->alter_list);
List_iterator<Key> key_it(alter_info->key_list); List_iterator<Key> key_it(alter_info->key_list);
List_iterator<create_field> find_it(new_create_list); List_iterator<Create_field> find_it(new_create_list);
List_iterator<create_field> field_it(new_create_list); List_iterator<Create_field> field_it(new_create_list);
List<key_part_spec> key_parts; List<Key_part_spec> key_parts;
uint db_create_options= (table->s->db_create_options uint db_create_options= (table->s->db_create_options
& ~(HA_OPTION_PACK_RECORD)); & ~(HA_OPTION_PACK_RECORD));
uint used_fields= create_info->used_fields; uint used_fields= create_info->used_fields;
@ -5314,7 +5314,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
create_info->tablespace= tablespace; create_info->tablespace= tablespace;
} }
restore_record(table, s->default_values); // Empty record for DEFAULT restore_record(table, s->default_values); // Empty record for DEFAULT
create_field *def; Create_field *def;
/* /*
First collect all fields from table which isn't in drop_list First collect all fields from table which isn't in drop_list
@ -5370,7 +5370,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
This field was not dropped and not changed, add it to the list This field was not dropped and not changed, add it to the list
for the new table. for the new table.
*/ */
def= new create_field(field, field); def= new Create_field(field, field);
new_create_list.push_back(def); new_create_list.push_back(def);
alter_it.rewind(); // Change default if ALTER alter_it.rewind(); // Change default if ALTER
Alter_column *alter; Alter_column *alter;
@ -5425,7 +5425,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
new_create_list.push_front(def); new_create_list.push_front(def);
else else
{ {
create_field *find; Create_field *find;
find_it.rewind(); find_it.rewind();
while ((find=find_it++)) // Add new columns while ((find=find_it++)) // Add new columns
{ {
@ -5483,7 +5483,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
if (!key_part->field) if (!key_part->field)
continue; // Wrong field (from UNIREG) continue; // Wrong field (from UNIREG)
const char *key_part_name=key_part->field->field_name; const char *key_part_name=key_part->field->field_name;
create_field *cfield; Create_field *cfield;
field_it.rewind(); field_it.rewind();
while ((cfield=field_it++)) while ((cfield=field_it++))
{ {
@ -5525,7 +5525,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
key_part_length= 0; // Use whole field key_part_length= 0; // Use whole field
} }
key_part_length /= key_part->field->charset()->mbmaxlen; key_part_length /= key_part->field->charset()->mbmaxlen;
key_parts.push_back(new key_part_spec(cfield->field_name, key_parts.push_back(new Key_part_spec(cfield->field_name,
key_part_length)); key_part_length));
} }
if (key_parts.elements) if (key_parts.elements)
@ -6722,7 +6722,7 @@ err_with_placeholders:
static int static int
copy_data_between_tables(TABLE *from,TABLE *to, copy_data_between_tables(TABLE *from,TABLE *to,
List<create_field> &create, List<Create_field> &create,
bool ignore, bool ignore,
uint order_num, ORDER *order, uint order_num, ORDER *order,
ha_rows *copied, ha_rows *copied,
@ -6776,8 +6776,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
save_sql_mode= thd->variables.sql_mode; save_sql_mode= thd->variables.sql_mode;
List_iterator<create_field> it(create); List_iterator<Create_field> it(create);
create_field *def; Create_field *def;
copy_end=copy; copy_end=copy;
for (Field **ptr=to->field ; *ptr ; ptr++) for (Field **ptr=to->field ; *ptr ; ptr++)
{ {

View File

@ -456,7 +456,7 @@ Item* handle_sql2003_note184_exception(THD *thd, Item* left, bool equal,
List<Item> *item_list; List<Item> *item_list;
List<String> *string_list; List<String> *string_list;
String *string; String *string;
key_part_spec *key_part; Key_part_spec *key_part;
TABLE_LIST *table_list; TABLE_LIST *table_list;
udf_func *udf; udf_func *udf;
LEX_USER *lex_user; LEX_USER *lex_user;
@ -4498,7 +4498,7 @@ key_def:
{ {
LEX *lex=Lex; LEX *lex=Lex;
const char *key_name= $4 ? $4 : $1; const char *key_name= $4 ? $4 : $1;
Key *key= new foreign_key(key_name, lex->col_list, Key *key= new Foreign_key(key_name, lex->col_list,
$8, $8,
lex->ref_list, lex->ref_list,
lex->fk_delete_opt, lex->fk_delete_opt,
@ -4925,8 +4925,8 @@ opt_ref_list:
| '(' ref_list ')' opt_on_delete {}; | '(' ref_list ')' opt_on_delete {};
ref_list: ref_list:
ref_list ',' ident { Lex->ref_list.push_back(new key_part_spec($3.str)); } ref_list ',' ident { Lex->ref_list.push_back(new Key_part_spec($3.str)); }
| ident { Lex->ref_list.push_back(new key_part_spec($1.str)); }; | ident { Lex->ref_list.push_back(new Key_part_spec($1.str)); };
opt_on_delete: opt_on_delete:
@ -4940,16 +4940,16 @@ opt_on_delete_list:
opt_on_delete_item: opt_on_delete_item:
ON DELETE_SYM delete_option { Lex->fk_delete_opt= $3; } ON DELETE_SYM delete_option { Lex->fk_delete_opt= $3; }
| ON UPDATE_SYM delete_option { Lex->fk_update_opt= $3; } | ON UPDATE_SYM delete_option { Lex->fk_update_opt= $3; }
| MATCH FULL { Lex->fk_match_option= foreign_key::FK_MATCH_FULL; } | MATCH FULL { Lex->fk_match_option= Foreign_key::FK_MATCH_FULL; }
| MATCH PARTIAL { Lex->fk_match_option= foreign_key::FK_MATCH_PARTIAL; } | MATCH PARTIAL { Lex->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
| MATCH SIMPLE_SYM { Lex->fk_match_option= foreign_key::FK_MATCH_SIMPLE; }; | MATCH SIMPLE_SYM { Lex->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; };
delete_option: delete_option:
RESTRICT { $$= (int) foreign_key::FK_OPTION_RESTRICT; } RESTRICT { $$= (int) Foreign_key::FK_OPTION_RESTRICT; }
| CASCADE { $$= (int) foreign_key::FK_OPTION_CASCADE; } | CASCADE { $$= (int) Foreign_key::FK_OPTION_CASCADE; }
| SET NULL_SYM { $$= (int) foreign_key::FK_OPTION_SET_NULL; } | SET NULL_SYM { $$= (int) Foreign_key::FK_OPTION_SET_NULL; }
| NO_SYM ACTION { $$= (int) foreign_key::FK_OPTION_NO_ACTION; } | NO_SYM ACTION { $$= (int) Foreign_key::FK_OPTION_NO_ACTION; }
| SET DEFAULT { $$= (int) foreign_key::FK_OPTION_DEFAULT; }; | SET DEFAULT { $$= (int) Foreign_key::FK_OPTION_DEFAULT; };
key_type: key_type:
key_or_index { $$= Key::MULTIPLE; } key_or_index { $$= Key::MULTIPLE; }
@ -5061,7 +5061,7 @@ key_list:
| key_part order_dir { Lex->col_list.push_back($1); }; | key_part order_dir { Lex->col_list.push_back($1); };
key_part: key_part:
ident { $$=new key_part_spec($1.str); } ident { $$=new Key_part_spec($1.str); }
| ident '(' NUM ')' | ident '(' NUM ')'
{ {
int key_part_len= atoi($3.str); int key_part_len= atoi($3.str);
@ -5069,7 +5069,7 @@ key_part:
{ {
my_error(ER_KEY_PART_0, MYF(0), $1.str); my_error(ER_KEY_PART_0, MYF(0), $1.str);
} }
$$=new key_part_spec($1.str,(uint) key_part_len); $$=new Key_part_spec($1.str,(uint) key_part_len);
}; };
opt_ident: opt_ident:

View File

@ -29,21 +29,21 @@
#define FCOMP 17 /* Bytes for a packed field */ #define FCOMP 17 /* Bytes for a packed field */
static uchar * pack_screens(List<create_field> &create_fields, static uchar * pack_screens(List<Create_field> &create_fields,
uint *info_length, uint *screens, bool small_file); uint *info_length, uint *screens, bool small_file);
static uint pack_keys(uchar *keybuff,uint key_count, KEY *key_info, static uint pack_keys(uchar *keybuff,uint key_count, KEY *key_info,
ulong data_offset); ulong data_offset);
static bool pack_header(uchar *forminfo,enum legacy_db_type table_type, static bool pack_header(uchar *forminfo,enum legacy_db_type table_type,
List<create_field> &create_fields, List<Create_field> &create_fields,
uint info_length, uint screens, uint table_options, uint info_length, uint screens, uint table_options,
ulong data_offset, handler *file); ulong data_offset, handler *file);
static uint get_interval_id(uint *int_count,List<create_field> &create_fields, static uint get_interval_id(uint *int_count,List<Create_field> &create_fields,
create_field *last_field); Create_field *last_field);
static bool pack_fields(File file, List<create_field> &create_fields, static bool pack_fields(File file, List<Create_field> &create_fields,
ulong data_offset); ulong data_offset);
static bool make_empty_rec(THD *thd, int file, enum legacy_db_type table_type, static bool make_empty_rec(THD *thd, int file, enum legacy_db_type table_type,
uint table_options, uint table_options,
List<create_field> &create_fields, List<Create_field> &create_fields,
uint reclength, ulong data_offset, uint reclength, ulong data_offset,
handler *handler); handler *handler);
@ -70,7 +70,7 @@ static bool make_empty_rec(THD *thd, int file, enum legacy_db_type table_type,
bool mysql_create_frm(THD *thd, const char *file_name, bool mysql_create_frm(THD *thd, const char *file_name,
const char *db, const char *table, const char *db, const char *table,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &create_fields, List<Create_field> &create_fields,
uint keys, KEY *key_info, uint keys, KEY *key_info,
handler *db_file) handler *db_file)
{ {
@ -294,8 +294,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
Restore all UCS2 intervals. Restore all UCS2 intervals.
HEX representation of them is not needed anymore. HEX representation of them is not needed anymore.
*/ */
List_iterator<create_field> it(create_fields); List_iterator<Create_field> it(create_fields);
create_field *field; Create_field *field;
while ((field=it++)) while ((field=it++))
{ {
if (field->save_interval) if (field->save_interval)
@ -341,7 +341,7 @@ err3:
int rea_create_table(THD *thd, const char *path, int rea_create_table(THD *thd, const char *path,
const char *db, const char *table_name, const char *db, const char *table_name,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &create_fields, List<Create_field> &create_fields,
uint keys, KEY *key_info, handler *file) uint keys, KEY *key_info, handler *file)
{ {
DBUG_ENTER("rea_create_table"); DBUG_ENTER("rea_create_table");
@ -371,7 +371,7 @@ err_handler:
/* Pack screens to a screen for save in a form-file */ /* Pack screens to a screen for save in a form-file */
static uchar *pack_screens(List<create_field> &create_fields, static uchar *pack_screens(List<Create_field> &create_fields,
uint *info_length, uint *screens, uint *info_length, uint *screens,
bool small_file) bool small_file)
{ {
@ -380,7 +380,7 @@ static uchar *pack_screens(List<create_field> &create_fields,
uint length,cols; uint length,cols;
uchar *info,*pos,*start_screen; uchar *info,*pos,*start_screen;
uint fields=create_fields.elements; uint fields=create_fields.elements;
List_iterator<create_field> it(create_fields); List_iterator<Create_field> it(create_fields);
DBUG_ENTER("pack_screens"); DBUG_ENTER("pack_screens");
start_row=4; end_row=22; cols=80; fields_on_screen=end_row+1-start_row; start_row=4; end_row=22; cols=80; fields_on_screen=end_row+1-start_row;
@ -388,7 +388,7 @@ static uchar *pack_screens(List<create_field> &create_fields,
*screens=(fields-1)/fields_on_screen+1; *screens=(fields-1)/fields_on_screen+1;
length= (*screens) * (SC_INFO_LENGTH+ (cols>> 1)+4); length= (*screens) * (SC_INFO_LENGTH+ (cols>> 1)+4);
create_field *field; Create_field *field;
while ((field=it++)) while ((field=it++))
length+=(uint) strlen(field->field_name)+1+TE_INFO_LENGTH+cols/2; length+=(uint) strlen(field->field_name)+1+TE_INFO_LENGTH+cols/2;
@ -401,7 +401,7 @@ static uchar *pack_screens(List<create_field> &create_fields,
it.rewind(); it.rewind();
for (i=0 ; i < fields ; i++) for (i=0 ; i < fields ; i++)
{ {
create_field *cfield=it++; Create_field *cfield=it++;
if (row++ == end_row) if (row++ == end_row)
{ {
if (i) if (i)
@ -521,7 +521,7 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
/* Make formheader */ /* Make formheader */
static bool pack_header(uchar *forminfo, enum legacy_db_type table_type, static bool pack_header(uchar *forminfo, enum legacy_db_type table_type,
List<create_field> &create_fields, List<Create_field> &create_fields,
uint info_length, uint screens, uint table_options, uint info_length, uint screens, uint table_options,
ulong data_offset, handler *file) ulong data_offset, handler *file)
{ {
@ -544,8 +544,8 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type,
/* Check fields */ /* Check fields */
List_iterator<create_field> it(create_fields); List_iterator<Create_field> it(create_fields);
create_field *field; Create_field *field;
while ((field=it++)) while ((field=it++))
{ {
uint tmp_len= system_charset_info->cset->charpos(system_charset_info, uint tmp_len= system_charset_info->cset->charpos(system_charset_info,
@ -687,11 +687,11 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type,
/* get each unique interval each own id */ /* get each unique interval each own id */
static uint get_interval_id(uint *int_count,List<create_field> &create_fields, static uint get_interval_id(uint *int_count,List<Create_field> &create_fields,
create_field *last_field) Create_field *last_field)
{ {
List_iterator<create_field> it(create_fields); List_iterator<Create_field> it(create_fields);
create_field *field; Create_field *field;
TYPELIB *interval=last_field->interval; TYPELIB *interval=last_field->interval;
while ((field=it++) != last_field) while ((field=it++) != last_field)
@ -715,18 +715,18 @@ static uint get_interval_id(uint *int_count,List<create_field> &create_fields,
/* Save fields, fieldnames and intervals */ /* Save fields, fieldnames and intervals */
static bool pack_fields(File file, List<create_field> &create_fields, static bool pack_fields(File file, List<Create_field> &create_fields,
ulong data_offset) ulong data_offset)
{ {
reg2 uint i; reg2 uint i;
uint int_count, comment_length=0; uint int_count, comment_length=0;
uchar buff[MAX_FIELD_WIDTH]; uchar buff[MAX_FIELD_WIDTH];
create_field *field; Create_field *field;
DBUG_ENTER("pack_fields"); DBUG_ENTER("pack_fields");
/* Write field info */ /* Write field info */
List_iterator<create_field> it(create_fields); List_iterator<Create_field> it(create_fields);
int_count=0; int_count=0;
while ((field=it++)) while ((field=it++))
@ -856,7 +856,7 @@ static bool pack_fields(File file, List<create_field> &create_fields,
static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type, static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type,
uint table_options, uint table_options,
List<create_field> &create_fields, List<Create_field> &create_fields,
uint reclength, uint reclength,
ulong data_offset, ulong data_offset,
handler *handler) handler *handler)
@ -867,7 +867,7 @@ static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type,
uchar *buff,*null_pos; uchar *buff,*null_pos;
TABLE table; TABLE table;
TABLE_SHARE share; TABLE_SHARE share;
create_field *field; Create_field *field;
enum_check_fields old_count_cuted_fields= thd->count_cuted_fields; enum_check_fields old_count_cuted_fields= thd->count_cuted_fields;
DBUG_ENTER("make_empty_rec"); DBUG_ENTER("make_empty_rec");
@ -893,7 +893,7 @@ static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type,
} }
null_pos= buff; null_pos= buff;
List_iterator<create_field> it(create_fields); List_iterator<Create_field> it(create_fields);
thd->count_cuted_fields= CHECK_FIELD_WARN; // To find wrong default values thd->count_cuted_fields= CHECK_FIELD_WARN; // To find wrong default values
while ((field=it++)) while ((field=it++))
{ {

View File

@ -74,6 +74,7 @@
#define MAX_TIME_WIDTH 23 /* -DDDDDD HH:MM:SS.###### */ #define MAX_TIME_WIDTH 23 /* -DDDDDD HH:MM:SS.###### */
#define MAX_DATETIME_FULL_WIDTH 29 /* YYYY-MM-DD HH:MM:SS.###### AM */ #define MAX_DATETIME_FULL_WIDTH 29 /* YYYY-MM-DD HH:MM:SS.###### AM */
#define MAX_DATETIME_WIDTH 19 /* YYYY-MM-DD HH:MM:SS */ #define MAX_DATETIME_WIDTH 19 /* YYYY-MM-DD HH:MM:SS */
#define MAX_DATETIME_COMPRESSED_WIDTH 14 /* YYYYMMDDHHMMSS */
#define MAX_TABLES (sizeof(table_map)*8-3) /* Max tables in join */ #define MAX_TABLES (sizeof(table_map)*8-3) /* Max tables in join */
#define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3)) #define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3))

View File

@ -16161,6 +16161,59 @@ static void test_bug27876()
} }
/*
Bug#27592 (stack overrun when storing datetime value using prepared statements)
*/
static void test_bug27592()
{
const int NUM_ITERATIONS= 40;
int i;
int rc;
MYSQL_STMT *stmt= NULL;
MYSQL_BIND bind[1];
MYSQL_TIME time_val;
DBUG_ENTER("test_bug27592");
myheader("test_bug27592");
mysql_query(mysql, "DROP TABLE IF EXISTS t1");
mysql_query(mysql, "CREATE TABLE t1(c2 DATETIME)");
stmt= mysql_simple_prepare(mysql, "INSERT INTO t1 VALUES (?)");
DIE_UNLESS(stmt);
memset(bind, 0, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_DATETIME;
bind[0].buffer= (char *) &time_val;
bind[0].length= NULL;
for (i= 0; i < NUM_ITERATIONS; i++)
{
time_val.year= 2007;
time_val.month= 6;
time_val.day= 7;
time_val.hour= 18;
time_val.minute= 41;
time_val.second= 3;
time_val.second_part=0;
time_val.neg=0;
rc= mysql_stmt_bind_param(stmt, bind);
check_execute(stmt, rc);
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
}
mysql_stmt_close(stmt);
DBUG_VOID_RETURN;
}
/* /*
Read and parse arguments and MySQL options from my.cnf Read and parse arguments and MySQL options from my.cnf
*/ */
@ -16449,6 +16502,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug28075", test_bug28075 }, { "test_bug28075", test_bug28075 },
#endif #endif
{ "test_bug27876", test_bug27876 }, { "test_bug27876", test_bug27876 },
{ "test_bug27592", test_bug27592 },
{ 0, 0 } { 0, 0 }
}; };