summaryrefslogtreecommitdiff
path: root/client/mysqltest.c
diff options
context:
space:
mode:
authorunknown <hartmut@mysql.com>2005-09-30 18:16:57 +0200
committerunknown <hartmut@mysql.com>2005-09-30 18:16:57 +0200
commit7d3c939e81f8da8c9f57421864e07b4315f03f57 (patch)
treee8f6638a94b8cca6df059c2a836b5b37761c6195 /client/mysqltest.c
parent0585fcbe639000fa9e4210e2a4149570268f8a72 (diff)
parent39ba8376e6a3331a2c75fb3f9f5fbd6ff42f6a62 (diff)
downloadmariadb-git-7d3c939e81f8da8c9f57421864e07b4315f03f57.tar.gz
Merge hholzgraefe@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/hartmut/projects/mysql/dev/5.0 ndb/tools/ndb_config.cpp: Auto merged
Diffstat (limited to 'client/mysqltest.c')
-rw-r--r--client/mysqltest.c81
1 files changed, 45 insertions, 36 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index fdc1dec6dc1..497c2de5e36 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -59,12 +59,16 @@
#include <stdarg.h>
#include <sys/stat.h>
#include <violite.h>
-#include <regex.h> /* Our own version of lib */
+#include "my_regex.h" /* Our own version of lib */
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifndef WEXITSTATUS
-# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+# ifdef __WIN__
+# define WEXITSTATUS(stat_val) (stat_val)
+# else
+# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+# endif
#endif
/* MAX_QUERY is 256K -- there is a test in sp-big that is >128K */
#define MAX_QUERY (256*1024)
@@ -208,7 +212,7 @@ static int got_end_timer= FALSE;
static void timer_output(void);
static ulonglong timer_now(void);
-static regex_t ps_re; /* Holds precompiled re for valid PS statements */
+static my_regex_t ps_re; /* Holds precompiled re for valid PS statements */
static void ps_init_re(void);
static int ps_match_re(char *);
static char *ps_eprint(int);
@@ -549,7 +553,7 @@ static void close_cons()
static void close_files()
{
DBUG_ENTER("close_files");
- for (; cur_file != (file_stack-1) ; cur_file--)
+ for (; cur_file >= file_stack; cur_file--)
{
DBUG_PRINT("info", ("file_name: %s", cur_file->file_name));
if (cur_file->file && cur_file->file != stdin)
@@ -609,7 +613,8 @@ static void die(const char *fmt, ...)
if (cur_file && cur_file != file_stack)
fprintf(stderr, "In included file \"%s\": ",
cur_file->file_name);
- fprintf(stderr, "At line %u: ", start_lineno);
+ if (start_lineno != 0)
+ fprintf(stderr, "At line %u: ", start_lineno);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
fflush(stderr);
@@ -642,7 +647,9 @@ static void verbose_msg(const char *fmt, ...)
va_start(args, fmt);
- fprintf(stderr, "mysqltest: At line %u: ", start_lineno);
+ fprintf(stderr, "mysqltest: ");
+ if (start_lineno > 0)
+ fprintf(stderr, "At line %u: ", start_lineno);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);
@@ -1097,8 +1104,8 @@ static void do_exec(struct st_query *query)
(query->expected_errno[i].code.errnum == status))
{
ok= 1;
- verbose_msg("command \"%s\" failed with expected error: %d",
- cmd, status);
+ DBUG_PRINT("info", ("command \"%s\" failed with expected error: %d",
+ cmd, status));
}
}
if (!ok)
@@ -1383,9 +1390,7 @@ int do_sync_with_master2(long offset)
int rpl_parse;
if (!master_pos.file[0])
- {
- die("Line %u: Calling 'sync_with_master' without calling 'save_master_pos'", start_lineno);
- }
+ die("Calling 'sync_with_master' without calling 'save_master_pos'");
rpl_parse= mysql_rpl_parse_enabled(mysql);
mysql_disable_rpl_parse(mysql);
@@ -1395,14 +1400,13 @@ int do_sync_with_master2(long offset)
wait_for_position:
if (mysql_query(mysql, query_buf))
- die("line %u: failed in %s: %d: %s", start_lineno, query_buf,
- mysql_errno(mysql), mysql_error(mysql));
+ die("failed in %s: %d: %s", query_buf, mysql_errno(mysql),
+ mysql_error(mysql));
if (!(last_result= res= mysql_store_result(mysql)))
- die("line %u: mysql_store_result() returned NULL for '%s'", start_lineno,
- query_buf);
+ die("mysql_store_result() returned NULL for '%s'", query_buf);
if (!(row= mysql_fetch_row(res)))
- die("line %u: empty result in %s", start_lineno, query_buf);
+ die("empty result in %s", query_buf);
if (!row[0])
{
/*
@@ -1410,10 +1414,7 @@ wait_for_position:
SLAVE has been issued ?
*/
if (tries++ == 3)
- {
- die("line %u: could not sync with master ('%s' returned NULL)",
- start_lineno, query_buf);
- }
+ die("could not sync with master ('%s' returned NULL)", query_buf);
sleep(1); /* So at most we will wait 3 seconds and make 4 tries */
mysql_free_result(res);
goto wait_for_position;
@@ -1459,10 +1460,9 @@ int do_save_master_pos()
mysql_errno(mysql), mysql_error(mysql));
if (!(last_result =res = mysql_store_result(mysql)))
- die("line %u: mysql_store_result() retuned NULL for '%s'", start_lineno,
- query);
+ die("mysql_store_result() retuned NULL for '%s'", query);
if (!(row = mysql_fetch_row(res)))
- die("line %u: empty result in show master status", start_lineno);
+ die("empty result in show master status");
strnmov(master_pos.file, row[0], sizeof(master_pos.file)-1);
master_pos.pos = strtoul(row[1], (char**) 0, 10);
mysql_free_result(res); last_result=0;
@@ -2768,7 +2768,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
fn_format(buff, argument, "", "", 4);
DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
if (!(cur_file->file=
- my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME))))
+ my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0))))
die("Could not open %s: errno = %d", buff, errno);
cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
break;
@@ -2874,7 +2874,7 @@ void str_to_file(const char *fname, char *str, int size)
fname=buff;
}
fn_format(buff,fname,"","",4);
-
+
if ((fd = my_open(buff, O_WRONLY | O_CREAT | O_TRUNC,
MYF(MY_WME | MY_FFNF))) < 0)
die("Could not open %s: errno = %d", buff, errno);
@@ -3767,12 +3767,13 @@ static void ps_init_re(void)
"[[:space:]]*UPDATE[[:space:]]+MULTI[[:space:]]|"
"[[:space:]]*INSERT[[:space:]]+SELECT[[:space:]])";
- int err= regcomp(&ps_re, ps_re_str, (REG_EXTENDED | REG_ICASE | REG_NOSUB),
- &my_charset_latin1);
+ int err= my_regcomp(&ps_re, ps_re_str,
+ (REG_EXTENDED | REG_ICASE | REG_NOSUB),
+ &my_charset_latin1);
if (err)
{
char erbuf[100];
- int len= regerror(err, &ps_re, erbuf, sizeof(erbuf));
+ int len= my_regerror(err, &ps_re, erbuf, sizeof(erbuf));
fprintf(stderr, "error %s, %d/%d `%s'\n",
ps_eprint(err), len, (int)sizeof(erbuf), erbuf);
exit(1);
@@ -3782,7 +3783,7 @@ static void ps_init_re(void)
static int ps_match_re(char *stmt_str)
{
- int err= regexec(&ps_re, stmt_str, (size_t)0, NULL, 0);
+ int err= my_regexec(&ps_re, stmt_str, (size_t)0, NULL, 0);
if (err == 0)
return 1;
@@ -3791,7 +3792,7 @@ static int ps_match_re(char *stmt_str)
else
{
char erbuf[100];
- int len= regerror(err, &ps_re, erbuf, sizeof(erbuf));
+ int len= my_regerror(err, &ps_re, erbuf, sizeof(erbuf));
fprintf(stderr, "error %s, %d/%d `%s'\n",
ps_eprint(err), len, (int)sizeof(erbuf), erbuf);
exit(1);
@@ -3801,7 +3802,7 @@ static int ps_match_re(char *stmt_str)
static char *ps_eprint(int err)
{
static char epbuf[100];
- size_t len= regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf));
+ size_t len= my_regerror(REG_ITOA|err, (my_regex_t *)NULL, epbuf, sizeof(epbuf));
assert(len <= sizeof(epbuf));
return(epbuf);
}
@@ -3809,7 +3810,7 @@ static char *ps_eprint(int err)
static void ps_free_reg(void)
{
- regfree(&ps_re);
+ my_regfree(&ps_re);
}
/****************************************************************************/
@@ -4304,12 +4305,20 @@ int main(int argc, char **argv)
if (res_info.st_size)
error|= (RESULT_CONTENT_MISMATCH | RESULT_LENGTH_MISMATCH);
}
- if (result_file && ds_res.length && !error)
+ if (ds_res.length && !error)
{
- if (!record)
- error |= check_result(&ds_res, result_file, q->require_file);
+ if (result_file)
+ {
+ if (!record)
+ error |= check_result(&ds_res, result_file, q->require_file);
+ else
+ str_to_file(result_file, ds_res.str, ds_res.length);
+ }
else
- str_to_file(result_file, ds_res.str, ds_res.length);
+ {
+ /* Print the result to stdout */
+ printf("%s", ds_res.str);
+ }
}
dynstr_free(&ds_res);