From f240aa4cbfc50de1f2cb83ebce658bd331091f61 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 17 Aug 2011 12:32:15 +0400 Subject: [PATCH] field_conv.cc: added comments opt_range.cc: modified print_key() so that it doesn't do memory re-allocs when printing multipart keys over varchar columns. When it did, key printout in debug trace was interrupted with my_malloc/free printouts. --- sql/field_conv.cc | 14 ++++++++++++++ sql/opt_range.cc | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sql/field_conv.cc b/sql/field_conv.cc index afc4d8252ff..588a99f560f 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -204,6 +204,14 @@ static void do_skip(Copy_field *copy __attribute__((unused))) } +/* + Copy: (NULLable field) -> (NULLable field) + + note: if the record we're copying from is NULL-complemetned (i.e. + from_field->table->null_row==1), it will also have all NULLable columns to be + set to NULLs, so we dont need to check table->null_row here. +*/ + static void do_copy_null(Copy_field *copy) { if (*copy->from_null_ptr & copy->from_bit) @@ -218,6 +226,10 @@ static void do_copy_null(Copy_field *copy) } } +/* + Copy: (not-NULL field in table that can be NULL-complemented) -> (NULLable + field) +*/ static void do_outer_field_null(Copy_field *copy) { @@ -235,6 +247,7 @@ static void do_outer_field_null(Copy_field *copy) } +/* Copy: (NULL-able field) -> (not NULL-able field) */ static void do_copy_not_null(Copy_field *copy) { if (*copy->from_null_ptr & copy->from_bit) @@ -248,6 +261,7 @@ static void do_copy_not_null(Copy_field *copy) } +/* Copy: (non-NULLable field) -> (NULLable field) */ static void do_copy_maybe_null(Copy_field *copy) { *copy->to_null_ptr&= ~copy->to_bit; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 3ed975a59bb..1226144f5ad 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -13644,7 +13644,6 @@ print_key(KEY_PART *key_part, const uchar *key, uint used_length) { char buff[1024]; const uchar *key_end= key+used_length; - String tmp(buff,sizeof(buff),&my_charset_bin); uint store_length; TABLE *table= key_part->field->table; my_bitmap_map *old_sets[2]; @@ -13653,6 +13652,7 @@ print_key(KEY_PART *key_part, const uchar *key, uint used_length) for (; key < key_end; key+=store_length, key_part++) { + String tmp(buff,sizeof(buff),&my_charset_bin); Field *field= key_part->field; store_length= key_part->store_length;