Fixed some issues found by valgrind
(one testcase, one memory leak and some accesses to not initialized memory) mysql-test/r/events_scheduling.result: Changed event timer to two seconds to not get problems with slow system or when running with valgrind mysql-test/t/events_scheduling.test: Changed event timer to two seconds to not get problems with slow system or when running with valgrind mysql-test/valgrind.supp: Avoid purify warnings from DBUG library (safe to do) sql/ha_berkeley.cc: Fix problem with not freed memory sql/sql_class.cc: Ensure that row_count is initalized (as we otherwise may access it uninitialized) sql/sql_show.cc: c_ptr -> ptr to avoid accessing not initialized memory sql/sql_yacc.yy: Fix to not access not initialized memory sql/table.cc: Fix to not access not initialized memory sql/time.cc: Fix to not access not initialized memory
This commit is contained in:
parent
6c3babe52c
commit
2017107969
@ -6,7 +6,7 @@ CREATE TABLE table_3(a int);
|
|||||||
CREATE TABLE table_4(a int);
|
CREATE TABLE table_4(a int);
|
||||||
CREATE TABLE T19170(s1 TIMESTAMP);
|
CREATE TABLE T19170(s1 TIMESTAMP);
|
||||||
SET GLOBAL event_scheduler=1;
|
SET GLOBAL event_scheduler=1;
|
||||||
CREATE EVENT E19170 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO T19170 VALUES(CURRENT_TIMESTAMP);
|
CREATE EVENT E19170 ON SCHEDULE EVERY 2 SECOND DO INSERT INTO T19170 VALUES(CURRENT_TIMESTAMP);
|
||||||
CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1);
|
CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1);
|
||||||
CREATE EVENT start_n_end
|
CREATE EVENT start_n_end
|
||||||
ON SCHEDULE EVERY 1 SECOND
|
ON SCHEDULE EVERY 1 SECOND
|
||||||
|
@ -6,7 +6,9 @@ CREATE TABLE table_3(a int);
|
|||||||
CREATE TABLE table_4(a int);
|
CREATE TABLE table_4(a int);
|
||||||
CREATE TABLE T19170(s1 TIMESTAMP);
|
CREATE TABLE T19170(s1 TIMESTAMP);
|
||||||
SET GLOBAL event_scheduler=1;
|
SET GLOBAL event_scheduler=1;
|
||||||
CREATE EVENT E19170 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO T19170 VALUES(CURRENT_TIMESTAMP);
|
# We need to have 2 to make it safe with valgrind. This is probably because
|
||||||
|
# of when we calculate the timestamp value
|
||||||
|
CREATE EVENT E19170 ON SCHEDULE EVERY 2 SECOND DO INSERT INTO T19170 VALUES(CURRENT_TIMESTAMP);
|
||||||
CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1);
|
CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1);
|
||||||
CREATE EVENT start_n_end
|
CREATE EVENT start_n_end
|
||||||
ON SCHEDULE EVERY 1 SECOND
|
ON SCHEDULE EVERY 1 SECOND
|
||||||
|
@ -420,3 +420,16 @@
|
|||||||
fun:fprintf
|
fun:fprintf
|
||||||
fun:print_stacktrace
|
fun:print_stacktrace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Safe warnings, that may happen because of thread scheduling
|
||||||
|
#
|
||||||
|
|
||||||
|
{
|
||||||
|
dbug initialization
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:malloc
|
||||||
|
fun:DbugMalloc
|
||||||
|
fun:ListAdd
|
||||||
|
fun:_db_set_
|
||||||
|
}
|
||||||
|
@ -361,6 +361,7 @@ static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
|
|||||||
init_sql_alloc(&show_logs_root, BDB_LOG_ALLOC_BLOCK_SIZE,
|
init_sql_alloc(&show_logs_root, BDB_LOG_ALLOC_BLOCK_SIZE,
|
||||||
BDB_LOG_ALLOC_BLOCK_SIZE);
|
BDB_LOG_ALLOC_BLOCK_SIZE);
|
||||||
*root_ptr= &show_logs_root;
|
*root_ptr= &show_logs_root;
|
||||||
|
all_logs= free_logs= 0;
|
||||||
|
|
||||||
if ((error= db_env->log_archive(db_env, &all_logs,
|
if ((error= db_env->log_archive(db_env, &all_logs,
|
||||||
DB_ARCH_ABS | DB_ARCH_LOG)) ||
|
DB_ARCH_ABS | DB_ARCH_LOG)) ||
|
||||||
@ -395,6 +396,10 @@ static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
err:
|
err:
|
||||||
|
if (all_logs)
|
||||||
|
free(all_logs);
|
||||||
|
if (free_logs)
|
||||||
|
free(free_logs);
|
||||||
free_root(&show_logs_root,MYF(0));
|
free_root(&show_logs_root,MYF(0));
|
||||||
*root_ptr= old_mem_root;
|
*root_ptr= old_mem_root;
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
|
@ -228,7 +228,7 @@ THD::THD()
|
|||||||
hash_clear(&handler_tables_hash);
|
hash_clear(&handler_tables_hash);
|
||||||
tmp_table=0;
|
tmp_table=0;
|
||||||
used_tables=0;
|
used_tables=0;
|
||||||
cuted_fields= sent_row_count= 0L;
|
cuted_fields= sent_row_count= row_count= 0L;
|
||||||
limit_found_rows= 0;
|
limit_found_rows= 0;
|
||||||
statement_id_counter= 0UL;
|
statement_id_counter= 0UL;
|
||||||
#ifdef ERROR_INJECT_SUPPORT
|
#ifdef ERROR_INJECT_SUPPORT
|
||||||
|
@ -4178,7 +4178,7 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
|
|||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
|
|
||||||
sch_table->field[7]->set_notnull();
|
sch_table->field[7]->set_notnull();
|
||||||
sch_table->field[7]->store(show_str.c_ptr(), show_str.length(), scs);
|
sch_table->field[7]->store(show_str.ptr(), show_str.length(), scs);
|
||||||
|
|
||||||
LEX_STRING *ival= &interval_type_to_name[et.interval];
|
LEX_STRING *ival= &interval_type_to_name[et.interval];
|
||||||
sch_table->field[8]->set_notnull();
|
sch_table->field[8]->set_notnull();
|
||||||
|
@ -1385,7 +1385,7 @@ ev_schedule_time: EVERY_SYM expr interval
|
|||||||
String str(buff,(uint32) sizeof(buff), system_charset_info);
|
String str(buff,(uint32) sizeof(buff), system_charset_info);
|
||||||
String *str2= $2->val_str(&str);
|
String *str2= $2->val_str(&str);
|
||||||
my_error(ER_WRONG_VALUE, MYF(0), "AT",
|
my_error(ER_WRONG_VALUE, MYF(0), "AT",
|
||||||
str2? str2->c_ptr():"NULL");
|
str2? str2->c_ptr_safe():"NULL");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1436,8 +1436,8 @@ ev_starts: /* empty */
|
|||||||
char buff[20];
|
char buff[20];
|
||||||
String str(buff,(uint32) sizeof(buff), system_charset_info);
|
String str(buff,(uint32) sizeof(buff), system_charset_info);
|
||||||
String *str2= $2->val_str(&str);
|
String *str2= $2->val_str(&str);
|
||||||
my_error(ER_WRONG_VALUE, MYF(0), "STARTS", str2? str2->c_ptr():
|
my_error(ER_WRONG_VALUE, MYF(0), "STARTS",
|
||||||
NULL);
|
str2 ? str2->c_ptr_safe() : NULL);
|
||||||
YYABORT;
|
YYABORT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
14
sql/table.cc
14
sql/table.cc
@ -2392,26 +2392,28 @@ table_check_intact(TABLE *table, uint table_f_count,
|
|||||||
table_f_count, table->s->fields);
|
table_f_count, table->s->fields);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
moving from newer mysql to older one -> let's say not an error but
|
moving from newer mysql to older one -> let's say not an error but
|
||||||
will check the definition afterwards. If a column was added at the end
|
will check the definition afterwards. If a column was added at the
|
||||||
then we don't care much since it's not in the middle.
|
end then we don't care much since it's not in the middle.
|
||||||
*/
|
*/
|
||||||
error= FALSE;
|
error= FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//definitely something has changed
|
//definitely something has changed
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
for (i=0 ;i < table_f_count; ++i, ++table_def)
|
for (i=0 ; i < table_f_count; i++, table_def++)
|
||||||
{
|
{
|
||||||
Field *field= table->field[i];
|
|
||||||
String sql_type(buffer, sizeof(buffer), system_charset_info);
|
String sql_type(buffer, sizeof(buffer), system_charset_info);
|
||||||
sql_type.length(0);
|
sql_type.length(0);
|
||||||
/*
|
/*
|
||||||
name changes are not fatal, we use sequence numbers => no prob for us
|
name changes are not fatal, we use sequence numbers => no prob for us
|
||||||
but this can show tampered table or broken table.
|
but this can show tampered table or broken table.
|
||||||
*/
|
*/
|
||||||
if (!fields_diff_count || i < table->s->fields)
|
if (i < table->s->fields)
|
||||||
{
|
{
|
||||||
|
Field *field= table->field[i];
|
||||||
if (strncmp(field->field_name, table_def->name.str,
|
if (strncmp(field->field_name, table_def->name.str,
|
||||||
table_def->name.length))
|
table_def->name.length))
|
||||||
{
|
{
|
||||||
@ -2459,7 +2461,7 @@ table_check_intact(TABLE *table, uint table_f_count,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sql_print_error("(%s) Expected field %s at position %d to have type %s "
|
sql_print_error("(%s) Expected field %s at position %d to have type %s "
|
||||||
" but no field found.", table_def->name.str,
|
" but no field found.", table->alias,
|
||||||
table_def->name.str, i, table_def->type.str);
|
table_def->name.str, i, table_def->type.str);
|
||||||
error= TRUE;
|
error= TRUE;
|
||||||
}
|
}
|
||||||
|
@ -692,6 +692,7 @@ void make_truncated_value_warning(THD *thd, const char *str_val,
|
|||||||
char buff[128];
|
char buff[128];
|
||||||
String str(buff,(uint32) sizeof(buff), system_charset_info);
|
String str(buff,(uint32) sizeof(buff), system_charset_info);
|
||||||
str.copy(str_val, str_length, system_charset_info);
|
str.copy(str_val, str_length, system_charset_info);
|
||||||
|
str[str_length]= 0; // Ensure we have end 0 for snprintf
|
||||||
|
|
||||||
switch (time_type) {
|
switch (time_type) {
|
||||||
case MYSQL_TIMESTAMP_DATE:
|
case MYSQL_TIMESTAMP_DATE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user