From 523c849d14acf041670337afa6a7e2a6deeaab67 Mon Sep 17 00:00:00 2001 From: Jorgen Loland Date: Fri, 18 Nov 2011 14:47:11 +0100 Subject: Backmerge of BUG#12997905 --- sql/field_conv.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/field_conv.cc') diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 1dc7ec57944..ff56a1fdda8 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -707,7 +707,7 @@ Copy_field::get_copy_func(Field *to,Field *from) if (((Field_varstring*) to)->length_bytes != ((Field_varstring*) from)->length_bytes) return do_field_string; - if (to_length != from_length) + else return (((Field_varstring*) to)->length_bytes == 1 ? (from->charset()->mbmaxlen == 1 ? do_varstring1 : do_varstring1_mb) : -- cgit v1.2.1 From 0b590282fc116a1911eabe4cf1c7804a66f9bb48 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sun, 8 Jan 2012 14:43:14 +0400 Subject: BUG#912510: Crash in do_copy_not_null with semijoin=ON, firstmatch=ON, aggregate ... - Create/use do_copy_nullable_row_to_notnull() function for ref access, which is used when copying from not-NULL field in table that can be NULL-complemented to not-NULL field. --- sql/field_conv.cc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'sql/field_conv.cc') diff --git a/sql/field_conv.cc b/sql/field_conv.cc index ce914f7b368..ed910c4ef70 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -248,6 +248,25 @@ static void do_outer_field_null(Copy_field *copy) } } +/* + Copy: (not-NULL field in table that can be NULL-complemented) -> (not-NULL + field) +*/ +static void do_copy_nullable_row_to_notnull(Copy_field *copy) +{ + if (*copy->null_row || + (copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit))) + { + copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_DATA_TRUNCATED, 1); + copy->to_field->reset(); + } + else + { + (copy->do_copy2)(copy); + } + +} /* Copy: (NULL-able field) -> (not NULL-able field) */ static void do_copy_not_null(Copy_field *copy) @@ -638,7 +657,15 @@ void Copy_field::set(Field *to,Field *from,bool save) else if (to_field == to_field->table->next_number_field) do_copy= do_copy_next_number; else - do_copy= do_copy_not_null; + { + if (!from_null_ptr) + { + null_row= &from->table->null_row; + do_copy= do_copy_nullable_row_to_notnull; + } + else + do_copy= do_copy_not_null; + } } } else if (to_field->real_maybe_null()) -- cgit v1.2.1