mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Safety fix to enable RAID in max binaries
Better fix for format('nan') Fix for HAVING COUNT(DISTINCT...) myisam/mi_check.c: Better error message myisam/mi_dynrec.c: Simple code cleanup myisam/myisamchk.c: Better error messages mysql-test/r/func_misc.result: Added back test for format('nan') mysql-test/r/having.result: New test mysql-test/t/func_misc.test: Added back test for format('nan') mysql-test/t/having.test: Added test for count(distinct) in having mysys/raid.cc: Safety fix to enable RAID in max binaries scripts/mysql_install_db.sh: Create data directories even if --in-rpm is used (for MaxOSX) sql/item_strfunc.cc: Better fix for format('nan') sql/mysqld.cc: Give stacktrace on assert() sql/sql_yacc.yy: Fix for HAVING COUNT(DISTINCT...) tests/big_record.pl: Extend test to abuse packed MyISAM tables tests/table_types.pl: Fixed wrong merge
This commit is contained in:
@ -873,15 +873,19 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
|
||||
{
|
||||
if (b_type & BLOCK_LAST)
|
||||
{
|
||||
mi_check_print_error(param,"Record link to short for record at %s",
|
||||
llstr(start_recpos,llbuff));
|
||||
mi_check_print_error(param,
|
||||
"Wrong record length %s of %s at %s",
|
||||
llstr(block_info.rec_len-left_length,llbuff),
|
||||
llstr(block_info.rec_len, llbuff2),
|
||||
llstr(start_recpos,llbuff3));
|
||||
got_error=1;
|
||||
break;
|
||||
}
|
||||
if (info->state->data_file_length < block_info.next_filepos)
|
||||
{
|
||||
mi_check_print_error(param,"Found next-recordlink that points outside datafile at %s",
|
||||
llstr(block_info.filepos,llbuff));
|
||||
mi_check_print_error(param,
|
||||
"Found next-recordlink that points outside datafile at %s",
|
||||
llstr(block_info.filepos,llbuff));
|
||||
got_error=1;
|
||||
break;
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ int _mi_write_part_record(MI_INFO *info,
|
||||
{
|
||||
info->update&= ~HA_STATE_EXTEND_BLOCK;
|
||||
if (my_block_write(&info->rec_cache,(byte*) *record-head_length,
|
||||
length+extra_length+del_length,filepos))
|
||||
length+extra_length+del_length,filepos))
|
||||
goto err;
|
||||
}
|
||||
else if (my_b_write(&info->rec_cache,(byte*) *record-head_length,
|
||||
@ -1412,10 +1412,7 @@ uint _mi_get_block_info(MI_BLOCK_INFO *info, File file, my_off_t filepos)
|
||||
VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0)));
|
||||
if (my_read(file,(char*) header,sizeof(info->header),MYF(0)) !=
|
||||
sizeof(info->header))
|
||||
{
|
||||
my_errno=HA_ERR_WRONG_IN_RECORD;
|
||||
return BLOCK_FATAL_ERROR;
|
||||
}
|
||||
goto err;
|
||||
}
|
||||
DBUG_DUMP("header",(byte*) header,MI_BLOCK_INFO_HEADER_LENGTH);
|
||||
if (info->second_read)
|
||||
@ -1435,10 +1432,7 @@ uint _mi_get_block_info(MI_BLOCK_INFO *info, File file, my_off_t filepos)
|
||||
if ((info->block_len=(uint) mi_uint3korr(header+1)) <
|
||||
MI_MIN_BLOCK_LENGTH ||
|
||||
(info->block_len & (MI_DYN_ALIGN_SIZE -1)))
|
||||
{
|
||||
my_errno=HA_ERR_WRONG_IN_RECORD;
|
||||
return BLOCK_ERROR;
|
||||
}
|
||||
goto err;
|
||||
info->filepos=filepos;
|
||||
info->next_filepos=mi_sizekorr(header+4);
|
||||
info->prev_filepos=mi_sizekorr(header+12);
|
||||
@ -1449,7 +1443,7 @@ uint _mi_get_block_info(MI_BLOCK_INFO *info, File file, my_off_t filepos)
|
||||
(mi_uint4korr(header+12) != 0 &&
|
||||
(mi_uint4korr(header+12) != (ulong) ~0 ||
|
||||
info->prev_filepos != (ulong) ~0)))
|
||||
return BLOCK_FATAL_ERROR;
|
||||
goto err;
|
||||
#endif
|
||||
return return_val | BLOCK_DELETED; /* Deleted block */
|
||||
|
||||
@ -1529,8 +1523,9 @@ uint _mi_get_block_info(MI_BLOCK_INFO *info, File file, my_off_t filepos)
|
||||
info->second_read=1;
|
||||
info->filepos=filepos+12;
|
||||
return return_val;
|
||||
default:
|
||||
my_errno=HA_ERR_WRONG_IN_RECORD; /* Garbage */
|
||||
return BLOCK_ERROR;
|
||||
}
|
||||
|
||||
err:
|
||||
my_errno=HA_ERR_WRONG_IN_RECORD; /* Garbage */
|
||||
return BLOCK_ERROR;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ static const char *load_default_groups[]= { "myisamchk", 0 };
|
||||
static const char *set_charset_name;
|
||||
static CHARSET_INFO *set_charset;
|
||||
static long opt_myisam_block_size;
|
||||
static const char *my_progname_short;
|
||||
|
||||
static const char *type_names[]=
|
||||
{ "?","char","binary", "short", "long", "float",
|
||||
@ -85,6 +86,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int error;
|
||||
MY_INIT(argv[0]);
|
||||
my_progname_short= my_progname+dirname_length(my_progname);
|
||||
|
||||
#ifdef __EMX__
|
||||
_wildcard (&argc, &argv);
|
||||
@ -330,7 +332,7 @@ static void usage(void)
|
||||
puts("This software comes with NO WARRANTY: see the PUBLIC for details.\n");
|
||||
puts("Description, check and repair of MyISAM tables.");
|
||||
puts("Used without options all tables on the command will be checked for errors");
|
||||
printf("Usage: %s [OPTIONS] tables[.MYI]\n", my_progname);
|
||||
printf("Usage: %s [OPTIONS] tables[.MYI]\n", my_progname_short);
|
||||
puts("\nGlobal options:\n\
|
||||
-#, --debug=... Output debug log. Often this is 'd:t:o,filename'\n\
|
||||
-?, --help Display this help and exit.\n\
|
||||
@ -679,7 +681,7 @@ static void get_options(register int *argc,register char ***argv)
|
||||
{
|
||||
VOID(fprintf(stderr,
|
||||
"%s: --unpack can't be used with --quick or --sort-records\n",
|
||||
my_progname));
|
||||
my_progname_short));
|
||||
exit(1);
|
||||
}
|
||||
if ((check_param.testflag & T_READONLY) &&
|
||||
@ -689,7 +691,7 @@ static void get_options(register int *argc,register char ***argv)
|
||||
{
|
||||
VOID(fprintf(stderr,
|
||||
"%s: Can't use --readonly when repairing or sorting\n",
|
||||
my_progname));
|
||||
my_progname_short));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -1655,13 +1657,13 @@ void mi_check_print_warning(MI_CHECK *param, const char *fmt,...)
|
||||
if (!param->warning_printed && !param->error_printed)
|
||||
{
|
||||
if (param->testflag & T_SILENT)
|
||||
fprintf(stderr,"%s: MyISAM file %s\n",my_progname,
|
||||
fprintf(stderr,"%s: MyISAM file %s\n",my_progname_short,
|
||||
param->isam_file_name);
|
||||
param->out_flag|= O_DATA_LOST;
|
||||
}
|
||||
param->warning_printed=1;
|
||||
va_start(args,fmt);
|
||||
fprintf(stderr,"%s: warning: ",my_progname);
|
||||
fprintf(stderr,"%s: warning: ",my_progname_short);
|
||||
VOID(vfprintf(stderr, fmt, args));
|
||||
VOID(fputc('\n',stderr));
|
||||
fflush(stderr);
|
||||
@ -1681,12 +1683,12 @@ void mi_check_print_error(MI_CHECK *param, const char *fmt,...)
|
||||
if (!param->warning_printed && !param->error_printed)
|
||||
{
|
||||
if (param->testflag & T_SILENT)
|
||||
fprintf(stderr,"%s: MyISAM file %s\n",my_progname,param->isam_file_name);
|
||||
fprintf(stderr,"%s: MyISAM file %s\n",my_progname_short,param->isam_file_name);
|
||||
param->out_flag|= O_DATA_LOST;
|
||||
}
|
||||
param->error_printed|=1;
|
||||
va_start(args,fmt);
|
||||
fprintf(stderr,"%s: error: ",my_progname);
|
||||
fprintf(stderr,"%s: error: ",my_progname_short);
|
||||
VOID(vfprintf(stderr, fmt, args));
|
||||
VOID(fputc('\n',stderr));
|
||||
fflush(stderr);
|
||||
|
@ -10,3 +10,6 @@ inet_aton("255.255.255.255.255") inet_aton("255.255.1.255") inet_aton("0.1.255")
|
||||
select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
|
||||
inet_ntoa(1099511627775) inet_ntoa(4294902271) inet_ntoa(511)
|
||||
NULL 255.255.1.255 0.0.1.255
|
||||
select length(format('nan', 2)) > 0;
|
||||
length(format('nan', 2)) > 0
|
||||
1
|
||||
|
@ -69,4 +69,12 @@ select id, sum(qty) as sqty from t1 group by id having sqty>2;
|
||||
id sqty
|
||||
1 5
|
||||
2 9
|
||||
select sum(qty) as sqty from t1 group by id having count(id) > 0;
|
||||
sqty
|
||||
5
|
||||
9
|
||||
select sum(qty) as sqty from t1 group by id having count(distinct id) > 0;
|
||||
sqty
|
||||
5
|
||||
9
|
||||
drop table t1;
|
||||
|
@ -7,3 +7,8 @@ select format(1.5555,0),format(123.5555,1),format(1234.5555,2),format(12345.5555
|
||||
select inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"));
|
||||
select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
|
||||
select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
|
||||
|
||||
#
|
||||
# Test for core dump with nan
|
||||
#
|
||||
select length(format('nan', 2)) > 0;
|
||||
|
@ -63,4 +63,6 @@ drop table t1;
|
||||
create table t1 (id int not null, qty int not null);
|
||||
insert into t1 values (1,2),(1,3),(2,4),(2,5);
|
||||
select id, sum(qty) as sqty from t1 group by id having sqty>2;
|
||||
select sum(qty) as sqty from t1 group by id having count(id) > 0;
|
||||
select sum(qty) as sqty from t1 group by id having count(distinct id) > 0;
|
||||
drop table t1;
|
||||
|
@ -157,10 +157,10 @@ extern "C" {
|
||||
DBUG_PRINT("enter",("Fd: %d pos: %lu whence: %d MyFlags: %d",
|
||||
fd, (ulong) pos, whence, MyFlags));
|
||||
|
||||
assert(pos != MY_FILEPOS_ERROR);
|
||||
|
||||
if (is_raid(fd))
|
||||
{
|
||||
assert(pos != MY_FILEPOS_ERROR);
|
||||
|
||||
RaidFd *raid= (*dynamic_element(&RaidFd::_raid_map,fd,RaidFd**));
|
||||
DBUG_RETURN(raid->Seek(pos,whence,MyFlags));
|
||||
}
|
||||
|
@ -118,7 +118,8 @@ then
|
||||
resolved=`$bindir/resolveip localhost 2>&1`
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Sorry, the host '$hostname' could not be looked up."
|
||||
echo "Neither host '$hostname' and 'localhost' could not be looked up with"
|
||||
echo "$bindir/resolveip"
|
||||
echo "Please configure the 'hostname' command to return a correct hostname."
|
||||
echo "If you want to solve this at a later stage, restart this script with"
|
||||
echo "the --force option"
|
||||
@ -134,15 +135,12 @@ then
|
||||
fi
|
||||
|
||||
# Create database directories mysql & test
|
||||
if test "$IN_RPM" -eq 0
|
||||
then
|
||||
if test ! -d $ldata; then mkdir $ldata; chmod 700 $ldata ; fi
|
||||
if test ! -d $ldata/mysql; then mkdir $ldata/mysql; chmod 700 $ldata/mysql ; fi
|
||||
if test ! -d $ldata/test; then mkdir $ldata/test; chmod 700 $ldata/test ; fi
|
||||
if test -w / -a ! -z "$user"; then
|
||||
chown $user $ldata $ldata/mysql $ldata/test;
|
||||
fi
|
||||
fi
|
||||
|
||||
# Initialize variables
|
||||
c_d="" i_d=""
|
||||
|
@ -1473,15 +1473,17 @@ String *Item_func_format::val_str(String *str)
|
||||
str_length=str->length();
|
||||
if (nr < 0)
|
||||
str_length--; // Don't count sign
|
||||
length=str->length()+(diff=(str_length- dec-1)/3);
|
||||
if (diff && diff < 330) // size of buff ...
|
||||
|
||||
/* We need this test to handle 'nan' values */
|
||||
if (str_length >= dec+4)
|
||||
{
|
||||
char *tmp,*pos;
|
||||
str=copy_if_not_alloced(&tmp_str,str,length);
|
||||
length= str->length()+(diff=(str_length- dec-1)/3);
|
||||
str= copy_if_not_alloced(&tmp_str,str,length);
|
||||
str->length(length);
|
||||
tmp=(char*) str->ptr()+length - dec-1;
|
||||
for (pos=(char*) str->ptr()+length ; pos != tmp; pos--)
|
||||
pos[0]=pos[- (int) diff];
|
||||
tmp= (char*) str->ptr()+length - dec-1;
|
||||
for (pos= (char*) str->ptr()+length ; pos != tmp; pos--)
|
||||
pos[0]= pos[-(int) diff];
|
||||
while (diff)
|
||||
{
|
||||
pos[0]=pos[-(int) diff]; pos--;
|
||||
|
@ -1607,6 +1607,7 @@ static void init_signals(void)
|
||||
sa.sa_handler=handle_segfault;
|
||||
#endif
|
||||
sigaction(SIGSEGV, &sa, NULL);
|
||||
sigaction(SIGABRT, &sa, NULL);
|
||||
#ifdef SIGBUS
|
||||
sigaction(SIGBUS, &sa, NULL);
|
||||
#endif
|
||||
|
@ -2017,8 +2017,12 @@ sum_expr:
|
||||
{ $$=new Item_sum_count(new Item_int((int32) 0L,1)); }
|
||||
| COUNT_SYM '(' in_sum_expr ')'
|
||||
{ $$=new Item_sum_count($3); }
|
||||
| COUNT_SYM '(' DISTINCT expr_list ')'
|
||||
{ $$=new Item_sum_count_distinct(* $4); }
|
||||
| COUNT_SYM '(' DISTINCT
|
||||
{ Select->in_sum_expr++; }
|
||||
expr_list
|
||||
{ Select->in_sum_expr--; }
|
||||
')'
|
||||
{ $$=new Item_sum_count_distinct(* $5); }
|
||||
| GROUP_UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' in_sum_expr ')'
|
||||
{ $$= new Item_sum_unique_users($3,atoi($5.str),atoi($7.str),$9); }
|
||||
| MIN_SYM '(' in_sum_expr ')'
|
||||
|
@ -11,12 +11,13 @@ use Getopt::Long;
|
||||
$opt_host="";
|
||||
$opt_user=$opt_password="";
|
||||
$opt_db="test";
|
||||
$opt_rows=200; # Test of blobs up to ($rows-1)*100000+1 bytes
|
||||
$opt_rows=20; # Test of blobs up to ($rows-1)*100000+1 bytes
|
||||
$opt_compress=0;
|
||||
$opt_table="test_big_record";
|
||||
$opt_loop_count=100000; # Change this to make test harder/easier
|
||||
|
||||
GetOptions("host=s","db=s","user=s", "password=s", "table=s", "rows=i",
|
||||
"compress") || die "Aborted";
|
||||
"compress", "loop-count=i") || die "Aborted";
|
||||
|
||||
print "Connection to database $test_db\n";
|
||||
|
||||
@ -42,12 +43,12 @@ $|=1; # Flush output to stdout to be able to monitor process
|
||||
for ($i=0 ; $i < $opt_rows ; $i++)
|
||||
{
|
||||
$tmp= chr(65+($i % 16)) x ($i*100000+1);
|
||||
print $i," ",length($tmp),"\n";
|
||||
$tmp= $dbh->quote($tmp);
|
||||
$dbh->do("insert into $opt_table (test) values ($tmp)") or die $DBI::errstr;
|
||||
print ".";
|
||||
}
|
||||
|
||||
print "Reading records\n";
|
||||
print "\nReading records\n";
|
||||
|
||||
$sth=$dbh->prepare("select * from $opt_table", { "mysql_use_result" => 1}) or die $dbh->errstr;
|
||||
|
||||
@ -56,14 +57,40 @@ $sth->execute() or die $sth->errstr;
|
||||
$i=0;
|
||||
while (($row = $sth->fetchrow_arrayref))
|
||||
{
|
||||
print $row->[0]," ",length($row->[1]),"\n";
|
||||
die "Record $i had wrong data in blob" if ($row->[1] ne (chr(65+($i % 16)) x ($i*100000+1)));
|
||||
$i++;
|
||||
}
|
||||
|
||||
die "Didn't get all rows from server" if ($i != $opt_rows);
|
||||
|
||||
$dbh->do("drop table $opt_table") or die $DBI::errstr;
|
||||
#
|
||||
# Test by insert/updating/deleting random rows for a while
|
||||
#
|
||||
|
||||
print "Test ok\n";
|
||||
print "Testing insert/update/delete\n";
|
||||
|
||||
$max_row_id= $rows;
|
||||
for ($i= 0 ; $i < $opt_loop_count ; $i++)
|
||||
{
|
||||
$length= int(rand 65535);
|
||||
$tmp= chr(65+($i % 16)) x $length;
|
||||
$tmp= $dbh->quote($tmp);
|
||||
$dbh->do("insert into $opt_table (test) values ($tmp)") or die $DBI::errstr;
|
||||
$max_row_id++;
|
||||
$length=int(rand 65535);
|
||||
$tmp= chr(65+($i % 16)) x $length;
|
||||
$tmp= $dbh->quote($tmp);
|
||||
$id= int(rand $max_row_id);
|
||||
$dbh->do("update $opt_table set test= $tmp where auto= $id") or die $DBI::errstr;
|
||||
if (($i % 2) == 1)
|
||||
{
|
||||
$id= int(rand $max_row_id);
|
||||
$dbh->do("delete from $opt_table where auto= $id") or die $DBI::errstr;
|
||||
}
|
||||
print "." if ($i % ($opt_loop_count/100) == 1);
|
||||
}
|
||||
|
||||
# $dbh->do("drop table $opt_table") or die $DBI::errstr;
|
||||
|
||||
print "\nTest ok\n";
|
||||
exit 0;
|
||||
|
@ -66,13 +66,6 @@ $dbh = $server->connect();
|
||||
####
|
||||
|
||||
$table_name="bench1";
|
||||
<<<<<<< table_types.pl
|
||||
||||||| 1.2
|
||||
test("n","type=isam","char"); test("m","type=myisam pack_keys=1","char"); exit(1);
|
||||
|
||||
=======
|
||||
|
||||
>>>>>>> /tmp/T4a17019
|
||||
test($table_name,"type=isam","char");
|
||||
test($table_name,"type=myisam pack_keys=0","char");
|
||||
test($table_name,"type=myisam pack_keys=0","char");
|
||||
@ -91,7 +84,7 @@ exit (0);
|
||||
|
||||
sub test {
|
||||
my ($name,$options,$chartype)=@_;
|
||||
|
||||
|
||||
print "\nTesting with options: '$options'\n";
|
||||
$dbh->do("drop table $name");
|
||||
do_many($dbh,$server->create("$name",
|
||||
@ -102,23 +95,23 @@ sub test {
|
||||
["primary key (id,id2)",
|
||||
"index index_id3 (id3)"],
|
||||
$options));
|
||||
|
||||
|
||||
if ($opt_lock_tables)
|
||||
{
|
||||
$sth = $dbh->do("LOCK TABLES $name WRITE") || die $DBI::errstr;
|
||||
}
|
||||
|
||||
|
||||
if ($opt_fast && defined($server->{vacuum}))
|
||||
{
|
||||
$server->vacuum(\$dbh,1);
|
||||
}
|
||||
|
||||
|
||||
####
|
||||
#### Insert $total_rows records in order, in reverse order and random.
|
||||
####
|
||||
|
||||
|
||||
$loop_time=new Benchmark;
|
||||
|
||||
|
||||
if ($opt_fast_insert)
|
||||
{
|
||||
$query="insert into $name values ";
|
||||
@ -127,11 +120,11 @@ sub test {
|
||||
{
|
||||
$query="insert into $name (id,id2,id3,dummy1) values ";
|
||||
}
|
||||
|
||||
|
||||
if (($opt_fast || $opt_fast_insert) && $limits->{'multi_value_insert'})
|
||||
{
|
||||
$query_size=$server->{'limits'}->{'query_size'};
|
||||
|
||||
|
||||
print "Inserting $opt_loop_count multiple-value rows in order\n";
|
||||
$res=$query;
|
||||
for ($i=0 ; $i < $opt_loop_count ; $i++)
|
||||
@ -186,7 +179,7 @@ sub test {
|
||||
{
|
||||
$sth = $dbh->do($query . "($i,$i,$i,'ABCDEFGHIJ')") or die $DBI::errstr;
|
||||
}
|
||||
|
||||
|
||||
print "Inserting $opt_loop_count rows in reverse order\n";
|
||||
for ($i=0 ; $i < $opt_loop_count ; $i++)
|
||||
{
|
||||
@ -195,25 +188,25 @@ sub test {
|
||||
($total_rows-1-$i) . ",'BCDEFGHIJK')")
|
||||
or die $DBI::errstr;
|
||||
}
|
||||
|
||||
|
||||
print "Inserting $opt_loop_count rows in random order\n";
|
||||
|
||||
|
||||
for ($i=0 ; $i < $opt_loop_count ; $i++)
|
||||
{
|
||||
$sth = $dbh->do($query . "(". $random[$i] . "," . $random[$i] .
|
||||
"," . $random[$i] . ",'CDEFGHIJKL')") or die $DBI::errstr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$end_time=new Benchmark;
|
||||
print "Time for insert (" . ($total_rows) . "): " .
|
||||
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
|
||||
|
||||
|
||||
if ($opt_fast && defined($server->{vacuum}))
|
||||
{
|
||||
$server->vacuum(\$dbh,1);
|
||||
}
|
||||
|
||||
|
||||
$sth=$dbh->prepare("show table status like '$name'");
|
||||
$sth->execute || die "Show table status returned error: $DBI::errstr\n";
|
||||
while (@row = $sth->fetchrow_array)
|
||||
|
Reference in New Issue
Block a user