Commit 7f8ee99d authored by monty@donna.mysql.com's avatar monty@donna.mysql.com

merge

parents 3b3bdf7f 110a5f2d
jani@janikt.pp.saunalahti.fi
sasha@mysql.sashanet.com
monty@donna.mysql.com
This diff is collapsed.
......@@ -1239,7 +1239,7 @@ AC_CHECK_FUNCS(alarm bmove \
chsize ftruncate rint finite fpsetmask fpresetsticky\
cuserid fcntl fconvert poll \
getrusage getpwuid getcwd getrlimit getwd index stpcpy locking longjmp \
perror pread realpath rename \
perror pread realpath readlink rename \
socket strnlen madvise mkstemp \
strtol strtoul strtoull snprintf tempnam thr_setconcurrency \
gethostbyaddr_r gethostbyname_r getpwnam \
......
......@@ -197,4 +197,5 @@
#define ER_CRASHED_ON_USAGE 1194
#define ER_CRASHED_ON_REPAIR 1195
#define ER_WARNING_NOT_COMPLETE_ROLLBACK 1196
#define ER_ERROR_MESSAGES 197
#define ER_TRANS_CACHE_FULL 1197
#define ER_ERROR_MESSAGES 198
# This file describes how to run benchmarks and crash-me with FrontBase
Installed components:
- FrontBase-2.1-8.rpm
(had to run with rpm -i --nodeps; the rpm wanted libreadline.so.4.0,
but only libreadline.so.4.1 was available)
- DBD-FB-0.03.tar.gz
(perl Makefile.Pl;
make;
make test;
make install;)
- DBI-1.14.tar.gz
(perl Makefile.Pl;
make;
make test;
make install;)
- Msql-Mysql-modules-1.2215.tar.gz
(perl Makefile.Pl;
make;
make test;
make install;)
After installations:
- cd /etc/rc.d
FBWeb start
FrontBase start
- cd /usr/local/mysql/sql-bench
- FBExec &
- FrontBase test
crash-me:
There were a lot of troubles running the crash-me; FrontBase core
dumped several tens of times while crash-me was trying to determine
the maximum values in different areas.
The crash-me program itself was also needed to be tuned quite a lot
for FB. There were also some bugs/lacking features in the crash-me
program, which are now fixed to the new version.
After we finally got the limits, we runned the benchmarks.
benchmarks:
Problems again. Frontbase core dumped with every part of the
benchmark (8/8) tests. After a lot of fine-tuning we got the
benchmarks to run through. The maximum values had to be dropped
down a lot in many of the tests.
The benchmarks were run with the following command:
perl run-all-tests --server=frontbase --host=prima
--cmp=frontbase,mysql --tcpip --log
This diff is collapsed.
......@@ -27,11 +27,13 @@
typedef struct st_berkeley_share {
ulonglong auto_ident;
ha_rows rows, org_rows, *rec_per_key;
THR_LOCK lock;
pthread_mutex_t mutex;
char *table_name;
DB *status_block;
uint table_name_length,use_count;
bool primary_key_inited;
uint status,version;
} BDB_SHARE;
......@@ -49,7 +51,8 @@ class ha_berkeley: public handler
BDB_SHARE *share;
ulong int_option_flag;
ulong alloced_rec_buff_length;
uint primary_key,last_dup_key, hidden_primary_key;
ulong changed_rows;
uint primary_key,last_dup_key, hidden_primary_key, version;
bool fixed_length_row, fixed_length_primary_key, key_read;
bool fix_rec_buff_for_blob(ulong length);
byte current_ident[BDB_HIDDEN_PRIMARY_KEY_LENGTH];
......@@ -58,7 +61,8 @@ class ha_berkeley: public handler
int pack_row(DBT *row,const byte *record, bool new_row);
void unpack_row(char *record, DBT *row);
void ha_berkeley::unpack_key(char *record, DBT *key, uint index);
DBT *pack_key(DBT *key, uint keynr, char *buff, const byte *record);
DBT *create_key(DBT *key, uint keynr, char *buff, const byte *record,
int key_length = MAX_KEY_LENGTH);
DBT *pack_key(DBT *key, uint keynr, char *buff, const byte *key_ptr,
uint key_length);
int remove_key(DB_TXN *trans, uint keynr, const byte *record,
......@@ -79,8 +83,9 @@ class ha_berkeley: public handler
HA_KEYPOS_TO_RNDPOS | HA_READ_ORDER | HA_LASTKEY_ORDER |
HA_LONGLONG_KEYS | HA_NULL_KEY | HA_HAVE_KEY_READ_ONLY |
HA_BLOB_KEY | HA_NOT_EXACT_COUNT |
HA_PRIMARY_KEY_IN_READ_INDEX | HA_DROP_BEFORE_CREATE),
last_dup_key((uint) -1)
HA_PRIMARY_KEY_IN_READ_INDEX | HA_DROP_BEFORE_CREATE |
HA_AUTO_PART_KEY),
last_dup_key((uint) -1),version(0)
{
}
~ha_berkeley() {}
......@@ -123,6 +128,10 @@ class ha_berkeley: public handler
int reset(void);
int external_lock(THD *thd, int lock_type);
void position(byte *record);
int analyze(THD* thd,HA_CHECK_OPT* check_opt);
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
int check(THD* thd, HA_CHECK_OPT* check_opt);
ha_rows records_in_range(int inx,
const byte *start_key,uint start_key_len,
enum ha_rkey_function start_search_flag,
......@@ -135,7 +144,7 @@ class ha_berkeley: public handler
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type);
void update_auto_primary_key();
void get_status();
inline void get_auto_primary_key(byte *to)
{
ulonglong tmp;
......@@ -144,11 +153,12 @@ class ha_berkeley: public handler
int5store(to,share->auto_ident);
pthread_mutex_unlock(&share->mutex);
}
longlong ha_berkeley::get_auto_increment();
};
extern bool berkeley_skip;
extern bool berkeley_skip, berkeley_shared_data;
extern u_int32_t berkeley_init_flags,berkeley_lock_type,berkeley_lock_types[];
extern ulong berkeley_cache_size, berkeley_lock_max;
extern ulong berkeley_cache_size, berkeley_max_lock;
extern char *berkeley_home, *berkeley_tmpdir, *berkeley_logdir;
extern long berkeley_lock_scan_time;
extern TYPELIB berkeley_lock_typelib;
......
......@@ -33,7 +33,8 @@ const char **ha_heap::bas_ext() const
int ha_heap::open(const char *name, int mode, uint test_if_locked)
{
uint key,part,parts;
uint key,part,parts,mem_per_row=0;
ulong max_rows;
HP_KEYDEF *keydef;
HP_KEYSEG *seg;
......@@ -47,6 +48,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
for (key=0 ; key < table->keys ; key++)
{
KEY *pos=table->key_info+key;
mem_per_row += (pos->key_length + (sizeof(char*) * 2));
keydef[key].keysegs=(uint) pos->key_parts;
keydef[key].flag = (pos->flags & HA_NOSAME);
......@@ -66,9 +68,13 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
seg++;
}
}
mem_per_row += MY_ALIGN(table->reclength+1, sizeof(char*));
max_rows = (ulong) (max_heap_table_size / mem_per_row);
file=heap_open(table->path,mode,
table->keys,keydef,
table->reclength,table->max_rows,
table->reclength,
((table->max_rows < max_rows && table->max_rows) ?
table->max_rows : max_rows),
table->min_rows);
my_free((gptr) keydef,MYF(0));
info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE);
......
......@@ -191,8 +191,7 @@ int ha_autocommit_or_rollback(THD *thd, int error)
{
DBUG_ENTER("ha_autocommit_or_rollback");
#ifdef USING_TRANSACTIONS
if (!(thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN)) &&
!thd->locked_tables)
if (!(thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN)))
{
if (!error)
{
......@@ -211,6 +210,16 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
{
int error=0;
DBUG_ENTER("ha_commit");
#ifdef USING_TRANSACTIONS
/* Update the binary log if we have cached some queries */
if (trans == &thd->transaction.all && mysql_bin_log.is_open() &&
my_b_tell(&thd->transaction.trans_log))
{
mysql_bin_log.write(&thd->transaction.trans_log);
reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1);
thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
}
#ifdef HAVE_BERKELEY_DB
if (trans->bdb_tid)
{
......@@ -224,13 +233,16 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
#endif
#ifdef HAVE_INNOBASE_DB
{
if ((error=innobase_commit(thd,trans->innobase_tid))
if ((error=innobase_commit(thd,trans->innobase_tid)))
{
my_error(ER_ERROR_DURING_COMMIT, MYF(0), error);
error=1;
}
trans->innobase_tid=0;
}
#endif
if (error && trans == &thd->transaction.all && mysql_bin_log.is_open())
sql_print_error("Error: Got error during commit; Binlog is not up to date!");
#endif
DBUG_RETURN(error);
}
......@@ -260,6 +272,12 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
}
trans->innobase_tid=0;
}
#endif
#ifdef USING_TRANSACTIONS
if (trans == &thd->transaction.all)
reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1);
thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
#endif
DBUG_RETURN(error);
}
......
......@@ -180,20 +180,21 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors)
VOID(pthread_mutex_lock(&hostname_cache->lock));
if (!(hp=gethostbyaddr((char*) in,sizeof(*in), AF_INET)))
{
DBUG_PRINT("error",("gethostbyaddr returned %d",errno));
VOID(pthread_mutex_unlock(&hostname_cache->lock));
add_wrong_ip(in);
DBUG_RETURN(0);
DBUG_PRINT("error",("gethostbyaddr returned %d",errno));
goto err;
}
if (!hp->h_name[0])
if (!hp->h_name[0]) // Don't allow empty hostnames
{
VOID(pthread_mutex_unlock(&hostname_cache->lock));
DBUG_PRINT("error",("Got an empty hostname"));
add_wrong_ip(in);
DBUG_RETURN(0); // Don't allow empty hostnames
goto err;
}
if (!(name=my_strdup(hp->h_name,MYF(0))))
{
VOID(pthread_mutex_unlock(&hostname_cache->lock));
DBUG_RETURN(0); // out of memory
}
check=gethostbyname(name);
VOID(pthread_mutex_unlock(&hostname_cache->lock));
if (!check)
......@@ -214,8 +215,7 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors)
{
DBUG_PRINT("error",("mysqld doesn't accept hostnames that starts with a number followed by a '.'"));
my_free(name,MYF(0));
add_wrong_ip(in);
DBUG_RETURN(0);
goto err;
}
}
......@@ -230,6 +230,8 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors)
}
DBUG_PRINT("error",("Couldn't verify hostname with gethostbyname"));
my_free(name,MYF(0));
err:
add_wrong_ip(in);
DBUG_RETURN(0);
}
......@@ -16,6 +16,7 @@
/* logging of commands */
/* TODO: Abort logging when we get an error in reading or writing log files */
#include "mysql_priv.h"
#include "sql_acl.h"
......@@ -523,14 +524,12 @@ void MYSQL_LOG::new_file()
}
void MYSQL_LOG::write(THD *thd,enum enum_server_command command,
bool MYSQL_LOG::write(THD *thd,enum enum_server_command command,
const char *format,...)
{
if (is_open() && (what_to_log & (1L << (uint) command)))
{
va_list args;
va_start(args,format);
char buff[32];
int error=0;
VOID(pthread_mutex_lock(&LOCK_log));
/* Test if someone closed after the is_open test */
......@@ -538,14 +537,17 @@ void MYSQL_LOG::write(THD *thd,enum enum_server_command command,
{
time_t skr;
ulong id;
int error=0;
va_list args;
va_start(args,format);
char buff[32];
if (thd)
{ // Normal thread
if ((thd->options & OPTION_LOG_OFF) &&
(thd->master_access & PROCESS_ACL))
{
VOID(pthread_mutex_unlock(&LOCK_log));
return; // No logging
return 0; // No logging
}
id=thd->thread_id;
if (thd->user_time || !(skr=thd->query_start()))
......@@ -593,48 +595,47 @@ void MYSQL_LOG::write(THD *thd,enum enum_server_command command,
write_error=1;
sql_print_error(ER(ER_ERROR_ON_WRITE),name,error);
}
}
va_end(args);
VOID(pthread_mutex_unlock(&LOCK_log));
}
VOID(pthread_mutex_unlock(&LOCK_log));
return error != 0;
}
return 0;
}
/* Write to binary log in a format to be used for replication */
void MYSQL_LOG::write(Query_log_event* event_info)
bool MYSQL_LOG::write(Query_log_event* event_info)
{
if (is_open())
{
/* In most cases this is only called if 'is_open()' is true */
bool error=1;
VOID(pthread_mutex_lock(&LOCK_log));
if (is_open())
{
THD *thd=event_info->thd;
IO_CACHE *file = (event_info->cache_stmt ? &thd->transaction.trans_log :
&log_file);
if ((!(thd->options & OPTION_BIN_LOG) &&
thd->master_access & PROCESS_ACL) ||
!db_ok(event_info->db, binlog_do_db, binlog_ignore_db))
{
VOID(pthread_mutex_unlock(&LOCK_log));
return;
return 0;
}
if (thd->last_insert_id_used)
{
Intvar_log_event e((uchar)LAST_INSERT_ID_EVENT, thd->last_insert_id);
if (e.write(&log_file))
{
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
if (e.write(file))
goto err;
}
}
if (thd->insert_id_used)
{
Intvar_log_event e((uchar)INSERT_ID_EVENT, thd->last_insert_id);
if (e.write(&log_file))
{
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
if (e.write(file))
goto err;
}
}
if (thd->convert_set)
{
char buf[1024] = "SET CHARACTER SET ";
......@@ -644,28 +645,93 @@ void MYSQL_LOG::write(Query_log_event* event_info)
// just in case somebody wants it later
thd->query_length = (uint)(p - buf);
Query_log_event e(thd, buf);
if (e.write(&log_file))
{
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
if (e.write(file))
goto err;
}
thd->query_length = save_query_length; // clean up
}
if (event_info->write(&log_file) || flush_io_cache(&log_file))
if (event_info->write(file) ||
file == &log_file && flush_io_cache(file))
goto err;
error=0;
err:
if (error)
{
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
if (my_errno == EFBIG)
my_error(ER_TRANS_CACHE_FULL, MYF(0));
else
my_error(ER_ERROR_ON_WRITE, MYF(0), name, errno);
write_error=1;
}
err:
if (file == &log_file)
VOID(pthread_cond_broadcast(&COND_binlog_update));
}
else
error=0;
VOID(pthread_mutex_unlock(&LOCK_log));
}
return error;
}
void MYSQL_LOG::write(Load_log_event* event_info)
/*
Write a cached log entry to the binary log
We only come here if there is something in the cache.
'cache' needs to be reinitialized after this functions returns.
*/
bool MYSQL_LOG::write(IO_CACHE *cache)
{
VOID(pthread_mutex_lock(&LOCK_log));
bool error=1;
if (is_open())
{
uint length;
my_off_t start_pos=my_b_tell(&log_file);
if (reinit_io_cache(cache, WRITE_CACHE, 0, 0, 0))
{
if (!write_error)
sql_print_error(ER(ER_ERROR_ON_WRITE), cache->file_name, errno);
goto err;
}
while ((length=my_b_fill(cache)))
{
if (my_b_write(&log_file, cache->rc_pos, length))
{
if (!write_error)
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
goto err;
}
cache->rc_pos=cache->rc_end; // Mark buffer used up
}
if (flush_io_cache(&log_file))
{
if (!write_error)
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
goto err;
}
if (cache->error) // Error on read
{
if (!write_error)
sql_print_error(ER(ER_ERROR_ON_READ), cache->file_name, errno);
goto err;
}
}
error=0;
err:
if (error)
write_error=1;
else
VOID(pthread_cond_broadcast(&COND_binlog_update));
VOID(pthread_mutex_unlock(&LOCK_log));
return error;
}
bool MYSQL_LOG::write(Load_log_event* event_info)
{
bool error=0;
VOID(pthread_mutex_lock(&LOCK_log));
if (is_open())
{
......@@ -674,34 +740,39 @@ void MYSQL_LOG::write(Load_log_event* event_info)
!(thd->master_access & PROCESS_ACL))
{
if (event_info->write(&log_file) || flush_io_cache(&log_file))
{
if (!write_error)
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
error=write_error=1;
}
VOID(pthread_cond_broadcast(&COND_binlog_update));
}
}
VOID(pthread_mutex_unlock(&LOCK_log));
}
return error;
}
/* Write update log in a format suitable for incremental backup */
void MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
time_t query_start)
{
bool error=0;
if (is_open())
{
time_t current_time;
VOID(pthread_mutex_lock(&LOCK_log));
if (is_open())
{ // Safety agains reopen
int error=0;
int tmp_errno=0;
char buff[80],*end;
end=buff;
if (!(thd->options & OPTION_UPDATE_LOG) &&
(thd->master_access & PROCESS_ACL))
{
VOID(pthread_mutex_unlock(&LOCK_log));
return;
return 0;
}
if ((specialflag & SPECIAL_LONG_LOG_FORMAT) || query_start)
{
......@@ -722,14 +793,14 @@ void MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
start->tm_min,
start->tm_sec);
if (my_b_write(&log_file, (byte*) buff,24))
error=errno;
tmp_errno=errno;
}
if (my_b_printf(&log_file, "# User@Host: %s[%s] @ %s [%s]\n",
thd->priv_user,
thd->user,
thd->host ? thd->host : "",
thd->ip ? thd->ip : "") == (uint) -1)
error=errno;
tmp_errno=errno;
}
if (query_start)
{
......@@ -739,12 +810,12 @@ void MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
(ulong) (current_time - query_start),
(ulong) (thd->time_after_lock - query_start),
(ulong) thd->sent_row_count) == (uint) -1)
error=errno;
tmp_errno=errno;
}
if (thd->db && strcmp(thd->db,db))
{ // Database changed
if (my_b_printf(&log_file,"use %s;\n",thd->db) == (uint) -1)
error=errno;
tmp_errno=errno;
strmov(db,thd->db);
}
if (thd->last_insert_id_used)
......@@ -777,7 +848,7 @@ void MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
*end=0;
if (my_b_write(&log_file, (byte*) "SET ",4) ||
my_b_write(&log_file, (byte*) buff+1,(uint) (end-buff)-1))
error=errno;
tmp_errno=errno;
}
if (!query)
{
......@@ -787,28 +858,21 @@ void MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
if (my_b_write(&log_file, (byte*) query,query_length) ||
my_b_write(&log_file, (byte*) ";\n",2) ||
flush_io_cache(&log_file))
error=errno;
if (error && ! write_error)
tmp_errno=errno;
if (tmp_errno)
{
error=1;
if (! write_error)
{
write_error=1;
sql_print_error(ER(ER_ERROR_ON_WRITE),name,error);
}
}
VOID(pthread_mutex_unlock(&LOCK_log));
}
}
#ifdef TO_BE_REMOVED
void MYSQL_LOG::flush()
{
if (is_open())
if (flush_io_cache(log_file) && ! write_error)
{
write_error=1;
sql_print_error(ER(ER_ERROR_ON_WRITE),name,errno);
VOID(pthread_mutex_unlock(&LOCK_log));
}
return error;
}
#endif
void MYSQL_LOG::close(bool exiting)
......
......@@ -118,16 +118,18 @@ public:
ulong thread_id;
#if !defined(MYSQL_CLIENT)
THD* thd;
Query_log_event(THD* thd_arg, const char* query_arg):
Log_event(thd_arg->start_time,0,0,thd_arg->server_id), data_buf(0),
bool cache_stmt;
Query_log_event(THD* thd_arg, const char* query_arg, bool using_trans=0):
Log_event(thd_arg->start_time,0,1,thd_arg->server_id), data_buf(0),
query(query_arg), db(thd_arg->db), q_len(thd_arg->query_length),
error_code(thd_arg->net.last_errno),
thread_id(thd_arg->thread_id), thd(thd_arg)
thread_id(thd_arg->thread_id), thd(thd_arg),
cache_stmt(using_trans &&
(thd_arg->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN)))
{
time_t end_time;
time(&end_time);
exec_time = (ulong) (end_time - thd->start_time);
valid_exec_time = 1;
db_len = (db) ? (uint32) strlen(db) : 0;
}
#endif
......
......@@ -121,7 +121,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
}
/* end_of_file may be changed by user later */
info->end_of_file= ((type == READ_NET || type == READ_FIFO ) ? 0
: MY_FILEPOS_ERROR);
: ~(my_off_t) 0);
info->type=type;
info->error=0;
info->read_function=(type == READ_NET) ? _my_b_net_read : _my_b_read; /* net | file */
......@@ -176,6 +176,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 the whole file is in memory, avoid flushing to disk */
if (! clear_cache &&
seek_offset >= info->pos_in_file &&
seek_offset <= info->pos_in_file +
......@@ -186,8 +188,12 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
info->rc_end=info->rc_pos;
info->end_of_file=my_b_tell(info);
}
else if (info->type == READ_CACHE && type == WRITE_CACHE)
else if (type == WRITE_CACHE)
{
if (info->type == READ_CACHE)
info->rc_end=info->buffer+info->buffer_length;
info->end_of_file = ~(my_off_t) 0;
}
info->rc_pos=info->rc_request_pos+(seek_offset-info->pos_in_file);
#ifdef HAVE_AIOWAIT
my_aiowait(&info->aio_result); /* Wait for outstanding req */
......@@ -195,11 +201,20 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
}
else
{
/*
If we change from WRITE_CACHE to READ_CACHE, assume that everything
after the current positions should be ignored
*/
if (info->type == WRITE_CACHE && type == READ_CACHE)
info->end_of_file=my_b_tell(info);
if (flush_io_cache(info))
/* No need to flush cache if we want to reuse it */
if ((type != WRITE_CACHE || !clear_cache) && flush_io_cache(info))
DBUG_RETURN(1);
if (info->pos_in_file != seek_offset)
{
info->pos_in_file=seek_offset;
info->seek_not_done=1;
}
info->rc_request_pos=info->rc_pos=info->buffer;
if (type == READ_CACHE || type == READ_NET || type == READ_FIFO)
{
......@@ -210,7 +225,7 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
info->rc_end=info->buffer+info->buffer_length-
(seek_offset & (IO_SIZE-1));
info->end_of_file= ((type == READ_NET || type == READ_FIFO) ? 0 :
MY_FILEPOS_ERROR);
~(my_off_t) 0);
}
}
info->type=type;
......@@ -536,6 +551,11 @@ int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count)
Buffer+=rest_length;
Count-=rest_length;
info->rc_pos+=rest_length;
if (info->pos_in_file+info->buffer_length > info->end_of_file)
{
my_errno=errno=EFBIG;
return info->error = -1;
}
if (flush_io_cache(info))
return 1;
if (Count >= IO_SIZE)
......
......@@ -507,9 +507,9 @@ extern ulong keybuff_size,sortbuff_size,max_item_sort_length,table_cache_size,
net_read_timeout,net_write_timeout,
what_to_log,flush_time,
max_tmp_tables,max_heap_table_size,query_buff_size,
lower_case_table_names,thread_stack,thread_stack_min;
extern ulong specialflag;
extern ulong current_pid;
lower_case_table_names,thread_stack,thread_stack_min,
binlog_cache_size, max_binlog_cache_size;
extern ulong specialflag, current_pid;
extern bool low_priority_updates;
extern bool opt_sql_bin_update;
extern char language[LIBLEN],reg_ext[FN_EXTLEN],blob_newline;
......
......@@ -201,10 +201,10 @@ ulong keybuff_size,sortbuff_size,max_item_sort_length,table_cache_size,
query_buff_size, lower_case_table_names, mysqld_net_retry_count,
net_interactive_timeout, slow_launch_time = 2L,
net_read_timeout,net_write_timeout,slave_open_temp_tables=0;
ulong thread_cache_size=0;
ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0;
volatile ulong cached_thread_count=0;
// replication parameters, if master_host is not NULL, we are slaving off the master
// replication parameters, if master_host is not NULL, we are a slave
my_string master_user = (char*) "test", master_password = 0, master_host=0,
master_info_file = (char*) "master.info";
const char *localhost=LOCAL_HOST;
......@@ -1496,9 +1496,10 @@ int main(int argc, char **argv)
if (opt_update_log)
open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
LOG_NEW);
if (!server_id)
server_id= !master_host ? 1 : 2;
if (opt_bin_log)
{
if(server_id)
{
if (!opt_bin_logname)
{
......@@ -1511,9 +1512,6 @@ int main(int argc, char **argv)
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
LOG_BIN);
}
else
sql_print_error("Server id is not set - binary logging disabled");
}
if (opt_slow_log)
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
......@@ -1620,9 +1618,7 @@ int main(int argc, char **argv)
}
// slave thread
if(master_host)
{
if(server_id)
if (master_host)
{
pthread_t hThread;
if(!opt_skip_slave_start &&
......@@ -1631,9 +1627,6 @@ int main(int argc, char **argv)
else if(opt_skip_slave_start)
init_master_info(&glob_mi);
}
else
sql_print_error("Server id is not set, slave thread will not be started");
}
printf(ER(ER_READY),my_progname,server_version,"");
fflush(stdout);
......@@ -2205,7 +2198,8 @@ enum options {
OPT_BDB_HOME, OPT_BDB_LOG,
OPT_BDB_TMP, OPT_BDB_NOSYNC,
OPT_BDB_LOCK, OPT_BDB_SKIP,
OPT_BDB_RECOVER, OPT_MASTER_HOST,
OPT_BDB_RECOVER, OPT_BDB_SHARED,
OPT_MASTER_HOST,
OPT_MASTER_USER, OPT_MASTER_PASSWORD,
OPT_MASTER_PORT, OPT_MASTER_INFO_FILE,
OPT_MASTER_CONNECT_RETRY, OPT_SQL_BIN_UPDATE_SAME,
......@@ -2233,6 +2227,7 @@ static struct option long_options[] = {
{"bdb-logdir", required_argument, 0, (int) OPT_BDB_LOG},
{"bdb-recover", no_argument, 0, (int) OPT_BDB_RECOVER},
{"bdb-no-sync", no_argument, 0, (int) OPT_BDB_NOSYNC},
{"bdb-shared-data", required_argument, 0, (int) OPT_BDB_SHARED},
{"bdb-tmpdir", required_argument, 0, (int) OPT_BDB_TMP},
#endif
{"big-tables", no_argument, 0, (int) OPT_BIG_TABLES},
......@@ -2323,7 +2318,7 @@ static struct option long_options[] = {
(int) OPT_REPLICATE_REWRITE_DB},
{"safe-mode", no_argument, 0, (int) OPT_SAFE},
{"socket", required_argument, 0, (int) OPT_SOCKET},
{"server-id", required_argument, 0, (int)OPT_SERVER_ID},
{"server-id", required_argument, 0, (int) OPT_SERVER_ID},
{"set-variable", required_argument, 0, 'O'},
#ifdef HAVE_BERKELEY_DB
{"skip-bdb", no_argument, 0, (int) OPT_BDB_SKIP},
......@@ -2363,9 +2358,14 @@ CHANGEABLE_VAR changeable_vars[] = {
#ifdef HAVE_BERKELEY_DB
{ "bdb_cache_size", (long*) &berkeley_cache_size,
KEY_CACHE_SIZE, 20*1024, (long) ~0, 0, IO_SIZE },
{ "bdb_lock_max", (long*) &berkeley_lock_max,
{ "bdb_max_lock", (long*) &berkeley_max_lock,
1000, 0, (long) ~0, 0, 1 },
/* QQ: The following should be removed soon! */
{ "bdb_lock_max", (long*) &berkeley_max_lock,
1000, 0, (long) ~0, 0, 1 },
#endif
{ "binlog_cache_size", (long*) &binlog_cache_size,
32*1024L, IO_SIZE, ~0L, 0, IO_SIZE },
{ "connect_timeout", (long*) &connect_timeout,
CONNECT_TIMEOUT, 2, 65535, 0, 1 },
{ "delayed_insert_timeout", (long*) &delayed_insert_timeout,
......@@ -2390,7 +2390,7 @@ CHANGEABLE_VAR changeable_vars[] = {
{"innobase_buffer_pool_size",
(long*) &innobase_buffer_pool_size, 8*1024*1024L, 1024*1024L,
~0L, 0, 1024*1024L},
{"innobase_additional_mem_pool_size_mb",
{"innobase_additional_mem_pool_size",
(long*) &innobase_additional_mem_pool_size, 1*1024*1024L, 512*1024L,
~0L, 0, 1024},
{"innobase_file_io_threads",
......@@ -2408,6 +2408,8 @@ CHANGEABLE_VAR changeable_vars[] = {
IF_WIN(1,0), 0, 1, 0, 1 },
{ "max_allowed_packet", (long*) &max_allowed_packet,
1024*1024L, 80, 17*1024*1024L, MALLOC_OVERHEAD, 1024 },
{ "max_binlog_cache_size", (long*) &max_binlog_cache_size,
~0L, IO_SIZE, ~0L, 0, IO_SIZE },
{ "max_connections", (long*) &max_connections,
100, 1, 16384, 0, 1 },
{ "max_connect_errors", (long*) &max_connect_errors,
......@@ -2465,10 +2467,12 @@ struct show_var_st init_vars[]= {
#ifdef HAVE_BERKELEY_DB
{"bdb_cache_size", (char*) &berkeley_cache_size, SHOW_LONG},
{"bdb_home", (char*) &berkeley_home, SHOW_CHAR_PTR},
{"bdb_lock_max", (char*) &berkeley_lock_max, SHOW_LONG},
{"bdb_max_lock", (char*) &berkeley_max_lock, SHOW_LONG},
{"bdb_logdir", (char*) &berkeley_logdir, SHOW_CHAR_PTR},
{"bdb_shared_data", (char*) &berkeley_shared_data, SHOW_BOOL},
{"bdb_tmpdir", (char*) &berkeley_tmpdir, SHOW_CHAR_PTR},
#endif
{"binlog_cache_size", (char*) &binlog_cache_size, SHOW_LONG},
{"character_set", default_charset, SHOW_CHAR},
{"character_sets", (char*) &charsets_list, SHOW_CHAR_PTR},
{"concurrent_insert", (char*) &myisam_concurrent_insert, SHOW_MY_BOOL},
......@@ -2497,6 +2501,7 @@ struct show_var_st init_vars[]= {
{"low_priority_updates", (char*) &low_priority_updates, SHOW_BOOL},
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_LONG},
{"max_allowed_packet", (char*) &max_allowed_packet, SHOW_LONG},
{"max_binlog_cache_size", (char*) &max_binlog_cache_size, SHOW_LONG},
{"max_connections", (char*) &max_connections, SHOW_LONG},
{"max_connect_errors", (char*) &max_connect_errors, SHOW_LONG},
{"max_delayed_threads", (char*) &max_insert_delayed_threads, SHOW_LONG},
......@@ -2711,8 +2716,9 @@ static void usage(void)
--bdb-lock-detect=# Berkeley lock detect\n\
(DEFAULT, OLDEST, RANDOM or YOUNGEST, # sec)\n\
--bdb-logdir=directory Berkeley DB log file directory\n\
--bdb-nosync Don't synchronously flush logs\n\
--bdb-no-sync Don't synchronously flush logs\n\
--bdb-recover Start Berkeley DB in recover mode\n\
--bdb-shared-data Start Berkeley DB in multi-process mode\n\
--bdb-tmpdir=directory Berkeley DB tempfile name\n\
--skip-bdb Don't use berkeley db (will save memory)\n\
");
......@@ -3224,6 +3230,10 @@ static void get_options(int argc,char **argv)
}
break;
}
case OPT_BDB_SHARED:
berkeley_init_flags&= ~(DB_PRIVATE);
berkeley_shared_data=1;
break;
case OPT_BDB_SKIP:
berkeley_skip=1;
break;
......
......@@ -207,3 +207,4 @@
"Tabulka '%-.64s' je ozna-Bena jako poruen a mla by bt opravena",-A
"Tabulka '%-.64s' je ozna-Bena jako poruen a posledn (automatick?) oprava se nezdaila",-A
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -201,3 +201,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -198,3 +198,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -198,3 +198,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -202,3 +202,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -198,3 +198,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -201,3 +201,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -198,3 +198,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -200,3 +200,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -198,3 +198,4 @@
"La tabella '%-.64s' e' segnalata come rovinata e deve essere riparata",
"La tabella '%-.64s' e' segnalata come rovinata e l'ultima ricostruzione (automatica?) e' fallita",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -200,3 +200,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -198,3 +198,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -200,3 +200,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -200,3 +200,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -202,3 +202,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -198,3 +198,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -202,3 +202,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -201,3 +201,4 @@
" '%-.64s' ",
" '%-.64s' (?) ",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -206,3 +206,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -199,3 +199,4 @@
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
......@@ -198,3 +198,5 @@
"Tabell '%-.64s' är crashad och bör repareras med REPAIR TABLE",
"Tabell '%-.64s' är crashad och senast (automatiska?) reparation misslyckades",
"Warning: Några icke transaktionella tabeller kunde inte återställas vid ROLLBACK",
#ER_TRANS_CACHE_FULL
"Transaktionen krävde mera än 'max_binlog_cache_size' minne. Utöka denna mysqld variabel och försök på nytt",
......@@ -198,3 +198,4 @@
"Tabell '%-.64s' är crashad och bör repareras med REPAIR TABLE",
"Tabell '%-.64s' är crashad och senast (automatiska?) reparation misslyckades",
"Warning: Några icke transaktionella tabeller kunde inte återställas vid ROLLBACK",
"Transaktionen krävde mera än 'max_binlog_cache_size' minne. Utöka denna mysqld variabel och försök på nytt",
......@@ -454,7 +454,7 @@ void close_temporary_tables(THD *thd)
next=table->next;
close_temporary(table);
}
if(query && mysql_bin_log.is_open())
if (query && mysql_bin_log.is_open())
{
uint save_query_len = thd->query_length;
*--p = 0;
......
......@@ -121,8 +121,10 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
#ifdef USING_TRANSACTIONS
bzero((char*) &transaction,sizeof(transaction));
if (open_cached_file(&transaction.trans_log,
mysql_tmpdir,LOG_PREFIX,0,MYF(MY_WME)))
mysql_tmpdir, LOG_PREFIX, binlog_cache_size,
MYF(MY_WME)))
killed=1;
transaction.trans_log.end_of_file= max_binlog_cache_size;
#endif
#ifdef __WIN__
......
......@@ -74,12 +74,12 @@ public:
void open(const char *log_name,enum_log_type log_type,
const char *new_name=0);
void new_file(void);
void write(THD *thd, enum enum_server_command command,const char *format,...);
void write(THD *thd, const char *query, uint query_length,
bool write(THD *thd, enum enum_server_command command,const char *format,...);
bool 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);
bool write(Query_log_event* event_info); // binary log write
bool write(Load_log_event* event_info);
bool write(IO_CACHE *cache);
int generate_new_name(char *new_name,const char *old_name);
void make_log_name(char* buf, const char* log_ident);
bool is_active(const char* log_file_name);
......
......@@ -158,14 +158,14 @@ exit:
are 2 digits (raid directories).
*/
static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *path,
static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *org_path,
uint level)
{
long deleted=0;
ulong found_other_files=0;
char filePath[FN_REFLEN];
DBUG_ENTER("mysql_rm_known_files");
DBUG_PRINT("enter",("path: %s", path));
DBUG_PRINT("enter",("path: %s", org_path));
/* remove all files with known extensions */
for (uint idx=2 ;
......@@ -181,7 +181,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *path,
{
char newpath[FN_REFLEN];
MY_DIR *new_dirp;
strxmov(newpath,path,"/",file->name,NullS);
strxmov(newpath,org_path,"/",file->name,NullS);
unpack_filename(newpath,newpath);
if ((new_dirp = my_dir(newpath,MYF(MY_DONT_SORT))))
{
......@@ -199,7 +199,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *path,
found_other_files++;
continue;
}
strxmov(filePath,path,"/",file->name,NullS);
strxmov(filePath,org_path,"/",file->name,NullS);
unpack_filename(filePath,filePath);
if (my_delete(filePath,MYF(MY_WME)))
{
......@@ -224,9 +224,9 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *path,
*/
if (!found_other_files)
{
#ifdef HAVE_READLINK
char tmp_path[FN_REFLEN];
path=unpack_filename(tmp_path,path);
char *path=unpack_filename(tmp_path,org_path);
#ifdef HAVE_READLINK
int linkcount = readlink(path,filePath,sizeof(filePath)-1);
if (linkcount > 0) // If the path was a symbolic link
{
......
......@@ -126,7 +126,7 @@ int mysql_delete(THD *thd,TABLE_LIST *table_list,COND *conds,ha_rows limit,
SQL_SELECT *select;
READ_RECORD info;
bool using_limit=limit != HA_POS_ERROR;
bool use_generate_table;
bool use_generate_table,using_transactions;
DBUG_ENTER("mysql_delete");
if (!table_list->db)
......@@ -214,18 +214,20 @@ int mysql_delete(THD *thd,TABLE_LIST *table_list,COND *conds,ha_rows limit,
(void) table->file->extra(HA_EXTRA_READCHECK);
if (options & OPTION_QUICK)
(void) table->file->extra(HA_EXTRA_NORMAL);
if (deleted)
using_transactions=table->file->has_transactions();
if (deleted && (error == 0 || !using_transactions))
{
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);
Query_log_event qinfo(thd, thd->query, using_transactions);
if (mysql_bin_log.write(&qinfo) && using_transactions)
error=1;
}
if (!table->file->has_transactions())
if (!using_transactions)
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
}
if (ha_autocommit_or_rollback(thd,error >= 0))
if (using_transactions && ha_autocommit_or_rollback(thd,error >= 0))
error=1;
if (thd->lock)
{
......
......@@ -102,6 +102,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
int error;
bool log_on= ((thd->options & OPTION_UPDATE_LOG) ||
!(thd->master_access & PROCESS_ACL));
bool using_transactions;
uint value_count;
uint save_time_stamp;
ulong counter = 1;
......@@ -254,17 +255,20 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
thd->insert_id(id); // For update log
else if (table->next_number_field)
id=table->next_number_field->val_int(); // Return auto_increment value
if (info.copied || info.deleted)
using_transactions=table->file->has_transactions();
if ((info.copied || info.deleted) && (error == 0 || !using_transactions))
{
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);
Query_log_event qinfo(thd, thd->query, using_transactions);
if (mysql_bin_log.write(&qinfo) && using_transactions)
error=1;
}
if (!table->file->has_transactions())
if (!using_transactions)
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
}
if (using_transactions)
error=ha_autocommit_or_rollback(thd,error);
if (thd->lock)
{
......@@ -1265,7 +1269,8 @@ bool select_insert::send_eof()
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
Query_log_event qinfo(thd, thd->query,
table->file->has_transactions());
mysql_bin_log.write(&qinfo);
}
return 0;
......
......@@ -245,10 +245,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
if (!table->file->has_transactions())
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
if (!read_file_from_client)
if (!read_file_from_client && mysql_bin_log.is_open())
{
ex->skip_lines = save_skip_lines;
Load_log_event qinfo(thd, ex, table->table_name, fields, handle_duplicates);
Load_log_event qinfo(thd, ex, table->table_name, fields,
handle_duplicates);
mysql_bin_log.write(&qinfo);
}
DBUG_RETURN(0);
......
......@@ -172,7 +172,7 @@ check_connections(THD *thd)
vio_description(net->vio)));
if (!thd->host) // If TCP/IP connection
{
char ip[17];
char ip[30];
if (vio_peer_addr(net->vio,ip))
return (ER_BAD_HOST_ERROR);
......@@ -718,7 +718,7 @@ bool do_command(THD *thd)
case COM_DROP_DB:
{
char *db=thd->strdup(packet+1);
if (check_access(thd,DROP_ACL,db,0,1))
if (check_access(thd,DROP_ACL,db,0,1) || end_active_trans(thd))
break;
mysql_log.write(thd,command,db);
mysql_rm_db(thd,db,0);
......@@ -1136,6 +1136,9 @@ mysql_execute_command(void)
goto error; /* purecov: inspected */
if (grant_option && check_grant(thd,INDEX_ACL,tables))
goto error;
if (end_active_trans(thd))
res= -1;
else
res = mysql_create_index(thd, tables, lex->key_list);
break;
......@@ -1224,7 +1227,9 @@ mysql_execute_command(void)
goto error;
}
}
if (mysql_rename_tables(thd,tables))
if (end_active_trans(thd))
res= -1;
else if (mysql_rename_tables(thd,tables))
res= -1;
break;
}
......@@ -1428,6 +1433,9 @@ mysql_execute_command(void)
{
if (check_table_access(thd,DROP_ACL,tables))
goto error; /* purecov: inspected */
if (end_active_trans(thd))
res= -1;
else
res = mysql_rm_table(thd,tables,lex->drop_if_exists);
}
break;
......@@ -1438,6 +1446,9 @@ mysql_execute_command(void)
goto error; /* purecov: inspected */
if (grant_option && check_grant(thd,INDEX_ACL,tables))
goto error;
if (end_active_trans(thd))
res= -1;
else
res = mysql_drop_index(thd, tables, lex->drop_list);
break;
case SQLCOM_SHOW_DATABASES:
......@@ -1643,7 +1654,8 @@ mysql_execute_command(void)
}
case SQLCOM_DROP_DB:
{
if (check_access(thd,DROP_ACL,lex->name,0,1))
if (check_access(thd,DROP_ACL,lex->name,0,1) ||
end_active_trans(thd))
break;
mysql_rm_db(thd,lex->name,lex->drop_if_exists);
break;
......
......@@ -1427,6 +1427,17 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
thd->count_cuted_fields=0; /* Don`t calc cuted fields */
new_table->time_stamp=save_time_stamp;
#if defined( __WIN__) || defined( __EMX__)
/*
We must do the COMMIT here so that we can close and rename the
temporary table (as windows can't rename open tables)
*/
if (ha_commit_stmt(thd))
error=1;
if (ha_commit(thd))
error=1;
#endif
if (table->tmp_table)
{
/* We changed a temporary table */
......@@ -1544,6 +1555,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
goto err;
}
}
#if !(defined( __WIN__) || defined( __EMX__))
/* The ALTER TABLE is always in it's own transaction */
error = ha_commit_stmt(thd);
if (ha_commit(thd))
......@@ -1554,6 +1567,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
VOID(pthread_mutex_unlock(&LOCK_open));
goto err;
}
#endif
thd->proc_info="end";
mysql_update_log.write(thd, thd->query,thd->query_length);
......
......@@ -49,7 +49,7 @@ int mysql_update(THD *thd,TABLE_LIST *table_list,List<Item> &fields,
thr_lock_type lock_type)
{
bool using_limit=limit != HA_POS_ERROR;
bool used_key_is_modified;
bool used_key_is_modified, using_transactions;
int error=0;
uint save_time_stamp, used_index;
key_map old_used_keys;
......@@ -237,18 +237,20 @@ int mysql_update(THD *thd,TABLE_LIST *table_list,List<Item> &fields,
thd->proc_info="end";
VOID(table->file->extra(HA_EXTRA_READCHECK));
table->time_stamp=save_time_stamp; // Restore auto timestamp pointer
if (updated)
using_transactions=table->file->has_transactions();
if (updated && (error == 0 || !using_transactions))
{
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);
Query_log_event qinfo(thd, thd->query, using_transactions);
if (mysql_bin_log.write(&qinfo) && using_transactions)
error=1;
}
if (!table->file->has_transactions())
if (!using_transactions)
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
}
if (ha_autocommit_or_rollback(thd, error >= 0))
if (using_transactions && ha_autocommit_or_rollback(thd, error >= 0))
error=1;
if (thd->lock)
{
......
......@@ -2451,6 +2451,7 @@ user:
keyword:
ACTION {}
| AFTER_SYM {}
| AGAINST {}
| AGGREGATE_SYM {}
| AUTOCOMMIT {}
| AVG_ROW_LENGTH {}
......
......@@ -34,10 +34,12 @@ set-variable = record_buffer=2M
set-variable = thread_cache=8
set-variable = thread_concurrency=8 # Try number of CPU's*2
set-variable = myisam_sort_buffer_size=64M
log-update
log-bin
server-id = 1
# Uncomment the following if you are using BDB tables
#set-variable = bdb_cache_size=384M
#set-variable = bdb_max_lock=100000
# Point the following paths to different dedicated disks
#tmpdir = /tmp/
......
......@@ -34,10 +34,12 @@ set-variable = record_buffer=1M
set-variable = myisam_sort_buffer_size=64M
set-variable = thread_cache=8
set-variable = thread_concurrency=8 # Try number of CPU's*2
log-update
log-bin
server-id = 1
# Uncomment the following if you are using BDB tables
#set-variable = bdb_cache_size=64M
#set-variable = bdb_max_lock=100000
# Point the following paths to different dedicated disks
#tmpdir = /tmp/
......
......@@ -33,10 +33,12 @@ set-variable = table_cache=64
set-variable = sort_buffer=512K
set-variable = net_buffer_length=8K
set-variable = myisam_sort_buffer_size=8M
log-update
log-bin
server-id = 1
# Uncomment the following if you are using BDB tables
#set-variable = bdb_cache_size=4M
#set-variable = bdb_max_lock=10000
# Point the following paths to different dedicated disks
#tmpdir = /tmp/
......
......@@ -33,12 +33,13 @@ set-variable = thread_stack=64K
set-variable = table_cache=4
set-variable = sort_buffer=64K
set-variable = net_buffer_length=2K
server-id = 1
# Uncomment the following if you are NOT using BDB tables
#skip-bdb
# Uncomment the following if you want to log updates
#log-update
#log-bin
[mysqldump]
quick
......
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