summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormonty@narttu.mysql.fi <>2003-05-19 16:35:49 +0300
committermonty@narttu.mysql.fi <>2003-05-19 16:35:49 +0300
commitdd2b7918cdd5e0e643cff0305542ccd4aa8f1b6b (patch)
tree6025913cf3d482ba0783bf3420f7341c10cd574a /tests
parent524878e9358706ffb5908677c746a9060c66ad32 (diff)
parentfc0df599dc72408419e80a5f1d3e07dc5f0fec88 (diff)
downloadmariadb-git-dd2b7918cdd5e0e643cff0305542ccd4aa8f1b6b.tar.gz
Merge with 4.0.13
Diffstat (limited to 'tests')
-rwxr-xr-xtests/big_record.pl41
-rw-r--r--tests/grant.pl43
-rw-r--r--tests/grant.res60
-rwxr-xr-xtests/table_types.pl35
4 files changed, 138 insertions, 41 deletions
diff --git a/tests/big_record.pl b/tests/big_record.pl
index 08547b50823..fbe94e3540f 100755
--- a/tests/big_record.pl
+++ b/tests/big_record.pl
@@ -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;
diff --git a/tests/grant.pl b/tests/grant.pl
index 5a24127d79d..3146b7b6c25 100644
--- a/tests/grant.pl
+++ b/tests/grant.pl
@@ -63,6 +63,12 @@ user_connect(1);
#goto test;
#
+# Enable column grant code
+#
+safe_query("grant select(user) on mysql.user to $user");
+safe_query("revoke select(user) on mysql.user from $user");
+
+#
# Test grants on user level
#
@@ -76,6 +82,7 @@ user_query("select * from mysql.user where user = '$opt_user'");
user_query("select * from mysql.db where user = '$opt_user'");
safe_query("grant select on *.* to $user,$user");
safe_query("show grants for $user");
+user_connect(0);
# The following should fail
user_query("insert into mysql.user (host,user) values ('error','$opt_user')",1);
@@ -89,16 +96,21 @@ safe_query("grant select on $opt_database.not_exists to $opt_user",1);
safe_query("grant FILE on $opt_database.test to $opt_user",1);
safe_query("grant select on *.* to wrong___________user_name",1);
safe_query("grant select on $opt_database.* to wrong___________user_name",1);
+user_connect(0);
user_query("grant select on $opt_database.test to $opt_user with grant option",1);
safe_query("set password FOR ''\@''=''",1);
user_query("set password FOR root\@$opt_host = password('test')",1);
# Change privileges for user
safe_query("revoke select on *.* from $user");
-safe_query("grant create on *.* to $user");
+safe_query("grant create,update on *.* to $user");
user_connect(0);
+safe_query("flush privileges");
user_query("create table $opt_database.test (a int,b int)");
-
+user_query("update $opt_database.test set b=b+1 where a > 0",1);
+safe_query("show grants for $user");
+safe_query("revoke update on *.* from $user");
+user_connect(0);
safe_query("grant select(c) on $opt_database.test to $user",1);
safe_query("revoke select(c) on $opt_database.test from $user",1);
safe_query("grant select on $opt_database.test to wrong___________user_name",1);
@@ -217,8 +229,21 @@ user_query("update $opt_database.test set b=b+1",1);
safe_query("grant SELECT on *.* to $user");
user_connect(0);
user_query("update $opt_database.test set b=b+1");
+user_query("update $opt_database.test set b=b+1 where a > 0");
safe_query("revoke SELECT on *.* from $user");
+safe_query("grant SELECT on $opt_database.* to $user");
user_connect(0);
+user_query("update $opt_database.test set b=b+1");
+user_query("update $opt_database.test set b=b+1 where a > 0");
+safe_query("grant UPDATE on *.* to $user");
+user_connect(0);
+user_query("update $opt_database.test set b=b+1");
+user_query("update $opt_database.test set b=b+1 where a > 0");
+safe_query("revoke UPDATE on *.* from $user");
+safe_query("revoke SELECT on $opt_database.* from $user");
+user_connect(0);
+user_query("update $opt_database.test set b=b+1 where a > 0",1);
+user_query("update $opt_database.test set b=b+1",1);
# Add one privilege at a time until the user has all privileges
user_query("select * from test",1);
@@ -408,21 +433,29 @@ safe_query("grant ALL PRIVILEGES on $opt_database.test to $user identified by 'd
user_connect(0,"dummy");
safe_query("grant SELECT on $opt_database.* to $user identified by ''");
user_connect(0);
-safe_query("revoke ALL PRIVILEGES on $opt_database.test from $user identified by ''");
+safe_query("revoke ALL PRIVILEGES on $opt_database.test from $user identified by '', ${opt_user}\@127.0.0.1 identified by 'dummy2'");
safe_query("revoke ALL PRIVILEGES on $opt_database.* from $user identified by ''");
+
safe_query("show grants for $user");
#
# Test bug reported in SELECT INTO OUTFILE
#
-safe_query("create table $opt_database.test3 (a int)");
+safe_query("create table $opt_database.test3 (a int, b int)");
safe_query("grant SELECT on $opt_database.test3 to $user");
safe_query("grant FILE on *.* to $user");
-safe_query("insert into $opt_database.test3 values (1)");
+safe_query("insert into $opt_database.test3 values (1,1)");
user_connect(0);
user_query("select * into outfile '$tmp_table' from $opt_database.test3");
safe_query("revoke SELECT on $opt_database.test3 from $user");
+safe_query("grant SELECT(a) on $opt_database.test3 to $user");
+user_query("select a from $opt_database.test3");
+user_query("select * from $opt_database.test3",1);
+user_query("select a,b from $opt_database.test3",1);
+user_query("select b from $opt_database.test3",1);
+
+safe_query("revoke SELECT(a) on $opt_database.test3 from $user");
safe_query("revoke FILE on *.* from $user");
safe_query("drop table $opt_database.test3");
diff --git a/tests/grant.res b/tests/grant.res
index adb4494eb28..7b244f099f8 100644
--- a/tests/grant.res
+++ b/tests/grant.res
@@ -10,6 +10,8 @@ Error in execute: Can't drop database 'grant_test'. Database doesn't exist
create database grant_test
Connecting grant_user
Error on connect: Access denied for user: '@localhost' to database 'grant_test'
+grant select(user) on mysql.user to grant_user@localhost
+revoke select(user) on mysql.user from grant_user@localhost
grant select on *.* to grant_user@localhost
set password FOR grant_user2@localhost = password('test')
Error in execute: Can't find any matching row in the user table
@@ -26,6 +28,7 @@ grant select on *.* to grant_user@localhost,grant_user@localhost
show grants for grant_user@localhost
GRANT SELECT ON *.* TO 'grant_user'@'localhost'
+Connecting grant_user
insert into mysql.user (host,user) values ('error','grant_user')
Error in execute: Access denied for user: 'grant_user@localhost' to database 'mysql'
update mysql.user set host='error' WHERE user='grant_user'
@@ -48,6 +51,7 @@ grant select on *.* to wrong___________user_name
Error in execute: The host or user argument to GRANT is too long
grant select on grant_test.* to wrong___________user_name
Error in execute: The host or user argument to GRANT is too long
+Connecting grant_user
grant select on grant_test.test to grant_user with grant option
Error in execute: grant command denied to user: 'grant_user@localhost' for table 'test'
set password FOR ''@''=''
@@ -55,9 +59,17 @@ Error in execute: Can't find any matching row in the user table
set password FOR root@localhost = password('test')
Error in execute: Access denied for user: 'grant_user@localhost' to database 'mysql'
revoke select on *.* from grant_user@localhost
-grant create on *.* to grant_user@localhost
+grant create,update on *.* to grant_user@localhost
Connecting grant_user
+flush privileges
create table grant_test.test (a int,b int)
+update grant_test.test set b=b+1 where a > 0
+Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'a' in table 'test'
+show grants for grant_user@localhost
+GRANT UPDATE, CREATE ON *.* TO 'grant_user'@'localhost'
+
+revoke update on *.* from grant_user@localhost
+Connecting grant_user
grant select(c) on grant_test.test to grant_user@localhost
Error in execute: Unknown column 'c' in 'test'
revoke select(c) on grant_test.test from grant_user@localhost
@@ -198,9 +210,24 @@ Error in execute: SELECT command denied to user: 'grant_user@localhost' for colu
grant SELECT on *.* to grant_user@localhost
Connecting grant_user
update grant_test.test set b=b+1
+update grant_test.test set b=b+1 where a > 0
revoke SELECT on *.* from grant_user@localhost
+grant SELECT on grant_test.* to grant_user@localhost
+Connecting grant_user
+update grant_test.test set b=b+1
+update grant_test.test set b=b+1 where a > 0
+grant UPDATE on *.* to grant_user@localhost
Connecting grant_user
-lect * from test
+update grant_test.test set b=b+1
+update grant_test.test set b=b+1 where a > 0
+revoke UPDATE on *.* from grant_user@localhost
+revoke SELECT on grant_test.* from grant_user@localhost
+Connecting grant_user
+update grant_test.test set b=b+1 where a > 0
+Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'a' in table 'test'
+update grant_test.test set b=b+1
+Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test'
+select * from test
Error in execute: select command denied to user: 'grant_user@localhost' for table 'test'
grant select on grant_test.test to grant_user@localhost
delete from grant_test.test where a=1
@@ -448,21 +475,34 @@ grant ALL PRIVILEGES on grant_test.test to grant_user@localhost identified by 'd
Connecting grant_user
grant SELECT on grant_test.* to grant_user@localhost identified by ''
Connecting grant_user
-revoke ALL PRIVILEGES on grant_test.test from grant_user@localhost identified by ''
+revoke ALL PRIVILEGES on grant_test.test from grant_user@localhost identified by '', grant_user@127.0.0.1 identified by 'dummy2'
revoke ALL PRIVILEGES on grant_test.* from grant_user@localhost identified by ''
show grants for grant_user@localhost
-create table grant_test.test3 (a int)
+GRANT USAGE ON *.* TO 'grant_user'@'localhost'
+
+create table grant_test.test3 (a int, b int)
grant SELECT on grant_test.test3 to grant_user@localhost
grant FILE on *.* to grant_user@localhost
-insert into grant_test.test3 values (1)
+insert into grant_test.test3 values (1,1)
Connecting grant_user
select * into outfile '/tmp/mysql-grant.test' from grant_test.test3
revoke SELECT on grant_test.test3 from grant_user@localhost
+grant SELECT(a) on grant_test.test3 to grant_user@localhost
+select a from grant_test.test3
+1
+
+select * from grant_test.test3
+Error in execute: select command denied to user: 'grant_user@localhost' for column 'b' in table 'test3'
+select a,b from grant_test.test3
+Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test3'
+select b from grant_test.test3
+Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test3'
+revoke SELECT(a) on grant_test.test3 from grant_user@localhost
revoke FILE on *.* from grant_user@localhost
drop table grant_test.test3
create table grant_test.test3 (a int)
Connecting grant_user
-Access denied for user: 'grant_user@localhost' to database 'grant_test'
+Error on connect: Access denied for user: 'grant_user@localhost' to database 'grant_test'
grant INSERT on grant_test.test3 to grant_user@localhost
Connecting grant_user
select * into outfile '/tmp/mysql-grant.test' from grant_test.test3
@@ -474,7 +514,7 @@ Error in execute: Access denied for user: 'grant_user@localhost' to database 'gr
grant LOCK TABLES on *.* to grant_user@localhost
show grants for grant_user@localhost
GRANT LOCK TABLES ON *.* TO 'grant_user'@'localhost'
-GRANT SELECT, INSERT ON grant_test.test3 TO 'grant_user'@'localhost'
+GRANT SELECT, INSERT ON `grant_test`.`test3` TO 'grant_user'@'localhost'
select * from mysql.user where user='grant_user'
127.0.0.1 grant_user *042a99b3d247ae587783f647f2d69496d390aa71eab3 N N N N N N N N N N N N N N N N N N N N N 0 0 0
@@ -487,9 +527,11 @@ revoke SELECT,INSERT,UPDATE,DELETE on grant_test.test3 from grant_user@localhost
Connecting grant_user
revoke LOCK TABLES on *.* from grant_user@localhost
Connecting grant_user
-Access denied for user: 'grant_user@localhost' to database 'grant_test'
+Error on connect: Access denied for user: 'grant_user@localhost' to database 'grant_test'
drop table grant_test.test3
show grants for grant_user@localhost
+GRANT USAGE ON *.* TO 'grant_user'@'localhost'
+
grant all on *.* to grant_user@localhost WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 3
show grants for grant_user@localhost
GRANT ALL PRIVILEGES ON *.* TO 'grant_user'@'localhost' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 3
@@ -501,6 +543,8 @@ GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, F
revoke ALL PRIVILEGES on *.* from grant_user@localhost
show grants for grant_user@localhost
+GRANT USAGE ON *.* TO 'grant_user'@'localhost' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 3
+
drop database grant_test
delete from user where user='grant_user'
delete from db where user='grant_user'
diff --git a/tests/table_types.pl b/tests/table_types.pl
index 8198cd9ba86..4dbcdcb975c 100755
--- a/tests/table_types.pl
+++ b/tests/table_types.pl
@@ -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)