Lots of code fixes to the replication code (especially the binary logging and index log file handling)

Fixed bugs in my last changeset that made MySQL hard to compile.
Added mutex around some data that could cause table cache corruptions when using OPTIMIZE TABLE / REPAIR TABLE or automatic repair of MyISAM tables.
Added mutex around some data in the slave start/stop code that could cause THD linked list corruptions
Extended my_chsize() to allow one to specify a filler character.
Extend vio_blocking to return the old state (This made some usage of this function much simpler)
Added testing for some functions that they caller have got the required mutexes before calling the function.
Use setrlimit() to ensure that we can write core file if one specifies --core-file.
Added --slave-compressed-protocol
Made 2 the minimum length for ft_min_word_len
Added variables foreign_key_checks & unique_checks.
Less logging from replication code (if not started with --log-warnings)
Changed that SHOW INNODB STATUS requre the SUPER privilege
More DBUG statements and a lot of new code comments
This commit is contained in:
monty@mashka.mysql.fi 2002-08-08 03:12:02 +03:00
parent bc035c71f1
commit 2c4fa340cc
109 changed files with 1852 additions and 1536 deletions

View File

@ -20058,14 +20058,16 @@ If the temporary file used for fast index creation would be bigger than
using the key cache by the amount specified here, then prefer the key using the key cache by the amount specified here, then prefer the key
cache method. This is mainly used to force long character keys in large cache method. This is mainly used to force long character keys in large
tables to use the slower key cache method to create the index. tables to use the slower key cache method to create the index.
@strong{Note} that this parameter is given in megabytes! @strong{Note} that this parameter is given in megabytes before 4.0.3 and
in bytes starting from this version.
@item @code{myisam_max_sort_file_size} @item @code{myisam_max_sort_file_size}
The maximum size of the temporary file MySQL is allowed to use The maximum size of the temporary file MySQL is allowed to use
while recreating the index (during @code{REPAIR}, @code{ALTER TABLE} while recreating the index (during @code{REPAIR}, @code{ALTER TABLE}
or @code{LOAD DATA INFILE}. If the file-size would be bigger than this, or @code{LOAD DATA INFILE}. If the file-size would be bigger than this,
the index will be created through the key cache (which is slower). the index will be created through the key cache (which is slower).
@strong{Note} that this parameter is given in megabytes! @strong{Note} that this parameter is given in megabytes before 4.0.3 and
in bytes starting from this version.
@item @code{net_buffer_length} @item @code{net_buffer_length}
The communication buffer is reset to this size between queries. This The communication buffer is reset to this size between queries. This
@ -23246,11 +23248,11 @@ to the log file (by default named @file{'hostname'.log}). This log can
be very useful when you suspect an error in a client and want to know be very useful when you suspect an error in a client and want to know
exactly what @code{mysqld} thought the client sent to it. exactly what @code{mysqld} thought the client sent to it.
By default, the @code{mysql.server} script starts the MySQL By default, the @code{mysql.server} script starts the MySQL server with
server with the @code{-l} option. If you need better performance when the @code{-l} option (General query log). If you need better
you start using MySQL in a production environment, you can performance when you start using MySQL in a production environment, you
remove the @code{-l} option from @code{mysql.server} or change it to can remove the @code{-l} option from @code{mysql.server} or change it to
@code{--log-bin}. @code{--log-bin}. @xref{Binary log}.
The entries in this log are written as @code{mysqld} receives the questions. The entries in this log are written as @code{mysqld} receives the questions.
This may be different from the order in which the statements are executed. This may be different from the order in which the statements are executed.
@ -23329,7 +23331,9 @@ we recommend you to switch to this log format as soon as possible!
The binary log contains all information that is available in the update The binary log contains all information that is available in the update
log in a more efficient format. It also contains information about how long log in a more efficient format. It also contains information about how long
every query that updated the database took. every query that updated the database took. It doesn't contain queries that
doesn't modify any data. If you want to log all queries (for example to
find a problem query) you should use the general query log. @xref{Query log}.
The binary log is also used when you are replicating a slave from a master. The binary log is also used when you are replicating a slave from a master.
@xref{Replication}. @xref{Replication}.
@ -23900,7 +23904,8 @@ the slave to apply updates from one database on the master to the one
with a different name on the slave. with a different name on the slave.
@item @item
Starting in Version 3.23.28, you can use @code{PURGE MASTER LOGS TO 'log-name'} Starting in Version 3.23.28, you can use @code{PURGE MASTER LOGS TO 'log-name'}
to get rid of old logs while the slave is running. to get rid of old logs while the slave is running. This will remove all old
logs before, but not including @code{'log-name'}.
@item @item
Due to the non-transactional nature of MyISAM tables, it is possible to have Due to the non-transactional nature of MyISAM tables, it is possible to have
a query that will only partially update a table and return an error code. This a query that will only partially update a table and return an error code. This
@ -23933,7 +23938,6 @@ above bugs are conceptually very simple to fix, we have not yet found a way
to do this without a sigficant code change that would compromize the stability to do this without a sigficant code change that would compromize the stability
status of 3.23 branch. There exists a workaround for both if in the rare case status of 3.23 branch. There exists a workaround for both if in the rare case
it happens to affect your application -- use @code{slave-skip-errors}. it happens to affect your application -- use @code{slave-skip-errors}.
@end itemize @end itemize
@ -24203,6 +24207,10 @@ Example:
Tells the slave server not to start the slave on the startup. The user Tells the slave server not to start the slave on the startup. The user
can start it later with @code{SLAVE START}. can start it later with @code{SLAVE START}.
@item @code{slave_compressed_protocol=#} @tab
If 1, then use compression on the slave/client protocol if both
slave and master supports this.
@item @code{slave_net_timeout=#} @tab @item @code{slave_net_timeout=#} @tab
Number of seconds to wait for more data from the master before aborting Number of seconds to wait for more data from the master before aborting
the read. the read.
@ -28698,6 +28706,7 @@ and if you can use @code{GLOBAL} or @code{SESSION} with them.
@item delayed_queue_size @tab num @tab GLOBAL @item delayed_queue_size @tab num @tab GLOBAL
@item flush @tab bool @tab GLOBAL @item flush @tab bool @tab GLOBAL
@item flush_time @tab num @tab GLOBAL @item flush_time @tab num @tab GLOBAL
@item foreign_key_checks @tab bool @tab SESSION
@item identity @tab num @tab SESSION @item identity @tab num @tab SESSION
@item insert_id @tab bool @tab SESSION @item insert_id @tab bool @tab SESSION
@item interactive_timeout @tab num @tab GLOBAL | SESSION @item interactive_timeout @tab num @tab GLOBAL | SESSION
@ -28734,6 +28743,7 @@ and if you can use @code{GLOBAL} or @code{SESSION} with them.
@item rpl_recovery_rank @tab num @tab GLOBAL @item rpl_recovery_rank @tab num @tab GLOBAL
@item safe_show_database @tab bool @tab GLOBAL @item safe_show_database @tab bool @tab GLOBAL
@item server_id @tab num @tab GLOBAL @item server_id @tab num @tab GLOBAL
@item slave_compressed_protocol @tab bool @tab GLOBAL
@item slave_net_timeout @tab num @tab GLOBAL @item slave_net_timeout @tab num @tab GLOBAL
@item slow_launch_time @tab num @tab GLOBAL @item slow_launch_time @tab num @tab GLOBAL
@item sort_buffer_size @tab num @tab GLOBAL | SESSION @item sort_buffer_size @tab num @tab GLOBAL | SESSION
@ -28759,6 +28769,7 @@ and if you can use @code{GLOBAL} or @code{SESSION} with them.
@item tx_isolation @tab enum @tab GLOBAL | SESSION @item tx_isolation @tab enum @tab GLOBAL | SESSION
@item version @tab string @tab GLOBAL @item version @tab string @tab GLOBAL
@item wait_timeout @tab num @tab GLOBAL | SESSION @item wait_timeout @tab num @tab GLOBAL | SESSION
@item unique_checks @tab bool @tab SESSION
@end multitable @end multitable
Variables that are marked with @code{num} can be given a numerical Variables that are marked with @code{num} can be given a numerical
@ -37647,8 +37658,8 @@ The following options to @code{mysqld} can be used to change the behaviour of
@item @code{--myisam-recover=#} @tab Automatic recovery of crashed tables. @item @code{--myisam-recover=#} @tab Automatic recovery of crashed tables.
@item @code{-O myisam_sort_buffer_size=#} @tab Buffer used when recovering tables. @item @code{-O myisam_sort_buffer_size=#} @tab Buffer used when recovering tables.
@item @code{--delay-key-write-for-all-tables} @tab Don't flush key buffers between writes for any MyISAM table @item @code{--delay-key-write-for-all-tables} @tab Don't flush key buffers between writes for any MyISAM table
@item @code{-O myisam_max_extra_sort_file_size=#} @tab Used to help MySQL to decide when to use the slow but safe key cache index create method. @strong{Note} that this parameter is given in megabytes! @item @code{-O myisam_max_extra_sort_file_size=#} @tab Used to help MySQL to decide when to use the slow but safe key cache index create method. @strong{Note} that this parameter is given in megabytes before 4.0.3 and in bytes starting from this version.
@item @code{-O myisam_max_sort_file_size=#} @tab Don't use the fast sort index method to created index if the temporary file would get bigger than this. @strong{Note} that this paramter is given in megabytes! @item @code{-O myisam_max_sort_file_size=#} @tab Don't use the fast sort index method to created index if the temporary file would get bigger than this. @strong{Note} that this parameter is given in megabytes before 4.0.3 and in bytes starting from this version.
@item @code{-O bulk_insert_buffer_size=#} @tab Size of tree cache used in bulk insert optimisation. @strong{Note} that this is a limit @strong{per thread}! @item @code{-O bulk_insert_buffer_size=#} @tab Size of tree cache used in bulk insert optimisation. @strong{Note} that this is a limit @strong{per thread}!
@end multitable @end multitable
@ -50016,9 +50027,14 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@appendixsubsec Changes in release 4.0.3 @appendixsubsec Changes in release 4.0.3
@itemize @bullet @itemize @bullet
@item @item
Big code cleanup in replication code.
@item
If one specifies @code{--code-file}, call @code{setrlmit()} to change allowed
core file size to unlimited, to be able to generate core files.
@item
Allow @code{DEFAULT} with @code{INSERT} statement. Allow @code{DEFAULT} with @code{INSERT} statement.
@item @item
The startup parameters @code{myisam_max_extra_sort_file_size} and The startup parameters @code{myisam_max_sort_file_size} and
@code{myisam_max_extra_sort_file_size} are now given in bytes, not megabytes. @code{myisam_max_extra_sort_file_size} are now given in bytes, not megabytes.
@item @item
External system locking of MyISAM/ISAM files is now turned off by default. External system locking of MyISAM/ISAM files is now turned off by default.
@ -50034,6 +50050,8 @@ Fixed a timing bug in @code{DROP DATABASE}
New @code{SET [GLOBAL | SESSION]} syntax to change thread specific and global New @code{SET [GLOBAL | SESSION]} syntax to change thread specific and global
server variables at runtime. server variables at runtime.
@item @item
Added variable @code{slave_compressed_protocol}.
@item
Renamed variable @code{query_cache_startup_type} to @code{query_cache_type}, Renamed variable @code{query_cache_startup_type} to @code{query_cache_type},
@code{myisam_bulk_insert_tree_size} to @code{bulk_insert_buffer_size}, @code{myisam_bulk_insert_tree_size} to @code{bulk_insert_buffer_size},
@code{record_buffer} to @code{read_buffer_size} and @code{record_buffer} to @code{read_buffer_size} and

View File

@ -42,7 +42,7 @@
**********************************************************************/ **********************************************************************/
#define MTEST_VERSION "1.24" #define MTEST_VERSION "1.25"
#include <my_global.h> #include <my_global.h>
#include <mysql_embed.h> #include <mysql_embed.h>
@ -314,25 +314,24 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
register int escaped = 0; register int escaped = 0;
VAR* v; VAR* v;
for(p = query; (c = *p); ++p) for (p= query; (c = *p); ++p)
{
switch(c)
{ {
switch(c) {
case '$': case '$':
if(escaped) if (escaped)
{ {
escaped = 0; escaped = 0;
dynstr_append_mem(query_eval, p, 1); dynstr_append_mem(query_eval, p, 1);
} }
else else
{ {
if(!(v = var_get(p, &p, 0, 0))) if (!(v = var_get(p, &p, 0, 0)))
die("Bad variable in eval"); die("Bad variable in eval");
dynstr_append_mem(query_eval, v->str_val, v->str_val_len); dynstr_append_mem(query_eval, v->str_val, v->str_val_len);
} }
break; break;
case '\\': case '\\':
if(escaped) if (escaped)
{ {
escaped = 0; escaped = 0;
dynstr_append_mem(query_eval, p, 1); dynstr_append_mem(query_eval, p, 1);
@ -347,6 +346,7 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
} }
} }
static void close_cons() static void close_cons()
{ {
DBUG_ENTER("close_cons"); DBUG_ENTER("close_cons");
@ -360,6 +360,7 @@ static void close_cons()
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
static void close_files() static void close_files()
{ {
DBUG_ENTER("close_files"); DBUG_ENTER("close_files");
@ -371,6 +372,7 @@ static void close_files()
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
static void free_used_memory() static void free_used_memory()
{ {
uint i; uint i;
@ -389,9 +391,9 @@ static void free_used_memory()
my_free((gptr) (*q)->query_buf,MYF(MY_ALLOW_ZERO_PTR)); my_free((gptr) (*q)->query_buf,MYF(MY_ALLOW_ZERO_PTR));
my_free((gptr) (*q),MYF(0)); my_free((gptr) (*q),MYF(0));
} }
for(i=0; i < 10; i++) for (i=0; i < 10; i++)
{ {
if(var_reg[i].alloced_len) if (var_reg[i].alloced_len)
my_free(var_reg[i].str_val, MYF(MY_WME)); my_free(var_reg[i].str_val, MYF(MY_WME));
} }
while (embedded_server_arg_count > 1) while (embedded_server_arg_count > 1)
@ -503,7 +505,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname)
{ {
do_eval(&res_ds, tmp); do_eval(&res_ds, tmp);
res_ptr = res_ds.str; res_ptr = res_ds.str;
if((res_len = res_ds.length) != ds->length) if ((res_len = res_ds.length) != ds->length)
{ {
res = 2; res = 2;
goto err; goto err;
@ -518,7 +520,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname)
res = (memcmp(res_ptr, ds->str, res_len)) ? 1 : 0; res = (memcmp(res_ptr, ds->str, res_len)) ? 1 : 0;
err: err:
if(res && eval_result) if (res && eval_result)
str_to_file(fn_format(eval_file, fname, "", ".eval",2), res_ptr, str_to_file(fn_format(eval_file, fname, "", ".eval",2), res_ptr,
res_len); res_len);
@ -537,8 +539,7 @@ static int check_result(DYNAMIC_STRING* ds, const char* fname,
if (res && require_option) if (res && require_option)
abort_not_supported_test(); abort_not_supported_test();
switch (res) switch (res) {
{
case 0: case 0:
break; /* ok */ break; /* ok */
case 2: case 2:
@ -614,7 +615,7 @@ err:
static VAR* var_obtain(char* name, int len) static VAR* var_obtain(char* name, int len)
{ {
VAR* v; VAR* v;
if((v = (VAR*)hash_search(&var_hash, name, len))) if ((v = (VAR*)hash_search(&var_hash, name, len)))
return v; return v;
v = var_init(0, name, len, "", 0); v = var_init(0, name, len, "", 0);
hash_insert(&var_hash, (byte*)v); hash_insert(&var_hash, (byte*)v);
@ -855,7 +856,7 @@ int eval_expr(VAR* v, const char* p, const char** p_end)
return 0; return 0;
} }
} }
else if(*p == '`') else if (*p == '`')
{ {
return var_query_set(v, p, p_end); return var_query_set(v, p, p_end);
} }
@ -944,6 +945,7 @@ int do_echo(struct st_query* q)
return 0; return 0;
} }
int do_sync_with_master(struct st_query* q) int do_sync_with_master(struct st_query* q)
{ {
MYSQL_RES* res; MYSQL_RES* res;
@ -954,31 +956,36 @@ int do_sync_with_master(struct st_query* q)
char* p = q->first_argument; char* p = q->first_argument;
int rpl_parse; int rpl_parse;
if (!master_pos.file[0])
{
die("Line %u: Calling 'sync_with_master' without calling 'save_master_pos'", start_lineno);
}
rpl_parse = mysql_rpl_parse_enabled(mysql); rpl_parse = mysql_rpl_parse_enabled(mysql);
mysql_disable_rpl_parse(mysql); mysql_disable_rpl_parse(mysql);
if(*p) if (*p)
offset = atoi(p); offset = atoi(p);
sprintf(query_buf, "select master_pos_wait('%s', %ld)", master_pos.file, sprintf(query_buf, "select master_pos_wait('%s', %ld)", master_pos.file,
master_pos.pos + offset); master_pos.pos + offset);
if(mysql_query(mysql, query_buf)) if (mysql_query(mysql, query_buf))
die("At line %u: failed in %s: %d: %s", start_lineno, query_buf, die("line %u: failed in %s: %d: %s", start_lineno, query_buf,
mysql_errno(mysql), mysql_error(mysql)); mysql_errno(mysql), mysql_error(mysql));
if(!(last_result = res = mysql_store_result(mysql))) if (!(last_result = res = mysql_store_result(mysql)))
die("line %u: mysql_store_result() retuned NULL", start_lineno); die("line %u: mysql_store_result() retuned NULL", start_lineno);
if(!(row = mysql_fetch_row(res))) if (!(row = mysql_fetch_row(res)))
die("line %u: empty result in %s", start_lineno, query_buf); die("line %u: empty result in %s", start_lineno, query_buf);
if(!row[0]) if (!row[0])
die("Error on slave while syncing with master"); die("Error on slave while syncing with master");
mysql_free_result(res); last_result=0; mysql_free_result(res); last_result=0;
if(rpl_parse) if (rpl_parse)
mysql_enable_rpl_parse(mysql); mysql_enable_rpl_parse(mysql);
return 0; return 0;
} }
int do_save_master_pos() int do_save_master_pos()
{ {
MYSQL_RES* res; MYSQL_RES* res;
@ -989,19 +996,19 @@ int do_save_master_pos()
rpl_parse = mysql_rpl_parse_enabled(mysql); rpl_parse = mysql_rpl_parse_enabled(mysql);
mysql_disable_rpl_parse(mysql); mysql_disable_rpl_parse(mysql);
if(mysql_query(mysql, "show master status")) if (mysql_query(mysql, "show master status"))
die("At line %u: failed in show master status: %d: %s", start_lineno, die("At line %u: failed in show master status: %d: %s", start_lineno,
mysql_errno(mysql), mysql_error(mysql)); mysql_errno(mysql), mysql_error(mysql));
if(!(last_result =res = mysql_store_result(mysql))) if (!(last_result =res = mysql_store_result(mysql)))
die("line %u: mysql_store_result() retuned NULL", start_lineno); die("line %u: mysql_store_result() retuned NULL", start_lineno);
if(!(row = mysql_fetch_row(res))) if (!(row = mysql_fetch_row(res)))
die("line %u: empty result in show master status", start_lineno); die("line %u: empty result in show master status", start_lineno);
strncpy(master_pos.file, row[0], sizeof(master_pos.file)); strnmov(master_pos.file, row[0], sizeof(master_pos.file)-1);
master_pos.pos = strtoul(row[1], (char**) 0, 10); master_pos.pos = strtoul(row[1], (char**) 0, 10);
mysql_free_result(res); last_result=0; mysql_free_result(res); last_result=0;
if(rpl_parse) if (rpl_parse)
mysql_enable_rpl_parse(mysql); mysql_enable_rpl_parse(mysql);
return 0; return 0;
@ -1027,7 +1034,7 @@ int do_let(struct st_query* q)
int do_rpl_probe(struct st_query* q __attribute__((unused))) int do_rpl_probe(struct st_query* q __attribute__((unused)))
{ {
if(mysql_rpl_probe(&cur_con->mysql)) if (mysql_rpl_probe(&cur_con->mysql))
die("Failed in mysql_rpl_probe(): %s", mysql_error(&cur_con->mysql)); die("Failed in mysql_rpl_probe(): %s", mysql_error(&cur_con->mysql));
return 0; return 0;
} }
@ -1079,7 +1086,7 @@ int do_sleep(struct st_query* q)
p++; p++;
p_end = p + 6; p_end = p + 6;
for(;p <= p_end; ++p) for (;p <= p_end; ++p)
{ {
c = (int) (*p - '0'); c = (int) (*p - '0');
if (c < 10 && (int) c >= 0) if (c < 10 && (int) c >= 0)
@ -1975,7 +1982,7 @@ int parse_args(int argc, char **argv)
char* safe_str_append(char* buf, const char* str, int size) char* safe_str_append(char* buf, const char* str, int size)
{ {
int i,c ; int i,c ;
for(i = 0; (c = *str++) && i < size - 1; i++) for (i = 0; (c = *str++) && i < size - 1; i++)
*buf++ = c; *buf++ = c;
*buf = 0; *buf = 0;
return buf; return buf;
@ -2164,7 +2171,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
while ((row = mysql_fetch_row(res))) while ((row = mysql_fetch_row(res)))
{ {
lengths = mysql_fetch_lengths(res); lengths = mysql_fetch_lengths(res);
for(i = 0; i < num_fields; i++) for (i = 0; i < num_fields; i++)
{ {
val = (char*)row[i]; val = (char*)row[i];
len = lengths[i]; len = lengths[i];
@ -2202,7 +2209,7 @@ end:
last_result=0; last_result=0;
if (ds == &ds_tmp) if (ds == &ds_tmp)
dynstr_free(&ds_tmp); dynstr_free(&ds_tmp);
if(q->type == Q_EVAL) if (q->type == Q_EVAL)
dynstr_free(&eval_query); dynstr_free(&eval_query);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
@ -2475,8 +2482,7 @@ int main(int argc, char** argv)
if (!processed) if (!processed)
{ {
current_line_inc = 0; current_line_inc = 0;
switch(q->type) switch(q->type) {
{
case Q_WHILE: do_while(q); break; case Q_WHILE: do_while(q); break;
case Q_END_BLOCK: do_done(q); break; case Q_END_BLOCK: do_done(q); break;
default: current_line_inc = 1; break; default: current_line_inc = 1; break;
@ -3218,7 +3224,7 @@ uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
end=(to= *start) + *max_length-1; end=(to= *start) + *max_length-1;
rep_pos=rep+1; rep_pos=rep+1;
for(;;) for (;;)
{ {
while (!rep_pos->found) while (!rep_pos->found)
{ {

View File

@ -476,6 +476,9 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__) #define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
#define pthread_mutex_trylock(A) pthread_mutex_lock(A) #define pthread_mutex_trylock(A) pthread_mutex_lock(A)
#define pthread_mutex_t safe_mutex_t #define pthread_mutex_t safe_mutex_t
#define safe_mutex_assert_owner(mp) DBUG_ASSERT((mp)->count > 0 && pthread_equal(pthread_self(),(mp)->thread))
#else
#define safe_mutex_assert_owner(mp)
#endif /* SAFE_MUTEX */ #endif /* SAFE_MUTEX */
/* READ-WRITE thread locking */ /* READ-WRITE thread locking */

View File

@ -556,7 +556,7 @@ extern void init_glob_errs(void);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags); extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
extern int my_fclose(FILE *fd,myf MyFlags); extern int my_fclose(FILE *fd,myf MyFlags);
extern int my_chsize(File fd,my_off_t newlength,myf MyFlags); extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
extern int my_error _VARARGS((int nr,myf MyFlags, ...)); extern int my_error _VARARGS((int nr,myf MyFlags, ...));
extern int my_printf_error _VARARGS((uint my_err, const char *format, extern int my_printf_error _VARARGS((uint my_err, const char *format,
myf MyFlags, ...) myf MyFlags, ...)
@ -678,6 +678,7 @@ extern int end_io_cache(IO_CACHE *info);
extern uint my_b_fill(IO_CACHE *info); extern uint my_b_fill(IO_CACHE *info);
extern void my_b_seek(IO_CACHE *info,my_off_t pos); 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_gets(IO_CACHE *info, char *to, uint max_length);
extern my_off_t my_b_filelength(IO_CACHE *info);
extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...); extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap); extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir, extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,

View File

@ -27,7 +27,10 @@ C_MODE_START
extern const char *raid_type_string[]; extern const char *raid_type_string[];
C_MODE_END C_MODE_END
#if defined(USE_RAID) && !defined(DONT_USE_RAID) #ifdef DONT_USE_RAID
#undef USE_RAID
#endif
#if defined(USE_RAID)
#ifdef __GNUC__ #ifdef __GNUC__
#pragma interface /* gcc class implementation */ #pragma interface /* gcc class implementation */
@ -41,7 +44,7 @@ C_MODE_END
#define my_write(A,B,C,D) my_raid_write(A,B,C,D) #define my_write(A,B,C,D) my_raid_write(A,B,C,D)
#define my_pwrite(A,B,C,D,E) my_raid_pwrite(A,B,C,D,E) #define my_pwrite(A,B,C,D,E) my_raid_pwrite(A,B,C,D,E)
#define my_pread(A,B,C,D,E) my_raid_pread(A,B,C,D,E) #define my_pread(A,B,C,D,E) my_raid_pread(A,B,C,D,E)
#define my_chsize(A,B,C) my_raid_chsize(A,B,C) #define my_chsize(A,B,C,D) my_raid_chsize(A,B,C,D)
#define my_close(A,B) my_raid_close(A,B) #define my_close(A,B) my_raid_close(A,B)
#define my_tell(A,B) my_raid_tell(A,B) #define my_tell(A,B) my_raid_tell(A,B)
#define my_seek(A,B,C,D) my_raid_seek(A,B,C,D) #define my_seek(A,B,C,D) my_raid_seek(A,B,C,D)
@ -82,7 +85,7 @@ extern "C" {
int my_raid_lock(File,int locktype, my_off_t start, my_off_t length, int my_raid_lock(File,int locktype, my_off_t start, my_off_t length,
myf MyFlags); myf MyFlags);
int my_raid_chsize(File fd, my_off_t newlength, myf MyFlags); int my_raid_chsize(File fd, my_off_t newlength, int filler, myf MyFlags);
int my_raid_close(File, myf MyFlags); int my_raid_close(File, myf MyFlags);
int my_raid_fstat(int Filedes, struct stat *buf, myf MyFlags); int my_raid_fstat(int Filedes, struct stat *buf, myf MyFlags);
@ -113,7 +116,7 @@ class RaidFd {
int Write(const byte *Buffer, uint Count, myf MyFlags); int Write(const byte *Buffer, uint Count, myf MyFlags);
int Read(const byte *Buffer, uint Count, myf MyFlags); int Read(const byte *Buffer, uint Count, myf MyFlags);
int Lock(int locktype, my_off_t start, my_off_t length, myf MyFlags); int Lock(int locktype, my_off_t start, my_off_t length, myf MyFlags);
int Chsize(File fd, my_off_t newlength, myf MyFlags); int Chsize(File fd, my_off_t newlength, int filler, myf MyFlags);
int Fstat(int fd, MY_STAT *stat_area, myf MyFlags ); int Fstat(int fd, MY_STAT *stat_area, myf MyFlags );
int Close(myf MyFlags); int Close(myf MyFlags);
static bool IsRaid(File fd); static bool IsRaid(File fd);

View File

@ -60,7 +60,7 @@ int vio_write(Vio *vio, const gptr buf, int size);
/* /*
* Whenever the socket is set to blocking mode or not. * Whenever the socket is set to blocking mode or not.
*/ */
int vio_blocking(Vio *vio, my_bool onoff); int vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode);
my_bool vio_is_blocking(Vio *vio); my_bool vio_is_blocking(Vio *vio);
/* /*
* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. * setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible.
@ -112,7 +112,8 @@ my_bool vio_poll_read(Vio *vio,uint timeout);
#define vio_errno(vio) (vio)->vioerrno(vio) #define vio_errno(vio) (vio)->vioerrno(vio)
#define vio_read(vio, buf, size) (vio)->read(vio,buf,size) #define vio_read(vio, buf, size) (vio)->read(vio,buf,size)
#define vio_write(vio, buf, size) (vio)->write(vio, buf, size) #define vio_write(vio, buf, size) (vio)->write(vio, buf, size)
#define vio_blocking(vio, set_blocking_mode) (vio)->vioblocking(vio, set_blocking_mode) #define vio_blocking(vio, set_blocking_mode, old_mode)\
(vio)->vioblocking(vio, set_blocking_mode, old_mode)
#define vio_is_blocking(vio) (vio)->is_blocking(vio) #define vio_is_blocking(vio) (vio)->is_blocking(vio)
#define vio_fastsend(vio) (vio)->fastsend(vio) #define vio_fastsend(vio) (vio)->fastsend(vio)
#define vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive) #define vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive)
@ -213,7 +214,7 @@ struct st_vio
int (*vioerrno)(Vio*); int (*vioerrno)(Vio*);
int (*read)(Vio*, gptr, int); int (*read)(Vio*, gptr, int);
int (*write)(Vio*, gptr, int); int (*write)(Vio*, gptr, int);
int (*vioblocking)(Vio*, my_bool); int (*vioblocking)(Vio*, my_bool, my_bool *);
my_bool (*is_blocking)(Vio*); my_bool (*is_blocking)(Vio*);
int (*viokeepalive)(Vio*, my_bool); int (*viokeepalive)(Vio*, my_bool);
int (*fastsend)(Vio*); int (*fastsend)(Vio*);

View File

@ -17,13 +17,8 @@ typedef struct dyn_block_struct dyn_block_t;
typedef dyn_block_t dyn_array_t; typedef dyn_block_t dyn_array_t;
/* Initial 'payload' size in bytes in a dynamic array block */ /* This must be > MLOG_BUF_MARGIN + 30 */
#ifndef _AIX #define DYN_ARRAY_DATA_SIZE 512
#define DYN_ARRAY_DATA_SIZE 1024
#else
/* AIX has a quite small stack / thread */
#define DYN_ARRAY_DATA_SIZE 128
#endif
/************************************************************************* /*************************************************************************
Initializes a dynamic array. */ Initializes a dynamic array. */

View File

@ -185,7 +185,8 @@ dyn_array_open(
/*===========*/ /*===========*/
/* out: pointer to the buffer */ /* out: pointer to the buffer */
dyn_array_t* arr, /* in: dynamic array */ dyn_array_t* arr, /* in: dynamic array */
ulint size) /* in: size in bytes of the buffer */ ulint size) /* in: size in bytes of the buffer; MUST be
smaller than DYN_ARRAY_DATA_SIZE! */
{ {
dyn_block_t* block; dyn_block_t* block;
ulint used; ulint used;
@ -207,6 +208,7 @@ dyn_array_open(
if (used + size > DYN_ARRAY_DATA_SIZE) { if (used + size > DYN_ARRAY_DATA_SIZE) {
block = dyn_array_add_block(arr); block = dyn_array_add_block(arr);
used = block->used; used = block->used;
ut_a(size <= DYN_ARRAY_DATA_SIZE);
} }
} }

View File

@ -294,13 +294,13 @@ int nisam_create(const char *name,uint keys,N_KEYDEF *keyinfo,
goto err; goto err;
/* Enlarge files */ /* Enlarge files */
if (my_chsize(file,(ulong) share.base.keystart,MYF(0))) if (my_chsize(file, (ulong) share.base.keystart, 0, MYF(0)))
goto err; goto err;
if (! (flags & HA_DONT_TOUCH_DATA)) if (! (flags & HA_DONT_TOUCH_DATA))
{ {
#ifdef USE_RELOC #ifdef USE_RELOC
if (my_chsize(dfile,share.base.min_pack_length*reloc,MYF(0))) if (my_chsize(dfile, share.base.min_pack_length*reloc, 0, MYF(0)))
goto err; goto err;
#endif #endif
errpos=1; errpos=1;

View File

@ -1552,7 +1552,7 @@ my_string name;
{ {
VOID(fputs(" \r",stdout)); VOID(fflush(stdout)); VOID(fputs(" \r",stdout)); VOID(fflush(stdout));
} }
if (my_chsize(share->kfile,share->state.key_file_length,MYF(0))) if (my_chsize(share->kfile, share->state.key_file_length, 0, MYF(0)))
{ {
print_warning("Can't change size of indexfile, error: %d",my_errno); print_warning("Can't change size of indexfile, error: %d",my_errno);
goto err; goto err;
@ -2514,10 +2514,10 @@ my_string name;
skr=share->base.reloc*share->base.min_pack_length; skr=share->base.reloc*share->base.min_pack_length;
#endif #endif
if (skr != sort_info.filelength) if (skr != sort_info.filelength)
if (my_chsize(info->dfile,skr,MYF(0))) if (my_chsize(info->dfile, skr, 0, MYF(0)))
print_warning("Can't change size of datafile, error: %d",my_errno); print_warning("Can't change size of datafile, error: %d",my_errno);
} }
if (my_chsize(share->kfile,share->state.key_file_length,MYF(0))) if (my_chsize(share->kfile, share->state.key_file_length, 0, MYF(0)))
print_warning("Can't change size of indexfile, error: %d",my_errno); print_warning("Can't change size of indexfile, error: %d",my_errno);
if (!(testflag & T_SILENT)) if (!(testflag & T_SILENT))

View File

@ -1959,7 +1959,7 @@ static void save_state(N_INFO *isam_file,MRG_INFO *mrg,my_off_t new_length,
isam_file->update|=(HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); isam_file->update|=(HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
isam_file->this_uniq=crc; /* Save crc here */ isam_file->this_uniq=crc; /* Save crc here */
share->changed=1; /* Force write of header */ share->changed=1; /* Force write of header */
VOID(my_chsize(share->kfile,share->state.key_file_length, VOID(my_chsize(share->kfile, share->state.key_file_length, 0,
MYF(0))); MYF(0)));
if (share->state.keys != share->base.keys) if (share->state.keys != share->base.keys)
isamchk_neaded=1; isamchk_neaded=1;

View File

@ -90,6 +90,7 @@ MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
char msg_buf[MAX_MYSQL_MANAGER_MSG]; char msg_buf[MAX_MYSQL_MANAGER_MSG];
int msg_len; int msg_len;
Vio* vio; Vio* vio;
my_bool not_used;
if (!host) if (!host)
host="localhost"; host="localhost";
@ -110,7 +111,7 @@ MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
strmov(con->last_error,"Cannot create network I/O object"); strmov(con->last_error,"Cannot create network I/O object");
goto err; goto err;
} }
vio_blocking(vio,TRUE); vio_blocking(vio, TRUE, &not_used);
my_net_init(&con->net,vio); my_net_init(&con->net,vio);
bzero((char*) &sock_addr,sizeof(sock_addr)); bzero((char*) &sock_addr,sizeof(sock_addr));
sock_addr.sin_family = AF_INET; sock_addr.sin_family = AF_INET;

View File

@ -459,17 +459,18 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
/* Setup log files */ /* Setup log files */
if (opt_log) if (opt_log)
open_log(&mysql_log, glob_hostname, opt_logname, ".log", LOG_NORMAL); open_log(&mysql_log, glob_hostname, opt_logname, ".log", NullS,
LOG_NORMAL);
if (opt_update_log) if (opt_update_log)
{ {
open_log(&mysql_update_log, glob_hostname, opt_update_logname, "", open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
LOG_NEW); NullS, LOG_NEW);
using_update_log=1; using_update_log=1;
} }
if (opt_slow_log) if (opt_slow_log)
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log", open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
LOG_NORMAL); NullS, LOG_NORMAL);
if (ha_init()) if (ha_init())
{ {
sql_print_error("Can't init databases"); sql_print_error("Can't init databases");
@ -532,9 +533,8 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
strmov(strcend(tmp,'.'),"-bin"); strmov(strcend(tmp,'.'),"-bin");
opt_bin_logname=my_strdup(tmp,MYF(MY_WME)); 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, glob_hostname, opt_bin_logname, "-bin", open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
LOG_BIN); opt_binlog_index_name, LOG_BIN);
using_update_log=1; using_update_log=1;
} }

View File

@ -73,7 +73,7 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length,
if (flag & READING_NEXT || info->share) if (flag & READING_NEXT || info->share)
{ {
if (pos != (info->pos_in_file + if (pos != (info->pos_in_file +
(uint) (info->rc_end - info->rc_request_pos))) (uint) (info->read_end - info->request_pos)))
{ {
info->pos_in_file=pos; /* Force start here */ info->pos_in_file=pos; /* Force start here */
info->read_pos=info->read_end=info->request_pos; /* Everything used */ info->read_pos=info->read_end=info->request_pos; /* Everything used */

View File

@ -1259,7 +1259,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
{ {
VOID(fputs(" \r",stdout)); VOID(fflush(stdout)); VOID(fputs(" \r",stdout)); VOID(fflush(stdout));
} }
if (my_chsize(share->kfile,info->state->key_file_length,MYF(0))) if (my_chsize(share->kfile,info->state->key_file_length,0,MYF(0)))
{ {
mi_check_print_warning(param, mi_check_print_warning(param,
"Can't change size of indexfile, error: %d", "Can't change size of indexfile, error: %d",
@ -2027,7 +2027,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
skr=share->base.reloc*share->base.min_pack_length; skr=share->base.reloc*share->base.min_pack_length;
#endif #endif
if (skr != sort_info.filelength && !info->s->base.raid_type) if (skr != sort_info.filelength && !info->s->base.raid_type)
if (my_chsize(info->dfile,skr,MYF(0))) if (my_chsize(info->dfile,skr,0,MYF(0)))
mi_check_print_warning(param, mi_check_print_warning(param,
"Can't change size of datafile, error: %d", "Can't change size of datafile, error: %d",
my_errno); my_errno);
@ -2035,7 +2035,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
if (param->testflag & T_CALC_CHECKSUM) if (param->testflag & T_CALC_CHECKSUM)
share->state.checksum=param->glob_crc; share->state.checksum=param->glob_crc;
if (my_chsize(share->kfile,info->state->key_file_length,MYF(0))) if (my_chsize(share->kfile,info->state->key_file_length,0,MYF(0)))
mi_check_print_warning(param, mi_check_print_warning(param,
"Can't change size of indexfile, error: %d", "Can't change size of indexfile, error: %d",
my_errno); my_errno);
@ -2410,7 +2410,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
skr=share->base.reloc*share->base.min_pack_length; skr=share->base.reloc*share->base.min_pack_length;
#endif #endif
if (skr != sort_info.filelength && !info->s->base.raid_type) if (skr != sort_info.filelength && !info->s->base.raid_type)
if (my_chsize(info->dfile,skr,MYF(0))) if (my_chsize(info->dfile,skr,0,MYF(0)))
mi_check_print_warning(param, mi_check_print_warning(param,
"Can't change size of datafile, error: %d", "Can't change size of datafile, error: %d",
my_errno); my_errno);
@ -2418,7 +2418,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
if (param->testflag & T_CALC_CHECKSUM) if (param->testflag & T_CALC_CHECKSUM)
share->state.checksum=param->glob_crc; share->state.checksum=param->glob_crc;
if (my_chsize(share->kfile,info->state->key_file_length,MYF(0))) if (my_chsize(share->kfile,info->state->key_file_length,0,MYF(0)))
mi_check_print_warning(param, mi_check_print_warning(param,
"Can't change size of indexfile, error: %d", my_errno); "Can't change size of indexfile, error: %d", my_errno);

View File

@ -616,13 +616,13 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
#endif #endif
/* Enlarge files */ /* Enlarge files */
if (my_chsize(file,(ulong) share.base.keystart,MYF(0))) if (my_chsize(file,(ulong) share.base.keystart,0,MYF(0)))
goto err; goto err;
if (! (flags & HA_DONT_TOUCH_DATA)) if (! (flags & HA_DONT_TOUCH_DATA))
{ {
#ifdef USE_RELOC #ifdef USE_RELOC
if (my_chsize(dfile,share.base.min_pack_length*ci->reloc_rows,MYF(0))) if (my_chsize(dfile,share.base.min_pack_length*ci->reloc_rows,0,MYF(0)))
goto err; goto err;
#endif #endif
errpos=2; errpos=2;

View File

@ -50,7 +50,7 @@ int mi_delete_all_rows(MI_INFO *info)
myisam_log_command(MI_LOG_DELETE_ALL,info,(byte*) 0,0,0); myisam_log_command(MI_LOG_DELETE_ALL,info,(byte*) 0,0,0);
VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE)); VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
if (my_chsize(info->dfile, 0, MYF(MY_WME))) if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)))
goto err; goto err;
allow_break(); /* Allow SIGHUP & SIGINT */ allow_break(); /* Allow SIGHUP & SIGINT */
DBUG_RETURN(0); DBUG_RETURN(0);

View File

@ -2046,7 +2046,7 @@ static int save_state(MI_INFO *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length,
share->changed=1; /* Force write of header */ share->changed=1; /* Force write of header */
share->state.open_count=0; share->state.open_count=0;
share->global_changed=0; share->global_changed=0;
VOID(my_chsize(share->kfile,share->state.state.key_file_length, VOID(my_chsize(share->kfile, share->state.state.key_file_length, 0,
MYF(0))); MYF(0)));
if (share->base.keys) if (share->base.keys)
isamchk_neaded=1; isamchk_neaded=1;

View File

@ -7,6 +7,7 @@ connection slave;
!slave stop; !slave stop;
@r/slave-stopped.result show status like 'Slave_running'; @r/slave-stopped.result show status like 'Slave_running';
connection master; connection master;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
connection slave; connection slave;
reset slave; reset slave;
@ -14,3 +15,6 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start; slave start;
@r/slave-running.result show status like 'Slave_running'; @r/slave-running.result show status like 'Slave_running';
# Set the default connection to 'master'
connection master;

View File

@ -234,6 +234,10 @@ while test $# -gt 0; do
--skip-rpl) NO_SLAVE=1 ;; --skip-rpl) NO_SLAVE=1 ;;
--skip-test=*) SKIP_TEST=`$ECHO "$1" | $SED -e "s;--skip-test=;;"`;; --skip-test=*) SKIP_TEST=`$ECHO "$1" | $SED -e "s;--skip-test=;;"`;;
--do-test=*) DO_TEST=`$ECHO "$1" | $SED -e "s;--do-test=;;"`;; --do-test=*) DO_TEST=`$ECHO "$1" | $SED -e "s;--do-test=;;"`;;
--warnings | --log-warnings)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --log-warnings"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --log-warnings"
;;
--wait-timeout=*) --wait-timeout=*)
START_WAIT_TIMEOUT=`$ECHO "$1" | $SED -e "s;--wait-timeout=;;"` START_WAIT_TIMEOUT=`$ECHO "$1" | $SED -e "s;--wait-timeout=;;"`
STOP_WAIT_TIMEOUT=$START_WAIT_TIMEOUT;; STOP_WAIT_TIMEOUT=$START_WAIT_TIMEOUT;;
@ -456,10 +460,6 @@ XTERM=`which xterm`
#++ #++
# Function Definitions # Function Definitions
#-- #--
wait_for_server_start ()
{
$MYSQLADMIN --no-defaults -u $DBUSER --silent -O connect_timeout=10 -w2 --host=$hostname --port=$1 ping >/dev/null 2>&1
}
prompt_user () prompt_user ()
{ {
@ -845,7 +845,7 @@ start_slave()
master_info="--master-user=root \ master_info="--master-user=root \
--master-connect-retry=1 \ --master-connect-retry=1 \
--master-host=127.0.0.1 \ --master-host=127.0.0.1 \
--master-password= \ --master-password="" \
--master-port=$MASTER_MYPORT \ --master-port=$MASTER_MYPORT \
--server-id=$slave_server_id --rpl-recovery-rank=$slave_rpl_rank" --server-id=$slave_server_id --rpl-recovery-rank=$slave_rpl_rank"
else else

View File

@ -19,25 +19,27 @@ insert into t1 values (0,"mysql a");
insert into t1 values (0,"r1manic"); insert into t1 values (0,"r1manic");
insert into t1 values (0,"r1man"); insert into t1 values (0,"r1man");
drop table t1; drop table t1;
create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello"); create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello", i int);
insert into t1 values (default,default,default), (default,default,default), (4,0,"a"),(default,default,default); insert into t1 values (default,default,default,default), (default,default,default,default), (4,0,"a",5),(default,default,default,default);
select a,t>0,c from t1; select a,t>0,c,i from t1;
a t>0 c a t>0 c i
1 1 hello 1 1 hello NULL
2 1 hello 2 1 hello NULL
4 0 a 4 0 a 5
5 1 hello 5 1 hello NULL
truncate table t1; truncate table t1;
insert into t1 set a=default,t=default,c=default; insert into t1 set a=default,t=default,c=default;
insert into t1 set a=default,t=default,c=default; insert into t1 set a=default,t=default,c=default,i=default;
insert into t1 set a=4,t=0,c="a"; insert into t1 set a=4,t=0,c="a",i=5;
insert into t1 set a=default,t=default,c=default; insert into t1 set a=5,t=0,c="a",i=null;
select a,t>0,c from t1; insert into t1 set a=default,t=default,c=default,i=default;
a t>0 c select a,t>0,c,i from t1;
1 1 hello a t>0 c i
2 1 hello 1 1 hello NULL
4 0 a 2 1 hello NULL
5 1 hello 4 0 a 5
5 0 a NULL
6 1 hello NULL
drop table t1; drop table t1;
drop database if exists foo; drop database if exists foo;
create database foo; create database foo;

View File

@ -1,10 +1,10 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start; slave start;
use test; drop table if exists t1,t2,t3;
drop table if exists t1,t3;
create table t1 (word char(20) not null); create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1; load data infile '../../std_data/words.dat' into table t1;
load data local infile 'MYSQL_TEST_DIR/std_data/words.dat' into table t1; load data local infile 'MYSQL_TEST_DIR/std_data/words.dat' into table t1;
@ -30,11 +30,12 @@ abandoned
abandoning abandoning
abandonment abandonment
abandons abandons
slave stop;
set password for root@"localhost" = password('foo'); set password for root@"localhost" = password('foo');
slave start;
set password for root@"localhost" = password(''); set password for root@"localhost" = password('');
create table t3(n int); create table t3(n int);
insert into t3 values(1),(2); insert into t3 values(1),(2);
use test;
select * from t3; select * from t3;
n n
1 1
@ -46,7 +47,6 @@ drop table t1,t3;
reset master; reset master;
slave stop; slave stop;
reset slave; reset slave;
drop table if exists t1,t2;
create table t1(n int); create table t1(n int);
select get_lock("hold_slave",10); select get_lock("hold_slave",10);
get_lock("hold_slave",10) get_lock("hold_slave",10)
@ -58,8 +58,8 @@ release_lock("hold_slave")
unlock tables; unlock tables;
create table t2(id int); create table t2(id int);
insert into t2 values(connection_id()); insert into t2 values(connection_id());
create temporary table t1_temp(n int); create temporary table t3(n int);
insert into t1_temp select get_lock('crash_lock%20C', 1) from t2; insert into t3 select get_lock('crash_lock%20C', 1) from t2;
update t1 set n = n + get_lock('crash_lock%20C', 2); update t1 set n = n + get_lock('crash_lock%20C', 2);
select (@id := id) - id from t2; select (@id := id) - id from t2;
(@id := id) - id (@id := id) - id
@ -75,17 +75,15 @@ count(*)
drop table t1; drop table t1;
create table t1 (n int); create table t1 (n int);
insert into t1 values(3456); insert into t1 values(3456);
use mysql; insert into mysql.user (Host, User, Password)
insert into user (Host, User, Password)
VALUES ("10.10.10.%", "blafasel2", password("blafasel2")); VALUES ("10.10.10.%", "blafasel2", password("blafasel2"));
select select_priv,user from mysql.user where user = 'blafasel2'; select select_priv,user from mysql.user where user = 'blafasel2';
select_priv user select_priv user
N blafasel2 N blafasel2
update user set Select_priv = "Y" where User="blafasel2"; update mysql.user set Select_priv = "Y" where User="blafasel2";
select select_priv,user from mysql.user where user = 'blafasel2'; select select_priv,user from mysql.user where user = 'blafasel2';
select_priv user select_priv user
Y blafasel2 Y blafasel2
use test;
select n from t1; select n from t1;
n n
3456 3456

View File

@ -1,14 +1,13 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start; slave start;
use test;
drop table if exists t1; drop table if exists t1;
create table t1 (n int auto_increment primary key); create table t1 (n int auto_increment primary key);
set insert_id = 2000; set insert_id = 2000;
insert into t1 values (NULL),(NULL),(NULL); insert into t1 values (NULL),(NULL),(NULL);
use test;
select * from t1; select * from t1;
n n
2000 2000
@ -16,7 +15,7 @@ n
2002 2002
show slave hosts; show slave hosts;
Server_id Host Port Rpl_recovery_rank Master_id Server_id Host Port Rpl_recovery_rank Master_id
2 127.0.0.1 $SLAVE_MYPORT 2 1 2 127.0.0.1 9999 2 1
drop table t1; drop table t1;
slave stop; slave stop;
drop table if exists t2; drop table if exists t2;

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,9 +1,9 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start; slave start;
use test;
set SQL_LOG_BIN=0; set SQL_LOG_BIN=0;
drop table if exists t1; drop table if exists t1;
create table t1 (word char(20) not null, index(word)); create table t1 (word char(20) not null, index(word));
@ -12,7 +12,6 @@ drop table if exists t2;
create table t2 (word char(20) not null); create table t2 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t2; load data infile '../../std_data/words.dat' into table t2;
create table t3 (word char(20) not null primary key); create table t3 (word char(20) not null primary key);
use test;
drop table if exists t1; drop table if exists t1;
load table t1 from master; load table t1 from master;
drop table if exists t2; drop table if exists t2;

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,13 +1,12 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start; slave start;
use test;
drop table if exists foo; drop table if exists foo;
create table foo (n int); create table foo (n int);
insert into foo values(4); insert into foo values(4);
use test;
drop table if exists foo; drop table if exists foo;
create table foo (s char(20)); create table foo (s char(20));
load data infile '../../std_data/words.dat' into table foo; load data infile '../../std_data/words.dat' into table foo;

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,9 +1,9 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start; slave start;
use test;
drop table if exists t1; drop table if exists t1;
create table t1 (n int); create table t1 (n int);
insert into t1 values(1); insert into t1 values(1);

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
@ -8,7 +9,7 @@ File Position Binlog_do_db Binlog_ignore_db
master-bin.001 79 master-bin.001 79
show slave status; show slave status;
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root MASTER_PORT 1 master-bin.001 79 slave-relay-bin.002 120 master-bin.001 Yes Yes 0 0 79 128 127.0.0.1 root MASTER_PORT 1 master-bin.001 79 slave-relay-bin.002 120 master-bin.001 Yes Yes 0 0 79 124
change master to master_log_pos=73; change master to master_log_pos=73;
slave stop; slave stop;
change master to master_log_pos=73; change master to master_log_pos=73;

View File

@ -1,9 +1,9 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start; slave start;
use test;
drop database if exists d1; drop database if exists d1;
create database d1; create database d1;
create table d1.t1 ( n int); create table d1.t1 ( n int);

View File

@ -1,77 +0,0 @@
slave stop;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
use test;
drop table if exists t1,t3;
create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1;
select * from t1;
word
Aarhus
Aaron
Ababa
aback
abaft
abandon
abandoned
abandoning
abandonment
abandons
set password for root@"localhost" = password('foo');
set password for root@"localhost" = password('');
create table t3(n int);
insert into t3 values(1),(2);
use test;
select * from t3;
n
1
2
select sum(length(word)) from t1;
sum(length(word))
71
drop table t1,t3;
reset master;
slave stop;
reset slave;
create table t1(n int);
insert into t1 values (1),(2),(3);
create table t2(id int);
insert into t2 values(connection_id());
create temporary table t1_temp(n int);
insert into t1_temp select get_lock('crash_lock%20C', 1) from t2;
update t1 set n = n + get_lock('crash_lock%20C', 2);
select (@id := id) - id from t2;
(@id := id) - id
0
kill @id;
drop table t2;
Server shutdown in progress
slave start;
set sql_slave_skip_counter=1;
slave start;
select count(*) from t1;
count(*)
3
drop table t1;
create table t1 (n int);
insert into t1 values(3456);
use mysql;
insert into user (Host, User, Password)
VALUES ("10.10.10.%", "blafasel2", password("blafasel2"));
select select_priv,user from mysql.user where user = 'blafasel2';
select_priv user
N blafasel2
update user set Select_priv = "Y" where User="blafasel2";
select select_priv,user from mysql.user where user = 'blafasel2';
select_priv user
Y blafasel2
use test;
select n from t1;
n
3456
select select_priv,user from mysql.user where user = 'blafasel2';
select_priv user
Y blafasel2
drop table t1;

View File

@ -1,9 +1,9 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start; slave start;
use test;
drop table if exists t1; drop table if exists t1;
show slave status; show slave status;
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
@ -75,7 +76,7 @@ slave-bin.002 115 Query 1 62 use test; insert into t1 values (1)
slave-bin.002 175 Query 1 122 use test; drop table t1 slave-bin.002 175 Query 1 122 use test; drop table t1
show slave status; show slave status;
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root MASTER_PORT 1 master-bin.002 170 slave-relay-bin.002 916 master-bin.002 Yes Yes 0 0 170 924 127.0.0.1 root MASTER_PORT 1 master-bin.002 170 slave-relay-bin.002 916 master-bin.002 Yes Yes 0 0 170 920
show new master for slave with master_log_file='master-bin.001' and show new master for slave with master_log_file='master-bin.001' and
master_log_pos=4 and master_server_id=1; master_log_pos=4 and master_server_id=1;
Log_name Log_pos Log_name Log_pos

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,5 +1,5 @@
drop table if exists t1;
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -1,4 +1,5 @@
slave stop; slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

@ -27,15 +27,16 @@ drop table t1;
# Test insert syntax # Test insert syntax
# #
create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello"); create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello", i int);
insert into t1 values (default,default,default), (default,default,default), (4,0,"a"),(default,default,default); insert into t1 values (default,default,default,default), (default,default,default,default), (4,0,"a",5),(default,default,default,default);
select a,t>0,c from t1; select a,t>0,c,i from t1;
truncate table t1; truncate table t1;
insert into t1 set a=default,t=default,c=default; insert into t1 set a=default,t=default,c=default;
insert into t1 set a=default,t=default,c=default; insert into t1 set a=default,t=default,c=default,i=default;
insert into t1 set a=4,t=0,c="a"; insert into t1 set a=4,t=0,c="a",i=5;
insert into t1 set a=default,t=default,c=default; insert into t1 set a=5,t=0,c="a",i=null;
select a,t>0,c from t1; insert into t1 set a=default,t=default,c=default,i=default;
select a,t>0,c,i from t1;
drop table t1; drop table t1;
# #

View File

@ -1,21 +1,34 @@
eval_result;
source include/master-slave.inc; source include/master-slave.inc;
connection master; drop table if exists t1,t2,t3;
use test;
drop table if exists t1,t3;
create table t1 (word char(20) not null); create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1; load data infile '../../std_data/words.dat' into table t1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1; eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1;
select * from t1; select * from t1;
#
# Test slave with wrong password
#
save_master_pos;
connection slave;
sync_with_master;
slave stop;
connection master;
set password for root@"localhost" = password('foo'); set password for root@"localhost" = password('foo');
connection slave;
slave start;
connection master;
# Give slave time to do at last one failed connect retry
sleep 2;
set password for root@"localhost" = password(''); set password for root@"localhost" = password('');
# Give slave time to connect (will retry every second)
sleep 2;
create table t3(n int); create table t3(n int);
insert into t3 values(1),(2); insert into t3 values(1),(2);
save_master_pos; save_master_pos;
connection slave; connection slave;
sync_with_master; sync_with_master;
use test;
select * from t3; select * from t3;
select sum(length(word)) from t1; select sum(length(word)) from t1;
connection master; connection master;
@ -32,7 +45,6 @@ slave stop;
reset slave; reset slave;
connection master; connection master;
drop table if exists t1,t2;
create table t1(n int); create table t1(n int);
#we want the log to exceed 16K to test deal with the log that is bigger than #we want the log to exceed 16K to test deal with the log that is bigger than
#IO_SIZE #IO_SIZE
@ -45,12 +57,12 @@ while ($1)
} }
enable_query_log; enable_query_log;
#try to cause a large relay log lag on the slave # Try to cause a large relay log lag on the slave
connection slave; connection slave;
select get_lock("hold_slave",10); select get_lock("hold_slave",10);
slave start; slave start;
#hope this is long enough for I/O thread to fetch over 16K relay log data #hope this is long enough for I/O thread to fetch over 16K relay log data
sleep 1; sleep 3;
select release_lock("hold_slave"); select release_lock("hold_slave");
unlock tables; unlock tables;
@ -59,24 +71,24 @@ create table t2(id int);
insert into t2 values(connection_id()); insert into t2 values(connection_id());
save_master_pos; save_master_pos;
connection master1; connection master1;
#avoid generating result # Avoid generating result
create temporary table t1_temp(n int); create temporary table t3(n int);
insert into t1_temp select get_lock('crash_lock%20C', 1) from t2; insert into t3 select get_lock('crash_lock%20C', 1) from t2;
connection master; connection master;
send update t1 set n = n + get_lock('crash_lock%20C', 2); send update t1 set n = n + get_lock('crash_lock%20C', 2);
connection master1; connection master1;
sleep 2; sleep 3;
select (@id := id) - id from t2; select (@id := id) - id from t2;
kill @id; kill @id;
# We don't drop t3 as this is a temporary table
drop table t2; drop table t2;
connection master; connection master;
--error 1053; --error 1053;
reap; reap;
connection slave; connection slave;
sync_with_master ; sync_with_master;
#give the slave a chance to exit #give the slave a chance to exit
wait_for_slave_to_stop; wait_for_slave_to_stop;
@ -92,13 +104,11 @@ connection master1;
drop table t1; drop table t1;
create table t1 (n int); create table t1 (n int);
insert into t1 values(3456); insert into t1 values(3456);
use mysql; insert into mysql.user (Host, User, Password)
insert into user (Host, User, Password)
VALUES ("10.10.10.%", "blafasel2", password("blafasel2")); VALUES ("10.10.10.%", "blafasel2", password("blafasel2"));
select select_priv,user from mysql.user where user = 'blafasel2'; select select_priv,user from mysql.user where user = 'blafasel2';
update user set Select_priv = "Y" where User="blafasel2"; update mysql.user set Select_priv = "Y" where User="blafasel2";
select select_priv,user from mysql.user where user = 'blafasel2'; select select_priv,user from mysql.user where user = 'blafasel2';
use test;
save_master_pos; save_master_pos;
connection slave; connection slave;
sync_with_master; sync_with_master;
@ -109,5 +119,3 @@ drop table t1;
save_master_pos; save_master_pos;
connection slave; connection slave;
sync_with_master; sync_with_master;

View File

@ -1,17 +1,14 @@
source include/master-slave.inc; source include/master-slave.inc;
eval_result;
connection master;
use test;
drop table if exists t1; drop table if exists t1;
create table t1 (n int auto_increment primary key); create table t1 (n int auto_increment primary key);
set insert_id = 2000; set insert_id = 2000;
insert into t1 values (NULL),(NULL),(NULL); insert into t1 values (NULL),(NULL),(NULL);
save_master_pos; save_master_pos;
connection slave; connection slave;
use test;
sync_with_master; sync_with_master;
select * from t1; select * from t1;
connection master; connection master;
--replace_result $SLAVE_MYPORT 9999
show slave hosts; show slave hosts;
drop table t1; drop table t1;
save_master_pos; save_master_pos;

View File

@ -1,5 +1,4 @@
source include/master-slave.inc; source include/master-slave.inc;
connection master;
drop table if exists t1; drop table if exists t1;
create table t1(n int primary key); create table t1(n int primary key);
!insert into t1 values (1),(2),(2); !insert into t1 values (1),(2),(2);

View File

@ -1,6 +1,4 @@
source include/master-slave.inc; source include/master-slave.inc;
connection master;
use test;
set SQL_LOG_BIN=0; set SQL_LOG_BIN=0;
drop table if exists t1; drop table if exists t1;
create table t1 (word char(20) not null, index(word)); create table t1 (word char(20) not null, index(word));
@ -10,7 +8,6 @@ create table t2 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t2; load data infile '../../std_data/words.dat' into table t2;
create table t3 (word char(20) not null primary key); create table t3 (word char(20) not null primary key);
connection slave; connection slave;
use test;
drop table if exists t1; drop table if exists t1;
load table t1 from master; load table t1 from master;
drop table if exists t2; drop table if exists t2;

View File

@ -1,5 +1,4 @@
source include/master-slave.inc; source include/master-slave.inc;
connection master;
drop table if exists t1; drop table if exists t1;
CREATE TABLE t1 (name varchar(64), age smallint(3)); CREATE TABLE t1 (name varchar(64), age smallint(3));
INSERT INTO t1 SET name='Andy', age=31; INSERT INTO t1 SET name='Andy', age=31;

View File

@ -2,7 +2,6 @@
# Test forced timestamp # Test forced timestamp
# #
source include/master-slave.inc; source include/master-slave.inc;
connection master;
# Don't log table creating to the slave as we want to test LOAD TABLE # Don't log table creating to the slave as we want to test LOAD TABLE
set SQL_LOG_BIN=0,timestamp=200006; set SQL_LOG_BIN=0,timestamp=200006;

View File

@ -2,12 +2,10 @@
#the ones on bar #the ones on bar
source include/master-slave.inc; source include/master-slave.inc;
connection slave; connection slave;
use test;
drop table if exists foo; drop table if exists foo;
create table foo (n int); create table foo (n int);
insert into foo values(4); insert into foo values(4);
connection master; connection master;
use test;
drop table if exists foo; drop table if exists foo;
create table foo (s char(20)); create table foo (s char(20));
load data infile '../../std_data/words.dat' into table foo; load data infile '../../std_data/words.dat' into table foo;

View File

@ -2,7 +2,6 @@
# the ones in database bar # the ones in database bar
source include/master-slave.inc; source include/master-slave.inc;
connection master;
drop database if exists foo; drop database if exists foo;
create database foo; create database foo;
drop database if exists bar; drop database if exists bar;

View File

@ -1,6 +1,4 @@
source include/master-slave.inc; source include/master-slave.inc;
connection master;
use test;
drop table if exists t1; drop table if exists t1;
create table t1 (n int); create table t1 (n int);
insert into t1 values(1); insert into t1 values(1);

View File

@ -1,5 +1,4 @@
source include/master-slave.inc; source include/master-slave.inc;
connection master;
save_master_pos; save_master_pos;
connection slave; connection slave;
sync_with_master; sync_with_master;

View File

@ -1,5 +1,4 @@
source include/master-slave.inc; source include/master-slave.inc;
connection master;
show master status; show master status;
save_master_pos; save_master_pos;
connection slave; connection slave;

View File

@ -1,6 +1,4 @@
source include/master-slave.inc; source include/master-slave.inc;
connection master;
use test;
drop database if exists d1; drop database if exists d1;
create database d1; create database d1;
create table d1.t1 ( n int); create table d1.t1 ( n int);

View File

@ -1,86 +0,0 @@
eval_result;
source include/master-slave.inc;
connection master;
require_version 3.23;
use test;
drop table if exists t1,t3;
create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1;
select * from t1;
set password for root@"localhost" = password('foo');
set password for root@"localhost" = password('');
create table t3(n int);
insert into t3 values(1),(2);
save_master_pos;
connection slave;
sync_with_master;
use test;
select * from t3;
select sum(length(word)) from t1;
connection master;
drop table t1,t3;
save_master_pos;
connection slave;
sync_with_master;
#test handling of aborted connection in the middle of update
connection master;
reset master;
connection slave;
slave stop;
reset slave;
connection master;
create table t1(n int);
insert into t1 values (1),(2),(3);
create table t2(id int);
insert into t2 values(connection_id());
save_master_pos;
connection master1;
#avoid generating result
create temporary table t1_temp(n int);
insert into t1_temp select get_lock('crash_lock%20C', 1) from t2;
connection master;
send update t1 set n = n + get_lock('crash_lock%20C', 2);
connection master1;
sleep 2;
select (@id := id) - id from t2;
kill @id;
drop table t2;
connection master;
--error 1053;
reap;
connection slave;
slave start;
sync_with_master ;
#now slave will hit an error
wait_for_slave_to_stop;
set global sql_slave_skip_counter=1;
slave start;
select count(*) from t1;
connection master1;
drop table t1;
create table t1 (n int);
insert into t1 values(3456);
use mysql;
insert into user (Host, User, Password)
VALUES ("10.10.10.%", "blafasel2", password("blafasel2"));
select select_priv,user from mysql.user where user = 'blafasel2';
update user set Select_priv = "Y" where User="blafasel2";
select select_priv,user from mysql.user where user = 'blafasel2';
use test;
save_master_pos;
connection slave;
sync_with_master;
select n from t1;
select select_priv,user from mysql.user where user = 'blafasel2';
connection master1;
drop table t1;
save_master_pos;
connection slave;
sync_with_master;

View File

@ -1,6 +1,4 @@
source include/master-slave.inc; source include/master-slave.inc;
connection master;
use test;
drop table if exists t1; drop table if exists t1;
show slave status; show slave status;
--error 1218 --error 1218

View File

@ -1,5 +1,5 @@
source include/master-slave.inc; source include/master-slave.inc;
connection master;
create table t1(n int); create table t1(n int);
insert into t1 values(get_lock("lock",2)); insert into t1 values(get_lock("lock",2));
dirty_close master; dirty_close master;

View File

@ -1,7 +1,6 @@
source include/master-slave.inc; source include/master-slave.inc;
#first, make sure the slave has had enough time to register #first, make sure the slave has had enough time to register
connection master;
save_master_pos; save_master_pos;
connection slave; connection slave;
sync_with_master; sync_with_master;

View File

@ -1,8 +1,7 @@
# test case to make slave thread get ahead by 22 bytes # test case to make slave thread get ahead by 22 bytes
drop table if exists t1;
source include/master-slave.inc; source include/master-slave.inc;
connection master;
# first, cause a duplicate key problem on the slave # first, cause a duplicate key problem on the slave
create table t1(n int auto_increment primary key); create table t1(n int auto_increment primary key);
save_master_pos; save_master_pos;

View File

@ -1,6 +1,6 @@
source include/master-slave.inc; source include/master-slave.inc;
connection master;
drop table if exists t1; drop table if exists t1;
create table t1 (n int not null primary key); create table t1 (n int not null primary key);
save_master_pos; save_master_pos;
connection slave; connection slave;

View File

@ -2,8 +2,8 @@
# COM_BINLOG_DUMP and additionally limits the number of events per dump # COM_BINLOG_DUMP and additionally limits the number of events per dump
source include/master-slave.inc; source include/master-slave.inc;
connection master;
drop table if exists t1,t2; drop table if exists t1,t2;
create table t2(n int); create table t2(n int);
create table t1(n int not null auto_increment primary key); create table t1(n int not null auto_increment primary key);
insert into t1 values (NULL),(NULL); insert into t1 values (NULL),(NULL);

View File

@ -123,7 +123,8 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
uint min_cache; uint min_cache;
my_off_t end_of_file= ~(my_off_t) 0; my_off_t end_of_file= ~(my_off_t) 0;
DBUG_ENTER("init_io_cache"); DBUG_ENTER("init_io_cache");
DBUG_PRINT("enter",("type: %d pos: %ld",(int) type, (ulong) seek_offset)); DBUG_PRINT("enter",("cache: %lx type: %d pos: %ld",
(ulong) info, (int) type, (ulong) seek_offset));
info->file= file; info->file= file;
info->type=type; info->type=type;
@ -264,8 +265,9 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
pbool clear_cache) pbool clear_cache)
{ {
DBUG_ENTER("reinit_io_cache"); DBUG_ENTER("reinit_io_cache");
DBUG_PRINT("enter",("type: %d seek_offset: %lu clear_cache: %d", DBUG_PRINT("enter",("cache: %lx type: %d seek_offset: %lu clear_cache: %d",
type, (ulong) seek_offset, (int) clear_cache)); (ulong) info, type, (ulong) seek_offset,
(int) clear_cache));
/* One can't do reinit with the following types */ /* One can't do reinit with the following types */
DBUG_ASSERT(type != READ_NET && info->type != READ_NET && DBUG_ASSERT(type != READ_NET && info->type != READ_NET &&
@ -283,11 +285,15 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
{ {
info->read_end=info->write_pos; info->read_end=info->write_pos;
info->end_of_file=my_b_tell(info); info->end_of_file=my_b_tell(info);
info->seek_not_done=1;
} }
else if (type == WRITE_CACHE) else if (type == WRITE_CACHE)
{ {
if (info->type == READ_CACHE) if (info->type == READ_CACHE)
{
info->write_end=info->write_buffer+info->buffer_length; info->write_end=info->write_buffer+info->buffer_length;
info->seek_not_done=1;
}
info->end_of_file = ~(my_off_t) 0; info->end_of_file = ~(my_off_t) 0;
} }
pos=info->request_pos+(seek_offset-info->pos_in_file); pos=info->request_pos+(seek_offset-info->pos_in_file);

View File

@ -212,6 +212,20 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length)
} }
my_off_t my_b_filelength(IO_CACHE *info)
{
if (info->type == WRITE_CACHE)
{
return my_b_tell(info);
}
else
{
info->seek_not_done=0;
return my_seek(info->file,0L,MY_SEEK_END,MYF(0));
}
}
/* /*
Simple printf version. Supports '%s', '%d', '%u', "%ld" and "%lu" Simple printf version. Supports '%s', '%d', '%u', "%ld" and "%lu"
Used for logging in MySQL Used for logging in MySQL

View File

@ -25,17 +25,19 @@
my_chsize() my_chsize()
fd File descriptor fd File descriptor
new_length New file size new_length New file size
filler If we don't have truncate, fill up all bytes after
new_length with this character
MyFlags Flags MyFlags Flags
DESCRIPTION DESCRIPTION
my_chsize() truncates file if shorter, else expand with zero. my_chsize() truncates file if shorter, else fill with the filler character
RETURN VALUE RETURN VALUE
0 Ok 0 Ok
1 Error 1 Error
*/ */
int my_chsize(File fd, my_off_t newlength, myf MyFlags) int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
{ {
DBUG_ENTER("my_chsize"); DBUG_ENTER("my_chsize");
DBUG_PRINT("my",("fd: %d length: %lu MyFlags: %d",fd,(ulong) newlength, DBUG_PRINT("my",("fd: %d length: %lu MyFlags: %d",fd,(ulong) newlength,
@ -81,7 +83,7 @@ int my_chsize(File fd, my_off_t newlength, myf MyFlags)
} }
#endif #endif
/* Full file with 0 until it's as big as requested */ /* Full file with 0 until it's as big as requested */
bzero(buff,IO_SIZE); bfill(buff, IO_SIZE, filler);
while (newlength-oldsize > IO_SIZE) while (newlength-oldsize > IO_SIZE)
{ {
if (my_write(fd,(byte*) buff,IO_SIZE,MYF(MY_NABP))) if (my_write(fd,(byte*) buff,IO_SIZE,MYF(MY_NABP)))

View File

@ -75,7 +75,7 @@
#endif #endif
#include "mysys_priv.h" #include "mysys_priv.h"
#include "my_dir.h" #include <my_dir.h>
#include <m_string.h> #include <m_string.h>
#include <assert.h> #include <assert.h>
@ -281,7 +281,7 @@ extern "C" {
DBUG_RETURN(my_close(fd, MyFlags)); DBUG_RETURN(my_close(fd, MyFlags));
} }
int my_raid_chsize(File fd, my_off_t newlength, myf MyFlags) int my_raid_chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
{ {
DBUG_ENTER("my_raid_chsize"); DBUG_ENTER("my_raid_chsize");
DBUG_PRINT("enter",("Fd: %d newlength: %u MyFlags: %d", DBUG_PRINT("enter",("Fd: %d newlength: %u MyFlags: %d",
@ -289,10 +289,10 @@ extern "C" {
if (is_raid(fd)) if (is_raid(fd))
{ {
RaidFd *raid= (*dynamic_element(&RaidFd::_raid_map,fd,RaidFd**)); RaidFd *raid= (*dynamic_element(&RaidFd::_raid_map,fd,RaidFd**));
DBUG_RETURN(raid->Chsize(fd, newlength, MyFlags)); DBUG_RETURN(raid->Chsize(fd, newlength, filler, MyFlags));
} }
else else
DBUG_RETURN(my_chsize(fd, newlength, MyFlags)); DBUG_RETURN(my_chsize(fd, newlength, filler, MyFlags));
} }
int my_raid_rename(const char *from, const char *to, int my_raid_rename(const char *from, const char *to,
@ -738,7 +738,7 @@ Tell(myf MyFlags)
} }
int RaidFd:: int RaidFd::
Chsize(File fd, my_off_t newlength, myf MyFlags) Chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
{ {
DBUG_ENTER("RaidFd::Chsize"); DBUG_ENTER("RaidFd::Chsize");
DBUG_PRINT("enter",("Fd: %d, newlength: %d, MyFlags: %d", DBUG_PRINT("enter",("Fd: %d, newlength: %d, MyFlags: %d",
@ -752,17 +752,16 @@ Chsize(File fd, my_off_t newlength, myf MyFlags)
if ( i < _this_block ) if ( i < _this_block )
newpos = my_chsize(_fd_vector[i], newpos = my_chsize(_fd_vector[i],
_this_block * _raid_chunksize + (_rounds + 1) * _this_block * _raid_chunksize + (_rounds + 1) *
_raid_chunksize, _raid_chunksize, filler, MyFlags);
MyFlags);
else if ( i == _this_block ) else if ( i == _this_block )
newpos = my_chsize(_fd_vector[i], newpos = my_chsize(_fd_vector[i],
_this_block * _raid_chunksize + _rounds * _this_block * _raid_chunksize + _rounds *
_raid_chunksize + (newlength % _raid_chunksize), _raid_chunksize + (newlength % _raid_chunksize),
MyFlags); filler, MyFlags);
else // this means: i > _this_block else // this means: i > _this_block
newpos = my_chsize(_fd_vector[i], newpos = my_chsize(_fd_vector[i],
_this_block * _raid_chunksize + _rounds * _this_block * _raid_chunksize + _rounds *
_raid_chunksize, MyFlags); _raid_chunksize, filler, MyFlags);
if (newpos) if (newpos)
DBUG_RETURN(1); DBUG_RETURN(1);
} }

View File

@ -73,6 +73,9 @@ public:
virtual void set_default() virtual void set_default()
{ {
memcpy(ptr, ptr + table->rec_buff_length, pack_length()); memcpy(ptr, ptr + table->rec_buff_length, pack_length());
if (null_ptr)
*null_ptr= ((*null_ptr & (uchar) ~null_bit) |
null_ptr[table->rec_buff_length] & null_bit);
} }
virtual bool binary() const { return 1; } virtual bool binary() const { return 1; }
virtual bool zero_pack() const { return 1; } virtual bool zero_pack() const { return 1; }
@ -93,12 +96,12 @@ public:
virtual int key_cmp(const byte *str, uint length) virtual int key_cmp(const byte *str, uint length)
{ return cmp(ptr,(char*) str); } { return cmp(ptr,(char*) str); }
virtual uint decimals() const { return 0; } virtual uint decimals() const { return 0; }
virtual void sql_type(String &str) const =0;
/* /*
Caller beware: sql_type can change str.Ptr, so check Caller beware: sql_type can change str.Ptr, so check
ptr() to see if it changed if you are using your own buffer ptr() to see if it changed if you are using your own buffer
in str and restore it with set() if needed in str and restore it with set() if needed
*/ */
virtual void sql_type(String &str) const =0;
virtual uint size_of() const =0; /* For new field */ virtual uint size_of() const =0; /* For new field */
inline bool is_null(uint row_offset=0) inline bool is_null(uint row_offset=0)
{ return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : table->null_row; } { return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : table->null_row; }

View File

@ -167,7 +167,6 @@ class ha_berkeley: public handler
}; };
extern bool berkeley_skip, berkeley_shared_data; extern bool berkeley_skip, berkeley_shared_data;
extern SHOW_COMP_OPTION have_berkeley_db;
extern u_int32_t berkeley_init_flags,berkeley_env_flags, berkeley_lock_type, extern u_int32_t berkeley_init_flags,berkeley_env_flags, berkeley_lock_type,
berkeley_lock_types[]; berkeley_lock_types[];
extern ulong berkeley_cache_size, berkeley_max_lock, berkeley_log_buffer_size; extern ulong berkeley_cache_size, berkeley_max_lock, berkeley_log_buffer_size;

View File

@ -284,10 +284,9 @@ innobase_mysql_print_thd(
thd = (THD*) input_thd; thd = (THD*) input_thd;
/* We can't use value of sprintf() as this is not portable */ /* We can't use value of sprintf() as this is not portable */
sprintf(buf, "MySQL thread id %lu, query id %lu", buf+= my_sprintf(buf,
thd->thread_id, thd->query_id); (buf, "MySQL thread id %lu, query id %lu",
buf=strend(buf); thd->thread_id, thd->query_id));
if (thd->host) if (thd->host)
{ {
*buf++=' '; *buf++=' ';
@ -309,7 +308,7 @@ innobase_mysql_print_thd(
if (thd->proc_info) if (thd->proc_info)
{ {
*buf++=' '; *buf++=' ';
buf=strnmov(buf, thd->procinfo, 50); buf=strnmov(buf, thd->proc_info, 50);
} }
if (thd->query) if (thd->query)
@ -610,16 +609,19 @@ innobase_commit_low(
/*================*/ /*================*/
trx_t* trx) /* in: transaction handle */ trx_t* trx) /* in: transaction handle */
{ {
if (current_thd->slave_thread) { if (current_thd->slave_thread)
{
/* Update the replication position info inside InnoDB */ /* Update the replication position info inside InnoDB */
#ifdef NEED_TO_BE_FIXED
trx->mysql_master_log_file_name = glob_mi.log_file_name; trx->mysql_relay_log_file_name= active_mi->rli.log_file_name;
trx->mysql_master_log_pos = (ib_longlong) trx->mysql_relay_log_pos= active_mi->rli.relay_log_pos;
(glob_mi.pos + glob_mi.event_len #endif
+ glob_mi.pending); trx->mysql_master_log_file_name= active_mi->rli.master_log_name;
trx->mysql_master_log_pos= ((ib_longlong)
(active_mi->rli.master_log_pos +
active_mi->rli.event_len +
active_mi->rli.pending));
} }
trx_commit_for_mysql(trx); trx_commit_for_mysql(trx);
} }
@ -3176,8 +3178,9 @@ ha_innobase::update_table_comment(
*pos++=' '; *pos++=' ';
} }
pos += sprintf(pos, "InnoDB free: %lu kB", pos += my_sprintf(pos,
(ulong) innobase_get_free_space()); (pos,"InnoDB free: %lu kB",
(ulong) innobase_get_free_space()));
/* We assume 450 - length bytes of space to print info */ /* We assume 450 - length bytes of space to print info */

View File

@ -169,7 +169,6 @@ class ha_innobase: public handler
}; };
extern bool innodb_skip; extern bool innodb_skip;
extern SHOW_COMP_OPTION have_innodb;
extern uint innobase_init_flags, innobase_lock_type; extern uint innobase_init_flags, innobase_lock_type;
extern ulong innobase_cache_size; extern ulong innobase_cache_size;
extern char *innobase_home, *innobase_tmpdir, *innobase_logdir; extern char *innobase_home, *innobase_tmpdir, *innobase_logdir;

View File

@ -275,40 +275,11 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
{ {
bool operation_done= 0; bool operation_done= 0;
bool transaction_commited= 0; bool transaction_commited= 0;
/* Update the binary log if we have cached some queries */ /* Update the binary log if we have cached some queries */
if (trans == &thd->transaction.all && mysql_bin_log.is_open() && if (trans == &thd->transaction.all && mysql_bin_log.is_open() &&
my_b_tell(&thd->transaction.trans_log)) my_b_tell(&thd->transaction.trans_log))
{ {
/* We write the command "COMMIT" as the last SQL command in the
binlog segment cached for this transaction */
int save_query_length = thd->query_length;
thd->query_length = 6; /* length of 'COMMIT'; note that we may come
here because a DROP TABLE, for instance,
makes an implicit commit, and then
thd->query is not 'COMMIT'! */
Query_log_event qinfo(thd, "COMMIT", TRUE);
/* When we come here, and the user wrapped the transaction into
BEGIN and COMMIT, then qinfo got above the field cache_stmt
erroneously set to 0. Let us set it to 1: */
qinfo.cache_stmt = 1;
/* Write the 'COMMIT' entry to the cache */
if (mysql_bin_log.write(&qinfo)) {
my_error(ER_ERROR_DURING_COMMIT, MYF(0), 5000);
error=1;
}
thd->query_length = save_query_length;
/* Now we write the binlog segment cached for this transaction to
the real binlog */
mysql_bin_log.write(thd, &thd->transaction.trans_log); mysql_bin_log.write(thd, &thd->transaction.trans_log);
reinit_io_cache(&thd->transaction.trans_log, reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1); WRITE_CACHE, (my_off_t) 0, 0, 1);

View File

@ -1437,20 +1437,15 @@ void item_user_lock_release(ULL *ull)
ull->locked=0; ull->locked=0;
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
THD *thd = current_thd;
uint save_query_length;
char buf[256]; char buf[256];
String tmp(buf,sizeof(buf)); String tmp(buf,sizeof(buf));
tmp.length(0); tmp.length(0);
tmp.append("DO RELEASE_LOCK(\""); tmp.append("DO RELEASE_LOCK(\"");
tmp.append(ull->key,ull->key_length); tmp.append(ull->key,ull->key_length);
tmp.append("\")"); tmp.append("\")");
save_query_length=thd->query_length; Query_log_event qev(current_thd,tmp.ptr(), tmp.length());
thd->query_length=tmp.length();
Query_log_event qev(thd,tmp.ptr());
qev.error_code=0; // this query is always safe to run on slave qev.error_code=0; // this query is always safe to run on slave
mysql_bin_log.write(&qev); mysql_bin_log.write(&qev);
thd->query_length=save_query_length;
} }
if (--ull->count) if (--ull->count)
pthread_cond_signal(&ull->cond); pthread_cond_signal(&ull->cond);

View File

@ -208,8 +208,13 @@ public:
void fix_length_and_dec() {} void fix_length_and_dec() {}
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
if (!t_arg) return result_field; if (!t_arg)
return (max_length > 11) ? (Field *)new Field_longlong(max_length,maybe_null,name, t_arg,unsigned_flag) : (Field *)new Field_long(max_length,maybe_null,name, t_arg,unsigned_flag); return result_field;
return ((max_length > 11) ?
(Field *)new Field_longlong(max_length, maybe_null, name, t_arg,
unsigned_flag) :
(Field *)new Field_long(max_length, maybe_null, name, t_arg,
unsigned_flag));
} }
}; };

View File

@ -37,12 +37,18 @@ public:
void left_right_max_length(); void left_right_max_length();
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
if (!t_arg) return result_field; if (!t_arg)
return (max_length > 255) ? (Field *)new Field_blob(max_length,maybe_null, name,t_arg, binary) : (Field *) new Field_string(max_length,maybe_null, name,t_arg, binary); return result_field;
return ((max_length > 255) ?
(Field *) new Field_blob(max_length, maybe_null, name, t_arg,
binary) :
(Field *) new Field_string(max_length, maybe_null, name, t_arg,
binary));
} }
unsigned int size_of() { return sizeof(*this);} unsigned int size_of() { return sizeof(*this);}
}; };
class Item_func_md5 :public Item_str_func class Item_func_md5 :public Item_str_func
{ {
String tmp_value; String tmp_value;

View File

@ -237,8 +237,7 @@ public:
} }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
if (!t_arg) return result_field; return (!t_arg) ? result_field : new Field_date(maybe_null, name, t_arg);
return new Field_date(maybe_null, name, t_arg);
} }
unsigned int size_of() { return sizeof(*this);} unsigned int size_of() { return sizeof(*this);}
}; };
@ -256,8 +255,8 @@ public:
} }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
if (!t_arg) return result_field; return (!t_arg) ? result_field : new Field_datetime(maybe_null, name,
return new Field_datetime(maybe_null, name, t_arg); t_arg);
} }
unsigned int size_of() { return sizeof(*this);} unsigned int size_of() { return sizeof(*this);}
}; };
@ -284,8 +283,7 @@ public:
} }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
if (!t_arg) return result_field; return (!t_arg) ? result_field : new Field_time(maybe_null, name, t_arg);
return new Field_time(maybe_null, name, t_arg);
} }
unsigned int size_of() { return sizeof(*this);} unsigned int size_of() { return sizeof(*this);}
}; };
@ -381,11 +379,11 @@ public:
} }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
if (!t_arg) return result_field; return (!t_arg) ? result_field : new Field_time(maybe_null, name, t_arg);
return new Field_time(maybe_null, name, t_arg);
} }
}; };
enum interval_type { INTERVAL_YEAR, INTERVAL_MONTH, INTERVAL_DAY, enum interval_type { INTERVAL_YEAR, INTERVAL_MONTH, INTERVAL_DAY,
INTERVAL_HOUR, INTERVAL_MINUTE, INTERVAL_SECOND, INTERVAL_HOUR, INTERVAL_MINUTE, INTERVAL_SECOND,
INTERVAL_YEAR_MONTH, INTERVAL_DAY_HOUR, INTERVAL_YEAR_MONTH, INTERVAL_DAY_HOUR,
@ -447,8 +445,7 @@ public:
} }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
if (!t_arg) return result_field; return (!t_arg) ? result_field : new Field_date(maybe_null, name, t_arg);
return new Field_date(maybe_null, name, t_arg);
} }
}; };
@ -463,8 +460,7 @@ public:
} }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
if (!t_arg) return result_field; return (!t_arg) ? result_field : new Field_time(maybe_null, name, t_arg);
return new Field_time(maybe_null, name, t_arg);
} }
}; };
@ -479,7 +475,7 @@ public:
} }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
if (!t_arg) return result_field; return (!t_arg) ? result_field : new Field_datetime(maybe_null, name,
return new Field_datetime(maybe_null, name, t_arg); t_arg);
} }
}; };

