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 my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument __attribute__((unused)))
{
switch(optid) {
case 'd':
dump=1;
complain(count || query);
break;
case 's':
stats=1;
complain(query!=0);
break;
case 'c':
count= 1;
complain(dump || query);
break;
case 'l':
lstats=1;
complain(query!=0);
break;
case 'e':
complain(dump || count || stats);
break;
case '?':
case 'h':
usage();
}
return 0;
}
static void get_options(int argc, char *argv[]) static void get_options(int argc, char *argv[])
{ {
int c; int ho_error;
while ((c=getopt(argc,argv,options)) != -1) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{ {
switch(c) { printf("%s: handle_options() failed with error %d\n", my_progname,
case 'd': dump=1; complain(count || query); break; ho_error);
case 's': stats=1; complain(query!=0); break; exit(1);
case 'v': verbose=1; break;
case 'c': count=1; complain(dump || query); break;
case 'l': lstats=1; complain(query!=0); break;
case 'e': query=my_strdup(optarg,MYF(MY_FAE)); complain(dump || count || stats); break;
case '?':
case 'h':
default:
usage(argv);
}
} }
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) {
...@@ -94,7 +110,7 @@ int main(int argc,char *argv[]) ...@@ -94,7 +110,7 @@ int main(int argc,char *argv[])
t=uint2korr(read_record); t=uint2korr(read_record);
w=ft_nlq_get_relevance(result); w=ft_nlq_get_relevance(result);
printf("%d %.*s %f\n",i,t,read_record+2,w); printf("%d %.*s %f\n",i,t,read_record+2,w);
} }
if(err != HA_ERR_END_OF_FILE) { if(err != HA_ERR_END_OF_FILE) {
printf("ft_read_next %d failed with errno %3d\n",j,my_errno); printf("ft_read_next %d failed with errno %3d\n",j,my_errno);
goto err; goto err;
...@@ -106,57 +122,67 @@ int main(int argc,char *argv[]) ...@@ -106,57 +122,67 @@ 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)
case 's': {
if(stopwordlist && stopwordlist!=ft_precompiled_stopwords) break; switch(optid) {
{ case 's':
FILE *f; char s[HA_FT_MAXLEN]; int i=0,n=SWL_INIT; if(stopwordlist && stopwordlist!=ft_precompiled_stopwords) break;
{
if(!(stopwordlist=(const char**) malloc(n*sizeof(char *)))) FILE *f; char s[HA_FT_MAXLEN]; int i=0,n=SWL_INIT;
print_error(1,"malloc(%d)",n*sizeof(char *));
if(!(f=fopen(optarg,"r"))) if(!(stopwordlist=(const char**) malloc(n*sizeof(char *))))
print_error(1,"fopen(%s)",optarg); print_error(1,"malloc(%d)",n*sizeof(char *));
while(!feof(f)) { if(!(f=fopen(argument,"r")))
if(!(fgets(s,HA_FT_MAXLEN,f))) print_error(1,"fopen(%s)",argument);
print_error(1,"fgets(s,%d,%s)",HA_FT_MAXLEN,optarg); while(!feof(f)) {
if(!(stopwordlist[i++]=strdup(s))) if(!(fgets(s,HA_FT_MAXLEN,f)))
print_error(1,"strdup(%s)",s); print_error(1,"fgets(s,%d,%s)",HA_FT_MAXLEN,argument);
if(i>=n) { if(!(stopwordlist[i++]=strdup(s)))
n+=SWL_PLUS; print_error(1,"strdup(%s)",s);
if(!(stopwordlist=(const char**) realloc((char*) stopwordlist,n*sizeof(char *)))) if(i>=n) {
print_error(1,"realloc(%d)",n*sizeof(char *)); n+=SWL_PLUS;
} if(!(stopwordlist=(const char**) realloc((char*) stopwordlist,n*sizeof(char *))))
print_error(1,"realloc(%d)",n*sizeof(char *));
} }
fclose(f);
stopwordlist[i]=NULL;
break;
} }
case 'q': silent=1; break; fclose(f);
case 'S': if(stopwordlist==ft_precompiled_stopwords) stopwordlist=NULL; break; stopwordlist[i]=NULL;
case '#':
DEBUGGER_ON;
DBUG_PUSH (optarg);
break; break;
case 'V':
case '?':
case 'h':
default:
printf("%s -[%s] <d_file> <q_file>\n", argv[0], options);
exit(0);
} }
case 'q': silent=1; break;
case 'S': if(stopwordlist==ft_precompiled_stopwords) stopwordlist=NULL; break;
case '#':
DEBUGGER_ON;
DBUG_PUSH (argument);
break;
case 'V':
case '?':
case 'h':
usage();
exit(1);
}
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,34 +251,51 @@ void create_record(char *pos, int n) ...@@ -232,34 +251,51 @@ void create_record(char *pos, int n)
} }
} }
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch(optid) {
case 'v': verbose=1; break;
case 's': silent=1; break;
case 'F': no_fulltext=1; no_search=1;
case 'U': skip_update=1; break;
case 'K': no_keys=no_search=1; break;
case 'N': no_search=1; break;
case 'S': no_stopwords=1; break;
case '#':
DEBUGGER_ON;
DBUG_PUSH (argument);
break;
case 'V':
case '?':
case 'h':
usage();
exit(1);
}
return 0;
}
/* Read options */ /* Read options */
static void get_options(int argc,char *argv[]) static void get_options(int argc,char *argv[])
{ {
int c; int ho_error;
const char *options="hVvsNSKFU#:";
while ((c=getopt(argc,argv,options)) != -1) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{ {
switch(c) { printf("%s: handle_options() failed with error %d\n", my_progname,
case 'v': verbose=1; break; ho_error);
case 's': silent=1; break; exit(1);
case 'F': no_fulltext=1; no_search=1;
case 'U': skip_update=1; break;
case 'K': no_keys=no_search=1; break;
case 'N': no_search=1; break;
case 'S': no_stopwords=1; break;
case '#':
DEBUGGER_ON;
DBUG_PUSH (optarg);
break;
case 'V':
case '?':
case 'h':
default:
printf("%s -[%s]\n", argv[0], options);
exit(0);
}
} }
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,139 +504,158 @@ static void update_record(char *record) ...@@ -501,139 +504,158 @@ 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}
}; };
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch(optid) {
case 'a':
key_type= HA_KEYTYPE_TEXT;
break;
case 'c':
create_flag|= HA_CREATE_CHECKSUM;
break;
case 'R': /* Length of record pointer */
if (rec_pointer_size > 3)
rec_pointer_size=0;
break;
case 'P':
pack_keys= HA_PACK_KEY; /* Use prefix compression */
break;
case 'B':
pack_keys= HA_BINARY_PACK_KEY; /* Use binary compression */
break;
case 'S':
if (key_field == FIELD_VARCHAR)
{
create_flag=0; /* Static sized varchar */
}
else if (key_field != FIELD_BLOB)
{
key_field=FIELD_NORMAL; /* static-size record */
extra_field=FIELD_NORMAL;
}
break;
case 'p':
pack_keys=HA_PACK_KEY; /* Use prefix + space packing */
pack_seg=HA_SPACE_PACK;
key_type=HA_KEYTYPE_TEXT;
break;
case 'm':
unique_key=0;
break;
case 'b':
key_field=FIELD_BLOB; /* blob key */
extra_field= FIELD_BLOB;
pack_seg|= HA_BLOB_PART;
key_type= HA_KEYTYPE_VARTEXT;
break;
case 'k':
if (key_length < 4 || key_length > MI_MAX_KEY_LENGTH)
{
fprintf(stderr,"Wrong key length\n");
exit(1);
}
break;
case 'w':
key_field=FIELD_VARCHAR; /* varchar keys */
extra_field= FIELD_VARCHAR;
key_type= HA_KEYTYPE_VARTEXT;
pack_seg|= HA_VAR_LENGTH;
create_flag|= HA_PACK_RECORD;
break;
case 'K': /* Use key cacheing */
key_cacheing=1;
break;
case 'V':
printf("test1 Ver 1.1 \n");
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (argument);
break;
case '?':
usage();
exit(1);
}
return 0;
}
/* Read options */ /* Read options */
static void get_options(int argc,char *argv[]) static void get_options(int argc, char *argv[])
{ {
int c,option_index=0; int ho_error;
while ((c=getopt_long(argc,argv,"abBcCd:i:k:KmPR:SspNu:UvVw#:", if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
long_options, &option_index)) != EOF)
{ {
switch(c) { printf("%s: handle_options() failed with error %d\n", my_progname,
case 'a': ho_error);
key_type= HA_KEYTYPE_TEXT; exit(1);
break;
case 'c':
create_flag|= HA_CREATE_CHECKSUM;
break;
case 'C':
opt_unique=1;
break;
case 'R': /* Length of record pointer */
rec_pointer_size=atoi(optarg);
if (rec_pointer_size > 3)
rec_pointer_size=0;
break;
case 'P':
pack_keys= HA_PACK_KEY; /* Use prefix compression */
break;
case 'B':
pack_keys= HA_BINARY_PACK_KEY; /* Use binary compression */
break;
case 'S':
if (key_field == FIELD_VARCHAR)
{
create_flag=0; /* Static sized varchar */
}
else if (key_field != FIELD_BLOB)
{
key_field=FIELD_NORMAL; /* static-size record */
extra_field=FIELD_NORMAL;
}
break;
case 'p':
pack_keys=HA_PACK_KEY; /* Use prefix + space packing */
pack_seg=HA_SPACE_PACK;
key_type=HA_KEYTYPE_TEXT;
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':
unique_key=0;
break;
case 'b':
key_field=FIELD_BLOB; /* blob key */
extra_field= FIELD_BLOB;
pack_seg|= HA_BLOB_PART;
key_type= HA_KEYTYPE_VARTEXT;
break;
case 'k':
key_length=atoi(optarg);
if (key_length < 4 || key_length > MI_MAX_KEY_LENGTH)
{
fprintf(stderr,"Wrong key length\n");
exit(1);
}
break;
case 's':
silent=1;
break;
case 'w':
key_field=FIELD_VARCHAR; /* varchar keys */
extra_field= FIELD_VARCHAR;
key_type= HA_KEYTYPE_VARTEXT;
pack_seg|= HA_VAR_LENGTH;
create_flag|= HA_PACK_RECORD;
break;
case 'K': /* Use key cacheing */
key_cacheing=1;
break;
case 'V':
printf("test1 Ver 1.0 \n");
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (optarg);
break;
}
} }
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,22 +285,54 @@ static void usage(void) ...@@ -267,22 +285,54 @@ 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\ static my_bool
-s, --silent Be more silent.\n\ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
-t, --test Don't pack table, only test packing it.\n\ char *argument)
-v, --verbose Write info about progress and packing result.\n\ {
-w, --wait Wait and retry if table is in use.\n\ uint length;
-T, --tmpdir=... Use temporary directory to store temporary table.\n\
-#, --debug=... Output debug log. Often this is 'd:t:o,filename`\n\ switch(optid) {
-?, --help Display this help and exit.\n\ case 'f':
-V, --version Output version information and exit."); force_pack= 1;
print_defaults("my",load_default_groups); tmpfile_createflag= O_RDWR | O_TRUNC;
break;
case 's':
write_loop= verbose= 0;
silent= 1;
break;
case 't':
test_only= verbose= 1;
break;
case 'T':
length= (uint) (strmov(tmp_dir, argument) - tmp_dir);
if (length != dirname_length(tmp_dir))
{
tmp_dir[length]=FN_LIBCHAR;
tmp_dir[length+1]=0;
}
break;
case 'v':
verbose= 1;
silent= 0;
break;
case '#':
DBUG_PUSH(argument ? argument : "d:t:o");
break;
case 'V':
print_version();
exit(0);
case 'I':
case '?':
usage();
exit(0);
}
return 0;
} }
/* reads options */ /* reads options */
...@@ -290,66 +340,18 @@ static void usage(void) ...@@ -290,66 +340,18 @@ static void usage(void)
static void get_options(int *argc,char ***argv) static void get_options(int *argc,char ***argv)
{ {
int c,option_index=0; int ho_error;
uint length;
my_progname= argv[0][0]; my_progname= argv[0][0];
if (isatty(fileno(stdout))) if (isatty(fileno(stdout)))
write_loop=1; write_loop=1;
while ((c=getopt_long(*argc,*argv,"bfj:stvwT:#::?V",long_options, if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
&option_index)) != EOF)
{ {
switch(c) { printf("%s: handle_options() failed with error %d\n", my_progname,
case 'b': ho_error);
backup=1; exit(1);
break;
case 'f':
force_pack=1;
tmpfile_createflag=O_RDWR | O_TRUNC;
break;
case 'j':
join_table=optarg;
break;
case 's':
write_loop=verbose=0; silent=1;
break;
case 't':
test_only=verbose=1;
break;
case 'T':
length=(uint) (strmov(tmp_dir,optarg)-tmp_dir);
if (length != dirname_length(tmp_dir))
{
tmp_dir[length]=FN_LIBCHAR;
tmp_dir[length+1]=0;
}
break;
case 'v':
verbose=1; silent=0;
break;
case 'w':
opt_wait=1;
break;
case '#':
DBUG_PUSH(optarg ? optarg : "d:t:o");
break;
case OPT_CHARSETS_DIR_MP:
charsets_dir = optarg;
break;
case 'V': print_version(); exit(0);
case 'I':
case '?':
usage();
exit(0);
default:
fprintf(stderr,"%s: Illegal option: -%c\n",my_progname,opterr);
usage();
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,29 +658,32 @@ void my_print_help(const struct my_option *options) ...@@ -658,29 +658,32 @@ void my_print_help(const struct my_option *options)
printf(" "); printf(" ");
col= 2; col= 2;
} }
printf("--%s", optp->name); if (strlen(optp->name))
col+= 2 + strlen(optp->name);
if (optp->var_type == GET_STR || optp->var_type == GET_STR_ALLOC)
{ {
printf("%s=name%s ", optp->arg_type == OPT_ARG ? "[" : "", printf("--%s", optp->name);
optp->arg_type == OPT_ARG ? "]" : ""); col+= 2 + strlen(optp->name);
col+= (optp->arg_type == OPT_ARG) ? 8 : 6; if (optp->var_type == GET_STR || optp->var_type == GET_STR_ALLOC)
} {
else if (optp->var_type == GET_NO_ARG || optp->var_type == GET_BOOL) printf("%s=name%s ", optp->arg_type == OPT_ARG ? "[" : "",
{ optp->arg_type == OPT_ARG ? "]" : "");
putchar(' '); col+= (optp->arg_type == OPT_ARG) ? 8 : 6;
col++; }
} else if (optp->var_type == GET_NO_ARG || optp->var_type == GET_BOOL)
else {
{ putchar(' ');
printf("%s=#%s ", optp->arg_type == OPT_ARG ? "[" : "", col++;
optp->arg_type == OPT_ARG ? "]" : ""); }
col+= (optp->arg_type == OPT_ARG) ? 5 : 3; else
} {
if (col > name_space && optp->comment && *optp->comment) printf("%s=#%s ", optp->arg_type == OPT_ARG ? "[" : "",
{ optp->arg_type == OPT_ARG ? "]" : "");
putchar('\n'); col+= (optp->arg_type == OPT_ARG) ? 5 : 3;
col= 0; }
if (col > name_space && optp->comment && *optp->comment)
{
putchar('\n');
col= 0;
}
} }
for (; col < name_space; col++) for (; col < name_space; col++)
putchar(' '); putchar(' ');
......
...@@ -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 my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument __attribute__((unused)))
{
switch(optid) {
case 'v':
opt_verbose++;
break;
case 'V':
usage(1);
exit(0);
case 'I':
case '?':
usage(0);
exit(0);
}
return 0;
} }
static uint best_type;
static ulong best_t1,best_t2, best_start_value;
static int get_options(int argc, char **argv) static int get_options(int argc, char **argv)
{ {
int c,option_index=0; int ho_error;
while ((c=getopt_long(argc,argv,"?SvVc:r:R:t:", if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
long_options, &option_index)) != EOF)
{ {
switch(c) { printf("%s: handle_options() failed with error %d\n", my_progname,
case 'c': ho_error);
opt_count=atol(optarg); exit(1);
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':
opt_verbose++;
break;
case 'V': usage(1); exit(0);
case 'I':
case '?':
usage(0);
exit(0);
default:
fprintf(stderr,"illegal option: -%c\n",opterr);
usage(0);
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,76 +1302,40 @@ static void usage() ...@@ -1280,76 +1302,40 @@ 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 static my_bool
printf("\ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
-P, --port=... Port number to listen on.\n\ char *argument)
-l, --log=... Path to log file.\n\ {
-b, --bind-address=... Address to listen on.\n\ switch (optid) {
-B, --tcp-backlog==... Size of TCP/IP listen queue.\n\ case '#':
-g, --greeting= Set greeting on connect \n\ DBUG_PUSH(argument ? argument : "d:t:O,/tmp/mysqlmgrd.trace");
-m, --max-command-len Maximum command length \n\ break;
-d, --one-thread Use one thread ( for debugging) \n\ case 'V':
-C, --connect-retries Number of attempts to establish MySQL connection \n\ print_version();
-m, --max-command-len Maximum command length \n\ exit(0);
-V, --version Output version information and exit.\n\n"); case '?':
usage();
exit(0);
}
return 0;
} }
static int parse_args(int argc, char **argv) static int parse_args(int argc, char **argv)
{ {
int c, option_index = 0; int ho_error;
while ((c=getopt_long(argc,argv,"P:?#:Vl:b:B:g:m:dC:p:f:",
long_options,&option_index)) != EOF) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{ {
switch (c) printf("%s: handle_options() failed with error %d\n", my_progname,
{ ho_error);
case '#': exit(1);
DBUG_PUSH(optarg ? optarg : "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;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
default:
usage();
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