Commit 45f667cd authored by stewart@mysql.com's avatar stewart@mysql.com

Merge ssmith@bk-internal.mysql.com:/home/bk/mysql-4.1

into  mysql.com:/home/stewart/Documents/MySQL/4.1/main
parents b738727f 844d964f
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <violite.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 #ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
...@@ -188,7 +188,7 @@ static int got_end_timer= FALSE; ...@@ -188,7 +188,7 @@ static int got_end_timer= FALSE;
static void timer_output(void); static void timer_output(void);
static ulonglong timer_now(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 void ps_init_re(void);
static int ps_match_re(char *); static int ps_match_re(char *);
static char *ps_eprint(int); static char *ps_eprint(int);
...@@ -585,6 +585,7 @@ static void die(const char *fmt, ...) ...@@ -585,6 +585,7 @@ static void die(const char *fmt, ...)
if (cur_file && cur_file != file_stack) if (cur_file && cur_file != file_stack)
fprintf(stderr, "In included file \"%s\": ", fprintf(stderr, "In included file \"%s\": ",
cur_file->file_name); cur_file->file_name);
if (start_lineno != 0)
fprintf(stderr, "At line %u: ", start_lineno); fprintf(stderr, "At line %u: ", start_lineno);
vfprintf(stderr, fmt, args); vfprintf(stderr, fmt, args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
...@@ -618,7 +619,9 @@ static void verbose_msg(const char *fmt, ...) ...@@ -618,7 +619,9 @@ static void verbose_msg(const char *fmt, ...)
va_start(args, 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); vfprintf(stderr, fmt, args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
va_end(args); va_end(args);
...@@ -1068,8 +1071,8 @@ static void do_exec(struct st_query *query) ...@@ -1068,8 +1071,8 @@ static void do_exec(struct st_query *query)
(query->expected_errno[i].code.errnum == status)) (query->expected_errno[i].code.errnum == status))
{ {
ok= 1; ok= 1;
verbose_msg("command \"%s\" failed with expected error: %d", DBUG_PRINT("info", ("command \"%s\" failed with expected error: %d",
cmd, status); cmd, status));
} }
} }
if (!ok) if (!ok)
...@@ -1354,9 +1357,7 @@ int do_sync_with_master2(long offset) ...@@ -1354,9 +1357,7 @@ int do_sync_with_master2(long offset)
int rpl_parse; int rpl_parse;
if (!master_pos.file[0]) if (!master_pos.file[0])
{ die("Calling 'sync_with_master' without calling 'save_master_pos'");
die("Line %u: Calling 'sync_with_master' without calling 'save_master_pos'", start_lineno);
}
rpl_parse= mysql_rpl_parse_enabled(mysql); rpl_parse= mysql_rpl_parse_enabled(mysql);
mysql_disable_rpl_parse(mysql); mysql_disable_rpl_parse(mysql);
...@@ -1366,14 +1367,13 @@ int do_sync_with_master2(long offset) ...@@ -1366,14 +1367,13 @@ int do_sync_with_master2(long offset)
wait_for_position: wait_for_position:
if (mysql_query(mysql, query_buf)) if (mysql_query(mysql, query_buf))
die("line %u: failed in %s: %d: %s", start_lineno, query_buf, die("failed in %s: %d: %s", query_buf, mysql_errno(mysql),
mysql_errno(mysql), mysql_error(mysql)); mysql_error(mysql));
if (!(last_result= res= mysql_store_result(mysql))) if (!(last_result= res= mysql_store_result(mysql)))
die("line %u: mysql_store_result() returned NULL for '%s'", start_lineno, die("mysql_store_result() returned NULL for '%s'", query_buf);
query_buf);
if (!(row= mysql_fetch_row(res))) 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]) if (!row[0])
{ {
/* /*
...@@ -1381,10 +1381,7 @@ wait_for_position: ...@@ -1381,10 +1381,7 @@ wait_for_position:
SLAVE has been issued ? SLAVE has been issued ?
*/ */
if (tries++ == 3) if (tries++ == 3)
{ die("could not sync with master ('%s' returned NULL)", query_buf);
die("line %u: could not sync with master ('%s' returned NULL)",
start_lineno, query_buf);
}
sleep(1); /* So at most we will wait 3 seconds and make 4 tries */ sleep(1); /* So at most we will wait 3 seconds and make 4 tries */
mysql_free_result(res); mysql_free_result(res);
goto wait_for_position; goto wait_for_position;
...@@ -1430,10 +1427,9 @@ int do_save_master_pos() ...@@ -1430,10 +1427,9 @@ int do_save_master_pos()
mysql_errno(mysql), mysql_error(mysql)); mysql_errno(mysql), mysql_error(mysql));
if (!(last_result =res = mysql_store_result(mysql))) if (!(last_result =res = mysql_store_result(mysql)))
die("line %u: mysql_store_result() retuned NULL for '%s'", start_lineno, die("mysql_store_result() retuned NULL for '%s'", query);
query);
if (!(row = mysql_fetch_row(res))) 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); strnmov(master_pos.file, row[0], sizeof(master_pos.file)-1);
master_pos.pos = strtoul(row[1], (char**) 0, 10); master_pos.pos = strtoul(row[1], (char**) 0, 10);
mysql_free_result(res); last_result=0; mysql_free_result(res); last_result=0;
...@@ -2571,7 +2567,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -2571,7 +2567,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
fn_format(buff, argument, "", "", 4); fn_format(buff, argument, "", "", 4);
DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0); DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
if (!(cur_file->file= 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); die("Could not open %s: errno = %d", buff, errno);
cur_file->file_name= my_strdup(buff, MYF(MY_FAE)); cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
break; break;
...@@ -3589,12 +3585,13 @@ static void ps_init_re(void) ...@@ -3589,12 +3585,13 @@ static void ps_init_re(void)
"[[:space:]]*UPDATE[[:space:]]+MULTI[[:space:]]|" "[[:space:]]*UPDATE[[:space:]]+MULTI[[:space:]]|"
"[[:space:]]*INSERT[[:space:]]+SELECT[[:space:]])"; "[[:space:]]*INSERT[[:space:]]+SELECT[[:space:]])";
int err= regcomp(&ps_re, ps_re_str, (REG_EXTENDED | REG_ICASE | REG_NOSUB), int err= my_regcomp(&ps_re, ps_re_str,
(REG_EXTENDED | REG_ICASE | REG_NOSUB),
&my_charset_latin1); &my_charset_latin1);
if (err) if (err)
{ {
char erbuf[100]; 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", fprintf(stderr, "error %s, %d/%d `%s'\n",
ps_eprint(err), len, (int)sizeof(erbuf), erbuf); ps_eprint(err), len, (int)sizeof(erbuf), erbuf);
exit(1); exit(1);
...@@ -3604,7 +3601,7 @@ static void ps_init_re(void) ...@@ -3604,7 +3601,7 @@ static void ps_init_re(void)
static int ps_match_re(char *stmt_str) 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) if (err == 0)
return 1; return 1;
...@@ -3613,7 +3610,7 @@ static int ps_match_re(char *stmt_str) ...@@ -3613,7 +3610,7 @@ static int ps_match_re(char *stmt_str)
else else
{ {
char erbuf[100]; 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", fprintf(stderr, "error %s, %d/%d `%s'\n",
ps_eprint(err), len, (int)sizeof(erbuf), erbuf); ps_eprint(err), len, (int)sizeof(erbuf), erbuf);
exit(1); exit(1);
...@@ -3623,7 +3620,7 @@ static int ps_match_re(char *stmt_str) ...@@ -3623,7 +3620,7 @@ static int ps_match_re(char *stmt_str)
static char *ps_eprint(int err) static char *ps_eprint(int err)
{ {
static char epbuf[100]; 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)); assert(len <= sizeof(epbuf));
return(epbuf); return(epbuf);
} }
...@@ -3631,7 +3628,7 @@ static char *ps_eprint(int err) ...@@ -3631,7 +3628,7 @@ static char *ps_eprint(int err)
static void ps_free_reg(void) static void ps_free_reg(void)
{ {
regfree(&ps_re); my_regfree(&ps_re);
} }
/****************************************************************************/ /****************************************************************************/
...@@ -4074,13 +4071,21 @@ int main(int argc, char **argv) ...@@ -4074,13 +4071,21 @@ int main(int argc, char **argv)
if (res_info.st_size) if (res_info.st_size)
error|= (RESULT_CONTENT_MISMATCH | RESULT_LENGTH_MISMATCH); error|= (RESULT_CONTENT_MISMATCH | RESULT_LENGTH_MISMATCH);
} }
if (result_file && ds_res.length && !error) if (ds_res.length && !error)
{
if (result_file)
{ {
if (!record) if (!record)
error |= check_result(&ds_res, result_file, q->require_file); error |= check_result(&ds_res, result_file, q->require_file);
else else
str_to_file(result_file, ds_res.str, ds_res.length); str_to_file(result_file, ds_res.str, ds_res.length);
} }
else
{
/* Print the result to stdout */
printf("%s", ds_res.str);
}
}
dynstr_free(&ds_res); dynstr_free(&ds_res);
if (!silent) if (!silent)
......
...@@ -680,7 +680,8 @@ sub mtr_mysqladmin_shutdown { ...@@ -680,7 +680,8 @@ sub mtr_mysqladmin_shutdown {
mtr_add_arg($args, "shutdown"); mtr_add_arg($args, "shutdown");
# We don't wait for termination of mysqladmin # We don't wait for termination of mysqladmin
my $pid= mtr_spawn($::exe_mysqladmin, $args, my $pid= mtr_spawn($::exe_mysqladmin, $args,
"", $::path_manager_log, $::path_manager_log, ""); "", $::path_manager_log, $::path_manager_log, "",
{ append_log_file => 1 });
$mysql_admin_pids{$pid}= 1; $mysql_admin_pids{$pid}= 1;
} }
......
...@@ -2,37 +2,35 @@ ...@@ -2,37 +2,35 @@
# -*- cperl -*- # -*- cperl -*-
# This is a transformation of the "mysql-test-run" Bourne shell script # This is a transformation of the "mysql-test-run" Bourne shell script
# to Perl. This is just an intermediate step, the goal is to rewrite # to Perl. There are reasons this rewrite is not the prettiest Perl
# the Perl script to C. The complexity of the mysql-test-run script # you have seen
# makes it a bit hard to write and debug it as a C program directly,
# so this is considered a prototype.
# #
# Because of this the Perl coding style may in some cases look a bit # - The original script is huge and for most part uncommented,
# funny. The rules used are # not even a usage description of the flags.
# #
# - The coding style is as close as possible to the C/C++ MySQL # - There has been an attempt to write a replacement in C for the
# coding standard. # original Bourne shell script. It was kind of working but lacked
# lot of functionality to really be a replacement. Not to redo
# that mistake and catch all the obscure features of the original
# script, the rewrite in Perl is more close to the original script
# meaning it also share some of the ugly parts as well.
# #
# - Where NULL is to be returned, the undefined value is used. # - The original intention was that this script was to be a prototype
# to be the base for a new C version with full functionality. Since
# then it was decided that the Perl version should replace the
# Bourne shell version, but the Perl style still reflects the wish
# to make the Perl to C step easy.
# #
# - Regexp comparisons are simple and can be translated to strcmp # Some coding style from the original intent has been kept
# and other string functions. To ease this transformation matching
# is done in the lib "lib/mtr_match.pl", i.e. regular expressions
# should be avoided in the main program.
# #
# - The "unless" construct is not to be used. It is the same as "if !". # - To make this Perl script easy to alter even for those that not
# # code Perl that often, the coding style is as close as possible to
# - opendir/readdir/closedir is used instead of glob()/<*>. # the C/C++ MySQL coding standard.
# #
# - All lists of arguments to send to commands are Perl lists/arrays, # - All lists of arguments to send to commands are Perl lists/arrays,
# not strings we append args to. Within reason, most string # not strings we append args to. Within reason, most string
# concatenation for arguments should be avoided. # concatenation for arguments should be avoided.
# #
# - sprintf() is to be used, within reason, for all string creation.
# This mtr_add_arg() function is also based on sprintf(), i.e. you
# use a format string and put the variable argument in the argument
# list.
#
# - Functions defined in the main program are not to be prefixed, # - Functions defined in the main program are not to be prefixed,
# functions in "library files" are to be prefixed with "mtr_" (for # functions in "library files" are to be prefixed with "mtr_" (for
# Mysql-Test-Run). There are some exceptions, code that fits best in # Mysql-Test-Run). There are some exceptions, code that fits best in
...@@ -467,6 +465,7 @@ sub command_line_setup () { ...@@ -467,6 +465,7 @@ sub command_line_setup () {
# Read the command line # Read the command line
# Note: Keep list, and the order, in sync with usage at end of this file # Note: Keep list, and the order, in sync with usage at end of this file
Getopt::Long::Configure("pass_through");
GetOptions( GetOptions(
# Control what engine/variation to run # Control what engine/variation to run
'embedded-server' => \$opt_embedded_server, 'embedded-server' => \$opt_embedded_server,
...@@ -554,7 +553,21 @@ sub command_line_setup () { ...@@ -554,7 +553,21 @@ sub command_line_setup () {
usage(""); usage("");
} }
@opt_cases= @ARGV; foreach my $arg ( @ARGV )
{
if ( $arg =~ /^--skip-/ )
{
push(@opt_extra_mysqld_opt, $arg);
}
elsif ( $arg =~ /^-/ )
{
usage("Invalid option \"$arg\"");
}
else
{
push(@opt_cases, $arg);
}
}
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Set the "var/" directory, as it is the base for everything else # Set the "var/" directory, as it is the base for everything else
...@@ -743,47 +756,62 @@ sub command_line_setup () { ...@@ -743,47 +756,62 @@ sub command_line_setup () {
# Put this into a hash, will be a C struct # Put this into a hash, will be a C struct
$master->[0]->{'path_myddir'}= "$opt_vardir/master-data"; $master->[0]=
$master->[0]->{'path_myerr'}= "$opt_vardir/log/master.err"; {
$master->[0]->{'path_mylog'}= "$opt_vardir/log/master.log"; path_myddir => "$opt_vardir/master-data",
$master->[0]->{'path_mypid'}= "$opt_vardir/run/master.pid"; path_myerr => "$opt_vardir/log/master.err",
$master->[0]->{'path_mysock'}= "$opt_tmpdir/master.sock"; path_mylog => "$opt_vardir/log/master.log",
$master->[0]->{'path_myport'}= $opt_master_myport; path_mypid => "$opt_vardir/run/master.pid",
$master->[0]->{'start_timeout'}= 400; # enough time create innodb tables path_mysock => "$opt_tmpdir/master.sock",
path_myport => $opt_master_myport,
$master->[0]->{'ndbcluster'}= 1; # ndbcluster not started start_timeout => 400, # enough time create innodb tables
$master->[1]->{'path_myddir'}= "$opt_vardir/master1-data"; ndbcluster => 1, # ndbcluster not started
$master->[1]->{'path_myerr'}= "$opt_vardir/log/master1.err"; };
$master->[1]->{'path_mylog'}= "$opt_vardir/log/master1.log";
$master->[1]->{'path_mypid'}= "$opt_vardir/run/master1.pid"; $master->[1]=
$master->[1]->{'path_mysock'}= "$opt_tmpdir/master1.sock"; {
$master->[1]->{'path_myport'}= $opt_master_myport + 1; path_myddir => "$opt_vardir/master1-data",
$master->[1]->{'start_timeout'}= 400; # enough time create innodb tables path_myerr => "$opt_vardir/log/master1.err",
path_mylog => "$opt_vardir/log/master1.log",
$slave->[0]->{'path_myddir'}= "$opt_vardir/slave-data"; path_mypid => "$opt_vardir/run/master1.pid",
$slave->[0]->{'path_myerr'}= "$opt_vardir/log/slave.err"; path_mysock => "$opt_tmpdir/master1.sock",
$slave->[0]->{'path_mylog'}= "$opt_vardir/log/slave.log"; path_myport => $opt_master_myport + 1,
$slave->[0]->{'path_mypid'}= "$opt_vardir/run/slave.pid"; start_timeout => 400, # enough time create innodb tables
$slave->[0]->{'path_mysock'}= "$opt_tmpdir/slave.sock"; };
$slave->[0]->{'path_myport'}= $opt_slave_myport;
$slave->[0]->{'start_timeout'}= 400; $slave->[0]=
{
$slave->[1]->{'path_myddir'}= "$opt_vardir/slave1-data"; path_myddir => "$opt_vardir/slave-data",
$slave->[1]->{'path_myerr'}= "$opt_vardir/log/slave1.err"; path_myerr => "$opt_vardir/log/slave.err",
$slave->[1]->{'path_mylog'}= "$opt_vardir/log/slave1.log"; path_mylog => "$opt_vardir/log/slave.log",
$slave->[1]->{'path_mypid'}= "$opt_vardir/run/slave1.pid"; path_mypid => "$opt_vardir/run/slave.pid",
$slave->[1]->{'path_mysock'}= "$opt_tmpdir/slave1.sock"; path_mysock => "$opt_tmpdir/slave.sock",
$slave->[1]->{'path_myport'}= $opt_slave_myport + 1; path_myport => $opt_slave_myport,
$slave->[1]->{'start_timeout'}= 300; start_timeout => 400,
};
$slave->[2]->{'path_myddir'}= "$opt_vardir/slave2-data";
$slave->[2]->{'path_myerr'}= "$opt_vardir/log/slave2.err"; $slave->[1]=
$slave->[2]->{'path_mylog'}= "$opt_vardir/log/slave2.log"; {
$slave->[2]->{'path_mypid'}= "$opt_vardir/run/slave2.pid"; path_myddir => "$opt_vardir/slave1-data",
$slave->[2]->{'path_mysock'}= "$opt_tmpdir/slave2.sock"; path_myerr => "$opt_vardir/log/slave1.err",
$slave->[2]->{'path_myport'}= $opt_slave_myport + 2; path_mylog => "$opt_vardir/log/slave1.log",
$slave->[2]->{'start_timeout'}= 300; path_mypid => "$opt_vardir/run/slave1.pid",
path_mysock => "$opt_tmpdir/slave1.sock",
path_myport => $opt_slave_myport + 1,
start_timeout => 300,
};
$slave->[2]=
{
path_myddir => "$opt_vardir/slave2-data",
path_myerr => "$opt_vardir/log/slave2.err",
path_mylog => "$opt_vardir/log/slave2.log",
path_mypid => "$opt_vardir/run/slave2.pid",
path_mysock => "$opt_tmpdir/slave2.sock",
path_myport => $opt_slave_myport + 2,
start_timeout => 300,
};
if ( $opt_extern ) if ( $opt_extern )
{ {
...@@ -1956,7 +1984,9 @@ sub mysqld_start ($$$$) { ...@@ -1956,7 +1984,9 @@ sub mysqld_start ($$$$) {
{ {
if ( $pid= mtr_spawn($exe, $args, "", if ( $pid= mtr_spawn($exe, $args, "",
$master->[$idx]->{'path_myerr'}, $master->[$idx]->{'path_myerr'},
$master->[$idx]->{'path_myerr'}, "") ) $master->[$idx]->{'path_myerr'},
"",
{ append_log_file => 1 }) )
{ {
return sleep_until_file_created($master->[$idx]->{'path_mypid'}, return sleep_until_file_created($master->[$idx]->{'path_mypid'},
$master->[$idx]->{'start_timeout'}, $pid); $master->[$idx]->{'start_timeout'}, $pid);
...@@ -1967,7 +1997,9 @@ sub mysqld_start ($$$$) { ...@@ -1967,7 +1997,9 @@ sub mysqld_start ($$$$) {
{ {
if ( $pid= mtr_spawn($exe, $args, "", if ( $pid= mtr_spawn($exe, $args, "",
$slave->[$idx]->{'path_myerr'}, $slave->[$idx]->{'path_myerr'},
$slave->[$idx]->{'path_myerr'}, "") ) $slave->[$idx]->{'path_myerr'},
"",
{ append_log_file => 1 }) )
{ {
return sleep_until_file_created($slave->[$idx]->{'path_mypid'}, return sleep_until_file_created($slave->[$idx]->{'path_mypid'},
$master->[$idx]->{'start_timeout'}, $pid); $master->[$idx]->{'start_timeout'}, $pid);
...@@ -2197,7 +2229,7 @@ sub run_mysqltest ($) { ...@@ -2197,7 +2229,7 @@ sub run_mysqltest ($) {
$ENV{'MYSQL_TEST'}= "$exe_mysqltest " . join(" ", @$args); $ENV{'MYSQL_TEST'}= "$exe_mysqltest " . join(" ", @$args);
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Add args that should not go into the MYSQL_TEST environment var # Add arguments that should not go into the MYSQL_TEST env var
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
mtr_add_arg($args, "-R"); mtr_add_arg($args, "-R");
......
...@@ -179,6 +179,7 @@ source database ...@@ -179,6 +179,7 @@ source database
echo message echo message echo message echo message
mysqltest: At line 1: Empty variable mysqltest: At line 1: Empty variable
mysqltest: At line 1: command "false" failed
mysqltest: At line 1: Missing argument in exec mysqltest: At line 1: Missing argument in exec
MySQL MySQL
"MySQL" "MySQL"
...@@ -300,6 +301,7 @@ mysqltest: At line 1: First argument to dec must be a variable (start with $) ...@@ -300,6 +301,7 @@ mysqltest: At line 1: First argument to dec must be a variable (start with $)
mysqltest: At line 1: End of line junk detected: "1000" mysqltest: At line 1: End of line junk detected: "1000"
mysqltest: At line 1: Missing arguments to system, nothing to do! mysqltest: At line 1: Missing arguments to system, nothing to do!
mysqltest: At line 1: Missing arguments to system, nothing to do! mysqltest: At line 1: Missing arguments to system, nothing to do!
mysqltest: At line 1: system command 'false' failed
test test
test2 test2
test3 test3
...@@ -343,6 +345,10 @@ mysqltest: At line 1: Wrong column number to replace_column in 'replace_column 1 ...@@ -343,6 +345,10 @@ mysqltest: At line 1: Wrong column number to replace_column in 'replace_column 1
mysqltest: At line 1: Invalid integer argument "10!" mysqltest: At line 1: Invalid integer argument "10!"
mysqltest: At line 1: End of line junk detected: "!" mysqltest: At line 1: End of line junk detected: "!"
mysqltest: At line 1: Invalid integer argument "a" mysqltest: At line 1: Invalid integer argument "a"
Output from mysqltest-x.inc
Output from mysqltest-x.inc
Output from mysqltest-x.inc
mysqltest: Could not open ./non_existing_file.inc: errno = 2
failing_statement; failing_statement;
ERROR 42000: 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_statement' at line 1 ERROR 42000: 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_statement' at line 1
failing_statement; failing_statement;
......
...@@ -426,9 +426,8 @@ echo ; ...@@ -426,9 +426,8 @@ echo ;
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Illegal use of exec # Illegal use of exec
# Disabled, some shells prints the failed command regardless of pipes --error 1
#--error 1 --exec echo "--exec false" | $MYSQL_TEST 2>&1
#--exec echo "--exec ';' 2> /dev/null" | $MYSQL_TEST 2>&1
--error 1 --error 1
--exec echo "--exec " | $MYSQL_TEST 2>&1 --exec echo "--exec " | $MYSQL_TEST 2>&1
...@@ -675,9 +674,8 @@ system echo "hej" > /dev/null; ...@@ -675,9 +674,8 @@ system echo "hej" > /dev/null;
--exec echo "system;" | $MYSQL_TEST 2>&1 --exec echo "system;" | $MYSQL_TEST 2>&1
--error 1 --error 1
--exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1 --exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1
# Disabled, some shells prints the failed command regardless of pipes --error 1
#--error 1 --exec echo "system false;" | $MYSQL_TEST 2>&1
#--exec echo "system NonExistsinfComamdn 2> /dev/null;" | $MYSQL_TEST 2>&1
--disable_abort_on_error --disable_abort_on_error
system NonExistsinfComamdn; system NonExistsinfComamdn;
...@@ -812,11 +810,11 @@ select "a" as col1, "c" as col2; ...@@ -812,11 +810,11 @@ select "a" as col1, "c" as col2;
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# -x <file_name>, use the file specified after -x as the test file # -x <file_name>, use the file specified after -x as the test file
#--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1 --exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc
#--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1 --exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc
#--exec $MYSQL_TEST --result_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1 --exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc
#--error 1 --error 1
#--exec $MYSQL_TEST -x non_existing_file.inc 2>&1 --exec $MYSQL_TEST -x non_existing_file.inc 2>&1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
......
...@@ -127,11 +127,23 @@ my_bool my_init(void) ...@@ -127,11 +127,23 @@ my_bool my_init(void)
void my_end(int infoflag) void my_end(int infoflag)
{ {
FILE *info_file; /*
if (!(info_file=DBUG_FILE)) this code is suboptimal to workaround a bug in
info_file=stderr; Sun CC: Sun C++ 5.6 2004/06/02 for x86, and should not be
DBUG_PRINT("info",("Shutting down")); optimized until this compiler is not in use anymore
if (infoflag & MY_CHECK_ERROR || info_file != stderr) */
FILE *info_file= DBUG_FILE;
my_bool print_info= (info_file != stderr);
DBUG_ENTER("my_end");
if (!info_file)
{
info_file= stderr;
print_info= 0;
}
DBUG_PRINT("info",("Shutting down: print_info: %d", print_info));
if ((infoflag & MY_CHECK_ERROR) || print_info)
{ /* Test if some file is left open */ { /* Test if some file is left open */
if (my_file_opened | my_stream_opened) if (my_file_opened | my_stream_opened)
{ {
...@@ -141,7 +153,8 @@ void my_end(int infoflag) ...@@ -141,7 +153,8 @@ void my_end(int infoflag)
} }
} }
my_once_free(); my_once_free();
if (infoflag & MY_GIVE_INFO || info_file != stderr)
if ((infoflag & MY_GIVE_INFO) || print_info)
{ {
#ifdef HAVE_GETRUSAGE #ifdef HAVE_GETRUSAGE
struct rusage rus; struct rusage rus;
......
...@@ -12,7 +12,7 @@ group client_global_pch = ...@@ -12,7 +12,7 @@ group client_global_pch =
'm_ctype.h', 'mysqld_error.h', 'm_ctype.h', 'mysqld_error.h',
'my_list.h', 'my_sys.h', 'my_net.h', 'my_list.h', 'my_sys.h', 'my_net.h',
'myisam.h', 'myisampack.h', '.\myisam\myisamdef.h', 'myisam.h', 'myisampack.h', '.\myisam\myisamdef.h',
'.\regex\regex.h' '.\regex\my_regex.h'
group server_global_pch = group server_global_pch =
'os2.h', 'os2.h',
...@@ -38,7 +38,7 @@ group server_global_pch = ...@@ -38,7 +38,7 @@ group server_global_pch =
'my_tree.h', '..\mysys\my_static.h', 'netdb.h', 'my_tree.h', '..\mysys\my_static.h', 'netdb.h',
'thr_alarm.h', 'heap.h', '..\myisam\fulltext.h', 'thr_alarm.h', 'heap.h', '..\myisam\fulltext.h',
'..\myisam\ftdefs.h', 'myisammrg.h', '..\myisam\ftdefs.h', 'myisammrg.h',
'.\regex\regex.h' '.\regex\my_regex.h'
group server_pch = group server_pch =
'ha_heap.h', 'ha_myisammrg.h', 'opt_ft.h', 'ha_heap.h', 'ha_myisammrg.h', 'opt_ft.h',
......
...@@ -19,7 +19,7 @@ INCLUDES = @MT_INCLUDES@ \ ...@@ -19,7 +19,7 @@ INCLUDES = @MT_INCLUDES@ \
-I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/include
noinst_LIBRARIES = libregex.a noinst_LIBRARIES = libregex.a
LDADD= libregex.a $(top_builddir)/strings/libmystrings.a LDADD= libregex.a $(top_builddir)/strings/libmystrings.a
noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c regex.h noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c my_regex.h
libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
noinst_PROGRAMS = re noinst_PROGRAMS = re
re_SOURCES = split.c debug.c main.c re_SOURCES = split.c debug.c main.c
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include <m_ctype.h> #include <m_ctype.h>
#include <m_string.h> #include <m_string.h>
#include <sys/types.h> #include <sys/types.h>
#include <regex.h>
#include "my_regex.h"
#include "utils.h" #include "utils.h"
#include "regex2.h" #include "regex2.h"
#include "debug.ih" #include "debug.ih"
...@@ -15,7 +16,7 @@ ...@@ -15,7 +16,7 @@
*/ */
void void
regprint(r, d) regprint(r, d)
regex_t *r; my_regex_t *r;
FILE *d; FILE *d;
{ {
register struct re_guts *g = r->re_g; register struct re_guts *g = r->re_g;
......
...@@ -4,7 +4,7 @@ extern "C" { ...@@ -4,7 +4,7 @@ extern "C" {
#endif #endif
/* === debug.c === */ /* === debug.c === */
void regprint(regex_t *r, FILE *d); void regprint(my_regex_t *r, FILE *d);
static void s_print(CHARSET_INFO *charset, register struct re_guts *g, FILE *d); static void s_print(CHARSET_INFO *charset, register struct re_guts *g, FILE *d);
static char *regchar(CHARSET_INFO *charset, int ch,char *buf); static char *regchar(CHARSET_INFO *charset, int ch,char *buf);
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
struct match { struct match {
struct re_guts *g; struct re_guts *g;
int eflags; int eflags;
regmatch_t *pmatch; /* [nsub+1] (0 element unused) */ my_regmatch_t *pmatch; /* [nsub+1] (0 element unused) */
char *offp; /* offsets work from here */ char *offp; /* offsets work from here */
char *beginp; /* start of string -- virtual NUL precedes */ char *beginp; /* start of string -- virtual NUL precedes */
char *endp; /* end of string -- virtual NUL here */ char *endp; /* end of string -- virtual NUL here */
...@@ -68,7 +68,7 @@ CHARSET_INFO *charset; ...@@ -68,7 +68,7 @@ CHARSET_INFO *charset;
register struct re_guts *g; register struct re_guts *g;
char *str; char *str;
size_t nmatch; size_t nmatch;
regmatch_t pmatch[]; my_regmatch_t pmatch[];
int eflags; int eflags;
{ {
register char *endp; register char *endp;
...@@ -148,8 +148,8 @@ int eflags; ...@@ -148,8 +148,8 @@ int eflags;
/* oh my, he wants the subexpressions... */ /* oh my, he wants the subexpressions... */
if (m->pmatch == NULL) if (m->pmatch == NULL)
m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * m->pmatch = (my_regmatch_t *)malloc((m->g->nsub + 1) *
sizeof(regmatch_t)); sizeof(my_regmatch_t));
if (m->pmatch == NULL) { if (m->pmatch == NULL) {
if (m->lastpos != NULL) if (m->lastpos != NULL)
free((char *)m->lastpos); free((char *)m->lastpos);
......
...@@ -4,7 +4,7 @@ extern "C" { ...@@ -4,7 +4,7 @@ extern "C" {
#endif #endif
/* === engine.c === */ /* === engine.c === */
static int matcher(CHARSET_INFO *charset,register struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], int eflags); static int matcher(CHARSET_INFO *charset,register struct re_guts *g, char *string, size_t nmatch, my_regmatch_t pmatch[], int eflags);
static char *dissect(CHARSET_INFO *charset,register struct match *m, char *start, char *stop, sopno startst, sopno stopst); static char *dissect(CHARSET_INFO *charset,register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
static char *backref(CHARSET_INFO *charset, register struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev); static char *backref(CHARSET_INFO *charset, register struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev);
static char *fast(CHARSET_INFO *charset, register struct match *m, char *start, char *stop, sopno startst, sopno stopst); static char *fast(CHARSET_INFO *charset, register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
......
#include <my_global.h> #include <my_global.h>
#include <m_string.h> #include <m_string.h>
#include <sys/types.h> #include <sys/types.h>
#include <regex.h>
#include <assert.h> #include <assert.h>
#include "my_regex.h"
#include "main.ih" #include "main.ih"
char *progname; char *progname;
...@@ -27,9 +27,9 @@ int main(argc, argv) ...@@ -27,9 +27,9 @@ int main(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
{ {
regex_t re; my_regex_t re;
# define NS 10 # define NS 10
regmatch_t subs[NS]; my_regmatch_t subs[NS];
char erbuf[100]; char erbuf[100];
int err; int err;
size_t len; size_t len;
...@@ -74,9 +74,9 @@ char *argv[]; ...@@ -74,9 +74,9 @@ char *argv[];
exit(status); exit(status);
} }
err = regcomp(&re, argv[optind++], copts, &my_charset_latin1); err = my_regcomp(&re, argv[optind++], copts, &my_charset_latin1);
if (err) { if (err) {
len = regerror(err, &re, erbuf, sizeof(erbuf)); len = my_regerror(err, &re, erbuf, sizeof(erbuf));
fprintf(stderr, "error %s, %d/%d `%s'\n", fprintf(stderr, "error %s, %d/%d `%s'\n",
eprint(err), len, (int) sizeof(erbuf), erbuf); eprint(err), len, (int) sizeof(erbuf), erbuf);
exit(status); exit(status);
...@@ -84,7 +84,7 @@ char *argv[]; ...@@ -84,7 +84,7 @@ char *argv[];
regprint(&re, stdout); regprint(&re, stdout);
if (optind >= argc) { if (optind >= argc) {
regfree(&re); my_regfree(&re);
exit(status); exit(status);
} }
...@@ -92,9 +92,9 @@ char *argv[]; ...@@ -92,9 +92,9 @@ char *argv[];
subs[0].rm_so = startoff; subs[0].rm_so = startoff;
subs[0].rm_eo = strlen(argv[optind]) - endoff; subs[0].rm_eo = strlen(argv[optind]) - endoff;
} }
err = regexec(&re, argv[optind], (size_t)NS, subs, eopts); err = my_regexec(&re, argv[optind], (size_t)NS, subs, eopts);
if (err) { if (err) {
len = regerror(err, &re, erbuf, sizeof(erbuf)); len = my_regerror(err, &re, erbuf, sizeof(erbuf));
fprintf(stderr, "error %s, %d/%d `%s'\n", fprintf(stderr, "error %s, %d/%d `%s'\n",
eprint(err), (int) len, (int) sizeof(erbuf), erbuf); eprint(err), (int) len, (int) sizeof(erbuf), erbuf);
exit(status); exit(status);
...@@ -136,7 +136,7 @@ FILE *in; ...@@ -136,7 +136,7 @@ FILE *in;
const char *badpat = "invalid regular expression"; const char *badpat = "invalid regular expression";
# define SHORT 10 # define SHORT 10
const char *bpname = "REG_BADPAT"; const char *bpname = "REG_BADPAT";
regex_t re; my_regex_t re;
while (fgets(inbuf, sizeof(inbuf), in) != NULL) { while (fgets(inbuf, sizeof(inbuf), in) != NULL) {
line++; line++;
...@@ -163,27 +163,27 @@ FILE *in; ...@@ -163,27 +163,27 @@ FILE *in;
options('c', f[1]) &~ REG_EXTENDED); options('c', f[1]) &~ REG_EXTENDED);
} }
ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf)); ne = my_regerror(REG_BADPAT, (my_regex_t *)NULL, erbuf, sizeof(erbuf));
if (strcmp(erbuf, badpat) != 0 || ne != strlen(badpat)+1) { if (strcmp(erbuf, badpat) != 0 || ne != strlen(badpat)+1) {
fprintf(stderr, "end: regerror() test gave `%s' not `%s'\n", fprintf(stderr, "end: regerror() test gave `%s' not `%s'\n",
erbuf, badpat); erbuf, badpat);
status = 1; status = 1;
} }
ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, (size_t)SHORT); ne = my_regerror(REG_BADPAT, (my_regex_t *)NULL, erbuf, (size_t)SHORT);
if (strncmp(erbuf, badpat, SHORT-1) != 0 || erbuf[SHORT-1] != '\0' || if (strncmp(erbuf, badpat, SHORT-1) != 0 || erbuf[SHORT-1] != '\0' ||
ne != strlen(badpat)+1) { ne != strlen(badpat)+1) {
fprintf(stderr, "end: regerror() short test gave `%s' not `%.*s'\n", fprintf(stderr, "end: regerror() short test gave `%s' not `%.*s'\n",
erbuf, SHORT-1, badpat); erbuf, SHORT-1, badpat);
status = 1; status = 1;
} }
ne = regerror(REG_ITOA|REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf)); ne = my_regerror(REG_ITOA|REG_BADPAT, (my_regex_t *)NULL, erbuf, sizeof(erbuf));
if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) { if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) {
fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n", fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n",
erbuf, bpname); erbuf, bpname);
status = 1; status = 1;
} }
re.re_endp = bpname; re.re_endp = bpname;
ne = regerror(REG_ATOI, &re, erbuf, sizeof(erbuf)); ne = my_regerror(REG_ATOI, &re, erbuf, sizeof(erbuf));
if (atoi(erbuf) != (int)REG_BADPAT) { if (atoi(erbuf) != (int)REG_BADPAT) {
fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n", fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
erbuf, (long)REG_BADPAT); erbuf, (long)REG_BADPAT);
...@@ -208,9 +208,9 @@ char *f3; ...@@ -208,9 +208,9 @@ char *f3;
char *f4; char *f4;
int opts; /* may not match f1 */ int opts; /* may not match f1 */
{ {
regex_t re; my_regex_t re;
# define NSUBS 10 # define NSUBS 10
regmatch_t subs[NSUBS]; my_regmatch_t subs[NSUBS];
# define NSHOULD 15 # define NSHOULD 15
char *should[NSHOULD]; char *should[NSHOULD];
int nshould; int nshould;
...@@ -226,10 +226,10 @@ int opts; /* may not match f1 */ ...@@ -226,10 +226,10 @@ int opts; /* may not match f1 */
strcpy(f0copy, f0); strcpy(f0copy, f0);
re.re_endp = (opts&REG_PEND) ? f0copy + strlen(f0copy) : NULL; re.re_endp = (opts&REG_PEND) ? f0copy + strlen(f0copy) : NULL;
fixstr(f0copy); fixstr(f0copy);
err = regcomp(&re, f0copy, opts, &my_charset_latin1); err = my_regcomp(&re, f0copy, opts, &my_charset_latin1);
if (err != 0 && (!opt('C', f1) || err != efind(f2))) { if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
/* unexpected error or wrong error */ /* unexpected error or wrong error */
len = regerror(err, &re, erbuf, sizeof(erbuf)); len = my_regerror(err, &re, erbuf, sizeof(erbuf));
fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n", fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n",
line, type, eprint(err), len, line, type, eprint(err), len,
(int) sizeof(erbuf), erbuf); (int) sizeof(erbuf), erbuf);
...@@ -243,7 +243,7 @@ int opts; /* may not match f1 */ ...@@ -243,7 +243,7 @@ int opts; /* may not match f1 */
} }
if (err != 0) { if (err != 0) {
regfree(&re); my_regfree(&re);
return; return;
} }
...@@ -256,11 +256,11 @@ int opts; /* may not match f1 */ ...@@ -256,11 +256,11 @@ int opts; /* may not match f1 */
subs[0].rm_so = strchr(f2, '(') - f2 + 1; subs[0].rm_so = strchr(f2, '(') - f2 + 1;
subs[0].rm_eo = strchr(f2, ')') - f2; subs[0].rm_eo = strchr(f2, ')') - f2;
} }
err = regexec(&re, f2copy, NSUBS, subs, options('e', f1)); err = my_regexec(&re, f2copy, NSUBS, subs, options('e', f1));
if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) { if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
/* unexpected error or wrong error */ /* unexpected error or wrong error */
len = regerror(err, &re, erbuf, sizeof(erbuf)); len = my_regerror(err, &re, erbuf, sizeof(erbuf));
fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n", fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
line, type, eprint(err), len, line, type, eprint(err), len,
(int) sizeof(erbuf), erbuf); (int) sizeof(erbuf), erbuf);
...@@ -282,7 +282,7 @@ int opts; /* may not match f1 */ ...@@ -282,7 +282,7 @@ int opts; /* may not match f1 */
} }
if (err != 0 || f4 == NULL) { if (err != 0 || f4 == NULL) {
regfree(&re); my_regfree(&re);
return; return;
} }
...@@ -303,7 +303,7 @@ int opts; /* may not match f1 */ ...@@ -303,7 +303,7 @@ int opts; /* may not match f1 */
} }
} }
regfree(&re); my_regfree(&re);
} }
/* /*
...@@ -404,7 +404,7 @@ register char *p; ...@@ -404,7 +404,7 @@ register char *p;
char * /* NULL or complaint */ char * /* NULL or complaint */
check(str, sub, should) check(str, sub, should)
char *str; char *str;
regmatch_t sub; my_regmatch_t sub;
char *should; char *should;
{ {
register int len; register int len;
...@@ -485,7 +485,7 @@ int err; ...@@ -485,7 +485,7 @@ int err;
static char epbuf[100]; static char epbuf[100];
size_t len; size_t len;
len = regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf)); len = my_regerror(REG_ITOA|err, (my_regex_t *)NULL, epbuf, sizeof(epbuf));
assert(len <= sizeof(epbuf)); assert(len <= sizeof(epbuf));
return(epbuf); return(epbuf);
} }
...@@ -499,11 +499,11 @@ efind(name) ...@@ -499,11 +499,11 @@ efind(name)
char *name; char *name;
{ {
static char efbuf[100]; static char efbuf[100];
regex_t re; my_regex_t re;
sprintf(efbuf, "REG_%s", name); sprintf(efbuf, "REG_%s", name);
assert(strlen(efbuf) < sizeof(efbuf)); assert(strlen(efbuf) < sizeof(efbuf));
re.re_endp = efbuf; re.re_endp = efbuf;
(void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf)); (void) my_regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
return(atoi(efbuf)); return(atoi(efbuf));
} }
...@@ -9,7 +9,7 @@ void rx_try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts); ...@@ -9,7 +9,7 @@ void rx_try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
int options(int type, char *s); int options(int type, char *s);
int opt(int c, char *s); int opt(int c, char *s);
void fixstr(register char *p); void fixstr(register char *p);
char *check(char *str, regmatch_t sub, char *should); char *check(char *str, my_regmatch_t sub, char *should);
static char *eprint(int err); static char *eprint(int err);
static int efind(char *name); static int efind(char *name);
......
...@@ -20,15 +20,15 @@ typedef struct { ...@@ -20,15 +20,15 @@ typedef struct {
const char *re_endp; /* end pointer for REG_PEND */ const char *re_endp; /* end pointer for REG_PEND */
struct re_guts *re_g; /* none of your business :-) */ struct re_guts *re_g; /* none of your business :-) */
CHARSET_INFO *charset; /* For ctype things */ CHARSET_INFO *charset; /* For ctype things */
} regex_t; } my_regex_t;
typedef struct { typedef struct {
regoff_t rm_so; /* start of match */ regoff_t rm_so; /* start of match */
regoff_t rm_eo; /* end of match */ regoff_t rm_eo; /* end of match */
} regmatch_t; } my_regmatch_t;
/* === regcomp.c === */ /* === regcomp.c === */
extern int regcomp(regex_t *, const char *, int, CHARSET_INFO *charset); extern int my_regcomp(my_regex_t *, const char *, int, CHARSET_INFO *charset);
#define REG_BASIC 0000 #define REG_BASIC 0000
#define REG_EXTENDED 0001 #define REG_EXTENDED 0001
#define REG_ICASE 0002 #define REG_ICASE 0002
...@@ -58,11 +58,11 @@ extern int regcomp(regex_t *, const char *, int, CHARSET_INFO *charset); ...@@ -58,11 +58,11 @@ extern int regcomp(regex_t *, const char *, int, CHARSET_INFO *charset);
#define REG_INVARG 16 #define REG_INVARG 16
#define REG_ATOI 255 /* convert name to number (!) */ #define REG_ATOI 255 /* convert name to number (!) */
#define REG_ITOA 0400 /* convert number to name (!) */ #define REG_ITOA 0400 /* convert number to name (!) */
extern size_t regerror(int, const regex_t *, char *, size_t); extern size_t my_regerror(int, const my_regex_t *, char *, size_t);
/* === regexec.c === */ /* === regexec.c === */
extern int regexec(const regex_t *, const char *, size_t, regmatch_t [], int); extern int my_regexec(const my_regex_t *, const char *, size_t, my_regmatch_t [], int);
#define REG_NOTBOL 00001 #define REG_NOTBOL 00001
#define REG_NOTEOL 00002 #define REG_NOTEOL 00002
#define REG_STARTEND 00004 #define REG_STARTEND 00004
...@@ -72,12 +72,12 @@ extern int regexec(const regex_t *, const char *, size_t, regmatch_t [], int); ...@@ -72,12 +72,12 @@ extern int regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
/* === regfree.c === */ /* === regfree.c === */
extern void regfree(regex_t *); extern void my_regfree(my_regex_t *);
/* === reginit.c === */ /* === reginit.c === */
extern void regex_init(CHARSET_INFO *cs); /* Should be called for multithread progs */ extern void my_regex_init(CHARSET_INFO *cs); /* Should be called for multithread progs */
extern void regex_end(void); /* If one wants a clean end */ extern void my_regex_end(void); /* If one wants a clean end */
#ifdef __cplusplus #ifdef __cplusplus
} }
......
#include <my_global.h> #include <my_global.h>
#include <m_string.h> #include <m_string.h>
#include <m_ctype.h> #include <m_ctype.h>
#include <regex.h>
#ifdef __WIN__ #ifdef __WIN__
#include <limits.h> #include <limits.h>
#endif #endif
#include "my_regex.h"
#include "utils.h" #include "utils.h"
#include "regex2.h" #include "regex2.h"
...@@ -100,8 +100,8 @@ static int never = 0; /* for use in asserts; shuts lint up */ ...@@ -100,8 +100,8 @@ static int never = 0; /* for use in asserts; shuts lint up */
= #define REG_DUMP 0200 = #define REG_DUMP 0200
*/ */
int /* 0 success, otherwise REG_something */ int /* 0 success, otherwise REG_something */
regcomp(preg, pattern, cflags, charset) my_regcomp(preg, pattern, cflags, charset)
regex_t *preg; my_regex_t *preg;
const char *pattern; const char *pattern;
int cflags; int cflags;
CHARSET_INFO *charset; CHARSET_INFO *charset;
...@@ -117,7 +117,7 @@ CHARSET_INFO *charset; ...@@ -117,7 +117,7 @@ CHARSET_INFO *charset;
# define GOODFLAGS(f) ((f)&~REG_DUMP) # define GOODFLAGS(f) ((f)&~REG_DUMP)
#endif #endif
regex_init(charset); /* Init cclass if neaded */ my_regex_init(charset); /* Init cclass if neaded */
preg->charset=charset; preg->charset=charset;
cflags = GOODFLAGS(cflags); cflags = GOODFLAGS(cflags);
if ((cflags&REG_EXTENDED) && (cflags&REG_NOSPEC)) if ((cflags&REG_EXTENDED) && (cflags&REG_NOSPEC))
...@@ -199,7 +199,7 @@ CHARSET_INFO *charset; ...@@ -199,7 +199,7 @@ CHARSET_INFO *charset;
/* win or lose, we're done */ /* win or lose, we're done */
if (p->error != 0) /* lose */ if (p->error != 0) /* lose */
regfree(preg); my_regfree(preg);
return(p->error); return(p->error);
} }
......
#include <my_global.h> #include <my_global.h>
#include <m_string.h> #include <m_string.h>
#include <m_ctype.h> #include <m_ctype.h>
#include <regex.h>
#include "my_regex.h"
#include "utils.h" #include "utils.h"
#include "regerror.ih" #include "regerror.ih"
...@@ -56,7 +56,7 @@ static struct rerr { ...@@ -56,7 +56,7 @@ static struct rerr {
*/ */
/* ARGSUSED */ /* ARGSUSED */
size_t size_t
regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) my_regerror(int errcode, const my_regex_t *preg, char *errbuf, size_t errbuf_size)
{ {
register struct rerr *r; register struct rerr *r;
register size_t len; register size_t len;
...@@ -101,7 +101,7 @@ regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) ...@@ -101,7 +101,7 @@ regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
*/ */
static char * static char *
regatoi(preg, localbuf) regatoi(preg, localbuf)
const regex_t *preg; const my_regex_t *preg;
char *localbuf; char *localbuf;
{ {
register struct rerr *r; register struct rerr *r;
......
...@@ -4,7 +4,7 @@ extern "C" { ...@@ -4,7 +4,7 @@ extern "C" {
#endif #endif
/* === regerror.c === */ /* === regerror.c === */
static char *regatoi(const regex_t *preg, char *localbuf); static char *regatoi(const my_regex_t *preg, char *localbuf);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -8,11 +8,10 @@ ...@@ -8,11 +8,10 @@
#include <my_global.h> #include <my_global.h>
#include <m_string.h> #include <m_string.h>
#include <m_ctype.h> #include <m_ctype.h>
#include <regex.h>
#ifdef __WIN__ #ifdef __WIN__
#include <limits.h> #include <limits.h>
#endif #endif
#include "my_regex.h"
#include "utils.h" #include "utils.h"
#include "regex2.h" #include "regex2.h"
...@@ -110,11 +109,11 @@ static int nope = 0; /* for use in asserts; shuts lint up */ ...@@ -110,11 +109,11 @@ static int nope = 0; /* for use in asserts; shuts lint up */
* have been prototyped. * have been prototyped.
*/ */
int /* 0 success, REG_NOMATCH failure */ int /* 0 success, REG_NOMATCH failure */
regexec(preg, str, nmatch, pmatch, eflags) my_regexec(preg, str, nmatch, pmatch, eflags)
const regex_t *preg; const my_regex_t *preg;
const char *str; const char *str;
size_t nmatch; size_t nmatch;
regmatch_t pmatch[]; my_regmatch_t pmatch[];
int eflags; int eflags;
{ {
register struct re_guts *g = preg->re_g; register struct re_guts *g = preg->re_g;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <regex.h> #include "my_regex.h"
#include "utils.h" #include "utils.h"
#include "regex2.h" #include "regex2.h"
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
= extern void regfree(regex_t *); = extern void regfree(regex_t *);
*/ */
void void
regfree(preg) my_regfree(preg)
regex_t *preg; my_regex_t *preg;
{ {
register struct re_guts *g; register struct re_guts *g;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
static bool regex_inited=0; static bool regex_inited=0;
void regex_init(CHARSET_INFO *cs) void my_regex_init(CHARSET_INFO *cs)
{ {
char buff[CCLASS_LAST][256]; char buff[CCLASS_LAST][256];
int count[CCLASS_LAST]; int count[CCLASS_LAST];
...@@ -67,7 +67,7 @@ void regex_init(CHARSET_INFO *cs) ...@@ -67,7 +67,7 @@ void regex_init(CHARSET_INFO *cs)
return; return;
} }
void regex_end() void my_regex_end()
{ {
if (regex_inited) if (regex_inited)
{ {
......
...@@ -2556,14 +2556,14 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -2556,14 +2556,14 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return 0; return 0;
} }
int error; int error;
if ((error= regcomp(&preg,res->c_ptr(), if ((error= my_regcomp(&preg,res->c_ptr(),
((cmp_collation.collation->state & ((cmp_collation.collation->state &
(MY_CS_BINSORT | MY_CS_CSSORT)) ? (MY_CS_BINSORT | MY_CS_CSSORT)) ?
REG_EXTENDED | REG_NOSUB : REG_EXTENDED | REG_NOSUB :
REG_EXTENDED | REG_NOSUB | REG_ICASE), REG_EXTENDED | REG_NOSUB | REG_ICASE),
cmp_collation.collation))) cmp_collation.collation)))
{ {
(void) regerror(error,&preg,buff,sizeof(buff)); (void) my_regerror(error,&preg,buff,sizeof(buff));
my_printf_error(ER_REGEXP_ERROR,ER(ER_REGEXP_ERROR),MYF(0),buff); my_printf_error(ER_REGEXP_ERROR,ER(ER_REGEXP_ERROR),MYF(0),buff);
return 1; return 1;
} }
...@@ -2605,10 +2605,10 @@ longlong Item_func_regex::val_int() ...@@ -2605,10 +2605,10 @@ longlong Item_func_regex::val_int()
prev_regexp.copy(*res2); prev_regexp.copy(*res2);
if (regex_compiled) if (regex_compiled)
{ {
regfree(&preg); my_regfree(&preg);
regex_compiled=0; regex_compiled=0;
} }
if (regcomp(&preg,res2->c_ptr(), if (my_regcomp(&preg,res2->c_ptr(),
((cmp_collation.collation->state & ((cmp_collation.collation->state &
(MY_CS_BINSORT | MY_CS_CSSORT)) ? (MY_CS_BINSORT | MY_CS_CSSORT)) ?
REG_EXTENDED | REG_NOSUB : REG_EXTENDED | REG_NOSUB :
...@@ -2622,7 +2622,7 @@ longlong Item_func_regex::val_int() ...@@ -2622,7 +2622,7 @@ longlong Item_func_regex::val_int()
} }
} }
null_value=0; null_value=0;
return regexec(&preg,res->c_ptr(),0,(regmatch_t*) 0,0) ? 0 : 1; return my_regexec(&preg,res->c_ptr(),0,(my_regmatch_t*) 0,0) ? 0 : 1;
} }
...@@ -2632,7 +2632,7 @@ void Item_func_regex::cleanup() ...@@ -2632,7 +2632,7 @@ void Item_func_regex::cleanup()
Item_bool_func::cleanup(); Item_bool_func::cleanup();
if (regex_compiled) if (regex_compiled)
{ {
regfree(&preg); my_regfree(&preg);
regex_compiled=0; regex_compiled=0;
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
...@@ -915,11 +915,11 @@ public: ...@@ -915,11 +915,11 @@ public:
#ifdef USE_REGEX #ifdef USE_REGEX
#include <regex.h> #include "my_regex.h"
class Item_func_regex :public Item_bool_func class Item_func_regex :public Item_bool_func
{ {
regex_t preg; my_regex_t preg;
bool regex_compiled; bool regex_compiled;
bool regex_is_const; bool regex_is_const;
String prev_regexp; String prev_regexp;
......
...@@ -1028,7 +1028,7 @@ void clean_up(bool print_message) ...@@ -1028,7 +1028,7 @@ void clean_up(bool print_message)
my_free((gptr) ssl_acceptor_fd, MYF(MY_ALLOW_ZERO_PTR)); my_free((gptr) ssl_acceptor_fd, MYF(MY_ALLOW_ZERO_PTR));
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
#ifdef USE_REGEX #ifdef USE_REGEX
regex_end(); my_regex_end();
#endif #endif
if (print_message && errmesg) if (print_message && errmesg)
...@@ -2529,7 +2529,7 @@ static int init_common_variables(const char *conf_file_name, int argc, ...@@ -2529,7 +2529,7 @@ static int init_common_variables(const char *conf_file_name, int argc,
set_var_init(); set_var_init();
mysys_uses_curses=0; mysys_uses_curses=0;
#ifdef USE_REGEX #ifdef USE_REGEX
regex_init(&my_charset_latin1); my_regex_init(&my_charset_latin1);
#endif #endif
if (!(default_charset_info= get_charset_by_csname(default_character_set_name, if (!(default_charset_info= get_charset_by_csname(default_character_set_name,
MY_CS_PRIMARY, MY_CS_PRIMARY,
...@@ -5879,7 +5879,7 @@ static void mysql_init_variables(void) ...@@ -5879,7 +5879,7 @@ static void mysql_init_variables(void)
#else #else
have_openssl=SHOW_OPTION_NO; have_openssl=SHOW_OPTION_NO;
#endif #endif
#ifdef HAVE_BROKEN_REALPATH #if !defined(HAVE_REALPATH) || defined(HAVE_BROKEN_REALPATH)
have_symlink=SHOW_OPTION_NO; have_symlink=SHOW_OPTION_NO;
#else #else
have_symlink=SHOW_OPTION_YES; have_symlink=SHOW_OPTION_YES;
...@@ -6550,7 +6550,7 @@ static void get_options(int argc,char **argv) ...@@ -6550,7 +6550,7 @@ static void get_options(int argc,char **argv)
usage(); usage();
exit(0); exit(0);
} }
#if defined(HAVE_BROKEN_REALPATH) #if !defined(HAVE_REALPATH) || defined(HAVE_BROKEN_REALPATH)
my_use_symdir=0; my_use_symdir=0;
my_disable_symlinks=1; my_disable_symlinks=1;
have_symlink=SHOW_OPTION_NO; have_symlink=SHOW_OPTION_NO;
......
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