Commit a916a039 authored by monty@narttu.mysql.fi's avatar monty@narttu.mysql.fi

Fixes to avoid errors from valgrind

Fixed problem with 'wrong packet number' in union
parent 5dd970c3
...@@ -870,7 +870,13 @@ typedef char bool; /* Ordinary boolean values 0 1 */ ...@@ -870,7 +870,13 @@ typedef char bool; /* Ordinary boolean values 0 1 */
((uint32) (uchar) (A)[0]))) ((uint32) (uchar) (A)[0])))
#define sint4korr(A) (*((long *) (A))) #define sint4korr(A) (*((long *) (A)))
#define uint2korr(A) (*((uint16 *) (A))) #define uint2korr(A) (*((uint16 *) (A)))
#ifdef HAVE_purify
#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16))
#else
#define uint3korr(A) (long) (*((unsigned long *) (A)) & 0xFFFFFF) #define uint3korr(A) (long) (*((unsigned long *) (A)) & 0xFFFFFF)
#endif
#define uint4korr(A) (*((unsigned long *) (A))) #define uint4korr(A) (*((unsigned long *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[1])) << 8) +\
......
...@@ -91,6 +91,7 @@ sync_slave_with_master; ...@@ -91,6 +91,7 @@ sync_slave_with_master;
connection master; connection master;
purge master logs to 'master-bin.000002'; purge master logs to 'master-bin.000002';
show binary logs; show binary logs;
--sleep 1;
purge logs before now(); purge logs before now();
show binary logs; show binary logs;
insert into t2 values (65); insert into t2 values (65);
......
...@@ -527,7 +527,7 @@ class Item_ref :public Item_ident ...@@ -527,7 +527,7 @@ class Item_ref :public Item_ident
enum Item_result result_type () const { return (*ref)->result_type(); } enum Item_result result_type () const { return (*ref)->result_type(); }
enum_field_types field_type() const { return (*ref)->field_type(); } enum_field_types field_type() const { return (*ref)->field_type(); }
table_map used_tables() const { return (*ref)->used_tables(); } table_map used_tables() const { return (*ref)->used_tables(); }
void set_result_field(Field *field) { result_field= field; } void set_result_field(Field *field) { result_field= field; }
bool is_result_field() { return 1; } bool is_result_field() { return 1; }
void save_in_result_field(bool no_conversions) void save_in_result_field(bool no_conversions)
{ {
......
...@@ -1100,7 +1100,7 @@ byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type) ...@@ -1100,7 +1100,7 @@ byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type)
} }
if (tmp.length()) if (tmp.length())
tmp.length(tmp.length() - 1); tmp.length(tmp.length() - 1);
return (byte*) thd->strdup(tmp.c_ptr()); return (byte*) thd->strmake(tmp.ptr(), tmp.length());
} }
......
...@@ -449,6 +449,7 @@ JOIN::optimize() ...@@ -449,6 +449,7 @@ JOIN::optimize()
// quick abort // quick abort
delete procedure; delete procedure;
error= thd->is_fatal_error ? -1 : 1; error= thd->is_fatal_error ? -1 : 1;
DBUG_PRINT("error",("Error from optimize_cond"));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -456,6 +457,7 @@ JOIN::optimize() ...@@ -456,6 +457,7 @@ JOIN::optimize()
(!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS))) (!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS)))
{ /* Impossible cond */ { /* Impossible cond */
zero_result_cause= "Impossible WHERE"; zero_result_cause= "Impossible WHERE";
error= 0;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -468,16 +470,18 @@ JOIN::optimize() ...@@ -468,16 +470,18 @@ JOIN::optimize()
if (res < 0) if (res < 0)
{ {
zero_result_cause= "No matching min/max row"; zero_result_cause= "No matching min/max row";
error=0;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
zero_result_cause= "Select tables optimized away"; zero_result_cause= "Select tables optimized away";
tables_list= 0; // All tables resolved tables_list= 0; // All tables resolved
} }
} }
if (!tables_list) if (!tables_list)
{
error= 0;
DBUG_RETURN(0); DBUG_RETURN(0);
}
error= -1; // Error is sent to client error= -1; // Error is sent to client
sort_by_table= get_sort_by_table(order, group_list, tables_list); sort_by_table= get_sort_by_table(order, group_list, tables_list);
...@@ -485,18 +489,24 @@ JOIN::optimize() ...@@ -485,18 +489,24 @@ JOIN::optimize()
thd->proc_info= "statistics"; thd->proc_info= "statistics";
if (make_join_statistics(this, tables_list, conds, &keyuse) || if (make_join_statistics(this, tables_list, conds, &keyuse) ||
thd->is_fatal_error) thd->is_fatal_error)
{
DBUG_PRINT("error",("Error: make_join_statistics() failed"));
DBUG_RETURN(1); DBUG_RETURN(1);
}
thd->proc_info= "preparing"; thd->proc_info= "preparing";
if (result->initialize_tables(this)) if (result->initialize_tables(this))
{ {
DBUG_RETURN(1); // error = -1 DBUG_PRINT("error",("Error: initialize_tables() failed"));
DBUG_RETURN(1); // error == -1
} }
if (const_table_map != found_const_table_map && if (const_table_map != found_const_table_map &&
!(select_options & SELECT_DESCRIBE)) !(select_options & SELECT_DESCRIBE))
{ {
zero_result_cause= "no matching row in const table"; zero_result_cause= "no matching row in const table";
DBUG_PRINT("error",("Error: %s", zero_result_cause));
select_options= 0; //TODO why option in return_zero_rows was droped select_options= 0; //TODO why option in return_zero_rows was droped
error= 0;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (!(thd->options & OPTION_BIG_SELECTS) && if (!(thd->options & OPTION_BIG_SELECTS) &&
...@@ -535,13 +545,14 @@ JOIN::optimize() ...@@ -535,13 +545,14 @@ JOIN::optimize()
if (error) if (error)
{ /* purecov: inspected */ { /* purecov: inspected */
error= -1; /* purecov: inspected */ error= -1; /* purecov: inspected */
DBUG_PRINT("error",("Error: make_select() failed"));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (make_join_select(this, select, conds)) if (make_join_select(this, select, conds))
{ {
zero_result_cause= zero_result_cause=
"Impossible WHERE noticed after reading const tables"; "Impossible WHERE noticed after reading const tables";
DBUG_RETURN(0); DBUG_RETURN(0); // error == 0
} }
error= -1; /* if goto err */ error= -1; /* if goto err */
...@@ -705,8 +716,10 @@ JOIN::optimize() ...@@ -705,8 +716,10 @@ JOIN::optimize()
} }
if (select_options & SELECT_DESCRIBE) if (select_options & SELECT_DESCRIBE)
{
error= 0;
DBUG_RETURN(0); DBUG_RETURN(0);
}
tmp_having= having; tmp_having= having;
having= 0; having= 0;
...@@ -806,10 +819,12 @@ JOIN::optimize() ...@@ -806,10 +819,12 @@ JOIN::optimize()
{ {
if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN)))) if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN))))
DBUG_RETURN(-1); DBUG_RETURN(-1);
error= 0; // Ensure that tmp_join.error= 0
restore_tmp(); restore_tmp();
} }
} }
error= 0;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -875,9 +890,9 @@ void ...@@ -875,9 +890,9 @@ void
JOIN::exec() JOIN::exec()
{ {
int tmp_error; int tmp_error;
DBUG_ENTER("JOIN::exec"); DBUG_ENTER("JOIN::exec");
error= 0;
if (procedure) if (procedure)
{ {
if (procedure->change_columns(fields_list) || if (procedure->change_columns(fields_list) ||
...@@ -887,7 +902,6 @@ JOIN::exec() ...@@ -887,7 +902,6 @@ JOIN::exec()
if (!tables_list) if (!tables_list)
{ // Only test of functions { // Only test of functions
error=0;
if (select_options & SELECT_DESCRIBE) if (select_options & SELECT_DESCRIBE)
select_describe(this, false, false, false, select_describe(this, false, false, false,
(zero_result_cause?zero_result_cause:"No tables used")); (zero_result_cause?zero_result_cause:"No tables used"));
...@@ -914,8 +928,6 @@ JOIN::exec() ...@@ -914,8 +928,6 @@ JOIN::exec()
if (zero_result_cause) if (zero_result_cause)
{ {
error=0;
(void) return_zero_rows(this, result, tables_list, fields_list, (void) return_zero_rows(this, result, tables_list, fields_list,
tmp_table_param.sum_func_count != 0 && tmp_table_param.sum_func_count != 0 &&
!group_list, !group_list,
...@@ -940,7 +952,6 @@ JOIN::exec() ...@@ -940,7 +952,6 @@ JOIN::exec()
select_describe(this, need_tmp, select_describe(this, need_tmp,
order != 0 && !skip_sort_order, order != 0 && !skip_sort_order,
select_distinct); select_distinct);
error=0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1252,6 +1263,7 @@ JOIN::exec() ...@@ -1252,6 +1263,7 @@ JOIN::exec()
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/* /*
Clean up join. Return error that hold JOIN. Clean up join. Return error that hold JOIN.
*/ */
...@@ -1278,7 +1290,6 @@ JOIN::cleanup(THD *thd) ...@@ -1278,7 +1290,6 @@ JOIN::cleanup(THD *thd)
DBUG_RETURN(tmp_join->cleanup(thd)); DBUG_RETURN(tmp_join->cleanup(thd));
} }
lock=0; // It's faster to unlock later lock=0; // It's faster to unlock later
join_free(this, 1); join_free(this, 1);
if (exec_tmp_table1) if (exec_tmp_table1)
...@@ -1297,6 +1308,7 @@ JOIN::cleanup(THD *thd) ...@@ -1297,6 +1308,7 @@ JOIN::cleanup(THD *thd)
DBUG_RETURN(error); DBUG_RETURN(error);
} }
int int
mysql_select(THD *thd, Item ***rref_pointer_array, mysql_select(THD *thd, Item ***rref_pointer_array,
TABLE_LIST *tables, uint wild_num, List<Item> &fields, TABLE_LIST *tables, uint wild_num, List<Item> &fields,
...@@ -4929,17 +4941,25 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) ...@@ -4929,17 +4941,25 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
int tmp; int tmp;
if ((tmp=table->file->extra(HA_EXTRA_NO_CACHE))) if ((tmp=table->file->extra(HA_EXTRA_NO_CACHE)))
{ {
my_errno=tmp; DBUG_PRINT("error",("extra(HA_EXTRA_NO_CACHE) failed"));
my_errno= tmp;
error= -1; error= -1;
} }
if ((tmp=table->file->index_end())) if ((tmp=table->file->index_end()))
{ {
my_errno=tmp; DBUG_PRINT("error",("index_end() failed"));
my_errno= tmp;
error= -1; error= -1;
} }
if (error == -1) if (error == -1)
table->file->print_error(my_errno,MYF(0)); table->file->print_error(my_errno,MYF(0));
} }
#ifndef DBUG_OFF
if (error)
{
DBUG_PRINT("error",("Error: do_select() failed"));
}
#endif
DBUG_RETURN(error || join->thd->net.report_error); DBUG_RETURN(error || join->thd->net.report_error);
} }
......
...@@ -241,11 +241,13 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result, ...@@ -241,11 +241,13 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result,
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
int st_select_lex_unit::exec() int st_select_lex_unit::exec()
{ {
DBUG_ENTER("st_select_lex_unit::exec"); DBUG_ENTER("st_select_lex_unit::exec");
SELECT_LEX_NODE *lex_select_save= thd->lex.current_select; SELECT_LEX_NODE *lex_select_save= thd->lex.current_select;
SELECT_LEX *select_cursor=first_select_in_union(), *last_select; SELECT_LEX *select_cursor=first_select_in_union(), *last_select;
LINT_INIT(last_select);
if (executed && !(dependent || uncacheable)) if (executed && !(dependent || uncacheable))
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -321,14 +323,9 @@ int st_select_lex_unit::exec() ...@@ -321,14 +323,9 @@ int st_select_lex_unit::exec()
thd->lex.current_select = select_cursor; thd->lex.current_select = select_cursor;
res =-1; res =-1;
{ {
#if 0
List<Item_func_match> ftfunc_list;
ftfunc_list.empty();
#else
List<Item_func_match> empty_list; List<Item_func_match> empty_list;
empty_list.empty(); empty_list.empty();
thd->lex.select_lex.ftfunc_list= &empty_list; thd->lex.select_lex.ftfunc_list= &empty_list;
#endif
if (!thd->is_fatal_error) // Check if EOM if (!thd->is_fatal_error) // Check if EOM
{ {
...@@ -360,9 +357,8 @@ int st_select_lex_unit::exec() ...@@ -360,9 +357,8 @@ int st_select_lex_unit::exec()
int st_select_lex_unit::cleanup() int st_select_lex_unit::cleanup()
{ {
DBUG_ENTER("st_select_lex_unit::cleanup");
int error= 0; int error= 0;
DBUG_ENTER("st_select_lex_unit::cleanup");
if (union_result) if (union_result)
{ {
......
...@@ -732,7 +732,17 @@ double my_strntod_8bit(CHARSET_INFO *cs __attribute__((unused)), ...@@ -732,7 +732,17 @@ double my_strntod_8bit(CHARSET_INFO *cs __attribute__((unused)),
double result; double result;
errno= 0; /* Safety */ errno= 0; /* Safety */
/*
The following define is to avoid warnings from valgrind as str[length]
may not be defined (which is not fatal in real life)
*/
#ifdef HAVE_purify
if (length == INT_MAX32)
#else
if (length == INT_MAX32 || str[length] == 0) if (length == INT_MAX32 || str[length] == 0)
#endif
result= strtod(str, end); result= strtod(str, end);
else else
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment