summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorSreeharsha Ramanavarapu <sreeharsha.ramanavarapu@oracle.com>2015-09-18 07:34:32 +0530
committerSreeharsha Ramanavarapu <sreeharsha.ramanavarapu@oracle.com>2015-09-18 07:34:32 +0530
commit4acc7615eedc167fbad6fcc14966a054de35fd75 (patch)
tree6716b628f0845195a255df95994254bda78bca65 /sql/item_cmpfunc.cc
parent17387bc574a4054a9aeac7ba4aa60e25588dc7bf (diff)
downloadmariadb-git-4acc7615eedc167fbad6fcc14966a054de35fd75.tar.gz
Bug #19929406: HANDLE_FATAL_SIGNAL (SIG=11) IN
__MEMMOVE_SSSE3_BACK FROM STRING::COPY Issue: ----- While using row comparators, the store_value functions call val_xxx functions in the prepare phase. This can cause valgrind issues. SOLUTION: --------- Setting up of the comparators should be done by alloc_comparators in the prepare phase. Also, make sure store_value will be called only during execute phase. This is a backport of the fix for Bug#17755540.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc37
1 files changed, 22 insertions, 15 deletions
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<cmp_item_row*>(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);