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
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.
@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}
The maximum size of the temporary file MySQL is allowed to use
while recreating the index (during @code{REPAIR}, @code{ALTER TABLE}
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).
@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}
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
exactly what @code{mysqld} thought the client sent to it.
By default, the @code{mysql.server} script starts the MySQL
server with the @code{-l} option. If you need better performance when
you start using MySQL in a production environment, you can
remove the @code{-l} option from @code{mysql.server} or change it to
@code{--log-bin}.
By default, the @code{mysql.server} script starts the MySQL server with
the @code{-l} option (General query log). If you need better
performance when you start using MySQL in a production environment, you
can remove the @code{-l} option from @code{mysql.server} or change it to
@code{--log-bin}. @xref{Binary log}.
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.
@ -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
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.
@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.
@item
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
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
@ -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
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}.
@end itemize
@ -24203,6 +24207,10 @@ Example:
Tells the slave server not to start the slave on the startup. The user
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
Number of seconds to wait for more data from the master before aborting
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 flush @tab bool @tab GLOBAL
@item flush_time @tab num @tab GLOBAL
@item foreign_key_checks @tab bool @tab SESSION
@item identity @tab num @tab SESSION
@item insert_id @tab bool @tab 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 safe_show_database @tab bool @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 slow_launch_time @tab num @tab GLOBAL
@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 version @tab string @tab GLOBAL
@item wait_timeout @tab num @tab GLOBAL | SESSION
@item unique_checks @tab bool @tab SESSION
@end multitable
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{-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{-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_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_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 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}!
@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
@itemize @bullet
@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.
@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.
@item
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
server variables at runtime.
@item
Added variable @code{slave_compressed_protocol}.
@item
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{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 <mysql_embed.h>
@ -85,7 +85,7 @@
time
*/
#define CON_RETRY_SLEEP 2
#define MAX_CON_TRIES 5
#define MAX_CON_TRIES 5
#ifndef OS2
#define SLAVE_POLL_INTERVAL 300000 /* 0.3 of a sec */
@ -101,7 +101,7 @@ static char *db = 0, *pass=0;
const char* user = 0, *host = 0, *unix_sock = 0, *opt_basedir="./";
static int port = 0;
static my_bool opt_big_test= 0, opt_compress= 0, silent= 0, verbose = 0,
tty_password= 0;
tty_password= 0;
static uint start_lineno, *lineno;
const char* manager_user="root",*manager_host=0;
char *manager_pass=0;
@ -128,7 +128,7 @@ static uint global_expected_errno[MAX_EXPECTED_ERRORS], global_expected_errors;
DYNAMIC_ARRAY q_lines;
typedef struct
typedef struct
{
char file[FN_REFLEN];
ulong pos;
@ -177,27 +177,27 @@ struct connection* cur_con, *next_con, *cons_end;
/* Add new commands before Q_UNKNOWN !*/
enum enum_commands {
Q_CONNECTION=1, Q_QUERY,
Q_CONNECT, Q_SLEEP,
Q_INC, Q_DEC,
Q_SOURCE, Q_DISCONNECT,
Q_LET, Q_ECHO,
Q_WHILE, Q_END_BLOCK,
Q_SYSTEM, Q_RESULT,
Q_REQUIRE, Q_SAVE_MASTER_POS,
Q_SYNC_WITH_MASTER, Q_ERROR,
Q_SEND, Q_REAP,
Q_DIRTY_CLOSE, Q_REPLACE,
Q_PING, Q_EVAL,
Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
Q_CONNECTION=1, Q_QUERY,
Q_CONNECT, Q_SLEEP,
Q_INC, Q_DEC,
Q_SOURCE, Q_DISCONNECT,
Q_LET, Q_ECHO,
Q_WHILE, Q_END_BLOCK,
Q_SYSTEM, Q_RESULT,
Q_REQUIRE, Q_SAVE_MASTER_POS,
Q_SYNC_WITH_MASTER, Q_ERROR,
Q_SEND, Q_REAP,
Q_DIRTY_CLOSE, Q_REPLACE,
Q_PING, Q_EVAL,
Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG,
Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER,
Q_WAIT_FOR_SLAVE_TO_STOP,
Q_REQUIRE_VERSION,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
Q_COMMENT_WITH_COMMAND
};
@ -215,18 +215,18 @@ struct st_query
const char *command_names[] = {
"connection", "query",
"connect", "sleep",
"inc", "dec",
"source", "disconnect",
"let", "echo",
"while", "end",
"system", "result",
"require", "save_master_pos",
"connect", "sleep",
"inc", "dec",
"source", "disconnect",
"let", "echo",
"while", "end",
"system", "result",
"require", "save_master_pos",
"sync_with_master", "error",
"send", "reap",
"send", "reap",
"dirty_close", "replace_result",
"ping", "eval",
"rpl_probe", "enable_rpl_parse",
"ping", "eval",
"rpl_probe", "enable_rpl_parse",
"disable_rpl_parse", "eval_result",
"enable_query_log", "disable_query_log",
"enable_result_log", "disable_result_log",
@ -264,7 +264,7 @@ typedef struct st_pointer_array { /* when using array-strings */
TYPELIB typelib; /* Pointer to strings */
byte *str; /* Strings is here */
int7 *flag; /* Flag about each var. */
uint array_allocs,max_count,length,max_length;
uint array_allocs,max_count,length,max_length;
} POINTER_ARRAY;
struct st_replace;
@ -314,39 +314,39 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
register int escaped = 0;
VAR* v;
for(p = query; (c = *p); ++p)
{
switch(c)
{
case '$':
if(escaped)
{
escaped = 0;
dynstr_append_mem(query_eval, p, 1);
}
else
{
if(!(v = var_get(p, &p, 0, 0)))
die("Bad variable in eval");
dynstr_append_mem(query_eval, v->str_val, v->str_val_len);
}
break;
case '\\':
if(escaped)
{
escaped = 0;
dynstr_append_mem(query_eval, p, 1);
}
else
escaped = 1;
break;
default:
dynstr_append_mem(query_eval, p, 1);
break;
}
for (p= query; (c = *p); ++p)
{
switch(c) {
case '$':
if (escaped)
{
escaped = 0;
dynstr_append_mem(query_eval, p, 1);
}
else
{
if (!(v = var_get(p, &p, 0, 0)))
die("Bad variable in eval");
dynstr_append_mem(query_eval, v->str_val, v->str_val_len);
}
break;
case '\\':
if (escaped)
{
escaped = 0;
dynstr_append_mem(query_eval, p, 1);
}
else
escaped = 1;
break;
default:
dynstr_append_mem(query_eval, p, 1);
break;
}
}
}
static void close_cons()
{
DBUG_ENTER("close_cons");
@ -360,6 +360,7 @@ static void close_cons()
DBUG_VOID_RETURN;
}
static void close_files()
{
DBUG_ENTER("close_files");
@ -371,14 +372,15 @@ static void close_files()
DBUG_VOID_RETURN;
}
static void free_used_memory()
{
uint i;
DBUG_ENTER("free_used_memory");
#ifndef EMBEDDED_LIBRARY
#ifndef EMBEDDED_LIBRARY
if (manager)
mysql_manager_close(manager);
#endif
#endif
close_cons();
close_files();
hash_free(&var_hash);
@ -389,9 +391,9 @@ static void free_used_memory()
my_free((gptr) (*q)->query_buf,MYF(MY_ALLOW_ZERO_PTR));
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));
}
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);
res_ptr = res_ds.str;
if((res_len = res_ds.length) != ds->length)
if ((res_len = res_ds.length) != ds->length)
{
res = 2;
goto err;
@ -517,10 +519,10 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname)
res = (memcmp(res_ptr, ds->str, res_len)) ? 1 : 0;
err:
if(res && eval_result)
str_to_file(fn_format(eval_file, fname, "", ".eval",2), res_ptr,
res_len);
err:
if (res && eval_result)
str_to_file(fn_format(eval_file, fname, "", ".eval",2), res_ptr,
res_len);
my_free((gptr) tmp, MYF(0));
my_close(fd, MYF(MY_WME));
@ -537,8 +539,7 @@ static int check_result(DYNAMIC_STRING* ds, const char* fname,
if (res && require_option)
abort_not_supported_test();
switch (res)
{
switch (res) {
case 0:
break; /* ok */
case 2:
@ -592,7 +593,7 @@ VAR* var_get(const char* var_name, const char** var_name_end, my_bool raw,
}
--var_name; /* Point at last character */
}
else
else
v = var_reg + digit;
if (!raw && v->int_dirty)
@ -614,7 +615,7 @@ err:
static VAR* var_obtain(char* name, int len)
{
VAR* v;
if((v = (VAR*)hash_search(&var_hash, name, len)))
if ((v = (VAR*)hash_search(&var_hash, name, len)))
return v;
v = var_init(0, name, len, "", 0);
hash_insert(&var_hash, (byte*)v);
@ -637,7 +638,7 @@ int var_set(char* var_name, char* var_name_end, char* var_val,
{
v = var_obtain(var_name, var_name_end - var_name);
}
else
else
v = var_reg + digit;
return eval_expr(v, var_val, (const char**)&var_val_end);
@ -667,7 +668,7 @@ int open_file(const char* name)
int do_wait_for_slave_to_stop(struct st_query* q __attribute__((unused)))
{
MYSQL* mysql = &cur_con->mysql;
#ifndef OS2
#ifndef OS2
struct timeval t;
#endif
for (;;)
@ -676,7 +677,7 @@ int do_wait_for_slave_to_stop(struct st_query* q __attribute__((unused)))
MYSQL_ROW row;
int done;
LINT_INIT(res);
if (mysql_query(mysql,"show status like 'Slave_running'")
|| !(res=mysql_store_result(mysql)))
die("Query failed while probing slave for stop: %s",
@ -690,7 +691,7 @@ int do_wait_for_slave_to_stop(struct st_query* q __attribute__((unused)))
mysql_free_result(res);
if (done)
break;
#ifndef OS2
#ifndef OS2
t.tv_sec=0;
t.tv_usec=SLAVE_POLL_INTERVAL;
select(0,0,0,0,&t); /* sleep */
@ -698,7 +699,7 @@ int do_wait_for_slave_to_stop(struct st_query* q __attribute__((unused)))
DosSleep(OS2_SLAVE_POLL_INTERVAL);
#endif
}
return 0;
}
@ -761,7 +762,7 @@ int do_require_version(struct st_query* q)
char* p=q->first_argument, *ver_arg;
uint ver_arg_len,ver_len;
LINT_INIT(res);
if (!*p)
die("Missing version argument in require_version\n");
ver_arg = p;
@ -769,7 +770,7 @@ int do_require_version(struct st_query* q)
p++;
*p = 0;
ver_arg_len = p - ver_arg;
if (mysql_query(mysql, "select version()") ||
!(res=mysql_store_result(mysql)))
die("Query failed while check server version: %s",
@ -855,7 +856,7 @@ int eval_expr(VAR* v, const char* p, const char** p_end)
return 0;
}
}
else if(*p == '`')
else if (*p == '`')
{
return var_query_set(v, p, p_end);
}
@ -865,7 +866,7 @@ int eval_expr(VAR* v, const char* p, const char** p_end)
(int) (*p_end - p) : (int) strlen(p);
if (new_val_len + 1 >= v->alloced_len)
{
v->alloced_len = (new_val_len < MIN_VAR_ALLOC - 1) ?
v->alloced_len = (new_val_len < MIN_VAR_ALLOC - 1) ?
MIN_VAR_ALLOC : new_val_len + 1;
if (!(v->str_val =
v->str_val ? my_realloc(v->str_val, v->alloced_len+1,
@ -944,6 +945,7 @@ int do_echo(struct st_query* q)
return 0;
}
int do_sync_with_master(struct st_query* q)
{
MYSQL_RES* res;
@ -954,31 +956,36 @@ int do_sync_with_master(struct st_query* q)
char* p = q->first_argument;
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);
mysql_disable_rpl_parse(mysql);
if(*p)
if (*p)
offset = atoi(p);
sprintf(query_buf, "select master_pos_wait('%s', %ld)", master_pos.file,
master_pos.pos + offset);
if(mysql_query(mysql, query_buf))
die("At line %u: failed in %s: %d: %s", start_lineno, query_buf,
if (mysql_query(mysql, query_buf))
die("line %u: failed in %s: %d: %s", start_lineno, query_buf,
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);
if(!(row = mysql_fetch_row(res)))
if (!(row = mysql_fetch_row(res)))
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");
mysql_free_result(res); last_result=0;
if(rpl_parse)
if (rpl_parse)
mysql_enable_rpl_parse(mysql);
return 0;
}
int do_save_master_pos()
{
MYSQL_RES* res;
@ -989,19 +996,19 @@ int do_save_master_pos()
rpl_parse = mysql_rpl_parse_enabled(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,
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);
if(!(row = mysql_fetch_row(res)))
if (!(row = mysql_fetch_row(res)))
die("line %u: empty result in show master status", start_lineno);
strncpy(master_pos.file, row[0], sizeof(master_pos.file));
master_pos.pos = strtoul(row[1], (char**) 0, 10);
strnmov(master_pos.file, row[0], sizeof(master_pos.file)-1);
master_pos.pos = strtoul(row[1], (char**) 0, 10);
mysql_free_result(res); last_result=0;
if(rpl_parse)
if (rpl_parse)
mysql_enable_rpl_parse(mysql);
return 0;
@ -1027,7 +1034,7 @@ int do_let(struct st_query* q)
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));
return 0;
}
@ -1079,7 +1086,7 @@ int do_sleep(struct st_query* q)
p++;
p_end = p + 6;
for(;p <= p_end; ++p)
for (;p <= p_end; ++p)
{
c = (int) (*p - '0');
if (c < 10 && (int) c >= 0)
@ -1882,7 +1889,7 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch(optid) {
switch(optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:S:i:O,/tmp/mysqltest.trace");
break;
@ -1975,7 +1982,7 @@ int parse_args(int argc, char **argv)
char* safe_str_append(char* buf, const char* str, int size)
{
int i,c ;
for(i = 0; (c = *str++) && i < size - 1; i++)
for (i = 0; (c = *str++) && i < size - 1; i++)
*buf++ = c;
*buf = 0;
return buf;
@ -2024,7 +2031,7 @@ static void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val,
/*
* flags control the phased/stages of query execution to be performed
* flags control the phased/stages of query execution to be performed
* if QUERY_SEND bit is on, the query will be sent. If QUERY_REAP is on
* the result will be read - for regular query, both bits must be on
*/
@ -2123,7 +2130,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
dynstr_append_mem(ds,"\n",1);
verbose_msg("query '%s' failed: %d: %s", q->query, mysql_errno(mysql),
mysql_error(mysql));
/*
/*
if we do not abort on error, failure to run the query does
not fail the whole test case
*/
@ -2164,7 +2171,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
while ((row = mysql_fetch_row(res)))
{
lengths = mysql_fetch_lengths(res);
for(i = 0; i < num_fields; i++)
for (i = 0; i < num_fields; i++)
{
val = (char*)row[i];
len = lengths[i];
@ -2202,7 +2209,7 @@ end:
last_result=0;
if (ds == &ds_tmp)
dynstr_free(&ds_tmp);
if(q->type == Q_EVAL)
if (q->type == Q_EVAL)
dynstr_free(&eval_query);
DBUG_RETURN(error);
}
@ -2247,12 +2254,12 @@ static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
if (!val_len && val)
val_len = strlen(val) ;
val_alloc_len = val_len + 16; /* room to grow */
if (!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var)
if (!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var)
+ name_len, MYF(MY_WME))))
die("Out of memory");
tmp_var->name = (name) ? (char*) tmp_var + sizeof(*tmp_var) : 0;
tmp_var->alloced = (v == 0);
tmp_var->alloced = (v == 0);
if (!(tmp_var->str_val = my_malloc(val_alloc_len+1, MYF(MY_WME))))
die("Out of memory");
@ -2286,7 +2293,7 @@ static void var_from_env(const char* name, const char* def_val)
if (!(tmp = getenv(name)))
tmp = def_val;
v = var_init(0, name, 0, tmp, 0);
v = var_init(0, name, 0, tmp, 0);
hash_insert(&var_hash, (byte*)v);
}
@ -2377,12 +2384,12 @@ int main(int argc, char** argv)
case Q_CONNECT: do_connect(q); break;
case Q_CONNECTION: select_connection(q); break;
case Q_DISCONNECT:
case Q_DIRTY_CLOSE:
case Q_DIRTY_CLOSE:
close_connection(q); break;
case Q_RPL_PROBE: do_rpl_probe(q); break;
case Q_ENABLE_RPL_PARSE: do_enable_rpl_parse(q); break;
case Q_ENABLE_RPL_PARSE: do_enable_rpl_parse(q); break;
case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break;
case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
case Q_ENABLE_RESULT_LOG: disable_result_log=0; break;
case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
@ -2391,22 +2398,22 @@ int main(int argc, char** argv)
case Q_REQUIRE_VERSION: do_require_version(q); break;
case Q_WAIT_FOR_SLAVE_TO_STOP: do_wait_for_slave_to_stop(q); break;
case Q_REQUIRE_MANAGER: do_require_manager(q); break;
#ifndef EMBEDDED_LIBRARY
#ifndef EMBEDDED_LIBRARY
case Q_SERVER_START: do_server_start(q); break;
case Q_SERVER_STOP: do_server_stop(q); break;
#endif
#endif
case Q_INC: do_inc(q); break;
case Q_DEC: do_dec(q); break;
case Q_ECHO: do_echo(q); break;
case Q_SYSTEM: do_system(q); break;
case Q_LET: do_let(q); break;
case Q_EVAL_RESULT: eval_result = 1; break;
case Q_EVAL_RESULT: eval_result = 1; break;
case Q_EVAL:
if (q->query == q->query_buf)
if (q->query == q->query_buf)
q->query= q->first_argument;
/* fall through */
/* fall through */
case Q_QUERY:
case Q_REAP:
case Q_REAP:
{
/*
We read the result always regardless of the mode for both full
@ -2461,10 +2468,10 @@ int main(int argc, char** argv)
case Q_REPLACE:
get_replace(q);
break;
case Q_SAVE_MASTER_POS: do_save_master_pos(); break;
case Q_SYNC_WITH_MASTER: do_sync_with_master(q); break;
case Q_SAVE_MASTER_POS: do_save_master_pos(); break;
case Q_SYNC_WITH_MASTER: do_sync_with_master(q); break;
case Q_COMMENT: /* Ignore row */
case Q_COMMENT_WITH_COMMAND:
case Q_COMMENT_WITH_COMMAND:
case Q_PING:
(void) mysql_ping(&cur_con->mysql);
break;
@ -2475,8 +2482,7 @@ int main(int argc, char** argv)
if (!processed)
{
current_line_inc = 0;
switch(q->type)
{
switch(q->type) {
case Q_WHILE: do_while(q); break;
case Q_END_BLOCK: do_done(q); break;
default: current_line_inc = 1; break;
@ -2567,7 +2573,7 @@ static int read_server_arguments(const char* name)
#define LAST_CHAR_CODE 259
typedef struct st_replace {
bool found;
bool found;
struct st_replace *next[256];
} REPLACE;
@ -2673,12 +2679,12 @@ void free_pointer_array(POINTER_ARRAY *pa)
#define SET_MALLOC_HUNC 64
typedef struct st_rep_set {
uint *bits; /* Pointer to used sets */
short next[LAST_CHAR_CODE]; /* Pointer to next sets */
uint *bits; /* Pointer to used sets */
short next[LAST_CHAR_CODE]; /* Pointer to next sets */
uint found_len; /* Best match to date */
int found_offset;
uint table_offset;
uint size_of_bits; /* For convinience */
uint table_offset;
uint size_of_bits; /* For convinience */
} REP_SET;
typedef struct st_rep_sets {
@ -3209,7 +3215,7 @@ static uint replace_len(my_string str)
/* Replace strings; Return length of result string */
uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
const char *from)
{
reg1 REPLACE *rep_pos;
@ -3218,7 +3224,7 @@ uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
end=(to= *start) + *max_length-1;
rep_pos=rep+1;
for(;;)
for (;;)
{
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_mutex_trylock(A) pthread_mutex_lock(A)
#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 */
/* 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_fdopen(File Filedes,const char *name, int Flags,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_printf_error _VARARGS((uint my_err, const char *format,
myf MyFlags, ...)
@ -678,6 +678,7 @@ extern int end_io_cache(IO_CACHE *info);
extern uint my_b_fill(IO_CACHE *info);
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
extern my_off_t my_b_filelength(IO_CACHE *info);
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 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[];
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__
#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_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_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_tell(A,B) my_raid_tell(A,B)
#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,
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_fstat(int Filedes, struct stat *buf, myf MyFlags);
@ -113,7 +116,7 @@ class RaidFd {
int Write(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 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 Close(myf MyFlags);
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.
*/
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);
/*
* 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_read(vio, buf, size) (vio)->read(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_fastsend(vio) (vio)->fastsend(vio)
#define vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive)
@ -213,7 +214,7 @@ struct st_vio
int (*vioerrno)(Vio*);
int (*read)(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*);
int (*viokeepalive)(Vio*, my_bool);
int (*fastsend)(Vio*);

View File

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

View File

@ -185,7 +185,8 @@ dyn_array_open(
/*===========*/
/* out: pointer to the buffer */
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;
ulint used;
@ -207,6 +208,7 @@ dyn_array_open(
if (used + size > DYN_ARRAY_DATA_SIZE) {
block = dyn_array_add_block(arr);
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;
/* 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;
if (! (flags & HA_DONT_TOUCH_DATA))
{
#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;
#endif
errpos=1;

View File

@ -1552,7 +1552,7 @@ my_string name;
{
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);
goto err;
@ -2514,10 +2514,10 @@ my_string name;
skr=share->base.reloc*share->base.min_pack_length;
#endif
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);
}
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);
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->this_uniq=crc; /* Save crc here */
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)));
if (share->state.keys != share->base.keys)
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];
int msg_len;
Vio* vio;
my_bool not_used;
if (!host)
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");
goto err;
}
vio_blocking(vio,TRUE);
vio_blocking(vio, TRUE, &not_used);
my_net_init(&con->net,vio);
bzero((char*) &sock_addr,sizeof(sock_addr));
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 */
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)
{
open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
LOG_NEW);
NullS, LOG_NEW);
using_update_log=1;
}
if (opt_slow_log)
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
LOG_NORMAL);
NullS, LOG_NORMAL);
if (ha_init())
{
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");
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",
LOG_BIN);
opt_binlog_index_name, LOG_BIN);
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 (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->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));
}
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,
"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;
#endif
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,
"Can't change size of datafile, error: %d",
my_errno);
@ -2035,7 +2035,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
if (param->testflag & T_CALC_CHECKSUM)
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,
"Can't change size of indexfile, error: %d",
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;
#endif
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,
"Can't change size of datafile, error: %d",
my_errno);
@ -2418,7 +2418,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
if (param->testflag & T_CALC_CHECKSUM)
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,
"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
/* 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;
if (! (flags & HA_DONT_TOUCH_DATA))
{
#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;
#endif
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);
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;
allow_break(); /* Allow SIGHUP & SIGINT */
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->state.open_count=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)));
if (share->base.keys)
isamchk_neaded=1;

