#At file:///export/home/didrik/repo/next-mr-opt-backporting-bug56936/ based on revid:tor.didriksen@stripped
3251 Tor Didriksen 2010-09-23
Bug #56936 valgrind warnings, TABLE_REF objects are not properly initialized
Use placement new, and constructor, rather than thd->alloc() and ad-hoc initialization.
@ sql/sql_select.cc
Use placement new.
Fix some missing DBUG_RETURN(TRUE)
@ sql/sql_select.h
st_table_ref: inherit from Sql_alloc, so we can do placement new.
Add constructor.
modified:
sql/sql_select.cc
sql/sql_select.h
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2010-09-22 11:37:38 +0000
+++ b/sql/sql_select.cc 2010-09-23 12:16:36 +0000
@@ -10680,7 +10680,7 @@ bool setup_sj_materialization(JOIN_TAB *
temptable.
*/
TABLE_REF *tab_ref;
- if (!(tab_ref= (TABLE_REF*) thd->alloc(sizeof(TABLE_REF))))
+ if (!(tab_ref= new (thd->mem_root) TABLE_REF))
DBUG_RETURN(TRUE); /* purecov: inspected */
tab_ref->key= 0; /* The only temp table index. */
tab_ref->key_length= tmp_key->key_length;
@@ -10693,10 +10693,8 @@ bool setup_sj_materialization(JOIN_TAB *
(Item**) thd->alloc(sizeof(Item*) * tmp_key_parts)))
DBUG_RETURN(TRUE); /* purecov: inspected */
- tab_ref->key_buff2=tab_ref->key_buff+ALIGN_SIZE(tmp_key->key_length);
- tab_ref->key_err=1;
+ tab_ref->key_buff2= tab_ref->key_buff+ALIGN_SIZE(tmp_key->key_length);
tab_ref->null_rejecting= 1;
- tab_ref->disable_cache= FALSE;
KEY_PART_INFO *cur_key_part= tmp_key->key_part;
store_key **ref_key= tab_ref->key_copy;
@@ -10887,7 +10885,7 @@ make_join_readinfo(JOIN *join, ulonglong
{
if (!(tab->loosescan_buf= (uchar*)join->thd->alloc(tab->
loosescan_key_len)))
- return TRUE; /* purecov: inspected */
+ DBUG_RETURN(TRUE); /* purecov: inspected */
}
if (sj_is_materialize_strategy(join->best_positions[i].sj_strategy))
{
@@ -10900,7 +10898,7 @@ make_join_readinfo(JOIN *join, ulonglong
tab[-1].next_select= sub_select_sjm;
if (setup_sj_materialization(tab))
- return TRUE;
+ DBUG_RETURN(TRUE);
}
switch (tab->type) {
case JT_EQ_REF:
=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h 2010-09-22 11:37:38 +0000
+++ b/sql/sql_select.h 2010-09-23 12:16:36 +0000
@@ -72,7 +72,7 @@ typedef struct keyuse_t {
class store_key;
-typedef struct st_table_ref
+typedef struct st_table_ref : public Sql_alloc
{
bool key_err;
/** True if something was read into buffer in join_read_key. */
@@ -116,6 +116,25 @@ typedef struct st_table_ref
*/
bool disable_cache;
+ st_table_ref()
+ : key_err(TRUE),
+ has_record(FALSE),
+ key_parts(0),
+ key_length(0),
+ key(-1),
+ key_buff(NULL),
+ key_buff2(NULL),
+ key_copy(NULL),
+ items(NULL),
+ cond_guards(NULL),
+ null_rejecting(0),
+ depend_map(0),
+ null_ref_key(NULL),
+ use_count(0),
+ disable_cache(FALSE)
+ {
+ }
+
/**
@returns whether the reference contains NULL values which could never give
a match.
Attachment: [text/bzr-bundle] bzr/tor.didriksen@oracle.com-20100923121636-xdv42pcbfhwvjkqa.bundle
| Thread |
|---|
| • bzr commit into mysql-next-mr-bugfixing branch (tor.didriksen:3251) Bug#56936 | Tor Didriksen | 24 Sep |