summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
Diffstat (limited to 'extra')
-rw-r--r--extra/Makefile.am2
-rw-r--r--extra/comp_err.c31
-rw-r--r--extra/my_print_defaults.c125
-rw-r--r--extra/mysql_install.c218
-rw-r--r--extra/mysql_waitpid.c117
-rw-r--r--extra/perror.c150
-rw-r--r--extra/replace.c31
-rw-r--r--extra/resolve_stack_dump.c252
-rw-r--r--extra/resolveip.c74
9 files changed, 652 insertions, 348 deletions
diff --git a/extra/Makefile.am b/extra/Makefile.am
index 6292faf4ad4..8e4491969b5 100644
--- a/extra/Makefile.am
+++ b/extra/Makefile.am
@@ -18,7 +18,7 @@ INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include -I..
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
../dbug/libdbug.a ../strings/libmystrings.a
bin_PROGRAMS = replace comp_err perror resolveip my_print_defaults \
-resolve_stack_dump
+ resolve_stack_dump mysql_install mysql_waitpid
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/extra/comp_err.c b/extra/comp_err.c
index f7b68ff0891..806fb5052b4 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -1,23 +1,22 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
+/* 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+ 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 */
/* Saves all errmesg in a header file, updated by me, in a compact file */
-#include <global.h>
+#include <my_global.h>
#include <m_ctype.h>
#include <my_sys.h>
#include <m_string.h>
diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c
index 316d91ef7b3..c0f8a54f432 100644
--- a/extra/my_print_defaults.c
+++ b/extra/my_print_defaults.c
@@ -1,19 +1,18 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
+/* 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+ 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 */
/*
** print_default.c:
@@ -22,73 +21,79 @@
** Written by Monty
*/
-#include <global.h>
+#include <my_global.h>
#include <my_sys.h>
-#include <getopt.h>
+#include <my_getopt.h>
const char *config_file="my"; /* Default config file */
-static struct option long_options[] =
+static struct my_option my_long_options[] =
{
- {"config-file", required_argument, 0, 'c'},
- {"defaults-file", required_argument, 0, 'c'},
- {"defaults-extra-file", required_argument, 0, 'e'},
- {"extra-file", required_argument, 0, 'e'},
- {"no-defaults", no_argument, 0, 'n'},
- {"help", no_argument, 0, '?'},
- {"version", no_argument, 0, 'V'},
- {0, 0, 0, 0}
+ {"config-file", 'c', "The config file to be used",
+ (gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0},
+ {"defaults-file", 'c', "Synonym for --config-file",
+ (gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0},
+ {"defaults-extra-file", 'e',
+ "Read this file after the global /etc config file and before the config file in the users home directory.",
+ (gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR,
+ REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"extra-file", 'e',
+ "Synonym for --defaults-extra-file",
+ (gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR,
+ REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"no-defaults", 'n', "Return an empty string (useful for scripts)",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"help", '?', "Display this help message and exit.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"version", 'V', "Output version information and exit.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
+
static void usage(my_bool version)
{
- printf("%s Ver 1.3 for %s at %s\n",my_progname,SYSTEM_TYPE,
+ printf("%s Ver 1.5 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
if (version)
return;
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
puts("Prints all arguments that is give to some program using the default files");
- printf("Usage: %s [OPTIONS] groups\n",my_progname);
- printf("\n\
- -c, --config-file=#, --defaults-file=#\n\
- The config file to use (default '%s')\n\
- -e, --extra-file=#, --defaults-extra-file=#\n\
- Read this file after the global /etc config file and\n\
- before the config file in the users home directory.\n\
- -n, --no-defaults Return an empty string (useful for scripts)\n\
- -?, --help Display this help message and exit.\n\
- -V, --version Output version information and exit.\n",
- config_file);
- printf("\nExample usage: %s --config-file=my client mysql\n",my_progname);
+ printf("Usage: %s [OPTIONS] groups\n", my_progname);
+ my_print_help(my_long_options);
+ my_print_variables(my_long_options);
+ printf("\nExample usage:\n%s --config-file=my client mysql\n", my_progname);
}
-static int get_options(int *argc,char ***argv)
-{
- int c,option_index;
- while ((c=getopt_long(*argc,*argv,"nc:e:V?I",
- long_options, &option_index)) != EOF)
- {
- switch (c) {
- case 'c':
- config_file=optarg;
- break;
- case 'e':
- defaults_extra_file=optarg; /* Used by the load_defaults */
- break;
+static my_bool
+get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+ char *argument __attribute__((unused)))
+{
+ switch (optid) {
case 'n':
- exit(0);
+ exit(0);
case 'I':
case '?':
- usage(0);
- exit(0);
+ usage(0);
+ exit(0);
case 'V':
- usage(1);
- exit(0);
- }
+ usage(1);
+ exit(0);
}
- (*argc)-=optind;
- (*argv)+=optind;
+ return 0;
+}
+
+
+static int get_options(int *argc,char ***argv)
+{
+ int ho_error;
+
+ if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
+ exit(ho_error);
+
if (*argc < 1)
{
usage(0);
diff --git a/extra/mysql_install.c b/extra/mysql_install.c
index dfd71895647..e2783f906b9 100644
--- a/extra/mysql_install.c
+++ b/extra/mysql_install.c
@@ -18,24 +18,212 @@
/* Install or upgrade MySQL server. By Sasha Pachev <sasha@mysql.com>
*/
-#define INSTALL_VERSION "1.0"
+#define INSTALL_VERSION "1.2"
#define DONT_USE_RAID
-#include <global.h>
+#include <my_global.h>
#include <m_ctype.h>
#include <my_sys.h>
#include <m_string.h>
#include <mysql_version.h>
#include <errno.h>
-#include <getopt.h>
+#include <my_getopt.h>
-struct option long_options[] =
+#define ANSWERS_CHUNCK 32
+
+int have_gui=0;
+
+static struct my_option my_long_options[] =
{
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'V'},
- {0, 0,0,0}
+ {"help", '?', "Display this help and exit.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"version", 'V', "Output version information and exit.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
+/* For now, not much exciting here, but we'll add more once
+ we add GUI support
+ */
+typedef struct
+{
+ FILE* out;
+ FILE* in;
+ const char* question;
+ int default_ind;
+ DYNAMIC_ARRAY answers;
+} QUESTION_WIDGET;
+
+static void usage();
+static void die(const char* fmt, ...);
+static void print_version(void);
+static char get_answer_char(int ans_ind);
+static int ask_user(const char* question,int default_ind, ...);
+static void add_answer(QUESTION_WIDGET* w, const char* ans);
+static void display_question(QUESTION_WIDGET* w);
+static int init_question_widget(QUESTION_WIDGET* w, const char* question,
+ int default_ind);
+static void end_question_widget(QUESTION_WIDGET* w);
+static int get_answer(QUESTION_WIDGET* w);
+static char answer_from_char(char c);
+static void invalid_answer(QUESTION_WIDGET* w);
+
+enum {IMODE_STANDARD=0,IMODE_CUSTOM,IMODE_UPGRAGE} install_mode
+ = IMODE_STANDARD;
+
+static char get_answer_char(int ans_ind)
+{
+ return 'a' + ans_ind;
+}
+
+static void invalid_answer(QUESTION_WIDGET* w)
+{
+ if (!have_gui)
+ {
+ fprintf(w->out, "ERROR: invalid answer, try again...\a\n");
+ }
+}
+
+static char answer_from_char(char c)
+{
+ return c - 'a';
+}
+
+static void die(const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ fprintf(stderr, "%s: ", my_progname);
+ vfprintf(stderr, fmt, args);
+ fprintf(stderr, "\n");
+ va_end(args);
+ exit(1);
+}
+
+static void display_question(QUESTION_WIDGET* w)
+{
+ if (!have_gui)
+ {
+ uint i,num_answers=w->answers.elements;
+ DYNAMIC_ARRAY* answers = &w->answers;
+ fprintf(w->out,"\n%s\n\n",w->question);
+
+ for (i=0; i<num_answers; i++)
+ {
+ char* ans;
+ get_dynamic(answers,(gptr)&ans,i);
+ fprintf(w->out,"%c - %s\n",get_answer_char(i),ans);
+ }
+ fprintf(w->out,"q - Abort Install/Upgrade\n\n");
+ }
+}
+
+static void add_answer(QUESTION_WIDGET* w, const char* ans)
+{
+ insert_dynamic(&w->answers,(gptr)&ans);
+}
+
+static int init_question_widget(QUESTION_WIDGET* w, const char* question,
+ int default_ind)
+{
+ if (have_gui)
+ {
+ w->in = w->out = 0;
+ }
+ else
+ {
+ w->out = stdout;
+ w->in = stdin;
+ }
+ w->question = question;
+ w->default_ind = default_ind;
+ if (my_init_dynamic_array(&w->answers,sizeof(char*),
+ ANSWERS_CHUNCK,ANSWERS_CHUNCK))
+ die("Out of memory");
+ return 0;
+}
+
+static void end_question_widget(QUESTION_WIDGET* w)
+{
+ delete_dynamic(&w->answers);
+}
+
+static int get_answer(QUESTION_WIDGET* w)
+{
+ if (!have_gui)
+ {
+ char buf[32];
+ int ind;
+ char c;
+ if (!fgets(buf,sizeof(buf),w->in))
+ die("Failed fgets on input stream");
+ switch ((c=tolower(*buf)))
+ {
+ case '\n':
+ return w->default_ind;
+ case 'q':
+ die("Install/Upgrade aborted");
+ default:
+ ind = answer_from_char(c);
+ if (ind >= 0 && ind < (int)w->answers.elements)
+ return ind;
+ }
+ }
+ return -1;
+}
+
+static int ask_user(const char* question,int default_ind, ...)
+{
+ va_list args;
+ char* opt;
+ QUESTION_WIDGET w;
+ int ans;
+
+ va_start(args,default_ind);
+ init_question_widget(&w,question,default_ind);
+ for (;(opt=va_arg(args,char*));)
+ {
+ add_answer(&w,opt);
+ }
+ for (;;)
+ {
+ display_question(&w);
+ if ((ans = get_answer(&w)) >= 0)
+ break;
+ invalid_answer(&w);
+ }
+ end_question_widget(&w);
+ va_end(args);
+ return ans;
+}
+
+
+static my_bool
+get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+ char *argument __attribute__((unused)))
+{
+ switch(optid) {
+ case 'V':
+ print_version();
+ exit(0);
+ case '?':
+ usage();
+ exit(0);
+ }
+ return 0;
+}
+
+
+static int parse_args(int argc, char **argv)
+{
+ int ho_error;
+
+ if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
+ exit(ho_error);
+
+ return 0;
+}
+
static void print_version(void)
{
printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,INSTALL_VERSION,
@@ -49,12 +237,20 @@ static void usage()
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
printf("Install or upgrade MySQL server.\n\n");
printf("Usage: %s [OPTIONS] \n", my_progname);
- printf("\n\
- -?, --help Display this help and exit.\n\
- -h, --host=... Connect to host.\n\
- -V, --version Output version information and exit.\n");
+ my_print_help(my_long_options);
+ my_print_variables(my_long_options);
}
+int main(int argc, char** argv)
+{
+ MY_INIT(argv[0]);
+ parse_args(argc,argv);
+ install_mode = ask_user("Please select install/upgrade mode",
+ install_mode, "Standard Install",
+ "Custom Install", "Upgrade",0);
+ printf("mode=%d\n", install_mode);
+ return 0;
+}
diff --git a/extra/mysql_waitpid.c b/extra/mysql_waitpid.c
new file mode 100644
index 00000000000..bff1752ec21
--- /dev/null
+++ b/extra/mysql_waitpid.c
@@ -0,0 +1,117 @@
+/* Copyright (C) 2003 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 */
+
+/* Wait until a program dies */
+
+#ifndef __NETWARE__
+
+#include <my_global.h>
+#include <m_string.h>
+#include <my_getopt.h>
+#include <signal.h>
+#include <errno.h>
+
+static const char *VER= "1.1";
+static char *progname;
+static my_bool verbose;
+
+void usage(void);
+
+static struct my_option my_long_options[] =
+{
+ {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
+ 0, 0, 0, 0, 0},
+ {"help", 'I', "Synonym for -?.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
+ 0, 0, 0, 0, 0},
+ {"verbose", 'v',
+ "Be more verbose. Give a warning, if kill can't handle signal 0.",
+ (gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"version", 'V', "Print version information and exit.", 0, 0, 0,
+ GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
+};
+
+static my_bool
+get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+ char *argument __attribute__((unused)))
+{
+ switch(optid) {
+ case 'V':
+ printf("%s version %s by Jani Tolonen\n", progname, VER);
+ exit(-1);
+ case 'I':
+ case '?':
+ usage();
+ }
+ return 0;
+}
+
+
+int main(int argc, char *argv[])
+{
+ int pid= 0, t= 0, sig= 0;
+
+ progname= argv[0];
+
+ if (handle_options(&argc, &argv, my_long_options, get_one_option))
+ exit(-1);
+ if (!argv[0] || !argv[1] || (pid= atoi(argv[0])) <= 0 ||
+ (t= atoi(argv[1])) <= 0)
+ usage();
+ for (; t > 0; t--)
+ {
+ if (kill((pid_t) pid, sig))
+ {
+ if (errno == EINVAL)
+ {
+ if (verbose)
+ printf("WARNING: kill couldn't handle signal 0, using signal 1.\n");
+ sig= 1;
+ t++;
+ continue;
+ }
+ return 0;
+ }
+ sleep(1);
+ }
+ return 1;
+}
+
+void usage(void)
+{
+ printf("%s version %s by Jani Tolonen\n\n", progname, VER);
+ printf("usage: %s [options] #pid #time\n\n", progname);
+ printf("Description: Waits for a program, which program id is #pid, to\n");
+ printf("terminate within #time seconds. If the program terminates within\n");
+ printf("this time, or if the #pid no longer exists, value 0 is returned.\n");
+ printf("Otherwise 1 is returned. Both #pid and #time must be positive\n");
+ printf("integer arguments.\n\n");
+ printf("Options:\n");
+ my_print_help(my_long_options);
+ exit(-1);
+}
+
+#else
+
+#include <stdio.h>
+
+main()
+{
+ fprintf(stderr,"This tool has not been ported to NetWare\n");
+ return 0;
+}
+
+#endif /* __NETWARE__ */
diff --git a/extra/perror.c b/extra/perror.c
index 6cb86eedf27..ca6bbfb54f9 100644
--- a/extra/perror.c
+++ b/extra/perror.c
@@ -1,48 +1,57 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
+/* 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+ 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 */
/* Return error-text for system error messages and nisam messages */
-#define PERROR_VERSION "2.7"
+#define PERROR_VERSION "2.9"
-#include <global.h>
+#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
#include <errno.h>
-#include <getopt.h>
+#include <my_getopt.h>
+static my_bool verbose, print_all_codes;
-static struct option long_options[] =
+static struct my_option my_long_options[] =
{
- {"help", no_argument, 0, '?'},
- {"info", no_argument, 0, 'I'},
- {"all", no_argument, 0, 'a'},
- {"silent", no_argument, 0, 's'},
- {"verbose", no_argument, 0, 'v'},
- {"version", no_argument, 0, 'V'},
- {0, 0, 0, 0}
+ {"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG,
+ NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"info", 'I', "Synonym for --help", 0, 0, 0, GET_NO_ARG,
+ NO_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef HAVE_SYS_ERRLIST
+ {"all", 'a', "Print all the error messages and the number.",
+ (gptr*) &print_all_codes, (gptr*) &print_all_codes, 0, GET_BOOL, NO_ARG,
+ 0, 0, 0, 0, 0, 0},
+#endif
+ {"silent", 's', "Only print the error message", 0, 0, 0, GET_NO_ARG, NO_ARG,
+ 0, 0, 0, 0, 0, 0},
+ {"verbose", 'v', "Print error code and message (default).", (gptr*) &verbose,
+ (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
+ {"version", 'V', "Displays version information and exits.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
+
typedef struct ha_errors {
int errcode;
const char *msg;
} HA_ERRORS;
-static int verbose=1,print_all_codes=0;
static HA_ERRORS ha_errlist[]=
{
@@ -50,8 +59,10 @@ static HA_ERRORS ha_errlist[]=
{ 121,"Duplicate key on write or update" },
{ 123,"Someone has changed the row since it was read; Update with is recoverable" },
{ 124,"Wrong index given to function" },
- { 126,"Index file is crashed / Wrong file format" },
+ { 126,"Index file is crashed" },
{ 127,"Record-file is crashed" },
+ { 128,"Out of memory" },
+ { 130,"Incorrect file format" },
{ 131,"Command not supported by database" },
{ 132,"Old database file" },
{ 133,"No record read before update" },
@@ -64,13 +75,16 @@ static HA_ERRORS ha_errlist[]=
{ 140,"Wrong create options"},
{ 141,"Duplicate unique key or constraint on write or update"},
{ 142,"Unknown character set used"},
- { 143,"Conflicting table definition between MERGE and mapped table"},
+ { 143,"Conflicting table definitions in sub-tables of MERGE table"},
{ 144,"Table is crashed and last repair failed"},
{ 145,"Table was marked as crashed and should be repaired"},
{ 146,"Lock timed out; Retry transaction"},
{ 147,"Lock table is full; Restart program with a larger locktable"},
{ 148,"Updates are not allowed under a read only transactions"},
{ 149,"Lock deadlock; Retry transaction"},
+ { 150,"Foreign key constraint is incorrectly formed"},
+ { 151,"Cannot add a child row"},
+ { 152,"Cannot delete a parent row"},
{ -30999, "DB_INCOMPLETE: Sync didn't finish"},
{ -30998, "DB_KEYEMPTY: Key/data deleted or never created"},
{ -30997, "DB_KEYEXIST: The key/data pair already exists"},
@@ -97,60 +111,43 @@ static void usage(void)
{
print_version();
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
- printf("Print a description for a system error code or a error code from\na MyISAM/ISAM/BDB table handler.\n");
+ printf("Print a description for a system error code or an error code from\na MyISAM/ISAM/BDB table handler.\n");
printf("If you want to get the error for a negative error code, you should use\n-- before the first error code to tell perror that there was no more options.\n\n");
printf("Usage: %s [OPTIONS] [ERRORCODE [ERRORCODE...]]\n",my_progname);
- printf("\n\
- -?, --help Displays this help and exits.\n\
- -I, --info Synonym for the above.");
-#ifdef HAVE_SYS_ERRLIST
- printf("\n\
- -a, --all Print all the error messages and the number.");
-#endif
- printf("\n\
- -s, --silent Only print the error message\n\
- -v, --verbose Print error code and message (default).\n\
- -V, --version Displays version information and exits.\n");
-}
+ my_print_help(my_long_options);
+ my_print_variables(my_long_options);
+}
+
+
+static my_bool
+get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+ char *argument __attribute__((unused)))
+{
+ switch (optid) {
+ case 's':
+ verbose=0;
+ break;
+ case 'V':
+ print_version();
+ exit(0);
+ break;
+ case 'I':
+ case '?':
+ usage();
+ exit(0);
+ break;
+ }
+ return 0;
+}
static int get_options(int *argc,char ***argv)
{
- int c,option_index;
+ int ho_error;
+
+ if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
+ exit(ho_error);
- while ((c=getopt_long(*argc,*argv,"asvVI?",long_options,
- &option_index)) != EOF)
- {
- switch (c) {
-#ifdef HAVE_SYS_ERRLIST
- case 'a':
- print_all_codes=1;
- break;
-#endif
- case 'v':
- verbose=1;
- break;
- case 's':
- verbose=0;
- break;
- case 'V':
- print_version();
- exit(0);
- break;
- case 'I':
- case '?':
- usage();
- exit(0);
- break;
- default:
- fprintf(stderr,"%s: Illegal option character '%c'\n",
- my_progname,opterr);
- return(1);
- break;
- }
- }
- (*argc)-=optind;
- (*argv)+=optind;
if (!*argc && !print_all_codes)
{
usage();
@@ -231,4 +228,3 @@ int main(int argc,char *argv[])
exit(error);
return error;
}
-
diff --git a/extra/replace.c b/extra/replace.c
index ef3abda5cc5..41312f5e3d4 100644
--- a/extra/replace.c
+++ b/extra/replace.c
@@ -1,19 +1,18 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
+/* 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+ 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 */
/* Replace strings in textfile
This program replace strings in a file or on stdin/stdout.
@@ -38,7 +37,7 @@
*/
#define DONT_USE_RAID
-#include <global.h>
+#include <my_global.h>
#include <m_ctype.h>
#include <my_sys.h>
#include <m_string.h>
diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c
index a08845b8de3..c54f17a186e 100644
--- a/extra/resolve_stack_dump.c
+++ b/extra/resolve_stack_dump.c
@@ -1,37 +1,36 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
+/* 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+ 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 */
/* Resolve numeric stack dump produced by mysqld 3.23.30 and later
versions into symbolic names. By Sasha Pachev <sasha@mysql.com>
*/
#define DONT_USE_RAID
-#include <global.h>
+#include <my_global.h>
#include <m_ctype.h>
#include <my_sys.h>
#include <m_string.h>
#include <mysql_version.h>
#include <errno.h>
-#include <getopt.h>
+#include <my_getopt.h>
#define INIT_SYM_TABLE 4096
#define INC_SYM_TABLE 4096
#define MAX_SYM_SIZE 128
-#define DUMP_VERSION "1.2"
+#define DUMP_VERSION "1.4"
#define HEX_INVALID (uchar)255
typedef ulong my_long_addr_t ; /* at some point, we need to fix configure
@@ -49,15 +48,21 @@ static char* dump_fname = 0, *sym_fname = 0;
static DYNAMIC_ARRAY sym_table; /* how do you like this , static DYNAMIC ? */
static FILE* fp_dump, *fp_sym = 0, *fp_out;
-struct option long_options[] =
+static struct my_option my_long_options[] =
{
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'V'},
- {"symbols-file", required_argument, 0, 's'},
- {"numeric-dump-file", required_argument, 0, 'n'},
- {0, 0,0,0}
+ {"help", 'h', "Display this help and exit.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"version", 'V', "Output version information and exit.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"symbols-file", 's', "Use specified symbols file.", (gptr*) &sym_fname,
+ (gptr*) &sym_fname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"numeric-dump-file", 'n', "Read the dump from specified file.",
+ (gptr*) &dump_fname, (gptr*) &dump_fname, 0, GET_STR, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0},
+ { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
+
static void verify_sort();
static void print_version(void)
@@ -72,12 +77,10 @@ static void usage()
printf("MySQL AB, by Sasha Pachev\n");
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
printf("Resolve numeric stack strace dump into symbols.\n\n");
- printf("Usage: %s [OPTIONS] symbols-file [numeric-dump-file]\n", my_progname);
- printf("\n\
- -?, --help Display this help and exit.\n\
- -s, --symbols-file=... Use specified symbols file.\n\
- -n, --numeric-dump-file=... Read the dump from specified file.\n\
- -V, --version Output version information and exit.\n");
+ printf("Usage: %s [OPTIONS] symbols-file [numeric-dump-file]\n",
+ my_progname);
+ my_print_help(my_long_options);
+ my_print_variables(my_long_options);
printf("\n\
The symbols-file should include the output from: 'nm --numeric-sort mysqld'.\n\
The numeric-dump-file should contain a numeric stack trace from mysqld.\n\
@@ -98,40 +101,33 @@ static void die(const char* fmt, ...)
}
-static int parse_args(int argc, char **argv)
+static my_bool
+get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+ char *argument __attribute__((unused)))
{
- int c, option_index = 0;
+ switch(optid) {
+ case 'V':
+ print_version();
+ exit(0);
+ case '?':
+ usage();
+ exit(0);
+ }
+ return 0;
+}
- while((c = getopt_long(argc, argv, "?Vn:s:",
- long_options, &option_index)) != EOF)
- {
- switch(c)
- {
- case 'n':
- dump_fname = optarg;
- break;
- case 's':
- sym_fname = optarg;
- break;
- case 'V':
- print_version();
- exit(0);
- case '?':
- usage();
- exit(0);
- default:
- usage();
- exit(1);
- }
- }
- argc-=optind;
- argv+=optind;
+static int parse_args(int argc, char **argv)
+{
+ int ho_error;
+
+ if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
+ exit(ho_error);
/*
The following code is to make the command compatible with the old
version that required one to use the -n and -s options
- */
+ */
if (argc == 2)
{
@@ -163,26 +159,26 @@ static void open_files()
{
fp_out = stdout;
fp_dump = stdin;
-
- if(dump_fname && !(fp_dump = my_fopen(dump_fname, O_RDONLY, MYF(MY_WME))))
+
+ if (dump_fname && !(fp_dump = my_fopen(dump_fname, O_RDONLY, MYF(MY_WME))))
die("Could not open %s", dump_fname);
/* if name not given, assume stdin*/
- if(!sym_fname)
+ if (!sym_fname)
die("Please run nm --numeric-sort on mysqld binary that produced stack \
trace dump and specify the path to it with -s or --symbols-file");
- if(!(fp_sym = my_fopen(sym_fname, O_RDONLY, MYF(MY_WME))))
+ if (!(fp_sym = my_fopen(sym_fname, O_RDONLY, MYF(MY_WME))))
die("Could not open %s", sym_fname);
-
+
}
static uchar hex_val(char c)
{
uchar l;
- if(isdigit(c))
+ if (isdigit(c))
return c - '0';
l = tolower(c);
- if(l < 'a' || l > 'f')
+ if (l < 'a' || l > 'f')
return HEX_INVALID;
return (uchar)10 + ((uchar)c - (uchar)'a');
}
@@ -192,10 +188,10 @@ static my_long_addr_t read_addr(char** buf)
uchar c;
char* p = *buf;
my_long_addr_t addr = 0;
-
+
while((c = hex_val(*p++)) != HEX_INVALID)
addr = (addr << 4) + c;
-
+
*buf = p;
return addr;
}
@@ -205,25 +201,18 @@ static int init_sym_entry(SYM_ENTRY* se, char* buf)
char* p, *p_end;
se->addr = (uchar*)read_addr(&buf);
- if(!se->addr)
+ if (!se->addr)
return -1;
- while(isspace(*buf++))
- /* empty */;
-
- while(isspace(*buf++))
- /* empty - skip more space */;
+ while (isspace(*buf++)) ;
+
+ while (isspace(*buf++)) ; /* skip more space */
--buf;
/* now we are on the symbol */
- for(p = se->symbol, p_end = se->symbol + sizeof(se->symbol) - 1;
- *buf != '\n' && *buf; ++buf,++p )
- {
- if(p < p_end)
- *p = *buf;
- else
- break;
- }
+ for (p = se->symbol, p_end = se->symbol + sizeof(se->symbol) - 1;
+ *buf != '\n' && *buf && p < p_end; ++buf,++p)
+ *p = *buf;
*p = 0;
- if(!strcmp(se->symbol, "gcc2_compiled."))
+ if (!strcmp(se->symbol, "gcc2_compiled."))
return -1;
return 0;
}
@@ -231,18 +220,18 @@ static int init_sym_entry(SYM_ENTRY* se, char* buf)
static void init_sym_table()
{
char buf[512];
- if(my_init_dynamic_array(&sym_table, sizeof(SYM_ENTRY), INIT_SYM_TABLE,
- INC_SYM_TABLE))
+ if (my_init_dynamic_array(&sym_table, sizeof(SYM_ENTRY), INIT_SYM_TABLE,
+ INC_SYM_TABLE))
die("Failed in my_init_dynamic_array() -- looks like out of memory problem");
- while(fgets(buf, sizeof(buf), fp_sym))
- {
- SYM_ENTRY se;
- if(init_sym_entry(&se, buf))
- continue;
- if(insert_dynamic(&sym_table, (gptr)&se))
- die("insert_dynamic() failed - looks like we are out of memory");
- }
+ while (fgets(buf, sizeof(buf), fp_sym))
+ {
+ SYM_ENTRY se;
+ if (init_sym_entry(&se, buf))
+ continue;
+ if (insert_dynamic(&sym_table, (gptr)&se))
+ die("insert_dynamic() failed - looks like we are out of memory");
+ }
verify_sort();
}
@@ -256,67 +245,69 @@ static void verify_sort()
{
uint i;
uchar* last = 0;
-
- for(i = 0; i < sym_table.elements; i++)
- {
- SYM_ENTRY se;
- get_dynamic(&sym_table, (gptr)&se, i);
- if(se.addr < last)
- die("sym table does not appear to be sorted, did you forget \
+
+ for (i = 0; i < sym_table.elements; i++)
+ {
+ SYM_ENTRY se;
+ get_dynamic(&sym_table, (gptr)&se, i);
+ if (se.addr < last)
+ die("sym table does not appear to be sorted, did you forget \
--numeric-sort arg to nm? trouble addr = %p, last = %p", se.addr, last);
- last = se.addr;
- }
+ last = se.addr;
+ }
}
+
static SYM_ENTRY* resolve_addr(uchar* addr, SYM_ENTRY* se)
{
uint i;
get_dynamic(&sym_table, (gptr)se, 0);
- if(addr < se->addr)
+ if (addr < se->addr)
return 0;
-
- for(i = 1; i < sym_table.elements; i++)
+
+ for (i = 1; i < sym_table.elements; i++)
+ {
+ get_dynamic(&sym_table, (gptr)se, i);
+ if (addr < se->addr)
{
- get_dynamic(&sym_table, (gptr)se, i);
- if(addr < se->addr)
- {
- get_dynamic(&sym_table, (gptr)se, i - 1);
- return se;
- }
+ get_dynamic(&sym_table, (gptr)se, i - 1);
+ return se;
}
+ }
return se;
}
+
static void do_resolve()
{
char buf[1024], *p;
- while(fgets(buf, sizeof(buf), fp_dump))
+ while (fgets(buf, sizeof(buf), fp_dump))
+ {
+ p = buf;
+ while(isspace(*p))
+ ++p;
+
+ if (*p++ == '0' && *p++ == 'x')
{
- p = buf;
- while(isspace(*p))
- ++p;
- /* skip space */;
-
- if(*p++ == '0' && *p++ == 'x')
- {
- SYM_ENTRY se ;
- uchar* addr = (uchar*)read_addr(&p);
- if(resolve_addr(addr, &se))
- fprintf(fp_out, "%p %s + %d\n", addr, se.symbol,
- (int) (addr - se.addr));
- else
- fprintf(fp_out, "%p (?)\n", addr);
-
- }
+ SYM_ENTRY se ;
+ uchar* addr = (uchar*)read_addr(&p);
+ if (resolve_addr(addr, &se))
+ fprintf(fp_out, "%p %s + %d\n", addr, se.symbol,
+ (int) (addr - se.addr));
else
- {
- fputs(buf, fp_out);
- continue;
- }
+ fprintf(fp_out, "%p (?)\n", addr);
+
}
+ else
+ {
+ fputs(buf, fp_out);
+ continue;
+ }
+ }
}
+
int main(int argc, char** argv)
{
MY_INIT(argv[0]);
@@ -327,4 +318,3 @@ int main(int argc, char** argv)
clean_up();
return 0;
}
-
diff --git a/extra/resolveip.c b/extra/resolveip.c
index 764844bf622..9851ec49605 100644
--- a/extra/resolveip.c
+++ b/extra/resolveip.c
@@ -16,7 +16,7 @@
/* Resolves IP's to hostname and hostnames to IP's */
-#define RESOLVE_VERSION "2.0"
+#define RESOLVE_VERSION "2.3"
#include <my_global.h>
#include <m_ctype.h>
@@ -30,22 +30,26 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <my_net.h>
-#include <getopt.h>
+#include <my_getopt.h>
#if !defined(_AIX) && !defined(HAVE_UNIXWARE7_THREADS) && !defined(HAVE_UNIXWARE7_POSIX) && !defined(h_errno)
extern int h_errno;
#endif
-static int silent=0;
+static my_bool silent;
-static struct option long_options[] =
+static struct my_option my_long_options[] =
{
- {"help", no_argument, 0, '?'},
- {"info", no_argument, 0, 'I'},
- {"silent", no_argument, 0, 's'},
- {"version", no_argument, 0, 'V'},
- {0, 0, 0, 0}
+ {"help", '?', "Displays this help and exits.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"info", 'I', "Synonym for --help",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent,
+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"version", 'V', "Displays version information and exits.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -62,41 +66,36 @@ static void usage(void)
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
puts("Get hostname based on IP-address or IP-address based on hostname.\n");
printf("Usage: %s [OPTIONS] hostname or IP-address\n",my_progname);
- printf("\n\
- -?, --help Displays this help and exits.\n\
- -I, --info Synonym for the above.\n\
- -s, --silent Be more silent.\n\
- -V, --version Displays version information and exits.\n");
+ my_print_help(my_long_options);
+ my_print_variables(my_long_options);
+}
+
+
+static my_bool
+get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+ char *argument __attribute__((unused)))
+{
+ switch (optid) {
+ case 'V': print_version(); exit(0);
+ case 'I':
+ case '?':
+ usage();
+ exit(0);
+ }
+ return 0;
}
/*static my_string load_default_groups[]= { "resolveip","client",0 }; */
static int get_options(int *argc,char ***argv)
{
- int c,option_index;
+ int ho_error;
/* load_defaults("my",load_default_groups,argc,argv); */
- while ((c=getopt_long(*argc,*argv,"?IsV",
- long_options, &option_index)) != EOF)
- {
- switch (c) {
- case 's':
- silent=1;
- break;
- case 'V': print_version(); exit(0);
- case 'I':
- case '?':
- usage();
- exit(0);
- default:
- fprintf(stderr,"%s: Illegal option character '%c'\n",
- my_progname,opterr);
- return(1);
- break;
- }
- }
- (*argc)-=optind;
- (*argv)+=optind;
+
+ if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
+ exit(ho_error);
+
if (*argc == 0)
{
usage();
@@ -148,8 +147,11 @@ int main(int argc, char **argv)
else
{
printf ("Host name of %s is %s", ip,hpaddr->h_name);
+#ifndef __NETWARE__
+ /* this information is not available on NetWare */
for (q = hpaddr->h_aliases; *q != 0; q++)
(void) printf(", %s", *q);
+#endif /* __NETWARE__ */
puts("");
}
}