fixed bugs in mysqltest to get nested while loops to work

added multi-delete test case that does not work - something for Sinisa to fix
parent 697f4d5a
......@@ -95,9 +95,13 @@ static FILE** cur_file;
static FILE** file_stack_end;
static uint lineno_stack[MAX_INCLUDE_DEPTH];
static char TMPDIR[FN_REFLEN];
static int *block_ok_stack_end;
static int block_stack[BLOCK_STACK_DEPTH];
static int *cur_block, *block_stack_end;
static int block_stack[BLOCK_STACK_DEPTH];
static int block_ok_stack[BLOCK_STACK_DEPTH];
static uint global_expected_errno[MAX_EXPECTED_ERRORS];
DYNAMIC_ARRAY q_lines;
......@@ -121,7 +125,7 @@ typedef struct
PARSER parser;
MASTER_POS master_pos;
int block_ok = 1; /* set to 0 if the current block should not be executed */
int* block_ok; /* set to 0 if the current block should not be executed */
int false_block_depth = 0;
const char* result_file = 0; /* if set, all results are concated and
compared against this file*/
......@@ -1091,13 +1095,14 @@ int do_done(struct st_query* q)
q->type = Q_END_BLOCK;
if (cur_block == block_stack)
die("Stray '}' - end of block before beginning");
if (block_ok)
if (*block_ok--)
{
parser.current_line = *--cur_block;
}
else
{
if (!--false_block_depth)
block_ok = 1;
++parser.current_line;
--cur_block;
}
return 0;
}
......@@ -1109,11 +1114,14 @@ int do_while(struct st_query* q)
VAR v;
if (cur_block == block_stack_end)
die("Nesting too deeply");
if (!block_ok)
if (!*block_ok)
{
++false_block_depth;
*++block_ok = 0;
*cur_block++ = parser.current_line++;
return 0;
}
expr_start = strchr(p, '(');
if (!expr_start)
die("missing '(' in while");
......@@ -1124,9 +1132,11 @@ int do_while(struct st_query* q)
*cur_block++ = parser.current_line++;
if (!v.int_val)
{
block_ok = 0;
false_block_depth = 1;
*++block_ok = 0;
false_block_depth++;
}
else
*++block_ok = 1;
return 0;
}
......@@ -1837,7 +1847,11 @@ int main(int argc, char** argv)
INIT_Q_LINES);
memset(block_stack, 0, sizeof(block_stack));
block_stack_end = block_stack + BLOCK_STACK_DEPTH;
memset(block_ok_stack, 0, sizeof(block_stack));
block_ok_stack_end = block_ok_stack + BLOCK_STACK_DEPTH;
cur_block = block_stack;
block_ok = block_ok_stack;
*block_ok = 1;
init_dynamic_string(&ds_res, "", 0, 65536);
parse_args(argc, argv);
init_var_hash();
......@@ -1861,7 +1875,7 @@ int main(int argc, char** argv)
int current_line_inc = 1, processed = 0;
if (q->type == Q_UNKNOWN || q->type == Q_COMMENT_WITH_COMMAND)
get_query_type(q);
if (block_ok)
if (*block_ok)
{
processed = 1;
switch (q->type) {
......
id1 t
1 3
2 2
3 1
id2 t
3 3
3 2
3 1
2 3
2 2
2 1
1 3
1 2
1 1
id3 t
3 3
3 2
3 1
2 3
2 2
2 1
1 3
1 2
1 1
drop table if exists t1,t2,t3;
create table t1(id1 int not null auto_increment primary key, t char(12));
create table t2(id2 int not null, t char(12), index(id2));
create table t3(id3 int not null, t char(12), index(id3));
let $1 = 3;
while ($1)
{
let $2 = 3;
eval insert into t1(t) values ('$1');
while ($2)
{
eval insert into t2(id2,t) values ($1,'$2');
eval insert into t3(id3,t) values ($1,'$2');
dec $2;
}
dec $1;
}
select * from t1;
select * from t2;
select * from t3;
delete from t1,t2 where t1.id = t2.id and t1.id = 3;
select * from t1;
select * from t2;
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