View File

@ -7,6 +7,7 @@ connection slave;
!slave stop;
@r/slave-stopped.result show status like 'Slave_running';
connection master;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
connection slave;
reset slave;
@ -14,3 +15,6 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
@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-test=*) SKIP_TEST=`$ECHO "$1" | $SED -e "s;--skip-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=*)
START_WAIT_TIMEOUT=`$ECHO "$1" | $SED -e "s;--wait-timeout=;;"`
STOP_WAIT_TIMEOUT=$START_WAIT_TIMEOUT;;
@ -456,10 +460,6 @@ XTERM=`which xterm`
#++
# 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 ()
{
@ -845,7 +845,7 @@ start_slave()
master_info="--master-user=root \
--master-connect-retry=1 \
--master-host=127.0.0.1 \
--master-password= \
--master-password="" \
--master-port=$MASTER_MYPORT \
--server-id=$slave_server_id --rpl-recovery-rank=$slave_rpl_rank"
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,"r1man");
drop table t1;
create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello");
insert into t1 values (default,default,default), (default,default,default), (4,0,"a"),(default,default,default);
select a,t>0,c from t1;
a t>0 c
1 1 hello
2 1 hello
4 0 a
5 1 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,default,default), (4,0,"a",5),(default,default,default,default);
select a,t>0,c,i from t1;
a t>0 c i
1 1 hello NULL
2 1 hello NULL
4 0 a 5
5 1 hello NULL
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=4,t=0,c="a";
insert into t1 set a=default,t=default,c=default;
select a,t>0,c from t1;
a t>0 c
1 1 hello
2 1 hello
4 0 a
5 1 hello
insert into t1 set a=default,t=default,c=default,i=default;
insert into t1 set a=4,t=0,c="a",i=5;
insert into t1 set a=5,t=0,c="a",i=null;
insert into t1 set a=default,t=default,c=default,i=default;
select a,t>0,c,i from t1;
a t>0 c i
1 1 hello NULL
2 1 hello NULL
4 0 a 5
5 0 a NULL
6 1 hello NULL
drop table t1;
drop database if exists foo;
create database foo;

View File

@ -1,10 +1,10 @@
slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
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;
drop table if exists t1,t2,t3;
create table t1 (word char(20) not null);
load data infile '../../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
abandonment
abandons
slave stop;
set password for root@"localhost" = password('foo');
slave start;
set password for root@"localhost" = password('');
create table t3(n int);
insert into t3 values(1),(2);
use test;
select * from t3;
n
1
@ -46,7 +47,6 @@ drop table t1,t3;
reset master;
slave stop;
reset slave;
drop table if exists t1,t2;
create table t1(n int);
select get_lock("hold_slave",10);
get_lock("hold_slave",10)
@ -58,8 +58,8 @@ release_lock("hold_slave")
unlock tables;
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;
create temporary table t3(n int);
insert into t3 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
@ -75,17 +75,15 @@ count(*)
drop table t1;
create table t1 (n int);
insert into t1 values(3456);
use mysql;
insert into user (Host, User, Password)
insert into mysql.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";
update mysql.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

View File

@ -1,14 +1,13 @@
slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
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;
create table t1 (n int auto_increment primary key);
set insert_id = 2000;
insert into t1 values (NULL),(NULL),(NULL);
use test;
select * from t1;
n
2000
@ -16,7 +15,7 @@ n
2002
show slave hosts;
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;
slave stop;
drop table if exists t2;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,9 @@
slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
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;
create table t1 (n int);
insert into t1 values(1);

View File

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

View File

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

View File

@ -1,4 +1,5 @@
slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
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
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
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;
slave stop;
change master to master_log_pos=73;

View File

@ -1,9 +1,9 @@
slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
use test;
drop database if exists d1;
create database d1;
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;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
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;
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

View File

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

View File

@ -1,4 +1,5 @@
slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
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
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
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
master_log_pos=4 and master_server_id=1;
Log_name Log_pos

View File

@ -1,4 +1,5 @@
slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
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;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;

View File

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

View File

@ -1,4 +1,5 @@
slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
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
#
create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello");
insert into t1 values (default,default,default), (default,default,default), (4,0,"a"),(default,default,default);
select a,t>0,c from t1;
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,default,default), (4,0,"a",5),(default,default,default,default);
select a,t>0,c,i from 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=4,t=0,c="a";
insert into t1 set a=default,t=default,c=default;
select a,t>0,c from t1;
insert into t1 set a=default,t=default,c=default,i=default;
insert into t1 set a=4,t=0,c="a",i=5;
insert into t1 set a=5,t=0,c="a",i=null;
insert into t1 set a=default,t=default,c=default,i=default;
select a,t>0,c,i from t1;
drop table t1;
#

View File

@ -1,21 +1,34 @@
eval_result;
source include/master-slave.inc;
connection master;
use test;
drop table if exists t1,t3;
drop table if exists t1,t2,t3;
create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table 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');
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('');
# Give slave time to connect (will retry every second)
sleep 2;
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;
@ -32,7 +45,6 @@ slave stop;
reset slave;
connection master;
drop table if exists t1,t2;
create table t1(n int);
#we want the log to exceed 16K to test deal with the log that is bigger than
#IO_SIZE
@ -45,12 +57,12 @@ while ($1)
}
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;
select get_lock("hold_slave",10);
slave start;
#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");
unlock tables;
@ -59,24 +71,24 @@ 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;
# Avoid generating result
create temporary table t3(n int);
insert into t3 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;
sleep 3;
select (@id := id) - id from t2;
kill @id;
# We don't drop t3 as this is a temporary table
drop table t2;
connection master;
--error 1053;
reap;
connection slave;
sync_with_master ;
sync_with_master;
#give the slave a chance to exit
wait_for_slave_to_stop;
@ -92,13 +104,11 @@ connection master1;
drop table t1;
create table t1 (n int);
insert into t1 values(3456);
use mysql;
insert into user (Host, User, Password)
insert into mysql.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";
update mysql.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;
@ -109,5 +119,3 @@ drop table t1;
save_master_pos;
connection slave;
sync_with_master;

View File

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

View File

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

View File

@ -1,6 +1,4 @@
source include/master-slave.inc;
connection master;
use test;
set SQL_LOG_BIN=0;
drop table if exists t1;
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;
create table t3 (word char(20) not null primary key);
connection slave;
use test;
drop table if exists t1;
load table t1 from master;
drop table if exists t2;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,4 @@
source include/master-slave.inc;
connection master;
use test;
drop database if exists d1;
create database d1;
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;
connection master;
use test;
drop table if exists t1;
show slave status;
--error 1218

View File

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

View File

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

View File

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

View File

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

View File

@ -2,8 +2,8 @@
# COM_BINLOG_DUMP and additionally limits the number of events per dump
source include/master-slave.inc;
connection master;
drop table if exists t1,t2;
create table t2(n int);
create table t1(n int not null auto_increment primary key);
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;
my_off_t end_of_file= ~(my_off_t) 0;
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->type=type;
@ -264,8 +265,9 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
pbool clear_cache)
{
DBUG_ENTER("reinit_io_cache");
DBUG_PRINT("enter",("type: %d seek_offset: %lu clear_cache: %d",
type, (ulong) seek_offset, (int) clear_cache));
DBUG_PRINT("enter",("cache: %lx type: %d seek_offset: %lu clear_cache: %d",
(ulong) info, type, (ulong) seek_offset,
(int) clear_cache));
/* One can't do reinit with the following types */
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->end_of_file=my_b_tell(info);
info->seek_not_done=1;
}
else if (type == WRITE_CACHE)
{
if (info->type == READ_CACHE)
{
info->write_end=info->write_buffer+info->buffer_length;
info->seek_not_done=1;
}
info->end_of_file = ~(my_off_t) 0;
}
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"
Used for logging in MySQL

View File

@ -25,17 +25,19 @@
my_chsize()
fd File descriptor
new_length New file size
filler If we don't have truncate, fill up all bytes after
new_length with this character
MyFlags Flags
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
0 Ok
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_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
/* 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)
{
if (my_write(fd,(byte*) buff,IO_SIZE,MYF(MY_NABP)))

View File

@ -75,7 +75,7 @@
#endif
#include "mysys_priv.h"
#include "my_dir.h"
#include <my_dir.h>
#include <m_string.h>
#include <assert.h>
@ -281,7 +281,7 @@ extern "C" {
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_PRINT("enter",("Fd: %d newlength: %u MyFlags: %d",
@ -289,10 +289,10 @@ extern "C" {
if (is_raid(fd))
{
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
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,
@ -738,7 +738,7 @@ Tell(myf MyFlags)
}
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_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 )
newpos = my_chsize(_fd_vector[i],
_this_block * _raid_chunksize + (_rounds + 1) *
_raid_chunksize,
MyFlags);
_raid_chunksize, filler, MyFlags);
else if ( i == _this_block )
newpos = my_chsize(_fd_vector[i],
_this_block * _raid_chunksize + _rounds *
_raid_chunksize + (newlength % _raid_chunksize),
MyFlags);
filler, MyFlags);
else // this means: i > _this_block
newpos = my_chsize(_fd_vector[i],
_this_block * _raid_chunksize + _rounds *
_raid_chunksize, MyFlags);
_raid_chunksize, filler, MyFlags);
if (newpos)
DBUG_RETURN(1);
}

View File

@ -73,6 +73,9 @@ public:
virtual void set_default()
{
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 zero_pack() const { return 1; }
@ -93,12 +96,12 @@ public:
virtual int key_cmp(const byte *str, uint length)
{ return cmp(ptr,(char*) str); }
virtual uint decimals() const { return 0; }
virtual void sql_type(String &str) const =0;
/*
Caller beware: sql_type can change str.Ptr, so check
ptr() to see if it changed if you are using your own buffer
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 */
inline bool is_null(uint row_offset=0)
{ 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 SHOW_COMP_OPTION have_berkeley_db;
extern u_int32_t berkeley_init_flags,berkeley_env_flags, berkeley_lock_type,
berkeley_lock_types[];
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;
/* We can't use value of sprintf() as this is not portable */
sprintf(buf, "MySQL thread id %lu, query id %lu",
thd->thread_id, thd->query_id);
buf=strend(buf);
buf+= my_sprintf(buf,
(buf, "MySQL thread id %lu, query id %lu",
thd->thread_id, thd->query_id));
if (thd->host)
{
*buf++=' ';
@ -309,7 +308,7 @@ innobase_mysql_print_thd(
if (thd->proc_info)
{
*buf++=' ';
buf=strnmov(buf, thd->procinfo, 50);
buf=strnmov(buf, thd->proc_info, 50);
}
if (thd->query)
@ -610,17 +609,20 @@ innobase_commit_low(
/*================*/
trx_t* trx) /* in: transaction handle */
{
if (current_thd->slave_thread) {
/* Update the replication position info inside InnoDB */
trx->mysql_master_log_file_name = glob_mi.log_file_name;
trx->mysql_master_log_pos = (ib_longlong)
(glob_mi.pos + glob_mi.event_len
+ glob_mi.pending);
}
trx_commit_for_mysql(trx);
if (current_thd->slave_thread)
{
/* Update the replication position info inside InnoDB */
#ifdef NEED_TO_BE_FIXED
trx->mysql_relay_log_file_name= active_mi->rli.log_file_name;
trx->mysql_relay_log_pos= active_mi->rli.relay_log_pos;
#endif
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);
}
/*********************************************************************
@ -3176,8 +3178,9 @@ ha_innobase::update_table_comment(
*pos++=' ';
}
pos += sprintf(pos, "InnoDB free: %lu kB",
(ulong) innobase_get_free_space());
pos += my_sprintf(pos,
(pos,"InnoDB free: %lu kB",
(ulong) innobase_get_free_space()));
/* 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 SHOW_COMP_OPTION have_innodb;
extern uint innobase_init_flags, innobase_lock_type;
extern ulong innobase_cache_size;
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 transaction_commited= 0;
/* Update the binary log if we have cached some queries */
if (trans == &thd->transaction.all && mysql_bin_log.is_open() &&
my_b_tell(&thd->transaction.trans_log))
{
/* 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);
reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1);

View File

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

View File

@ -208,9 +208,14 @@ public:
void fix_length_and_dec() {}
Field *tmp_table_field(TABLE *t_arg)
{
if (!t_arg) 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);
}
if (!t_arg)
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));
}
};
class Item_func_signed :public Item_int_func

View File

@ -37,12 +37,18 @@ public:
void left_right_max_length();
Field *tmp_table_field(TABLE *t_arg)
{
if (!t_arg) 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);
}
if (!t_arg)
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);}
};
class Item_func_md5 :public Item_str_func
{
String tmp_value;

View File

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

View File

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

1131
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()
{
@ -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)
{
if (rli)
if (rli) // QQ When is this not true ?
{
rli->inc_pos(get_event_len(),log_pos);
DBUG_ASSERT(rli->sql_thd != 0);
@ -749,9 +757,9 @@ int Rotate_log_event::write_data(IO_CACHE* file)
#ifndef MYSQL_CLIENT
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),
q_len(thd_arg->query_length),
q_len((uint32) query_length),
error_code(thd_arg->killed ? ER_SERVER_SHUTDOWN: thd_arg->net.last_errno),
thread_id(thd_arg->thread_id),
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)
{
DBUG_ENTER("Slave_log_event");
if (!rli->inited)
if (!rli->inited) // QQ When can this happen ?
DBUG_VOID_RETURN;
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);
thd->db = rewrite_db((char*)db);
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))
{
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)
{
/* All temporary tables was deleted on the master */
close_temporary_tables(thd);
/*
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)
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)
{
// 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
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
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
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);
flush_relay_log_info(rli);
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)
{
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
rotate local binlog only if the name of remote has changed
*/
if (!*log_name || !(log_name[ident_len] == 0 &&
!memcmp(log_name, new_log_ident, ident_len)))
if (!*log_name || (memcmp(log_name, new_log_ident, ident_len) ||
log_name[ident_len] != 0))
{
write_slave_event = (!(flags & LOG_EVENT_FORCED_ROTATE_F)
&& mysql_bin_log.is_open());
write_slave_event = (!(flags & LOG_EVENT_FORCED_ROTATE_F) &&
mysql_bin_log.is_open());
rotate_binlog = (*log_name && write_slave_event);
if (ident_len >= sizeof(rli->master_log_name))
{
// This should be impossible
pthread_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1);
}
memcpy(log_name, new_log_ident,ident_len);
memcpy(log_name, new_log_ident, ident_len);
log_name[ident_len] = 0;
}
rli->master_log_pos = pos;
@ -1848,7 +1904,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
if (rotate_binlog)
{
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));
pthread_cond_broadcast(&rli->data_cond);

View File

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

View File

@ -199,7 +199,7 @@ MYSQL *mc_mysql_init(MYSQL *mysql)
#ifdef __WIN__
mysql->options.connect_timeout=20;
#endif
mysql->net.timeout = slave_net_timeout;
mysql->net.read_timeout = slave_net_timeout;
return mysql;
}
@ -416,7 +416,9 @@ my_bool mc_mysql_reconnect(MYSQL *mysql)
mysql->client_flag, mysql->net.read_timeout))
{
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);
}
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;
#endif
DBUG_ENTER("mc_mysql_connect");
DBUG_PRINT("enter",("host: %s db: %s user: %s",
DBUG_PRINT("enter",("host: %s db: %s user: %s connect_time_out: %u read_timeout: %u",
host ? host : "(Null)",
db ? db : "(Null)",
user ? user : "(Null)"));
user ? user : "(Null)",
net_read_timeout,
(uint) slave_net_timeout));
thr_alarm_init(&alarmed);
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;
}
vio_keepalive(net->vio,TRUE);
net->timeout=slave_net_timeout;
net->read_timeout=slave_net_timeout;
/* Get version info */
mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */
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)));
bool fn_format_relative_to_data_home(my_string to, const char *name,
const char *dir, const char *extension);
void open_log(MYSQL_LOG *log, const char *hostname,
const char *opt_name, const char *extension,
bool open_log(MYSQL_LOG *log, const char *hostname,
const char *opt_name, const char *extension,
const char *index_file_name,
enum_log_type type, bool read_append = 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 slave_open_temp_tables, query_cache_size;
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_key_count, ha_read_next_count, ha_read_prev_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 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_slave_compressed_protocol;
extern char f_fyllchar;
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 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__
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;
ulong back_log, connect_timeout;
ulong back_log, connect_timeout, concurrency;
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_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 ulong opt_specialflag=SPECIAL_ENGLISH;
static ulong concurrency;
static ulong opt_myisam_block_size;
static my_socket unix_sock= INVALID_SOCKET,ip_sock= INVALID_SOCKET;
static my_string opt_logname=0,opt_update_logname=0,
@ -1428,6 +1428,17 @@ static void init_signals(void)
sigaction(SIGILL, &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);
#ifdef THREAD_SPECIFIC_SIGPIPE
sigset(SIGPIPE,abort_thread);
@ -1701,10 +1712,11 @@ const char *load_default_groups[]= { "mysqld","server",0 };
char *libwrapName=NULL;
#endif
void open_log(MYSQL_LOG *log, const char *hostname,
const char *opt_name, const char *extension,
enum_log_type type, bool read_append,
bool no_auto_events)
bool open_log(MYSQL_LOG *log, const char *hostname,
const char *opt_name, const char *extension,
const char *index_file_name,
enum_log_type type, bool read_append,
bool no_auto_events)
{
char tmp[FN_REFLEN];
if (!opt_name || !opt_name[0])
@ -1728,8 +1740,9 @@ void open_log(MYSQL_LOG *log, const char *hostname,
opt_name=tmp;
}
}
log->open(opt_name,type,0,(read_append) ? SEQ_READ_APPEND : WRITE_CACHE,
no_auto_events);
return log->open(opt_name, type, 0, index_file_name,
(read_append) ? SEQ_READ_APPEND : WRITE_CACHE,
no_auto_events);
}
@ -1939,17 +1952,18 @@ int main(int argc, char **argv)
/* Setup log files */
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)
{
open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
LOG_NEW);
NullS, LOG_NEW);
using_update_log=1;
}
if (opt_slow_log)
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
LOG_NORMAL);
NullS, LOG_NORMAL);
#ifdef __WIN__
#define MYSQL_ERR_FILE "mysql.err"
if (!opt_console)
@ -2051,9 +2065,8 @@ The server will not act as a slave.");
strmov(strcend(tmp,'.'),"-bin");
opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
}
mysql_bin_log.set_index_file_name(opt_binlog_index_name);
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
LOG_BIN);
opt_binlog_index_name,LOG_BIN);
using_update_log=1;
}
@ -2353,13 +2366,7 @@ static void create_new_thread(THD *thd)
delete thd;
DBUG_VOID_RETURN;
}
if (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;
}
pthread_mutex_lock(&LOCK_thread_count);
if (thread_count-delayed_insert_threads > max_used_connections)
max_used_connections=thread_count-delayed_insert_threads;
thd->thread_id=thread_id++;
@ -2818,7 +2825,7 @@ enum options {
OPT_QUERY_CACHE_LIMIT, OPT_QUERY_CACHE_SIZE,
OPT_QUERY_CACHE_TYPE, OPT_RECORD_BUFFER,
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_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE,
OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
@ -2968,8 +2975,9 @@ struct my_option my_long_options[] =
0, 0, 0, 0, 0, 0},
{"innodb_flush_log_at_trx_commit", OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT,
"Set to 0 if you don't want to flush logs",
&innobase_flush_log_at_trx_commit, &innobase_flush_log_at_trx_commit,
0, GET_LONG, OPT_ARG, 0, 0, 10, 0, 0, 0},
(gptr*) &innobase_flush_log_at_trx_commit,
(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,
"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,
@ -3047,7 +3055,7 @@ struct my_option my_long_options[] =
{"master-retry-count", OPT_MASTER_RETRY_COUNT,
"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,
REQUIRED_ARG, 60, 0, 0, 0, 0, 0},
REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0},
{"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.",
(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,
"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,
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,
"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,
@ -3548,6 +3556,11 @@ struct my_option my_long_options[] =
"Undocumented", (gptr*) &relay_log_space_limit,
(gptr*) &relay_log_space_limit, 0, GET_ULONG, REQUIRED_ARG, 0L, 0L,
(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,
"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,

View File

@ -107,7 +107,10 @@ int my_net_init(NET *net, Vio* vio)
net->fd = vio_fd(vio); /* For perl DBI/DBD */
#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) && !defined(OS2)
if (!(test_flags & TEST_BLOCKING))
vio_blocking(vio, FALSE);
{
my_bool old_mode;
vio_blocking(vio, FALSE, &old_mode);
}
#endif
vio_fastsend(vio);
}
@ -161,17 +164,14 @@ void net_clear(NET *net)
{
#if !defined(EXTRA_DEBUG) && !defined(EMBEDDED_LIBRARY)
int count; /* One may get 'unused' warn */
bool is_blocking=vio_is_blocking(net->vio);
if (is_blocking)
vio_blocking(net->vio, FALSE);
if (!vio_is_blocking(net->vio)) /* Safety if SSL */
my_bool old_mode;
if (!vio_blocking(net->vio, FALSE, &old_mode))
{
while ( (count = vio_read(net->vio, (char*) (net->buff),
(uint32) net->max_packet)) > 0)
DBUG_PRINT("info",("skipped %d bytes from file: %s",
count,vio_description(net->vio)));
if (is_blocking)
vio_blocking(net->vio, TRUE);
vio_blocking(net->vio, TRUE, &old_mode);
}
#endif /* EXTRA_DEBUG */
net->pkt_nr=net->compress_pkt_nr=0; /* Ready for new command */
@ -382,20 +382,18 @@ net_real_write(NET *net,const char *packet,ulong len)
{
if (!thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff))
{ /* 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)
continue;
if (vio_should_retry(net->vio) && retry_count++ < RETRY_COUNT)
continue;
#ifdef EXTRA_DEBUG
fprintf(stderr,
"%s: my_net_write: fcntl returned error %d, aborting thread\n",
my_progname,vio_errno(net->vio));
fprintf(stderr,
"%s: my_net_write: fcntl returned error %d, aborting thread\n",
my_progname,vio_errno(net->vio));
#endif /* EXTRA_DEBUG */
net->error=2; /* Close socket */
goto end;
}
net->error=2; /* Close socket */
goto end;
}
retry_count=0;
continue;
@ -439,8 +437,9 @@ net_real_write(NET *net,const char *packet,ulong len)
#endif
if (thr_alarm_in_use(&alarmed))
{
my_bool old_mode;
thr_end_alarm(&alarmed);
vio_blocking(net->vio, net_blocking);
vio_blocking(net->vio, net_blocking, &old_mode);
}
net->reading_or_writing=0;
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;
uint retry_count=0;
my_bool old_mode;
if (!thr_alarm_in_use(&alarmed))
{
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 */
}
while (remain > 0)
@ -538,29 +539,27 @@ my_real_read(NET *net, ulong *complen)
{
if (!thr_alarm(&alarmed,net->read_timeout,&alarm_buff)) /* Don't wait too long */
{
if (!vio_is_blocking(net->vio))
{
while (vio_blocking(net->vio,TRUE) < 0)
{
if (vio_should_retry(net->vio) &&
retry_count++ < RETRY_COUNT)
continue;
DBUG_PRINT("error",
("fcntl returned error %d, aborting thread",
vio_errno(net->vio)));
my_bool old_mode;
while (vio_blocking(net->vio, TRUE, &old_mode) < 0)
{
if (vio_should_retry(net->vio) &&
retry_count++ < RETRY_COUNT)
continue;
DBUG_PRINT("error",
("fcntl returned error %d, aborting thread",
vio_errno(net->vio)));
#ifdef EXTRA_DEBUG
fprintf(stderr,
"%s: read: fcntl returned error %d, aborting thread\n",
my_progname,vio_errno(net->vio));
fprintf(stderr,
"%s: read: fcntl returned error %d, aborting thread\n",
my_progname,vio_errno(net->vio));
#endif /* EXTRA_DEBUG */
len= packet_error;
net->error=2; /* Close socket */
len= packet_error;
net->error=2; /* Close socket */
#ifdef MYSQL_SERVER
net->last_errno=ER_NET_FCNTL_ERROR;
net->last_errno=ER_NET_FCNTL_ERROR;
#endif
goto end;
}
}
goto end;
}
retry_count=0;
continue;
}
@ -583,7 +582,9 @@ my_real_read(NET *net, ulong *complen)
continue;
}
#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;
net->error=2; /* Close socket */
#ifdef MYSQL_SERVER
@ -653,8 +654,9 @@ my_real_read(NET *net, ulong *complen)
end:
if (thr_alarm_in_use(&alarmed))
{
my_bool old_mode;
thr_end_alarm(&alarmed);
vio_blocking(net->vio, net_blocking);
vio_blocking(net->vio, net_blocking, &old_mode);
}
net->reading_or_writing=0;
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)
{
LOG_INFO linfo;
char search_file_name[FN_REFLEN],last_log_name[FN_REFLEN];
char last_log_name[FN_REFLEN];
IO_CACHE log;
File file = -1, last_file = -1;
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;
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");
return 1;
@ -619,18 +618,22 @@ int show_slave_hosts(THD* thd)
int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi)
{
if (!mi->host || !*mi->host) /* empty host */
return 1;
DBUG_ENTER("connect_to_master");
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,
mi->port, 0, 0,
slave_net_timeout))
{
sql_print_error("Connection to master failed: %s",
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;
}
/*
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)
{
MYSQL mysql;
MYSQL_RES* master_status_res = 0;
bool slave_was_running = 0;
int error = 0;
const char* errmsg=0;
int restart_thread_mask;
@ -840,7 +848,8 @@ int load_master_data(THD* thd)
}
}
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))
{
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",
&opt_safe_show_db);
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",
&slave_net_timeout);
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",
set_option_bit,
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 */
@ -290,6 +301,7 @@ sys_var *sys_variables[]=
&sys_delayed_queue_size,
&sys_flush,
&sys_flush_time,
&sys_foreign_key_checks,
&sys_identity,
&sys_insert_id,
&sys_interactive_timeout,
@ -326,7 +338,7 @@ sys_var *sys_variables[]=
#ifdef HAVE_QUERY_CACHE
&sys_query_cache_limit,
&sys_query_cache_type,
#endif HAVE_QUERY_CACHE
#endif /* HAVE_QUERY_CACHE */
&sys_quote_show_create,
&sys_read_buff_size,
&sys_read_rnd_buff_size,
@ -335,6 +347,7 @@ sys_var *sys_variables[]=
&sys_safe_updates,
&sys_select_limit,
&sys_server_id,
&sys_slave_compressed_protocol,
&sys_slave_net_timeout,
&sys_slave_skip_counter,
&sys_slow_launch_time,
@ -349,6 +362,7 @@ sys_var *sys_variables[]=
&sys_timestamp,
&sys_tmp_table_size,
&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_force_recovery", (char*) &innobase_force_recovery, 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_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
{"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)
{
if (var->save_result.ulong_value == 0)
thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
sys_var_thd_bit *sys_var= ((sys_var_thd_bit*) var->var);
if ((var->save_result.ulong_value != 0) == sys_var->reverse)
thd->options&= ~sys_var->bit_flag;
else
thd->options|= ((sys_var_thd_bit*) var->var)->bit_flag;
thd->options|= sys_var->bit_flag;
return 0;
}
@ -1142,7 +1157,7 @@ void set_var_free()
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,
length ? length :

View File

@ -128,7 +128,7 @@ public:
}
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; }
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 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
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;
bzero(&info_file,sizeof(info_file));
bzero(&cache_buf, sizeof(cache_buf));
pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&data_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,
but required otherwise
but required otherwise as var is a longlong
*/
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);
} RELAY_LOG_INFO;
Log_event* next_event(RELAY_LOG_INFO* rli);
/*
@ -251,16 +261,7 @@ typedef struct st_master_info
char master_log_name[FN_REFLEN];
my_off_t master_log_pos;
File fd;
/*
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;
File fd; // we keep the file open, so we need to remember the file pointer
IO_CACHE file;
/* 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)
{
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(&data_lock, MY_MUTEX_INIT_FAST);
pthread_cond_init(&data_cond, NULL);
@ -337,8 +338,8 @@ typedef struct st_table_rule_ent
int init_slave();
void init_slave_skip_errors(const char* arg);
int flush_master_info(MASTER_INFO* mi);
int flush_relay_log_info(RELAY_LOG_INFO* rli);
bool flush_master_info(MASTER_INFO* mi);
bool flush_relay_log_info(RELAY_LOG_INFO* rli);
int register_slave_on_master(MYSQL* mysql);
int terminate_slave_threads(MASTER_INFO* mi, int thread_mask,
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 */
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);
int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname);
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,
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 ;
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;
*priv_user=(char*) user;
char *ptr=0;
DBUG_ENTER("acl_getroot");
bzero(mqh,sizeof(USER_RESOURCES));
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));
/*
@ -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));
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));
char buff[460];
Query_log_event qinfo(thd, buff);
qinfo.q_len =
ulong query_length=
my_sprintf(buff,
(buff,"SET PASSWORD FOR \"%-.120s\"@\"%-.120s\"=\"%-.120s\"",
acl_user->user ? acl_user->user : "",
acl_user->host.hostname ? acl_user->host.hostname : "",
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);
DBUG_RETURN(0);
}

View File

@ -279,6 +279,7 @@ void intern_close_table(TABLE *table)
static void free_cache_entry(TABLE *table)
{
DBUG_ENTER("free_cache_entry");
safe_mutex_assert_owner(&LOCK_open);
intern_close_table(table);
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)); */
if (!locked)
VOID(pthread_mutex_lock(&LOCK_open));
safe_mutex_assert_owner(&LOCK_open);
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())
{
uint save_query_len = thd->query_length;
*--end = 0; // Remove last ','
thd->query_length = (uint)(end-query);
Query_log_event qinfo(thd, query);
/* The -1 is to remove last ',' */
Query_log_event qinfo(thd, query, (ulong)(end-query)-1);
qinfo.error_code=0;
mysql_bin_log.write(&qinfo);
thd->query_length = save_query_len;
}
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
LOCK_OPEN ; This lock will be unlocked on return.
LOCK_open ; This lock will be unlocked on return.
*/
void wait_for_refresh(THD *thd)
{
safe_mutex_assert_owner(&LOCK_open);
/* Wait until the current table is up to date */
const char *proc_info;
thd->mysys_var->current_mutex= &LOCK_open;
@ -931,6 +932,7 @@ bool reopen_table(TABLE *table,bool locked)
#endif
if (!locked)
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,
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)
{
DBUG_ENTER("reopen_tables");
safe_mutex_assert_owner(&LOCK_open);
if (!thd->open_tables)
DBUG_RETURN(0);
@ -1259,6 +1263,8 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
table_list.next=0;
if (!locked)
pthread_mutex_lock(&LOCK_open);
safe_mutex_assert_owner(&LOCK_open);
if ((error=lock_table_name(thd,&table_list)))
{
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->variables.query_cache_type == 0)
{
DBUG_PRINT("qcache", ("query cache disabled or not in autocommit mode"));
goto err;
}
/* Check that we haven't forgot to reset the query cache variables */
DBUG_ASSERT(thd->net.query_cache_query == 0);
@ -1021,6 +1018,7 @@ err:
DBUG_RETURN(0); // Query was not cached
}
/*
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
{
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;
bool fatal; // if the purge happens to give us a negative offset
pthread_mutex_t lock;
@ -64,7 +64,7 @@ class MYSQL_LOG {
ulonglong bytes_written;
time_t last_time,query_start;
IO_CACHE log_file;
File index_file;
IO_CACHE index_file;
char *name;
char time_buff[20],db[NAME_LEN+1];
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 wait_for_update(THD* thd);
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,
enum cache_type io_cache_type_arg = WRITE_CACHE,
bool no_auto_events_arg = 0);
void open(const char *log_name,enum_log_type log_type,
const char *new_name, enum cache_type io_cache_type_arg,
bool open(const char *log_name,enum_log_type log_type,
const char *new_name, const char *index_file_name_arg,
enum cache_type io_cache_type_arg,
bool no_auto_events_arg);
void new_file(bool inside_mutex = 0);
bool open_index(int options);
void close_index();
void new_file(bool need_lock= 1);
bool write(THD *thd, enum enum_server_command command,
const char *format,...);
bool write(THD *thd, const char *query, uint query_length,
@ -135,13 +133,13 @@ public:
bool is_active(const char* log_file_name);
int purge_logs(THD* thd, const char* to_log);
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
void close(bool exiting = 0);
// iterating through the log index file
int find_first_log(LOG_INFO* linfo, const char* log_name,
bool need_mutex=1);
int find_log_pos(LOG_INFO* linfo, const char* log_name,
bool need_mutex=1);
int find_next_log(LOG_INFO* linfo, bool need_mutex=1);
int get_current_log(LOG_INFO* linfo);
uint next_file_id();
@ -154,7 +152,7 @@ public:
inline void lock_index() { pthread_mutex_lock(&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; }
};

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);
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);
}
}
@ -153,7 +153,9 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
send_ok(&thd->net,0);
goto exit;
}
pthread_mutex_lock(&LOCK_open);
remove_db_from_cache(db);
pthread_mutex_unlock(&LOCK_open);
error = -1;
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);
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);
}
if (thd->query == path)

View File

@ -167,7 +167,8 @@ cleanup:
mysql_update_log.write(thd,thd->query, thd->query_length);
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)
error=1;
}
@ -468,7 +469,7 @@ bool multi_delete::send_eof()
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
Query_log_event qinfo(thd, thd->query, thd->query_length);
if (mysql_bin_log.write(&qinfo) &&
!not_trans_safe)
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);
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);
}
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);
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)
error=1;
}
@ -1196,8 +1197,7 @@ bool delayed_insert::handle_inserts(void)
mysql_update_log.write(&thd,row->query, row->query_length);
if (using_bin_log)
{
thd.query_length = row->query_length;
Query_log_event qinfo(&thd, row->query);
Query_log_event qinfo(&thd, row->query, row->query_length);
mysql_bin_log.write(&qinfo);
}
}
@ -1377,7 +1377,7 @@ bool select_insert::send_eof()
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query,
Query_log_event qinfo(thd, thd->query, thd->query_length,
table->file->has_transactions());
mysql_bin_log.write(&qinfo);
}

View File

@ -24,7 +24,7 @@
#include <assert.h>
#ifdef HAVE_INNOBASE_DB
#include "ha_innobase.h"
#include "ha_innodb.h"
#endif
#ifdef HAVE_OPENSSL
@ -1428,13 +1428,16 @@ mysql_execute_command(void)
case SQLCOM_LOAD_MASTER_DATA: // sync with master
if (check_global_access(thd, SUPER_ACL))
goto error;
res = load_master_data(thd);
if (end_active_trans(thd))
res= -1;
else
res = load_master_data(thd);
break;
#ifdef HAVE_INNOBASE_DB
case SQLCOM_SHOW_INNODB_STATUS:
{
if (check_process_priv(thd))
if (check_global_access(thd, SUPER_ACL))
goto error;
res = innodb_show_status(thd);
break;
@ -2319,7 +2322,7 @@ mysql_execute_command(void)
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
Query_log_event qinfo(thd, thd->query, thd->query_length);
mysql_bin_log.write(&qinfo);
}
}
@ -2339,7 +2342,7 @@ mysql_execute_command(void)
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
Query_log_event qinfo(thd, thd->query, thd->query_length);
mysql_bin_log.write(&qinfo);
}
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;
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)
{
acl_reload();
@ -3382,7 +3383,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
if (options & REFRESH_SLAVE)
{
LOCK_ACTIVE_MI;
if (reset_slave(active_mi))
if (reset_slave(thd, active_mi))
result=1;
UNLOCK_ACTIVE_MI;
}

View File

@ -94,7 +94,7 @@ end:
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
Query_log_event qinfo(thd, thd->query, thd->query_length);
mysql_bin_log.write(&qinfo);
}
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)
{
THD *tmp;
@ -193,9 +214,10 @@ void adjust_linfo_offsets(my_off_t purge_offset)
if ((linfo = tmp->current_linfo))
{
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
we have nothing to adjust
/*
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
*/
if (linfo->index_file_offset < purge_offset)
linfo->fatal = (linfo->index_file_offset != 0);
@ -274,7 +296,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
{
LOG_INFO linfo;
char *log_file_name = linfo.log_file_name;
char search_file_name[FN_REFLEN];
char search_file_name[FN_REFLEN], *name;
IO_CACHE log;
File file = -1;
String* packet = &thd->packet;
@ -295,7 +317,6 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
}
#endif
if (!mysql_bin_log.is_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;
}
name=search_file_name;
if (log_ident[0])
mysql_bin_log.make_log_name(search_file_name, log_ident);
else
search_file_name[0] = 0;
name=0; // Find first log
linfo.index_file_offset = 0;
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;
}
@ -332,19 +354,19 @@ impossible position";
}
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
// to distiquish it from error
packet->append("\0", 1);
/*
We need to start a packet with something other than 255
to distiquish it from error
*/
packet->set("\0", 1);
// 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
if (fake_rotate_event(net, packet, log_file_name, &errmsg))
goto err;
packet->length(0);
packet->append("\0", 1);
packet->set("\0", 1);
}
while (!net->error && net->vio != 0 && !thd->killed)
@ -376,20 +398,21 @@ impossible position";
goto err;
}
}
packet->length(0);
packet->append("\0",1);
packet->set("\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)
{
switch(error) {
switch (error) {
case LOG_READ_BOGUS:
errmsg = "bogus data in log event";
break;
case LOG_READ_TOO_LARGE:
errmsg = "log event entry exceeded max_allowed_packet -\
increase max_allowed_packet on master";
errmsg = "log event entry exceeded max_allowed_packet; \
Increase max_allowed_packet on master";
break;
case LOG_READ_IO:
errmsg = "I/O error reading log event";
@ -410,18 +433,21 @@ impossible position";
if (!(flags & BINLOG_DUMP_NON_BLOCK) &&
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))
{
errmsg = "failed on net_flush()";
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
// if we did not miss anything, we just wait for other threads
// to signal us
/*
We may have missed the update broadcast from the log
that has just happened, let's try to catch it if it did.
If we did not miss anything, we just wait for other threads
to signal us.
*/
{
log.error=0;
bool read_packet = 0, fatal_error = 0;
@ -435,32 +461,32 @@ impossible position";
}
#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);
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:
pthread_mutex_unlock(log_lock);
/* we read successfully, so we'll need to send it to the slave */
read_packet = 1;
// we read successfully, so we'll need to send it to the
// slave
break;
case LOG_READ_EOF:
DBUG_PRINT("wait",("waiting for data in binary log"));
// wait_for_update unlocks the log lock - needed to avoid race
if (!thd->killed)
mysql_bin_log.wait_for_update(thd);
else
pthread_mutex_unlock(log_lock);
DBUG_PRINT("wait",("binary log received update"));
break;
default:
pthread_mutex_unlock(log_lock);
fatal_error = 1;
break;
}
pthread_mutex_unlock(log_lock);
if (read_packet)
{
@ -479,10 +505,11 @@ impossible position";
goto err;
}
}
packet->length(0);
packet->append("\0",1);
// no need to net_flush because we will get to flush later when
// we hit EOF pretty quick
packet->set("\0", 1);
/*
No need to net_flush because we will get to flush later when
we hit EOF pretty quick
*/
}
if (fatal_error)
@ -539,7 +566,6 @@ impossible position";
err:
thd->proc_info = "waiting to finalize termination";
end_io_cache(&log);
pthread_mutex_lock(&LOCK_thread_count);
/*
Exclude iteration through thread list
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
after we return from this stack frame
*/
pthread_mutex_lock(&LOCK_thread_count);
thd->current_linfo = 0;
pthread_mutex_unlock(&LOCK_thread_count);
if (file >= 0)
@ -561,16 +588,19 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
if (!thd) thd = current_thd;
NET* net = &thd->net;
int thread_mask;
DBUG_ENTER("start_slave");
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
init_thread_mask(&thread_mask,mi,1 /* inverse */);
if (thd->lex.slave_thd_opt)
thread_mask &= thd->lex.slave_thd_opt;
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 */,
1 /* wait for start */,
mi,
@ -588,12 +618,12 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
{
if (net_report)
send_error(net, slave_errno);
return 1;
DBUG_RETURN(1);
}
else if (net_report)
send_ok(net);
return 0;
DBUG_RETURN(0);
}
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;
}
int reset_slave(MASTER_INFO* mi)
int reset_slave(THD *thd, MASTER_INFO* mi)
{
MY_STAT stat_area;
char fname[FN_REFLEN];
@ -639,7 +669,9 @@ int reset_slave(MASTER_INFO* mi)
lock_slave_threads(mi);
init_thread_mask(&restart_thread_mask,mi,0 /* not inverse */);
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;
end_master_info(mi);
@ -713,16 +745,17 @@ int change_master(THD* thd, MASTER_INFO* mi)
thd->proc_info = "changing master";
LEX_MASTER_INFO* lex_mi = &thd->lex.mi;
// 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");
unlock_slave_threads(mi);
DBUG_RETURN(1);
}
/* 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
could possibly modify the data structures from running
/*
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
could possibly modify the data structures from running
*/
if ((lex_mi->host || lex_mi->port) && !lex_mi->log_file_name && !lex_mi->pos)
{
@ -772,7 +805,8 @@ int change_master(THD* thd, MASTER_INFO* mi)
{
mi->rli.skip_log_purge=0;
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))
{
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
{
const char* msg;
if (init_relay_log_pos(&mi->rli,0/*log already inited*/,
0 /*pos already inited*/,
/* Relay log is already initialized */
if (init_relay_log_pos(&mi->rli,
mi->rli.relay_log_name,
mi->rli.relay_log_pos,
0 /*no data lock*/,
&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);
unlock_slave_threads(mi);
DBUG_RETURN(1);
@ -857,26 +892,27 @@ int show_binlog_events(THD* thd)
if (mysql_bin_log.is_open())
{
LOG_INFO linfo;
char search_file_name[FN_REFLEN];
LEX_MASTER_INFO* lex_mi = &thd->lex.mi;
LEX_MASTER_INFO *lex_mi = &thd->lex.mi;
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;
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_end = thd->lex.select->select_limit + limit_start;
name= search_file_name;
if (log_file_name)
mysql_bin_log.make_log_name(search_file_name, log_file_name);
else
search_file_name[0] = 0;
name=0; // Find first log
linfo.index_file_offset = 0;
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";
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)
{
const char* errmsg = 0;
File index_file;
const char *errmsg;
IO_CACHE *index_file;
char fname[FN_REFLEN];
NET* net = &thd->net;
List<Item> field_list;
String* packet = &thd->packet;
IO_CACHE io_cache;
String *packet = &thd->packet;
uint length;
if (!mysql_bin_log.is_open())
{
errmsg = "binlog is not open";
goto err;
//TODO: Replace with ER() error message
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))
{
sql_print_error("Failed in send_fields");
return 1;
}
mysql_bin_log.lock_index();
index_file = mysql_bin_log.get_index_file();
if (index_file < 0)
index_file=mysql_bin_log.get_index_file();
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);
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()))
{
sql_print_error("Failed in my_net_write");
end_io_cache(&io_cache);
mysql_bin_log.unlock_index();
return 1;
}
goto err;
}
mysql_bin_log.unlock_index();
end_io_cache(&io_cache);
send_eof(net);
return 0;
err2:
mysql_bin_log.unlock_index();
end_io_cache(&io_cache);
err:
err_with_msg:
send_error(net, 0, errmsg);
err:
mysql_bin_log.unlock_index();
return 1;
}
int log_loaded_block(IO_CACHE* file)
{
LOAD_FILE_INFO* lf_info;

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