Commit 751f2d1f authored by monty@donna.mysql.com's avatar monty@donna.mysql.com

Faster log::write() call, memory leak fix, flush master fix.

parent a99c1757
......@@ -6,11 +6,13 @@ aclocal; autoheader; aclocal; automake; autoconf
CC=ccc CFLAGS="-fast -O3 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -mcpu=ev6 -Wa,-mev6" CXXLDFLAGS='/usr/lib/compaq/libots-2.2.7/libots.so /usr/lib/compaq/cpml-5.0.0/libcpml_ev6.a' ./configure --prefix=/usr/local/mysql --disable-shared --with-extra-charsets=complex --enable-thread-safe-client
make
rm */.deps/*
make
if [ $? = 0 ]
then
rm */.deps/*
bin/mysqladmin shutdown
make install
sur make install
if [ $? = 0 ]
then
scripts/make_binary_distribution
......
......@@ -5917,12 +5917,12 @@ The solution to this is to do one of the following steps:
@itemize @bullet
@item
Configure with @code{CFLAGS=-DHAVE_CURSES_H CXXFLAGS=-DHAVE_CURSES_H ./configure}
@item
Edit @file{/usr/include/widec.h} as indicted above and rerun configure
@item
Remove the @code{#define HAVE_TERM} line from @file{config.h} file and
run @code{make} again.
@item
Configure with @code{CFLAGS=-DHAVE_CURSES CXXFLAGS=-DHAVE_CURSES ./configure}
@end itemize
If you get a problem that your linker can't find @code{-lz} when linking
......@@ -5950,9 +5950,9 @@ experience problems with core dumps under load, you should use the
following @code{configure} command:
@example
shell> CC=gcc CFLAGS="-O6 -fomit-frame-pointer" \
shell> CC=gcc CFLAGS="-O6 -fomit-frame-pointer -DHAVE_CURSES_H" \
CXX=gcc \
CXXFLAGS="-O6 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" \
CXXFLAGS="-O6 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -DHAVE_CURSES_H" \
./configure --prefix=/usr/local/mysql
@end example
......@@ -8557,6 +8557,11 @@ LOW_PRIORITY ...} to lower the priority of only one query, or by
priority in one thread.
@xref{Table locking}.
@item --memlock
Lock the @code{mysqld} process in memory. This works only if your system
supports the @code{mlockall()} system call. This may help if you have
a problem where the opearting system is causing @code{mysqld} to swap on disk.
@item --pid-file=path
Path to pid file used by @code{safe_mysqld}.
......@@ -8597,6 +8602,11 @@ because sometimes it takes a long time to perform backward resolutions.
@strong{MySQL} 3.22 caches hostnames (unless @code{--skip-host-cache} is
used) and has this option enabled by default.
@item --skip-concurrent-insert
Turn of that one can insert and select at the same time on @code{MyISAM}
tables. (This is only to be used if you think you have found a bug
in this feature).
@item --skip-delay-key-write
Ignore the @code{delay_key_write} option for all tables.
@xref{Server parameters}.
......@@ -10210,13 +10220,14 @@ The following @code{mysqld} options affect networking security:
@table @code
@item --secure
IP numbers returned by the @code{gethostbyname()} system call are checked to
make sure they resolve back to the original hostname. This makes it harder
for someone on the outside to get access by pretending to be another host. This
option also adds some sanity checks of hostnames. The option is turned off
by default in @strong{MySQL} 3.21 because sometimes it takes a long time to
perform backward resolutions. @strong{MySQL} 3.22 caches hostnames and has
this option enabled by default.
IP numbers returned by the @code{gethostbyname()} system call are
checked to make sure they resolve back to the original hostname. This
makes it harder for someone on the outside to get access by pretending
to be another host. This option also adds some sanity checks of
hostnames. The option is turned off by default in @strong{MySQL} 3.21
because sometimes it takes a long time to perform backward resolutions.
@strong{MySQL} 3.22 caches hostnames and has this option enabled by
default.
@item --skip-grant-tables
This option causes the server not to use the privilege system at all. This
......@@ -17953,6 +17964,10 @@ files directly, because the contents of the file must travel from the client
host to the server host. On the other hand, you do not need the
@strong{file} privilege to load local files.
Note that you can't read from a FIFO with @code{LOAD DATA INFILE}; If
you need to read from a FIFO (for example the output from gunzip), use
@code{LOAD DATA LOCAL INFILE} instead.
@cindex @code{mysqlimport}
You can also load data files by using the @code{mysqlimport} utility; it
operates by sending a @code{LOAD DATA INFILE} command to the server. The
......@@ -35513,12 +35528,13 @@ only on Linux.
You can always find the latest version
@uref{http://www.trash.net/~ffischer/admin/index.html, here}.
@item @uref{http://www.mysql.com/Downloads/Win32/MySQL-Maker092.zip,MySQL-Maker 092}.
Shareware @strong{MySQL} client for windows. It's WYSIWYG tool which allows
you to create, change and delete databases and tables.
You can change field - structure and add, change and delete data in
these tables directly without ODBC-driver.
@uref{http://62.26.183.157/presult/support/su_sweiche_download.html, MySQL Maker homepage}
@c Link temporary removed on request because of a bug in the current version
@c @item @uref{http://www.mysql.com/Downloads/Win32/MySQL-Maker092.zip,MySQL-Maker 092}.
@c Shareware @strong{MySQL} client for windows. It's WYSIWYG tool which allows
@c you to create, change and delete databases and tables.
@c You can change field - structure and add, change and delete data in
@c these tables directly without ODBC-driver.
@c @uref{http://62.26.183.157/presult/support/su_sweiche_download.html, MySQL Maker homepage}
@item @uref{http://www.mysql.com/Downloads/Contrib/mysqlwinadmn.zip, mysqlwinadmn.zip}
Windows GUI (binary only) to administrate a database, by David B. Mansel,
......@@ -35653,9 +35669,9 @@ programming! By Marc Beneteau, @email{marc@@odbsoft.com}.
@item @uref{http://www.mysql.com/Downloads/Contrib/sqlhtml.tar.gz, sqlhtml.tar.gz}
SQL/HTML is an HTML database manager for @strong{MySQL} using @code{DBI} 1.06.
@item @uref{http://www.mysql.com/Downloads/Contrib/udmsearch-3.0.21.tar.gz, UdmSearch 3.0.21 (stable version)}
@item @uref{http://www.mysql.com/Downloads/Contrib/udmsearch-3.0.21.tar.gz, UdmSearch 3.0.22 (stable version)}
@item @uref{http://www.mysql.com/Downloads/Contrib/udmsearch-3.1.3.tar.gz, UdmSearch 3.1.3 (development version)}
@item @uref{http://mysearch.udm.net, UdmSearch home page}
@item @uref{http://search.mnoGo.ru, UdmSearch home page}
A SQL-based search engine for Internet. By
Alexander I. Barkov @email{bar@@izhcom.ru}.
......@@ -36291,6 +36307,19 @@ though, so 3.23 is not released as a stable version yet.
@appendixsubsec Changes in release 3.23.25
@itemize @bullet
@item
Fixed a core dump bug when doing @code{FLUSH MASTER} when one didn't give
a filename argument to @code{--log-bin}
@item
Added missing ha_berkeley.x files to the MySQL windows source distribution.
@item
Fixed some mutex bugs in the log code that could cause thread blocks if new
log files couldn't be created.
@item
Added lock time and number of selected processed rows to slow query log.
@item
Added @code{--memlock} option to mysqld to lock mysqld in memory on
systems with the @code{mlockall()} call (like in Solaris).
@item
@code{HEAP} tables didn't use keys properly. (Bug from 3.23.23)
@item
Added better support for @code{MERGE} tables (keys, mapping, creation,
......@@ -40543,6 +40572,8 @@ Subqueries. @code{select id from t where grp in (select grp from g where u > 100
@item
Add range checking to @code{MERGE} tables.
@item
@code{SHOW OPEN TABLES}
@item
Port of @strong{MySQL} to BeOS.
@item
Add a temporary key buffer cache during @code{insert/delete/update} so that we
......@@ -40802,18 +40833,12 @@ Negative @code{LIMIT} to retrieve data from the end.
@item
Alarm around client connect/read/write functions.
@item
Make a @code{mysqld} version which isn't multithreaded (3-5 days).
@item
Please note the changes to @code{safe_mysqld}: according to FSSTND (which
Debian tries to follow) PID files should go into @file{/var/run/<progname>.pid}
and log files into @file{/var/log}. It would be nice if you could put the
"DATADIR" in the first declaration of "pidfile" and "log", so the
placement of these files can be changed with a single statement.
@item
Better dynamic record layout to avoid fragmentation.
@item
@code{UPDATE SET blob=read_blob_from_file('my_gif') where id=1;}
@item
Allow a client to request logging.
@item
Add use of @code{zlib()} for @code{gzip}-ed files to @code{LOAD DATA INFILE}.
......@@ -1172,7 +1172,7 @@ AC_SUBST(MAKE_SHELL)
# Already-done: stdlib.h string.h unistd.h termios.h
AC_CHECK_HEADERS(varargs.h stdarg.h dirent.h locale.h ndir.h sys/dir.h \
sys/file.h sys/ndir.h sys/ptem.h sys/pte.h sys/select.h sys/stream.h \
curses.h termcap.h termio.h termbits.h asm/termbits.h grp.h)
sys/mman.h curses.h termcap.h termio.h termbits.h asm/termbits.h grp.h)
# Already-done: strcasecmp
AC_CHECK_FUNCS(lstat putenv select setenv setlocale strcoll tcgetattr)
......@@ -1218,7 +1218,7 @@ AC_CHECK_FUNCS(alarm bmove \
pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \
pthread_condattr_create rwlock_init pthread_rwlock_rdlock \
crypt dlopen dlerror fchmod getpass getpassphrase initgroups)
crypt dlopen dlerror fchmod getpass getpassphrase initgroups, mlockall)
# Sanity check: We chould not have any fseeko symbol unless
# large_file_support=yes
......
......@@ -179,11 +179,12 @@ extern void free_charsets(void);
extern char *list_charsets(myf want_flags); /* my_free() this string... */
/* statisticts */
/* statistics */
extern ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests,
_my_cache_read;
extern ulong _my_blocks_used,_my_blocks_changed;
extern uint my_file_opened,my_stream_opened;
extern my_bool key_cache_inited;
/* Point to current my_message() */
extern void (*my_sigtstp_cleanup)(void),
......
......@@ -18,8 +18,7 @@
#include "mymrgdef.h"
int myrg_close(info)
register MYRG_INFO *info;
int myrg_close(MYRG_INFO *info)
{
int error=0,new_error;
MYRG_TABLE *file;
......@@ -28,6 +27,7 @@ register MYRG_INFO *info;
for (file=info->open_tables ; file != info->end_table ; file++)
if ((new_error=mi_close(file->table)))
error=new_error;
delete_queue(&info->by_key);
pthread_mutex_lock(&THR_LOCK_open);
myrg_open_list=list_delete(myrg_open_list,&info->open_list);
pthread_mutex_unlock(&THR_LOCK_open);
......
......@@ -86,7 +86,7 @@ int handle_locking;
*m_info=info;
m_info->open_tables=(MYRG_TABLE *) (m_info+1);
m_info->tables=files;
for (i=files ; i-- > 0 ; )
{
m_info->open_tables[i].table=isam;
......@@ -104,12 +104,16 @@ int handle_locking;
m_info->open_tables[i].file_offset=(my_off_t) file_offset;
file_offset+=m_info->open_tables[i].table->state->data_file_length;
}
errpos=2;
if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L)
{
my_errno=HA_ERR_RECORD_FILE_FULL;
my_free((char*) m_info,MYF(0));
goto err;
}
/* Allocate memory for queue */
if (m_info->open_tables->table->s->base.keys &&
_myrg_init_queue(m_info,0,HA_READ_KEY_EXACT))
goto err;
m_info->end_table=m_info->open_tables+files;
m_info->last_used_table=m_info->open_tables;
......@@ -119,12 +123,14 @@ int handle_locking;
pthread_mutex_lock(&THR_LOCK_open);
myrg_open_list=list_add(myrg_open_list,&m_info->open_list);
pthread_mutex_unlock(&THR_LOCK_open);
m_info->by_key.root=0;
DBUG_RETURN(m_info);
err:
save_errno=my_errno;
switch (errpos) {
case 2:
my_free((char*) m_info,MYF(0));
/* Fall through */
case 1:
VOID(my_fclose(file,MYF(0)));
for (i=files ; i-- > 0 ; )
......
......@@ -31,6 +31,7 @@
/* 8 Pack filename as short as possibly */
/* 16 Resolve symbolic links for filename */
/* 32 Resolve filename to full path */
/* 64 Return NULL if too long path */
#ifdef MAXPATHLEN
#define BUFF_LEN MAXPATHLEN
......@@ -80,7 +81,10 @@ my_string fn_format(my_string to, const char *name, const char *dsk,
if (strlen(dev)+length+strlen(ext) >= FN_REFLEN || length >= FN_LEN )
{ /* To long path, return original */
uint tmp_length=strlength(startpos);
uint tmp_length;
if (flag & 64)
return 0;
tmp_length=strlength(startpos);
DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %d",dev,ext,length));
(void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
}
......
......@@ -85,7 +85,7 @@ int init_key_cache(ulong use_mem,
if (key_cache_inited && _my_disk_blocks > 0)
{
DBUG_PRINT("warning",("key cache allready in use")); /* purecov: inspected */
DBUG_PRINT("warning",("key cache already in use")); /* purecov: inspected */
DBUG_RETURN(0); /* purecov: inspected */
}
if (! key_cache_inited)
......@@ -161,6 +161,7 @@ void end_key_cache(void)
_my_disk_blocks= -1;
}
}
key_cache_inited=0;
DBUG_PRINT("status",
("used: %d changed: %d w_requests: %ld writes: %ld r_requests: %ld reads: %ld",
_my_blocks_used,_my_blocks_changed,_my_cache_w_requests,
......
......@@ -52,8 +52,6 @@ extern char NEAR curr_dir[FN_REFLEN],NEAR home_dir_buff[FN_REFLEN];
extern volatile int _my_signals;
extern struct st_remember _my_sig_remember[MAX_SIGNALS];
extern my_bool key_cache_inited;
extern const char *soundex_map;
extern USED_MEM* my_once_root_block;
......
2000-09-15 Michael Widenius <monty@mysql.com>
* Added a thd argument to log::write() to get more speed.
2000-09-01 Michael Widenius <monty@mysql.com>
* Avoid allocation of "localhost" string.
......
......@@ -127,6 +127,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
sql_lock=0;
}
}
thd->lock_time();
DBUG_RETURN (sql_lock);
}
......
......@@ -338,7 +338,7 @@ void MYSQL_LOG::new_file()
close();
open(old_name, log_type, new_name);
my_free(old_name,MYF(0));
if (!file) // Something got wrong
if (!file) // Something went wrong
log_type=LOG_CLOSED;
last_time=query_start=0;
write_error=0;
......@@ -347,10 +347,10 @@ void MYSQL_LOG::new_file()
}
void MYSQL_LOG::write(enum enum_server_command command,
void MYSQL_LOG::write(THD *thd,enum enum_server_command command,
const char *format,...)
{
if (name && (what_to_log & (1L << (uint) command)))
if (is_open() && (what_to_log & (1L << (uint) command)))
{
va_list args;
va_start(args,format);
......@@ -359,7 +359,6 @@ void MYSQL_LOG::write(enum enum_server_command command,
{
time_t skr;
ulong id;
THD *thd=current_thd;
int error=0;
if (thd)
{ // Normal thread
......@@ -423,14 +422,14 @@ void MYSQL_LOG::write(enum enum_server_command command,
void MYSQL_LOG::write(Query_log_event* event_info)
{
if (name)
if (is_open())
{
VOID(pthread_mutex_lock(&LOCK_log));
if(file)
if (file)
{
THD *thd=event_info->thd;
if ((!(thd->options & OPTION_BIN_LOG) &&
thd->master_access & PROCESS_ACL) ||
thd->master_access & PROCESS_ACL) ||
!db_ok(event_info->db, binlog_do_db, binlog_ignore_db))
{
VOID(pthread_mutex_unlock(&LOCK_log));
......@@ -457,57 +456,50 @@ void MYSQL_LOG::write(Query_log_event* event_info)
}
}
if(event_info->write(file))
if (event_info->write(file))
{
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
}
err:
VOID(pthread_cond_broadcast(&COND_binlog_update));
VOID(pthread_mutex_unlock(&LOCK_log));
}
VOID(pthread_mutex_unlock(&LOCK_log));
}
}
void MYSQL_LOG::write(Load_log_event* event_info)
{
if(name)
if (is_open())
{
VOID(pthread_mutex_lock(&LOCK_log));
if(file)
if (file)
{
THD *thd=event_info->thd;
if (!(thd->options & OPTION_BIN_LOG) &&
(thd->master_access & PROCESS_ACL))
if ((thd->options & OPTION_BIN_LOG) ||
!(thd->master_access & PROCESS_ACL))
{
VOID(pthread_mutex_unlock(&LOCK_log));
return;
if (event_info->write(file))
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
VOID(pthread_cond_broadcast(&COND_binlog_update));
}
if (event_info->write(file))
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
VOID(pthread_cond_broadcast(&COND_binlog_update));
VOID(pthread_mutex_unlock(&LOCK_log));
}
VOID(pthread_mutex_unlock(&LOCK_log));
}
}
/* Write update log in a format suitable for incremental backup */
void MYSQL_LOG::write(const char *query, uint query_length,
ulong time_for_query)
void MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
time_t query_start)
{
if (name)
if (is_open())
{
time_t current_time;
VOID(pthread_mutex_lock(&LOCK_log));
if (file)
{ // Safety agains reopen
int error=0;
THD *thd=current_thd;
char buff[80],*end;
end=buff;
if (!(thd->options & OPTION_UPDATE_LOG) &&
......@@ -518,13 +510,13 @@ void MYSQL_LOG::write(const char *query, uint query_length,
}
if (specialflag & SPECIAL_LONG_LOG_FORMAT)
{
time_t skr=time(NULL);
if (skr != last_time)
current_time=time(NULL);
if (current_time != last_time)
{
last_time=skr;
last_time=current_time;
struct tm tm_tmp;
struct tm *start;
localtime_r(&skr,&tm_tmp);
localtime_r(&current_time,&tm_tmp);
start=&tm_tmp;
if (fprintf(file,"# Time: %02d%02d%02d %2d:%02d:%02d\n",
start->tm_year % 100,
......@@ -542,8 +534,16 @@ void MYSQL_LOG::write(const char *query, uint query_length,
thd->ip ? thd->ip : "") < 0)
error=errno;;
}
if (time_for_query)
fprintf(file,"# Time: %lu\n",time_for_query);
if (query_start)
{
/* For slow query log */
if (!(specialflag & SPECIAL_LONG_LOG_FORMAT))
current_time=time(NULL);
fprintf(file,"# Time: %lu Lock_time: %lu Rows_sent %lu\n",
(ulong) (current_time - query_start),
(ulong) (thd->time_after_lock - query_start),
(ulong) thd->sent_row_count);
}
if (thd->db && strcmp(thd->db,db))
{ // Database changed
if (fprintf(file,"use %s;\n",thd->db) < 0)
......@@ -637,16 +637,15 @@ void MYSQL_LOG::close(bool exiting)
name=0;
}
if(exiting && index_file)
if (exiting && index_file)
{
if (my_fclose(index_file,MYF(0)) < 0 && ! write_error)
{
if (my_fclose(index_file,MYF(0)) < 0 && ! write_error)
{
write_error=1;
sql_print_error(ER(ER_ERROR_ON_WRITE),name,errno);
}
index_file=0;
write_error=1;
sql_print_error(ER(ER_ERROR_ON_WRITE),name,errno);
}
index_file=0;
}
}
......
......@@ -458,7 +458,7 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open,
extern pthread_cond_t COND_refresh,COND_thread_count, COND_binlog_update,
COND_slave_stopped;
extern pthread_attr_t connection_attrib;
extern bool opt_endinfo,using_udf_functions;
extern bool opt_endinfo,using_udf_functions, locked_in_memory;
extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count,
ha_read_key_count, ha_read_next_count, ha_read_prev_count,
ha_read_first_count, ha_read_last_count,
......
......@@ -72,6 +72,10 @@ int allow_severity = LOG_INFO;
int deny_severity = LOG_WARNING;
#endif /* HAVE_LIBWRAP */
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
#include <ieeefp.h>
#ifdef HAVE_FP_EXCEPT // Fix type conflict
......@@ -139,13 +143,13 @@ static my_socket unix_sock= INVALID_SOCKET,ip_sock= INVALID_SOCKET;
static ulong back_log,connect_timeout,concurrency;
static my_string opt_logname=0,opt_update_logname=0,
opt_binlog_index_name = 0,opt_slow_logname=0;
my_string opt_bin_logname = 0; // this one needs to be seen in sql_parse.cc
my_string opt_bin_logname = 0; // this one needs to be seen in sql_parse.cc
static char mysql_home[FN_REFLEN],pidfile_name[FN_REFLEN];
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,opt_myisam_log=0;
opt_ansi_mode=0,opt_myisam_log=0;
bool opt_sql_bin_update = 0, opt_log_slave_updates = 0;
// if sql_bin_update is true, SQL_LOG_UPDATE and SQL_LOG_BIN are kept in sync, and are
......@@ -197,7 +201,7 @@ uint master_port = MYSQL_PORT, master_connect_retry = 60;
ulong max_tmp_tables,max_heap_table_size;
ulong bytes_sent = 0L, bytes_received = 0L;
bool opt_endinfo,using_udf_functions,low_priority_updates;
bool opt_endinfo,using_udf_functions,low_priority_updates, locked_in_memory;
bool volatile abort_loop,select_thread_in_use,flush_thread_in_use,grant_option;
bool volatile ready_to_exit,shutdown_in_progress;
ulong refresh_version=1L,flush_version=1L; /* Increments on each reload */
......@@ -589,6 +593,7 @@ void clean_up(void)
x_free((gptr) errmsg[ERRMAPP]); /* Free messages */
free_defaults(defaults_argv);
my_free(mysql_tmpdir,MYF(0));
x_free(opt_bin_logname);
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
/* Tell main we are ready */
......@@ -1472,6 +1477,13 @@ int main(int argc, char **argv)
LOG_NEW);
if (opt_bin_log)
{
if (!opt_bin_logname)
{
char tmp[FN_REFLEN];
strnmov(tmp,hostname,FN_REFLEN-5);
strmov(strcend(tmp,'.'),"-bin");
opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
}
mysql_bin_log.set_index_file_name(opt_binlog_index_name);
open_log(&mysql_bin_log, hostname, opt_bin_logname, "-bin",
LOG_BIN);
......@@ -1484,6 +1496,21 @@ int main(int argc, char **argv)
sql_print_error("Can't init databases");
exit(1);
}
#ifdef HAVE_MLOCKALL
if (locked_in_memory && !geteuid())
{
ha_key_cache();
if (mlockall(MCL_CURRENT))
{
sql_print_error("Warning: Failed to lock memory. Errno: %d\n",errno);
}
else
locked_in_memory=1;
}
#else
locked_in_memory=0;
#endif
if (opt_myisam_log)
(void) mi_log( 1 );
ft_init_stopwords(ft_precompiled_stopwords); /* SerG */
......@@ -2171,7 +2198,8 @@ enum options {
OPT_MASTER_CONNECT_RETRY, OPT_SQL_BIN_UPDATE_SAME,
OPT_REPLICATE_DO_DB, OPT_REPLICATE_IGNORE_DB,
OPT_LOG_SLAVE_UPDATES, OPT_BINLOG_DO_DB,
OPT_BINLOG_IGNORE_DB, OPT_WANT_CORE
OPT_BINLOG_IGNORE_DB, OPT_WANT_CORE,
OPT_SKIP_CONCURRENT_INSERT, OPT_MEMLOCK
};
static struct option long_options[] = {
......@@ -2225,6 +2253,7 @@ static struct option long_options[] = {
{"master-port", required_argument, 0, (int) OPT_MASTER_PORT},
{"master-connect-retry", required_argument, 0, (int) OPT_MASTER_CONNECT_RETRY},
{"master-info-file", required_argument, 0, (int) OPT_MASTER_INFO_FILE},
{"memlock", no_argument, 0, (int) OPT_MEMLOCK},
{"new", no_argument, 0, 'n'},
{"old-protocol", no_argument, 0, 'o'},
#ifndef DBUG_OFF
......@@ -2240,6 +2269,7 @@ static struct option long_options[] = {
#ifdef HAVE_BERKELEY_DB
{"skip-bdb", no_argument, 0, (int) OPT_BDB_SKIP},
#endif
{"skip-concurrent-insert", no_argument, 0, (int) OPT_SKIP_CONCURRENT_INSERT},
{"skip-delay-key-write", no_argument, 0, (int) OPT_SKIP_DELAY_KEY_WRITE},
{"skip-grant-tables", no_argument, 0, (int) OPT_SKIP_GRANT},
{"skip-locking", no_argument, 0, (int) OPT_SKIP_LOCK},
......@@ -2369,6 +2399,9 @@ struct show_var_st init_vars[]= {
{"interactive_timeout", (char*) &net_interactive_timeout, SHOW_LONG},
{"key_buffer_size", (char*) &keybuff_size, SHOW_LONG},
{"language", language, SHOW_CHAR},
#ifdef HAVE_MEMLOCKALL
{"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL},
#endif
{"log", (char*) &opt_log, SHOW_BOOL},
{"log_update", (char*) &opt_update_log, SHOW_BOOL},
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
......@@ -2532,9 +2565,10 @@ static void usage(void)
Log slow queries to this log file. Defaults logging\n\
to hostname-slow.log\n\
--pid-file=path Pid file used by safe_mysqld\n\
-P, --port=... Port number to use for connection\n\
--memlock Lock mysqld in memory\n\
-n, --new Use very new possible 'unsafe' functions\n\
-o, --old-protocol Use the old (3.20) protocol\n");
-o, --old-protocol Use the old (3.20) protocol\n\
-P, --port=... Port number to use for connection\n");
#ifndef DBUG_OFF
puts("\
--one-thread Only use one thread (for debugging under Linux)\n");
......@@ -2546,6 +2580,8 @@ static void usage(void)
Start without grant tables. This gives all users\n\
FULL ACCESS to all tables!\n\
--safe-mode Skip some optimize stages (for testing)\n\
--skip-concurrent-insert\n\
Don't use concurrent insert with MyISAM\n\
--skip-delay-key-write\n\
Ignore the delay_key_write option for all tables\n\
--skip-locking Don't use system locking. To use isamchk one has\n\
......@@ -2607,11 +2643,12 @@ The default values (after parsing the command line arguments) are:\n\n");
printf("logfile: %s\n",opt_logname);
if (opt_update_logname)
printf("update log: %s\n",opt_update_logname);
if (opt_bin_logname)
{
printf("binary log: %s\n",opt_bin_logname);
printf("binary log index: %s\n",opt_binlog_index_name);
}
if (opt_bin_log)
{
printf("binary log: %s\n",opt_bin_logname ? opt_bin_logname : "");
printf("binary log index: %s\n",
opt_binlog_index_name ? opt_binlog_index_name : "");
}
if (opt_slow_logname)
printf("update log: %s\n",opt_slow_logname);
printf("TCP port: %d\n",mysql_port);
......@@ -2771,7 +2808,9 @@ static void get_options(int argc,char **argv)
break;
case (int) OPT_BIN_LOG:
opt_bin_log=1;
opt_bin_logname=optarg;
x_free(opt_bin_logname);
if (optarg && optarg[0])
opt_bin_logname=my_strdup(optarg,MYF(0));
break;
case (int) OPT_LOG_SLAVE_UPDATES:
opt_log_slave_updates = 1;
......@@ -2820,6 +2859,9 @@ static void get_options(int argc,char **argv)
myisam_delay_key_write=0;
myisam_concurrent_insert=0;
break;
case (int) OPT_SKIP_CONCURRENT_INSERT:
myisam_concurrent_insert=0;
break;
case (int) OPT_SKIP_PRIOR:
opt_specialflag|= SPECIAL_NO_PRIOR;
break;
......@@ -2853,6 +2895,9 @@ static void get_options(int argc,char **argv)
opt_specialflag|=SPECIAL_SKIP_SHOW_DB;
mysql_port=0;
break;
case (int) OPT_MEMLOCK:
locked_in_memory=1;
break;
case (int) OPT_ONE_THREAD:
test_flags |= TEST_NO_THREADS;
break;
......
......@@ -820,7 +820,7 @@ bool change_password(THD *thd, const char *host, const char *user,
acl_user->user,
acl_user->host.hostname ? acl_user->host.hostname : "",
new_password));
mysql_update_log.write(buff,(uint) strlen(buff));
mysql_update_log.write(thd,buff,qinfo.q_len);
mysql_bin_log.write(&qinfo);
return 0;
}
......
......@@ -29,7 +29,6 @@
#include <io.h>
#endif
static int key_cache_used=0;
TABLE *unused_tables; /* Used by mysql_test */
HASH open_cache; /* Used by mysql_test */
......@@ -550,10 +549,9 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
VOID(hash_delete(&open_cache,(byte*) unused_tables));
#endif
}
if (!open_cache.records)
if (!open_cache.records && ! locked_in_memory)
{
end_key_cache(); /* No tables in memory */
key_cache_used=0;
}
refresh_version++; // Force close of open tables
}
......@@ -980,11 +978,8 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
table->key_length=key_length;
table->version=refresh_version;
table->flush_version=flush_version;
if (!key_cache_used)
{
key_cache_used=1;
if (!key_cache_inited)
ha_key_cache();
}
DBUG_PRINT("info", ("inserting table %p into the cache", table));
VOID(hash_insert(&open_cache,(byte*) table));
}
......
......@@ -221,6 +221,7 @@ bool select_send::send_data(List<Item> &items)
DBUG_RETURN(1);
}
}
thd->sent_row_count++;
bool error=my_net_write(&thd->net,(char*) packet->ptr(),packet->length());
DBUG_RETURN(error);
}
......@@ -256,6 +257,7 @@ select_export::~select_export()
(void) my_close(file,MYF(0));
file= -1;
}
thd->sent_row_count=row_count;
}
int
......@@ -461,10 +463,10 @@ bool select_export::send_data(List<Item> &items)
void select_export::send_error(uint errcode,const char *err)
{
::send_error(&thd->net,errcode,err);
(void) end_io_cache(&cache);
(void) my_close(file,MYF(0));
file= -1;
::send_error(&thd->net,errcode,err);
(void) end_io_cache(&cache);
(void) my_close(file,MYF(0));
file= -1;
}
......
......@@ -94,8 +94,9 @@ class MYSQL_LOG {
void open(const char *log_name,enum_log_type log_type,
const char *new_name=0);
void new_file(void);
void write(enum enum_server_command command,const char *format,...);
void write(const char *query, uint query_length, ulong time_to_do_query=0);
void write(THD *thd, enum enum_server_command command,const char *format,...);
void write(THD *thd, const char *query, uint query_length,
time_t query_start=0);
void write(Query_log_event* event_info); // binary log write
void write(Load_log_event* event_info);
......@@ -111,7 +112,7 @@ class MYSQL_LOG {
int find_next_log(LOG_INFO* linfo);
int get_current_log(LOG_INFO* linfo);
bool is_open() { return log_type != LOG_CLOSED; }
inline bool is_open() { return log_type != LOG_CLOSED; }
char* get_index_fname() { return index_file_name;}
char* get_log_fname() { return log_file_name; }
};
......@@ -241,7 +242,7 @@ class THD :public ilink {
const char *where;
char* last_nx_table; // last non-existent table, we need this for replication
char* last_nx_db; // database of the last nx table
time_t start_time;
time_t start_time,time_after_lock;
time_t connect_time,thr_create_time; // track down slow pthread_create
thr_lock_type update_lock_default;
delayed_insert *di;
......@@ -257,7 +258,7 @@ class THD :public ilink {
#endif
ulonglong next_insert_id,last_insert_id,current_insert_id;
ha_rows select_limit,offset_limit,default_select_limit,cuted_fields,
max_join_size;
max_join_size,sent_row_count;
ulong query_id,version, inactive_timeout,options,thread_id;
long dbug_thread_id;
pthread_t real_id;
......@@ -276,6 +277,7 @@ class THD :public ilink {
inline time_t query_start() { query_start_used=1; return start_time; }
inline void set_time() { if (!user_time) time(&start_time); }
inline void set_time(time_t t) { start_time=t; user_time=1; }
inline void lock_time() { time(&time_after_lock); }
inline void insert_id(ulonglong id)
{ last_insert_id=id; insert_id_used=1; }
inline ulonglong insert_id(void)
......
......@@ -71,9 +71,12 @@ void mysql_create_db(THD *thd, char *db, uint create_options)
path);
}
{
mysql_update_log.write(thd->query, thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd,thd->query, thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
}
if (thd->query == path)
{
......@@ -131,9 +134,12 @@ void mysql_rm_db(THD *thd,char *db,bool if_exists)
thd->query_length = (uint) (strxmov(path,"drop database ", db, NullS)-
path);
}
mysql_update_log.write(thd->query, thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
if (thd->query == path)
{
thd->query = 0; // just in case
......@@ -276,7 +282,7 @@ bool mysql_change_db(THD *thd,const char *name)
thd->priv_user,
thd->host ? thd->host : thd->ip ? thd->ip : "unknown",
dbname);
mysql_log.write(COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
thd->priv_user,
thd->host ? thd->host : thd->ip ? thd->ip : "unknown",
dbname);
......
......@@ -89,9 +89,12 @@ static int generate_table(THD *thd, TABLE_LIST *table_list,
if (!error)
{
send_ok(&thd->net); // This should return record count
mysql_update_log.write(thd->query,thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
}
DBUG_RETURN(error ? -1 : 0);
}
......@@ -188,9 +191,12 @@ int mysql_delete(THD *thd,TABLE_LIST *table_list,COND *conds,ha_rows limit,
VOID(table->file->extra(HA_EXTRA_READCHECK));
if (deleted)
{
mysql_update_log.write(thd->query, thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd,thd->query, thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
}
if (ha_autocommit_or_rollback(thd,error >= 0))
error=1;
......
......@@ -246,9 +246,12 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
id=table->next_number_field->val_int(); // Return auto_increment value
if (info.copied || info.deleted)
{
mysql_update_log.write(thd->query, thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
}
error=ha_autocommit_or_rollback(thd,error);
if (thd->lock)
......@@ -1085,9 +1088,12 @@ bool delayed_insert::handle_inserts(void)
}
if (row->query && row->log_query)
{
mysql_update_log.write(row->query, row->query_length);
Query_log_event qinfo(&thd, row->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(&thd,row->query, row->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(&thd, row->query);
mysql_bin_log.write(&qinfo);
}
}
if (table->blob_fields)
free_delayed_insert_blobs(table);
......@@ -1245,9 +1251,12 @@ bool select_insert::send_eof()
if (last_insert_id)
thd->insert_id(last_insert_id); // For update log
::send_ok(&thd->net,info.copied,last_insert_id,buff);
mysql_update_log.write(thd->query,thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
return 0;
}
}
......
......@@ -244,14 +244,14 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
sprintf(name,ER(ER_LOAD_INFO),info.records,info.deleted,
info.records-info.copied,thd->cuted_fields);
send_ok(&thd->net,info.copied+info.deleted,0L,name);
mysql_update_log.write(thd->query,thd->query_length);
mysql_update_log.write(thd,thd->query,thd->query_length);
if(!read_file_from_client)
{
ex->skip_lines = save_skip_lines;
Load_log_event qinfo(thd, ex, table->table_name, fields, handle_duplicates);
mysql_bin_log.write(&qinfo);
}
if (!read_file_from_client)
{
ex->skip_lines = save_skip_lines;
Load_log_event qinfo(thd, ex, table->table_name, fields, handle_duplicates);
mysql_bin_log.write(&qinfo);
}
DBUG_RETURN(0);
}
......
......@@ -119,7 +119,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
thd->user,
thd->host ? thd->host : thd->ip,
passwd[0] ? ER(ER_YES) : ER(ER_NO));
mysql_log.write(COM_CONNECT,ER(ER_ACCESS_DENIED_ERROR),
mysql_log.write(thd,COM_CONNECT,ER(ER_ACCESS_DENIED_ERROR),
thd->user,
thd->host ? thd->host : thd->ip ? thd->ip : "unknown ip",
passwd[0] ? ER(ER_YES) : ER(ER_NO));
......@@ -137,7 +137,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
return(1);
}
}
mysql_log.write(command,
mysql_log.write(thd,command,
(thd->priv_user == thd->user ?
(char*) "%s@%s on %s" :
(char*) "%s@%s as anonymous on %s"),
......@@ -578,7 +578,7 @@ bool do_command(THD *thd)
switch(command) {
case COM_INIT_DB:
if (!mysql_change_db(thd,packet+1))
mysql_log.write(command,"%s",thd->db);
mysql_log.write(thd,command,"%s",thd->db);
break;
case COM_TABLE_DUMP:
{
......@@ -646,7 +646,7 @@ bool do_command(THD *thd)
thd->packet.shrink(net_buffer_length); // Reclaim some memory
if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),QUERY_PRIOR);
mysql_log.write(command,"%s",thd->query);
mysql_log.write(thd,command,"%s",thd->query);
DBUG_PRINT("query",("%s",thd->query));
mysql_parse(thd,thd->query,packet_length-1);
if (!(specialflag & SPECIAL_NO_PRIOR))
......@@ -671,7 +671,7 @@ bool do_command(THD *thd)
thd->free_list=0;
table_list.name=table_list.real_name=thd->strdup(packet+1);
thd->query=fields=thd->strdup(strend(packet+1)+1);
mysql_log.write(command,"%s %s",table_list.real_name,fields);
mysql_log.write(thd,command,"%s %s",table_list.real_name,fields);
remove_escape(table_list.real_name); // This can't have wildcards
if (check_access(thd,SELECT_ACL,table_list.db,&thd->col_access))
......@@ -685,7 +685,7 @@ bool do_command(THD *thd)
}
#endif
case COM_QUIT:
mysql_log.write(command,NullS);
mysql_log.write(thd,command,NullS);
net->error=0; // Don't give 'abort' message
error=TRUE; // End server
break;
......@@ -695,7 +695,7 @@ bool do_command(THD *thd)
char *db=thd->strdup(packet+1);
if (check_access(thd,CREATE_ACL,db,0,1))
break;
mysql_log.write(command,packet+1);
mysql_log.write(thd,command,packet+1);
mysql_create_db(thd,db,0);
break;
}
......@@ -704,7 +704,7 @@ bool do_command(THD *thd)
char *db=thd->strdup(packet+1);
if (check_access(thd,DROP_ACL,db,0,1))
break;
mysql_log.write(command,db);
mysql_log.write(thd,command,db);
mysql_rm_db(thd,db,0);
break;
}
......@@ -712,7 +712,7 @@ bool do_command(THD *thd)
{
if(check_access(thd, FILE_ACL, any_db))
break;
mysql_log.write(command, 0);
mysql_log.write(thd,command, 0);
ulong pos;
ushort flags;
......@@ -726,7 +726,7 @@ bool do_command(THD *thd)
uint options=(uchar) packet[1];
if (check_access(thd,RELOAD_ACL,any_db))
break;
mysql_log.write(command,NullS);
mysql_log.write(thd,command,NullS);
if (reload_acl_and_cache(thd, options, (TABLE_LIST*) 0))
send_error(net,0);
else
......@@ -737,7 +737,7 @@ bool do_command(THD *thd)
if (check_access(thd,SHUTDOWN_ACL,any_db))
break; /* purecov: inspected */
DBUG_PRINT("quit",("Got shutdown command"));
mysql_log.write(command,NullS);
mysql_log.write(thd,command,NullS);
send_eof(net);
#ifdef __WIN__
sleep(1); // must wait after eof()
......@@ -752,7 +752,7 @@ bool do_command(THD *thd)
case COM_STATISTICS:
{
mysql_log.write(command,NullS);
mysql_log.write(thd,command,NullS);
char buff[200];
ulong uptime = (ulong) (time((time_t*) 0) - start_time);
sprintf((char*) buff,
......@@ -776,7 +776,7 @@ bool do_command(THD *thd)
case COM_PROCESS_INFO:
if (!thd->priv_user[0] && check_access(thd,PROCESS_ACL,any_db))
break;
mysql_log.write(command,NullS);
mysql_log.write(thd,command,NullS);
mysqld_list_processes(thd,thd->master_access & PROCESS_ACL ? NullS :
thd->priv_user,0);
break;
......@@ -790,7 +790,7 @@ bool do_command(THD *thd)
if (check_access(thd,PROCESS_ACL,any_db))
break; /* purecov: inspected */
mysql_print_status(thd);
mysql_log.write(command,NullS);
mysql_log.write(thd,command,NullS);
send_eof(net);
break;
case COM_SLEEP:
......@@ -816,8 +816,7 @@ bool do_command(THD *thd)
if ((ulong) (thd->start_time - start_of_query) > long_query_time)
{
long_query_count++;
mysql_slow_log.write(thd->query, thd->query_length,
(ulong) (thd->start_time - start_of_query));
mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
}
VOID(pthread_mutex_lock(&LOCK_thread_count)); // For process list
thd->proc_info=0;
......@@ -1625,11 +1624,14 @@ mysql_execute_command(void)
res = mysql_table_grant(thd,tables,lex->users_list, lex->columns,
lex->grant, lex->sql_command == SQLCOM_REVOKE);
if(!res)
{
mysql_update_log.write(thd, thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
mysql_update_log.write(thd->query,thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
}
}
else
{
......@@ -1643,9 +1645,12 @@ mysql_execute_command(void)
lex->sql_command == SQLCOM_REVOKE);
if(!res)
{
mysql_update_log.write(thd->query,thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd, thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
}
}
break;
......@@ -1905,6 +1910,7 @@ mysql_init_query(THD *thd)
thd->lex.table_list.next= (byte**) &thd->lex.table_list.first;
thd->fatal_error=0; // Safety
thd->last_insert_id_used=thd->query_start_used=thd->insert_id_used=0;
thd->sent_row_count=0;
DBUG_VOID_RETURN;
}
......@@ -2625,37 +2631,23 @@ static int change_master(THD* thd)
static void reset_master()
{
if(!mysql_bin_log.is_open())
{
my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(ME_BELL+ME_WAITTANG));
return;
}
{
my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(ME_BELL+ME_WAITTANG));
return;
}
LOG_INFO linfo;
if(mysql_bin_log.find_first_log(&linfo, ""))
if (mysql_bin_log.find_first_log(&linfo, ""))
return;
for(;;)
{
my_delete(linfo.log_file_name, MYF(MY_WME));
if(mysql_bin_log.find_next_log(&linfo))
break;
}
mysql_bin_log.close(1); // exiting close
my_delete(mysql_bin_log.get_index_fname(), MYF(MY_WME));
char tmp[FN_REFLEN];
if (!opt_bin_logname || !opt_bin_logname[0])
{
char hostname[FN_REFLEN];
if (gethostname(hostname,sizeof(hostname)-4) < 0)
strmov(hostname,"mysql");
strnmov(tmp,hostname,FN_REFLEN-5);
strmov(strcend(tmp,'.'),"-bin");
opt_bin_logname=tmp;
my_delete(linfo.log_file_name, MYF(MY_WME));
if (mysql_bin_log.find_next_log(&linfo))
break;
}
mysql_bin_log.close(1); // exiting close
my_delete(mysql_bin_log.get_index_fname(), MYF(MY_WME));
mysql_bin_log.open(opt_bin_logname,LOG_BIN);
}
......
......@@ -87,9 +87,12 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
}
if (!error)
{
mysql_update_log.write(thd->query,thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
send_ok(&thd->net);
}
for (TABLE_LIST *table=table_list ; table != lock_table ; table=table->next)
......
......@@ -117,9 +117,12 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
}
if (some_tables_deleted)
{
mysql_update_log.write(thd->query,thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd, thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
}
VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh
......@@ -526,9 +529,12 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
if (!tmp_table && !no_log)
{
// Must be written before unlock
mysql_update_log.write(thd->query, thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd,thd->query, thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
}
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
{
......@@ -966,9 +972,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
VOID(pthread_mutex_unlock(&LOCK_open));
if (!error)
{
mysql_update_log.write(thd->query,thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
send_ok(&thd->net);
}
......@@ -1257,10 +1266,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
my_free((gptr) new_table,MYF(0));
goto err;
}
mysql_update_log.write(thd->query,thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd, thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
goto end_temporary;
DBUG_RETURN(0);
}
......@@ -1364,7 +1375,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
thd->proc_info="end";
mysql_update_log.write(thd->query,thd->query_length);
mysql_update_log.write(thd, thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
......
......@@ -237,9 +237,12 @@ int mysql_update(THD *thd,TABLE_LIST *table_list,List<Item> &fields,
table->time_stamp=save_time_stamp; // Restore auto timestamp pointer
if (updated)
{
mysql_update_log.write(thd->query,thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
}
if (ha_autocommit_or_rollback(thd, error >= 0))
error=1;
......
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