mysqltest reads input lines and processes them as follows:
“End of line” means a newline (linefeed) character. A carriage return/linefeed (CRLF) pair also is allowable as as a line terminator (the carriage return is ignored). Carriage return by itself is not allowed as a line terminator.
A line that begins with “#
” as
the first nonwhitespace content is treated as a comment that
extends to the end of the line and is ignored. Example:
# this is a comment
Earlier versions would also allow comments beginning with
“--
” unless he first word was
a valid mysqltest command, but this has
been deprecated and is longer allowed.
Other input is taken as normal command input. The command
extends to the next occurrence of the command delimiter, which
is semicolon (“;
”) by default.
The delimiter can be changed with the
delimiter
command.
If mysqltest recognizes the first word of the delimiter-terminated command, mysqltest executes the command itself. Otherwise, mysqltest assumes that the command is an SQL statement and sends it to the MySQL server to be executed.
Because the command extends to the delimiter, a given input
line can contain multiple commands, and a given command can
span multiple lines. The ability to write multiple-line
statements is useful for making long statements more readable,
such as a create table
statement for a
table that has many columns.
After mysqltest reads a command up to a delimiter and executes it, input reading restarts following the delimiter and any remaining input on the line that contains the delimiter is treated as though it begins on a new line. Consider the following two input lines:
echo issue a select statement; select 1; echo done issuing the select statement;
That input contains two commands and one SQL statement:
echo issue a SELECT statement SELECT 1; echo done issuing the SELECT statement
Similarly, “#
” comments can begin
on a command line following a delimiter:
SELECT 'hello'; # select a string value
On a multiple-line command, “#
” or
“--
” at the beginning of the
second or following lines is not special. Thus, the second and
third lines of the following variable-assignment command are not
taken as comments. Instead, the variable $a
is
set to a value that contains two linefeed characters:
let $a= This is a variable # assignment that sets a variable -- to a multiple-line value;
Note that “--
” commands and normal
commands have complementary properties with regard to how
mysqltest reads them:
A “--
” command is terminated
by a newline, regardless of how many delimiters it contains.
A normal command (without
“--
”) is terminated by the
delimiter (semicolon), no matter how many newlines it
contains.
mysqltest commands can be written either with a
leading “--
”) or as normal command
input (no leading “--
”). Use the
command delimiter only in the latter case. Thus, these two lines
are equivalent:
--sleep 2 sleep 2;
The equivalence is true even for the delimiter
command. For example, to set the delimiter to
“//
”, either of these commands
work:
--delimiter // delimiter //;
To set the delimiter back to “;”, use either of these commands:
--delimiter ; delimiter ;//
A potential ambiguity occurs because a command line can contain either a mysqltest command or an SQL statement. This has a couple of implications:
Any ambiguity can be resolved by using the
“--
” syntax to force interpetation
as a mysqltest command, or the
query command to force interpretation as SQL.
All file paths used in test commands should use forward slash
"/"
as the directory separator as in Unix. They
will be automatically converted when needed if the test is run on
Windows. We also recommend putting all temporary or auxiliary
files made during the test under the directories referred to by
$MYSQLTEST_VARDIR
or
$MYSQL_TMP_DIR
(the latter is equivalent to
$MYSQLTEST_VARDIR/tmp
). Do not put them under
fixed full paths like /tmp
. This will help
ensuring portability of the test, and avoiding conflicts with
other programs.