Commit 2742e50c authored by Bjorn Munch's avatar Bjorn Munch

merge from 5.5-mtr

parents 66e675c4 d3d436f0
......@@ -487,7 +487,8 @@ VAR* var_init(VAR* v, const char *name, int name_len, const char *val,
int val_len);
VAR* var_get(const char *var_name, const char** var_name_end,
my_bool raw, my_bool ignore_not_existing);
void eval_expr(VAR* v, const char *p, const char** p_end);
void eval_expr(VAR* v, const char *p, const char** p_end,
bool open_end=false, bool backtick=true);
my_bool match_delimiter(int c, const char *delim, uint length);
void dump_result_to_reject_file(char *buf, int size);
void dump_warning_messages();
......@@ -2045,9 +2046,11 @@ static void var_free(void *v)
C_MODE_END
void var_set_int(VAR *v, const char *str)
void var_check_int(VAR *v)
{
char *endptr;
char *str= v->str_val;
/* Initially assume not a number */
v->int_val= 0;
v->is_int= false;
......@@ -2094,7 +2097,7 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
memcpy(tmp_var->str_val, val, val_len);
tmp_var->str_val[val_len]= 0;
}
var_set_int(tmp_var, val);
var_check_int(tmp_var);
tmp_var->name_len = name_len;
tmp_var->str_val_len = val_len;
tmp_var->alloced_len = val_alloc_len;
......@@ -2335,7 +2338,8 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
dynstr_append_mem(&result, "\t", 1);
}
end= result.str + result.length-1;
eval_expr(var, result.str, (const char**) &end);
/* Evaluation should not recurse via backtick */
eval_expr(var, result.str, (const char**) &end, false, false);
dynstr_free(&result);
}
else
......@@ -2545,7 +2549,8 @@ void var_copy(VAR *dest, VAR *src)
}
void eval_expr(VAR *v, const char *p, const char **p_end)
void eval_expr(VAR *v, const char *p, const char **p_end,
bool open_end, bool backtick)
{
DBUG_ENTER("eval_expr");
......@@ -2563,14 +2568,14 @@ void eval_expr(VAR *v, const char *p, const char **p_end)
/* Make sure there was just a $variable and nothing else */
const char* end= *p_end + 1;
if (end < expected_end)
if (end < expected_end && !open_end)
die("Found junk '%.*s' after $variable in expression",
(int)(expected_end - end - 1), end);
DBUG_VOID_RETURN;
}
if (*p == '`')
if (*p == '`' && backtick)
{
var_query_set(v, p, p_end);
DBUG_VOID_RETURN;
......@@ -2610,7 +2615,7 @@ void eval_expr(VAR *v, const char *p, const char **p_end)
v->str_val_len = new_val_len;
memcpy(v->str_val, p, new_val_len);
v->str_val[new_val_len] = 0;
var_set_int(v, p);
var_check_int(v);
}
DBUG_VOID_RETURN;
}
......@@ -4240,7 +4245,7 @@ int do_save_master_pos()
const char latest_applied_binlog_epoch_str[]=
"latest_applied_binlog_epoch=";
if (count)
sleep(1);
my_sleep(100*1000); /* 100ms */
if (mysql_query(mysql, query= "show engine ndb status"))
die("failed in '%s': %d %s", query,
mysql_errno(mysql), mysql_error(mysql));
......@@ -4329,7 +4334,7 @@ int do_save_master_pos()
count++;
if (latest_handled_binlog_epoch >= start_epoch)
do_continue= 0;
else if (count > 30)
else if (count > 300) /* 30s */
{
break;
}
......@@ -5521,6 +5526,40 @@ int do_done(struct st_command *command)
return 0;
}
/* Operands available in if or while conditions */
enum block_op {
EQ_OP,
NE_OP,
GT_OP,
GE_OP,
LT_OP,
LE_OP,
ILLEG_OP
};
enum block_op find_operand(const char *start)
{
char first= *start;
char next= *(start+1);
if (first == '=' && next == '=')
return EQ_OP;
if (first == '!' && next == '=')
return NE_OP;
if (first == '>' && next == '=')
return GE_OP;
if (first == '>')
return GT_OP;
if (first == '<' && next == '=')
return LE_OP;
if (first == '<')
return LT_OP;
return ILLEG_OP;
}
/*
Process start of a "if" or "while" statement
......@@ -5546,6 +5585,13 @@ int do_done(struct st_command *command)
A '!' can be used before the <expr> to indicate it should
be executed if it evaluates to zero.
<expr> can also be a simple comparison condition:
<variable> <op> <expr>
The left hand side must be a variable, the right hand side can be a
variable, number, string or `query`. Operands are ==, !=, <, <=, >, >=.
== and != can be used for strings, all can be used for numerical values.
*/
void do_block(enum block_cmd cmd, struct st_command* command)
......@@ -5581,11 +5627,16 @@ void do_block(enum block_cmd cmd, struct st_command* command)
if (!expr_start++)
die("missing '(' in %s", cmd_name);
while (my_isspace(charset_info, *expr_start))
expr_start++;
/* Check for !<expr> */
if (*expr_start == '!')
{
not_expr= TRUE;
expr_start++; /* Step past the '!' */
expr_start++; /* Step past the '!', then any whitespace */
while (*expr_start && my_isspace(charset_info, *expr_start))
expr_start++;
}
/* Find ending ')' */
expr_end= strrchr(expr_start, ')');
......@@ -5599,14 +5650,94 @@ void do_block(enum block_cmd cmd, struct st_command* command)
die("Missing '{' after %s. Found \"%s\"", cmd_name, p);
var_init(&v,0,0,0,0);
eval_expr(&v, expr_start, &expr_end);
/* If expression starts with a variable, it may be a compare condition */
if (*expr_start == '$')
{
const char *curr_ptr= expr_end;
eval_expr(&v, expr_start, &curr_ptr, true);
while (my_isspace(charset_info, *++curr_ptr))
{}
/* If there was nothing past the variable, skip condition part */
if (curr_ptr == expr_end)
goto NO_COMPARE;
enum block_op operand= find_operand(curr_ptr);
if (operand == ILLEG_OP)
die("Found junk '%.*s' after $variable in condition",
(int)(expr_end - curr_ptr), curr_ptr);
/* We could silently allow this, but may be confusing */
if (not_expr)
die("Negation and comparison should not be combined, please rewrite");
/* Skip the 1 or 2 chars of the operand, then white space */
if (operand == LT_OP || operand == GT_OP)
{
curr_ptr++;
}
else
{
curr_ptr+= 2;
}
while (my_isspace(charset_info, *curr_ptr))
curr_ptr++;
VAR v2;
var_init(&v2,0,0,0,0);
eval_expr(&v2, curr_ptr, &expr_end);
if ((operand!=EQ_OP && operand!=NE_OP) && ! (v.is_int && v2.is_int))
die ("Only == and != are supported for string values");
/* Now we overwrite the first variable with 0 or 1 (for false or true) */
switch (operand)
{
case EQ_OP:
if (v.is_int)
v.int_val= (v2.is_int && v2.int_val == v.int_val);
else
v.int_val= !strcmp (v.str_val, v2.str_val);
break;
case NE_OP:
if (v.is_int)
v.int_val= ! (v2.is_int && v2.int_val == v.int_val);
else
v.int_val= (strcmp (v.str_val, v2.str_val) != 0);
break;
case LT_OP:
v.int_val= (v.int_val < v2.int_val);
break;
case LE_OP:
v.int_val= (v.int_val <= v2.int_val);
break;
case GT_OP:
v.int_val= (v.int_val > v2.int_val);
break;
case GE_OP:
v.int_val= (v.int_val >= v2.int_val);
break;
}
v.is_int= TRUE;
} else
{
if (*expr_start != '`' && ! my_isdigit(charset_info, *expr_start))
die("Expression in if/while must beging with $, ` or a number");
eval_expr(&v, expr_start, &expr_end);
}
NO_COMPARE:
/* Define inner block */
cur_block++;
cur_block->cmd= cmd;
if (v.int_val)
if (v.is_int)
{
cur_block->ok= TRUE;
cur_block->ok= (v.int_val != 0);
} else
/* Any non-empty string which does not begin with 0 is also TRUE */
{
......
......@@ -12,13 +12,13 @@ eval CREATE TABLE t1 (a INT) ENGINE=$engine;
eval CREATE TABLE t2 (a INT) ENGINE=$engine;
INSERT INTO t2 VALUES (1),(2),(3);
let $binlog_start = query_get_value("SHOW MASTER STATUS", Position, 1);
if (`select length('$before_truncate') > 0`) {
if ($before_truncate) {
eval $before_truncate;
}
--echo **** Truncate of empty table shall be logged
TRUNCATE TABLE t1;
if (`select length('$before_truncate') > 0`) {
if ($before_truncate) {
eval $before_truncate;
}
TRUNCATE TABLE t2;
......@@ -35,7 +35,7 @@ eval CREATE TABLE t2 (a INT) ENGINE=$engine;
INSERT INTO t1 VALUES (1),(2);
let $binlog_start = query_get_value("SHOW MASTER STATUS", Position, 1);
if (`select length('$before_truncate') > 0`) {
if ($before_truncate) {
eval $before_truncate;
}
......
......@@ -173,7 +173,7 @@ insert into t1 values(2);
rollback;
let $master_log_pos_2= query_get_value(SHOW MASTER STATUS, Position, 1);
if (`SELECT $master_log_pos_2 <> $master_log_pos_1`)
if ($master_log_pos_2 != $master_log_pos_1)
{
echo $master_log_pos_1 $master_log_pos_2;
die Rollbacked transaction has been binlogged;
......
......@@ -319,7 +319,7 @@ if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
{
--let $binlog_rollback= query_get_value(SHOW BINLOG EVENTS, Pos, 7)
--let $binlog_query= query_get_value(SHOW BINLOG EVENTS, Info, 7)
if (`SELECT 'ROLLBACK' != '$binlog_query'`) {
if ($binlog_query != ROLLBACK) {
--echo Wrong query from SHOW BINLOG EVENTS. Expected ROLLBACK, got '$binlog_query'
--source include/show_rpl_debug_info.inc
--die Wrong value for slave parameter
......
......@@ -167,7 +167,9 @@
--let $CRC_create=
######## func_retval ########
if (`SELECT $CRC_ARG_type = 0 AND '$CRC_ARG_value' != ''`) {
# if inside if in lieu of AND operand
if ($CRC_ARG_type == 0) {
if ($CRC_ARG_value) {
# It will be safe to call this function and discard the return
# value, but it will be unsafe to use return value (e.g., in
# INSERT...SELECT).
......@@ -180,10 +182,11 @@ if (`SELECT $CRC_ARG_type = 0 AND '$CRC_ARG_value' != ''`) {
--let $CRC_RET_drop= DROP FUNCTION $CRC_name
--let $CRC_RET_is_toplevel= 0
--let $CRC_RET_desc= function $CRC_name returning value from $CRC_ARG_desc
}
}
######## func_sidef ########
if (`SELECT $CRC_ARG_type = 1`) {
if ($CRC_ARG_type == 1) {
# It will be unsafe to call func even if you discard return value.
--let $CRC_name= func_sidef_$CRC_ARG_level
--let $CRC_create= CREATE FUNCTION $CRC_name() RETURNS VARCHAR(100) BEGIN INSERT INTO ta$CRC_ARG_level VALUES (47); $CRC_ARG_stmt_sidef; RETURN 0; END
......@@ -197,7 +200,7 @@ if (`SELECT $CRC_ARG_type = 1`) {
}
######## proc ########
if (`SELECT $CRC_ARG_type = 2`) {
if ($CRC_ARG_type == 2) {
# It will be unsafe to call this procedure.
--let $CRC_name= proc_$CRC_ARG_level
--let $CRC_create= CREATE PROCEDURE $CRC_name() BEGIN $CRC_ARG_stmt_sidef; INSERT INTO ta$CRC_ARG_level VALUES (47); END
......@@ -211,7 +214,7 @@ if (`SELECT $CRC_ARG_type = 2`) {
}
######## trig ########
if (`SELECT $CRC_ARG_type = 3`) {
if ($CRC_ARG_type == 3) {
# It will be unsafe to invoke this trigger.
--let $CRC_name= trig_$CRC_ARG_level
--let $CRC_create= CREATE TRIGGER $CRC_name BEFORE INSERT ON trigger_table_$CRC_ARG_level FOR EACH ROW BEGIN INSERT INTO ta$CRC_ARG_level VALUES (47); $CRC_ARG_stmt_sidef; END
......@@ -225,7 +228,8 @@ if (`SELECT $CRC_ARG_type = 3`) {
}
######## view_retval ########
if (`SELECT $CRC_ARG_type = 4 AND '$CRC_ARG_sel_retval' != ''`) {
if ($CRC_ARG_type == 4) {
if ($CRC_ARG_sel_retval) {
# It will be safe to select from this view if you discard the result
# set, but unsafe to use result set (e.g., in INSERT..SELECT).
--let $CRC_name= view_retval_$CRC_ARG_level
......@@ -237,10 +241,12 @@ if (`SELECT $CRC_ARG_type = 4 AND '$CRC_ARG_sel_retval' != ''`) {
--let $CRC_RET_drop= DROP VIEW $CRC_name
--let $CRC_RET_is_toplevel= 0
--let $CRC_RET_desc= view $CRC_name returning value from $CRC_ARG_desc
}
}
######## view_sidef ########
if (`SELECT $CRC_ARG_type = 5 AND '$CRC_ARG_sel_sidef' != ''`) {
if ($CRC_ARG_type == 5) {
if ($CRC_ARG_sel_sidef) {
# It will be unsafe to select from this view, even if you discard
# the return value.
--let $CRC_name= view_sidef_$CRC_ARG_level
......@@ -252,10 +258,11 @@ if (`SELECT $CRC_ARG_type = 5 AND '$CRC_ARG_sel_sidef' != ''`) {
--let $CRC_RET_drop= DROP VIEW $CRC_name
--let $CRC_RET_is_toplevel= 0
--let $CRC_RET_desc= view $CRC_name invoking $CRC_ARG_desc
}
}
######## prep ########
if (`SELECT $CRC_ARG_type = 6`) {
if ($CRC_ARG_type == 6) {
# It will be unsafe to execute this prepared statement
--let $CRC_name= prep_$CRC_ARG_level
--let $CRC_create= PREPARE $CRC_name FROM "$CRC_ARG_stmt_sidef"
......@@ -269,7 +276,7 @@ if (`SELECT $CRC_ARG_type = 6`) {
}
######## no recursive construct: just return the given statement ########
if (`SELECT $CRC_ARG_type = 7`) {
if ($CRC_ARG_type == 7) {
# CRC_ARG_type=7 is a special case. We just set $CRC_RET_x =
# $CRC_ARG_x. This way, the $CRC_ARG_stmt gets executed directly
# (below). In binlog_unsafe.test, it is used to invoke the unsafe
......@@ -295,7 +302,7 @@ if ($CRC_RET_stmt_sidef) {
--echo * binlog_format = STATEMENT: expect $CRC_ARG_expected_number_of_warnings warnings.
--eval $CRC_RET_stmt_sidef
--let $n_warnings= `SHOW COUNT(*) WARNINGS`
if (`SELECT '$n_warnings' != '$CRC_ARG_expected_number_of_warnings'`) {
if ($n_warnings != $CRC_ARG_expected_number_of_warnings) {
--echo ******** Failure! Expected $CRC_ARG_expected_number_of_warnings warnings, got $n_warnings warnings. ********
SHOW WARNINGS;
SHOW BINLOG EVENTS;
......@@ -312,14 +319,14 @@ if ($CRC_RET_stmt_sidef) {
RESET MASTER;
--eval $CRC_RET_stmt_sidef
--let $n_warnings= `SHOW COUNT(*) WARNINGS`
if (`SELECT '$n_warnings' != '0'`) {
if ($n_warnings) {
--echo ******** Failure! Expected 0 warnings, got $n_warnings warnings. ********
SHOW WARNINGS;
SHOW BINLOG EVENTS;
--die Wrong number of warnings.
}
--let $binlog_event= query_get_value(SHOW BINLOG EVENTS, Event_type, 2)
if (`SELECT '$binlog_event' != 'No such row'`) {
if ($binlog_event != No such row) {
--enable_query_log
--echo ******** Failure! Something was written to the binlog despite SQL_LOG_BIN=0 ********
SHOW BINLOG EVENTS;
......@@ -332,7 +339,7 @@ if ($CRC_RET_stmt_sidef) {
RESET MASTER;
--eval $CRC_RET_stmt_sidef
--let $n_warnings= `SHOW COUNT(*) WARNINGS`
if (`SELECT '$n_warnings' != '0'`) {
if ($n_warnings) {
--echo ******** Failure! Expected 0 warnings, got $n_warnings warnings. ********
SHOW WARNINGS;
SHOW BINLOG EVENTS;
......@@ -375,7 +382,7 @@ if ($CRC_RET_sel_retval) {
# fail. When the bug is fixed, we should execute the following.
#--let $n_warnings= `SHOW COUNT(*) WARNINGS`
#if (`SELECT '$n_warnings' != '0'`) {
#if ($n_warnings) {
# --enable_query_log
# --echo Failure! Expected 0 warnings, got $n_warnings warnings.
# SHOW WARNINGS;
......
......@@ -35,7 +35,7 @@ if (`SELECT HEX(@commands) = HEX('configure')`)
# when a command ends.
#
--let $n= $tot_table
while (`SELECT $n != 0`)
while ($n)
{
--eval DROP TEMPORARY TABLE IF EXISTS nt_tmp_$n
--eval CREATE TEMPORARY TABLE nt_tmp_$n ( id INT ) ENGINE = MyIsam
......@@ -62,7 +62,7 @@ if (`SELECT HEX(@commands) = HEX('configure')`)
# when a command ends.
#
--let $n= $tot_table
while (`SELECT $n != 0`)
while ($n)
{
--eval DROP TEMPORARY TABLE IF EXISTS tt_tmp_$n
--eval CREATE TEMPORARY TABLE tt_tmp_$n ( id INT ) ENGINE = Innodb
......@@ -89,7 +89,7 @@ if (`SELECT HEX(@commands) = HEX('configure')`)
# when a command ends.
#
--let $n= $tot_table
while (`SELECT $n != 0`)
while ($n)
{
--eval DROP TABLE IF EXISTS nt_$n
--eval CREATE TABLE nt_$n ( id INT ) ENGINE = MyIsam
......@@ -116,7 +116,7 @@ if (`SELECT HEX(@commands) = HEX('configure')`)
# when a command ends.
#
--let $n= $tot_table
while (`SELECT $n != 0`)
while ($n)
{
--eval DROP TABLE IF EXISTS tt_$n
--eval CREATE TABLE tt_$n ( id INT ) ENGINE = Innodb
......@@ -163,14 +163,14 @@ if (`SELECT HEX(@commands) = HEX('clean')`)
DROP TABLE IF EXISTS nt_xx_1;
--let $n= $tot_table
while (`SELECT $n != 0`)
while ($n)
{
--eval DROP TABLE IF EXISTS nt_$n
--dec $n
}
--let $n= $tot_table
while (`SELECT $n != 0`)
while ($n)
{
--eval DROP TABLE IF EXISTS tt_$n
--dec $n
......@@ -634,11 +634,11 @@ while (`SELECT HEX(@commands) != HEX('')`)
{
--let $dropped_temp= $table
}
if (`SELECT $n = 1`)
if ($n == 1)
{
--let $table_1= $table
}
if (`SELECT $n = 2`)
if ($n == 2)
{
--let $table_2= $table
}
......@@ -886,7 +886,7 @@ while (`SELECT HEX(@commands) != HEX('')`)
--let $available_n_temp=
--let $dropped_n_temp=
--let $n= $tot_table
while (`SELECT $n != 0`)
while ($n)
{
--eval DROP TEMPORARY TABLE IF EXISTS nt_tmp_$n
--eval CREATE TEMPORARY TABLE nt_tmp_$n ( id INT ) ENGINE = MyIsam
......@@ -905,7 +905,7 @@ while (`SELECT HEX(@commands) != HEX('')`)
--let $available_t_temp=
--let $dropped_t_temp=
--let $n= $tot_table
while (`SELECT $n != 0`)
while ($n)
{
--eval DROP TEMPORARY TABLE IF EXISTS tt_tmp_$n
--eval CREATE TEMPORARY TABLE tt_tmp_$n ( id INT ) ENGINE = Innodb
......@@ -924,7 +924,7 @@ while (`SELECT HEX(@commands) != HEX('')`)
--let $available_t=
--let $dropped_t=
--let $n= $tot_table
while (`SELECT $n != 0`)
while ($n)
{
--eval DROP TABLE IF EXISTS tt_$n
--eval CREATE TABLE tt_$n ( id INT ) ENGINE = Innodb
......@@ -943,7 +943,7 @@ while (`SELECT HEX(@commands) != HEX('')`)
--let $available_n=
--let $dropped_n=
--let $n= $tot_table
while (`SELECT $n != 0`)
while ($n)
{
--eval DROP TABLE IF EXISTS nt_$n
--eval CREATE TABLE nt_$n ( id INT ) ENGINE = MyIsam
......
......@@ -406,7 +406,7 @@ sync_slave_with_master;
# Error reaction is up to sql_mode of the slave sql (bug#38173)
#--echo *** Create t9 on slave ***
# Please, check BUG#47741 to see why you are not testing NDB.
if (`SELECT $engine_type != 'NDB'`)
if ($engine_type != NDB)
{
STOP SLAVE;
RESET SLAVE;
......
......@@ -33,7 +33,7 @@ INSERT INTO tt_2(ddl_case) VALUES(0);
--echo #########################################################################
SET AUTOCOMMIT= 0;
let $ddl_cases= 41;
while (`SELECT $ddl_cases >= 1`)
while ($ddl_cases >= 1)
{
--echo -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
let $in_temporary= "no";
......@@ -76,7 +76,7 @@ while (`SELECT $ddl_cases >= 1`)
# 6: ROW EVENT
# 7: COMMIT
#
if (`select '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 7;
}
......@@ -84,10 +84,10 @@ while (`SELECT $ddl_cases >= 1`)
let $first_binlog_position= query_get_value("SHOW MASTER STATUS", Position, 1);
--enable_query_log
eval INSERT INTO tt_1(ddl_case) VALUES ($ddl_cases);
if (`SELECT $ddl_cases = 41`)
if ($ddl_cases == 41)
{
let $cmd= LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES;
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
# This seems to be related to epochs.
# We need to check this against an updated version or avoid it.
......@@ -95,7 +95,7 @@ while (`SELECT $ddl_cases >= 1`)
let $commit_event_row_number= 6;
}
}
if (`SELECT $ddl_cases = 40`)
if ($ddl_cases == 40)
{
let $cmd= LOAD INDEX INTO CACHE tt_1, tt_2 IGNORE LEAVES;
#
......@@ -109,16 +109,16 @@ while (`SELECT $ddl_cases >= 1`)
# 5: ROW EVENT
# 6: COMMIT
#
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 6;
}
}
if (`SELECT $ddl_cases = 39`)
if ($ddl_cases == 39)
{
let $cmd= ANALYZE TABLE nt_1;
}
if (`SELECT $ddl_cases = 38`)
if ($ddl_cases == 38)
{
let $cmd= CHECK TABLE nt_1;
#
......@@ -132,20 +132,20 @@ while (`SELECT $ddl_cases >= 1`)
# 5: ROW EVENT
# 6: COMMIT
#
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 6;
}
}
if (`SELECT $ddl_cases = 37`)
if ($ddl_cases == 37)
{
let $cmd= OPTIMIZE TABLE nt_1;
}
if (`SELECT $ddl_cases = 36`)
if ($ddl_cases == 36)
{
let $cmd= REPAIR TABLE nt_1;
}
if (`SELECT $ddl_cases = 35`)
if ($ddl_cases == 35)
{
let $cmd= LOCK TABLES tt_1 WRITE;
#
......@@ -159,12 +159,12 @@ while (`SELECT $ddl_cases >= 1`)
# 5: ROW EVENT
# 6: COMMIT
#
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 6;
}
}
if (`SELECT $ddl_cases = 34`)
if ($ddl_cases == 34)
{
let $cmd= UNLOCK TABLES;
#
......@@ -178,20 +178,20 @@ while (`SELECT $ddl_cases >= 1`)
# 5: ROW EVENT
# 6: COMMIT
#
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 6;
}
}
if (`SELECT $ddl_cases = 33`)
if ($ddl_cases == 33)
{
let $cmd= CREATE USER 'user'@'localhost';
}
if (`SELECT $ddl_cases = 32`)
if ($ddl_cases == 32)
{
let $cmd= GRANT ALL ON *.* TO 'user'@'localhost';
}
if (`SELECT $ddl_cases = 31`)
if ($ddl_cases == 31)
{
let $cmd= SET PASSWORD FOR 'user'@'localhost' = PASSWORD('newpass');
#
......@@ -231,35 +231,35 @@ while (`SELECT $ddl_cases >= 1`)
let $commit_event_row_number= 7;
}
}
if (`SELECT $ddl_cases = 30`)
if ($ddl_cases == 30)
{
let $cmd= REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost';
}
if (`SELECT $ddl_cases = 29`)
if ($ddl_cases == 29)
{
let $cmd= RENAME USER 'user'@'localhost' TO 'user_new'@'localhost';
}
if (`SELECT $ddl_cases = 28`)
if ($ddl_cases == 28)
{
let $cmd= DROP USER 'user_new'@'localhost';
}
if (`SELECT $ddl_cases = 27`)
if ($ddl_cases == 27)
{
let $cmd= CREATE EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1;
}
if (`SELECT $ddl_cases = 26`)
if ($ddl_cases == 26)
{
let $cmd= ALTER EVENT evt COMMENT 'evt';
}
if (`SELECT $ddl_cases = 25`)
if ($ddl_cases == 25)
{
let $cmd= DROP EVENT evt;
}
if (`SELECT $ddl_cases = 24`)
if ($ddl_cases == 24)
{
let $cmd= CREATE TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case;
}
if (`SELECT $ddl_cases = 23`)
if ($ddl_cases == 23)
{
let $cmd= DROP TRIGGER tr;
#
......@@ -277,43 +277,43 @@ while (`SELECT $ddl_cases >= 1`)
let $commit_event_row_number= 5;
}
}
if (`SELECT $ddl_cases = 22`)
if ($ddl_cases == 22)
{
let $cmd= CREATE FUNCTION fc () RETURNS VARCHAR(64) RETURN "fc";
}
if (`SELECT $ddl_cases = 21`)
if ($ddl_cases == 21)
{
let $cmd= ALTER FUNCTION fc COMMENT 'fc';
}
if (`SELECT $ddl_cases = 20`)
if ($ddl_cases == 20)
{
let $cmd= DROP FUNCTION fc;
}
if (`SELECT $ddl_cases = 19`)
if ($ddl_cases == 19)
{
let $cmd= CREATE PROCEDURE pc () UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case;
}
if (`SELECT $ddl_cases = 18`)
if ($ddl_cases == 18)
{
let $cmd= ALTER PROCEDURE pc COMMENT 'pc';
}
if (`SELECT $ddl_cases = 17`)
if ($ddl_cases == 17)
{
let $cmd= DROP PROCEDURE pc;
}
if (`SELECT $ddl_cases = 16`)
if ($ddl_cases == 16)
{
let $cmd= CREATE VIEW v AS SELECT * FROM tt_1;
}
if (`SELECT $ddl_cases = 15`)
if ($ddl_cases == 15)
{
let $cmd= ALTER VIEW v AS SELECT * FROM tt_1;
}
if (`SELECT $ddl_cases = 14`)
if ($ddl_cases == 14)
{
let $cmd= DROP VIEW v;
}
if (`SELECT $ddl_cases = 13`)
if ($ddl_cases == 13)
{
let $cmd= CREATE INDEX ix ON tt_1(ddl_case);
#
......@@ -328,12 +328,12 @@ while (`SELECT $ddl_cases >= 1`)
# 6: COMMIT
# 7: DDL EVENT which triggered the previous commmit.
#
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 6;
}
}
if (`SELECT $ddl_cases = 12`)
if ($ddl_cases == 12)
{
let $cmd= DROP INDEX ix ON tt_1;
#
......@@ -348,12 +348,12 @@ while (`SELECT $ddl_cases >= 1`)
# 6: COMMIT
# 7: DDL EVENT which triggered the previous commmit.
#
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 6;
}
}
if (`SELECT $ddl_cases = 11`)
if ($ddl_cases == 11)
{
let $cmd= CREATE TEMPORARY TABLE tt_xx (a int);
let $in_temporary= "yes";
......@@ -411,7 +411,7 @@ while (`SELECT $ddl_cases >= 1`)
let $commit_event_row_number= 9;
}
}
if (`SELECT $ddl_cases = 10`)
if ($ddl_cases == 10)
{
let $cmd= ALTER TABLE tt_xx ADD COLUMN (b int);
#
......@@ -438,12 +438,12 @@ while (`SELECT $ddl_cases >= 1`)
# 5: ROW EVENT
# 6: COMMIT
#
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 6;
}
}
if (`SELECT $ddl_cases = 9`)
if ($ddl_cases == 9)
{
let $cmd= ALTER TABLE tt_xx RENAME new_tt_xx;
#
......@@ -470,12 +470,12 @@ while (`SELECT $ddl_cases >= 1`)
# 5: ROW EVENT
# 6: COMMIT
#
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 6;
}
}
if (`SELECT $ddl_cases = 8`)
if ($ddl_cases == 8)
{
let $cmd= DROP TEMPORARY TABLE IF EXISTS new_tt_xx;
let $in_temporary= "yes";
......@@ -528,7 +528,7 @@ while (`SELECT $ddl_cases >= 1`)
# 8: ROW EVENT
# 9: COMMIT
#
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 9;
}
......@@ -551,27 +551,27 @@ while (`SELECT $ddl_cases >= 1`)
let $commit_event_row_number= 9;
}
}
if (`SELECT $ddl_cases = 7`)
if ($ddl_cases == 7)
{
let $cmd= CREATE TABLE tt_xx (a int);
}
if (`SELECT $ddl_cases = 6`)
if ($ddl_cases == 6)
{
let $cmd= ALTER TABLE tt_xx ADD COLUMN (b int);
}
if (`SELECT $ddl_cases = 5`)
if ($ddl_cases == 5)
{
let $cmd= RENAME TABLE tt_xx TO new_tt_xx;
}
if (`SELECT $ddl_cases = 4`)
if ($ddl_cases == 4)
{
let $cmd= TRUNCATE TABLE new_tt_xx;
}
if (`SELECT $ddl_cases = 3`)
if ($ddl_cases == 3)
{
let $cmd= DROP TABLE IF EXISTS tt_xx, new_tt_xx;
}
if (`SELECT $ddl_cases = 2`)
if ($ddl_cases == 2)
{
let $cmd= CREATE DATABASE db;
#
......@@ -586,12 +586,12 @@ while (`SELECT $ddl_cases >= 1`)
# 6: COMMIT
# 7: DDL EVENT which triggered the previous commmit.
#
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 6;
}
}
if (`SELECT $ddl_cases = 1`)
if ($ddl_cases == 1)
{
let $cmd= DROP DATABASE IF EXISTS db;
#
......@@ -606,7 +606,7 @@ while (`SELECT $ddl_cases >= 1`)
# 6: COMMIT
# 7: DDL EVENT which triggered the previous commmit.
#
if (`SELECT '$engine' = 'NDB'`)
if ($engine == NDB)
{
let $commit_event_row_number= 6;
}
......@@ -618,14 +618,14 @@ while (`SELECT $ddl_cases >= 1`)
# commit. The flag in_temporary is used to avoid aborting the test in such
# cases. Thus we force the commit.
#
if (`SELECT $in_temporary = "yes"`)
if ($in_temporary == "yes")
{
--eval COMMIT
}
let $event_commit= query_get_value("SHOW BINLOG EVENTS FROM $first_binlog_position", Info, $commit_event_row_number);
if (`SELECT SUBSTRING("$event_commit",1,6) != "COMMIT"`)
{
if (`SELECT $ok = "yes"`)
if ($ok == "yes")
{
--echo it *does not* commit the current transaction.
--echo $cmd
......
......@@ -121,7 +121,7 @@ if (`SELECT @@global.binlog_format = 'STATEMENT'`)
# The second INSERT DELAYED statement is the 5 item if two INSERT DELAYED are
# handled separately
if (`SELECT '$stmt' = 'COMMIT'`)
if ($stmt == COMMIT)
{
--let $stmt= query_get_value(SHOW BINLOG EVENTS IN '$binlog_file' FROM $_start, Info, 5)
}
......
......@@ -177,7 +177,7 @@ sync_slave_with_master;
#--source include/wait_for_slave_to_start.inc
#
#let $y=0;
#while (`select $y < 6`)
#while ($y < 6)
#{
# connection master;
#
......@@ -202,21 +202,21 @@ sync_slave_with_master;
# `c` INT DEFAULT 500,
# PRIMARY KEY(`a`)) ENGINE=$engine DEFAULT CHARSET=LATIN1;
#
# if (`select $y=0`)
# if ($y==0)
# {
# --echo ************* EXECUTION WITH INSERTS *************
# connection master;
# INSERT INTO t1(a) VALUES (1);
# }
#
# if (`select $y=1`)
# if ($y==1)
# {
# --echo ************* EXECUTION WITH INSERTS *************
# connection master;
# INSERT INTO t1(a, b) VALUES (1, NULL);
# }
#
# if (`select $y=2`)
# if ($y==2)
# {
# --echo ************* EXECUTION WITH UPDATES *************
# connection master;
......@@ -225,14 +225,14 @@ sync_slave_with_master;
# UPDATE t3 SET b = NULL where a= 1;
# }
#
# if (`select $y=3`)
# if ($y==3)
# {
# --echo ************* EXECUTION WITH INSERTS/REPLACES *************
# connection master;
# REPLACE INTO t3(a, b) VALUES (1, null);
# }
#
# if (`select $y=4`)
# if ($y==4)
# {
# --echo ************* EXECUTION WITH UPDATES/REPLACES *************
# connection master;
......@@ -240,7 +240,7 @@ sync_slave_with_master;
# REPLACE INTO t3(a, b) VALUES (1, null);
# }
#
# if (`select $y=5`)
# if ($y==5)
# {
# --echo ************* EXECUTION WITH MULTI-ROW INSERTS *************
# connection master;
......
......@@ -8,10 +8,18 @@
--echo Checking that both slave threads are running.
--let $running= 1
--let $slave_sql_running = query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1)
--let $slave_io_running = query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1)
if (`SELECT '$slave_sql_running' != 'Yes' OR '$slave_io_running' != 'Yes'`) {
if ($slave_sql_running != Yes) {
--let $running= 0
}
if ($slave_io_running != Yes) {
--let $running= 0
}
if (!$running) {
--echo Slave not running: Slave_SQL_Running = $slave_sql_running Slave_IO_Running = $slave_io_running
--source include/show_rpl_debug_info.inc
--die Expected slave to be running, but it was not running.
......
......@@ -9,7 +9,7 @@
# --source include/check_slave_param.inc
--let $_param_value= query_get_value(SHOW SLAVE STATUS, $slave_param, 1)
if (`SELECT '$_param_value' != '$slave_param_value'`) {
if ($_param_value != $slave_param_value) {
--echo Wrong value for $slave_param. Expected '$slave_param_value', got '$_param_value'
--source include/show_rpl_debug_info.inc
--die Wrong value for slave parameter
......
......@@ -69,7 +69,7 @@ while ($_diff_i) {
# and connect the appropriate server.
let $_pos= `SELECT LOCATE(':', '$_diff_table')`;
let $_diff_conn=`SELECT SUBSTR('$_diff_table', 1, $_pos-1)`;
if (`SELECT 'XX$_diff_conn' <> 'XX'`) {
if ($_diff_conn) {
let $_diff_table=`SELECT SUBSTR('$_diff_table', $_pos+1)`;
connection $_diff_conn;
}
......
......@@ -8,7 +8,7 @@ if (`SELECT @@have_dynamic_loading != 'YES'`) {
#
# Check if the variable EXAMPLE_PLUGIN is set
#
if (`SELECT LENGTH('$EXAMPLE_PLUGIN') = 0`) {
if (!$EXAMPLE_PLUGIN) {
--skip Example plugin requires the environment variable \$EXAMPLE_PLUGIN to be set (normally done by mtr)
}
......
......@@ -8,7 +8,7 @@ if (`SELECT @@have_dynamic_loading != 'YES'`) {
#
# Check if the variable SEMISYNC_MASTER_PLUGIN is set
#
if (`select LENGTH('$SEMISYNC_MASTER_PLUGIN') = 0`)
if (!$SEMISYNC_MASTER_PLUGIN)
{
skip Need semisync plugins;
}
......
......@@ -8,7 +8,7 @@ if (`SELECT @@have_dynamic_loading != 'YES'`) {
#
# Check if the variable SIMPLE_PARSER is set
#
if (`SELECT LENGTH('$SIMPLE_PARSER') = 0`) {
if (!$SIMPLE_PARSER) {
--skip simple parser requires the environment variable \$SIMPLE_PARSER to be set (normally done by mtr)
}
......
......@@ -8,7 +8,7 @@ if (`SELECT @@have_dynamic_loading != 'YES'`) {
#
# Check if the variable UDF_EXAMPLE_LIB is set
#
if (`SELECT LENGTH('$UDF_EXAMPLE_LIB') = 0`) {
if (!$UDF_EXAMPLE_LIB) {
--skip UDF requires the environment variable \$UDF_EXAMPLE_LIB to be set (normally done by mtr)
}
......
......@@ -17,7 +17,7 @@ select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade;
# Therefore, truncate the log table in advance and issue a statement
# that should be logged.
#
if (`SELECT $VALGRIND_TEST`)
if ($VALGRIND_TEST)
{
--disable_query_log
--disable_result_log
......
......@@ -5,8 +5,9 @@
# Therefore we require that the option "--big-test" is also set.
#
if (`SELECT $VALGRIND_TEST <> 0 AND '$BIG_TEST' = ''`)
{
--skip Need "--big-test" when running with Valgrind
if ($VALGRIND_TEST) {
if (!$BIG_TEST)
{
--skip Need "--big-test" when running with Valgrind
}
}
if (`SELECT '$MTR_PARALLEL' > 1`) {
if ($MTR_PARALLEL > 1) {
--skip test requires --parallel=1
}
......@@ -8,13 +8,13 @@
# --source include/rpl_diff_tables.inc
# #############################################################################
if (`SELECT "XX$diff_table" = "XX"`)
if (!$diff_table)
{
--die diff_table is null.
}
--let $_servers= master, slave
if (`SELECT "XX$diff_server_list" <> "XX"`)
if ($diff_server_list)
{
--let $_servers= $diff_server_list
}
......@@ -22,7 +22,7 @@ if (`SELECT "XX$diff_server_list" <> "XX"`)
--let $_master= `SELECT SUBSTRING_INDEX('$_servers', ',', 1)`
--let $_servers= `SELECT LTRIM(SUBSTRING('$_servers', LENGTH('$_master') + 2))`
connection $_master;
while (`SELECT "XX$_servers" <> "XX"`)
while ($_servers)
{
--let $_slave= `SELECT SUBSTRING_INDEX('$_servers', ',', 1)`
--let $_servers= `SELECT LTRIM(SUBSTRING('$_servers', LENGTH('$_slave') + 2))`
......
......@@ -40,9 +40,16 @@ let $_fake_relay_log_printable= `SELECT REPLACE('$fake_relay_log', '$MYSQL_TEST_
--echo Setting up fake replication from $_fake_relay_log_printable
# Sanity check.
let $running= 0;
let $_sql_running= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
let $_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1);
if (`SELECT "$_sql_running" = "Yes" OR "$_io_running" = "Yes"`) {
if ($_sql_running == Yes) {
let $running= 1;
}
if ($_io_running == Yes) {
let $running= 1;
}
if ($running) {
--echo Error: Slave was running when test case sourced
--echo include/setup_fake_replication.inc
--echo Slave_IO_Running = $_io_running; Slave_SQL_Running = $_sql_running
......
......@@ -50,7 +50,7 @@ eval SHOW BINLOG EVENTS IN '$binlog_name';
let $_master_con= $master_connection;
if (!$_master_con)
{
if (`SELECT '$_con' = 'slave'`)
if ($_con == slave)
{
let $_master_con= master;
}
......@@ -80,7 +80,7 @@ if ($_master_con)
--echo
--echo **** SHOW BINLOG EVENTS on $_master_con ****
eval SHOW BINLOG EVENTS IN '$master_binlog_name_sql';
if (`SELECT '$master_binlog_name_io' != '$master_binlog_name_sql'`)
if ($master_binlog_name_io != $master_binlog_name_sql)
{
eval SHOW BINLOG EVENTS IN '$master_binlog_name_io';
}
......
# truncate a giving file, all contents of the file are be cleared
if (`SELECT 'x$file' = 'x'`)
if (!$file)
{
--echo Please assign a file name to $file!!
exit;
......
......@@ -14,7 +14,7 @@
# if server has not used CHANGE MASTER to initiate slave, SHOW SLAVE
# STATUS will return an empty set.
let $_slave_io_running= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1);
if (`SELECT '$_slave_io_running' != 'No such row'`)
if ($_slave_io_running != No such row)
{
let $slave_param= Slave_IO_Running;
let $slave_param_value= No;
......
......@@ -34,7 +34,7 @@ let $slave_error_message= Failed while waiting for slave to stop the SQL thread
source include/wait_for_slave_param.inc;
let $_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
if (`SELECT '$_error' != '$slave_sql_errno'`) {
if ($_error != $slave_sql_errno) {
--echo **** Slave stopped with wrong error code: $_error (expected $slave_sql_errno) ****
source include/show_rpl_debug_info.inc;
--echo **** Slave stopped with wrong error code: $_error (expected $slave_sql_errno) ****
......
......@@ -14,7 +14,7 @@
# if server has not used CHANGE MASTER to initiate slave, SHOW SLAVE
# STATUS will return an empty set.
let $_slave_io_running= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1);
if (`SELECT '$_slave_io_running' != 'No such row'`)
if ($_slave_io_running != No such row)
{
let $slave_param= Slave_SQL_Running;
let $slave_param_value= No;
......
......@@ -14,7 +14,7 @@
# if server has not used CHANGE MASTER to initiate slave, SHOW SLAVE
# STATUS will return an empty set.
let $_slave_io_running= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1);
if (`SELECT '$_slave_io_running' != 'No such row'`)
if ($_slave_io_running != No such row)
{
let $slave_error_message= Failed while waiting for slave to stop;
......
......@@ -50,7 +50,7 @@ inc $max_run_time;
let $found= 0;
let $max_end_time= `SELECT UNIX_TIMESTAMP() + $max_run_time`;
if (`SELECT '$wait_for_all' != '1'`)
if ($wait_for_all != 1)
{
while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`)
{
......@@ -58,24 +58,27 @@ if (`SELECT '$wait_for_all' != '1'`)
real_sleep 0.2;
let $rowno= 1;
let $process_result= 1;
while (`SELECT $process_result = 1 AND $found = 0`)
let $do_loop= 1;
while ($do_loop)
{
let $field_value= query_get_value($show_statement, $field, $rowno);
if (`SELECT '$field_value' $condition`)
{
let $found= 1;
let $do_loop= 0;
}
if (`SELECT '$field_value' = 'No such row'`)
if ($field_value == No such row)
{
# We are behind the last row of the result set.
let $process_result= 0;
let $do_loop= 0;
}
inc $rowno;
}
}
}
if (`SELECT '$wait_for_all' = '1'`)
if ($wait_for_all == 1)
{
while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`)
{
......@@ -83,16 +86,19 @@ if (`SELECT '$wait_for_all' = '1'`)
real_sleep 0.2;
let $rowno= 1;
let $process_result= 1;
while (`SELECT $process_result = 1 AND $found = 0`)
let $do_loop= 1;
while ($do_loop)
{
let $field_value= query_get_value($show_statement, $field, $rowno);
if (`SELECT '$field_value' = 'No such row'`)
if ($field_value == No such row)
{
let $found= 1;
let $do_loop= 0;
}
if (`SELECT $found = 0 AND NOT '$field_value' $condition`)
{
let process_result= 0;
let $do_loop= 0;
}
inc $rowno;
}
......
......@@ -1811,17 +1811,17 @@ sub executable_setup () {
if ( ! $opt_skip_ndbcluster )
{
$exe_ndbd=
my_find_bin($basedir,
my_find_bin($bindir,
["storage/ndb/src/kernel", "libexec", "sbin", "bin"],
"ndbd");
$exe_ndb_mgmd=
my_find_bin($basedir,
my_find_bin($bindir,
["storage/ndb/src/mgmsrv", "libexec", "sbin", "bin"],
"ndb_mgmd");
$exe_ndb_waiter=
my_find_bin($basedir,
my_find_bin($bindir,
["storage/ndb/tools/", "bin"],
"ndb_waiter");
......@@ -2193,12 +2193,12 @@ sub environment_setup {
if ( ! $opt_skip_ndbcluster )
{
$ENV{'NDB_MGM'}=
my_find_bin($basedir,
my_find_bin($bindir,
["storage/ndb/src/mgmclient", "bin"],
"ndb_mgm");
$ENV{'NDB_TOOLS_DIR'}=
my_find_dir($basedir,
my_find_dir($bindir,
["storage/ndb/tools", "bin"]);
$ENV{'NDB_EXAMPLES_DIR'}=
......@@ -2206,7 +2206,7 @@ sub environment_setup {
["storage/ndb/ndbapi-examples", "bin"]);
$ENV{'NDB_EXAMPLES_BINARY'}=
my_find_bin($basedir,
my_find_bin($bindir,
["storage/ndb/ndbapi-examples/ndbapi_simple", "bin"],
"ndbapi_simple", NOT_REQUIRED);
......
......@@ -308,6 +308,10 @@ var3 two columns with same name
var4 from query that returns NULL
var5 from query that returns no row
failing query in let
create table t1 (a varchar(100));
insert into t1 values ('`select 42`');
`select 42`
drop table t1;
mysqltest: At line 1: Error running query 'failing query': 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'failing query' at line 1
mysqltest: At line 1: Missing required argument 'filename' to command 'source'
mysqltest: At line 1: Could not open './non_existingFile' for reading, errno: 2
......@@ -399,10 +403,40 @@ true-inner
true-inner again
true-outer
Counter is greater than 0, (counter=10)
Counter should still be 10, is 10
Counter is not 0, (counter=0)
Not space var works
Counter is true, (counter=alpha)
Beta is true
while with string, only once
5<7
5<7 again
5<7 still
5<6
5>=5
5>=5 again
5>3
5==5
5!=8
5!=five
5==3+2
5 == 5
hello == hello
hello == hello
hello != goodbye
two words
two words are two words
right answer
anything goes
0 != string
mysqltest: At line 2: Only == and != are supported for string values
mysqltest: At line 2: Found junk '~= 6' after $variable in condition
mysqltest: At line 2: Expression in if/while must beging with $, ` or a number
counter is 2
counter is 3
counter is 4
counter is 5
counter is 6
counter is 7
1
Testing while with not
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest_while.inc": At line 64: Nesting too deeply
......@@ -807,8 +841,6 @@ dir-list.txt
SELECT 'c:\\a.txt' AS col;
col
z
hej
mysqltest: At line 1: Found junk ' != 143' after $variable in expression
select 1;
1
1
......
......@@ -83,17 +83,17 @@ while($i)
-- let $flags=--database=b42941
# construct CLI for mysqlbinlog
if(`SELECT $i=3`)
if($i==3)
{
-- let $flags= $flags --verbose --hexdump
}
if(`SELECT $i=2`)
if($i==2)
{
-- let $flags= $flags --verbose
}
# if(`SELECT $i=1`)
# if($i==1)
# {
# do nothing $flags is already set as it should be
# }
......
......@@ -116,7 +116,7 @@ DROP TABLE t1;
SET GLOBAL log_warnings = @old_log_warnings;
let $log_error_= `SELECT @@GLOBAL.log_error`;
if(!`select LENGTH('$log_error_')`)
if(!$log_error_)
{
# MySQL Server on windows is started with --console and thus
# does not know the location of its .err log, use default location
......
......@@ -141,11 +141,11 @@ END|
# In each iteration of this loop, we select one method to make the
# statement unsafe.
--let $unsafe_type= 0
while (`SELECT $unsafe_type < 9`) {
while ($unsafe_type < 9) {
--echo
if (`SELECT $unsafe_type = 0`) {
if ($unsafe_type == 0) {
--echo ==== Testing UUID() unsafeness ====
--let $desc_0= unsafe UUID() function
--let $stmt_sidef_0= INSERT INTO t0 VALUES (UUID())
......@@ -155,7 +155,7 @@ while (`SELECT $unsafe_type < 9`) {
--let $CRC_ARG_expected_number_of_warnings= 1
}
if (`SELECT $unsafe_type = 1`) {
if ($unsafe_type == 1) {
--echo ==== Testing @@hostname unsafeness ====
--let $desc_0= unsafe @@hostname variable
--let $stmt_sidef_0= INSERT INTO t0 VALUES (@@hostname)
......@@ -168,7 +168,7 @@ while (`SELECT $unsafe_type < 9`) {
--let $CRC_ARG_expected_number_of_warnings= 1
}
if (`SELECT $unsafe_type = 2`) {
if ($unsafe_type == 2) {
--echo ==== Testing SELECT...LIMIT unsafeness ====
--let $desc_0= unsafe SELECT...LIMIT statement
--let $stmt_sidef_0= INSERT INTO t0 SELECT * FROM data_table LIMIT 1
......@@ -178,7 +178,7 @@ while (`SELECT $unsafe_type < 9`) {
--let $CRC_ARG_expected_number_of_warnings= 1
}
if (`SELECT $unsafe_type = 3`) {
if ($unsafe_type == 3) {
--echo ==== Testing INSERT DELAYED safeness after BUG#54579 is fixed ====
--let $desc_0= unsafe INSERT DELAYED statement
--let $stmt_sidef_0= INSERT DELAYED INTO t0 VALUES (1), (2)
......@@ -188,7 +188,7 @@ while (`SELECT $unsafe_type < 9`) {
--let $CRC_ARG_expected_number_of_warnings= 0
}
if (`SELECT $unsafe_type = 4`) {
if ($unsafe_type == 4) {
--echo ==== Testing unsafeness of insert of two autoinc values ====
--let $desc_0= unsafe update of two autoinc columns
--let $stmt_sidef_0= INSERT INTO double_autoinc_table VALUES (NULL)
......@@ -198,7 +198,7 @@ while (`SELECT $unsafe_type < 9`) {
--let $CRC_ARG_expected_number_of_warnings= 1
}
if (`SELECT $unsafe_type = 5`) {
if ($unsafe_type == 5) {
--echo ==== Testing unsafeness of UDF's ====
--let $desc_0= unsafe UDF
--let $stmt_sidef_0= INSERT INTO t0 VALUES (myfunc_int(10))
......@@ -208,7 +208,7 @@ while (`SELECT $unsafe_type < 9`) {
--let $CRC_ARG_expected_number_of_warnings= 1
}
if (`SELECT $unsafe_type = 6`) {
if ($unsafe_type == 6) {
--echo ==== Testing unsafeness of access to mysql.general_log ====
--let $desc_0= unsafe use of mysql.general_log
--let $stmt_sidef_0= INSERT INTO t0 SELECT COUNT(*) FROM mysql.general_log
......@@ -218,7 +218,7 @@ while (`SELECT $unsafe_type < 9`) {
--let $CRC_ARG_expected_number_of_warnings= 1
}
if (`SELECT $unsafe_type = 7`) {
if ($unsafe_type == 7) {
--echo ==== Testing a statement that is unsafe in many ways ====
--let $desc_0= statement that is unsafe in many ways
# Concatenate three unsafe values, and then concatenate NULL to
......@@ -230,7 +230,7 @@ while (`SELECT $unsafe_type < 9`) {
--let $CRC_ARG_expected_number_of_warnings= 6
}
if (`SELECT $unsafe_type = 8`) {
if ($unsafe_type == 8) {
--echo ==== Testing a statement that is unsafe several times ====
--let $desc_0= statement that is unsafe several times
--let $stmt_sidef_0= INSERT INTO ta0 VALUES (multi_unsafe_func())
......@@ -249,7 +249,7 @@ while (`SELECT $unsafe_type < 9`) {
# construct. Instead, we just invoke the unsafe statement directly.
--let $call_type_1= 0
while (`SELECT $call_type_1 < 8`) {
while ($call_type_1 < 8) {
#--echo debug: level 1, types $call_type_1 -> $unsafe_type
--let $CRC_ARG_level= 1
--let $CRC_ARG_type= $call_type_1
......@@ -280,7 +280,7 @@ while (`SELECT $unsafe_type < 9`) {
# construct.
--let $call_type_2= 0
while (`SELECT $call_type_2 < 7`) {
while ($call_type_2 < 7) {
#--echo debug: level 2, types $call_type_2 -> $call_type_1 -> $unsafe_type
--let $CRC_ARG_level= 2
--let $CRC_ARG_type= $call_type_2
......@@ -309,7 +309,7 @@ while (`SELECT $unsafe_type < 9`) {
# construct.
--let $call_type_3= 0
while (`SELECT $call_type_3 < 7`) {
while ($call_type_3 < 7) {
#--echo debug: level 3, types $call_type_2 -> $call_type_2 -> $call_type_1 -> $unsafe_type
--let $CRC_ARG_level= 3
--let $CRC_ARG_type= $call_type_3
......
# Check that path to the specific test program has been setup
if (`select LENGTH("$MYSQL_BUG25714") = 0`)
if (!$MYSQL_BUG25714)
{
skip Need bug25714 test program;
}
......
......@@ -19,7 +19,7 @@
let $have_table= `SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'`;
if (`SELECT ($have_table = 0)`) {
if (!$have_table) {
--source suite/perfschema_stress/t/setup.test
}
......
......@@ -23,10 +23,10 @@ if (`SELECT VERSION() LIKE '%embedded%'`)
--disable_query_log
--disable_result_log
if (`SELECT LENGTH('$engine_type') = 0`) {
if (!$engine_type) {
let $engine_type= $default_engine_type;
}
if (`SELECT '$engine_type' = 'Falcon'`) {
if ($engine_type == Falcon) {
--source include/have_falcon.inc
}
......
......@@ -19,7 +19,7 @@
let $have_table= `SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'`;
if (`SELECT ($have_table = 0)`) {
if (!$have_table) {
--source suite/perfschema_stress/t/setup.test
}
......
......@@ -23,7 +23,7 @@ source include/stop_slave.inc;
let $read_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
let $exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
if (`SELECT $read_pos = $exec_pos`)
if ($read_pos == $exec_pos)
{
source include/show_rpl_debug_info.inc;
echo 'Read_Master_Log_Pos: $read_pos' == 'Exec_Master_Log_Pos: $exec_pos';
......@@ -32,7 +32,7 @@ if (`SELECT $read_pos = $exec_pos`)
change master to master_user='root';
let $read_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
let $exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
if (`SELECT $read_pos <> $exec_pos`)
if ($read_pos != $exec_pos)
{
source include/show_rpl_debug_info.inc;
echo 'Read_Master_Log_Pos: $read_pos' <> 'Exec_Master_Log_Pos: $exec_pos';
......
......@@ -53,24 +53,24 @@ while ($type)
{
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
connection conn1;
if (`select $type = 2`)
if ($type == 2)
{
SET AUTOCOMMIT = 1;
BEGIN;
}
if (`select $type = 1`)
if ($type == 1)
{
SET AUTOCOMMIT = 0;
}
eval UPDATE t SET f = 'yellow $type' WHERE i = 3;
connection conn2;
if (`select $type = 2`)
if ($type == 2)
{
SET AUTOCOMMIT = 1;
BEGIN;
}
if (`select $type = 1`)
if ($type == 1)
{
SET AUTOCOMMIT = 0;
}
......@@ -88,24 +88,24 @@ while ($type)
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
connection conn1;
if (`select $type = 2`)
if ($type == 2)
{
SET AUTOCOMMIT = 1;
BEGIN;
}
if (`select $type = 1`)
if ($type == 1)
{
SET AUTOCOMMIT = 0;
}
eval UPDATE t SET f = 'gray $type' WHERE i = 3;
connection conn2;
if (`select $type = 2`)
if ($type == 2)
{
SET AUTOCOMMIT = 1;
BEGIN;
}
if (`select $type = 1`)
if ($type == 1)
{
SET AUTOCOMMIT = 0;
}
......
......@@ -142,7 +142,7 @@ source include/check_slave_param.inc;
let $slave_wait_param_counter= 300;
let $slave_value= query_get_value("SHOW STATUS like 'Slave_received_heartbeats'", Value, 1);
# Checking the fact that at least one heartbeat is received
while (`select $slave_value = 0`)
while (!$slave_value)
{
dec $slave_wait_param_counter;
if (!$slave_wait_param_counter)
......
......@@ -30,7 +30,7 @@ sync_slave_with_master;
connection master;
let $after_position= query_get_value(SHOW MASTER STATUS, Position, 1);
if (`SELECT '$before_position'='$after_position'`)
if ($before_position == $after_position)
{
echo Master position is not changed;
}
......@@ -48,7 +48,7 @@ connection master;
let $after_file= query_get_value(SHOW MASTER STATUS, File, 1);
let $after_position= query_get_value(SHOW MASTER STATUS, Position, 1);
if (!`SELECT '$before_position'='$after_position'`)
if ($before_position != $after_position)
{
echo Master position has been changed;
}
......
......@@ -58,7 +58,7 @@ echo [ on master ];
disable_query_log;
let $value = query_get_value(show variables like 'rpl_semi_sync_master_enabled', Value, 1);
if (`select '$value' = 'No such row'`)
if ($value == No such row)
{
set sql_log_bin=0;
eval INSTALL PLUGIN rpl_semi_sync_master SONAME '$SEMISYNC_MASTER_PLUGIN';
......@@ -123,7 +123,7 @@ echo [ on slave ];
disable_query_log;
let $value= query_get_value(show variables like 'rpl_semi_sync_slave_enabled', Value, 1);
if (`select '$value' = 'No such row'`)
if ($value == No such row)
{
set sql_log_bin=0;
eval INSTALL PLUGIN rpl_semi_sync_slave SONAME '$SEMISYNC_SLAVE_PLUGIN';
......
......@@ -20,7 +20,7 @@ enable_query_log;
connection master;
disable_query_log;
let $value = query_get_value(show variables like 'rpl_semi_sync_master_enabled', Value, 1);
if (`select '$value' = 'No such row'`)
if ($value == No such row)
{
set sql_log_bin=0;
eval INSTALL PLUGIN rpl_semi_sync_master SONAME '$SEMISYNC_MASTER_PLUGIN';
......@@ -34,7 +34,7 @@ source include/stop_slave.inc;
disable_query_log;
let $value= query_get_value(show variables like 'rpl_semi_sync_slave_enabled', Value, 1);
if (`select '$value' = 'No such row'`)
if ($value == No such row)
{
set sql_log_bin=0;
eval INSTALL PLUGIN rpl_semi_sync_slave SONAME '$SEMISYNC_SLAVE_PLUGIN';
......
......@@ -233,7 +233,7 @@ let $master_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text
-- sync_slave_with_master
let $slave_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$slow_query'`;
if (`SELECT $master_slow_query != $slave_slow_query`)
if ($master_slow_query != $slave_slow_query)
{
-- connection master
-- echo ***********************************************
......@@ -250,7 +250,7 @@ if (`SELECT $master_slow_query != $slave_slow_query`)
-- die "Assertion failed! Master and slave slow log contents differ. Bailing out!"
}
if (`SELECT $master_slow_query = $slave_slow_query`)
if ($master_slow_query == $slave_slow_query)
{
-- echo ### Assertion is good. Both Master and Slave exhibit the
-- echo ### same number of queries in slow log: $master_slow_query
......@@ -276,7 +276,7 @@ let $master_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text
-- sync_slave_with_master
let $slave_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$slow_query'`;
if (`SELECT $master_slow_query != $slave_slow_query`)
if ($master_slow_query != $slave_slow_query)
{
-- connection master
-- echo ***********************************************
......@@ -293,7 +293,7 @@ if (`SELECT $master_slow_query != $slave_slow_query`)
-- die "Assertion failed! Master and slave slow log contents differ. Bailing out!"
}
if (`SELECT $master_slow_query = $slave_slow_query`)
if ($master_slow_query == $slave_slow_query)
{
-- echo ### Assertion is good. Both Master and Slave exhibit the
-- echo ### same number of queries in slow log: $master_slow_query
......
......@@ -75,7 +75,7 @@ source include/check_slave_is_running.inc;
let $slave_count= `select count(*) from t1`;
if (`select $slave_count != $master_count`)
if ($slave_count != $master_count)
{
echo master and slave differed in number of rows;
echo master: $master_count;
......
......@@ -84,7 +84,7 @@ let $value_before=
CONNECT (conn2,localhost,root,,);
let $value_after=
query_get_value(show status like 'slow_launch_threads', Value, 1);
if (!`SELECT $value_after = $value_before`)
if ($value_after != $value_before)
{
--echo ERROR: Subtest FN_DYNVARS_124_02 failed
--echo A new connect must not be counted as 'slow_launch_thread' if
......
......@@ -117,7 +117,7 @@ let $before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_select',Value,1);
let $after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_select',Value,1);
if (`select $after != $before`){
if ($after != $before){
SHOW GLOBAL STATUS LIKE 'com_select';
die The value of com_select changed during change_user;
}
......
......@@ -49,7 +49,7 @@ while ($i)
let $i = 1//
# Check that mysql_errno is 1436
if (`select $mysql_errno != 1436`)
if ($mysql_errno != 1436)
{
die Wrong error triggered, expected 1436 but got $mysql_errno//
}
......
......@@ -3,7 +3,7 @@
# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set
# to the location of mysql_fix_privilege_tables.sql
if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`)
if (!$MYSQL_FIX_PRIVILEGE_TABLES)
{
skip Test need MYSQL_FIX_PRIVILEGE_TABLES;
}
......
......@@ -854,6 +854,13 @@ let $var2= `failing query`;
echo $var2;
EOF
create table t1 (a varchar(100));
insert into t1 values ('`select 42`');
let $a= `select * from t1`;
# This should output `select 42`, not evaluate it again to 42
echo $a;
drop table t1;
--error 1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/let.sql 2>&1
......@@ -1134,6 +1141,11 @@ if (!$counter)
{
echo Counter is not 0, (counter=10);
}
if (! $counter)
{
let $counter=5;
}
echo Counter should still be 10, is $counter;
let $counter=0;
if($counter)
{
......@@ -1143,6 +1155,10 @@ if (!$counter)
{
echo Counter is not 0, (counter=0);
}
if (! $counter)
{
echo Not space var works;
}
# ----------------------------------------------------------------------------
# Test if with some non-numerics
......@@ -1163,10 +1179,11 @@ if ($counter)
{
echo oops, -0 is true;
}
if (beta)
{
echo Beta is true;
}
# This is no longer allowed, as a precaution against mistyped conditionals
# if (beta)
# {
# echo Beta is true;
# }
let $counter=gamma;
while ($counter)
{
......@@ -1174,6 +1191,179 @@ while ($counter)
let $counter=000;
}
# ----------------------------------------------------------------------------
# Test if with compare conditions
# ----------------------------------------------------------------------------
let $ifvar= 5;
let $ifvar2= 6;
if ($ifvar < 7)
{
echo 5<7;
}
if ($ifvar< 7)
{
echo 5<7 again;
}
if ($ifvar<7)
{
echo 5<7 still;
}
if ($ifvar < $ifvar2)
{
echo 5<6;
}
if ($ifvar <= 4)
{
echo 5<=4;
}
if ($ifvar >= 5)
{
echo 5>=5;
}
if ($ifvar>=5)
{
echo 5>=5 again;
}
if ($ifvar > 3)
{
echo 5>3;
}
if ($ifvar == 4)
{
echo 5==4;
}
if ($ifvar == 5)
{
echo 5==5;
}
if ($ifvar != 8)
{
echo 5!=8;
}
# Any number should compare unequal to any string
if ($ifvar != five)
{
echo 5!=five;
}
if ($ifvar == `SELECT 3+2`)
{
echo 5==3+2;
}
if ($ifvar == 5)
{
echo 5 == 5;
}
let $ifvar= hello;
if ($ifvar == hello there)
{
echo hello == hello there;
}
if ($ifvar == hello)
{
echo hello == hello;
}
if ($ifvar == hell)
{
echo hello == hell;
}
if ($ifvar == hello)
{
echo hello == hello;
}
if ($ifvar != goodbye)
{
echo hello != goodbye;
}
let $ifvar= two words;
if ($ifvar == two words)
{
echo two words;
}
if ($ifvar == `SELECT 'two words'`)
{
echo two words are two words;
}
if (42)
{
echo right answer;
}
if (0)
{
echo wrong answer;
}
# Non-empty string treated as 'true'
if (`SELECT 'something'`)
{
echo anything goes;
}
# Make sure 0 and string compare right
let $ifvar= 0;
if ($ifvar == string)
{
echo 0 == string;
}
if ($ifvar != string)
{
echo 0 != string;
}
--write_file $MYSQL_TMP_DIR/mysqltest.sql
let $var= 5;
if ($var >= four)
{
echo 5>=four;
}
EOF
--error 1
--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1
remove_file $MYSQL_TMP_DIR/mysqltest.sql;
--write_file $MYSQL_TMP_DIR/mysqltest.sql
let $var= 5;
if ($var ~= 6)
{
echo 5~=6;
}
EOF
--error 1
--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1
remove_file $MYSQL_TMP_DIR/mysqltest.sql;
--write_file $MYSQL_TMP_DIR/mysqltest.sql
let $var= text;
if (var == text)
{
echo Oops I forgot the $;
}
EOF
--error 1
--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1
remove_file $MYSQL_TMP_DIR/mysqltest.sql;
# ----------------------------------------------------------------------------
# Test while with compare conditions
# ----------------------------------------------------------------------------
let $counter= 2;
while ($counter < 5)
{
echo counter is $counter;
inc $counter;
}
let $ifvar=;
while ($ifvar != stop)
{
if ($counter >= 7)
{
let $ifvar= stop;
}
echo counter is $counter;
inc $counter;
}
# ----------------------------------------------------------------------------
# Test while, { and }
# ----------------------------------------------------------------------------
......@@ -2438,15 +2628,15 @@ let $count= 0;
while ($run)
{
let $Field= query_get_value($show_statement, Field, $rowno);
if (`SELECT '$Field' = 'No such row'`)
if ($Field == No such row)
{
let $run= 0;
}
if (`SELECT '$Field' <> 'No such row'`)
if ($Field != No such row)
{
let $Type= query_get_value($show_statement, Type, $rowno);
let $Null= query_get_value($show_statement, Null, $rowno);
if (`SELECT '$Null' = 'YES'`)
if ($Null == YES)
{
inc $count;
}
......@@ -2529,26 +2719,6 @@ rmdir $MYSQLTEST_VARDIR/tmp/testdir;
--replace_result c:\\a.txt z
SELECT 'c:\\a.txt' AS col;
#
# Bug#32307 mysqltest - does not detect illegal if syntax
#
let $test= 1;
if ($test){
echo hej;
}
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
if ($mysql_errno != 1436)
{
echo ^ Should not be allowed!
}
EOF
--error 1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
# ----------------------------------------------------------------------------
# Test that -- is not allowed as comment, only as mysqltest builtin command
# ----------------------------------------------------------------------------
......
......@@ -5,7 +5,7 @@
# Only run this test if named pipe is avaliable
let $nmp= query_get_value("SHOW VARIABLES LIKE 'named_pipe'", Value, 1);
if (`SELECT '$nmp' != 'ON'`){
if ($nmp != ON){
skip No named pipe support;
}
......
......@@ -4,7 +4,7 @@
# Only run this test if shared memory is avaliable
let $shm= query_get_value("SHOW VARIABLES LIKE 'shared_memory'", Value, 1);
if (`SELECT '$shm' != 'ON'`){
if ($shm != ON){
skip No shm support;
}
let $shm_name= query_get_value("SHOW GLOBAL VARIABLES LIKE 'shared_memory_base_name'", Value, 1);
......
......@@ -3,7 +3,7 @@
# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set
# to the location of mysql_fix_privilege_tables.sql
if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`)
if (!$MYSQL_FIX_PRIVILEGE_TABLES)
{
skip Test need MYSQL_FIX_PRIVILEGE_TABLES;
}
......
......@@ -3,7 +3,7 @@
# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set
# to the location of mysql_fix_privilege_tables.sql
if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`)
if (!$MYSQL_FIX_PRIVILEGE_TABLES)
{
skip Test needs MYSQL_FIX_PRIVILEGE_TABLES;
}
......
......@@ -3,7 +3,7 @@
# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set
# to the location of mysql_fix_privilege_tables.sql
if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`)
if (!$MYSQL_FIX_PRIVILEGE_TABLES)
{
skip Test needs MYSQL_FIX_PRIVILEGE_TABLES;
}
......
......@@ -14,7 +14,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
use Test::Harness;
use File::Find;
use Getopt::Long;
......@@ -38,9 +37,10 @@ unit - Run unit tests in directory
my $big= $ENV{'MYTAP_CONFIG'} eq 'big';
my $opt_verbose;
my $result = GetOptions (
"big!" => \$big,
"verbose!" => \$Test::Harness::verbose,
"verbose!" => \$opt_verbose,
);
$ENV{'MYTAP_CONFIG'} = $big ? 'big' : '';
......@@ -60,6 +60,19 @@ Run all unit tests in the current directory and all subdirectories.
=cut
BEGIN {
# Test::Harness have been extensively rewritten in newer perl
# versions and is now just a backward compatibility wrapper
# (with a bug causing the HARNESS_PERL_SWITCHES to be mangled)
# Prefer to use TAP::Harness directly if available
if (eval "use TAP::Harness; 1") {
eval 'sub NEW_HARNESS { 1 }';
warn "using TAP::Harness";
} else {
eval "use Test::Harness; 1" or die "couldn't find Test::Harness!";
eval 'sub NEW_HARNESS { 0 }';
}
}
sub _find_test_files (@) {
my @dirs = @_;
......@@ -102,8 +115,19 @@ sub run_cmd (@) {
if (@files > 0) {
# Removing the first './' from the file names
foreach (@files) { s!^\./!! }
$ENV{'HARNESS_PERL_SWITCHES'} .= ' -e "exec @ARGV"';
runtests @files;
if (NEW_HARNESS())
{
my %args = ( exec => [ ], verbosity => $opt_verbose );
my $harness = TAP::Harness->new( \%args );
$harness->runtests(@files);
}
else
{
$ENV{'HARNESS_VERBOSE'} = $opt_verbose;
$ENV{'HARNESS_PERL_SWITCHES'} .= ' -e "exec @ARGV"';
runtests(@files);
}
}
}
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