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.

204 lines
5.3 KiB

Don't do signal() on windows (Causes instability problems) Safer, a bit faster filesort. Code changes to avoid calls to current_thd() (faster code). Removed all compiler warnings from readline. BitKeeper/etc/ignore: Add my_global.h back. Docs/manual.texi: 4.0.1 Changelog include/my_sys.h: Added strmake_root libmysql/libmysql.c: Don't do signal() on windows (Causes instability problems) mysys/my_alloc.c: Added strmake_root readline/bind.c: Remove warnings readline/complete.c: Remove warnings readline/display.c: Remove warnings readline/funmap.c: Remove warnings readline/histexpand.c: Remove warnings readline/histfile.c: Remove warnings readline/history.h: Remove warnings readline/histsearch.c: Remove warnings readline/isearch.c: Remove warnings readline/kill.c: Remove warnings readline/macro.c: Remove warnings readline/readline.c: Remove warnings readline/readline.h: Remove warnings readline/rltty.c: Remove warnings readline/search.c: Remove warnings readline/shell.c: Remove warnings readline/terminal.c: Remove warnings readline/tilde.c: Remove warnings readline/tilde.h: Remove warnings readline/undo.c: Remove warnings readline/util.c: Remove warnings readline/vi_mode.c: Remove warnings sql-bench/server-cfg.sh: Added use of truncate table sql-bench/test-insert.sh: Added use of truncate table Changed some tests to use keys instead of 'range' sql-bench/test-wisconsin.sh: Cleanup sql/field.cc: Add 'thd' to send() (To avoid usage of 'current_thd') sql/field.h: Add 'thd' to send() (To avoid usage of 'current_thd') sql/filesort.cc: Safer memory allocation; Don't allocate pointer to buffers directly, but use an IO_CACHE instead. This will allow us to use more memory for keys and will also work better if the number of rows that is to be sorted is much larger than expected. sql/item.cc: Add 'thd' to send() (To avoid usage of 'current_thd') sql/item.h: Add 'thd' to send() (To avoid usage of 'current_thd') sql/item_func.h: Cleanup sql/opt_range.cc: Use mem_root instead of sql_alloc() to get more speed sql/sql_class.cc: Add 'thd' to send() (To avoid usage of 'current_thd') sql/sql_class.h: Added strmake() sql/sql_handler.cc: Add 'thd' to send() (To avoid usage of 'current_thd') sql/sql_lex.cc: Use mem_root instead of sql_alloc() to get more speed sql/sql_select.cc: Add 'thd' to send() (To avoid usage of 'current_thd') tests/fork2_test.pl: Fixed typos tests/fork_big.pl: Fixed typos tests/insert_and_repair.pl: Fixed typos tests/rename_test.pl: Fixed typos tests/test_delayed_insert.pl: Fixed typos
24 years ago
  1. #!/usr/bin/perl -w
  2. #
  3. # This is a test with uses processes to insert, select and drop tables.
  4. #
  5. $opt_loop_count=100000; # Change this to make test harder/easier
  6. ##################### Standard benchmark inits ##############################
  7. use DBI;
  8. use Getopt::Long;
  9. use Benchmark;
  10. package main;
  11. $opt_skip_create=$opt_skip_delete=$opt_skip_flush=0;
  12. $opt_host=""; $opt_db="test";
  13. GetOptions("host=s","db=s","loop-count=i","skip-create","skip-delete",
  14. "skip-flush") || die "Aborted";
  15. print "Testing 5 multiple connections to a server with 1 insert, 1 rename\n";
  16. print "1 select and 1 flush thread\n";
  17. $firsttable = "bench_f1";
  18. ####
  19. #### Start timing and start test
  20. ####
  21. $start_time=new Benchmark;
  22. if (!$opt_skip_create)
  23. {
  24. $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
  25. $opt_user, $opt_password,
  26. { PrintError => 0}) || die $DBI::errstr;
  27. $dbh->do("drop table if exists $firsttable, ${firsttable}_1, ${firsttable}_2");
  28. print "Creating table $firsttable in database $opt_db\n";
  29. $dbh->do("create table $firsttable (id int(6) not null, info varchar(32), marker char(1), primary key(id))") || die $DBI::errstr;
  30. $dbh->disconnect; $dbh=0; # Close handler
  31. }
  32. $|= 1; # Autoflush
  33. ####
  34. #### Start the tests
  35. ####
  36. test_insert() if (($pid=fork()) == 0); $work{$pid}="insert";
  37. test_rename(1) if (($pid=fork()) == 0); $work{$pid}="rename 1";
  38. test_rename(2) if (($pid=fork()) == 0); $work{$pid}="rename 2";
  39. test_select() if (($pid=fork()) == 0); $work{$pid}="select";
  40. if (!$opt_skip_flush)
  41. {
  42. test_flush() if (($pid=fork()) == 0); $work{$pid}="flush";
  43. }
  44. $errors=0;
  45. while (($pid=wait()) != -1)
  46. {
  47. $ret=$?/256;
  48. print "thread '" . $work{$pid} . "' finished with exit code $ret\n";
  49. $errors++ if ($ret != 0);
  50. }
  51. if (!$opt_skip_delete && !$errors)
  52. {
  53. $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
  54. $opt_user, $opt_password,
  55. { PrintError => 0}) || die $DBI::errstr;
  56. $dbh->do("drop table $firsttable");
  57. $dbh->disconnect; $dbh=0; # Close handler
  58. }
  59. print ($errors ? "Test failed\n" :"Test ok\n");
  60. $end_time=new Benchmark;
  61. print "Total time: " .
  62. timestr(timediff($end_time, $start_time),"noc") . "\n";
  63. exit(0);
  64. #
  65. # Insert records in the table. Delete table when test is finished
  66. #
  67. sub test_insert
  68. {
  69. my ($dbh,$i,$error);
  70. $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
  71. $opt_user, $opt_password,
  72. { PrintError => 0}) || die $DBI::errstr;
  73. for ($i=0 ; $i < $opt_loop_count; $i++)
  74. {
  75. if (!$dbh->do("insert into $firsttable values ($i,'This is entry $i','')"))
  76. {
  77. $error=$dbh->errstr;
  78. $dbh->do("drop table ${firsttable}"); # End other threads
  79. die "Warning; Got error on insert: " . $error . "\n";
  80. }
  81. }
  82. sleep(1);
  83. $dbh->do("drop table ${firsttable}") || die "Got error on drop table: " . $dbh->errstr . "\n";
  84. $dbh->disconnect; $dbh=0;
  85. print "Test_insert: Inserted $i rows\n";
  86. exit(0);
  87. }
  88. sub test_rename
  89. {
  90. my ($id) = @_;
  91. my ($dbh,$i,$error_counter,$sleep_time);
  92. $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
  93. $opt_user, $opt_password,
  94. { PrintError => 0}) || die $DBI::errstr;
  95. $error_counter=0;
  96. $sleep_time=2;
  97. for ($i=0 ; $i < $opt_loop_count ; $i++)
  98. {
  99. sleep($sleep_time);
  100. $dbh->do("create table ${firsttable}_$id (id int(6) not null, info varchar(32), marker char(1), primary key(id))") || die $DBI::errstr;
  101. if (!$dbh->do("rename table $firsttable to ${firsttable}_${id}_1, ${firsttable}_$id to ${firsttable}"))
  102. {
  103. last if ($dbh->errstr =~ /^Can\'t find/);
  104. die "Got error on rename: " . $dbh->errstr . "\n";
  105. }
  106. $dbh->do("drop table ${firsttable}_${id}_1") || die "Got error on drop table: " . $dbh->errstr . "\n";
  107. }
  108. $dbh->disconnect; $dbh=0;
  109. print "Test_drop: Did a drop $i times\n";
  110. exit(0);
  111. }
  112. #
  113. # select records
  114. #
  115. sub test_select
  116. {
  117. my ($dbh,$i,$sth,@row,$sleep_time);
  118. $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
  119. $opt_user, $opt_password,
  120. { PrintError => 0}) || die $DBI::errstr;
  121. $sleep_time=3;
  122. for ($i=0 ; $i < $opt_loop_count ; $i++)
  123. {
  124. sleep($sleep_time);
  125. $sth=$dbh->prepare("select sum(t.id) from $firsttable as t,$firsttable as t2") || die "Got error on select: $dbh->errstr;\n";
  126. if ($sth->execute)
  127. {
  128. @row = $sth->fetchrow_array();
  129. $sth->finish;
  130. }
  131. else
  132. {
  133. $sth->finish;
  134. last if (! ($dbh->errstr =~ /doesn\'t exist/));
  135. die "Got error on select: " . $dbh->errstr . "\n";
  136. }
  137. }
  138. $dbh->disconnect; $dbh=0;
  139. print "Test_select: ok\n";
  140. exit(0);
  141. }
  142. #
  143. # flush records
  144. #
  145. sub test_flush
  146. {
  147. my ($dbh,$i,$sth,@row,$error_counter,$sleep_time);
  148. $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
  149. $opt_user, $opt_password,
  150. { PrintError => 0}) || die $DBI::errstr;
  151. $error_counter=0;
  152. $sleep_time=5;
  153. for ($i=0 ; $i < $opt_loop_count ; $i++)
  154. {
  155. sleep($sleep_time);
  156. $sth=$dbh->prepare("select count(*) from $firsttable") || die "Got error on prepar: $dbh->errstr;\n";
  157. if ($sth->execute)
  158. {
  159. @row = $sth->fetchrow_array();
  160. $sth->finish;
  161. $sleep_time=5;
  162. $dbh->do("flush tables $firsttable") || die "Got error on flush table: " . $dbh->errstr . "\n";
  163. }
  164. else
  165. {
  166. last if (! ($dbh->errstr =~ /doesn\'t exist/));
  167. die "Got error on flush: " . $dbh->errstr . "\n";
  168. }
  169. }
  170. $dbh->disconnect; $dbh=0;
  171. print "Test_select: ok\n";
  172. exit(0);
  173. }