mysql-test_V1.9.pl
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:35k
源码类别:

MySQL数据库

开发平台:

Visual C++

  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::errstrn";
  38. if (!$sth->execute)
  39. {
  40.   print "Couldn't execute query: $DBI::errstrn";
  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 RUNNINGn");
  51.   printf("####      mysql-test version $VERn####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.   
  65.   $query = create_show_tables();
  66.   &exec_query(["drop table my_t"], $MAY_ERR, $SILENT);
  67.   for ($i = 0; $query[$i]; $i++)
  68.   {
  69.     &exec_query([$query[$i]], $NO_ERR, $VERBOSE, $HS);
  70.     &exec_query(["show fields from my_t"], $NO_ERR, $VERBOSE, $HS);
  71.     &exec_query(["show keys from my_t"], $NO_ERR, $VERBOSE, $HS);
  72.     &exec_query(["drop table my_t"], $NO_ERR, $SILENT);
  73.   }
  74. }
  75. sub create_show_tables
  76. {
  77.   my ($query, $i);
  78.   
  79.   $query[0] = <<EOF;
  80. create table my_t (i int, f float, s char(64), b blob, t text)
  81. EOF
  82.   $query[1] = <<EOF;
  83. create table my_t (i int, f float, s char(64), b blob, t text, primary key (i))
  84. EOF
  85.   $query[2] = <<EOF;
  86. create table my_t (i int, f float, s char(64), b blob, t text, unique (i), unique(s))
  87. EOF
  88.   for ($i = 0; $query[$i]; $i++) { chop($query[$i]); }
  89.   return $query;
  90. }
  91. ####
  92. #### test procedures, currently only procedure analyze()
  93. ####
  94. sub test_mysql_procedures
  95. {
  96.   test_analyze();
  97. }
  98. sub test_analyze
  99. {
  100.   my ($query, $i, $j);
  101.   
  102.   if ($opt_help)
  103.   {
  104.     usage();
  105.   }
  106.   # invalid queries
  107.   &exec_query(["select * from mails procedure analyse(-1)"], 
  108.       $EXP_ERR, $VERBOSE, $HS);
  109.   &exec_query(["select * from mails procedure analyse(10, -1)"], 
  110.       $EXP_ERR, $VERBOSE, $HS);
  111.   &exec_query(["select * from mails procedure analyse(1, 2, 3)"],
  112.       $EXP_ERR, $VERBOSE, $HS);
  113.   &exec_query(["select * from mails procedure analyse(-10, 10)"],
  114.       $EXP_ERR, $VERBOSE, $HS);
  115.   &exec_query(["select * from mails procedure analyse('a', 'a')"],
  116.       $EXP_ERR, $VERBOSE, $HS);
  117.   # valid queries
  118. #  &exec_query(["select * from mails procedure analyse(10)"], 0, 0);
  119. #  &exec_query(["select * from mails procedure analyse(10, 10)"], 0, 0);
  120. #  &exec_query(["select hash from mails procedure analyse()"], 0, 0);
  121.   &exec_query(["use mysql_test"], $NO_ERR, $VERBOSE, $HS);
  122. #  &exec_query(["select timestamp from w32_user procedure analyse(0)"], 0, 0); 
  123.   $query = create_test_tables();
  124.   &exec_query(["drop table my_t"], $MAY_ERR, $SILENT);
  125.   for ($i = 0; $query[$i][0]; $i++)
  126.   {
  127.     &exec_query([$query[$i][0]], $NO_ERR, $SILENT); # create table
  128.     for ($j = 1; $query[$i][$j]; $j++)
  129.     {
  130.       &exec_query([$query[$i][$j]], $NO_ERR, $SILENT); # do inserts
  131.     }
  132.     &exec_query(["select * from my_t procedure analyse(0,0)"],
  133. $NO_ERR, $VERBOSE, $HS);
  134.     &exec_query(["select * from my_t procedure analyse()"],
  135. $NO_ERR, $VERBOSE, $HS);
  136.     &exec_query(["drop table my_t"], $NO_ERR, $SILENT);
  137.   }
  138. }
  139. ####
  140. #### if $opt is found as a part from the '--without=...' option string
  141. #### return 0, else 1. if zero is returned, then that part of MySQL
  142. #### won't be tested
  143. ####
  144. sub chk_package
  145. {
  146.   my ($opt_str, $opt) = @_;
  147.   
  148.   $sub_opt_str = '';
  149.   for ($i = 0, $ptr = substr($opt_str, $i, 1); $ptr || $ptr eq '0';
  150.        $i++, $ptr = substr($opt_str, $i, 1))
  151.   {
  152.     $sub_opt_str .= $ptr;
  153.     if ($sub_opt_str eq $opt)
  154.     {
  155.       $next_chr = substr($opt_str, ($i + 1), 1);
  156.       if ($next_chr eq ',' || (!$next_chr && $next_chr ne '0'))
  157.       {
  158. return 0;
  159.       }
  160.     }
  161.     if ($ptr eq ',')
  162.     {
  163.       # next word on the opt_str
  164.       $sub_opt_str = '';
  165.     }
  166.   }
  167.   return 1;
  168. }
  169. ####
  170. #### Tests given function(s) with given value(s) $count rounds
  171. #### If function doesn't have an arg, test it once and continue.
  172. #### ulargs (number of unlimited args) is the number of arguments 
  173. #### to be placed in place of '.' . '.' means that any number
  174. #### of the last argument type is possible to the function.
  175. #### If force is given, never mind about errors
  176. #### args: $func:   list of functions to be tested
  177. ####       $value:  list of values to be used with functions
  178. ####       $count:  number of times one function should be tested
  179. ####       $ulargs: number of unlimited args to be used when possible
  180. ####       $table_info: information about the table to be used, contains:
  181. ####       table name, info about the fields in the table, for example:
  182. ####       [mysql_test1, "Zi", "Rd"], where mysql_test1 is the name of the
  183. ####       table, "Zi" tells, that the first field name is 'i' and it is
  184. ####       type 'Z' (integer), see test_mysql_functions, 'Rd' tells that
  185. ####       the second field name is 'd' and the type is 'R' (real number)
  186. ####       $force:  if given, never mind about errors
  187. ####       $mix:    if 0, use the same argument at a time in a 
  188. ####                function that has two or more same type arguments
  189. ####                if 1, use different values
  190. ####
  191. sub test_func()
  192. {
  193.   my ($func, $value, $count, $ulargs, $table_info, $force, $mix) = @_;
  194.   my ($query, $i, $j, $k, $no_arg, $row, $ulimit, $tbinfo, $tbused, $arg);
  195.   
  196.   if (!$func->[0][0])
  197.   {
  198.     printf("No function found!n");
  199.     if (!$force) { die; }
  200.   }
  201.   
  202.   for ($i = 0; $func->[$i][0]; $i++)
  203.   {
  204.     $tbused = 0;
  205.     $no_arg = 0;
  206.     for ($j = 0; $j < $count && !$no_arg; $j++)
  207.     {      
  208.       if ($tbused || $no_arg) { next; }
  209.       $query = "select $func->[$i][0](";
  210.       #search the values for the args
  211.       for ($k = 0; $k < length($func->[$i][1]) && !$no_arg; $k++)
  212.       {
  213. if ($mix)
  214. {
  215.   $arg = $j + 1 + $k;
  216. }
  217. else
  218. {
  219.   $arg = $j + 1;
  220. }
  221. if (substr($func->[$i][1], $k, 1) eq 'E')
  222. {
  223.   $no_arg = 1;
  224.   next;
  225. }
  226. if ($k) { $query .= ','; }
  227. if (substr($func->[$i][1], $k, 1) eq 'S')
  228. {
  229.   $query .= &find_value(@value, 'S', $arg);
  230. }
  231. elsif (substr($func->[$i][1], $k, 1) eq 'N')
  232. {
  233.   $query .= &find_value(@value, 'N', $arg);
  234. }
  235. elsif (substr($func->[$i][1], $k, 1) eq 'Z')
  236. {
  237.   $query .= &find_value(@value, 'Z', $arg);
  238. }
  239. elsif ((substr($func->[$i][1], $k, 1) eq 'R'))
  240. {
  241.   $query .= &find_value(@value, 'R', $arg);
  242. }
  243. elsif (substr($func->[$i][1], $k, 1) eq 'T')
  244. {
  245.   $query .= &find_value(@value, 'T', $arg);
  246. }
  247. elsif (substr($func->[$i][1], $k, 1) eq 'D')
  248. {
  249.   $query .= &find_value(@value, 'D', $arg);
  250. }
  251. elsif (substr($func->[$i][1], $k, 1) eq 'B')
  252. {
  253.   $query .= &find_value(@value, 'B', $arg);
  254. }
  255. elsif (substr($func->[$i][1], $k, 1) eq 'C')
  256. {
  257.   $query .= &find_value(@value, 'C', $arg);
  258. }
  259. elsif (substr($func->[$i][1], $k, 1) eq 'F')
  260. {
  261.   $query .= &find_value(@value, 'F', $arg);
  262. }
  263. elsif (substr($func->[$i][1], $k, 1) eq '.')
  264. {
  265.   chop($query);
  266.   for ($ulimit = 0; $ulimit < $ulargs; $ulimit++)
  267.   {
  268.     $query .= ',';
  269.     $query .= &find_value(@value,
  270.   substr($func->[$i][1], $k - 1, 1),
  271.   $j + $ulimit + 2);
  272.   }
  273. }
  274. elsif (substr($func->[$i][1], $k, 1) eq 'A')
  275. {
  276.   for ($tbinfo = 1; substr($table_info->[$tbinfo], 0, 1) ne
  277.        substr($func->[$i][1], $k + 1, 1); $tbinfo++)
  278.   {
  279.     if (!defined($table_info->[$tbinfo]))
  280.     {
  281.       printf("Illegal function structure!n");
  282.       printf("A table was needed, but no type specified!n");
  283.       printf("Unready query was: $queryn");
  284.       if (!$force) { die; }
  285.       else { next; }
  286.     }
  287.   }
  288.   if ($k) { $query .= ","; }
  289.   $query .= substr($table_info->[$tbinfo], 1,
  290.    length($table_info->[$tbinfo]) - 1);
  291.   $k++;
  292.   $tbused = 1;
  293. }
  294.     else
  295. {
  296.   printf("Not a valid type: n");
  297.   printf(substr($func->[$i][1], $k, 1));
  298.   printf("nAttempted to be used with unready query: n");
  299.   printf("$queryn");
  300. }
  301.       }
  302.       $query .= ")";
  303.       if ($tbused)
  304.       {
  305. $query .= " from ";
  306. $query .= $table_info->[0];
  307.       }
  308.       if (!($sth = $dbh->prepare($query)))
  309.       {
  310. printf("Couldn't prepare: $queryn");
  311. if (!$force) { die; }
  312.       }
  313.       if (!$sth->execute)
  314.       {
  315. printf("Execution failed: $DBI::errstrn");
  316. printf("Attempted query was:n$queryn");
  317. $sth->finish;
  318. if (!$force) { die; }
  319.       }
  320.       else 
  321.       { 
  322. printf("mysql> $query;n");
  323. display($sth, 1);
  324. printf("Query OKnn");
  325.       }
  326.     }
  327.   }
  328. }
  329. ####
  330. #### mk_str returns a string where the first arg is repeated second arg times
  331. #### if repeat is 1, return the original str
  332. ####
  333. sub mk_str()
  334. {
  335.   my ($str, $repeat) = @_;
  336.   my ($res_str);
  337.   if ($repeat <= 0)
  338.   {
  339.     die "Invalid repeat times!n";
  340.   }
  341.   
  342.   for ($repeat--, $res_str = $str; $repeat > 0; $repeat--)
  343.   {
  344.     $res_str .= $str;
  345.   }
  346.   return $res_str;
  347. }
  348. ####
  349. #### find_value: returns a value from list of values
  350. #### args: $values:  list of values
  351. ####       $type:    type of argument (S = string, N = integer etc.)
  352. ####       $ordinal: the ordinal number of an argument in the list
  353. ####
  354. sub find_value()
  355. {
  356.   my ($values, $type, $ordinal) = @_;
  357.   my ($total, $i, $j, $tmp, $val);
  358.   $total = -1; # The first one is the type
  359.   for ($i = 0; $values[$i][0]; $i++)
  360.   {
  361.     if ($values[$i][0] eq $type)
  362.     {
  363.       $tmp = $values[$i];
  364.       foreach $val (@$tmp) { $total++; }
  365.       for ( ;$total < $ordinal; )
  366.       {
  367. $ordinal -= $total;
  368.       }
  369.       return $values[$i][$ordinal];
  370.     }
  371.   }
  372.   printf("No type '$type' found in valuesn");
  373.   die;
  374. }
  375. ####
  376. #### exec_query: execute a query, print information if wanted and exit
  377. #### args: $queries:      list of queries to be executed
  378. ####       $expect_error: if 0, error is not expected. In this case if an
  379. ####                      error occurs, inform about it and quit
  380. ####                      if 1, error is expected. In this case if sql server
  381. ####                      doesn't give an error message, inform about it
  382. ####                      and quit
  383. ####                      if 2, error may happen or not, don't care
  384. ####       $silent:       if true, reduce output
  385. ####       $style:        type of output, 0 == horizontal, 1 == vertical
  386. ####
  387. sub exec_query()
  388. {
  389.   my ($queries, $expect_error, $silent, $style) = @_;
  390.   my ($query);
  391.   foreach $query (@$queries)
  392.   {
  393.     if (!($sth = $dbh->prepare($query)))
  394.     {
  395.       printf("Couldn't prepare: $queryn");
  396.       die;
  397.     }
  398.     if (!$sth->execute)
  399.     {
  400.       if ($expect_error == 1)
  401.       {
  402.         printf("An invalid instruction was purposely made,n"); 
  403.         printf("server failed succesfully:n");
  404.         printf("$DBI::errstrn");
  405.         printf("Everything OK, continuing...n");
  406.         return;
  407.       }
  408.       if ($expect_error != 2)
  409.       {
  410.         printf("Execution failed: $DBI::errstrn");
  411.         printf("Attempted query was:n$queryn");
  412.         die;
  413.       }
  414.     }
  415.     if ($expect_error == 1)
  416.     {
  417.       printf("An invalid instruction was purposely made,n");
  418.       printf("server didn't note, ALARM!n");
  419.       printf("The query made was: $queryn");
  420.       printf("The output from the server:n");
  421.     }
  422.     if ($expect_error == 2) { return; }
  423.     if (!$silent) { printf("mysql> $query;n"); }
  424.     display($sth, $style);
  425.     if (!$silent) { printf("Query OKnn"); }
  426.     if ($expect_error) { die; }
  427.   }
  428.   return;
  429. }
  430. ####
  431. #### Display to stderr
  432. #### Args: 1: ($sth) statememt handler
  433. ####       2: ($style) 0 == horizontal style, 1 == vertical style
  434. ####
  435. sub display()
  436. {
  437.   my ($sth, $style) = @_;
  438.   my (@data, @max_length, $row, $nr_rows, $nr_cols, $i, $j, $tmp, $mxl);
  439.   
  440.   # Store the field names and values in @data.
  441.   # Store the max field lengths in @max_length
  442.   for ($i = 0; ($row = $sth->fetchrow_arrayref); $i++)
  443.   {
  444.     if (!$i)
  445.     {
  446.       $nr_cols = $#$row;
  447.       for ($j = 0; $j <= $#$row; $j++)
  448.       {
  449.         $data[$i][$j] = $sth->{NAME}->[$j];
  450.         $max_length[$j] = length($data[$i][$j]);
  451.       }
  452.       $i++;
  453.     }
  454.     for ($j = 0; $j <= $#$row; $j++)
  455.     {
  456.       $data[$i][$j] = $row->[$j];
  457.       $max_length[$j] = $tmp if ($max_length[$j] < 
  458.  ($tmp = length($data[$i][$j])));
  459.     }
  460.   }
  461.   if (!($nr_rows = $i))
  462.   {
  463.     return;
  464.   }
  465.   # Display data
  466.   if ($style == 0)
  467.   {
  468.     for ($i = 0; $i < $nr_rows; $i++)
  469.     {
  470.       if (!$i)
  471.       {
  472.         for ($j = 0; $j <= $nr_cols; $j++)
  473.         {
  474.           print "+"; print "-" x ($max_length[$j] + 2);
  475.         }
  476.         print "+n";
  477.       }
  478.       print "|";
  479.       for ($j = 0; $j <= $nr_cols; $j++)
  480.       {
  481.         print " ";
  482.         if (defined($data[$i][$j]))
  483.         {
  484.           print $data[$i][$j];
  485.   $tmp = length($data[$i][$j]);
  486.         }
  487. else
  488. {
  489.   print "NULL";
  490.   $tmp = 4;
  491. }
  492.         print " " x ($max_length[$j] - $tmp);
  493.         print " |";
  494.       }
  495.       print "n";
  496.       if (!$i)
  497.       {
  498.         for ($j = 0; $j <= $nr_cols; $j++)
  499.         {
  500.           print "+"; print "-" x ($max_length[$j] + 2);
  501.         }
  502.         print "+n";
  503.       }
  504.     }
  505.     for ($j = 0; $j <= $nr_cols; $j++)
  506.     {
  507.       print "+"; print "-" x ($max_length[$j] + 2);
  508.     }
  509.     print "+n";
  510.     return;
  511.   }
  512.   if ($style == 1)
  513.   {
  514.     for ($i = 0; $max_length[$i]; $i++)
  515.     {
  516.       $mxl = $max_length[$i] if ($mxl < $max_length[$i]);
  517.     }
  518.     for ($i = 1; $i < $nr_rows; $i++)
  519.     {
  520.       print "*" x 27;
  521.       print " " . $i . ". row ";
  522.       print "*" x 27;
  523.       print "n";
  524.       for ($j = 0; $j <= $nr_cols; $j++)
  525.       {
  526. print " " x ($mxl - length($data[0][$j]));
  527. print "$data[0][$j]: ";
  528. if (defined($data[$i][$j]))
  529. {
  530.   print "$data[$i][$j] n";
  531. }
  532. else
  533. {
  534.   print "NULLn";
  535. }
  536.       }
  537.     }
  538.     return;
  539.   }
  540. }
  541. ####
  542. #### usage
  543. ####
  544. sub usage
  545. {
  546.     print <<EOF;
  547. mysql-test $VER by Jani Tolonen
  548. Usage: mysql-test [options]
  549. Options:
  550. --help      Show this help
  551. --db=       Database to use (Default: $opt_db)
  552. --port=     TCP/IP port to use for connection (Default: $opt_port)
  553. --socket=   UNIX socket to use for connection (Default: $opt_socket)
  554. --host=     Connect to host (Default: $opt_host)
  555. --user=     User for login if not current user
  556. --password  Password to use when connecting to server
  557. --without=PART_NAME1,PART_NAME2,...  
  558.             test without a certain part of MySQL, optional parts listed below
  559. Optional parts:
  560. FUNC        Ignore MySQL basic functions
  561. PROC        Ignore MySQL procedure functions
  562. EOF
  563.   exit(0);
  564. }
  565. sub test_mysql_functions
  566. {
  567.   
  568.   ####
  569.   #### MySQL functions
  570.   ####
  571.   #### Types: S = string (or real number) , N = unsigned integer, Z = integer, 
  572.   ####        R = real number, T = time_stamp, E = no argument, D = date, 
  573.   ####        B = boolean, C = character
  574.   ####        F = format (usually used with the date-types)
  575.   ####        . = any number of the last argument type possible
  576.   ####        A = require table for test, the following argument 
  577.   ####            is the argument for the function
  578.   
  579.   # Muista get_lock,group_unique_users,
  580.   # position, unique_users
  581.   
  582.   # ks. kaikki date function, ker滗 yhteen, testaa erikseen
  583.   # adddate, date_add, subdate, date_sub, between, benchmark, count
  584.   # decode, encode, get_lock, make_set, position
  585.   
  586.   @functions = (["abs","R"],["acos","R"],["ascii","C"],["asin","R"],
  587. ["atan","R"],["atan2","R"],["avg","AR"],["bin","Z"],
  588. ["bit_count","Z"],["bit_or","AZ"],["bit_and","AZ"],
  589. ["ceiling","R"],["char","N."],["char_length","S"],
  590. ["concat","SS."],["conv","ZZZ"],
  591. ["cos","R"],["cot","R"],["curdate","E"],
  592. ["curtime","E"],["database","E"],["date_format","DF"],
  593. ["dayofmonth","D"],["dayofyear","D"],["dayname","D"],
  594. ["degrees","R"],["elt","NS."],["encode","SS"],
  595. ["encrypt","S"],["encrypt","SS"],["exp","R"],["field","SS."],
  596. ["find_in_set","SS"],["floor","R"],["format","RN"],
  597. ["from_days","N"],["from_unixtime","N"],
  598. ["from_unixtime","NF"],["greatest","RR."],["hex","Z"],
  599. ["hour","D"],["if","ZSS"],["ifnull","SS"],["insert","SNNS"],
  600. ["instr","SS"],["interval","RR."],["isnull","S"],
  601. ["last_insert_id","E"],["lcase","S"],["least","RR."],
  602. ["left","SN"],["length","S"],["locate","SS"],
  603. ["log","R"],["log10","R"],["lpad","SNS"],["ltrim","S"],
  604. ["max","AR"],["mid","SNN"],["min","AR"],["minute","D"],
  605. ["mod","ZZ"],["monthname","D"],
  606. ["month","D"],["now","E"],["oct","Z"],
  607. ["octet_length","S"],["password","S"],["period_add","DD"],
  608. ["period_diff","DD"],["pi","E"],
  609. ["pow","RR"],["quarter","D"],["radians","R"],
  610. ["rand","E"],["rand","R"],["release_lock","S"],
  611. ["repeat","SN"],["replace","SSS"],["reverse","S"],
  612. ["right","SN"],["round","R"],["round","RN"],
  613. ["rpad","SNS"],["rtrim","S"],["sec_to_time","N"],
  614. ["second","T"],["sign","R"],["sin","R"],
  615. ["space","N"],["soundex","S"],["sqrt","R"],["std","AR"],
  616. ["strcmp","SS"],["substring","SN"],["substring","SNN"],
  617. ["substring_index","SSZ"],["sum","AR"],
  618. ["tan","R"],["time_format","TF"],["time_to_sec","T"],
  619. ["to_days","D"],["trim","S"],
  620. ["truncate","RN"],["ucase","S"],
  621. ["unix_timestamp","E"],["unix_timestamp","D"],["user","E"],
  622. ["version","E"],["week","D"],["weekday","D"],["year","D"]);
  623.   ####
  624.   #### Various tests for the functions above
  625.   ####
  626.   
  627.   &exec_query(["drop table mysql_test1"], $MAY_ERR, $SILENT);
  628.   
  629.   $query .= <<EOF;
  630. create table mysql_test1 (
  631.   i int,
  632.   d double
  633. )
  634. EOF
  635.   chop($query);
  636.   &exec_query([$query], $NO_ERR, $SILENT);
  637.   
  638.   ####
  639.   #### Basic tests
  640.   ####
  641.   
  642.   printf("####n#### BASIC TESTS FOR FUNCTIONSn####nn");
  643.   @bunch = ("insert into mysql_test1 values(-20,-10.5),(20,10.5),(50,100.00)",
  644.     "insert into mysql_test1 values(100,500.333)");
  645.   &exec_query(@bunch, $NO_ERR, $SILENT);
  646.   
  647.   printf("n####n#### First basic test partn####nn");
  648.   @values = (["S", "'a'", "'abc'", "'abc def'", "'abcd'", "'QWERTY'", 
  649.       "'\\'", "'*.!"#