Commit a5d1744a authored by unknown's avatar unknown

Merge work:/home/bk/mysql-4.0

into rhols221.arenanet.fi:/home/my/bk/mysql-4.0


BitKeeper/etc/logging_ok:
  auto-union
parents 50a32945 072e605c
...@@ -13,9 +13,11 @@ davida@isil.mysql.com ...@@ -13,9 +13,11 @@ davida@isil.mysql.com
heikki@donna.mysql.fi heikki@donna.mysql.fi
heikki@hundin.mysql.fi heikki@hundin.mysql.fi
jani@dsl-jkl1657.dial.inet.fi jani@dsl-jkl1657.dial.inet.fi
jani@hynda.(none)
jani@hynda.mysql.fi jani@hynda.mysql.fi
jani@janikt.pp.saunalahti.fi jani@janikt.pp.saunalahti.fi
jani@rhols221.adsl.netsonic.fi jani@rhols221.adsl.netsonic.fi
jani@rhols221.arenanet.fi
jcole@abel.spaceapes.com jcole@abel.spaceapes.com
jcole@main.burghcom.com jcole@main.burghcom.com
jcole@mugatu.spaceapes.com jcole@mugatu.spaceapes.com
...@@ -59,7 +61,6 @@ tonu@volk.internalnet ...@@ -59,7 +61,6 @@ tonu@volk.internalnet
tonu@x153.internalnet tonu@x153.internalnet
tonu@x3.internalnet tonu@x3.internalnet
venu@work.mysql.com venu@work.mysql.com
worm@altair.is.lan
zak@balfor.local zak@balfor.local
zak@linux.local zak@linux.local
jani@hynda.(none)
worm@altair.is.lan
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <signal.h> #include <signal.h>
#include <violite.h> #include <violite.h>
const char *VER= "12.6"; const char *VER= "12.7";
/* Don't try to make a nice table if the data is too big */ /* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024 #define MAX_COLUMN_LENGTH 1024
...@@ -467,10 +467,11 @@ static struct my_option my_long_options[] = ...@@ -467,10 +467,11 @@ static struct my_option my_long_options[] =
{"force", 'f', "Continue even if we get an sql error.", {"force", 'f', "Continue even if we get an sql error.",
(gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, (gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
0, 0, 0, 0}, 0, 0, 0, 0},
{"no-named-commands", 'g', "Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option depricated; use --disable-named-commands instead.", {"no-named-commands", 'g',
"Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option depricated; use --disable-named-commands instead.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"named-commands", 'G', {"named-commands", 'G',
"Enable named commands. Disable with --disable-named-commands. This option is disabled by default.", "Enable named commands. Named commands mean this program's internal commands; see mysql> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default.",
(gptr*) &named_cmds, (gptr*) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (gptr*) &named_cmds, (gptr*) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"ignore-space", 'i', "Ignore space after function names.", 0, 0, 0, {"ignore-space", 'i', "Ignore space after function names.", 0, 0, 0,
......
...@@ -14,22 +14,46 @@ ...@@ -14,22 +14,46 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Written by Sergei A. Golubchik, who has a shared copyright to this code */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code
added support for long options (my_getopt) 22.5.2002 by Jani Tolonen */
#include "ftdefs.h" #include "ftdefs.h"
#include <getopt.h> #include <my_getopt.h>
static void get_options(int argc,char *argv[]); static void get_options(int argc,char *argv[]);
static void usage(char *argv[]); static void usage();
static void complain(int val); static void complain(int val);
static int count=0, stats=0, dump=0, verbose=0, lstats=0; static int count=0, stats=0, dump=0, lstats=0;
static my_bool verbose;
static char *query=NULL; static char *query=NULL;
static uint lengths[256]; static uint lengths[256];
#define MAX_LEN (HA_FT_MAXLEN+10) #define MAX_LEN (HA_FT_MAXLEN+10)
#define HOW_OFTEN_TO_WRITE 10000 #define HOW_OFTEN_TO_WRITE 10000
static struct my_option my_long_options[] =
{
{"dump", 'd', "Dump index (incl. data offsets and word weights)",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"stats", 's', "Report global stats",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Be verbose",
(gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"count", 'c', "Calculate per-word stats (counts and global weights)",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"length", 'l', "Report length distribution",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"execute", 'e', "Execute given query", (gptr*) &query, (gptr*) &query, 0,
GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"help", 'h', "Display help and exit",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Synonym for -h",
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}
};
int main(int argc,char *argv[]) int main(int argc,char *argv[])
{ {
int error=0; int error=0;
...@@ -52,7 +76,7 @@ int main(int argc,char *argv[]) ...@@ -52,7 +76,7 @@ int main(int argc,char *argv[])
setbuf(stdout,NULL); setbuf(stdout,NULL);
if (argc-optind < 2) if (argc-optind < 2)
usage(argv); usage();
if (!(info=mi_open(argv[optind],2,HA_OPEN_ABORT_IF_LOCKED))) if (!(info=mi_open(argv[optind],2,HA_OPEN_ABORT_IF_LOCKED)))
goto err; goto err;
...@@ -184,45 +208,60 @@ int main(int argc,char *argv[]) ...@@ -184,45 +208,60 @@ int main(int argc,char *argv[])
return 0; return 0;
} }
const char *options="dslcvh";
static void get_options(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; switch(optid) {
case 'd':
while ((c=getopt(argc,argv,options)) != -1) dump=1;
{ complain(count || query);
switch(c) { break;
case 'd': dump=1; complain(count || query); break; case 's':
case 's': stats=1; complain(query!=0); break; stats=1;
case 'v': verbose=1; break; complain(query!=0);
case 'c': count=1; complain(dump || query); break; break;
case 'l': lstats=1; complain(query!=0); break; case 'c':
case 'e': query=my_strdup(optarg,MYF(MY_FAE)); complain(dump || count || stats); break; count= 1;
complain(dump || query);
break;
case 'l':
lstats=1;
complain(query!=0);
break;
case 'e':
complain(dump || count || stats);
break;
case '?': case '?':
case 'h': case 'h':
default: usage();
usage(argv);
} }
return 0;
}
static void get_options(int argc, char *argv[])
{
int ho_error;
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;
} /* get options */ } /* get options */
static void usage(char *argv[])
static void usage()
{ {
printf("\n\ printf("Use: ft_dump <table_name> <index_no>\n");
Use: %s [-%s] <table_name> <index_no>\n\ my_print_help(my_long_options);
\n\ my_print_variables(my_long_options);
-d Dump index (incl. data offsets and word weights)\n\
-s Report global stats\n\
-c Calculate per-word stats (counts and global weights)\n\
-l Report length distribution\n\
-v Be verbose\n\
-h This text\n\
", *argv, options);
exit(1); exit(1);
} }
static void complain(int val) /* Kinda assert :-) */ static void complain(int val) /* Kinda assert :-) */
{ {
if (val) if (val)
......
...@@ -11,18 +11,32 @@ ...@@ -11,18 +11,32 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Written by Sergei A. Golubchik, who has a shared copyright to this code */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code
added support for long options (my_getopt) 22.5.2002 by Jani Tolonen */
#include "ftdefs.h" #include "ftdefs.h"
#include "ft_eval.h" #include "ft_eval.h"
#include <stdarg.h> #include <stdarg.h>
#include <getopt.h> #include <my_getopt.h>
static void print_error(int exit_code, const char *fmt,...); static void print_error(int exit_code, const char *fmt,...);
static void get_options(int argc, char *argv[]); static void get_options(int argc, char *argv[]);
static int create_record(char *pos, FILE *file); static int create_record(char *pos, FILE *file);
static void usage();
int main(int argc,char *argv[]) static struct my_option my_long_options[] =
{
{"", 's', "", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"", 'q', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'S', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", '#', "", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"", 'V', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", '?', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'h', "", 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}
};
int main(int argc, char *argv[])
{ {
MI_INFO *file; MI_INFO *file;
int i,j; int i,j;
...@@ -81,7 +95,9 @@ int main(int argc,char *argv[]) ...@@ -81,7 +95,9 @@ int main(int argc,char *argv[])
if (!silent) if (!silent)
printf("- Reading rows with key\n"); printf("- Reading rows with key\n");
for(i=1;create_record(record,qf);i++) { for(i=1;create_record(record,qf);i++) {
FT_DOCLIST *result; double w; int t,err; FT_DOCLIST *result;
double w;
int t, err;
result=ft_nlq_init_search(file,0,blob_record,(uint) strlen(blob_record),1); result=ft_nlq_init_search(file,0,blob_record,(uint) strlen(blob_record),1);
if(!result) { if(!result) {
...@@ -106,20 +122,19 @@ int main(int argc,char *argv[]) ...@@ -106,20 +122,19 @@ int main(int argc,char *argv[])
my_end(MY_CHECK_ERROR); my_end(MY_CHECK_ERROR);
return (0); return (0);
err:
err:
printf("got error: %3d when using myisam-database\n",my_errno); printf("got error: %3d when using myisam-database\n",my_errno);
return 1; /* skipp warning */ return 1; /* skip warning */
} }
static void get_options(int argc,char *argv[])
{
int c;
char *options=(char*) "Vh#:qSs:";
while ((c=getopt(argc,argv,options)) != -1) static my_bool
{ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
switch(c) { char *argument)
{
switch(optid) {
case 's': case 's':
if(stopwordlist && stopwordlist!=ft_precompiled_stopwords) break; if(stopwordlist && stopwordlist!=ft_precompiled_stopwords) break;
{ {
...@@ -127,11 +142,11 @@ static void get_options(int argc,char *argv[]) ...@@ -127,11 +142,11 @@ static void get_options(int argc,char *argv[])
if(!(stopwordlist=(const char**) malloc(n*sizeof(char *)))) if(!(stopwordlist=(const char**) malloc(n*sizeof(char *))))
print_error(1,"malloc(%d)",n*sizeof(char *)); print_error(1,"malloc(%d)",n*sizeof(char *));
if(!(f=fopen(optarg,"r"))) if(!(f=fopen(argument,"r")))
print_error(1,"fopen(%s)",optarg); print_error(1,"fopen(%s)",argument);
while(!feof(f)) { while(!feof(f)) {
if(!(fgets(s,HA_FT_MAXLEN,f))) if(!(fgets(s,HA_FT_MAXLEN,f)))
print_error(1,"fgets(s,%d,%s)",HA_FT_MAXLEN,optarg); print_error(1,"fgets(s,%d,%s)",HA_FT_MAXLEN,argument);
if(!(stopwordlist[i++]=strdup(s))) if(!(stopwordlist[i++]=strdup(s)))
print_error(1,"strdup(%s)",s); print_error(1,"strdup(%s)",s);
if(i>=n) { if(i>=n) {
...@@ -148,15 +163,26 @@ static void get_options(int argc,char *argv[]) ...@@ -148,15 +163,26 @@ static void get_options(int argc,char *argv[])
case 'S': if(stopwordlist==ft_precompiled_stopwords) stopwordlist=NULL; break; case 'S': if(stopwordlist==ft_precompiled_stopwords) stopwordlist=NULL; break;
case '#': case '#':
DEBUGGER_ON; DEBUGGER_ON;
DBUG_PUSH (optarg); DBUG_PUSH (argument);
break; break;
case 'V': case 'V':
case '?': case '?':
case 'h': case 'h':
default: usage();
printf("%s -[%s] <d_file> <q_file>\n", argv[0], options); exit(1);
exit(0);
} }
return 0;
}
static void get_options(int argc, char *argv[])
{
int ho_error;
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);
} }
if(!(d_file=argv[optind])) print_error(1,"No d_file"); if(!(d_file=argv[optind])) print_error(1,"No d_file");
if(!(df=fopen(d_file,"r"))) if(!(df=fopen(d_file,"r")))
...@@ -206,3 +232,11 @@ static void print_error(int exit_code, const char *fmt,...) ...@@ -206,3 +232,11 @@ static void print_error(int exit_code, const char *fmt,...)
va_end(args); va_end(args);
exit(exit_code); exit(exit_code);
} }
static void usage()
{
printf("%s [options]\n", my_progname);
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
...@@ -14,11 +14,12 @@ ...@@ -14,11 +14,12 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Written by Sergei A. Golubchik, who has a shared copyright to this code */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code
added support for long options (my_getopt) 22.5.2002 by Jani Tolonen */
#include "ftdefs.h" #include "ftdefs.h"
#include "ft_test1.h" #include "ft_test1.h"
#include <getopt.h> #include <my_getopt.h>
static int key_field=FIELD_VARCHAR,extra_field=FIELD_SKIP_ENDSPACE; static int key_field=FIELD_VARCHAR,extra_field=FIELD_SKIP_ENDSPACE;
static uint key_length=200,extra_length=50; static uint key_length=200,extra_length=50;
...@@ -33,8 +34,26 @@ static char record[MAX_REC_LENGTH],read_record[MAX_REC_LENGTH]; ...@@ -33,8 +34,26 @@ static char record[MAX_REC_LENGTH],read_record[MAX_REC_LENGTH];
static int run_test(const char *filename); static int run_test(const char *filename);
static void get_options(int argc, char *argv[]); static void get_options(int argc, char *argv[]);
static void create_record(char *, int); static void create_record(char *, int);
static void usage();
int main(int argc,char *argv[]) static struct my_option my_long_options[] =
{
{"", 'v', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", '?', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'h', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'V', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'v', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 's', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'N', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'S', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'K', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'F', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'U', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", '#', "", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
int main(int argc, char *argv[])
{ {
MY_INIT(argv[0]); MY_INIT(argv[0]);
...@@ -173,7 +192,7 @@ static int run_test(const char *filename) ...@@ -173,7 +192,7 @@ static int run_test(const char *filename)
return (0); return (0);
err: err:
printf("got error: %3d when using myisam-database\n",my_errno); printf("got error: %3d when using myisam-database\n",my_errno);
return 1; /* skipp warning */ return 1; /* skip warning */
} }
static char blob_key[MAX_REC_LENGTH]; static char blob_key[MAX_REC_LENGTH];
...@@ -232,16 +251,12 @@ void create_record(char *pos, int n) ...@@ -232,16 +251,12 @@ void create_record(char *pos, int n)
} }
} }
/* Read options */
static void get_options(int argc,char *argv[]) static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{ {
int c; switch(optid) {
const char *options="hVvsNSKFU#:";
while ((c=getopt(argc,argv,options)) != -1)
{
switch(c) {
case 'v': verbose=1; break; case 'v': verbose=1; break;
case 's': silent=1; break; case 's': silent=1; break;
case 'F': no_fulltext=1; no_search=1; case 'F': no_fulltext=1; no_search=1;
...@@ -251,15 +266,36 @@ static void get_options(int argc,char *argv[]) ...@@ -251,15 +266,36 @@ static void get_options(int argc,char *argv[])
case 'S': no_stopwords=1; break; case 'S': no_stopwords=1; break;
case '#': case '#':
DEBUGGER_ON; DEBUGGER_ON;
DBUG_PUSH (optarg); DBUG_PUSH (argument);
break; break;
case 'V': case 'V':
case '?': case '?':
case 'h': case 'h':
default: usage();
printf("%s -[%s]\n", argv[0], options); exit(1);
exit(0);
} }
return 0;
}
/* Read options */
static void get_options(int argc,char *argv[])
{
int ho_error;
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; return;
} /* get options */ } /* get options */
static void usage()
{
printf("%s [options]\n", my_progname);
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "ftdefs.h" #include "ftdefs.h"
#include <m_ctype.h> #include <m_ctype.h>
#include <stdarg.h> #include <stdarg.h>
#include <getopt.h> #include <my_getopt.h>
#include <assert.h> #include <assert.h>
#ifdef HAVE_SYS_VADVISE_H #ifdef HAVE_SYS_VADVISE_H
#include <sys/vadvise.h> #include <sys/vadvise.h>
......
...@@ -17,20 +17,23 @@ ...@@ -17,20 +17,23 @@
/* Testing of the basic functions of a MyISAM table */ /* Testing of the basic functions of a MyISAM table */
#include "myisam.h" #include "myisam.h"
#include <getopt.h> #include <my_getopt.h>
#include <m_string.h> #include <m_string.h>
#define MAX_REC_LENGTH 1024 #define MAX_REC_LENGTH 1024
static int rec_pointer_size=0,verbose=0,flags[50]; static void usage();
static int rec_pointer_size=0, flags[50];
static int key_field=FIELD_SKIP_PRESPACE,extra_field=FIELD_SKIP_ENDSPACE; static int key_field=FIELD_SKIP_PRESPACE,extra_field=FIELD_SKIP_ENDSPACE;
static int key_type=HA_KEYTYPE_NUM; static int key_type=HA_KEYTYPE_NUM;
static int create_flag=0; static int create_flag=0;
static uint insert_count= 1000,update_count=1000,remove_count=1000; static uint insert_count, update_count, remove_count;
static uint pack_keys=0,pack_seg=0,null_fields=0,key_length=6,skip_update=0; static uint pack_keys=0, pack_seg=0, key_length;
static uint unique_key=HA_NOSAME,key_cacheing=0,opt_unique=0; static uint unique_key=HA_NOSAME;
static uint silent; static my_bool key_cacheing, null_fields, silent, skip_update, opt_unique,
verbose;
static MI_COLUMNDEF recinfo[4]; static MI_COLUMNDEF recinfo[4];
static MI_KEYDEF keyinfo[10]; static MI_KEYDEF keyinfo[10];
static MI_KEYSEG keyseg[10]; static MI_KEYSEG keyseg[10];
...@@ -501,58 +504,73 @@ static void update_record(char *record) ...@@ -501,58 +504,73 @@ static void update_record(char *record)
} }
static struct option long_options[] = static struct my_option my_long_options[] =
{ {
{"checksum", no_argument, 0, 'c'}, {"checksum", 'c', "Undocumented",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifndef DBUG_OFF #ifndef DBUG_OFF
{"debug", required_argument, 0, '#'}, {"debug", '#', "Undocumented",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"delete_rows", required_argument, 0, 'd'}, {"delete_rows", 'd', "Undocumented", (gptr*) &remove_count,
{"help", no_argument, 0, '?'}, (gptr*) &remove_count, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0},
{"insert_rows", required_argument, 0, 'i'}, {"help", '?', "Display help and exit",
{"key_alpha", no_argument, 0, 'a'}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"key_binary_pack", no_argument, 0, 'B'}, {"insert_rows", 'i', "Undocumented", (gptr*) &insert_count,
{"key_blob", required_argument, 0, 'b'}, (gptr*) &insert_count, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0},
{"key_cache", no_argument, 0, 'K'}, {"key_alpha", 'a', "Undocumented",
{"key_length", required_argument, 0, 'k'}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"key_multiple", no_argument, 0, 'm'}, {"key_binary_pack", 'B', "Undocumented",
{"key_prefix_pack", no_argument, 0, 'P'}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"key_space_pack", no_argument, 0, 'p'}, {"key_blob", 'b', "Undocumented",
{"key_varchar", no_argument, 0, 'w'}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"null_fields", no_argument, 0, 'N'}, {"key_cache", 'K', "Undocumented", (gptr*) &key_cacheing,
{"row_fixed_size", no_argument, 0, 'S'}, (gptr*) &key_cacheing, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"row_pointer_size", required_argument, 0, 'R'}, {"key_length", 'k', "Undocumented", (gptr*) &key_length, (gptr*) &key_length,
{"silent", no_argument, 0, 's'}, 0, GET_UINT, REQUIRED_ARG, 6, 0, 0, 0, 0, 0},
{"skip_update", no_argument, 0, 'U'}, {"key_multiple", 'm', "Undocumented",
{"unique", no_argument, 0, 'C'}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"update_rows", required_argument, 0, 'u'}, {"key_prefix_pack", 'P', "Undocumented",
{"verbose", no_argument, 0, 'v'}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", no_argument, 0, 'V'}, {"key_space_pack", 'p', "Undocumented",
{0, 0, 0, 0} 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"key_varchar", 'w', "Undocumented",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"null_fields", 'N', "Undocumented",
(gptr*) &null_fields, (gptr*) &null_fields, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
{"row_fixed_size", 'S', "Undocumented",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"row_pointer_size", 'R', "Undocumented", (gptr*) &rec_pointer_size,
(gptr*) &rec_pointer_size, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's', "Undocumented",
(gptr*) &silent, (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip_update", 'U', "Undocumented", (gptr*) &skip_update,
(gptr*) &skip_update, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"unique", 'C', "Undocumented", (gptr*) &opt_unique, (gptr*) &opt_unique, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"update_rows", 'u', "Undocumented", (gptr*) &update_count,
(gptr*) &update_count, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0},
{"verbose", 'v', "Be more verbose", (gptr*) &verbose, (gptr*) &verbose, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Print version number 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}
}; };
/* Read options */ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
static void get_options(int argc,char *argv[]) char *argument)
{ {
int c,option_index=0; switch(optid) {
while ((c=getopt_long(argc,argv,"abBcCd:i:k:KmPR:SspNu:UvVw#:",
long_options, &option_index)) != EOF)
{
switch(c) {
case 'a': case 'a':
key_type= HA_KEYTYPE_TEXT; key_type= HA_KEYTYPE_TEXT;
break; break;
case 'c': case 'c':
create_flag|= HA_CREATE_CHECKSUM; create_flag|= HA_CREATE_CHECKSUM;
break; break;
case 'C':
opt_unique=1;
break;
case 'R': /* Length of record pointer */ case 'R': /* Length of record pointer */
rec_pointer_size=atoi(optarg);
if (rec_pointer_size > 3) if (rec_pointer_size > 3)
rec_pointer_size=0; rec_pointer_size=0;
break; break;
...@@ -578,24 +596,6 @@ static void get_options(int argc,char *argv[]) ...@@ -578,24 +596,6 @@ static void get_options(int argc,char *argv[])
pack_seg=HA_SPACE_PACK; pack_seg=HA_SPACE_PACK;
key_type=HA_KEYTYPE_TEXT; key_type=HA_KEYTYPE_TEXT;
break; break;
case 'N':
null_fields=1; /* First key part may be null */
break;
case 'v': /* verbose */
verbose=1;
break;
case 'd':
remove_count=atoi(optarg);
break;
case 'i':
insert_count=atoi(optarg);
break;
case 'u':
update_count=atoi(optarg);
break;
case 'U':
skip_update=1;
break;
case 'm': case 'm':
unique_key=0; unique_key=0;
break; break;
...@@ -606,16 +606,12 @@ static void get_options(int argc,char *argv[]) ...@@ -606,16 +606,12 @@ static void get_options(int argc,char *argv[])
key_type= HA_KEYTYPE_VARTEXT; key_type= HA_KEYTYPE_VARTEXT;
break; break;
case 'k': case 'k':
key_length=atoi(optarg);
if (key_length < 4 || key_length > MI_MAX_KEY_LENGTH) if (key_length < 4 || key_length > MI_MAX_KEY_LENGTH)
{ {
fprintf(stderr,"Wrong key length\n"); fprintf(stderr,"Wrong key length\n");
exit(1); exit(1);
} }
break; break;
case 's':
silent=1;
break;
case 'w': case 'w':
key_field=FIELD_VARCHAR; /* varchar keys */ key_field=FIELD_VARCHAR; /* varchar keys */
extra_field= FIELD_VARCHAR; extra_field= FIELD_VARCHAR;
...@@ -627,13 +623,39 @@ static void get_options(int argc,char *argv[]) ...@@ -627,13 +623,39 @@ static void get_options(int argc,char *argv[])
key_cacheing=1; key_cacheing=1;
break; break;
case 'V': case 'V':
printf("test1 Ver 1.0 \n"); printf("test1 Ver 1.1 \n");
exit(0); exit(0);
case '#': case '#':
DEBUGGER_ON; DEBUGGER_ON;
DBUG_PUSH (optarg); DBUG_PUSH (argument);
break; break;
case '?':
usage();
exit(1);
} }
return 0;
}
/* Read options */
static void get_options(int argc, char *argv[])
{
int ho_error;
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; return;
} /* get options */ } /* get options */
static void usage()
{
printf("Usage: %s [options]\n\n", my_progname);
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#ifndef __GNU_LIBRARY__ #ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ /* Skip warnings in getopt.h */ #define __GNU_LIBRARY__ /* Skip warnings in getopt.h */
#endif #endif
#include <getopt.h> #include <my_getopt.h>
#if INT_MAX > 32767 #if INT_MAX > 32767
#define BITS_SAVED 32 #define BITS_SAVED 32
...@@ -169,9 +169,10 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf); ...@@ -169,9 +169,10 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf);
static void mrg_reset(PACK_MRG_INFO *mrg); static void mrg_reset(PACK_MRG_INFO *mrg);
static int backup=0,error_on_write=0,test_only=0,verbose=0,silent=0, static int error_on_write=0,test_only=0,verbose=0,silent=0,
write_loop=0,force_pack=0,opt_wait=0,isamchk_neaded=0; write_loop=0,force_pack=0, isamchk_neaded=0;
static int tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL; static int tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL;
static my_bool backup, opt_wait;
static uint tree_buff_length=8196-MALLOC_OVERHEAD; static uint tree_buff_length=8196-MALLOC_OVERHEAD;
static char tmp_dir[FN_REFLEN]={0},*join_table; static char tmp_dir[FN_REFLEN]={0},*join_table;
static my_off_t intervall_length; static my_off_t intervall_length;
...@@ -232,26 +233,43 @@ int main(int argc, char **argv) ...@@ -232,26 +233,43 @@ int main(int argc, char **argv)
enum options_mp {OPT_CHARSETS_DIR_MP=256}; enum options_mp {OPT_CHARSETS_DIR_MP=256};
static struct option long_options[] = static struct my_option my_long_options[] =
{ {
{"backup", no_argument, 0, 'b'}, {"backup", 'b', "Make a backup of the table as table_name.OLD",
{"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR_MP}, (gptr*) &backup, (gptr*) &backup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug", optional_argument, 0, '#'}, {"character-sets-dir", OPT_CHARSETS_DIR_MP,
{"force", no_argument, 0, 'f'}, "Directory where character sets are.", (gptr*) &charsets_dir,
{"join", required_argument, 0, 'j'}, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"help", no_argument, 0, '?'}, {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'",
{"silent", no_argument, 0, 's'}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"tmpdir", required_argument, 0, 'T'}, {"force", 'f',
{"test", no_argument, 0, 't'}, "Force packing of table even if it gets bigger or if tempfile exists.",
{"verbose", no_argument, 0, 'v'}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", no_argument, 0, 'V'}, {"join", 'j',
{"wait", no_argument, 0, 'w'}, "Join all given tables into 'new_table_name'. All tables MUST have identical layouts.",
{0, 0, 0, 0} (gptr*) &join_table, (gptr*) &join_table, 0, GET_STR, 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},
{"silent", 's', "Be more silent.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"tmpdir", 'T', "Use temporary directory to store temporary table.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"test", 't', "Don't pack table, only test packing it.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Write info about progress and packing result.",
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},
{"wait", 'w', "Wait and retry if table is in use.", (gptr*) &opt_wait,
(gptr*) &opt_wait, 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 print_version(void) static void print_version(void)
{ {
printf("%s Ver 1.13 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE); printf("%s Ver 1.20 for %s on %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
} }
static void usage(void) static void usage(void)
...@@ -267,58 +285,32 @@ static void usage(void) ...@@ -267,58 +285,32 @@ static void usage(void)
puts("You should give the .MSI file as the filename argument."); puts("You should give the .MSI file as the filename argument.");
printf("\nUsage: %s [OPTIONS] filename...\n", my_progname); printf("\nUsage: %s [OPTIONS] filename...\n", my_progname);
puts("\n\ my_print_help(my_long_options);
-b, --backup Make a backup of the table as table_name.OLD\n\ print_defaults("my", load_default_groups);
-f, --force Force packing of table even if it gets bigger or if\n\ my_print_variables(my_long_options);
tempfile exists.\n\
-j, --join='new_table_name'\n\
Join all given tables into 'new_table_name'.\n\
All tables MUST have identical layouts.\n\
-s, --silent Be more silent.\n\
-t, --test Don't pack table, only test packing it.\n\
-v, --verbose Write info about progress and packing result.\n\
-w, --wait Wait and retry if table is in use.\n\
-T, --tmpdir=... Use temporary directory to store temporary table.\n\
-#, --debug=... Output debug log. Often this is 'd:t:o,filename`\n\
-?, --help Display this help and exit.\n\
-V, --version Output version information and exit.");
print_defaults("my",load_default_groups);
} }
/* reads options */
/* Initiates DEBUG - but no debugging here ! */
static void get_options(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;
uint length; uint length;
my_progname= argv[0][0]; switch(optid) {
if (isatty(fileno(stdout)))
write_loop=1;
while ((c=getopt_long(*argc,*argv,"bfj:stvwT:#::?V",long_options,
&option_index)) != EOF)
{
switch(c) {
case 'b':
backup=1;
break;
case 'f': case 'f':
force_pack=1; force_pack= 1;
tmpfile_createflag=O_RDWR | O_TRUNC; tmpfile_createflag= O_RDWR | O_TRUNC;
break;
case 'j':
join_table=optarg;
break; break;
case 's': case 's':
write_loop=verbose=0; silent=1; write_loop= verbose= 0;
silent= 1;
break; break;
case 't': case 't':
test_only=verbose=1; test_only= verbose= 1;
break; break;
case 'T': case 'T':
length=(uint) (strmov(tmp_dir,optarg)-tmp_dir); length= (uint) (strmov(tmp_dir, argument) - tmp_dir);
if (length != dirname_length(tmp_dir)) if (length != dirname_length(tmp_dir))
{ {
tmp_dir[length]=FN_LIBCHAR; tmp_dir[length]=FN_LIBCHAR;
...@@ -326,30 +318,40 @@ static void get_options(int *argc,char ***argv) ...@@ -326,30 +318,40 @@ static void get_options(int *argc,char ***argv)
} }
break; break;
case 'v': case 'v':
verbose=1; silent=0; verbose= 1;
break; silent= 0;
case 'w':
opt_wait=1;
break; break;
case '#': case '#':
DBUG_PUSH(optarg ? optarg : "d:t:o"); DBUG_PUSH(argument ? argument : "d:t:o");
break;
case OPT_CHARSETS_DIR_MP:
charsets_dir = optarg;
break; break;
case 'V': print_version(); exit(0); case 'V':
print_version();
exit(0);
case 'I': case 'I':
case '?': case '?':
usage(); usage();
exit(0); exit(0);
default:
fprintf(stderr,"%s: Illegal option: -%c\n",my_progname,opterr);
usage();
exit(1);
} }
return 0;
}
/* reads options */
/* Initiates DEBUG - but no debugging here ! */
static void get_options(int *argc,char ***argv)
{
int ho_error;
my_progname= argv[0][0];
if (isatty(fileno(stdout)))
write_loop=1;
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;
if (!*argc) if (!*argc)
{ {
usage(); usage();
......
...@@ -650,7 +650,7 @@ void my_print_help(const struct my_option *options) ...@@ -650,7 +650,7 @@ void my_print_help(const struct my_option *options)
{ {
if (optp->id < 256) if (optp->id < 256)
{ {
printf(" -%c, ", optp->id); printf(" -%c%s", optp->id, strlen(optp->name) ? ", " : " ");
col= 6; col= 6;
} }
else else
...@@ -658,6 +658,8 @@ void my_print_help(const struct my_option *options) ...@@ -658,6 +658,8 @@ void my_print_help(const struct my_option *options)
printf(" "); printf(" ");
col= 2; col= 2;
} }
if (strlen(optp->name))
{
printf("--%s", optp->name); printf("--%s", optp->name);
col+= 2 + strlen(optp->name); col+= 2 + strlen(optp->name);
if (optp->var_type == GET_STR || optp->var_type == GET_STR_ALLOC) if (optp->var_type == GET_STR || optp->var_type == GET_STR_ALLOC)
...@@ -682,6 +684,7 @@ void my_print_help(const struct my_option *options) ...@@ -682,6 +684,7 @@ void my_print_help(const struct my_option *options)
putchar('\n'); putchar('\n');
col= 0; col= 0;
} }
}
for (; col < name_space; col++) for (; col < name_space; col++)
putchar(' '); putchar(' ');
if (optp->comment && *optp->comment) if (optp->comment && *optp->comment)
......
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
#ifndef __GNU_LIBRARY__ #ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h #define __GNU_LIBRARY__ // Skip warnings in getopt.h
#endif #endif
#include <getopt.h> #include <my_getopt.h>
#include "mysql_version.h" #include "mysql_version.h"
#include "lex.h" #include "lex.h"
bool opt_search=0; my_bool opt_search;
int opt_verbose=0; int opt_verbose;
ulong opt_count=100000; ulong opt_count;
#define max_allowed_array 8000 // Don't generate bigger arrays than this #define max_allowed_array 8000 // Don't generate bigger arrays than this
#define max_symbol 32767 // Use this for 'not found' #define max_symbol 32767 // Use this for 'not found'
...@@ -55,6 +55,35 @@ static uchar bits[how_much_and/8+1]; ...@@ -55,6 +55,35 @@ static uchar bits[how_much_and/8+1];
static uint primes[max_allowed_array+1]; static uint primes[max_allowed_array+1];
static ulong hash_results[type_count][how_much_for_plus+1][total_symbols]; static ulong hash_results[type_count][how_much_for_plus+1][total_symbols];
static ulong start_value=0; static ulong start_value=0;
static uint best_type;
static ulong best_t1,best_t2, best_start_value;
static struct my_option my_long_options[] =
{
{"help", '?', "Display help and exit",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"count", 'c', "Try count times to find a optimal hash table",
(gptr*) &opt_count, (gptr*) &opt_count, 0, GET_ULONG, REQUIRED_ARG,
100000, 0, 0, 0, 0, 0},
{"search", 'S', "Search after good rnd1 and rnd2 values",
(gptr*) &opt_search, (gptr*) &opt_search, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
{"verbose", 'v', "Write some information while the program executes",
(gptr*) &opt_verbose, (gptr*) &opt_verbose, 0, GET_INT, 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},
{"rnd1", 'r', "Set 1 part of rnd value for hash generator",
(gptr*) &best_t1, (gptr*) &best_t1, 0, GET_ULONG, REQUIRED_ARG, 6657025L,
0, 0, 0, 0, 0},
{"rnd2", 'R', "Set 2 part of rnd value for hash generator",
(gptr*) &best_t2, (gptr*) &best_t2, 0, GET_ULONG, REQUIRED_ARG, 6114496L,
0, 0, 0, 0, 0},
{"type", 't', "Set type of char table to generate",
(gptr*) &best_type, (gptr*) &best_type, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0,
0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
struct rand_struct { struct rand_struct {
unsigned long seed1,seed2,max_value; unsigned long seed1,seed2,max_value;
...@@ -325,82 +354,51 @@ void print_arrays() ...@@ -325,82 +354,51 @@ void print_arrays()
} }
static struct option long_options[] =
{
{"count", required_argument, 0, 'c'},
{"search", no_argument, 0, 'S'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"rnd1", required_argument, 0, 'r'},
{"rnd2", required_argument, 0, 'R'},
{"type", required_argument, 0, 't'},
{0, 0, 0, 0}
};
static void usage(int version) static void usage(int version)
{ {
printf("%s Ver 3.3 Distrib %s, for %s (%s)\n", printf("%s Ver 3.4 Distrib %s, for %s (%s)\n",
my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
if (version) if (version)
return; return;
puts("Copyright (C) 2001 MySQL AB, by Sinisa and Monty"); puts("Copyright (C) 2001 MySQL AB, by Sinisa and Monty");
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("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("This program generates a perfect hashing function for the sql_lex.cc"); puts("This program generates a perfect hashing function for the sql_lex.cc");
printf("Usage: %s [OPTIONS]\n", my_progname); printf("Usage: %s [OPTIONS]\n\n", my_progname);
printf("\n\ my_print_help(my_long_options);
-c, --count=# Try count times to find a optimal hash table\n\ my_print_variables(my_long_options);
-r, --rnd1=# Set 1 part of rnd value for hash generator\n\
-R, --rnd2=# Set 2 part of rnd value for hash generator\n\
-t, --type=# Set type of char table to generate\n\
-S, --search Search after good rnd1 and rnd2 values\n\
-v, --verbose Write some information while the program executes\n\
-V, --version Output version information and exit\n");
} }
static uint best_type;
static ulong best_t1,best_t2, best_start_value;
static int get_options(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) {
while ((c=getopt_long(argc,argv,"?SvVc:r:R:t:",
long_options, &option_index)) != EOF)
{
switch(c) {
case 'c':
opt_count=atol(optarg);
break;
case 'r':
best_t1=atol(optarg);
break;
case 'R':
best_t2=atol(optarg);
break;
case 't':
best_type=atoi(optarg);
break;
case 'S':
opt_search=1;
break;
case 'v': case 'v':
opt_verbose++; opt_verbose++;
break; break;
case 'V': usage(1); exit(0); case 'V':
usage(1);
exit(0);
case 'I': case 'I':
case '?': case '?':
usage(0); usage(0);
exit(0); exit(0);
default:
fprintf(stderr,"illegal option: -%c\n",opterr);
usage(0);
exit(1);
} }
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)))
{
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
} }
argc-=optind;
argv+=optind;
if (argc >= 1) if (argc >= 1)
{ {
usage(0); usage(0);
...@@ -483,7 +481,7 @@ int main(int argc,char **argv) ...@@ -483,7 +481,7 @@ int main(int argc,char **argv)
MY_INIT(argv[0]); MY_INIT(argv[0]);
start_value=1109118L; best_t1=6657025L; best_t2=6114496L; best_type=1; /* mode=4903 add=3 type: 0 */ start_value=1109118L; /* mode=4903 add=3 type: 0 */
if (get_options(argc,(char **) argv)) if (get_options(argc,(char **) argv))
exit(1); exit(1);
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <m_string.h> #include <m_string.h>
#include <m_ctype.h> #include <m_ctype.h>
#include <hash.h> #include <hash.h>
#include <getopt.h> #include <my_getopt.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
#define MANAGER_VERSION "1.0" #define MANAGER_VERSION "1.1"
#define MANAGER_GREETING "MySQL Server Management Daemon v. 1.0" #define MANAGER_GREETING "MySQL Server Management Daemon v. 1.0"
#define LOG_ERR 1 #define LOG_ERR 1
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
#define DO_STACKTRACE 1 #define DO_STACKTRACE 1
#endif #endif
uint manager_port = MANAGER_PORT; uint manager_port;
FILE* errfp; FILE* errfp;
const char* manager_log_file = MANAGER_LOG_FILE; const char* manager_log_file = MANAGER_LOG_FILE;
pthread_mutex_t lock_log,lock_shutdown,lock_exec_hash,lock_launch_thd; pthread_mutex_t lock_log,lock_shutdown,lock_exec_hash,lock_launch_thd;
...@@ -108,14 +108,14 @@ pthread_t loop_th,launch_msg_th; ...@@ -108,14 +108,14 @@ pthread_t loop_th,launch_msg_th;
int manager_sock = -1; int manager_sock = -1;
uchar* stack_bottom=0; uchar* stack_bottom=0;
struct sockaddr_in manager_addr; struct sockaddr_in manager_addr;
ulong manager_bind_addr = INADDR_ANY; ulong manager_bind_addr;
int manager_back_log = MANAGER_BACK_LOG; int manager_back_log;
int in_shutdown = 0, shutdown_requested=0; int in_shutdown = 0, shutdown_requested=0;
int manager_connect_retries=MANAGER_CONNECT_RETRIES; int manager_connect_retries;
const char* manager_greeting = MANAGER_GREETING; const char* manager_greeting = MANAGER_GREETING;
uint manager_max_cmd_len = MANAGER_MAX_CMD_LEN; uint manager_max_cmd_len;
const char* manager_pw_file=MANAGER_PW_FILE; const char* manager_pw_file=MANAGER_PW_FILE;
int one_thread = 0; /* for debugging */ my_bool one_thread; /* for debugging */
typedef enum {PARAM_STDOUT,PARAM_STDERR} PARAM_TYPE; typedef enum {PARAM_STDOUT,PARAM_STDERR} PARAM_TYPE;
...@@ -272,22 +272,44 @@ struct manager_cmd commands[] = ...@@ -272,22 +272,44 @@ struct manager_cmd commands[] =
{0,0,0,0} {0,0,0,0}
}; };
struct option long_options[] =
{ static struct my_option my_long_options[] =
{"debug", optional_argument, 0, '#'}, {
{"help", no_argument, 0, 'h'}, #ifndef DBUG_OFF
{"port", required_argument, 0, 'P'}, {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'",
{"log", required_argument, 0, 'l'}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"bind-address", required_argument, 0, 'b'}, #endif
{"tcp-backlog", required_argument, 0, 'B'}, {"help", '?', "Display this help and exit.",
{"greeting", required_argument, 0, 'g'}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"max-command-len",required_argument,0,'m'}, {"port", 'P', "Port number to listen on.", (gptr*) &manager_port,
{"one-thread",no_argument,0,'d'}, (gptr*) &manager_port, 0, GET_UINT, REQUIRED_ARG, MANAGER_PORT, 0, 0, 0,
{"connect-retries",required_argument,0,'C'}, 0, 0},
{"password-file",required_argument,0,'p'}, {"log", 'l', "Path to log file.", (gptr*) &manager_log_file,
{"pid-file",required_argument,0,'f'}, (gptr*) &manager_log_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"version", no_argument, 0, 'V'}, {"bind-address", 'b', "Address to listen on.", (gptr*) &manager_bind_addr,
{0, 0, 0, 0} (gptr*) &manager_bind_addr, 0, GET_ULONG, REQUIRED_ARG, INADDR_ANY, 0,
0, 0, 0, 0},
{"tcp-backlog", 'B', "Size of TCP/IP listen queue.",
(gptr*) &manager_back_log, (gptr*) &manager_back_log, 0, GET_INT,
REQUIRED_ARG, MANAGER_BACK_LOG, 0, 0, 0, 0, 0},
{"greeting", 'g', "Set greeting on connect", (gptr*) &manager_greeting,
(gptr*) &manager_greeting, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"max-command-len", 'm', "Maximum command length",
(gptr*) &manager_max_cmd_len, (gptr*) &manager_max_cmd_len, 0, GET_UINT,
REQUIRED_ARG, MANAGER_MAX_CMD_LEN, 0, 0, 0, 0, 0},
{"one-thread", 'd', "Use one thread ( for debugging)", (gptr*) &one_thread,
(gptr*) &one_thread, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"connect-retries", 'C', "Number of attempts to establish MySQL connection",
(gptr*) &manager_connect_retries, (gptr*) &manager_connect_retries, 0,
GET_INT, REQUIRED_ARG, MANAGER_CONNECT_RETRIES, 0, 0, 0, 0, 0},
{"password-file", 'p', "Password file for manager",
(gptr*) &manager_pw_file, (gptr*) &manager_pw_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"pid-file", 'f', "Pid file to use", (gptr*) &pid_file, (gptr*) &pid_file,
0, GET_STR, 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},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
static void die(const char* fmt,...); static void die(const char* fmt,...);
...@@ -1280,65 +1302,19 @@ static void usage() ...@@ -1280,65 +1302,19 @@ static void usage()
printf("MySQL AB, by Sasha\n"); printf("MySQL AB, by Sasha\n");
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n"); printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
printf("Manages instances of MySQL server.\n\n"); printf("Manages instances of MySQL server.\n\n");
printf("Usage: %s [OPTIONS]", my_progname); printf("Usage: %s [OPTIONS]\n\n", my_progname);
printf("\n\ my_print_help(my_long_options);
-?, --help Display this help and exit.\n"); my_print_variables(my_long_options);
#ifndef DBUG_OFF
puts("\
-#, --debug=[...] Output debug log. Often this is 'd:t:o,filename`");
#endif
printf("\
-P, --port=... Port number to listen on.\n\
-l, --log=... Path to log file.\n\
-b, --bind-address=... Address to listen on.\n\
-B, --tcp-backlog==... Size of TCP/IP listen queue.\n\
-g, --greeting= Set greeting on connect \n\
-m, --max-command-len Maximum command length \n\
-d, --one-thread Use one thread ( for debugging) \n\
-C, --connect-retries Number of attempts to establish MySQL connection \n\
-m, --max-command-len Maximum command length \n\
-V, --version Output version information and exit.\n\n");
} }
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)
{ {
int c, option_index = 0; switch (optid) {
while ((c=getopt_long(argc,argv,"P:?#:Vl:b:B:g:m:dC:p:f:",
long_options,&option_index)) != EOF)
{
switch (c)
{
case '#': case '#':
DBUG_PUSH(optarg ? optarg : "d:t:O,/tmp/mysqlmgrd.trace"); DBUG_PUSH(argument ? argument : "d:t:O,/tmp/mysqlmgrd.trace");
break;
case 'd':
one_thread=1;
break;
case 'p':
manager_pw_file=optarg;
break;
case 'f':
pid_file=optarg;
break;
case 'C':
manager_connect_retries=atoi(optarg);
break;
case 'P':
manager_port=atoi(optarg);
break;
case 'm':
manager_max_cmd_len=atoi(optarg);
break;
case 'g':
manager_greeting=optarg;
case 'b':
manager_bind_addr = inet_addr(optarg);
break;
case 'B':
manager_back_log = atoi(optarg);
break;
case 'l':
manager_log_file=optarg;
break; break;
case 'V': case 'V':
print_version(); print_version();
...@@ -1346,10 +1322,20 @@ static int parse_args(int argc, char **argv) ...@@ -1346,10 +1322,20 @@ static int parse_args(int argc, char **argv)
case '?': case '?':
usage(); usage();
exit(0); exit(0);
default:
usage();
exit(1);
} }
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)))
{
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
} }
return 0; return 0;
} }
......
...@@ -25,11 +25,11 @@ ...@@ -25,11 +25,11 @@
#ifndef __GNU_LIBRARY__ #ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h #define __GNU_LIBRARY__ // Skip warnings in getopt.h
#endif #endif
#include <getopt.h> #include <my_getopt.h>
#include <signal.h> #include <signal.h>
#include <violite.h> #include <violite.h>
const char *VER="0.1"; const char *VER="0.2";
#ifndef DBUG_OFF #ifndef DBUG_OFF
......
...@@ -25,11 +25,11 @@ ...@@ -25,11 +25,11 @@
#ifndef __GNU_LIBRARY__ #ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h #define __GNU_LIBRARY__ // Skip warnings in getopt.h
#endif #endif
#include <getopt.h> #include <my_getopt.h>
#include <signal.h> #include <signal.h>
#include <violite.h> #include <violite.h>
const char *VER="0.1"; const char *VER="0.2";
#ifndef DBUG_OFF #ifndef DBUG_OFF
......
...@@ -25,11 +25,11 @@ ...@@ -25,11 +25,11 @@
#ifndef __GNU_LIBRARY__ #ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h #define __GNU_LIBRARY__ // Skip warnings in getopt.h
#endif #endif
#include <getopt.h> #include <my_getopt.h>
#include <signal.h> #include <signal.h>
#include <violite.h> #include <violite.h>
const char *VER="0.1"; const char *VER="0.2";
#ifndef DBUG_OFF #ifndef DBUG_OFF
......
...@@ -25,12 +25,12 @@ ...@@ -25,12 +25,12 @@
#ifndef __GNU_LIBRARY__ #ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h #define __GNU_LIBRARY__ // Skip warnings in getopt.h
#endif #endif
#include <getopt.h> #include <my_getopt.h>
//#include "my_readline.h" //#include "my_readline.h"
#include <signal.h> #include <signal.h>
#include <violite.h> #include <violite.h>
const char *VER="0.1"; const char *VER="0.2";
#ifndef DBUG_OFF #ifndef DBUG_OFF
......
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