Commit 64dc74a1 authored by unknown's avatar unknown

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


client/mysqltest.c:
  fixed bugs to make nested whiles to work
parent 6cddf470
...@@ -95,9 +95,13 @@ static FILE** cur_file; ...@@ -95,9 +95,13 @@ static FILE** cur_file;
static FILE** file_stack_end; static FILE** file_stack_end;
static uint lineno_stack[MAX_INCLUDE_DEPTH]; static uint lineno_stack[MAX_INCLUDE_DEPTH];
static char TMPDIR[FN_REFLEN]; 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 *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]; static uint global_expected_errno[MAX_EXPECTED_ERRORS];
DYNAMIC_ARRAY q_lines; DYNAMIC_ARRAY q_lines;
...@@ -121,7 +125,7 @@ typedef struct ...@@ -121,7 +125,7 @@ typedef struct
PARSER parser; PARSER parser;
MASTER_POS master_pos; 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; int false_block_depth = 0;
const char* result_file = 0; /* if set, all results are concated and const char* result_file = 0; /* if set, all results are concated and
compared against this file*/ compared against this file*/
...@@ -1091,13 +1095,14 @@ int do_done(struct st_query* q) ...@@ -1091,13 +1095,14 @@ int do_done(struct st_query* q)
q->type = Q_END_BLOCK; q->type = Q_END_BLOCK;
if (cur_block == block_stack) if (cur_block == block_stack)
die("Stray '}' - end of block before beginning"); die("Stray '}' - end of block before beginning");
if (block_ok) if (*block_ok--)
{
parser.current_line = *--cur_block; parser.current_line = *--cur_block;
}
else else
{ {
if (!--false_block_depth)
block_ok = 1;
++parser.current_line; ++parser.current_line;
--cur_block;
} }
return 0; return 0;
} }
...@@ -1109,11 +1114,14 @@ int do_while(struct st_query* q) ...@@ -1109,11 +1114,14 @@ int do_while(struct st_query* q)
VAR v; VAR v;
if (cur_block == block_stack_end) if (cur_block == block_stack_end)
die("Nesting too deeply"); die("Nesting too deeply");
if (!block_ok) if (!*block_ok)
{ {
++false_block_depth; ++false_block_depth;
*++block_ok = 0;
*cur_block++ = parser.current_line++;
return 0; return 0;
} }
expr_start = strchr(p, '('); expr_start = strchr(p, '(');
if (!expr_start) if (!expr_start)
die("missing '(' in while"); die("missing '(' in while");
...@@ -1124,9 +1132,11 @@ int do_while(struct st_query* q) ...@@ -1124,9 +1132,11 @@ int do_while(struct st_query* q)
*cur_block++ = parser.current_line++; *cur_block++ = parser.current_line++;
if (!v.int_val) if (!v.int_val)
{ {
block_ok = 0; *++block_ok = 0;
false_block_depth = 1; false_block_depth++;
} }
else
*++block_ok = 1;
return 0; return 0;
} }
...@@ -1837,7 +1847,11 @@ int main(int argc, char** argv) ...@@ -1837,7 +1847,11 @@ int main(int argc, char** argv)
INIT_Q_LINES); INIT_Q_LINES);
memset(block_stack, 0, sizeof(block_stack)); memset(block_stack, 0, sizeof(block_stack));
block_stack_end = block_stack + BLOCK_STACK_DEPTH; 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; cur_block = block_stack;
block_ok = block_ok_stack;
*block_ok = 1;
init_dynamic_string(&ds_res, "", 0, 65536); init_dynamic_string(&ds_res, "", 0, 65536);
parse_args(argc, argv); parse_args(argc, argv);
init_var_hash(); init_var_hash();
...@@ -1861,7 +1875,7 @@ int main(int argc, char** argv) ...@@ -1861,7 +1875,7 @@ int main(int argc, char** argv)
int current_line_inc = 1, processed = 0; int current_line_inc = 1, processed = 0;
if (q->type == Q_UNKNOWN || q->type == Q_COMMENT_WITH_COMMAND) if (q->type == Q_UNKNOWN || q->type == Q_COMMENT_WITH_COMMAND)
get_query_type(q); get_query_type(q);
if (block_ok) if (*block_ok)
{ {
processed = 1; processed = 1;
switch (q->type) { 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