|
12 | 12 | # --let $statement= <STATEMENT> |
13 | 13 | # --let $output_file= {<FILE>|GENERATE} |
14 | 14 | # [--let $dont_print_statement= 1] |
| 15 | +# [--let $allow_error= 1] |
| 16 | +# [--let $append= 1] |
15 | 17 | # --source include/write_result_to_file.inc |
16 | 18 | # |
17 | 19 | # Parameters: |
|
27 | 29 | # By default, the statement is echoed to the result log. If the |
28 | 30 | # statement contains non-deterministic output, set this variable |
29 | 31 | # to suppress it. |
| 32 | +# |
| 33 | +# $allow_error |
| 34 | +# By default, this script causes the test to fail if the statement |
| 35 | +# generates an error. If $allow_error is set, errors are ignored. |
| 36 | +# |
| 37 | +# $append |
| 38 | +# By default, any existing file is overwritten. If $append is |
| 39 | +# specified, and the file exists, it appends to the file. |
30 | 40 |
|
31 | 41 | # Get the port and socket used by mysqld on current connection |
32 | 42 | --let _WRTF_SERVER_PORT= `SELECT @@PORT` |
@@ -58,19 +68,37 @@ if ($output_file == GENERATE) |
58 | 68 | } |
59 | 69 | --let _WRTF_OUTPUT_FILE= $output_file |
60 | 70 |
|
| 71 | +if ($allow_error) |
| 72 | +{ |
| 73 | + --let _WRTF_ALLOW_ERROR= 1 |
| 74 | +} |
| 75 | +if (!$allow_error) |
| 76 | +{ |
| 77 | + --let _WRTF_ALLOW_ERROR= 0 |
| 78 | +} |
| 79 | +if ($append) |
| 80 | +{ |
| 81 | + --let _WRTF_APPEND= 1 |
| 82 | +} |
| 83 | +if (!$append) |
| 84 | +{ |
| 85 | + --let _WRTF_APPEND= 0 |
| 86 | +} |
| 87 | + |
61 | 88 | perl; |
62 | 89 | use strict; |
63 | 90 | my $stmt= $ENV{'_WRTF_STATEMENT'}; |
64 | 91 | # Connecting mysql to same mysqld as current connectiona |
65 | 92 | # by overriding port and socket |
66 | | - my $mysql = $ENV{'MYSQL'}; |
| 93 | + my $mysql= $ENV{'MYSQL'}; |
67 | 94 | my $server_port= $ENV{'_WRTF_SERVER_PORT'}; |
68 | 95 | my $server_socket= $ENV{'_WRTF_SERVER_SOCKET'}; |
| 96 | + my $redirection_type= $ENV{'_WRTF_APPEND'} ? '>>' : '>'; |
69 | 97 | $mysql .= " --port=$server_port --socket=$server_socket"; |
70 | 98 | my $outfile = $ENV{'_WRTF_OUTPUT_FILE'}; |
71 | | - open MYSQL, "| $mysql > $outfile" or die "Failed to open MYSQL pipe: '$mysql > $outfile'"; |
| 99 | + open MYSQL, "| $mysql $redirection_type $outfile" or die "Failed to open MYSQL pipe: '$mysql > $outfile'"; |
72 | 100 | print MYSQL $stmt, ';' or die "Error printing statement to MYSQL pipe: $!"; |
73 | | - close MYSQL or die "Error closing MYSQL pipe: $!"; |
| 101 | + close MYSQL or $ENV{'_WRTF_ALLOW_ERROR'} or die "Error closing MYSQL pipe: $!"; |
74 | 102 | EOF |
75 | 103 |
|
76 | 104 | --let $include_filename= write_result_to_file.inc [$write_result_msg] |
|
0 commit comments