Commit bb07d5c0 authored by unknown's avatar unknown

Changed mysqlbinlog, mysqlmanager-pwgen, mysqlmanagerc, mysqltest,

thread_test and isamchk to use my_getopt.

Fixed a bug in my_getopt.


client/mysqlbinlog.cc:
  Changed mysqlbinlog.cc to use my_getopt.
client/mysqlmanager-pwgen.c:
  Changed mysqlmanager-pwgen to use my_getopt.
client/mysqlmanagerc.c:
  Changed mysqlmanagerc to use my_getopt.
client/mysqltest.c:
  Changed mysqltest to use my_getopt.
client/thread_test.c:
  Changed thread_test to use my_getopt.
isam/isamchk.c:
  Changed isamchk to use my_getopt.
mysys/my_getopt.c:
  Fixed a bug in printing options when option didn't have a comment.
  Added startup initializing and printing for 'GET_BOOL' type variables.
sql/mysql_priv.h:
  Changed type.
sql/mysqld.cc:
  Fixed a bug in --local-infile option.
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
parent 3181a6af
......@@ -61,3 +61,4 @@ tonu@x3.internalnet
venu@work.mysql.com
zak@balfor.local
zak@linux.local
jani@hynda.(none)
......@@ -19,6 +19,7 @@
#include "client_priv.h"
#include <time.h>
#include "log_event.h"
#include <my_getopt.h>
#define PROBE_HEADER_LEN (4+EVENT_LEN_OFFSET+4)
......@@ -38,26 +39,6 @@ static FILE *result_file;
static const char* default_dbug_option = "d:t:o,/tmp/mysqlbinlog.trace";
#endif
static struct option long_options[] =
{
#ifndef DBUG_OFF
{"debug", optional_argument, 0, '#'},
#endif
{"database", required_argument, 0, 'd'},
{"help", no_argument, 0, '?'},
{"host", required_argument, 0, 'h'},
{"offset", required_argument, 0, 'o'},
{"password", required_argument, 0, 'p'},
{"port", required_argument, 0, 'P'},
{"position", required_argument, 0, 'j'},
{"result-file", required_argument, 0, 'r'},
{"short-form", no_argument, 0, 's'},
{"table", required_argument, 0, 't'},
{"user", required_argument, 0, 'u'},
{"version", no_argument, 0, 'V'},
{0,0,0,0}
};
void sql_print_error(const char *format,...);
static bool one_database = 0;
......@@ -82,6 +63,44 @@ static void dump_remote_table(NET* net, const char* db, const char* table);
static void die(const char* fmt, ...);
static MYSQL* safe_connect();
static struct my_option my_long_options[] =
{
#ifndef DBUG_OFF
{"debug", '#', "Output debug log.", (gptr*) &default_dbug_option,
(gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"database", 'd', "List entries for just this database (local log only)",
(gptr*) &database, (gptr*) &database, 0, GET_STR_ALLOC, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"help", '?', "Display this help and exit",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Get the binlog from server", (gptr*) &host, (gptr*) &host,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"offset", 'o', "Skip the first N entries", (gptr*) &offset, (gptr*) &offset,
0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', "Password to connect to remote server",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Use port to connect to the remote server",
(gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, MYSQL_PORT, 0, 0,
0, 0, 0},
{"position", 'j', "Start reading the binlog at position N",
(gptr*) &position, (gptr*) &position, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0,
0, 0},
{"result-file", 'r', "Direct output to a given file", 0, 0, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"short-form", 's', "Just show the queries, no extra info",
(gptr*) &short_form, (gptr*) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
{"table", 't', "Get raw table dump using COM_TABLE_DUMB", (gptr*) &table,
(gptr*) &table, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"user", 'u', "Connect to the remote server as username",
(gptr*) &user, (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0,
0, 0},
{"version", 'V', "Print version 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}
};
void sql_print_error(const char *format,...)
{
......@@ -106,7 +125,7 @@ static void die(const char* fmt, ...)
static void print_version()
{
printf("%s Ver 1.9 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE);
printf("%s Ver 2.0 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
}
......@@ -120,26 +139,10 @@ and you are welcome to modify and redistribute it under the GPL license\n");
printf("\
Dumps a MySQL binary log in a format usable for viewing or for pipeing to\n\
the mysql command line client\n\n");
printf("Usage: %s [options] log-files\n",my_progname);
puts("Options:");
#ifndef DBUG_OFF
printf("-#, --debug[=...] Output debug log. (%s)\n",
default_dbug_option);
#endif
printf("\
-?, --help Display this help and exit\n\
-s, --short-form Just show the queries, no extra info\n\
-o, --offset=N Skip the first N entries\n\
-d, --database=database List entries for just this database (local log only)\n\
-h, --host=server Get the binlog from server\n\
-P, --port=port Use port to connect to the remote server\n\
-u, --user=username Connect to the remote server as username\n\
-p, --password=password Password to connect to remote server\n\
-r, --result-file=file Direct output to a given file\n\
-j, --position=N Start reading the binlog at position N\n\
-t, --table=name Get raw table dump using COM_TABLE_DUMB\n\
-V, --version Print version and exit.\n\
");
printf("Usage: %s [options] log-files\n", my_progname);
my_print_help(my_long_options);
putchar('\n');
my_print_variables(my_long_options);
}
static void dump_remote_file(NET* net, const char* fname)
......@@ -172,82 +175,61 @@ static void dump_remote_file(NET* net, const char* fname)
fflush(result_file);
}
static int parse_args(int *argc, char*** argv)
{
int c, opt_index = 0;
result_file = stdout;
while((c = getopt_long(*argc, *argv, "so:#::d:h:j:u:p:P:r:t:?V", long_options,
&opt_index)) != EOF)
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch(optid)
{
switch(c)
{
#ifndef DBUG_OFF
case '#':
DBUG_PUSH(optarg ? optarg : default_dbug_option);
break;
case '#':
DBUG_PUSH(argument ? argument : default_dbug_option);
break;
#endif
case 'd':
one_database = 1;
database = my_strdup(optarg, MYF(0));
break;
case 's':
short_form = 1;
break;
case 'o':
offset = strtoull(optarg,(char**) 0, 10);
break;
case 'j':
position = strtoull(optarg,(char**) 0, 10);
break;
case 'h':
use_remote = 1;
host = my_strdup(optarg, MYF(0));
break;
case 'P':
use_remote = 1;
port = atoi(optarg);
break;
case 'p':
use_remote = 1;
pass = my_strdup(optarg, MYF(0));
break;
case 'r':
if (!(result_file = my_fopen(optarg, O_WRONLY | O_BINARY, MYF(MY_WME))))
exit(1);
break;
case 'u':
use_remote = 1;
user = my_strdup(optarg, MYF(0));
break;
case 't':
table = my_strdup(optarg, MYF(0));
break;
case 'd':
one_database = 1;
break;
case 'h':
use_remote = 1;
break;
case 'P':
use_remote = 1;
break;
case 'p':
use_remote = 1;
pass = my_strdup(argument, MYF(0));
break;
case 'r':
if (!(result_file = my_fopen(argument, O_WRONLY | O_BINARY, MYF(MY_WME))))
exit(1);
break;
case 'u':
use_remote = 1;
break;
case 'V':
print_version();
exit(0);
case '?':
default:
usage();
exit(0);
}
return 0;
}
case 'V':
print_version();
exit(0);
case '?':
default:
usage();
exit(0);
static int parse_args(int *argc, char*** argv)
{
int ho_error;
}
result_file = stdout;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
{
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
}
(*argc)-=optind;
(*argv)+=optind;
return 0;
}
......
......@@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define MANAGER_PWGEN_VERSION "1.0"
#define MANAGER_PWGEN_VERSION "1.1"
#include <my_global.h>
#include <m_ctype.h>
......@@ -22,18 +22,23 @@
#include <m_string.h>
#include <mysql_version.h>
#include <errno.h>
#include <getopt.h>
#include <my_getopt.h>
#include <md5.h>
const char* outfile=0,*user="root";
struct option long_options[] =
static struct my_option my_long_options[] =
{
{"output-file",required_argument,0,'o'},
{"user",required_argument,0,'u'},
{"help",no_argument,0,'?'},
{"version",no_argument,0,'V'},
{0,0,0,0}
{"output-file", 'o', "Write the output to the file with the given name",
(gptr*) &outfile, (gptr*) &outfile, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0,
0, 0},
{"user", 'u', "Put given user in the password file", (gptr*) &user,
(gptr*) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Display this message and exit", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
{"version", 'V', "Display version info", 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 die(const char* fmt, ...)
......@@ -66,36 +71,39 @@ void usage()
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
printf("Generates a password file to be used by mysqltest.\n\n");
printf("Usage: %s [OPTIONS]\n", my_progname);
printf("-?,--help Display this message and exit\n\
-V,--version Display version info\n\
-u,--user= Put given user in the password file\n\
-o,--output-file= Write the output to the file with the given name\n");
my_print_help(my_long_options);
putchar('\n');
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 '?':
usage();
exit(0);
case 'V':
print_version();
exit(0);
default:
usage();
exit(1);
}
return 0;
}
int parse_args(int argc, char** argv)
{
int c,option_index=0;
while ((c=getopt_long(argc,argv,"?Vu:o:",long_options,&option_index))
!= EOF)
int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{
switch (c)
{
case 'o':
outfile=optarg;
break;
case 'u':
user=optarg;
break;
case '?':
usage();
exit(0);
case 'V':
print_version();
exit(0);
default:
usage();
exit(1);
}
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
}
return 0;
}
......
......@@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define MANAGER_CLIENT_VERSION "1.1"
#define MANAGER_CLIENT_VERSION "1.2"
#include <my_global.h>
#include <mysql.h>
......@@ -22,7 +22,7 @@
#include <mysqld_error.h>
#include <my_sys.h>
#include <m_string.h>
#include <getopt.h>
#include <my_getopt.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <unistd.h>
......@@ -35,23 +35,31 @@ static void die(const char* fmt, ...);
const char* user="root",*host="localhost";
char* pass=0;
int quiet=0;
my_bool quiet=0;
uint port=MYSQL_MANAGER_PORT;
static const char *load_default_groups[]= { "mysqlmanagerc",0 };
char** default_argv;
MYSQL_MANAGER *manager;
FILE* fp, *fp_out;
struct option long_options[] =
static struct my_option my_long_options[] =
{
{"host",required_argument,0,'h'},
{"user",required_argument,0,'u'},
{"password",optional_argument,0,'p',},
{"port",required_argument,0,'P'},
{"help",no_argument,0,'?'},
{"version",no_argument,0,'V'},
{"quiet",no_argument,0,'q'},
{0,0,0,0}
{"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"user", 'u', "User for login.", (gptr*) &user, (gptr*) &user, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', "Password to use when connecting to server.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &port,
(gptr*) &port, 0, GET_UINT, REQUIRED_ARG, MYSQL_MANAGER_PORT, 0, 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},
{"quiet", 'q', "Suppress all normal output.", (gptr*) &quiet, (gptr*) &quiet,
0, GET_BOOL, 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 die(const char* fmt, ...)
......@@ -84,65 +92,53 @@ void usage()
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
printf("Command-line client for MySQL manager daemon.\n\n");
printf("Usage: %s [OPTIONS] < command_file\n", my_progname);
printf("\n\
-?, --help Display this help and exit.\n");
printf("\
-h, --host=... Connect to host.\n\
-u, --user=... User for login.\n\
-p[password], --password[=...]\n\
Password to use when connecting to server.\n\
-P, --port=... Port number to use for connection.\n\
-q, --quiet, --silent Suppress all normal output.\n\
-V, --version Output version information and exit.\n\
--no-defaults Don't read default options from any options file.\n\n");
my_print_help(my_long_options);
printf(" --no-defaults Don't read default options from any options file.\n\n");
my_print_variables(my_long_options);
}
int parse_args(int argc, char **argv)
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
int c, option_index = 0;
my_bool tty_password=0;
switch (optid) {
case 'p':
if (argument)
{
my_free(pass, MYF(MY_ALLOW_ZERO_PTR));
pass= my_strdup(argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
}
else
tty_password=1;
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
int parse_args(int argc, char **argv)
{
int ho_error;
load_defaults("my",load_default_groups,&argc,&argv);
default_argv= argv;
while ((c = getopt_long(argc, argv, "h:p::u:P:?Vq",
long_options, &option_index)) != EOF)
{
switch (c)
{
case 'h':
host=optarg;
break;
case 'u':
user=optarg;
break;
case 'p':
if (optarg)
{
my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
pass=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */
}
else
tty_password=1;
break;
case 'P':
port=atoi(optarg);
break;
case 'q':
quiet=1;
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
default:
usage();
exit(1);
}
}
return 0;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
}
return 0;
}
int main(int argc, char** argv)
{
......
This diff is collapsed.
......@@ -28,9 +28,9 @@ int main(int argc __attribute__((unused)), char **argv __attribute__((unused)))
#include <my_sys.h>
#include <my_pthread.h>
#include "mysql.h"
#include <getopt.h>
#include <my_getopt.h>
static my_bool version,verbose;
static my_bool version, verbose, tty_password= 0;
static uint thread_count,number_of_tests=1000,number_of_threads=2;
static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count;
......@@ -84,23 +84,39 @@ unsigned __stdcall test_thread(void *arg)
}
static struct option long_options[] =
static struct my_option my_long_options[] =
{
{"help", no_argument, 0, '?'},
{"database", required_argument, 0, 'D'},
{"host", required_argument, 0, 'h'},
{"password", optional_argument, 0, 'p'},
{"user", required_argument, 0, 'u'},
{"version", no_argument, 0, 'V'},
{"verbose", no_argument, 0, 'v'},
{"query", required_argument, 0, 'Q'},
{"port", required_argument, 0, 'P'},
{"socket", required_argument, 0, 'S'},
{"test-count",required_argument, 0, 'c'},
{"thread-count",required_argument, 0, 't'},
{0, 0, 0, 0}
{"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
0, 0, 0, 0, 0},
{"database", 'D', "Database to use", (gptr*) &database, (gptr*) &database,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host", (gptr*) &host, (gptr*) &host, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"user", 'u', "User for login if not current user", (gptr*) &user,
(gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_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},
{"verbose", 'v', "Write some progress indicators", (gptr*) &verbose,
(gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"query", 'Q', "Query to execute in each threads", (gptr*) &query,
(gptr*) &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection", (gptr*) &tcp_port,
(gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection", (gptr*) &unix_socket,
(gptr*) &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"test-count", 'c', "Run test count times (default %d)",
(gptr*) &number_of_tests, (gptr*) &number_of_tests, 0, GET_UINT,
REQUIRED_ARG, 1000, 0, 0, 0, 0, 0},
{"thread-count", 't', "Number of threads to start",
(gptr*) &number_of_threads, (gptr*) &number_of_threads, 0, GET_UINT,
REQUIRED_ARG, 2, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static const char *load_default_groups[]= { "client",0 };
static void usage()
......@@ -110,103 +126,59 @@ static void usage()
return;
puts("This software comes with ABSOLUTELY NO WARRANTY.\n");
printf("Usage: %s [OPTIONS] [database]\n", my_progname);
printf("\n\
-?, --help Display this help and exit\n\
-c #, --test-count=# Run test count times (default %d)\n",number_of_tests);
printf("\
-D, --database=.. Database to use\n\
-h, --host=... Connect to host\n\
-p[password], --password[=...]\n\
Password to use when connecting to server\n\
If password is not given it's asked from the tty.\n");
printf("\n\
-P --port=... Port number to use for connection\n\
-Q, --query=... Query to execute in each threads\n\
-S --socket=... Socket file to use for connection\n");
printf("\
-t --thread-count=# Number of threads to start (default: %d) \n\
-u, --user=# User for login if not current user\n\
-v, --verbose Write some progress indicators\n\
-V, --version Output version information and exit\n",
number_of_threads);
my_print_help(my_long_options);
print_defaults("my",load_default_groups);
my_print_variables(my_long_options);
printf("\nExample usage:\n\n\
%s -Q 'select * from mysql.user' -c %d -t %d\n",
my_progname, number_of_tests, number_of_threads);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case 'p':
if (argument)
{
my_free(password, MYF(MY_ALLOW_ZERO_PTR));
password= my_strdup(argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
}
else
tty_password= 1;
break;
case 'V':
version= 1;
usage();
exit(0);
break;
case '?':
case 'I': /* Info */
usage();
exit(1);
break;
}
return 0;
}
static void get_options(int argc, char **argv)
{
int c,option_index=0,error=0;
bool tty_password=0;
int ho_error;
load_defaults("my",load_default_groups,&argc,&argv);
while ((c=getopt_long(argc,argv, "c:D:h:p::VQ:P:S:t:?I",
long_options, &option_index)) != EOF)
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{
switch (c) {
case 'c':
number_of_tests=atoi(optarg);
break;
case 'D':
my_free(database,MYF(MY_ALLOW_ZERO_PTR));
database=my_strdup(optarg,MYF(MY_WME));
break;
case 'h':
host = optarg;
break;
case 'Q': /* Allow old 'q' option */
query= optarg;
break;
case 'p':
if (optarg)
{
my_free(password,MYF(MY_ALLOW_ZERO_PTR));
password=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */
}
else
tty_password=1;
break;
case 'u':
my_free(user,MYF(MY_ALLOW_ZERO_PTR));
user= my_strdup(optarg,MYF(0));
break;
case 'P':
tcp_port= (unsigned int) atoi(optarg);
break;
case 'S':
my_free(unix_socket,MYF(MY_ALLOW_ZERO_PTR));
unix_socket= my_strdup(optarg,MYF(0));
break;
case 't':
number_of_threads=atoi(optarg);
break;
case 'v':
verbose=1;
break;
case 'V':
version=1;
usage();
exit(0);
break;
default:
fprintf(stderr,"Illegal option character '%c'\n",opterr);
/* Fall through */
case '?':
case 'I': /* Info */
error++;
break;
}
}
if (error || argc != optind)
{
usage();
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
}
free_defaults(argv);
if (tty_password)
password=get_tty_password(NullS);
......
This diff is collapsed.
......@@ -593,6 +593,9 @@ static void init_variables(const struct my_option *options)
else if (options->var_type == GET_UINT)
*((uint*) options->u_max_value)= *((uint*) options->value)=
(uint) options->def_value;
else if (options->var_type == GET_BOOL)
*((my_bool*) options->u_max_value)= *((my_bool*) options->value)=
(my_bool) options->def_value;
else if (options->var_type == GET_LONG)
*((long*) options->u_max_value)= *((long*) options->value)=
(long) options->def_value;
......@@ -653,7 +656,7 @@ void my_print_help(const struct my_option *options)
optp->arg_type == OPT_ARG ? "]" : "");
col+= (optp->arg_type == OPT_ARG) ? 5 : 3;
}
if (col > name_space)
if (col > name_space && optp->comment && *optp->comment)
{
putchar('\n');
col= 0;
......@@ -697,7 +700,7 @@ void my_print_variables(const struct my_option *options)
printf("--------------------------------- -------------\n");
for (optp= options; optp->id; optp++)
{
if (optp->value && optp->var_type != GET_BOOL)
if (optp->value)
{
printf("%s", optp->name);
length= strlen(optp->name);
......@@ -710,6 +713,13 @@ void my_print_variables(const struct my_option *options)
else
printf("(No default value)\n");
}
else if (optp->var_type == GET_BOOL)
{
if (!optp->def_value && !*((my_bool*) optp->value))
printf("(No default value)\n");
else
printf("%d\n", *((my_bool*) optp->value));
}
else if (optp->var_type == GET_INT)
{
if (!optp->def_value && !*((int*) optp->value))
......
......@@ -617,7 +617,7 @@ extern pthread_cond_t COND_refresh,COND_thread_count;
extern pthread_attr_t connection_attrib;
extern bool opt_endinfo, using_udf_functions, locked_in_memory,
opt_using_transactions, use_temp_pool, mysql_embedded;
extern bool opt_local_infile;
extern my_bool opt_local_infile;
extern char f_fyllchar;
extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count,
ha_read_key_count, ha_read_next_count, ha_read_prev_count,
......
......@@ -334,7 +334,7 @@ ulong bytes_sent = 0L, bytes_received = 0L;
bool opt_endinfo,using_udf_functions,low_priority_updates, locked_in_memory;
bool opt_using_transactions, using_update_log, opt_warnings=0;
bool opt_local_infile=1;
my_bool opt_local_infile=1;
bool volatile abort_loop,select_thread_in_use,grant_option;
bool volatile ready_to_exit,shutdown_in_progress;
ulong refresh_version=1L,flush_version=1L; /* Increments on each reload */
......@@ -2974,7 +2974,7 @@ static struct my_option my_long_options[] =
{"local-infile", OPT_LOCAL_INFILE,
"Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0)",
(gptr*) &opt_local_infile, (gptr*) &opt_local_infile, 0, GET_BOOL, OPT_ARG,
0, 0, 0, 0, 0, 0},
1, 0, 0, 0, 0, 0},
{"log-bin", OPT_BIN_LOG,
"Log queries in new binary format (for replication)",
(gptr*) &opt_bin_logname, (gptr*) &opt_bin_logname, 0, GET_STR_ALLOC,
......@@ -3987,9 +3987,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'o':
protocol_version=PROTOCOL_VERSION-1;
break;
case OPT_LOCAL_INFILE:
opt_local_infile= test(!argument || atoi(argument) != 0);
break;
case OPT_SLAVE_SKIP_ERRORS:
init_slave_skip_errors(argument);
break;
......
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