create.sql 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # To maintain consistency across servers and fix a problem with the jdbc per
  2. # http://stackoverflow.com/questions/37719818/the-server-time-zone-value-aest-is-unrecognized-or-represents-more-than-one-ti
  3. SET GLOBAL time_zone = '+00:00';
  4. CREATE USER IF NOT EXISTS 'benchmarkdbuser'@'%' IDENTIFIED WITH caching_sha2_password BY 'benchmarkdbpass';
  5. CREATE USER IF NOT EXISTS 'benchmarkdbuser'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'benchmarkdbpass';
  6. -- GitHub Actions/CI run the database server on the same system as the benchmarks.
  7. -- Because we setup MySQL with the skip-name-resolve option, the IP address 127.0.0.1 might not be resolved to localhost
  8. -- anymore. This does not seem to matter, as long as Unix sockets are being used (e.g. when setting up the docker image),
  9. -- because the host is set to be localhost implicitly, but it matters for local TCP connections.
  10. CREATE USER IF NOT EXISTS 'benchmarkdbuser'@'127.0.0.1' IDENTIFIED WITH caching_sha2_password BY 'benchmarkdbpass';
  11. # modified from SO answer http://stackoverflow.com/questions/5125096/for-loop-in-mysql
  12. CREATE DATABASE IF NOT EXISTS hello_world;
  13. USE hello_world;
  14. CREATE TABLE world (
  15. id int(10) unsigned NOT NULL auto_increment,
  16. randomNumber int NOT NULL default 0,
  17. PRIMARY KEY (id)
  18. )
  19. ENGINE=INNODB;
  20. GRANT ALL PRIVILEGES ON hello_world.world TO 'benchmarkdbuser'@'%';
  21. GRANT ALL PRIVILEGES ON hello_world.world TO 'benchmarkdbuser'@'localhost';
  22. GRANT ALL PRIVILEGES ON hello_world.world TO 'benchmarkdbuser'@'127.0.0.1';
  23. DELIMITER #
  24. CREATE PROCEDURE load_data()
  25. BEGIN
  26. declare v_max int unsigned default 10000;
  27. declare v_counter int unsigned default 0;
  28. TRUNCATE TABLE world;
  29. START TRANSACTION;
  30. while v_counter < v_max do
  31. INSERT INTO world (randomNumber) VALUES ( least(floor(1 + (rand() * 10000)), 10000) );
  32. SET v_counter=v_counter+1;
  33. end while;
  34. commit;
  35. END
  36. #
  37. DELIMITER ;
  38. CALL load_data();
  39. CREATE TABLE fortune (
  40. id int(10) unsigned NOT NULL auto_increment,
  41. message varchar(2048) CHARACTER SET 'utf8' NOT NULL,
  42. PRIMARY KEY (id)
  43. )
  44. ENGINE=INNODB;
  45. GRANT ALL PRIVILEGES ON hello_world.fortune TO 'benchmarkdbuser'@'%';
  46. GRANT ALL PRIVILEGES ON hello_world.fortune TO 'benchmarkdbuser'@'localhost';
  47. GRANT ALL PRIVILEGES ON hello_world.fortune TO 'benchmarkdbuser'@'127.0.0.1';
  48. INSERT INTO fortune (message) VALUES ('fortune: No such file or directory');
  49. INSERT INTO fortune (message) VALUES ('A computer scientist is someone who fixes things that aren''t broken.');
  50. INSERT INTO fortune (message) VALUES ('After enough decimal places, nobody gives a damn.');
  51. INSERT INTO fortune (message) VALUES ('A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1');
  52. INSERT INTO fortune (message) VALUES ('A computer program does what you tell it to do, not what you want it to do.');
  53. INSERT INTO fortune (message) VALUES ('Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen');
  54. INSERT INTO fortune (message) VALUES ('Any program that runs right is obsolete.');
  55. INSERT INTO fortune (message) VALUES ('A list is only as strong as its weakest link. — Donald Knuth');
  56. INSERT INTO fortune (message) VALUES ('Feature: A bug with seniority.');
  57. INSERT INTO fortune (message) VALUES ('Computers make very fast, very accurate mistakes.');
  58. INSERT INTO fortune (message) VALUES ('<script>alert("This should not be displayed in a browser alert box.");</script>');
  59. INSERT INTO fortune (message) VALUES ('フレームワークのベンチマーク');