You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
4.8 KiB

- Improved portability of the sql-bench Perl scripts by replacing the calls of external programs "uname" and "pwd" with Perl builtin functions "cwd()" and "POSIX::uname()" sql-bench/as3ap.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/bench-count-distinct.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/bench-init.pl.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. - portability fix: don't call external "uname" in various combinations, use POSIX::uname() instead. sql-bench/copy-db.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/crash-me.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. - portability fix: don't call external "uname" in various combinations, use POSIX::uname() instead. sql-bench/innotest1.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/innotest1a.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/innotest1b.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/innotest2.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/innotest2a.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/innotest2b.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/run-all-tests.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-ATIS.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-alter-table.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-big-tables.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-connect.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-create.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-insert.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-select.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-transactions.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-wisconsin.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead.
22 years ago
- Improved portability of the sql-bench Perl scripts by replacing the calls of external programs "uname" and "pwd" with Perl builtin functions "cwd()" and "POSIX::uname()" sql-bench/as3ap.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/bench-count-distinct.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/bench-init.pl.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. - portability fix: don't call external "uname" in various combinations, use POSIX::uname() instead. sql-bench/copy-db.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/crash-me.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. - portability fix: don't call external "uname" in various combinations, use POSIX::uname() instead. sql-bench/innotest1.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/innotest1a.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/innotest1b.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/innotest2.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/innotest2a.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/innotest2b.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/run-all-tests.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-ATIS.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-alter-table.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-big-tables.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-connect.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-create.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-insert.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-select.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-transactions.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead. sql-bench/test-wisconsin.sh: - portability fix: don't call external "pwd" command, use the "cwd()" builtin function instead.
22 years ago
  1. #!/usr/bin/perl
  2. ############################################################################
  3. # Stress test for MySQL/InnoDB combined database
  4. # (c) 2002 Innobase Oy & MySQL AB
  5. #
  6. ############################################################################
  7. use Cwd;
  8. use DBI;
  9. use Benchmark;
  10. $opt_loop_count = 100000;
  11. $pwd = cwd(); $pwd = "." if ($pwd eq '');
  12. require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n";
  13. print "Innotest1: MySQL/InnoDB stress test in Perl\n";
  14. print "-------------------------------------------\n";
  15. print "This is a randomized stress test for concurrent inserts,\n";
  16. print "updates, deletes, commits and rollbacks. The test will generate\n";
  17. print "also a lot of deadlocks, duplicate key errors, and other SQL errors.\n";
  18. print "\n";
  19. print "You should run innotest1, innotest1a, and innotest1b concurrently.\n";
  20. print "The thing to watch is that the server does not crash or does not\n";
  21. print "print to the .err log anything. Currently, due to a buglet in MySQL,\n";
  22. print "warnings about MySQL lock reservations can appear in the .err log.\n";
  23. print "The test will run very long, even several hours. You can kill\n";
  24. print "the perl processes running this test at any time and do CHECK\n";
  25. print "TABLE on table innotest1 in the 'test' database.\n";
  26. print "\n";
  27. print "Some of these stress tests will print a lot of SQL errors\n";
  28. print "to the standard output. That is not to be worried about.\n";
  29. print "You can direct the output to a file like this:\n";
  30. print "perl innotest1 > out1\n\n";
  31. print "Generating random keys\n";
  32. $random[$opt_loop_count] = 0;
  33. $rnd_str[$opt_loop_count] = "a";
  34. for ($i = 0; $i < $opt_loop_count; $i++) {
  35. $random[$i] = ($i * 63857) % $opt_loop_count;
  36. if (0 == ($random[$i] % 3)) {
  37. $rnd_str[$i] = "kjgclgrtfuylfluyfyufyulfulfyyulofuyolfyufyufuyfyufyufyufyufyyufujhfghd";
  38. } else { if (1 == ($random[$i] % 3)) {
  39. $rnd_str[$i] = "khd";
  40. } else { if (2 == ($random[$i] % 3)) {
  41. $rnd_str[$i] = "kh";
  42. }}}
  43. for ($j = 0; $j < (($i * 764877) % 20); $j++) {
  44. $rnd_str[$i] = $rnd_str[$i]."k";
  45. }
  46. }
  47. ####
  48. #### Connect
  49. ####
  50. $dbh = $server->connect()
  51. || die $dbh->errstr;
  52. $dbh->do("set autocommit = 0");
  53. $n = 0;
  54. for ($i = 0; $i < 1; $i++) {
  55. print "Dropping table innotest1\n";
  56. $dbh->do("drop table innotest1");
  57. print "Creating table innotest1\n";
  58. $dbh->do(
  59. "create table innotest1 (A INT NOT NULL AUTO_INCREMENT, D INT NOT NULL, B VARCHAR(200) NOT NULL, C VARCHAR(175), E TIMESTAMP, F TIMESTAMP, G DATETIME, PRIMARY KEY (A, D), INDEX
  60. (B, C), INDEX (C), INDEX (D), INDEX(E), INDEX(G)) TYPE = INNODB")
  61. || die $dbh->errstr;
  62. for ($j = 2; $j < $opt_loop_count - 10; $j = $j + 2) {
  63. if ($j % 10 == 0) {
  64. $dbh->do(
  65. "insert into innotest1 (D, B, C, F, G) values (5, '".$rnd_str[$j]."' ,'".$rnd_str[$j]."', NULL, NULL)");
  66. } else {
  67. $dbh->do(
  68. "insert into innotest1 (D, B, C, F, G) values (5, '".$rnd_str[$j]."' ,'".$rnd_str[$j]."', NOW(), NOW())");
  69. }
  70. $dbh->do("update innotest1 set B = '".$rnd_str[$j + 7]."' where A = ".$random[$j + 5]);
  71. $dbh->do("update innotest1 SET D = D + 1 where A =".($j / 2 - 500));
  72. $dbh->do("update innotest1 set B = '".$rnd_str[$j + 1]."' where A =".($j / 2 - 505));
  73. $dbh->do("delete from innotest1 where A = ".$random[$random[$j]]);
  74. fetch_all_rows($dbh, "select b, c from innotest1 where a > ".$random[$j]." and a < ".($random[$j] + 7));
  75. if (0 == ($j % 10)) {
  76. $dbh->do("commit");
  77. }
  78. if (0 == ($j % 97)) {
  79. fetch_all_rows($dbh, "select c, e, f, g from innotest1 where c = '".$rnd_str[$j - 68]."'");
  80. fetch_all_rows($dbh, "select b, e, f, g from innotest1 where b = '".$rnd_str[$j - 677]."'");
  81. fetch_all_rows($dbh, "select b, c, e, f, g from innotest1 where c = '".$rnd_str[$j - 68]."'");
  82. fetch_all_rows($dbh, "select b, c, g from innotest1 where b = '".$rnd_str[$j - 677]."'");
  83. fetch_all_rows($dbh, "select a, b, c, e, f, g from innotest1 where c = '".$rnd_str[$j - 68]."'");
  84. fetch_all_rows($dbh, "select a, b, c, e, f, g from innotest1 where b = '".$rnd_str[$j - 677]."'");
  85. fetch_all_rows($dbh, "select d, b, c from innotest1 where c = '".$rnd_str[$j - 68]."'");
  86. fetch_all_rows($dbh, "select d, b, c, g from innotest1 where b = '".$rnd_str[$j - 677]."'");
  87. $dbh->do("rollback");
  88. }
  89. for ($k = 1; $k < 10; $k++) {
  90. $n += fetch_all_rows($dbh,
  91. "SELECT a, d from innotest1 where a = ".(($k * 1764767) % $j));
  92. $n += fetch_all_rows($dbh,
  93. "SELECT * from innotest1 where a = ".(($k * 187567) % $j));
  94. }
  95. if (0 == ($j % 1000)) {
  96. print "round $j, $n rows fetched\n";
  97. }
  98. if (0 == ($j % 20000)) {
  99. print "Checking table innotest1...\n";
  100. $dbh->do("check table innotest1");
  101. print "Table checked.\n";
  102. }
  103. }
  104. $dbh->do("commit");
  105. }
  106. $dbh->disconnect; # close connection