View File

@ -28,6 +28,7 @@ TODO:
#include "mysql_priv.h" #include "mysql_priv.h"
#include <hash.h> #include <hash.h>
#include <assert.h>
extern HASH open_cache; extern HASH open_cache;
@ -427,6 +428,7 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
char key[MAX_DBKEY_LENGTH]; char key[MAX_DBKEY_LENGTH];
uint key_length; uint key_length;
DBUG_ENTER("lock_table_name"); DBUG_ENTER("lock_table_name");
safe_mutex_assert_owner(&LOCK_open);
key_length=(uint) (strmov(strmov(key,table_list->db)+1,table_list->name) key_length=(uint) (strmov(strmov(key,table_list->db)+1,table_list->name)
-key)+ 1; -key)+ 1;
@ -486,6 +488,7 @@ bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list)
{ {
bool result=0; bool result=0;
DBUG_ENTER("wait_for_locked_table_names"); DBUG_ENTER("wait_for_locked_table_names");
safe_mutex_assert_owner(&LOCK_open);
while (locked_named_table(thd,table_list)) while (locked_named_table(thd,table_list))
{ {

1039
sql/log.cc

File diff suppressed because it is too large Load Diff

View File

@ -149,6 +149,14 @@ Log_event::Log_event(THD* thd_arg, uint16 flags_arg)
} }
} }
/*
Delete all temporary files used for SQL_LOAD.
TODO
- When we get a 'server start' event, we should only remove
the files associated with the server id that just started.
Easily fixable by adding server_id as a prefix to the log files.
*/
static void cleanup_load_tmpdir() static void cleanup_load_tmpdir()
{ {
@ -195,7 +203,7 @@ Log_event::Log_event(const char* buf, bool old_format)
int Log_event::exec_event(struct st_relay_log_info* rli) int Log_event::exec_event(struct st_relay_log_info* rli)
{ {
if (rli) if (rli) // QQ When is this not true ?
{ {
rli->inc_pos(get_event_len(),log_pos); rli->inc_pos(get_event_len(),log_pos);
DBUG_ASSERT(rli->sql_thd != 0); DBUG_ASSERT(rli->sql_thd != 0);
@ -749,9 +757,9 @@ int Rotate_log_event::write_data(IO_CACHE* file)
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
bool using_trans) ulong query_length, bool using_trans)
:Log_event(thd_arg), data_buf(0), query(query_arg), db(thd_arg->db), :Log_event(thd_arg), data_buf(0), query(query_arg), db(thd_arg->db),
q_len(thd_arg->query_length), q_len((uint32) query_length),
error_code(thd_arg->killed ? ER_SERVER_SHUTDOWN: thd_arg->net.last_errno), error_code(thd_arg->killed ? ER_SERVER_SHUTDOWN: thd_arg->net.last_errno),
thread_id(thd_arg->thread_id), thread_id(thd_arg->thread_id),
cache_stmt(using_trans && cache_stmt(using_trans &&
@ -1267,7 +1275,7 @@ Slave_log_event::Slave_log_event(THD* thd_arg,
Log_event(thd_arg),mem_pool(0),master_host(0) Log_event(thd_arg),mem_pool(0),master_host(0)
{ {
DBUG_ENTER("Slave_log_event"); DBUG_ENTER("Slave_log_event");
if (!rli->inited) if (!rli->inited) // QQ When can this happen ?
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
MASTER_INFO* mi = rli->mi; MASTER_INFO* mi = rli->mi;
@ -1605,6 +1613,14 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
init_sql_alloc(&thd->mem_root, 8192,0); init_sql_alloc(&thd->mem_root, 8192,0);
thd->db = rewrite_db((char*)db); thd->db = rewrite_db((char*)db);
DBUG_ASSERT(q_len == strlen(query)); DBUG_ASSERT(q_len == strlen(query));
/*
InnoDB internally stores the master log position it has processed so far;
position to store is really pos + pending + event_len
since we must store the pos of the END of the current log event
*/
rli->event_len= get_event_len();
if (db_ok(thd->db, replicate_do_db, replicate_ignore_db)) if (db_ok(thd->db, replicate_do_db, replicate_ignore_db))
{ {
thd->query = (char*)query; thd->query = (char*)query;
@ -1783,14 +1799,26 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli)
} }
/*
The master started
IMPLEMENTATION
- To handle the case where the master died without a stop event,
we clean up all temporary tables + locks that we got.
TODO
- Remove all active user locks
- If we have an active transaction at this point, the master died
in the middle while writing the transaction to the binary log.
In this case we should stop the slave.
*/
int Start_log_event::exec_event(struct st_relay_log_info* rli) int Start_log_event::exec_event(struct st_relay_log_info* rli)
{ {
/* All temporary tables was deleted on the master */
close_temporary_tables(thd); close_temporary_tables(thd);
/* /*
If we have old format, load_tmpdir is cleaned up by the I/O thread If we have old format, load_tmpdir is cleaned up by the I/O thread
TODO: cleanup_load_tmpdir() needs to remove only the files associated
with the server id that has just started
*/ */
if (!rli->mi->old_format) if (!rli->mi->old_format)
cleanup_load_tmpdir(); cleanup_load_tmpdir();
@ -1798,6 +1826,14 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli)
} }
/*
The master stopped. Clean up all temporary tables + locks that the
master may have set.
TODO
- Remove all active user locks
*/
int Stop_log_event::exec_event(struct st_relay_log_info* rli) int Stop_log_event::exec_event(struct st_relay_log_info* rli)
{ {
// do not clean up immediately after rotate event // do not clean up immediately after rotate event
@ -1808,16 +1844,35 @@ int Stop_log_event::exec_event(struct st_relay_log_info* rli)
} }
/* /*
We do not want to update master_log pos because we get a rotate event We do not want to update master_log pos because we get a rotate event
before stop, so by now master_log_name is set to the next log before stop, so by now master_log_name is set to the next log.
if we updated it, we will have incorrect master coordinates and this If we updated it, we will have incorrect master coordinates and this
could give false triggers in MASTER_POS_WAIT() that we have reached could give false triggers in MASTER_POS_WAIT() that we have reached
the targed position when in fact we have not the target position when in fact we have not.
*/ */
rli->inc_pos(get_event_len(), 0); rli->inc_pos(get_event_len(), 0);
flush_relay_log_info(rli); flush_relay_log_info(rli);
return 0; return 0;
} }
/*
Got a rotate log even from the master
IMPLEMENTATION
- Rotate the log file if the name of the log file changed
(In practice this should always be the case)
TODO
- Investigate/Test if we can't ignore all rotate log events
that we get from the master (and not even write it to the local
binary log).
RETURN VALUES
0 ok
1 Impossible new log file name (rotate log event is ignored)
*/
int Rotate_log_event::exec_event(struct st_relay_log_info* rli) int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
{ {
bool rotate_binlog = 0, write_slave_event = 0; bool rotate_binlog = 0, write_slave_event = 0;
@ -1829,18 +1884,19 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
TODO: probably needs re-write TODO: probably needs re-write
rotate local binlog only if the name of remote has changed rotate local binlog only if the name of remote has changed
*/ */
if (!*log_name || !(log_name[ident_len] == 0 && if (!*log_name || (memcmp(log_name, new_log_ident, ident_len) ||
!memcmp(log_name, new_log_ident, ident_len))) log_name[ident_len] != 0))
{ {
write_slave_event = (!(flags & LOG_EVENT_FORCED_ROTATE_F) write_slave_event = (!(flags & LOG_EVENT_FORCED_ROTATE_F) &&
&& mysql_bin_log.is_open()); mysql_bin_log.is_open());
rotate_binlog = (*log_name && write_slave_event); rotate_binlog = (*log_name && write_slave_event);
if (ident_len >= sizeof(rli->master_log_name)) if (ident_len >= sizeof(rli->master_log_name))
{ {
// This should be impossible
pthread_mutex_unlock(&rli->data_lock); pthread_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
memcpy(log_name, new_log_ident,ident_len); memcpy(log_name, new_log_ident, ident_len);
log_name[ident_len] = 0; log_name[ident_len] = 0;
} }
rli->master_log_pos = pos; rli->master_log_pos = pos;
@ -1848,7 +1904,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
if (rotate_binlog) if (rotate_binlog)
{ {
mysql_bin_log.new_file(); mysql_bin_log.new_file();
rli->master_log_pos = 4; rli->master_log_pos = BIN_LOG_HEADER_SIZE;
} }
DBUG_PRINT("info", ("master_log_pos: %d", (ulong) rli->master_log_pos)); DBUG_PRINT("info", ("master_log_pos: %d", (ulong) rli->master_log_pos));
pthread_cond_broadcast(&rli->data_cond); pthread_cond_broadcast(&rli->data_cond);

View File

@ -317,7 +317,7 @@ public:
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
bool cache_stmt; bool cache_stmt;
Query_log_event(THD* thd_arg, const char* query_arg, Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length,
bool using_trans=0); bool using_trans=0);
const char* get_db() { return db; } const char* get_db() { return db; }
void pack_info(String* packet); void pack_info(String* packet);

View File

@ -199,7 +199,7 @@ MYSQL *mc_mysql_init(MYSQL *mysql)
#ifdef __WIN__ #ifdef __WIN__
mysql->options.connect_timeout=20; mysql->options.connect_timeout=20;
#endif #endif
mysql->net.timeout = slave_net_timeout; mysql->net.read_timeout = slave_net_timeout;
return mysql; return mysql;
} }
@ -417,6 +417,8 @@ my_bool mc_mysql_reconnect(MYSQL *mysql)
{ {
tmp_mysql.reconnect=0; tmp_mysql.reconnect=0;
mc_mysql_close(&tmp_mysql); mc_mysql_close(&tmp_mysql);
mysql->net.last_errno=CR_SERVER_GONE_ERROR;
strmov(mysql->net.last_error,ER(mysql->net.last_errno));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
tmp_mysql.free_me=mysql->free_me; tmp_mysql.free_me=mysql->free_me;
@ -507,11 +509,12 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
struct sockaddr_un UNIXaddr; struct sockaddr_un UNIXaddr;
#endif #endif
DBUG_ENTER("mc_mysql_connect"); DBUG_ENTER("mc_mysql_connect");
DBUG_PRINT("enter",("host: %s db: %s user: %s connect_time_out: %u read_timeout: %u",
DBUG_PRINT("enter",("host: %s db: %s user: %s",
host ? host : "(Null)", host ? host : "(Null)",
db ? db : "(Null)", db ? db : "(Null)",
user ? user : "(Null)")); user ? user : "(Null)",
net_read_timeout,
(uint) slave_net_timeout));
thr_alarm_init(&alarmed); thr_alarm_init(&alarmed);
thr_alarm(&alarmed, net_read_timeout, &alarm_buff); thr_alarm(&alarmed, net_read_timeout, &alarm_buff);
@ -655,7 +658,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
goto error; goto error;
} }
vio_keepalive(net->vio,TRUE); vio_keepalive(net->vio,TRUE);
net->timeout=slave_net_timeout; net->read_timeout=slave_net_timeout;
/* Get version info */ /* Get version info */
mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */ mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */
if ((pkt_length=mc_net_safe_read(mysql)) == packet_error) if ((pkt_length=mc_net_safe_read(mysql)) == packet_error)

View File

@ -580,8 +580,9 @@ void sql_print_error(const char *format,...)
__attribute__ ((format (printf, 1, 2))); __attribute__ ((format (printf, 1, 2)));
bool fn_format_relative_to_data_home(my_string to, const char *name, bool fn_format_relative_to_data_home(my_string to, const char *name,
const char *dir, const char *extension); const char *dir, const char *extension);
void open_log(MYSQL_LOG *log, const char *hostname, bool open_log(MYSQL_LOG *log, const char *hostname,
const char *opt_name, const char *extension, const char *opt_name, const char *extension,
const char *index_file_name,
enum_log_type type, bool read_append = 0, enum_log_type type, bool read_append = 0,
bool no_auto_events = 0); bool no_auto_events = 0);
@ -616,7 +617,7 @@ extern ulong select_range_check_count, select_range_count, select_scan_count;
extern ulong select_full_range_join_count,select_full_join_count; extern ulong select_full_range_join_count,select_full_join_count;
extern ulong slave_open_temp_tables, query_cache_size; extern ulong slave_open_temp_tables, query_cache_size;
extern ulong thd_startup_options, slow_launch_threads, slow_launch_time; extern ulong thd_startup_options, slow_launch_threads, slow_launch_time;
extern ulong server_id; extern ulong server_id, concurrency;
extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count; extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count;
extern ulong ha_read_key_count, ha_read_next_count, ha_read_prev_count; extern ulong ha_read_key_count, ha_read_next_count, ha_read_prev_count;
extern ulong ha_read_first_count, ha_read_last_count; extern ulong ha_read_first_count, ha_read_last_count;
@ -643,6 +644,7 @@ extern bool opt_disable_networking, opt_skip_show_db;
extern bool volatile abort_loop, shutdown_in_progress, grant_option; extern bool volatile abort_loop, shutdown_in_progress, grant_option;
extern uint volatile thread_count, thread_running, global_read_lock; extern uint volatile thread_count, thread_running, global_read_lock;
extern my_bool opt_safe_show_db, opt_local_infile, lower_case_table_names; extern my_bool opt_safe_show_db, opt_local_infile, lower_case_table_names;
extern my_bool opt_slave_compressed_protocol;
extern char f_fyllchar; extern char f_fyllchar;
extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
@ -666,7 +668,8 @@ extern struct system_variables global_system_variables;
extern struct system_variables max_system_variables; extern struct system_variables max_system_variables;
extern SHOW_COMP_OPTION have_isam, have_raid, have_openssl, have_symlink; extern SHOW_COMP_OPTION have_isam, have_raid, have_openssl, have_symlink;
extern SHOW_COMP_OPTION have_query_cache; extern SHOW_COMP_OPTION have_query_cache, have_berkeley_db, have_innodb;
#ifndef __WIN__ #ifndef __WIN__
extern pthread_t signal_thread; extern pthread_t signal_thread;

View File

@ -252,15 +252,15 @@ bool opt_skip_slave_start = 0; // If set, slave is not autostarted
*/ */
bool opt_reckless_slave = 0; bool opt_reckless_slave = 0;
ulong back_log, connect_timeout; ulong back_log, connect_timeout, concurrency;
char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], time_zone[30]; char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], time_zone[30];
bool opt_log, opt_update_log, opt_bin_log, opt_slow_log; bool opt_log, opt_update_log, opt_bin_log, opt_slow_log;
bool opt_disable_networking=0, opt_skip_show_db=0; bool opt_disable_networking=0, opt_skip_show_db=0;
my_bool opt_local_infile, opt_external_locking; my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol;
static bool opt_do_pstack = 0; static bool opt_do_pstack = 0;
static ulong opt_specialflag=SPECIAL_ENGLISH; static ulong opt_specialflag=SPECIAL_ENGLISH;
static ulong concurrency;
static ulong opt_myisam_block_size; static ulong opt_myisam_block_size;
static my_socket unix_sock= INVALID_SOCKET,ip_sock= INVALID_SOCKET; static my_socket unix_sock= INVALID_SOCKET,ip_sock= INVALID_SOCKET;
static my_string opt_logname=0,opt_update_logname=0, static my_string opt_logname=0,opt_update_logname=0,
@ -1428,6 +1428,17 @@ static void init_signals(void)
sigaction(SIGILL, &sa, NULL); sigaction(SIGILL, &sa, NULL);
sigaction(SIGFPE, &sa, NULL); sigaction(SIGFPE, &sa, NULL);
} }
#ifdef HAVE_GETRLIMIT
if (test_flags & TEST_CORE_ON_SIGNAL)
{
/* Change limits so that we will get a core file */
struct rlimit rl;
rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &rl))
sql_print_error("Warning: setrlimit could not change the size of core files to 'infinity'; We may not be able to generate a core file on signals");
}
#endif
(void) sigemptyset(&set); (void) sigemptyset(&set);
#ifdef THREAD_SPECIFIC_SIGPIPE #ifdef THREAD_SPECIFIC_SIGPIPE
sigset(SIGPIPE,abort_thread); sigset(SIGPIPE,abort_thread);
@ -1701,8 +1712,9 @@ const char *load_default_groups[]= { "mysqld","server",0 };
char *libwrapName=NULL; char *libwrapName=NULL;
#endif #endif
void open_log(MYSQL_LOG *log, const char *hostname, bool open_log(MYSQL_LOG *log, const char *hostname,
const char *opt_name, const char *extension, const char *opt_name, const char *extension,
const char *index_file_name,
enum_log_type type, bool read_append, enum_log_type type, bool read_append,
bool no_auto_events) bool no_auto_events)
{ {
@ -1728,7 +1740,8 @@ void open_log(MYSQL_LOG *log, const char *hostname,
opt_name=tmp; opt_name=tmp;
} }
} }
log->open(opt_name,type,0,(read_append) ? SEQ_READ_APPEND : WRITE_CACHE, return log->open(opt_name, type, 0, index_file_name,
(read_append) ? SEQ_READ_APPEND : WRITE_CACHE,
no_auto_events); no_auto_events);
} }
@ -1939,17 +1952,18 @@ int main(int argc, char **argv)
/* Setup log files */ /* Setup log files */
if (opt_log) if (opt_log)
open_log(&mysql_log, glob_hostname, opt_logname, ".log", LOG_NORMAL); open_log(&mysql_log, glob_hostname, opt_logname, ".log", NullS,
LOG_NORMAL);
if (opt_update_log) if (opt_update_log)
{ {
open_log(&mysql_update_log, glob_hostname, opt_update_logname, "", open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
LOG_NEW); NullS, LOG_NEW);
using_update_log=1; using_update_log=1;
} }
if (opt_slow_log) if (opt_slow_log)
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log", open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
LOG_NORMAL); NullS, LOG_NORMAL);
#ifdef __WIN__ #ifdef __WIN__
#define MYSQL_ERR_FILE "mysql.err" #define MYSQL_ERR_FILE "mysql.err"
if (!opt_console) if (!opt_console)
@ -2051,9 +2065,8 @@ The server will not act as a slave.");
strmov(strcend(tmp,'.'),"-bin"); strmov(strcend(tmp,'.'),"-bin");
opt_bin_logname=my_strdup(tmp,MYF(MY_WME)); 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, glob_hostname, opt_bin_logname, "-bin", open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
LOG_BIN); opt_binlog_index_name,LOG_BIN);
using_update_log=1; using_update_log=1;
} }
@ -2353,13 +2366,7 @@ static void create_new_thread(THD *thd)
delete thd; delete thd;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
if (pthread_mutex_lock(&LOCK_thread_count)) pthread_mutex_lock(&LOCK_thread_count);
{
DBUG_PRINT("error",("Can't lock LOCK_thread_count"));
close_connection(net,ER_OUT_OF_RESOURCES);
delete thd;
DBUG_VOID_RETURN;
}
if (thread_count-delayed_insert_threads > max_used_connections) if (thread_count-delayed_insert_threads > max_used_connections)
max_used_connections=thread_count-delayed_insert_threads; max_used_connections=thread_count-delayed_insert_threads;
thd->thread_id=thread_id++; thd->thread_id=thread_id++;
@ -2818,7 +2825,7 @@ enum options {
OPT_QUERY_CACHE_LIMIT, OPT_QUERY_CACHE_SIZE, OPT_QUERY_CACHE_LIMIT, OPT_QUERY_CACHE_SIZE,
OPT_QUERY_CACHE_TYPE, OPT_RECORD_BUFFER, OPT_QUERY_CACHE_TYPE, OPT_RECORD_BUFFER,
OPT_RECORD_RND_BUFFER, OPT_RELAY_LOG_SPACE_LIMIT, OPT_RECORD_RND_BUFFER, OPT_RELAY_LOG_SPACE_LIMIT,
OPT_SLAVE_NET_TIMEOUT, OPT_SLOW_LAUNCH_TIME, OPT_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME,
OPT_SORT_BUFFER, OPT_TABLE_CACHE, OPT_SORT_BUFFER, OPT_TABLE_CACHE,
OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE, OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE,
OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK, OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
@ -2968,8 +2975,9 @@ struct my_option my_long_options[] =
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"innodb_flush_log_at_trx_commit", OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT, {"innodb_flush_log_at_trx_commit", OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT,
"Set to 0 if you don't want to flush logs", "Set to 0 if you don't want to flush logs",
&innobase_flush_log_at_trx_commit, &innobase_flush_log_at_trx_commit, (gptr*) &innobase_flush_log_at_trx_commit,
0, GET_LONG, OPT_ARG, 0, 0, 10, 0, 0, 0}, (gptr*) &innobase_flush_log_at_trx_commit,
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"innodb_flush_method", OPT_INNODB_FLUSH_METHOD, {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
"With which method to flush data", (gptr*) &innobase_unix_file_flush_method, "With which method to flush data", (gptr*) &innobase_unix_file_flush_method,
(gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
@ -3047,7 +3055,7 @@ struct my_option my_long_options[] =
{"master-retry-count", OPT_MASTER_RETRY_COUNT, {"master-retry-count", OPT_MASTER_RETRY_COUNT,
"The number of tries the slave will make to connect to the master before giving up.", "The number of tries the slave will make to connect to the master before giving up.",
(gptr*) &master_retry_count, (gptr*) &master_retry_count, 0, GET_ULONG, (gptr*) &master_retry_count, (gptr*) &master_retry_count, 0, GET_ULONG,
REQUIRED_ARG, 60, 0, 0, 0, 0, 0}, REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0},
{"master-info-file", OPT_MASTER_INFO_FILE, {"master-info-file", OPT_MASTER_INFO_FILE,
"The location of the file that remembers where we left off on the master during the replication process. The default is `master.info' in the data directory. You should not need to change this.", "The location of the file that remembers where we left off on the master during the replication process. The default is `master.info' in the data directory. You should not need to change this.",
(gptr*) &master_info_file, (gptr*) &master_info_file, 0, GET_STR, (gptr*) &master_info_file, (gptr*) &master_info_file, 0, GET_STR,
@ -3330,7 +3338,7 @@ struct my_option my_long_options[] =
{ "ft_min_word_len", OPT_FT_MIN_WORD_LEN, { "ft_min_word_len", OPT_FT_MIN_WORD_LEN,
"The minimum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable.", "The minimum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable.",
(gptr*) &ft_min_word_len, (gptr*) &ft_min_word_len, 0, GET_ULONG, (gptr*) &ft_min_word_len, (gptr*) &ft_min_word_len, 0, GET_ULONG,
REQUIRED_ARG, 4, 1, HA_FT_MAXLEN, 0, 1, 0}, REQUIRED_ARG, 4, 2, HA_FT_MAXLEN, 0, 1, 0},
{ "ft_max_word_len", OPT_FT_MAX_WORD_LEN, { "ft_max_word_len", OPT_FT_MAX_WORD_LEN,
"The maximum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable.", "The maximum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable.",
(gptr*) &ft_max_word_len, (gptr*) &ft_max_word_len, 0, GET_ULONG, (gptr*) &ft_max_word_len, (gptr*) &ft_max_word_len, 0, GET_ULONG,
@ -3548,6 +3556,11 @@ struct my_option my_long_options[] =
"Undocumented", (gptr*) &relay_log_space_limit, "Undocumented", (gptr*) &relay_log_space_limit,
(gptr*) &relay_log_space_limit, 0, GET_ULONG, REQUIRED_ARG, 0L, 0L, (gptr*) &relay_log_space_limit, 0, GET_ULONG, REQUIRED_ARG, 0L, 0L,
(longlong) ULONG_MAX, 0, 1, 0}, (longlong) ULONG_MAX, 0, 1, 0},
{"slave_compressed_protocol", OPT_SLAVE_COMPRESSED_PROTOCOL,
"Use compression on master/slave protocol",
(gptr*) &opt_slave_compressed_protocol,
(gptr*) &opt_slave_compressed_protocol,
0, GET_BOOL, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
{"slave_net_timeout", OPT_SLAVE_NET_TIMEOUT, {"slave_net_timeout", OPT_SLAVE_NET_TIMEOUT,
"Number of seconds to wait for more data from a master/slave connection before aborting the read.", "Number of seconds to wait for more data from a master/slave connection before aborting the read.",
(gptr*) &slave_net_timeout, (gptr*) &slave_net_timeout, 0, (gptr*) &slave_net_timeout, (gptr*) &slave_net_timeout, 0,

View File

@ -107,7 +107,10 @@ int my_net_init(NET *net, Vio* vio)
net->fd = vio_fd(vio); /* For perl DBI/DBD */ net->fd = vio_fd(vio); /* For perl DBI/DBD */
#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) #if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) && !defined(OS2)
if (!(test_flags & TEST_BLOCKING)) if (!(test_flags & TEST_BLOCKING))
vio_blocking(vio, FALSE); {
my_bool old_mode;
vio_blocking(vio, FALSE, &old_mode);
}
#endif #endif
vio_fastsend(vio); vio_fastsend(vio);
} }
@ -161,17 +164,14 @@ void net_clear(NET *net)
{ {
#if !defined(EXTRA_DEBUG) && !defined(EMBEDDED_LIBRARY) #if !defined(EXTRA_DEBUG) && !defined(EMBEDDED_LIBRARY)
int count; /* One may get 'unused' warn */ int count; /* One may get 'unused' warn */
bool is_blocking=vio_is_blocking(net->vio); my_bool old_mode;
if (is_blocking) if (!vio_blocking(net->vio, FALSE, &old_mode))
vio_blocking(net->vio, FALSE);
if (!vio_is_blocking(net->vio)) /* Safety if SSL */
{ {
while ( (count = vio_read(net->vio, (char*) (net->buff), while ( (count = vio_read(net->vio, (char*) (net->buff),
(uint32) net->max_packet)) > 0) (uint32) net->max_packet)) > 0)
DBUG_PRINT("info",("skipped %d bytes from file: %s", DBUG_PRINT("info",("skipped %d bytes from file: %s",
count,vio_description(net->vio))); count,vio_description(net->vio)));
if (is_blocking) vio_blocking(net->vio, TRUE, &old_mode);
vio_blocking(net->vio, TRUE);
} }
#endif /* EXTRA_DEBUG */ #endif /* EXTRA_DEBUG */
net->pkt_nr=net->compress_pkt_nr=0; /* Ready for new command */ net->pkt_nr=net->compress_pkt_nr=0; /* Ready for new command */
@ -382,9 +382,8 @@ net_real_write(NET *net,const char *packet,ulong len)
{ {
if (!thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff)) if (!thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff))
{ /* Always true for client */ { /* Always true for client */
if (!vio_is_blocking(net->vio)) my_bool old_mode;
{ while (vio_blocking(net->vio, TRUE, &old_mode) < 0)
while (vio_blocking(net->vio, TRUE) < 0)
{ {
if (vio_should_retry(net->vio) && retry_count++ < RETRY_COUNT) if (vio_should_retry(net->vio) && retry_count++ < RETRY_COUNT)
continue; continue;
@ -396,7 +395,6 @@ net_real_write(NET *net,const char *packet,ulong len)
net->error=2; /* Close socket */ net->error=2; /* Close socket */
goto end; goto end;
} }
}
retry_count=0; retry_count=0;
continue; continue;
} }
@ -439,8 +437,9 @@ net_real_write(NET *net,const char *packet,ulong len)
#endif #endif
if (thr_alarm_in_use(&alarmed)) if (thr_alarm_in_use(&alarmed))
{ {
my_bool old_mode;
thr_end_alarm(&alarmed); thr_end_alarm(&alarmed);
vio_blocking(net->vio, net_blocking); vio_blocking(net->vio, net_blocking, &old_mode);
} }
net->reading_or_writing=0; net->reading_or_writing=0;
DBUG_RETURN(((int) (pos != end))); DBUG_RETURN(((int) (pos != end)));
@ -461,10 +460,12 @@ static void my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed)
{ {
ALARM alarm_buff; ALARM alarm_buff;
uint retry_count=0; uint retry_count=0;
my_bool old_mode;
if (!thr_alarm_in_use(&alarmed)) if (!thr_alarm_in_use(&alarmed))
{ {
if (!thr_alarm(alarmed,net->read_timeout,&alarm_buff) || if (!thr_alarm(alarmed,net->read_timeout,&alarm_buff) ||
(!vio_is_blocking(net->vio) && vio_blocking(net->vio,TRUE) < 0)) vio_blocking(net->vio, TRUE, &old_mode) < 0)
return; /* Can't setup, abort */ return; /* Can't setup, abort */
} }
while (remain > 0) while (remain > 0)
@ -538,9 +539,8 @@ my_real_read(NET *net, ulong *complen)
{ {
if (!thr_alarm(&alarmed,net->read_timeout,&alarm_buff)) /* Don't wait too long */ if (!thr_alarm(&alarmed,net->read_timeout,&alarm_buff)) /* Don't wait too long */
{ {
if (!vio_is_blocking(net->vio)) my_bool old_mode;
{ while (vio_blocking(net->vio, TRUE, &old_mode) < 0)
while (vio_blocking(net->vio,TRUE) < 0)
{ {
if (vio_should_retry(net->vio) && if (vio_should_retry(net->vio) &&
retry_count++ < RETRY_COUNT) retry_count++ < RETRY_COUNT)
@ -560,7 +560,6 @@ my_real_read(NET *net, ulong *complen)
#endif #endif
goto end; goto end;
} }
}
retry_count=0; retry_count=0;
continue; continue;
} }
@ -583,7 +582,9 @@ my_real_read(NET *net, ulong *complen)
continue; continue;
} }
#endif #endif
DBUG_PRINT("error",("Couldn't read packet: remain: %lu errno: %d length: %ld alarmed: %d", remain,vio_errno(net->vio),length,alarmed)); DBUG_PRINT("error",("Couldn't read packet: remain: %lu errno: %d length: %ld alarmed: %d",
remain,vio_errno(net->vio), length,
thr_got_alarm(&alarmed)));
len= packet_error; len= packet_error;
net->error=2; /* Close socket */ net->error=2; /* Close socket */
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
@ -653,8 +654,9 @@ my_real_read(NET *net, ulong *complen)
end: end:
if (thr_alarm_in_use(&alarmed)) if (thr_alarm_in_use(&alarmed))
{ {
my_bool old_mode;
thr_end_alarm(&alarmed); thr_end_alarm(&alarmed);
vio_blocking(net->vio, net_blocking); vio_blocking(net->vio, net_blocking, &old_mode);
} }
net->reading_or_writing=0; net->reading_or_writing=0;
return(len); return(len);

View File

@ -240,7 +240,7 @@ static int find_target_pos(LEX_MASTER_INFO *mi, IO_CACHE *log, char *errmsg)
int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg) int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg)
{ {
LOG_INFO linfo; LOG_INFO linfo;
char search_file_name[FN_REFLEN],last_log_name[FN_REFLEN]; char last_log_name[FN_REFLEN];
IO_CACHE log; IO_CACHE log;
File file = -1, last_file = -1; File file = -1, last_file = -1;
pthread_mutex_t *log_lock; pthread_mutex_t *log_lock;
@ -264,9 +264,8 @@ int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg)
} }
linfo.index_file_offset = 0; linfo.index_file_offset = 0;
search_file_name[0] = 0;
if (mysql_bin_log.find_first_log(&linfo, search_file_name)) if (mysql_bin_log.find_log_pos(&linfo, NullS))
{ {
strmov(errmsg,"Could not find first log"); strmov(errmsg,"Could not find first log");
return 1; return 1;
@ -619,18 +618,22 @@ int show_slave_hosts(THD* thd)
int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi) int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi)
{ {
if (!mi->host || !*mi->host) /* empty host */ DBUG_ENTER("connect_to_master");
return 1;
if (!mi->host || !*mi->host) /* empty host */
{
DBUG_PRINT("error",("empty hostname"));
DBUG_RETURN(1);
}
if (!mc_mysql_connect(mysql, mi->host, mi->user, mi->password, 0, if (!mc_mysql_connect(mysql, mi->host, mi->user, mi->password, 0,
mi->port, 0, 0, mi->port, 0, 0,
slave_net_timeout)) slave_net_timeout))
{ {
sql_print_error("Connection to master failed: %s", sql_print_error("Connection to master failed: %s",
mc_mysql_error(mysql)); mc_mysql_error(mysql));
return 1; DBUG_RETURN(1);
} }
return 0; DBUG_RETURN(0);
} }
@ -671,12 +674,17 @@ static inline int fetch_db_tables(THD* thd, MYSQL* mysql, const char* db,
return 0; return 0;
} }
/*
Load all MyISAM tables from master to this slave.
REQUIREMENTS
- No active transaction (flush_relay_log_info would not work in this case)
*/
int load_master_data(THD* thd) int load_master_data(THD* thd)
{ {
MYSQL mysql; MYSQL mysql;
MYSQL_RES* master_status_res = 0; MYSQL_RES* master_status_res = 0;
bool slave_was_running = 0;
int error = 0; int error = 0;
const char* errmsg=0; const char* errmsg=0;
int restart_thread_mask; int restart_thread_mask;
@ -840,7 +848,8 @@ int load_master_data(THD* thd)
} }
} }
thd->proc_info="purging old relay logs"; thd->proc_info="purging old relay logs";
if (purge_relay_logs(&active_mi->rli,0 /* not only reset, but also reinit */, if (purge_relay_logs(&active_mi->rli,thd,
0 /* not only reset, but also reinit */,
&errmsg)) &errmsg))
{ {
send_error(&thd->net, 0, "Failed purging old relay logs"); send_error(&thd->net, 0, "Failed purging old relay logs");

View File

@ -186,6 +186,8 @@ sys_var_thd_enum sys_query_cache_type("query_cache_type",
sys_var_bool_ptr sys_safe_show_db("safe_show_database", sys_var_bool_ptr sys_safe_show_db("safe_show_database",
&opt_safe_show_db); &opt_safe_show_db);
sys_var_long_ptr sys_server_id("server_id",&server_id); sys_var_long_ptr sys_server_id("server_id",&server_id);
sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol",
&opt_slave_compressed_protocol);
sys_var_long_ptr sys_slave_net_timeout("slave_net_timeout", sys_var_long_ptr sys_slave_net_timeout("slave_net_timeout",
&slave_net_timeout); &slave_net_timeout);
sys_var_long_ptr sys_slow_launch_time("slow_launch_time", sys_var_long_ptr sys_slow_launch_time("slow_launch_time",
@ -251,6 +253,15 @@ static sys_var_thd_bit sys_buffer_results("sql_buffer_result",
static sys_var_thd_bit sys_quote_show_create("sql_quote_show_create", static sys_var_thd_bit sys_quote_show_create("sql_quote_show_create",
set_option_bit, set_option_bit,
OPTION_QUOTE_SHOW_CREATE); OPTION_QUOTE_SHOW_CREATE);
static sys_var_thd_bit sys_foreign_key_checks("foreign_key_checks",
set_option_bit,
OPTION_NO_FOREIGN_KEY_CHECKS,
1);
static sys_var_thd_bit sys_unique_checks("unique_checks",
set_option_bit,
OPTION_RELAXED_UNIQUE_CHECKS,
1);
/* Local state variables */ /* Local state variables */
@ -290,6 +301,7 @@ sys_var *sys_variables[]=
&sys_delayed_queue_size, &sys_delayed_queue_size,
&sys_flush, &sys_flush,
&sys_flush_time, &sys_flush_time,
&sys_foreign_key_checks,
&sys_identity, &sys_identity,
&sys_insert_id, &sys_insert_id,
&sys_interactive_timeout, &sys_interactive_timeout,
@ -326,7 +338,7 @@ sys_var *sys_variables[]=
#ifdef HAVE_QUERY_CACHE #ifdef HAVE_QUERY_CACHE
&sys_query_cache_limit, &sys_query_cache_limit,
&sys_query_cache_type, &sys_query_cache_type,
#endif HAVE_QUERY_CACHE #endif /* HAVE_QUERY_CACHE */
&sys_quote_show_create, &sys_quote_show_create,
&sys_read_buff_size, &sys_read_buff_size,
&sys_read_rnd_buff_size, &sys_read_rnd_buff_size,
@ -335,6 +347,7 @@ sys_var *sys_variables[]=
&sys_safe_updates, &sys_safe_updates,
&sys_select_limit, &sys_select_limit,
&sys_server_id, &sys_server_id,
&sys_slave_compressed_protocol,
&sys_slave_net_timeout, &sys_slave_net_timeout,
&sys_slave_skip_counter, &sys_slave_skip_counter,
&sys_slow_launch_time, &sys_slow_launch_time,
@ -349,6 +362,7 @@ sys_var *sys_variables[]=
&sys_timestamp, &sys_timestamp,
&sys_tmp_table_size, &sys_tmp_table_size,
&sys_tx_isolation, &sys_tx_isolation,
&sys_unique_checks
}; };
@ -403,7 +417,7 @@ struct show_var_st init_vars[]= {
{"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG }, {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
{"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG }, {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
{"innodb_thread_concurrency", (char*) &innobase_thread_concurrency, SHOW_LONG }, {"innodb_thread_concurrency", (char*) &innobase_thread_concurrency, SHOW_LONG },
{"innodb_flush_log_at_trx_commit", (char*) &innobase_flush_log_at_trx_commit, SHOW_MY_BOOL}, {"innodb_flush_log_at_trx_commit", (char*) &innobase_flush_log_at_trx_commit, SHOW_LONG},
{"innodb_fast_shutdown", (char*) &innobase_fast_shutdown, SHOW_MY_BOOL}, {"innodb_fast_shutdown", (char*) &innobase_fast_shutdown, SHOW_MY_BOOL},
{"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR}, {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
{"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG }, {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
@ -988,10 +1002,11 @@ bool sys_var_slave_skip_counter::update(THD *thd, set_var *var)
static bool set_option_bit(THD *thd, set_var *var) static bool set_option_bit(THD *thd, set_var *var)
{ {
if (var->save_result.ulong_value == 0) sys_var_thd_bit *sys_var= ((sys_var_thd_bit*) var->var);
thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag; if ((var->save_result.ulong_value != 0) == sys_var->reverse)
thd->options&= ~sys_var->bit_flag;
else else
thd->options|= ((sys_var_thd_bit*) var->var)->bit_flag; thd->options|= sys_var->bit_flag;
return 0; return 0;
} }
@ -1142,7 +1157,7 @@ void set_var_free()
0 Unknown variable (error message is given) 0 Unknown variable (error message is given)
*/ */
sys_var *find_sys_var(const char *str, uint length=0) sys_var *find_sys_var(const char *str, uint length)
{ {
sys_var *var= (sys_var*) hash_search(&system_variable_hash, str, sys_var *var= (sys_var*) hash_search(&system_variable_hash, str,
length ? length : length ? length :

View File

@ -128,7 +128,7 @@ public:
} }
void set_default(THD *thd, enum_var_type type) void set_default(THD *thd, enum_var_type type)
{ {
return (*set_default_func)(thd, type); (*set_default_func)(thd, type);
} }
SHOW_TYPE type() { return SHOW_CHAR; } SHOW_TYPE type() { return SHOW_CHAR; }
byte *value_ptr(THD *thd, enum_var_type type) { return (byte*) value; } byte *value_ptr(THD *thd, enum_var_type type) { return (byte*) value; }

File diff suppressed because it is too large Load Diff

View File

@ -138,6 +138,14 @@ typedef struct st_relay_log_info
ulonglong relay_log_pos, pending; ulonglong relay_log_pos, pending;
ulonglong log_space_limit,log_space_total; ulonglong log_space_limit,log_space_total;
/*
InnoDB internally stores the master log position it has processed
so far; the position to store is really the sum of
pos + pending + event_len here since we must store the pos of the
END of the current log event
*/
int event_len;
/* /*
Needed for problems when slave stops and we want to restart it Needed for problems when slave stops and we want to restart it
skipping one or more events in the master log that have caused skipping one or more events in the master log that have caused
@ -167,6 +175,7 @@ typedef struct st_relay_log_info
{ {
relay_log_name[0] = master_log_name[0] = 0; relay_log_name[0] = master_log_name[0] = 0;
bzero(&info_file,sizeof(info_file)); bzero(&info_file,sizeof(info_file));
bzero(&cache_buf, sizeof(cache_buf));
pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST); pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST); pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&log_space_lock, MY_MUTEX_INIT_FAST); pthread_mutex_init(&log_space_lock, MY_MUTEX_INIT_FAST);
@ -204,7 +213,7 @@ typedef struct st_relay_log_info
} }
/* /*
thread safe read of position - not needed if we are in the slave thread, thread safe read of position - not needed if we are in the slave thread,
but required otherwise but required otherwise as var is a longlong
*/ */
inline void read_pos(ulonglong& var) inline void read_pos(ulonglong& var)
{ {
@ -216,6 +225,7 @@ typedef struct st_relay_log_info
int wait_for_pos(THD* thd, String* log_name, ulonglong log_pos); int wait_for_pos(THD* thd, String* log_name, ulonglong log_pos);
} RELAY_LOG_INFO; } RELAY_LOG_INFO;
Log_event* next_event(RELAY_LOG_INFO* rli); Log_event* next_event(RELAY_LOG_INFO* rli);
/* /*
@ -251,16 +261,7 @@ typedef struct st_master_info
char master_log_name[FN_REFLEN]; char master_log_name[FN_REFLEN];
my_off_t master_log_pos; my_off_t master_log_pos;
File fd; File fd; // we keep the file open, so we need to remember the file pointer
/*
InnoDB internally stores the master log position it has processed
so far; the position to store is really the sum of
pos + pending + event_len here since we must store the pos of the
END of the current log event
*/
int event_len;
File fd;
IO_CACHE file; IO_CACHE file;
/* the variables below are needed because we can change masters on the fly */ /* the variables below are needed because we can change masters on the fly */
@ -288,7 +289,7 @@ typedef struct st_master_info
slave_running(0) slave_running(0)
{ {
host[0] = 0; user[0] = 0; password[0] = 0; host[0] = 0; user[0] = 0; password[0] = 0;
bzero(&file,sizeof(file)); bzero(&file, sizeof(file));
pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST); pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST); pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
pthread_cond_init(&data_cond, NULL); pthread_cond_init(&data_cond, NULL);
@ -337,8 +338,8 @@ typedef struct st_table_rule_ent
int init_slave(); int init_slave();
void init_slave_skip_errors(const char* arg); void init_slave_skip_errors(const char* arg);
int flush_master_info(MASTER_INFO* mi); bool flush_master_info(MASTER_INFO* mi);
int flush_relay_log_info(RELAY_LOG_INFO* rli); bool flush_relay_log_info(RELAY_LOG_INFO* rli);
int register_slave_on_master(MYSQL* mysql); int register_slave_on_master(MYSQL* mysql);
int terminate_slave_threads(MASTER_INFO* mi, int thread_mask, int terminate_slave_threads(MASTER_INFO* mi, int thread_mask,
bool skip_lock = 0); bool skip_lock = 0);
@ -393,7 +394,8 @@ void slave_print_error(RELAY_LOG_INFO* rli,int err_code, const char* msg, ...);
void end_slave(); /* clean up */ void end_slave(); /* clean up */
int init_master_info(MASTER_INFO* mi, const char* master_info_fname, int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
const char* slave_info_fname); const char* slave_info_fname,
bool abort_if_no_master_info_file);
void end_master_info(MASTER_INFO* mi); void end_master_info(MASTER_INFO* mi);
int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname); int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname);
void end_relay_log_info(RELAY_LOG_INFO* rli); void end_relay_log_info(RELAY_LOG_INFO* rli);
@ -403,7 +405,8 @@ void init_thread_mask(int* mask,MASTER_INFO* mi,bool inverse);
int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log,ulonglong pos, int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log,ulonglong pos,
bool need_data_lock, const char** errmsg); bool need_data_lock, const char** errmsg);
int purge_relay_logs(RELAY_LOG_INFO* rli,bool just_reset,const char** errmsg); int purge_relay_logs(RELAY_LOG_INFO* rli, THD *thd, bool just_reset,
const char** errmsg);
extern bool opt_log_slave_updates ; extern bool opt_log_slave_updates ;
pthread_handler_decl(handle_slave_io,arg); pthread_handler_decl(handle_slave_io,arg);

View File

@ -497,10 +497,14 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user,
ulong user_access=NO_ACCESS; ulong user_access=NO_ACCESS;
*priv_user=(char*) user; *priv_user=(char*) user;
char *ptr=0; char *ptr=0;
DBUG_ENTER("acl_getroot");
bzero(mqh,sizeof(USER_RESOURCES)); bzero(mqh,sizeof(USER_RESOURCES));
if (!initialized) if (!initialized)
return (ulong) ~NO_ACCESS; // If no data allow anything /* purecov: tested */ {
// If no data allow anything
DBUG_RETURN((ulong) ~NO_ACCESS); /* purecov: tested */
}
VOID(pthread_mutex_lock(&acl_cache->lock)); VOID(pthread_mutex_lock(&acl_cache->lock));
/* /*
@ -616,7 +620,7 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user,
} }
} }
VOID(pthread_mutex_unlock(&acl_cache->lock)); VOID(pthread_mutex_unlock(&acl_cache->lock));
return user_access; DBUG_RETURN(user_access);
} }
@ -1053,15 +1057,14 @@ bool change_password(THD *thd, const char *host, const char *user,
VOID(pthread_mutex_unlock(&acl_cache->lock)); VOID(pthread_mutex_unlock(&acl_cache->lock));
char buff[460]; char buff[460];
ulong query_length=
Query_log_event qinfo(thd, buff);
qinfo.q_len =
my_sprintf(buff, my_sprintf(buff,
(buff,"SET PASSWORD FOR \"%-.120s\"@\"%-.120s\"=\"%-.120s\"", (buff,"SET PASSWORD FOR \"%-.120s\"@\"%-.120s\"=\"%-.120s\"",
acl_user->user ? acl_user->user : "", acl_user->user ? acl_user->user : "",
acl_user->host.hostname ? acl_user->host.hostname : "", acl_user->host.hostname ? acl_user->host.hostname : "",
new_password)); new_password));
mysql_update_log.write(thd,buff,qinfo.q_len); mysql_update_log.write(thd, buff, query_length);
Query_log_event qinfo(thd, buff, query_length);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
DBUG_RETURN(0); DBUG_RETURN(0);
} }

View File

@ -279,6 +279,7 @@ void intern_close_table(TABLE *table)
static void free_cache_entry(TABLE *table) static void free_cache_entry(TABLE *table)
{ {
DBUG_ENTER("free_cache_entry"); DBUG_ENTER("free_cache_entry");
safe_mutex_assert_owner(&LOCK_open);
intern_close_table(table); intern_close_table(table);
if (!table->in_use) if (!table->in_use)
@ -425,6 +426,7 @@ void close_thread_tables(THD *thd, bool locked)
/* VOID(pthread_sigmask(SIG_SETMASK,&thd->block_signals,NULL)); */ /* VOID(pthread_sigmask(SIG_SETMASK,&thd->block_signals,NULL)); */
if (!locked) if (!locked)
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
safe_mutex_assert_owner(&LOCK_open);
DBUG_PRINT("info", ("thd->open_tables=%p", thd->open_tables)); DBUG_PRINT("info", ("thd->open_tables=%p", thd->open_tables));
@ -550,13 +552,10 @@ void close_temporary_tables(THD *thd)
} }
if (query && found_user_tables && mysql_bin_log.is_open()) if (query && found_user_tables && mysql_bin_log.is_open())
{ {
uint save_query_len = thd->query_length; /* The -1 is to remove last ',' */
*--end = 0; // Remove last ',' Query_log_event qinfo(thd, query, (ulong)(end-query)-1);
thd->query_length = (uint)(end-query);
Query_log_event qinfo(thd, query);
qinfo.error_code=0; qinfo.error_code=0;
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
thd->query_length = save_query_len;
} }
thd->temporary_tables=0; thd->temporary_tables=0;
} }
@ -669,11 +668,13 @@ TABLE *unlink_open_table(THD *thd, TABLE *list, TABLE *find)
/* /*
When we call the following function we must have a lock on When we call the following function we must have a lock on
LOCK_OPEN ; This lock will be unlocked on return. LOCK_open ; This lock will be unlocked on return.
*/ */
void wait_for_refresh(THD *thd) void wait_for_refresh(THD *thd)
{ {
safe_mutex_assert_owner(&LOCK_open);
/* Wait until the current table is up to date */ /* Wait until the current table is up to date */
const char *proc_info; const char *proc_info;
thd->mysys_var->current_mutex= &LOCK_open; thd->mysys_var->current_mutex= &LOCK_open;
@ -931,6 +932,7 @@ bool reopen_table(TABLE *table,bool locked)
#endif #endif
if (!locked) if (!locked)
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
safe_mutex_assert_owner(&LOCK_open);
if (open_unireg_entry(current_thd,&tmp,db,table_name,table->table_name, if (open_unireg_entry(current_thd,&tmp,db,table_name,table->table_name,
locked)) locked))
@ -1022,6 +1024,8 @@ bool close_data_tables(THD *thd,const char *db, const char *table_name)
bool reopen_tables(THD *thd,bool get_locks,bool in_refresh) bool reopen_tables(THD *thd,bool get_locks,bool in_refresh)
{ {
DBUG_ENTER("reopen_tables"); DBUG_ENTER("reopen_tables");
safe_mutex_assert_owner(&LOCK_open);
if (!thd->open_tables) if (!thd->open_tables)
DBUG_RETURN(0); DBUG_RETURN(0);
@ -1259,6 +1263,8 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
table_list.next=0; table_list.next=0;
if (!locked) if (!locked)
pthread_mutex_lock(&LOCK_open); pthread_mutex_lock(&LOCK_open);
safe_mutex_assert_owner(&LOCK_open);
if ((error=lock_table_name(thd,&table_list))) if ((error=lock_table_name(thd,&table_list)))
{ {
if (error < 0) if (error < 0)

View File

@ -873,10 +873,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) || (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) ||
thd->variables.query_cache_type == 0) thd->variables.query_cache_type == 0)
{
DBUG_PRINT("qcache", ("query cache disabled or not in autocommit mode"));
goto err; goto err;
}
/* Check that we haven't forgot to reset the query cache variables */ /* Check that we haven't forgot to reset the query cache variables */
DBUG_ASSERT(thd->net.query_cache_query == 0); DBUG_ASSERT(thd->net.query_cache_query == 0);
@ -1021,6 +1018,7 @@ err:
DBUG_RETURN(0); // Query was not cached DBUG_RETURN(0); // Query was not cached
} }
/* /*
Remove all cached queries that uses any of the tables in the list Remove all cached queries that uses any of the tables in the list
*/ */

View File

@ -47,7 +47,7 @@ struct st_relay_log_info;
typedef struct st_log_info typedef struct st_log_info
{ {
char log_file_name[FN_REFLEN]; char log_file_name[FN_REFLEN];
my_off_t index_file_offset; my_off_t index_file_offset, index_file_start_offset;
my_off_t pos; my_off_t pos;
bool fatal; // if the purge happens to give us a negative offset bool fatal; // if the purge happens to give us a negative offset
pthread_mutex_t lock; pthread_mutex_t lock;
@ -64,7 +64,7 @@ class MYSQL_LOG {
ulonglong bytes_written; ulonglong bytes_written;
time_t last_time,query_start; time_t last_time,query_start;
IO_CACHE log_file; IO_CACHE log_file;
File index_file; IO_CACHE index_file;
char *name; char *name;
char time_buff[20],db[NAME_LEN+1]; char time_buff[20],db[NAME_LEN+1];
char log_file_name[FN_REFLEN],index_file_name[FN_REFLEN]; char log_file_name[FN_REFLEN],index_file_name[FN_REFLEN];
@ -106,16 +106,14 @@ public:
void signal_update() { pthread_cond_broadcast(&update_cond);} void signal_update() { pthread_cond_broadcast(&update_cond);}
void wait_for_update(THD* thd); void wait_for_update(THD* thd);
void set_need_start_event() { need_start_event = 1; } void set_need_start_event() { need_start_event = 1; }
void set_index_file_name(const char* index_file_name = 0);
void init(enum_log_type log_type_arg, void init(enum_log_type log_type_arg,
enum cache_type io_cache_type_arg = WRITE_CACHE, enum cache_type io_cache_type_arg = WRITE_CACHE,
bool no_auto_events_arg = 0); bool no_auto_events_arg = 0);
void open(const char *log_name,enum_log_type log_type, bool open(const char *log_name,enum_log_type log_type,
const char *new_name, enum cache_type io_cache_type_arg, const char *new_name, const char *index_file_name_arg,
enum cache_type io_cache_type_arg,
bool no_auto_events_arg); bool no_auto_events_arg);
void new_file(bool inside_mutex = 0); void new_file(bool need_lock= 1);
bool open_index(int options);
void close_index();
bool write(THD *thd, enum enum_server_command command, bool write(THD *thd, enum enum_server_command command,
const char *format,...); const char *format,...);
bool write(THD *thd, const char *query, uint query_length, bool write(THD *thd, const char *query, uint query_length,
@ -135,12 +133,12 @@ public:
bool is_active(const char* log_file_name); bool is_active(const char* log_file_name);
int purge_logs(THD* thd, const char* to_log); int purge_logs(THD* thd, const char* to_log);
int purge_first_log(struct st_relay_log_info* rli); int purge_first_log(struct st_relay_log_info* rli);
int reset_logs(THD* thd); bool reset_logs(THD* thd);
// if we are exiting, we also want to close the index file // if we are exiting, we also want to close the index file
void close(bool exiting = 0); void close(bool exiting = 0);
// iterating through the log index file // iterating through the log index file
int find_first_log(LOG_INFO* linfo, const char* log_name, int find_log_pos(LOG_INFO* linfo, const char* log_name,
bool need_mutex=1); bool need_mutex=1);
int find_next_log(LOG_INFO* linfo, bool need_mutex=1); int find_next_log(LOG_INFO* linfo, bool need_mutex=1);
int get_current_log(LOG_INFO* linfo); int get_current_log(LOG_INFO* linfo);
@ -154,7 +152,7 @@ public:
inline void lock_index() { pthread_mutex_lock(&LOCK_index);} inline void lock_index() { pthread_mutex_lock(&LOCK_index);}
inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);} inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);}
inline File get_index_file() { return index_file;} inline IO_CACHE *get_index_file() { return &index_file;}
inline uint32 get_open_count() { return open_count; } inline uint32 get_open_count() { return open_count; }
}; };

View File

@ -85,7 +85,7 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent)
mysql_update_log.write(thd,thd->query, thd->query_length); mysql_update_log.write(thd,thd->query, thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query); Query_log_event qinfo(thd, thd->query, thd->query_length);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
} }
@ -153,7 +153,9 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
send_ok(&thd->net,0); send_ok(&thd->net,0);
goto exit; goto exit;
} }
pthread_mutex_lock(&LOCK_open);
remove_db_from_cache(db); remove_db_from_cache(db);
pthread_mutex_unlock(&LOCK_open);
error = -1; error = -1;
if ((deleted=mysql_rm_known_files(thd, dirp, db, path,0)) >= 0 && thd) if ((deleted=mysql_rm_known_files(thd, dirp, db, path,0)) >= 0 && thd)
@ -171,7 +173,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
mysql_update_log.write(thd, thd->query, thd->query_length); mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query); Query_log_event qinfo(thd, thd->query, thd->query_length);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
if (thd->query == path) if (thd->query == path)

