summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/mysqltest.cc81
1 files changed, 45 insertions, 36 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 43107d838ee..d3181fea522 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -1117,7 +1117,7 @@ void close_files()
if (cur_file->file && cur_file->file != stdin)
{
DBUG_PRINT("info", ("closing file: %s", cur_file->file_name));
- my_fclose(cur_file->file, MYF(0));
+ fclose(cur_file->file);
}
my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
cur_file->file_name= 0;
@@ -2491,7 +2491,7 @@ int open_file(const char *name)
if (cur_file == file_stack_end)
die("Source directives are nesting too deep");
cur_file++;
- if (!(cur_file->file = my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0))))
+ if (!(cur_file->file = fopen(buff, "rb")))
{
cur_file--;
die("Could not open '%s' for reading, errno: %d", buff, errno);
@@ -3686,49 +3686,58 @@ void do_perl(struct st_command *command)
sizeof(perl_args)/sizeof(struct command_arg),
' ');
- /* If no delimiter was provided, use EOF */
- if (ds_delimiter.length == 0)
- dynstr_set(&ds_delimiter, "EOF");
+ ds_script= command->content;
+ /* If it hasn't been done already by a loop iteration, fill it in */
+ if (! ds_script.str)
+ {
+ /* If no delimiter was provided, use EOF */
+ if (ds_delimiter.length == 0)
+ dynstr_set(&ds_delimiter, "EOF");
- init_dynamic_string(&ds_script, "", 1024, 1024);
- read_until_delimiter(&ds_script, &ds_delimiter);
+ init_dynamic_string(&ds_script, "", 1024, 1024);
+ read_until_delimiter(&ds_script, &ds_delimiter);
+ command->content= ds_script;
+ }
- DBUG_PRINT("info", ("Executing perl: %s", ds_script.str));
+ /* This function could be called even if "false", so check before doing */
+ if (cur_block->ok)
+ {
+ DBUG_PRINT("info", ("Executing perl: %s", ds_script.str));
- /* Create temporary file name */
- if ((fd= create_temp_file(temp_file_path, getenv("MYSQLTEST_VARDIR"),
- "tmp", O_CREAT | O_SHARE | O_RDWR,
- MYF(MY_WME))) < 0)
- die("Failed to create temporary file for perl command");
- my_close(fd, MYF(0));
+ /* Create temporary file name */
+ if ((fd= create_temp_file(temp_file_path, getenv("MYSQLTEST_VARDIR"),
+ "tmp", O_CREAT | O_SHARE | O_RDWR,
+ MYF(MY_WME))) < 0)
+ die("Failed to create temporary file for perl command");
+ my_close(fd, MYF(0));
- str_to_file(temp_file_path, ds_script.str, ds_script.length);
+ str_to_file(temp_file_path, ds_script.str, ds_script.length);
- /* Format the "perl <filename>" command */
- my_snprintf(buf, sizeof(buf), "perl %s", temp_file_path);
+ /* Format the "perl <filename>" command */
+ my_snprintf(buf, sizeof(buf), "perl %s", temp_file_path);
- if (!(res_file= popen(buf, "r")) && command->abort_on_error)
- die("popen(\"%s\", \"r\") failed", buf);
+ if (!(res_file= popen(buf, "r")) && command->abort_on_error)
+ die("popen(\"%s\", \"r\") failed", buf);
- while (fgets(buf, sizeof(buf), res_file))
- {
- if (disable_result_log)
- {
- buf[strlen(buf)-1]=0;
- DBUG_PRINT("exec_result",("%s", buf));
- }
- else
+ while (fgets(buf, sizeof(buf), res_file))
{
- replace_dynstr_append(&ds_res, buf);
+ if (disable_result_log)
+ {
+ buf[strlen(buf)-1]=0;
+ DBUG_PRINT("exec_result",("%s", buf));
+ }
+ else
+ {
+ replace_dynstr_append(&ds_res, buf);
+ }
}
- }
- error= pclose(res_file);
+ error= pclose(res_file);
- /* Remove the temporary file */
- my_delete(temp_file_path, MYF(0));
+ /* Remove the temporary file */
+ my_delete(temp_file_path, MYF(0));
- handle_command_error(command, WEXITSTATUS(error));
- dynstr_free(&ds_script);
+ handle_command_error(command, WEXITSTATUS(error));
+ }
dynstr_free(&ds_delimiter);
DBUG_VOID_RETURN;
}
@@ -5348,7 +5357,7 @@ int read_line(char *buf, int size)
found_eof:
if (cur_file->file != stdin)
{
- my_fclose(cur_file->file, MYF(0));
+ fclose(cur_file->file);
cur_file->file= 0;
}
my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
@@ -5960,7 +5969,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
if (!(cur_file->file=
- my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0))))
+ fopen(buff, "rb")))
die("Could not open '%s' for reading, errno: %d", buff, errno);
cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
cur_file->lineno= 1;