~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/lib/mtr_report.pl

  • Committer: Prafulla Tekawade
  • Date: 2010-07-13 16:07:35 UTC
  • mto: (1662.1.4 rollup)
  • mto: This revision was merged to the branch mainline in revision 1664.
  • Revision ID: prafulla_t@users.sourceforge.net-20100713160735-2fsdtrm3azayuyu1
This bug is simillar to mysql bug 36133
http://bugs.mysql.com/bug.php?id=36133

Taking changes from that fix.

  - The problem was that the range optimizer evaluated constant expressions, 
    and among them it would try to evaluate IN-subquery predicates slated for
    handling with materialization strategy. However, these predicates require
    that parent_join->setup_subquery_materialization() is invoked before one
    attempts to evaluate them.
  
  - Fixed by making the range optimizer not to evaluate expressions that have
    item->is_expensive() == TRUE (these are materialization subqueries and 
    stored function calls). This should also resolve the problem that EXPLAIN 
    may be too long. 
    This change cuts off some opportunities for range optimizer, but this is 
    the price we're willing to pay for separation of query optimization and
    execution. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- cperl -*-
 
2
# Copyright (C) 2004-2006 MySQL AB
 
3
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; version 2 of the License.
 
7
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
16
 
 
17
# This is a library file used by the Perl version of mysql-test-run,
 
18
# and is part of the translation of the Bourne shell script with the
 
19
# same name.
 
20
 
 
21
use strict;
 
22
use warnings;
 
23
 
 
24
sub mtr_report_test_name($);
 
25
sub mtr_report_test_passed($);
 
26
sub mtr_report_test_failed($);
 
27
sub mtr_report_test_skipped($);
 
28
sub mtr_report_test_not_skipped_though_disabled($);
 
29
 
 
30
sub mtr_report_stats ($);
 
31
sub mtr_print_line ();
 
32
sub mtr_print_thick_line ();
 
33
sub mtr_print_header ();
 
34
sub mtr_report (@);
 
35
sub mtr_warning (@);
 
36
sub mtr_error (@);
 
37
sub mtr_child_error (@);
 
38
sub mtr_debug (@);
 
39
sub mtr_verbose (@);
 
40
 
 
41
my $tot_real_time= 0;
 
42
 
 
43
 
 
44
 
 
45
##############################################################################
 
46
#
 
47
#  
 
48
#
 
49
##############################################################################
 
50
 
 
51
sub mtr_report_test_name ($) {
 
52
  my $tinfo= shift;
 
53
  my $tname= $tinfo->{name};
 
54
 
 
55
  $tname.= " '$tinfo->{combination}'"
 
56
    if defined $tinfo->{combination};
 
57
 
 
58
  _mtr_log($tname);
 
59
  if ($::opt_subunit) {
 
60
    printf "test: $tname\n";
 
61
  } else {
 
62
    printf "%-60s ", $tname;
 
63
  }
 
64
}
 
65
 
 
66
sub mtr_report_test_skipped ($) {
 
67
  my $tinfo= shift;
 
68
  my $tname= $tinfo->{name};
 
69
  my $cause= "";
 
70
 
 
71
  $tinfo->{'result'}= 'MTR_RES_SKIPPED';
 
72
  if ( $tinfo->{'disable'} )
 
73
  {
 
74
    $cause.= "disable";
 
75
  }
 
76
  else
 
77
  {
 
78
    $cause.= "skipped";
 
79
  }
 
80
  if ( $tinfo->{'comment'} )
 
81
  {
 
82
    if ($::opt_subunit) {
 
83
      mtr_report("skip: $tname [\ncause: $cause\n$tinfo->{'comment'}\n]");
 
84
    } else { 
 
85
      mtr_report("[ $cause ]   $tinfo->{'comment'}");
 
86
    }
 
87
  }
 
88
  else
 
89
  {
 
90
    if ($::opt_subunit) {
 
91
      mtr_report("skip: $tname");
 
92
    } else {
 
93
      mtr_report("[ $cause ]");
 
94
    }
 
95
  }
 
96
}
 
97
 
 
98
sub mtr_report_tests_not_skipped_though_disabled ($) {
 
99
  my $tests= shift;
 
100
 
 
101
  if ( $::opt_enable_disabled )
 
102
  {
 
103
    my @disabled_tests= grep {$_->{'dont_skip_though_disabled'}} @$tests;
 
104
    if ( @disabled_tests )
 
105
    {
 
106
      print "\nTest(s) which will be run though they are marked as disabled:\n";
 
107
      foreach my $tinfo ( sort {$a->{'name'} cmp $b->{'name'}} @disabled_tests )
 
108
      {
 
109
        printf "  %-20s : %s\n", $tinfo->{'name'}, $tinfo->{'comment'};
 
110
      }
 
111
    }
 
112
  }
 
113
}
 
