Commit 8a62c4b6 authored by unknown's avatar unknown

merge


configure.in:
  Auto merged
include/my_sys.h:
  Auto merged
libmysql/libmysql.c:
  Auto merged
sql/ha_berkeley.cc:
  Auto merged
sql/handler.h:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/lex.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_string.h:
  Auto merged
BitKeeper/etc/logging_ok:
  Auto merged
parents 0d55a136 415381f6
jcole@tetra.bedford.progress.com jcole@tetra.bedford.progress.com
jcole@tetra.spaceapes.com jcole@tetra.spaceapes.com
monty@narttu.mysql.fi
mwagner@evoq.home.mwagner.org
sasha@laptop.slkc.uswest.net sasha@laptop.slkc.uswest.net
sasha@mysql.sashanet.com sasha@mysql.sashanet.com
sasha@work.mysql.com sasha@work.mysql.com
serg@serg.mysql.com serg@serg.mysql.com
yfaktoro@nslinuxw2.bedford.progress.com yfaktoro@nslinuxw2.bedford.progress.com
mwagner@evoq.home.mwagner.org
This diff is collapsed.
...@@ -115,7 +115,7 @@ static bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, ...@@ -115,7 +115,7 @@ static bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0,
opt_compress=0, opt_compress=0,
vertical=0,skip_line_numbers=0,skip_column_names=0,opt_html=0, vertical=0,skip_line_numbers=0,skip_column_names=0,opt_html=0,
no_named_cmds=1; // we want this to be the default no_named_cmds=1; // we want this to be the default
static uint verbose=0,opt_silent=0,opt_mysql_port=0; static uint verbose=0,opt_silent=0,opt_mysql_port=0,opt_connect_timeout=0;
static my_string opt_mysql_unix_port=0; static my_string opt_mysql_unix_port=0;
static int connect_flag=CLIENT_INTERACTIVE; static int connect_flag=CLIENT_INTERACTIVE;
static char *current_host,*current_db,*current_user=0,*opt_password=0, static char *current_host,*current_db,*current_user=0,*opt_password=0,
...@@ -334,7 +334,7 @@ sig_handler mysql_end(int sig) ...@@ -334,7 +334,7 @@ sig_handler mysql_end(int sig)
exit(status.exit_status); exit(status.exit_status);
} }
enum options {OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET} ; enum options {OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET, OPT_TIMEOUT} ;
static struct option long_options[] = static struct option long_options[] =
...@@ -374,6 +374,7 @@ static struct option long_options[] = ...@@ -374,6 +374,7 @@ static struct option long_options[] =
{"socket", required_argument, 0, 'S'}, {"socket", required_argument, 0, 'S'},
#include "sslopt-longopts.h" #include "sslopt-longopts.h"
{"table", no_argument, 0, 't'}, {"table", no_argument, 0, 't'},
{"timeout", required_argument, 0, OPT_TIMEOUT},
#ifndef DONT_ALLOW_USER_CHANGE #ifndef DONT_ALLOW_USER_CHANGE
{"user", required_argument, 0, 'u'}, {"user", required_argument, 0, 'u'},
#endif #endif
...@@ -545,9 +546,12 @@ static int get_options(int argc, char **argv) ...@@ -545,9 +546,12 @@ static int get_options(int argc, char **argv)
case 'p': case 'p':
if (optarg) if (optarg)
{ {
char *start=optarg;
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
opt_password=my_strdup(optarg,MYF(MY_FAE)); opt_password=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; // Destroy argument while (*optarg) *optarg++= 'x'; // Destroy argument
if (*start)
start[1]=0;
} }
else else
tty_password=1; tty_password=1;
...@@ -603,6 +607,9 @@ static int get_options(int argc, char **argv) ...@@ -603,6 +607,9 @@ static int get_options(int argc, char **argv)
opt_mysql_unix_port=my_strdup(MYSQL_NAMEDPIPE,MYF(0)); opt_mysql_unix_port=my_strdup(MYSQL_NAMEDPIPE,MYF(0));
#endif #endif
break; break;
case OPT_TIMEOUT:
opt_connect_timeout=atoi(optarg);
break;
case 'V': usage(1); exit(0); case 'V': usage(1); exit(0);
case 'I': case 'I':
case '?': case '?':
...@@ -1772,6 +1779,9 @@ sql_real_connect(char *host,char *database,char *user,char *password, ...@@ -1772,6 +1779,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
connected= 0; connected= 0;
} }
mysql_init(&mysql); mysql_init(&mysql);
if (opt_connect_timeout)
mysql_options(&mysql,MYSQL_OPT_CONNECT_TIMEOUT,
(char*) &opt_connect_timeout);
if (opt_compress) if (opt_compress)
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS); mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <my_pthread.h> /* because of signal() */ #include <my_pthread.h> /* because of signal() */
#endif #endif
#define ADMIN_VERSION "8.9" #define ADMIN_VERSION "8.11"
#define MAX_MYSQL_VAR 64 #define MAX_MYSQL_VAR 64
#define MAX_TIME_TO_WAIT 3600 /* Wait for shutdown */ #define MAX_TIME_TO_WAIT 3600 /* Wait for shutdown */
#define MAX_TRUNC_LENGTH 3 #define MAX_TRUNC_LENGTH 3
...@@ -137,7 +137,7 @@ int main(int argc,char *argv[]) ...@@ -137,7 +137,7 @@ int main(int argc,char *argv[])
{ {
int c, error = 0,option_index=0; int c, error = 0,option_index=0;
MYSQL mysql; MYSQL mysql;
char *host = NULL,*password=0,*user=0,**commands; char *host = NULL,*opt_password=0,*user=0,**commands;
my_bool tty_password=0; my_bool tty_password=0;
MY_INIT(argv[0]); MY_INIT(argv[0]);
mysql_init(&mysql); mysql_init(&mysql);
...@@ -160,9 +160,12 @@ int main(int argc,char *argv[]) ...@@ -160,9 +160,12 @@ int main(int argc,char *argv[])
case 'p': case 'p':
if (optarg) if (optarg)
{ {
my_free(password,MYF(MY_ALLOW_ZERO_PTR)); char *start=optarg;
password=my_strdup(optarg,MYF(MY_FAE)); my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
opt_password=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */ while (*optarg) *optarg++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
} }
else else
tty_password=1; tty_password=1;
...@@ -243,12 +246,11 @@ int main(int argc,char *argv[]) ...@@ -243,12 +246,11 @@ int main(int argc,char *argv[])
exit(1); exit(1);
} }
if (tty_password) if (tty_password)
password = get_tty_password(NullS); opt_password = get_tty_password(NullS);
VOID(signal(SIGINT,endprog)); /* Here if abort */ VOID(signal(SIGINT,endprog)); /* Here if abort */
VOID(signal(SIGTERM,endprog)); /* Here if abort */ VOID(signal(SIGTERM,endprog)); /* Here if abort */
mysql_init(&mysql);
if (opt_compress) if (opt_compress)
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS); mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
...@@ -256,7 +258,7 @@ int main(int argc,char *argv[]) ...@@ -256,7 +258,7 @@ int main(int argc,char *argv[])
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath); opt_ssl_capath);
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
if (sql_connect(&mysql,host,user,password,option_wait)) if (sql_connect(&mysql,host,user,opt_password,option_wait))
error = 1; error = 1;
else else
{ {
...@@ -269,7 +271,7 @@ int main(int argc,char *argv[]) ...@@ -269,7 +271,7 @@ int main(int argc,char *argv[])
if (option_wait && !interrupted) if (option_wait && !interrupted)
{ {
mysql_close(&mysql); mysql_close(&mysql);
if (!sql_connect(&mysql,host,user,password,option_wait)) if (!sql_connect(&mysql,host,user,opt_password,option_wait))
continue; /* Retry */ continue; /* Retry */
} }
error=1; error=1;
...@@ -286,7 +288,7 @@ int main(int argc,char *argv[]) ...@@ -286,7 +288,7 @@ int main(int argc,char *argv[])
} }
mysql_close(&mysql); mysql_close(&mysql);
} }
my_free(password,MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
my_free(user,MYF(MY_ALLOW_ZERO_PTR)); my_free(user,MYF(MY_ALLOW_ZERO_PTR));
free_defaults(argv); free_defaults(argv);
my_end(0); my_end(0);
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
** Tnu Samuel <tonu@please.do.not.remove.this.spam.ee> ** Tnu Samuel <tonu@please.do.not.remove.this.spam.ee>
**/ **/
#define DUMP_VERSION "8.10" #define DUMP_VERSION "8.11"
#include <global.h> #include <global.h>
#include <my_sys.h> #include <my_sys.h>
...@@ -75,7 +75,7 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick=0, extended_insert = 0, ...@@ -75,7 +75,7 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick=0, extended_insert = 0,
opt_delayed=0,create_options=0,opt_quoted=0,opt_databases=0, opt_delayed=0,create_options=0,opt_quoted=0,opt_databases=0,
opt_alldbs=0,opt_create_db=0,opt_first_slave=0; opt_alldbs=0,opt_create_db=0,opt_first_slave=0;
static MYSQL mysql_connection,*sock=0; static MYSQL mysql_connection,*sock=0;
static char insert_pat[12 * 1024],*password=0,*current_user=0, static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
*current_host=0,*path=0,*fields_terminated=0, *current_host=0,*path=0,*fields_terminated=0,
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0, *lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0,
*where=0, *default_charset; *where=0, *default_charset;
...@@ -333,9 +333,12 @@ static int get_options(int *argc,char ***argv) ...@@ -333,9 +333,12 @@ static int get_options(int *argc,char ***argv)
case 'p': case 'p':
if (optarg) if (optarg)
{ {
my_free(password,MYF(MY_ALLOW_ZERO_PTR)); char *start=optarg;
password=my_strdup(optarg,MYF(MY_FAE)); my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
while (*optarg) *optarg++= 'x'; /* Destroy argument */ opt_password=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
} }
else else
tty_password=1; tty_password=1;
...@@ -459,7 +462,7 @@ static int get_options(int *argc,char ***argv) ...@@ -459,7 +462,7 @@ static int get_options(int *argc,char ***argv)
return 1; return 1;
} }
if (tty_password) if (tty_password)
password=get_tty_password(NullS); opt_password=get_tty_password(NullS);
return(0); return(0);
} /* get_options */ } /* get_options */
...@@ -596,7 +599,6 @@ static uint getTableStructure(char *table, char* db) ...@@ -596,7 +599,6 @@ static uint getTableStructure(char *table, char* db)
sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", opt_quoted); sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", opt_quoted);
table_name=quote_name(table,table_buff); table_name=quote_name(table,table_buff);
if (mysql_query(sock,insert_pat)) if (mysql_query(sock,insert_pat))
{ {
/* using SHOW CREATE statement */ /* using SHOW CREATE statement */
...@@ -1318,7 +1320,7 @@ int main(int argc, char **argv) ...@@ -1318,7 +1320,7 @@ int main(int argc, char **argv)
my_end(0); my_end(0);
exit(EX_USAGE); exit(EX_USAGE);
} }
if (dbConnect(current_host, current_user, password)) if (dbConnect(current_host, current_user, opt_password))
exit(EX_MYSQLERR); exit(EX_MYSQLERR);
if (!path) if (!path)
write_heder(stdout, *argv); write_heder(stdout, *argv);
...@@ -1358,7 +1360,7 @@ int main(int argc, char **argv) ...@@ -1358,7 +1360,7 @@ int main(int argc, char **argv)
} }
dbDisconnect(current_host); dbDisconnect(current_host);
puts(""); puts("");
my_free(password, MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
if (extended_insert) if (extended_insert)
dynstr_free(&extended_row); dynstr_free(&extended_row);
my_end(0); my_end(0);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
** * * ** * *
** ************************* ** *************************
*/ */
#define IMPORT_VERSION "2.4" #define IMPORT_VERSION "2.6"
#include <global.h> #include <global.h>
#include <my_sys.h> #include <my_sys.h>
...@@ -45,7 +45,7 @@ static my_bool verbose=0,lock_tables=0,ignore_errors=0,delete=0, ...@@ -45,7 +45,7 @@ static my_bool verbose=0,lock_tables=0,ignore_errors=0,delete=0,
replace=0,silent=0,ignore=0,opt_compress=0,opt_local_file=0; replace=0,silent=0,ignore=0,opt_compress=0,opt_local_file=0;
static MYSQL mysql_connection; static MYSQL mysql_connection;
static char *password=0, *current_user=0, static char *opt_password=0, *current_user=0,
*current_host=0, *current_db=0, *fields_terminated=0, *current_host=0, *current_db=0, *fields_terminated=0,
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *lines_terminated=0, *enclosed=0, *opt_enclosed=0,
*escaped=0, opt_low_priority=0, *opt_columns=0; *escaped=0, opt_low_priority=0, *opt_columns=0;
...@@ -125,7 +125,7 @@ file. The SQL command 'LOAD DATA INFILE' is used to import the rows.\n"); ...@@ -125,7 +125,7 @@ file. The SQL command 'LOAD DATA INFILE' is used to import the rows.\n");
Give the column names in a comma separated list.\n\ Give the column names in a comma separated list.\n\
This is same as giving columns to LOAD DATA INFILE.\n\ This is same as giving columns to LOAD DATA INFILE.\n\
-C, --compress Use compression in server/client protocol\n\ -C, --compress Use compression in server/client protocol\n\
-d, --delete Deletes first all rows from table.\n\ -d, --delete First delete all rows from table.\n\
-f, --force Continue even if we get an sql-error.\n\ -f, --force Continue even if we get an sql-error.\n\
-h, --host=... Connect to host.\n\ -h, --host=... Connect to host.\n\
-i, --ignore If duplicate unique key was found, keep old row.\n\ -i, --ignore If duplicate unique key was found, keep old row.\n\
...@@ -202,9 +202,12 @@ static int get_options(int *argc, char ***argv) ...@@ -202,9 +202,12 @@ static int get_options(int *argc, char ***argv)
case 'p': case 'p':
if (optarg) if (optarg)
{ {
my_free(password,MYF(MY_ALLOW_ZERO_PTR)); char *start=optarg;
password= my_strdup(optarg,MYF(MY_FAE)); my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
opt_password=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */ while (*optarg) *optarg++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
} }
else else
tty_password= 1; tty_password= 1;
...@@ -276,7 +279,7 @@ static int get_options(int *argc, char ***argv) ...@@ -276,7 +279,7 @@ static int get_options(int *argc, char ***argv)
current_db= *((*argv)++); current_db= *((*argv)++);
(*argc)--; (*argc)--;
if (tty_password) if (tty_password)
password=get_tty_password(NullS); opt_password=get_tty_password(NullS);
return(0); return(0);
} }
...@@ -504,7 +507,7 @@ int main(int argc, char **argv) ...@@ -504,7 +507,7 @@ int main(int argc, char **argv)
argv_to_free= argv; argv_to_free= argv;
if (get_options(&argc, &argv)) if (get_options(&argc, &argv))
return(1); return(1);
if (!(sock= db_connect(current_host,current_db,current_user,password))) if (!(sock= db_connect(current_host,current_db,current_user,opt_password)))
return(1); /* purecov: deadcode */ return(1); /* purecov: deadcode */
if (lock_tables) if (lock_tables)
lock_table(sock, argc, argv); lock_table(sock, argc, argv);
...@@ -513,7 +516,7 @@ int main(int argc, char **argv) ...@@ -513,7 +516,7 @@ int main(int argc, char **argv)
if (exitcode == 0) if (exitcode == 0)
exitcode = error; exitcode = error;
db_disconnect(current_host, sock); db_disconnect(current_host, sock);
my_free(password,MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
free_defaults(argv_to_free); free_defaults(argv_to_free);
my_end(0); my_end(0);
return(exitcode); return(exitcode);
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <getopt.h> #include <getopt.h>
static my_string host=0,password=0,user=0; static my_string host=0,opt_password=0,user=0;
static my_bool opt_show_keys=0,opt_compress=0,opt_status=0; static my_bool opt_show_keys=0,opt_compress=0,opt_status=0;
static void get_options(int *argc,char ***argv); static void get_options(int *argc,char ***argv);
...@@ -88,15 +88,13 @@ int main(int argc, char **argv) ...@@ -88,15 +88,13 @@ int main(int argc, char **argv)
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath); opt_ssl_capath);
#endif #endif
if (!(mysql_real_connect(&mysql,host,user,password, if (!(mysql_real_connect(&mysql,host,user,opt_password,
argv[0],opt_mysql_port,opt_mysql_unix_port, argv[0],opt_mysql_port,opt_mysql_unix_port,
0))) 0)))
{ {
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql)); fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql));
exit(1); exit(1);
} }
/* if (!(mysql_connect(&mysql,host,user,password))) */
switch (argc) switch (argc)
{ {
...@@ -111,11 +109,12 @@ int main(int argc, char **argv) ...@@ -111,11 +109,12 @@ int main(int argc, char **argv)
if (opt_status && ! wild) if (opt_status && ! wild)
error=list_table_status(&mysql,argv[0],argv[1]); error=list_table_status(&mysql,argv[0],argv[1]);
else else
error=list_fields(&mysql,argv[0],argv[1],wild); break; error=list_fields(&mysql,argv[0],argv[1],wild);
break;
} }
mysql_close(&mysql); /* Close & free connection */ mysql_close(&mysql); /* Close & free connection */
if (password) if (opt_password)
my_free(password,MYF(0)); my_free(opt_password,MYF(0));
my_end(0); my_end(0);
exit(error ? 1 : 0); exit(error ? 1 : 0);
return 0; /* No compiler warnings */ return 0; /* No compiler warnings */
...@@ -223,9 +222,12 @@ get_options(int *argc,char ***argv) ...@@ -223,9 +222,12 @@ get_options(int *argc,char ***argv)
case 'p': case 'p':
if (optarg) if (optarg)
{ {
my_free(password,MYF(MY_ALLOW_ZERO_PTR)); char *start=optarg;
password=my_strdup(optarg,MYF(MY_FAE)); my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
opt_password=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */ while (*optarg) *optarg++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
} }
else else
tty_password=1; tty_password=1;
...@@ -266,7 +268,7 @@ get_options(int *argc,char ***argv) ...@@ -266,7 +268,7 @@ get_options(int *argc,char ***argv)
(*argc)-=optind; (*argc)-=optind;
(*argv)+=optind; (*argv)+=optind;
if (tty_password) if (tty_password)
password=get_tty_password(NullS); opt_password=get_tty_password(NullS);
return; return;
} }
......
...@@ -95,17 +95,6 @@ bool String::realloc(uint32 alloc_length) ...@@ -95,17 +95,6 @@ bool String::realloc(uint32 alloc_length)
return FALSE; return FALSE;
} }
#ifdef NOT_NEEDED
bool String::set(long num)
{
if (alloc(14))
return TRUE;
str_length=(uint32) (int10_to_str(num,Ptr,-10)-Ptr);
return FALSE;
}
#endif
bool String::set(longlong num) bool String::set(longlong num)
{ {
if (alloc(21)) if (alloc(21))
...@@ -274,6 +263,7 @@ bool String::append(const char *s,uint32 arg_length) ...@@ -274,6 +263,7 @@ bool String::append(const char *s,uint32 arg_length)
return FALSE; return FALSE;
} }
#ifdef TO_BE_REMOVED
bool String::append(FILE* file, uint32 arg_length, myf my_flags) bool String::append(FILE* file, uint32 arg_length, myf my_flags)
{ {
if (realloc(str_length+arg_length)) if (realloc(str_length+arg_length))
...@@ -286,6 +276,20 @@ bool String::append(FILE* file, uint32 arg_length, myf my_flags) ...@@ -286,6 +276,20 @@ bool String::append(FILE* file, uint32 arg_length, myf my_flags)
str_length+=arg_length; str_length+=arg_length;
return FALSE; return FALSE;
} }
#endif
bool String::append(IO_CACHE* file, uint32 arg_length)
{
if (realloc(str_length+arg_length))
return TRUE;
if (my_b_read(file, (byte*) Ptr + str_length, arg_length))
{
shrink(str_length);
return TRUE;
}
str_length+=arg_length;
return FALSE;
}
uint32 String::numchars() uint32 String::numchars()
{ {
......
...@@ -100,16 +100,16 @@ class String ...@@ -100,16 +100,16 @@ class String
bool set(ulonglong num); bool set(ulonglong num);
bool set(double num,uint decimals=2); bool set(double num,uint decimals=2);
inline void free() inline void free()
{
if (alloced)
{ {
if (alloced) alloced=0;
{ Alloced_length=0;
alloced=0; my_free(Ptr,MYF(0));
Alloced_length=0; Ptr=0;
my_free(Ptr,MYF(0)); str_length=0; /* Safety */
Ptr=0;
}
} }
}
inline bool alloc(uint32 arg_length) inline bool alloc(uint32 arg_length)
{ {
if (arg_length < Alloced_length) if (arg_length < Alloced_length)
...@@ -152,7 +152,7 @@ class String ...@@ -152,7 +152,7 @@ class String
bool copy(const char *s,uint32 arg_length); // Allocate new string bool copy(const char *s,uint32 arg_length); // Allocate new string
bool append(const String &s); bool append(const String &s);
bool append(const char *s,uint32 arg_length=0); bool append(const char *s,uint32 arg_length=0);
bool append(FILE* file, uint32 arg_length, myf my_flags); bool append(IO_CACHE* file, uint32 arg_length);
int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1 int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
int strrstr(const String &search,uint32 offset=0); // Returns offset to substring or -1 int strrstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
bool replace(uint32 offset,uint32 arg_length,const String &to); bool replace(uint32 offset,uint32 arg_length,const String &to);
......
...@@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. ...@@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT(sql/mysqld.cc) AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
# The Docs Makefile.am parses this line! # The Docs Makefile.am parses this line!
AM_INIT_AUTOMAKE(mysql, 3.23.27-beta) AM_INIT_AUTOMAKE(mysql, 3.23.28-gamma)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10 PROTOCOL_VERSION=10
...@@ -687,6 +687,8 @@ case $SYSTEM_TYPE in ...@@ -687,6 +687,8 @@ case $SYSTEM_TYPE in
then then
CFLAGS="$CFLAGS -traditional-cpp -DHAVE_DARWIN_THREADS" CFLAGS="$CFLAGS -traditional-cpp -DHAVE_DARWIN_THREADS"
CXXFLAGS="$CXXFLAGS -traditional-cpp -DHAVE_DARWIN_THREADS" CXXFLAGS="$CXXFLAGS -traditional-cpp -DHAVE_DARWIN_THREADS"
CFLAGS="$CFLAGS -traditional-cpp -DHAVE_DARWIN_THREADS -D_P1003_1B_VISIBLE"
CXXFLAGS="$CXXFLAGS -traditional-cpp -DHAVE_DARWIN_THREADS -D_P1003_1B_VISIBLE"
MAX_C_OPTIMIZE="-O" MAX_C_OPTIMIZE="-O"
with_named_curses="" with_named_curses=""
fi fi
...@@ -1235,13 +1237,13 @@ AC_FUNC_UTIME_NULL ...@@ -1235,13 +1237,13 @@ AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF AC_FUNC_VPRINTF
AC_CHECK_FUNCS(alarm bmove \ AC_CHECK_FUNCS(alarm bmove \
chsize ftruncate rint finite fpsetmask fpresetsticky\ chsize ftruncate rint finite fpsetmask fpresetsticky\
cuserid fcntl fconvert \ cuserid fcntl fconvert poll \
getrusage getpwuid getcwd getrlimit getwd index stpcpy locking longjmp \ getrusage getpwuid getcwd getrlimit getwd index stpcpy locking longjmp \
perror pread realpath rename \ perror pread realpath rename \
socket strnlen madvise mkstemp \ socket strnlen madvise mkstemp \
strtol strtoul strtoull snprintf tempnam thr_setconcurrency \ strtol strtoul strtoull snprintf tempnam thr_setconcurrency \
gethostbyaddr_r gethostbyname_r getpwnam \ gethostbyaddr_r gethostbyname_r getpwnam \
bfill bzero bcmp strstr strpbrk strerror\ bfill bzero bcmp strstr strpbrk strerror \
tell atod memcpy memmove \ tell atod memcpy memmove \
setupterm strcasecmp sighold \ setupterm strcasecmp sighold \
vidattr setupterm lrand48 localtime_r \ vidattr setupterm lrand48 localtime_r \
......
...@@ -351,10 +351,9 @@ struct tm *localtime_r(const time_t *clock, struct tm *res); ...@@ -351,10 +351,9 @@ struct tm *localtime_r(const time_t *clock, struct tm *res);
#define pthread_kill(A,B) pthread_dummy(0) #define pthread_kill(A,B) pthread_dummy(0)
#define pthread_condattr_init(A) pthread_dummy(0) #define pthread_condattr_init(A) pthread_dummy(0)
#define pthread_condattr_destroy(A) pthread_dummy(0) #define pthread_condattr_destroy(A) pthread_dummy(0)
#define pthread_cond_init( A, B ) pthread_cond_init( (A), 0 )
#define pthread_signal(A,B) pthread_dummy(0) #define pthread_signal(A,B) pthread_dummy(0)
#undef pthread_detach_this_thread #undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); } #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); }
#undef sigset #undef sigset
#define sigset(A,B) pthread_signal((A),(void (*)(int)) (B)) #define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
#endif #endif
......
...@@ -59,6 +59,7 @@ extern int NEAR my_errno; /* Last error in mysys */ ...@@ -59,6 +59,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_WME 16 /* Write message on error */ #define MY_WME 16 /* Write message on error */
#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ #define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
#define MY_RAID 64 /* Support for RAID (not the "Johnson&Johnson"-s one ;) */ #define MY_RAID 64 /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */ #define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
#define MY_COPYTIME 64 /* my_redel() copys time */ #define MY_COPYTIME 64 /* my_redel() copys time */
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */ #define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
...@@ -506,6 +507,10 @@ extern int my_block_write(IO_CACHE *info, const byte *Buffer, ...@@ -506,6 +507,10 @@ extern int my_block_write(IO_CACHE *info, const byte *Buffer,
uint Count, my_off_t pos); uint Count, my_off_t pos);
extern int flush_io_cache(IO_CACHE *info); extern int flush_io_cache(IO_CACHE *info);
extern int end_io_cache(IO_CACHE *info); extern int end_io_cache(IO_CACHE *info);
extern uint my_b_fill(IO_CACHE *info);
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir, extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
const char *prefix, uint cache_size, const char *prefix, uint cache_size,
myf cache_myflags); myf cache_myflags);
......
...@@ -108,6 +108,9 @@ my_bool vio_peer_addr(Vio * vio, char *buf); ...@@ -108,6 +108,9 @@ my_bool vio_peer_addr(Vio * vio, char *buf);
void vio_in_addr(Vio *vio, struct in_addr *in); void vio_in_addr(Vio *vio, struct in_addr *in);
/* Return 1 if there is data to be read */
my_bool vio_poll_read(Vio *vio,uint timeout);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -64,6 +64,12 @@ my_string mysql_unix_port=0; ...@@ -64,6 +64,12 @@ my_string mysql_unix_port=0;
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS) #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS)
#ifdef __WIN__
#define CONNECT_TIMEOUT 20
#else
#define CONNECT_TIMEOUT 0
#endif
#if defined(MSDOS) || defined(__WIN__) #if defined(MSDOS) || defined(__WIN__)
#define ERRNO WSAGetLastError() #define ERRNO WSAGetLastError()
#define perror(A) #define perror(A)
...@@ -113,7 +119,7 @@ static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, ...@@ -113,7 +119,7 @@ static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
*****************************************************************************/ *****************************************************************************/
static int connect2(my_socket s, const struct sockaddr *name, uint namelen, static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
uint to) uint timeout)
{ {
#if defined(__WIN__) #if defined(__WIN__)
return connect(s, (struct sockaddr*) name, namelen); return connect(s, (struct sockaddr*) name, namelen);
...@@ -128,7 +134,7 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, ...@@ -128,7 +134,7 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
* exactly like the normal connect() call does. * exactly like the normal connect() call does.
*/ */
if (to == 0) if (timeout == 0)
return connect(s, (struct sockaddr*) name, namelen); return connect(s, (struct sockaddr*) name, namelen);
flags = fcntl(s, F_GETFL, 0); /* Set socket to not block */ flags = fcntl(s, F_GETFL, 0); /* Set socket to not block */
...@@ -175,13 +181,13 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, ...@@ -175,13 +181,13 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
start_time = time(NULL); start_time = time(NULL);
for (;;) for (;;)
{ {
tv.tv_sec = (long) to; tv.tv_sec = (long) timeout;
tv.tv_usec = 0; tv.tv_usec = 0;
if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0) if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0)
break; break;
now_time=time(NULL); now_time=time(NULL);
to-= (uint) (now_time - start_time); timeout-= (uint) (now_time - start_time);
if (errno != EINTR || (int) to <= 0) if (errno != EINTR || (int) timeout <= 0)
return -1; return -1;
} }
...@@ -195,7 +201,7 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, ...@@ -195,7 +201,7 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
return(-1); return(-1);
if (s_err) if (s_err)
{ /* getsockopt() could suceed */ { /* getsockopt could succeed */
errno = s_err; errno = s_err;
return(-1); /* but return an error... */ return(-1); /* but return an error... */
} }
...@@ -1001,9 +1007,7 @@ mysql_init(MYSQL *mysql) ...@@ -1001,9 +1007,7 @@ mysql_init(MYSQL *mysql)
} }
else else
bzero((char*) (mysql),sizeof(*(mysql))); bzero((char*) (mysql),sizeof(*(mysql)));
#ifdef __WIN__ mysql->options.connect_timeout=CONNECT_TIMEOUT;
mysql->options.connect_timeout=20;
#endif
#if defined(SIGPIPE) && defined(THREAD) #if defined(SIGPIPE) && defined(THREAD)
if (!((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE)) if (!((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE))
(void) signal(SIGPIPE,pipe_sig_handler); (void) signal(SIGPIPE,pipe_sig_handler);
...@@ -1140,7 +1144,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1140,7 +1144,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db, const char *passwd, const char *db,
uint port, const char *unix_socket,uint client_flag) uint port, const char *unix_socket,uint client_flag)
{ {
char buff[100],charset_name_buff[16],*end,*host_info, *charset_name; char buff[NAME_LEN+100],charset_name_buff[16],*end,*host_info,
*charset_name;
my_socket sock; my_socket sock;
uint32 ip_addr; uint32 ip_addr;
struct sockaddr_in sock_addr; struct sockaddr_in sock_addr;
...@@ -1342,6 +1347,13 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1342,6 +1347,13 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
/* Get version info */ /* Get version info */
mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */ mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */
if (mysql->options.connect_timeout &&
vio_poll_read(net->vio, mysql->options.connect_timeout))
{
net->last_errno= CR_SERVER_LOST;
strmov(net->last_error,ER(net->last_errno));
goto error;
}
if ((pkt_length=net_safe_read(mysql)) == packet_error) if ((pkt_length=net_safe_read(mysql)) == packet_error)
goto error; goto error;
...@@ -1497,7 +1509,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1497,7 +1509,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
int3store(buff+2,max_allowed_packet); int3store(buff+2,max_allowed_packet);
if (user && user[0]) if (user && user[0])
strmake(buff+5,user,32); strmake(buff+5,user,32); /* Max user name */
else else
read_user_name((char*) buff+5); read_user_name((char*) buff+5);
#ifdef _CUSTOMCONFIG_ #ifdef _CUSTOMCONFIG_
...@@ -1508,7 +1520,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1508,7 +1520,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
(my_bool) (mysql->protocol_version == 9)); (my_bool) (mysql->protocol_version == 9));
if (db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB)) if (db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB))
{ {
end=strmov(end+1,db); end=strmake(end+1,db,NAME_LEN);
mysql->db=my_strdup(db,MYF(MY_WME)); mysql->db=my_strdup(db,MYF(MY_WME));
db=0; db=0;
} }
......
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
#include <my_sys.h> #include <my_sys.h>
#include <my_net.h> #include <my_net.h>
#include <m_string.h> #include <m_string.h>
#ifdef HAVE_POLL
#include <sys/poll.h>
#endif
#if defined(__EMX__) #if defined(__EMX__)
#include <sys/ioctl.h> #include <sys/ioctl.h>
...@@ -98,7 +101,9 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) ...@@ -98,7 +101,9 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
if ((vio = (Vio*) my_malloc(sizeof(*vio),MYF(MY_WME)))) if ((vio = (Vio*) my_malloc(sizeof(*vio),MYF(MY_WME))))
{ {
vio_reset(vio, type, sd, 0, localhost); vio_reset(vio, type, sd, 0, localhost);
sprintf(vio->desc, "socket (%d)", vio->sd); sprintf(vio->desc,
(vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"),
vio->sd);
#if !defined(___WIN__) && !defined(__EMX__) #if !defined(___WIN__) && !defined(__EMX__)
#if !defined(NO_FCNTL_NONBLOCK) #if !defined(NO_FCNTL_NONBLOCK)
vio->fcntl_mode = fcntl(sd, F_GETFL); vio->fcntl_mode = fcntl(sd, F_GETFL);
...@@ -261,7 +266,7 @@ vio_is_blocking(Vio * vio) ...@@ -261,7 +266,7 @@ vio_is_blocking(Vio * vio)
} }
int vio_fastsend(Vio * vio, my_bool onoff) int vio_fastsend(Vio * vio __attribute__((unused)), my_bool onoff)
{ {
int r=0; int r=0;
DBUG_ENTER("vio_fastsend"); DBUG_ENTER("vio_fastsend");
...@@ -322,7 +327,7 @@ int vio_close(Vio * vio) ...@@ -322,7 +327,7 @@ int vio_close(Vio * vio)
if (vio->type == VIO_TYPE_NAMEDPIPE) if (vio->type == VIO_TYPE_NAMEDPIPE)
{ {
#if defined(__NT__) && defined(MYSQL_SERVER) #if defined(__NT__) && defined(MYSQL_SERVER)
CancelIO(vio->hPipe); CancelIo(vio->hPipe);
DisconnectNamedPipe(vio->hPipe); DisconnectNamedPipe(vio->hPipe);
#endif #endif
r=CloseHandle(vio->hPipe); r=CloseHandle(vio->hPipe);
...@@ -397,4 +402,26 @@ void vio_in_addr(Vio *vio, struct in_addr *in) ...@@ -397,4 +402,26 @@ void vio_in_addr(Vio *vio, struct in_addr *in)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/* Return 0 if there is data to be read */
my_bool vio_poll_read(Vio *vio,uint timeout)
{
#ifndef HAVE_POLL
return 0;
#else
struct pollfd fds;
int res;
DBUG_ENTER("vio_poll");
fds.fd=vio->sd;
fds.events=POLLIN;
fds.revents=0;
if ((res=poll(&fds,1,(int) timeout*1000)) <= 0)
{
DBUG_RETURN(res < 0 ? 0 : 1); /* Don't return 1 on errors */
}
DBUG_RETURN(fds.revents & POLLIN ? 0 : 1);
#endif
}
#endif /* HAVE_VIO */ #endif /* HAVE_VIO */
No preview for this file type
...@@ -26,7 +26,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\ ...@@ -26,7 +26,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
mf_path.c mf_loadpath.c\ mf_path.c mf_loadpath.c\
my_open.c my_create.c my_seek.c my_read.c \ my_open.c my_create.c my_seek.c my_read.c \
my_pread.c my_write.c \ my_pread.c my_write.c \
mf_reccache.c mf_keycache.c \ mf_keycache.c \
mf_iocache.c mf_cache.c mf_tempfile.c \ mf_iocache.c mf_cache.c mf_tempfile.c \
my_lock.c mf_brkhant.c my_alarm.c \ my_lock.c mf_brkhant.c my_alarm.c \
my_malloc.c my_realloc.c my_once.c mulalloc.c \ my_malloc.c my_realloc.c my_once.c mulalloc.c \
......
...@@ -374,10 +374,11 @@ my_bool hash_delete(HASH *hash,byte *record) ...@@ -374,10 +374,11 @@ my_bool hash_delete(HASH *hash,byte *record)
uint blength,pos2,pos_hashnr,lastpos_hashnr,idx,empty_index; uint blength,pos2,pos_hashnr,lastpos_hashnr,idx,empty_index;
HASH_LINK *data,*lastpos,*gpos,*pos,*pos3,*empty; HASH_LINK *data,*lastpos,*gpos,*pos,*pos3,*empty;
DBUG_ENTER("hash_delete"); DBUG_ENTER("hash_delete");
if (!hash->records)
DBUG_RETURN(1);
blength=hash->blength; blength=hash->blength;
data=dynamic_element(&hash->array,0,HASH_LINK*); data=dynamic_element(&hash->array,0,HASH_LINK*);
/* Search after record with key */ /* Search after record with key */
pos=data+ hash_mask(rec_hashnr(hash,record),blength,hash->records); pos=data+ hash_mask(rec_hashnr(hash,record),blength,hash->records);
gpos = 0; gpos = 0;
......
...@@ -74,7 +74,7 @@ my_bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix, ...@@ -74,7 +74,7 @@ my_bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix,
} }
my_free(cache->dir, MYF(MY_ALLOW_ZERO_PTR)); my_free(cache->dir, MYF(MY_ALLOW_ZERO_PTR));
my_free(cache->prefix,MYF(MY_ALLOW_ZERO_PTR)); my_free(cache->prefix,MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN(0); DBUG_RETURN(1);
} }
/* Create the temporary file */ /* Create the temporary file */
...@@ -101,10 +101,12 @@ void close_cached_file(IO_CACHE *cache) ...@@ -101,10 +101,12 @@ void close_cached_file(IO_CACHE *cache)
DBUG_ENTER("close_cached_file"); DBUG_ENTER("close_cached_file");
if (my_b_inited(cache)) if (my_b_inited(cache))
{ {
File file=cache->file;
cache->file= -1; /* Don't flush data */
(void) end_io_cache(cache); (void) end_io_cache(cache);
if (cache->file >= 0) if (file >= 0)
{ {
(void) my_close(cache->file,MYF(0)); (void) my_close(file,MYF(0));
#ifdef CANT_DELETE_OPEN_FILES #ifdef CANT_DELETE_OPEN_FILES
if (cache->file_name) if (cache->file_name)
{ {
......
...@@ -22,10 +22,13 @@ ...@@ -22,10 +22,13 @@
(and get a EOF-error). (and get a EOF-error).
Possibly use of asyncronic io. Possibly use of asyncronic io.
macros for read and writes for faster io. macros for read and writes for faster io.
Used instead of FILE when reading or writing hole files. Used instead of FILE when reading or writing whole files.
This shall make mf_rec_cache obsolite. This will make mf_rec_cache obsolete.
One can change info->pos_in_file to a higer value to skipp bytes in file if One can change info->pos_in_file to a higher value to skip bytes in file if
also info->rc_pos is set to info->rc_end. also info->rc_pos is set to info->rc_end.
If called through open_cached_file(), then the temporary file will
only be created if a write exeeds the file buffer or if one calls
flush_io_cache().
*/ */
#define MAP_TO_USE_RAID #define MAP_TO_USE_RAID
...@@ -40,7 +43,7 @@ static void my_aiowait(my_aio_result *result); ...@@ -40,7 +43,7 @@ static void my_aiowait(my_aio_result *result);
/* /*
** if cachesize == 0 then use default cachesize (from s-file) ** if cachesize == 0 then use default cachesize (from s-file)
** if file == -1 then real_open_cached_file() will be called to ** if file == -1 then real_open_cached_file() will be called.
** returns 0 if ok ** returns 0 if ok
*/ */
...@@ -59,17 +62,24 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, ...@@ -59,17 +62,24 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
min_cache=use_async_io ? IO_SIZE*4 : IO_SIZE*2; min_cache=use_async_io ? IO_SIZE*4 : IO_SIZE*2;
if (type == READ_CACHE) if (type == READ_CACHE)
{ /* Assume file isn't growing */ { /* Assume file isn't growing */
my_off_t file_pos,end_of_file; if (cache_myflags & MY_DONT_CHECK_FILESIZE)
if ((file_pos=my_tell(file,MYF(0)) == MY_FILEPOS_ERROR))
DBUG_RETURN(1);
end_of_file=my_seek(file,0L,MY_SEEK_END,MYF(0));
if (end_of_file < seek_offset)
end_of_file=seek_offset;
VOID(my_seek(file,file_pos,MY_SEEK_SET,MYF(0)));
if ((my_off_t) cachesize > end_of_file-seek_offset+IO_SIZE*2-1)
{ {
cachesize=(uint) (end_of_file-seek_offset)+IO_SIZE*2-1; cache_myflags &= ~MY_DONT_CHECK_FILESIZE;
use_async_io=0; /* No nead to use async */ }
else
{
my_off_t file_pos,end_of_file;
if ((file_pos=my_tell(file,MYF(0)) == MY_FILEPOS_ERROR))
DBUG_RETURN(1);
end_of_file=my_seek(file,0L,MY_SEEK_END,MYF(0));
if (end_of_file < seek_offset)
end_of_file=seek_offset;
VOID(my_seek(file,file_pos,MY_SEEK_SET,MYF(0)));
if ((my_off_t) cachesize > end_of_file-seek_offset+IO_SIZE*2-1)
{
cachesize=(uint) (end_of_file-seek_offset)+IO_SIZE*2-1;
use_async_io=0; /* No nead to use async */
}
} }
} }
...@@ -545,7 +555,6 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count, ...@@ -545,7 +555,6 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count,
return error; return error;
} }
/* Flush write cache */ /* Flush write cache */
int flush_io_cache(IO_CACHE *info) int flush_io_cache(IO_CACHE *info)
...@@ -565,7 +574,9 @@ int flush_io_cache(IO_CACHE *info) ...@@ -565,7 +574,9 @@ int flush_io_cache(IO_CACHE *info)
length=(uint) (info->rc_pos - info->buffer); length=(uint) (info->rc_pos - info->buffer);
if (info->seek_not_done) if (info->seek_not_done)
{ /* File touched, do seek */ { /* File touched, do seek */
VOID(my_seek(info->file,info->pos_in_file,MY_SEEK_SET,MYF(0))); if (my_seek(info->file,info->pos_in_file,MY_SEEK_SET,MYF(0)) ==
MY_FILEPOS_ERROR)
DBUG_RETURN((info->error= -1));
info->seek_not_done=0; info->seek_not_done=0;
} }
info->rc_pos=info->buffer; info->rc_pos=info->buffer;
......
...@@ -21,74 +21,49 @@ ...@@ -21,74 +21,49 @@
#include <stdarg.h> #include <stdarg.h>
#include <m_ctype.h> #include <m_ctype.h>
int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
int my_vsnprintf(char* str, size_t n, const char* fmt, va_list ap)
{ {
uint olen = 0, plen; char *start=to, *end=to+n-1;
const char *tpos;
reg1 char *endpos;
reg2 char * par;
char* ebuff = str;
endpos=ebuff;
tpos = fmt;
while (*tpos) for (; *fmt ; fmt++)
{ {
if (tpos[0] != '%') if (fmt[0] != '%')
{ {
if(olen + 1 >= n) if (to == end) /* End of buffer */
break; break;
*to++= *fmt; /* Copy ordinary char */
*endpos++= *tpos++; /* Copy ordinary char */
olen++;
continue; continue;
} }
if (*++tpos == '%') /* test if %% */ /* Skipp if max size is used (to be compatible with printf) */
{ while (isdigit(*fmt) || *fmt == '.' || *fmt == '-')
olen--; fmt++;
} if (*fmt == 's') /* String parameter */
else
{ {
/* Skipp if max size is used (to be compatible with printf) */ reg2 char *par = va_arg(ap, char *);
while (isdigit(*tpos) || *tpos == '.' || *tpos == '-') uint plen = (uint) strlen(par);
tpos++; if ((uint) (end-to) > plen) /* Replace if possible */
if (*tpos == 's') /* String parameter */
{
par = va_arg(ap, char *);
plen = (uint) strlen(par);
if (olen + plen < n) /* Replace if possible */
{
endpos=strmov(endpos,par);
tpos++;
olen+=plen;
continue;
}
}
else if (*tpos == 'd' || *tpos == 'u') /* Integer parameter */
{ {
register int iarg; to=strmov(to,par);
iarg = va_arg(ap, int); continue;
if(olen + 16 >= n) break;
if (*tpos == 'd')
plen= (uint) (int2str((long) iarg,endpos, -10) - endpos);
else
plen= (uint) (int2str((long) (uint) iarg,endpos,10)- endpos);
if (olen + plen < n) /* Replace parameter if possible */
{
endpos+=plen;
tpos++;
olen+=plen;
continue;
}
} }
} }
*endpos++='%'; /* % used as % or unknown code */ else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */
{
register int iarg;
if ((uint) (end-to) < 16)
break;
iarg = va_arg(ap, int);
if (*fmt == 'd')
to=int10_to_str((long) iarg,to, -10);
else
to=int10_to_str((long) (uint) iarg,to,10);
continue;
}
/* We come here on '%%', unknown code or too long parameter */
if (to == end)
break;
*to++='%'; /* % used as % or unknown code */
} }
*endpos='\0'; *to='\0'; /* End of errmessage */
/* End of errmessage */ return (uint) (to - start);
return olen;
} }
...@@ -28,10 +28,13 @@ parse_arguments() { ...@@ -28,10 +28,13 @@ parse_arguments() {
--socket=*) MYSQL_UNIX_PORT=`echo "$arg" | sed -e "s;--socket=;;"` ;; --socket=*) MYSQL_UNIX_PORT=`echo "$arg" | sed -e "s;--socket=;;"` ;;
--port=*) MYSQL_TCP_PORT=`echo "$arg" | sed -e "s;--port=;;"` ;; --port=*) MYSQL_TCP_PORT=`echo "$arg" | sed -e "s;--port=;;"` ;;
--log=*) log=`echo "$arg" | sed -e "s;--log=;;"` ;; --log=*) log=`echo "$arg" | sed -e "s;--log=;;"` ;;
--err-log=*) err_log=`echo "$arg" | sed -e "s;--err-log=;;"` ;;
--basedir=*) MY_BASEDIR_VERSION=`echo "$arg" | sed -e "s;--basedir=;;"` ;; --basedir=*) MY_BASEDIR_VERSION=`echo "$arg" | sed -e "s;--basedir=;;"` ;;
--ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;;
--user=*) user=`echo "$arg" | sed -e "s;--user=;;"` ;; --user=*) user=`echo "$arg" | sed -e "s;--user=;;"` ;;
--ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;;
--err-log=*) err_log=`echo "$arg" | sed -e "s;--err-log=;;"` ;;
--open-files=*) open_files=`echo "$arg" | sed -e "s;--open-files=;;"` ;;
--core-file-size*) core_file_size=`echo "$arg" | sed -e "s;--core_file_size=;;"` ;;
--timezone=*) TZ=`echo "$arg" | sed -e "s;--timezone=;;"` ; export TZ; ;;
esac esac
done done
} }
...@@ -105,6 +108,14 @@ if test -w / ...@@ -105,6 +108,14 @@ if test -w /
then then
# If we are root, change the err log to the right user. # If we are root, change the err log to the right user.
touch $err_log; chown $user $err_log touch $err_log; chown $user $err_log
if test -n "$open_files"
then
ulimit -n $open_files
fi
if test -n "$core_file_size"
then
ulimit -c $core_file_size
fi
fi fi
# #
......
...@@ -339,6 +339,15 @@ sub end_benchmark ...@@ -339,6 +339,15 @@ sub end_benchmark
exit 0; exit 0;
} }
sub print_time
{
my ($estimated)=@_;
if ($estimated)
{ print "Estimated time"; }
else
{ print "Time"; }
}
# #
# Create a filename part for the machine that can be used for log file. # Create a filename part for the machine that can be used for log file.
# #
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
# "3-byte int" or "same as xxx". # "3-byte int" or "same as xxx".
$version="1.50"; $version="1.51";
use DBI; use DBI;
use Getopt::Long; use Getopt::Long;
...@@ -289,6 +289,11 @@ report("rename table","rename_table", ...@@ -289,6 +289,11 @@ report("rename table","rename_table",
$dbh->do("drop table crash_q1"); $dbh->do("drop table crash_q1");
$dbh->do("drop table crash_q"); $dbh->do("drop table crash_q");
report("truncate table","truncate_table",
"create table crash_q (a integer, b integer,c CHAR(10))",
"truncate table crash_q",
"drop table crash_q1");
if ($dbh->do("create table crash_q (a integer, b integer,c CHAR(10))") && if ($dbh->do("create table crash_q (a integer, b integer,c CHAR(10))") &&
$dbh->do("create table crash_q1 (a integer, b integer,c CHAR(10) not null)")) $dbh->do("create table crash_q1 (a integer, b integer,c CHAR(10) not null)"))
{ {
......
...@@ -270,7 +270,7 @@ for ($i=1 ; $i <= $small_loop_count ; $i++) ...@@ -270,7 +270,7 @@ for ($i=1 ; $i <= $small_loop_count ; $i++)
{ {
if (!$error++) if (!$error++)
{ {
print "Warning: Got $found_rows rows when selecting a hole table of " . ($total_rows) . " rows\nContact the database or DBD author!\n"; print "Warning: Got $found_rows rows when selecting a whole table of " . ($total_rows) . " rows\nContact the database or DBD author!\n";
} }
} }
$count+=$found_rows; $count+=$found_rows;
...@@ -280,44 +280,125 @@ $end_time=new Benchmark; ...@@ -280,44 +280,125 @@ $end_time=new Benchmark;
print "Time for select_big ($small_loop_count:$count): " . print "Time for select_big ($small_loop_count:$count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n"; timestr(timediff($end_time, $loop_time),"all") . "\n";
#
# Do a lot of different ORDER BY queries
#
$loop_time=new Benchmark; $loop_time=new Benchmark;
$estimated=0; $estimated=$rows=0;
$rows=0; for ($i=1 ; $i <= $small_loop_count ; $i++)
$count=0;
for ($i=1 ; $i <= $small_loop_count/2 ; $i++)
{ {
$rows+=fetch_all_rows($dbh,"select id from bench1 order by id",1); $rows+=fetch_all_rows($dbh,"select id from bench1 order by id",1);
$end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$i,$i,
$small_loop_count));
}
if ($estimated)
{ print "Estimated time"; }
else
{ print "Time"; }
print " for order_by_big_key ($small_loop_count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark;
$estimated=$rows=0;
for ($i=1 ; $i <= $small_loop_count ; $i++)
{
$rows+=fetch_all_rows($dbh,"select id from bench1 order by id desc",1); $rows+=fetch_all_rows($dbh,"select id from bench1 order by id desc",1);
$count+=2;
$end_time=new Benchmark; $end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$count, last if ($estimated=predict_query_time($loop_time,$end_time,\$i,$i,
$small_loop_count)); $small_loop_count));
} }
if ($estimated) if ($estimated)
{ print "Estimated time"; } { print "Estimated time"; }
else else
{ print "Time"; } { print "Time"; }
print " for order_by_key ($count:$rows): " . print " for order_by_big_key_desc ($small_loop_count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n"; timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark; $loop_time=new Benchmark;
$estimated=0; $estimated=$rows=0;
$rows=0; for ($i=1 ; $i <= $small_loop_count ; $i++)
$count=0;
for ($i=1 ; $i <= $small_loop_count/2 ; $i++)
{ {
$rows+=fetch_all_rows($dbh,"select id2 from bench1 order by id2",1); $rows+=fetch_all_rows($dbh,"select id3 from bench1 order by id3",1);
$rows+=fetch_all_rows($dbh,"select id2 from bench1 order by id2 desc",1);
$count+=2;
$end_time=new Benchmark; $end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$count, last if ($estimated=predict_query_time($loop_time,$end_time,\$i,$i,
$small_loop_count));
}
if ($estimated)
{ print "Estimated time"; }
else
{ print "Time"; }
print " for order_by_big_key2 ($small_loop_count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark;
$estimated=$rows=0;
for ($i=1 ; $i <= $small_loop_count ; $i++)
{
$rows+=fetch_all_rows($dbh,"select id2 from bench1 order by id3",1);
$end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$i,$i,
$small_loop_count)); $small_loop_count));
} }
if ($estimated) if ($estimated)
{ print "Estimated time"; } { print "Estimated time"; }
else else
{ print "Time"; } { print "Time"; }
print " for order_by ($count:$rows): " . print " for order_by_big_key_diff ($small_loop_count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark;
$estimated=$rows=0;
for ($i=1 ; $i <= $small_loop_count ; $i++)
{
$rows+=fetch_all_rows($dbh,"select id from bench1 order by id2,id3",1);
$end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$i,$i,
$small_loop_count));
}
if ($estimated)
{ print "Estimated time"; }
else
{ print "Time"; }
print " for order_by_big ($small_loop_count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark;
$estimated=$rows=0;
for ($i=1 ; $i <= $small_loop_count ; $i++)
{
$start=$opt_loop_count/$small_loop_count*$i;
$end=$start+$i;
$rows+=fetch_all_rows($dbh,"select dummy1 from bench1 where id>=$start and id <= $end order by id",1);
$end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$i,$i,
$small_loop_count));
}
if ($estimated)
{ print "Estimated time"; }
else
{ print "Time"; }
print " for order_by_key ($small_loop_count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark;
$estimated=$rows=0;
for ($i=1 ; $i <= $small_loop_count ; $i++)
{
$start=$opt_loop_count/$small_loop_count*$i;
$end=$start+$small_loop_count;
$rows+=fetch_all_rows($dbh,"select id2 from bench1 where id3>=$start and id3 <= $end order by id3",1);
$end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$i,$i,
$small_loop_count));
}
if ($estimated)
{ print "Estimated time"; }
else
{ print "Time"; }
print " for order_by_key2_diff ($small_loop_count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n"; timestr(timediff($end_time, $loop_time),"all") . "\n";
# #
...@@ -417,6 +498,7 @@ if ($limits->{'group_functions'}) ...@@ -417,6 +498,7 @@ if ($limits->{'group_functions'})
$loop_time=new Benchmark; $loop_time=new Benchmark;
$count=1; $count=1;
$estimated=0;
for ($tests=0 ; $tests < $small_loop_count ; $tests++) for ($tests=0 ; $tests < $small_loop_count ; $tests++)
{ {
$sth=$dbh->prepare($query="select count(*) from bench1") or die $DBI::errstr; $sth=$dbh->prepare($query="select count(*) from bench1") or die $DBI::errstr;
...@@ -492,9 +574,12 @@ if ($limits->{'group_functions'}) ...@@ -492,9 +574,12 @@ if ($limits->{'group_functions'})
print "Warning: '$query' returned wrong number of rows\n"; print "Warning: '$query' returned wrong number of rows\n";
} }
} }
$end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$tests,
$small_loop_count));
} }
$end_time=new Benchmark; print_time($estimated);
print "Time for select_group ($count): " . print " for select_group ($count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n"; timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark; $loop_time=new Benchmark;
......
...@@ -205,10 +205,7 @@ for ($i=0 ; $i < $opt_small_loop_count ; $i++) ...@@ -205,10 +205,7 @@ for ($i=0 ; $i < $opt_small_loop_count ; $i++)
$opt_small_loop_count)); $opt_small_loop_count));
} }
if ($estimated) print_time($estimated);
{ print "Estimated time"; }
else
{ print "Time"; }
print " for select_range ($count:$rows): " . print " for select_range ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n"; timestr(timediff($end_time, $loop_time),"all") . "\n";
...@@ -243,10 +240,7 @@ if ($limits->{'group_functions'}) ...@@ -243,10 +240,7 @@ if ($limits->{'group_functions'})
last if ($estimated=predict_query_time($loop_time,$end_time,\$count, last if ($estimated=predict_query_time($loop_time,$end_time,\$count,
$tests+1, $opt_loop_count)); $tests+1, $opt_loop_count));
} }
if ($estimated) print_time($estimated);
{ print "Estimated time"; }
else
{ print "Time"; }
print " for min_max_on_key ($count): " . print " for min_max_on_key ($count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n"; timestr(timediff($end_time, $loop_time),"all") . "\n";
...@@ -267,10 +261,7 @@ if ($limits->{'group_functions'}) ...@@ -267,10 +261,7 @@ if ($limits->{'group_functions'})
last if ($estimated=predict_query_time($loop_time,$end_time,\$count, last if ($estimated=predict_query_time($loop_time,$end_time,\$count,
$tests+1, $opt_loop_count)); $tests+1, $opt_loop_count));
} }
if ($estimated) print_time($estimated);
{ print "Estimated time"; }
else
{ print "Time"; }
print " for count_on_key ($count): " . print " for count_on_key ($count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n\n"; timestr(timediff($end_time, $loop_time),"all") . "\n\n";
...@@ -278,7 +269,7 @@ if ($limits->{'group_functions'}) ...@@ -278,7 +269,7 @@ if ($limits->{'group_functions'})
$rows=0; $rows=0;
for ($i=0 ; $i < $opt_medium_loop_count ; $i++) for ($i=0 ; $i < $opt_medium_loop_count ; $i++)
{ {
fetch_all_rows($dbh,"select grp,count(*) from bench1 group by grp"); $rows+=fetch_all_rows($dbh,"select grp,count(*) from bench1 group by grp");
} }
$end_time=new Benchmark; $end_time=new Benchmark;
print "Time for count_group_on_key_parts ($i:$rows): " . print "Time for count_group_on_key_parts ($i:$rows): " .
...@@ -289,54 +280,74 @@ if ($limits->{'group_functions'}) ...@@ -289,54 +280,74 @@ if ($limits->{'group_functions'})
{ {
print "Testing count(distinct) on the table\n"; print "Testing count(distinct) on the table\n";
$loop_time=new Benchmark; $loop_time=new Benchmark;
$rows=0; $rows=$estimated=$count=0;
for ($i=0 ; $i < $opt_medium_loop_count ; $i++) for ($i=0 ; $i < $opt_medium_loop_count ; $i++)
{ {
$count+=2;
$rows+=fetch_all_rows($dbh,"select count(distinct region) from bench1"); $rows+=fetch_all_rows($dbh,"select count(distinct region) from bench1");
$rows+=fetch_all_rows($dbh,"select count(distinct grp) from bench1"); $rows+=fetch_all_rows($dbh,"select count(distinct grp) from bench1");
$end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i+1,
$opt_medium_loop_count));
} }
$end_time=new Benchmark; print_time($estimated);
print "Time for count_distinct ($i:$rows): " . print " for count_distinct ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n"; timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark; $loop_time=new Benchmark;
$rows=0; $rows=$estimated=$count=0;
for ($i=0 ; $i < $opt_medium_loop_count ; $i++) for ($i=0 ; $i < $opt_medium_loop_count ; $i++)
{ {
$count++;
$rows+=fetch_all_rows($dbh,"select region,count(distinct idn) from bench1 group by region"); $rows+=fetch_all_rows($dbh,"select region,count(distinct idn) from bench1 group by region");
$end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i+1,
$opt_medium_loop_count));
} }
$end_time=new Benchmark; print_time($estimated);
print "Time for count_distinct_group_on_key ($i:$rows): " . print " for count_distinct_group_on_key ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n"; timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark; $loop_time=new Benchmark;
$rows=0; $rows=$estimated=$count=0;
for ($i=0 ; $i < $opt_medium_loop_count ; $i++) for ($i=0 ; $i < $opt_medium_loop_count ; $i++)
{ {
$count++;
$rows+=fetch_all_rows($dbh,"select grp,count(distinct idn) from bench1 group by grp"); $rows+=fetch_all_rows($dbh,"select grp,count(distinct idn) from bench1 group by grp");
$end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i+1,
$opt_medium_loop_count));
} }
$end_time=new Benchmark; print_time($estimated);
print "Time for count_distinct_group_on_key_parts ($i:$rows): " . print " for count_distinct_group_on_key_parts ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n"; timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark; $loop_time=new Benchmark;
$rows=0; $rows=$estimated=$count=0;
for ($i=0 ; $i < $opt_medium_loop_count ; $i++) for ($i=0 ; $i < $opt_medium_loop_count ; $i++)
{ {
$count++;
$rows+=fetch_all_rows($dbh,"select grp,count(distinct rev_idn) from bench1 group by grp"); $rows+=fetch_all_rows($dbh,"select grp,count(distinct rev_idn) from bench1 group by grp");
$end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i+1,
$opt_medium_loop_count));
} }
$end_time=new Benchmark; print_time($estimated);
print "Time for count_distinct_group ($i:$rows): " . print " for count_distinct_group ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n"; timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark; $loop_time=new Benchmark;
$rows=0; $rows=$estimated=$count=0;
for ($i=0 ; $i < $opt_medium_loop_count ; $i++) for ($i=0 ; $i < $opt_medium_loop_count ; $i++)
{ {
$count++;
$rows+=fetch_all_rows($dbh,"select idn,count(distinct region) from bench1 group by idn"); $rows+=fetch_all_rows($dbh,"select idn,count(distinct region) from bench1 group by idn");
$end_time=new Benchmark;
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i+1,
$opt_medium_loop_count));
} }
$end_time=new Benchmark; print_time($estimated);
print "Time for count_distinct_big ($i:$rows): " . print " for count_distinct_big ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n"; timestr(timediff($end_time, $loop_time),"all") . "\n";
} }
......
...@@ -38,8 +38,8 @@ if (my_b_write((file),(byte*) (from),param->ref_length)) \ ...@@ -38,8 +38,8 @@ if (my_b_write((file),(byte*) (from),param->ref_length)) \
typedef struct st_buffpek { /* Struktur om sorteringsbuffrarna */ typedef struct st_buffpek { /* Struktur om sorteringsbuffrarna */
my_off_t file_pos; /* Where we are in the sort file */ my_off_t file_pos; /* Where we are in the sort file */
ha_rows count; /* Number of rows in table */
uchar *base,*key; /* key pointers */ uchar *base,*key; /* key pointers */
ha_rows count; /* Number of rows in table */
ulong mem_count; /* numbers of keys in memory */ ulong mem_count; /* numbers of keys in memory */
ulong max_keys; /* Max keys in buffert */ ulong max_keys; /* Max keys in buffert */
} BUFFPEK; } BUFFPEK;
...@@ -98,7 +98,6 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length, ...@@ -98,7 +98,6 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
BUFFPEK *buffpek; BUFFPEK *buffpek;
ha_rows records; ha_rows records;
uchar **sort_keys; uchar **sort_keys;
gptr save_1,save_2;
IO_CACHE tempfile,*selected_records_file,*outfile; IO_CACHE tempfile,*selected_records_file,*outfile;
SORTPARAM param; SORTPARAM param;
DBUG_ENTER("filesort"); DBUG_ENTER("filesort");
...@@ -109,7 +108,6 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length, ...@@ -109,7 +108,6 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
outfile= table[0]->io_cache; outfile= table[0]->io_cache;
my_b_clear(&tempfile); my_b_clear(&tempfile);
save_1=save_2=0;
buffpek= (BUFFPEK *) NULL; sort_keys= (uchar **) NULL; error= 1; buffpek= (BUFFPEK *) NULL; sort_keys= (uchar **) NULL; error= 1;
maxbuffer=1; maxbuffer=1;
param.ref_length= table[0]->file->ref_length; param.ref_length= table[0]->file->ref_length;
...@@ -148,7 +146,7 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length, ...@@ -148,7 +146,7 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
else else
{ {
table[0]->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);/* Get record-count */ table[0]->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);/* Get record-count */
records=table[0]->file->records+EXTRA_RECORDS; records=table[0]->file->estimate_number_of_rows();
selected_records_file= 0; selected_records_file= 0;
} }
if (param.sort_length == param.ref_length && records > param.max_rows) if (param.sort_length == param.ref_length && records > param.max_rows)
...@@ -160,16 +158,11 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length, ...@@ -160,16 +158,11 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
goto err; goto err;
#endif #endif
/* Reserve memory for IO_CACHE files */
if (! (save_1=my_malloc(DISK_BUFFER_SIZE,MYF(MY_WME))) ||
! (save_2=my_malloc(DISK_BUFFER_SIZE,MYF(MY_WME))))
goto err;
memavl=sortbuff_size; memavl=sortbuff_size;
while (memavl >= MIN_SORT_MEMORY) while (memavl >= MIN_SORT_MEMORY)
{ {
if ((records+1)*(param.sort_length+sizeof(char*))+sizeof(BUFFPEK)*10 < if ((ulonglong) (records+1)*(param.sort_length+sizeof(char*))+sizeof(BUFFPEK)*10 <
(ulong) memavl) (ulonglong) memavl)
param.keys=(uint) records+1; param.keys=(uint) records+1;
else else
{ {
...@@ -207,10 +200,6 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length, ...@@ -207,10 +200,6 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
my_error(ER_OUTOFMEMORY,MYF(ME_ERROR+ME_WAITTANG),sortbuff_size); my_error(ER_OUTOFMEMORY,MYF(ME_ERROR+ME_WAITTANG),sortbuff_size);
goto err; goto err;
} }
my_free(save_1,MYF(0)); /* Free for later use */
my_free(save_2,MYF(0));
save_1=save_2=0;
param.sort_form= table[0]; param.sort_form= table[0];
param.end=(param.local_sortorder=sortorder)+s_length; param.end=(param.local_sortorder=sortorder)+s_length;
if ((records=find_all_keys(&param,select,sort_keys,buffpek,&maxbuffer, if ((records=find_all_keys(&param,select,sort_keys,buffpek,&maxbuffer,
...@@ -252,8 +241,6 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length, ...@@ -252,8 +241,6 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
#endif #endif
x_free((gptr) sort_keys); x_free((gptr) sort_keys);
x_free((gptr) buffpek); x_free((gptr) buffpek);
x_free(save_1);
x_free(save_2);
close_cached_file(&tempfile); close_cached_file(&tempfile);
if (my_b_inited(outfile)) if (my_b_inited(outfile))
{ {
...@@ -382,6 +369,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, ...@@ -382,6 +369,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
} }
if (*killed) if (*killed)
{ {
DBUG_PRINT("info",("Sort killed by user"));
(void) file->extra(HA_EXTRA_NO_CACHE); (void) file->extra(HA_EXTRA_NO_CACHE);
file->rnd_end(); file->rnd_end();
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */ DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
......
...@@ -25,8 +25,9 @@ ...@@ -25,8 +25,9 @@
We will need an updated Berkeley DB version for this. We will need an updated Berkeley DB version for this.
- Killing threads that has got a 'deadlock' - Killing threads that has got a 'deadlock'
- SHOW TABLE STATUS should give more information about the table. - SHOW TABLE STATUS should give more information about the table.
- Get a more accurate count of the number of rows. - Get a more accurate count of the number of rows (estimate_number_of_rows()).
We could store the found number of rows when the table is scanned. We could store the found number of rows when the table is scanned and
then increment the counter for each attempted write.
- We will need a manager thread that calls flush_logs, removes old - We will need a manager thread that calls flush_logs, removes old
logs and makes checkpoints at given intervals. logs and makes checkpoints at given intervals.
- When not using UPDATE IGNORE, don't make a sub transaction but abort - When not using UPDATE IGNORE, don't make a sub transaction but abort
...@@ -42,7 +43,6 @@ ...@@ -42,7 +43,6 @@
- LOCK TABLES - LOCK TABLES
- CHAR keys - CHAR keys
- BLOBS - BLOBS
- delete from t1;
*/ */
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#define HA_BERKELEY_ROWS_IN_TABLE 10000 /* to get optimization right */ #define HA_BERKELEY_ROWS_IN_TABLE 10000 /* to get optimization right */
#define HA_BERKELEY_RANGE_COUNT 100 #define HA_BERKELEY_RANGE_COUNT 100
#define HA_BERKELEY_MAX_ROWS 10000000 /* Max rows in table */
const char *ha_berkeley_ext=".db"; const char *ha_berkeley_ext=".db";
bool berkeley_skip=0; bool berkeley_skip=0;
...@@ -1297,7 +1298,7 @@ void ha_berkeley::info(uint flag) ...@@ -1297,7 +1298,7 @@ void ha_berkeley::info(uint flag)
DBUG_ENTER("info"); DBUG_ENTER("info");
if (flag & HA_STATUS_VARIABLE) if (flag & HA_STATUS_VARIABLE)
{ {
records = HA_BERKELEY_ROWS_IN_TABLE; // Just to get optimisations right records = estimate_number_of_rows(); // Just to get optimisations right
deleted = 0; deleted = 0;
} }
else if (flag & HA_STATUS_ERRKEY) else if (flag & HA_STATUS_ERRKEY)
...@@ -1607,4 +1608,21 @@ void ha_berkeley::update_auto_primary_key() ...@@ -1607,4 +1608,21 @@ void ha_berkeley::update_auto_primary_key()
pthread_mutex_unlock(&share->mutex); pthread_mutex_unlock(&share->mutex);
} }
/*
Return an estimated of the number of rows in the table.
Used when sorting to allocate buffers and by the optimizer.
*/
ha_rows ha_berkeley::estimate_number_of_rows()
{
ulonglong max_ident;
ulonglong max_rows=table->max_rows ? table->max_rows : HA_BERKELEY_MAX_ROWS;
if (!hidden_primary_key)
return (ha_rows) max_rows;
pthread_mutex_lock(&share->mutex);
max_ident=share->auto_ident+EXTRA_RECORDS;
pthread_mutex_unlock(&share->mutex);
return (ha_rows) min(max_ident,max_rows);
}
#endif /* HAVE_BERKELEY_DB */ #endif /* HAVE_BERKELEY_DB */
...@@ -91,7 +91,8 @@ class ha_berkeley: public handler ...@@ -91,7 +91,8 @@ class ha_berkeley: public handler
uint max_keys() const { return MAX_KEY-1; } uint max_keys() const { return MAX_KEY-1; }
uint max_key_parts() const { return MAX_REF_PARTS; } uint max_key_parts() const { return MAX_REF_PARTS; }
uint max_key_length() const { return MAX_KEY_LENGTH; } uint max_key_length() const { return MAX_KEY_LENGTH; }
uint extra_rec_buf_length() { return BDB_HIDDEN_PRIMARY_KEY_LENGTH; } uint extra_rec_buf_length() { return BDB_HIDDEN_PRIMARY_KEY_LENGTH; }
ha_rows estimate_number_of_rows();
bool fast_key_read() { return 1;} bool fast_key_read() { return 1;}
bool has_transactions() { return 1;} bool has_transactions() { return 1;}
......
...@@ -203,6 +203,7 @@ class handler :public Sql_alloc ...@@ -203,6 +203,7 @@ class handler :public Sql_alloc
virtual bool fast_key_read() { return 0;} virtual bool fast_key_read() { return 0;}
virtual bool has_transactions(){ return 0;} virtual bool has_transactions(){ return 0;}
virtual uint extra_rec_buf_length() { return 0; } virtual uint extra_rec_buf_length() { return 0; }
virtual ha_rows estimate_number_of_rows() { return records+EXTRA_RECORDS; }
virtual int index_init(uint idx) { active_index=idx; return 0;} virtual int index_init(uint idx) { active_index=idx; return 0;}
virtual int index_end() {return 0; } virtual int index_end() {return 0; }
......
...@@ -352,11 +352,6 @@ Item *create_func_to_days(Item* a) ...@@ -352,11 +352,6 @@ Item *create_func_to_days(Item* a)
return new Item_func_to_days(a); return new Item_func_to_days(a);
} }
Item *create_func_truncate (Item *a, Item *b)
{
return new Item_func_round(a,b,1);
}
Item *create_func_ucase(Item* a) Item *create_func_ucase(Item* a)
{ {
return new Item_func_ucase(a); return new Item_func_ucase(a);
......
...@@ -81,7 +81,6 @@ Item *create_func_tan(Item* a);; ...@@ -81,7 +81,6 @@ Item *create_func_tan(Item* a);;
Item *create_func_time_format(Item *a, Item *b); Item *create_func_time_format(Item *a, Item *b);
Item *create_func_time_to_sec(Item* a); Item *create_func_time_to_sec(Item* a);
Item *create_func_to_days(Item* a); Item *create_func_to_days(Item* a);
Item *create_func_truncate (Item *a, Item *b);
Item *create_func_ucase(Item* a); Item *create_func_ucase(Item* a);
Item *create_func_version(void); Item *create_func_version(void);
Item *create_func_weekday(Item* a); Item *create_func_weekday(Item* a);
......
...@@ -1598,7 +1598,7 @@ String *Item_load_file::val_str(String *str) ...@@ -1598,7 +1598,7 @@ String *Item_load_file::val_str(String *str)
if (!(file_name= args[0]->val_str(str)) || if (!(file_name= args[0]->val_str(str)) ||
!(current_thd->master_access & FILE_ACL) || !(current_thd->master_access & FILE_ACL) ||
!my_stat(file_name->c_ptr(), &stat_info, MYF(MY_FAE))) !my_stat(file_name->c_ptr(), &stat_info, MYF(MY_WME)))
goto err; goto err;
if (!(stat_info.st_mode & S_IROTH)) if (!(stat_info.st_mode & S_IROTH))
{ {
......
...@@ -302,6 +302,7 @@ static SYMBOL symbols[] = { ...@@ -302,6 +302,7 @@ static SYMBOL symbols[] = {
{ "TINYTEXT", SYM(TINYTEXT),0,0}, { "TINYTEXT", SYM(TINYTEXT),0,0},
{ "TINYINT", SYM(TINYINT),0,0}, { "TINYINT", SYM(TINYINT),0,0},
{ "TRAILING", SYM(TRAILING),0,0}, { "TRAILING", SYM(TRAILING),0,0},
{ "TRUNCATE", SYM(TRUNCATE_SYM),0,0},
{ "TO", SYM(TO_SYM),0,0}, { "TO", SYM(TO_SYM),0,0},
{ "TYPE", SYM(TYPE_SYM),0,0}, { "TYPE", SYM(TYPE_SYM),0,0},
{ "UNION", SYM(UNION_SYM),0,0}, { "UNION", SYM(UNION_SYM),0,0},
...@@ -443,7 +444,6 @@ static SYMBOL sql_functions[] = { ...@@ -443,7 +444,6 @@ static SYMBOL sql_functions[] = {
{ "TIME_TO_SEC", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_time_to_sec)}, { "TIME_TO_SEC", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_time_to_sec)},
{ "TO_DAYS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_to_days)}, { "TO_DAYS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_to_days)},
{ "TRIM", SYM(TRIM),0,0}, { "TRIM", SYM(TRIM),0,0},
{ "TRUNCATE", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_truncate )},
{ "UCASE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)}, { "UCASE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)},
{ "UPPER", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)}, { "UPPER", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)},
{ "UNIQUE_USERS", SYM(UNIQUE_USERS),0,0}, { "UNIQUE_USERS", SYM(UNIQUE_USERS),0,0},
......
...@@ -70,8 +70,8 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count) ...@@ -70,8 +70,8 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
thd->proc_info="Waiting for table"; thd->proc_info="Waiting for table";
pthread_mutex_unlock(&thd->mysys_var->mutex); pthread_mutex_unlock(&thd->mysys_var->mutex);
while (global_read_lock && ! thd->killed || while (global_read_lock && ! thd->killed &&
thd->version != refresh_version) thd->version == refresh_version)
{ {
(void) pthread_cond_wait(&COND_refresh,&LOCK_open); (void) pthread_cond_wait(&COND_refresh,&LOCK_open);
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -65,9 +65,9 @@ class Log_event ...@@ -65,9 +65,9 @@ class Log_event
int valid_exec_time; // if false, the exec time setting is bogus int valid_exec_time; // if false, the exec time setting is bogus
uint32 server_id; uint32 server_id;
int write(FILE* file); int write(IO_CACHE* file);
int write_header(FILE* file); int write_header(IO_CACHE* file);
virtual int write_data(FILE* file __attribute__((unused))) { return 0; } virtual int write_data(IO_CACHE* file __attribute__((unused))) { return 0; }
virtual Log_event_type get_type_code() = 0; virtual Log_event_type get_type_code() = 0;
Log_event(time_t when_arg, ulong exec_time_arg = 0, Log_event(time_t when_arg, ulong exec_time_arg = 0,
int valid_exec_time_arg = 0, uint32 server_id = 0): when(when_arg), int valid_exec_time_arg = 0, uint32 server_id = 0): when(when_arg),
...@@ -92,11 +92,11 @@ class Log_event ...@@ -92,11 +92,11 @@ class Log_event
void print_header(FILE* file); void print_header(FILE* file);
// if mutex is 0, the read will proceed without mutex // if mutex is 0, the read will proceed without mutex
static Log_event* read_log_event(FILE* file, pthread_mutex_t* log_lock); static Log_event* read_log_event(IO_CACHE* file, pthread_mutex_t* log_lock);
static Log_event* read_log_event(const char* buf, int event_len); static Log_event* read_log_event(const char* buf, int event_len);
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
static int read_log_event(FILE* file, String* packet, static int read_log_event(IO_CACHE* file, String* packet,
pthread_mutex_t* log_lock); pthread_mutex_t* log_lock);
#endif #endif
...@@ -132,18 +132,18 @@ class Query_log_event: public Log_event ...@@ -132,18 +132,18 @@ class Query_log_event: public Log_event
} }
#endif #endif
Query_log_event(FILE* file, time_t when, uint32 server_id); Query_log_event(IO_CACHE* file, time_t when, uint32 server_id);
Query_log_event(const char* buf, int event_len); Query_log_event(const char* buf, int event_len);
~Query_log_event() ~Query_log_event()
{ {
if (data_buf) if (data_buf)
{ {
my_free((gptr)data_buf, MYF(0)); my_free((gptr) data_buf, MYF(0));
} }
} }
Log_event_type get_type_code() { return QUERY_EVENT; } Log_event_type get_type_code() { return QUERY_EVENT; }
int write(FILE* file); int write(IO_CACHE* file);
int write_data(FILE* file); // returns 0 on success, -1 on error int write_data(IO_CACHE* file); // returns 0 on success, -1 on error
int get_data_size() int get_data_size()
{ {
return q_len + db_len + 2 + return q_len + db_len + 2 +
...@@ -183,6 +183,8 @@ class Load_log_event: public Log_event ...@@ -183,6 +183,8 @@ class Load_log_event: public Log_event
{ {
protected: protected:
char* data_buf; char* data_buf;
void Load_log_event::copy_log_event(const char *buf, ulong data_len);
public: public:
int thread_id; int thread_id;
uint32 table_name_len; uint32 table_name_len;
...@@ -272,17 +274,17 @@ class Load_log_event: public Log_event ...@@ -272,17 +274,17 @@ class Load_log_event: public Log_event
void set_fields(List<Item> &fields); void set_fields(List<Item> &fields);
#endif #endif
Load_log_event(FILE* file, time_t when, uint32 server_id); Load_log_event(IO_CACHE * file, time_t when, uint32 server_id);
Load_log_event(const char* buf, int event_len); Load_log_event(const char* buf, int event_len);
~Load_log_event() ~Load_log_event()
{ {
if (data_buf) if (data_buf)
{ {
my_free((gptr)data_buf, MYF(0)); my_free((gptr) data_buf, MYF(0));
} }
} }
Log_event_type get_type_code() { return LOAD_EVENT; } Log_event_type get_type_code() { return LOAD_EVENT; }
int write_data(FILE* file); // returns 0 on success, -1 on error int write_data(IO_CACHE* file); // returns 0 on success, -1 on error
int get_data_size() int get_data_size()
{ {
return table_name_len + 2 + db_len + 2 + fname_len return table_name_len + 2 + db_len + 2 + fname_len
...@@ -311,30 +313,26 @@ class Start_log_event: public Log_event ...@@ -311,30 +313,26 @@ class Start_log_event: public Log_event
created = (uint32) when; created = (uint32) when;
memcpy(server_version, ::server_version, sizeof(server_version)); memcpy(server_version, ::server_version, sizeof(server_version));
} }
Start_log_event(FILE* file, time_t when_arg, uint32 server_id) : Start_log_event(IO_CACHE* file, time_t when_arg, uint32 server_id) :
Log_event(when_arg, 0, 0, server_id) Log_event(when_arg, 0, 0, server_id)
{ {
char buf[sizeof(server_version) + sizeof(binlog_version) + char buf[sizeof(server_version) + sizeof(binlog_version) +
sizeof(created)]; sizeof(created)+4];
my_fseek(file, 4L, MY_SEEK_CUR, MYF(MY_WME)); // skip the event length if (my_b_read(file, (byte*) buf, sizeof(buf)))
if (my_fread(file, (byte*) buf, sizeof(buf), MYF(MY_NABP | MY_WME)))
return; return;
binlog_version = uint2korr(buf); binlog_version = uint2korr(buf+4);
memcpy(server_version, buf + 2, sizeof(server_version)); memcpy(server_version, buf + 6, sizeof(server_version));
created = uint4korr(buf + 2 + sizeof(server_version)); created = uint4korr(buf + 6 + sizeof(server_version));
} }
Start_log_event(const char* buf); Start_log_event(const char* buf);
~Start_log_event() {} ~Start_log_event() {}
Log_event_type get_type_code() { return START_EVENT;} Log_event_type get_type_code() { return START_EVENT;}
int write_data(FILE* file) int write_data(IO_CACHE* file)
{ {
if(my_fwrite(file, (byte*) &binlog_version, sizeof(binlog_version), if (my_b_write(file, (byte*) &binlog_version, sizeof(binlog_version)) ||
MYF(MY_NABP | MY_WME)) || my_b_write(file, (byte*) server_version, sizeof(server_version)) ||
my_fwrite(file, (byte*) server_version, sizeof(server_version), my_b_write(file, (byte*) &created, sizeof(created)))
MYF(MY_NABP | MY_WME)) ||
my_fwrite(file, (byte*) &created, sizeof(created),
MYF(MY_NABP | MY_WME)))
return -1; return -1;
return 0; return 0;
} }
...@@ -354,12 +352,12 @@ class Intvar_log_event: public Log_event ...@@ -354,12 +352,12 @@ class Intvar_log_event: public Log_event
Intvar_log_event(uchar type_arg, ulonglong val_arg) Intvar_log_event(uchar type_arg, ulonglong val_arg)
:Log_event(time(NULL)),val(val_arg),type(type_arg) :Log_event(time(NULL)),val(val_arg),type(type_arg)
{} {}
Intvar_log_event(FILE* file, time_t when, uint32 server_id); Intvar_log_event(IO_CACHE* file, time_t when, uint32 server_id);
Intvar_log_event(const char* buf); Intvar_log_event(const char* buf);
~Intvar_log_event() {} ~Intvar_log_event() {}
Log_event_type get_type_code() { return INTVAR_EVENT;} Log_event_type get_type_code() { return INTVAR_EVENT;}
int get_data_size() { return sizeof(type) + sizeof(val);} int get_data_size() { return sizeof(type) + sizeof(val);}
int write_data(FILE* file); int write_data(IO_CACHE* file);
void print(FILE* file, bool short_form = 0); void print(FILE* file, bool short_form = 0);
...@@ -370,10 +368,11 @@ class Stop_log_event: public Log_event ...@@ -370,10 +368,11 @@ class Stop_log_event: public Log_event
public: public:
Stop_log_event() :Log_event(time(NULL)) Stop_log_event() :Log_event(time(NULL))
{} {}
Stop_log_event(FILE* file, time_t when_arg, uint32 server_id): Stop_log_event(IO_CACHE* file, time_t when_arg, uint32 server_id):
Log_event(when_arg,0,0,server_id) Log_event(when_arg,0,0,server_id)
{ {
my_fseek(file, 4L, MY_SEEK_CUR, MYF(MY_WME)); // skip the event length char skip[4];
my_b_read(file, skip, sizeof(skip)); // skip the event length
} }
Stop_log_event(const char* buf):Log_event(buf) Stop_log_event(const char* buf):Log_event(buf)
{ {
...@@ -397,7 +396,7 @@ class Rotate_log_event: public Log_event ...@@ -397,7 +396,7 @@ class Rotate_log_event: public Log_event
alloced(0) alloced(0)
{} {}
Rotate_log_event(FILE* file, time_t when, uint32 server_id) ; Rotate_log_event(IO_CACHE* file, time_t when, uint32 server_id) ;
Rotate_log_event(const char* buf, int event_len); Rotate_log_event(const char* buf, int event_len);
~Rotate_log_event() ~Rotate_log_event()
{ {
...@@ -406,7 +405,7 @@ class Rotate_log_event: public Log_event ...@@ -406,7 +405,7 @@ class Rotate_log_event: public Log_event
} }
Log_event_type get_type_code() { return ROTATE_EVENT;} Log_event_type get_type_code() { return ROTATE_EVENT;}
int get_data_size() { return ident_len;} int get_data_size() { return ident_len;}
int write_data(FILE* file); int write_data(IO_CACHE* file);
void print(FILE* file, bool short_form = 0); void print(FILE* file, bool short_form = 0);
}; };
......
...@@ -32,17 +32,19 @@ ...@@ -32,17 +32,19 @@
#define MAP_TO_USE_RAID #define MAP_TO_USE_RAID
#include "mysql_priv.h" #include "mysql_priv.h"
#include <mysys_err.h>
#ifdef HAVE_AIOWAIT #ifdef HAVE_AIOWAIT
#include <mysys_err.h>
#include <errno.h> #include <errno.h>
static void my_aiowait(my_aio_result *result); static void my_aiowait(my_aio_result *result);
#endif #endif
/* if cachesize == 0 then use default cachesize (from s-file) */
/* returns 0 if we have enough memory */
extern "C" { extern "C" {
/*
** if cachesize == 0 then use default cachesize (from s-file)
** if file == -1 then real_open_cached_file() will be called.
** returns 0 if ok
*/
int init_io_cache(IO_CACHE *info, File file, uint cachesize, int init_io_cache(IO_CACHE *info, File file, uint cachesize,
enum cache_type type, my_off_t seek_offset, enum cache_type type, my_off_t seek_offset,
...@@ -60,20 +62,26 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, ...@@ -60,20 +62,26 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
min_cache=use_async_io ? IO_SIZE*4 : IO_SIZE*2; min_cache=use_async_io ? IO_SIZE*4 : IO_SIZE*2;
if (type == READ_CACHE) if (type == READ_CACHE)
{ /* Assume file isn't growing */ { /* Assume file isn't growing */
my_off_t file_pos,end_of_file; if (cache_myflags & MY_DONT_CHECK_FILESIZE)
if ((file_pos=my_tell(file,MYF(0)) == MY_FILEPOS_ERROR)) {
DBUG_RETURN(1); cache_myflags &= ~MY_DONT_CHECK_FILESIZE;
end_of_file=my_seek(file,0L,MY_SEEK_END,MYF(0)); }
if (end_of_file < seek_offset) else
end_of_file=seek_offset;
VOID(my_seek(file,file_pos,MY_SEEK_SET,MYF(0)));
if ((my_off_t) cachesize > end_of_file-seek_offset+IO_SIZE*2-1)
{ {
cachesize=(uint) (end_of_file-seek_offset)+IO_SIZE*2-1; my_off_t file_pos,end_of_file;
use_async_io=0; /* No nead to use async */ if ((file_pos=my_tell(file,MYF(0)) == MY_FILEPOS_ERROR))
DBUG_RETURN(1);
end_of_file=my_seek(file,0L,MY_SEEK_END,MYF(0));
if (end_of_file < seek_offset)
end_of_file=seek_offset;
VOID(my_seek(file,file_pos,MY_SEEK_SET,MYF(0)));
if ((my_off_t) cachesize > end_of_file-seek_offset+IO_SIZE*2-1)
{
cachesize=(uint) (end_of_file-seek_offset)+IO_SIZE*2-1;
use_async_io=0; /* No nead to use async */
}
} }
} }
if ((int) type < (int) READ_NET) if ((int) type < (int) READ_NET)
{ {
for (;;) for (;;)
...@@ -167,7 +175,8 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, ...@@ -167,7 +175,8 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
DBUG_ENTER("reinit_io_cache"); DBUG_ENTER("reinit_io_cache");
info->seek_not_done= test(info->file >= 0); /* Seek not done */ info->seek_not_done= test(info->file >= 0); /* Seek not done */
if (!clear_cache && seek_offset >= info->pos_in_file && if (! clear_cache &&
seek_offset >= info->pos_in_file &&
seek_offset <= info->pos_in_file + seek_offset <= info->pos_in_file +
(uint) (info->rc_end - info->rc_request_pos)) (uint) (info->rc_end - info->rc_request_pos))
{ /* use current buffer */ { /* use current buffer */
...@@ -231,6 +240,7 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count) ...@@ -231,6 +240,7 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
{ {
uint length,diff_length,left_length; uint length,diff_length,left_length;
my_off_t max_length, pos_in_file; my_off_t max_length, pos_in_file;
memcpy(Buffer,info->rc_pos, memcpy(Buffer,info->rc_pos,
(size_t) (left_length=(uint) (info->rc_end-info->rc_pos))); (size_t) (left_length=(uint) (info->rc_end-info->rc_pos)));
Buffer+=left_length; Buffer+=left_length;
...@@ -607,7 +617,9 @@ int flush_io_cache(IO_CACHE *info) ...@@ -607,7 +617,9 @@ int flush_io_cache(IO_CACHE *info)
length=(uint) (info->rc_pos - info->buffer); length=(uint) (info->rc_pos - info->buffer);
if (info->seek_not_done) if (info->seek_not_done)
{ /* File touched, do seek */ { /* File touched, do seek */
VOID(my_seek(info->file,info->pos_in_file,MY_SEEK_SET,MYF(0))); if (my_seek(info->file,info->pos_in_file,MY_SEEK_SET,MYF(0)) ==
MY_FILEPOS_ERROR)
DBUG_RETURN((info->error= -1));
info->seek_not_done=0; info->seek_not_done=0;
} }
info->rc_pos=info->buffer; info->rc_pos=info->buffer;
...@@ -644,4 +656,4 @@ int end_io_cache(IO_CACHE *info) ...@@ -644,4 +656,4 @@ int end_io_cache(IO_CACHE *info)
DBUG_RETURN(error); DBUG_RETURN(error);
} /* end_io_cache */ } /* end_io_cache */
} } /* extern "C" */
This diff is collapsed.
...@@ -131,7 +131,7 @@ extern "C" int gethostname(char *name, int namelen); ...@@ -131,7 +131,7 @@ extern "C" int gethostname(char *name, int namelen);
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char* default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace", static const char* default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace",
"d:t:i:o,/tmp/mysqld.trace"); "d:t:i:o,/tmp/mysqld.trace");
#endif #endif
#ifdef __NT__ #ifdef __NT__
...@@ -157,7 +157,7 @@ static pthread_t select_thread; ...@@ -157,7 +157,7 @@ static pthread_t select_thread;
static pthread_t flush_thread; // Used when debugging static pthread_t flush_thread; // Used when debugging
static bool opt_log,opt_update_log,opt_bin_log,opt_slow_log,opt_noacl, static bool opt_log,opt_update_log,opt_bin_log,opt_slow_log,opt_noacl,
opt_disable_networking=0, opt_bootstrap=0,opt_skip_show_db=0, opt_disable_networking=0, opt_bootstrap=0,opt_skip_show_db=0,
opt_ansi_mode=0,opt_myisam_log=0; opt_ansi_mode=0,opt_myisam_log=0, opt_large_files=sizeof(my_off_t) > 4;
bool opt_sql_bin_update = 0, opt_log_slave_updates = 0; bool opt_sql_bin_update = 0, opt_log_slave_updates = 0;
extern MASTER_INFO glob_mi; extern MASTER_INFO glob_mi;
extern int init_master_info(MASTER_INFO* mi); extern int init_master_info(MASTER_INFO* mi);
...@@ -579,8 +579,8 @@ void unireg_abort(int exit_code) ...@@ -579,8 +579,8 @@ void unireg_abort(int exit_code)
{ {
if (exit_code) if (exit_code)
sql_print_error("Aborting\n"); sql_print_error("Aborting\n");
(void) my_delete(pidfile_name,MYF(0)); // This may not always exist
clean_up(); /* purecov: inspected */ clean_up(); /* purecov: inspected */
(void) my_delete(pidfile_name,MYF(0)); // This may not always exist
exit(exit_code); /* purecov: inspected */ exit(exit_code); /* purecov: inspected */
} }
...@@ -2436,20 +2436,21 @@ struct show_var_st init_vars[]= { ...@@ -2436,20 +2436,21 @@ struct show_var_st init_vars[]= {
#endif #endif
{"character_set", default_charset, SHOW_CHAR}, {"character_set", default_charset, SHOW_CHAR},
{"character_sets", (char*) &charsets_list, SHOW_CHAR_PTR}, {"character_sets", (char*) &charsets_list, SHOW_CHAR_PTR},
{"connect_timeout", (char*) &connect_timeout, SHOW_LONG},
{"concurrent_insert", (char*) &myisam_concurrent_insert, SHOW_MY_BOOL}, {"concurrent_insert", (char*) &myisam_concurrent_insert, SHOW_MY_BOOL},
{"connect_timeout", (char*) &connect_timeout, SHOW_LONG},
{"datadir", mysql_real_data_home, SHOW_CHAR}, {"datadir", mysql_real_data_home, SHOW_CHAR},
{"delay_key_write", (char*) &myisam_delay_key_write, SHOW_MY_BOOL}, {"delay_key_write", (char*) &myisam_delay_key_write, SHOW_MY_BOOL},
{"delayed_insert_limit", (char*) &delayed_insert_limit, SHOW_LONG}, {"delayed_insert_limit", (char*) &delayed_insert_limit, SHOW_LONG},
{"delayed_insert_timeout", (char*) &delayed_insert_timeout, SHOW_LONG}, {"delayed_insert_timeout", (char*) &delayed_insert_timeout, SHOW_LONG},
{"delayed_queue_size", (char*) &delayed_queue_size, SHOW_LONG}, {"delayed_queue_size", (char*) &delayed_queue_size, SHOW_LONG},
{"join_buffer_size", (char*) &join_buff_size, SHOW_LONG},
{"flush", (char*) &myisam_flush, SHOW_MY_BOOL}, {"flush", (char*) &myisam_flush, SHOW_MY_BOOL},
{"flush_time", (char*) &flush_time, SHOW_LONG}, {"flush_time", (char*) &flush_time, SHOW_LONG},
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR}, {"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
{"interactive_timeout", (char*) &net_interactive_timeout, SHOW_LONG}, {"interactive_timeout", (char*) &net_interactive_timeout, SHOW_LONG},
{"join_buffer_size", (char*) &join_buff_size, SHOW_LONG},
{"key_buffer_size", (char*) &keybuff_size, SHOW_LONG}, {"key_buffer_size", (char*) &keybuff_size, SHOW_LONG},
{"language", language, SHOW_CHAR}, {"language", language, SHOW_CHAR},
{"large_files_support", (char*) &opt_large_files, SHOW_BOOL},
#ifdef HAVE_MLOCKALL #ifdef HAVE_MLOCKALL
{"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL}, {"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL},
#endif #endif
...@@ -2472,12 +2473,15 @@ struct show_var_st init_vars[]= { ...@@ -2472,12 +2473,15 @@ struct show_var_st init_vars[]= {
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR}, {"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
{"myisam_sort_buffer_size", (char*) &myisam_sort_buffer_size, SHOW_LONG}, {"myisam_sort_buffer_size", (char*) &myisam_sort_buffer_size, SHOW_LONG},
{"net_buffer_length", (char*) &net_buffer_length, SHOW_LONG}, {"net_buffer_length", (char*) &net_buffer_length, SHOW_LONG},
{"net_read_timeout", (char*) &net_read_timeout, SHOW_LONG},
{"net_retry_count", (char*) &mysqld_net_retry_count, SHOW_LONG}, {"net_retry_count", (char*) &mysqld_net_retry_count, SHOW_LONG},
{"net_write_timeout", (char*) &net_write_timeout, SHOW_LONG},
{"pid_file", (char*) pidfile_name, SHOW_CHAR}, {"pid_file", (char*) pidfile_name, SHOW_CHAR},
{"port", (char*) &mysql_port, SHOW_INT}, {"port", (char*) &mysql_port, SHOW_INT},
{"protocol_version", (char*) &protocol_version, SHOW_INT}, {"protocol_version", (char*) &protocol_version, SHOW_INT},
{"record_buffer", (char*) &my_default_record_cache_size,SHOW_LONG}, {"record_buffer", (char*) &my_default_record_cache_size,SHOW_LONG},
{"server_id", (char*) &server_id, SHOW_LONG}, {"query_buffer_size", (char*) &query_buff_size, SHOW_LONG},
{"server_id", (char*) &server_id, SHOW_LONG},
{"skip_locking", (char*) &my_disable_locking, SHOW_MY_BOOL}, {"skip_locking", (char*) &my_disable_locking, SHOW_MY_BOOL},
{"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL}, {"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL}, {"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
...@@ -2486,11 +2490,11 @@ struct show_var_st init_vars[]= { ...@@ -2486,11 +2490,11 @@ struct show_var_st init_vars[]= {
{"sort_buffer", (char*) &sortbuff_size, SHOW_LONG}, {"sort_buffer", (char*) &sortbuff_size, SHOW_LONG},
{"table_cache", (char*) &table_cache_size, SHOW_LONG}, {"table_cache", (char*) &table_cache_size, SHOW_LONG},
{"table_type", (char*) &default_table_type_name, SHOW_CHAR_PTR}, {"table_type", (char*) &default_table_type_name, SHOW_CHAR_PTR},
{"thread_cache_size", (char*) &thread_cache_size, SHOW_LONG},
#ifdef HAVE_THR_SETCONCURRENCY #ifdef HAVE_THR_SETCONCURRENCY
{"thread_concurrency", (char*) &concurrency, SHOW_LONG}, {"thread_concurrency", (char*) &concurrency, SHOW_LONG},
#endif #endif
{"thread_stack", (char*) &thread_stack, SHOW_LONG}, {"thread_stack", (char*) &thread_stack, SHOW_LONG},
{"thread_cache_size", (char*) &thread_cache_size, SHOW_LONG},
#ifdef HAVE_TZNAME #ifdef HAVE_TZNAME
{"timezone", time_zone, SHOW_CHAR}, {"timezone", time_zone, SHOW_CHAR},
#endif #endif
...@@ -3414,7 +3418,7 @@ static int get_service_parameters() ...@@ -3414,7 +3418,7 @@ static int get_service_parameters()
else if ( lstrcmp(szKeyValueName, TEXT("ShowDatabase")) == 0 ) else if ( lstrcmp(szKeyValueName, TEXT("ShowDatabase")) == 0 )
{ {
CHECK_KEY_TYPE( REG_DWORD, szKeyValueName ); CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
opt_disable_networking = !(*lpdwValue); opt_skip_show_db = !(*lpdwValue);
} }
else if ( lstrcmp(szKeyValueName, TEXT("HostnameCaching")) == 0 ) else if ( lstrcmp(szKeyValueName, TEXT("HostnameCaching")) == 0 )
{ {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -158,7 +158,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -158,7 +158,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
unpack_filename(name,ex->file_name); unpack_filename(name,ex->file_name);
#ifndef __WIN__ #ifndef __WIN__
MY_STAT stat_info; MY_STAT stat_info;
if (!my_stat(name,&stat_info,MYF(MY_FAE))) if (!my_stat(name,&stat_info,MYF(MY_WME)))
DBUG_RETURN(-1); DBUG_RETURN(-1);
// the file must be: // the file must be:
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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