View File

@ -167,7 +167,8 @@ cleanup:
mysql_update_log.write(thd,thd->query, thd->query_length); mysql_update_log.write(thd,thd->query, thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query, using_transactions); Query_log_event qinfo(thd, thd->query, thd->query_length,
using_transactions);
if (mysql_bin_log.write(&qinfo) && using_transactions) if (mysql_bin_log.write(&qinfo) && using_transactions)
error=1; error=1;
} }
@ -468,7 +469,7 @@ bool multi_delete::send_eof()
mysql_update_log.write(thd,thd->query,thd->query_length); mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query); Query_log_event qinfo(thd, thd->query, thd->query_length);
if (mysql_bin_log.write(&qinfo) && if (mysql_bin_log.write(&qinfo) &&
!not_trans_safe) !not_trans_safe)
error=1; // Log write failed: roll back the SQL statement error=1; // Log write failed: roll back the SQL statement
@ -570,7 +571,7 @@ end:
mysql_update_log.write(thd,thd->query,thd->query_length); mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query); Query_log_event qinfo(thd, thd->query, thd->query_length);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
send_ok(&thd->net); // This should return record count send_ok(&thd->net); // This should return record count

View File

@ -301,7 +301,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
mysql_update_log.write(thd, thd->query, thd->query_length); mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query, using_transactions); Query_log_event qinfo(thd, thd->query, thd->query_length,
using_transactions);
if (mysql_bin_log.write(&qinfo) && using_transactions) if (mysql_bin_log.write(&qinfo) && using_transactions)
error=1; error=1;
} }
@ -1196,8 +1197,7 @@ bool delayed_insert::handle_inserts(void)
mysql_update_log.write(&thd,row->query, row->query_length); mysql_update_log.write(&thd,row->query, row->query_length);
if (using_bin_log) if (using_bin_log)
{ {
thd.query_length = row->query_length; Query_log_event qinfo(&thd, row->query, row->query_length);
Query_log_event qinfo(&thd, row->query);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
} }
@ -1377,7 +1377,7 @@ bool select_insert::send_eof()
mysql_update_log.write(thd,thd->query,thd->query_length); mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query, Query_log_event qinfo(thd, thd->query, thd->query_length,
table->file->has_transactions()); table->file->has_transactions());
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }

