mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Making a better fix for double released pointers and safe
TMP_TABLE_PARAM. This involved moving things around in include files. All tests, including the ones with Valgrind passed.
This commit is contained in:
@ -815,11 +815,52 @@ public:
|
|||||||
void abort();
|
void abort();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include <myisam.h>
|
||||||
|
|
||||||
|
/* Param to create temporary tables when doing SELECT:s */
|
||||||
|
|
||||||
|
class TMP_TABLE_PARAM :public Sql_alloc
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
List<Item> copy_funcs;
|
||||||
|
List<Item> save_copy_funcs;
|
||||||
|
List_iterator_fast<Item> copy_funcs_it;
|
||||||
|
Copy_field *copy_field, *copy_field_end;
|
||||||
|
Copy_field *save_copy_field, *save_copy_field_end;
|
||||||
|
byte *group_buff;
|
||||||
|
Item **items_to_copy; /* Fields in tmp table */
|
||||||
|
MI_COLUMNDEF *recinfo,*start_recinfo;
|
||||||
|
KEY *keyinfo;
|
||||||
|
ha_rows end_write_records;
|
||||||
|
uint field_count,sum_func_count,func_count;
|
||||||
|
uint hidden_field_count;
|
||||||
|
uint group_parts,group_length,group_null_parts;
|
||||||
|
uint quick_group;
|
||||||
|
bool using_indirect_summary_function;
|
||||||
|
|
||||||
|
TMP_TABLE_PARAM()
|
||||||
|
:copy_funcs_it(copy_funcs), copy_field(0), group_parts(0),
|
||||||
|
group_length(0), group_null_parts(0)
|
||||||
|
{}
|
||||||
|
~TMP_TABLE_PARAM()
|
||||||
|
{
|
||||||
|
cleanup();
|
||||||
|
}
|
||||||
|
inline void cleanup(void)
|
||||||
|
{
|
||||||
|
if (copy_field) /* Fix for Intel compiler */
|
||||||
|
{
|
||||||
|
delete [] copy_field;
|
||||||
|
copy_field=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class select_union :public select_result {
|
class select_union :public select_result {
|
||||||
public:
|
public:
|
||||||
TABLE *table;
|
TABLE *table;
|
||||||
COPY_INFO info;
|
COPY_INFO info;
|
||||||
TMP_TABLE_PARAM *tmp_table_param;
|
TMP_TABLE_PARAM tmp_table_param;
|
||||||
bool not_describe;
|
bool not_describe;
|
||||||
|
|
||||||
select_union(TABLE *table_par);
|
select_union(TABLE *table_par);
|
||||||
|
@ -151,7 +151,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
|
|||||||
|
|
||||||
if ((derived_result=new select_union(table)))
|
if ((derived_result=new select_union(table)))
|
||||||
{
|
{
|
||||||
derived_result->tmp_table_param=&tmp_table_param;
|
derived_result->tmp_table_param=tmp_table_param;
|
||||||
unit->offset_limit_cnt= select_cursor->offset_limit;
|
unit->offset_limit_cnt= select_cursor->offset_limit;
|
||||||
unit->select_limit_cnt= select_cursor->select_limit+
|
unit->select_limit_cnt= select_cursor->select_limit+
|
||||||
select_cursor->offset_limit;
|
select_cursor->offset_limit;
|
||||||
|
@ -397,7 +397,7 @@ public:
|
|||||||
|
|
||||||
friend void mysql_init_query(THD *thd);
|
friend void mysql_init_query(THD *thd);
|
||||||
st_select_lex(struct st_lex *lex);
|
st_select_lex(struct st_lex *lex);
|
||||||
st_select_lex() {;}
|
st_select_lex() {}
|
||||||
void make_empty_select(st_select_lex *last_select)
|
void make_empty_select(st_select_lex *last_select)
|
||||||
{
|
{
|
||||||
select_number=INT_MAX;
|
select_number=INT_MAX;
|
||||||
@ -480,7 +480,7 @@ typedef struct st_lex
|
|||||||
CHARSET_INFO *charset;
|
CHARSET_INFO *charset;
|
||||||
char *help_arg;
|
char *help_arg;
|
||||||
SQL_LIST *gorder_list;
|
SQL_LIST *gorder_list;
|
||||||
st_lex() {;}
|
st_lex() {}
|
||||||
inline void uncacheable()
|
inline void uncacheable()
|
||||||
{
|
{
|
||||||
safe_to_cache_query= 0;
|
safe_to_cache_query= 0;
|
||||||
|
@ -1281,16 +1281,10 @@ JOIN::cleanup(THD *thd)
|
|||||||
JOIN_TAB *tab, *end;
|
JOIN_TAB *tab, *end;
|
||||||
for (tab= join_tab, end= tab+tables ; tab != end ; tab++)
|
for (tab= join_tab, end= tab+tables ; tab != end ; tab++)
|
||||||
{
|
{
|
||||||
if (tab->select)
|
delete tab->select;
|
||||||
{
|
delete tab->quick;
|
||||||
delete tab->select;
|
tab->select=0;
|
||||||
tab->select=0;
|
tab->quick=0;
|
||||||
}
|
|
||||||
if (tab->quick)
|
|
||||||
{
|
|
||||||
delete tab->quick;
|
|
||||||
tab->quick=0;
|
|
||||||
}
|
|
||||||
x_free(tab->cache.buff);
|
x_free(tab->cache.buff);
|
||||||
tab->cache.buff= 0;
|
tab->cache.buff= 0;
|
||||||
}
|
}
|
||||||
@ -3292,16 +3286,10 @@ join_free(JOIN *join, bool full)
|
|||||||
{
|
{
|
||||||
for (tab=join->join_tab,end=tab+join->tables ; tab != end ; tab++)
|
for (tab=join->join_tab,end=tab+join->tables ; tab != end ; tab++)
|
||||||
{
|
{
|
||||||
if (tab->select)
|
delete tab->select;
|
||||||
{
|
delete tab->quick;
|
||||||
delete tab->select;
|
tab->select=0;
|
||||||
tab->select=0;
|
tab->quick=0;
|
||||||
}
|
|
||||||
if (tab->quick)
|
|
||||||
{
|
|
||||||
delete tab->quick;
|
|
||||||
tab->quick=0;
|
|
||||||
}
|
|
||||||
x_free(tab->cache.buff);
|
x_free(tab->cache.buff);
|
||||||
tab->cache.buff= 0;
|
tab->cache.buff= 0;
|
||||||
if (tab->table)
|
if (tab->table)
|
||||||
|
@ -113,45 +113,6 @@ typedef struct st_position { /* Used in find_best */
|
|||||||
} POSITION;
|
} POSITION;
|
||||||
|
|
||||||
|
|
||||||
/* Param to create temporary tables when doing SELECT:s */
|
|
||||||
|
|
||||||
class TMP_TABLE_PARAM :public Sql_alloc
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
List<Item> copy_funcs;
|
|
||||||
List<Item> save_copy_funcs;
|
|
||||||
List_iterator_fast<Item> copy_funcs_it;
|
|
||||||
Copy_field *copy_field, *copy_field_end;
|
|
||||||
Copy_field *save_copy_field, *save_copy_field_end;
|
|
||||||
byte *group_buff;
|
|
||||||
Item **items_to_copy; /* Fields in tmp table */
|
|
||||||
MI_COLUMNDEF *recinfo,*start_recinfo;
|
|
||||||
KEY *keyinfo;
|
|
||||||
ha_rows end_write_records;
|
|
||||||
uint field_count,sum_func_count,func_count;
|
|
||||||
uint hidden_field_count;
|
|
||||||
uint group_parts,group_length,group_null_parts;
|
|
||||||
uint quick_group;
|
|
||||||
bool using_indirect_summary_function;
|
|
||||||
|
|
||||||
TMP_TABLE_PARAM()
|
|
||||||
:copy_funcs_it(copy_funcs), copy_field(0), group_parts(0),
|
|
||||||
group_length(0), group_null_parts(0)
|
|
||||||
{}
|
|
||||||
~TMP_TABLE_PARAM()
|
|
||||||
{
|
|
||||||
cleanup();
|
|
||||||
}
|
|
||||||
inline void cleanup(void)
|
|
||||||
{
|
|
||||||
if (copy_field) /* Fix for Intel compiler */
|
|
||||||
{
|
|
||||||
delete [] copy_field;
|
|
||||||
copy_field=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class JOIN :public Sql_alloc
|
class JOIN :public Sql_alloc
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -82,7 +82,7 @@ bool select_union::send_data(List<Item> &values)
|
|||||||
if (thd->net.last_errno == ER_RECORD_FILE_FULL)
|
if (thd->net.last_errno == ER_RECORD_FILE_FULL)
|
||||||
{
|
{
|
||||||
thd->clear_error(); // do not report user about table overflow
|
thd->clear_error(); // do not report user about table overflow
|
||||||
if (create_myisam_from_heap(thd, table, tmp_table_param,
|
if (create_myisam_from_heap(thd, table, &tmp_table_param,
|
||||||
info.last_errno, 0))
|
info.last_errno, 0))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -186,8 +186,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result,
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
union_result->not_describe=1;
|
union_result->not_describe=1;
|
||||||
if (!(union_result->tmp_table_param=(TMP_TABLE_PARAM *)thd->memdup((char *)&tmp_table_param, sizeof(TMP_TABLE_PARAM))))
|
union_result->tmp_table_param=tmp_table_param;
|
||||||
goto err;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The following piece of code is placed here solely for the purpose of
|
The following piece of code is placed here solely for the purpose of
|
||||||
|
Reference in New Issue
Block a user