Remove extra newline added to files created by write_file and append_file

parent 86658784
...@@ -753,6 +753,15 @@ void check_command_args(struct st_command *command, ...@@ -753,6 +753,15 @@ void check_command_args(struct st_command *command,
command->first_word_len, command->query); command->first_word_len, command->query);
} }
/* Check for too many arguments passed */
ptr= command->last_argument;
while(ptr <= command->end)
{
if (*ptr && *ptr != ' ')
die("Extra argument '%s' passed to '%.*s'",
ptr, command->first_word_len, command->query);
ptr++;
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -2691,8 +2700,22 @@ void read_until_delimiter(DYNAMIC_STRING *ds, ...@@ -2691,8 +2700,22 @@ void read_until_delimiter(DYNAMIC_STRING *ds,
c= my_getc(cur_file->file); c= my_getc(cur_file->file);
if (c == '\n') if (c == '\n')
{
cur_file->lineno++; cur_file->lineno++;
/* Skip newline from the same line as the command */
if (start_lineno == (cur_file->lineno - 1))
continue;
}
else if (start_lineno == cur_file->lineno)
{
/*
No characters except \n are allowed on
the same line as the command
*/
die("Trailing characters found after command");
}
if (feof(cur_file->file)) if (feof(cur_file->file))
die("End of file encountered before '%s' delimiter was found", die("End of file encountered before '%s' delimiter was found",
ds_delimiter->str); ds_delimiter->str);
......
...@@ -533,6 +533,7 @@ drop table t1; ...@@ -533,6 +533,7 @@ drop table t1;
mysqltest: At line 1: Missing required argument 'filename' to command 'remove_file' mysqltest: At line 1: Missing required argument 'filename' to command 'remove_file'
mysqltest: At line 1: Missing required argument 'filename' to command 'write_file' mysqltest: At line 1: Missing required argument 'filename' to command 'write_file'
mysqltest: At line 1: End of file encountered before 'EOF' delimiter was found mysqltest: At line 1: End of file encountered before 'EOF' delimiter was found
Content for test_file1
Some data Some data
for cat_file command for cat_file command
of mysqltest of mysqltest
......
...@@ -1564,6 +1564,7 @@ write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; ...@@ -1564,6 +1564,7 @@ write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
Content for test_file1 Content for test_file1
EOF EOF
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp END_DELIMITER; write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp END_DELIMITER;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment