Commit 2ae89fca authored by unknown's avatar unknown

Fixes to avoid errors from valgrind

Fixed problem with 'wrong packet number' in union


include/my_global.h:
  Fix for valgrind
mysql-test/t/rpl_rotate_logs.test:
  Fix to avoid timeing problem
sql/item.h:
  Indentation change
sql/set_var.cc:
  Fix to avoid reference to uninitialized memory
sql/sql_select.cc:
  More DBUG_PRINT messages
  Fixed problem with 'wrong packet number' in union (tmp_join.error was not correctly reset)
sql/sql_union.cc:
  Simple code cleanup
strings/ctype-simple.c:
  Fix for valgrind
parent ec8e9125
......@@ -870,7 +870,13 @@ typedef char bool; /* Ordinary boolean values 0 1 */
((uint32) (uchar) (A)[0])))
#define sint4korr(A) (*((long *) (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)
#endif
#define uint4korr(A) (*((unsigned long *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
......
......@@ -91,6 +91,7 @@ sync_slave_with_master;
connection master;
purge master logs to 'master-bin.000002';
show binary logs;
--sleep 1;
purge logs before now();
show binary logs;
insert into t2 values (65);
......
......@@ -527,7 +527,7 @@ class Item_ref :public Item_ident
enum Item_result result_type () const { return (*ref)->result_type(); }
enum_field_types field_type() const { return (*ref)->field_type(); }
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; }
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)
}
if (tmp.length())
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()
// quick abort
delete procedure;
error= thd->is_fatal_error ? -1 : 1;
DBUG_PRINT("error",("Error from optimize_cond"));
DBUG_RETURN(error);
}
......@@ -456,6 +457,7 @@ JOIN::optimize()
(!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS)))
{ /* Impossible cond */
zero_result_cause= "Impossible WHERE";
error= 0;
DBUG_RETURN(0);
}
......@@ -468,16 +470,18 @@ JOIN::optimize()
if (res < 0)
{
zero_result_cause= "No matching min/max row";
error=0;
DBUG_RETURN(0);
}
zero_result_cause= "Select tables optimized away";
tables_list= 0; // All tables resolved
}
}
if (!tables_list)
{
error= 0;
DBUG_RETURN(0);
}
error= -1; // Error is sent to client
sort_by_table= get_sort_by_table(order, group_list, tables_list);
......@@ -485,18 +489,24 @@ JOIN::optimize()
thd->proc_info= "statistics";
if (make_join_statistics(this, tables_list, conds, &keyuse) ||
thd->is_fatal_error)
{
DBUG_PRINT("error",("Error: make_join_statistics() failed"));
DBUG_RETURN(1);
}
thd->proc_info= "preparing";
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 &&
!(select_options & SELECT_DESCRIBE))
{
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
error= 0;
DBUG_RETURN(0);
}
if (!(thd->options & OPTION_BIG_SELECTS) &&
......@@ -535,13 +545,14 @@ JOIN::optimize()
if (error)
{ /* purecov: inspected */
error= -1; /* purecov: inspected */
DBUG_PRINT("error",("Error: make_select() failed"));
DBUG_RETURN(1);
}
if (make_join_select(this, select, conds))
{
zero_result_cause=
"Impossible WHERE noticed after reading const tables";
DBUG_RETURN(0);
DBUG_RETURN(0); // error == 0
}
error= -1; /* if goto err */
......@@ -705,8 +716,10 @@ JOIN::optimize()
}
if (select_options & SELECT_DESCRIBE)
{
error= 0;
DBUG_RETURN(0);
}
tmp_having= having;
having= 0;
......@@ -806,10 +819,12 @@ JOIN::optimize()
{
if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN))))
DBUG_RETURN(-1);
error= 0; // Ensure that tmp_join.error= 0
restore_tmp();
}
}
error= 0;
DBUG_RETURN(0);
}
......@@ -875,9 +890,9 @@ void
JOIN::exec()
{
int tmp_error;
DBUG_ENTER("JOIN::exec");
error= 0;
if (procedure)
{
if (procedure->change_columns(fields_list) ||
......@@ -887,7 +902,6 @@ JOIN::exec()
if (!tables_list)
{ // Only test of functions
error=0;
if (select_options & SELECT_DESCRIBE)
select_describe(this, false, false, false,
(zero_result_cause?zero_result_cause:"No tables used"));
......@@ -914,8 +928,6 @@ JOIN::exec()
if (zero_result_cause)
{
error=0;
(void) return_zero_rows(this, result, tables_list, fields_list,
tmp_table_param.sum_func_count != 0 &&
!group_list,
......@@ -940,7 +952,6 @@ JOIN::exec()
select_describe(this, need_tmp,
order != 0 && !skip_sort_order,
select_distinct);
error=0;
DBUG_VOID_RETURN;
}
......@@ -1252,6 +1263,7 @@ JOIN::exec()
DBUG_VOID_RETURN;
}
/*
Clean up join. Return error that hold JOIN.
*/
......@@ -1278,7 +1290,6 @@ JOIN::cleanup(THD *thd)
DBUG_RETURN(tmp_join->cleanup(thd));
}
lock=0; // It's faster to unlock later
join_free(this, 1);
if (exec_tmp_table1)
......@@ -1297,6 +1308,7 @@ JOIN::cleanup(THD *thd)
DBUG_RETURN(error);
}
int
mysql_select(THD *thd, Item ***rref_pointer_array,
TABLE_LIST *tables, uint wild_num, List<Item> &fields,
......@@ -4929,17 +4941,25 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
int tmp;
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;
}
if ((tmp=table->file->index_end()))
{
my_errno=tmp;
DBUG_PRINT("error",("index_end() failed"));
my_errno= tmp;
error= -1;
}
if (error == -1)
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);
}
......
......@@ -241,11 +241,13 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result,
DBUG_RETURN(-1);
}
int st_select_lex_unit::exec()
{
DBUG_ENTER("st_select_lex_unit::exec");
SELECT_LEX_NODE *lex_select_save= thd->lex.current_select;
SELECT_LEX *select_cursor=first_select_in_union(), *last_select;
LINT_INIT(last_select);
if (executed && !(dependent || uncacheable))
DBUG_RETURN(0);
......@@ -321,14 +323,9 @@ int st_select_lex_unit::exec()
thd->lex.current_select = select_cursor;
res =-1;
{
#if 0
List<Item_func_match> ftfunc_list;
ftfunc_list.empty();
#else
List<Item_func_match> empty_list;
empty_list.empty();
thd->lex.select_lex.ftfunc_list= &empty_list;
#endif
if (!thd->is_fatal_error) // Check if EOM
{
......@@ -360,9 +357,8 @@ int st_select_lex_unit::exec()
int st_select_lex_unit::cleanup()
{
DBUG_ENTER("st_select_lex_unit::cleanup");
int error= 0;
DBUG_ENTER("st_select_lex_unit::cleanup");
if (union_result)
{
......
......@@ -732,7 +732,17 @@ double my_strntod_8bit(CHARSET_INFO *cs __attribute__((unused)),
double result;
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)
#endif
result= strtod(str, end);
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