114
 
 
115
sub mtr_report_test_passed ($) {
 
116
  my $tinfo= shift;
 
117
  my $tname= $tinfo->{name};
 
118
 
 
119
  my $timer=  "";
 
120
  if ( $::opt_timer and -f "$::opt_vardir/log/timer" )
 
121
  {
 
122
    $timer= mtr_fromfile("$::opt_vardir/log/timer");
 
123
    $tot_real_time += ($timer/1000);
 
124
    $timer= sprintf "%7s", $timer;
 
125
    ### XXX: How to format this as iso6801 datetime?
 
126
  }
 
127
  $tinfo->{'result'}= 'MTR_RES_PASSED';
 
128
  if ($::opt_subunit) {
 
129
    mtr_report("success: $tname");
 
130
  } else {
 
131
    mtr_report("[ pass ] $timer");
 
132
  }
 
133
}
 
134
 
 
135
sub mtr_report_test_failed ($) {
 
136
  my $tinfo= shift;
 
137
  my $tname= $tinfo->{name};
 
138
  my $comment= "";
 
139
 
 
140
  $tinfo->{'result'}= 'MTR_RES_FAILED';
 
141
  if ( defined $tinfo->{'timeout'} )
 
142
  {
 
143
    $comment.= "timeout";
 
144
  }
 
145
  elsif ( $tinfo->{'comment'} )
 
146
  {
 
147
    # The test failure has been detected by mysql-test-run.pl
 
148
    # when starting the servers or due to other error, the reason for
 
149
    # failing the test is saved in "comment"
 
150
    $comment.= "$tinfo->{'comment'}";
 
151
  }
 
152
  elsif ( -f $::path_timefile )
 
153
  {
 
154
    # Test failure was detected by test tool and it's report
 
155
    # about what failed has been saved to file. Display the report.
 
156
    $comment.= mtr_fromfile($::path_timefile);
 
157
  }
 
158
  else
 
159
  {
 
160
    # Neither this script or the test tool has recorded info
 
161
    # about why the test has failed. Should be debugged.
 
162
    $comment.= "Unexpected termination, probably when starting mysqld";
 
163
  }
 
164
  if ($::opt_subunit) {
 
165
    mtr_report("failure: $tname [\n$comment\n]");
 
166
  } else {
 
167
    mtr_report("[ fail ]\n$comment");
 
168
  }
 
169
}
 
170
 
 
171
sub mtr_report_stats ($) {
 
172
  my $tests= shift;
 
173
 
 
174
  # ----------------------------------------------------------------------
 
175
  # Find out how we where doing
 
176
  # ----------------------------------------------------------------------
 
177
 
 
178
  my $tot_skiped= 0;
 
179
  my $tot_passed= 0;
 
180
  my $tot_failed= 0;
 
181
  my $tot_tests=  0;
 
182
  my $tot_restarts= 0;
 
183
  my $found_problems= 0; # Some warnings in the logfiles are errors...
 
184
 
 
185
  foreach my $tinfo (@$tests)
 
186
  {
 
187
    if ( $tinfo->{'result'} eq 'MTR_RES_SKIPPED' )
 
188
    {
 
189
      $tot_skiped++;
 
190
    }
 
191
    elsif ( $tinfo->{'result'} eq 'MTR_RES_PASSED' )
 
192
    {
 
193
      $tot_tests++;
 
194
      $tot_passed++;
 
195
    }
 
196
    elsif ( $tinfo->{'result'} eq 'MTR_RES_FAILED' )
 
197
    {
 
198
      $tot_tests++;
 
199
      $tot_failed++;
 
200
    }
 
201
    if ( $tinfo->{'restarted'} )
 
202
    {
 
203
      $tot_restarts++;
 
204
    }
 
205
  }
 
206
 
 
207
  # ----------------------------------------------------------------------
 
208
  # Print out a summary report to screen
 
209
  # ----------------------------------------------------------------------
 
210
 
 
211
  if ( ! $tot_failed )
 
212
  {
 
213
    print "All $tot_tests tests were successful.\n";
 
214
  }
 
215
  else
 
216
  {
 
217
    my $ratio=  $tot_passed * 100 / $tot_tests;
 
218
    print "Failed $tot_failed/$tot_tests tests, ";
 
219
    printf("%.2f", $ratio);
 
220
    print "\% were successful.\n\n";
 
221
    print
 
222
      "The log files in var/log may give you some hint\n",
 
223
      "of what went wrong.\n",
 
224
      "If you want to report this error, go to:\n",
 
225
      "\thttp://bugs.launchpad.net/drizzle\n";
 
226
  }
 
227
  if (!$::opt_extern)
 
228
  {
 
229
    print "The servers were restarted $tot_restarts times\n";
 
230
  }
 
231
 
 
232
  if ( $::opt_timer )
 
233
  {
 
234
    use English;
 
235
 
 
236
    mtr_report("Spent", sprintf("%.3f", $tot_real_time),"of",
 
237
               time - $BASETIME, "seconds executing testcases");
 
238
  }
 
239
 
 
240
  print "\n";
 
241
 
 
242
  # Print a list of testcases that failed
 
243
  if ( $tot_failed != 0 )
 
244
  {
 
245
    my $test_mode= join(" ", @::glob_test_mode) || "default";
 
246
    print "mysql-test-run in $test_mode mode: *** Failing the test(s):";
 
247
 
 
248
    foreach my $tinfo (@$tests)
 
249
    {
 
250
      if ( $tinfo->{'result'} eq 'MTR_RES_FAILED' )
 
251
      {
 
252
        print " $tinfo->{'name'}";
 
253
      }
 
254
    }
 
255
    print "\n";
 
256
 
 
257
  }
 
258
 
 
259
  # Print a list of check_testcases that failed(if any)
 
260
  if ( $::opt_check_testcases )
 
261
  {
 
262
    my @check_testcases= ();
 
263
 
 
264
    foreach my $tinfo (@$tests)
 
265
    {
 
266
      if ( defined $tinfo->{'check_testcase_failed'} )
 
267
      {
 
268
        push(@check_testcases, $tinfo->{'name'});
 
269
      }
 
270
    }
 
271
 
 
272
    if ( @check_testcases )
 
273
    {
 
274
      print "Check of testcase failed for: ";
 
275
      print join(" ", @check_testcases);
 
276
      print "\n\n";
 
277
    }
 
278
  }
 
279
 
 
280
  if ( $tot_failed != 0 || $found_problems)
 
281
  {
 
282
    mtr_error("there were failing test cases");
 
283
  }
 
284
}
 
