mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
into pilot.blaudden:/home/msvensson/mysql/mysql-5.1-new-maint client/mysqltest.c: Auto merged mysql-test/lib/mtr_misc.pl: Auto merged BitKeeper/deleted/.del-CMakeLists.txt~7: Auto merged mysql-test/mysql-test-run.pl: Manual merge with add of --debug-info
This commit is contained in:
45
client/echo.c
Normal file
45
client/echo.c
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/* Copyright (C) 2000 MySQL AB
|
||||||
|
|
||||||
|
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
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
|
/*
|
||||||
|
echo is a replacement for the "echo" command builtin to cmd.exe
|
||||||
|
on Windows, to get a Unix eqvivalent behaviour when running commands
|
||||||
|
like:
|
||||||
|
$> echo "hello" | mysql
|
||||||
|
|
||||||
|
The windows "echo" would have sent "hello" to mysql while
|
||||||
|
Unix echo will send hello without the enclosing hyphens
|
||||||
|
|
||||||
|
This is a very advanced high tech program so take care when
|
||||||
|
you change it and remember to valgrind it before production
|
||||||
|
use.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i= 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "%s", argv[i]);
|
||||||
|
if (i < argc - 1)
|
||||||
|
fprintf(stdout, " ");
|
||||||
|
}
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
return 0;
|
||||||
|
}
|
@ -409,6 +409,8 @@ TYPELIB command_typelib= {array_elements(command_names),"",
|
|||||||
|
|
||||||
DYNAMIC_STRING ds_res, ds_progress, ds_warning_messages;
|
DYNAMIC_STRING ds_res, ds_progress, ds_warning_messages;
|
||||||
|
|
||||||
|
char builtin_echo[FN_REFLEN];
|
||||||
|
|
||||||
void die(const char *fmt, ...)
|
void die(const char *fmt, ...)
|
||||||
ATTRIBUTE_FORMAT(printf, 1, 2);
|
ATTRIBUTE_FORMAT(printf, 1, 2);
|
||||||
void abort_not_supported_test(const char *fmt, ...)
|
void abort_not_supported_test(const char *fmt, ...)
|
||||||
@ -935,10 +937,10 @@ void warning_msg(const char *fmt, ...)
|
|||||||
dynstr_append_mem(&ds_warning_messages,
|
dynstr_append_mem(&ds_warning_messages,
|
||||||
buff, len);
|
buff, len);
|
||||||
}
|
}
|
||||||
#ifndef __WIN__
|
|
||||||
len= vsnprintf(buff, sizeof(buff), fmt, args);
|
len= my_vsnprintf(buff, sizeof(buff), fmt, args);
|
||||||
dynstr_append_mem(&ds_warning_messages, buff, len);
|
dynstr_append_mem(&ds_warning_messages, buff, len);
|
||||||
#endif
|
|
||||||
dynstr_append(&ds_warning_messages, "\n");
|
dynstr_append(&ds_warning_messages, "\n");
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
@ -1537,29 +1539,36 @@ void do_source(struct st_command *command)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __WIN__
|
#if defined __WIN__
|
||||||
|
|
||||||
|
#ifdef USE_CYGWIN
|
||||||
/* Variables used for temporary sh files used for emulating Unix on Windows */
|
/* Variables used for temporary sh files used for emulating Unix on Windows */
|
||||||
char tmp_sh_name[64], tmp_sh_cmd[70];
|
char tmp_sh_name[64], tmp_sh_cmd[70];
|
||||||
|
#endif
|
||||||
|
|
||||||
void init_tmp_sh_file()
|
void init_tmp_sh_file()
|
||||||
{
|
{
|
||||||
|
#ifdef USE_CYGWIN
|
||||||
/* Format a name for the tmp sh file that is unique for this process */
|
/* Format a name for the tmp sh file that is unique for this process */
|
||||||
my_snprintf(tmp_sh_name, sizeof(tmp_sh_name), "tmp_%d.sh", getpid());
|
my_snprintf(tmp_sh_name, sizeof(tmp_sh_name), "tmp_%d.sh", getpid());
|
||||||
/* Format the command to execute in order to run the script */
|
/* Format the command to execute in order to run the script */
|
||||||
my_snprintf(tmp_sh_cmd, sizeof(tmp_sh_cmd), "sh %s", tmp_sh_name);
|
my_snprintf(tmp_sh_cmd, sizeof(tmp_sh_cmd), "sh %s", tmp_sh_name);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void free_tmp_sh_file()
|
void free_tmp_sh_file()
|
||||||
{
|
{
|
||||||
|
#ifdef USE_CYGWIN
|
||||||
my_delete(tmp_sh_name, MYF(0));
|
my_delete(tmp_sh_name, MYF(0));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode)
|
FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode)
|
||||||
{
|
{
|
||||||
#ifdef __WIN__
|
#if defined __WIN__ && defined USE_CYGWIN
|
||||||
/* Dump the command into a sh script file and execute with popen */
|
/* Dump the command into a sh script file and execute with popen */
|
||||||
str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length);
|
str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length);
|
||||||
return popen(tmp_sh_cmd, mode);
|
return popen(tmp_sh_cmd, mode);
|
||||||
@ -1569,6 +1578,64 @@ FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void init_builtin_echo(void)
|
||||||
|
{
|
||||||
|
#ifdef __WIN__
|
||||||
|
|
||||||
|
/* Look for "echo.exe" in same dir as mysqltest was started from */
|
||||||
|
dirname_part(builtin_echo, my_progname);
|
||||||
|
fn_format(builtin_echo, ".\\echo.exe",
|
||||||
|
builtin_echo, "", MYF(MY_REPLACE_DIR));
|
||||||
|
|
||||||
|
/* Make sure echo.exe exists */
|
||||||
|
if (access(builtin_echo, F_OK) != 0)
|
||||||
|
builtin_echo[0]= 0;
|
||||||
|
return;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
builtin_echo[0]= 0;
|
||||||
|
return;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Replace a substring
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
replace
|
||||||
|
ds_str The string to search and perform the replace in
|
||||||
|
search_str The string to search for
|
||||||
|
search_len Length of the string to search for
|
||||||
|
replace_str The string to replace with
|
||||||
|
replace_len Length of the string to replace with
|
||||||
|
|
||||||
|
RETURN
|
||||||
|
0 String replaced
|
||||||
|
1 Could not find search_str in str
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int replace(DYNAMIC_STRING *ds_str,
|
||||||
|
const char *search_str, ulong search_len,
|
||||||
|
const char *replace_str, ulong replace_len)
|
||||||
|
{
|
||||||
|
DYNAMIC_STRING ds_tmp;
|
||||||
|
const char *start= strstr(ds_str->str, search_str);
|
||||||
|
if (!start)
|
||||||
|
return 1;
|
||||||
|
init_dynamic_string(&ds_tmp, "",
|
||||||
|
ds_str->length + replace_len, 256);
|
||||||
|
dynstr_append_mem(&ds_tmp, ds_str->str, start - ds_str->str);
|
||||||
|
dynstr_append_mem(&ds_tmp, replace_str, replace_len);
|
||||||
|
dynstr_append(&ds_tmp, start + search_len);
|
||||||
|
dynstr_set(ds_str, ds_tmp.str);
|
||||||
|
dynstr_free(&ds_tmp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Execute given command.
|
Execute given command.
|
||||||
|
|
||||||
@ -1587,13 +1654,13 @@ FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode)
|
|||||||
NOTE
|
NOTE
|
||||||
Although mysqltest is executed from cygwin shell, the command will be
|
Although mysqltest is executed from cygwin shell, the command will be
|
||||||
executed in "cmd.exe". Thus commands like "rm" etc can NOT be used, use
|
executed in "cmd.exe". Thus commands like "rm" etc can NOT be used, use
|
||||||
system for those commands.
|
mysqltest commmand(s) like "remove_file" for that
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void do_exec(struct st_command *command)
|
void do_exec(struct st_command *command)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
char buf[1024];
|
char buf[512];
|
||||||
FILE *res_file;
|
FILE *res_file;
|
||||||
char *cmd= command->first_argument;
|
char *cmd= command->first_argument;
|
||||||
DYNAMIC_STRING ds_cmd;
|
DYNAMIC_STRING ds_cmd;
|
||||||
@ -1611,6 +1678,13 @@ void do_exec(struct st_command *command)
|
|||||||
/* Eval the command, thus replacing all environment variables */
|
/* Eval the command, thus replacing all environment variables */
|
||||||
do_eval(&ds_cmd, cmd, command->end, TRUE);
|
do_eval(&ds_cmd, cmd, command->end, TRUE);
|
||||||
|
|
||||||
|
/* Check if echo should be replaced with "builtin" echo */
|
||||||
|
if (builtin_echo[0] && strncmp(cmd, "echo", 4) == 0)
|
||||||
|
{
|
||||||
|
/* Replace echo with our "builtin" echo */
|
||||||
|
replace(&ds_cmd, "echo", 4, builtin_echo, strlen(builtin_echo));
|
||||||
|
}
|
||||||
|
|
||||||
DBUG_PRINT("info", ("Executing '%s' as '%s'",
|
DBUG_PRINT("info", ("Executing '%s' as '%s'",
|
||||||
command->first_argument, ds_cmd.str));
|
command->first_argument, ds_cmd.str));
|
||||||
|
|
||||||
@ -1736,7 +1810,7 @@ int do_modify_var(struct st_command *command,
|
|||||||
|
|
||||||
int my_system(DYNAMIC_STRING* ds_cmd)
|
int my_system(DYNAMIC_STRING* ds_cmd)
|
||||||
{
|
{
|
||||||
#ifdef __WIN__
|
#if defined __WIN__ && defined USE_CYGWIN
|
||||||
/* Dump the command into a sh script file and execute with system */
|
/* Dump the command into a sh script file and execute with system */
|
||||||
str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length);
|
str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length);
|
||||||
return system(tmp_sh_cmd);
|
return system(tmp_sh_cmd);
|
||||||
@ -5669,6 +5743,7 @@ int main(int argc, char **argv)
|
|||||||
parser.current_line= parser.read_lines= 0;
|
parser.current_line= parser.read_lines= 0;
|
||||||
memset(&var_reg, 0, sizeof(var_reg));
|
memset(&var_reg, 0, sizeof(var_reg));
|
||||||
|
|
||||||
|
init_builtin_echo();
|
||||||
#ifdef __WIN__
|
#ifdef __WIN__
|
||||||
init_tmp_sh_file();
|
init_tmp_sh_file();
|
||||||
init_win_path_patterns();
|
init_win_path_patterns();
|
||||||
|
@ -22,6 +22,7 @@ use strict;
|
|||||||
|
|
||||||
sub mtr_full_hostname ();
|
sub mtr_full_hostname ();
|
||||||
sub mtr_short_hostname ();
|
sub mtr_short_hostname ();
|
||||||
|
sub mtr_native_path($);
|
||||||
sub mtr_init_args ($);
|
sub mtr_init_args ($);
|
||||||
sub mtr_add_arg ($$@);
|
sub mtr_add_arg ($$@);
|
||||||
sub mtr_path_exists(@);
|
sub mtr_path_exists(@);
|
||||||
@ -63,6 +64,16 @@ sub mtr_short_hostname () {
|
|||||||
return $hostname;
|
return $hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Convert path to OS native format
|
||||||
|
sub mtr_native_path($)
|
||||||
|
{
|
||||||
|
my $path= shift;
|
||||||
|
$path=~ s/\//\\/g
|
||||||
|
if ($::glob_win32);
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# FIXME move to own lib
|
# FIXME move to own lib
|
||||||
|
|
||||||
sub mtr_init_args ($) {
|
sub mtr_init_args ($) {
|
||||||
|
@ -357,6 +357,7 @@ sub stop_all_servers ();
|
|||||||
sub run_mysqltest ($);
|
sub run_mysqltest ($);
|
||||||
sub usage ($);
|
sub usage ($);
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
#
|
#
|
||||||
# Main program
|
# Main program
|
||||||
@ -1569,7 +1570,8 @@ sub executable_setup () {
|
|||||||
sub generate_cmdline_mysqldump ($) {
|
sub generate_cmdline_mysqldump ($) {
|
||||||
my($mysqld) = @_;
|
my($mysqld) = @_;
|
||||||
return
|
return
|
||||||
"$exe_mysqldump --no-defaults --debug-info -uroot " .
|
mtr_native_path($exe_mysqldump) .
|
||||||
|
" --no-defaults -uroot --debug-info " .
|
||||||
"--port=$mysqld->{'port'} " .
|
"--port=$mysqld->{'port'} " .
|
||||||
"--socket=$mysqld->{'path_sock'} --password=";
|
"--socket=$mysqld->{'path_sock'} --password=";
|
||||||
}
|
}
|
||||||
@ -1815,7 +1817,8 @@ sub environment_setup () {
|
|||||||
# Setup env so childs can execute mysqlcheck
|
# Setup env so childs can execute mysqlcheck
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
my $cmdline_mysqlcheck=
|
my $cmdline_mysqlcheck=
|
||||||
"$exe_mysqlcheck --no-defaults --debug-info -uroot " .
|
mtr_native_path($exe_mysqlcheck) .
|
||||||
|
" --no-defaults --debug-info -uroot " .
|
||||||
"--port=$master->[0]->{'port'} " .
|
"--port=$master->[0]->{'port'} " .
|
||||||
"--socket=$master->[0]->{'path_sock'} --password=";
|
"--socket=$master->[0]->{'path_sock'} --password=";
|
||||||
|
|
||||||
@ -1849,7 +1852,8 @@ sub environment_setup () {
|
|||||||
if ( $exe_mysqlslap )
|
if ( $exe_mysqlslap )
|
||||||
{
|
{
|
||||||
my $cmdline_mysqlslap=
|
my $cmdline_mysqlslap=
|
||||||
"$exe_mysqlslap -uroot " .
|
mtr_native_path($exe_mysqlslap) .
|
||||||
|
" -uroot " .
|
||||||
"--port=$master->[0]->{'port'} " .
|
"--port=$master->[0]->{'port'} " .
|
||||||
"--socket=$master->[0]->{'path_sock'} --password= " .
|
"--socket=$master->[0]->{'path_sock'} --password= " .
|
||||||
"--lock-directory=$opt_tmpdir";
|
"--lock-directory=$opt_tmpdir";
|
||||||
@ -1866,7 +1870,8 @@ sub environment_setup () {
|
|||||||
# Setup env so childs can execute mysqlimport
|
# Setup env so childs can execute mysqlimport
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
my $cmdline_mysqlimport=
|
my $cmdline_mysqlimport=
|
||||||
"$exe_mysqlimport --debug-info -uroot " .
|
mtr_native_path($exe_mysqlimport) .
|
||||||
|
" -uroot --debug-info " .
|
||||||
"--port=$master->[0]->{'port'} " .
|
"--port=$master->[0]->{'port'} " .
|
||||||
"--socket=$master->[0]->{'path_sock'} --password=";
|
"--socket=$master->[0]->{'path_sock'} --password=";
|
||||||
|
|
||||||
@ -1882,7 +1887,8 @@ sub environment_setup () {
|
|||||||
# Setup env so childs can execute mysqlshow
|
# Setup env so childs can execute mysqlshow
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
my $cmdline_mysqlshow=
|
my $cmdline_mysqlshow=
|
||||||
"$exe_mysqlshow --debug-info -uroot " .
|
mtr_native_path($exe_mysqlshow) .
|
||||||
|
" -uroot --debug-info " .
|
||||||
"--port=$master->[0]->{'port'} " .
|
"--port=$master->[0]->{'port'} " .
|
||||||
"--socket=$master->[0]->{'path_sock'} --password=";
|
"--socket=$master->[0]->{'path_sock'} --password=";
|
||||||
|
|
||||||
@ -1897,7 +1903,7 @@ sub environment_setup () {
|
|||||||
# Setup env so childs can execute mysqlbinlog
|
# Setup env so childs can execute mysqlbinlog
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
my $cmdline_mysqlbinlog=
|
my $cmdline_mysqlbinlog=
|
||||||
"$exe_mysqlbinlog" .
|
mtr_native_path($exe_mysqlbinlog) .
|
||||||
" --no-defaults --disable-force-if-open --debug-info --local-load=$opt_tmpdir";
|
" --no-defaults --disable-force-if-open --debug-info --local-load=$opt_tmpdir";
|
||||||
if ( $mysql_version_id >= 50000 )
|
if ( $mysql_version_id >= 50000 )
|
||||||
{
|
{
|
||||||
@ -1915,7 +1921,8 @@ sub environment_setup () {
|
|||||||
# Setup env so childs can execute mysql
|
# Setup env so childs can execute mysql
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
my $cmdline_mysql=
|
my $cmdline_mysql=
|
||||||
"$exe_mysql --no-defaults --debug-info --host=localhost --user=root --password= " .
|
mtr_native_path($exe_mysql) .
|
||||||
|
" --no-defaults --debug-info --host=localhost --user=root --password= " .
|
||||||
"--port=$master->[0]->{'port'} " .
|
"--port=$master->[0]->{'port'} " .
|
||||||
"--socket=$master->[0]->{'path_sock'} ".
|
"--socket=$master->[0]->{'path_sock'} ".
|
||||||
"--character-sets-dir=$path_charsetsdir";
|
"--character-sets-dir=$path_charsetsdir";
|
||||||
@ -1953,17 +1960,17 @@ sub environment_setup () {
|
|||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
# Setup env so childs can execute my_print_defaults
|
# Setup env so childs can execute my_print_defaults
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults;
|
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
|
||||||
|
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
# Setup env so childs can execute mysqladmin
|
# Setup env so childs can execute mysqladmin
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
$ENV{'MYSQLADMIN'}= $exe_mysqladmin;
|
$ENV{'MYSQLADMIN'}= mtr_native_path($exe_mysqladmin);
|
||||||
|
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
# Setup env so childs can execute perror
|
# Setup env so childs can execute perror
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
$ENV{'MY_PERROR'}= $exe_perror;
|
$ENV{'MY_PERROR'}= mtr_native_path($exe_perror);
|
||||||
|
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
# Add the path where mysqld will find udf_example.so
|
# Add the path where mysqld will find udf_example.so
|
||||||
@ -4648,7 +4655,8 @@ sub run_mysqltest ($) {
|
|||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# export MYSQL_TEST variable containing <path>/mysqltest <args>
|
# export MYSQL_TEST variable containing <path>/mysqltest <args>
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
$ENV{'MYSQL_TEST'}= "$exe_mysqltest " . join(" ", @$args);
|
$ENV{'MYSQL_TEST'}=
|
||||||
|
mtr_native_path($exe_mysqltest) . " " . join(" ", @$args);
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# Add arguments that should not go into the MYSQL_TEST env var
|
# Add arguments that should not go into the MYSQL_TEST env var
|
||||||
|
Reference in New Issue
Block a user