Skip to content

Commit

Permalink
Fixed issues found by valgrind
Browse files Browse the repository at this point in the history
- mysqltest didn't free read_command_buf
- wait_for_slave_param did write different things to the log if valgrind
  was used.
- Table open cache should not write the initial variable value as it
  can depend on the configuration or if valgrind is used
- A variable in GetResult was used uninitalized
  • Loading branch information
montywi committed Aug 12, 2019
1 parent 3b23410 commit fe8181a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 42 deletions.
3 changes: 2 additions & 1 deletion client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ static char TMPDIR[FN_REFLEN];
static char global_subst_from[200];
static char global_subst_to[200];
static char *global_subst= NULL;
static char *read_command_buf= NULL;
static MEM_ROOT require_file_root;
static const my_bool my_true= 1;
static const my_bool my_false= 0;
Expand Down Expand Up @@ -1531,6 +1532,7 @@ void free_used_memory()
free_defaults(default_argv);
free_root(&require_file_root, MYF(0));
free_re();
my_free(read_command_buf);
#ifdef _WIN32
free_tmp_sh_file();
free_win_path_patterns();
Expand Down Expand Up @@ -6563,7 +6565,6 @@ static inline bool is_escape_char(char c, char in_string)
*/

static char *read_command_buf= NULL;
static size_t read_command_buflen= 0;
static const size_t max_multibyte_length= 6;

Expand Down
2 changes: 1 addition & 1 deletion mysql-test/include/wait_for_slave_param.inc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if (!$_slave_param_comparison)

if ($rpl_debug)
{
--echo Waiting until '$slave_param' $_slave_param_comparison '$slave_param_value' [timeout='$_slave_timeout', \$slave_error_param='$slave_error_param']
--echo Waiting until '$slave_param' $_slave_param_comparison '$slave_param_value' [\$slave_error_param='$slave_error_param']
}

--let $_slave_check_configured= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1)
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/suite/rpl/r/rpl_gtid_delete_domain.result
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ START SLAVE;
.. con='slave' warn='1' qlog='1' rlog='1' aborterr='1'
...==== BEGIN include/wait_for_slave_param.inc [Slave_IO_Running] ====
... con='slave' warn='1' qlog='1' rlog='1' aborterr='1'
Waiting until 'Slave_IO_Running' = 'Yes' [timeout='300', $slave_error_param='Last_IO_Errno']
Waiting until 'Slave_IO_Running' = 'Yes' [$slave_error_param='Last_IO_Errno']
[connection slave]
...==== END include/wait_for_slave_param.inc [Slave_IO_Running] ====
... con='slave' warn='1' qlog='1' rlog='1' aborterr='1'
Expand All @@ -52,7 +52,7 @@ Waiting until 'Slave_IO_Running' = 'Yes' [timeout='300', $slave_error_param='Las
.. con='slave' warn='1' qlog='1' rlog='1' aborterr='1'
...==== BEGIN include/wait_for_slave_param.inc [Slave_SQL_Running] ====
... con='slave' warn='1' qlog='1' rlog='1' aborterr='1'
Waiting until 'Slave_SQL_Running' = 'Yes' [timeout='300', $slave_error_param='1']
Waiting until 'Slave_SQL_Running' = 'Yes' [$slave_error_param='1']
[connection slave]
...==== END include/wait_for_slave_param.inc [Slave_SQL_Running] ====
... con='slave' warn='1' qlog='1' rlog='1' aborterr='1'
Expand Down
20 changes: 3 additions & 17 deletions mysql-test/suite/sys_vars/r/table_open_cache_basic.result
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
SET @start_value = @@global.table_open_cache ;
SELECT @start_value;
@start_value
421
'#--------------------FN_DYNVARS_001_01------------------------#'
SET @@global.table_open_cache = 99;
SET @@global.table_open_cache = DeFAULT;
SELECT @@global.table_open_cache;
@@global.table_open_cache
2000
'#---------------------FN_DYNVARS_001_02-------------------------#'
SET @@global.table_open_cache = Default;
SELECT @@global.table_open_cache = 400;
@@global.table_open_cache = 400
0
SELECT @@global.table_open_cache > 0;
@@global.table_open_cache > 0
1
'#--------------------FN_DYNVARS_001_03------------------------#'
SET @@global.table_open_cache = 8;
Warnings:
Expand Down Expand Up @@ -101,13 +92,8 @@ SELECT @@table_open_cache = @@global.table_open_cache ;
'#---------------------FN_DYNVARS_001_11----------------------#'
SET table_open_cache = 8;
ERROR HY000: Variable 'table_open_cache' is a GLOBAL variable and should be set with SET GLOBAL
SET global.table_open_cache = 10;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'table_open_cache = 10' at line 1
SELECT global.table_open_cache ;
ERROR 42S02: Unknown table 'global' in field list
SELECT table_open_cache = @@session.table_open_cache ;
ERROR 42S22: Unknown column 'table_open_cache' in 'field list'
SET @@global.table_open_cache = @start_value;
SELECT @@global.table_open_cache ;
@@global.table_open_cache
421
23 changes: 3 additions & 20 deletions mysql-test/suite/sys_vars/t/table_open_cache_basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Scope: GLOBAL #
# Access Type: Dynamic #
# Data Type: numeric #
# Default Value: 400 #
# Range: 64-524288 #
# Default Value: 400 #
# Range: 64-524288 #
# #
# #
# Creation Date: 2008-02-13 #
Expand Down Expand Up @@ -35,26 +35,14 @@
##########################################################################

SET @start_value = @@global.table_open_cache ;
SELECT @start_value;


--echo '#--------------------FN_DYNVARS_001_01------------------------#'
########################################################################
# Display the DEFAULT value of table_open_cache #
########################################################################

SET @@global.table_open_cache = 99;
SET @@global.table_open_cache = DeFAULT;
SELECT @@global.table_open_cache;


--echo '#---------------------FN_DYNVARS_001_02-------------------------#'
###############################################
# Verify default value of variable #
###############################################

SET @@global.table_open_cache = Default;
SELECT @@global.table_open_cache = 400;
SELECT @@global.table_open_cache > 0;

--echo '#--------------------FN_DYNVARS_001_03------------------------#'
########################################################################
Expand Down Expand Up @@ -152,8 +140,6 @@ SELECT @@table_open_cache = @@global.table_open_cache ;

--Error ER_GLOBAL_VARIABLE
SET table_open_cache = 8;
--Error ER_PARSE_ERROR
SET global.table_open_cache = 10;
--Error ER_UNKNOWN_TABLE
SELECT global.table_open_cache ;
--Error ER_BAD_FIELD_ERROR
Expand All @@ -165,10 +151,7 @@ SELECT table_open_cache = @@session.table_open_cache ;
##############################

SET @@global.table_open_cache = @start_value;
SELECT @@global.table_open_cache ;


##################################################################
# END OF table_open_cache TESTS #
##################################################################

2 changes: 1 addition & 1 deletion storage/connect/myconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ MYSQL_FIELD *MYSQLC::GetNextField(void)
PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
{
PCSZ fmt;
char *name, v;
char *name, v= 0;
int n;
bool uns;
PCOLRES *pcrp, crp;
Expand Down

0 comments on commit fe8181a

Please sign in to comment.