View File

@ -24,7 +24,7 @@
#include <assert.h> #include <assert.h>
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
#include "ha_innobase.h" #include "ha_innodb.h"
#endif #endif
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
@ -1428,13 +1428,16 @@ mysql_execute_command(void)
case SQLCOM_LOAD_MASTER_DATA: // sync with master case SQLCOM_LOAD_MASTER_DATA: // sync with master
if (check_global_access(thd, SUPER_ACL)) if (check_global_access(thd, SUPER_ACL))
goto error; goto error;
if (end_active_trans(thd))
res= -1;
else
res = load_master_data(thd); res = load_master_data(thd);
break; break;
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
case SQLCOM_SHOW_INNODB_STATUS: case SQLCOM_SHOW_INNODB_STATUS:
{ {
if (check_process_priv(thd)) if (check_global_access(thd, SUPER_ACL))
goto error; goto error;
res = innodb_show_status(thd); res = innodb_show_status(thd);
break; break;
@ -2319,7 +2322,7 @@ mysql_execute_command(void)
mysql_update_log.write(thd, thd->query, thd->query_length); mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query); Query_log_event qinfo(thd, thd->query, thd->query_length);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
} }
@ -2339,7 +2342,7 @@ mysql_execute_command(void)
mysql_update_log.write(thd, thd->query, thd->query_length); mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query); Query_log_event qinfo(thd, thd->query, thd->query_length);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
if (mqh_used && lex->sql_command == SQLCOM_GRANT) if (mqh_used && lex->sql_command == SQLCOM_GRANT)
@ -3325,8 +3328,6 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
bool result=0; bool result=0;
select_errors=0; /* Write if more errors */ select_errors=0; /* Write if more errors */
// TODO: figure out what's up with the commented out line below
// mysql_log.flush(); // Flush log
if (options & REFRESH_GRANT) if (options & REFRESH_GRANT)
{ {
acl_reload(); acl_reload();
@ -3382,7 +3383,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
if (options & REFRESH_SLAVE) if (options & REFRESH_SLAVE)
{ {
LOCK_ACTIVE_MI; LOCK_ACTIVE_MI;
if (reset_slave(active_mi)) if (reset_slave(thd, active_mi))
result=1; result=1;
UNLOCK_ACTIVE_MI; UNLOCK_ACTIVE_MI;
} }

View File

@ -94,7 +94,7 @@ end:
mysql_update_log.write(thd,thd->query,thd->query_length); mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query); Query_log_event qinfo(thd, thd->query, thd->query_length);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
send_ok(&thd->net); send_ok(&thd->net);

View File

@ -180,6 +180,27 @@ err:
} }
/*
Adjust the position pointer in the binary log file for all running slaves
SYNOPSIS
adjust_linfo_offsets()
purge_offset Number of bytes removed from start of log index file
NOTES
- This is called when doing a PURGE when we delete lines from the
index log file
REQUIREMENTS
- Before calling this function, we have to ensure that no threads are
using any binary log file before purge_offset.a
TODO
- Inform the slave threads that they should sync the position
in the binary log file with flush_relay_log_info.
Now they sync is done for next read.
*/
void adjust_linfo_offsets(my_off_t purge_offset) void adjust_linfo_offsets(my_off_t purge_offset)
{ {
THD *tmp; THD *tmp;
@ -193,8 +214,9 @@ void adjust_linfo_offsets(my_off_t purge_offset)
if ((linfo = tmp->current_linfo)) if ((linfo = tmp->current_linfo))
{ {
pthread_mutex_lock(&linfo->lock); pthread_mutex_lock(&linfo->lock);
/* index file offset can be less that purge offset /*
only if we just started reading the index file. In that case Index file offset can be less that purge offset only if
we just started reading the index file. In that case
we have nothing to adjust we have nothing to adjust
*/ */
if (linfo->index_file_offset < purge_offset) if (linfo->index_file_offset < purge_offset)
@ -274,7 +296,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
{ {
LOG_INFO linfo; LOG_INFO linfo;
char *log_file_name = linfo.log_file_name; char *log_file_name = linfo.log_file_name;
char search_file_name[FN_REFLEN]; char search_file_name[FN_REFLEN], *name;
IO_CACHE log; IO_CACHE log;
File file = -1; File file = -1;
String* packet = &thd->packet; String* packet = &thd->packet;
@ -295,7 +317,6 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
} }
#endif #endif
if (!mysql_bin_log.is_open()) if (!mysql_bin_log.is_open())
{ {
errmsg = "Binary log is not open"; errmsg = "Binary log is not open";
@ -307,17 +328,18 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
goto err; goto err;
} }
name=search_file_name;
if (log_ident[0]) if (log_ident[0])
mysql_bin_log.make_log_name(search_file_name, log_ident); mysql_bin_log.make_log_name(search_file_name, log_ident);
else else
search_file_name[0] = 0; name=0; // Find first log
linfo.index_file_offset = 0; linfo.index_file_offset = 0;
thd->current_linfo = &linfo; thd->current_linfo = &linfo;
if (mysql_bin_log.find_first_log(&linfo, search_file_name)) if (mysql_bin_log.find_log_pos(&linfo, name))
{ {
errmsg = "Could not find first log"; errmsg = "Could not find first log file name in binary log index file";
goto err; goto err;
} }
@ -332,19 +354,19 @@ impossible position";
} }
my_b_seek(&log, pos); // Seek will done on next read my_b_seek(&log, pos); // Seek will done on next read
packet->length(0); /*
// we need to start a packet with something other than 255 We need to start a packet with something other than 255
// to distiquish it from error to distiquish it from error
packet->append("\0", 1); */
packet->set("\0", 1);
// if we are at the start of the log // if we are at the start of the log
if (pos == 4) if (pos == BIN_LOG_HEADER_SIZE)
{ {
// tell the client log name with a fake rotate_event // tell the client log name with a fake rotate_event
if (fake_rotate_event(net, packet, log_file_name, &errmsg)) if (fake_rotate_event(net, packet, log_file_name, &errmsg))
goto err; goto err;
packet->length(0); packet->set("\0", 1);
packet->append("\0", 1);
} }
while (!net->error && net->vio != 0 && !thd->killed) while (!net->error && net->vio != 0 && !thd->killed)
@ -376,20 +398,21 @@ impossible position";
goto err; goto err;
} }
} }
packet->length(0); packet->set("\0", 1);
packet->append("\0",1);
} }
// TODO: now that we are logging the offset, check to make sure /*
// the recorded offset and the actual match TODO: now that we are logging the offset, check to make sure
the recorded offset and the actual match
*/
if (error != LOG_READ_EOF) if (error != LOG_READ_EOF)
{ {
switch(error) { switch (error) {
case LOG_READ_BOGUS: case LOG_READ_BOGUS:
errmsg = "bogus data in log event"; errmsg = "bogus data in log event";
break; break;
case LOG_READ_TOO_LARGE: case LOG_READ_TOO_LARGE:
errmsg = "log event entry exceeded max_allowed_packet -\ errmsg = "log event entry exceeded max_allowed_packet; \
increase max_allowed_packet on master"; Increase max_allowed_packet on master";
break; break;
case LOG_READ_IO: case LOG_READ_IO:
errmsg = "I/O error reading log event"; errmsg = "I/O error reading log event";
@ -410,18 +433,21 @@ impossible position";
if (!(flags & BINLOG_DUMP_NON_BLOCK) && if (!(flags & BINLOG_DUMP_NON_BLOCK) &&
mysql_bin_log.is_active(log_file_name)) mysql_bin_log.is_active(log_file_name))
{ {
// block until there is more data in the log /*
// unless non-blocking mode requested Block until there is more data in the log
*/
if (net_flush(net)) if (net_flush(net))
{ {
errmsg = "failed on net_flush()"; errmsg = "failed on net_flush()";
goto err; goto err;
} }
// we may have missed the update broadcast from the log /*
// that has just happened, let's try to catch it if it did We may have missed the update broadcast from the log
// if we did not miss anything, we just wait for other threads that has just happened, let's try to catch it if it did.
// to signal us If we did not miss anything, we just wait for other threads
to signal us.
*/
{ {
log.error=0; log.error=0;
bool read_packet = 0, fatal_error = 0; bool read_packet = 0, fatal_error = 0;
@ -435,32 +461,32 @@ impossible position";
} }
#endif #endif
// no one will update the log while we are reading /*
// now, but we'll be quick and just read one record No one will update the log while we are reading
now, but we'll be quick and just read one record
To be able to handle EOF properly, we have to have the
pthread_mutex_unlock() statements in the case statements.
*/
pthread_mutex_lock(log_lock); pthread_mutex_lock(log_lock);
switch (Log_event::read_log_event(&log, packet, (pthread_mutex_t*)0)) switch (Log_event::read_log_event(&log, packet, (pthread_mutex_t*)0)) {
{
case 0: case 0:
pthread_mutex_unlock(log_lock); /* we read successfully, so we'll need to send it to the slave */
read_packet = 1; read_packet = 1;
// we read successfully, so we'll need to send it to the
// slave
break; break;
case LOG_READ_EOF: case LOG_READ_EOF:
DBUG_PRINT("wait",("waiting for data in binary log")); DBUG_PRINT("wait",("waiting for data in binary log"));
// wait_for_update unlocks the log lock - needed to avoid race
if (!thd->killed) if (!thd->killed)
mysql_bin_log.wait_for_update(thd); mysql_bin_log.wait_for_update(thd);
else
pthread_mutex_unlock(log_lock);
DBUG_PRINT("wait",("binary log received update")); DBUG_PRINT("wait",("binary log received update"));
break; break;
default: default:
pthread_mutex_unlock(log_lock);
fatal_error = 1; fatal_error = 1;
break; break;
} }
pthread_mutex_unlock(log_lock);
if (read_packet) if (read_packet)
{ {
@ -479,10 +505,11 @@ impossible position";
goto err; goto err;
} }
} }
packet->length(0); packet->set("\0", 1);
packet->append("\0",1); /*
// no need to net_flush because we will get to flush later when No need to net_flush because we will get to flush later when
// we hit EOF pretty quick we hit EOF pretty quick
*/
} }
if (fatal_error) if (fatal_error)
@ -539,7 +566,6 @@ impossible position";
err: err:
thd->proc_info = "waiting to finalize termination"; thd->proc_info = "waiting to finalize termination";
end_io_cache(&log); end_io_cache(&log);
pthread_mutex_lock(&LOCK_thread_count);
/* /*
Exclude iteration through thread list Exclude iteration through thread list
this is needed for purge_logs() - it will iterate through this is needed for purge_logs() - it will iterate through
@ -547,6 +573,7 @@ impossible position";
this mutex will make sure that it never tried to update our linfo this mutex will make sure that it never tried to update our linfo
after we return from this stack frame after we return from this stack frame
*/ */
pthread_mutex_lock(&LOCK_thread_count);
thd->current_linfo = 0; thd->current_linfo = 0;
pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_thread_count);
if (file >= 0) if (file >= 0)
@ -561,16 +588,19 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
if (!thd) thd = current_thd; if (!thd) thd = current_thd;
NET* net = &thd->net; NET* net = &thd->net;
int thread_mask; int thread_mask;
DBUG_ENTER("start_slave");
if (check_access(thd, SUPER_ACL, any_db)) if (check_access(thd, SUPER_ACL, any_db))
return 1; DBUG_RETURN(1);
lock_slave_threads(mi); // this allows us to cleanly read slave_running lock_slave_threads(mi); // this allows us to cleanly read slave_running
init_thread_mask(&thread_mask,mi,1 /* inverse */); init_thread_mask(&thread_mask,mi,1 /* inverse */);
if (thd->lex.slave_thd_opt) if (thd->lex.slave_thd_opt)
thread_mask &= thd->lex.slave_thd_opt; thread_mask &= thd->lex.slave_thd_opt;
if (thread_mask) if (thread_mask)
{ {
if (server_id_supplied && (!mi->inited || (mi->inited && *mi->host))) if (init_master_info(mi,master_info_file,relay_log_info_file, 0))
slave_errno=ER_MASTER_INFO;
else if (server_id_supplied && *mi->host)
slave_errno = start_slave_threads(0 /*no mutex */, slave_errno = start_slave_threads(0 /*no mutex */,
1 /* wait for start */, 1 /* wait for start */,
mi, mi,
@ -588,12 +618,12 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
{ {
if (net_report) if (net_report)
send_error(net, slave_errno); send_error(net, slave_errno);
return 1; DBUG_RETURN(1);
} }
else if (net_report) else if (net_report)
send_ok(net); send_ok(net);
return 0; DBUG_RETURN(0);
} }
int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report ) int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report )
@ -628,7 +658,7 @@ int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report )
return 0; return 0;
} }
int reset_slave(MASTER_INFO* mi) int reset_slave(THD *thd, MASTER_INFO* mi)
{ {
MY_STAT stat_area; MY_STAT stat_area;
char fname[FN_REFLEN]; char fname[FN_REFLEN];
@ -639,7 +669,9 @@ int reset_slave(MASTER_INFO* mi)
lock_slave_threads(mi); lock_slave_threads(mi);
init_thread_mask(&restart_thread_mask,mi,0 /* not inverse */); init_thread_mask(&restart_thread_mask,mi,0 /* not inverse */);
if ((error=terminate_slave_threads(mi,restart_thread_mask,1 /*skip lock*/)) if ((error=terminate_slave_threads(mi,restart_thread_mask,1 /*skip lock*/))
|| (error=purge_relay_logs(&mi->rli,1 /*just reset*/,&errmsg))) || (error=purge_relay_logs(&mi->rli, thd,
1 /* just reset */,
&errmsg)))
goto err; goto err;
end_master_info(mi); end_master_info(mi);
@ -713,14 +745,15 @@ int change_master(THD* thd, MASTER_INFO* mi)
thd->proc_info = "changing master"; thd->proc_info = "changing master";
LEX_MASTER_INFO* lex_mi = &thd->lex.mi; LEX_MASTER_INFO* lex_mi = &thd->lex.mi;
// TODO: see if needs re-write // TODO: see if needs re-write
if (init_master_info(mi,master_info_file,relay_log_info_file)) if (init_master_info(mi, master_info_file, relay_log_info_file, 0))
{ {
send_error(&thd->net, 0, "Could not initialize master info"); send_error(&thd->net, 0, "Could not initialize master info");
unlock_slave_threads(mi); unlock_slave_threads(mi);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
/* data lock not needed since we have already stopped the running threads, /*
Data lock not needed since we have already stopped the running threads,
and we have the hold on the run locks which will keep all threads that and we have the hold on the run locks which will keep all threads that
could possibly modify the data structures from running could possibly modify the data structures from running
*/ */
@ -772,7 +805,8 @@ int change_master(THD* thd, MASTER_INFO* mi)
{ {
mi->rli.skip_log_purge=0; mi->rli.skip_log_purge=0;
thd->proc_info="purging old relay logs"; thd->proc_info="purging old relay logs";
if (purge_relay_logs(&mi->rli,0 /* not only reset, but also reinit*/, if (purge_relay_logs(&mi->rli, thd,
0 /* not only reset, but also reinit */,
&errmsg)) &errmsg))
{ {
net_printf(&thd->net, 0, "Failed purging old relay logs: %s",errmsg); net_printf(&thd->net, 0, "Failed purging old relay logs: %s",errmsg);
@ -782,12 +816,13 @@ int change_master(THD* thd, MASTER_INFO* mi)
else else
{ {
const char* msg; const char* msg;
if (init_relay_log_pos(&mi->rli,0/*log already inited*/, /* Relay log is already initialized */
0 /*pos already inited*/, if (init_relay_log_pos(&mi->rli,
mi->rli.relay_log_name,
mi->rli.relay_log_pos,
0 /*no data lock*/, 0 /*no data lock*/,
&msg)) &msg))
{ {
//Sasha: note that I had to change net_printf() to make this work
net_printf(&thd->net,0,"Failed initializing relay log position: %s",msg); net_printf(&thd->net,0,"Failed initializing relay log position: %s",msg);
unlock_slave_threads(mi); unlock_slave_threads(mi);
DBUG_RETURN(1); DBUG_RETURN(1);
@ -857,26 +892,27 @@ int show_binlog_events(THD* thd)
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
LOG_INFO linfo; LEX_MASTER_INFO *lex_mi = &thd->lex.mi;
char search_file_name[FN_REFLEN];
LEX_MASTER_INFO* lex_mi = &thd->lex.mi;
uint event_count, limit_start, limit_end; uint event_count, limit_start, limit_end;
const char* log_file_name = lex_mi->log_file_name;
Log_event* ev;
my_off_t pos = lex_mi->pos; my_off_t pos = lex_mi->pos;
char search_file_name[FN_REFLEN], *name;
const char *log_file_name = lex_mi->log_file_name;
LOG_INFO linfo;
Log_event* ev;
limit_start = thd->lex.select->offset_limit; limit_start = thd->lex.select->offset_limit;
limit_end = thd->lex.select->select_limit + limit_start; limit_end = thd->lex.select->select_limit + limit_start;
name= search_file_name;
if (log_file_name) if (log_file_name)
mysql_bin_log.make_log_name(search_file_name, log_file_name); mysql_bin_log.make_log_name(search_file_name, log_file_name);
else else
search_file_name[0] = 0; name=0; // Find first log
linfo.index_file_offset = 0; linfo.index_file_offset = 0;
thd->current_linfo = &linfo; thd->current_linfo = &linfo;
if (mysql_bin_log.find_first_log(&linfo, search_file_name)) if (mysql_bin_log.find_log_pos(&linfo, name))
{ {
errmsg = "Could not find target log"; errmsg = "Could not find target log";
goto err; goto err;
@ -981,71 +1017,65 @@ int show_binlog_info(THD* thd)
} }
/*
Send a lost of all binary logs to client
SYNOPSIS
show_binlogs()
thd Thread specific variable
RETURN VALUES
0 ok
1 error (Error message sent to client)
*/
int show_binlogs(THD* thd) int show_binlogs(THD* thd)
{ {
const char* errmsg = 0; const char *errmsg;
File index_file; IO_CACHE *index_file;
char fname[FN_REFLEN]; char fname[FN_REFLEN];
NET* net = &thd->net; NET* net = &thd->net;
List<Item> field_list; List<Item> field_list;
String* packet = &thd->packet; String *packet = &thd->packet;
IO_CACHE io_cache;
uint length; uint length;
if (!mysql_bin_log.is_open()) if (!mysql_bin_log.is_open())
{ {
errmsg = "binlog is not open"; //TODO: Replace with ER() error message
goto err; errmsg= "You are not using binary logging";
goto err_with_msg;
} }
field_list.push_back(new Item_empty_string("Log_name", 128)); field_list.push_back(new Item_empty_string("Log_name", 255));
if (send_fields(thd, field_list, 1)) if (send_fields(thd, field_list, 1))
{
sql_print_error("Failed in send_fields");
return 1; return 1;
}
mysql_bin_log.lock_index(); mysql_bin_log.lock_index();
index_file = mysql_bin_log.get_index_file(); index_file=mysql_bin_log.get_index_file();
if (index_file < 0)
reinit_io_cache(index_file, READ_CACHE, (my_off_t) 0, 0, 0);
/* The file ends with EOF or empty line */
while ((length=my_b_gets(index_file, fname, sizeof(fname))) > 1)
{ {
errmsg = "Uninitialized index file pointer";
goto err2;
}
if (init_io_cache(&io_cache, index_file, IO_SIZE, READ_CACHE, 0, 0,
MYF(MY_WME)))
{
errmsg = "Failed on init_io_cache()";
goto err2;
}
while ((length=my_b_gets(&io_cache, fname, sizeof(fname))))
{
fname[--length]=0;
int dir_len = dirname_length(fname); int dir_len = dirname_length(fname);
packet->length(0); packet->length(0);
net_store_data(packet, fname + dir_len, length-dir_len); /* The -1 is for removing newline from fname */
net_store_data(packet, fname + dir_len, length-1-dir_len);
if (my_net_write(net, (char*) packet->ptr(), packet->length())) if (my_net_write(net, (char*) packet->ptr(), packet->length()))
{ goto err;
sql_print_error("Failed in my_net_write");
end_io_cache(&io_cache);
mysql_bin_log.unlock_index();
return 1;
} }
}
mysql_bin_log.unlock_index(); mysql_bin_log.unlock_index();
end_io_cache(&io_cache);
send_eof(net); send_eof(net);
return 0; return 0;
err2: err_with_msg:
mysql_bin_log.unlock_index();
end_io_cache(&io_cache);
err:
send_error(net, 0, errmsg); send_error(net, 0, errmsg);
err:
mysql_bin_log.unlock_index();
return 1; return 1;
} }
int log_loaded_block(IO_CACHE* file) int log_loaded_block(IO_CACHE* file)
{ {
LOAD_FILE_INFO* lf_info; LOAD_FILE_INFO* lf_info;

Some files were not shown because too many files have changed in this diff Show More