summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2012-01-08 14:43:14 +0400
committerSergey Petrunya <psergey@askmonty.org>2012-01-08 14:43:14 +0400
commit0b590282fc116a1911eabe4cf1c7804a66f9bb48 (patch)
treed16ebbfaa4bad9cb8412cfbd4220f5a685126253 /sql/field_conv.cc
parentcd55894a52b5b2bf4a740eb0f39d91d7a82f673c (diff)
downloadmariadb-git-0b590282fc116a1911eabe4cf1c7804a66f9bb48.tar.gz
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.
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc29
1 files changed, 28 insertions, 1 deletions
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())