285
 
 
286
##############################################################################
 
287
#
 
288
#  Text formatting
 
289
#
 
290
##############################################################################
 
291
 
 
292
sub mtr_print_line () {
 
293
  print '-' x 80, "\n";
 
294
}
 
295
 
 
296
sub mtr_print_thick_line () {
 
297
  print '=' x 80, "\n";
 
298
}
 
299
 
 
300
sub mtr_print_header () {
 
301
  print "DEFAULT STORAGE ENGINE: $::opt_engine\n";
 
302
  if ( $::opt_timer )
 
303
  {
 
304
    printf "%-61s%-9s%10s\n","TEST","RESULT","TIME (ms)";
 
305
  }
 
306
  else
 
307
  {
 
308
    print "TEST                           RESULT\n";
 
309
  }
 
310
  mtr_print_line();
 
311
  print "\n";
 
312
}
 
313
 
 
314
 
 
315
##############################################################################
 
316
#
 
317
#  Log and reporting functions
 
318
#
 
319
##############################################################################
 
320
 
 
321
use IO::File;
 
322
 
 
323
my $log_file_ref= undef;
 
324
 
 
325
sub mtr_log_init ($) {
 
326
  my ($filename)= @_;
 
327
 
 
328
  mtr_error("Log is already open") if defined $log_file_ref;
 
329
 
 
330
  $log_file_ref= IO::File->new($filename, "a") or
 
331
    mtr_warning("Could not create logfile $filename: $!");
 
332
}
 
333
 
 
334
sub _mtr_log (@) {
 
335
  print $log_file_ref join(" ", @_),"\n"
 
336
    if defined $log_file_ref;
 
337
}
 
338
 
 
339
sub mtr_report (@) {
 
340
  # Print message to screen and log
 
341
  _mtr_log(@_);
 
342
  print join(" ", @_),"\n";
 
343
}
 
344
 
 
345
sub mtr_warning (@) {
 
346
  # Print message to screen and log
 
347
  _mtr_log("WARNING: ", @_);
 
348
  print STDERR "mysql-test-run: WARNING: ",join(" ", @_),"\n";
 
349
}
 
350
 
 
351
sub mtr_error (@) {
 
352
  # Print message to screen and log
 
353
  _mtr_log("ERROR: ", @_);
 
354
  print STDERR "mysql-test-run: *** ERROR: ",join(" ", @_),"\n";
 
355
  mtr_exit(1);
 
356
}
 
357
 
 
358
sub mtr_child_error (@) {
 
359
  # Print message to screen and log
 
360
  _mtr_log("ERROR(child): ", @_);
 
361
  print STDERR "mysql-test-run: *** ERROR(child): ",join(" ", @_),"\n";
 
362
  exit(1);
 
363
}
 
364
 
 
365
sub mtr_debug (@) {
 
366
  # Only print if --script-debug is used
 
367
  if ( $::opt_script_debug )
 
368
  {
 
369
    _mtr_log("###: ", @_);
 
370
    print STDERR "####: ",join(" ", @_),"\n";
 
371
  }
 
372
}
 
373
 
 
374
sub mtr_verbose (@) {
 
375
  # Always print to log, print to screen only when --verbose is used
 
376
  _mtr_log("> ",@_);
 
377
  if ( $::opt_verbose )
 
378
  {
 
379
    print STDERR "> ",join(" ", @_),"\n";
 
380
  }
 
381
}
 
382
 
 
383
1;