summaryrefslogtreecommitdiff
path: root/tests/grant.pl
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-03-13 16:43:43 +0200
committerunknown <monty@mashka.mysql.fi>2003-03-13 16:43:43 +0200
commitf3eb7fe0c3259b001f77c30844f42f96562c23f1 (patch)
treed43ad5953e51872d781cba2e6dd77912dfa42de9 /tests/grant.pl
parentc7551b88408430007ed7c27ed5e9f40f584e29d0 (diff)
downloadmariadb-git-f3eb7fe0c3259b001f77c30844f42f96562c23f1.tar.gz
Better fix for GRANT bug
tests/grant.pl: More options for test tests/grant.res: new test results
Diffstat (limited to 'tests/grant.pl')
-rw-r--r--tests/grant.pl55
1 files changed, 33 insertions, 22 deletions
diff --git a/tests/grant.pl b/tests/grant.pl
index a82e99645bc..c41b22157bd 100644
--- a/tests/grant.pl
+++ b/tests/grant.pl
@@ -8,12 +8,13 @@ use DBI;
use Getopt::Long;
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);
+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
+ $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";
@@ -21,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";
@@ -477,7 +478,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!";
@@ -492,7 +496,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))
{
@@ -509,7 +513,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))
{
@@ -525,8 +529,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)))
@@ -536,25 +540,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;
}