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.spaceapes.com
monty@narttu.mysql.fi
mwagner@evoq.home.mwagner.org
sasha@laptop.slkc.uswest.net
sasha@mysql.sashanet.com
sasha@work.mysql.com
serg@serg.mysql.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,
opt_compress=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
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 int connect_flag=CLIENT_INTERACTIVE;
static char *current_host,*current_db,*current_user=0,*opt_password=0,
......@@ -334,7 +334,7 @@ sig_handler mysql_end(int sig)
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[] =
......@@ -374,6 +374,7 @@ static struct option long_options[] =
{"socket", required_argument, 0, 'S'},
#include "sslopt-longopts.h"
{"table", no_argument, 0, 't'},
{"timeout", required_argument, 0, OPT_TIMEOUT},
#ifndef DONT_ALLOW_USER_CHANGE
{"user", required_argument, 0, 'u'},
#endif
......@@ -545,9 +546,12 @@ static int get_options(int argc, char **argv)
case 'p':
if (optarg)
{
char *start=optarg;
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
opt_password=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; // Destroy argument
if (*start)
start[1]=0;
}
else
tty_password=1;
......@@ -603,6 +607,9 @@ static int get_options(int argc, char **argv)
opt_mysql_unix_port=my_strdup(MYSQL_NAMEDPIPE,MYF(0));
#endif
break;
case OPT_TIMEOUT:
opt_connect_timeout=atoi(optarg);
break;
case 'V': usage(1); exit(0);
case 'I':
case '?':
......@@ -1772,6 +1779,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
connected= 0;
}
mysql_init(&mysql);
if (opt_connect_timeout)
mysql_options(&mysql,MYSQL_OPT_CONNECT_TIMEOUT,
(char*) &opt_connect_timeout);
if (opt_compress)
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
#ifdef HAVE_OPENSSL
......
......@@ -28,7 +28,7 @@
#include <my_pthread.h> /* because of signal() */
#endif
#define ADMIN_VERSION "8.9"
#define ADMIN_VERSION "8.11"
#define MAX_MYSQL_VAR 64
#define MAX_TIME_TO_WAIT 3600 /* Wait for shutdown */
#define MAX_TRUNC_LENGTH 3
......@@ -137,7 +137,7 @@ int main(int argc,char *argv[])
{
int c, error = 0,option_index=0;
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_INIT(argv[0]);
mysql_init(&mysql);
......@@ -160,9 +160,12 @@ int main(int argc,char *argv[])
case 'p':
if (optarg)
{
my_free(password,MYF(MY_ALLOW_ZERO_PTR));
password=my_strdup(optarg,MYF(MY_FAE));
char *start=optarg;
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
opt_password=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
}
else
tty_password=1;
......@@ -243,12 +246,11 @@ int main(int argc,char *argv[])
exit(1);
}
if (tty_password)
password = get_tty_password(NullS);
opt_password = get_tty_password(NullS);
VOID(signal(SIGINT,endprog)); /* Here if abort */
VOID(signal(SIGTERM,endprog)); /* Here if abort */
mysql_init(&mysql);
if (opt_compress)
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
#ifdef HAVE_OPENSSL
......@@ -256,7 +258,7 @@ int main(int argc,char *argv[])
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath);
#endif /* HAVE_OPENSSL */
if (sql_connect(&mysql,host,user,password,option_wait))
if (sql_connect(&mysql,host,user,opt_password,option_wait))
error = 1;
else
{
......@@ -269,7 +271,7 @@ int main(int argc,char *argv[])
if (option_wait && !interrupted)
{
mysql_close(&mysql);
if (!sql_connect(&mysql,host,user,password,option_wait))
if (!sql_connect(&mysql,host,user,opt_password,option_wait))
continue; /* Retry */
}
error=1;
......@@ -286,7 +288,7 @@ int main(int argc,char *argv[])
}
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));
free_defaults(argv);
my_end(0);
......
......@@ -37,7 +37,7 @@
** Tnu Samuel <tonu@please.do.not.remove.this.spam.ee>
**/
#define DUMP_VERSION "8.10"
#define DUMP_VERSION "8.11"
#include <global.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,
opt_delayed=0,create_options=0,opt_quoted=0,opt_databases=0,
opt_alldbs=0,opt_create_db=0,opt_first_slave=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,
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0,
*where=0, *default_charset;
......@@ -333,9 +333,12 @@ static int get_options(int *argc,char ***argv)
case 'p':
if (optarg)
{
my_free(password,MYF(MY_ALLOW_ZERO_PTR));
password=my_strdup(optarg,MYF(MY_FAE));
char *start=optarg;
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
opt_password=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
}
else
tty_password=1;
......@@ -459,7 +462,7 @@ static int get_options(int *argc,char ***argv)
return 1;
}
if (tty_password)
password=get_tty_password(NullS);
opt_password=get_tty_password(NullS);
return(0);
} /* get_options */
......@@ -596,7 +599,6 @@ static uint getTableStructure(char *table, char* db)
sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", opt_quoted);
table_name=quote_name(table,table_buff);
if (mysql_query(sock,insert_pat))
{
/* using SHOW CREATE statement */
......@@ -1318,7 +1320,7 @@ int main(int argc, char **argv)
my_end(0);
exit(EX_USAGE);
}
if (dbConnect(current_host, current_user, password))
if (dbConnect(current_host, current_user, opt_password))
exit(EX_MYSQLERR);
if (!path)
write_heder(stdout, *argv);
......@@ -1358,7 +1360,7 @@ int main(int argc, char **argv)
}
dbDisconnect(current_host);
puts("");
my_free(password, MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
if (extended_insert)
dynstr_free(&extended_row);
my_end(0);
......
......@@ -25,7 +25,7 @@
** * *
** *************************
*/
#define IMPORT_VERSION "2.4"
#define IMPORT_VERSION "2.6"
#include <global.h>
#include <my_sys.h>
......@@ -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;
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,
*lines_terminated=0, *enclosed=0, *opt_enclosed=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");
Give the column names in a comma separated list.\n\
This is same as giving columns to LOAD DATA INFILE.\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\
-h, --host=... Connect to host.\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)
case 'p':
if (optarg)
{
my_free(password,MYF(MY_ALLOW_ZERO_PTR));
password= my_strdup(optarg,MYF(MY_FAE));
char *start=optarg;
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
opt_password=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
}
else
tty_password= 1;
......@@ -276,7 +279,7 @@ static int get_options(int *argc, char ***argv)
current_db= *((*argv)++);
(*argc)--;
if (tty_password)
password=get_tty_password(NullS);
opt_password=get_tty_password(NullS);
return(0);
}
......@@ -504,7 +507,7 @@ int main(int argc, char **argv)
argv_to_free= argv;
if (get_options(&argc, &argv))
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 */
if (lock_tables)
lock_table(sock, argc, argv);
......@@ -513,7 +516,7 @@ int main(int argc, char **argv)
if (exitcode == 0)
exitcode = error;
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);
my_end(0);
return(exitcode);
......
......@@ -28,7 +28,7 @@
#include <stdarg.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 void get_options(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,
opt_ssl_capath);
#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,
0)))
{
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql));
exit(1);
}
/* if (!(mysql_connect(&mysql,host,user,password))) */
switch (argc)
{
......@@ -111,11 +109,12 @@ int main(int argc, char **argv)
if (opt_status && ! wild)
error=list_table_status(&mysql,argv[0],argv[1]);
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 */
if (password)
my_free(password,MYF(0));
if (opt_password)
my_free(opt_password,MYF(0));
my_end(0);
exit(error ? 1 : 0);
return 0; /* No compiler warnings */
......@@ -223,9 +222,12 @@ get_options(int *argc,char ***argv)
case 'p':
if (optarg)
{
my_free(password,MYF(MY_ALLOW_ZERO_PTR));
password=my_strdup(optarg,MYF(MY_FAE));
char *start=optarg;
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
opt_password=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
}
else
tty_password=1;
......@@ -266,7 +268,7 @@ get_options(int *argc,char ***argv)
(*argc)-=optind;
(*argv)+=optind;
if (tty_password)
password=get_tty_password(NullS);
opt_password=get_tty_password(NullS);
return;
}
......
......@@ -95,17 +95,6 @@ bool String::realloc(uint32 alloc_length)
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)
{
if (alloc(21))
......@@ -274,6 +263,7 @@ bool String::append(const char *s,uint32 arg_length)
return FALSE;
}
#ifdef TO_BE_REMOVED
bool String::append(FILE* file, uint32 arg_length, myf my_flags)
{
if (realloc(str_length+arg_length))
......@@ -286,6 +276,20 @@ bool String::append(FILE* file, uint32 arg_length, myf my_flags)
str_length+=arg_length;
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()
{
......
......@@ -107,9 +107,9 @@ class String
Alloced_length=0;
my_free(Ptr,MYF(0));
Ptr=0;
str_length=0; /* Safety */
}
}
inline bool alloc(uint32 arg_length)
{
if (arg_length < Alloced_length)
......@@ -152,7 +152,7 @@ class String
bool copy(const char *s,uint32 arg_length); // Allocate new string
bool append(const String &s);
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 strrstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
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.
AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM
# 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)
PROTOCOL_VERSION=10
......@@ -687,6 +687,8 @@ case $SYSTEM_TYPE in
then
CFLAGS="$CFLAGS -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"
with_named_curses=""
fi
......@@ -1235,13 +1237,13 @@ AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(alarm bmove \
chsize ftruncate rint finite fpsetmask fpresetsticky\
cuserid fcntl fconvert \
cuserid fcntl fconvert poll \
getrusage getpwuid getcwd getrlimit getwd index stpcpy locking longjmp \
perror pread realpath rename \
socket strnlen madvise mkstemp \
strtol strtoul strtoull snprintf tempnam thr_setconcurrency \
gethostbyaddr_r gethostbyname_r getpwnam \
bfill bzero bcmp strstr strpbrk strerror\
bfill bzero bcmp strstr strpbrk strerror \
tell atod memcpy memmove \
setupterm strcasecmp sighold \
vidattr setupterm lrand48 localtime_r \
......
......@@ -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_condattr_init(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)
#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
#define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
#endif
......
......@@ -59,6 +59,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_WME 16 /* Write message on 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_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
#define MY_COPYTIME 64 /* my_redel() copys time */
#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,
uint Count, my_off_t pos);
extern int flush_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,
const char *prefix, uint cache_size,
myf cache_myflags);
......
......@@ -108,6 +108,9 @@ my_bool vio_peer_addr(Vio * vio, char *buf);
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
}
#endif
......
......@@ -64,6 +64,12 @@ my_string mysql_unix_port=0;
#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__)
#define ERRNO WSAGetLastError()
#define perror(A)
......@@ -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,
uint to)
uint timeout)
{
#if defined(__WIN__)
return connect(s, (struct sockaddr*) name, namelen);
......@@ -128,7 +134,7 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
* exactly like the normal connect() call does.
*/
if (to == 0)
if (timeout == 0)
return connect(s, (struct sockaddr*) name, namelen);
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,
start_time = time(NULL);
for (;;)
{
tv.tv_sec = (long) to;
tv.tv_sec = (long) timeout;
tv.tv_usec = 0;
if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0)
break;
now_time=time(NULL);
to-= (uint) (now_time - start_time);
if (errno != EINTR || (int) to <= 0)
timeout-= (uint) (now_time - start_time);
if (errno != EINTR || (int) timeout <= 0)
return -1;
}
......@@ -195,7 +201,7 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
return(-1);
if (s_err)
{ /* getsockopt() could suceed */
{ /* getsockopt could succeed */
errno = s_err;
return(-1); /* but return an error... */
}
......@@ -1001,9 +1007,7 @@ mysql_init(MYSQL *mysql)
}
else
bzero((char*) (mysql),sizeof(*(mysql)));
#ifdef __WIN__
mysql->options.connect_timeout=20;
#endif
mysql->options.connect_timeout=CONNECT_TIMEOUT;
#if defined(SIGPIPE) && defined(THREAD)
if (!((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE))
(void) signal(SIGPIPE,pipe_sig_handler);
......@@ -1140,7 +1144,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
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;
uint32 ip_addr;
struct sockaddr_in sock_addr;
......@@ -1342,6 +1347,13 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
/* Get version info */
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)
goto error;
......@@ -1497,7 +1509,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
int3store(buff+2,max_allowed_packet);
if (user && user[0])
strmake(buff+5,user,32);
strmake(buff+5,user,32); /* Max user name */
else
read_user_name((char*) buff+5);
#ifdef _CUSTOMCONFIG_
......@@ -1508,7 +1520,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
(my_bool) (mysql->protocol_version == 9));
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));
db=0;
}
......
......@@ -32,6 +32,9 @@
#include <my_sys.h>
#include <my_net.h>
#include <m_string.h>
#ifdef HAVE_POLL
#include <sys/poll.h>
#endif
#if defined(__EMX__)
#include <sys/ioctl.h>
......@@ -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))))
{
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(NO_FCNTL_NONBLOCK)
vio->fcntl_mode = fcntl(sd, F_GETFL);
......@@ -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;
DBUG_ENTER("vio_fastsend");
......@@ -322,7 +327,7 @@ int vio_close(Vio * vio)
if (vio->type == VIO_TYPE_NAMEDPIPE)
{
#if defined(__NT__) && defined(MYSQL_SERVER)
CancelIO(vio->hPipe);
CancelIo(vio->hPipe);
DisconnectNamedPipe(vio->hPipe);
#endif
r=CloseHandle(vio->hPipe);
......@@ -397,4 +402,26 @@ void vio_in_addr(Vio *vio, struct in_addr *in)
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 */
No preview for this file type
......@@ -26,7 +26,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
mf_path.c mf_loadpath.c\
my_open.c my_create.c my_seek.c my_read.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 \
my_lock.c mf_brkhant.c my_alarm.c \
my_malloc.c my_realloc.c my_once.c mulalloc.c \
......
......@@ -374,10 +374,11 @@ my_bool hash_delete(HASH *hash,byte *record)
uint blength,pos2,pos_hashnr,lastpos_hashnr,idx,empty_index;
HASH_LINK *data,*lastpos,*gpos,*pos,*pos3,*empty;
DBUG_ENTER("hash_delete");
if (!hash->records)
DBUG_RETURN(1);
blength=hash->blength;
data=dynamic_element(&hash->array,0,HASH_LINK*);
/* Search after record with key */
pos=data+ hash_mask(rec_hashnr(hash,record),blength,hash->records);
gpos = 0;
......
......@@ -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->prefix,MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN(0);
DBUG_RETURN(1);
}
/* Create the temporary file */
......@@ -101,10 +101,12 @@ void close_cached_file(IO_CACHE *cache)
DBUG_ENTER("close_cached_file");
if (my_b_inited(cache))
{
File file=cache->file;
cache->file= -1; /* Don't flush data */
(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
if (cache->file_name)
{
......
......@@ -22,10 +22,13 @@
(and get a EOF-error).
Possibly use of asyncronic io.
macros for read and writes for faster io.
Used instead of FILE when reading or writing hole files.
This shall make mf_rec_cache obsolite.
One can change info->pos_in_file to a higer value to skipp bytes in file if
Used instead of FILE when reading or writing whole files.
This will make mf_rec_cache obsolete.
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.
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
......@@ -40,7 +43,7 @@ static void my_aiowait(my_aio_result *result);
/*
** 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
*/
......@@ -59,6 +62,12 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
min_cache=use_async_io ? IO_SIZE*4 : IO_SIZE*2;
if (type == READ_CACHE)
{ /* Assume file isn't growing */
if (cache_myflags & MY_DONT_CHECK_FILESIZE)
{
cache_myflags &= ~MY_DONT_CHECK_FILESIZE;
}
else
{
my_off_t file_pos,end_of_file;
if ((file_pos=my_tell(file,MYF(0)) == MY_FILEPOS_ERROR))
DBUG_RETURN(1);
......@@ -72,6 +81,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
use_async_io=0; /* No nead to use async */
}
}
}
for (;;)
{
......@@ -545,7 +555,6 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count,
return error;
}
/* Flush write cache */
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);
if (info->seek_not_done)
{ /* 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->rc_pos=info->buffer;
......
......@@ -21,74 +21,49 @@
#include <stdarg.h>
#include <m_ctype.h>
int my_vsnprintf(char* str, size_t n, const char* fmt, va_list ap)
int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
{
uint olen = 0, plen;
const char *tpos;
reg1 char *endpos;
reg2 char * par;
char* ebuff = str;
char *start=to, *end=to+n-1;
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;
*endpos++= *tpos++; /* Copy ordinary char */
olen++;
*to++= *fmt; /* Copy ordinary char */
continue;
}
if (*++tpos == '%') /* test if %% */
{
olen--;
}
else
{
/* Skipp if max size is used (to be compatible with printf) */
while (isdigit(*tpos) || *tpos == '.' || *tpos == '-')
tpos++;
if (*tpos == 's') /* String parameter */
while (isdigit(*fmt) || *fmt == '.' || *fmt == '-')
fmt++;
if (*fmt == 's') /* String parameter */
{
par = va_arg(ap, char *);
plen = (uint) strlen(par);
if (olen + plen < n) /* Replace if possible */
reg2 char *par = va_arg(ap, char *);
uint plen = (uint) strlen(par);
if ((uint) (end-to) > plen) /* Replace if possible */
{
endpos=strmov(endpos,par);
tpos++;
olen+=plen;
to=strmov(to,par);
continue;
}
}
else if (*tpos == 'd' || *tpos == 'u') /* Integer parameter */
else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */
{
register int iarg;
if ((uint) (end-to) < 16)
break;
iarg = va_arg(ap, int);
if(olen + 16 >= n) break;
if (*tpos == 'd')
plen= (uint) (int2str((long) iarg,endpos, -10) - endpos);
if (*fmt == 'd')
to=int10_to_str((long) iarg,to, -10);
else
plen= (uint) (int2str((long) (uint) iarg,endpos,10)- endpos);
if (olen + plen < n) /* Replace parameter if possible */
{
endpos+=plen;
tpos++;
olen+=plen;
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++='%'; /* % used as % or unknown code */
}
*endpos='\0';
/* End of errmessage */
return olen;
*to='\0'; /* End of errmessage */
return (uint) (to - start);
}
......@@ -28,10 +28,13 @@ parse_arguments() {
--socket=*) MYSQL_UNIX_PORT=`echo "$arg" | sed -e "s;--socket=;;"` ;;
--port=*) MYSQL_TCP_PORT=`echo "$arg" | sed -e "s;--port=;;"` ;;
--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=;;"` ;;
--ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;;
--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
done
}
......@@ -105,6 +108,14 @@ if test -w /
then
# If we are root, change the err log to the right user.
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
#
......
......@@ -339,6 +339,15 @@ sub end_benchmark
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.
#
......
......@@ -39,7 +39,7 @@
# "3-byte int" or "same as xxx".
$version="1.50";
$version="1.51";
use DBI;
use Getopt::Long;
......@@ -289,6 +289,11 @@ report("rename table","rename_table",
$dbh->do("drop table crash_q1");
$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))") &&
$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++)
{
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;
......@@ -280,44 +280,125 @@ $end_time=new Benchmark;
print "Time for select_big ($small_loop_count:$count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
#
# Do a lot of different ORDER BY queries
#
$loop_time=new Benchmark;
$estimated=0;
$rows=0;
$count=0;
for ($i=1 ; $i <= $small_loop_count/2 ; $i++)
$estimated=$rows=0;
for ($i=1 ; $i <= $small_loop_count ; $i++)
{
$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);
$count+=2;
$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_key ($count:$rows): " .
print " for order_by_big_key_desc ($small_loop_count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark;
$estimated=0;
$rows=0;
$count=0;
for ($i=1 ; $i <= $small_loop_count/2 ; $i++)
$estimated=$rows=0;
for ($i=1 ; $i <= $small_loop_count ; $i++)
{
$rows+=fetch_all_rows($dbh,"select id2 from bench1 order by id2",1);
$rows+=fetch_all_rows($dbh,"select id2 from bench1 order by id2 desc",1);
$count+=2;
$rows+=fetch_all_rows($dbh,"select id3 from bench1 order by id3",1);
$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));
}
if ($estimated)
{ print "Estimated time"; }
else
{ 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";
#
......@@ -417,6 +498,7 @@ if ($limits->{'group_functions'})
$loop_time=new Benchmark;
$count=1;
$estimated=0;
for ($tests=0 ; $tests < $small_loop_count ; $tests++)
{
$sth=$dbh->prepare($query="select count(*) from bench1") or die $DBI::errstr;
......@@ -492,9 +574,12 @@ if ($limits->{'group_functions'})
print "Warning: '$query' returned wrong number of rows\n";
}
}
}
$end_time=new Benchmark;
print "Time for select_group ($count): " .
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$tests,
$small_loop_count));
}
print_time($estimated);
print " for select_group ($count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark;
......
......@@ -205,10 +205,7 @@ for ($i=0 ; $i < $opt_small_loop_count ; $i++)
$opt_small_loop_count));
}
if ($estimated)
{ print "Estimated time"; }
else
{ print "Time"; }
print_time($estimated);
print " for select_range ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
......@@ -243,10 +240,7 @@ if ($limits->{'group_functions'})
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,
$tests+1, $opt_loop_count));
}
if ($estimated)
{ print "Estimated time"; }
else
{ print "Time"; }
print_time($estimated);
print " for min_max_on_key ($count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
......@@ -267,10 +261,7 @@ if ($limits->{'group_functions'})
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,
$tests+1, $opt_loop_count));
}
if ($estimated)
{ print "Estimated time"; }
else
{ print "Time"; }
print_time($estimated);
print " for count_on_key ($count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
......@@ -278,7 +269,7 @@ if ($limits->{'group_functions'})
$rows=0;
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;
print "Time for count_group_on_key_parts ($i:$rows): " .
......@@ -289,54 +280,74 @@ if ($limits->{'group_functions'})
{
print "Testing count(distinct) on the table\n";
$loop_time=new Benchmark;
$rows=0;
$rows=$estimated=$count=0;
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 grp) from bench1");
}
$end_time=new Benchmark;
print "Time for count_distinct ($i:$rows): " .
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i+1,
$opt_medium_loop_count));
}
print_time($estimated);
print " for count_distinct ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark;
$rows=0;
$rows=$estimated=$count=0;
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");
}
$end_time=new Benchmark;
print "Time for count_distinct_group_on_key ($i:$rows): " .
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i+1,
$opt_medium_loop_count));
}
print_time($estimated);
print " for count_distinct_group_on_key ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark;
$rows=0;
$rows=$estimated=$count=0;
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");
}
$end_time=new Benchmark;
print "Time for count_distinct_group_on_key_parts ($i:$rows): " .
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i+1,
$opt_medium_loop_count));
}
print_time($estimated);
print " for count_distinct_group_on_key_parts ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark;
$rows=0;
$rows=$estimated=$count=0;
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");
}
$end_time=new Benchmark;
print "Time for count_distinct_group ($i:$rows): " .
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i+1,
$opt_medium_loop_count));
}
print_time($estimated);
print " for count_distinct_group ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
$loop_time=new Benchmark;
$rows=0;
$rows=$estimated=$count=0;
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");
}
$end_time=new Benchmark;
print "Time for count_distinct_big ($i:$rows): " .
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i+1,
$opt_medium_loop_count));
}
print_time($estimated);
print " for count_distinct_big ($count:$rows): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
}
......
......@@ -38,8 +38,8 @@ if (my_b_write((file),(byte*) (from),param->ref_length)) \
typedef struct st_buffpek { /* Struktur om sorteringsbuffrarna */
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 */
ha_rows count; /* Number of rows in table */
ulong mem_count; /* numbers of keys in memory */
ulong max_keys; /* Max keys in buffert */
} BUFFPEK;
......@@ -98,7 +98,6 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
BUFFPEK *buffpek;
ha_rows records;
uchar **sort_keys;
gptr save_1,save_2;
IO_CACHE tempfile,*selected_records_file,*outfile;
SORTPARAM param;
DBUG_ENTER("filesort");
......@@ -109,7 +108,6 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
outfile= table[0]->io_cache;
my_b_clear(&tempfile);
save_1=save_2=0;
buffpek= (BUFFPEK *) NULL; sort_keys= (uchar **) NULL; error= 1;
maxbuffer=1;
param.ref_length= table[0]->file->ref_length;
......@@ -148,7 +146,7 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
else
{
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;
}
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,
goto err;
#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;
while (memavl >= MIN_SORT_MEMORY)
{
if ((records+1)*(param.sort_length+sizeof(char*))+sizeof(BUFFPEK)*10 <
(ulong) memavl)
if ((ulonglong) (records+1)*(param.sort_length+sizeof(char*))+sizeof(BUFFPEK)*10 <
(ulonglong) memavl)
param.keys=(uint) records+1;
else
{
......@@ -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);
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.end=(param.local_sortorder=sortorder)+s_length;
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,
#endif
x_free((gptr) sort_keys);
x_free((gptr) buffpek);
x_free(save_1);
x_free(save_2);
close_cached_file(&tempfile);
if (my_b_inited(outfile))
{
......@@ -382,6 +369,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
}
if (*killed)
{
DBUG_PRINT("info",("Sort killed by user"));
(void) file->extra(HA_EXTRA_NO_CACHE);
file->rnd_end();
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
......
......@@ -25,8 +25,9 @@
We will need an updated Berkeley DB version for this.
- Killing threads that has got a 'deadlock'
- SHOW TABLE STATUS should give more information about the table.
- Get a more accurate count of the number of rows.
We could store the found number of rows when the table is scanned.
- 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 and
then increment the counter for each attempted write.
- We will need a manager thread that calls flush_logs, removes old
logs and makes checkpoints at given intervals.
- When not using UPDATE IGNORE, don't make a sub transaction but abort
......@@ -42,7 +43,6 @@
- LOCK TABLES
- CHAR keys
- BLOBS
- delete from t1;
*/
......@@ -60,6 +60,7 @@
#define HA_BERKELEY_ROWS_IN_TABLE 10000 /* to get optimization right */
#define HA_BERKELEY_RANGE_COUNT 100
#define HA_BERKELEY_MAX_ROWS 10000000 /* Max rows in table */
const char *ha_berkeley_ext=".db";
bool berkeley_skip=0;
......@@ -1297,7 +1298,7 @@ void ha_berkeley::info(uint flag)
DBUG_ENTER("info");
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;
}
else if (flag & HA_STATUS_ERRKEY)
......@@ -1607,4 +1608,21 @@ void ha_berkeley::update_auto_primary_key()
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 */
......@@ -92,6 +92,7 @@ class ha_berkeley: public handler
uint max_key_parts() const { return MAX_REF_PARTS; }
uint max_key_length() const { return MAX_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 has_transactions() { return 1;}
......
......@@ -203,6 +203,7 @@ class handler :public Sql_alloc
virtual bool fast_key_read() { return 0;}
virtual bool has_transactions(){ 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_end() {return 0; }
......
......@@ -352,11 +352,6 @@ Item *create_func_to_days(Item* 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)
{
return new Item_func_ucase(a);
......
......@@ -81,7 +81,6 @@ Item *create_func_tan(Item* a);;
Item *create_func_time_format(Item *a, Item *b);
Item *create_func_time_to_sec(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_version(void);
Item *create_func_weekday(Item* a);
......
......@@ -1598,7 +1598,7 @@ String *Item_load_file::val_str(String *str)
if (!(file_name= args[0]->val_str(str)) ||
!(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;
if (!(stat_info.st_mode & S_IROTH))
{
......
......@@ -302,6 +302,7 @@ static SYMBOL symbols[] = {
{ "TINYTEXT", SYM(TINYTEXT),0,0},
{ "TINYINT", SYM(TINYINT),0,0},
{ "TRAILING", SYM(TRAILING),0,0},
{ "TRUNCATE", SYM(TRUNCATE_SYM),0,0},
{ "TO", SYM(TO_SYM),0,0},
{ "TYPE", SYM(TYPE_SYM),0,0},
{ "UNION", SYM(UNION_SYM),0,0},
......@@ -443,7 +444,6 @@ static SYMBOL sql_functions[] = {
{ "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)},
{ "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)},
{ "UPPER", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)},
{ "UNIQUE_USERS", SYM(UNIQUE_USERS),0,0},
......
......@@ -70,8 +70,8 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
thd->proc_info="Waiting for table";
pthread_mutex_unlock(&thd->mysys_var->mutex);
while (global_read_lock && ! thd->killed ||
thd->version != refresh_version)
while (global_read_lock && ! thd->killed &&
thd->version == refresh_version)
{
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -65,9 +65,9 @@ class Log_event
int valid_exec_time; // if false, the exec time setting is bogus
uint32 server_id;
int write(FILE* file);
int write_header(FILE* file);
virtual int write_data(FILE* file __attribute__((unused))) { return 0; }
int write(IO_CACHE* file);
int write_header(IO_CACHE* file);
virtual int write_data(IO_CACHE* file __attribute__((unused))) { return 0; }
virtual Log_event_type get_type_code() = 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),
......@@ -92,11 +92,11 @@ class Log_event
void print_header(FILE* file);
// 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);
#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);
#endif
......@@ -132,18 +132,18 @@ class Query_log_event: public Log_event
}
#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()
{
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; }
int write(FILE* file);
int write_data(FILE* file); // returns 0 on success, -1 on error
int write(IO_CACHE* file);
int write_data(IO_CACHE* file); // returns 0 on success, -1 on error
int get_data_size()
{
return q_len + db_len + 2 +
......@@ -183,6 +183,8 @@ class Load_log_event: public Log_event
{
protected:
char* data_buf;
void Load_log_event::copy_log_event(const char *buf, ulong data_len);
public:
int thread_id;
uint32 table_name_len;
......@@ -272,17 +274,17 @@ class Load_log_event: public Log_event
void set_fields(List<Item> &fields);
#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()
{
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; }
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()
{
return table_name_len + 2 + db_len + 2 + fname_len
......@@ -311,30 +313,26 @@ class Start_log_event: public Log_event
created = (uint32) when;
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)
{
char buf[sizeof(server_version) + sizeof(binlog_version) +
sizeof(created)];
my_fseek(file, 4L, MY_SEEK_CUR, MYF(MY_WME)); // skip the event length
if (my_fread(file, (byte*) buf, sizeof(buf), MYF(MY_NABP | MY_WME)))
sizeof(created)+4];
if (my_b_read(file, (byte*) buf, sizeof(buf)))
return;
binlog_version = uint2korr(buf);
memcpy(server_version, buf + 2, sizeof(server_version));
created = uint4korr(buf + 2 + sizeof(server_version));
binlog_version = uint2korr(buf+4);
memcpy(server_version, buf + 6, sizeof(server_version));
created = uint4korr(buf + 6 + sizeof(server_version));
}
Start_log_event(const char* buf);
~Start_log_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),
MYF(MY_NABP | MY_WME)) ||
my_fwrite(file, (byte*) server_version, sizeof(server_version),
MYF(MY_NABP | MY_WME)) ||
my_fwrite(file, (byte*) &created, sizeof(created),
MYF(MY_NABP | MY_WME)))
if (my_b_write(file, (byte*) &binlog_version, sizeof(binlog_version)) ||
my_b_write(file, (byte*) server_version, sizeof(server_version)) ||
my_b_write(file, (byte*) &created, sizeof(created)))
return -1;
return 0;
}
......@@ -354,12 +352,12 @@ class Intvar_log_event: public Log_event
Intvar_log_event(uchar type_arg, ulonglong val_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() {}
Log_event_type get_type_code() { return INTVAR_EVENT;}
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);
......@@ -370,10 +368,11 @@ class Stop_log_event: public Log_event
public:
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)
{
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)
{
......@@ -397,7 +396,7 @@ class Rotate_log_event: public Log_event
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()
{
......@@ -406,7 +405,7 @@ class Rotate_log_event: public Log_event
}
Log_event_type get_type_code() { return ROTATE_EVENT;}
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);
};
......
......@@ -32,17 +32,19 @@
#define MAP_TO_USE_RAID
#include "mysql_priv.h"
#include <mysys_err.h>
#ifdef HAVE_AIOWAIT
#include <mysys_err.h>
#include <errno.h>
static void my_aiowait(my_aio_result *result);
#endif
/* if cachesize == 0 then use default cachesize (from s-file) */
/* returns 0 if we have enough memory */
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,
enum cache_type type, my_off_t seek_offset,
......@@ -60,6 +62,12 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
min_cache=use_async_io ? IO_SIZE*4 : IO_SIZE*2;
if (type == READ_CACHE)
{ /* Assume file isn't growing */
if (cache_myflags & MY_DONT_CHECK_FILESIZE)
{
cache_myflags &= ~MY_DONT_CHECK_FILESIZE;
}
else
{
my_off_t file_pos,end_of_file;
if ((file_pos=my_tell(file,MYF(0)) == MY_FILEPOS_ERROR))
DBUG_RETURN(1);
......@@ -73,7 +81,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
use_async_io=0; /* No nead to use async */
}
}
}
if ((int) type < (int) READ_NET)
{
for (;;)
......@@ -167,7 +175,8 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
DBUG_ENTER("reinit_io_cache");
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 +
(uint) (info->rc_end - info->rc_request_pos))
{ /* use current buffer */
......@@ -231,6 +240,7 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
{
uint length,diff_length,left_length;
my_off_t max_length, pos_in_file;
memcpy(Buffer,info->rc_pos,
(size_t) (left_length=(uint) (info->rc_end-info->rc_pos)));
Buffer+=left_length;
......@@ -607,7 +617,9 @@ int flush_io_cache(IO_CACHE *info)
length=(uint) (info->rc_pos - info->buffer);
if (info->seek_not_done)
{ /* 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->rc_pos=info->buffer;
......@@ -644,4 +656,4 @@ int end_io_cache(IO_CACHE *info)
DBUG_RETURN(error);
} /* end_io_cache */
}
} /* extern "C" */
......@@ -55,7 +55,7 @@ static struct option long_options[] =
{"password", required_argument,0, 'p'},
{"position", required_argument,0, 'j'},
#ifndef DBUG_OFF
{"debug", required_argument, 0, '#'}
{"debug", optional_argument, 0, '#'}
#endif
};
......@@ -151,7 +151,7 @@ static int parse_args(int *argc, char*** argv)
{
int c, opt_index = 0;
while((c = getopt_long(*argc, *argv, "so:#:h:j:u:p:P:t:?", long_options,
while((c = getopt_long(*argc, *argv, "so:#::h:j:u:p:P:t:?", long_options,
&opt_index)) != EOF)
{
switch(c)
......@@ -310,24 +310,43 @@ Unfortunately, no sweepstakes today, adjusted position to 4\n");
static void dump_local_log_entries(const char* logname)
{
FILE* file;
File fd;
IO_CACHE cache,*file= &cache;
int rec_count = 0;
if(logname && logname[0] != '-')
file = my_fopen(logname, O_RDONLY|O_BINARY, MYF(MY_WME));
if (logname && logname[0] != '-')
{
if ((fd = my_open(logname, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0)
exit(1);
if (init_io_cache(file, fd, 0, READ_CACHE, (my_off_t) position, 0,
MYF(MY_WME | MY_NABP)))
exit(1);
}
else
file = stdin;
if(!file)
die("Could not open log file %s", logname);
if(my_fseek(file, position, MY_SEEK_SET, MYF(MY_WME)) == MY_FILEPOS_ERROR)
die("failed on my_fseek()");
{
if (init_io_cache(file, fileno(stdout), 0, READ_CACHE, (my_off_t) 0,
0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE)))
exit(1);
if (position)
{
/* skip 'position' characters from stdout */
char buff[IO_SIZE];
my_off_t length,tmp;
for (length=position ; length > 0 ; length-=tmp)
{
tmp=min(length,sizeof(buff));
if (my_b_read(file,buff,tmp))
exit(1);
}
}
file->pos_in_file=position;
file->seek_not_done=0;
}
if(!position)
if (!position)
{
char magic[4];
if (my_fread(file, (byte*) magic, sizeof(magic), MYF(MY_NABP|MY_WME)))
if (my_b_read(file, (byte*) magic, sizeof(magic)))
die("I/O error reading binlog magic number");
if(memcmp(magic, BINLOG_MAGIC, 4))
die("Bad magic number");
......@@ -336,23 +355,24 @@ static void dump_local_log_entries(const char* logname)
while(1)
{
Log_event* ev = Log_event::read_log_event(file, 0);
if(!ev)
if(!feof(file))
if (!ev)
{
if (file->error)
die("Could not read entry at offset %ld : Error in log format or \
read error",
my_ftell(file, MYF(MY_WME)));
else
my_b_tell(file));
break;
if(rec_count >= offset)
}
if (rec_count >= offset)
ev->print(stdout, short_form);
rec_count++;
delete ev;
}
my_fclose(file, MYF(MY_WME));
my_close(fd, MYF(MY_WME));
end_io_cache(file);
}
int main(int argc, char** argv)
{
MY_INIT(argv[0]);
......@@ -370,7 +390,7 @@ int main(int argc, char** argv)
mysql = safe_connect();
}
if(table)
if (table)
{
if(!use_remote)
die("You must specify connection parameter to get table dump");
......@@ -382,14 +402,14 @@ int main(int argc, char** argv)
dump_remote_table(&mysql->net, db, tbl);
}
else
{
while(--argc >= 0)
{
dump_log_entries(*(argv++));
}
if(use_remote)
}
if (use_remote)
mc_mysql_close(mysql);
return 0;
}
......
......@@ -157,7 +157,7 @@ static pthread_t select_thread;
static pthread_t flush_thread; // Used when debugging
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_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;
extern MASTER_INFO glob_mi;
extern int init_master_info(MASTER_INFO* mi);
......@@ -579,8 +579,8 @@ void unireg_abort(int exit_code)
{
if (exit_code)
sql_print_error("Aborting\n");
(void) my_delete(pidfile_name,MYF(0)); // This may not always exist
clean_up(); /* purecov: inspected */
(void) my_delete(pidfile_name,MYF(0)); // This may not always exist
exit(exit_code); /* purecov: inspected */
}
......@@ -2436,20 +2436,21 @@ struct show_var_st init_vars[]= {
#endif
{"character_set", default_charset, SHOW_CHAR},
{"character_sets", (char*) &charsets_list, SHOW_CHAR_PTR},
{"connect_timeout", (char*) &connect_timeout, SHOW_LONG},
{"concurrent_insert", (char*) &myisam_concurrent_insert, SHOW_MY_BOOL},
{"connect_timeout", (char*) &connect_timeout, SHOW_LONG},
{"datadir", mysql_real_data_home, SHOW_CHAR},
{"delay_key_write", (char*) &myisam_delay_key_write, SHOW_MY_BOOL},
{"delayed_insert_limit", (char*) &delayed_insert_limit, SHOW_LONG},
{"delayed_insert_timeout", (char*) &delayed_insert_timeout, 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_time", (char*) &flush_time, SHOW_LONG},
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
{"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},
{"language", language, SHOW_CHAR},
{"large_files_support", (char*) &opt_large_files, SHOW_BOOL},
#ifdef HAVE_MLOCKALL
{"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL},
#endif
......@@ -2472,11 +2473,14 @@ struct show_var_st init_vars[]= {
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
{"myisam_sort_buffer_size", (char*) &myisam_sort_buffer_size, 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_write_timeout", (char*) &net_write_timeout, SHOW_LONG},
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
{"port", (char*) &mysql_port, SHOW_INT},
{"protocol_version", (char*) &protocol_version, SHOW_INT},
{"record_buffer", (char*) &my_default_record_cache_size,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_networking", (char*) &opt_disable_networking, SHOW_BOOL},
......@@ -2486,11 +2490,11 @@ struct show_var_st init_vars[]= {
{"sort_buffer", (char*) &sortbuff_size, SHOW_LONG},
{"table_cache", (char*) &table_cache_size, SHOW_LONG},
{"table_type", (char*) &default_table_type_name, SHOW_CHAR_PTR},
{"thread_cache_size", (char*) &thread_cache_size, SHOW_LONG},
#ifdef HAVE_THR_SETCONCURRENCY
{"thread_concurrency", (char*) &concurrency, SHOW_LONG},
#endif
{"thread_stack", (char*) &thread_stack, SHOW_LONG},
{"thread_cache_size", (char*) &thread_cache_size, SHOW_LONG},
#ifdef HAVE_TZNAME
{"timezone", time_zone, SHOW_CHAR},
#endif
......@@ -3414,7 +3418,7 @@ static int get_service_parameters()
else if ( lstrcmp(szKeyValueName, TEXT("ShowDatabase")) == 0 )
{
CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
opt_disable_networking = !(*lpdwValue);
opt_skip_show_db = !(*lpdwValue);
}
else if ( lstrcmp(szKeyValueName, TEXT("HostnameCaching")) == 0 )
{
......
......@@ -114,11 +114,17 @@ THD::THD()
ull=0;
system_thread=0;
bzero((char*) &mem_root,sizeof(mem_root));
#if defined(HAVE_BDB) || defined(HAVE_INNOBASE) || defined(HAVE_GEMENI)
if (open_cached_file(&transactions.trans_log,
mysql_tempdir,LOG_PREFIX,0,MYF(MY_WME)))
killed=1;
transaction.bdb_lock_count=0;
#endif
transaction.bdb_tid=0;
#ifdef __WIN__
real_id = 0 ;
#endif
transaction.bdb_lock_count=0;
transaction.bdb_tid=0;
}
THD::~THD()
......@@ -137,6 +143,9 @@ THD::~THD()
close_thread_tables(this);
}
close_temporary_tables(this);
#if defined(HAVE_BDB) || defined(HAVE_INNOBASE) || defined(HAVE_GEMENI)
close_cached_file(transactions.trans_log);
#endif
if (global_read_lock)
{
pthread_mutex_lock(&LOCK_open);
......
......@@ -52,16 +52,16 @@ typedef struct st_log_info
class MYSQL_LOG {
public:
private:
pthread_mutex_t LOCK_log, LOCK_index;
FILE *file, *index_file;
time_t last_time,query_start;
IO_CACHE log_file;
File index_file;
char *name;
enum_log_type log_type;
volatile enum_log_type log_type;
char time_buff[20],db[NAME_LEN+1];
char log_file_name[FN_REFLEN],index_file_name[FN_REFLEN];
bool write_error,inited;
bool write_error,inited,opened;
bool no_rotate; // for binlog - if log name can never change
// we should not try to rotate it or write any rotation events
// the user should use FLUSH MASTER instead of FLUSH LOGS for
......@@ -85,7 +85,6 @@ class MYSQL_LOG {
void make_log_name(char* buf, const char* log_ident);
bool is_active(const char* log_file_name);
int purge_logs(THD* thd, const char* to_log);
void flush(void);
void close(bool exiting = 0); // if we are exiting, we also want to close the
// index file
......@@ -244,6 +243,7 @@ class THD :public ilink {
thr_lock_type update_lock_default;
delayed_insert *di;
struct st_transactions {
IO_CACHE trans_log;
void *bdb_tid;
uint bdb_lock_count;
} transaction;
......
......@@ -571,7 +571,7 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list)
thread_count++;
pthread_mutex_unlock(&LOCK_thread_count);
if (!(tmp->thd.db=my_strdup(table_list->db,MYF(MY_WME))) ||
!(tmp->thd.query=my_strdup(table_list->real_name,MYF(MY_FAE))))
!(tmp->thd.query=my_strdup(table_list->real_name,MYF(MY_WME))))
{
delete tmp;
thd->fatal_error=1;
......@@ -1325,6 +1325,7 @@ bool select_create::send_eof()
{
VOID(pthread_mutex_lock(&LOCK_open));
mysql_unlock_tables(thd, lock);
if (!table->tmp_table)
hash_delete(&open_cache,(byte*) table);
lock=0; table=0;
VOID(pthread_mutex_unlock(&LOCK_open));
......@@ -1343,6 +1344,7 @@ void select_create::abort()
if (table)
{
enum db_type table_type=table->db_type;
if (!table->tmp_table)
hash_delete(&open_cache,(byte*) table);
quick_rm_table(table_type,db,name);
table=0;
......
......@@ -34,19 +34,23 @@ class LEX_COLUMN;
#endif
enum enum_sql_command {
SQLCOM_SELECT,SQLCOM_CREATE_TABLE,SQLCOM_CREATE_INDEX,SQLCOM_ALTER_TABLE,
SQLCOM_UPDATE,SQLCOM_INSERT,SQLCOM_INSERT_SELECT,SQLCOM_DELETE,
SQLCOM_DROP_TABLE,SQLCOM_DROP_INDEX,SQLCOM_SHOW_DATABASES,
SQLCOM_SHOW_TABLES,SQLCOM_SHOW_FIELDS,SQLCOM_SHOW_KEYS,
SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_CREATE_INDEX, SQLCOM_ALTER_TABLE,
SQLCOM_UPDATE, SQLCOM_INSERT, SQLCOM_INSERT_SELECT,
SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX,
SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_STATUS,
SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT,
SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE,
SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
SQLCOM_GRANT, SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB,
SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT, SQLCOM_SHOW_VARIABLES,
SQLCOM_SHOW_STATUS, SQLCOM_CREATE_FUNCTION, SQLCOM_DROP_FUNCTION,
SQLCOM_SHOW_PROCESSLIST,SQLCOM_REVOKE,SQLCOM_OPTIMIZE, SQLCOM_CHECK,
SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_SHOW_GRANTS, SQLCOM_ANALYZE,
SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT,
SQLCOM_CREATE_FUNCTION, SQLCOM_DROP_FUNCTION,
SQLCOM_REVOKE,SQLCOM_OPTIMIZE, SQLCOM_CHECK,
SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE,
SQLCOM_ROLLBACK, SQLCOM_COMMIT, SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_SHOW_CREATE,
SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT, SQLCOM_CHANGE_MASTER,
SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_CHANGE_MASTER,
SQLCOM_RENAME_TABLE, SQLCOM_BACKUP_TABLE, SQLCOM_RESTORE_TABLE,
SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_SHOW_BINLOGS
};
......
......@@ -158,7 +158,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
unpack_filename(name,ex->file_name);
#ifndef __WIN__
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);
// the file must be:
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -152,7 +152,7 @@ class String
bool copy(const char *s,uint32 arg_length); // Allocate new string
bool append(const String &s);
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 strrstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
bool replace(uint32 offset,uint32 arg_length,const String &to);
......
This diff is collapsed.
......@@ -413,16 +413,6 @@ ulong convert_month_to_period(ulong month)
return year*100+month%12+1;
}
#ifdef NOT_NEEDED
ulong add_to_period(ulong period,int months)
{
if (period == 0L)
return 0L;
return convert_month_to_period(convert_period_to_month(period)+months);
}
#endif
/*****************************************************************************
** convert a timestamp string to a TIME value.
......
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