diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 42e79754b95..e6cc3272ceb 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3708,29 +3708,39 @@ cmp_item_row::~cmp_item_row() } -void cmp_item_row::alloc_comparators() +void cmp_item_row::alloc_comparators(Item *item) { + n= item->cols(); + DBUG_ASSERT(comparators == NULL); if (!comparators) comparators= (cmp_item **) current_thd->calloc(sizeof(cmp_item *)*n); + if (comparators) + { + for (uint i= 0; i < n; i++) + { + DBUG_ASSERT(comparators[i] == NULL); + Item *item_i= item->element_index(i); + if (!(comparators[i]= + cmp_item::get_comparator(item_i->result_type(), + item_i->collation.collation))) + break; // new failed + if (item_i->result_type() == ROW_RESULT) + static_cast(comparators[i])->alloc_comparators(item_i); + } + } } void cmp_item_row::store_value(Item *item) { DBUG_ENTER("cmp_item_row::store_value"); - n= item->cols(); - alloc_comparators(); + DBUG_ASSERT(comparators); if (comparators) { item->bring_value(); item->null_value= 0; - for (uint i=0; i < n; i++) + for (uint i= 0; i < n; i++) { - if (!comparators[i]) - if (!(comparators[i]= - cmp_item::get_comparator(item->element_index(i)->result_type(), - item->element_index(i)->collation.collation))) - break; // new failed comparators[i]->store_value(item->element_index(i)); item->null_value|= item->element_index(i)->null_value; } @@ -3991,7 +4001,7 @@ void Item_func_in::fix_length_and_dec() cmp_items[ROW_RESULT]= cmp; } cmp->n= args[0]->cols(); - cmp->alloc_comparators(); + cmp->alloc_comparators(args[0]); } /* All DATE/DATETIME fields/functions has the STRING result type. */ if (cmp_type == STRING_RESULT || cmp_type == ROW_RESULT) @@ -4102,11 +4112,8 @@ void Item_func_in::fix_length_and_dec() break; case ROW_RESULT: /* - The row comparator was created at the beginning but only DATETIME - items comparators were initialized. Call store_value() to setup - others. + The row comparator was created at the beginning. */ - ((in_row*)array)->tmp.store_value(args[0]); break; case DECIMAL_RESULT: array= new in_decimal(arg_count - 1); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 38a88d88715..115d6db300d 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1,7 +1,7 @@ #ifndef ITEM_CMPFUNC_INCLUDED #define ITEM_CMPFUNC_INCLUDED -/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1288,7 +1288,7 @@ public: cmp_item_row(): comparators(0), n(0) {} ~cmp_item_row(); void store_value(Item *item); - inline void alloc_comparators(); + inline void alloc_comparators(Item *item); int cmp(Item *arg); int compare(cmp_item *arg); cmp_item *make_same(); diff --git a/sql/table.cc b/sql/table.cc index c17ee39fe9e..750b870da75 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1910,21 +1910,6 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, outparam->record[1]= outparam->record[0]; // Safety } -#ifdef HAVE_purify - /* - We need this because when we read var-length rows, we are not updating - bytes after end of varchar - */ - if (records > 1) - { - memcpy(outparam->record[0], share->default_values, share->rec_buff_length); - memcpy(outparam->record[1], share->default_values, share->null_bytes); - if (records > 2) - memcpy(outparam->record[1], share->default_values, - share->rec_buff_length); - } -#endif - if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root, (uint) ((share->fields+1)* sizeof(Field*)))))