Commit 6fb150b8 authored by unknown's avatar unknown

mysql-test-run.sh remove *.reject before testing

mrg000001.test	clean merge tables for other tests to work
mysqltest.c	always compare vs. @result if any
mrg000002.result	corrected


mysql-test/r/mrg000002.result:
  corrected
client/mysqltest.c:
  always compare vs. @result if any
mysql-test/t/mrg000001.test:
  clean merge tables for other tests to work
mysql-test/mysql-test-run.sh:
  remove *.reject before testing
parent e94ec730
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
...@@ -84,7 +84,7 @@ int false_block_depth = 0; ...@@ -84,7 +84,7 @@ 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*/
typedef struct typedef struct
{ {
char* name; char* name;
char* str_val; char* str_val;
...@@ -208,7 +208,7 @@ int dyn_string_cmp(DYN_STRING* ds, const char* fname) ...@@ -208,7 +208,7 @@ int dyn_string_cmp(DYN_STRING* ds, const char* fname)
die("Could not open %s: errno = %d", fname, errno); die("Could not open %s: errno = %d", fname, errno);
if(my_read(fd, (byte*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP))) if(my_read(fd, (byte*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP)))
die("read failed"); die("read failed");
res = (memcmp(tmp, ds->str, stat_info.st_size)) ? 1 : 0; res = (memcmp(tmp, ds->str, stat_info.st_size)) ? 1 : 0;
my_free((gptr)tmp, MYF(0)); my_free((gptr)tmp, MYF(0));
my_close(fd, MYF(0)); my_close(fd, MYF(0));
return res; return res;
...@@ -263,7 +263,7 @@ VAR* var_get(char* var_name, char* var_name_end, int raw) ...@@ -263,7 +263,7 @@ VAR* var_get(char* var_name, char* var_name_end, int raw)
if(var_name_end) if(var_name_end)
*var_name_end = 0; *var_name_end = 0;
die("Unsupported variable name: %s", var_name); die("Unsupported variable name: %s", var_name);
return 0; return 0;
} }
int var_set(char* var_name, char* var_name_end, char* var_val, int var_set(char* var_name, char* var_name_end, char* var_val,
...@@ -306,7 +306,7 @@ int open_file(const char* name) ...@@ -306,7 +306,7 @@ int open_file(const char* name)
die("Source directives are nesting too deep"); die("Source directives are nesting too deep");
if(!(*cur_file = fopen(name, "r"))) if(!(*cur_file = fopen(name, "r")))
die("Could not read '%s': errno %d\n", name, errno); die("Could not read '%s': errno %d\n", name, errno);
return 0; return 0;
} }
...@@ -321,7 +321,7 @@ int do_source(struct query* q) ...@@ -321,7 +321,7 @@ int do_source(struct query* q)
while(*p && !isspace(*p)) while(*p && !isspace(*p))
p++; p++;
*p = 0; *p = 0;
return open_file(name); return open_file(name);
} }
...@@ -343,7 +343,7 @@ int eval_expr(VAR* v, char* p, char* p_end) ...@@ -343,7 +343,7 @@ int eval_expr(VAR* v, char* p, char* p_end)
v->str_val_len = p_end ? p_end - p : strlen(p); v->str_val_len = p_end ? p_end - p : strlen(p);
return 0; return 0;
} }
if(p_end) if(p_end)
*p_end = 0; *p_end = 0;
die("Invalid expr: %s", p); die("Invalid expr: %s", p);
...@@ -450,7 +450,7 @@ int do_sleep(struct query* q) ...@@ -450,7 +450,7 @@ int do_sleep(struct query* q)
char *p_end; char *p_end;
p++; p++;
p_end = p + 6; p_end = p + 6;
for(;p <= p_end; ++p) for(;p <= p_end; ++p)
{ {
c = *p - '0'; c = *p - '0';
...@@ -481,7 +481,7 @@ int select_connection(struct query* q) ...@@ -481,7 +481,7 @@ int select_connection(struct query* q)
while(*p && !isspace(*p)) while(*p && !isspace(*p))
p++; p++;
*p = 0; *p = 0;
for(con = cons; con < next_con; con++) for(con = cons; con < next_con; con++)
if(!strcmp(con->name, name)) if(!strcmp(con->name, name))
{ {
...@@ -505,7 +505,7 @@ int close_connection(struct query* q) ...@@ -505,7 +505,7 @@ int close_connection(struct query* q)
while(*p && !isspace(*p)) while(*p && !isspace(*p))
p++; p++;
*p = 0; *p = 0;
for(con = cons; con < next_con; con++) for(con = cons; con < next_con; con++)
if(!strcmp(con->name, name)) if(!strcmp(con->name, name))
{ {
...@@ -522,7 +522,7 @@ int close_connection(struct query* q) ...@@ -522,7 +522,7 @@ int close_connection(struct query* q)
future to handle quotes. For now we assume that anything that is not future to handle quotes. For now we assume that anything that is not
a comma, a space or ) belongs to the argument. space is a chopper, comma or a comma, a space or ) belongs to the argument. space is a chopper, comma or
) are delimiters/terminators ) are delimiters/terminators
*/ */
char* safe_get_param(char* str, char** arg, const char* msg) char* safe_get_param(char* str, char** arg, const char* msg)
{ {
while(*str && isspace(*str)) str++; while(*str && isspace(*str)) str++;
...@@ -534,7 +534,7 @@ char* safe_get_param(char* str, char** arg, const char* msg) ...@@ -534,7 +534,7 @@ char* safe_get_param(char* str, char** arg, const char* msg)
} }
if(!*str) if(!*str)
die(msg); die(msg);
*str++ = 0; *str++ = 0;
return str; return str;
} }
...@@ -602,7 +602,7 @@ int do_while(struct query* q) ...@@ -602,7 +602,7 @@ int do_while(struct query* q)
{ {
++false_block_depth; ++false_block_depth;
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");
...@@ -610,13 +610,13 @@ int do_while(struct query* q) ...@@ -610,13 +610,13 @@ int do_while(struct query* q)
if(!expr_end) if(!expr_end)
die("missing ')' in while"); die("missing ')' in while");
eval_expr(&v, ++expr_start, --expr_end); eval_expr(&v, ++expr_start, --expr_end);
*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 = 1;
} }
return 0; return 0;
} }
void close_cons() void close_cons()
...@@ -635,7 +635,7 @@ int safe_copy_unescape(char* dest, char* src, int size) ...@@ -635,7 +635,7 @@ int safe_copy_unescape(char* dest, char* src, int size)
enum { ST_NORMAL, ST_ESCAPED, ST_HEX2} state = ST_NORMAL ; enum { ST_NORMAL, ST_ESCAPED, ST_HEX2} state = ST_NORMAL ;
size--; /* just to make life easier */ size--; /* just to make life easier */
for(; p_dest - size < dest && p_src - size < src for(; p_dest - size < dest && p_src - size < src
&& (c = *p_src) != '\n' && c; ++p_src ) && (c = *p_src) != '\n' && c; ++p_src )
{ {
...@@ -672,7 +672,7 @@ int safe_copy_unescape(char* dest, char* src, int size) ...@@ -672,7 +672,7 @@ int safe_copy_unescape(char* dest, char* src, int size)
state = ST_NORMAL; state = ST_NORMAL;
break; break;
} }
} }
...@@ -688,7 +688,7 @@ int read_line(char* buf, int size) ...@@ -688,7 +688,7 @@ int read_line(char* buf, int size)
enum {R_NORMAL, R_Q1, R_ESC_Q_Q1, R_ESC_Q_Q2, enum {R_NORMAL, R_Q1, R_ESC_Q_Q1, R_ESC_Q_Q2,
R_ESC_SLASH_Q1, R_ESC_SLASH_Q2, R_ESC_SLASH_Q1, R_ESC_SLASH_Q2,
R_Q2, R_COMMENT, R_LINE_START} state = R_LINE_START; R_Q2, R_COMMENT, R_LINE_START} state = R_LINE_START;
for(; p < buf_end ;) for(; p < buf_end ;)
{ {
no_save = 0; no_save = 0;
...@@ -696,7 +696,7 @@ int read_line(char* buf, int size) ...@@ -696,7 +696,7 @@ int read_line(char* buf, int size)
if(feof(*cur_file)) if(feof(*cur_file))
{ {
fclose(*cur_file); fclose(*cur_file);
if(cur_file == file_stack) if(cur_file == file_stack)
return 1; return 1;
else else
...@@ -705,7 +705,7 @@ int read_line(char* buf, int size) ...@@ -705,7 +705,7 @@ int read_line(char* buf, int size)
continue; continue;
} }
} }
switch(state) switch(state)
{ {
case R_NORMAL: case R_NORMAL:
...@@ -722,14 +722,14 @@ int read_line(char* buf, int size) ...@@ -722,14 +722,14 @@ int read_line(char* buf, int size)
state = R_Q2; state = R_Q2;
else if(c == '\n') else if(c == '\n')
state = R_LINE_START; state = R_LINE_START;
break; break;
case R_COMMENT: case R_COMMENT:
no_save = 1; no_save = 1;
if(c == '\n') if(c == '\n')
state = R_LINE_START; state = R_LINE_START;
break; break;
case R_LINE_START: case R_LINE_START:
if(c == '#') if(c == '#')
{ {
...@@ -752,7 +752,7 @@ int read_line(char* buf, int size) ...@@ -752,7 +752,7 @@ int read_line(char* buf, int size)
else else
state = R_NORMAL; state = R_NORMAL;
break; break;
case R_Q1: case R_Q1:
if(c == '\'') if(c == '\'')
state = R_ESC_Q_Q1; state = R_ESC_Q_Q1;
...@@ -771,7 +771,7 @@ int read_line(char* buf, int size) ...@@ -771,7 +771,7 @@ int read_line(char* buf, int size)
case R_ESC_SLASH_Q1: case R_ESC_SLASH_Q1:
state = R_Q1; state = R_Q1;
break; break;
case R_Q2: case R_Q2:
if(c == '"') if(c == '"')
state = R_ESC_Q_Q2; state = R_ESC_Q_Q2;
...@@ -795,7 +795,7 @@ int read_line(char* buf, int size) ...@@ -795,7 +795,7 @@ int read_line(char* buf, int size)
if(!no_save) if(!no_save)
*p++ = c; *p++ = c;
} }
return feof(*cur_file); return feof(*cur_file);
} }
int read_query(struct query** q_ptr) int read_query(struct query** q_ptr)
...@@ -813,7 +813,7 @@ int read_query(struct query** q_ptr) ...@@ -813,7 +813,7 @@ int read_query(struct query** q_ptr)
|| insert_dynamic(&q_lines, (gptr)&q) || insert_dynamic(&q_lines, (gptr)&q)
) )
die("Out of memory"); die("Out of memory");
q->record_file[0] = 0; q->record_file[0] = 0;
q->abort_on_error = 1; q->abort_on_error = 1;
q->has_result_set = 0; q->has_result_set = 0;
...@@ -845,15 +845,15 @@ int read_query(struct query** q_ptr) ...@@ -845,15 +845,15 @@ int read_query(struct query** q_ptr)
while(!isspace(c = *p) && while(!isspace(c = *p) &&
p1 < q->record_file + sizeof(q->record_file) - 1) p1 < q->record_file + sizeof(q->record_file) - 1)
*p1++ = *p++; *p1++ = *p++;
*p1 = 0; *p1 = 0;
} }
while(*p && isspace(*p)) p++; while(*p && isspace(*p)) p++;
p1 = q->q; p1 = q->q;
while(*p && !isspace(*p)) while(*p && !isspace(*p))
*p1++ = *p++; *p1++ = *p++;
q->first_word_len = p1 - q->q; q->first_word_len = p1 - q->q;
strcpy(p1, p); strcpy(p1, p);
parser.read_lines++; parser.read_lines++;
...@@ -895,9 +895,9 @@ void verbose_msg(const char* fmt, ...) ...@@ -895,9 +895,9 @@ void verbose_msg(const char* fmt, ...)
va_list args; va_list args;
if(!verbose) return; if(!verbose) return;
va_start(args, fmt); va_start(args, fmt);
fprintf(stderr, "%s: ", my_progname); fprintf(stderr, "%s: ", my_progname);
vfprintf(stderr, fmt, args); vfprintf(stderr, fmt, args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
...@@ -1054,14 +1054,14 @@ int run_query(MYSQL* mysql, struct query* q) ...@@ -1054,14 +1054,14 @@ int run_query(MYSQL* mysql, struct query* q)
DYN_STRING *ds = &ds_res; DYN_STRING *ds = &ds_res;
DYN_STRING ds_tmp; DYN_STRING ds_tmp;
dyn_string_init(&ds_tmp); dyn_string_init(&ds_tmp);
if( q->record_file[0]) if( q->record_file[0])
{ {
ds = &ds_tmp; ds = &ds_tmp;
} }
if(mysql_query(mysql, q->q)) if(mysql_query(mysql, q->q))
{ {
if(q->abort_on_error) if(q->abort_on_error)
...@@ -1076,11 +1076,11 @@ int run_query(MYSQL* mysql, struct query* q) ...@@ -1076,11 +1076,11 @@ int run_query(MYSQL* mysql, struct query* q)
%d instead of %d", q->q, mysql_errno(mysql), q->expected_errno); %d instead of %d", q->q, mysql_errno(mysql), q->expected_errno);
goto end; goto end;
} }
verbose_msg("query '%s' failed: %s", q->q, mysql_error(mysql)); verbose_msg("query '%s' failed: %s", q->q, mysql_error(mysql));
/* if we do not abort on error, failure to run the query does /* if we do not abort on error, failure to run the query does
not fail the whole test case not fail the whole test case
*/ */
goto end; goto end;
} }
} }
...@@ -1092,7 +1092,7 @@ int run_query(MYSQL* mysql, struct query* q) ...@@ -1092,7 +1092,7 @@ int run_query(MYSQL* mysql, struct query* q)
q->q, q->expected_errno); q->q, q->expected_errno);
goto end; goto end;
} }
if(!(res = mysql_store_result(mysql)) && mysql_field_count(mysql)) if(!(res = mysql_store_result(mysql)) && mysql_field_count(mysql))
{ {
...@@ -1107,7 +1107,7 @@ int run_query(MYSQL* mysql, struct query* q) ...@@ -1107,7 +1107,7 @@ int run_query(MYSQL* mysql, struct query* q)
} }
if(!res) goto end; if(!res) goto end;
fields = mysql_fetch_fields(res); fields = mysql_fetch_fields(res);
num_fields = mysql_num_fields(res); num_fields = mysql_num_fields(res);
for( i = 0; i < num_fields; i++) for( i = 0; i < num_fields; i++)
...@@ -1126,17 +1126,17 @@ int run_query(MYSQL* mysql, struct query* q) ...@@ -1126,17 +1126,17 @@ int run_query(MYSQL* mysql, struct query* q)
{ {
val = (char*)row[i]; val = (char*)row[i];
len = lengths[i]; len = lengths[i];
if(!val) if(!val)
{ {
val = (char*)"NULL"; val = (char*)"NULL";
len = 4; len = 4;
} }
dyn_string_append(ds, val, len); dyn_string_append(ds, val, len);
dyn_string_append(ds, "\t", 1); dyn_string_append(ds, "\t", 1);
} }
dyn_string_append(ds, "\n", 1); dyn_string_append(ds, "\n", 1);
} }
...@@ -1147,11 +1147,11 @@ int run_query(MYSQL* mysql, struct query* q) ...@@ -1147,11 +1147,11 @@ int run_query(MYSQL* mysql, struct query* q)
if(!result_file) if(!result_file)
str_to_file(q->record_file, ds->str, ds->len); str_to_file(q->record_file, ds->str, ds->len);
} }
else if(!result_file && q->record_file[0]) else if(q->record_file[0])
{ {
error = check_result(ds, q->record_file); error = check_result(ds, q->record_file);
} }
end: end:
if(res) mysql_free_result(res); if(res) mysql_free_result(res);
return error; return error;
...@@ -1164,7 +1164,7 @@ int check_first_word(struct query* q, const char* word, int len) ...@@ -1164,7 +1164,7 @@ int check_first_word(struct query* q, const char* word, int len)
if(len != q->first_word_len) if(len != q->first_word_len)
return 0; return 0;
p = word; p = word;
end = p + len; end = p + len;
p1 = q->q; p1 = q->q;
...@@ -1220,7 +1220,7 @@ void get_query_type(struct query* q) ...@@ -1220,7 +1220,7 @@ void get_query_type(struct query* q)
else if(check_first_word(q, "disconnect", 10)) else if(check_first_word(q, "disconnect", 10))
q->type = Q_DISCONNECT; q->type = Q_DISCONNECT;
break; break;
} }
} }
...@@ -1234,7 +1234,7 @@ int main(int argc, char** argv) ...@@ -1234,7 +1234,7 @@ int main(int argc, char** argv)
cons_end = cons + MAX_CONS; cons_end = cons + MAX_CONS;
next_con = cons + 1; next_con = cons + 1;
cur_con = cons; cur_con = cons;
memset(file_stack, 0, sizeof(file_stack)); memset(file_stack, 0, sizeof(file_stack));
file_stack_end = file_stack + MAX_INCLUDE_DEPTH; file_stack_end = file_stack + MAX_INCLUDE_DEPTH;
cur_file = file_stack; cur_file = file_stack;
...@@ -1248,17 +1248,17 @@ int main(int argc, char** argv) ...@@ -1248,17 +1248,17 @@ int main(int argc, char** argv)
if(!*cur_file) if(!*cur_file)
*cur_file = stdin; *cur_file = stdin;
if(!( mysql_init(&cur_con->mysql))) if(!( mysql_init(&cur_con->mysql)))
die("Failed in mysql_init()"); die("Failed in mysql_init()");
mysql_options(&cur_con->mysql, MYSQL_READ_DEFAULT_GROUP, "mysql"); mysql_options(&cur_con->mysql, MYSQL_READ_DEFAULT_GROUP, "mysql");
cur_con->name = my_strdup("default", MYF(MY_WME)); cur_con->name = my_strdup("default", MYF(MY_WME));
if(!cur_con->name) if(!cur_con->name)
die("Out of memory"); die("Out of memory");
if(!mysql_real_connect(&cur_con->mysql, host, if(!mysql_real_connect(&cur_con->mysql, host,
user, pass, db, port, unix_sock, user, pass, db, port, unix_sock,
0)) 0))
...@@ -1288,7 +1288,7 @@ int main(int argc, char** argv) ...@@ -1288,7 +1288,7 @@ int main(int argc, char** argv)
default: processed = 0; break; default: processed = 0; break;
} }
} }
if(!processed) if(!processed)
{ {
current_line_inc = 0; current_line_inc = 0;
...@@ -1309,18 +1309,18 @@ int main(int argc, char** argv) ...@@ -1309,18 +1309,18 @@ int main(int argc, char** argv)
{ {
if(!record) if(!record)
error |= check_result(&ds_res, result_file); error |= check_result(&ds_res, result_file);
else else
str_to_file(result_file, ds_res.str, ds_res.len); str_to_file(result_file, ds_res.str, ds_res.len);
} }
dyn_string_end(&ds_res); dyn_string_end(&ds_res);
if (!silent) { if (!silent) {
if(error) if(error)
printf("not ok\n"); printf("not ok\n");
else else
printf("ok\n"); printf("ok\n");
} }
exit(error); exit(error);
return error; return error;
} }
...@@ -339,7 +339,7 @@ stop_slave () ...@@ -339,7 +339,7 @@ stop_slave ()
if [ -f $SLAVE_MYPID ] ; then if [ -f $SLAVE_MYPID ] ; then
echo "slave refused to die, resorting to SIGKILL murder" echo "slave refused to die, resorting to SIGKILL murder"
kill -9 `cat $SLAVE_MYPID` kill -9 `cat $SLAVE_MYPID`
rm -f $SLAVE_MYPID $RM -f $SLAVE_MYPID
else else
echo "slave responded to SIGTERM " echo "slave responded to SIGTERM "
fi fi
...@@ -360,7 +360,7 @@ stop_master () ...@@ -360,7 +360,7 @@ stop_master ()
if [ -f $MASTER_MYPID ] ; then if [ -f $MASTER_MYPID ] ; then
echo "master refused to die, resorting to SIGKILL murder" echo "master refused to die, resorting to SIGKILL murder"
kill -9 `cat $MASTER_MYPID` kill -9 `cat $MASTER_MYPID`
rm -f $MASTER_MYPID $RM -f $MASTER_MYPID
else else
echo "master responded to SIGTERM " echo "master responded to SIGTERM "
fi fi
...@@ -450,6 +450,7 @@ run_testcase () ...@@ -450,6 +450,7 @@ run_testcase ()
cd $MYSQL_TEST_DIR cd $MYSQL_TEST_DIR
if [ -f $tf ] ; then if [ -f $tf ] ; then
$RM -f r/$tname.*.reject
mytime=`$TIME -p $MYSQL_TEST -R r/$tname.result $extra_flags \ mytime=`$TIME -p $MYSQL_TEST -R r/$tname.result $extra_flags \
< $tf 2> $TIMEFILE` < $tf 2> $TIMEFILE`
res=$? res=$?
......
...@@ -15,3 +15,7 @@ INSERT INTO test1 VALUES (11,20),(13,43),(15,11),(17,22),(19,37); ...@@ -15,3 +15,7 @@ INSERT INTO test1 VALUES (11,20),(13,43),(15,11),(17,22),(19,37);
INSERT INTO test2 VALUES (12,25),(14,31),(16,42),(18,27),(10,30); INSERT INTO test2 VALUES (12,25),(14,31),(16,42),(18,27),(10,30);
@r/mrg000001.result SELECT * from test3 where incr in (1,2,3,4) order by othr; @r/mrg000001.result SELECT * from test3 where incr in (1,2,3,4) order by othr;
DROP TABLE IF EXISTS test3;
DROP TABLE IF EXISTS test1;
DROP TABLE IF EXISTS test2;
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