mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fix for Valgrind errors when running rt_test and ma_rt_test, and segmentation fault
in ma_rt_test -M (BUG#36321); keyinfo/recinfo/keyseg had non-initialized parts. maria_scan() was not wrapped in maria_scan_init()/end() so "ma_rt_test -M" found no rows. Preparing for inclusion into ma_test_all-t and ma_test_recovery.pl (still prevented by BUG#37307 "Maria: R-tree unit test produces corrupted table"). storage/maria/ma_rt_test.c: Some members of keyinfo, recinfo, keyseg had non-initialized parts, led to Valgrind errors, and also segmentation fault when running with -M (=BLOCK_RECORD) (BUG#36321). We now bzero them like they are in mi_test1. Other problems: - maria_scan() was not wrapped in maria_scan_init()/end() so "ma_rt_test -M" found no rows. - --silent had almost no effect, now it really silences normal output. - Some errors were going to stdout, they now go to stderr. Added option for testing versioning, to fit well into ma_test_all-t. storage/maria/unittest/ma_test_all-t: preparing for running ma_rt_test when ma_rt_test remaining bugs are fixed storage/maria/unittest/ma_test_recovery.pl: preparing for running ma_rt_test when ma_rt_test remaining bugs are fixed storage/myisam/rt_test.c: Some members of keyinfo, recinfo, keyseg were not initialized, led to Valgrind errors. We now bzero them like they are in mi_test1.
This commit is contained in:
@@ -86,8 +86,9 @@ static double rt_data[]=
|
||||
-1
|
||||
};
|
||||
|
||||
static int silent= 0, testflag= 0, transactional= 0,
|
||||
die_in_middle_of_transaction= 0, checkpoint= 0, create_flag= 0;
|
||||
static int testflag, checkpoint, create_flag;
|
||||
static my_bool silent, transactional, die_in_middle_of_transaction,
|
||||
opt_versioning;
|
||||
static enum data_file_type record_type= DYNAMIC_RECORD;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -141,6 +142,12 @@ static int run_test(const char *filename)
|
||||
int upd= 10;
|
||||
ha_rows hrows;
|
||||
|
||||
bzero(&uniquedef, sizeof(uniquedef));
|
||||
bzero(&create_info, sizeof(create_info));
|
||||
bzero(recinfo, sizeof(recinfo));
|
||||
bzero(keyinfo, sizeof(keyinfo));
|
||||
bzero(keyseg, sizeof(keyseg));
|
||||
|
||||
/* Define a column for NULLs and DEL markers*/
|
||||
|
||||
recinfo[0].type=FIELD_NORMAL;
|
||||
@@ -177,7 +184,6 @@ static int run_test(const char *filename)
|
||||
if (!silent)
|
||||
printf("- Creating isam-file\n");
|
||||
|
||||
bzero((char*) &create_info,sizeof(create_info));
|
||||
create_info.max_rows=10000000;
|
||||
create_info.transactional= transactional;
|
||||
|
||||
@@ -195,6 +201,8 @@ static int run_test(const char *filename)
|
||||
if (!(file=maria_open(filename,2,HA_OPEN_ABORT_IF_LOCKED)))
|
||||
goto err;
|
||||
maria_begin(file);
|
||||
if (opt_versioning)
|
||||
maria_versioning(file, 1);
|
||||
if (testflag == 1)
|
||||
goto end;
|
||||
if (checkpoint == 1 && ma_checkpoint_execute(CHECKPOINT_MEDIUM, FALSE))
|
||||
@@ -213,13 +221,19 @@ static int run_test(const char *filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("maria_write: %d\n", error);
|
||||
fprintf(stderr, "maria_write: %d\n", error);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (maria_scan_init(file))
|
||||
{
|
||||
fprintf(stderr, "maria_scan_init failed\n");
|
||||
goto err;
|
||||
}
|
||||
if ((error=read_with_pos(file)))
|
||||
goto err;
|
||||
maria_scan_end(file);
|
||||
|
||||
if (!silent)
|
||||
printf("- Reading rows with key\n");
|
||||
@@ -234,7 +248,7 @@ static int run_test(const char *filename)
|
||||
|
||||
if (error && error!=HA_ERR_KEY_NOT_FOUND)
|
||||
{
|
||||
printf(" maria_rkey: %3d errno: %3d\n",error,my_errno);
|
||||
fprintf(stderr," maria_rkey: %3d errno: %3d\n",error,my_errno);
|
||||
goto err;
|
||||
}
|
||||
if (error == HA_ERR_KEY_NOT_FOUND)
|
||||
@@ -266,7 +280,8 @@ static int run_test(const char *filename)
|
||||
error=maria_scan(file,read_record);
|
||||
if (error)
|
||||
{
|
||||
printf("pos: %2d maria_rrnd: %3d errno: %3d\n",i,error,my_errno);
|
||||
fprintf(stderr, "pos: %2d maria_rrnd: %3d errno: %3d\n", i, error,
|
||||
my_errno);
|
||||
goto err;
|
||||
}
|
||||
print_record(read_record,maria_position(file),"\n");
|
||||
@@ -274,7 +289,8 @@ static int run_test(const char *filename)
|
||||
error=maria_delete(file,read_record);
|
||||
if (error)
|
||||
{
|
||||
printf("pos: %2d maria_delete: %3d errno: %3d\n",i,error,my_errno);
|
||||
fprintf(stderr, "pos: %2d maria_delete: %3d errno: %3d\n", i, error,
|
||||
my_errno);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@@ -303,6 +319,7 @@ static int run_test(const char *filename)
|
||||
{
|
||||
if (error==HA_ERR_RECORD_DELETED)
|
||||
{
|
||||
if (!silent)
|
||||
printf("found deleted record\n");
|
||||
/*
|
||||
In BLOCK_RECORD format, maria_scan() never returns deleted records,
|
||||
@@ -311,17 +328,20 @@ static int run_test(const char *filename)
|
||||
max_i++;
|
||||
continue;
|
||||
}
|
||||
printf("pos: %2d maria_rrnd: %3d errno: %3d\n",i,error,my_errno);
|
||||
fprintf(stderr, "pos: %2d maria_rrnd: %3d errno: %3d\n",i , error,
|
||||
my_errno);
|
||||
goto err;
|
||||
}
|
||||
print_record(read_record,maria_position(file),"");
|
||||
create_record(record,i+nrecords*upd);
|
||||
if (!silent)
|
||||
printf("\t-> ");
|
||||
print_record(record,maria_position(file),"\n");
|
||||
error=maria_update(file,read_record,record);
|
||||
if (error)
|
||||
{
|
||||
printf("pos: %2d maria_update: %3d errno: %3d\n",i,error,my_errno);
|
||||
fprintf(stderr, "pos: %2d maria_update: %3d errno: %3d\n",i, error,
|
||||
my_errno);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@@ -349,7 +369,7 @@ static int run_test(const char *filename)
|
||||
if ((error=maria_rkey(file,read_record,0,record+1,HA_WHOLE_KEY,
|
||||
HA_READ_MBR_INTERSECT)))
|
||||
{
|
||||
printf("maria_rkey: %3d errno: %3d\n",error,my_errno);
|
||||
fprintf(stderr, "maria_rkey: %3d errno: %3d\n",error,my_errno);
|
||||
goto err;
|
||||
}
|
||||
print_record(read_record,maria_position(file)," maria_rkey\n");
|
||||
@@ -361,12 +381,13 @@ static int run_test(const char *filename)
|
||||
{
|
||||
if (error==HA_ERR_END_OF_FILE)
|
||||
break;
|
||||
printf("maria_next: %3d errno: %3d\n",error,my_errno);
|
||||
fprintf(stderr, "maria_next: %3d errno: %3d\n",error,my_errno);
|
||||
goto err;
|
||||
}
|
||||
print_record(read_record,maria_position(file)," maria_rnext_same\n");
|
||||
row_count++;
|
||||
}
|
||||
if (!silent)
|
||||
printf(" %d rows\n",row_count);
|
||||
|
||||
if (!silent)
|
||||
@@ -375,7 +396,7 @@ static int run_test(const char *filename)
|
||||
error=maria_rfirst(file,read_record,0);
|
||||
if (error)
|
||||
{
|
||||
printf("maria_rfirst: %3d errno: %3d\n",error,my_errno);
|
||||
fprintf(stderr, "maria_rfirst: %3d errno: %3d\n",error,my_errno);
|
||||
goto err;
|
||||
}
|
||||
row_count=1;
|
||||
@@ -387,12 +408,13 @@ static int run_test(const char *filename)
|
||||
{
|
||||
if (error==HA_ERR_END_OF_FILE)
|
||||
break;
|
||||
printf("maria_next: %3d errno: %3d\n",error,my_errno);
|
||||
fprintf(stderr, "maria_next: %3d errno: %3d\n",error,my_errno);
|
||||
goto err;
|
||||
}
|
||||
print_record(read_record,maria_position(file)," maria_rnext\n");
|
||||
row_count++;
|
||||
}
|
||||
if (!silent)
|
||||
printf(" %d rows\n",row_count);
|
||||
|
||||
if (!silent)
|
||||
@@ -405,6 +427,7 @@ static int run_test(const char *filename)
|
||||
range.length= 1000; /* Big enough */
|
||||
range.flag= HA_READ_MBR_INTERSECT;
|
||||
hrows= maria_records_in_range(file,0, &range, (key_range*) 0);
|
||||
if (!silent)
|
||||
printf(" %ld rows\n", (long) hrows);
|
||||
|
||||
end:
|
||||
@@ -430,6 +453,7 @@ end:
|
||||
goto err;
|
||||
break;
|
||||
}
|
||||
if (!silent)
|
||||
printf("Dying on request without maria_commit()/maria_close()\n");
|
||||
exit(0);
|
||||
}
|
||||
@@ -442,7 +466,7 @@ end:
|
||||
return 0;
|
||||
|
||||
err:
|
||||
printf("got error: %3d when using maria-database\n",my_errno);
|
||||
fprintf(stderr, "got error: %3d when using maria-database\n",my_errno);
|
||||
return 1; /* skip warning */
|
||||
}
|
||||
|
||||
@@ -467,7 +491,8 @@ static int read_with_pos (MARIA_HA * file)
|
||||
break;
|
||||
if (error==HA_ERR_RECORD_DELETED)
|
||||
continue;
|
||||
printf("pos: %2d maria_rrnd: %3d errno: %3d\n",i,error,my_errno);
|
||||
fprintf(stderr, "pos: %2d maria_rrnd: %3d errno: %3d\n", i, error,
|
||||
my_errno);
|
||||
return error;
|
||||
}
|
||||
print_record(read_record,maria_position(file),"\n");
|
||||
@@ -483,6 +508,8 @@ static void bprint_record(char * record,
|
||||
{
|
||||
int i;
|
||||
char * pos;
|
||||
if (silent)
|
||||
return;
|
||||
i=(unsigned char)record[0];
|
||||
printf("%02X ",i);
|
||||
|
||||
@@ -503,6 +530,8 @@ static void print_record(uchar *record,
|
||||
uchar *pos;
|
||||
double c;
|
||||
|
||||
if (silent)
|
||||
return;
|
||||
printf(" rec=(%d)",(unsigned char)record[0]);
|
||||
for ( pos=record+1, i=0; i<2*ndims; i++)
|
||||
{
|
||||
@@ -603,6 +632,9 @@ static struct my_option my_long_options[] =
|
||||
"Test in transactional mode. (Only works with block format)",
|
||||
(uchar**) &transactional, (uchar**) &transactional, 0, GET_BOOL, NO_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"versioning", 'C', "Use row versioning (only works with block format)",
|
||||
(uchar**) &opt_versioning, (uchar**) &opt_versioning, 0, GET_BOOL,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@@ -259,12 +259,15 @@ sub run_check_tests
|
||||
["-m10000 -e16384 -E16384 -K -L","-sm"],
|
||||
["-L -K -W -P -b32768", "-se"],
|
||||
["-c -b65000","-se"] );
|
||||
my @ma_rt_test_opt= ( ); # (["--checksum", "-se"] );
|
||||
|
||||
|
||||
if ($count)
|
||||
{
|
||||
$nr_tests= 2; # Number of tests outside loops
|
||||
for ($i= 0; defined($ma_test1_opt[$i]); $i++) { $nr_tests+=2; }
|
||||
for ($i= 0; defined($ma_test2_opt[$i]); $i++) { $nr_tests+=2; }
|
||||
for ($i= 0; defined($ma_rt_test_opt[$i]); $i++) { $nr_tests+=2; }
|
||||
return $nr_tests;
|
||||
}
|
||||
|
||||
@@ -291,6 +294,16 @@ sub run_check_tests
|
||||
ok("$maria_exe_path/maria_chk$suffix $ma_test2_opt[$i][1] test2",
|
||||
$verbose, $i + 1);
|
||||
}
|
||||
|
||||
for ($i= 0; defined($ma_rt_test_opt[$i]); $i++)
|
||||
{
|
||||
unlink <maria_log_control maria_log.*>;
|
||||
ok("$maria_exe_path/ma_rt_test$suffix $silent $ma_rt_test_opt[$i][0] $row_type",
|
||||
$verbose, $i + 1);
|
||||
ok("$maria_exe_path/maria_chk$suffix $ma_rt_test_opt[$i][1] rt_test",
|
||||
$verbose, $i + 1);
|
||||
}
|
||||
|
||||
unlink <maria_log_control maria_log.*>;
|
||||
|
||||
return 0;
|
||||
|
@@ -91,7 +91,9 @@ sub main
|
||||
"ma_test2$suffix $silent -M -T -c -b65000",
|
||||
"ma_test2$suffix $silent -M -T -c -b65000 -d800",
|
||||
"ma_test1$suffix $silent -M -T -c -C",
|
||||
"ma_test2$suffix $silent -L -K -W -P -M -T -c -d500 -C"
|
||||
"ma_test2$suffix $silent -L -K -W -P -M -T -c -d500 -C",
|
||||
#"ma_rt_test$suffix $silent -M -T -c -C",
|
||||
# @todo: also add to @t2
|
||||
);
|
||||
|
||||
foreach my $prog (@t)
|
||||
@@ -103,10 +105,14 @@ sub main
|
||||
$res= my_exec("$maria_exe_path/$prog");
|
||||
print MY_LOG $res;
|
||||
# derive table's name from program's name
|
||||
if ($prog =~ m/ma_(test[0-9]+).*/)
|
||||
if ($prog =~ m/^ma_(\S+)\s.*/)
|
||||
{
|
||||
$table= $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
die("can't guess table name");
|
||||
}
|
||||
$com= "$maria_exe_path/maria_chk$suffix -dvv $table ";
|
||||
$com.= "| grep -v \"Creation time:\" | grep -v \"file length\" ";
|
||||
$com.= "> $tmp/maria_chk_message.good.txt 2>&1";
|
||||
@@ -182,10 +188,14 @@ sub main
|
||||
$res= my_exec("$maria_exe_path/$prog $commit_run_args");
|
||||
print MY_LOG $res;
|
||||
# derive table's name from program's name
|
||||
if ($prog =~ m/ma_(test[0-9]+).*/)
|
||||
if ($prog =~ m/^ma_(\S+)\s.*/)
|
||||
{
|
||||
$table= $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
die("can't guess table name");
|
||||
}
|
||||
$com= "$maria_exe_path/maria_chk$suffix -dvv $table ";
|
||||
$com.= "| grep -v \"Creation time:\" | grep -v \"file length\" ";
|
||||
$com.= "> $tmp/maria_chk_message.good.txt 2>&1";
|
||||
|
@@ -113,6 +113,12 @@ static int run_test(const char *filename)
|
||||
int upd= 10;
|
||||
ha_rows hrows;
|
||||
|
||||
bzero(&uniquedef, sizeof(uniquedef));
|
||||
bzero(&create_info, sizeof(create_info));
|
||||
bzero(recinfo, sizeof(recinfo));
|
||||
bzero(keyinfo, sizeof(keyinfo));
|
||||
bzero(keyseg, sizeof(keyseg));
|
||||
|
||||
/* Define a column for NULLs and DEL markers*/
|
||||
|
||||
recinfo[0].type=FIELD_NORMAL;
|
||||
@@ -147,7 +153,6 @@ static int run_test(const char *filename)
|
||||
if (!silent)
|
||||
printf("- Creating isam-file\n");
|
||||
|
||||
bzero((char*) &create_info,sizeof(create_info));
|
||||
create_info.max_rows=10000000;
|
||||
|
||||
if (mi_create(filename,
|
||||
|
Reference in New Issue
Block a user