Skip to content

Commit 4acc761

Browse files
author
Sreeharsha Ramanavarapu
committed
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.
1 parent 17387bc commit 4acc761

File tree

3 files changed

+25
-33
lines changed

3 files changed

+25
-33
lines changed

sql/item_cmpfunc.cc

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -3708,29 +3708,39 @@ cmp_item_row::~cmp_item_row()
37083708
}
37093709

37103710

3711-
void cmp_item_row::alloc_comparators()
3711+
void cmp_item_row::alloc_comparators(Item *item)
37123712
{
3713+
n= item->cols();
3714+
DBUG_ASSERT(comparators == NULL);
37133715
if (!comparators)
37143716
comparators= (cmp_item **) current_thd->calloc(sizeof(cmp_item *)*n);
3717+
if (comparators)
3718+
{
3719+
for (uint i= 0; i < n; i++)
3720+
{
3721+
DBUG_ASSERT(comparators[i] == NULL);
3722+
Item *item_i= item->element_index(i);
3723+
if (!(comparators[i]=
3724+
cmp_item::get_comparator(item_i->result_type(),
3725+
item_i->collation.collation)))
3726+
break; // new failed
3727+
if (item_i->result_type() == ROW_RESULT)
3728+
static_cast<cmp_item_row*>(comparators[i])->alloc_comparators(item_i);
3729+
}
3730+
}
37153731
}
37163732

37173733

37183734
void cmp_item_row::store_value(Item *item)
37193735
{
37203736
DBUG_ENTER("cmp_item_row::store_value");
3721-
n= item->cols();
3722-
alloc_comparators();
3737+
DBUG_ASSERT(comparators);
37233738
if (comparators)
37243739
{
37253740
item->bring_value();
37263741
item->null_value= 0;
3727-
for (uint i=0; i < n; i++)
3742+
for (uint i= 0; i < n; i++)
37283743
{
3729-
if (!comparators[i])
3730-
if (!(comparators[i]=
3731-
cmp_item::get_comparator(item->element_index(i)->result_type(),
3732-
item->element_index(i)->collation.collation)))
3733-
break; // new failed
37343744
comparators[i]->store_value(item->element_index(i));
37353745
item->null_value|= item->element_index(i)->null_value;
37363746
}
@@ -3991,7 +4001,7 @@ void Item_func_in::fix_length_and_dec()
39914001
cmp_items[ROW_RESULT]= cmp;
39924002
}
39934003
cmp->n= args[0]->cols();
3994-
cmp->alloc_comparators();
4004+
cmp->alloc_comparators(args[0]);
39954005
}
39964006
/* All DATE/DATETIME fields/functions has the STRING result type. */
39974007
if (cmp_type == STRING_RESULT || cmp_type == ROW_RESULT)
@@ -4102,11 +4112,8 @@ void Item_func_in::fix_length_and_dec()
41024112
break;
41034113
case ROW_RESULT:
41044114
/*
4105-
The row comparator was created at the beginning but only DATETIME
4106-
items comparators were initialized. Call store_value() to setup
4107-
others.
4115+
The row comparator was created at the beginning.
41084116
*/
4109-
((in_row*)array)->tmp.store_value(args[0]);
41104117
break;
41114118
case DECIMAL_RESULT:
41124119
array= new in_decimal(arg_count - 1);

sql/item_cmpfunc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef ITEM_CMPFUNC_INCLUDED
22
#define ITEM_CMPFUNC_INCLUDED
33

4-
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
4+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
55
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -1288,7 +1288,7 @@ class cmp_item_row :public cmp_item
12881288
cmp_item_row(): comparators(0), n(0) {}
12891289
~cmp_item_row();
12901290
void store_value(Item *item);
1291-
inline void alloc_comparators();
1291+
inline void alloc_comparators(Item *item);
12921292
int cmp(Item *arg);
12931293
int compare(cmp_item *arg);
12941294
cmp_item *make_same();

sql/table.cc

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
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,
19101910
outparam->record[1]= outparam->record[0]; // Safety
19111911
}
19121912

1913-
#ifdef HAVE_purify
1914-
/*
1915-
We need this because when we read var-length rows, we are not updating
1916-
bytes after end of varchar
1917-
*/
1918-
if (records > 1)
1919-
{
1920-
memcpy(outparam->record[0], share->default_values, share->rec_buff_length);
1921-
memcpy(outparam->record[1], share->default_values, share->null_bytes);
1922-
if (records > 2)
1923-
memcpy(outparam->record[1], share->default_values,
1924-
share->rec_buff_length);
1925-
}
1926-
#endif
1927-
19281913
if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root,
19291914
(uint) ((share->fields+1)*
19301915
sizeof(Field*)))))

0 commit comments

Comments
 (0)