~eday/drizzle/eday-dev

« back to all changes in this revision

Viewing changes to tests/misc/mysql-test_V1.9.pl

  • Committer: Eric Day
  • Date: 2010-01-07 20:02:38 UTC
  • mfrom: (971.3.291 staging)
  • Revision ID: eday@oddments.org-20100107200238-uqw8v6kv9pl7nny5
Merged trunk.

Show diffs side-by-side

added added

removed removed

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