summaryrefslogtreecommitdiff
path: root/sql-bench/bench-init.pl.sh
diff options
context:
space:
mode:
authorunknown <monty@mysql.com/narttu.mysql.fi>2006-11-29 22:51:09 +0200
committerunknown <monty@mysql.com/narttu.mysql.fi>2006-11-29 22:51:09 +0200
commitee1c5226b9758648c1b699e4a0ebe9c1d3f4bf30 (patch)
treed9287bcf6cac6fec1a2d75f4ea0cb4afc3e6926f /sql-bench/bench-init.pl.sh
parent76b4ccbdf8d4913993eb64ef08986654ac5f0423 (diff)
downloadmariadb-git-ee1c5226b9758648c1b699e4a0ebe9c1d3f4bf30.tar.gz
Added back sql-bench directory, so that one can more easily run benchmarks on a server and add new benchmarks for new optimizations
Fixed memory leak in _db_set() (Bug#24497 Valgrind warning: get_one_option) Don't call net_clear() on COM_QUIT. This avoids a warning from net_clear() after shutdown: "skipped ## bytes from file" BUG#21428: skipped 9 bytes from file: socket (3)" on "mysqladmin shutdown" sql-bench/test-wisconsin.sh: Rename: BitKeeper/deleted/.del-test-wisconsin.sh~c0b86821b5f95f26 -> sql-bench/test-wisconsin.sh sql-bench/test-transactions.sh: Rename: BitKeeper/deleted/.del-test-transactions.sh~c1c892f10c40caf -> sql-bench/test-transactions.sh sql-bench/test-insert.sh: Rename: BitKeeper/deleted/.del-test-insert.sh~893bfac9dedb79a7 -> sql-bench/test-insert.sh sql-bench/test-select.sh: Rename: BitKeeper/deleted/.del-test-select.sh~6d5cc770acf11be6 -> sql-bench/test-select.sh sql-bench/test-create.sh: Rename: BitKeeper/deleted/.del-test-create.sh~f9a1ea38c191b17a -> sql-bench/test-create.sh sql-bench/test-big-tables.sh: Rename: BitKeeper/deleted/.del-test-big-tables.sh~5b1b0c5fb623565a -> sql-bench/test-big-tables.sh sql-bench/test-connect.sh: Rename: BitKeeper/deleted/.del-test-connect.sh~382a728c949ee075 -> sql-bench/test-connect.sh sql-bench/test-ATIS.sh: Rename: BitKeeper/deleted/.del-test-ATIS.sh~e8ebff7086c95773 -> sql-bench/test-ATIS.sh sql-bench/test-alter-table.sh: Rename: BitKeeper/deleted/.del-test-alter-table.sh~eba6cfa9972fcced -> sql-bench/test-alter-table.sh sql-bench/innotest2b.sh: Rename: BitKeeper/deleted/.del-innotest2b.sh~7b99ece835e8dff3 -> sql-bench/innotest2b.sh sql-bench/run-all-tests.sh: Rename: BitKeeper/deleted/.del-run-all-tests.sh~41d6da1cf211ee95 -> sql-bench/run-all-tests.sh sql-bench/innotest2.sh: Rename: BitKeeper/deleted/.del-innotest2.sh~9c14df528285603 -> sql-bench/innotest2.sh sql-bench/innotest2a.sh: Rename: BitKeeper/deleted/.del-innotest2a.sh~e01d016a7cafdc0b -> sql-bench/innotest2a.sh sql-bench/innotest1a.sh: Rename: BitKeeper/deleted/.del-innotest1a.sh~c64f4610ae1e26fe -> sql-bench/innotest1a.sh sql-bench/innotest1b.sh: Rename: BitKeeper/deleted/.del-innotest1b.sh~aafd0819ae84da7b -> sql-bench/innotest1b.sh sql-bench/innotest1.sh: Rename: BitKeeper/deleted/.del-innotest1.sh~aa36bce09ca783c7 -> sql-bench/innotest1.sh sql-bench/crash-me.sh: Rename: BitKeeper/deleted/.del-crash-me.sh~2fa881d0b40339c8 -> sql-bench/crash-me.sh sql-bench/graph-compare-results.sh: Rename: BitKeeper/deleted/.del-graph-compare-results.sh~7e4e28b3591b4542 -> sql-bench/graph-compare-results.sh sql-bench/copy-db.sh: Rename: BitKeeper/deleted/.del-copy-db.sh~e8116afb93144ccd -> sql-bench/copy-db.sh sql-bench/compare-results.sh: Rename: BitKeeper/deleted/.del-compare-results.sh~a9e26e2644c694b3 -> sql-bench/compare-results.sh sql-bench/bench-count-distinct.sh: Rename: BitKeeper/deleted/.del-bench-count-distinct.sh~a92f174271a831d7 -> sql-bench/bench-count-distinct.sh sql-bench/as3ap.sh: Rename: BitKeeper/deleted/.del-as3ap.sh~f54eebbd8d34c9b6 -> sql-bench/as3ap.sh sql-bench/Comments/Informix.crash-me: Rename: BitKeeper/deleted/.del-Informix.crash-me~51ab5b717cefe74 -> sql-bench/Comments/Informix.crash-me sql-bench/Comments/postgres.crash-me: Rename: BitKeeper/deleted/.del-postgres.crash-me~eacac145c3e30f17 -> sql-bench/Comments/postgres.crash-me sql-bench/Comments/Empress.crash-me: Rename: BitKeeper/deleted/.del-Empress.crash-me~bdaff0c68ce10f02 -> sql-bench/Comments/Empress.crash-me sql-bench/Comments/Adabas.crash-me: Rename: BitKeeper/deleted/.del-Adabas.crash-me~ce88ba1a540971ac -> sql-bench/Comments/Adabas.crash-me sql-bench/Comments/Access.crash-me: Rename: BitKeeper/deleted/.del-Access.crash-me~bb457ec282d939b6 -> sql-bench/Comments/Access.crash-me sql-bench/Comments/postgres.benchmark: Rename: BitKeeper/deleted/.del-postgres.benchmark~4d30890732b784a -> sql-bench/Comments/postgres.benchmark sql-bench/Comments/mysql.benchmark: Rename: BitKeeper/deleted/.del-mysql.benchmark~4d8729c0937456fc -> sql-bench/Comments/mysql.benchmark sql-bench/Comments/FrontBase.benchmark: Rename: BitKeeper/deleted/.del-FrontBase.benchmark~217041ef18274c2e -> sql-bench/Comments/FrontBase.benchmark sql-bench/Comments/interbase: Rename: BitKeeper/deleted/.del-interbase~cdad59622b4d6f3 -> sql-bench/Comments/interbase sql-bench/uname.bat: Rename: BitKeeper/deleted/.del-uname.bat~a6d933d2ee9314c -> sql-bench/uname.bat sql-bench/pwd.bat: Rename: BitKeeper/deleted/.del-pwd.bat~9b64050849abf51 -> sql-bench/pwd.bat sql-bench/example.bat: Rename: BitKeeper/deleted/.del-example.bat~22d0170bccf0f030 -> sql-bench/example.bat sql-bench/Makefile.am: Rename: BitKeeper/deleted/.del-Makefile.am~7b07da85b2e9375 -> sql-bench/Makefile.am sql-bench/Data/ATIS/transport.txt: Rename: BitKeeper/deleted/.del-transport.txt~fa4ca40735f8354c -> sql-bench/Data/ATIS/transport.txt sql-bench/Data/ATIS/time_zone.txt: Rename: BitKeeper/deleted/.del-time_zone.txt~4171f9ca732f65c0 -> sql-bench/Data/ATIS/time_zone.txt sql-bench/Data/Wisconsin/tenk.data: Rename: BitKeeper/deleted/.del-tenk.data~6aeaebdd534e458e -> sql-bench/Data/Wisconsin/tenk.data sql-bench/Data/Wisconsin/onek.data: Rename: BitKeeper/deleted/.del-onek.data~6cd1edaf596a7f7 -> sql-bench/Data/Wisconsin/onek.data sql-bench/Data/ATIS/stop1.txt: Rename: BitKeeper/deleted/.del-stop1.txt~f09ba164ad44a288 -> sql-bench/Data/ATIS/stop1.txt sql-bench/Data/ATIS/time_interval.txt: Rename: BitKeeper/deleted/.del-time_interval.txt~a1def62e267a59b2 -> sql-bench/Data/ATIS/time_interval.txt sql-bench/Data/ATIS/stop.txt: Rename: BitKeeper/deleted/.del-stop.txt~31fb564e1f415e34 -> sql-bench/Data/ATIS/stop.txt sql-bench/Data/ATIS/restriction.txt: Rename: BitKeeper/deleted/.del-restriction.txt~6ae208924617784a -> sql-bench/Data/ATIS/restriction.txt sql-bench/Data/ATIS/state.txt: Rename: BitKeeper/deleted/.del-state.txt~9dd470ce14075b90 -> sql-bench/Data/ATIS/state.txt sql-bench/Data/ATIS/restrict_class.txt: Rename: BitKeeper/deleted/.del-restrict_class.txt~2f741bf0ea498f84 -> sql-bench/Data/ATIS/restrict_class.txt sql-bench/Data/ATIS/month_name.txt: Rename: BitKeeper/deleted/.del-month_name.txt~4c44f7a323d57d92 -> sql-bench/Data/ATIS/month_name.txt sql-bench/Data/ATIS/restrict_carrier.txt: Rename: BitKeeper/deleted/.del-restrict_carrier.txt~925b5492f3f9cba3 -> sql-bench/Data/ATIS/restrict_carrier.txt sql-bench/Data/ATIS/ground_service.txt: Rename: BitKeeper/deleted/.del-ground_service.txt~1087e477e86e84c -> sql-bench/Data/ATIS/ground_service.txt sql-bench/Data/ATIS/food_service.txt: Rename: BitKeeper/deleted/.del-food_service.txt~66d95a150c28458 -> sql-bench/Data/ATIS/food_service.txt sql-bench/Data/ATIS/flight_day.txt: Rename: BitKeeper/deleted/.del-flight_day.txt~76868d6d265d441e -> sql-bench/Data/ATIS/flight_day.txt sql-bench/Data/ATIS/flight_fare.txt: Rename: BitKeeper/deleted/.del-flight_fare.txt~d7322593c8530487 -> sql-bench/Data/ATIS/flight_fare.txt sql-bench/Data/ATIS/flight_class.txt: Rename: BitKeeper/deleted/.del-flight_class.txt~1801101474c29098 -> sql-bench/Data/ATIS/flight_class.txt sql-bench/Data/ATIS/fconnection.txt: Rename: BitKeeper/deleted/.del-fconnection.txt~e0ef6a8b5560a713 -> sql-bench/Data/ATIS/fconnection.txt sql-bench/Data/ATIS/flight.txt: Rename: BitKeeper/deleted/.del-flight.txt~e5065423760e99eb -> sql-bench/Data/ATIS/flight.txt sql-bench/Data/ATIS/fare.txt: Rename: BitKeeper/deleted/.del-fare.txt~ea0652f490bc24a6 -> sql-bench/Data/ATIS/fare.txt sql-bench/Data/ATIS/day_name.txt: Rename: BitKeeper/deleted/.del-day_name.txt~f813b215955d894c -> sql-bench/Data/ATIS/day_name.txt sql-bench/Data/ATIS/dual_carrier.txt: Rename: BitKeeper/deleted/.del-dual_carrier.txt~a7dd776224fbd92b -> sql-bench/Data/ATIS/dual_carrier.txt sql-bench/Data/ATIS/date_day.txt: Rename: BitKeeper/deleted/.del-date_day.txt~4e9a282fcf54cfd8 -> sql-bench/Data/ATIS/date_day.txt sql-bench/Data/ATIS/compound_class.txt: Rename: BitKeeper/deleted/.del-compound_class.txt~d4a2f1b7f96340b9 -> sql-bench/Data/ATIS/compound_class.txt sql-bench/Data/ATIS/connect_leg.txt: Rename: BitKeeper/deleted/.del-connect_leg.txt~f97b6e94e108bb36 -> sql-bench/Data/ATIS/connect_leg.txt sql-bench/Data/ATIS/code_description.txt: Rename: BitKeeper/deleted/.del-code_description.txt~f9117373e438b0e2 -> sql-bench/Data/ATIS/code_description.txt sql-bench/Data/ATIS/city.txt: Rename: BitKeeper/deleted/.del-city.txt~d96dd6d073344d2e -> sql-bench/Data/ATIS/city.txt sql-bench/Data/ATIS/class_of_service.txt: Rename: BitKeeper/deleted/.del-class_of_service.txt~21f6b9848b8c76d -> sql-bench/Data/ATIS/class_of_service.txt sql-bench/Data/ATIS/airport_service.txt: Rename: BitKeeper/deleted/.del-airport_service.txt~6ee6d5b852b3e38 -> sql-bench/Data/ATIS/airport_service.txt sql-bench/Data/ATIS/airline.txt: Rename: BitKeeper/deleted/.del-airline.txt~a79f8eadf853f2c8 -> sql-bench/Data/ATIS/airline.txt sql-bench/Data/ATIS/airport.txt: Rename: BitKeeper/deleted/.del-airport.txt~59c78514130e1f45 -> sql-bench/Data/ATIS/airport.txt sql-bench/Data/ATIS/aircraft.txt: Rename: BitKeeper/deleted/.del-aircraft.txt~15e4de7ab37c92d3 -> sql-bench/Data/ATIS/aircraft.txt sql-bench/TODO: Rename: BitKeeper/deleted/.del-TODO~cac6d7a63c426ae5 -> sql-bench/TODO sql-bench/limits/sybase.cfg: Rename: BitKeeper/deleted/.del-sybase.cfg~c4636b12767b3f14 -> sql-bench/limits/sybase.cfg sql-bench/limits/solid-nt4.cfg: Rename: BitKeeper/deleted/.del-solid-nt4.cfg~cca779f0c9e29d31 -> sql-bench/limits/solid-nt4.cfg sql-bench/limits/solid.cfg: Rename: BitKeeper/deleted/.del-solid.cfg~5ae0e4342eadb0fb -> sql-bench/limits/solid.cfg sql-bench/limits/pg.cfg: Rename: BitKeeper/deleted/.del-pg.cfg~db59cf39a5d417be -> sql-bench/limits/pg.cfg sql-bench/limits/mysql.cfg: Rename: BitKeeper/deleted/.del-mysql.cfg~9cab20a8771b93cf -> sql-bench/limits/mysql.cfg sql-bench/limits/oracle.cfg: Rename: BitKeeper/deleted/.del-oracle.cfg~affab21af8f438fd -> sql-bench/limits/oracle.cfg sql-bench/limits/mysql-4.1.cfg: Rename: BitKeeper/deleted/.del-mysql-4.1.cfg~b6c5e74aefc99e3c -> sql-bench/limits/mysql-4.1.cfg sql-bench/limits/mysql-3.23.cfg: Rename: BitKeeper/deleted/.del-mysql-3.23.cfg~3cf9d6be54b77a3c -> sql-bench/limits/mysql-3.23.cfg sql-bench/limits/mysql-4.0.cfg: Rename: BitKeeper/deleted/.del-mysql-4.0.cfg~6c9d63c85b5ef574 -> sql-bench/limits/mysql-4.0.cfg sql-bench/limits/mysql-3.22.cfg: Rename: BitKeeper/deleted/.del-mysql-3.22.cfg~e706f26a161175cd -> sql-bench/limits/mysql-3.22.cfg sql-bench/limits/msql.cfg: Rename: BitKeeper/deleted/.del-msql.cfg~52710b12932cceb9 -> sql-bench/limits/msql.cfg sql-bench/limits/ms-sql65.cfg: Rename: BitKeeper/deleted/.del-ms-sql65.cfg~6b9bc3c460dbee05 -> sql-bench/limits/ms-sql65.cfg sql-bench/limits/mimer.cfg: Rename: BitKeeper/deleted/.del-mimer.cfg~234e6c1c3c47b612 -> sql-bench/limits/mimer.cfg sql-bench/limits/ms-sql.cfg: Rename: BitKeeper/deleted/.del-ms-sql.cfg~1907964264d2786a -> sql-bench/limits/ms-sql.cfg sql-bench/limits/interbase.cfg: Rename: BitKeeper/deleted/.del-interbase.cfg~c6951a0376cc6ff3 -> sql-bench/limits/interbase.cfg sql-bench/limits/interbase-dialect3.cfg: Rename: BitKeeper/deleted/.del-interbase-dialect3.cfg~46277bdfc74c667a -> sql-bench/limits/interbase-dialect3.cfg sql-bench/limits/interbase-superserver.cfg: Rename: BitKeeper/deleted/.del-interbase-superserver.cfg~22501198689243b0 -> sql-bench/limits/interbase-superserver.cfg sql-bench/limits/interbase-dialect1.cfg: Rename: BitKeeper/deleted/.del-interbase-dialect1.cfg~659206b5b9a11036 -> sql-bench/limits/interbase-dialect1.cfg sql-bench/limits/empress.cfg: Rename: BitKeeper/deleted/.del-empress.cfg~1f97f34d6560a499 -> sql-bench/limits/empress.cfg sql-bench/limits/frontbase.cfg: Rename: BitKeeper/deleted/.del-frontbase.cfg~71369e9c002696e -> sql-bench/limits/frontbase.cfg sql-bench/limits/db2.cfg: Rename: BitKeeper/deleted/.del-db2.cfg~711099b4d7906959 -> sql-bench/limits/db2.cfg sql-bench/limits/access.cfg: Rename: BitKeeper/deleted/.del-access.cfg~5239ea3655b7bba0 -> sql-bench/limits/access.cfg sql-bench/limits/access_odbc.cfg: Rename: BitKeeper/deleted/.del-access_odbc.cfg~34b4cf0eda56c4b1 -> sql-bench/limits/access_odbc.cfg sql-bench/limits/Informix.cfg: Rename: BitKeeper/deleted/.del-Informix.cfg~b94188e1ececb51b -> sql-bench/limits/Informix.cfg sql-bench/limits/Adabas.cfg: Rename: BitKeeper/deleted/.del-Adabas.cfg~343ed4e7f8b02111 -> sql-bench/limits/Adabas.cfg sql-bench/README: Rename: BitKeeper/deleted/.del-README~b1aa0c1bf9f5eb5e -> sql-bench/README BitKeeper/deleted/.del-create-pg_fast-Linux_2.2.14_my_SMP_i686-crashed: Delete: sql-bench/Results/create-pg_fast-Linux_2.2.14_my_SMP_i686-crashed Makefile.am: Added back sql-bench configure.in: Added back sql-bench dbug/dbug.c: Fixed memory leak in _db_set() This is not a complete fix as we can still get memory leaks if we do any of the following: mysqld --debug --debug CAll DBUG_SET or DBUG_SET_INITIAL more than once in a program Use SET @@global.debug=xxxx At some point we should fix the above, but this is not critical for normal operation (only for debugging) Bug #24497 Valgrind warning: get_one_option Note that all changes to _db_set_ is only a variable access change, and can be ignored while reviewing the bug fix. mysql-test/t/flush_read_lock_kill-master.opt: Added '+' to option, to be able to use this together with --debug mysql-test/valgrind.supp: Removed warning that is now fixed mysys/ptr_cmp.c: Fixed wrong pointer read (probably never used) scripts/make_binary_distribution.sh: Added back sql_bench sql/field.h: Removed class function that was identical in parent class sql/mysqld.cc: Removed some calls to my_thread_init() / my_thread_end() that was not needed. Only call DBUG_SET_INITAL, not DBUG_SET (Fixes memory leak in dbug) Mark some code as deadcode sql/net_serv.cc: Add information about from where error comes sql-bench/bench-init.pl.sh: Cleaned up help text sql-bench/server-cfg.sh: Don't write '/' after server name of no ssl version sql-common/client.c: Don't call net_clear() on COM_QUIT. This avoids a warning from net_clear() after shutdown: "skipped ## bytes from file" BUG#21428: skipped 9 bytes from file: socket (3)" on "mysqladmin shutdown" sql/sql_parse.cc: Added comment sql/table.h: Removed compiler warning
Diffstat (limited to 'sql-bench/bench-init.pl.sh')
-rw-r--r--sql-bench/bench-init.pl.sh598
1 files changed, 598 insertions, 0 deletions
diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh
new file mode 100644
index 00000000000..482b4f69e3a
--- /dev/null
+++ b/sql-bench/bench-init.pl.sh
@@ -0,0 +1,598 @@
+#!@PERL@
+# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA
+#
+##########################################################
+# this is the base file every test is using ....
+# this is made for not changing every file if we want to
+# add an option or just want to change something in
+# code what is the same in every file ...
+##########################################################
+
+#
+# The exported values are:
+
+# $opt_... Various options
+# $date Current date in ISO format
+# $server Object for current server
+# $limits Hash reference to limits for benchmark
+
+$benchmark_version="2.15";
+use Getopt::Long;
+use POSIX;
+
+require "$pwd/server-cfg" || die "Can't read Configuration file: $!\n";
+
+$|=1; # Output data immediately
+
+$opt_skip_test=$opt_skip_create=$opt_skip_delete=$opt_verbose=$opt_fast_insert=$opt_lock_tables=$opt_debug=$opt_skip_delete=$opt_fast=$opt_force=$opt_log=$opt_use_old_results=$opt_help=$opt_odbc=$opt_small_test=$opt_small_tables=$opt_samll_key_tables=$opt_stage=$opt_old_headers=$opt_die_on_errors=$opt_tcpip=$opt_random=0;
+$opt_cmp=$opt_user=$opt_password=$opt_connect_options="";
+$opt_server="mysql"; $opt_dir="output";
+$opt_host="localhost";$opt_database="test";
+$opt_machine=""; $opt_suffix="";
+$opt_create_options=undef;
+$opt_optimization="None";
+$opt_hw="";
+$opt_threads=5;
+
+if (!defined($opt_time_limit))
+{
+ $opt_time_limit=10*60; # Don't wait more than 10 min for some tests
+}
+
+$log_prog_args=join(" ", skip_arguments(\@ARGV,"comments","cmp","server",
+ "user", "host", "database", "password",
+ "use-old-results","skip-test",
+ "optimization","hw",
+ "machine", "dir", "suffix", "log"));
+GetOptions("skip-test=s","comments=s","cmp=s","server=s","user=s","host=s","database=s","password=s","loop-count=i","row-count=i","skip-create","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","field-count=i","regions=i","groups=i","time-limit=i","log","use-old-results","machine=s","dir=s","suffix=s","help","odbc","small-test","small-tables","small-key-tables","stage=i","threads=i","random","old-headers","die-on-errors","create-options=s","hires","tcpip","silent","optimization=s","hw=s","socket=s","connect-options=s") || usage();
+
+usage() if ($opt_help);
+$server=get_server($opt_server,$opt_host,$opt_database,$opt_odbc,
+ machine_part(), $opt_socket, $opt_connect_options);
+$limits=merge_limits($server,$opt_cmp);
+$date=date();
+@estimated=(0.0,0.0,0.0); # For estimated time support
+
+if ($opt_hires)
+{
+ eval "use Time::HiRes;";
+}
+
+{
+ my $tmp= $opt_server;
+ $tmp =~ s/_odbc$//;
+ if (length($opt_cmp) && index($opt_cmp,$tmp) < 0)
+ {
+ $opt_cmp.=",$tmp";
+ }
+}
+$opt_cmp=lc(join(",",sort(split(',',$opt_cmp))));
+
+#
+# set opt_lock_tables if one uses --fast and drivers supports it
+#
+
+if (($opt_lock_tables || $opt_fast) && $server->{'limits'}->{'lock_tables'})
+{
+ $opt_lock_tables=1;
+}
+else
+{
+ $opt_lock_tables=0;
+}
+if ($opt_fast)
+{
+ $opt_fast_insert=1;
+ $opt_suffix="_fast" if (!length($opt_suffix));
+}
+
+if ($opt_odbc)
+{
+ $opt_suffix="_odbc" if (!length($opt_suffix));
+}
+
+if (!$opt_silent)
+{
+ print "Testing server '" . $server->version() . "' at $date\n\n";
+}
+
+if ($opt_debug)
+{
+ print "\nCurrent limits: \n";
+ foreach $key (sort keys %$limits)
+ {
+ print $key . " " x (30-length($key)) . $limits->{$key} . "\n";
+ }
+ print "\n";
+}
+
+#
+# Some help functions
+#
+
+sub skip_arguments
+{
+ my($argv,@skip_args)=@_;
+ my($skip,$arg,$name,@res);
+
+ foreach $arg (@$argv)
+ {
+ if ($arg =~ /^\-+([^=]*)/)
+ {
+ $name=$1;
+ foreach $skip (@skip_args)
+ {
+ if (index($skip,$name) == 0)
+ {
+ $name=""; # Don't use this parameters
+ last;
+ }
+ }
+ push (@res,$arg) if (length($name));
+ }
+ }
+ return @res;
+}
+
+
+sub merge_limits
+{
+ my ($server,$cmp)= @_;
+ my ($name,$tmp_server,$limits,$res_limits,$limit,$tmp_limits);
+
+ $res_limits=$server->{'limits'};
+ if ($cmp)
+ {
+ foreach $name (split(",",$cmp))
+ {
+ $tmp_server= (get_server($name,$opt_host, $opt_database,
+ $opt_odbc,machine_part())
+ || die "Unknown SQL server: $name\n");
+ $limits=$tmp_server->{'limits'};
+ %new_limits=();
+ foreach $limit (keys(%$limits))
+ {
+ if (defined($res_limits->{$limit}) && defined($limits->{$limit}))
+ {
+ $new_limits{$limit}=min($res_limits->{$limit},$limits->{$limit});
+ }
+ }
+ %tmp_limits=%new_limits;
+ $res_limits=\%tmp_limits;
+ }
+ }
+ return $res_limits;
+}
+
+sub date
+{
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime(time());
+ sprintf("%04d-%02d-%02d %2d:%02d:%02d",
+ 1900+$year,$mon+1,$mday,$hour,$min,$sec);
+}
+
+sub min
+{
+ my($min)=$_[0];
+ my($i);
+ for ($i=1 ; $i <= $#_; $i++)
+ {
+ $min=$_[$i] if ($min > $_[$i]);
+ }
+ return $min;
+}
+
+sub max
+{
+ my($max)=$_[0];
+ my($i);
+ for ($i=1 ; $i <= $#_; $i++)
+ {
+ $max=$_[$i] if ($max < $_[$i]);
+ }
+ return $max;
+}
+
+
+#
+# Execute many statements in a row
+#
+
+sub do_many
+{
+ my ($dbh,@statements)=@_;
+ my ($statement,$sth);
+
+ foreach $statement (@statements)
+ {
+ if (!($sth=$dbh->do($statement)))
+ {
+ die "Can't execute command '$statement'\nError: $DBI::errstr\n";
+ }
+ }
+}
+
+sub safe_do_many
+{
+ my ($dbh,@statements)=@_;
+ my ($statement,$sth);
+
+ foreach $statement (@statements)
+ {
+ if (!($sth=$dbh->do($statement)))
+ {
+ print STDERR "Can't execute command '$statement'\nError: $DBI::errstr\n";
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+
+#
+# Do a query and fetch all rows from a statement and return the number of rows
+#
+
+sub fetch_all_rows
+{
+ my ($dbh,$query,$must_get_result)=@_;
+ my ($count,$sth);
+ $count=0;
+
+ print "$query: " if ($opt_debug);
+ if (!($sth= $dbh->prepare($query)))
+ {
+ print "\n" if ($opt_debug);
+ die "Error occured with prepare($query)\n -> $DBI::errstr\n";
+ return undef;
+ }
+ if (!$sth->execute)
+ {
+ print "\n" if ($opt_debug);
+ if (defined($server->{'error_on_execute_means_zero_rows'}) &&
+ !$server->abort_if_fatal_error())
+ {
+ if (defined($must_get_result) && $must_get_result)
+ {
+ die "Error: Query $query didn't return any rows\n";
+ }
+ $sth->finish;
+ print "0\n" if ($opt_debug);
+ return 0;
+ }
+ die "Error occured with execute($query)\n -> $DBI::errstr\n";
+ $sth->finish;
+ return undef;
+ }
+ while ($sth->fetchrow_arrayref)
+ {
+ $count++;
+ }
+ print "$count\n" if ($opt_debug);
+ if (defined($must_get_result) && $must_get_result && !$count)
+ {
+ die "Error: Query $query didn't return any rows\n";
+ }
+ $sth->finish;
+ undef($sth);
+ return $count;
+}
+
+sub do_query
+{
+ my($dbh,$query)=@_;
+ print "$query\n" if ($opt_debug);
+ $dbh->do($query) or
+ die "\nError executing '$query':\n$DBI::errstr\n";
+}
+
+#
+# Run a query X times
+#
+
+sub time_fetch_all_rows
+{
+ my($test_text,$result_text,$query,$dbh,$test_count)=@_;
+ my($i,$loop_time,$end_time,$count,$rows,$estimated);
+
+ print $test_text . "\n" if (defined($test_text));
+ $count=$rows=0;
+ $loop_time=new Benchmark;
+ for ($i=1 ; $i <= $test_count ; $i++)
+ {
+ $count++;
+ $rows+=fetch_all_rows($dbh,$query) or die $DBI::errstr;
+ $end_time=new Benchmark;
+ last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i,
+ $test_count));
+ }
+ $end_time=new Benchmark;
+ if ($estimated)
+ { print "Estimated time"; }
+ else
+ { print "Time"; }
+ print " for $result_text ($count:$rows) " .
+ timestr(timediff($end_time, $loop_time),"all") . "\n\n";
+}
+
+
+#
+# Handle estimated time of the server is too slow
+# Returns 0 if one should continue as normal
+#
+
+sub predict_query_time
+{
+ my ($loop_time,$end_time,$count_ref,$loop,$loop_count)= @_;
+ my ($k,$tmp);
+
+ if (($end_time->[0] - $loop_time->[0]) > $opt_time_limit)
+ {
+ # We can't wait until the SUN dies. Try to predict the end time
+ if ($loop != $loop_count)
+ {
+ $tmp=($end_time->[0] - $loop_time->[0]);
+ print "Note: Query took longer then time-limit: $opt_time_limit\nEstimating end time based on:\n";
+ print "$$count_ref queries in $loop loops of $loop_count loops took $tmp seconds\n";
+ for ($k=0; $k < 3; $k++)
+ {
+ $tmp=$loop_time->[$k]+($end_time->[$k]-$loop_time->[$k])/$loop*
+ $loop_count;
+ $estimated[$k]+=($tmp-$end_time->[$k]);
+ $end_time->[$k]=$tmp;
+ }
+ $$count_ref= int($$count_ref/$loop*$loop_count);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#
+# standard end of benchmark
+#
+
+sub end_benchmark
+{
+ my ($start_time)=@_;
+
+ $end_time=new Benchmark;
+ if ($estimated[0])
+ {
+ print "Estimated total time: ";
+ $end_time->[0]+=$estimated[0];
+ $end_time->[1]+=$estimated[1];
+ $end_time->[2]+=$estimated[2];
+ }
+ else
+ {
+ print "Total time: "
+ }
+ print timestr(timediff($end_time, $start_time),"all") . "\n";
+ exit 0;
+}
+
+sub print_time
+{
+ my ($estimated)=@_;
+ if ($estimated)
+ { print "Estimated time"; }
+ else
+ { print "Time"; }
+}
+
+#
+# Create a filename part for the machine that can be used for log file.
+#
+
+sub machine_part
+{
+ my ($name,$orig);
+ return $opt_machine if (length($opt_machine)); # Specified by user
+# Specified by user
+ $orig=$name=machine();
+ $name="win9$1" if ($orig =~ /win.*9(\d)/i);
+ $name="NT_$1" if ($orig =~ /Windows NT.*(\d+\.\d+)/i);
+ $name="win2k" if ($orig =~ /Windows 2000/i);
+ $name =~ s/\s+/_/g; # Make the filenames easier to parse
+ $name =~ s/-/_/g;
+ $name =~ s/\//_/g;
+ return $name;
+}
+
+sub machine
+{
+ my @name = POSIX::uname();
+ my $name= $name[0] . " " . $name[2] . " " . $name[4];
+ return $name;
+}
+
+#
+# Usage
+#
+
+sub usage
+{
+ print <<EOF;
+The MySQL benchmarks Ver $benchmark_version
+
+All benchmarks takes the following options:
+
+--comments
+ Add a comment to the benchmark output. Comments should contain
+ extra information that 'uname -a' doesn\'t give and if the database was
+ stared with some specific, non default, options.
+
+--cmp=server[,server...]
+ Run the test with limits from the given servers. If you run all servers
+ with the same --cmp, you will get a test that is comparable between
+ the different sql servers.
+
+--create-options=#
+ Extra argument to all create statements. If you for example want to
+ create all MySQL tables as InnoDB tables use:
+ --create-options=ENGINE=InnoDB
+
+--database (Default $opt_database)
+ In which database the test tables are created.
+
+--debug
+ This is a test specific option that is only used when debugging a test.
+ Print out debugging information.
+
+--dir (Default $opt_dir)
+ Option to 'run-all-tests' to where the test results should be stored.
+
+--fast
+ Allow the database to use non standard ANSI SQL commands to make the
+ test go faster.
+
+--fast-insert
+ Use "insert into table_name values(...)" instead of
+ "insert into table_name (....) values(...)"
+ If the database supports it, some tests uses multiple value lists.
+
+--field-count
+ This is a test specific option that is only used when debugging a test.
+ This usually means how many fields there should be in the test table.
+
+--force
+ This is a test specific option that is only used when debugging a test.
+ Continue the test even if there is some error.
+ Delete tables before creating new ones.
+
+--groups (Default $opt_groups)
+ This is a test specific option that is only used when debugging a test.
+ This usually means how many different groups there should be in the test.
+
+--lock-tables
+ Allow the database to use table locking to get more speed.
+
+--log
+ Option to 'run-all-tests' to save the result to the '--dir' directory.
+
+--loop-count (Default $opt_loop_count)
+ This is a test specific option that is only used when debugging a test.
+ This usually means how many times times each test loop is executed.
+
+--help
+ Shows this help
+
+--host='host name' (Default $opt_host)
+ Host name where the database server is located.
+
+--machine="machine or os_name"
+ The machine/os name that is added to the benchmark output filename.
+ The default is the OS name + version.
+
+--odbc
+ Use the ODBC DBI driver to connect to the database.
+
+--password='password'
+ Password for the current user.
+
+--socket='socket'
+ If the database supports connecting through a Unix socket,
+ then use this socket to connect
+
+--regions
+ This is a test specific option that is only used when debugging a test.
+ This usually means how AND levels should be tested.
+
+--old-headers
+ Get the old benchmark headers from the old RUN- file.
+
+--server='server name' (Default $opt_server)
+ Run the test on the given SQL server.
+ Known servers names are: Access, Adabas, AdabasD, Empress, Oracle,
+ Informix, DB2, mSQL, MS-SQL, MySQL, Pg, Solid and Sybase
+
+--silent
+ Don't print info about the server when starting test.
+
+--skip-delete
+ This is a test specific option that is only used when debugging a test.
+ This will keep the test tables after the test is run.
+
+--skip-test=test1[,test2,...]
+ For run-all-programs; Don\'t execute the named tests.
+
+--small-test
+ This runs some tests with smaller limits to get a faster test.
+ Can be used if you just want to verify that the database works, but
+ don't have time to run a full test.
+
+--small-tables
+ This runs some tests that generate big tables with fewer rows.
+ This can be used with databases that can\'t handle that many rows
+ because of pre-sized partitions.
+
+--suffix (Default $opt_suffix)
+ The suffix that is added to the database name in the benchmark output
+ filename. This can be used to run the benchmark multiple times with
+ different server options without overwritten old files.
+ When using --fast the suffix is automaticly set to '_fast'.
+
+--random
+ Inform test suite that we are generate random inital values for sequence of
+ test executions. It should be used for imitation of real conditions.
+
+--threads=# (Default 5)
+ Number of threads for multi-user benchmarks.
+
+--tcpip
+ Inform test suite that we are using TCP/IP to connect to the server. In
+ this case we can\t do many new connections in a row as we in this case may
+ fill the TCP/IP stack
+
+--time-limit (Default $opt_time_limit)
+ How long a test loop is allowed to take, in seconds, before the end result
+ is 'estimated'.
+
+--use-old-results
+ Option to 'run-all-tests' to use the old results from the '--dir' directory
+ instead of running the tests.
+
+--user='user_name'
+ User name to log into the SQL server.
+
+--verbose
+ This is a test specific option that is only used when debugging a test.
+ Print more information about what is going on.
+
+--optimization='some comments'
+ Add coments about optimization of DBMS, which was done before the test.
+
+--hw='some comments'
+ Add coments about hardware used for this test.
+
+--connect-options='some connect options'
+ Add options, which uses at DBI connect.
+ For example --connect-options=mysql_read_default_file=/etc/my.cnf.
+
+EOF
+ exit(0);
+}
+
+
+
+####
+#### The end of the base file ...
+####
+1;