summaryrefslogtreecommitdiff
path: root/tests/grant.pl
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2003-03-16 19:17:54 +0200
committerunknown <monty@narttu.mysql.fi>2003-03-16 19:17:54 +0200
commit4b3b8d3724f1eab648f51ecba3919d6ec51f0104 (patch)
tree956d20750d7fec498888d037be8d588dab6412f0 /tests/grant.pl
parent1eefda14de68b8a72dfda807febddf31e39424fa (diff)
parent26e849bead957643b76fb7d2ea4cce73c6e268fd (diff)
downloadmariadb-git-4b3b8d3724f1eab648f51ecba3919d6ec51f0104.tar.gz
Merge with 4.0
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BitKeeper/deleted/.del-compile-netware-standard: Delete: netware/BUILD/compile-netware-standard BitKeeper/deleted/.del-mwenv: Delete: netware/BUILD/mwenv BitKeeper/deleted/.del-nwbootstrap: Delete: netware/BUILD/nwbootstrap BitKeeper/deleted/.del-compile-AUTOTOOLS: Delete: netware/BUILD/compile-AUTOTOOLS BitKeeper/deleted/.del-compile-linux-tools: Delete: netware/BUILD/compile-linux-tools BitKeeper/deleted/.del-compile-netware-END: Delete: netware/BUILD/compile-netware-END BitKeeper/deleted/.del-compile-netware-START: Delete: netware/BUILD/compile-netware-START BitKeeper/deleted/.del-compile-netware-all: Delete: netware/BUILD/compile-netware-all BitKeeper/deleted/.del-compile-netware-debug: Delete: netware/BUILD/compile-netware-debug BitKeeper/deleted/.del-mwasmnlm~bc5746809d67feb5: Auto merged BitKeeper/deleted/.del-mwenv~35c8b56062f4b6aa: Auto merged BitKeeper/deleted/.del-mwccnlm~be63afd25a14c3f: Auto merged BitKeeper/deleted/.del-mwldnlm~efb26c57cba3c980: Auto merged BitKeeper/deleted/.del-netware.patch~f70a3a965f54d9ee: Auto merged Docs/internals.texi: Auto merged VC++Files/bdb/bdb.dsp: Auto merged VC++Files/bdb/build_win32/Berkeley_DB.dsw: Auto merged VC++Files/bdb/build_win32/db_archive.dsp: Auto merged VC++Files/bdb/build_win32/db_buildall.dsp: Auto merged VC++Files/bdb/build_win32/db_checkpoint.dsp: Auto merged VC++Files/bdb/build_win32/db_deadlock.dsp: Auto merged VC++Files/bdb/build_win32/db_dll.dsp: Auto merged VC++Files/bdb/build_win32/db_dump.dsp: Auto merged VC++Files/bdb/build_win32/db_java.dsp: Auto merged VC++Files/bdb/build_win32/db_load.dsp: Auto merged VC++Files/bdb/build_win32/db_printlog.dsp: Auto merged VC++Files/bdb/build_win32/db_recover.dsp: Auto merged VC++Files/bdb/build_win32/db_stat.dsp: Auto merged VC++Files/bdb/build_win32/db_static.dsp: Auto merged VC++Files/bdb/build_win32/db_static1.dsp: Auto merged VC++Files/bdb/build_win32/db_tcl.dsp: Auto merged VC++Files/bdb/build_win32/db_test.dsp: Auto merged VC++Files/bdb/build_win32/db_upgrade.dsp: Auto merged VC++Files/bdb/build_win32/db_verify.dsp: Auto merged VC++Files/bdb/build_win32/ex_access.dsp: Auto merged VC++Files/bdb/build_win32/ex_btrec.dsp: Auto merged VC++Files/bdb/build_win32/ex_env.dsp: Auto merged VC++Files/bdb/build_win32/ex_lock.dsp: Auto merged VC++Files/bdb/build_win32/ex_mpool.dsp: Auto merged VC++Files/bdb/build_win32/ex_tpcb.dsp: Auto merged VC++Files/bdb/build_win32/excxx_access.dsp: Auto merged VC++Files/bdb/build_win32/excxx_btrec.dsp: Auto merged VC++Files/bdb/build_win32/excxx_env.dsp: Auto merged VC++Files/bdb/build_win32/excxx_lock.dsp: Auto merged VC++Files/bdb/build_win32/excxx_mpool.dsp: Auto merged VC++Files/bdb/build_win32/excxx_tpcb.dsp: Auto merged VC++Files/client/mysql.dsp: Auto merged VC++Files/client/mysqladmin.dsp: Auto merged VC++Files/client/mysqlcheck.dsp: Auto merged VC++Files/client/mysqlclient.dsp: Auto merged VC++Files/client/mysqlclient.dsw: Auto merged VC++Files/client/mysqldump.dsp: Auto merged VC++Files/client/mysqlimport.dsp: Auto merged VC++Files/client/mysqlshow.dsp: Auto merged VC++Files/comp_err/comp_err.dsp: Auto merged VC++Files/contrib/asm386/zlibvc.dsp: Auto merged VC++Files/contrib/asm386/zlibvc.dsw: Auto merged VC++Files/contrib/minizip/zlibvc.dsp: Auto merged VC++Files/contrib/minizip/zlibvc.dsw: Auto merged VC++Files/dbug/dbug.dsp: Auto merged VC++Files/dbug/dbug.dsw: Auto merged VC++Files/heap/heap.dsp: Auto merged VC++Files/innobase/innobase.dsp: Auto merged VC++Files/isam/isam.dsp: Auto merged VC++Files/isam/isam.dsw: Auto merged VC++Files/isamchk/isamchk.dsp: Auto merged VC++Files/libmysql/libmysql.dsp: Auto merged VC++Files/libmysql/libmysql.dsw: Auto merged VC++Files/libmysqld/examples/test_libmysqld.dsp: Auto merged VC++Files/libmysqld/libmysqld.dsp: Auto merged VC++Files/libmysqltest/myTest.dsp: Auto merged VC++Files/libmysqltest/mytest.dsw: Auto merged VC++Files/merge/merge.dsp: Auto merged VC++Files/merge/merge.dsw: Auto merged VC++Files/my_print_defaults/my_print_defaults.dsp: Auto merged VC++Files/myisam/myisam.dsp: Auto merged VC++Files/myisamchk/myisamchk.dsp: Auto merged VC++Files/myisamlog/myisamlog.dsp: Auto merged VC++Files/myisammrg/myisammrg.dsp: Auto merged VC++Files/mysql.dsp: Auto merged VC++Files/mysql.dsw: Auto merged VC++Files/myisampack/myisampack.dsp: Auto merged VC++Files/mysqlbinlog/mysqlbinlog.dsp: Auto merged VC++Files/mysqlcheck/mysqlcheck.dsp: Auto merged VC++Files/mysqldemb/mysqldemb.dsp: Auto merged VC++Files/mysqlmanager/MySqlManager.dsp: Auto merged VC++Files/mysqlmanager/mysqlmanager.dsw: Auto merged VC++Files/mysqlserver/mysqlserver.dsp: Auto merged VC++Files/mysqlshutdown/myshutdown.dsp: Auto merged VC++Files/mysqlshutdown/mysqlshutdown.dsp: Auto merged VC++Files/mysqlwatch/mysqlwatch.dsp: Auto merged VC++Files/mysys/mysys.dsp: Auto merged VC++Files/mysys/mysys.dsw: Auto merged VC++Files/pack_isam/pack_isam.dsp: Auto merged VC++Files/perror/perror.dsp: Auto merged VC++Files/regex/regex.dsp: Auto merged VC++Files/regex/regex.dsw: Auto merged VC++Files/replace/replace.dsp: Auto merged VC++Files/sql/mysqld.dsw: Auto merged VC++Files/sql/mysqldmax.dsp: Auto merged VC++Files/sql/old/mysqld.dsw: Auto merged VC++Files/strings/MASM6x/strings.dsp: Auto merged VC++Files/strings/MASM6x/strings.dsw: Auto merged VC++Files/strings/backup/strings.dsp: Auto merged VC++Files/strings/backup/strings.dsw: Auto merged VC++Files/strings/noMASM/strings.dsp: Auto merged VC++Files/strings/noMASM/strings.dsw: Auto merged VC++Files/strings/strings.dsw: Auto merged VC++Files/test1/test1.dsp: Auto merged VC++Files/thr_insert_test/thr_insert_test.dsp: Auto merged VC++Files/thr_test/thr_test.dsp: Auto merged VC++Files/vio/vio.dsp: Auto merged VC++Files/zlib/zlib.dsp: Auto merged client/mysqlbinlog.cc: Auto merged client/mysqlshow.c: Auto merged include/my_global.h: Auto merged include/my_sys.h: Auto merged include/myisam.h: Auto merged include/thr_lock.h: Auto merged include/violite.h: Auto merged innobase/buf/buf0buf.c: Auto merged innobase/os/os0file.c: Auto merged innobase/row/row0sel.c: Auto merged innobase/srv/srv0start.c: Auto merged innobase/trx/trx0sys.c: Auto merged libmysqld/lib_vio.c: Auto merged myisam/mi_create.c: Auto merged mysql-test/Makefile.am: Auto merged mysql-test/r/create.result: Auto merged mysql-test/r/group_by.result: Auto merged mysql-test/r/innodb.result: Auto merged mysql-test/r/join.result: Auto merged mysql-test/r/rpl000001.result: Auto merged mysql-test/r/select.result: Auto merged mysql-test/t/auto_increment.test: Auto merged mysql-test/t/create.test: Auto merged mysql-test/t/func_like.test: Auto merged mysql-test/t/group_by.test: Auto merged mysql-test/t/innodb.test: Auto merged mysql-test/t/join.test: Auto merged mysql-test/t/type_datetime.test: Auto merged mysql-test/t/type_timestamp.test: Auto merged mysys/default.c: Auto merged mysys/thr_lock.c: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysqld_safe.sh: Auto merged sql/filesort.cc: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.cc: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/lock.cc: Auto merged sql/log.cc: Auto merged sql/log_event.h: Auto merged sql/mf_iocache.cc: Auto merged sql/mysql_priv.h: Auto merged sql/net_serv.cc: Auto merged sql/opt_range.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/repl_failsafe.h: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sql_analyse.cc: Auto merged sql/sql_base.cc: Auto merged sql-bench/crash-me.sh: Auto merged sql/share/polish/errmsg.txt: Auto merged sql/sql_class.h: Auto merged sql/sql_rename.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_repl.h: Auto merged sql/sql_update.cc: Auto merged sql/stacktrace.c: Auto merged sql/table.cc: Auto merged sql/unireg.h: Auto merged strings/ctype-tis620.c: Auto merged strings/t_ctype.h: Auto merged support-files/mysql.spec.sh: Auto merged tests/grant.res: Auto merged vio/viosocket.c: Auto merged
Diffstat (limited to 'tests/grant.pl')
-rw-r--r--tests/grant.pl60
1 files changed, 40 insertions, 20 deletions
diff --git a/tests/grant.pl b/tests/grant.pl
index 9212c610ac1..5a24127d79d 100644
--- a/tests/grant.pl
+++ b/tests/grant.pl
@@ -11,10 +11,10 @@ use strict;
use vars qw($dbh $user_dbh $opt_help $opt_Information $opt_force $opt_debug
$opt_verbose $opt_server $opt_root_user $opt_password $opt_user
$opt_database $opt_host $version $user $tables_cols $columns_cols
- $tmp_table);
+ $tmp_table $opt_silent);
-$version="1.0";
-$opt_help=$opt_Information=$opt_force=$opt_debug=$opt_verbose=0;
+$version="1.1";
+$opt_help=$opt_Information=$opt_force=$opt_debug=$opt_verbose=$opt_silent=0;
$opt_host="localhost",
$opt_server="mysql";
$opt_root_user="root";
@@ -22,7 +22,7 @@ $opt_password="";
$opt_user="grant_user";
$opt_database="grant_test";
-GetOptions("Information","help","server=s","root-user=s","password=s","user","database=s","force","host=s","debug","verbose") || usage();
+GetOptions("Information","help","server=s","root-user=s","password=s","user","database=s","force","host=s","debug","verbose","silent") || usage();
usage() if ($opt_help || $opt_Information);
$user="$opt_user\@$opt_host";
@@ -210,6 +210,16 @@ user_query("delete from $opt_database.test where a=1",1);
user_query("update $opt_database.test set b=3 where b=1",1);
user_query("update $opt_database.test set b=b+1",1);
+#
+# Test global SELECT privilege combined with table level privileges
+#
+
+safe_query("grant SELECT on *.* to $user");
+user_connect(0);
+user_query("update $opt_database.test set b=b+1");
+safe_query("revoke SELECT on *.* from $user");
+user_connect(0);
+
# Add one privilege at a time until the user has all privileges
user_query("select * from test",1);
safe_query("grant select on $opt_database.test to $user");
@@ -543,7 +553,10 @@ sub user_connect
$password, { PrintError => 0});
if (!$user_dbh)
{
- print "$DBI::errstr\n";
+ if ($opt_verbose || !$ignore_error)
+ {
+ print "Error on connect: $DBI::errstr\n";
+ }
if (!$ignore_error)
{
die "The above should not have failed!";
@@ -558,7 +571,7 @@ sub user_connect
sub safe_query
{
my ($query,$ignore_error)=@_;
- if (do_query($dbh,$query))
+ if (do_query($dbh,$query, $ignore_error))
{
if (!defined($ignore_error))
{
@@ -575,7 +588,7 @@ sub safe_query
sub user_query
{
my ($query,$ignore_error)=@_;
- if (do_query($user_dbh,$query))
+ if (do_query($user_dbh,$query, $ignore_error))
{
if (!defined($ignore_error))
{
@@ -591,8 +604,8 @@ sub user_query
sub do_query
{
- my ($my_dbh, $query)=@_;
- my ($sth,$row,$tab,$col,$found);
+ my ($my_dbh, $query, $ignore_error)=@_;
+ my ($sth, $row, $tab, $col, $found, $fatal_error);
print "$query\n" if ($opt_debug || $opt_verbose);
if (!($sth= $my_dbh->prepare($query)))
@@ -602,25 +615,32 @@ sub do_query
}
if (!$sth->execute)
{
- print "Error in execute: $DBI::errstr\n";
- die if ($DBI::errstr =~ /parse error/);
+ $fatal_error= ($DBI::errstr =~ /parse error/);
+ if (!$ignore_error || $opt_verbose || $fatal_error)
+ {
+ print "Error in execute: $DBI::errstr\n";
+ }
+ die if ($fatal_error);
$sth->finish;
return 1;
}
$found=0;
- while (($row=$sth->fetchrow_arrayref))
+ if (!$opt_silent)
{
- $found=1;
- $tab="";
- foreach $col (@$row)
+ while (($row=$sth->fetchrow_arrayref))
{
- print $tab;
- print defined($col) ? $col : "NULL";
- $tab="\t";
+ $found=1;
+ $tab="";
+ foreach $col (@$row)
+ {
+ print $tab;
+ print defined($col) ? $col : "NULL";
+ $tab="\t";
+ }
+ print "\n";
}
- print "\n";
+ print "\n" if ($found);
}
- print "\n" if ($found);
$sth->finish;
return 0;
}