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.

1121 lines
35 KiB

sel000029.xml Escaped &,< chars. sel000022.xml Escaped &,< chars. sel000021.xml Escaped &,< chars. sel000020.xml Escaped &,< chars. sel000011.xml Escaped &,< chars. sel000010.xml Escaped &,< chars. translate-tests BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/mybin/translate-tests select.tst Marked where `ok' tests end. select.res Added first 30 tests into test suite, left marker. sel000004.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000004.result sel000005.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000005.result sel000006.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000006.result sel000007.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000007.result sel000008.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000008.result sel000009.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000009.result sel000010.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000010.result sel000011.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000011.result sel000012.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000012.result sel000013.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000013.result sel000014.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000014.result sel000015.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000015.result sel000016.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000016.result sel000017.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000017.result sel000018.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000018.result sel000019.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000019.result sel000020.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000020.result sel000021.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000021.result sel000022.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000022.result sel000023.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000023.result sel000024.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000024.result sel000025.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000025.result sel000026.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000026.result sel000027.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000027.result sel000028.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000028.result sel000029.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000029.result sel000030.result BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/r/3.23/sel000030.result sel000015.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000015.xml sel000010.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000010.xml sel000011.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000011.xml sel000020.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000020.xml sel000021.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000021.xml sel000012.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000012.xml sel000013.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000013.xml sel000014.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000014.xml sel000016.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000016.xml sel000017.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000017.xml sel000018.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000018.xml sel000019.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000019.xml sel000022.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000022.xml sel000029.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000029.xml sel000023.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000023.xml sel000024.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000024.xml sel000025.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000025.xml sel000026.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000026.xml sel000027.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000027.xml sel000028.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000028.xml sel000009.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000009.xml sel000008.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000008.xml sel000007.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000007.xml sel000006.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000006.xml sel000005.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000005.xml sel000004.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000004.xml sel000030.xml BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/xml/tests/sel000030.xml mysql-test_V1.9.pl BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/chew_on_this/mysql-test_V1.9.pl stop-mysqld BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/mybin/stop-mysqld start-mysqld BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/mybin/start-mysqld select.res BitKeeper file /home/mwagner/work/bk/mysql/mysql-test/chew_on_this/select.res mysql-test/mybin/start-mysqld: ***MISSING WEAVE*** mysql-test/mybin/stop-mysqld: ***MISSING WEAVE*** mysql-test/chew_on_this/select.res: ***MISSING WEAVE*** mysql-test/chew_on_this/select.tst: Marked where `ok' tests end. mysql-test/mybin/translate-tests: ***MISSING WEAVE*** mysql-test/xml/tests/sel000010.xml: Escaped &,< chars. mysql-test/xml/tests/sel000011.xml: Escaped &,< chars. mysql-test/xml/tests/sel000020.xml: Escaped &,< chars. mysql-test/xml/tests/sel000021.xml: Escaped &,< chars. mysql-test/xml/tests/sel000022.xml: Escaped &,< chars. mysql-test/xml/tests/sel000029.xml: Escaped &,< chars.
26 years ago
  1. #!/usr/bin/perl
  2. #
  3. # Tests MySQL. Output is given to the stderr. Use
  4. # diff to check the possible differencies.
  5. #
  6. use DBI;
  7. use Getopt::Long;
  8. $VER = "1.9";
  9. $| = 1;
  10. $opt_db = "test";
  11. $opt_user = $opt_password = $opt_without = "";
  12. $opt_host = "localhost";
  13. $opt_port = "3306";
  14. $opt_socket = "/tmp/mysql.sock";
  15. $opt_help = 0;
  16. $NO_ERR = 0; # No error
  17. $EXP_ERR = 1; # Expect error
  18. $MAY_ERR = 2; # Maybe error
  19. $HS = 0; # Horizontal style of output
  20. $VS = 1; # Vertical style of output
  21. $VERBOSE = 0; # Print the results
  22. $SILENT = 1; # No output
  23. @test_packages = ("FUNC", "PROC", "SHOW");
  24. ####
  25. #### main program
  26. ####
  27. main();
  28. sub main()
  29. {
  30. GetOptions("help", "db=s", "port=i", "host=s", "password=s", "user=s", "socket=s",
  31. "without=s") || usage();
  32. usage() if ($opt_help);
  33. $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host:port=$opt_port:mysql_socket=$opt_socket", $opt_user, $opt_password, { PrintError => 0 })
  34. || die $DBI::errstr;
  35. ## QQ ######################################
  36. $sth = $dbh->prepare("show felds from t2")
  37. || die "Couldn't prepare query: $DBI::errstr\n";
  38. if (!$sth->execute)
  39. {
  40. print "Couldn't execute query: $DBI::errstr\n";
  41. $sth->finish;
  42. die;
  43. }
  44. while (($row = $sth->fetchrow_arrayref))
  45. {
  46. print "$row->[1]\n";
  47. }
  48. exit(0);
  49. ## QQ ######################################
  50. printf("####\n#### THIS IS mysql-test script RUNNING\n");
  51. printf("#### mysql-test version $VER\n####\n");
  52. test_mysql_functions() if (&chk_package($opt_without, $test_packages[0]));
  53. test_mysql_procedures() if (&chk_package($opt_without, $test_packages[1]));
  54. test_mysql_show() if (&chk_package($opt_without, $test_packages[2]));
  55. print "\n";
  56. return;
  57. }
  58. ####
  59. #### test show -command of MySQL
  60. ####
  61. sub test_mysql_show
  62. {
  63. my ($query, $i);
  64. $query = create_show_tables();
  65. &exec_query(["drop table my_t"], $MAY_ERR, $SILENT);
  66. for ($i = 0; $query[$i]; $i++)
  67. {
  68. &exec_query([$query[$i]], $NO_ERR, $VERBOSE, $HS);
  69. &exec_query(["show fields from my_t"], $NO_ERR, $VERBOSE, $HS);
  70. &exec_query(["show keys from my_t"], $NO_ERR, $VERBOSE, $HS);
  71. &exec_query(["drop table my_t"], $NO_ERR, $SILENT);
  72. }
  73. }
  74. sub create_show_tables
  75. {
  76. my ($query, $i);
  77. $query[0] = <<EOF;
  78. create table my_t (i int, f float, s char(64), b blob, t text)
  79. EOF
  80. $query[1] = <<EOF;
  81. create table my_t (i int, f float, s char(64), b blob, t text, primary key (i))
  82. EOF
  83. $query[2] = <<EOF;
  84. create table my_t (i int, f float, s char(64), b blob, t text, unique (i), unique(s))
  85. EOF
  86. for ($i = 0; $query[$i]; $i++) { chop($query[$i]); }
  87. return $query;
  88. }
  89. ####
  90. #### test procedures, currently only procedure analyze()
  91. ####
  92. sub test_mysql_procedures
  93. {
  94. test_analyze();
  95. }
  96. sub test_analyze
  97. {
  98. my ($query, $i, $j);
  99. if ($opt_help)
  100. {
  101. usage();
  102. }
  103. # invalid queries
  104. &exec_query(["select * from mails procedure analyse(-1)"],
  105. $EXP_ERR, $VERBOSE, $HS);
  106. &exec_query(["select * from mails procedure analyse(10, -1)"],
  107. $EXP_ERR, $VERBOSE, $HS);
  108. &exec_query(["select * from mails procedure analyse(1, 2, 3)"],
  109. $EXP_ERR, $VERBOSE, $HS);
  110. &exec_query(["select * from mails procedure analyse(-10, 10)"],
  111. $EXP_ERR, $VERBOSE, $HS);
  112. &exec_query(["select * from mails procedure analyse('a', 'a')"],
  113. $EXP_ERR, $VERBOSE, $HS);
  114. # valid queries
  115. # &exec_query(["select * from mails procedure analyse(10)"], 0, 0);
  116. # &exec_query(["select * from mails procedure analyse(10, 10)"], 0, 0);
  117. # &exec_query(["select hash from mails procedure analyse()"], 0, 0);
  118. &exec_query(["use mysql_test"], $NO_ERR, $VERBOSE, $HS);
  119. # &exec_query(["select timestamp from w32_user procedure analyse(0)"], 0, 0);
  120. $query = create_test_tables();
  121. &exec_query(["drop table my_t"], $MAY_ERR, $SILENT);
  122. for ($i = 0; $query[$i][0]; $i++)
  123. {
  124. &exec_query([$query[$i][0]], $NO_ERR, $SILENT); # create table
  125. for ($j = 1; $query[$i][$j]; $j++)
  126. {
  127. &exec_query([$query[$i][$j]], $NO_ERR, $SILENT); # do inserts
  128. }
  129. &exec_query(["select * from my_t procedure analyse(0,0)"],
  130. $NO_ERR, $VERBOSE, $HS);
  131. &exec_query(["select * from my_t procedure analyse()"],
  132. $NO_ERR, $VERBOSE, $HS);
  133. &exec_query(["drop table my_t"], $NO_ERR, $SILENT);
  134. }
  135. }
  136. ####
  137. #### if $opt is found as a part from the '--without=...' option string
  138. #### return 0, else 1. if zero is returned, then that part of MySQL
  139. #### won't be tested
  140. ####
  141. sub chk_package
  142. {
  143. my ($opt_str, $opt) = @_;
  144. $sub_opt_str = '';
  145. for ($i = 0, $ptr = substr($opt_str, $i, 1); $ptr || $ptr eq '0';
  146. $i++, $ptr = substr($opt_str, $i, 1))
  147. {
  148. $sub_opt_str .= $ptr;
  149. if ($sub_opt_str eq $opt)
  150. {
  151. $next_chr = substr($opt_str, ($i + 1), 1);
  152. if ($next_chr eq ',' || (!$next_chr && $next_chr ne '0'))
  153. {
  154. return 0;
  155. }
  156. }
  157. if ($ptr eq ',')
  158. {
  159. # next word on the opt_str
  160. $sub_opt_str = '';
  161. }
  162. }
  163. return 1;
  164. }
  165. ####
  166. #### Tests given function(s) with given value(s) $count rounds
  167. #### If function doesn't have an arg, test it once and continue.
  168. #### ulargs (number of unlimited args) is the number of arguments
  169. #### to be placed in place of '.' . '.' means that any number
  170. #### of the last argument type is possible to the function.
  171. #### If force is given, never mind about errors
  172. #### args: $func: list of functions to be tested
  173. #### $value: list of values to be used with functions
  174. #### $count: number of times one function should be tested
  175. #### $ulargs: number of unlimited args to be used when possible
  176. #### $table_info: information about the table to be used, contains:
  177. #### table name, info about the fields in the table, for example:
  178. #### [mysql_test1, "Zi", "Rd"], where mysql_test1 is the name of the
  179. #### table, "Zi" tells, that the first field name is 'i' and it is
  180. #### type 'Z' (integer), see test_mysql_functions, 'Rd' tells that
  181. #### the second field name is 'd' and the type is 'R' (real number)
  182. #### $force: if given, never mind about errors
  183. #### $mix: if 0, use the same argument at a time in a
  184. #### function that has two or more same type arguments
  185. #### if 1, use different values
  186. ####
  187. sub test_func()
  188. {
  189. my ($func, $value, $count, $ulargs, $table_info, $force, $mix) = @_;
  190. my ($query, $i, $j, $k, $no_arg, $row, $ulimit, $tbinfo, $tbused, $arg);
  191. if (!$func->[0][0])
  192. {
  193. printf("No function found!\n");
  194. if (!$force) { die; }
  195. }
  196. for ($i = 0; $func->[$i][0]; $i++)
  197. {
  198. $tbused = 0;
  199. $no_arg = 0;
  200. for ($j = 0; $j < $count && !$no_arg; $j++)
  201. {
  202. if ($tbused || $no_arg) { next; }
  203. $query = "select $func->[$i][0](";
  204. #search the values for the args
  205. for ($k = 0; $k < length($func->[$i][1]) && !$no_arg; $k++)
  206. {
  207. if ($mix)
  208. {
  209. $arg = $j + 1 + $k;
  210. }
  211. else
  212. {
  213. $arg = $j + 1;
  214. }
  215. if (substr($func->[$i][1], $k, 1) eq 'E')
  216. {
  217. $no_arg = 1;
  218. next;
  219. }
  220. if ($k) { $query .= ','; }
  221. if (substr($func->[$i][1], $k, 1) eq 'S')
  222. {
  223. $query .= &find_value(\@value, 'S', $arg);
  224. }
  225. elsif (substr($func->[$i][1], $k, 1) eq 'N')
  226. {
  227. $query .= &find_value(\@value, 'N', $arg);
  228. }
  229. elsif (substr($func->[$i][1], $k, 1) eq 'Z')
  230. {
  231. $query .= &find_value(\@value, 'Z', $arg);
  232. }
  233. elsif ((substr($func->[$i][1], $k, 1) eq 'R'))
  234. {
  235. $query .= &find_value(\@value, 'R', $arg);
  236. }
  237. elsif (substr($func->[$i][1], $k, 1) eq 'T')
  238. {
  239. $query .= &find_value(\@value, 'T', $arg);
  240. }
  241. elsif (substr($func->[$i][1], $k, 1) eq 'D')
  242. {
  243. $query .= &find_value(\@value, 'D', $arg);
  244. }
  245. elsif (substr($func->[$i][1], $k, 1) eq 'B')
  246. {
  247. $query .= &find_value(\@value, 'B', $arg);
  248. }
  249. elsif (substr($func->[$i][1], $k, 1) eq 'C')
  250. {
  251. $query .= &find_value(\@value, 'C', $arg);
  252. }
  253. elsif (substr($func->[$i][1], $k, 1) eq 'F')
  254. {
  255. $query .= &find_value(\@value, 'F', $arg);
  256. }
  257. elsif (substr($func->[$i][1], $k, 1) eq '.')
  258. {
  259. chop($query);
  260. for ($ulimit = 0; $ulimit < $ulargs; $ulimit++)
  261. {
  262. $query .= ',';
  263. $query .= &find_value(\@value,
  264. substr($func->[$i][1], $k - 1, 1),
  265. $j + $ulimit + 2);
  266. }
  267. }
  268. elsif (substr($func->[$i][1], $k, 1) eq 'A')
  269. {
  270. for ($tbinfo = 1; substr($table_info->[$tbinfo], 0, 1) ne
  271. substr($func->[$i][1], $k + 1, 1); $tbinfo++)
  272. {
  273. if (!defined($table_info->[$tbinfo]))
  274. {
  275. printf("Illegal function structure!\n");
  276. printf("A table was needed, but no type specified!\n");
  277. printf("Unready query was: $query\n");
  278. if (!$force) { die; }
  279. else { next; }
  280. }
  281. }
  282. if ($k) { $query .= ","; }
  283. $query .= substr($table_info->[$tbinfo], 1,
  284. length($table_info->[$tbinfo]) - 1);
  285. $k++;
  286. $tbused = 1;
  287. }
  288. else
  289. {
  290. printf("Not a valid type: \n");
  291. printf(substr($func->[$i][1], $k, 1));
  292. printf("\nAttempted to be used with unready query: \n");
  293. printf("$query\n");
  294. }
  295. }
  296. $query .= ")";
  297. if ($tbused)
  298. {
  299. $query .= " from ";
  300. $query .= $table_info->[0];
  301. }
  302. if (!($sth = $dbh->prepare($query)))
  303. {
  304. printf("Couldn't prepare: $query\n");
  305. if (!$force) { die; }
  306. }
  307. if (!$sth->execute)
  308. {
  309. printf("Execution failed: $DBI::errstr\n");
  310. printf("Attempted query was:\n$query\n");
  311. $sth->finish;
  312. if (!$force) { die; }
  313. }
  314. else
  315. {
  316. printf("mysql> $query;\n");
  317. display($sth, 1);
  318. printf("Query OK\n\n");
  319. }
  320. }
  321. }
  322. }
  323. ####
  324. #### mk_str returns a string where the first arg is repeated second arg times
  325. #### if repeat is 1, return the original str
  326. ####
  327. sub mk_str()
  328. {
  329. my ($str, $repeat) = @_;
  330. my ($res_str);
  331. if ($repeat <= 0)
  332. {
  333. die "Invalid repeat times!\n";
  334. }
  335. for ($repeat--, $res_str = $str; $repeat > 0; $repeat--)
  336. {
  337. $res_str .= $str;
  338. }
  339. return $res_str;
  340. }
  341. ####
  342. #### find_value: returns a value from list of values
  343. #### args: $values: list of values
  344. #### $type: type of argument (S = string, N = integer etc.)
  345. #### $ordinal: the ordinal number of an argument in the list
  346. ####
  347. sub find_value()
  348. {
  349. my ($values, $type, $ordinal) = @_;
  350. my ($total, $i, $j, $tmp, $val);
  351. $total = -1; # The first one is the type
  352. for ($i = 0; $values[$i][0]; $i++)
  353. {
  354. if ($values[$i][0] eq $type)
  355. {
  356. $tmp = $values[$i];
  357. foreach $val (@$tmp) { $total++; }
  358. for ( ;$total < $ordinal; )
  359. {
  360. $ordinal -= $total;
  361. }
  362. return $values[$i][$ordinal];
  363. }
  364. }
  365. printf("No type '$type' found in values\n");
  366. die;
  367. }
  368. ####
  369. #### exec_query: execute a query, print information if wanted and exit
  370. #### args: $queries: list of queries to be executed
  371. #### $expect_error: if 0, error is not expected. In this case if an
  372. #### error occurs, inform about it and quit
  373. #### if 1, error is expected. In this case if sql server
  374. #### doesn't give an error message, inform about it
  375. #### and quit
  376. #### if 2, error may happen or not, don't care
  377. #### $silent: if true, reduce output
  378. #### $style: type of output, 0 == horizontal, 1 == vertical
  379. ####
  380. sub exec_query()
  381. {
  382. my ($queries, $expect_error, $silent, $style) = @_;
  383. my ($query);
  384. foreach $query (@$queries)
  385. {
  386. if (!($sth = $dbh->prepare($query)))
  387. {
  388. printf("Couldn't prepare: $query\n");
  389. die;
  390. }
  391. if (!$sth->execute)
  392. {
  393. if ($expect_error == 1)
  394. {
  395. printf("An invalid instruction was purposely made,\n");
  396. printf("server failed succesfully:\n");
  397. printf("$DBI::errstr\n");
  398. printf("Everything OK, continuing...\n");
  399. return;
  400. }
  401. if ($expect_error != 2)
  402. {
  403. printf("Execution failed: $DBI::errstr\n");
  404. printf("Attempted query was:\n$query\n");
  405. die;
  406. }
  407. }
  408. if ($expect_error == 1)
  409. {
  410. printf("An invalid instruction was purposely made,\n");
  411. printf("server didn't note, ALARM!\n");
  412. printf("The query made was: $query\n");
  413. printf("The output from the server:\n");
  414. }
  415. if ($expect_error == 2) { return; }
  416. if (!$silent) { printf("mysql> $query;\n"); }
  417. display($sth, $style);
  418. if (!$silent) { printf("Query OK\n\n"); }
  419. if ($expect_error) { die; }
  420. }
  421. return;
  422. }
  423. ####
  424. #### Display to stderr
  425. #### Args: 1: ($sth) statememt handler
  426. #### 2: ($style) 0 == horizontal style, 1 == vertical style
  427. ####
  428. sub display()
  429. {
  430. my ($sth, $style) = @_;
  431. my (@data, @max_length, $row, $nr_rows, $nr_cols, $i, $j, $tmp, $mxl);
  432. # Store the field names and values in @data.
  433. # Store the max field lengths in @max_length
  434. for ($i = 0; ($row = $sth->fetchrow_arrayref); $i++)
  435. {
  436. if (!$i)
  437. {
  438. $nr_cols = $#$row;
  439. for ($j = 0; $j <= $#$row; $j++)
  440. {
  441. $data[$i][$j] = $sth->{NAME}->[$j];
  442. $max_length[$j] = length($data[$i][$j]);
  443. }
  444. $i++;
  445. }
  446. for ($j = 0; $j <= $#$row; $j++)
  447. {
  448. $data[$i][$j] = $row->[$j];
  449. $max_length[$j] = $tmp if ($max_length[$j] <
  450. ($tmp = length($data[$i][$j])));
  451. }
  452. }
  453. if (!($nr_rows = $i))
  454. {
  455. return;
  456. }
  457. # Display data
  458. if ($style == 0)
  459. {
  460. for ($i = 0; $i < $nr_rows; $i++)
  461. {
  462. if (!$i)
  463. {
  464. for ($j = 0; $j <= $nr_cols; $j++)
  465. {
  466. print "+"; print "-" x ($max_length[$j] + 2);
  467. }
  468. print "+\n";
  469. }
  470. print "|";
  471. for ($j = 0; $j <= $nr_cols; $j++)
  472. {
  473. print " ";
  474. if (defined($data[$i][$j]))
  475. {
  476. print $data[$i][$j];
  477. $tmp = length($data[$i][$j]);
  478. }
  479. else
  480. {
  481. print "NULL";
  482. $tmp = 4;
  483. }
  484. print " " x ($max_length[$j] - $tmp);
  485. print " |";
  486. }
  487. print "\n";
  488. if (!$i)
  489. {
  490. for ($j = 0; $j <= $nr_cols; $j++)
  491. {
  492. print "+"; print "-" x ($max_length[$j] + 2);
  493. }
  494. print "+\n";
  495. }
  496. }
  497. for ($j = 0; $j <= $nr_cols; $j++)
  498. {
  499. print "+"; print "-" x ($max_length[$j] + 2);
  500. }
  501. print "+\n";
  502. return;
  503. }
  504. if ($style == 1)
  505. {
  506. for ($i = 0; $max_length[$i]; $i++)
  507. {
  508. $mxl = $max_length[$i] if ($mxl < $max_length[$i]);
  509. }
  510. for ($i = 1; $i < $nr_rows; $i++)
  511. {
  512. print "*" x 27;
  513. print " " . $i . ". row ";
  514. print "*" x 27;
  515. print "\n";
  516. for ($j = 0; $j <= $nr_cols; $j++)
  517. {
  518. print " " x ($mxl - length($data[0][$j]));
  519. print "$data[0][$j]: ";
  520. if (defined($data[$i][$j]))
  521. {
  522. print "$data[$i][$j] \n";
  523. }
  524. else
  525. {
  526. print "NULL\n";
  527. }
  528. }
  529. }
  530. return;
  531. }
  532. }
  533. ####
  534. #### usage
  535. ####
  536. sub usage
  537. {
  538. print <<EOF;
  539. mysql-test $VER by Jani Tolonen
  540. Usage: mysql-test [options]
  541. Options:
  542. --help Show this help
  543. --db= Database to use (Default: $opt_db)
  544. --port= TCP/IP port to use for connection (Default: $opt_port)
  545. --socket= UNIX socket to use for connection (Default: $opt_socket)
  546. --host= Connect to host (Default: $opt_host)
  547. --user= User for login if not current user
  548. --password Password to use when connecting to server
  549. --without=PART_NAME1,PART_NAME2,...
  550. test without a certain part of MySQL, optional parts listed below
  551. Optional parts:
  552. FUNC Ignore MySQL basic functions
  553. PROC Ignore MySQL procedure functions
  554. EOF
  555. exit(0);
  556. }
  557. sub test_mysql_functions
  558. {
  559. ####
  560. #### MySQL functions
  561. ####
  562. #### Types: S = string (or real number) , N = unsigned integer, Z = integer,
  563. #### R = real number, T = time_stamp, E = no argument, D = date,
  564. #### B = boolean, C = character
  565. #### F = format (usually used with the date-types)
  566. #### . = any number of the last argument type possible
  567. #### A = require table for test, the following argument
  568. #### is the argument for the function
  569. # Muista get_lock,group_unique_users,
  570. # position, unique_users
  571. # ks. kaikki date function, ker�� yhteen, testaa erikseen
  572. # adddate, date_add, subdate, date_sub, between, benchmark, count
  573. # decode, encode, get_lock, make_set, position
  574. @functions = (["abs","R"],["acos","R"],["ascii","C"],["asin","R"],
  575. ["atan","R"],["atan2","R"],["avg","AR"],["bin","Z"],
  576. ["bit_count","Z"],["bit_or","AZ"],["bit_and","AZ"],
  577. ["ceiling","R"],["char","N."],["char_length","S"],
  578. ["concat","SS."],["conv","ZZZ"],
  579. ["cos","R"],["cot","R"],["curdate","E"],
  580. ["curtime","E"],["database","E"],["date_format","DF"],
  581. ["dayofmonth","D"],["dayofyear","D"],["dayname","D"],
  582. ["degrees","R"],["elt","NS."],["encode","SS"],
  583. ["encrypt","S"],["encrypt","SS"],["exp","R"],["field","SS."],
  584. ["find_in_set","SS"],["floor","R"],["format","RN"],
  585. ["from_days","N"],["from_unixtime","N"],
  586. ["from_unixtime","NF"],["greatest","RR."],["hex","Z"],
  587. ["hour","D"],["if","ZSS"],["ifnull","SS"],["insert","SNNS"],
  588. ["instr","SS"],["interval","RR."],["isnull","S"],
  589. ["last_insert_id","E"],["lcase","S"],["least","RR."],
  590. ["left","SN"],["length","S"],["locate","SS"],
  591. ["log","R"],["log10","R"],["lpad","SNS"],["ltrim","S"],
  592. ["max","AR"],["mid","SNN"],["min","AR"],["minute","D"],
  593. ["mod","ZZ"],["monthname","D"],
  594. ["month","D"],["now","E"],["oct","Z"],
  595. ["octet_length","S"],["password","S"],["period_add","DD"],
  596. ["period_diff","DD"],["pi","E"],
  597. ["pow","RR"],["quarter","D"],["radians","R"],
  598. ["rand","E"],["rand","R"],["release_lock","S"],
  599. ["repeat","SN"],["replace","SSS"],["reverse","S"],
  600. ["right","SN"],["round","R"],["round","RN"],
  601. ["rpad","SNS"],["rtrim","S"],["sec_to_time","N"],
  602. ["second","T"],["sign","R"],["sin","R"],
  603. ["space","N"],["soundex","S"],["sqrt","R"],["std","AR"],
  604. ["strcmp","SS"],["substring","SN"],["substring","SNN"],
  605. ["substring_index","SSZ"],["sum","AR"],
  606. ["tan","R"],["time_format","TF"],["time_to_sec","T"],
  607. ["to_days","D"],["trim","S"],
  608. ["truncate","RN"],["ucase","S"],
  609. ["unix_timestamp","E"],["unix_timestamp","D"],["user","E"],
  610. ["version","E"],["week","D"],["weekday","D"],["year","D"]);
  611. ####
  612. #### Various tests for the functions above
  613. ####
  614. &exec_query(["drop table mysql_test1"], $MAY_ERR, $SILENT);
  615. $query .= <<EOF;
  616. create table mysql_test1 (
  617. i int,
  618. d double
  619. )
  620. EOF
  621. chop($query);
  622. &exec_query([$query], $NO_ERR, $SILENT);
  623. ####
  624. #### Basic tests
  625. ####
  626. printf("####\n#### BASIC TESTS FOR FUNCTIONS\n####\n\n");
  627. @bunch = ("insert into mysql_test1 values(-20,-10.5),(20,10.5),(50,100.00)",
  628. "insert into mysql_test1 values(100,500.333)");
  629. &exec_query(\@bunch, $NO_ERR, $SILENT);
  630. printf("\n####\n#### First basic test part\n####\n\n");
  631. @values = (["S", "'a'", "'abc'", "'abc def'", "'abcd'", "'QWERTY'",
  632. "'\\\\'", "'*.!\"#�%&/()'", "'" . &mk_str('a',1024) . "'",
  633. "?", "<>", "#__#"],
  634. ["N", -1000, -500, -100, -1, 0, 1, 40, 50, 70, 90,
  635. 100, 500, 1000],
  636. ["Z", -100, -50, 200, 1000],
  637. ["R", -500.5, -10.333, 100.667, 400.0],
  638. ["T", 19980728154204, 19980728154205, 19980728154206,
  639. 19980728154207],
  640. ["D", "'1997-12-06'", "'1997-12-07'", "'1997-12-08'",
  641. "'1997-12-09'"],
  642. ["B", 1, 0, 0, 1],
  643. ["C", "'a'", "'e'", "'r'", "'q'"],
  644. ["F", "'%a'", "'%b'", "'%d'", "'%H'"]);
  645. &test_func(\@functions, \@values, 4, 5, ["mysql_test1","Zi","Rd"]);
  646. printf("\n####\n#### Second basic test part\n####\n\n");
  647. @values = (["S", "'a'", "'BC'", "'def'", "'HIJK'", "'lmnop'", "'QRSTUV'"],
  648. ["N", 0, 1, 2, 3, 4, 5],
  649. ["Z", 0, 1, 2, 3, 4, 5],
  650. ["R", 0, 1, 2, 3, 4, 5],
  651. ["T", 19990608234530, 20000709014631, 20010810024732,
  652. 20020911034833, 20031012044934, 20041113055035],
  653. ["D", "'1999-06-08'", "'2000-07-09'", "'2001-08-10'",
  654. "'2002-09-11'", "'2003-10-12'", "'2004-11-13'"],
  655. ["B", 0, 1, 0, 1, 0, 1],
  656. ["C", "'a'", "'BC'", "'def'", "'HIJK'", "'lmnop'", "'QRSTUV'"],
  657. ["F", "'%a'", "'%b'", "'%d'", "'%h'", "'%H'", "'%i'"]);
  658. &test_func(\@functions, \@values, 6, 6, ["mysql_test1","Zi","Rd"], 0, 1);
  659. printf("\n####\n#### Third basic test part\n####\n\n");
  660. @values = (["S", "'Monty'", "'Jani'", "'MySQL'", "''"],
  661. ["N", 10, 54, -70, -499],
  662. ["Z", 11.03, "'Abo'", 54.333, "''"],
  663. ["R", 12, "'gnome'", -34.211, "''"],
  664. ["T", 3, "'Redhat'", -19984021774433, "''"],
  665. ["D", "'1990-01-31'", "'-3333-10-23'", -5631_23_12, "''"],
  666. ["B", 0, "'asb'", -4, "''"],
  667. ["C", "'a'", 503, -45353453, "''"],
  668. ["F", "'%a'", -231, "'Mitsubishi'", "''"]);
  669. &test_func(\@functions, \@values, 3, 3, ["mysql_test1","Zi","Rd"], 0, 1);
  670. &exec_query(["delete from mysql_test1"], $NO_ERR, $SILENT);
  671. ####
  672. #### Null tests
  673. ####
  674. printf("\n\n####\n#### NULL TESTS FOR FUNCTIONS\n####\n\n\n");
  675. &exec_query(["insert into mysql_test1 values(null,null)"], $NO_ERR,
  676. $SILENT);
  677. @values = (["S", "NULL"],
  678. ["N", "NULL"],
  679. ["Z", "NULL"],
  680. ["R", "NULL"],
  681. ["T", "NULL"],
  682. ["D", "NULL"],
  683. ["B", "NULL"],
  684. ["C", "NULL"],
  685. ["F", "NULL"]);
  686. &test_func(\@functions, \@values, 1, 5, ["mysql_test1","Zi","Rd"], 1);
  687. &exec_query(["delete from mysql_test1"], $NO_ERR, $SILENT);
  688. ####
  689. #### Tests to fulfill the main part of function tests above
  690. ####
  691. printf("\n\n####\n#### FULFILL TESTS \n####\n\n\n");
  692. &exec_query(["drop table my_t"], $MAY_ERR, $SILENT);
  693. &exec_query(["create table my_t (s1 char(64), s2 char(64))"],
  694. $NO_ERR, $VERBOSE, $HS);
  695. $query = <<EOF;
  696. insert into my_t values('aaa','aaa'),('aaa|qqq','qqq'),('gheis','^[^a-dXYZ]+\$'),('aab','^aa?b'),('Baaan','^Ba*n'),('aaa','qqq|aaa'),('qqq','qqq|aaa'),('bbb','qqq|aaa'),('bbb','qqq'),('aaa','aba'),(null,'abc'),('def',null),(null,null),('ghi','ghi[')
  697. EOF
  698. chop($query);
  699. &exec_query([$query], $NO_ERR, $VERBOSE, $HS);
  700. &exec_query(["select s1 regexp s2 from my_t"],
  701. $NO_ERR, $VERBOSE, $HS);
  702. ####
  703. #### ["position","SS"],
  704. ####
  705. }
  706. sub create_test_tables
  707. {
  708. $query[0][0] = <<EOF;
  709. CREATE TABLE my_t (
  710. auto int(5) unsigned DEFAULT '0' NOT NULL auto_increment,
  711. string varchar(10) DEFAULT 'hello',
  712. binary_string varchar(10) binary DEFAULT '' NOT NULL,
  713. tiny tinyint(4) DEFAULT '0' NOT NULL,
  714. short smallint(6) DEFAULT '1' NOT NULL,
  715. medium mediumint(8) DEFAULT '0' NOT NULL,
  716. longint int(11) DEFAULT '0' NOT NULL,
  717. longlong bigint(13) DEFAULT '0' NOT NULL,
  718. num decimal(5,2) DEFAULT '0.00' NOT NULL,
  719. num_fill decimal(6,2) unsigned zerofill DEFAULT '0000.00' NOT NULL,
  720. real_float float(13,1) DEFAULT '0.0' NOT NULL,
  721. real_double double(13,1),
  722. utiny tinyint(3) unsigned DEFAULT '0' NOT NULL,
  723. ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL,
  724. umedium mediumint(8) unsigned DEFAULT '0' NOT NULL,
  725. ulong int(11) unsigned DEFAULT '0' NOT NULL,
  726. ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL,
  727. zero int(5) unsigned zerofill,
  728. time_stamp timestamp(14),
  729. date_field date,
  730. time_field time,
  731. date_time datetime,
  732. blob_col blob,
  733. tinyblob_col tinyblob,
  734. mediumblob_col mediumblob NOT NULL,
  735. longblob_col longblob NOT NULL,
  736. options enum('one','two','three'),
  737. flags set('one','two','three'),
  738. PRIMARY KEY (auto)
  739. )
  740. EOF
  741. chop($query[0][0]);
  742. $query[0][1] = <<EOF;
  743. INSERT INTO my_t VALUES (1,'hello','',0,1,0,0,0,0.00,0000.00,0.0,NULL,0,
  744. 00000,0,0,0,NULL,19980728154204,NULL,'01:00:00',
  745. NULL,NULL,NULL,'','',NULL,NULL)
  746. EOF
  747. chop($query[0][1]);
  748. $query[0][2] = <<EOF;
  749. INSERT INTO my_t VALUES (2,'hello','',0,1,0,0,0,0.00,0000.00,
  750. -340282346638528859811704183484516925440.0,NULL,0,
  751. 00000,0,0,0,NULL,19980728154205,NULL,NULL,NULL,NULL,
  752. NULL,'','',NULL,NULL)
  753. EOF
  754. chop($query[0][2]);
  755. $query[0][3] = <<EOF;
  756. INSERT INTO my_t VALUES (3,'hello','',0,1,0,0,0,0.00,0000.00,0.0,NULL,0,00000,
  757. 0,0,0,NULL,19980728154205,NULL,NULL,
  758. '2002-12-30 22:04:02',NULL,NULL,'','',NULL,NULL)
  759. EOF
  760. chop($query[0][3]);
  761. $query[0][4] = <<EOF;
  762. INSERT INTO my_t VALUES (4,'hello','',0,1,0,0,0,0.00,0000.00,0.0,NULL,0,00000,
  763. 0,0,0,NULL,19980728154205,'1997-12-06',NULL,NULL,
  764. NULL,NULL,'','',NULL,NULL)
  765. EOF
  766. chop($query[0][4]);
  767. $query[0][5] = <<EOF;
  768. INSERT INTO my_t VALUES (5,'hello','',0,1,0,0,0,0.00,0000.00,0.0,NULL,0,00000,
  769. 0,0,0,NULL,19980728154205,NULL,'20:10:08',NULL,NULL,
  770. NULL,'','',NULL,NULL)
  771. EOF
  772. chop($query[0][5]);
  773. $query[0][6] = <<EOF;
  774. INSERT INTO my_t VALUES (6,'hello','',0,1,0,0,0,-0.22,0000.00,0.0,NULL,0,
  775. 00000,0,0,0,NULL,19980728154205,NULL,NULL,NULL,
  776. NULL,NULL,'','',NULL,NULL)
  777. EOF
  778. chop($query[0][6]);
  779. $query[0][7] = <<EOF;
  780. INSERT INTO my_t VALUES (7,'hello','',0,1,0,0,0,-0.00,0000.00,0.0,NULL,0,
  781. 00000,0,0,0,NULL,19980728154205,NULL,NULL,NULL,
  782. NULL,NULL,'','',NULL,NULL)
  783. EOF
  784. chop($query[0][7]);
  785. $query[0][8] = <<EOF;
  786. INSERT INTO my_t VALUES (8,'hello','',0,1,0,0,0,+0.00,0000.00,0.0,NULL,0,
  787. 00000,0,0,0,NULL,19980728154205,NULL,NULL,NULL,
  788. NULL,NULL,'','',NULL,NULL)
  789. EOF
  790. chop($query[0][8]);
  791. $query[0][9] = <<EOF;
  792. INSERT INTO my_t VALUES (9,'hello','',0,1,0,0,0,+0.90,0000.00,0.0,NULL,0,
  793. 00000,0,0,0,NULL,19980728154205,NULL,NULL,NULL,
  794. NULL,NULL,'','',NULL,NULL)
  795. EOF
  796. chop($query[0][9]);
  797. $query[0][10] = <<EOF;
  798. INSERT INTO my_t VALUES (10,'hello','',0,1,0,0,0,-999.99,0000.00,0.0,NULL,0,
  799. 00000,0,0,0,NULL,19980728154206,NULL,NULL,NULL,NULL,
  800. NULL,'','',NULL,NULL)
  801. EOF
  802. chop($query[0][10]);
  803. $query[0][11] = <<EOF;
  804. INSERT INTO my_t VALUES (11,'hello','',127,32767,8388607,2147483647,
  805. 9223372036854775807,9999.99,9999.99,
  806. 329999996548271212625250308919809540096.0,9.0,255,
  807. 65535,16777215,4294967295,18446744073709551615,
  808. 4294967295,00000000000000,'9999-12-31','23:59:59',
  809. '9999-12-31 23:59:59',NULL,NULL,' ',' ','',
  810. 'one,two,three')
  811. EOF
  812. chop($query[0][11]);
  813. $query[0][12] = <<EOF;
  814. INSERT INTO my_t VALUES (12,'hello','',-128,-32768,-8388608,-2147483648,
  815. -9223372036854775808,-999.99,0000.00,
  816. -329999996548271212625250308919809540096.0,10.0,0,
  817. 00000,0,0,0,00000,00000000000000,
  818. '9999-12-31','23:59:59','9999-12-31 23:59:59',NULL,
  819. NULL,' ,-',' ,-','','one,two,three')
  820. EOF
  821. chop($query[0][12]);
  822. $query[0][13] = <<EOF;
  823. INSERT INTO my_t VALUES (13,'hello','',0,1,0,0,0,0.09,0000.00,0.0,NULL,0,
  824. 00000,0,0,0,NULL,19980728154223,NULL,NULL,NULL,
  825. NULL,NULL,'','',NULL,NULL)
  826. EOF
  827. chop($query[0][13]);
  828. $query[0][14] = <<EOF;
  829. INSERT INTO my_t VALUES (14,'hello','',0,1,0,0,0,0.00,0000.00,0.0,NULL,0,
  830. 00000,0,0,0,NULL,19980728154223,NULL,NULL,NULL,
  831. NULL,NULL,'','',NULL,NULL)
  832. EOF
  833. chop($query[0][14]);
  834. $query[0][15] = <<EOF;
  835. INSERT INTO my_t VALUES (15,'hello','',0,1,0,0,0,0.00,0044.00,0.0,NULL,0,
  836. 00000,0,0,0,NULL,19980728154223,NULL,NULL,NULL,
  837. NULL,NULL,'','',NULL,NULL)
  838. EOF
  839. chop($query[0][15]);
  840. $query[0][16] = <<EOF;
  841. INSERT INTO my_t VALUES (16,'hello','',0,1,0,0,0,0.00,9999.99,0.0,NULL,0,
  842. 00000,0,0,0,NULL,19980728154223,NULL,NULL,NULL,
  843. NULL,NULL,'','',NULL,NULL)
  844. EOF
  845. chop($query[0][16]);
  846. $query[0][17] = <<EOF;
  847. INSERT INTO my_t VALUES (17,'hello','',127,32767,8388607,2147483647,
  848. 9223372036854775807,9999.99,9999.99,
  849. 329999996548271212625250308919809540096.0,9.0,255,
  850. 65535,16777215,4294967295,18446744073709551615,
  851. 4294967295,00000000000000,'9999-12-31','23:59:59',
  852. '9999-12-31 23:59:59',NULL,NULL,' ',' ','',
  853. 'one,two,three')
  854. EOF
  855. chop($query[0][17]);
  856. $query[0][18] = <<EOF;
  857. INSERT INTO my_t VALUES (18,'hello','',127,32767,8388607,2147483647,
  858. 9223372036854775807,9999.99,9999.99,0.0,NULL,255,
  859. 65535,16777215,4294967295,18446744073709551615,
  860. 4294967295,19980728154224,NULL,NULL,NULL,NULL,
  861. NULL,'','',NULL,NULL)
  862. EOF
  863. chop($query[0][18]);
  864. $query[0][19] = <<EOF;
  865. INSERT INTO my_t VALUES (19,'hello','',127,32767,8388607,2147483647,
  866. 9223372036854775807,9999.99,9999.99,0.0,NULL,255,
  867. 65535,16777215,4294967295,0,4294967295,
  868. 19980728154224,NULL,NULL,NULL,NULL,NULL,'','',
  869. NULL,NULL)
  870. EOF
  871. chop($query[0][19]);
  872. $query[0][20] = <<EOF;
  873. INSERT INTO my_t VALUES (20,'hello','',-128,-32768,-8388608,-2147483648,
  874. -9223372036854775808,-999.99,0000.00,0.0,NULL,0,
  875. 00000,0,0,18446744073709551615,00000,19980728154224,
  876. NULL,NULL,NULL,NULL,NULL,'','',NULL,NULL)
  877. EOF
  878. chop($query[0][20]);
  879. $query[0][21] = <<EOF;
  880. INSERT INTO my_t VALUES (21,'hello','',-128,-32768,-8388608,-2147483648,
  881. -9223372036854775808,-999.99,0000.00,0.0,NULL,0,
  882. 00000,0,0,0,00000,19980728154225,NULL,NULL,NULL,
  883. NULL,NULL,'','',NULL,NULL)
  884. EOF
  885. chop($query[0][21]);
  886. $query[0][22] = <<EOF;
  887. INSERT INTO my_t VALUES (22,NULL,'1',1,1,1,1,1,1.00,0001.00,1.0,NULL,1,00001,
  888. 1,1,1,00001,19980728154244,NULL,NULL,NULL,NULL,NULL,
  889. '1','1',NULL,NULL)
  890. EOF
  891. chop($query[0][22]);
  892. $query[0][23] = <<EOF;
  893. INSERT INTO my_t VALUES (23,'2','2',2,2,2,2,2,2.00,0002.00,2.0,2.0,2,00002,
  894. 2,2,2,00002,00000000000000,'0000-00-00','02:00:00',
  895. '0000-00-00 00:00:00','2','2','2','2','','')
  896. EOF
  897. chop($query[0][23]);
  898. $query[0][24] = <<EOF;
  899. INSERT INTO my_t VALUES (24,'3','3',3,3,3,3,3,3.00,0003.00,3.0,3.0,3,00003,
  900. 3,3,3,00003,00000000000000,'2000-00-03','00:00:03',
  901. '0000-00-00 00:00:03','3.00','3.00','3.00','3.00',
  902. 'three','one,two')
  903. EOF
  904. chop($query[0][24]);
  905. $query[0][25] = <<EOF;
  906. INSERT INTO my_t VALUES (25,'-4.7','-4.7',-5,-5,-5,-5,-5,-4.70,0000.00,-4.7,
  907. -4.7,0,00000,0,0,0,00000,00000000000000,'0000-00-00',
  908. '00:00:00','0000-00-00 00:00:00','-4.70','-4.70',
  909. '-4.70','-4.70','','three')
  910. EOF
  911. chop($query[0][25]);
  912. $query[0][26] = <<EOF;
  913. INSERT INTO my_t VALUES (26,'+0.09','+0.09',0,0,0,0,0,+0.09,0000.00,0.1,0.1,
  914. 0,00000,0,0,0,00000,00000000000000,'0000-00-00',
  915. '00:09:00','0000-00-00 00:00:00','+0.09','+0.09',
  916. '+0.09','+0.09','','')
  917. EOF
  918. chop($query[0][26]);
  919. $query[0][27] = <<EOF;
  920. INSERT INTO my_t VALUES (27,'1','1',1,1,1,1,1,1.00,0001.00,1.0,1.0,1,00001,
  921. 1,1,1,00001,00000000000000,'2000-00-01','00:00:01',
  922. '0000-00-00 00:00:01','1','1','1','1','one','one')
  923. EOF
  924. chop($query[0][27]);
  925. $query[0][28] = <<EOF;
  926. INSERT INTO my_t VALUES (28,'-1','-1',-1,-1,-1,-1,-1,-1.00,0000.00,-1.0,-1.0,
  927. 0,00000,0,0,18446744073709551615,00000,
  928. 00000000000000,'0000-00-00','00:00:00',
  929. '0000-00-00 00:00:00','-1','-1','-1','-1','',
  930. 'one,two,three')
  931. EOF
  932. chop($query[0][28]);
  933. $query[0][29] = <<EOF;
  934. INSERT INTO my_t VALUES (29,'','',0,0,0,0,0,0.00,0000.00,0.0,0.0,0,00000,0,0,
  935. 0,00000,00000000000000,'0000-00-00','00:00:00',
  936. '0000-00-00 00:00:00','','','','','','')
  937. EOF
  938. chop($query[0][29]);
  939. $query[1][0] = "CREATE TABLE my_t (str char(64))";
  940. $query[1][1] = "INSERT INTO my_t VALUES ('5.5')";
  941. $query[1][2] = "INSERT INTO my_t VALUES ('6.8')";
  942. $query[2][0] = "CREATE TABLE my_t (str char(64))";
  943. $query[2][1] = <<EOF;
  944. INSERT INTO my_t VALUES
  945. ('9999999999993242342442323423443534529999.02235000054213')
  946. EOF
  947. chop($query[2][1]);
  948. $query[3][0] = "CREATE TABLE my_t (str char(64))";
  949. $query[3][1] = <<EOF;
  950. INSERT INTO my_t VALUES
  951. ('8494357934579347593475349579347593845948793454350349543348736453')
  952. EOF
  953. chop($query[3][1]);
  954. $query[4][0] = "CREATE TABLE my_t (d double(20,10))";
  955. $query[4][1] = "INSERT INTO my_t VALUES (10.0000000000)";
  956. $query[4][2] = "INSERT INTO my_t VALUES (-10.0000000000)";
  957. $query[5][0] = "CREATE TABLE my_t (d double(20,10))";
  958. $query[5][1] = "INSERT INTO my_t VALUES (50000.0000000000)";
  959. $query[6][0] = "CREATE TABLE my_t (d double(20,10))";
  960. $query[6][1] = "INSERT INTO my_t VALUES (5000000.0000000000)";
  961. $query[7][0] = "CREATE TABLE my_t (d double(20,10))";
  962. $query[7][1] = "INSERT INTO my_t VALUES (500000000.0000000000)";
  963. $query[8][0] = "CREATE TABLE my_t (d double(20,10))";
  964. $query[8][1] = "INSERT INTO my_t VALUES (50000000000.0000000000)";
  965. $query[8][2] = "INSERT INTO my_t VALUES (NULL)";
  966. $query[9][0] = "CREATE TABLE my_t (d double(60,10))";
  967. $query[9][1] = "INSERT INTO my_t VALUES (93850983054983462912.0000000000)";
  968. $query[9][2] = "INSERT INTO my_t VALUES (93850983.3495762944)";
  969. $query[9][3] = <<EOF;
  970. INSERT INTO my_t VALUES (938509832438723448371221493568778534912.0000000000)
  971. EOF
  972. chop($query[9][3]);
  973. $query[10][0] = "CREATE TABLE my_t (i int(11))";
  974. $query[10][1] = "INSERT INTO my_t VALUES (-100)";
  975. $query[10][2] = "INSERT INTO my_t VALUES (-200)";
  976. $query[11][0] = "CREATE TABLE my_t (s char(64))";
  977. $query[11][1] = "INSERT INTO my_t VALUES ('100.')";
  978. $query[12][0] = "CREATE TABLE my_t (s char(64))";
  979. $query[12][1] = "INSERT INTO my_t VALUES ('1e+50')";
  980. $query[13][0] = "CREATE TABLE my_t (s char(64))";
  981. $query[13][1] = "INSERT INTO my_t VALUES ('1E+50u')";
  982. $query[14][0] = "CREATE TABLE my_t (s char(64))";
  983. $query[14][1] = "INSERT INTO my_t VALUES ('1EU50')";
  984. $query[15][0] = "CREATE TABLE my_t (s char(64))";
  985. $query[15][1] = "INSERT INTO my_t VALUES ('123.000')";
  986. $query[15][2] = "INSERT INTO my_t VALUES ('123.000abc')";
  987. $query[16][0] = "CREATE TABLE my_t (s char(128))";
  988. $query[16][1] = <<EOF;
  989. INSERT INTO my_t VALUES
  990. ('-999999999999999999999999999999999999999999999999999999999999999999999999')
  991. EOF
  992. chop($query[16][1]);
  993. $query[17][0] = "CREATE TABLE my_t (s char(128))";
  994. $query[17][1] = "INSERT INTO my_t VALUES ('-9999999999999999')";
  995. $query[18][0] = "CREATE TABLE my_t (s char(128))";
  996. $query[18][1] = "INSERT INTO my_t VALUES ('28446744073709551615001')";
  997. $query[18][2] = "INSERT INTO my_t VALUES ('184467440737095516150000000')";
  998. $query[19][0] = "CREATE TABLE my_t (s char(128))";
  999. $query[19][1] = "INSERT INTO my_t VALUES ('18446744073709551615')";
  1000. $query[20][0] = "CREATE TABLE my_t (s char(128))";
  1001. $query[20][1] = "INSERT INTO my_t VALUES ('18446744073709551616')";
  1002. $query[21][0] = "CREATE TABLE my_t (s char(64))";
  1003. $query[21][1] = "INSERT INTO my_t VALUES ('00740')";
  1004. $query[21][2] = "INSERT INTO my_t VALUES ('00740.')";
  1005. $query[22][0] = "CREATE TABLE my_t (s char(128))";
  1006. $query[22][1] = "INSERT INTO my_t VALUES ('-18446744073709551615')";
  1007. $query[23][0] = "CREATE TABLE my_t (s char(32))";
  1008. $query[23][1] = "INSERT INTO my_t VALUES ('740')";
  1009. $query[23][2] = "INSERT INTO my_t VALUES ('12345')";
  1010. $query[23][3] = "INSERT INTO my_t VALUES ('12345')";
  1011. $query[24][0] = "CREATE TABLE my_t (s char(32))";
  1012. $query[24][1] = "INSERT INTO my_t VALUES ('00740')";
  1013. $query[24][2] = "INSERT INTO my_t VALUES ('00730')";
  1014. $query[24][3] = "INSERT INTO my_t VALUES ('00720')";
  1015. $query[24][4] = "INSERT INTO my_t VALUES ('12345.02')";
  1016. $query[25][0] = "CREATE TABLE my_t (i bigint(20) unsigned)";
  1017. $query[25][1] = "INSERT INTO my_t VALUES (3000)";
  1018. $query[25][2] = "INSERT INTO my_t VALUES (NULL)";
  1019. $query[25][3] = "INSERT INTO my_t VALUES (900000000003)";
  1020. $query[25][4] = "INSERT INTO my_t VALUES (90)";
  1021. $query[26][0] = "CREATE TABLE my_t (i int(11))";
  1022. $query[26][1] = "INSERT INTO my_t VALUES (NULL)";
  1023. $query[27][0] = "CREATE TABLE my_t (d date)";
  1024. $query[27][1] = "INSERT INTO my_t VALUES ('1999-05-01')";
  1025. $query[28][0] = "CREATE TABLE my_t (y year(4))";
  1026. $query[28][1] = "INSERT INTO my_t VALUES (1999)";
  1027. $query[29][0] = "CREATE TABLE my_t (s char(128))";
  1028. $query[29][1] = "INSERT INTO my_t VALUES ('453453444451.7976')";
  1029. $query[30][0] = "CREATE TABLE my_t (s char(128))";
  1030. $query[30][1] = "INSERT INTO my_t VALUES('')";
  1031. $query[31][0] = "CREATE TABLE my_t (s char(128))";
  1032. $query[31][1] = "INSERT INTO my_t VALUES(' ')";
  1033. return $query;
  1034. }