2013-05-07 13:05:09 +02:00
|
|
|
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
|
2014-08-02 21:26:16 +02:00
|
|
|
Copyright (c) 2008, 2014, SkySQL Ab.
|
2000-10-02 05:28:21 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2000-10-02 05:28:21 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2011-06-30 17:46:53 +02:00
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
2000-10-02 05:28:21 +02:00
|
|
|
|
2014-09-30 19:31:14 +02:00
|
|
|
#include <my_global.h>
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_priv.h"
|
|
|
|
#include "unireg.h"
|
2012-11-05 15:01:49 +01:00
|
|
|
#include "sql_base.h"
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_parse.h" // check_access
|
2003-01-15 09:11:44 +01:00
|
|
|
#ifdef HAVE_REPLICATION
|
|
|
|
|
2007-04-12 08:58:04 +02:00
|
|
|
#include "rpl_mi.h"
|
2012-11-05 15:01:49 +01:00
|
|
|
#include "rpl_rli.h"
|
2000-10-02 05:28:21 +02:00
|
|
|
#include "sql_repl.h"
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_acl.h" // SUPER_ACL
|
2000-10-02 05:28:21 +02:00
|
|
|
#include "log_event.h"
|
2005-03-21 22:09:42 +01:00
|
|
|
#include "rpl_filter.h"
|
2000-10-02 06:52:36 +02:00
|
|
|
#include <my_dir.h>
|
2009-09-26 06:49:49 +02:00
|
|
|
#include "rpl_handler.h"
|
2011-01-18 18:23:49 +01:00
|
|
|
#include "debug_sync.h"
|
2000-10-02 05:28:21 +02:00
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
|
|
|
|
enum enum_gtid_until_state {
|
|
|
|
GTID_UNTIL_NOT_DONE,
|
|
|
|
GTID_UNTIL_STOP_AFTER_STANDALONE,
|
|
|
|
GTID_UNTIL_STOP_AFTER_TRANSACTION
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-06-29 02:22:29 +02:00
|
|
|
int max_binlog_dump_events = 0; // unlimited
|
2002-08-22 15:50:58 +02:00
|
|
|
my_bool opt_sporadic_binlog_dump_fail = 0;
|
2007-02-27 10:27:04 +01:00
|
|
|
#ifndef DBUG_OFF
|
2001-06-29 02:22:29 +02:00
|
|
|
static int binlog_dump_count = 0;
|
2007-02-27 10:27:04 +01:00
|
|
|
#endif
|
2001-06-29 17:55:21 +02:00
|
|
|
|
2011-10-19 21:45:18 +02:00
|
|
|
extern TYPELIB binlog_checksum_typelib;
|
2011-05-03 14:01:11 +02:00
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
|
|
|
|
static int
|
|
|
|
fake_event_header(String* packet, Log_event_type event_type, ulong extra_len,
|
|
|
|
my_bool *do_checksum, ha_checksum *crc, const char** errmsg,
|
2015-08-30 15:03:55 +02:00
|
|
|
enum enum_binlog_checksum_alg checksum_alg_arg, uint32 end_pos)
|
2013-05-15 19:52:21 +02:00
|
|
|
{
|
|
|
|
char header[LOG_EVENT_HEADER_LEN];
|
|
|
|
ulong event_len;
|
|
|
|
|
|
|
|
*do_checksum= checksum_alg_arg != BINLOG_CHECKSUM_ALG_OFF &&
|
|
|
|
checksum_alg_arg != BINLOG_CHECKSUM_ALG_UNDEF;
|
|
|
|
|
|
|
|
/*
|
|
|
|
'when' (the timestamp) is set to 0 so that slave could distinguish between
|
|
|
|
real and fake Rotate events (if necessary)
|
|
|
|
*/
|
|
|
|
memset(header, 0, 4);
|
|
|
|
header[EVENT_TYPE_OFFSET] = (uchar)event_type;
|
|
|
|
event_len= LOG_EVENT_HEADER_LEN + extra_len +
|
|
|
|
(*do_checksum ? BINLOG_CHECKSUM_LEN : 0);
|
|
|
|
int4store(header + SERVER_ID_OFFSET, global_system_variables.server_id);
|
|
|
|
int4store(header + EVENT_LEN_OFFSET, event_len);
|
|
|
|
int2store(header + FLAGS_OFFSET, LOG_EVENT_ARTIFICIAL_F);
|
|
|
|
// TODO: check what problems this may cause and fix them
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
int4store(header + LOG_POS_OFFSET, end_pos);
|
2013-05-15 19:52:21 +02:00
|
|
|
if (packet->append(header, sizeof(header)))
|
|
|
|
{
|
|
|
|
*errmsg= "Failed due to out-of-memory writing event";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (*do_checksum)
|
|
|
|
{
|
2015-07-26 13:19:04 +02:00
|
|
|
*crc= my_checksum(0, (uchar*)header, sizeof(header));
|
2013-05-15 19:52:21 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
fake_event_footer(String *packet, my_bool do_checksum, ha_checksum crc, const char **errmsg)
|
|
|
|
{
|
|
|
|
if (do_checksum)
|
|
|
|
{
|
|
|
|
char b[BINLOG_CHECKSUM_LEN];
|
|
|
|
int4store(b, crc);
|
|
|
|
if (packet->append(b, sizeof(b)))
|
|
|
|
{
|
|
|
|
*errmsg= "Failed due to out-of-memory writing event checksum";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
fake_event_write(NET *net, String *packet, const char **errmsg)
|
|
|
|
{
|
|
|
|
if (my_net_write(net, (uchar*) packet->ptr(), packet->length()))
|
|
|
|
{
|
|
|
|
*errmsg = "failed on my_net_write()";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-09 10:27:38 +01:00
|
|
|
/*
|
|
|
|
Helper structure, used to pass miscellaneous info from mysql_binlog_send()
|
|
|
|
into the helper functions that it calls.
|
|
|
|
*/
|
|
|
|
struct binlog_send_info {
|
|
|
|
rpl_binlog_state until_binlog_state;
|
|
|
|
slave_connection_state gtid_state;
|
|
|
|
THD *thd;
|
|
|
|
NET *net;
|
|
|
|
String *packet;
|
2014-12-19 12:36:23 +01:00
|
|
|
char *const log_file_name; // ptr/alias to linfo.log_file_name
|
2014-03-09 10:27:38 +01:00
|
|
|
slave_connection_state *until_gtid_state;
|
2014-12-19 12:36:23 +01:00
|
|
|
slave_connection_state until_gtid_state_obj;
|
2014-03-09 10:27:38 +01:00
|
|
|
Format_description_log_event *fdev;
|
|
|
|
int mariadb_slave_capability;
|
|
|
|
enum_gtid_skip_type gtid_skip_group;
|
|
|
|
enum_gtid_until_state gtid_until_group;
|
|
|
|
ushort flags;
|
2015-08-30 15:03:55 +02:00
|
|
|
enum enum_binlog_checksum_alg current_checksum_alg;
|
2014-03-09 10:27:38 +01:00
|
|
|
bool slave_gtid_strict_mode;
|
|
|
|
bool send_fake_gtid_list;
|
|
|
|
bool slave_gtid_ignore_duplicates;
|
|
|
|
bool using_gtid_state;
|
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
int error;
|
|
|
|
const char *errmsg;
|
|
|
|
char error_text[MAX_SLAVE_ERRMSG];
|
|
|
|
rpl_gtid error_gtid;
|
|
|
|
|
|
|
|
ulonglong heartbeat_period;
|
|
|
|
|
|
|
|
/** start file/pos as requested by slave, for error message */
|
|
|
|
char start_log_file_name[FN_REFLEN];
|
|
|
|
my_off_t start_pos;
|
|
|
|
|
|
|
|
/** last pos for error message */
|
|
|
|
my_off_t last_pos;
|
|
|
|
|
|
|
|
#ifndef DBUG_OFF
|
|
|
|
int left_events;
|
|
|
|
uint dbug_reconnect_counter;
|
|
|
|
ulong hb_info_counter;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool clear_initial_log_pos;
|
|
|
|
bool should_stop;
|
|
|
|
|
|
|
|
binlog_send_info(THD *thd_arg, String *packet_arg, ushort flags_arg,
|
|
|
|
char *lfn)
|
2014-03-09 10:27:38 +01:00
|
|
|
: thd(thd_arg), net(&thd_arg->net), packet(packet_arg),
|
|
|
|
log_file_name(lfn), until_gtid_state(NULL), fdev(NULL),
|
|
|
|
gtid_skip_group(GTID_SKIP_NOT), gtid_until_group(GTID_UNTIL_NOT_DONE),
|
|
|
|
flags(flags_arg), current_checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF),
|
|
|
|
slave_gtid_strict_mode(false), send_fake_gtid_list(false),
|
2014-12-19 12:36:23 +01:00
|
|
|
slave_gtid_ignore_duplicates(false),
|
|
|
|
error(0),
|
|
|
|
errmsg("Unknown error"),
|
|
|
|
heartbeat_period(0),
|
|
|
|
#ifndef DBUG_OFF
|
|
|
|
left_events(max_binlog_dump_events),
|
|
|
|
dbug_reconnect_counter(0),
|
|
|
|
hb_info_counter(0),
|
|
|
|
#endif
|
|
|
|
clear_initial_log_pos(false),
|
|
|
|
should_stop(false)
|
|
|
|
{
|
|
|
|
error_text[0] = 0;
|
|
|
|
bzero(&error_gtid, sizeof(error_gtid));
|
2016-04-28 16:15:38 +02:00
|
|
|
until_binlog_state.init();
|
2014-12-19 12:36:23 +01:00
|
|
|
}
|
2014-03-09 10:27:38 +01:00
|
|
|
};
|
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
// prototype
|
|
|
|
static int reset_transmit_packet(struct binlog_send_info *info, ushort flags,
|
|
|
|
ulong *ev_offset, const char **errmsg);
|
|
|
|
|
XA (not completely polished out yet)
include/my_pthread.h:
cleanup. don't use gcc extensions
innobase/include/trx0sys.ic:
Jan's fix for innobase_xa_prepare
innobase/read/read0read.c:
Jan's fix for innobase_xa_prepare
innobase/trx/trx0trx.c:
Jan's fix for innobase_xa_prepare
mysql-test/include/varchar.inc:
test fix
mysql-test/r/ctype_ucs.result:
new log event - all binlog positions are changed :(
mysql-test/r/drop_temp_table.result:
new log event - all binlog positions are changed :(
mysql-test/r/insert_select.result:
new log event - all binlog positions are changed :(
mysql-test/r/mix_innodb_myisam_binlog.result:
new log event - all binlog positions are changed :(
mysql-test/r/myisam.result:
test fix
mysql-test/r/rpl000015.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_change_master.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_charset.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_error_ignored_table.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_flush_log_loop.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_flush_tables.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_loaddata.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_loaddata_rule_m.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_loaddata_rule_s.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_log.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_log_pos.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_max_relay_size.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_relayrotate.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_replicate_do.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_reset_slave.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_rotate_logs.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_server_id1.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_server_id2.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_temporary.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_timezone.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_until.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_user_variables.result:
new log event - all binlog positions are changed :(
mysql-test/r/user_var.result:
new log event - all binlog positions are changed :(
mysql-test/t/ctype_ucs.test:
new log event - all binlog positions are changed :(
mysql-test/t/mix_innodb_myisam_binlog.test:
new log event - all binlog positions are changed :(
mysql-test/t/mysqlbinlog.test:
new log event - all binlog positions are changed :(
mysql-test/t/mysqlbinlog2.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_charset.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_error_ignored_table.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_loaddata_rule_m.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_loaddata_rule_s.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_log.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_log_pos.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_user_variables.test:
new log event - all binlog positions are changed :(
mysql-test/t/user_var.test:
new log event - all binlog positions are changed :(
mysys/hash.c:
typo fixed
sql/ha_berkeley.cc:
handlerton framework
sql/ha_berkeley.h:
handlerton framework
sql/ha_innodb.cc:
handlerton framework
sql/ha_innodb.h:
handlerton framework
sql/handler.cc:
new transaction handling, handlerton framework, two-phase commit, XA support
sql/handler.h:
new transaction handling, handlerton framework, two-phase commit, XA support
sql/lex.h:
XA commands
sql/log.cc:
new transaction handling, handlerton framework, two-phase commit,
XA support, tc-logging, TC_LOG_MMAP class
sql/log_event.cc:
Xid_log_event
sql/log_event.h:
Xid_log_event, LOG_EVENT_BINLOG_CLOSED_F flag
sql/mysql_priv.h:
wrapper for query_id++
sql/mysqld.cc:
new command-line options --log-tc, --log-tc-size, --tc-heuristic-recover,
new status variables Tc_log_page_size, Tc_log_max_pages_used, Tc_log_page_waits.
init/stop tc logging
sql/set_var.h:
warning fixed
sql/share/errmsg.txt:
XA error messages
sql/sp_head.cc:
s/query_id++/next_query_id()/
sql/sql_base.cc:
typo fixed. new transaction handling.
sql/sql_class.cc:
cleanup of THD.transaction
sql/sql_class.h:
TC_LOG classes, new status variables, new savepoint handling, XA support
sql/sql_insert.cc:
comments
sql/sql_lex.cc:
s/found_colon/found_semicolon/
sql/sql_lex.h:
SQLCOM_XA_xxx, XA related changes in Lex
sql/sql_parse.cc:
cleanup, XA commands, new savepoint handling
sql/sql_repl.cc:
two functions moved to log.cc
sql/sql_repl.h:
two functions moved to log.cc
sql/sql_trigger.cc:
s/lex.name_and_length/lex.ident/
sql/sql_yacc.yy:
XA commands, cleanup
2005-01-16 13:16:23 +01:00
|
|
|
/*
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
fake_rotate_event() builds a fake (=which does not exist physically in any
|
|
|
|
binlog) Rotate event, which contains the name of the binlog we are going to
|
|
|
|
send to the slave (because the slave may not know it if it just asked for
|
|
|
|
MASTER_LOG_FILE='', MASTER_LOG_POS=4).
|
2005-02-09 20:04:28 +01:00
|
|
|
< 4.0.14, fake_rotate_event() was called only if the requested pos was 4.
|
|
|
|
After this version we always call it, so that a 3.23.58 slave can rely on
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
it to detect if the master is 4.0 (and stop) (the _fake_ Rotate event has
|
|
|
|
zeros in the good positions which, by chance, make it possible for the 3.23
|
|
|
|
slave to detect that this event is unexpected) (this is luck which happens
|
|
|
|
because the master and slave disagree on the size of the header of
|
|
|
|
Log_event).
|
2005-02-09 20:04:28 +01:00
|
|
|
|
|
|
|
Relying on the event length of the Rotate event instead of these
|
|
|
|
well-placed zeros was not possible as Rotate events have a variable-length
|
|
|
|
part.
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
*/
|
|
|
|
|
2014-03-09 10:27:38 +01:00
|
|
|
static int fake_rotate_event(binlog_send_info *info, ulonglong position,
|
2015-08-30 15:03:55 +02:00
|
|
|
const char** errmsg, enum enum_binlog_checksum_alg checksum_alg_arg)
|
2001-01-17 13:47:33 +01:00
|
|
|
{
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
DBUG_ENTER("fake_rotate_event");
|
2014-12-19 12:36:23 +01:00
|
|
|
ulong ev_offset;
|
2013-05-15 19:52:21 +02:00
|
|
|
char buf[ROTATE_HEADER_LEN+100];
|
|
|
|
my_bool do_checksum;
|
|
|
|
int err;
|
2014-03-09 10:27:38 +01:00
|
|
|
char* p = info->log_file_name+dirname_length(info->log_file_name);
|
2001-01-17 13:47:33 +01:00
|
|
|
uint ident_len = (uint) strlen(p);
|
2014-03-09 10:27:38 +01:00
|
|
|
String *packet= info->packet;
|
2013-05-15 19:52:21 +02:00
|
|
|
ha_checksum crc;
|
2005-02-09 20:04:28 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/* reset transmit packet for the fake rotate event below */
|
|
|
|
if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg))
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
if ((err= fake_event_header(packet, ROTATE_EVENT,
|
2014-12-19 12:36:23 +01:00
|
|
|
ident_len + ROTATE_HEADER_LEN, &do_checksum,
|
|
|
|
&crc,
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
errmsg, checksum_alg_arg, 0)))
|
2014-12-19 12:36:23 +01:00
|
|
|
{
|
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
2013-05-15 19:52:21 +02:00
|
|
|
DBUG_RETURN(err);
|
2014-12-19 12:36:23 +01:00
|
|
|
}
|
2005-02-09 20:04:28 +01:00
|
|
|
|
2003-06-22 14:10:46 +02:00
|
|
|
int8store(buf+R_POS_OFFSET,position);
|
2001-06-27 01:02:33 +02:00
|
|
|
packet->append(buf, ROTATE_HEADER_LEN);
|
2011-05-03 14:01:11 +02:00
|
|
|
packet->append(p, ident_len);
|
|
|
|
|
|
|
|
if (do_checksum)
|
|
|
|
{
|
|
|
|
crc= my_checksum(crc, (uchar*)buf, ROTATE_HEADER_LEN);
|
|
|
|
crc= my_checksum(crc, (uchar*)p, ident_len);
|
|
|
|
}
|
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
if ((err= fake_event_footer(packet, do_checksum, crc, errmsg)) ||
|
2014-03-09 10:27:38 +01:00
|
|
|
(err= fake_event_write(info->net, packet, errmsg)))
|
2014-12-19 12:36:23 +01:00
|
|
|
{
|
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
2013-05-15 19:52:21 +02:00
|
|
|
DBUG_RETURN(err);
|
2014-12-19 12:36:23 +01:00
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-09 10:27:38 +01:00
|
|
|
static int fake_gtid_list_event(binlog_send_info *info,
|
2013-05-15 19:52:21 +02:00
|
|
|
Gtid_list_log_event *glev, const char** errmsg,
|
2014-03-09 10:27:38 +01:00
|
|
|
uint32 current_pos)
|
2013-05-15 19:52:21 +02:00
|
|
|
{
|
|
|
|
my_bool do_checksum;
|
|
|
|
int err;
|
|
|
|
ha_checksum crc;
|
|
|
|
char buf[128];
|
|
|
|
String str(buf, sizeof(buf), system_charset_info);
|
2014-03-09 10:27:38 +01:00
|
|
|
String* packet= info->packet;
|
2013-05-15 19:52:21 +02:00
|
|
|
|
|
|
|
str.length(0);
|
|
|
|
if (glev->to_packet(&str))
|
2001-07-10 14:53:08 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
2013-05-15 19:52:21 +02:00
|
|
|
*errmsg= "Failed due to out-of-memory writing Gtid_list event";
|
|
|
|
return -1;
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
if ((err= fake_event_header(packet, GTID_LIST_EVENT,
|
|
|
|
str.length(), &do_checksum, &crc,
|
2014-03-09 10:27:38 +01:00
|
|
|
errmsg, info->current_checksum_alg, current_pos)))
|
2014-12-19 12:36:23 +01:00
|
|
|
{
|
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
2013-05-15 19:52:21 +02:00
|
|
|
return err;
|
2014-12-19 12:36:23 +01:00
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
|
|
|
|
packet->append(str);
|
|
|
|
if (do_checksum)
|
|
|
|
{
|
|
|
|
crc= my_checksum(crc, (uchar*)str.ptr(), str.length());
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((err= fake_event_footer(packet, do_checksum, crc, errmsg)) ||
|
2014-03-09 10:27:38 +01:00
|
|
|
(err= fake_event_write(info->net, packet, errmsg)))
|
2014-12-19 12:36:23 +01:00
|
|
|
{
|
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
2013-05-15 19:52:21 +02:00
|
|
|
return err;
|
2014-12-19 12:36:23 +01:00
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
|
|
|
|
return 0;
|
2001-01-17 13:47:33 +01:00
|
|
|
}
|
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
|
2009-09-26 06:49:49 +02:00
|
|
|
/*
|
|
|
|
Reset thread transmit packet buffer for event sending
|
|
|
|
|
|
|
|
This function allocates header bytes for event transmission, and
|
|
|
|
should be called before store the event data to the packet buffer.
|
|
|
|
*/
|
2014-12-19 12:36:23 +01:00
|
|
|
static int reset_transmit_packet(binlog_send_info *info, ushort flags,
|
2009-09-26 06:49:49 +02:00
|
|
|
ulong *ev_offset, const char **errmsg)
|
|
|
|
{
|
|
|
|
int ret= 0;
|
2014-12-19 12:36:23 +01:00
|
|
|
String *packet= &info->thd->packet;
|
2009-09-26 06:49:49 +02:00
|
|
|
|
|
|
|
/* reserve and set default header */
|
|
|
|
packet->length(0);
|
|
|
|
packet->set("\0", 1, &my_charset_bin);
|
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (RUN_HOOK(binlog_transmit, reserve_header, (info->thd, flags, packet)))
|
2009-09-26 06:49:49 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
2009-09-26 06:49:49 +02:00
|
|
|
*errmsg= "Failed to run hook 'reserve_header'";
|
|
|
|
ret= 1;
|
|
|
|
}
|
|
|
|
*ev_offset= packet->length();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-10-02 05:28:21 +02:00
|
|
|
static int send_file(THD *thd)
|
|
|
|
{
|
|
|
|
NET* net = &thd->net;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
int fd = -1, error = 1;
|
|
|
|
size_t bytes;
|
2000-10-02 05:28:21 +02:00
|
|
|
char fname[FN_REFLEN+1];
|
|
|
|
const char *errmsg = 0;
|
2000-12-15 01:43:13 +01:00
|
|
|
int old_timeout;
|
2005-06-03 11:16:37 +02:00
|
|
|
unsigned long packet_len;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
uchar buf[IO_SIZE]; // It's safe to alloc this
|
2000-10-02 05:28:21 +02:00
|
|
|
DBUG_ENTER("send_file");
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/*
|
|
|
|
The client might be slow loading the data, give him wait_timeout to do
|
|
|
|
the job
|
|
|
|
*/
|
2007-01-29 14:31:48 +01:00
|
|
|
old_timeout= net->read_timeout;
|
2007-05-24 11:21:27 +02:00
|
|
|
my_net_set_read_timeout(net, thd->variables.net_wait_timeout);
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
We need net_flush here because the client will not know it needs to send
|
|
|
|
us the file name until it has processed the load event entry
|
|
|
|
*/
|
2000-12-11 21:09:01 +01:00
|
|
|
if (net_flush(net) || (packet_len = my_net_read(net)) == packet_error)
|
2000-10-02 05:28:21 +02:00
|
|
|
{
|
2001-07-10 14:53:08 +02:00
|
|
|
errmsg = "while reading file name";
|
2000-10-02 05:28:21 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
// terminate with \0 for fn_format
|
|
|
|
*((char*)net->read_pos + packet_len) = 0;
|
|
|
|
fn_format(fname, (char*) net->read_pos + 1, "", "", 4);
|
2000-10-02 05:28:21 +02:00
|
|
|
// this is needed to make replicate-ignore-db
|
|
|
|
if (!strcmp(fname,"/dev/null"))
|
|
|
|
goto end;
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
if ((fd= mysql_file_open(key_file_send_file,
|
|
|
|
fname, O_RDONLY, MYF(0))) < 0)
|
2000-10-02 05:28:21 +02:00
|
|
|
{
|
2001-07-10 14:53:08 +02:00
|
|
|
errmsg = "on open of file";
|
2000-10-02 05:28:21 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
while ((long) (bytes= mysql_file_read(fd, buf, IO_SIZE, MYF(0))) > 0)
|
2000-10-02 05:28:21 +02:00
|
|
|
{
|
|
|
|
if (my_net_write(net, buf, bytes))
|
|
|
|
{
|
2001-07-10 14:53:08 +02:00
|
|
|
errmsg = "while writing data to client";
|
2000-10-02 05:28:21 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
if (my_net_write(net, (uchar*) "", 0) || net_flush(net) ||
|
2000-10-02 05:28:21 +02:00
|
|
|
(my_net_read(net) == packet_error))
|
|
|
|
{
|
2001-07-10 14:53:08 +02:00
|
|
|
errmsg = "while negotiating file transfer close";
|
2000-10-02 05:28:21 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
error = 0;
|
|
|
|
|
|
|
|
err:
|
2007-05-24 11:21:27 +02:00
|
|
|
my_net_set_read_timeout(net, old_timeout);
|
2001-07-10 14:53:08 +02:00
|
|
|
if (fd >= 0)
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_file_close(fd, MYF(0));
|
2000-10-02 05:28:21 +02:00
|
|
|
if (errmsg)
|
|
|
|
{
|
2001-07-10 14:53:08 +02:00
|
|
|
sql_print_error("Failed in send_file() %s", errmsg);
|
2009-06-29 15:17:01 +02:00
|
|
|
DBUG_PRINT("error", ("%s", errmsg));
|
2000-10-02 05:28:21 +02:00
|
|
|
}
|
|
|
|
DBUG_RETURN(error);
|
|
|
|
}
|
|
|
|
|
2000-11-15 22:00:06 +01:00
|
|
|
|
2011-05-03 14:01:11 +02:00
|
|
|
/**
|
|
|
|
Internal to mysql_binlog_send() routine that recalculates checksum for
|
|
|
|
a FD event (asserted) that needs additional arranment prior sending to slave.
|
|
|
|
*/
|
|
|
|
inline void fix_checksum(String *packet, ulong ev_offset)
|
|
|
|
{
|
|
|
|
/* recalculate the crc for this event */
|
|
|
|
uint data_len = uint4korr(packet->ptr() + ev_offset + EVENT_LEN_OFFSET);
|
2015-09-02 17:03:19 +02:00
|
|
|
ha_checksum crc;
|
2011-05-03 14:01:11 +02:00
|
|
|
DBUG_ASSERT(data_len ==
|
|
|
|
LOG_EVENT_MINIMAL_HEADER_LEN + FORMAT_DESCRIPTION_HEADER_LEN +
|
|
|
|
BINLOG_CHECKSUM_ALG_DESC_LEN + BINLOG_CHECKSUM_LEN);
|
2015-09-02 17:03:19 +02:00
|
|
|
crc= my_checksum(0, (uchar *)packet->ptr() + ev_offset, data_len -
|
2011-05-03 14:01:11 +02:00
|
|
|
BINLOG_CHECKSUM_LEN);
|
|
|
|
int4store(packet->ptr() + ev_offset + data_len - BINLOG_CHECKSUM_LEN, crc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static user_var_entry * get_binlog_checksum_uservar(THD * thd)
|
|
|
|
{
|
|
|
|
LEX_STRING name= { C_STRING_WITH_LEN("master_binlog_checksum")};
|
|
|
|
user_var_entry *entry=
|
|
|
|
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
|
|
|
|
name.length);
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for calling in mysql_binlog_send
|
|
|
|
to check if slave initiated checksum-handshake.
|
|
|
|
|
|
|
|
@param[in] thd THD to access a user variable
|
|
|
|
|
|
|
|
@return TRUE if handshake took place, FALSE otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool is_slave_checksum_aware(THD * thd)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("is_slave_checksum_aware");
|
|
|
|
user_var_entry *entry= get_binlog_checksum_uservar(thd);
|
|
|
|
DBUG_RETURN(entry? true : false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for calling in mysql_binlog_send
|
|
|
|
to get the value of @@binlog_checksum of the master at
|
|
|
|
time of checksum-handshake.
|
|
|
|
|
|
|
|
The value tells the master whether to compute or not, and the slave
|
|
|
|
to verify or not the first artificial Rotate event's checksum.
|
|
|
|
|
|
|
|
@param[in] thd THD to access a user variable
|
|
|
|
|
|
|
|
@return value of @@binlog_checksum alg according to
|
|
|
|
@c enum enum_binlog_checksum_alg
|
|
|
|
*/
|
|
|
|
|
2015-08-30 15:03:55 +02:00
|
|
|
static enum enum_binlog_checksum_alg get_binlog_checksum_value_at_connect(THD * thd)
|
2011-05-03 14:01:11 +02:00
|
|
|
{
|
2015-08-30 15:03:55 +02:00
|
|
|
enum enum_binlog_checksum_alg ret;
|
2011-05-03 14:01:11 +02:00
|
|
|
|
|
|
|
DBUG_ENTER("get_binlog_checksum_value_at_connect");
|
|
|
|
user_var_entry *entry= get_binlog_checksum_uservar(thd);
|
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
ret= BINLOG_CHECKSUM_ALG_UNDEF;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(entry->type == STRING_RESULT);
|
|
|
|
String str;
|
|
|
|
uint dummy_errors;
|
|
|
|
str.copy(entry->value, entry->length, &my_charset_bin, &my_charset_bin,
|
|
|
|
&dummy_errors);
|
2015-08-30 15:03:55 +02:00
|
|
|
ret= (enum_binlog_checksum_alg)
|
|
|
|
(find_type ((char*) str.ptr(), &binlog_checksum_typelib, 1) - 1);
|
2011-05-03 14:01:11 +02:00
|
|
|
DBUG_ASSERT(ret <= BINLOG_CHECKSUM_ALG_CRC32); // while it's just on CRC32 alg
|
|
|
|
}
|
|
|
|
DBUG_RETURN(ret);
|
|
|
|
}
|
|
|
|
|
2002-08-08 02:12:02 +02:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2000-10-27 06:11:55 +02:00
|
|
|
void adjust_linfo_offsets(my_off_t purge_offset)
|
|
|
|
{
|
|
|
|
THD *tmp;
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2010-01-12 02:47:27 +01:00
|
|
|
mysql_mutex_lock(&LOCK_thread_count);
|
2000-10-27 06:11:55 +02:00
|
|
|
I_List_iterator<THD> it(threads);
|
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
while ((tmp=it++))
|
|
|
|
{
|
|
|
|
LOG_INFO* linfo;
|
|
|
|
if ((linfo = tmp->current_linfo))
|
|
|
|
{
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&linfo->lock);
|
2002-08-08 02:12:02 +02:00
|
|
|
/*
|
|
|
|
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
|
2001-07-11 02:08:37 +02:00
|
|
|
*/
|
2001-07-10 14:53:08 +02:00
|
|
|
if (linfo->index_file_offset < purge_offset)
|
|
|
|
linfo->fatal = (linfo->index_file_offset != 0);
|
|
|
|
else
|
|
|
|
linfo->index_file_offset -= purge_offset;
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&linfo->lock);
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
|
|
|
}
|
2010-01-12 02:47:27 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_thread_count);
|
2000-10-27 06:11:55 +02:00
|
|
|
}
|
|
|
|
|
2000-11-15 23:24:11 +01:00
|
|
|
|
2000-10-27 06:11:55 +02:00
|
|
|
bool log_in_use(const char* log_name)
|
|
|
|
{
|
2009-02-10 23:47:54 +01:00
|
|
|
size_t log_name_len = strlen(log_name) + 1;
|
2000-10-27 06:11:55 +02:00
|
|
|
THD *tmp;
|
|
|
|
bool result = 0;
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2010-01-12 02:47:27 +01:00
|
|
|
mysql_mutex_lock(&LOCK_thread_count);
|
2000-10-27 06:11:55 +02:00
|
|
|
I_List_iterator<THD> it(threads);
|
2001-07-10 14:53:08 +02:00
|
|
|
|
|
|
|
while ((tmp=it++))
|
|
|
|
{
|
|
|
|
LOG_INFO* linfo;
|
|
|
|
if ((linfo = tmp->current_linfo))
|
2000-10-27 06:11:55 +02:00
|
|
|
{
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&linfo->lock);
|
Bug#53445: Build with -Wall and fix warnings that it generates
Apart strict-aliasing warnings, fix the remaining warnings
generated by GCC 4.4.4 -Wall and -Wextra flags.
One major source of warnings was the in-house function my_bcmp
which (unconventionally) took pointers to unsigned characters
as the byte sequences to be compared. Since my_bcmp and bcmp
are deprecated functions whose only difference with memcmp is
the return value, every use of the function is replaced with
memcmp as the special return value wasn't actually being used
by any caller.
There were also various other warnings, mostly due to type
mismatches, missing return values, missing prototypes, dead
code (unreachable) and ignored return values.
BUILD/SETUP.sh:
Remove flags that are implied by -Wall and -Wextra.
Do not warn about unused parameters in C++.
BUILD/check-cpu:
Print only the compiler version instead of verbose banner.
Although the option is gcc specific, the check was only
being used for GCC specific checks anyway.
client/mysql.cc:
bcmp is no longer defined.
client/mysqltest.cc:
Pass a string to function expecting a format string.
Replace use of bcmp with memcmp.
cmd-line-utils/readline/Makefile.am:
Always define _GNU_SOURCE when compiling GNU readline.
Required to make certain prototypes visible.
cmd-line-utils/readline/input.c:
Condition for the code to be meaningful.
configure.in:
Remove check for bcmp.
extra/comp_err.c:
Use appropriate type.
extra/replace.c:
Replace use of bcmp with memcmp.
extra/yassl/src/crypto_wrapper.cpp:
Do not ignore the return value of fgets. Retrieve the file
position if fgets succeed -- if it fails, the function will
bail out and return a error.
extra/yassl/taocrypt/include/blowfish.hpp:
Use a single array instead of accessing positions of the sbox_
through a subscript to pbox_.
extra/yassl/taocrypt/include/runtime.hpp:
One definition of such functions is enough.
extra/yassl/taocrypt/src/aes.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/taocrypt/src/algebra.cpp:
Rename arguments to avoid shadowing related warnings.
extra/yassl/taocrypt/src/blowfish.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/taocrypt/src/integer.cpp:
Do not define type within a anonymous union.
Use a variable to return a value instead of
leaving the result in a register -- compiler
does not know the logic inside the asm.
extra/yassl/taocrypt/src/misc.cpp:
Define handler for pure virtual functions.
Remove unused code.
extra/yassl/taocrypt/src/twofish.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/testsuite/test.hpp:
Function must have C language linkage.
include/m_string.h:
Remove check which relied on bcmp being defined -- they weren't
being used as bcmp is only visible when _BSD_SOURCE is defined.
include/my_bitmap.h:
Remove bogus helpers which were used only in a few files and
were causing warnings about dead code.
include/my_global.h:
Due to G++ bug, always silence false-positive uninitialized
variables warnings when compiling C++ code with G++.
Remove bogus helper.
libmysql/Makefile.shared:
Remove built-in implementation of bcmp.
mysql-test/lib/My/SafeProcess/safe_process.cc:
Cast pid to largest possible type for a process identifier.
mysys/mf_loadpath.c:
Leave space of the ending nul.
mysys/mf_pack.c:
Replace bcmp with memcmp.
mysys/my_bitmap.c:
Dead code removal.
mysys/my_gethwaddr.c:
Remove unused variable.
mysys/my_getopt.c:
Silence bogus uninitialized variable warning.
Do not cast away the constant qualifier.
mysys/safemalloc.c:
Cast to expected type.
mysys/thr_lock.c:
Silence bogus uninitialized variable warning.
sql/field.cc:
Replace bogus helper with a more appropriate logic which is
used throughout the code.
sql/item.cc:
Remove bogus logical condition which always evaluates to TRUE.
sql/item_create.cc:
Simplify code to avoid signedness related warnings.
sql/log_event.cc:
Replace use of bcmp with memcmp.
No need to use helpers for simple bit operations.
sql/log_event_old.cc:
Replace bmove_align with memcpy.
sql/mysqld.cc:
Move use declaration of variable to the ifdef block where it
is used. Remove now-unnecessary casts and arguments.
sql/set_var.cc:
Replace bogus helpers with simple and classic bit operations.
sql/slave.cc:
Cast to expected type and silence bogus warning.
sql/sql_class.h:
Don't use enum values as bit flags, the supposed type safety is
bogus as the combined bit flags are not a value in the enumeration.
sql/udf_example.c:
Only declare variable when necessary.
sql/unireg.h:
Replace use of bmove_align with memcpy.
storage/innobase/os/os0file.c:
Silence bogus warning.
storage/myisam/mi_open.c:
Remove bogus cast, DBUG_DUMP expects a pointer to unsigned
char.
storage/myisam/mi_page.c:
Remove bogus cast, DBUG_DUMP expects a pointer to unsigned
char.
strings/bcmp.c:
Remove built-in bcmp.
strings/ctype-ucs2.c:
Silence bogus warning.
tests/mysql_client_test.c:
Use a appropriate type as expected by simple_command().
2010-07-02 20:30:47 +02:00
|
|
|
result = !memcmp(log_name, linfo->log_file_name, log_name_len);
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&linfo->lock);
|
2002-08-22 15:50:58 +02:00
|
|
|
if (result)
|
|
|
|
break;
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
|
|
|
}
|
2000-10-27 06:11:55 +02:00
|
|
|
|
2010-01-12 02:47:27 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_thread_count);
|
2000-10-27 06:11:55 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-10-20 03:04:37 +02:00
|
|
|
bool purge_error_message(THD* thd, int res)
|
2000-10-27 06:11:55 +02:00
|
|
|
{
|
2009-11-20 14:30:35 +01:00
|
|
|
uint errcode;
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2009-11-20 14:30:35 +01:00
|
|
|
if ((errcode= purge_log_get_error_code(res)) != 0)
|
2001-07-10 14:53:08 +02:00
|
|
|
{
|
2015-07-06 19:24:14 +02:00
|
|
|
my_message(errcode, ER_THD(thd, errcode), MYF(0));
|
2004-10-20 03:04:37 +02:00
|
|
|
return TRUE;
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
2008-02-19 13:45:21 +01:00
|
|
|
my_ok(thd);
|
2004-10-20 03:04:37 +02:00
|
|
|
return FALSE;
|
2000-10-27 06:11:55 +02:00
|
|
|
}
|
|
|
|
|
2003-08-11 21:44:43 +02:00
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
/**
|
|
|
|
Execute a PURGE BINARY LOGS TO <log> command.
|
|
|
|
|
|
|
|
@param thd Pointer to THD object for the client thread executing the
|
|
|
|
statement.
|
|
|
|
|
|
|
|
@param to_log Name of the last log to purge.
|
|
|
|
|
|
|
|
@retval FALSE success
|
|
|
|
@retval TRUE failure
|
|
|
|
*/
|
2004-10-20 03:04:37 +02:00
|
|
|
bool purge_master_logs(THD* thd, const char* to_log)
|
2003-02-16 17:39:12 +01:00
|
|
|
{
|
|
|
|
char search_file_name[FN_REFLEN];
|
2003-08-11 21:44:43 +02:00
|
|
|
if (!mysql_bin_log.is_open())
|
|
|
|
{
|
2008-02-19 13:45:21 +01:00
|
|
|
my_ok(thd);
|
2004-10-20 03:04:37 +02:00
|
|
|
return FALSE;
|
2003-08-11 21:44:43 +02:00
|
|
|
}
|
2003-02-16 17:39:12 +01:00
|
|
|
|
|
|
|
mysql_bin_log.make_log_name(search_file_name, to_log);
|
2003-08-11 21:44:43 +02:00
|
|
|
return purge_error_message(thd,
|
|
|
|
mysql_bin_log.purge_logs(search_file_name, 0, 1,
|
2003-08-18 23:08:08 +02:00
|
|
|
1, NULL));
|
2003-02-16 17:39:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
/**
|
|
|
|
Execute a PURGE BINARY LOGS BEFORE <date> command.
|
|
|
|
|
|
|
|
@param thd Pointer to THD object for the client thread executing the
|
|
|
|
statement.
|
|
|
|
|
|
|
|
@param purge_time Date before which logs should be purged.
|
|
|
|
|
|
|
|
@retval FALSE success
|
|
|
|
@retval TRUE failure
|
|
|
|
*/
|
2004-10-20 03:04:37 +02:00
|
|
|
bool purge_master_logs_before_date(THD* thd, time_t purge_time)
|
2003-02-16 17:39:12 +01:00
|
|
|
{
|
2004-09-14 14:30:57 +02:00
|
|
|
if (!mysql_bin_log.is_open())
|
|
|
|
{
|
2008-02-19 13:45:21 +01:00
|
|
|
my_ok(thd);
|
2004-09-14 14:30:57 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return purge_error_message(thd,
|
|
|
|
mysql_bin_log.purge_logs_before_date(purge_time));
|
2003-02-16 17:39:12 +01:00
|
|
|
}
|
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
void set_read_error(binlog_send_info *info, int error)
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
{
|
2005-02-09 20:04:28 +01:00
|
|
|
if (error == LOG_READ_EOF)
|
2014-12-19 12:36:23 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
switch (error) {
|
|
|
|
case LOG_READ_BOGUS:
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "bogus data in log event";
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
break;
|
|
|
|
case LOG_READ_TOO_LARGE:
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "log event entry exceeded max_allowed_packet; "
|
|
|
|
"Increase max_allowed_packet on master";
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
break;
|
|
|
|
case LOG_READ_IO:
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "I/O error reading log event";
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
break;
|
|
|
|
case LOG_READ_MEM:
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "memory allocation failed reading log event";
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
break;
|
|
|
|
case LOG_READ_TRUNC:
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "binlog truncated in the middle of event; "
|
|
|
|
"consider out of disk space on master";
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
break;
|
2011-05-03 14:01:11 +02:00
|
|
|
case LOG_READ_CHECKSUM_FAILURE:
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "event read from binlog did not pass crc check";
|
2011-05-03 14:01:11 +02:00
|
|
|
break;
|
2015-09-02 09:58:08 +02:00
|
|
|
case LOG_READ_DECRYPT:
|
|
|
|
info->errmsg= "event decryption failure";
|
|
|
|
break;
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
default:
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "unknown error reading log event on the master";
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-29 13:16:23 +02:00
|
|
|
/**
|
|
|
|
An auxiliary function for calling in mysql_binlog_send
|
|
|
|
to initialize the heartbeat timeout in waiting for a binlogged event.
|
|
|
|
|
|
|
|
@param[in] thd THD to access a user variable
|
|
|
|
|
|
|
|
@return heartbeat period an ulonglong of nanoseconds
|
|
|
|
or zero if heartbeat was not demanded by slave
|
|
|
|
*/
|
|
|
|
static ulonglong get_heartbeat_period(THD * thd)
|
|
|
|
{
|
2011-04-25 17:22:25 +02:00
|
|
|
bool null_value;
|
2009-09-29 13:16:23 +02:00
|
|
|
LEX_STRING name= { C_STRING_WITH_LEN("master_heartbeat_period")};
|
|
|
|
user_var_entry *entry=
|
2009-10-28 09:42:18 +01:00
|
|
|
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
|
2009-09-29 13:16:23 +02:00
|
|
|
name.length);
|
|
|
|
return entry? entry->val_int(&null_value) : 0;
|
|
|
|
}
|
|
|
|
|
2012-06-22 11:40:40 +02:00
|
|
|
/*
|
|
|
|
Lookup the capabilities of the slave, which it announces by setting a value
|
|
|
|
MARIA_SLAVE_CAPABILITY_XXX in @mariadb_slave_capability.
|
|
|
|
|
|
|
|
Older MariaDB slaves, and other MySQL slaves, do not set
|
|
|
|
@mariadb_slave_capability, corresponding to a capability of
|
|
|
|
MARIA_SLAVE_CAPABILITY_UNKNOWN (0).
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
get_mariadb_slave_capability(THD *thd)
|
|
|
|
{
|
|
|
|
bool null_value;
|
|
|
|
const LEX_STRING name= { C_STRING_WITH_LEN("mariadb_slave_capability") };
|
|
|
|
const user_var_entry *entry=
|
|
|
|
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
|
|
|
|
name.length);
|
|
|
|
return entry ?
|
|
|
|
(int)(entry->val_int(&null_value)) : MARIA_SLAVE_CAPABILITY_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-15 13:11:35 +01:00
|
|
|
/*
|
|
|
|
Get the value of the @slave_connect_state user variable into the supplied
|
|
|
|
String (this is the GTID connect state requested by the connecting slave).
|
|
|
|
|
|
|
|
Returns false if error (ie. slave did not set the variable and does not
|
|
|
|
want to use GTID to set start position), true if success.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
get_slave_connect_state(THD *thd, String *out_str)
|
|
|
|
{
|
|
|
|
bool null_value;
|
|
|
|
|
|
|
|
const LEX_STRING name= { C_STRING_WITH_LEN("slave_connect_state") };
|
|
|
|
user_var_entry *entry=
|
|
|
|
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
|
|
|
|
name.length);
|
|
|
|
return entry && entry->val_str(&null_value, out_str, 0) && !null_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-28 13:28:31 +02:00
|
|
|
static bool
|
|
|
|
get_slave_gtid_strict_mode(THD *thd)
|
|
|
|
{
|
|
|
|
bool null_value;
|
|
|
|
|
|
|
|
const LEX_STRING name= { C_STRING_WITH_LEN("slave_gtid_strict_mode") };
|
|
|
|
user_var_entry *entry=
|
|
|
|
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
|
|
|
|
name.length);
|
|
|
|
return entry && entry->val_int(&null_value) && !null_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-09 10:27:38 +01:00
|
|
|
static bool
|
|
|
|
get_slave_gtid_ignore_duplicates(THD *thd)
|
|
|
|
{
|
|
|
|
bool null_value;
|
|
|
|
|
|
|
|
const LEX_STRING name= { C_STRING_WITH_LEN("slave_gtid_ignore_duplicates") };
|
|
|
|
user_var_entry *entry=
|
|
|
|
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
|
|
|
|
name.length);
|
|
|
|
return entry && entry->val_int(&null_value) && !null_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
/*
|
|
|
|
Get the value of the @slave_until_gtid user variable into the supplied
|
|
|
|
String (this is the GTID position specified for START SLAVE UNTIL
|
|
|
|
master_gtid_pos='xxx').
|
|
|
|
|
|
|
|
Returns false if error (ie. slave did not set the variable and is not doing
|
|
|
|
START SLAVE UNTIL mater_gtid_pos='xxx'), true if success.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
get_slave_until_gtid(THD *thd, String *out_str)
|
|
|
|
{
|
|
|
|
bool null_value;
|
|
|
|
|
|
|
|
const LEX_STRING name= { C_STRING_WITH_LEN("slave_until_gtid") };
|
|
|
|
user_var_entry *entry=
|
|
|
|
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
|
|
|
|
name.length);
|
|
|
|
return entry && entry->val_str(&null_value, out_str, 0) && !null_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-29 13:16:23 +02:00
|
|
|
/*
|
|
|
|
Function prepares and sends repliation heartbeat event.
|
|
|
|
|
|
|
|
@param net net object of THD
|
|
|
|
@param packet buffer to store the heartbeat instance
|
|
|
|
@param event_coordinates binlog file name and position of the last
|
|
|
|
real event master sent from binlog
|
|
|
|
|
|
|
|
@note
|
|
|
|
Among three essential pieces of heartbeat data Log_event::when
|
|
|
|
is computed locally.
|
|
|
|
The error to send is serious and should force terminating
|
|
|
|
the dump thread.
|
|
|
|
*/
|
2014-12-19 12:36:23 +01:00
|
|
|
static int send_heartbeat_event(binlog_send_info *info,
|
|
|
|
NET* net, String* packet,
|
2011-12-14 12:02:03 +01:00
|
|
|
const struct event_coordinates *coord,
|
2015-08-30 15:03:55 +02:00
|
|
|
enum enum_binlog_checksum_alg checksum_alg_arg)
|
2009-09-29 13:16:23 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("send_heartbeat_event");
|
2014-12-19 12:36:23 +01:00
|
|
|
|
|
|
|
ulong ev_offset;
|
|
|
|
if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg))
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
|
2009-09-29 13:16:23 +02:00
|
|
|
char header[LOG_EVENT_HEADER_LEN];
|
2011-12-14 12:02:03 +01:00
|
|
|
my_bool do_checksum= checksum_alg_arg != BINLOG_CHECKSUM_ALG_OFF &&
|
|
|
|
checksum_alg_arg != BINLOG_CHECKSUM_ALG_UNDEF;
|
2009-09-29 13:16:23 +02:00
|
|
|
/*
|
|
|
|
'when' (the timestamp) is set to 0 so that slave could distinguish between
|
|
|
|
real and fake Rotate events (if necessary)
|
|
|
|
*/
|
|
|
|
memset(header, 0, 4); // when
|
|
|
|
|
|
|
|
header[EVENT_TYPE_OFFSET] = HEARTBEAT_LOG_EVENT;
|
|
|
|
|
|
|
|
char* p= coord->file_name + dirname_length(coord->file_name);
|
|
|
|
|
|
|
|
uint ident_len = strlen(p);
|
2011-12-14 12:02:03 +01:00
|
|
|
ulong event_len = ident_len + LOG_EVENT_HEADER_LEN +
|
|
|
|
(do_checksum ? BINLOG_CHECKSUM_LEN : 0);
|
2012-10-23 12:46:29 +02:00
|
|
|
int4store(header + SERVER_ID_OFFSET, global_system_variables.server_id);
|
2009-09-29 13:16:23 +02:00
|
|
|
int4store(header + EVENT_LEN_OFFSET, event_len);
|
|
|
|
int2store(header + FLAGS_OFFSET, 0);
|
|
|
|
|
|
|
|
int4store(header + LOG_POS_OFFSET, coord->pos); // log_pos
|
|
|
|
|
|
|
|
packet->append(header, sizeof(header));
|
|
|
|
packet->append(p, ident_len); // log_file_name
|
|
|
|
|
2011-12-14 12:02:03 +01:00
|
|
|
if (do_checksum)
|
|
|
|
{
|
|
|
|
char b[BINLOG_CHECKSUM_LEN];
|
2015-09-02 17:03:19 +02:00
|
|
|
ha_checksum crc= my_checksum(0, (uchar*) header, sizeof(header));
|
2011-12-14 12:02:03 +01:00
|
|
|
crc= my_checksum(crc, (uchar*) p, ident_len);
|
|
|
|
int4store(b, crc);
|
|
|
|
packet->append(b, sizeof(b));
|
|
|
|
}
|
|
|
|
|
2009-09-29 13:16:23 +02:00
|
|
|
if (my_net_write(net, (uchar*) packet->ptr(), packet->length()) ||
|
|
|
|
net_flush(net))
|
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
2009-09-29 13:16:23 +02:00
|
|
|
DBUG_RETURN(-1);
|
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2009-09-29 13:16:23 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
2012-01-20 01:57:58 +01:00
|
|
|
|
2012-11-15 13:11:35 +01:00
|
|
|
struct binlog_file_entry
|
|
|
|
{
|
|
|
|
binlog_file_entry *next;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
static binlog_file_entry *
|
|
|
|
get_binlog_list(MEM_ROOT *memroot)
|
|
|
|
{
|
|
|
|
IO_CACHE *index_file;
|
|
|
|
char fname[FN_REFLEN];
|
|
|
|
size_t length;
|
|
|
|
binlog_file_entry *current_list= NULL, *e;
|
|
|
|
DBUG_ENTER("get_binlog_list");
|
|
|
|
|
|
|
|
if (!mysql_bin_log.is_open())
|
|
|
|
{
|
|
|
|
my_error(ER_NO_BINARY_LOGGING, MYF(0));
|
|
|
|
DBUG_RETURN(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
mysql_bin_log.lock_index();
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
--length; /* Remove the newline */
|
|
|
|
if (!(e= (binlog_file_entry *)alloc_root(memroot, sizeof(*e))) ||
|
|
|
|
!(e->name= strmake_root(memroot, fname, length)))
|
|
|
|
{
|
|
|
|
mysql_bin_log.unlock_index();
|
|
|
|
my_error(ER_OUTOFMEMORY, MYF(0), length + 1 + sizeof(*e));
|
|
|
|
DBUG_RETURN(NULL);
|
|
|
|
}
|
|
|
|
e->next= current_list;
|
|
|
|
current_list= e;
|
|
|
|
}
|
|
|
|
mysql_bin_log.unlock_index();
|
|
|
|
|
|
|
|
DBUG_RETURN(current_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Find the Gtid_list_log_event at the start of a binlog.
|
|
|
|
|
|
|
|
NULL for ok, non-NULL error message for error.
|
|
|
|
|
|
|
|
If ok, then the event is returned in *out_gtid_list. This can be NULL if we
|
|
|
|
get back to binlogs written by old server version without GTID support. If
|
|
|
|
so, it means we have reached the point to start from, as no GTID events can
|
|
|
|
exist in earlier binlogs.
|
|
|
|
*/
|
|
|
|
static const char *
|
|
|
|
get_gtid_list_event(IO_CACHE *cache, Gtid_list_log_event **out_gtid_list)
|
|
|
|
{
|
|
|
|
Format_description_log_event init_fdle(BINLOG_VERSION);
|
|
|
|
Format_description_log_event *fdle;
|
|
|
|
Log_event *ev;
|
|
|
|
const char *errormsg = NULL;
|
|
|
|
|
|
|
|
*out_gtid_list= NULL;
|
|
|
|
|
|
|
|
if (!(ev= Log_event::read_log_event(cache, 0, &init_fdle,
|
|
|
|
opt_master_verify_checksum)) ||
|
|
|
|
ev->get_type_code() != FORMAT_DESCRIPTION_EVENT)
|
2013-02-11 16:44:38 +01:00
|
|
|
{
|
|
|
|
if (ev)
|
|
|
|
delete ev;
|
2012-11-15 13:11:35 +01:00
|
|
|
return "Could not read format description log event while looking for "
|
|
|
|
"GTID position in binlog";
|
2013-02-11 16:44:38 +01:00
|
|
|
}
|
2012-11-15 13:11:35 +01:00
|
|
|
|
|
|
|
fdle= static_cast<Format_description_log_event *>(ev);
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
Log_event_type typ;
|
|
|
|
|
|
|
|
ev= Log_event::read_log_event(cache, 0, fdle, opt_master_verify_checksum);
|
|
|
|
if (!ev)
|
|
|
|
{
|
|
|
|
errormsg= "Could not read GTID list event while looking for GTID "
|
|
|
|
"position in binlog";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
typ= ev->get_type_code();
|
|
|
|
if (typ == GTID_LIST_EVENT)
|
|
|
|
break; /* Done, found it */
|
2015-09-02 09:58:08 +02:00
|
|
|
if (typ == START_ENCRYPTION_EVENT)
|
|
|
|
{
|
|
|
|
if (fdle->start_decryption((Start_encryption_log_event*) ev))
|
|
|
|
errormsg= "Could not set up decryption for binlog.";
|
|
|
|
}
|
2013-02-19 14:22:29 +01:00
|
|
|
delete ev;
|
2012-11-15 13:11:35 +01:00
|
|
|
if (typ == ROTATE_EVENT || typ == STOP_EVENT ||
|
2015-09-02 09:58:08 +02:00
|
|
|
typ == FORMAT_DESCRIPTION_EVENT || typ == START_ENCRYPTION_EVENT)
|
2012-11-15 13:11:35 +01:00
|
|
|
continue; /* Continue looking */
|
|
|
|
|
|
|
|
/* We did not find any Gtid_list_log_event, must be old binlog. */
|
|
|
|
ev= NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete fdle;
|
|
|
|
*out_gtid_list= static_cast<Gtid_list_log_event *>(ev);
|
|
|
|
return errormsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Check if every GTID requested by the slave is contained in this (or a later)
|
|
|
|
binlog file. Return true if so, false if not.
|
2013-03-18 15:09:36 +01:00
|
|
|
|
|
|
|
We do the check with a single scan of the list of GTIDs, avoiding the need
|
|
|
|
to build an in-memory hash or stuff like that.
|
|
|
|
|
|
|
|
We need to check that slave did not request GTID D-S-N1, when the
|
2013-05-03 11:27:29 +02:00
|
|
|
Gtid_list_log_event for this binlog file has D-S-N2 with N2 >= N1.
|
|
|
|
(Because this means that requested GTID is in an earlier binlog).
|
|
|
|
However, if the Gtid_list_log_event indicates that D-S-N1 is the very last
|
|
|
|
GTID for domain D in prior binlog files, then it is ok to start from the
|
|
|
|
very start of this binlog file. This special case is important, as it
|
|
|
|
allows to purge old logs even if some domain is unused for long.
|
2013-03-18 15:09:36 +01:00
|
|
|
|
|
|
|
In addition, we need to check that we do not have a GTID D-S-N3 in the
|
|
|
|
Gtid_list_log_event where D is not present in the requested slave state at
|
|
|
|
all. Since if D is not in requested slave state, it means that slave needs
|
|
|
|
to start at the very first GTID in domain D.
|
2012-11-15 13:11:35 +01:00
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
contains_all_slave_gtid(slave_connection_state *st, Gtid_list_log_event *glev)
|
|
|
|
{
|
|
|
|
uint32 i;
|
|
|
|
|
|
|
|
for (i= 0; i < glev->count; ++i)
|
|
|
|
{
|
2013-05-03 11:27:29 +02:00
|
|
|
uint32 gl_domain_id= glev->list[i].domain_id;
|
|
|
|
const rpl_gtid *gtid= st->find(gl_domain_id);
|
2013-03-18 15:09:36 +01:00
|
|
|
if (!gtid)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
The slave needs to start from the very beginning of this domain, which
|
|
|
|
is in an earlier binlog file. So we need to search back further.
|
|
|
|
*/
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (gtid->server_id == glev->list[i].server_id &&
|
2013-05-03 11:27:29 +02:00
|
|
|
gtid->seq_no <= glev->list[i].seq_no)
|
2012-11-15 13:11:35 +01:00
|
|
|
{
|
|
|
|
/*
|
2013-05-03 11:27:29 +02:00
|
|
|
The slave needs to start after gtid, but it is contained in an earlier
|
|
|
|
binlog file. So we need to search back further, unless it was the very
|
|
|
|
last gtid logged for the domain in earlier binlog files.
|
2012-11-15 13:11:35 +01:00
|
|
|
*/
|
2013-05-03 11:27:29 +02:00
|
|
|
if (gtid->seq_no < glev->list[i].seq_no)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
The slave requested D-S-N1, which happens to be the last GTID logged
|
|
|
|
in prior binlog files with same domain id D and server id S.
|
|
|
|
|
|
|
|
The Gtid_list is kept sorted on domain_id, with the last GTID in each
|
|
|
|
domain_id group being the last one logged. So if this is the last GTID
|
|
|
|
within the domain_id group, then it is ok to start from the very
|
|
|
|
beginning of this group, per the special case explained in comment at
|
|
|
|
the start of this function. If not, then we need to search back further.
|
|
|
|
*/
|
|
|
|
if (i+1 < glev->count && gl_domain_id == glev->list[i+1].domain_id)
|
|
|
|
return false;
|
2012-11-15 13:11:35 +01:00
|
|
|
}
|
|
|
|
}
|
2013-03-18 15:09:36 +01:00
|
|
|
|
2012-11-15 13:11:35 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-16 15:10:25 +02:00
|
|
|
static void
|
|
|
|
give_error_start_pos_missing_in_binlog(int *err, const char **errormsg,
|
|
|
|
rpl_gtid *error_gtid)
|
|
|
|
{
|
|
|
|
rpl_gtid binlog_gtid;
|
|
|
|
|
|
|
|
if (mysql_bin_log.lookup_domain_in_binlog_state(error_gtid->domain_id,
|
|
|
|
&binlog_gtid) &&
|
|
|
|
binlog_gtid.seq_no >= error_gtid->seq_no)
|
|
|
|
{
|
|
|
|
*errormsg= "Requested slave GTID state not found in binlog. The slave has "
|
2015-03-16 10:54:47 +01:00
|
|
|
"probably diverged due to executing erroneous transactions";
|
2013-08-16 15:10:25 +02:00
|
|
|
*err= ER_GTID_POSITION_NOT_FOUND_IN_BINLOG2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*errormsg= "Requested slave GTID state not found in binlog";
|
|
|
|
*err= ER_GTID_POSITION_NOT_FOUND_IN_BINLOG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-18 15:09:36 +01:00
|
|
|
/*
|
|
|
|
Check the start GTID state requested by the slave against our binlog state.
|
|
|
|
|
|
|
|
Give an error if the slave requests something that we do not have in our
|
|
|
|
binlog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
2014-03-09 10:27:38 +01:00
|
|
|
check_slave_start_position(binlog_send_info *info, const char **errormsg,
|
|
|
|
rpl_gtid *error_gtid)
|
2013-03-18 15:09:36 +01:00
|
|
|
{
|
|
|
|
uint32 i;
|
|
|
|
int err;
|
2013-08-16 15:10:25 +02:00
|
|
|
slave_connection_state::entry **delete_list= NULL;
|
2013-03-18 15:09:36 +01:00
|
|
|
uint32 delete_idx= 0;
|
2014-03-09 10:27:38 +01:00
|
|
|
slave_connection_state *st= &info->gtid_state;
|
2013-08-16 15:10:25 +02:00
|
|
|
|
2014-03-09 10:27:38 +01:00
|
|
|
if (rpl_load_gtid_slave_state(info->thd))
|
2013-08-16 15:10:25 +02:00
|
|
|
{
|
|
|
|
*errormsg= "Failed to load replication slave GTID state";
|
|
|
|
err= ER_CANNOT_LOAD_SLAVE_GTID_STATE;
|
|
|
|
goto end;
|
|
|
|
}
|
2013-03-18 15:09:36 +01:00
|
|
|
|
|
|
|
for (i= 0; i < st->hash.records; ++i)
|
|
|
|
{
|
2013-08-16 15:10:25 +02:00
|
|
|
slave_connection_state::entry *slave_gtid_entry=
|
|
|
|
(slave_connection_state::entry *)my_hash_element(&st->hash, i);
|
|
|
|
rpl_gtid *slave_gtid= &slave_gtid_entry->gtid;
|
2013-03-18 15:09:36 +01:00
|
|
|
rpl_gtid master_gtid;
|
|
|
|
rpl_gtid master_replication_gtid;
|
|
|
|
rpl_gtid start_gtid;
|
2013-08-16 15:10:25 +02:00
|
|
|
bool start_at_own_slave_pos=
|
2015-11-29 16:51:23 +01:00
|
|
|
rpl_global_gtid_slave_state->domain_to_gtid(slave_gtid->domain_id,
|
|
|
|
&master_replication_gtid) &&
|
2013-08-16 15:10:25 +02:00
|
|
|
slave_gtid->server_id == master_replication_gtid.server_id &&
|
|
|
|
slave_gtid->seq_no == master_replication_gtid.seq_no;
|
2013-03-18 15:09:36 +01:00
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
if (mysql_bin_log.find_in_binlog_state(slave_gtid->domain_id,
|
|
|
|
slave_gtid->server_id,
|
|
|
|
&master_gtid) &&
|
2013-03-18 15:09:36 +01:00
|
|
|
master_gtid.seq_no >= slave_gtid->seq_no)
|
|
|
|
{
|
2013-08-16 15:10:25 +02:00
|
|
|
/*
|
|
|
|
If connecting slave requests to start at the GTID we last applied when
|
|
|
|
we were ourselves a slave, then this GTID may not exist in our binlog
|
|
|
|
(in case of --log-slave-updates=0). So set the flag to disable the
|
|
|
|
error about missing GTID in the binlog in this case.
|
|
|
|
*/
|
|
|
|
if (start_at_own_slave_pos)
|
|
|
|
slave_gtid_entry->flags|= slave_connection_state::START_OWN_SLAVE_POS;
|
|
|
|
continue;
|
2013-03-18 15:09:36 +01:00
|
|
|
}
|
|
|
|
|
2013-08-16 15:10:25 +02:00
|
|
|
if (!start_at_own_slave_pos)
|
2013-03-18 15:09:36 +01:00
|
|
|
{
|
|
|
|
rpl_gtid domain_gtid;
|
2014-03-09 10:27:38 +01:00
|
|
|
slave_connection_state *until_gtid_state= info->until_gtid_state;
|
2013-05-15 19:52:21 +02:00
|
|
|
rpl_gtid *until_gtid;
|
2013-03-18 15:09:36 +01:00
|
|
|
|
|
|
|
if (!mysql_bin_log.lookup_domain_in_binlog_state(slave_gtid->domain_id,
|
|
|
|
&domain_gtid))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
We do not have anything in this domain, neither in the binlog nor
|
|
|
|
in the slave state. So we are probably one master in a multi-master
|
|
|
|
setup, and this domain is served by a different master.
|
2013-08-16 15:10:25 +02:00
|
|
|
|
|
|
|
But set a flag so that if we then ever _do_ happen to encounter
|
|
|
|
anything in this domain, then we will re-check that the requested
|
|
|
|
slave position exists, and give the error at that time if not.
|
2013-03-18 15:09:36 +01:00
|
|
|
*/
|
2013-08-16 15:10:25 +02:00
|
|
|
slave_gtid_entry->flags|= slave_connection_state::START_ON_EMPTY_DOMAIN;
|
2013-03-18 15:09:36 +01:00
|
|
|
continue;
|
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
|
2014-03-09 10:27:38 +01:00
|
|
|
if (info->slave_gtid_ignore_duplicates &&
|
|
|
|
domain_gtid.seq_no < slave_gtid->seq_no)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
When --gtid-ignore-duplicates, it is ok for the slave to request
|
|
|
|
something that we do not have (yet) - they might already have gotten
|
|
|
|
it through another path in a multi-path replication hierarchy.
|
|
|
|
*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
if (until_gtid_state &&
|
|
|
|
( !(until_gtid= until_gtid_state->find(slave_gtid->domain_id)) ||
|
|
|
|
(mysql_bin_log.find_in_binlog_state(until_gtid->domain_id,
|
|
|
|
until_gtid->server_id,
|
|
|
|
&master_gtid) &&
|
|
|
|
master_gtid.seq_no >= until_gtid->seq_no)))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
The slave requested to start from a position that is not (yet) in
|
|
|
|
our binlog, but it also specified an UNTIL condition that _is_ in
|
|
|
|
our binlog (or a missing UNTIL, which means stop at the very
|
|
|
|
beginning). So the stop position is before the start position, and
|
|
|
|
we just delete the entry from the UNTIL hash to mark that this
|
|
|
|
domain has already reached the UNTIL condition.
|
|
|
|
*/
|
|
|
|
if(until_gtid)
|
|
|
|
until_gtid_state->remove(until_gtid);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-03-18 15:09:36 +01:00
|
|
|
*error_gtid= *slave_gtid;
|
2013-08-16 15:10:25 +02:00
|
|
|
give_error_start_pos_missing_in_binlog(&err, errormsg, error_gtid);
|
2013-03-18 15:09:36 +01:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Ok, so connecting slave asked to start at a GTID that we do not have in
|
|
|
|
our binlog, but it was in fact the last GTID we applied earlier, when we
|
|
|
|
were acting as a replication slave.
|
|
|
|
|
|
|
|
So this means that we were running as a replication slave without
|
|
|
|
--log-slave-updates, but now we switched to be a master. It is worth it
|
|
|
|
to handle this special case, as it allows users to run a simple
|
|
|
|
master -> slave without --log-slave-updates, and then exchange slave and
|
|
|
|
master, as long as they make sure the slave is caught up before switching.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
First check if we logged something ourselves as a master after being a
|
|
|
|
slave. This will be seen as a GTID with our own server_id and bigger
|
|
|
|
seq_no than what is in the slave state.
|
|
|
|
|
|
|
|
If we did not log anything ourselves, then start the connecting slave
|
|
|
|
replicating from the current binlog end position, which in this case
|
|
|
|
corresponds to our replication slave state and hence what the connecting
|
|
|
|
slave is requesting.
|
|
|
|
*/
|
|
|
|
if (mysql_bin_log.find_in_binlog_state(slave_gtid->domain_id,
|
|
|
|
global_system_variables.server_id,
|
|
|
|
&start_gtid) &&
|
|
|
|
start_gtid.seq_no > slave_gtid->seq_no)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Start replication within this domain at the first GTID that we logged
|
|
|
|
ourselves after becoming a master.
|
2013-07-10 11:45:15 +02:00
|
|
|
|
|
|
|
Remember that this starting point is in fact a "fake" GTID which may
|
|
|
|
not exists in the binlog, so that we do not complain about it in
|
|
|
|
--gtid-strict-mode.
|
2013-03-18 15:09:36 +01:00
|
|
|
*/
|
|
|
|
slave_gtid->server_id= global_system_variables.server_id;
|
2013-08-16 15:10:25 +02:00
|
|
|
slave_gtid_entry->flags|= slave_connection_state::START_OWN_SLAVE_POS;
|
2013-03-18 15:09:36 +01:00
|
|
|
}
|
|
|
|
else if (mysql_bin_log.lookup_domain_in_binlog_state(slave_gtid->domain_id,
|
|
|
|
&start_gtid))
|
|
|
|
{
|
|
|
|
slave_gtid->server_id= start_gtid.server_id;
|
|
|
|
slave_gtid->seq_no= start_gtid.seq_no;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
We do not have _anything_ in our own binlog for this domain. Just
|
|
|
|
delete the entry in the slave connection state, then it will pick up
|
|
|
|
anything new that arrives.
|
|
|
|
|
|
|
|
We just queue up the deletion and do it later, after the loop, so that
|
|
|
|
we do not mess up the iteration over the hash.
|
|
|
|
*/
|
|
|
|
if (!delete_list)
|
|
|
|
{
|
2013-08-16 15:10:25 +02:00
|
|
|
if (!(delete_list= (slave_connection_state::entry **)
|
2013-07-10 12:01:52 +02:00
|
|
|
my_malloc(sizeof(*delete_list) * st->hash.records, MYF(MY_WME))))
|
2013-03-18 15:09:36 +01:00
|
|
|
{
|
|
|
|
*errormsg= "Out of memory while checking slave start position";
|
|
|
|
err= ER_OUT_OF_RESOURCES;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
2013-08-16 15:10:25 +02:00
|
|
|
delete_list[delete_idx++]= slave_gtid_entry;
|
2013-03-18 15:09:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do any delayed deletes from the hash. */
|
|
|
|
if (delete_list)
|
|
|
|
{
|
|
|
|
for (i= 0; i < delete_idx; ++i)
|
2013-08-16 15:10:25 +02:00
|
|
|
st->remove(&(delete_list[i]->gtid));
|
2013-03-18 15:09:36 +01:00
|
|
|
}
|
|
|
|
err= 0;
|
|
|
|
|
|
|
|
end:
|
|
|
|
if (delete_list)
|
|
|
|
my_free(delete_list);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-11-15 13:11:35 +01:00
|
|
|
/*
|
|
|
|
Find the name of the binlog file to start reading for a slave that connects
|
|
|
|
using GTID state.
|
|
|
|
|
|
|
|
Returns the file name in out_name, which must be of size at least FN_REFLEN.
|
|
|
|
|
|
|
|
Returns NULL on ok, error message on error.
|
2013-03-27 12:29:02 +01:00
|
|
|
|
|
|
|
In case of non-error return, the returned binlog file is guaranteed to
|
|
|
|
contain the first event to be transmitted to the slave for every domain
|
|
|
|
present in our binlogs. It is still necessary to skip all GTIDs up to
|
|
|
|
and including the GTID requested by slave within each domain.
|
|
|
|
|
|
|
|
However, as a special case, if the event to be sent to the slave is the very
|
|
|
|
first event (within that domain) in the returned binlog, then nothing should
|
|
|
|
be skipped, so that domain is deleted from the passed in slave connection
|
|
|
|
state.
|
|
|
|
|
|
|
|
This is necessary in case the slave requests a GTID within a replication
|
|
|
|
domain that has long been inactive. The binlog file containing that GTID may
|
|
|
|
have been long since purged. However, as long as no GTIDs after that have
|
|
|
|
been purged, we have the GTID requested by slave in the Gtid_list_log_event
|
|
|
|
of the latest binlog. So we can start from there, as long as we delete the
|
|
|
|
corresponding entry in the slave state so we do not wrongly skip any events
|
|
|
|
that might turn up if that domain becomes active again, vainly looking for
|
|
|
|
the requested GTID that was already purged.
|
2012-11-15 13:11:35 +01:00
|
|
|
*/
|
|
|
|
static const char *
|
2013-05-15 19:52:21 +02:00
|
|
|
gtid_find_binlog_file(slave_connection_state *state, char *out_name,
|
|
|
|
slave_connection_state *until_gtid_state)
|
2012-11-15 13:11:35 +01:00
|
|
|
{
|
|
|
|
MEM_ROOT memroot;
|
|
|
|
binlog_file_entry *list;
|
2013-02-22 10:23:17 +01:00
|
|
|
Gtid_list_log_event *glev= NULL;
|
2012-11-15 13:11:35 +01:00
|
|
|
const char *errormsg= NULL;
|
|
|
|
char buf[FN_REFLEN];
|
|
|
|
|
2013-03-14 10:39:16 +01:00
|
|
|
init_alloc_root(&memroot, 10*(FN_REFLEN+sizeof(binlog_file_entry)), 0,
|
|
|
|
MYF(MY_THREAD_SPECIFIC));
|
2012-11-15 13:11:35 +01:00
|
|
|
if (!(list= get_binlog_list(&memroot)))
|
|
|
|
{
|
|
|
|
errormsg= "Out of memory while looking for GTID position in binlog";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
2013-03-27 16:06:45 +01:00
|
|
|
File file;
|
|
|
|
IO_CACHE cache;
|
|
|
|
|
2012-11-15 13:11:35 +01:00
|
|
|
if (!list->next)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
It should be safe to read the currently used binlog, as we will only
|
|
|
|
read the header part that is already written.
|
|
|
|
|
|
|
|
But if that does not work on windows, then we will need to cache the
|
|
|
|
event somewhere in memory I suppose - that could work too.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
Read the Gtid_list_log_event at the start of the binlog file to
|
|
|
|
get the binlog state.
|
|
|
|
*/
|
|
|
|
if (normalize_binlog_name(buf, list->name, false))
|
|
|
|
{
|
|
|
|
errormsg= "Failed to determine binlog file name while looking for "
|
|
|
|
"GTID position in binlog";
|
|
|
|
goto end;
|
|
|
|
}
|
2013-03-27 16:06:45 +01:00
|
|
|
bzero((char*) &cache, sizeof(cache));
|
|
|
|
if ((file= open_binlog(&cache, buf, &errormsg)) == (File)-1)
|
|
|
|
goto end;
|
|
|
|
errormsg= get_gtid_list_event(&cache, &glev);
|
|
|
|
end_io_cache(&cache);
|
|
|
|
mysql_file_close(file, MYF(MY_WME));
|
|
|
|
if (errormsg)
|
2012-11-15 13:11:35 +01:00
|
|
|
goto end;
|
|
|
|
|
|
|
|
if (!glev || contains_all_slave_gtid(state, glev))
|
|
|
|
{
|
|
|
|
strmake(out_name, buf, FN_REFLEN);
|
2013-03-27 12:29:02 +01:00
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
if (glev)
|
2013-03-27 12:29:02 +01:00
|
|
|
{
|
2013-05-15 19:52:21 +02:00
|
|
|
uint32 i;
|
2013-05-03 11:27:29 +02:00
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
/*
|
|
|
|
As a special case, we allow to start from binlog file N if the
|
|
|
|
requested GTID is the last event (in the corresponding domain) in
|
|
|
|
binlog file (N-1), but then we need to remove that GTID from the slave
|
|
|
|
state, rather than skipping events waiting for it to turn up.
|
|
|
|
|
|
|
|
If slave is doing START SLAVE UNTIL, check for any UNTIL conditions
|
|
|
|
that are already included in a previous binlog file. Delete any such
|
|
|
|
from the UNTIL hash, to mark that such domains have already reached
|
|
|
|
their UNTIL condition.
|
|
|
|
*/
|
|
|
|
for (i= 0; i < glev->count; ++i)
|
2013-03-27 12:29:02 +01:00
|
|
|
{
|
2013-05-15 19:52:21 +02:00
|
|
|
const rpl_gtid *gtid= state->find(glev->list[i].domain_id);
|
|
|
|
if (!gtid)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Contains_all_slave_gtid() returns false if there is any domain in
|
|
|
|
Gtid_list_event which is not in the requested slave position.
|
|
|
|
|
|
|
|
We may delete a domain from the slave state inside this loop, but
|
|
|
|
we only do this when it is the very last GTID logged for that
|
|
|
|
domain in earlier binlogs, and then we can not encounter it in any
|
|
|
|
further GTIDs in the Gtid_list.
|
|
|
|
*/
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
} else if (gtid->server_id == glev->list[i].server_id &&
|
|
|
|
gtid->seq_no == glev->list[i].seq_no)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
The slave requested to start from the very beginning of this
|
|
|
|
domain in this binlog file. So delete the entry from the state,
|
|
|
|
we do not need to skip anything.
|
|
|
|
*/
|
|
|
|
state->remove(gtid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (until_gtid_state &&
|
|
|
|
(gtid= until_gtid_state->find(glev->list[i].domain_id)) &&
|
|
|
|
gtid->server_id == glev->list[i].server_id &&
|
|
|
|
gtid->seq_no <= glev->list[i].seq_no)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
We've already reached the stop position in UNTIL for this domain,
|
|
|
|
since it is before the start position.
|
|
|
|
*/
|
|
|
|
until_gtid_state->remove(gtid);
|
|
|
|
}
|
2013-03-27 12:29:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-15 13:11:35 +01:00
|
|
|
goto end;
|
|
|
|
}
|
2013-02-22 10:23:17 +01:00
|
|
|
delete glev;
|
|
|
|
glev= NULL;
|
2012-11-15 13:11:35 +01:00
|
|
|
list= list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We reached the end without finding anything. */
|
|
|
|
errormsg= "Could not find GTID state requested by slave in any binlog "
|
|
|
|
"files. Probably the slave state is too old and required binlog files "
|
|
|
|
"have been purged.";
|
|
|
|
|
|
|
|
end:
|
2013-02-22 10:23:17 +01:00
|
|
|
if (glev)
|
|
|
|
delete glev;
|
2012-11-15 13:11:35 +01:00
|
|
|
|
|
|
|
free_root(&memroot, MYF(0));
|
|
|
|
return errormsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-11 16:44:38 +01:00
|
|
|
/*
|
|
|
|
Given an old-style binlog position with file name and file offset, find the
|
|
|
|
corresponding gtid position. If the offset is not at an event boundary, give
|
|
|
|
an error.
|
|
|
|
|
|
|
|
Return NULL on ok, error message string on error.
|
|
|
|
|
|
|
|
ToDo: Improve the performance of this by using binlog index files.
|
|
|
|
*/
|
|
|
|
static const char *
|
|
|
|
gtid_state_from_pos(const char *name, uint32 offset,
|
|
|
|
slave_connection_state *gtid_state)
|
|
|
|
{
|
|
|
|
IO_CACHE cache;
|
|
|
|
File file;
|
|
|
|
const char *errormsg= NULL;
|
|
|
|
bool found_gtid_list_event= false;
|
|
|
|
bool found_format_description_event= false;
|
|
|
|
bool valid_pos= false;
|
2015-08-30 15:03:55 +02:00
|
|
|
enum enum_binlog_checksum_alg current_checksum_alg= BINLOG_CHECKSUM_ALG_UNDEF;
|
2013-02-11 16:44:38 +01:00
|
|
|
int err;
|
|
|
|
String packet;
|
2013-09-04 12:22:09 +02:00
|
|
|
Format_description_log_event *fdev= NULL;
|
2013-02-11 16:44:38 +01:00
|
|
|
|
|
|
|
if (gtid_state->load((const rpl_gtid *)NULL, 0))
|
|
|
|
{
|
|
|
|
errormsg= "Internal error (out of memory?) initializing slave state "
|
|
|
|
"while scanning binlog to find start position";
|
|
|
|
return errormsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((file= open_binlog(&cache, name, &errormsg)) == (File)-1)
|
|
|
|
return errormsg;
|
|
|
|
|
2013-09-04 12:22:09 +02:00
|
|
|
if (!(fdev= new Format_description_log_event(3)))
|
|
|
|
{
|
|
|
|
errormsg= "Out of memory initializing format_description event "
|
|
|
|
"while scanning binlog to find start position";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2013-02-11 16:44:38 +01:00
|
|
|
/*
|
|
|
|
First we need to find the initial GTID_LIST_EVENT. We need this even
|
|
|
|
if the offset is at the very start of the binlog file.
|
|
|
|
|
|
|
|
But if we do not find any GTID_LIST_EVENT, then this is an old binlog
|
|
|
|
with no GTID information, so we return empty GTID state.
|
|
|
|
*/
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
Log_event_type typ;
|
|
|
|
uint32 cur_pos;
|
|
|
|
|
|
|
|
cur_pos= (uint32)my_b_tell(&cache);
|
|
|
|
if (cur_pos == offset)
|
|
|
|
valid_pos= true;
|
|
|
|
if (found_format_description_event && found_gtid_list_event &&
|
|
|
|
cur_pos >= offset)
|
|
|
|
break;
|
|
|
|
|
|
|
|
packet.length(0);
|
2015-09-02 09:58:08 +02:00
|
|
|
err= Log_event::read_log_event(&cache, &packet, fdev,
|
2015-08-30 15:03:55 +02:00
|
|
|
opt_master_verify_checksum ? current_checksum_alg
|
|
|
|
: BINLOG_CHECKSUM_ALG_OFF);
|
2013-02-11 16:44:38 +01:00
|
|
|
if (err)
|
|
|
|
{
|
|
|
|
errormsg= "Could not read binlog while searching for slave start "
|
|
|
|
"position on master";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
The cast to uchar is needed to avoid a signed char being converted to a
|
|
|
|
negative number.
|
|
|
|
*/
|
|
|
|
typ= (Log_event_type)(uchar)packet[EVENT_TYPE_OFFSET];
|
|
|
|
if (typ == FORMAT_DESCRIPTION_EVENT)
|
|
|
|
{
|
2013-09-04 12:22:09 +02:00
|
|
|
Format_description_log_event *tmp;
|
|
|
|
|
2013-02-11 16:44:38 +01:00
|
|
|
if (found_format_description_event)
|
|
|
|
{
|
|
|
|
errormsg= "Duplicate format description log event found while "
|
|
|
|
"searching for old-style position in binlog";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
current_checksum_alg= get_checksum_alg(packet.ptr(), packet.length());
|
|
|
|
found_format_description_event= true;
|
2013-09-04 12:22:09 +02:00
|
|
|
if (!(tmp= new Format_description_log_event(packet.ptr(), packet.length(),
|
|
|
|
fdev)))
|
|
|
|
{
|
|
|
|
errormsg= "Corrupt Format_description event found or out-of-memory "
|
|
|
|
"while searching for old-style position in binlog";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
delete fdev;
|
|
|
|
fdev= tmp;
|
2013-02-11 16:44:38 +01:00
|
|
|
}
|
2015-09-02 09:58:08 +02:00
|
|
|
else if (typ == START_ENCRYPTION_EVENT)
|
|
|
|
{
|
|
|
|
uint sele_len = packet.length();
|
|
|
|
if (current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32)
|
|
|
|
{
|
|
|
|
sele_len -= BINLOG_CHECKSUM_LEN;
|
|
|
|
}
|
|
|
|
Start_encryption_log_event sele(packet.ptr(), sele_len, fdev);
|
|
|
|
if (fdev->start_decryption(&sele))
|
|
|
|
{
|
|
|
|
errormsg= "Could not start decryption of binlog.";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
2013-02-11 16:44:38 +01:00
|
|
|
else if (typ != FORMAT_DESCRIPTION_EVENT && !found_format_description_event)
|
|
|
|
{
|
|
|
|
errormsg= "Did not find format description log event while searching "
|
|
|
|
"for old-style position in binlog";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
else if (typ == ROTATE_EVENT || typ == STOP_EVENT ||
|
|
|
|
typ == BINLOG_CHECKPOINT_EVENT)
|
|
|
|
continue; /* Continue looking */
|
|
|
|
else if (typ == GTID_LIST_EVENT)
|
|
|
|
{
|
|
|
|
rpl_gtid *gtid_list;
|
|
|
|
bool status;
|
|
|
|
uint32 list_len;
|
|
|
|
|
|
|
|
if (found_gtid_list_event)
|
|
|
|
{
|
|
|
|
errormsg= "Found duplicate Gtid_list_log_event while scanning binlog "
|
|
|
|
"to find slave start position";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
status= Gtid_list_log_event::peek(packet.ptr(), packet.length(),
|
2013-05-15 19:52:21 +02:00
|
|
|
current_checksum_alg,
|
2013-09-04 12:22:09 +02:00
|
|
|
>id_list, &list_len, fdev);
|
2013-02-11 16:44:38 +01:00
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
errormsg= "Error reading Gtid_list_log_event while searching "
|
|
|
|
"for old-style position in binlog";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
err= gtid_state->load(gtid_list, list_len);
|
|
|
|
my_free(gtid_list);
|
|
|
|
if (err)
|
|
|
|
{
|
|
|
|
errormsg= "Internal error (out of memory?) initialising slave state "
|
|
|
|
"while scanning binlog to find start position";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
found_gtid_list_event= true;
|
|
|
|
}
|
|
|
|
else if (!found_gtid_list_event)
|
|
|
|
{
|
|
|
|
/* We did not find any Gtid_list_log_event, must be old binlog. */
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
else if (typ == GTID_EVENT)
|
|
|
|
{
|
|
|
|
rpl_gtid gtid;
|
|
|
|
uchar flags2;
|
2013-04-29 10:57:48 +02:00
|
|
|
if (Gtid_log_event::peek(packet.ptr(), packet.length(),
|
|
|
|
current_checksum_alg, >id.domain_id,
|
2013-09-04 12:22:09 +02:00
|
|
|
>id.server_id, >id.seq_no, &flags2, fdev))
|
2013-02-11 16:44:38 +01:00
|
|
|
{
|
|
|
|
errormsg= "Corrupt gtid_log_event found while scanning binlog to find "
|
|
|
|
"initial slave position";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
if (gtid_state->update(>id))
|
|
|
|
{
|
|
|
|
errormsg= "Internal error (out of memory?) updating slave state while "
|
|
|
|
"scanning binlog to find start position";
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!valid_pos)
|
|
|
|
{
|
|
|
|
errormsg= "Slave requested incorrect position in master binlog. "
|
|
|
|
"Requested position %u in file '%s', but this position does not "
|
|
|
|
"correspond to the location of any binlog event.";
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2013-09-04 12:22:09 +02:00
|
|
|
delete fdev;
|
2013-02-11 16:44:38 +01:00
|
|
|
end_io_cache(&cache);
|
|
|
|
mysql_file_close(file, MYF(MY_WME));
|
|
|
|
|
|
|
|
return errormsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2013-02-13 13:36:46 +01:00
|
|
|
gtid_state_from_binlog_pos(const char *in_name, uint32 pos, String *out_str)
|
2013-02-11 16:44:38 +01:00
|
|
|
{
|
|
|
|
slave_connection_state gtid_state;
|
2013-02-13 13:36:46 +01:00
|
|
|
const char *lookup_name;
|
|
|
|
char name_buf[FN_REFLEN];
|
|
|
|
LOG_INFO linfo;
|
|
|
|
|
2013-02-21 14:46:11 +01:00
|
|
|
if (!mysql_bin_log.is_open())
|
|
|
|
{
|
|
|
|
my_error(ER_NO_BINARY_LOGGING, MYF(0));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-02-13 13:36:46 +01:00
|
|
|
if (in_name && in_name[0])
|
|
|
|
{
|
|
|
|
mysql_bin_log.make_log_name(name_buf, in_name);
|
|
|
|
lookup_name= name_buf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
lookup_name= NULL;
|
|
|
|
linfo.index_file_offset= 0;
|
|
|
|
if (mysql_bin_log.find_log_pos(&linfo, lookup_name, 1))
|
|
|
|
return 1;
|
2013-02-11 16:44:38 +01:00
|
|
|
|
|
|
|
if (pos < 4)
|
|
|
|
pos= 4;
|
2013-02-13 13:36:46 +01:00
|
|
|
|
|
|
|
if (gtid_state_from_pos(linfo.log_file_name, pos, >id_state) ||
|
2013-02-11 16:44:38 +01:00
|
|
|
gtid_state.to_string(out_str))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
static bool
|
2014-03-09 10:27:38 +01:00
|
|
|
is_until_reached(binlog_send_info *info, ulong *ev_offset,
|
|
|
|
Log_event_type event_type, const char **errmsg,
|
|
|
|
uint32 current_pos)
|
2013-05-15 19:52:21 +02:00
|
|
|
{
|
2014-03-09 10:27:38 +01:00
|
|
|
switch (info->gtid_until_group)
|
2013-05-15 19:52:21 +02:00
|
|
|
{
|
|
|
|
case GTID_UNTIL_NOT_DONE:
|
|
|
|
return false;
|
|
|
|
case GTID_UNTIL_STOP_AFTER_STANDALONE:
|
|
|
|
if (Log_event::is_part_of_group(event_type))
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case GTID_UNTIL_STOP_AFTER_TRANSACTION:
|
|
|
|
if (event_type != XID_EVENT &&
|
|
|
|
(event_type != QUERY_EVENT ||
|
2014-03-09 10:27:38 +01:00
|
|
|
!Query_log_event::peek_is_commit_rollback
|
|
|
|
(info->packet->ptr()+*ev_offset,
|
|
|
|
info->packet->length()-*ev_offset,
|
|
|
|
info->current_checksum_alg)))
|
2013-05-15 19:52:21 +02:00
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
The last event group has been sent, now the START SLAVE UNTIL condition
|
|
|
|
has been reached.
|
|
|
|
|
|
|
|
Send a last fake Gtid_list_log_event with a flag set to mark that we
|
|
|
|
stop due to UNTIL condition.
|
|
|
|
*/
|
2014-12-19 12:36:23 +01:00
|
|
|
if (reset_transmit_packet(info, info->flags, ev_offset, errmsg))
|
2013-05-15 19:52:21 +02:00
|
|
|
return true;
|
2014-03-09 10:27:38 +01:00
|
|
|
Gtid_list_log_event glev(&info->until_binlog_state,
|
2013-05-15 19:52:21 +02:00
|
|
|
Gtid_list_log_event::FLAG_UNTIL_REACHED);
|
2014-03-09 10:27:38 +01:00
|
|
|
if (fake_gtid_list_event(info, &glev, errmsg, current_pos))
|
2013-05-15 19:52:21 +02:00
|
|
|
return true;
|
|
|
|
*errmsg= NULL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-21 21:04:22 +02:00
|
|
|
/*
|
2011-08-11 11:38:52 +02:00
|
|
|
Helper function for mysql_binlog_send() to write an event down the slave
|
|
|
|
connection.
|
|
|
|
|
|
|
|
Returns NULL on success, error message string on error.
|
2002-08-21 21:04:22 +02:00
|
|
|
*/
|
2011-08-11 11:38:52 +02:00
|
|
|
static const char *
|
2014-03-09 10:27:38 +01:00
|
|
|
send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
|
|
|
|
IO_CACHE *log, ulong ev_offset, rpl_gtid *error_gtid)
|
2011-08-11 11:38:52 +02:00
|
|
|
{
|
2012-03-01 12:41:49 +01:00
|
|
|
my_off_t pos;
|
2014-03-09 10:27:38 +01:00
|
|
|
String* const packet= info->packet;
|
2013-02-22 12:31:55 +01:00
|
|
|
size_t len= packet->length();
|
2014-03-09 10:27:38 +01:00
|
|
|
int mariadb_slave_capability= info->mariadb_slave_capability;
|
2015-08-30 15:03:55 +02:00
|
|
|
enum enum_binlog_checksum_alg current_checksum_alg= info->current_checksum_alg;
|
2014-03-09 10:27:38 +01:00
|
|
|
slave_connection_state *gtid_state= &info->gtid_state;
|
|
|
|
slave_connection_state *until_gtid_state= info->until_gtid_state;
|
2012-03-01 12:41:49 +01:00
|
|
|
|
2014-03-09 10:27:38 +01:00
|
|
|
if (event_type == GTID_LIST_EVENT &&
|
|
|
|
info->using_gtid_state && until_gtid_state)
|
2013-05-15 19:52:21 +02:00
|
|
|
{
|
|
|
|
rpl_gtid *gtid_list;
|
|
|
|
uint32 list_len;
|
|
|
|
bool err;
|
|
|
|
|
|
|
|
if (ev_offset > len ||
|
|
|
|
Gtid_list_log_event::peek(packet->ptr()+ev_offset, len - ev_offset,
|
|
|
|
current_checksum_alg,
|
2014-03-09 10:27:38 +01:00
|
|
|
>id_list, &list_len, info->fdev))
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
2013-05-15 19:52:21 +02:00
|
|
|
return "Failed to read Gtid_list_log_event: corrupt binlog";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2014-03-09 10:27:38 +01:00
|
|
|
err= info->until_binlog_state.load(gtid_list, list_len);
|
2013-05-15 19:52:21 +02:00
|
|
|
my_free(gtid_list);
|
|
|
|
if (err)
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
2013-05-15 19:52:21 +02:00
|
|
|
return "Failed in internal GTID book-keeping: Out of memory";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
}
|
|
|
|
|
2012-11-15 13:11:35 +01:00
|
|
|
/* Skip GTID event groups until we reach slave position within a domain_id. */
|
2014-03-09 10:27:38 +01:00
|
|
|
if (event_type == GTID_EVENT && info->using_gtid_state)
|
2012-11-15 13:11:35 +01:00
|
|
|
{
|
|
|
|
uchar flags2;
|
2013-08-16 15:10:25 +02:00
|
|
|
slave_connection_state::entry *gtid_entry;
|
2012-11-15 13:11:35 +01:00
|
|
|
rpl_gtid *gtid;
|
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
if (gtid_state->count() > 0 || until_gtid_state)
|
2012-11-15 13:11:35 +01:00
|
|
|
{
|
2013-05-15 19:52:21 +02:00
|
|
|
rpl_gtid event_gtid;
|
|
|
|
|
|
|
|
if (ev_offset > len ||
|
|
|
|
Gtid_log_event::peek(packet->ptr()+ev_offset, len - ev_offset,
|
|
|
|
current_checksum_alg,
|
|
|
|
&event_gtid.domain_id, &event_gtid.server_id,
|
2014-03-09 10:27:38 +01:00
|
|
|
&event_gtid.seq_no, &flags2, info->fdev))
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
2013-05-15 19:52:21 +02:00
|
|
|
return "Failed to read Gtid_log_event: corrupt binlog";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
DBUG_EXECUTE_IF("gtid_force_reconnect_at_10_1_100",
|
|
|
|
{
|
|
|
|
rpl_gtid *dbug_gtid;
|
2014-03-09 10:27:38 +01:00
|
|
|
if ((dbug_gtid= info->until_binlog_state.find_nolock(10,1)) &&
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
dbug_gtid->seq_no == 100)
|
|
|
|
{
|
|
|
|
DBUG_SET("-d,gtid_force_reconnect_at_10_1_100");
|
|
|
|
DBUG_SET_INITIAL("-d,gtid_force_reconnect_at_10_1_100");
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
return "DBUG-injected forced reconnect";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-03-09 10:27:38 +01:00
|
|
|
if (info->until_binlog_state.update_nolock(&event_gtid, false))
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
2013-05-15 19:52:21 +02:00
|
|
|
return "Failed in internal GTID book-keeping: Out of memory";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
|
|
|
|
if (gtid_state->count() > 0)
|
|
|
|
{
|
2013-08-16 15:10:25 +02:00
|
|
|
gtid_entry= gtid_state->find_entry(event_gtid.domain_id);
|
|
|
|
if (gtid_entry != NULL)
|
2013-05-15 19:52:21 +02:00
|
|
|
{
|
2013-08-16 15:10:25 +02:00
|
|
|
gtid= >id_entry->gtid;
|
|
|
|
if (gtid_entry->flags & slave_connection_state::START_ON_EMPTY_DOMAIN)
|
|
|
|
{
|
|
|
|
rpl_gtid master_gtid;
|
|
|
|
if (!mysql_bin_log.find_in_binlog_state(gtid->domain_id,
|
|
|
|
gtid->server_id,
|
|
|
|
&master_gtid) ||
|
|
|
|
master_gtid.seq_no < gtid->seq_no)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
const char *errormsg;
|
|
|
|
*error_gtid= *gtid;
|
|
|
|
give_error_start_pos_missing_in_binlog(&err, &errormsg, error_gtid);
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= err;
|
2013-08-16 15:10:25 +02:00
|
|
|
return errormsg;
|
|
|
|
}
|
|
|
|
gtid_entry->flags&= ~(uint32)slave_connection_state::START_ON_EMPTY_DOMAIN;
|
|
|
|
}
|
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
/* Skip this event group if we have not yet reached slave start pos. */
|
|
|
|
if (event_gtid.server_id != gtid->server_id ||
|
|
|
|
event_gtid.seq_no <= gtid->seq_no)
|
2014-03-09 10:27:38 +01:00
|
|
|
info->gtid_skip_group= (flags2 & Gtid_log_event::FL_STANDALONE ?
|
2013-05-15 19:52:21 +02:00
|
|
|
GTID_SKIP_STANDALONE : GTID_SKIP_TRANSACTION);
|
|
|
|
if (event_gtid.server_id == gtid->server_id &&
|
|
|
|
event_gtid.seq_no >= gtid->seq_no)
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-03-09 10:27:38 +01:00
|
|
|
if (info->slave_gtid_strict_mode &&
|
|
|
|
event_gtid.seq_no > gtid->seq_no &&
|
2013-08-16 15:10:25 +02:00
|
|
|
!(gtid_entry->flags & slave_connection_state::START_OWN_SLAVE_POS))
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
/*
|
|
|
|
In strict mode, it is an error if the slave requests to start
|
|
|
|
in a "hole" in the master's binlog: a GTID that does not
|
|
|
|
exist, even though both the prior and subsequent seq_no exists
|
|
|
|
for same domain_id and server_id.
|
|
|
|
*/
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_GTID_START_FROM_BINLOG_HOLE;
|
2013-06-07 14:39:00 +02:00
|
|
|
*error_gtid= *gtid;
|
|
|
|
return "The binlog on the master is missing the GTID requested "
|
|
|
|
"by the slave (even though both a prior and a subsequent "
|
|
|
|
"sequence number does exist), and GTID strict mode is enabled.";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2013-06-07 14:39:00 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Send a fake Gtid_list event to the slave.
|
|
|
|
This allows the slave to update its current binlog position
|
|
|
|
so MASTER_POS_WAIT() and MASTER_GTID_WAIT() can work.
|
|
|
|
The fake event will be sent at the end of this event group.
|
|
|
|
*/
|
2014-03-09 10:27:38 +01:00
|
|
|
info->send_fake_gtid_list= true;
|
2013-06-07 14:39:00 +02:00
|
|
|
|
2013-05-28 13:28:31 +02:00
|
|
|
/*
|
|
|
|
Delete this entry if we have reached slave start position (so we
|
|
|
|
will not skip subsequent events and won't have to look them up
|
|
|
|
and check).
|
|
|
|
*/
|
2013-05-15 19:52:21 +02:00
|
|
|
gtid_state->remove(gtid);
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (until_gtid_state)
|
|
|
|
{
|
|
|
|
gtid= until_gtid_state->find(event_gtid.domain_id);
|
|
|
|
if (gtid == NULL)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
This domain already reached the START SLAVE UNTIL stop condition,
|
|
|
|
so skip this event group.
|
|
|
|
*/
|
2014-03-09 10:27:38 +01:00
|
|
|
info->gtid_skip_group = (flags2 & Gtid_log_event::FL_STANDALONE ?
|
2013-05-15 19:52:21 +02:00
|
|
|
GTID_SKIP_STANDALONE : GTID_SKIP_TRANSACTION);
|
|
|
|
}
|
|
|
|
else if (event_gtid.server_id == gtid->server_id &&
|
|
|
|
event_gtid.seq_no >= gtid->seq_no)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
We have reached the stop condition.
|
|
|
|
Delete this domain_id from the hash, so we will skip all further
|
|
|
|
events in this domain and eventually stop when all domains are
|
|
|
|
done.
|
|
|
|
*/
|
|
|
|
uint64 until_seq_no= gtid->seq_no;
|
|
|
|
until_gtid_state->remove(gtid);
|
|
|
|
if (until_gtid_state->count() == 0)
|
2014-03-09 10:27:38 +01:00
|
|
|
info->gtid_until_group= (flags2 & Gtid_log_event::FL_STANDALONE ?
|
|
|
|
GTID_UNTIL_STOP_AFTER_STANDALONE :
|
|
|
|
GTID_UNTIL_STOP_AFTER_TRANSACTION);
|
2013-05-15 19:52:21 +02:00
|
|
|
if (event_gtid.seq_no > until_seq_no)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
The GTID in START SLAVE UNTIL condition is missing in our binlog.
|
|
|
|
This should normally not happen (user error), but since we can be
|
|
|
|
sure that we are now beyond the position that the UNTIL condition
|
|
|
|
should be in, we can just stop now. And we also need to skip this
|
|
|
|
event group (as it is beyond the UNTIL condition).
|
|
|
|
*/
|
2014-03-09 10:27:38 +01:00
|
|
|
info->gtid_skip_group = (flags2 & Gtid_log_event::FL_STANDALONE ?
|
2013-05-15 19:52:21 +02:00
|
|
|
GTID_SKIP_STANDALONE : GTID_SKIP_TRANSACTION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-15 13:11:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Skip event group if we have not yet reached the correct slave GTID position.
|
|
|
|
|
|
|
|
Note that slave that understands GTID can also tolerate holes, so there is
|
|
|
|
no need to supply dummy event.
|
|
|
|
*/
|
2014-03-09 10:27:38 +01:00
|
|
|
switch (info->gtid_skip_group)
|
2012-11-15 13:11:35 +01:00
|
|
|
{
|
|
|
|
case GTID_SKIP_STANDALONE:
|
2013-03-21 11:03:31 +01:00
|
|
|
if (!Log_event::is_part_of_group(event_type))
|
2014-03-09 10:27:38 +01:00
|
|
|
info->gtid_skip_group= GTID_SKIP_NOT;
|
2012-11-15 13:11:35 +01:00
|
|
|
return NULL;
|
|
|
|
case GTID_SKIP_TRANSACTION:
|
2013-02-22 12:31:55 +01:00
|
|
|
if (event_type == XID_EVENT ||
|
|
|
|
(event_type == QUERY_EVENT &&
|
|
|
|
Query_log_event::peek_is_commit_rollback(packet->ptr() + ev_offset,
|
2013-04-29 10:57:48 +02:00
|
|
|
len - ev_offset,
|
|
|
|
current_checksum_alg)))
|
2014-03-09 10:27:38 +01:00
|
|
|
info->gtid_skip_group= GTID_SKIP_NOT;
|
2012-11-15 13:11:35 +01:00
|
|
|
return NULL;
|
|
|
|
case GTID_SKIP_NOT:
|
|
|
|
break;
|
|
|
|
}
|
2012-03-01 12:41:49 +01:00
|
|
|
|
|
|
|
/* Do not send annotate_rows events unless slave requested it. */
|
2014-03-09 10:27:38 +01:00
|
|
|
if (event_type == ANNOTATE_ROWS_EVENT &&
|
|
|
|
!(info->flags & BINLOG_SEND_ANNOTATE_ROWS_EVENT))
|
2012-06-22 11:40:40 +02:00
|
|
|
{
|
|
|
|
if (mariadb_slave_capability >= MARIA_SLAVE_CAPABILITY_TOLERATE_HOLES)
|
|
|
|
{
|
|
|
|
/* This slave can tolerate events omitted from the binlog stream. */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else if (mariadb_slave_capability >= MARIA_SLAVE_CAPABILITY_ANNOTATE)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
The slave did not request ANNOTATE_ROWS_EVENT (it does not need them as
|
|
|
|
it will not log them in its own binary log). However, it understands the
|
|
|
|
event and will just ignore it, and it would break if we omitted it,
|
|
|
|
leaving a hole in the binlog stream. So just send the event as-is.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
The slave does not understand ANNOTATE_ROWS_EVENT.
|
|
|
|
|
|
|
|
Older MariaDB slaves (and MySQL slaves) will break replication if there
|
|
|
|
are holes in the binlog stream (they will miscompute the binlog offset
|
|
|
|
and request the wrong position when reconnecting).
|
|
|
|
|
|
|
|
So replace the event with a dummy event of the same size that will be
|
|
|
|
a no-operation on the slave.
|
|
|
|
*/
|
|
|
|
if (Query_log_event::dummy_event(packet, ev_offset, current_checksum_alg))
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
2012-06-22 11:40:40 +02:00
|
|
|
return "Failed to replace row annotate event with dummy: too small event.";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2012-06-22 11:40:40 +02:00
|
|
|
}
|
|
|
|
}
|
2011-08-11 11:38:52 +02:00
|
|
|
|
2012-06-22 11:46:28 +02:00
|
|
|
/*
|
2012-10-23 11:19:42 +02:00
|
|
|
Replace GTID events with old-style BEGIN events for slaves that do not
|
|
|
|
understand global transaction IDs. For stand-alone events, where there is
|
|
|
|
no terminating COMMIT query event, omit the GTID event or replace it with
|
|
|
|
a dummy event, as appropriate.
|
2012-06-22 11:46:28 +02:00
|
|
|
*/
|
2012-10-23 11:19:42 +02:00
|
|
|
if (event_type == GTID_EVENT &&
|
|
|
|
mariadb_slave_capability < MARIA_SLAVE_CAPABILITY_GTID)
|
|
|
|
{
|
|
|
|
bool need_dummy=
|
|
|
|
mariadb_slave_capability < MARIA_SLAVE_CAPABILITY_TOLERATE_HOLES;
|
|
|
|
bool err= Gtid_log_event::make_compatible_event(packet, &need_dummy,
|
|
|
|
ev_offset,
|
|
|
|
current_checksum_alg);
|
|
|
|
if (err)
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
2012-10-23 11:19:42 +02:00
|
|
|
return "Failed to replace GTID event with backwards-compatible event: "
|
|
|
|
"currupt event.";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2012-10-23 11:19:42 +02:00
|
|
|
if (!need_dummy)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Do not send binlog checkpoint or gtid list events to a slave that does not
|
|
|
|
understand it.
|
2012-06-22 11:46:28 +02:00
|
|
|
*/
|
2012-10-23 11:19:42 +02:00
|
|
|
if ((unlikely(event_type == BINLOG_CHECKPOINT_EVENT) &&
|
|
|
|
mariadb_slave_capability < MARIA_SLAVE_CAPABILITY_BINLOG_CHECKPOINT) ||
|
|
|
|
(unlikely(event_type == GTID_LIST_EVENT) &&
|
|
|
|
mariadb_slave_capability < MARIA_SLAVE_CAPABILITY_GTID))
|
2012-06-22 11:46:28 +02:00
|
|
|
{
|
|
|
|
if (mariadb_slave_capability >= MARIA_SLAVE_CAPABILITY_TOLERATE_HOLES)
|
|
|
|
{
|
|
|
|
/* This slave can tolerate events omitted from the binlog stream. */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
The slave does not understand BINLOG_CHECKPOINT_EVENT. Send a dummy
|
|
|
|
event instead, with same length so slave does not get confused about
|
|
|
|
binlog positions.
|
|
|
|
*/
|
|
|
|
if (Query_log_event::dummy_event(packet, ev_offset, current_checksum_alg))
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
2013-02-11 16:44:38 +01:00
|
|
|
return "Failed to replace binlog checkpoint or gtid list event with "
|
|
|
|
"dummy: too small event.";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2012-06-22 11:46:28 +02:00
|
|
|
}
|
|
|
|
}
|
2011-08-11 11:38:52 +02:00
|
|
|
|
|
|
|
/*
|
2011-08-12 13:18:34 +02:00
|
|
|
Skip events with the @@skip_replication flag set, if slave requested
|
2011-08-11 11:38:52 +02:00
|
|
|
skipping of such events.
|
|
|
|
*/
|
2014-03-09 10:27:38 +01:00
|
|
|
if (info->thd->variables.option_bits & OPTION_SKIP_REPLICATION)
|
2011-08-11 11:38:52 +02:00
|
|
|
{
|
2011-08-12 13:18:34 +02:00
|
|
|
/*
|
|
|
|
The first byte of the packet is a '\0' to distinguish it from an error
|
|
|
|
packet. So the actual event starts at offset +1.
|
|
|
|
*/
|
2012-03-01 12:41:49 +01:00
|
|
|
uint16 event_flags= uint2korr(&((*packet)[FLAGS_OFFSET+1]));
|
|
|
|
if (event_flags & LOG_EVENT_SKIP_REPLICATION_F)
|
2011-08-11 11:38:52 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-03-09 10:27:38 +01:00
|
|
|
THD_STAGE_INFO(info->thd, stage_sending_binlog_event_to_slave);
|
2012-03-01 12:41:49 +01:00
|
|
|
|
|
|
|
pos= my_b_tell(log);
|
|
|
|
if (RUN_HOOK(binlog_transmit, before_send_event,
|
2014-03-09 10:27:38 +01:00
|
|
|
(info->thd, info->flags, packet, info->log_file_name, pos)))
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
2012-03-01 12:41:49 +01:00
|
|
|
return "run 'before_send_event' hook failed";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2012-03-01 12:41:49 +01:00
|
|
|
|
2014-03-09 10:27:38 +01:00
|
|
|
if (my_net_write(info->net, (uchar*) packet->ptr(), len))
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
2011-08-11 11:38:52 +02:00
|
|
|
return "Failed on my_net_write()";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2011-08-11 11:38:52 +02:00
|
|
|
|
|
|
|
DBUG_PRINT("info", ("log event code %d", (*packet)[LOG_EVENT_OFFSET+1] ));
|
2012-03-01 12:41:49 +01:00
|
|
|
if (event_type == LOAD_EVENT)
|
2011-08-11 11:38:52 +02:00
|
|
|
{
|
2014-03-09 10:27:38 +01:00
|
|
|
if (send_file(info->thd))
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
2011-08-11 11:38:52 +02:00
|
|
|
return "failed in send_file()";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2011-08-11 11:38:52 +02:00
|
|
|
}
|
|
|
|
|
2014-03-09 10:27:38 +01:00
|
|
|
if (RUN_HOOK(binlog_transmit, after_send_event,
|
|
|
|
(info->thd, info->flags, packet)))
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
2012-03-01 12:41:49 +01:00
|
|
|
return "Failed to run hook 'after_send_event'";
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2012-03-01 12:41:49 +01:00
|
|
|
|
2011-08-11 11:38:52 +02:00
|
|
|
return NULL; /* Success */
|
|
|
|
}
|
2000-11-15 23:24:11 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
static int check_start_offset(binlog_send_info *info,
|
|
|
|
const char *log_file_name,
|
|
|
|
my_off_t pos)
|
2000-10-02 05:28:21 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
IO_CACHE log;
|
|
|
|
File file= -1;
|
2009-09-26 06:49:49 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/** check that requested position is inside of file */
|
|
|
|
if ((file=open_binlog(&log, log_file_name, &info->errmsg)) < 0)
|
|
|
|
{
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
return 1;
|
|
|
|
}
|
2009-09-26 06:49:49 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (pos < BIN_LOG_HEADER_SIZE || pos > my_b_filelength(&log))
|
|
|
|
{
|
|
|
|
const char* msg= "Client requested master to start replication from "
|
|
|
|
"impossible position";
|
|
|
|
|
|
|
|
info->errmsg= NULL; // don't do further modifications of error_text
|
|
|
|
snprintf(info->error_text, sizeof(info->error_text),
|
|
|
|
"%s; the first event '%s' at %lld, "
|
|
|
|
"the last event read from '%s' at %d, "
|
|
|
|
"the last byte read from '%s' at %d.",
|
|
|
|
msg,
|
|
|
|
my_basename(info->start_log_file_name), pos,
|
|
|
|
my_basename(info->start_log_file_name), BIN_LOG_HEADER_SIZE,
|
|
|
|
my_basename(info->start_log_file_name), BIN_LOG_HEADER_SIZE);
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
err:
|
|
|
|
end_io_cache(&log);
|
|
|
|
mysql_file_close(file, MYF(MY_WME));
|
|
|
|
return info->error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int init_binlog_sender(binlog_send_info *info,
|
|
|
|
LOG_INFO *linfo,
|
|
|
|
const char *log_ident,
|
|
|
|
my_off_t *pos)
|
|
|
|
{
|
|
|
|
THD *thd= info->thd;
|
2000-10-02 05:28:21 +02:00
|
|
|
int error;
|
2013-05-15 19:52:21 +02:00
|
|
|
char str_buf[128];
|
2012-11-15 13:11:35 +01:00
|
|
|
String connect_gtid_state(str_buf, sizeof(str_buf), system_charset_info);
|
2013-05-15 19:52:21 +02:00
|
|
|
char str_buf2[128];
|
|
|
|
String slave_until_gtid_str(str_buf2, sizeof(str_buf2), system_charset_info);
|
2014-12-19 12:36:23 +01:00
|
|
|
connect_gtid_state.length(0);
|
2010-09-06 19:18:44 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/** save start file/pos that was requested by slave */
|
|
|
|
strmake(info->start_log_file_name, log_ident,
|
|
|
|
sizeof(info->start_log_file_name));
|
|
|
|
info->start_pos= *pos;
|
2013-05-07 13:05:09 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/** init last pos */
|
|
|
|
info->last_pos= *pos;
|
2002-08-21 21:04:22 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
info->current_checksum_alg= get_binlog_checksum_value_at_connect(thd);
|
|
|
|
info->mariadb_slave_capability= get_mariadb_slave_capability(thd);
|
|
|
|
info->using_gtid_state= get_slave_connect_state(thd, &connect_gtid_state);
|
|
|
|
DBUG_EXECUTE_IF("simulate_non_gtid_aware_master",
|
|
|
|
info->using_gtid_state= false;);
|
2012-11-15 13:11:35 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (info->using_gtid_state)
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->slave_gtid_strict_mode= get_slave_gtid_strict_mode(thd);
|
|
|
|
info->slave_gtid_ignore_duplicates= get_slave_gtid_ignore_duplicates(thd);
|
|
|
|
if (get_slave_until_gtid(thd, &slave_until_gtid_str))
|
|
|
|
info->until_gtid_state= &info->until_gtid_state_obj;
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
DBUG_EXECUTE_IF("binlog_force_reconnect_after_22_events",
|
|
|
|
{
|
|
|
|
DBUG_SET("-d,binlog_force_reconnect_after_22_events");
|
|
|
|
DBUG_SET_INITIAL("-d,binlog_force_reconnect_after_22_events");
|
2014-12-19 12:36:23 +01:00
|
|
|
info->dbug_reconnect_counter= 22;
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
});
|
|
|
|
|
2012-05-24 12:55:07 +02:00
|
|
|
if (global_system_variables.log_warnings > 1)
|
2014-12-19 12:36:23 +01:00
|
|
|
sql_print_information(
|
|
|
|
"Start binlog_dump to slave_server(%lu), pos(%s, %lu)",
|
|
|
|
thd->variables.server_id, log_ident, (ulong)*pos);
|
2000-10-02 05:28:21 +02:00
|
|
|
|
2001-06-29 03:17:04 +02:00
|
|
|
#ifndef DBUG_OFF
|
2001-06-29 02:22:29 +02:00
|
|
|
if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
|
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "Master failed COM_BINLOG_DUMP to test if slave can recover";
|
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
|
|
|
return 1;
|
2001-06-29 02:22:29 +02:00
|
|
|
}
|
2001-07-10 14:53:08 +02:00
|
|
|
#endif
|
2001-06-29 02:22:29 +02:00
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
if (!mysql_bin_log.is_open())
|
2000-11-15 22:00:06 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "Binary log is not open";
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
return 1;
|
2000-11-15 22:00:06 +01:00
|
|
|
}
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
char search_file_name[FN_REFLEN];
|
|
|
|
const char *name=search_file_name;
|
|
|
|
if (info->using_gtid_state)
|
2012-11-15 13:11:35 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
if (info->gtid_state.load(connect_gtid_state.c_ptr_quick(),
|
2014-03-09 10:27:38 +01:00
|
|
|
connect_gtid_state.length()))
|
2012-11-15 13:11:35 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "Out of memory or malformed slave request when obtaining "
|
|
|
|
"start position from GTID state";
|
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
|
|
|
return 1;
|
2012-11-15 13:11:35 +01:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
if (info->until_gtid_state &&
|
|
|
|
info->until_gtid_state->load(slave_until_gtid_str.c_ptr_quick(),
|
2014-03-09 10:27:38 +01:00
|
|
|
slave_until_gtid_str.length()))
|
2013-05-15 19:52:21 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "Out of memory or malformed slave request when "
|
|
|
|
"obtaining UNTIL position sent from slave";
|
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
|
|
|
return 1;
|
2013-05-15 19:52:21 +02:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
if ((error= check_slave_start_position(info, &info->errmsg,
|
|
|
|
&info->error_gtid)))
|
2013-03-18 15:09:36 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= error;
|
|
|
|
return 1;
|
2013-03-18 15:09:36 +01:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
if ((info->errmsg= gtid_find_binlog_file(&info->gtid_state,
|
|
|
|
search_file_name,
|
|
|
|
info->until_gtid_state)))
|
2012-11-15 13:11:35 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
return 1;
|
2012-11-15 13:11:35 +01:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
|
|
|
|
/* start from beginning of binlog file */
|
|
|
|
*pos = 4;
|
2012-11-15 13:11:35 +01:00
|
|
|
}
|
2000-10-02 05:28:21 +02:00
|
|
|
else
|
2012-11-15 13:11:35 +01:00
|
|
|
{
|
|
|
|
if (log_ident[0])
|
|
|
|
mysql_bin_log.make_log_name(search_file_name, log_ident);
|
|
|
|
else
|
2014-12-19 12:36:23 +01:00
|
|
|
name=0; // Find first log
|
2012-11-15 13:11:35 +01:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
linfo->index_file_offset= 0;
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (mysql_bin_log.find_log_pos(linfo, name, 1))
|
2000-11-15 22:00:06 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "Could not find first log file name in binary "
|
|
|
|
"log index file";
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
return 1;
|
2000-11-15 22:00:06 +01:00
|
|
|
}
|
2000-10-02 05:28:21 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
// set current pos too
|
|
|
|
linfo->pos= *pos;
|
|
|
|
|
|
|
|
// note: publish that we use file, before we open it
|
|
|
|
thd->current_linfo= linfo;
|
2007-10-03 11:57:14 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (check_start_offset(info, linfo->log_file_name, *pos))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (*pos > BIN_LOG_HEADER_SIZE)
|
2002-08-21 21:04:22 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
/*
|
|
|
|
mark that first format descriptor with "log_pos=0", so the slave
|
|
|
|
should not increment master's binlog position
|
|
|
|
(rli->group_master_log_pos)
|
|
|
|
*/
|
|
|
|
info->clear_initial_log_pos= true;
|
2002-08-21 21:04:22 +02:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* send format descriptor event for one binlog file
|
|
|
|
*/
|
2015-08-30 14:59:12 +02:00
|
|
|
static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
|
|
|
|
LOG_INFO *linfo, my_off_t start_pos)
|
2014-12-19 12:36:23 +01:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
ulong ev_offset;
|
|
|
|
THD *thd= info->thd;
|
|
|
|
String *packet= info->packet;
|
|
|
|
Log_event_type event_type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 1) reset fdev before each log-file
|
|
|
|
* 2) read first event, should be the format descriptor
|
|
|
|
* 3) read second event, *might* be start encryption event
|
|
|
|
* if it's isn't, seek back to undo this read
|
|
|
|
*/
|
|
|
|
if (info->fdev != NULL)
|
|
|
|
delete info->fdev;
|
|
|
|
|
|
|
|
if (!(info->fdev= new Format_description_log_event(3)))
|
2000-11-15 22:00:06 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "Out of memory initializing format_description event";
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
return 1;
|
2000-11-15 22:00:06 +01:00
|
|
|
}
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
/* reset transmit packet for the event read from binary log file */
|
|
|
|
if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Try to find a Format_description_log_event at the beginning of
|
|
|
|
the binlog
|
|
|
|
*/
|
|
|
|
info->last_pos= my_b_tell(log);
|
2015-09-02 09:58:08 +02:00
|
|
|
error= Log_event::read_log_event(log, packet, info->fdev,
|
2015-08-30 14:59:12 +02:00
|
|
|
opt_master_verify_checksum
|
2015-09-02 09:58:08 +02:00
|
|
|
? info->current_checksum_alg
|
|
|
|
: BINLOG_CHECKSUM_ALG_OFF);
|
2015-08-30 14:59:12 +02:00
|
|
|
linfo->pos= my_b_tell(log);
|
|
|
|
|
|
|
|
if (error)
|
2001-01-22 03:46:32 +01:00
|
|
|
{
|
2015-08-30 14:59:12 +02:00
|
|
|
set_read_error(info, error);
|
|
|
|
return 1;
|
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
event_type= (Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]);
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
/*
|
|
|
|
The packet has offsets equal to the normal offsets in a
|
|
|
|
binlog event + ev_offset (the first ev_offset characters are
|
|
|
|
the header (default \0)).
|
|
|
|
*/
|
|
|
|
DBUG_PRINT("info",
|
|
|
|
("Looked for a Format_description_log_event, "
|
|
|
|
"found event type %d", (int)event_type));
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
if (event_type != FORMAT_DESCRIPTION_EVENT)
|
|
|
|
{
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
info->errmsg= "Failed to find format descriptor event in start of binlog";
|
|
|
|
sql_print_warning("Failed to find format descriptor event in "
|
|
|
|
"start of binlog: %s",
|
|
|
|
info->log_file_name);
|
|
|
|
return 1;
|
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
info->current_checksum_alg= get_checksum_alg(packet->ptr() + ev_offset,
|
|
|
|
packet->length() - ev_offset);
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
DBUG_ASSERT(info->current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
|
|
|
|
info->current_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
|
|
|
|
info->current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
if (!is_slave_checksum_aware(thd) &&
|
|
|
|
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
|
|
|
|
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
|
|
|
|
{
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
info->errmsg= "Slave can not handle replication events with the "
|
|
|
|
"checksum that master is configured to log";
|
|
|
|
sql_print_warning("Master is configured to log replication events "
|
|
|
|
"with checksum, but will not send such events to "
|
|
|
|
"slaves that cannot process them");
|
|
|
|
return 1;
|
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-09-02 09:58:08 +02:00
|
|
|
uint ev_len= packet->length() - ev_offset;
|
|
|
|
if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
|
|
|
|
ev_len-= BINLOG_CHECKSUM_LEN;
|
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
Format_description_log_event *tmp;
|
2015-09-02 09:58:08 +02:00
|
|
|
if (!(tmp= new Format_description_log_event(packet->ptr() + ev_offset,
|
|
|
|
ev_len, info->fdev)))
|
2015-08-30 14:59:12 +02:00
|
|
|
{
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
info->errmsg= "Corrupt Format_description event found "
|
|
|
|
"or out-of-memory";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
delete info->fdev;
|
|
|
|
info->fdev= tmp;
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
(*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F;
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
if (info->clear_initial_log_pos)
|
|
|
|
{
|
|
|
|
info->clear_initial_log_pos= false;
|
|
|
|
/*
|
|
|
|
mark that this event with "log_pos=0", so the slave
|
|
|
|
should not increment master's binlog position
|
|
|
|
(rli->group_master_log_pos)
|
|
|
|
*/
|
|
|
|
int4store((char*) packet->ptr()+LOG_POS_OFFSET+ev_offset, (ulong) 0);
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
/*
|
|
|
|
if reconnect master sends FD event with `created' as 0
|
|
|
|
to avoid destroying temp tables.
|
|
|
|
*/
|
|
|
|
int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
|
|
|
|
ST_CREATED_OFFSET+ev_offset, (ulong) 0);
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
/* fix the checksum due to latest changes in header */
|
|
|
|
if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
|
|
|
|
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
|
|
|
|
fix_checksum(packet, ev_offset);
|
|
|
|
}
|
|
|
|
else if (info->using_gtid_state)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
If this event has the field `created' set, then it will cause the
|
|
|
|
slave to delete all active temporary tables. This must not happen
|
|
|
|
if the slave received any later GTIDs in a previous connect, as
|
|
|
|
those GTIDs might have created new temporary tables that are still
|
|
|
|
needed.
|
|
|
|
|
|
|
|
So here, we check if the starting GTID position was already
|
|
|
|
reached before this format description event. If not, we clear the
|
|
|
|
`created' flag to preserve temporary tables on the slave. (If the
|
|
|
|
slave connects at a position past this event, it means that it
|
|
|
|
already received and handled it in a previous connect).
|
|
|
|
*/
|
|
|
|
if (!info->gtid_state.is_pos_reached())
|
2014-12-19 12:36:23 +01:00
|
|
|
{
|
|
|
|
int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
|
|
|
|
ST_CREATED_OFFSET+ev_offset, (ulong) 0);
|
|
|
|
if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
|
2015-08-30 14:59:12 +02:00
|
|
|
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
|
2014-12-19 12:36:23 +01:00
|
|
|
fix_checksum(packet, ev_offset);
|
|
|
|
}
|
2015-08-30 14:59:12 +02:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
/* send it */
|
|
|
|
if (my_net_write(info->net, (uchar*) packet->ptr(), packet->length()))
|
|
|
|
{
|
|
|
|
info->errmsg= "Failed on my_net_write()";
|
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
|
|
|
return 1;
|
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
|
2015-09-02 09:58:08 +02:00
|
|
|
/*
|
|
|
|
Read the following Start_encryption_log_event but don't send it to slave.
|
|
|
|
Slave doesn't need to know whether master's binlog is encrypted,
|
|
|
|
and if it'll want to encrypt its logs, it should generate its own
|
|
|
|
random nonce, not use the one from the master.
|
|
|
|
*/
|
|
|
|
packet->length(0);
|
|
|
|
info->last_pos= linfo->pos;
|
|
|
|
error= Log_event::read_log_event(log, packet, info->fdev,
|
|
|
|
opt_master_verify_checksum
|
|
|
|
? info->current_checksum_alg
|
|
|
|
: BINLOG_CHECKSUM_ALG_OFF);
|
|
|
|
linfo->pos= my_b_tell(log);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
set_read_error(info, error);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
event_type= (Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET]);
|
|
|
|
if (event_type == START_ENCRYPTION_EVENT)
|
|
|
|
{
|
|
|
|
Start_encryption_log_event *sele= (Start_encryption_log_event *)
|
|
|
|
Log_event::read_log_event(packet->ptr(), packet->length(), &info->errmsg,
|
|
|
|
info->fdev, BINLOG_CHECKSUM_ALG_OFF);
|
|
|
|
if (!sele)
|
|
|
|
{
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->fdev->start_decryption(sele))
|
|
|
|
{
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
info->errmsg= "Could not decrypt binlog: encryption key error";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
delete sele;
|
|
|
|
}
|
|
|
|
else if (start_pos == BIN_LOG_HEADER_SIZE)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
not Start_encryption_log_event - seek back. But only if
|
|
|
|
send_one_binlog_file() isn't going to seek anyway
|
|
|
|
*/
|
|
|
|
my_b_seek(log, info->last_pos);
|
|
|
|
linfo->pos= info->last_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-30 14:59:12 +02:00
|
|
|
/** all done */
|
|
|
|
return 0;
|
2014-12-19 12:36:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool should_stop(binlog_send_info *info)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
info->net->error ||
|
|
|
|
info->net->vio == NULL ||
|
|
|
|
info->thd->killed ||
|
|
|
|
info->error != 0 ||
|
|
|
|
info->should_stop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wait for new events to enter binlog
|
|
|
|
* this function will send heartbeats while waiting if so configured
|
|
|
|
*/
|
|
|
|
static int wait_new_events(binlog_send_info *info, /* in */
|
|
|
|
LOG_INFO* linfo, /* in */
|
|
|
|
char binlog_end_pos_filename[], /* out */
|
|
|
|
my_off_t *end_pos_ptr) /* out */
|
|
|
|
{
|
|
|
|
int ret= 1;
|
|
|
|
PSI_stage_info old_stage;
|
|
|
|
|
|
|
|
mysql_bin_log.lock_binlog_end_pos();
|
|
|
|
info->thd->ENTER_COND(mysql_bin_log.get_log_cond(),
|
|
|
|
mysql_bin_log.get_binlog_end_pos_lock(),
|
|
|
|
&stage_master_has_sent_all_binlog_to_slave,
|
|
|
|
&old_stage);
|
|
|
|
|
|
|
|
while (!should_stop(info))
|
|
|
|
{
|
|
|
|
*end_pos_ptr= mysql_bin_log.get_binlog_end_pos(binlog_end_pos_filename);
|
|
|
|
if (strcmp(linfo->log_file_name, binlog_end_pos_filename) != 0)
|
|
|
|
{
|
|
|
|
/* there has been a log file switch, we don't need to wait */
|
|
|
|
ret= 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (linfo->pos < *end_pos_ptr)
|
|
|
|
{
|
|
|
|
/* there is data to read, we don't need to wait */
|
|
|
|
ret= 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->heartbeat_period)
|
|
|
|
{
|
|
|
|
struct timespec ts;
|
|
|
|
set_timespec_nsec(ts, info->heartbeat_period);
|
|
|
|
ret= mysql_bin_log.wait_for_update_binlog_end_pos(info->thd, &ts);
|
|
|
|
if (ret == ETIMEDOUT || ret == ETIME)
|
|
|
|
{
|
|
|
|
struct event_coordinates coord = { linfo->log_file_name, linfo->pos };
|
|
|
|
#ifndef DBUG_OFF
|
|
|
|
const ulong hb_info_counter_limit = 3;
|
|
|
|
if (info->hb_info_counter < hb_info_counter_limit)
|
|
|
|
{
|
|
|
|
sql_print_information("master sends heartbeat message %s:%llu",
|
|
|
|
linfo->log_file_name, linfo->pos);
|
|
|
|
info->hb_info_counter++;
|
|
|
|
if (info->hb_info_counter == hb_info_counter_limit)
|
|
|
|
sql_print_information("the rest of heartbeat info skipped ...");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
mysql_bin_log.unlock_binlog_end_pos();
|
|
|
|
ret= send_heartbeat_event(info,
|
|
|
|
info->net, info->packet, &coord,
|
|
|
|
info->current_checksum_alg);
|
|
|
|
mysql_bin_log.lock_binlog_end_pos();
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ret= 1; // error
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* re-read heartbeat period after each sent
|
|
|
|
*/
|
|
|
|
info->heartbeat_period= get_heartbeat_period(info->thd);
|
|
|
|
}
|
|
|
|
else if (ret != 0)
|
|
|
|
{
|
|
|
|
ret= 1; // error
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret= mysql_bin_log.wait_for_update_binlog_end_pos(info->thd, NULL);
|
|
|
|
if (ret != 0 && ret != ETIMEDOUT && ret != ETIME)
|
|
|
|
{
|
|
|
|
ret= 1; // error
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-01-22 03:46:32 +01:00
|
|
|
}
|
2009-09-26 06:49:49 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/* it releases the lock set in ENTER_COND */
|
|
|
|
info->thd->EXIT_COND(&old_stage);
|
|
|
|
return ret;
|
|
|
|
}
|
2001-01-17 13:47:33 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/**
|
|
|
|
* get end pos of current log file, this function
|
|
|
|
* will wait if there is nothing available
|
|
|
|
*/
|
|
|
|
static my_off_t get_binlog_end_pos(binlog_send_info *info,
|
|
|
|
IO_CACHE* log,
|
|
|
|
LOG_INFO* linfo)
|
|
|
|
{
|
|
|
|
my_off_t log_pos= my_b_tell(log);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get current binlog end pos
|
|
|
|
*/
|
|
|
|
mysql_bin_log.lock_binlog_end_pos();
|
|
|
|
char binlog_end_pos_filename[FN_REFLEN];
|
|
|
|
my_off_t end_pos= mysql_bin_log.get_binlog_end_pos(binlog_end_pos_filename);
|
|
|
|
mysql_bin_log.unlock_binlog_end_pos();
|
|
|
|
|
|
|
|
do
|
2005-02-09 20:04:28 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
if (strcmp(binlog_end_pos_filename, linfo->log_file_name) != 0)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* this file is not active, since it's not written to again,
|
|
|
|
* it safe to check file length and use that as end_pos
|
|
|
|
*/
|
|
|
|
end_pos= my_b_filelength(log);
|
2009-09-26 06:49:49 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (log_pos == end_pos)
|
|
|
|
return 0; // already at end of file inactive file
|
|
|
|
else
|
|
|
|
return end_pos; // return size of inactive file
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* this is the active file
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
*/
|
2014-12-19 12:36:23 +01:00
|
|
|
|
|
|
|
if (log_pos < end_pos)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* there is data available to read
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
*/
|
2014-12-19 12:36:23 +01:00
|
|
|
return end_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* check if we should wait for more data
|
2005-02-21 13:47:57 +01:00
|
|
|
*/
|
2014-12-19 12:36:23 +01:00
|
|
|
if ((info->flags & BINLOG_DUMP_NON_BLOCK) ||
|
|
|
|
(info->thd->variables.server_id == 0))
|
|
|
|
{
|
|
|
|
info->should_stop= true;
|
|
|
|
return 0;
|
|
|
|
}
|
2005-02-09 20:04:28 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/**
|
|
|
|
* flush data before waiting
|
|
|
|
*/
|
|
|
|
if (net_flush(info->net))
|
|
|
|
{
|
|
|
|
info->errmsg= "failed on net_flush()";
|
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
|
|
|
return 1;
|
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (wait_new_events(info, linfo, binlog_end_pos_filename, &end_pos))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} while (!should_stop(info));
|
2013-05-15 19:52:21 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
return 0;
|
|
|
|
}
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/**
|
|
|
|
* This function sends events from one binlog file
|
|
|
|
* but only up until end_pos
|
|
|
|
*
|
|
|
|
* return 0 - OK
|
|
|
|
* else NOK
|
|
|
|
*/
|
2015-08-30 14:59:12 +02:00
|
|
|
static int send_events(binlog_send_info *info, IO_CACHE* log, LOG_INFO* linfo,
|
2014-12-19 12:36:23 +01:00
|
|
|
my_off_t end_pos)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
ulong ev_offset;
|
|
|
|
|
|
|
|
String *packet= info->packet;
|
|
|
|
linfo->pos= my_b_tell(log);
|
|
|
|
info->last_pos= my_b_tell(log);
|
|
|
|
|
|
|
|
while (linfo->pos < end_pos)
|
2000-11-15 22:00:06 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
if (should_stop(info))
|
|
|
|
return 0;
|
2009-09-26 06:49:49 +02:00
|
|
|
|
|
|
|
/* reset the transmit packet for the event read from binary log
|
|
|
|
file */
|
2014-12-19 12:36:23 +01:00
|
|
|
if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg))
|
|
|
|
return 1;
|
2011-01-31 14:11:05 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
info->last_pos= linfo->pos;
|
2015-09-02 09:58:08 +02:00
|
|
|
error= Log_event::read_log_event(log, packet, info->fdev,
|
2015-08-30 15:03:55 +02:00
|
|
|
opt_master_verify_checksum ? info->current_checksum_alg
|
|
|
|
: BINLOG_CHECKSUM_ALG_OFF);
|
2014-12-19 12:36:23 +01:00
|
|
|
linfo->pos= my_b_tell(log);
|
|
|
|
|
|
|
|
if (error)
|
2000-11-15 22:00:06 +01:00
|
|
|
{
|
2015-08-30 14:59:12 +02:00
|
|
|
set_read_error(info, error);
|
|
|
|
return 1;
|
2014-12-19 12:36:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Log_event_type event_type=
|
|
|
|
(Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]);
|
|
|
|
|
2001-06-29 02:22:29 +02:00
|
|
|
#ifndef DBUG_OFF
|
2014-12-19 12:36:23 +01:00
|
|
|
if (info->dbug_reconnect_counter > 0)
|
|
|
|
{
|
|
|
|
--info->dbug_reconnect_counter;
|
|
|
|
if (info->dbug_reconnect_counter == 0)
|
2001-06-29 02:22:29 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg= "DBUG-injected forced reconnect";
|
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
|
|
|
return 1;
|
2001-06-29 02:22:29 +02:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
}
|
2001-07-10 14:53:08 +02:00
|
|
|
#endif
|
2005-02-09 20:04:28 +01:00
|
|
|
|
2013-03-01 14:58:19 +01:00
|
|
|
#ifdef ENABLED_DEBUG_SYNC
|
2014-12-19 12:36:23 +01:00
|
|
|
DBUG_EXECUTE_IF("dump_thread_wait_before_send_xid",
|
|
|
|
{
|
|
|
|
if (event_type == XID_EVENT)
|
2011-01-18 18:23:49 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
net_flush(info->net);
|
|
|
|
const char act[]=
|
2011-01-18 18:23:49 +01:00
|
|
|
"now "
|
|
|
|
"wait_for signal.continue";
|
2014-12-19 12:36:23 +01:00
|
|
|
DBUG_ASSERT(debug_sync_service);
|
|
|
|
DBUG_ASSERT(!debug_sync_set_action(
|
|
|
|
info->thd,
|
|
|
|
STRING_WITH_LEN(act)));
|
|
|
|
|
|
|
|
const char act2[]=
|
2011-05-09 15:06:16 +02:00
|
|
|
"now "
|
|
|
|
"signal signal.continued";
|
2014-12-19 12:36:23 +01:00
|
|
|
DBUG_ASSERT(!debug_sync_set_action(
|
|
|
|
info->thd,
|
|
|
|
STRING_WITH_LEN(act2)));
|
|
|
|
}
|
|
|
|
});
|
2013-03-01 14:58:19 +01:00
|
|
|
#endif
|
2011-10-19 21:45:18 +02:00
|
|
|
|
2015-09-02 09:58:08 +02:00
|
|
|
if (event_type != START_ENCRYPTION_EVENT &&
|
|
|
|
((info->errmsg= send_event_to_slave(info, event_type, log,
|
|
|
|
ev_offset, &info->error_gtid))))
|
2014-12-19 12:36:23 +01:00
|
|
|
return 1;
|
2013-09-04 12:22:09 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (unlikely(info->send_fake_gtid_list) &&
|
|
|
|
info->gtid_skip_group == GTID_SKIP_NOT)
|
|
|
|
{
|
|
|
|
Gtid_list_log_event glev(&info->until_binlog_state, 0);
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg) ||
|
|
|
|
fake_gtid_list_event(info, &glev, &info->errmsg, my_b_tell(log)))
|
2009-09-26 06:49:49 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
|
|
|
return 1;
|
2000-11-15 22:00:06 +01:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
info->send_fake_gtid_list= false;
|
|
|
|
}
|
2013-06-07 14:39:00 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (info->until_gtid_state &&
|
|
|
|
is_until_reached(info, &ev_offset, event_type, &info->errmsg,
|
|
|
|
my_b_tell(log)))
|
|
|
|
{
|
|
|
|
if (info->errmsg)
|
2013-05-15 19:52:21 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
|
|
|
return 1;
|
2013-05-15 19:52:21 +02:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
info->should_stop= true;
|
|
|
|
return 0;
|
2000-11-15 22:00:06 +01:00
|
|
|
}
|
2005-02-09 20:04:28 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/* Abort server before it sends the XID_EVENT */
|
|
|
|
DBUG_EXECUTE_IF("crash_before_send_xid",
|
2013-02-15 22:57:35 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
if (event_type == XID_EVENT)
|
|
|
|
{
|
|
|
|
my_sleep(2000000);
|
|
|
|
DBUG_SUICIDE();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-02-15 22:57:35 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function sends one binlog file to slave
|
|
|
|
*
|
|
|
|
* return 0 - OK
|
|
|
|
* 1 - NOK
|
|
|
|
*/
|
|
|
|
static int send_one_binlog_file(binlog_send_info *info,
|
|
|
|
IO_CACHE* log,
|
|
|
|
LOG_INFO* linfo,
|
|
|
|
my_off_t start_pos)
|
|
|
|
{
|
2015-01-31 15:04:37 +01:00
|
|
|
mysql_mutex_assert_not_owner(mysql_bin_log.get_log_lock());
|
2014-12-19 12:36:23 +01:00
|
|
|
|
|
|
|
/* seek to the requested position, to start the requested dump */
|
|
|
|
if (start_pos != BIN_LOG_HEADER_SIZE)
|
|
|
|
{
|
|
|
|
my_b_seek(log, start_pos);
|
|
|
|
linfo->pos= start_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!should_stop(info))
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* get end pos of current log file, this function
|
|
|
|
* will wait if there is nothing available
|
2013-02-15 22:57:35 +01:00
|
|
|
*/
|
2014-12-19 12:36:23 +01:00
|
|
|
my_off_t end_pos= get_binlog_end_pos(info, log, linfo);
|
|
|
|
if (end_pos <= 1)
|
2001-07-10 14:53:08 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
/** end of file or error */
|
|
|
|
return end_pos;
|
|
|
|
}
|
2000-10-02 05:28:21 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/**
|
|
|
|
* send events from current position up to end_pos
|
|
|
|
*/
|
|
|
|
if (send_events(info, log, linfo, end_pos))
|
|
|
|
return 1;
|
|
|
|
}
|
2000-11-15 22:00:06 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2001-06-29 02:22:29 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
|
|
|
|
ushort flags)
|
|
|
|
{
|
|
|
|
LOG_INFO linfo;
|
2000-11-15 22:00:06 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
IO_CACHE log;
|
|
|
|
File file = -1;
|
|
|
|
String* const packet= &thd->packet;
|
2013-06-07 14:39:00 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
binlog_send_info infoobj(thd, packet, flags, linfo.log_file_name);
|
|
|
|
binlog_send_info *info= &infoobj;
|
2000-11-15 22:00:06 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
int old_max_allowed_packet= thd->variables.max_allowed_packet;
|
|
|
|
thd->variables.max_allowed_packet= MAX_MAX_ALLOWED_PACKET;
|
2005-10-03 18:34:42 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
DBUG_ENTER("mysql_binlog_send");
|
|
|
|
DBUG_PRINT("enter",("log_ident: '%s' pos: %ld", log_ident, (long) pos));
|
2000-11-15 22:00:06 +01:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
bzero((char*) &log,sizeof(log));
|
|
|
|
|
|
|
|
if (init_binlog_sender(info, &linfo, log_ident, &pos))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
/*
|
|
|
|
run hook first when all check has been made that slave seems to
|
|
|
|
be requesting a reasonable position. i.e when transmit actually starts
|
|
|
|
*/
|
|
|
|
if (RUN_HOOK(binlog_transmit, transmit_start, (thd, flags, log_ident, pos)))
|
|
|
|
{
|
|
|
|
info->errmsg= "Failed to run hook 'transmit_start'";
|
|
|
|
info->error= ER_UNKNOWN_ERROR;
|
|
|
|
goto err;
|
|
|
|
}
|
2006-04-13 09:50:33 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/*
|
|
|
|
heartbeat_period from @master_heartbeat_period user variable
|
|
|
|
NOTE: this is initialized after transmit_start-hook so that
|
|
|
|
the hook can affect value of heartbeat period
|
|
|
|
*/
|
|
|
|
info->heartbeat_period= get_heartbeat_period(thd);
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
while (!should_stop(info))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Tell the client about the log name with a fake Rotate event;
|
|
|
|
this is needed even if we also send a Format_description_log_event
|
|
|
|
just after, because that event does not contain the binlog's name.
|
|
|
|
Note that as this Rotate event is sent before
|
|
|
|
Format_description_log_event, the slave cannot have any info to
|
|
|
|
understand this event's format, so the header len of
|
|
|
|
Rotate_log_event is FROZEN (so in 5.0 it will have a header shorter
|
|
|
|
than other events except FORMAT_DESCRIPTION_EVENT).
|
|
|
|
Before 4.0.14 we called fake_rotate_event below only if (pos ==
|
|
|
|
BIN_LOG_HEADER_SIZE), because if this is false then the slave
|
|
|
|
already knows the binlog's name.
|
|
|
|
Since, we always call fake_rotate_event; if the slave already knew
|
|
|
|
the log's name (ex: CHANGE MASTER TO MASTER_LOG_FILE=...) this is
|
|
|
|
useless but does not harm much. It is nice for 3.23 (>=.58) slaves
|
|
|
|
which test Rotate events to see if the master is 4.0 (then they
|
|
|
|
choose to stop because they can't replicate 4.0); by always calling
|
|
|
|
fake_rotate_event we are sure that 3.23.58 and newer will detect the
|
|
|
|
problem as soon as replication starts (BUG#198).
|
|
|
|
Always calling fake_rotate_event makes sending of normal
|
|
|
|
(=from-binlog) Rotate events a priori unneeded, but it is not so
|
|
|
|
simple: the 2 Rotate events are not equivalent, the normal one is
|
|
|
|
before the Stop event, the fake one is after. If we don't send the
|
|
|
|
normal one, then the Stop event will be interpreted (by existing 4.0
|
|
|
|
slaves) as "the master stopped", which is wrong. So for safety,
|
|
|
|
given that we want minimum modification of 4.0, we send the normal
|
|
|
|
and fake Rotates.
|
|
|
|
*/
|
|
|
|
if (fake_rotate_event(info, pos, &info->errmsg, info->current_checksum_alg))
|
|
|
|
{
|
2003-06-21 18:10:59 +02:00
|
|
|
/*
|
2014-12-19 12:36:23 +01:00
|
|
|
This error code is not perfect, as fake_rotate_event() does not
|
|
|
|
read anything from the binlog; if it fails it's because of an
|
|
|
|
error in my_net_write(), fortunately it will say so in errmsg.
|
2003-06-21 18:10:59 +02:00
|
|
|
*/
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
goto err;
|
|
|
|
}
|
Many files:
Semi-synchronous replication for InnoDB type tables; before telling the client that a commit has been processed, wait that the replication thread has returned from my_net_send() where it sends the binlog to the slave; note that TCP/IP, even with the TCP_NODELAY option does not guarantee that the slave has RECEIVED the data - this is just heuristic at the moment; this is useful in failover: in almost all cases, every transaction that has returned from the commit has been sent and processed in the slave, which makes failover to the slave simpler if the master crashes; the code does not work yet as is, because MySQL should call innobase_report_binlog_offset_and_commit() in a commit; we will most probably return that call to 5.0.x, to make InnoDB Hot Backup and group commit to work again; XA code broke them temporarily in 5.0.3
sql/ha_innodb.cc:
Semi-synchronous replication for InnoDB type tables; before telling the client that a commit has been processed, wait that the replication thread has returned from my_net_send() where it sends the binlog to the slave; note that TCP/IP, even with the TCP_NODELAY option does not guarantee that the slave has RECEIVED the data - this is just heuristic at the moment; this is useful in failover: in almost all cases, every transaction that has returned from the commit has been sent and processed in the slave, which makes failover to the slave simpler if the master crashes; the code does not work yet as is, because MySQL should call innobase_report_binlog_offset_and_commit() in a commit; we will most probably return that call to 5.0.x, to make InnoDB Hot Backup and group commit to work again; XA code broke them temporarily in 5.0.3
sql/handler.cc:
Semi-synchronous replication for InnoDB type tables; before telling the client that a commit has been processed, wait that the replication thread has returned from my_net_send() where it sends the binlog to the slave; note that TCP/IP, even with the TCP_NODELAY option does not guarantee that the slave has RECEIVED the data - this is just heuristic at the moment; this is useful in failover: in almost all cases, every transaction that has returned from the commit has been sent and processed in the slave, which makes failover to the slave simpler if the master crashes; the code does not work yet as is, because MySQL should call innobase_report_binlog_offset_and_commit() in a commit; we will most probably return that call to 5.0.x, to make InnoDB Hot Backup and group commit to work again; XA code broke them temporarily in 5.0.3
sql/mysqld.cc:
Semi-synchronous replication for InnoDB type tables; before telling the client that a commit has been processed, wait that the replication thread has returned from my_net_send() where it sends the binlog to the slave; note that TCP/IP, even with the TCP_NODELAY option does not guarantee that the slave has RECEIVED the data - this is just heuristic at the moment; this is useful in failover: in almost all cases, every transaction that has returned from the commit has been sent and processed in the slave, which makes failover to the slave simpler if the master crashes; the code does not work yet as is, because MySQL should call innobase_report_binlog_offset_and_commit() in a commit; we will most probably return that call to 5.0.x, to make InnoDB Hot Backup and group commit to work again; XA code broke them temporarily in 5.0.3
sql/set_var.cc:
Semi-synchronous replication for InnoDB type tables; before telling the client that a commit has been processed, wait that the replication thread has returned from my_net_send() where it sends the binlog to the slave; note that TCP/IP, even with the TCP_NODELAY option does not guarantee that the slave has RECEIVED the data - this is just heuristic at the moment; this is useful in failover: in almost all cases, every transaction that has returned from the commit has been sent and processed in the slave, which makes failover to the slave simpler if the master crashes; the code does not work yet as is, because MySQL should call innobase_report_binlog_offset_and_commit() in a commit; we will most probably return that call to 5.0.x, to make InnoDB Hot Backup and group commit to work again; XA code broke them temporarily in 5.0.3
sql/sql_repl.cc:
Semi-synchronous replication for InnoDB type tables; before telling the client that a commit has been processed, wait that the replication thread has returned from my_net_send() where it sends the binlog to the slave; note that TCP/IP, even with the TCP_NODELAY option does not guarantee that the slave has RECEIVED the data - this is just heuristic at the moment; this is useful in failover: in almost all cases, every transaction that has returned from the commit has been sent and processed in the slave, which makes failover to the slave simpler if the master crashes; the code does not work yet as is, because MySQL should call innobase_report_binlog_offset_and_commit() in a commit; we will most probably return that call to 5.0.x, to make InnoDB Hot Backup and group commit to work again; XA code broke them temporarily in 5.0.3
sql/ha_innodb.h:
Semi-synchronous replication for InnoDB type tables; before telling the client that a commit has been processed, wait that the replication thread has returned from my_net_send() where it sends the binlog to the slave; note that TCP/IP, even with the TCP_NODELAY option does not guarantee that the slave has RECEIVED the data - this is just heuristic at the moment; this is useful in failover: in almost all cases, every transaction that has returned from the commit has been sent and processed in the slave, which makes failover to the slave simpler if the master crashes; the code does not work yet as is, because MySQL should call innobase_report_binlog_offset_and_commit() in a commit; we will most probably return that call to 5.0.x, to make InnoDB Hot Backup and group commit to work again; XA code broke them temporarily in 5.0.3
sql/handler.h:
Semi-synchronous replication for InnoDB type tables; before telling the client that a commit has been processed, wait that the replication thread has returned from my_net_send() where it sends the binlog to the slave; note that TCP/IP, even with the TCP_NODELAY option does not guarantee that the slave has RECEIVED the data - this is just heuristic at the moment; this is useful in failover: in almost all cases, every transaction that has returned from the commit has been sent and processed in the slave, which makes failover to the slave simpler if the master crashes; the code does not work yet as is, because MySQL should call innobase_report_binlog_offset_and_commit() in a commit; we will most probably return that call to 5.0.x, to make InnoDB Hot Backup and group commit to work again; XA code broke them temporarily in 5.0.3
2005-04-20 18:27:46 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if ((file=open_binlog(&log, linfo.log_file_name, &info->errmsg)) < 0)
|
|
|
|
{
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
goto err;
|
2000-10-02 05:28:21 +02:00
|
|
|
}
|
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (send_format_descriptor_event(info, &log, &linfo, pos))
|
|
|
|
{
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
goto err;
|
|
|
|
}
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
/*
|
|
|
|
We want to corrupt the first event that will be sent to the slave.
|
|
|
|
But we do not want the corruption to happen early, eg. when client does
|
|
|
|
BINLOG_GTID_POS(). So test case sets a DBUG trigger which causes us to
|
|
|
|
set the real DBUG injection here.
|
|
|
|
*/
|
2015-08-24 13:09:03 +02:00
|
|
|
DBUG_EXECUTE_IF("corrupt_read_log_event2_set",
|
2014-12-19 12:36:23 +01:00
|
|
|
{
|
2015-08-24 13:09:03 +02:00
|
|
|
DBUG_SET("-d,corrupt_read_log_event2_set");
|
2014-12-19 12:36:23 +01:00
|
|
|
DBUG_SET("+d,corrupt_read_log_event2");
|
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
Handle the case of START SLAVE UNTIL with an UNTIL condition already
|
|
|
|
fulfilled at the start position.
|
|
|
|
|
|
|
|
We will send one event, the format_description, and then stop.
|
|
|
|
*/
|
|
|
|
if (info->until_gtid_state && info->until_gtid_state->count() == 0)
|
|
|
|
info->gtid_until_group= GTID_UNTIL_STOP_AFTER_STANDALONE;
|
|
|
|
|
|
|
|
THD_STAGE_INFO(thd, stage_sending_binlog_event_to_slave);
|
|
|
|
if (send_one_binlog_file(info, &log, &linfo, pos))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (should_stop(info))
|
|
|
|
break;
|
|
|
|
|
|
|
|
DBUG_EXECUTE_IF("wait_after_binlog_EOF",
|
|
|
|
{
|
|
|
|
const char act[]= "now wait_for signal.rotate_finished";
|
|
|
|
DBUG_ASSERT(!debug_sync_set_action(current_thd,
|
|
|
|
STRING_WITH_LEN(act)));
|
|
|
|
};);
|
|
|
|
|
|
|
|
THD_STAGE_INFO(thd,
|
|
|
|
stage_finished_reading_one_binlog_switching_to_next_binlog);
|
|
|
|
if (mysql_bin_log.find_next_log(&linfo, 1))
|
|
|
|
{
|
|
|
|
info->errmsg= "could not find next log";
|
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** start from start of next file */
|
|
|
|
pos= BIN_LOG_HEADER_SIZE;
|
|
|
|
|
|
|
|
/** close current cache/file */
|
|
|
|
end_io_cache(&log);
|
|
|
|
mysql_file_close(file, MYF(MY_WME));
|
|
|
|
file= -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
err:
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
THD_STAGE_INFO(thd, stage_waiting_to_finalize_termination);
|
2014-12-19 12:36:23 +01:00
|
|
|
RUN_HOOK(binlog_transmit, transmit_stop, (thd, flags));
|
|
|
|
|
|
|
|
const bool binlog_open = my_b_inited(&log);
|
|
|
|
if (file >= 0)
|
|
|
|
{
|
|
|
|
end_io_cache(&log);
|
|
|
|
mysql_file_close(file, MYF(MY_WME));
|
|
|
|
}
|
|
|
|
|
2016-02-01 11:45:39 +01:00
|
|
|
thd->reset_current_linfo();
|
2010-07-20 17:27:13 +02:00
|
|
|
thd->variables.max_allowed_packet= old_max_allowed_packet;
|
2014-12-19 12:36:23 +01:00
|
|
|
delete info->fdev;
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2014-12-19 12:36:23 +01:00
|
|
|
if (info->error == ER_MASTER_FATAL_ERROR_READING_BINLOG && binlog_open)
|
2011-09-30 14:58:02 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
/*
|
|
|
|
detailing the fatal error message with coordinates
|
2011-09-29 13:14:43 +02:00
|
|
|
of the last position read.
|
|
|
|
*/
|
2014-12-19 12:36:23 +01:00
|
|
|
my_snprintf(info->error_text, sizeof(info->error_text),
|
2012-01-19 15:44:09 +01:00
|
|
|
"%s; the first event '%s' at %lld, "
|
|
|
|
"the last event read from '%s' at %lld, "
|
|
|
|
"the last byte read from '%s' at %lld.",
|
2014-12-19 12:36:23 +01:00
|
|
|
info->errmsg,
|
|
|
|
my_basename(info->start_log_file_name), info->start_pos,
|
|
|
|
my_basename(info->log_file_name), info->last_pos,
|
|
|
|
my_basename(info->log_file_name), linfo.pos);
|
2011-09-30 14:58:02 +02:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
else if (info->error == ER_GTID_POSITION_NOT_FOUND_IN_BINLOG)
|
2013-03-18 15:09:36 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
my_snprintf(info->error_text, sizeof(info->error_text),
|
2013-03-18 15:09:36 +01:00
|
|
|
"Error: connecting slave requested to start from GTID "
|
|
|
|
"%u-%u-%llu, which is not in the master's binlog",
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error_gtid.domain_id,
|
|
|
|
info->error_gtid.server_id,
|
|
|
|
info->error_gtid.seq_no);
|
2013-03-18 15:09:36 +01:00
|
|
|
/* Use this error code so slave will know not to try reconnect. */
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
2013-03-18 15:09:36 +01:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
else if (info->error == ER_GTID_POSITION_NOT_FOUND_IN_BINLOG2)
|
2013-08-16 15:10:25 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
my_snprintf(info->error_text, sizeof(info->error_text),
|
2013-08-16 15:10:25 +02:00
|
|
|
"Error: connecting slave requested to start from GTID "
|
|
|
|
"%u-%u-%llu, which is not in the master's binlog. Since the "
|
|
|
|
"master's binlog contains GTIDs with higher sequence numbers, "
|
|
|
|
"it probably means that the slave has diverged due to "
|
2015-03-16 10:54:47 +01:00
|
|
|
"executing extra erroneous transactions",
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error_gtid.domain_id,
|
|
|
|
info->error_gtid.server_id,
|
|
|
|
info->error_gtid.seq_no);
|
2013-08-16 15:10:25 +02:00
|
|
|
/* Use this error code so slave will know not to try reconnect. */
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
2013-08-16 15:10:25 +02:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
else if (info->error == ER_GTID_START_FROM_BINLOG_HOLE)
|
2013-05-28 13:28:31 +02:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
my_snprintf(info->error_text, sizeof(info->error_text),
|
2013-05-28 13:28:31 +02:00
|
|
|
"The binlog on the master is missing the GTID %u-%u-%llu "
|
|
|
|
"requested by the slave (even though both a prior and a "
|
|
|
|
"subsequent sequence number does exist), and GTID strict mode "
|
|
|
|
"is enabled",
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error_gtid.domain_id,
|
|
|
|
info->error_gtid.server_id,
|
|
|
|
info->error_gtid.seq_no);
|
2013-05-28 13:28:31 +02:00
|
|
|
/* Use this error code so slave will know not to try reconnect. */
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
2013-05-28 13:28:31 +02:00
|
|
|
}
|
2014-12-19 12:36:23 +01:00
|
|
|
else if (info->error == ER_CANNOT_LOAD_SLAVE_GTID_STATE)
|
2013-03-18 15:09:36 +01:00
|
|
|
{
|
2014-12-19 12:36:23 +01:00
|
|
|
my_snprintf(info->error_text, sizeof(info->error_text),
|
2013-03-18 15:09:36 +01:00
|
|
|
"Failed to load replication slave GTID state from table %s.%s",
|
|
|
|
"mysql", rpl_gtid_slave_state_table_name.str);
|
2014-12-19 12:36:23 +01:00
|
|
|
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
|
|
|
}
|
|
|
|
else if (info->error != 0 && info->errmsg != NULL)
|
|
|
|
strcpy(info->error_text, info->errmsg);
|
|
|
|
|
|
|
|
if (info->error == 0)
|
|
|
|
{
|
|
|
|
my_eof(thd);
|
2013-03-18 15:09:36 +01:00
|
|
|
}
|
2011-09-29 13:14:43 +02:00
|
|
|
else
|
2014-12-19 12:36:23 +01:00
|
|
|
{
|
|
|
|
my_message(info->error, info->error_text, MYF(0));
|
|
|
|
}
|
2005-10-03 18:34:42 +02:00
|
|
|
|
2000-10-02 05:28:21 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Execute a START SLAVE statement.
|
|
|
|
|
|
|
|
@param thd Pointer to THD object for the client thread executing the
|
|
|
|
statement.
|
|
|
|
|
|
|
|
@param mi Pointer to Master_info object for the slave's IO thread.
|
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
@param net_report If true, saves the exit status into thd->stmt_da.
|
2009-01-09 13:49:24 +01:00
|
|
|
|
|
|
|
@retval 0 success
|
|
|
|
@retval 1 error
|
2012-10-03 00:44:54 +02:00
|
|
|
@retval -1 fatal error
|
2009-01-09 13:49:24 +01:00
|
|
|
*/
|
2012-10-03 00:44:54 +02:00
|
|
|
|
2007-08-16 08:52:50 +02:00
|
|
|
int start_slave(THD* thd , Master_info* mi, bool net_report)
|
2000-10-02 05:28:21 +02:00
|
|
|
{
|
2003-09-13 22:13:41 +02:00
|
|
|
int slave_errno= 0;
|
2002-01-20 03:16:52 +01:00
|
|
|
int thread_mask;
|
2012-09-28 01:06:56 +02:00
|
|
|
char master_info_file_tmp[FN_REFLEN];
|
|
|
|
char relay_log_info_file_tmp[FN_REFLEN];
|
2002-08-08 02:12:02 +02:00
|
|
|
DBUG_ENTER("start_slave");
|
2005-02-09 20:04:28 +01:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
if (check_access(thd, SUPER_ACL, any_db, NULL, NULL, 0, 0))
|
2012-10-03 00:44:54 +02:00
|
|
|
DBUG_RETURN(-1);
|
|
|
|
|
|
|
|
create_logfile_name_with_suffix(master_info_file_tmp,
|
|
|
|
sizeof(master_info_file_tmp),
|
2013-05-03 00:50:42 +02:00
|
|
|
master_info_file, 0,
|
|
|
|
&mi->cmp_connection_name);
|
2012-10-03 00:44:54 +02:00
|
|
|
create_logfile_name_with_suffix(relay_log_info_file_tmp,
|
|
|
|
sizeof(relay_log_info_file_tmp),
|
|
|
|
relay_log_info_file, 0,
|
2013-05-03 00:50:42 +02:00
|
|
|
&mi->cmp_connection_name);
|
2012-10-03 00:44:54 +02:00
|
|
|
|
2002-01-20 03:16:52 +01:00
|
|
|
lock_slave_threads(mi); // this allows us to cleanly read slave_running
|
2003-03-03 23:12:17 +01:00
|
|
|
// Get a mask of _stopped_ threads
|
2002-01-20 03:16:52 +01:00
|
|
|
init_thread_mask(&thread_mask,mi,1 /* inverse */);
|
2013-05-15 19:52:21 +02:00
|
|
|
|
|
|
|
if (thd->lex->mi.gtid_pos_str.str)
|
|
|
|
{
|
|
|
|
if (thread_mask != (SLAVE_IO|SLAVE_SQL))
|
|
|
|
{
|
|
|
|
slave_errno= ER_SLAVE_WAS_RUNNING;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
if (thd->lex->slave_thd_opt)
|
|
|
|
{
|
|
|
|
slave_errno= ER_BAD_SLAVE_UNTIL_COND;
|
|
|
|
goto err;
|
|
|
|
}
|
2013-05-22 17:36:48 +02:00
|
|
|
if (mi->using_gtid == Master_info::USE_GTID_NO)
|
2013-05-15 19:52:21 +02:00
|
|
|
{
|
|
|
|
slave_errno= ER_UNTIL_REQUIRES_USING_GTID;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-03 23:12:17 +01:00
|
|
|
/*
|
2005-02-09 20:04:28 +01:00
|
|
|
Below we will start all stopped threads. But if the user wants to
|
|
|
|
start only one thread, do as if the other thread was running (as we
|
|
|
|
don't wan't to touch the other thread), so set the bit to 0 for the
|
|
|
|
other thread
|
2003-03-03 23:12:17 +01:00
|
|
|
*/
|
2003-05-05 20:54:37 +02:00
|
|
|
if (thd->lex->slave_thd_opt)
|
2003-12-19 18:52:13 +01:00
|
|
|
thread_mask&= thd->lex->slave_thd_opt;
|
2003-03-03 23:12:17 +01:00
|
|
|
if (thread_mask) //some threads are stopped, start them
|
2002-01-20 03:16:52 +01:00
|
|
|
{
|
2012-09-28 01:06:56 +02:00
|
|
|
if (init_master_info(mi,master_info_file_tmp,relay_log_info_file_tmp, 0,
|
2004-11-25 09:26:45 +01:00
|
|
|
thread_mask))
|
2002-08-08 02:12:02 +02:00
|
|
|
slave_errno=ER_MASTER_INFO;
|
2015-10-08 09:45:32 +02:00
|
|
|
else if (!*mi->host)
|
|
|
|
{
|
|
|
|
slave_errno= ER_BAD_SLAVE; net_report= 0;
|
|
|
|
my_message(slave_errno, "Misconfigured slave: MASTER_HOST was not set; Fix in config file or with CHANGE MASTER TO",
|
|
|
|
MYF(0));
|
|
|
|
}
|
|
|
|
else
|
2003-09-13 22:13:41 +02:00
|
|
|
{
|
2005-02-09 20:04:28 +01:00
|
|
|
/*
|
2005-02-21 13:47:57 +01:00
|
|
|
If we will start SQL thread we will care about UNTIL options If
|
|
|
|
not and they are specified we will ignore them and warn user
|
|
|
|
about this fact.
|
2003-09-13 22:13:41 +02:00
|
|
|
*/
|
|
|
|
if (thread_mask & SLAVE_SQL)
|
|
|
|
{
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&mi->rli.data_lock);
|
2003-09-13 22:13:41 +02:00
|
|
|
|
2003-09-24 15:26:20 +02:00
|
|
|
if (thd->lex->mi.pos)
|
2003-09-13 22:13:41 +02:00
|
|
|
{
|
2012-11-30 07:42:33 +01:00
|
|
|
if (thd->lex->mi.relay_log_pos)
|
|
|
|
slave_errno=ER_BAD_SLAVE_UNTIL_COND;
|
2007-08-16 07:37:50 +02:00
|
|
|
mi->rli.until_condition= Relay_log_info::UNTIL_MASTER_POS;
|
2003-09-24 15:26:20 +02:00
|
|
|
mi->rli.until_log_pos= thd->lex->mi.pos;
|
2005-02-09 20:04:28 +01:00
|
|
|
/*
|
|
|
|
We don't check thd->lex->mi.log_file_name for NULL here
|
2003-09-13 22:13:41 +02:00
|
|
|
since it is checked in sql_yacc.yy
|
|
|
|
*/
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(mi->rli.until_log_name, thd->lex->mi.log_file_name);
|
2005-02-09 20:04:28 +01:00
|
|
|
}
|
2003-09-24 15:26:20 +02:00
|
|
|
else if (thd->lex->mi.relay_log_pos)
|
2003-09-13 22:13:41 +02:00
|
|
|
{
|
2007-08-16 07:37:50 +02:00
|
|
|
mi->rli.until_condition= Relay_log_info::UNTIL_RELAY_POS;
|
2003-09-24 15:26:20 +02:00
|
|
|
mi->rli.until_log_pos= thd->lex->mi.relay_log_pos;
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(mi->rli.until_log_name, thd->lex->mi.relay_log_name);
|
2003-09-13 22:13:41 +02:00
|
|
|
}
|
2013-05-15 19:52:21 +02:00
|
|
|
else if (thd->lex->mi.gtid_pos_str.str)
|
|
|
|
{
|
|
|
|
if (mi->rli.until_gtid_pos.load(thd->lex->mi.gtid_pos_str.str,
|
|
|
|
thd->lex->mi.gtid_pos_str.length))
|
|
|
|
{
|
|
|
|
slave_errno= ER_INCORRECT_GTID_STATE;
|
|
|
|
mysql_mutex_unlock(&mi->rli.data_lock);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
mi->rli.until_condition= Relay_log_info::UNTIL_GTID;
|
|
|
|
}
|
2003-09-13 22:13:41 +02:00
|
|
|
else
|
2006-10-31 12:23:14 +01:00
|
|
|
mi->rli.clear_until_condition();
|
2003-09-13 22:13:41 +02:00
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
if (mi->rli.until_condition == Relay_log_info::UNTIL_MASTER_POS ||
|
|
|
|
mi->rli.until_condition == Relay_log_info::UNTIL_RELAY_POS)
|
2003-09-13 22:13:41 +02:00
|
|
|
{
|
|
|
|
/* Preparing members for effective until condition checking */
|
|
|
|
const char *p= fn_ext(mi->rli.until_log_name);
|
|
|
|
char *p_end;
|
|
|
|
if (*p)
|
|
|
|
{
|
|
|
|
//p points to '.'
|
|
|
|
mi->rli.until_log_name_extension= strtoul(++p,&p_end, 10);
|
|
|
|
/*
|
|
|
|
p_end points to the first invalid character. If it equals
|
|
|
|
to p, no digits were found, error. If it contains '\0' it
|
|
|
|
means conversion went ok.
|
2005-02-09 20:04:28 +01:00
|
|
|
*/
|
2003-10-08 20:50:05 +02:00
|
|
|
if (p_end==p || *p_end)
|
2003-09-13 22:13:41 +02:00
|
|
|
slave_errno=ER_BAD_SLAVE_UNTIL_COND;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
slave_errno=ER_BAD_SLAVE_UNTIL_COND;
|
2005-02-09 20:04:28 +01:00
|
|
|
|
2003-09-13 22:13:41 +02:00
|
|
|
/* mark the cached result of the UNTIL comparison as "undefined" */
|
2005-02-09 20:04:28 +01:00
|
|
|
mi->rli.until_log_names_cmp_result=
|
2007-08-16 07:37:50 +02:00
|
|
|
Relay_log_info::UNTIL_LOG_NAMES_CMP_UNKNOWN;
|
2013-05-15 19:52:21 +02:00
|
|
|
}
|
2003-09-13 22:13:41 +02:00
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
if (mi->rli.until_condition != Relay_log_info::UNTIL_NONE)
|
|
|
|
{
|
2003-09-13 22:13:41 +02:00
|
|
|
/* Issuing warning then started without --skip-slave-start */
|
|
|
|
if (!opt_skip_slave_start)
|
2013-06-15 17:32:08 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE,
|
2006-04-13 09:50:33 +02:00
|
|
|
ER_MISSING_SKIP_SLAVE,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_THD(thd, ER_MISSING_SKIP_SLAVE));
|
2003-09-13 22:13:41 +02:00
|
|
|
}
|
2005-02-09 20:04:28 +01:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&mi->rli.data_lock);
|
2003-09-13 22:13:41 +02:00
|
|
|
}
|
2003-09-24 15:26:20 +02:00
|
|
|
else if (thd->lex->mi.pos || thd->lex->mi.relay_log_pos)
|
2015-07-06 19:24:14 +02:00
|
|
|
push_warning(thd,
|
|
|
|
Sql_condition::WARN_LEVEL_NOTE, ER_UNTIL_COND_IGNORED,
|
|
|
|
ER_THD(thd, ER_UNTIL_COND_IGNORED));
|
2005-02-09 20:04:28 +01:00
|
|
|
|
2003-10-08 20:50:05 +02:00
|
|
|
if (!slave_errno)
|
2015-07-15 15:27:14 +02:00
|
|
|
slave_errno = start_slave_threads(thd,
|
|
|
|
0 /*no mutex */,
|
2012-09-28 01:06:56 +02:00
|
|
|
1 /* wait for start */,
|
|
|
|
mi,
|
|
|
|
master_info_file_tmp,
|
|
|
|
relay_log_info_file_tmp,
|
|
|
|
thread_mask);
|
2003-09-13 22:13:41 +02:00
|
|
|
}
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
2000-10-02 05:28:21 +02:00
|
|
|
else
|
2005-02-21 13:47:57 +01:00
|
|
|
{
|
|
|
|
/* no error if all threads are already started, only a warning */
|
2013-06-15 17:32:08 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_SLAVE_WAS_RUNNING,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_THD(thd, ER_SLAVE_WAS_RUNNING));
|
2005-02-21 13:47:57 +01:00
|
|
|
}
|
2006-04-13 09:50:33 +02:00
|
|
|
|
2013-05-15 19:52:21 +02:00
|
|
|
err:
|
2002-01-20 03:16:52 +01:00
|
|
|
unlock_slave_threads(mi);
|
2014-08-06 14:39:15 +02:00
|
|
|
thd_proc_info(thd, 0);
|
2005-02-09 20:04:28 +01:00
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
if (slave_errno)
|
|
|
|
{
|
2002-01-20 03:16:52 +01:00
|
|
|
if (net_report)
|
2012-09-28 01:06:56 +02:00
|
|
|
my_error(slave_errno, MYF(0),
|
|
|
|
(int) mi->connection_name.length,
|
|
|
|
mi->connection_name.str);
|
2012-10-03 00:44:54 +02:00
|
|
|
DBUG_RETURN(slave_errno == ER_BAD_SLAVE ? -1 : 1);
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
2000-10-02 05:28:21 +02:00
|
|
|
|
2002-08-08 02:12:02 +02:00
|
|
|
DBUG_RETURN(0);
|
2000-10-02 05:28:21 +02:00
|
|
|
}
|
|
|
|
|
2002-10-02 12:33:08 +02:00
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
/**
|
|
|
|
Execute a STOP SLAVE statement.
|
|
|
|
|
|
|
|
@param thd Pointer to THD object for the client thread executing the
|
|
|
|
statement.
|
|
|
|
|
|
|
|
@param mi Pointer to Master_info object for the slave's IO thread.
|
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
@param net_report If true, saves the exit status into thd->stmt_da.
|
2009-01-09 13:49:24 +01:00
|
|
|
|
|
|
|
@retval 0 success
|
|
|
|
@retval 1 error
|
2012-10-03 00:44:54 +02:00
|
|
|
@retval -1 error
|
2009-01-09 13:49:24 +01:00
|
|
|
*/
|
2012-10-03 00:44:54 +02:00
|
|
|
|
2007-08-16 08:52:50 +02:00
|
|
|
int stop_slave(THD* thd, Master_info* mi, bool net_report )
|
2000-10-02 05:28:21 +02:00
|
|
|
{
|
2003-03-03 23:12:17 +01:00
|
|
|
int slave_errno;
|
2012-09-28 01:06:56 +02:00
|
|
|
DBUG_ENTER("stop_slave");
|
|
|
|
DBUG_PRINT("enter",("Connection: %s", mi->connection_name.str));
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
if (check_access(thd, SUPER_ACL, any_db, NULL, NULL, 0, 0))
|
2012-10-03 00:44:54 +02:00
|
|
|
DBUG_RETURN(-1);
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
THD_STAGE_INFO(thd, stage_killing_slave);
|
2002-01-20 03:16:52 +01:00
|
|
|
int thread_mask;
|
|
|
|
lock_slave_threads(mi);
|
2003-03-03 23:12:17 +01:00
|
|
|
// Get a mask of _running_ threads
|
2002-01-20 03:16:52 +01:00
|
|
|
init_thread_mask(&thread_mask,mi,0 /* not inverse*/);
|
2003-03-03 23:12:17 +01:00
|
|
|
/*
|
|
|
|
Below we will stop all running threads.
|
|
|
|
But if the user wants to stop only one thread, do as if the other thread
|
|
|
|
was stopped (as we don't wan't to touch the other thread), so set the
|
|
|
|
bit to 0 for the other thread
|
|
|
|
*/
|
2003-05-05 20:54:37 +02:00
|
|
|
if (thd->lex->slave_thd_opt)
|
|
|
|
thread_mask &= thd->lex->slave_thd_opt;
|
2003-03-03 23:12:17 +01:00
|
|
|
|
|
|
|
if (thread_mask)
|
|
|
|
{
|
|
|
|
slave_errno= terminate_slave_threads(mi,thread_mask,
|
|
|
|
1 /*skip lock */);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//no error if both threads are already stopped, only a warning
|
|
|
|
slave_errno= 0;
|
2013-06-15 17:32:08 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_SLAVE_WAS_NOT_RUNNING,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_THD(thd, ER_SLAVE_WAS_NOT_RUNNING));
|
2003-03-03 23:12:17 +01:00
|
|
|
}
|
2002-01-20 03:16:52 +01:00
|
|
|
unlock_slave_threads(mi);
|
2000-10-02 05:28:21 +02:00
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
if (slave_errno)
|
|
|
|
{
|
|
|
|
if (net_report)
|
2015-07-06 19:24:14 +02:00
|
|
|
my_message(slave_errno, ER_THD(thd, slave_errno), MYF(0));
|
2007-02-03 20:14:16 +01:00
|
|
|
DBUG_RETURN(1);
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
2000-10-02 05:28:21 +02:00
|
|
|
|
2007-02-03 20:14:16 +01:00
|
|
|
DBUG_RETURN(0);
|
2000-10-02 05:28:21 +02:00
|
|
|
}
|
|
|
|
|
2002-12-13 11:05:24 +01:00
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
/**
|
|
|
|
Execute a RESET SLAVE statement.
|
2002-12-13 11:05:24 +01:00
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
@param thd Pointer to THD object of the client thread executing the
|
|
|
|
statement.
|
2002-12-13 11:05:24 +01:00
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
@param mi Pointer to Master_info object for the slave.
|
2002-12-13 11:05:24 +01:00
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
@retval 0 success
|
|
|
|
@retval 1 error
|
|
|
|
*/
|
2007-08-16 08:52:50 +02:00
|
|
|
int reset_slave(THD *thd, Master_info* mi)
|
2000-10-02 05:28:21 +02:00
|
|
|
{
|
|
|
|
MY_STAT stat_area;
|
|
|
|
char fname[FN_REFLEN];
|
2002-12-13 11:05:24 +01:00
|
|
|
int thread_mask= 0, error= 0;
|
2010-01-24 08:03:23 +01:00
|
|
|
uint sql_errno=ER_UNKNOWN_ERROR;
|
2016-03-04 01:09:37 +01:00
|
|
|
const char* errmsg= "Unknown error occurred while reseting slave";
|
2012-09-28 01:06:56 +02:00
|
|
|
char master_info_file_tmp[FN_REFLEN];
|
|
|
|
char relay_log_info_file_tmp[FN_REFLEN];
|
2002-06-05 22:04:38 +02:00
|
|
|
DBUG_ENTER("reset_slave");
|
|
|
|
|
2002-01-20 03:16:52 +01:00
|
|
|
lock_slave_threads(mi);
|
2002-12-13 11:05:24 +01:00
|
|
|
init_thread_mask(&thread_mask,mi,0 /* not inverse */);
|
|
|
|
if (thread_mask) // We refuse if any slave thread is running
|
|
|
|
{
|
2012-10-03 00:44:54 +02:00
|
|
|
unlock_slave_threads(mi);
|
|
|
|
my_error(ER_SLAVE_MUST_STOP, MYF(0), (int) mi->connection_name.length,
|
|
|
|
mi->connection_name.str);
|
|
|
|
DBUG_RETURN(ER_SLAVE_MUST_STOP);
|
2002-12-13 11:05:24 +01:00
|
|
|
}
|
2006-01-12 19:51:02 +01:00
|
|
|
|
Replication: new code to not modify in-memory log positions until the COMMIT
is executed, even if the transaction spans on >=2 relay logs (bug #53).
New variable relay_log_purge =0|1
New test to verify bug #53
sql/log.cc:
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT.
sql/log_event.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/mysql_priv.h:
new option relay_log_purge (the user can now decide himself
if he wants his relay logs to be automatically purged or not,
we don't make unsafe guesses like before)
sql/mysqld.cc:
new option --innodb (replaces --skip-innodb).
Useful for the test suite : we have skip-innodb in mysql-test-run,
but we can ('-opt.info' file) choose to start the server with
InnoDB for this test only.
New option --bdb
sql/repl_failsafe.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/set_var.cc:
new variable relay_log_purge
sql/slave.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT
sql/slave.h:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/sql_class.h:
prototypes change
sql/sql_parse.cc:
removed thd argument (was not used in the function's body)
sql/sql_repl.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Turn relay_log_purge silently off when someone does CHANGE
MASTER TO RELAY_LOG_*
2003-04-24 15:29:25 +02:00
|
|
|
// delete relay logs, clear relay log coordinates
|
2002-12-13 11:05:24 +01:00
|
|
|
if ((error= purge_relay_logs(&mi->rli, thd,
|
|
|
|
1 /* just reset */,
|
|
|
|
&errmsg)))
|
2009-04-30 14:28:07 +02:00
|
|
|
{
|
|
|
|
sql_errno= ER_RELAY_LOG_FAIL;
|
2002-01-20 03:16:52 +01:00
|
|
|
goto err;
|
2009-04-30 14:28:07 +02:00
|
|
|
}
|
2005-02-09 20:04:28 +01:00
|
|
|
|
BUG#11809016 - NO WAY TO DISCOVER AN INSTANCE IS NO LONGER A SLAVE FOLLOWING MYSQL BUG#28796
Before BUG#28796, an empty host was used to identify that an instance was no
longer a slave. However, BUG#28796 changed this behavior and one cannot set
an empty host. Besides, a RESET SLAVE only cleans up information on the next
event to retrieve from the master, disables ssl and resets heartbeat period.
So a call to SHOW SLAVE STATUS after issuing a RESET SLAVE still returns some
valid information, such as host, port, user and password.
To fix this problem, we have introduced the command RESET SLAVE ALL that does
what a regular RESET SLAVE does and also clears host, port, user and password
information thus allowing users to identify when an instance is no longer a
slave.
2011-07-18 19:18:03 +02:00
|
|
|
/* Clear master's log coordinates and associated information */
|
|
|
|
mi->clear_in_memory_info(thd->lex->reset_slave_info.all);
|
|
|
|
|
2005-02-09 20:04:28 +01:00
|
|
|
/*
|
A change of behaviour of Seconds_Behind_Master from SHOW SLAVE STATUS. It's going into 4.1
because old behaviour was somewhat nonsensical (kind of bug). Changes are that if repl threads are
down or disconnected the column will be NULL, and if master is idle the column will not grow indefinitely anymore.
sql/slave.cc:
mi->slave_running and rli->slave_running now uints (was needed only for mi but because of start_slave_thread() usage,
had to change both).
So mi->slave_running can now take 3 values: not running, running & not connected, running and connected.
The last value serves for calculation of Seconds_Behind_Master in SHOW SLAVE STATUS.
Changing this column's behaviour: if SQL or I/O thread is not running, or if I/O thread is not connected
(for example if it is reconnecting), it's NULL (to mean "unknown"). And if master is idle, the column will
not grow indefinitely like it used to (that was meaningless); this is fixed by forcing a value of 0
when the slave SQL thread has hit EOF of relay log (which has only a limited number of caveats explained
in comments in code).
sql/slave.h:
slave_running used to be bool but we need to distinguish, for the I/O slave thread, between
"running & connected" and "running & not connected" ("running" means the thread exists).
sql/sql_repl.cc:
we don't need anymore to set rli->last_master_timestamp to 0 (we used that to make Seconds_Behind_Master
be NULL) in RESET SLAVE and CHANGE MASTER, as these commands imply that slave threads are not running
and so Seconds_Behind_Master is already NULL because of that.
2004-12-16 18:12:22 +01:00
|
|
|
Reset errors (the idea is that we forget about the
|
2003-10-09 00:06:21 +02:00
|
|
|
old master).
|
|
|
|
*/
|
2009-06-03 16:14:18 +02:00
|
|
|
mi->clear_error();
|
2007-06-09 07:19:37 +02:00
|
|
|
mi->rli.clear_error();
|
2006-10-31 12:23:14 +01:00
|
|
|
mi->rli.clear_until_condition();
|
2014-06-25 15:24:11 +02:00
|
|
|
mi->rli.slave_skip_counter= 0;
|
2005-02-09 20:04:28 +01:00
|
|
|
|
Replication: new code to not modify in-memory log positions until the COMMIT
is executed, even if the transaction spans on >=2 relay logs (bug #53).
New variable relay_log_purge =0|1
New test to verify bug #53
sql/log.cc:
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT.
sql/log_event.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/mysql_priv.h:
new option relay_log_purge (the user can now decide himself
if he wants his relay logs to be automatically purged or not,
we don't make unsafe guesses like before)
sql/mysqld.cc:
new option --innodb (replaces --skip-innodb).
Useful for the test suite : we have skip-innodb in mysql-test-run,
but we can ('-opt.info' file) choose to start the server with
InnoDB for this test only.
New option --bdb
sql/repl_failsafe.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/set_var.cc:
new variable relay_log_purge
sql/slave.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT
sql/slave.h:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/sql_class.h:
prototypes change
sql/sql_parse.cc:
removed thd argument (was not used in the function's body)
sql/sql_repl.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Turn relay_log_purge silently off when someone does CHANGE
MASTER TO RELAY_LOG_*
2003-04-24 15:29:25 +02:00
|
|
|
// close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0
|
2002-01-20 03:16:52 +01:00
|
|
|
end_master_info(mi);
|
2012-09-28 01:06:56 +02:00
|
|
|
|
Replication: new code to not modify in-memory log positions until the COMMIT
is executed, even if the transaction spans on >=2 relay logs (bug #53).
New variable relay_log_purge =0|1
New test to verify bug #53
sql/log.cc:
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT.
sql/log_event.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/mysql_priv.h:
new option relay_log_purge (the user can now decide himself
if he wants his relay logs to be automatically purged or not,
we don't make unsafe guesses like before)
sql/mysqld.cc:
new option --innodb (replaces --skip-innodb).
Useful for the test suite : we have skip-innodb in mysql-test-run,
but we can ('-opt.info' file) choose to start the server with
InnoDB for this test only.
New option --bdb
sql/repl_failsafe.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/set_var.cc:
new variable relay_log_purge
sql/slave.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT
sql/slave.h:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/sql_class.h:
prototypes change
sql/sql_parse.cc:
removed thd argument (was not used in the function's body)
sql/sql_repl.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Turn relay_log_purge silently off when someone does CHANGE
MASTER TO RELAY_LOG_*
2003-04-24 15:29:25 +02:00
|
|
|
// and delete these two files
|
2012-10-03 00:44:54 +02:00
|
|
|
create_logfile_name_with_suffix(master_info_file_tmp,
|
2013-05-03 00:50:42 +02:00
|
|
|
sizeof(master_info_file_tmp),
|
|
|
|
master_info_file, 0,
|
|
|
|
&mi->cmp_connection_name);
|
2012-10-03 00:44:54 +02:00
|
|
|
create_logfile_name_with_suffix(relay_log_info_file_tmp,
|
2013-05-03 00:50:42 +02:00
|
|
|
sizeof(relay_log_info_file_tmp),
|
|
|
|
relay_log_info_file, 0,
|
|
|
|
&mi->cmp_connection_name);
|
2012-09-28 01:06:56 +02:00
|
|
|
|
|
|
|
fn_format(fname, master_info_file_tmp, mysql_data_home, "", 4+32);
|
2010-01-07 06:42:07 +01:00
|
|
|
if (mysql_file_stat(key_file_master_info, fname, &stat_area, MYF(0)) &&
|
|
|
|
mysql_file_delete(key_file_master_info, fname, MYF(MY_WME)))
|
2001-07-10 14:53:08 +02:00
|
|
|
{
|
2002-01-20 03:16:52 +01:00
|
|
|
error=1;
|
|
|
|
goto err;
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
2012-09-28 01:06:56 +02:00
|
|
|
else if (global_system_variables.log_warnings > 1)
|
|
|
|
sql_print_information("Deleted Master_info file '%s'.", fname);
|
|
|
|
|
Replication: new code to not modify in-memory log positions until the COMMIT
is executed, even if the transaction spans on >=2 relay logs (bug #53).
New variable relay_log_purge =0|1
New test to verify bug #53
sql/log.cc:
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT.
sql/log_event.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/mysql_priv.h:
new option relay_log_purge (the user can now decide himself
if he wants his relay logs to be automatically purged or not,
we don't make unsafe guesses like before)
sql/mysqld.cc:
new option --innodb (replaces --skip-innodb).
Useful for the test suite : we have skip-innodb in mysql-test-run,
but we can ('-opt.info' file) choose to start the server with
InnoDB for this test only.
New option --bdb
sql/repl_failsafe.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/set_var.cc:
new variable relay_log_purge
sql/slave.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT
sql/slave.h:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/sql_class.h:
prototypes change
sql/sql_parse.cc:
removed thd argument (was not used in the function's body)
sql/sql_repl.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Turn relay_log_purge silently off when someone does CHANGE
MASTER TO RELAY_LOG_*
2003-04-24 15:29:25 +02:00
|
|
|
// delete relay_log_info_file
|
2012-09-28 01:06:56 +02:00
|
|
|
fn_format(fname, relay_log_info_file_tmp, mysql_data_home, "", 4+32);
|
2010-01-07 06:42:07 +01:00
|
|
|
if (mysql_file_stat(key_file_relay_log_info, fname, &stat_area, MYF(0)) &&
|
|
|
|
mysql_file_delete(key_file_relay_log_info, fname, MYF(MY_WME)))
|
2002-01-20 03:16:52 +01:00
|
|
|
{
|
|
|
|
error=1;
|
|
|
|
goto err;
|
|
|
|
}
|
2012-09-28 01:06:56 +02:00
|
|
|
else if (global_system_variables.log_warnings > 1)
|
|
|
|
sql_print_information("Deleted Master_info file '%s'.", fname);
|
2002-12-13 11:05:24 +01:00
|
|
|
|
2009-09-26 06:49:49 +02:00
|
|
|
RUN_HOOK(binlog_relay_io, after_reset_slave, (thd, mi));
|
2002-01-20 03:16:52 +01:00
|
|
|
err:
|
|
|
|
unlock_slave_threads(mi);
|
2004-11-12 13:34:00 +01:00
|
|
|
if (error)
|
now my_printf_error is not better then my_error, but my_error call is shorter
used only one implementation of format parser of (printf)
fixed multistatement
include/mysqld_error.h:
newerror messages
mysql-test/t/key.test:
unknown error replaced with real error
mysys/my_error.c:
my_error & my_printf_error use my_vsprintf
sql/field_conv.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/ha_innodb.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/handler.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_cmpfunc.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_func.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_strfunc.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/lock.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/log.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/parse_file.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/procedure.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/protocol.cc:
no need reset thd->lex->found_colon to break multiline sequance now, send_error called too late
sql/repl_failsafe.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/set_var.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/share/czech/errmsg.txt:
new errors converted from unknown error
sql/share/danish/errmsg.txt:
new errors converted from unknown error
sql/share/dutch/errmsg.txt:
new errors converted from unknown error
sql/share/english/errmsg.txt:
new errors converted from unknown error
sql/share/estonian/errmsg.txt:
new errors converted from unknown error
sql/share/french/errmsg.txt:
new errors converted from unknown error
sql/share/german/errmsg.txt:
new errors converted from unknown error
sql/share/greek/errmsg.txt:
new errors converted from unknown error
sql/share/hungarian/errmsg.txt:
new errors converted from unknown error
sql/share/italian/errmsg.txt:
new errors converted from unknown error
sql/share/japanese/errmsg.txt:
new errors converted from unknown error
sql/share/korean/errmsg.txt:
new errors converted from unknown error
sql/share/norwegian-ny/errmsg.txt:
new errors converted from unknown error
sql/share/norwegian/errmsg.txt:
new errors converted from unknown error
sql/share/polish/errmsg.txt:
new errors converted from unknown error
sql/share/portuguese/errmsg.txt:
new errors converted from unknown error
sql/share/romanian/errmsg.txt:
new errors converted from unknown error
sql/share/russian/errmsg.txt:
new errors converted from unknown error
sql/share/serbian/errmsg.txt:
new errors converted from unknown error
sql/share/slovak/errmsg.txt:
new errors converted from unknown error
sql/share/spanish/errmsg.txt:
new errors converted from unknown error
sql/share/swedish/errmsg.txt:
new errors converted from unknown error
sql/share/ukrainian/errmsg.txt:
new errors converted from unknown error
sql/slave.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sp.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sp_head.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_acl.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_analyse.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_base.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_class.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_db.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_delete.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_handler.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_insert.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_load.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_map.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_parse.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
multi-row command fixed
sql/sql_prepare.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
remover send_error ingected from 4.1
sql/sql_rename.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_repl.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_select.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_show.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_table.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_trigger.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_udf.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_update.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_view.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_yacc.yy:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/table.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
strings/my_vsnprintf.c:
* format support added to my_vsprint
2004-11-13 18:35:51 +01:00
|
|
|
my_error(sql_errno, MYF(0), errmsg);
|
2002-06-05 22:04:38 +02:00
|
|
|
DBUG_RETURN(error);
|
2000-10-02 05:28:21 +02:00
|
|
|
}
|
|
|
|
|
2003-07-03 01:08:36 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Kill all Binlog_dump threads which previously talked to the same slave
|
|
|
|
("same" means with the same server id). Indeed, if the slave stops, if the
|
2010-01-07 06:42:07 +01:00
|
|
|
Binlog_dump thread is waiting (mysql_cond_wait) for binlog update, then it
|
2003-07-03 01:08:36 +02:00
|
|
|
will keep existing until a query is written to the binlog. If the master is
|
|
|
|
idle, then this could last long, and if the slave reconnects, we could have 2
|
|
|
|
Binlog_dump threads in SHOW PROCESSLIST, until a query is written to the
|
|
|
|
binlog. To avoid this, when the slave reconnects and sends COM_BINLOG_DUMP,
|
2011-09-23 00:13:38 +02:00
|
|
|
the master kills any existing thread with the slave's server id (if this id
|
|
|
|
is not zero; it will be true for real slaves, but false for mysqlbinlog when
|
|
|
|
it sends COM_BINLOG_DUMP to get a remote binlog dump).
|
2003-07-03 01:08:36 +02:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
kill_zombie_dump_threads()
|
|
|
|
slave_server_id the slave's server id
|
|
|
|
*/
|
2006-04-13 09:50:33 +02:00
|
|
|
|
2000-10-02 05:28:21 +02:00
|
|
|
void kill_zombie_dump_threads(uint32 slave_server_id)
|
|
|
|
{
|
2010-01-12 02:47:27 +01:00
|
|
|
mysql_mutex_lock(&LOCK_thread_count);
|
2000-10-03 01:59:12 +02:00
|
|
|
I_List_iterator<THD> it(threads);
|
|
|
|
THD *tmp;
|
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
while ((tmp=it++))
|
|
|
|
{
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
if (tmp->get_command() == COM_BINLOG_DUMP &&
|
2012-10-23 12:46:29 +02:00
|
|
|
tmp->variables.server_id == slave_server_id)
|
2000-10-03 01:59:12 +02:00
|
|
|
{
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&tmp->LOCK_thd_data); // Lock from delete
|
2002-08-22 15:50:58 +02:00
|
|
|
break;
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
|
|
|
}
|
2010-01-12 02:47:27 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_thread_count);
|
2002-08-22 15:50:58 +02:00
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Here we do not call kill_one_thread() as
|
|
|
|
it will be slow because it will iterate through the list
|
|
|
|
again. We just to do kill the thread ourselves.
|
|
|
|
*/
|
2011-09-23 00:13:38 +02:00
|
|
|
tmp->awake(KILL_QUERY);
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&tmp->LOCK_thd_data);
|
2002-08-22 15:50:58 +02:00
|
|
|
}
|
2000-10-02 05:28:21 +02:00
|
|
|
}
|
|
|
|
|
2013-01-10 23:35:33 +01:00
|
|
|
/**
|
|
|
|
Get value for a string parameter with error checking
|
|
|
|
|
|
|
|
Note that in case of error the original string should not be updated!
|
|
|
|
|
|
|
|
@ret 0 ok
|
|
|
|
@ret 1 error
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool get_string_parameter(char *to, const char *from, size_t length,
|
2013-04-18 22:17:29 +02:00
|
|
|
const char *name, CHARSET_INFO *cs)
|
2013-01-10 23:35:33 +01:00
|
|
|
{
|
|
|
|
if (from) // Empty paramaters allowed
|
|
|
|
{
|
2013-04-18 22:17:29 +02:00
|
|
|
size_t from_length= strlen(from);
|
|
|
|
uint from_numchars= cs->cset->numchars(cs, from, from + from_length);
|
|
|
|
if (from_numchars > length / cs->mbmaxlen)
|
2013-01-10 23:35:33 +01:00
|
|
|
{
|
2013-04-18 22:17:29 +02:00
|
|
|
my_error(ER_WRONG_STRING_LENGTH, MYF(0), from, name, length / cs->mbmaxlen);
|
2013-01-10 23:35:33 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
memcpy(to, from, from_length+1);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
/**
|
|
|
|
Execute a CHANGE MASTER statement.
|
|
|
|
|
|
|
|
@param thd Pointer to THD object for the client thread executing the
|
|
|
|
statement.
|
|
|
|
|
|
|
|
@param mi Pointer to Master_info object belonging to the slave's IO
|
|
|
|
thread.
|
|
|
|
|
2013-01-30 15:11:36 +01:00
|
|
|
@param master_info_added Out parameter saying if the Master_info *mi was
|
|
|
|
added to the global list of masters. This is useful in error conditions
|
|
|
|
to know if caller should free Master_info *mi.
|
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
@retval FALSE success
|
|
|
|
@retval TRUE error
|
|
|
|
*/
|
2013-01-30 15:11:36 +01:00
|
|
|
bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
|
2000-10-02 05:28:21 +02:00
|
|
|
{
|
2002-12-13 11:05:24 +01:00
|
|
|
int thread_mask;
|
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
And a new test for this bug.
mysql-test/r/rpl_loaddata.result:
Now, after CHANGE MASTER the coordinates of the I/O thread are the last ones of the SQL thread, so result update.
sql/sql_repl.cc:
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
2003-11-18 17:31:17 +01:00
|
|
|
const char* errmsg= 0;
|
|
|
|
bool need_relay_log_purge= 1;
|
2009-10-01 18:44:53 +02:00
|
|
|
bool ret= FALSE;
|
2010-05-04 11:17:20 +02:00
|
|
|
char saved_host[HOSTNAME_LENGTH + 1];
|
|
|
|
uint saved_port;
|
|
|
|
char saved_log_name[FN_REFLEN];
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
Master_info::enum_using_gtid saved_using_gtid;
|
2012-09-28 01:06:56 +02:00
|
|
|
char master_info_file_tmp[FN_REFLEN];
|
|
|
|
char relay_log_info_file_tmp[FN_REFLEN];
|
2010-05-04 11:17:20 +02:00
|
|
|
my_off_t saved_log_pos;
|
2009-10-01 18:44:53 +02:00
|
|
|
LEX_MASTER_INFO* lex_mi= &thd->lex->mi;
|
2014-12-04 04:30:48 +01:00
|
|
|
DYNAMIC_ARRAY *do_ids, *ignore_ids;
|
|
|
|
|
2002-06-08 20:02:01 +02:00
|
|
|
DBUG_ENTER("change_master");
|
2002-12-13 11:05:24 +01:00
|
|
|
|
2014-09-06 08:33:56 +02:00
|
|
|
mysql_mutex_assert_owner(&LOCK_active_mi);
|
|
|
|
DBUG_ASSERT(master_info_index);
|
|
|
|
|
2013-01-30 15:11:36 +01:00
|
|
|
*master_info_added= false;
|
2009-09-29 16:09:46 +02:00
|
|
|
/*
|
|
|
|
We need to check if there is an empty master_host. Otherwise
|
|
|
|
change master succeeds, a master.info file is created containing
|
|
|
|
empty master_host string and when issuing: start slave; an error
|
|
|
|
is thrown stating that the server is not configured as slave.
|
|
|
|
(See BUG#28796).
|
|
|
|
*/
|
2012-09-28 01:06:56 +02:00
|
|
|
if (lex_mi->host && !*lex_mi->host)
|
2009-09-29 16:09:46 +02:00
|
|
|
{
|
|
|
|
my_error(ER_WRONG_ARGUMENTS, MYF(0), "MASTER_HOST");
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2012-09-28 01:06:56 +02:00
|
|
|
if (master_info_index->check_duplicate_master_info(&lex_mi->connection_name,
|
|
|
|
lex_mi->host,
|
|
|
|
lex_mi->port))
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
|
2002-01-20 03:16:52 +01:00
|
|
|
lock_slave_threads(mi);
|
2002-12-13 11:05:24 +01:00
|
|
|
init_thread_mask(&thread_mask,mi,0 /*not inverse*/);
|
|
|
|
if (thread_mask) // We refuse if any slave thread is running
|
2002-01-20 03:16:52 +01:00
|
|
|
{
|
2012-10-03 00:44:54 +02:00
|
|
|
my_error(ER_SLAVE_MUST_STOP, MYF(0), (int) mi->connection_name.length,
|
|
|
|
mi->connection_name.str);
|
2009-10-01 18:44:53 +02:00
|
|
|
ret= TRUE;
|
|
|
|
goto err;
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
2002-12-13 11:05:24 +01:00
|
|
|
|
2012-10-19 20:38:59 +02:00
|
|
|
THD_STAGE_INFO(thd, stage_changing_master);
|
2012-09-28 01:06:56 +02:00
|
|
|
|
2012-10-03 00:44:54 +02:00
|
|
|
create_logfile_name_with_suffix(master_info_file_tmp,
|
2013-05-03 00:50:42 +02:00
|
|
|
sizeof(master_info_file_tmp),
|
|
|
|
master_info_file, 0,
|
|
|
|
&mi->cmp_connection_name);
|
2012-10-03 00:44:54 +02:00
|
|
|
create_logfile_name_with_suffix(relay_log_info_file_tmp,
|
2013-05-03 00:50:42 +02:00
|
|
|
sizeof(relay_log_info_file_tmp),
|
|
|
|
relay_log_info_file, 0,
|
|
|
|
&mi->cmp_connection_name);
|
2012-09-28 01:06:56 +02:00
|
|
|
|
|
|
|
/* if new Master_info doesn't exists, add it */
|
|
|
|
if (!master_info_index->get_master_info(&mi->connection_name,
|
2013-06-15 17:32:08 +02:00
|
|
|
Sql_condition::WARN_LEVEL_NOTE))
|
2009-09-29 16:09:46 +02:00
|
|
|
{
|
2012-09-28 01:06:56 +02:00
|
|
|
if (master_info_index->add_master_info(mi, TRUE))
|
|
|
|
{
|
|
|
|
my_error(ER_MASTER_INFO, MYF(0),
|
|
|
|
(int) lex_mi->connection_name.length,
|
|
|
|
lex_mi->connection_name.str);
|
|
|
|
ret= TRUE;
|
|
|
|
goto err;
|
|
|
|
}
|
2013-01-30 15:11:36 +01:00
|
|
|
*master_info_added= true;
|
2009-09-29 16:09:46 +02:00
|
|
|
}
|
2012-09-28 01:06:56 +02:00
|
|
|
if (global_system_variables.log_warnings > 1)
|
2015-07-17 00:50:26 +02:00
|
|
|
sql_print_information("Master connection name: '%.*s' "
|
|
|
|
"Master_info_file: '%s' "
|
2012-09-28 01:06:56 +02:00
|
|
|
"Relay_info_file: '%s'",
|
|
|
|
(int) mi->connection_name.length,
|
|
|
|
mi->connection_name.str,
|
|
|
|
master_info_file_tmp, relay_log_info_file_tmp);
|
|
|
|
|
|
|
|
if (init_master_info(mi, master_info_file_tmp, relay_log_info_file_tmp, 0,
|
2004-11-25 09:26:45 +01:00
|
|
|
thread_mask))
|
2001-07-10 14:53:08 +02:00
|
|
|
{
|
2012-09-28 01:06:56 +02:00
|
|
|
my_error(ER_MASTER_INFO, MYF(0),
|
|
|
|
(int) lex_mi->connection_name.length,
|
|
|
|
lex_mi->connection_name.str);
|
2009-10-01 18:44:53 +02:00
|
|
|
ret= TRUE;
|
|
|
|
goto err;
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
|
|
|
|
2002-08-08 02:12:02 +02:00
|
|
|
/*
|
|
|
|
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
|
2002-03-30 20:36:05 +01:00
|
|
|
*/
|
2003-07-24 22:29:09 +02:00
|
|
|
|
2010-05-04 11:17:20 +02:00
|
|
|
/*
|
|
|
|
Before processing the command, save the previous state.
|
|
|
|
*/
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(saved_host, mi->host);
|
2010-05-04 11:17:20 +02:00
|
|
|
saved_port= mi->port;
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(saved_log_name, mi->master_log_name);
|
2010-05-04 11:17:20 +02:00
|
|
|
saved_log_pos= mi->master_log_pos;
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
saved_using_gtid= mi->using_gtid;
|
2010-05-04 11:17:20 +02:00
|
|
|
|
2003-07-24 22:29:09 +02:00
|
|
|
/*
|
2006-04-13 09:50:33 +02:00
|
|
|
If the user specified host or port without binlog or position,
|
2003-07-24 22:29:09 +02:00
|
|
|
reset binlog's name to FIRST and position to 4.
|
2006-04-13 09:50:33 +02:00
|
|
|
*/
|
2003-07-24 22:29:09 +02:00
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
if ((lex_mi->host || lex_mi->port) && !lex_mi->log_file_name && !lex_mi->pos)
|
|
|
|
{
|
2002-01-20 03:16:52 +01:00
|
|
|
mi->master_log_name[0] = 0;
|
2002-06-08 20:02:01 +02:00
|
|
|
mi->master_log_pos= BIN_LOG_HEADER_SIZE;
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
2000-10-02 05:28:21 +02:00
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
if (lex_mi->log_file_name)
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(mi->master_log_name, lex_mi->log_file_name);
|
2001-07-10 14:53:08 +02:00
|
|
|
if (lex_mi->pos)
|
2001-06-01 00:54:16 +02:00
|
|
|
{
|
2002-06-08 20:02:01 +02:00
|
|
|
mi->master_log_pos= lex_mi->pos;
|
2001-06-01 00:54:16 +02:00
|
|
|
}
|
2006-11-20 21:42:06 +01:00
|
|
|
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2013-01-10 23:35:33 +01:00
|
|
|
if (get_string_parameter(mi->host, lex_mi->host, sizeof(mi->host)-1,
|
2013-04-18 22:17:29 +02:00
|
|
|
"MASTER_HOST", system_charset_info) ||
|
2013-01-10 23:35:33 +01:00
|
|
|
get_string_parameter(mi->user, lex_mi->user, sizeof(mi->user)-1,
|
2013-04-18 22:17:29 +02:00
|
|
|
"MASTER_USER", system_charset_info) ||
|
2013-01-10 23:35:33 +01:00
|
|
|
get_string_parameter(mi->password, lex_mi->password,
|
2013-04-18 22:17:29 +02:00
|
|
|
sizeof(mi->password)-1, "MASTER_PASSWORD",
|
|
|
|
&my_charset_bin))
|
2013-01-10 23:35:33 +01:00
|
|
|
{
|
|
|
|
ret= TRUE;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
if (lex_mi->port)
|
2002-01-20 03:16:52 +01:00
|
|
|
mi->port = lex_mi->port;
|
2001-07-10 14:53:08 +02:00
|
|
|
if (lex_mi->connect_retry)
|
2002-01-20 03:16:52 +01:00
|
|
|
mi->connect_retry = lex_mi->connect_retry;
|
2009-09-29 13:16:23 +02:00
|
|
|
if (lex_mi->heartbeat_opt != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
|
|
|
|
mi->heartbeat_period = lex_mi->heartbeat_period;
|
|
|
|
else
|
2013-03-25 23:03:13 +01:00
|
|
|
mi->heartbeat_period= (float) MY_MIN(SLAVE_MAX_HEARTBEAT_PERIOD,
|
2009-09-29 13:16:23 +02:00
|
|
|
(slave_net_timeout/2.0));
|
2013-04-07 14:00:16 +02:00
|
|
|
mi->received_heartbeats= 0; // counter lives until master is CHANGEd
|
2014-12-04 04:30:48 +01:00
|
|
|
|
2009-10-01 18:44:53 +02:00
|
|
|
/*
|
2014-12-04 04:30:48 +01:00
|
|
|
Reset the last time server_id list if the current CHANGE MASTER
|
2009-10-01 18:44:53 +02:00
|
|
|
is mentioning IGNORE_SERVER_IDS= (...)
|
|
|
|
*/
|
|
|
|
if (lex_mi->repl_ignore_server_ids_opt == LEX_MASTER_INFO::LEX_MI_ENABLE)
|
|
|
|
{
|
2014-12-04 04:30:48 +01:00
|
|
|
/* Check if the list contains replicate_same_server_id */
|
|
|
|
for (uint i= 0; i < lex_mi->repl_ignore_server_ids.elements; i ++)
|
2009-10-01 18:44:53 +02:00
|
|
|
{
|
2014-12-04 04:30:48 +01:00
|
|
|
ulong s_id;
|
|
|
|
get_dynamic(&lex_mi->repl_ignore_server_ids, (uchar*) &s_id, i);
|
|
|
|
if (s_id == global_system_variables.server_id && replicate_same_server_id)
|
|
|
|
{
|
|
|
|
my_error(ER_SLAVE_IGNORE_SERVER_IDS, MYF(0), static_cast<int>(s_id));
|
|
|
|
ret= TRUE;
|
|
|
|
goto err;
|
|
|
|
}
|
2009-10-01 18:44:53 +02:00
|
|
|
}
|
2014-12-04 04:30:48 +01:00
|
|
|
|
|
|
|
/* All ok. Update the old server ids with the new ones. */
|
|
|
|
update_change_master_ids(&lex_mi->repl_ignore_server_ids,
|
|
|
|
&mi->ignore_server_ids);
|
2009-10-01 18:44:53 +02:00
|
|
|
}
|
2006-04-13 09:50:33 +02:00
|
|
|
|
2009-09-29 13:16:23 +02:00
|
|
|
if (lex_mi->ssl != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
|
|
|
|
mi->ssl= (lex_mi->ssl == LEX_MASTER_INFO::LEX_MI_ENABLE);
|
2007-03-29 15:09:57 +02:00
|
|
|
|
2009-09-29 13:16:23 +02:00
|
|
|
if (lex_mi->ssl_verify_server_cert != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
|
2007-03-29 15:09:57 +02:00
|
|
|
mi->ssl_verify_server_cert=
|
2009-09-29 13:16:23 +02:00
|
|
|
(lex_mi->ssl_verify_server_cert == LEX_MASTER_INFO::LEX_MI_ENABLE);
|
2007-03-29 15:09:57 +02:00
|
|
|
|
2003-09-01 13:16:20 +02:00
|
|
|
if (lex_mi->ssl_ca)
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(mi->ssl_ca, lex_mi->ssl_ca);
|
2003-09-01 13:16:20 +02:00
|
|
|
if (lex_mi->ssl_capath)
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(mi->ssl_capath, lex_mi->ssl_capath);
|
2003-09-01 13:16:20 +02:00
|
|
|
if (lex_mi->ssl_cert)
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(mi->ssl_cert, lex_mi->ssl_cert);
|
2003-09-01 13:16:20 +02:00
|
|
|
if (lex_mi->ssl_cipher)
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(mi->ssl_cipher, lex_mi->ssl_cipher);
|
2003-09-01 13:16:20 +02:00
|
|
|
if (lex_mi->ssl_key)
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(mi->ssl_key, lex_mi->ssl_key);
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
if (lex_mi->ssl_crl)
|
2013-06-06 21:32:29 +02:00
|
|
|
strmake_buf(mi->ssl_crl, lex_mi->ssl_crl);
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
if (lex_mi->ssl_crlpath)
|
2013-06-06 21:32:29 +02:00
|
|
|
strmake_buf(mi->ssl_crlpath, lex_mi->ssl_crlpath);
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
|
2003-09-01 13:16:20 +02:00
|
|
|
#ifndef HAVE_OPENSSL
|
|
|
|
if (lex_mi->ssl || lex_mi->ssl_ca || lex_mi->ssl_capath ||
|
2007-03-29 15:09:57 +02:00
|
|
|
lex_mi->ssl_cert || lex_mi->ssl_cipher || lex_mi->ssl_key ||
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
lex_mi->ssl_verify_server_cert || lex_mi->ssl_crl || lex_mi->ssl_crlpath)
|
2013-06-15 17:32:08 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_SLAVE_IGNORED_SSL_PARAMS,
|
|
|
|
ER_THD(thd, ER_SLAVE_IGNORED_SSL_PARAMS));
|
2003-09-01 13:16:20 +02:00
|
|
|
#endif
|
2002-01-20 03:16:52 +01:00
|
|
|
|
2002-03-16 02:44:44 +01:00
|
|
|
if (lex_mi->relay_log_name)
|
|
|
|
{
|
2003-03-17 22:51:56 +01:00
|
|
|
need_relay_log_purge= 0;
|
2009-10-02 10:35:03 +02:00
|
|
|
char relay_log_name[FN_REFLEN];
|
|
|
|
mi->rli.relay_log.make_log_name(relay_log_name, lex_mi->relay_log_name);
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(mi->rli.group_relay_log_name, relay_log_name);
|
|
|
|
strmake_buf(mi->rli.event_relay_log_name, relay_log_name);
|
2002-03-16 02:44:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lex_mi->relay_log_pos)
|
|
|
|
{
|
2003-03-17 22:51:56 +01:00
|
|
|
need_relay_log_purge= 0;
|
Replication: new code to not modify in-memory log positions until the COMMIT
is executed, even if the transaction spans on >=2 relay logs (bug #53).
New variable relay_log_purge =0|1
New test to verify bug #53
sql/log.cc:
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT.
sql/log_event.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/mysql_priv.h:
new option relay_log_purge (the user can now decide himself
if he wants his relay logs to be automatically purged or not,
we don't make unsafe guesses like before)
sql/mysqld.cc:
new option --innodb (replaces --skip-innodb).
Useful for the test suite : we have skip-innodb in mysql-test-run,
but we can ('-opt.info' file) choose to start the server with
InnoDB for this test only.
New option --bdb
sql/repl_failsafe.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/set_var.cc:
new variable relay_log_purge
sql/slave.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT
sql/slave.h:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/sql_class.h:
prototypes change
sql/sql_parse.cc:
removed thd argument (was not used in the function's body)
sql/sql_repl.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Turn relay_log_purge silently off when someone does CHANGE
MASTER TO RELAY_LOG_*
2003-04-24 15:29:25 +02:00
|
|
|
mi->rli.group_relay_log_pos= mi->rli.event_relay_log_pos= lex_mi->relay_log_pos;
|
2002-03-16 02:44:44 +01:00
|
|
|
}
|
|
|
|
|
2013-05-22 17:36:48 +02:00
|
|
|
if (lex_mi->use_gtid_opt == LEX_MASTER_INFO::LEX_GTID_SLAVE_POS)
|
|
|
|
mi->using_gtid= Master_info::USE_GTID_SLAVE_POS;
|
|
|
|
else if (lex_mi->use_gtid_opt == LEX_MASTER_INFO::LEX_GTID_CURRENT_POS)
|
|
|
|
mi->using_gtid= Master_info::USE_GTID_CURRENT_POS;
|
|
|
|
else if (lex_mi->use_gtid_opt == LEX_MASTER_INFO::LEX_GTID_NO ||
|
2013-01-22 15:18:36 +01:00
|
|
|
lex_mi->log_file_name || lex_mi->pos ||
|
|
|
|
lex_mi->relay_log_name || lex_mi->relay_log_pos)
|
2013-05-22 17:36:48 +02:00
|
|
|
mi->using_gtid= Master_info::USE_GTID_NO;
|
2013-01-22 15:18:36 +01:00
|
|
|
|
2014-12-04 04:30:48 +01:00
|
|
|
do_ids= ((lex_mi->repl_do_domain_ids_opt ==
|
|
|
|
LEX_MASTER_INFO::LEX_MI_ENABLE) ?
|
|
|
|
&lex_mi->repl_do_domain_ids : NULL);
|
|
|
|
|
|
|
|
ignore_ids= ((lex_mi->repl_ignore_domain_ids_opt ==
|
|
|
|
LEX_MASTER_INFO::LEX_MI_ENABLE) ?
|
|
|
|
&lex_mi->repl_ignore_domain_ids : NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Note: mi->using_gtid stores the previous state in case no MASTER_USE_GTID
|
|
|
|
is specified.
|
|
|
|
*/
|
|
|
|
if (mi->domain_id_filter.update_ids(do_ids, ignore_ids, mi->using_gtid))
|
|
|
|
{
|
|
|
|
my_error(ER_MASTER_INFO, MYF(0),
|
|
|
|
(int) lex_mi->connection_name.length,
|
|
|
|
lex_mi->connection_name.str);
|
|
|
|
ret= TRUE;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
And a new test for this bug.
mysql-test/r/rpl_loaddata.result:
Now, after CHANGE MASTER the coordinates of the I/O thread are the last ones of the SQL thread, so result update.
sql/sql_repl.cc:
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
2003-11-18 17:31:17 +01:00
|
|
|
/*
|
|
|
|
If user did specify neither host nor port nor any log name nor any log
|
|
|
|
pos, i.e. he specified only user/password/master_connect_retry, he probably
|
|
|
|
wants replication to resume from where it had left, i.e. from the
|
|
|
|
coordinates of the **SQL** thread (imagine the case where the I/O is ahead
|
|
|
|
of the SQL; restarting from the coordinates of the I/O would lose some
|
|
|
|
events which is probably unwanted when you are just doing minor changes
|
|
|
|
like changing master_connect_retry).
|
|
|
|
A side-effect is that if only the I/O thread was started, this thread may
|
|
|
|
restart from ''/4 after the CHANGE MASTER. That's a minor problem (it is a
|
|
|
|
much more unlikely situation than the one we are fixing here).
|
|
|
|
Note: coordinates of the SQL thread must be read here, before the
|
|
|
|
'if (need_relay_log_purge)' block which resets them.
|
|
|
|
*/
|
|
|
|
if (!lex_mi->host && !lex_mi->port &&
|
|
|
|
!lex_mi->log_file_name && !lex_mi->pos &&
|
|
|
|
need_relay_log_purge)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
|
2013-03-25 23:03:13 +01:00
|
|
|
not initialized), so we use a MY_MAX().
|
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
And a new test for this bug.
mysql-test/r/rpl_loaddata.result:
Now, after CHANGE MASTER the coordinates of the I/O thread are the last ones of the SQL thread, so result update.
sql/sql_repl.cc:
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
2003-11-18 17:31:17 +01:00
|
|
|
What happens to mi->rli.master_log_pos during the initialization stages
|
|
|
|
of replication is not 100% clear, so we guard against problems using
|
2013-03-25 23:03:13 +01:00
|
|
|
MY_MAX().
|
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
And a new test for this bug.
mysql-test/r/rpl_loaddata.result:
Now, after CHANGE MASTER the coordinates of the I/O thread are the last ones of the SQL thread, so result update.
sql/sql_repl.cc:
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
2003-11-18 17:31:17 +01:00
|
|
|
*/
|
2013-03-25 23:03:13 +01:00
|
|
|
mi->master_log_pos = MY_MAX(BIN_LOG_HEADER_SIZE,
|
2003-11-21 00:53:01 +01:00
|
|
|
mi->rli.group_master_log_pos);
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(mi->master_log_name, mi->rli.group_master_log_name);
|
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
And a new test for this bug.
mysql-test/r/rpl_loaddata.result:
Now, after CHANGE MASTER the coordinates of the I/O thread are the last ones of the SQL thread, so result update.
sql/sql_repl.cc:
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
2003-11-18 17:31:17 +01:00
|
|
|
}
|
2013-02-15 15:55:17 +01:00
|
|
|
|
2003-11-23 17:02:59 +01:00
|
|
|
/*
|
|
|
|
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
|
|
|
|
a slave before).
|
|
|
|
*/
|
2010-02-03 17:56:17 +01:00
|
|
|
if (flush_master_info(mi, FALSE, FALSE))
|
2006-01-03 17:54:54 +01:00
|
|
|
{
|
|
|
|
my_error(ER_RELAY_LOG_INIT, MYF(0), "Failed to flush master info file");
|
2009-10-01 18:44:53 +02:00
|
|
|
ret= TRUE;
|
|
|
|
goto err;
|
2006-01-03 17:54:54 +01:00
|
|
|
}
|
2002-03-16 02:44:44 +01:00
|
|
|
if (need_relay_log_purge)
|
2002-01-20 03:16:52 +01:00
|
|
|
{
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
THD_STAGE_INFO(thd, stage_purging_old_relay_logs);
|
2002-08-08 02:12:02 +02:00
|
|
|
if (purge_relay_logs(&mi->rli, thd,
|
|
|
|
0 /* not only reset, but also reinit */,
|
2002-03-16 02:44:44 +01:00
|
|
|
&errmsg))
|
|
|
|
{
|
now my_printf_error is not better then my_error, but my_error call is shorter
used only one implementation of format parser of (printf)
fixed multistatement
include/mysqld_error.h:
newerror messages
mysql-test/t/key.test:
unknown error replaced with real error
mysys/my_error.c:
my_error & my_printf_error use my_vsprintf
sql/field_conv.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/ha_innodb.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/handler.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_cmpfunc.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_func.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_strfunc.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/lock.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/log.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/parse_file.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/procedure.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/protocol.cc:
no need reset thd->lex->found_colon to break multiline sequance now, send_error called too late
sql/repl_failsafe.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/set_var.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/share/czech/errmsg.txt:
new errors converted from unknown error
sql/share/danish/errmsg.txt:
new errors converted from unknown error
sql/share/dutch/errmsg.txt:
new errors converted from unknown error
sql/share/english/errmsg.txt:
new errors converted from unknown error
sql/share/estonian/errmsg.txt:
new errors converted from unknown error
sql/share/french/errmsg.txt:
new errors converted from unknown error
sql/share/german/errmsg.txt:
new errors converted from unknown error
sql/share/greek/errmsg.txt:
new errors converted from unknown error
sql/share/hungarian/errmsg.txt:
new errors converted from unknown error
sql/share/italian/errmsg.txt:
new errors converted from unknown error
sql/share/japanese/errmsg.txt:
new errors converted from unknown error
sql/share/korean/errmsg.txt:
new errors converted from unknown error
sql/share/norwegian-ny/errmsg.txt:
new errors converted from unknown error
sql/share/norwegian/errmsg.txt:
new errors converted from unknown error
sql/share/polish/errmsg.txt:
new errors converted from unknown error
sql/share/portuguese/errmsg.txt:
new errors converted from unknown error
sql/share/romanian/errmsg.txt:
new errors converted from unknown error
sql/share/russian/errmsg.txt:
new errors converted from unknown error
sql/share/serbian/errmsg.txt:
new errors converted from unknown error
sql/share/slovak/errmsg.txt:
new errors converted from unknown error
sql/share/spanish/errmsg.txt:
new errors converted from unknown error
sql/share/swedish/errmsg.txt:
new errors converted from unknown error
sql/share/ukrainian/errmsg.txt:
new errors converted from unknown error
sql/slave.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sp.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sp_head.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_acl.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_analyse.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_base.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_class.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_db.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_delete.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_handler.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_insert.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_load.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_map.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_parse.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
multi-row command fixed
sql/sql_prepare.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
remover send_error ingected from 4.1
sql/sql_rename.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_repl.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_select.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_show.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_table.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_trigger.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_udf.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_update.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_view.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_yacc.yy:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/table.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
strings/my_vsnprintf.c:
* format support added to my_vsprint
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_RELAY_LOG_FAIL, MYF(0), errmsg);
|
2009-10-01 18:44:53 +02:00
|
|
|
ret= TRUE;
|
|
|
|
goto err;
|
2002-03-16 02:44:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const char* msg;
|
2002-08-08 02:12:02 +02:00
|
|
|
/* Relay log is already initialized */
|
|
|
|
if (init_relay_log_pos(&mi->rli,
|
Replication: new code to not modify in-memory log positions until the COMMIT
is executed, even if the transaction spans on >=2 relay logs (bug #53).
New variable relay_log_purge =0|1
New test to verify bug #53
sql/log.cc:
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT.
sql/log_event.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/mysql_priv.h:
new option relay_log_purge (the user can now decide himself
if he wants his relay logs to be automatically purged or not,
we don't make unsafe guesses like before)
sql/mysqld.cc:
new option --innodb (replaces --skip-innodb).
Useful for the test suite : we have skip-innodb in mysql-test-run,
but we can ('-opt.info' file) choose to start the server with
InnoDB for this test only.
New option --bdb
sql/repl_failsafe.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/set_var.cc:
new variable relay_log_purge
sql/slave.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT
sql/slave.h:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/sql_class.h:
prototypes change
sql/sql_parse.cc:
removed thd argument (was not used in the function's body)
sql/sql_repl.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Turn relay_log_purge silently off when someone does CHANGE
MASTER TO RELAY_LOG_*
2003-04-24 15:29:25 +02:00
|
|
|
mi->rli.group_relay_log_name,
|
|
|
|
mi->rli.group_relay_log_pos,
|
2002-03-16 02:44:44 +01:00
|
|
|
0 /*no data lock*/,
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
&msg, 0))
|
2002-03-16 02:44:44 +01:00
|
|
|
{
|
now my_printf_error is not better then my_error, but my_error call is shorter
used only one implementation of format parser of (printf)
fixed multistatement
include/mysqld_error.h:
newerror messages
mysql-test/t/key.test:
unknown error replaced with real error
mysys/my_error.c:
my_error & my_printf_error use my_vsprintf
sql/field_conv.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/ha_innodb.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/handler.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_cmpfunc.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_func.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_strfunc.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/lock.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/log.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/parse_file.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/procedure.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/protocol.cc:
no need reset thd->lex->found_colon to break multiline sequance now, send_error called too late
sql/repl_failsafe.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/set_var.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/share/czech/errmsg.txt:
new errors converted from unknown error
sql/share/danish/errmsg.txt:
new errors converted from unknown error
sql/share/dutch/errmsg.txt:
new errors converted from unknown error
sql/share/english/errmsg.txt:
new errors converted from unknown error
sql/share/estonian/errmsg.txt:
new errors converted from unknown error
sql/share/french/errmsg.txt:
new errors converted from unknown error
sql/share/german/errmsg.txt:
new errors converted from unknown error
sql/share/greek/errmsg.txt:
new errors converted from unknown error
sql/share/hungarian/errmsg.txt:
new errors converted from unknown error
sql/share/italian/errmsg.txt:
new errors converted from unknown error
sql/share/japanese/errmsg.txt:
new errors converted from unknown error
sql/share/korean/errmsg.txt:
new errors converted from unknown error
sql/share/norwegian-ny/errmsg.txt:
new errors converted from unknown error
sql/share/norwegian/errmsg.txt:
new errors converted from unknown error
sql/share/polish/errmsg.txt:
new errors converted from unknown error
sql/share/portuguese/errmsg.txt:
new errors converted from unknown error
sql/share/romanian/errmsg.txt:
new errors converted from unknown error
sql/share/russian/errmsg.txt:
new errors converted from unknown error
sql/share/serbian/errmsg.txt:
new errors converted from unknown error
sql/share/slovak/errmsg.txt:
new errors converted from unknown error
sql/share/spanish/errmsg.txt:
new errors converted from unknown error
sql/share/swedish/errmsg.txt:
new errors converted from unknown error
sql/share/ukrainian/errmsg.txt:
new errors converted from unknown error
sql/slave.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sp.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sp_head.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_acl.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_analyse.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_base.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_class.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_db.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_delete.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_handler.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_insert.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_load.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_map.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_parse.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
multi-row command fixed
sql/sql_prepare.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
remover send_error ingected from 4.1
sql/sql_rename.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_repl.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_select.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_show.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_table.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_trigger.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_udf.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_update.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_view.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_yacc.yy:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/table.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
strings/my_vsnprintf.c:
* format support added to my_vsprint
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_RELAY_LOG_INIT, MYF(0), msg);
|
2009-10-01 18:44:53 +02:00
|
|
|
ret= TRUE;
|
|
|
|
goto err;
|
2002-03-16 02:44:44 +01:00
|
|
|
}
|
2002-01-20 03:16:52 +01:00
|
|
|
}
|
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
And a new test for this bug.
mysql-test/r/rpl_loaddata.result:
Now, after CHANGE MASTER the coordinates of the I/O thread are the last ones of the SQL thread, so result update.
sql/sql_repl.cc:
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
2003-11-18 17:31:17 +01:00
|
|
|
/*
|
|
|
|
Coordinates in rli were spoilt by the 'if (need_relay_log_purge)' block,
|
|
|
|
so restore them to good values. If we left them to ''/0, that would work;
|
|
|
|
but that would fail in the case of 2 successive CHANGE MASTER (without a
|
|
|
|
START SLAVE in between): because first one would set the coords in mi to
|
|
|
|
the good values of those in rli, the set those in rli to ''/0, then
|
|
|
|
second CHANGE MASTER would set the coords in mi to those of rli, i.e. to
|
|
|
|
''/0: we have lost all copies of the original good coordinates.
|
|
|
|
That's why we always save good coords in rli.
|
|
|
|
*/
|
2003-08-18 23:08:08 +02:00
|
|
|
mi->rli.group_master_log_pos= mi->master_log_pos;
|
2007-12-21 09:13:54 +01:00
|
|
|
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(mi->rli.group_master_log_name,mi->master_log_name);
|
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
And a new test for this bug.
mysql-test/r/rpl_loaddata.result:
Now, after CHANGE MASTER the coordinates of the I/O thread are the last ones of the SQL thread, so result update.
sql/sql_repl.cc:
Fix for BUG#1870
"CHANGE MASTER makes SQL thread restart from coordinates of I/O thread".
So, in CHANGE MASTER:
when it seems reasonable that the user did not want to discontinue
its replication (i.e. when he is not specifying host or port or master_log_file
or master_log_pos; this will be documented), set the coordinates of the
I/O thread to those of the SQL thread. This way, the SQL thread will see
no discontinuity in the relay log (i.e. will skip no events), because
the I/O thread will fill the brand new relay log with the events which
are just after the position where the SQL thread had stopped
(before CHANGE MASTER was issued).
2003-11-18 17:31:17 +01:00
|
|
|
|
Replication: new code to not modify in-memory log positions until the COMMIT
is executed, even if the transaction spans on >=2 relay logs (bug #53).
New variable relay_log_purge =0|1
New test to verify bug #53
sql/log.cc:
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT.
sql/log_event.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/mysql_priv.h:
new option relay_log_purge (the user can now decide himself
if he wants his relay logs to be automatically purged or not,
we don't make unsafe guesses like before)
sql/mysqld.cc:
new option --innodb (replaces --skip-innodb).
Useful for the test suite : we have skip-innodb in mysql-test-run,
but we can ('-opt.info' file) choose to start the server with
InnoDB for this test only.
New option --bdb
sql/repl_failsafe.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/set_var.cc:
new variable relay_log_purge
sql/slave.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Now we purge a relay log only when we are sure we won't need it,
i.e. we have executed the final query (if autocommit=1) or the COMMIT
sql/slave.h:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
sql/sql_class.h:
prototypes change
sql/sql_parse.cc:
removed thd argument (was not used in the function's body)
sql/sql_repl.cc:
Better tracking of the relay log's name and position
lastly executed, even if we are in a transaction which spans on
2 or more relay logs.
Turn relay_log_purge silently off when someone does CHANGE
MASTER TO RELAY_LOG_*
2003-04-24 15:29:25 +02:00
|
|
|
if (!mi->rli.group_master_log_name[0]) // uninitialized case
|
|
|
|
mi->rli.group_master_log_pos=0;
|
2002-03-30 20:36:05 +01:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&mi->rli.data_lock);
|
2003-07-24 22:29:09 +02:00
|
|
|
mi->rli.abort_pos_wait++; /* for MASTER_POS_WAIT() to abort */
|
A change of behaviour of Seconds_Behind_Master from SHOW SLAVE STATUS. It's going into 4.1
because old behaviour was somewhat nonsensical (kind of bug). Changes are that if repl threads are
down or disconnected the column will be NULL, and if master is idle the column will not grow indefinitely anymore.
sql/slave.cc:
mi->slave_running and rli->slave_running now uints (was needed only for mi but because of start_slave_thread() usage,
had to change both).
So mi->slave_running can now take 3 values: not running, running & not connected, running and connected.
The last value serves for calculation of Seconds_Behind_Master in SHOW SLAVE STATUS.
Changing this column's behaviour: if SQL or I/O thread is not running, or if I/O thread is not connected
(for example if it is reconnecting), it's NULL (to mean "unknown"). And if master is idle, the column will
not grow indefinitely like it used to (that was meaningless); this is fixed by forcing a value of 0
when the slave SQL thread has hit EOF of relay log (which has only a limited number of caveats explained
in comments in code).
sql/slave.h:
slave_running used to be bool but we need to distinguish, for the I/O slave thread, between
"running & connected" and "running & not connected" ("running" means the thread exists).
sql/sql_repl.cc:
we don't need anymore to set rli->last_master_timestamp to 0 (we used that to make Seconds_Behind_Master
be NULL) in RESET SLAVE and CHANGE MASTER, as these commands imply that slave threads are not running
and so Seconds_Behind_Master is already NULL because of that.
2004-12-16 18:12:22 +01:00
|
|
|
/* Clear the errors, for a clean start */
|
2007-06-09 07:19:37 +02:00
|
|
|
mi->rli.clear_error();
|
2006-10-31 12:23:14 +01:00
|
|
|
mi->rli.clear_until_condition();
|
2014-06-25 15:24:11 +02:00
|
|
|
mi->rli.slave_skip_counter= 0;
|
2010-05-04 11:17:20 +02:00
|
|
|
|
|
|
|
sql_print_information("'CHANGE MASTER TO executed'. "
|
|
|
|
"Previous state master_host='%s', master_port='%u', master_log_file='%s', "
|
|
|
|
"master_log_pos='%ld'. "
|
|
|
|
"New state master_host='%s', master_port='%u', master_log_file='%s', "
|
|
|
|
"master_log_pos='%ld'.", saved_host, saved_port, saved_log_name,
|
|
|
|
(ulong) saved_log_pos, mi->host, mi->port, mi->master_log_name,
|
|
|
|
(ulong) mi->master_log_pos);
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
if (saved_using_gtid != Master_info::USE_GTID_NO ||
|
|
|
|
mi->using_gtid != Master_info::USE_GTID_NO)
|
|
|
|
sql_print_information("Previous Using_Gtid=%s. New Using_Gtid=%s",
|
|
|
|
mi->using_gtid_astext(saved_using_gtid),
|
|
|
|
mi->using_gtid_astext(mi->using_gtid));
|
2010-05-04 11:17:20 +02:00
|
|
|
|
2003-08-11 21:44:43 +02:00
|
|
|
/*
|
|
|
|
If we don't write new coordinates to disk now, then old will remain in
|
|
|
|
relay-log.info until START SLAVE is issued; but if mysqld is shutdown
|
|
|
|
before START SLAVE, then old will remain in relay-log.info, and will be the
|
|
|
|
in-memory value at restart (thus causing errors, as the old relay log does
|
|
|
|
not exist anymore).
|
2003-07-24 22:29:09 +02:00
|
|
|
*/
|
2003-08-11 21:44:43 +02:00
|
|
|
flush_relay_log_info(&mi->rli);
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_cond_broadcast(&mi->data_cond);
|
|
|
|
mysql_mutex_unlock(&mi->rli.data_lock);
|
2000-10-02 05:28:21 +02:00
|
|
|
|
2009-10-01 18:44:53 +02:00
|
|
|
err:
|
2002-01-20 03:16:52 +01:00
|
|
|
unlock_slave_threads(mi);
|
2009-10-01 18:44:53 +02:00
|
|
|
if (ret == FALSE)
|
|
|
|
my_ok(thd);
|
|
|
|
DBUG_RETURN(ret);
|
2000-10-02 05:28:21 +02:00
|
|
|
}
|
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Execute a RESET MASTER statement.
|
|
|
|
|
|
|
|
@param thd Pointer to THD object of the client thread executing the
|
|
|
|
statement.
|
|
|
|
|
|
|
|
@retval 0 success
|
|
|
|
@retval 1 error
|
|
|
|
*/
|
2015-07-15 15:27:14 +02:00
|
|
|
int reset_master(THD* thd, rpl_gtid *init_state, uint32 init_state_len,
|
|
|
|
ulong next_log_number)
|
2000-10-02 05:28:21 +02:00
|
|
|
{
|
2001-07-10 14:53:08 +02:00
|
|
|
if (!mysql_bin_log.is_open())
|
2000-10-02 05:28:21 +02:00
|
|
|
{
|
2004-11-12 13:34:00 +01:00
|
|
|
my_message(ER_FLUSH_MASTER_BINLOG_CLOSED,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_THD(thd, ER_FLUSH_MASTER_BINLOG_CLOSED),
|
|
|
|
MYF(ME_BELL+ME_WAITTANG));
|
2002-01-20 03:16:52 +01:00
|
|
|
return 1;
|
2000-10-02 05:28:21 +02:00
|
|
|
}
|
2009-09-26 06:49:49 +02:00
|
|
|
|
2015-07-15 15:27:14 +02:00
|
|
|
if (mysql_bin_log.reset_logs(thd, 1, init_state, init_state_len,
|
|
|
|
next_log_number))
|
2009-09-26 06:49:49 +02:00
|
|
|
return 1;
|
|
|
|
RUN_HOOK(binlog_transmit, after_reset_master, (thd, 0 /* flags */));
|
|
|
|
return 0;
|
2000-10-02 05:28:21 +02:00
|
|
|
}
|
|
|
|
|
2002-09-11 05:40:08 +02:00
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
/**
|
|
|
|
Execute a SHOW BINLOG EVENTS statement.
|
|
|
|
|
|
|
|
@param thd Pointer to THD object for the client thread executing the
|
|
|
|
statement.
|
|
|
|
|
|
|
|
@retval FALSE success
|
|
|
|
@retval TRUE failure
|
|
|
|
*/
|
XA (not completely polished out yet)
include/my_pthread.h:
cleanup. don't use gcc extensions
innobase/include/trx0sys.ic:
Jan's fix for innobase_xa_prepare
innobase/read/read0read.c:
Jan's fix for innobase_xa_prepare
innobase/trx/trx0trx.c:
Jan's fix for innobase_xa_prepare
mysql-test/include/varchar.inc:
test fix
mysql-test/r/ctype_ucs.result:
new log event - all binlog positions are changed :(
mysql-test/r/drop_temp_table.result:
new log event - all binlog positions are changed :(
mysql-test/r/insert_select.result:
new log event - all binlog positions are changed :(
mysql-test/r/mix_innodb_myisam_binlog.result:
new log event - all binlog positions are changed :(
mysql-test/r/myisam.result:
test fix
mysql-test/r/rpl000015.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_change_master.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_charset.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_error_ignored_table.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_flush_log_loop.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_flush_tables.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_loaddata.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_loaddata_rule_m.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_loaddata_rule_s.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_log.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_log_pos.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_max_relay_size.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_relayrotate.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_replicate_do.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_reset_slave.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_rotate_logs.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_server_id1.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_server_id2.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_temporary.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_timezone.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_until.result:
new log event - all binlog positions are changed :(
mysql-test/r/rpl_user_variables.result:
new log event - all binlog positions are changed :(
mysql-test/r/user_var.result:
new log event - all binlog positions are changed :(
mysql-test/t/ctype_ucs.test:
new log event - all binlog positions are changed :(
mysql-test/t/mix_innodb_myisam_binlog.test:
new log event - all binlog positions are changed :(
mysql-test/t/mysqlbinlog.test:
new log event - all binlog positions are changed :(
mysql-test/t/mysqlbinlog2.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_charset.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_error_ignored_table.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_loaddata_rule_m.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_loaddata_rule_s.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_log.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_log_pos.test:
new log event - all binlog positions are changed :(
mysql-test/t/rpl_user_variables.test:
new log event - all binlog positions are changed :(
mysql-test/t/user_var.test:
new log event - all binlog positions are changed :(
mysys/hash.c:
typo fixed
sql/ha_berkeley.cc:
handlerton framework
sql/ha_berkeley.h:
handlerton framework
sql/ha_innodb.cc:
handlerton framework
sql/ha_innodb.h:
handlerton framework
sql/handler.cc:
new transaction handling, handlerton framework, two-phase commit, XA support
sql/handler.h:
new transaction handling, handlerton framework, two-phase commit, XA support
sql/lex.h:
XA commands
sql/log.cc:
new transaction handling, handlerton framework, two-phase commit,
XA support, tc-logging, TC_LOG_MMAP class
sql/log_event.cc:
Xid_log_event
sql/log_event.h:
Xid_log_event, LOG_EVENT_BINLOG_CLOSED_F flag
sql/mysql_priv.h:
wrapper for query_id++
sql/mysqld.cc:
new command-line options --log-tc, --log-tc-size, --tc-heuristic-recover,
new status variables Tc_log_page_size, Tc_log_max_pages_used, Tc_log_page_waits.
init/stop tc logging
sql/set_var.h:
warning fixed
sql/share/errmsg.txt:
XA error messages
sql/sp_head.cc:
s/query_id++/next_query_id()/
sql/sql_base.cc:
typo fixed. new transaction handling.
sql/sql_class.cc:
cleanup of THD.transaction
sql/sql_class.h:
TC_LOG classes, new status variables, new savepoint handling, XA support
sql/sql_insert.cc:
comments
sql/sql_lex.cc:
s/found_colon/found_semicolon/
sql/sql_lex.h:
SQLCOM_XA_xxx, XA related changes in Lex
sql/sql_parse.cc:
cleanup, XA commands, new savepoint handling
sql/sql_repl.cc:
two functions moved to log.cc
sql/sql_repl.h:
two functions moved to log.cc
sql/sql_trigger.cc:
s/lex.name_and_length/lex.ident/
sql/sql_yacc.yy:
XA commands, cleanup
2005-01-16 13:16:23 +01:00
|
|
|
bool mysql_show_binlog_events(THD* thd)
|
2001-06-21 21:19:24 +02:00
|
|
|
{
|
2002-12-11 08:17:51 +01:00
|
|
|
Protocol *protocol= thd->protocol;
|
2001-06-21 21:19:24 +02:00
|
|
|
List<Item> field_list;
|
2002-12-11 08:17:51 +01:00
|
|
|
const char *errmsg = 0;
|
2005-02-28 16:34:02 +01:00
|
|
|
bool ret = TRUE;
|
2001-06-21 21:19:24 +02:00
|
|
|
IO_CACHE log;
|
|
|
|
File file = -1;
|
2009-09-29 01:04:20 +02:00
|
|
|
MYSQL_BIN_LOG *binary_log= NULL;
|
2010-07-20 17:27:13 +02:00
|
|
|
int old_max_allowed_packet= thd->variables.max_allowed_packet;
|
2012-09-28 02:45:05 +02:00
|
|
|
Master_info *mi= 0;
|
2012-04-20 23:25:59 +02:00
|
|
|
LOG_INFO linfo;
|
2015-08-21 23:16:54 +02:00
|
|
|
LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
|
2012-04-20 23:25:59 +02:00
|
|
|
|
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),
- New optional handler function introduced: reset()
This is called after every DML statement to make it easy for a handler to
statement specific cleanups.
(The only case it's not called is if force the file to be closed)
- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
should be moved to handler::reset()
- table->read_set contains a bitmap over all columns that are needed
in the query. read_row() and similar functions only needs to read these
columns
- table->write_set contains a bitmap over all columns that will be updated
in the query. write_row() and update_row() only needs to update these
columns.
The above bitmaps should now be up to date in all context
(including ALTER TABLE, filesort()).
The handler is informed of any changes to the bitmap after
fix_fields() by calling the virtual function
handler::column_bitmaps_signal(). If the handler does caching of
these bitmaps (instead of using table->read_set, table->write_set),
it should redo the caching in this code. as the signal() may be sent
several times, it's probably best to set a variable in the signal
and redo the caching on read_row() / write_row() if the variable was
set.
- Removed the read_set and write_set bitmap objects from the handler class
- Removed all column bit handling functions from the handler class.
(Now one instead uses the normal bitmap functions in my_bitmap.c instead
of handler dedicated bitmap functions)
- field->query_id is removed. One should instead instead check
table->read_set and table->write_set if a field is used in the query.
- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
instead use table->read_set to check for which columns to retrieve.
- If a handler needs to call Field->val() or Field->store() on columns
that are not used in the query, one should install a temporary
all-columns-used map while doing so. For this, we provide the following
functions:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
field->val();
dbug_tmp_restore_column_map(table->read_set, old_map);
and similar for the write map:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
field->val();
dbug_tmp_restore_column_map(table->write_set, old_map);
If this is not done, you will sooner or later hit a DBUG_ASSERT
in the field store() / val() functions.
(For not DBUG binaries, the dbug_tmp_restore_column_map() and
dbug_tmp_restore_column_map() are inline dummy functions and should
be optimized away be the compiler).
- If one needs to temporary set the column map for all binaries (and not
just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
methods) one should use the functions tmp_use_all_columns() and
tmp_restore_column_map() instead of the above dbug_ variants.
- All 'status' fields in the handler base class (like records,
data_file_length etc) are now stored in a 'stats' struct. This makes
it easier to know what status variables are provided by the base
handler. This requires some trivial variable names in the extra()
function.
- New virtual function handler::records(). This is called to optimize
COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
(stats.records is not supposed to be an exact value. It's only has to
be 'reasonable enough' for the optimizer to be able to choose a good
optimization path).
- Non virtual handler::init() function added for caching of virtual
constants from engine.
- Removed has_transactions() virtual method. Now one should instead return
HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
transactions.
- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
that is to be used with 'new handler_name()' to allocate the handler
in the right area. The xxxx_create_handler() function is also
responsible for any initialization of the object before returning.
For example, one should change:
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
->
static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
{
return new (mem_root) ha_myisam(table);
}
- New optional virtual function: use_hidden_primary_key().
This is called in case of an update/delete when
(table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
but we don't have a primary key. This allows the handler to take precisions
in remembering any hidden primary key to able to update/delete any
found row. The default handler marks all columns to be read.
- handler::table_flags() now returns a ulonglong (to allow for more flags).
- New/changed table_flags()
- HA_HAS_RECORDS Set if ::records() is supported
- HA_NO_TRANSACTIONS Set if engine doesn't support transactions
- HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
Set if we should mark all primary key columns for
read when reading rows as part of a DELETE
statement. If there is no primary key,
all columns are marked for read.
- HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some
cases (based on table->read_set)
- HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- HA_DUPP_POS Renamed to HA_DUPLICATE_POS
- HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
Set this if we should mark ALL key columns for
read when when reading rows as part of a DELETE
statement. In case of an update we will mark
all keys for read for which key part changed
value.
- HA_STATS_RECORDS_IS_EXACT
Set this if stats.records is exact.
(This saves us some extra records() calls
when optimizing COUNT(*))
- Removed table_flags()
- HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if
handler::records() gives an exact count() and
HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
- HA_READ_RND_SAME Removed (no one supported this one)
- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()
- Renamed handler::dupp_pos to handler::dup_pos
- Removed not used variable handler::sortkey
Upper level handler changes:
- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
cache is updated on engine creation time and updated on open.
MySQL level changes (not obvious from the above):
- DBUG_ASSERT() added to check that column usage matches what is set
in the column usage bit maps. (This found a LOT of bugs in current
column marking code).
- In 5.1 before, all used columns was marked in read_set and only updated
columns was marked in write_set. Now we only mark columns for which we
need a value in read_set.
- Column bitmaps are created in open_binary_frm() and open_table_from_share().
(Before this was in table.cc)
- handler::table_flags() calls are replaced with handler::ha_table_flags()
- For calling field->val() you must have the corresponding bit set in
table->read_set. For calling field->store() you must have the
corresponding bit set in table->write_set. (There are asserts in
all store()/val() functions to catch wrong usage)
- thd->set_query_id is renamed to thd->mark_used_columns and instead
of setting this to an integer value, this has now the values:
MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
Changed also all variables named 'set_query_id' to mark_used_columns.
- In filesort() we now inform the handler of exactly which columns are needed
doing the sort and choosing the rows.
- The TABLE_SHARE object has a 'all_set' column bitmap one can use
when one needs a column bitmap with all columns set.
(This is used for table->use_all_columns() and other places)
- The TABLE object has 3 column bitmaps:
- def_read_set Default bitmap for columns to be read
- def_write_set Default bitmap for columns to be written
- tmp_set Can be used as a temporary bitmap when needed.
The table object has also two pointer to bitmaps read_set and write_set
that the handler should use to find out which columns are used in which way.
- count() optimization now calls handler::records() instead of using
handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).
- Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
- Added TABLE parameter to cp_buffer_from_ref()
- Don't close tables created with CREATE ... SELECT but keep them in
the table cache. (Faster usage of newly created tables).
New interfaces:
- table->clear_column_bitmaps() to initialize the bitmaps for tables
at start of new statements.
- table->column_bitmaps_set() to set up new column bitmaps and signal
the handler about this.
- table->column_bitmaps_set_no_signal() for some few cases where we need
to setup new column bitmaps but don't signal the handler (as the handler
has already been signaled about these before). Used for the momement
only in opt_range.cc when doing ROR scans.
- table->use_all_columns() to install a bitmap where all columns are marked
as use in the read and the write set.
- table->default_column_bitmaps() to install the normal read and write
column bitmaps, but not signaling the handler about this.
This is mainly used when creating TABLE instances.
- table->mark_columns_needed_for_delete(),
table->mark_columns_needed_for_delete() and
table->mark_columns_needed_for_insert() to allow us to put additional
columns in column usage maps if handler so requires.
(The handler indicates what it neads in handler->table_flags())
- table->prepare_for_position() to allow us to tell handler that it
needs to read primary key parts to be able to store them in
future table->position() calls.
(This replaces the table->file->ha_retrieve_all_pk function)
- table->mark_auto_increment_column() to tell handler are going to update
columns part of any auto_increment key.
- table->mark_columns_used_by_index() to mark all columns that is part of
an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
it to quickly know that it only needs to read colums that are part
of the key. (The handler can also use the column map for detecting this,
but simpler/faster handler can just monitor the extra() call).
- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
also mark all columns that is used by the given key.
- table->restore_column_maps_after_mark_index() to restore to default
column maps after a call to table->mark_columns_used_by_index().
- New item function register_field_in_read_map(), for marking used columns
in table->read_map. Used by filesort() to mark all used columns
- Maintain in TABLE->merge_keys set of all keys that are used in query.
(Simplices some optimization loops)
- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
but the field in the clustered key is not assumed to be part of all index.
(used in opt_range.cc for faster loops)
- dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
mark all columns as usable. The 'dbug_' version is primarily intended
inside a handler when it wants to just call Field:store() & Field::val()
functions, but don't need the column maps set for any other usage.
(ie:: bitmap_is_set() is never called)
- We can't use compare_records() to skip updates for handlers that returns
a partial column set and the read_set doesn't cover all columns in the
write set. The reason for this is that if we have a column marked only for
write we can't in the MySQL level know if the value changed or not.
The reason this worked before was that MySQL marked all to be written
columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
bug'.
- open_table_from_share() does not anymore setup temporary MEM_ROOT
object as a thread specific variable for the handler. Instead we
send the to-be-used MEMROOT to get_new_handler().
(Simpler, faster code)
Bugs fixed:
- Column marking was not done correctly in a lot of cases.
(ALTER TABLE, when using triggers, auto_increment fields etc)
(Could potentially result in wrong values inserted in table handlers
relying on that the old column maps or field->set_query_id was correct)
Especially when it comes to triggers, there may be cases where the
old code would cause lost/wrong values for NDB and/or InnoDB tables.
- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
This allowed me to remove some wrong warnings about:
"Some non-transactional changed tables couldn't be rolled back"
- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
(thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
some warnings about
"Some non-transactional changed tables couldn't be rolled back")
- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
which could cause delete_table to report random failures.
- Fixed core dumps for some tests when running with --debug
- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after
crash)
- slow_logs was not properly initialized, which could maybe cause
extra/lost entries in slow log.
- If we get an duplicate row on insert, change column map to read and
write all columns while retrying the operation. This is required by
the definition of REPLACE and also ensures that fields that are only
part of UPDATE are properly handled. This fixed a bug in NDB and
REPLACE where REPLACE wrongly copied some column values from the replaced
row.
- For table handler that doesn't support NULL in keys, we would give an error
when creating a primary key with NULL fields, even after the fields has been
automaticly converted to NOT NULL.
- Creating a primary key on a SPATIAL key, would fail if field was not
declared as NOT NULL.
Cleanups:
- Removed not used condition argument to setup_tables
- Removed not needed item function reset_query_id_processor().
- Field->add_index is removed. Now this is instead maintained in
(field->flags & FIELD_IN_ADD_INDEX)
- Field->fieldnr is removed (use field->field_index instead)
- New argument to filesort() to indicate that it should return a set of
row pointers (not used columns). This allowed me to remove some references
to sql_command in filesort and should also enable us to return column
results in some cases where we couldn't before.
- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
bitmap, which allowed me to use bitmap functions instead of looping over
all fields to create some needed bitmaps. (Faster and smaller code)
- Broke up found too long lines
- Moved some variable declaration at start of function for better code
readability.
- Removed some not used arguments from functions.
(setup_fields(), mysql_prepare_insert_check_table())
- setup_fields() now takes an enum instead of an int for marking columns
usage.
- For internal temporary tables, use handler::write_row(),
handler::delete_row() and handler::update_row() instead of
handler::ha_xxxx() for faster execution.
- Changed some constants to enum's and define's.
- Using separate column read and write sets allows for easier checking
of timestamp field was set by statement.
- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()
- Don't build table->normalized_path as this is now identical to table->path
(after bar's fixes to convert filenames)
- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
do comparision with the 'convert-dbug-for-diff' tool.
Things left to do in 5.1:
- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
Mats has promised to look into this.
- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
(I added several test cases for this, but in this case it's better that
someone else also tests this throughly).
Lars has promosed to do this.
BitKeeper/etc/ignore:
added mysys/test_bitmap
include/base64.h:
Removed my_global.h, as this must be included first in any program
include/heap.h:
Added heap_reset() (Required by new handler interface)
include/my_base.h:
Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET).
HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary
include/my_bitmap.h:
Remove my_pthread.h (should be included at upper level)
Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box
Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp()
Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void
include/myisam.h:
Added mi_reset() (Required by new handler interface)
include/myisammrg.h:
Added myrg_reset() (Required by new handler interface)
include/mysql_com.h:
Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/install_test_db.sh:
Simplify ldata usage
Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set)
mysql-test/mysql-test-run.pl:
Added --tmpdir=. to bootstrap
mysql-test/mysql-test-run.sh:
Use copy instead of INSTALL_DB for master and slave databases.
(Speeds up startup time a lot!)
Remove snapshot directories at startup (removes some strange warnings)
mysql-test/r/binlog_row_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/r/binlog_stm_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
mysql-test/r/create.result:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/r/federated.result:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/r/func_gconcat.result:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/r/func_time.result:
Added drop of test function
mysql-test/r/innodb_mysql.result:
Added tests for CREATE ... SELECT
mysql-test/r/insert.result:
More tests
Added testing of duplicate columns in insert
mysql-test/r/loaddata.result:
Added testing LOAD DATA ... SET ...
mysql-test/r/multi_update.result:
Test multi updates and deletes using primary key and without
mysql-test/r/ndb_index_unique.result:
Better error message
mysql-test/r/ndb_replace.result:
New correct result after fixing REPLACE handling with NDB
mysql-test/r/rpl_ddl.result:
Now we don't get these (wrong) warnings anymore
mysql-test/r/view_grant.result:
Drop used views
mysql-test/t/create.test:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/t/federated.test:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/t/func_gconcat.test:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/t/func_time.test:
Added drop of test function
mysql-test/t/innodb_mysql.test:
Added tests for CREATE ... SELECT
mysql-test/t/insert.test:
More tests
Added testing of duplicate columns in insert
mysql-test/t/loaddata.test:
Added testing LOAD DATA ... SET ...
mysql-test/t/multi_update.test:
Test multi updates and deletes using primary key and without
mysql-test/t/view_grant.test:
Drop used views
mysql-test/valgrind.supp:
Added supression of not needed warnings when printing stack trace
mysys/base64.c:
Include my_global.h first
mysys/my_bitmap.c:
Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy()
Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström)
Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed.
Changed how mutex is allocated to make 'bitmap_free()' function simpler.
mysys/thr_lock.c:
Added 0x before thread pointers (for easier comparison of DBUG traces)
sql/event.cc:
Ensure 'use_all_columns()' is used for event tables
Don't print warning that event table is damaged if it doesn't exists.
sql/field.cc:
Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set
(Rest of changes are only indentation cleanups)
sql/field.h:
Removed Field->query_id (replaced by table->read_set and table->write_set)
Removed Field->fieldnr (use Field->field_index instead)
Removed Field->add_index (Use Field->flags instead)
Add Field->part_of_key_not_clustered (for usage in opt_range.cc)
sql/filesort.cc:
Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set.
This allowed me to remove checking of sql_command.
Create a temporary column bitmap for fields that are used by the sorting process.
Use column bitmaps instead of query_id
sql/ha_berkeley.cc:
Update to 'newer' table handler interface
sql/ha_berkeley.h:
Update to 'newer' table handler interface
sql/ha_federated.cc:
Update to 'newer' table handler interface
Only read columns that are needed from remote server.
In case of eq ranges, don't generate two conditions in the WHERE clause
(this can still be optimized, but would require a bigger code change)
Use 'simpler to use' XXXX_LEN' macros
A bit simpler logic in ::write_row() when creating statements.
In update, only include test of fields actually read.
(This greatly simplifies the queries sent by the federated engine)
Similar changes done for delete_row()
sql/ha_federated.h:
Update to 'newer' table handler interface
Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc
Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE
sql/ha_heap.cc:
Update to 'newer' table handler interface
sql/ha_heap.h:
Update to 'newer' table handler interface
sql/ha_innodb.cc:
Update to 'newer' table handler interface
- Update innobase_create_handler() to new interface
- Removed HA_NOT_EXACT_COUNT (not needed)
- Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- Prefixed base status variables with 'stats'
- Use table column bitmaps instead of ha_get_bit_in_read_set()
- Added ::reset(), with code from ::extra(HA_EXTRA_RESET)
- Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as
the table->read_set and table->write_set bitmaps now are accurate
sql/ha_innodb.h:
Update to 'newer' table handler interface
- table_flags are now ulonglong
- Added reset() method
- Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns.
- Made build_template() a class function to be able to easier access class variables
sql/ha_myisam.cc:
Update to 'newer' table handler interface
sql/ha_myisam.h:
Update to 'newer' table handler interface
sql/ha_myisammrg.cc:
Update to 'newer' table handler interface
sql/ha_myisammrg.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster.cc:
Update to 'newer' table handler interface
Fixed use_blob_value() to be accurate
In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map
Correct dumping of field data with DBUG_DUMP
Prefix addresses in DBUG_PRINT with 0x
Fixed usage of not initialized memory
Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index.
sql/ha_ndbcluster.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster_binlog.cc:
Mark usage of all columns in ndbcluster binlog tables
false -> FALSE, true -> TRUE
Use table->s->all_set instead of creating a temporary bitmap.
sql/ha_partition.cc:
Update to 'newer' table handler interface
Added memroot to initialise_partitions() and related functions to get faster memory allocation.
partition_create_handler() is now responsible for initialisation of the partition object
Some trivial optimizations and indentation fixes
Ensure that table_flags() are up to date
Removed documentation for removed HA_EXTRA flags
Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance'
sql/ha_partition.h:
Update to 'newer' table handler interface
sql/handler.cc:
create_xxx handler now takes MEMROOT as an argument to simplify memory allocation.
Much simpler get_new_handler()
(Initialization of the object is now handled by the create method for the engine)
Moved all allocation of bitmap handling to the TABLE object (in table.cc)
Added column_bitmaps_signal() to signal column usage changes.
Changed binlog_log_row() to use the exiusting all_set bitmap in the table object.
Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset()
Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row
sql/handler.h:
Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS
Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME
HA_DUPP_POS -> HA_DUPLICATE_POS
HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records()
HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION
Added future row type 'ROW_TYPE_PAGES'
Added MEM_ROOT to handlerton 'create' function
Added ha_statistics, a structure for all status variable in the base handler class.
Moved all status variables in the handler class into a stats structs to improve readability.
ha_table_flags() is now a cached (not virtual) version of table_flags()
reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own.
Renamed dupp_ref to dup_ref
Renamed not used handler::sortkey
Moved read_set and write_set to TABLE structure
handler::init() function added for cacheing of virtual constants from engine.
sql/item.cc:
Added register_field_in_read_map() for marking used columns in expression.
This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting.
Initalize value.cs_info.character_set_client to fix core dump bug with --debug
set_query_id -> mark_used_columns
Mark used columns in read_set OR write_set.
sql/item.h:
Removed reset_query_id_processor() as it's not needed anymore.
Added register_field_in_read_map()
Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
sql/item_cmpfunc.cc:
Temporary mark used columns to be read/writable
Update Item::walk to new interface
sql/item_cmpfunc.h:
Added extra argument to Item::walk() to indicate if we should also traverse sub queries.
sql/item_func.cc:
Update Item::walk() to new interface
table_flags() -> ha_table_flags()
sql/item_func.h:
Update Item::walk() to new interface
sql/item_row.cc:
Update Item::walk() to new interface
sql/item_row.h:
Update Item::walk() to new interface
sql/item_strfunc.h:
Update Item::walk() to new interface
sql/item_subselect.cc:
Added Item_subselect::walk()
(It was a bug it was missing before. Not sure what kind of bugs this could have caused)
sql/item_subselect.h:
Update Item::walk() to new interface
sql/item_sum.cc:
Update Item::walk() to new interface
Updates for new handler interace
sql/item_sum.h:
Update Item::walk() to new interface
sql/key.cc:
Updates for new handler interace
sql/log.cc:
Mark all columns used for log tables
Split options flag
Ensured that second argument to trans_register_ha is a bool
sql/log_event.cc:
Fixed comments to be withing 79 characters
Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings
Updates for new handler interface
Use 0x%lx instead of %p (portability problem)
sql/mysql_priv.h:
Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback
Removed not used 'conds' argument to setup_tables
sql/mysqld.cc:
Indentation fixes and removed old comment
sql/opt_range.cc:
Update to new handler and bitmap interface.
Fixed calls to cp_buffer_from_ref() and walk() (new argument).
Create new temporary bitmaps for ror scans.
(Needed because of handler changes and to get more accurate column bitmaps than before)
Remove not needed file->ha_reset() call before file->close().
Some trivial optimization and indentation fixes.
Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts.
Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record.
This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling.
(This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans)
Optimized bitmap handling in ror scans:
- Start bitmap at position 0, not 1
- Use same bitmap size as in TABLE
- Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table
sql/opt_range.h:
Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan
Added temporary column bitmaps used in ROR scans
sql/opt_sum.cc:
Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS
Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set.
sql/protocol.cc:
We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user
sql/records.cc:
Updates for new handler interface
sql/set_var.cc:
Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags
sql/share/errmsg.txt:
Fixed wrong
sql/sp.cc:
Mark that we are using all columns for the proc table
Update call to setup_tables() to use new prototype
sql/sp_head.cc:
Removed QQ comment
sql/spatial.cc:
Removed wrong QQ comment
sql/sql_acl.cc:
Mark that we need all columns for acl tables
Supply memroot to some 'new' calls.
Indentation fixes
sql/sql_base.cc:
set_query_id removed
Ensure we call ha_reset() at end of each statement
Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set)
Fixed marking of some columns that was not proplerly marked before
Maintain in TABLE->merge_keys set of all keys that are used in some way
Removed not used 'conds' argument from setup_tables()
Remove not used setting of 'dupp_field' in insert_fields()
Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after crash)
sql/sql_bitmap.h:
Added is_overlapping()
sql/sql_class.cc:
Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log.
set_query_id -> mark_used_columns
Simpler variable usage in pack_row() (cleanup)
Moved some variable declartion at start of function for better code readability
sql/sql_class.h:
Added enum_mark_columns
Updated comments
Renamed dupp_field -> dup_field
Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE.
(This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables)
sql/sql_delete.cc:
Updates to new handler interface
Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires.
Call table->prepare_for_position() to tell handler that we are going to call ha_position().
Removed call to free_io_cache(). (io_cache is now removed in ha_reset()).
Fixed calls to setup_tables()
sql/sql_do.cc:
Update call to setup_fields()
sql/sql_handler.cc:
Tell handler tables to always read all columns.
Use temporary column map when storing value in field for later index usage
sql/sql_help.cc:
Makr all used fields to be read
Update call to setup_fields()
sql/sql_insert.cc:
Tell handler we are going to update the auto_increment column
dupp_field -> dup_field
Set column usage bits for timestamp field.
Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column()
Removed not used argument from mysql_prepare_insert_check_table().
If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation.
This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled.
This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row.
Setup new bitmaps for delayed insert rows
Remove reseting of next_number_fields as it will be reset on next call to handler_insert()
Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE.
The issue was that one should not to reset this flag as it may be set by a previous statement.
The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional.
I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done)
Don't close tables created with CREATE ... SELECT but keep them in the table cache.
Moved out MY_HOOKS from inside function (better readability)
sql/sql_load.cc:
Update to use new handler and column marking interface
Update using setup_tables()
sql/sql_olap.cc:
Update calls to setup_tables
Use enums instead of constants to setup_fields()
sql/sql_parse.cc:
Handle OPTION_KEEP_LOG:
- Set it on CREATE TEMPORARY TABLE / DROP TABLE
- Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset
- Don't set it for CREATE ... SELECT (this is handled in select_create class)
Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset.
If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands
sql/sql_partition.cc:
Update walk() usage
Trivial indentation fixes
sql/sql_plugin.cc:
Mark all columns as used for plugins
sql/sql_prepare.cc:
Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly)
Updates for new handler interface
Update calls to setup_fields()
sql/sql_repl.cc:
Indentation fixes
sql/sql_select.cc:
Update call to setup_tables() and setup_fields()
Remove some old disabled code
Update to new hadler interface
Indentation cleanups
Added column bitmaps for temporary tables.
Remove updating of the removed slots in the Field class
Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps)
For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution.
sql/sql_select.h:
Indentaition fixes.
Install temporary column usage maps when needed
Added TABLE element to cp_buffer_from_ref()
sql/sql_show.cc:
Update to new handler interface
Mark all columns used for internal tables.
Style fixes.
Added support for 'future' ROW_TYPE_PAGES.
Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly.
sql/sql_table.cc:
Update to new handler interface
Simple my_snprintf -> strmake()
Changed some constants to defines
Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL)
Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX
Mark all columns as used for ALTER TABLE
Style fixes
Update call to filesort()
sql/sql_trigger.h:
Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in.
sql/sql_udf.cc:
Mark all columns as used for udf system table.
sql/sql_union.cc:
Update call to walk()
Update to new handler interface
sql/sql_update.cc:
Remove query_id argument from compare_record()
Use column bitmaps instead of query_id.
We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value.
Update call to setup_fields()
Using separate column read and write sets allows for easier checking of timestamp field was set by statement.
Removed call to free_io_cache() as this is now done in ha_reset()
Call table->mark_columns_needed_for_update() and table->prepare_for_position()
Style fixes
sql/sql_view.cc:
Style fixes
sql/table.cc:
Remove implicitely include 'errno.h'
Remove code for building normalized path, as this is now identical to 'path'
Remove field->fieldnr
Added update of field->part_of_key_not_clustered()
Create column bitmaps in TABLE and TABLE_SHARE
Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler()
Update to new handler interface
Update call to walk()
Added new functions:
- st_table::clear_column_bitmaps()
- st_table::prepare_for_position()
- st_table::mark_columns_used_by_index()
- st_table::restore_column_maps_after_mark_index()
- st_table::mark_columns_used_by_index_no_reset()
- st_table::mark_auto_increment_column()
- st_table::mark_columns_needed_for_delete()
- st_table::mark_columns_needed_for_update()
- st_table::mark_columns_needed_for_insert()
sql/table.h:
Moved column usage bitmaps from handler to TABLE
Added to TABLE_SHARE all_set and column_bitmap_size
Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set.
Declared all new table column bitmap functions
Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps()
Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps
Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val().
sql/tztime.cc:
Mark all columns as used for timezone tables
storage/archive/ha_archive.cc:
Update to new handler interface
storage/archive/ha_archive.h:
Update to new handler interface
storage/blackhole/ha_blackhole.cc:
Update to new handler interface
storage/blackhole/ha_blackhole.h:
Update to new handler interface
removed not needed flag HA_DUPP_POS
storage/csv/ha_tina.cc:
Update to new handler interface
storage/csv/ha_tina.h:
Update to new handler interface
storage/example/ha_example.cc:
Update to new handler interface
storage/example/ha_example.h:
Update to new handler interface
storage/heap/hp_extra.c:
Added heap_reset() (Required by new handler interface)
storage/heap/hp_test2.c:
Use heap_reset()
storage/myisam/ft_boolean_search.c:
Fixed compiler warning
storage/myisam/mi_extra.c:
Added mi_reset() (Required by new handler interface)
storage/myisam/mi_search.c:
Fixed DBUG_PRINT messages to use 0x%lx instead of %lx
storage/myisam/mi_test2.c:
Use mi_reset()
storage/myisam/myisampack.c:
Use mi_reset()
storage/myisammrg/myrg_extra.c:
Added myrg_reset() (Required by new handler interface)
unittest/mysys/base64.t.c:
Include my_global.h
Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
|
|
|
DBUG_ENTER("mysql_show_binlog_events");
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2015-08-11 09:18:38 +02:00
|
|
|
Log_event::init_show_field_list(thd, &field_list);
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
if (protocol->send_result_set_metadata(&field_list,
|
Port of cursors to be pushed into 5.0 tree:
- client side part is simple and may be considered stable
- server side part now just joggles with THD state to save execution
state and has no additional locking wisdom.
Lot's of it are to be rewritten.
include/mysql.h:
Cursor patch to push into the main tree, client library part (considered
stable):
- new statement attribute STMT_ATTR_CURSOR_TYPE
- MYSQL_STMT::flags to store statement cursor type
- MYSQL_STMT::server_status to store server status (i. e. if the server
was able to open a cursor for this query).
include/mysql_com.h:
Cursor patch to push into the main tree, client library part (considered
stable):
- new COMmand, COM_FETCH, to fetch K rows from read-only cursor.
By design should support scrollable cursors as well.
- a few new server statuses:
SERVER_STATUS_CURSOR_EXISTS is sent by server in reply to COM_EXECUTE,
when cursor was successfully opened for this query
SERVER_STATUS_LAST_ROW_SENT is sent along with the last row to prevent one
more round trip just for finding out that all rows were fetched from
this cursor (this is server mem savier also).
- and finally, all possible values of STMT_ATTR_CURSOR_TYPE,
while now we support only CURSORT_TYPE_NO_CURSOR and
CURSOR_TYPE_READ_ONLY
libmysql/libmysql.c:
Cursor patch to push into the main tree, client library part (considered
stable):
- simple additions to mysql_stmt_fetch implementation to read data
from an opened cursor: we can read up to iteration count rows per
one request; read rows are buffered in the same way as rows of
mysql_stmt_store_result.
- now send stmt->flags to server to let him now if we wish to have
a cursor for this statement.
- support for setting/getting statement cursor type.
libmysqld/examples/Makefile.am:
Testing cursors was originally implemented in C++. Now when these tests
go into client_test, it's time to convert it to C++ as well.
libmysqld/lib_sql.cc:
- cleanup: send_fields flags are now named.
sql/ha_innodb.cc:
- cleanup: send_fields flags are now named.
sql/mysql_priv.h:
- cursors support: declaration for server-side handler of COM_FETCH
sql/protocol.cc:
- cleanup: send_fields flags are now named.
- we can't anymore assert that field_types[field_pos] is sensible:
if we have COM_EXCUTE(stmt1), COM_EXECUTE(stmt2), COM_FETCH(stmt1)
field_types[field_pos] will point to fields of stmt2.
sql/protocol.h:
- cleanup: send_fields flag_s_ are now named.
sql/protocol_cursor.cc:
- cleanup: send_fields flags are now named.
sql/repl_failsafe.cc:
- cleanup: send_fields flags are now named.
sql/slave.cc:
- cleanup: send_fields flags are now named.
sql/sp.cc:
- cleanup: send_fields flags are now named.
sql/sp_head.cc:
- cleanup: send_fields flags are now named.
sql/sql_acl.cc:
- cleanup: send_fields flags are now named.
sql/sql_class.cc:
- cleanup: send_fields flags are now named.
sql/sql_class.h:
- cleanup: send_fields flags are now named.
sql/sql_error.cc:
- cleanup: send_fields flags are now named.
sql/sql_handler.cc:
- cleanup: send_fields flags are now named.
sql/sql_help.cc:
- cleanup: send_fields flags are now named.
sql/sql_parse.cc:
Server side support for cursors:
- handle COM_FETCH
- enforce assumption that whenever we free thd->free_list,
we reset it to zero. This way it's much easier to handle free_list
in prepared statements implementation.
sql/sql_prepare.cc:
Server side support for cursors:
- implementation of mysql_stmt_fetch (fetch some rows from open cursor).
- management of cursors memory is quite tricky now.
- execute_stmt can't be reused anymore in mysql_stmt_execute and
mysql_sql_stmt_execute
sql/sql_repl.cc:
- cleanup: send_fields flags are now named.
sql/sql_select.cc:
Server side support for cursors:
- implementation of Cursor::open, Cursor::fetch (buggy when it comes to
non-equi joins), cursor cleanups.
- -4 -3 -0 constants indicating return value of sub_select and end_send are
to be renamed to something more readable:
it turned out to be not so simple, so it should come with the other patch.
sql/sql_select.h:
Server side support for cursors:
- declaration of Cursor class.
- JOIN::fetch_limit contains runtime value of rows fetched via cursor.
sql/sql_show.cc:
- cleanup: send_fields flags are now named.
sql/sql_table.cc:
- cleanup: send_fields flags are now named.
sql/sql_union.cc:
- if there was a cursor, don't cleanup unit: we'll need it to fetch
the rest of the rows.
tests/Makefile.am:
Now client_test is in C++.
tests/client_test.cc:
A few elementary tests for cursors.
BitKeeper/etc/ignore:
Added libmysqld/examples/client_test.cc to the ignore list
2004-08-03 12:32:21 +02:00
|
|
|
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
|
2004-10-20 03:04:37 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2006-01-03 17:54:54 +01:00
|
|
|
Format_description_log_event *description_event= new
|
|
|
|
Format_description_log_event(3); /* MySQL 4.0 by default */
|
|
|
|
|
2009-09-29 01:04:20 +02:00
|
|
|
DBUG_ASSERT(thd->lex->sql_command == SQLCOM_SHOW_BINLOG_EVENTS ||
|
|
|
|
thd->lex->sql_command == SQLCOM_SHOW_RELAYLOG_EVENTS);
|
2006-01-12 19:51:02 +01:00
|
|
|
|
2016-03-04 01:09:37 +01:00
|
|
|
/* select which binary log to use: binlog or relay */
|
2009-09-29 01:04:20 +02:00
|
|
|
if ( thd->lex->sql_command == SQLCOM_SHOW_BINLOG_EVENTS )
|
|
|
|
{
|
|
|
|
binary_log= &mysql_bin_log;
|
|
|
|
}
|
|
|
|
else /* showing relay log contents */
|
|
|
|
{
|
2015-08-21 23:16:54 +02:00
|
|
|
if (!lex_mi->connection_name.str)
|
|
|
|
lex_mi->connection_name= thd->variables.default_master_connection;
|
2012-09-28 02:45:05 +02:00
|
|
|
mysql_mutex_lock(&LOCK_active_mi);
|
2014-09-06 08:33:56 +02:00
|
|
|
if (!master_info_index ||
|
|
|
|
!(mi= master_info_index->
|
2015-08-21 23:16:54 +02:00
|
|
|
get_master_info(&lex_mi->connection_name,
|
2013-06-15 17:32:08 +02:00
|
|
|
Sql_condition::WARN_LEVEL_ERROR)))
|
2012-09-28 02:45:05 +02:00
|
|
|
{
|
|
|
|
mysql_mutex_unlock(&LOCK_active_mi);
|
2009-09-29 01:04:20 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
2012-09-28 02:45:05 +02:00
|
|
|
}
|
|
|
|
binary_log= &(mi->rli.relay_log);
|
2009-09-29 01:04:20 +02:00
|
|
|
}
|
2006-01-12 19:51:02 +01:00
|
|
|
|
2009-09-29 01:04:20 +02:00
|
|
|
if (binary_log->is_open())
|
2001-06-21 21:19:24 +02:00
|
|
|
{
|
Patch two (the final one) for Bug#7306 "the server side preparedStatement
error for LIMIT placeholder".
The patch adds grammar support for LIMIT ?, ? and changes the
type of ST_SELECT_LEX::select_limit,offset_limit from ha_rows to Item*,
so that it can point to Item_param.
mysql-test/include/ps_modify.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/include/ps_query.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/r/ps.result:
Add basic test coverage for LIMIT ?, ? and fix test results.
mysql-test/r/ps_2myisam.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_3innodb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_4heap.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_5merge.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_6bdb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_7ndb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/t/ps.test:
Add basic test coverage for LIMIT ?, ?.
sql/item.h:
Add a short-cut for (ulonglong) val_int() to Item.
Add a constructor to Item_int() that accepts ulonglong.
Simplify Item_uint constructor by using the c-tor above.
sql/item_subselect.cc:
Now select_limit has type Item *.
We can safely create an Item in Item_exists_subselect::fix_length_and_dec():
it will be allocated in runtime memory root and freed in the end of
execution.
sql/sp_head.cc:
Add a special initalization state for stored procedures to
be able to easily distinguish the first execution of a stored procedure
from prepared statement prepare.
sql/sql_class.h:
Introduce new state 'INITIALIZED_FOR_SP' to be able to easily distinguish
the first execution of a stored procedure from prepared statement prepare.
sql/sql_derived.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace. Add a warning about use of set_limit in
mysql_derived_filling.
sql/sql_error.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace.
- this change is also aware of bug#11095 "show warnings limit 0 returns
all rows instead of zero rows", so the one who merges the bugfix from
4.1 can use local version of sql_error.cc.
sql/sql_handler.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
sql/sql_lex.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_lex.h:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_parse.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
- we can create an Item_int to set global limit of a statement:
it will be created in the runtime mem root and freed in the end of
execution.
sql/sql_repl.cc:
Use unit->set_limit to initialize limits.
sql/sql_select.cc:
- select_limit is now Item* so the proper way to check for default value
is to compare it with NULL.
sql/sql_union.cc:
Evaluate offset_limit_cnt using the new type of ST_SELECT_LEX::offset_limit
sql/sql_view.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_yacc.yy:
Add grammar support for LIMIT ?, ? clause.
2005-06-07 12:11:36 +02:00
|
|
|
SELECT_LEX_UNIT *unit= &thd->lex->unit;
|
2002-11-14 11:21:36 +01:00
|
|
|
ha_rows event_count, limit_start, limit_end;
|
2013-03-25 23:03:13 +01:00
|
|
|
my_off_t pos = MY_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
|
2002-08-08 02:12:02 +02:00
|
|
|
char search_file_name[FN_REFLEN], *name;
|
|
|
|
const char *log_file_name = lex_mi->log_file_name;
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_t *log_lock = binary_log->get_log_lock();
|
2002-08-08 02:12:02 +02:00
|
|
|
Log_event* ev;
|
2005-02-09 20:04:28 +01:00
|
|
|
|
2012-09-28 02:45:05 +02:00
|
|
|
if (mi)
|
|
|
|
{
|
|
|
|
/* We can unlock the mutex as we have a lock on the file */
|
|
|
|
mysql_mutex_unlock(&LOCK_active_mi);
|
|
|
|
mi= 0;
|
|
|
|
}
|
|
|
|
|
Patch two (the final one) for Bug#7306 "the server side preparedStatement
error for LIMIT placeholder".
The patch adds grammar support for LIMIT ?, ? and changes the
type of ST_SELECT_LEX::select_limit,offset_limit from ha_rows to Item*,
so that it can point to Item_param.
mysql-test/include/ps_modify.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/include/ps_query.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/r/ps.result:
Add basic test coverage for LIMIT ?, ? and fix test results.
mysql-test/r/ps_2myisam.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_3innodb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_4heap.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_5merge.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_6bdb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_7ndb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/t/ps.test:
Add basic test coverage for LIMIT ?, ?.
sql/item.h:
Add a short-cut for (ulonglong) val_int() to Item.
Add a constructor to Item_int() that accepts ulonglong.
Simplify Item_uint constructor by using the c-tor above.
sql/item_subselect.cc:
Now select_limit has type Item *.
We can safely create an Item in Item_exists_subselect::fix_length_and_dec():
it will be allocated in runtime memory root and freed in the end of
execution.
sql/sp_head.cc:
Add a special initalization state for stored procedures to
be able to easily distinguish the first execution of a stored procedure
from prepared statement prepare.
sql/sql_class.h:
Introduce new state 'INITIALIZED_FOR_SP' to be able to easily distinguish
the first execution of a stored procedure from prepared statement prepare.
sql/sql_derived.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace. Add a warning about use of set_limit in
mysql_derived_filling.
sql/sql_error.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace.
- this change is also aware of bug#11095 "show warnings limit 0 returns
all rows instead of zero rows", so the one who merges the bugfix from
4.1 can use local version of sql_error.cc.
sql/sql_handler.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
sql/sql_lex.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_lex.h:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_parse.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
- we can create an Item_int to set global limit of a statement:
it will be created in the runtime mem root and freed in the end of
execution.
sql/sql_repl.cc:
Use unit->set_limit to initialize limits.
sql/sql_select.cc:
- select_limit is now Item* so the proper way to check for default value
is to compare it with NULL.
sql/sql_union.cc:
Evaluate offset_limit_cnt using the new type of ST_SELECT_LEX::offset_limit
sql/sql_view.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_yacc.yy:
Add grammar support for LIMIT ?, ? clause.
2005-06-07 12:11:36 +02:00
|
|
|
unit->set_limit(thd->lex->current_select);
|
|
|
|
limit_start= unit->offset_limit_cnt;
|
|
|
|
limit_end= unit->select_limit_cnt;
|
2001-06-21 21:19:24 +02:00
|
|
|
|
2002-08-08 02:12:02 +02:00
|
|
|
name= search_file_name;
|
2001-06-21 21:19:24 +02:00
|
|
|
if (log_file_name)
|
2009-09-29 01:04:20 +02:00
|
|
|
binary_log->make_log_name(search_file_name, log_file_name);
|
2001-06-21 21:19:24 +02:00
|
|
|
else
|
2002-08-08 02:12:02 +02:00
|
|
|
name=0; // Find first log
|
2001-06-21 21:19:24 +02:00
|
|
|
|
|
|
|
linfo.index_file_offset = 0;
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2009-09-29 01:04:20 +02:00
|
|
|
if (binary_log->find_log_pos(&linfo, name, 1))
|
2001-06-21 21:19:24 +02:00
|
|
|
{
|
|
|
|
errmsg = "Could not find target log";
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2016-02-01 11:45:39 +01:00
|
|
|
thd->current_linfo= &linfo;
|
2007-10-03 11:57:14 +02:00
|
|
|
|
2001-06-21 21:19:24 +02:00
|
|
|
if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0)
|
|
|
|
goto err;
|
|
|
|
|
2007-12-21 21:34:43 +01:00
|
|
|
/*
|
|
|
|
to account binlog event header size
|
|
|
|
*/
|
|
|
|
thd->variables.max_allowed_packet += MAX_LOG_EVENT_HEADER;
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(log_lock);
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
|
2005-02-09 20:04:28 +01:00
|
|
|
/*
|
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),
- New optional handler function introduced: reset()
This is called after every DML statement to make it easy for a handler to
statement specific cleanups.
(The only case it's not called is if force the file to be closed)
- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
should be moved to handler::reset()
- table->read_set contains a bitmap over all columns that are needed
in the query. read_row() and similar functions only needs to read these
columns
- table->write_set contains a bitmap over all columns that will be updated
in the query. write_row() and update_row() only needs to update these
columns.
The above bitmaps should now be up to date in all context
(including ALTER TABLE, filesort()).
The handler is informed of any changes to the bitmap after
fix_fields() by calling the virtual function
handler::column_bitmaps_signal(). If the handler does caching of
these bitmaps (instead of using table->read_set, table->write_set),
it should redo the caching in this code. as the signal() may be sent
several times, it's probably best to set a variable in the signal
and redo the caching on read_row() / write_row() if the variable was
set.
- Removed the read_set and write_set bitmap objects from the handler class
- Removed all column bit handling functions from the handler class.
(Now one instead uses the normal bitmap functions in my_bitmap.c instead
of handler dedicated bitmap functions)
- field->query_id is removed. One should instead instead check
table->read_set and table->write_set if a field is used in the query.
- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
instead use table->read_set to check for which columns to retrieve.
- If a handler needs to call Field->val() or Field->store() on columns
that are not used in the query, one should install a temporary
all-columns-used map while doing so. For this, we provide the following
functions:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
field->val();
dbug_tmp_restore_column_map(table->read_set, old_map);
and similar for the write map:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
field->val();
dbug_tmp_restore_column_map(table->write_set, old_map);
If this is not done, you will sooner or later hit a DBUG_ASSERT
in the field store() / val() functions.
(For not DBUG binaries, the dbug_tmp_restore_column_map() and
dbug_tmp_restore_column_map() are inline dummy functions and should
be optimized away be the compiler).
- If one needs to temporary set the column map for all binaries (and not
just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
methods) one should use the functions tmp_use_all_columns() and
tmp_restore_column_map() instead of the above dbug_ variants.
- All 'status' fields in the handler base class (like records,
data_file_length etc) are now stored in a 'stats' struct. This makes
it easier to know what status variables are provided by the base
handler. This requires some trivial variable names in the extra()
function.
- New virtual function handler::records(). This is called to optimize
COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
(stats.records is not supposed to be an exact value. It's only has to
be 'reasonable enough' for the optimizer to be able to choose a good
optimization path).
- Non virtual handler::init() function added for caching of virtual
constants from engine.
- Removed has_transactions() virtual method. Now one should instead return
HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
transactions.
- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
that is to be used with 'new handler_name()' to allocate the handler
in the right area. The xxxx_create_handler() function is also
responsible for any initialization of the object before returning.
For example, one should change:
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
->
static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
{
return new (mem_root) ha_myisam(table);
}
- New optional virtual function: use_hidden_primary_key().
This is called in case of an update/delete when
(table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
but we don't have a primary key. This allows the handler to take precisions
in remembering any hidden primary key to able to update/delete any
found row. The default handler marks all columns to be read.
- handler::table_flags() now returns a ulonglong (to allow for more flags).
- New/changed table_flags()
- HA_HAS_RECORDS Set if ::records() is supported
- HA_NO_TRANSACTIONS Set if engine doesn't support transactions
- HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
Set if we should mark all primary key columns for
read when reading rows as part of a DELETE
statement. If there is no primary key,
all columns are marked for read.
- HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some
cases (based on table->read_set)
- HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- HA_DUPP_POS Renamed to HA_DUPLICATE_POS
- HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
Set this if we should mark ALL key columns for
read when when reading rows as part of a DELETE
statement. In case of an update we will mark
all keys for read for which key part changed
value.
- HA_STATS_RECORDS_IS_EXACT
Set this if stats.records is exact.
(This saves us some extra records() calls
when optimizing COUNT(*))
- Removed table_flags()
- HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if
handler::records() gives an exact count() and
HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
- HA_READ_RND_SAME Removed (no one supported this one)
- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()
- Renamed handler::dupp_pos to handler::dup_pos
- Removed not used variable handler::sortkey
Upper level handler changes:
- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
cache is updated on engine creation time and updated on open.
MySQL level changes (not obvious from the above):
- DBUG_ASSERT() added to check that column usage matches what is set
in the column usage bit maps. (This found a LOT of bugs in current
column marking code).
- In 5.1 before, all used columns was marked in read_set and only updated
columns was marked in write_set. Now we only mark columns for which we
need a value in read_set.
- Column bitmaps are created in open_binary_frm() and open_table_from_share().
(Before this was in table.cc)
- handler::table_flags() calls are replaced with handler::ha_table_flags()
- For calling field->val() you must have the corresponding bit set in
table->read_set. For calling field->store() you must have the
corresponding bit set in table->write_set. (There are asserts in
all store()/val() functions to catch wrong usage)
- thd->set_query_id is renamed to thd->mark_used_columns and instead
of setting this to an integer value, this has now the values:
MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
Changed also all variables named 'set_query_id' to mark_used_columns.
- In filesort() we now inform the handler of exactly which columns are needed
doing the sort and choosing the rows.
- The TABLE_SHARE object has a 'all_set' column bitmap one can use
when one needs a column bitmap with all columns set.
(This is used for table->use_all_columns() and other places)
- The TABLE object has 3 column bitmaps:
- def_read_set Default bitmap for columns to be read
- def_write_set Default bitmap for columns to be written
- tmp_set Can be used as a temporary bitmap when needed.
The table object has also two pointer to bitmaps read_set and write_set
that the handler should use to find out which columns are used in which way.
- count() optimization now calls handler::records() instead of using
handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).
- Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
- Added TABLE parameter to cp_buffer_from_ref()
- Don't close tables created with CREATE ... SELECT but keep them in
the table cache. (Faster usage of newly created tables).
New interfaces:
- table->clear_column_bitmaps() to initialize the bitmaps for tables
at start of new statements.
- table->column_bitmaps_set() to set up new column bitmaps and signal
the handler about this.
- table->column_bitmaps_set_no_signal() for some few cases where we need
to setup new column bitmaps but don't signal the handler (as the handler
has already been signaled about these before). Used for the momement
only in opt_range.cc when doing ROR scans.
- table->use_all_columns() to install a bitmap where all columns are marked
as use in the read and the write set.
- table->default_column_bitmaps() to install the normal read and write
column bitmaps, but not signaling the handler about this.
This is mainly used when creating TABLE instances.
- table->mark_columns_needed_for_delete(),
table->mark_columns_needed_for_delete() and
table->mark_columns_needed_for_insert() to allow us to put additional
columns in column usage maps if handler so requires.
(The handler indicates what it neads in handler->table_flags())
- table->prepare_for_position() to allow us to tell handler that it
needs to read primary key parts to be able to store them in
future table->position() calls.
(This replaces the table->file->ha_retrieve_all_pk function)
- table->mark_auto_increment_column() to tell handler are going to update
columns part of any auto_increment key.
- table->mark_columns_used_by_index() to mark all columns that is part of
an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
it to quickly know that it only needs to read colums that are part
of the key. (The handler can also use the column map for detecting this,
but simpler/faster handler can just monitor the extra() call).
- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
also mark all columns that is used by the given key.
- table->restore_column_maps_after_mark_index() to restore to default
column maps after a call to table->mark_columns_used_by_index().
- New item function register_field_in_read_map(), for marking used columns
in table->read_map. Used by filesort() to mark all used columns
- Maintain in TABLE->merge_keys set of all keys that are used in query.
(Simplices some optimization loops)
- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
but the field in the clustered key is not assumed to be part of all index.
(used in opt_range.cc for faster loops)
- dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
mark all columns as usable. The 'dbug_' version is primarily intended
inside a handler when it wants to just call Field:store() & Field::val()
functions, but don't need the column maps set for any other usage.
(ie:: bitmap_is_set() is never called)
- We can't use compare_records() to skip updates for handlers that returns
a partial column set and the read_set doesn't cover all columns in the
write set. The reason for this is that if we have a column marked only for
write we can't in the MySQL level know if the value changed or not.
The reason this worked before was that MySQL marked all to be written
columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
bug'.
- open_table_from_share() does not anymore setup temporary MEM_ROOT
object as a thread specific variable for the handler. Instead we
send the to-be-used MEMROOT to get_new_handler().
(Simpler, faster code)
Bugs fixed:
- Column marking was not done correctly in a lot of cases.
(ALTER TABLE, when using triggers, auto_increment fields etc)
(Could potentially result in wrong values inserted in table handlers
relying on that the old column maps or field->set_query_id was correct)
Especially when it comes to triggers, there may be cases where the
old code would cause lost/wrong values for NDB and/or InnoDB tables.
- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
This allowed me to remove some wrong warnings about:
"Some non-transactional changed tables couldn't be rolled back"
- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
(thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
some warnings about
"Some non-transactional changed tables couldn't be rolled back")
- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
which could cause delete_table to report random failures.
- Fixed core dumps for some tests when running with --debug
- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after
crash)
- slow_logs was not properly initialized, which could maybe cause
extra/lost entries in slow log.
- If we get an duplicate row on insert, change column map to read and
write all columns while retrying the operation. This is required by
the definition of REPLACE and also ensures that fields that are only
part of UPDATE are properly handled. This fixed a bug in NDB and
REPLACE where REPLACE wrongly copied some column values from the replaced
row.
- For table handler that doesn't support NULL in keys, we would give an error
when creating a primary key with NULL fields, even after the fields has been
automaticly converted to NOT NULL.
- Creating a primary key on a SPATIAL key, would fail if field was not
declared as NOT NULL.
Cleanups:
- Removed not used condition argument to setup_tables
- Removed not needed item function reset_query_id_processor().
- Field->add_index is removed. Now this is instead maintained in
(field->flags & FIELD_IN_ADD_INDEX)
- Field->fieldnr is removed (use field->field_index instead)
- New argument to filesort() to indicate that it should return a set of
row pointers (not used columns). This allowed me to remove some references
to sql_command in filesort and should also enable us to return column
results in some cases where we couldn't before.
- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
bitmap, which allowed me to use bitmap functions instead of looping over
all fields to create some needed bitmaps. (Faster and smaller code)
- Broke up found too long lines
- Moved some variable declaration at start of function for better code
readability.
- Removed some not used arguments from functions.
(setup_fields(), mysql_prepare_insert_check_table())
- setup_fields() now takes an enum instead of an int for marking columns
usage.
- For internal temporary tables, use handler::write_row(),
handler::delete_row() and handler::update_row() instead of
handler::ha_xxxx() for faster execution.
- Changed some constants to enum's and define's.
- Using separate column read and write sets allows for easier checking
of timestamp field was set by statement.
- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()
- Don't build table->normalized_path as this is now identical to table->path
(after bar's fixes to convert filenames)
- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
do comparision with the 'convert-dbug-for-diff' tool.
Things left to do in 5.1:
- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
Mats has promised to look into this.
- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
(I added several test cases for this, but in this case it's better that
someone else also tests this throughly).
Lars has promosed to do this.
BitKeeper/etc/ignore:
added mysys/test_bitmap
include/base64.h:
Removed my_global.h, as this must be included first in any program
include/heap.h:
Added heap_reset() (Required by new handler interface)
include/my_base.h:
Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET).
HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary
include/my_bitmap.h:
Remove my_pthread.h (should be included at upper level)
Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box
Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp()
Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void
include/myisam.h:
Added mi_reset() (Required by new handler interface)
include/myisammrg.h:
Added myrg_reset() (Required by new handler interface)
include/mysql_com.h:
Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/install_test_db.sh:
Simplify ldata usage
Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set)
mysql-test/mysql-test-run.pl:
Added --tmpdir=. to bootstrap
mysql-test/mysql-test-run.sh:
Use copy instead of INSTALL_DB for master and slave databases.
(Speeds up startup time a lot!)
Remove snapshot directories at startup (removes some strange warnings)
mysql-test/r/binlog_row_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/r/binlog_stm_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
mysql-test/r/create.result:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/r/federated.result:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/r/func_gconcat.result:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/r/func_time.result:
Added drop of test function
mysql-test/r/innodb_mysql.result:
Added tests for CREATE ... SELECT
mysql-test/r/insert.result:
More tests
Added testing of duplicate columns in insert
mysql-test/r/loaddata.result:
Added testing LOAD DATA ... SET ...
mysql-test/r/multi_update.result:
Test multi updates and deletes using primary key and without
mysql-test/r/ndb_index_unique.result:
Better error message
mysql-test/r/ndb_replace.result:
New correct result after fixing REPLACE handling with NDB
mysql-test/r/rpl_ddl.result:
Now we don't get these (wrong) warnings anymore
mysql-test/r/view_grant.result:
Drop used views
mysql-test/t/create.test:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/t/federated.test:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/t/func_gconcat.test:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/t/func_time.test:
Added drop of test function
mysql-test/t/innodb_mysql.test:
Added tests for CREATE ... SELECT
mysql-test/t/insert.test:
More tests
Added testing of duplicate columns in insert
mysql-test/t/loaddata.test:
Added testing LOAD DATA ... SET ...
mysql-test/t/multi_update.test:
Test multi updates and deletes using primary key and without
mysql-test/t/view_grant.test:
Drop used views
mysql-test/valgrind.supp:
Added supression of not needed warnings when printing stack trace
mysys/base64.c:
Include my_global.h first
mysys/my_bitmap.c:
Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy()
Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström)
Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed.
Changed how mutex is allocated to make 'bitmap_free()' function simpler.
mysys/thr_lock.c:
Added 0x before thread pointers (for easier comparison of DBUG traces)
sql/event.cc:
Ensure 'use_all_columns()' is used for event tables
Don't print warning that event table is damaged if it doesn't exists.
sql/field.cc:
Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set
(Rest of changes are only indentation cleanups)
sql/field.h:
Removed Field->query_id (replaced by table->read_set and table->write_set)
Removed Field->fieldnr (use Field->field_index instead)
Removed Field->add_index (Use Field->flags instead)
Add Field->part_of_key_not_clustered (for usage in opt_range.cc)
sql/filesort.cc:
Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set.
This allowed me to remove checking of sql_command.
Create a temporary column bitmap for fields that are used by the sorting process.
Use column bitmaps instead of query_id
sql/ha_berkeley.cc:
Update to 'newer' table handler interface
sql/ha_berkeley.h:
Update to 'newer' table handler interface
sql/ha_federated.cc:
Update to 'newer' table handler interface
Only read columns that are needed from remote server.
In case of eq ranges, don't generate two conditions in the WHERE clause
(this can still be optimized, but would require a bigger code change)
Use 'simpler to use' XXXX_LEN' macros
A bit simpler logic in ::write_row() when creating statements.
In update, only include test of fields actually read.
(This greatly simplifies the queries sent by the federated engine)
Similar changes done for delete_row()
sql/ha_federated.h:
Update to 'newer' table handler interface
Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc
Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE
sql/ha_heap.cc:
Update to 'newer' table handler interface
sql/ha_heap.h:
Update to 'newer' table handler interface
sql/ha_innodb.cc:
Update to 'newer' table handler interface
- Update innobase_create_handler() to new interface
- Removed HA_NOT_EXACT_COUNT (not needed)
- Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- Prefixed base status variables with 'stats'
- Use table column bitmaps instead of ha_get_bit_in_read_set()
- Added ::reset(), with code from ::extra(HA_EXTRA_RESET)
- Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as
the table->read_set and table->write_set bitmaps now are accurate
sql/ha_innodb.h:
Update to 'newer' table handler interface
- table_flags are now ulonglong
- Added reset() method
- Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns.
- Made build_template() a class function to be able to easier access class variables
sql/ha_myisam.cc:
Update to 'newer' table handler interface
sql/ha_myisam.h:
Update to 'newer' table handler interface
sql/ha_myisammrg.cc:
Update to 'newer' table handler interface
sql/ha_myisammrg.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster.cc:
Update to 'newer' table handler interface
Fixed use_blob_value() to be accurate
In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map
Correct dumping of field data with DBUG_DUMP
Prefix addresses in DBUG_PRINT with 0x
Fixed usage of not initialized memory
Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index.
sql/ha_ndbcluster.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster_binlog.cc:
Mark usage of all columns in ndbcluster binlog tables
false -> FALSE, true -> TRUE
Use table->s->all_set instead of creating a temporary bitmap.
sql/ha_partition.cc:
Update to 'newer' table handler interface
Added memroot to initialise_partitions() and related functions to get faster memory allocation.
partition_create_handler() is now responsible for initialisation of the partition object
Some trivial optimizations and indentation fixes
Ensure that table_flags() are up to date
Removed documentation for removed HA_EXTRA flags
Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance'
sql/ha_partition.h:
Update to 'newer' table handler interface
sql/handler.cc:
create_xxx handler now takes MEMROOT as an argument to simplify memory allocation.
Much simpler get_new_handler()
(Initialization of the object is now handled by the create method for the engine)
Moved all allocation of bitmap handling to the TABLE object (in table.cc)
Added column_bitmaps_signal() to signal column usage changes.
Changed binlog_log_row() to use the exiusting all_set bitmap in the table object.
Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset()
Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row
sql/handler.h:
Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS
Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME
HA_DUPP_POS -> HA_DUPLICATE_POS
HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records()
HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION
Added future row type 'ROW_TYPE_PAGES'
Added MEM_ROOT to handlerton 'create' function
Added ha_statistics, a structure for all status variable in the base handler class.
Moved all status variables in the handler class into a stats structs to improve readability.
ha_table_flags() is now a cached (not virtual) version of table_flags()
reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own.
Renamed dupp_ref to dup_ref
Renamed not used handler::sortkey
Moved read_set and write_set to TABLE structure
handler::init() function added for cacheing of virtual constants from engine.
sql/item.cc:
Added register_field_in_read_map() for marking used columns in expression.
This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting.
Initalize value.cs_info.character_set_client to fix core dump bug with --debug
set_query_id -> mark_used_columns
Mark used columns in read_set OR write_set.
sql/item.h:
Removed reset_query_id_processor() as it's not needed anymore.
Added register_field_in_read_map()
Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
sql/item_cmpfunc.cc:
Temporary mark used columns to be read/writable
Update Item::walk to new interface
sql/item_cmpfunc.h:
Added extra argument to Item::walk() to indicate if we should also traverse sub queries.
sql/item_func.cc:
Update Item::walk() to new interface
table_flags() -> ha_table_flags()
sql/item_func.h:
Update Item::walk() to new interface
sql/item_row.cc:
Update Item::walk() to new interface
sql/item_row.h:
Update Item::walk() to new interface
sql/item_strfunc.h:
Update Item::walk() to new interface
sql/item_subselect.cc:
Added Item_subselect::walk()
(It was a bug it was missing before. Not sure what kind of bugs this could have caused)
sql/item_subselect.h:
Update Item::walk() to new interface
sql/item_sum.cc:
Update Item::walk() to new interface
Updates for new handler interace
sql/item_sum.h:
Update Item::walk() to new interface
sql/key.cc:
Updates for new handler interace
sql/log.cc:
Mark all columns used for log tables
Split options flag
Ensured that second argument to trans_register_ha is a bool
sql/log_event.cc:
Fixed comments to be withing 79 characters
Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings
Updates for new handler interface
Use 0x%lx instead of %p (portability problem)
sql/mysql_priv.h:
Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback
Removed not used 'conds' argument to setup_tables
sql/mysqld.cc:
Indentation fixes and removed old comment
sql/opt_range.cc:
Update to new handler and bitmap interface.
Fixed calls to cp_buffer_from_ref() and walk() (new argument).
Create new temporary bitmaps for ror scans.
(Needed because of handler changes and to get more accurate column bitmaps than before)
Remove not needed file->ha_reset() call before file->close().
Some trivial optimization and indentation fixes.
Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts.
Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record.
This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling.
(This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans)
Optimized bitmap handling in ror scans:
- Start bitmap at position 0, not 1
- Use same bitmap size as in TABLE
- Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table
sql/opt_range.h:
Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan
Added temporary column bitmaps used in ROR scans
sql/opt_sum.cc:
Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS
Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set.
sql/protocol.cc:
We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user
sql/records.cc:
Updates for new handler interface
sql/set_var.cc:
Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags
sql/share/errmsg.txt:
Fixed wrong
sql/sp.cc:
Mark that we are using all columns for the proc table
Update call to setup_tables() to use new prototype
sql/sp_head.cc:
Removed QQ comment
sql/spatial.cc:
Removed wrong QQ comment
sql/sql_acl.cc:
Mark that we need all columns for acl tables
Supply memroot to some 'new' calls.
Indentation fixes
sql/sql_base.cc:
set_query_id removed
Ensure we call ha_reset() at end of each statement
Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set)
Fixed marking of some columns that was not proplerly marked before
Maintain in TABLE->merge_keys set of all keys that are used in some way
Removed not used 'conds' argument from setup_tables()
Remove not used setting of 'dupp_field' in insert_fields()
Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after crash)
sql/sql_bitmap.h:
Added is_overlapping()
sql/sql_class.cc:
Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log.
set_query_id -> mark_used_columns
Simpler variable usage in pack_row() (cleanup)
Moved some variable declartion at start of function for better code readability
sql/sql_class.h:
Added enum_mark_columns
Updated comments
Renamed dupp_field -> dup_field
Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE.
(This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables)
sql/sql_delete.cc:
Updates to new handler interface
Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires.
Call table->prepare_for_position() to tell handler that we are going to call ha_position().
Removed call to free_io_cache(). (io_cache is now removed in ha_reset()).
Fixed calls to setup_tables()
sql/sql_do.cc:
Update call to setup_fields()
sql/sql_handler.cc:
Tell handler tables to always read all columns.
Use temporary column map when storing value in field for later index usage
sql/sql_help.cc:
Makr all used fields to be read
Update call to setup_fields()
sql/sql_insert.cc:
Tell handler we are going to update the auto_increment column
dupp_field -> dup_field
Set column usage bits for timestamp field.
Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column()
Removed not used argument from mysql_prepare_insert_check_table().
If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation.
This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled.
This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row.
Setup new bitmaps for delayed insert rows
Remove reseting of next_number_fields as it will be reset on next call to handler_insert()
Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE.
The issue was that one should not to reset this flag as it may be set by a previous statement.
The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional.
I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done)
Don't close tables created with CREATE ... SELECT but keep them in the table cache.
Moved out MY_HOOKS from inside function (better readability)
sql/sql_load.cc:
Update to use new handler and column marking interface
Update using setup_tables()
sql/sql_olap.cc:
Update calls to setup_tables
Use enums instead of constants to setup_fields()
sql/sql_parse.cc:
Handle OPTION_KEEP_LOG:
- Set it on CREATE TEMPORARY TABLE / DROP TABLE
- Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset
- Don't set it for CREATE ... SELECT (this is handled in select_create class)
Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset.
If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands
sql/sql_partition.cc:
Update walk() usage
Trivial indentation fixes
sql/sql_plugin.cc:
Mark all columns as used for plugins
sql/sql_prepare.cc:
Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly)
Updates for new handler interface
Update calls to setup_fields()
sql/sql_repl.cc:
Indentation fixes
sql/sql_select.cc:
Update call to setup_tables() and setup_fields()
Remove some old disabled code
Update to new hadler interface
Indentation cleanups
Added column bitmaps for temporary tables.
Remove updating of the removed slots in the Field class
Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps)
For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution.
sql/sql_select.h:
Indentaition fixes.
Install temporary column usage maps when needed
Added TABLE element to cp_buffer_from_ref()
sql/sql_show.cc:
Update to new handler interface
Mark all columns used for internal tables.
Style fixes.
Added support for 'future' ROW_TYPE_PAGES.
Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly.
sql/sql_table.cc:
Update to new handler interface
Simple my_snprintf -> strmake()
Changed some constants to defines
Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL)
Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX
Mark all columns as used for ALTER TABLE
Style fixes
Update call to filesort()
sql/sql_trigger.h:
Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in.
sql/sql_udf.cc:
Mark all columns as used for udf system table.
sql/sql_union.cc:
Update call to walk()
Update to new handler interface
sql/sql_update.cc:
Remove query_id argument from compare_record()
Use column bitmaps instead of query_id.
We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value.
Update call to setup_fields()
Using separate column read and write sets allows for easier checking of timestamp field was set by statement.
Removed call to free_io_cache() as this is now done in ha_reset()
Call table->mark_columns_needed_for_update() and table->prepare_for_position()
Style fixes
sql/sql_view.cc:
Style fixes
sql/table.cc:
Remove implicitely include 'errno.h'
Remove code for building normalized path, as this is now identical to 'path'
Remove field->fieldnr
Added update of field->part_of_key_not_clustered()
Create column bitmaps in TABLE and TABLE_SHARE
Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler()
Update to new handler interface
Update call to walk()
Added new functions:
- st_table::clear_column_bitmaps()
- st_table::prepare_for_position()
- st_table::mark_columns_used_by_index()
- st_table::restore_column_maps_after_mark_index()
- st_table::mark_columns_used_by_index_no_reset()
- st_table::mark_auto_increment_column()
- st_table::mark_columns_needed_for_delete()
- st_table::mark_columns_needed_for_update()
- st_table::mark_columns_needed_for_insert()
sql/table.h:
Moved column usage bitmaps from handler to TABLE
Added to TABLE_SHARE all_set and column_bitmap_size
Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set.
Declared all new table column bitmap functions
Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps()
Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps
Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val().
sql/tztime.cc:
Mark all columns as used for timezone tables
storage/archive/ha_archive.cc:
Update to new handler interface
storage/archive/ha_archive.h:
Update to new handler interface
storage/blackhole/ha_blackhole.cc:
Update to new handler interface
storage/blackhole/ha_blackhole.h:
Update to new handler interface
removed not needed flag HA_DUPP_POS
storage/csv/ha_tina.cc:
Update to new handler interface
storage/csv/ha_tina.h:
Update to new handler interface
storage/example/ha_example.cc:
Update to new handler interface
storage/example/ha_example.h:
Update to new handler interface
storage/heap/hp_extra.c:
Added heap_reset() (Required by new handler interface)
storage/heap/hp_test2.c:
Use heap_reset()
storage/myisam/ft_boolean_search.c:
Fixed compiler warning
storage/myisam/mi_extra.c:
Added mi_reset() (Required by new handler interface)
storage/myisam/mi_search.c:
Fixed DBUG_PRINT messages to use 0x%lx instead of %lx
storage/myisam/mi_test2.c:
Use mi_reset()
storage/myisam/myisampack.c:
Use mi_reset()
storage/myisammrg/myrg_extra.c:
Added myrg_reset() (Required by new handler interface)
unittest/mysys/base64.t.c:
Include my_global.h
Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
|
|
|
open_binlog() sought to position 4.
|
|
|
|
Read the first event in case it's a Format_description_log_event, to
|
|
|
|
know the format. If there's no such event, we are 3.23 or 4.x. This
|
|
|
|
code, like before, can't read 3.23 binlogs.
|
2015-09-02 09:58:08 +02:00
|
|
|
Also read the second event, in case it's a Start_encryption_log_event.
|
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),
- New optional handler function introduced: reset()
This is called after every DML statement to make it easy for a handler to
statement specific cleanups.
(The only case it's not called is if force the file to be closed)
- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
should be moved to handler::reset()
- table->read_set contains a bitmap over all columns that are needed
in the query. read_row() and similar functions only needs to read these
columns
- table->write_set contains a bitmap over all columns that will be updated
in the query. write_row() and update_row() only needs to update these
columns.
The above bitmaps should now be up to date in all context
(including ALTER TABLE, filesort()).
The handler is informed of any changes to the bitmap after
fix_fields() by calling the virtual function
handler::column_bitmaps_signal(). If the handler does caching of
these bitmaps (instead of using table->read_set, table->write_set),
it should redo the caching in this code. as the signal() may be sent
several times, it's probably best to set a variable in the signal
and redo the caching on read_row() / write_row() if the variable was
set.
- Removed the read_set and write_set bitmap objects from the handler class
- Removed all column bit handling functions from the handler class.
(Now one instead uses the normal bitmap functions in my_bitmap.c instead
of handler dedicated bitmap functions)
- field->query_id is removed. One should instead instead check
table->read_set and table->write_set if a field is used in the query.
- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
instead use table->read_set to check for which columns to retrieve.
- If a handler needs to call Field->val() or Field->store() on columns
that are not used in the query, one should install a temporary
all-columns-used map while doing so. For this, we provide the following
functions:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
field->val();
dbug_tmp_restore_column_map(table->read_set, old_map);
and similar for the write map:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
field->val();
dbug_tmp_restore_column_map(table->write_set, old_map);
If this is not done, you will sooner or later hit a DBUG_ASSERT
in the field store() / val() functions.
(For not DBUG binaries, the dbug_tmp_restore_column_map() and
dbug_tmp_restore_column_map() are inline dummy functions and should
be optimized away be the compiler).
- If one needs to temporary set the column map for all binaries (and not
just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
methods) one should use the functions tmp_use_all_columns() and
tmp_restore_column_map() instead of the above dbug_ variants.
- All 'status' fields in the handler base class (like records,
data_file_length etc) are now stored in a 'stats' struct. This makes
it easier to know what status variables are provided by the base
handler. This requires some trivial variable names in the extra()
function.
- New virtual function handler::records(). This is called to optimize
COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
(stats.records is not supposed to be an exact value. It's only has to
be 'reasonable enough' for the optimizer to be able to choose a good
optimization path).
- Non virtual handler::init() function added for caching of virtual
constants from engine.
- Removed has_transactions() virtual method. Now one should instead return
HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
transactions.
- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
that is to be used with 'new handler_name()' to allocate the handler
in the right area. The xxxx_create_handler() function is also
responsible for any initialization of the object before returning.
For example, one should change:
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
->
static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
{
return new (mem_root) ha_myisam(table);
}
- New optional virtual function: use_hidden_primary_key().
This is called in case of an update/delete when
(table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
but we don't have a primary key. This allows the handler to take precisions
in remembering any hidden primary key to able to update/delete any
found row. The default handler marks all columns to be read.
- handler::table_flags() now returns a ulonglong (to allow for more flags).
- New/changed table_flags()
- HA_HAS_RECORDS Set if ::records() is supported
- HA_NO_TRANSACTIONS Set if engine doesn't support transactions
- HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
Set if we should mark all primary key columns for
read when reading rows as part of a DELETE
statement. If there is no primary key,
all columns are marked for read.
- HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some
cases (based on table->read_set)
- HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- HA_DUPP_POS Renamed to HA_DUPLICATE_POS
- HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
Set this if we should mark ALL key columns for
read when when reading rows as part of a DELETE
statement. In case of an update we will mark
all keys for read for which key part changed
value.
- HA_STATS_RECORDS_IS_EXACT
Set this if stats.records is exact.
(This saves us some extra records() calls
when optimizing COUNT(*))
- Removed table_flags()
- HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if
handler::records() gives an exact count() and
HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
- HA_READ_RND_SAME Removed (no one supported this one)
- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()
- Renamed handler::dupp_pos to handler::dup_pos
- Removed not used variable handler::sortkey
Upper level handler changes:
- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
cache is updated on engine creation time and updated on open.
MySQL level changes (not obvious from the above):
- DBUG_ASSERT() added to check that column usage matches what is set
in the column usage bit maps. (This found a LOT of bugs in current
column marking code).
- In 5.1 before, all used columns was marked in read_set and only updated
columns was marked in write_set. Now we only mark columns for which we
need a value in read_set.
- Column bitmaps are created in open_binary_frm() and open_table_from_share().
(Before this was in table.cc)
- handler::table_flags() calls are replaced with handler::ha_table_flags()
- For calling field->val() you must have the corresponding bit set in
table->read_set. For calling field->store() you must have the
corresponding bit set in table->write_set. (There are asserts in
all store()/val() functions to catch wrong usage)
- thd->set_query_id is renamed to thd->mark_used_columns and instead
of setting this to an integer value, this has now the values:
MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
Changed also all variables named 'set_query_id' to mark_used_columns.
- In filesort() we now inform the handler of exactly which columns are needed
doing the sort and choosing the rows.
- The TABLE_SHARE object has a 'all_set' column bitmap one can use
when one needs a column bitmap with all columns set.
(This is used for table->use_all_columns() and other places)
- The TABLE object has 3 column bitmaps:
- def_read_set Default bitmap for columns to be read
- def_write_set Default bitmap for columns to be written
- tmp_set Can be used as a temporary bitmap when needed.
The table object has also two pointer to bitmaps read_set and write_set
that the handler should use to find out which columns are used in which way.
- count() optimization now calls handler::records() instead of using
handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).
- Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
- Added TABLE parameter to cp_buffer_from_ref()
- Don't close tables created with CREATE ... SELECT but keep them in
the table cache. (Faster usage of newly created tables).
New interfaces:
- table->clear_column_bitmaps() to initialize the bitmaps for tables
at start of new statements.
- table->column_bitmaps_set() to set up new column bitmaps and signal
the handler about this.
- table->column_bitmaps_set_no_signal() for some few cases where we need
to setup new column bitmaps but don't signal the handler (as the handler
has already been signaled about these before). Used for the momement
only in opt_range.cc when doing ROR scans.
- table->use_all_columns() to install a bitmap where all columns are marked
as use in the read and the write set.
- table->default_column_bitmaps() to install the normal read and write
column bitmaps, but not signaling the handler about this.
This is mainly used when creating TABLE instances.
- table->mark_columns_needed_for_delete(),
table->mark_columns_needed_for_delete() and
table->mark_columns_needed_for_insert() to allow us to put additional
columns in column usage maps if handler so requires.
(The handler indicates what it neads in handler->table_flags())
- table->prepare_for_position() to allow us to tell handler that it
needs to read primary key parts to be able to store them in
future table->position() calls.
(This replaces the table->file->ha_retrieve_all_pk function)
- table->mark_auto_increment_column() to tell handler are going to update
columns part of any auto_increment key.
- table->mark_columns_used_by_index() to mark all columns that is part of
an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
it to quickly know that it only needs to read colums that are part
of the key. (The handler can also use the column map for detecting this,
but simpler/faster handler can just monitor the extra() call).
- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
also mark all columns that is used by the given key.
- table->restore_column_maps_after_mark_index() to restore to default
column maps after a call to table->mark_columns_used_by_index().
- New item function register_field_in_read_map(), for marking used columns
in table->read_map. Used by filesort() to mark all used columns
- Maintain in TABLE->merge_keys set of all keys that are used in query.
(Simplices some optimization loops)
- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
but the field in the clustered key is not assumed to be part of all index.
(used in opt_range.cc for faster loops)
- dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
mark all columns as usable. The 'dbug_' version is primarily intended
inside a handler when it wants to just call Field:store() & Field::val()
functions, but don't need the column maps set for any other usage.
(ie:: bitmap_is_set() is never called)
- We can't use compare_records() to skip updates for handlers that returns
a partial column set and the read_set doesn't cover all columns in the
write set. The reason for this is that if we have a column marked only for
write we can't in the MySQL level know if the value changed or not.
The reason this worked before was that MySQL marked all to be written
columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
bug'.
- open_table_from_share() does not anymore setup temporary MEM_ROOT
object as a thread specific variable for the handler. Instead we
send the to-be-used MEMROOT to get_new_handler().
(Simpler, faster code)
Bugs fixed:
- Column marking was not done correctly in a lot of cases.
(ALTER TABLE, when using triggers, auto_increment fields etc)
(Could potentially result in wrong values inserted in table handlers
relying on that the old column maps or field->set_query_id was correct)
Especially when it comes to triggers, there may be cases where the
old code would cause lost/wrong values for NDB and/or InnoDB tables.
- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
This allowed me to remove some wrong warnings about:
"Some non-transactional changed tables couldn't be rolled back"
- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
(thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
some warnings about
"Some non-transactional changed tables couldn't be rolled back")
- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
which could cause delete_table to report random failures.
- Fixed core dumps for some tests when running with --debug
- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after
crash)
- slow_logs was not properly initialized, which could maybe cause
extra/lost entries in slow log.
- If we get an duplicate row on insert, change column map to read and
write all columns while retrying the operation. This is required by
the definition of REPLACE and also ensures that fields that are only
part of UPDATE are properly handled. This fixed a bug in NDB and
REPLACE where REPLACE wrongly copied some column values from the replaced
row.
- For table handler that doesn't support NULL in keys, we would give an error
when creating a primary key with NULL fields, even after the fields has been
automaticly converted to NOT NULL.
- Creating a primary key on a SPATIAL key, would fail if field was not
declared as NOT NULL.
Cleanups:
- Removed not used condition argument to setup_tables
- Removed not needed item function reset_query_id_processor().
- Field->add_index is removed. Now this is instead maintained in
(field->flags & FIELD_IN_ADD_INDEX)
- Field->fieldnr is removed (use field->field_index instead)
- New argument to filesort() to indicate that it should return a set of
row pointers (not used columns). This allowed me to remove some references
to sql_command in filesort and should also enable us to return column
results in some cases where we couldn't before.
- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
bitmap, which allowed me to use bitmap functions instead of looping over
all fields to create some needed bitmaps. (Faster and smaller code)
- Broke up found too long lines
- Moved some variable declaration at start of function for better code
readability.
- Removed some not used arguments from functions.
(setup_fields(), mysql_prepare_insert_check_table())
- setup_fields() now takes an enum instead of an int for marking columns
usage.
- For internal temporary tables, use handler::write_row(),
handler::delete_row() and handler::update_row() instead of
handler::ha_xxxx() for faster execution.
- Changed some constants to enum's and define's.
- Using separate column read and write sets allows for easier checking
of timestamp field was set by statement.
- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()
- Don't build table->normalized_path as this is now identical to table->path
(after bar's fixes to convert filenames)
- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
do comparision with the 'convert-dbug-for-diff' tool.
Things left to do in 5.1:
- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
Mats has promised to look into this.
- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
(I added several test cases for this, but in this case it's better that
someone else also tests this throughly).
Lars has promosed to do this.
BitKeeper/etc/ignore:
added mysys/test_bitmap
include/base64.h:
Removed my_global.h, as this must be included first in any program
include/heap.h:
Added heap_reset() (Required by new handler interface)
include/my_base.h:
Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET).
HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary
include/my_bitmap.h:
Remove my_pthread.h (should be included at upper level)
Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box
Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp()
Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void
include/myisam.h:
Added mi_reset() (Required by new handler interface)
include/myisammrg.h:
Added myrg_reset() (Required by new handler interface)
include/mysql_com.h:
Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/install_test_db.sh:
Simplify ldata usage
Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set)
mysql-test/mysql-test-run.pl:
Added --tmpdir=. to bootstrap
mysql-test/mysql-test-run.sh:
Use copy instead of INSTALL_DB for master and slave databases.
(Speeds up startup time a lot!)
Remove snapshot directories at startup (removes some strange warnings)
mysql-test/r/binlog_row_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/r/binlog_stm_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
mysql-test/r/create.result:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/r/federated.result:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/r/func_gconcat.result:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/r/func_time.result:
Added drop of test function
mysql-test/r/innodb_mysql.result:
Added tests for CREATE ... SELECT
mysql-test/r/insert.result:
More tests
Added testing of duplicate columns in insert
mysql-test/r/loaddata.result:
Added testing LOAD DATA ... SET ...
mysql-test/r/multi_update.result:
Test multi updates and deletes using primary key and without
mysql-test/r/ndb_index_unique.result:
Better error message
mysql-test/r/ndb_replace.result:
New correct result after fixing REPLACE handling with NDB
mysql-test/r/rpl_ddl.result:
Now we don't get these (wrong) warnings anymore
mysql-test/r/view_grant.result:
Drop used views
mysql-test/t/create.test:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/t/federated.test:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/t/func_gconcat.test:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/t/func_time.test:
Added drop of test function
mysql-test/t/innodb_mysql.test:
Added tests for CREATE ... SELECT
mysql-test/t/insert.test:
More tests
Added testing of duplicate columns in insert
mysql-test/t/loaddata.test:
Added testing LOAD DATA ... SET ...
mysql-test/t/multi_update.test:
Test multi updates and deletes using primary key and without
mysql-test/t/view_grant.test:
Drop used views
mysql-test/valgrind.supp:
Added supression of not needed warnings when printing stack trace
mysys/base64.c:
Include my_global.h first
mysys/my_bitmap.c:
Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy()
Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström)
Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed.
Changed how mutex is allocated to make 'bitmap_free()' function simpler.
mysys/thr_lock.c:
Added 0x before thread pointers (for easier comparison of DBUG traces)
sql/event.cc:
Ensure 'use_all_columns()' is used for event tables
Don't print warning that event table is damaged if it doesn't exists.
sql/field.cc:
Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set
(Rest of changes are only indentation cleanups)
sql/field.h:
Removed Field->query_id (replaced by table->read_set and table->write_set)
Removed Field->fieldnr (use Field->field_index instead)
Removed Field->add_index (Use Field->flags instead)
Add Field->part_of_key_not_clustered (for usage in opt_range.cc)
sql/filesort.cc:
Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set.
This allowed me to remove checking of sql_command.
Create a temporary column bitmap for fields that are used by the sorting process.
Use column bitmaps instead of query_id
sql/ha_berkeley.cc:
Update to 'newer' table handler interface
sql/ha_berkeley.h:
Update to 'newer' table handler interface
sql/ha_federated.cc:
Update to 'newer' table handler interface
Only read columns that are needed from remote server.
In case of eq ranges, don't generate two conditions in the WHERE clause
(this can still be optimized, but would require a bigger code change)
Use 'simpler to use' XXXX_LEN' macros
A bit simpler logic in ::write_row() when creating statements.
In update, only include test of fields actually read.
(This greatly simplifies the queries sent by the federated engine)
Similar changes done for delete_row()
sql/ha_federated.h:
Update to 'newer' table handler interface
Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc
Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE
sql/ha_heap.cc:
Update to 'newer' table handler interface
sql/ha_heap.h:
Update to 'newer' table handler interface
sql/ha_innodb.cc:
Update to 'newer' table handler interface
- Update innobase_create_handler() to new interface
- Removed HA_NOT_EXACT_COUNT (not needed)
- Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- Prefixed base status variables with 'stats'
- Use table column bitmaps instead of ha_get_bit_in_read_set()
- Added ::reset(), with code from ::extra(HA_EXTRA_RESET)
- Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as
the table->read_set and table->write_set bitmaps now are accurate
sql/ha_innodb.h:
Update to 'newer' table handler interface
- table_flags are now ulonglong
- Added reset() method
- Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns.
- Made build_template() a class function to be able to easier access class variables
sql/ha_myisam.cc:
Update to 'newer' table handler interface
sql/ha_myisam.h:
Update to 'newer' table handler interface
sql/ha_myisammrg.cc:
Update to 'newer' table handler interface
sql/ha_myisammrg.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster.cc:
Update to 'newer' table handler interface
Fixed use_blob_value() to be accurate
In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map
Correct dumping of field data with DBUG_DUMP
Prefix addresses in DBUG_PRINT with 0x
Fixed usage of not initialized memory
Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index.
sql/ha_ndbcluster.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster_binlog.cc:
Mark usage of all columns in ndbcluster binlog tables
false -> FALSE, true -> TRUE
Use table->s->all_set instead of creating a temporary bitmap.
sql/ha_partition.cc:
Update to 'newer' table handler interface
Added memroot to initialise_partitions() and related functions to get faster memory allocation.
partition_create_handler() is now responsible for initialisation of the partition object
Some trivial optimizations and indentation fixes
Ensure that table_flags() are up to date
Removed documentation for removed HA_EXTRA flags
Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance'
sql/ha_partition.h:
Update to 'newer' table handler interface
sql/handler.cc:
create_xxx handler now takes MEMROOT as an argument to simplify memory allocation.
Much simpler get_new_handler()
(Initialization of the object is now handled by the create method for the engine)
Moved all allocation of bitmap handling to the TABLE object (in table.cc)
Added column_bitmaps_signal() to signal column usage changes.
Changed binlog_log_row() to use the exiusting all_set bitmap in the table object.
Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset()
Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row
sql/handler.h:
Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS
Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME
HA_DUPP_POS -> HA_DUPLICATE_POS
HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records()
HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION
Added future row type 'ROW_TYPE_PAGES'
Added MEM_ROOT to handlerton 'create' function
Added ha_statistics, a structure for all status variable in the base handler class.
Moved all status variables in the handler class into a stats structs to improve readability.
ha_table_flags() is now a cached (not virtual) version of table_flags()
reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own.
Renamed dupp_ref to dup_ref
Renamed not used handler::sortkey
Moved read_set and write_set to TABLE structure
handler::init() function added for cacheing of virtual constants from engine.
sql/item.cc:
Added register_field_in_read_map() for marking used columns in expression.
This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting.
Initalize value.cs_info.character_set_client to fix core dump bug with --debug
set_query_id -> mark_used_columns
Mark used columns in read_set OR write_set.
sql/item.h:
Removed reset_query_id_processor() as it's not needed anymore.
Added register_field_in_read_map()
Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
sql/item_cmpfunc.cc:
Temporary mark used columns to be read/writable
Update Item::walk to new interface
sql/item_cmpfunc.h:
Added extra argument to Item::walk() to indicate if we should also traverse sub queries.
sql/item_func.cc:
Update Item::walk() to new interface
table_flags() -> ha_table_flags()
sql/item_func.h:
Update Item::walk() to new interface
sql/item_row.cc:
Update Item::walk() to new interface
sql/item_row.h:
Update Item::walk() to new interface
sql/item_strfunc.h:
Update Item::walk() to new interface
sql/item_subselect.cc:
Added Item_subselect::walk()
(It was a bug it was missing before. Not sure what kind of bugs this could have caused)
sql/item_subselect.h:
Update Item::walk() to new interface
sql/item_sum.cc:
Update Item::walk() to new interface
Updates for new handler interace
sql/item_sum.h:
Update Item::walk() to new interface
sql/key.cc:
Updates for new handler interace
sql/log.cc:
Mark all columns used for log tables
Split options flag
Ensured that second argument to trans_register_ha is a bool
sql/log_event.cc:
Fixed comments to be withing 79 characters
Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings
Updates for new handler interface
Use 0x%lx instead of %p (portability problem)
sql/mysql_priv.h:
Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback
Removed not used 'conds' argument to setup_tables
sql/mysqld.cc:
Indentation fixes and removed old comment
sql/opt_range.cc:
Update to new handler and bitmap interface.
Fixed calls to cp_buffer_from_ref() and walk() (new argument).
Create new temporary bitmaps for ror scans.
(Needed because of handler changes and to get more accurate column bitmaps than before)
Remove not needed file->ha_reset() call before file->close().
Some trivial optimization and indentation fixes.
Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts.
Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record.
This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling.
(This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans)
Optimized bitmap handling in ror scans:
- Start bitmap at position 0, not 1
- Use same bitmap size as in TABLE
- Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table
sql/opt_range.h:
Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan
Added temporary column bitmaps used in ROR scans
sql/opt_sum.cc:
Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS
Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set.
sql/protocol.cc:
We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user
sql/records.cc:
Updates for new handler interface
sql/set_var.cc:
Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags
sql/share/errmsg.txt:
Fixed wrong
sql/sp.cc:
Mark that we are using all columns for the proc table
Update call to setup_tables() to use new prototype
sql/sp_head.cc:
Removed QQ comment
sql/spatial.cc:
Removed wrong QQ comment
sql/sql_acl.cc:
Mark that we need all columns for acl tables
Supply memroot to some 'new' calls.
Indentation fixes
sql/sql_base.cc:
set_query_id removed
Ensure we call ha_reset() at end of each statement
Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set)
Fixed marking of some columns that was not proplerly marked before
Maintain in TABLE->merge_keys set of all keys that are used in some way
Removed not used 'conds' argument from setup_tables()
Remove not used setting of 'dupp_field' in insert_fields()
Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after crash)
sql/sql_bitmap.h:
Added is_overlapping()
sql/sql_class.cc:
Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log.
set_query_id -> mark_used_columns
Simpler variable usage in pack_row() (cleanup)
Moved some variable declartion at start of function for better code readability
sql/sql_class.h:
Added enum_mark_columns
Updated comments
Renamed dupp_field -> dup_field
Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE.
(This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables)
sql/sql_delete.cc:
Updates to new handler interface
Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires.
Call table->prepare_for_position() to tell handler that we are going to call ha_position().
Removed call to free_io_cache(). (io_cache is now removed in ha_reset()).
Fixed calls to setup_tables()
sql/sql_do.cc:
Update call to setup_fields()
sql/sql_handler.cc:
Tell handler tables to always read all columns.
Use temporary column map when storing value in field for later index usage
sql/sql_help.cc:
Makr all used fields to be read
Update call to setup_fields()
sql/sql_insert.cc:
Tell handler we are going to update the auto_increment column
dupp_field -> dup_field
Set column usage bits for timestamp field.
Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column()
Removed not used argument from mysql_prepare_insert_check_table().
If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation.
This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled.
This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row.
Setup new bitmaps for delayed insert rows
Remove reseting of next_number_fields as it will be reset on next call to handler_insert()
Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE.
The issue was that one should not to reset this flag as it may be set by a previous statement.
The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional.
I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done)
Don't close tables created with CREATE ... SELECT but keep them in the table cache.
Moved out MY_HOOKS from inside function (better readability)
sql/sql_load.cc:
Update to use new handler and column marking interface
Update using setup_tables()
sql/sql_olap.cc:
Update calls to setup_tables
Use enums instead of constants to setup_fields()
sql/sql_parse.cc:
Handle OPTION_KEEP_LOG:
- Set it on CREATE TEMPORARY TABLE / DROP TABLE
- Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset
- Don't set it for CREATE ... SELECT (this is handled in select_create class)
Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset.
If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands
sql/sql_partition.cc:
Update walk() usage
Trivial indentation fixes
sql/sql_plugin.cc:
Mark all columns as used for plugins
sql/sql_prepare.cc:
Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly)
Updates for new handler interface
Update calls to setup_fields()
sql/sql_repl.cc:
Indentation fixes
sql/sql_select.cc:
Update call to setup_tables() and setup_fields()
Remove some old disabled code
Update to new hadler interface
Indentation cleanups
Added column bitmaps for temporary tables.
Remove updating of the removed slots in the Field class
Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps)
For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution.
sql/sql_select.h:
Indentaition fixes.
Install temporary column usage maps when needed
Added TABLE element to cp_buffer_from_ref()
sql/sql_show.cc:
Update to new handler interface
Mark all columns used for internal tables.
Style fixes.
Added support for 'future' ROW_TYPE_PAGES.
Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly.
sql/sql_table.cc:
Update to new handler interface
Simple my_snprintf -> strmake()
Changed some constants to defines
Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL)
Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX
Mark all columns as used for ALTER TABLE
Style fixes
Update call to filesort()
sql/sql_trigger.h:
Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in.
sql/sql_udf.cc:
Mark all columns as used for udf system table.
sql/sql_union.cc:
Update call to walk()
Update to new handler interface
sql/sql_update.cc:
Remove query_id argument from compare_record()
Use column bitmaps instead of query_id.
We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value.
Update call to setup_fields()
Using separate column read and write sets allows for easier checking of timestamp field was set by statement.
Removed call to free_io_cache() as this is now done in ha_reset()
Call table->mark_columns_needed_for_update() and table->prepare_for_position()
Style fixes
sql/sql_view.cc:
Style fixes
sql/table.cc:
Remove implicitely include 'errno.h'
Remove code for building normalized path, as this is now identical to 'path'
Remove field->fieldnr
Added update of field->part_of_key_not_clustered()
Create column bitmaps in TABLE and TABLE_SHARE
Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler()
Update to new handler interface
Update call to walk()
Added new functions:
- st_table::clear_column_bitmaps()
- st_table::prepare_for_position()
- st_table::mark_columns_used_by_index()
- st_table::restore_column_maps_after_mark_index()
- st_table::mark_columns_used_by_index_no_reset()
- st_table::mark_auto_increment_column()
- st_table::mark_columns_needed_for_delete()
- st_table::mark_columns_needed_for_update()
- st_table::mark_columns_needed_for_insert()
sql/table.h:
Moved column usage bitmaps from handler to TABLE
Added to TABLE_SHARE all_set and column_bitmap_size
Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set.
Declared all new table column bitmap functions
Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps()
Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps
Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val().
sql/tztime.cc:
Mark all columns as used for timezone tables
storage/archive/ha_archive.cc:
Update to new handler interface
storage/archive/ha_archive.h:
Update to new handler interface
storage/blackhole/ha_blackhole.cc:
Update to new handler interface
storage/blackhole/ha_blackhole.h:
Update to new handler interface
removed not needed flag HA_DUPP_POS
storage/csv/ha_tina.cc:
Update to new handler interface
storage/csv/ha_tina.h:
Update to new handler interface
storage/example/ha_example.cc:
Update to new handler interface
storage/example/ha_example.h:
Update to new handler interface
storage/heap/hp_extra.c:
Added heap_reset() (Required by new handler interface)
storage/heap/hp_test2.c:
Use heap_reset()
storage/myisam/ft_boolean_search.c:
Fixed compiler warning
storage/myisam/mi_extra.c:
Added mi_reset() (Required by new handler interface)
storage/myisam/mi_search.c:
Fixed DBUG_PRINT messages to use 0x%lx instead of %lx
storage/myisam/mi_test2.c:
Use mi_reset()
storage/myisam/myisampack.c:
Use mi_reset()
storage/myisammrg/myrg_extra.c:
Added myrg_reset() (Required by new handler interface)
unittest/mysys/base64.t.c:
Include my_global.h
Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
|
|
|
This code will fail on a mixed relay log (one which has Format_desc then
|
|
|
|
Rotate then Format_desc).
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
*/
|
2015-09-02 09:58:08 +02:00
|
|
|
|
|
|
|
my_off_t scan_pos = BIN_LOG_HEADER_SIZE;
|
|
|
|
while (scan_pos < pos)
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
{
|
2015-09-02 09:58:08 +02:00
|
|
|
ev= Log_event::read_log_event(&log, (mysql_mutex_t*)0, description_event,
|
|
|
|
opt_master_verify_checksum);
|
|
|
|
scan_pos = my_b_tell(&log);
|
|
|
|
if (ev == NULL || !ev->is_valid())
|
|
|
|
{
|
|
|
|
mysql_mutex_unlock(log_lock);
|
|
|
|
errmsg = "Wrong offset or I/O error";
|
|
|
|
goto err;
|
|
|
|
}
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
if (ev->get_type_code() == FORMAT_DESCRIPTION_EVENT)
|
This is the final commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
It contains a few bugfixes (which I made when running the testsuite).
I carefully updated the results of the testsuite (i.e. I checked for every one,
if the difference between .reject and .result could be explained).
Apparently mysql-test-run --manager is broken in 4.1 and 5.0 currently,
so I could neither run the few tests which require --manager, nor check
that they pass nor modify their .result. But for builds, we don't run
with --manager.
Apart from --manager, the full testsuite passes, with Valgrind too (no errors).
I'm going to push in the next minutes. Remains: update the manual.
Note: by chance I saw that (in 4.1, in 5.0) rpl_get_lock fails when run alone;
this is normal at it makes assumptions on thread ids. I will fix this one day
in 4.1.
mysql-test/r/rpl000015.result:
result update
mysql-test/r/rpl_change_master.result:
result update
mysql-test/r/rpl_error_ignored_table.result:
result update
mysql-test/r/rpl_flush_log_loop.result:
result update
mysql-test/r/rpl_flush_tables.result:
result update
mysql-test/r/rpl_loaddata.result:
result update
mysql-test/r/rpl_loaddata_rule_m.result:
result update
mysql-test/r/rpl_loaddata_rule_s.result:
result update
mysql-test/r/rpl_log.result:
result update
mysql-test/r/rpl_log_pos.result:
result update
mysql-test/r/rpl_max_relay_size.result:
result update
mysql-test/r/rpl_relayrotate.result:
result update
mysql-test/r/rpl_replicate_do.result:
result update
mysql-test/r/rpl_reset_slave.result:
result update
mysql-test/r/rpl_rotate_logs.result:
result update
mysql-test/r/rpl_session_var.result:
result update
mysql-test/r/rpl_temporary.result:
result update
mysql-test/r/rpl_trunc_binlog.result:
result update
mysql-test/r/rpl_until.result:
result update
mysql-test/r/rpl_user_variables.result:
result update
mysql-test/t/rpl000010-slave.opt:
need to wait 2 events, because now we receive a Format_desc on top of the Rotate,
when replication starts.
mysql-test/t/rpl000015.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_change_master.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_empty_master_crash.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_error_ignored_table.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_flush_log_loop.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_loaddata.test:
position update
mysql-test/t/rpl_loaddata_rule_m.test:
position update
mysql-test/t/rpl_loaddata_rule_s.test:
position update
mysql-test/t/rpl_log.test:
position update
mysql-test/t/rpl_log_pos.test:
position update
mysql-test/t/rpl_max_relay_size.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_openssl.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_redirect.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_relayrotate-slave.opt:
better options for this test
mysql-test/t/rpl_relayrotate.test:
using max() is better for debugging (it shows at which place the slave
SQL thread resumed)
mysql-test/t/rpl_replicate_do.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_reset_slave.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_rotate_logs.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_session_var.test:
100 because password() is longer than 10 chars
mysql-test/t/rpl_trunc_binlog.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_until.test:
position update
mysql-test/t/rpl_user_variables.test:
position update
sql/log.cc:
Ensure that the Format_desc propagated on next relay logs does not trigger
undue actions (like incrementing some positions or clearing some files).
sql/log_event.cc:
* When the slave SQL thread finds a Rotate/Format_desc/Stop in the middle of
a transaction (then these were written by the slave itself to its relay log),
it should not increment rli->group* variables, but only rli->event* ones.
* When the slave SQL thread finds a Format_desc not to be ignored (not
the same server id as the slave's), if it has log_pos==0 it must not trigger
"unfinished transaction in master's binlog" (log_pos==0 is always a marker
in the relay log to mean "this event was not at this place in the master's
binlog": it's for fake Rotate events, and for Format_description events which the master had
to send us for replication to start).
* In the Query_log_event on disk, catalog is now terminated by '\0'.
* thd->catalog must be set to 0 when some exec_event() terminate (otherwise
double free).
sql/slave.cc:
* Fixes for a few bugs when ignoring events in the slave SQL thread:
- do not decrement rli->slave_skip_counter if the event is an event
related to the binlog or relay log itself (FORMAT_DESCRIPTION,
ROTATE, STOP) because these events should never be skipped (or the slave
will be confused). Usually the user wants to skip a query, not a Rotate...
- when we (re)connect to the master, we must free description_event_for_queue
(otherwise memory leak when we reconnect).
* Changed a bit the code where we change description_event_for_queue,
to make it look "safer".
* Moved 'created=0' to log.cc where it is safer.
* When the slave SQL thread finds a Rotate/Format_desc/Stop in the middle of
a transaction (then these were written by the slave itself to its relay log),
it should not increment rli->group* variables, but only rli->event* ones.
sql/sql_class.h:
a warning comment
sql/sql_repl.cc:
A mistake: I had passed a char* instead of char**
2003-12-19 22:40:23 +01:00
|
|
|
{
|
|
|
|
delete description_event;
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
description_event= (Format_description_log_event*) ev;
|
This is the final commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
It contains a few bugfixes (which I made when running the testsuite).
I carefully updated the results of the testsuite (i.e. I checked for every one,
if the difference between .reject and .result could be explained).
Apparently mysql-test-run --manager is broken in 4.1 and 5.0 currently,
so I could neither run the few tests which require --manager, nor check
that they pass nor modify their .result. But for builds, we don't run
with --manager.
Apart from --manager, the full testsuite passes, with Valgrind too (no errors).
I'm going to push in the next minutes. Remains: update the manual.
Note: by chance I saw that (in 4.1, in 5.0) rpl_get_lock fails when run alone;
this is normal at it makes assumptions on thread ids. I will fix this one day
in 4.1.
mysql-test/r/rpl000015.result:
result update
mysql-test/r/rpl_change_master.result:
result update
mysql-test/r/rpl_error_ignored_table.result:
result update
mysql-test/r/rpl_flush_log_loop.result:
result update
mysql-test/r/rpl_flush_tables.result:
result update
mysql-test/r/rpl_loaddata.result:
result update
mysql-test/r/rpl_loaddata_rule_m.result:
result update
mysql-test/r/rpl_loaddata_rule_s.result:
result update
mysql-test/r/rpl_log.result:
result update
mysql-test/r/rpl_log_pos.result:
result update
mysql-test/r/rpl_max_relay_size.result:
result update
mysql-test/r/rpl_relayrotate.result:
result update
mysql-test/r/rpl_replicate_do.result:
result update
mysql-test/r/rpl_reset_slave.result:
result update
mysql-test/r/rpl_rotate_logs.result:
result update
mysql-test/r/rpl_session_var.result:
result update
mysql-test/r/rpl_temporary.result:
result update
mysql-test/r/rpl_trunc_binlog.result:
result update
mysql-test/r/rpl_until.result:
result update
mysql-test/r/rpl_user_variables.result:
result update
mysql-test/t/rpl000010-slave.opt:
need to wait 2 events, because now we receive a Format_desc on top of the Rotate,
when replication starts.
mysql-test/t/rpl000015.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_change_master.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_empty_master_crash.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_error_ignored_table.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_flush_log_loop.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_loaddata.test:
position update
mysql-test/t/rpl_loaddata_rule_m.test:
position update
mysql-test/t/rpl_loaddata_rule_s.test:
position update
mysql-test/t/rpl_log.test:
position update
mysql-test/t/rpl_log_pos.test:
position update
mysql-test/t/rpl_max_relay_size.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_openssl.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_redirect.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_relayrotate-slave.opt:
better options for this test
mysql-test/t/rpl_relayrotate.test:
using max() is better for debugging (it shows at which place the slave
SQL thread resumed)
mysql-test/t/rpl_replicate_do.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_reset_slave.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_rotate_logs.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_session_var.test:
100 because password() is longer than 10 chars
mysql-test/t/rpl_trunc_binlog.test:
relay log information is not repeatable in general (if a reconnection
happens because --sleep=10 for example), so we hide these columns.
mysql-test/t/rpl_until.test:
position update
mysql-test/t/rpl_user_variables.test:
position update
sql/log.cc:
Ensure that the Format_desc propagated on next relay logs does not trigger
undue actions (like incrementing some positions or clearing some files).
sql/log_event.cc:
* When the slave SQL thread finds a Rotate/Format_desc/Stop in the middle of
a transaction (then these were written by the slave itself to its relay log),
it should not increment rli->group* variables, but only rli->event* ones.
* When the slave SQL thread finds a Format_desc not to be ignored (not
the same server id as the slave's), if it has log_pos==0 it must not trigger
"unfinished transaction in master's binlog" (log_pos==0 is always a marker
in the relay log to mean "this event was not at this place in the master's
binlog": it's for fake Rotate events, and for Format_description events which the master had
to send us for replication to start).
* In the Query_log_event on disk, catalog is now terminated by '\0'.
* thd->catalog must be set to 0 when some exec_event() terminate (otherwise
double free).
sql/slave.cc:
* Fixes for a few bugs when ignoring events in the slave SQL thread:
- do not decrement rli->slave_skip_counter if the event is an event
related to the binlog or relay log itself (FORMAT_DESCRIPTION,
ROTATE, STOP) because these events should never be skipped (or the slave
will be confused). Usually the user wants to skip a query, not a Rotate...
- when we (re)connect to the master, we must free description_event_for_queue
(otherwise memory leak when we reconnect).
* Changed a bit the code where we change description_event_for_queue,
to make it look "safer".
* Moved 'created=0' to log.cc where it is safer.
* When the slave SQL thread finds a Rotate/Format_desc/Stop in the middle of
a transaction (then these were written by the slave itself to its relay log),
it should not increment rli->group* variables, but only rli->event* ones.
sql/sql_class.h:
a warning comment
sql/sql_repl.cc:
A mistake: I had passed a char* instead of char**
2003-12-19 22:40:23 +01:00
|
|
|
}
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
else
|
2015-09-02 09:58:08 +02:00
|
|
|
{
|
|
|
|
if (ev->get_type_code() == START_ENCRYPTION_EVENT)
|
|
|
|
{
|
|
|
|
if (description_event->start_decryption((Start_encryption_log_event*) ev))
|
|
|
|
{
|
|
|
|
delete ev;
|
|
|
|
mysql_mutex_unlock(log_lock);
|
|
|
|
errmsg = "Could not initialize decryption of binlog.";
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
delete ev;
|
2015-09-02 09:58:08 +02:00
|
|
|
break;
|
|
|
|
}
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
}
|
|
|
|
|
2001-06-21 21:19:24 +02:00
|
|
|
my_b_seek(&log, pos);
|
|
|
|
|
2001-11-11 06:24:12 +01:00
|
|
|
for (event_count = 0;
|
2010-01-07 06:42:07 +01:00
|
|
|
(ev = Log_event::read_log_event(&log, (mysql_mutex_t*) 0,
|
2011-05-03 14:01:11 +02:00
|
|
|
description_event,
|
|
|
|
opt_master_verify_checksum)); )
|
2001-06-21 21:19:24 +02:00
|
|
|
{
|
|
|
|
if (event_count >= limit_start &&
|
2015-10-22 16:00:58 +02:00
|
|
|
ev->net_send(protocol, linfo.log_file_name, pos))
|
2001-07-10 14:53:08 +02:00
|
|
|
{
|
|
|
|
errmsg = "Net error";
|
|
|
|
delete ev;
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(log_lock);
|
2001-07-10 14:53:08 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2015-09-02 09:58:08 +02:00
|
|
|
if (ev->get_type_code() == FORMAT_DESCRIPTION_EVENT)
|
|
|
|
{
|
|
|
|
Format_description_log_event* new_fdle=
|
|
|
|
(Format_description_log_event*) ev;
|
|
|
|
new_fdle->copy_crypto_data(description_event);
|
|
|
|
delete description_event;
|
|
|
|
description_event= new_fdle;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ev->get_type_code() == START_ENCRYPTION_EVENT)
|
|
|
|
{
|
|
|
|
if (description_event->start_decryption((Start_encryption_log_event*) ev))
|
|
|
|
{
|
|
|
|
errmsg = "Error starting decryption";
|
|
|
|
delete ev;
|
|
|
|
mysql_mutex_unlock(log_lock);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete ev;
|
|
|
|
}
|
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
pos = my_b_tell(&log);
|
2001-06-21 21:19:24 +02:00
|
|
|
|
|
|
|
if (++event_count >= limit_end)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event_count < limit_end && log.error)
|
|
|
|
{
|
|
|
|
errmsg = "Wrong offset or I/O error";
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(log_lock);
|
2001-06-21 21:19:24 +02:00
|
|
|
goto err;
|
|
|
|
}
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(log_lock);
|
2001-06-21 21:19:24 +02:00
|
|
|
}
|
2012-09-28 02:45:05 +02:00
|
|
|
else if (mi)
|
|
|
|
mysql_mutex_unlock(&LOCK_active_mi);
|
|
|
|
|
2012-04-20 23:25:59 +02:00
|
|
|
// Check that linfo is still on the function scope.
|
|
|
|
DEBUG_SYNC(thd, "after_show_binlog_events");
|
2001-06-21 21:19:24 +02:00
|
|
|
|
2005-02-28 16:34:02 +01:00
|
|
|
ret= FALSE;
|
|
|
|
|
2001-06-21 21:19:24 +02:00
|
|
|
err:
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
client/Makefile.am:
mysqlbinlog.cc depends slightly on sql/mysql_priv.h
client/mysqlbinlog.cc:
Make mysqlbinlog able to read the new binlog format,
by seeking to the start and reading the first few events, to
detect the format of the binlog.
include/my_sys.h:
a correct tell() for SEQ_READ_APPEND caches.
mysys/mf_iocache2.c:
a correct tell() for SEQ_READ_APPEND caches
(my_b_tell() is not working for such caches).
sql/ha_innodb.cc:
we are getting rid of event lengthes here and there, which is good.
sql/log.cc:
Start events will have created==0 if generated by rotation (like in 3.23).
In 5.0 we always write a Format_description_log_event at the beginning of
every master's binary log and of every slave's relay log.
We also add Rotate and Stop to relay logs (like there already was in
master's binary logs).
When we rotate a relay log, we write the previous relay log's Start event
(the one which was sent from the master) to the beginning of the new log,
so that we don't need the previous relay log to understand the new one;
that's the purpose of MYSQL_LOG::description_event_for_queue.
Removed logging of SET FOREIGN_KEY_CHECKS, because we handle it as flags
in the Query event now.
sql/log_event.cc:
New event type: Format_description_log_event, to describe the log's format.
read_log_event() needs to be passed this event to be able to read 5.0 events.
Query_log_event has new members flags2 and sql_mode for replication of session
variables (except charsets which are WL#1062) and SQL_MODE.
flags2 is in fact a kind of copy of thd->options (&'d with a mask).
Now with this replication of FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS
and SQL_MODE work; with mysqlbinlog too.
sql/log_event.h:
Binlog version is changed to 4.
New classes (details in sql/log_event.cc).
Removing some useless #defines.
sql/mysql_priv.h:
Definition of SELECT_DISTINCT and others must be visible in client/mysqlbinlog.cc,
so adding #ifdefs.
sql/mysqld.cc:
update for prototype change
sql/slave.cc:
When the slave opens a relay log, it reads the first few events to know the format.
When slave I/O thread receives a Rotate from the master, it rotates its relay log
(to avoid mixed format in the relay log).
sql/slave.h:
in the slave we avoid lengthes and rely on absolute positions instead;
hence the introduction of future_group_master_log_pos and future_event_relay_log_pos
(explained in code).
sql/sql_class.cc:
catalog in THD
sql/sql_class.h:
catalog, and new members in MYSQL_LOG
sql/sql_repl.cc:
When the master starts sending binlog to slave, it must
first read the first few events to detect the binlog's format.
Same for SHOW BINLOG EVENTS.
2003-12-18 01:09:05 +01:00
|
|
|
delete description_event;
|
2001-06-21 21:19:24 +02:00
|
|
|
if (file >= 0)
|
|
|
|
{
|
|
|
|
end_io_cache(&log);
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_file_close(file, MYF(MY_WME));
|
2001-06-21 21:19:24 +02:00
|
|
|
}
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2001-06-21 21:19:24 +02:00
|
|
|
if (errmsg)
|
now my_printf_error is not better then my_error, but my_error call is shorter
used only one implementation of format parser of (printf)
fixed multistatement
include/mysqld_error.h:
newerror messages
mysql-test/t/key.test:
unknown error replaced with real error
mysys/my_error.c:
my_error & my_printf_error use my_vsprintf
sql/field_conv.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/ha_innodb.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/handler.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_cmpfunc.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_func.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_strfunc.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/lock.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/log.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/parse_file.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/procedure.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/protocol.cc:
no need reset thd->lex->found_colon to break multiline sequance now, send_error called too late
sql/repl_failsafe.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/set_var.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/share/czech/errmsg.txt:
new errors converted from unknown error
sql/share/danish/errmsg.txt:
new errors converted from unknown error
sql/share/dutch/errmsg.txt:
new errors converted from unknown error
sql/share/english/errmsg.txt:
new errors converted from unknown error
sql/share/estonian/errmsg.txt:
new errors converted from unknown error
sql/share/french/errmsg.txt:
new errors converted from unknown error
sql/share/german/errmsg.txt:
new errors converted from unknown error
sql/share/greek/errmsg.txt:
new errors converted from unknown error
sql/share/hungarian/errmsg.txt:
new errors converted from unknown error
sql/share/italian/errmsg.txt:
new errors converted from unknown error
sql/share/japanese/errmsg.txt:
new errors converted from unknown error
sql/share/korean/errmsg.txt:
new errors converted from unknown error
sql/share/norwegian-ny/errmsg.txt:
new errors converted from unknown error
sql/share/norwegian/errmsg.txt:
new errors converted from unknown error
sql/share/polish/errmsg.txt:
new errors converted from unknown error
sql/share/portuguese/errmsg.txt:
new errors converted from unknown error
sql/share/romanian/errmsg.txt:
new errors converted from unknown error
sql/share/russian/errmsg.txt:
new errors converted from unknown error
sql/share/serbian/errmsg.txt:
new errors converted from unknown error
sql/share/slovak/errmsg.txt:
new errors converted from unknown error
sql/share/spanish/errmsg.txt:
new errors converted from unknown error
sql/share/swedish/errmsg.txt:
new errors converted from unknown error
sql/share/ukrainian/errmsg.txt:
new errors converted from unknown error
sql/slave.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sp.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sp_head.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_acl.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_analyse.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_base.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_class.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_db.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_delete.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_handler.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_insert.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_load.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_map.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_parse.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
multi-row command fixed
sql/sql_prepare.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
remover send_error ingected from 4.1
sql/sql_rename.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_repl.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_select.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_show.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_table.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_trigger.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_udf.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_update.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_view.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_yacc.yy:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/table.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
strings/my_vsnprintf.c:
* format support added to my_vsprint
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0),
|
|
|
|
"SHOW BINLOG EVENTS", errmsg);
|
2007-07-05 10:09:56 +02:00
|
|
|
else
|
2008-02-19 13:58:08 +01:00
|
|
|
my_eof(thd);
|
2001-06-21 21:19:24 +02:00
|
|
|
|
2016-02-01 11:45:39 +01:00
|
|
|
thd->reset_current_linfo();
|
2010-07-20 17:27:13 +02:00
|
|
|
thd->variables.max_allowed_packet= old_max_allowed_packet;
|
2005-02-28 16:34:02 +01:00
|
|
|
DBUG_RETURN(ret);
|
2001-06-21 21:19:24 +02:00
|
|
|
}
|
|
|
|
|
2002-09-11 05:40:08 +02:00
|
|
|
|
2016-01-27 10:42:53 +01:00
|
|
|
void show_binlog_info_get_fields(THD *thd, List<Item> *field_list)
|
|
|
|
{
|
|
|
|
MEM_ROOT *mem_root= thd->mem_root;
|
|
|
|
field_list->push_back(new (mem_root)
|
|
|
|
Item_empty_string(thd, "File", FN_REFLEN),
|
|
|
|
mem_root);
|
|
|
|
field_list->push_back(new (mem_root)
|
|
|
|
Item_return_int(thd, "Position", 20,
|
|
|
|
MYSQL_TYPE_LONGLONG),
|
|
|
|
mem_root);
|
|
|
|
field_list->push_back(new (mem_root)
|
|
|
|
Item_empty_string(thd, "Binlog_Do_DB", 255),
|
|
|
|
mem_root);
|
|
|
|
field_list->push_back(new (mem_root)
|
|
|
|
Item_empty_string(thd, "Binlog_Ignore_DB", 255),
|
|
|
|
mem_root);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
/**
|
|
|
|
Execute a SHOW MASTER STATUS statement.
|
|
|
|
|
|
|
|
@param thd Pointer to THD object for the client thread executing the
|
|
|
|
statement.
|
|
|
|
|
|
|
|
@retval FALSE success
|
|
|
|
@retval TRUE failure
|
|
|
|
*/
|
2004-10-20 03:04:37 +02:00
|
|
|
bool show_binlog_info(THD* thd)
|
2000-10-02 05:28:21 +02:00
|
|
|
{
|
2002-12-11 08:17:51 +01:00
|
|
|
Protocol *protocol= thd->protocol;
|
2000-10-02 05:28:21 +02:00
|
|
|
DBUG_ENTER("show_binlog_info");
|
2015-08-20 14:24:13 +02:00
|
|
|
|
2000-10-02 05:28:21 +02:00
|
|
|
List<Item> field_list;
|
2016-01-27 10:42:53 +01:00
|
|
|
show_binlog_info_get_fields(thd, &field_list);
|
2000-10-02 05:28:21 +02:00
|
|
|
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
if (protocol->send_result_set_metadata(&field_list,
|
Port of cursors to be pushed into 5.0 tree:
- client side part is simple and may be considered stable
- server side part now just joggles with THD state to save execution
state and has no additional locking wisdom.
Lot's of it are to be rewritten.
include/mysql.h:
Cursor patch to push into the main tree, client library part (considered
stable):
- new statement attribute STMT_ATTR_CURSOR_TYPE
- MYSQL_STMT::flags to store statement cursor type
- MYSQL_STMT::server_status to store server status (i. e. if the server
was able to open a cursor for this query).
include/mysql_com.h:
Cursor patch to push into the main tree, client library part (considered
stable):
- new COMmand, COM_FETCH, to fetch K rows from read-only cursor.
By design should support scrollable cursors as well.
- a few new server statuses:
SERVER_STATUS_CURSOR_EXISTS is sent by server in reply to COM_EXECUTE,
when cursor was successfully opened for this query
SERVER_STATUS_LAST_ROW_SENT is sent along with the last row to prevent one
more round trip just for finding out that all rows were fetched from
this cursor (this is server mem savier also).
- and finally, all possible values of STMT_ATTR_CURSOR_TYPE,
while now we support only CURSORT_TYPE_NO_CURSOR and
CURSOR_TYPE_READ_ONLY
libmysql/libmysql.c:
Cursor patch to push into the main tree, client library part (considered
stable):
- simple additions to mysql_stmt_fetch implementation to read data
from an opened cursor: we can read up to iteration count rows per
one request; read rows are buffered in the same way as rows of
mysql_stmt_store_result.
- now send stmt->flags to server to let him now if we wish to have
a cursor for this statement.
- support for setting/getting statement cursor type.
libmysqld/examples/Makefile.am:
Testing cursors was originally implemented in C++. Now when these tests
go into client_test, it's time to convert it to C++ as well.
libmysqld/lib_sql.cc:
- cleanup: send_fields flags are now named.
sql/ha_innodb.cc:
- cleanup: send_fields flags are now named.
sql/mysql_priv.h:
- cursors support: declaration for server-side handler of COM_FETCH
sql/protocol.cc:
- cleanup: send_fields flags are now named.
- we can't anymore assert that field_types[field_pos] is sensible:
if we have COM_EXCUTE(stmt1), COM_EXECUTE(stmt2), COM_FETCH(stmt1)
field_types[field_pos] will point to fields of stmt2.
sql/protocol.h:
- cleanup: send_fields flag_s_ are now named.
sql/protocol_cursor.cc:
- cleanup: send_fields flags are now named.
sql/repl_failsafe.cc:
- cleanup: send_fields flags are now named.
sql/slave.cc:
- cleanup: send_fields flags are now named.
sql/sp.cc:
- cleanup: send_fields flags are now named.
sql/sp_head.cc:
- cleanup: send_fields flags are now named.
sql/sql_acl.cc:
- cleanup: send_fields flags are now named.
sql/sql_class.cc:
- cleanup: send_fields flags are now named.
sql/sql_class.h:
- cleanup: send_fields flags are now named.
sql/sql_error.cc:
- cleanup: send_fields flags are now named.
sql/sql_handler.cc:
- cleanup: send_fields flags are now named.
sql/sql_help.cc:
- cleanup: send_fields flags are now named.
sql/sql_parse.cc:
Server side support for cursors:
- handle COM_FETCH
- enforce assumption that whenever we free thd->free_list,
we reset it to zero. This way it's much easier to handle free_list
in prepared statements implementation.
sql/sql_prepare.cc:
Server side support for cursors:
- implementation of mysql_stmt_fetch (fetch some rows from open cursor).
- management of cursors memory is quite tricky now.
- execute_stmt can't be reused anymore in mysql_stmt_execute and
mysql_sql_stmt_execute
sql/sql_repl.cc:
- cleanup: send_fields flags are now named.
sql/sql_select.cc:
Server side support for cursors:
- implementation of Cursor::open, Cursor::fetch (buggy when it comes to
non-equi joins), cursor cleanups.
- -4 -3 -0 constants indicating return value of sub_select and end_send are
to be renamed to something more readable:
it turned out to be not so simple, so it should come with the other patch.
sql/sql_select.h:
Server side support for cursors:
- declaration of Cursor class.
- JOIN::fetch_limit contains runtime value of rows fetched via cursor.
sql/sql_show.cc:
- cleanup: send_fields flags are now named.
sql/sql_table.cc:
- cleanup: send_fields flags are now named.
sql/sql_union.cc:
- if there was a cursor, don't cleanup unit: we'll need it to fetch
the rest of the rows.
tests/Makefile.am:
Now client_test is in C++.
tests/client_test.cc:
A few elementary tests for cursors.
BitKeeper/etc/ignore:
Added libmysqld/examples/client_test.cc to the ignore list
2004-08-03 12:32:21 +02:00
|
|
|
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
|
2004-10-20 03:04:37 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
2002-12-11 08:17:51 +01:00
|
|
|
protocol->prepare_for_resend();
|
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
if (mysql_bin_log.is_open())
|
|
|
|
{
|
|
|
|
LOG_INFO li;
|
|
|
|
mysql_bin_log.get_current_log(&li);
|
|
|
|
int dir_len = dirname_length(li.log_file_name);
|
2003-03-18 08:34:19 +01:00
|
|
|
protocol->store(li.log_file_name + dir_len, &my_charset_bin);
|
2002-12-11 08:17:51 +01:00
|
|
|
protocol->store((ulonglong) li.pos);
|
2005-03-08 21:12:35 +01:00
|
|
|
protocol->store(binlog_filter->get_do_db());
|
|
|
|
protocol->store(binlog_filter->get_ignore_db());
|
2002-12-11 08:17:51 +01:00
|
|
|
if (protocol->write())
|
2004-10-20 03:04:37 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
2001-07-10 14:53:08 +02:00
|
|
|
}
|
2008-02-19 13:58:08 +01:00
|
|
|
my_eof(thd);
|
2004-10-20 03:04:37 +02:00
|
|
|
DBUG_RETURN(FALSE);
|
2000-10-02 05:28:21 +02:00
|
|
|
}
|
2000-10-27 06:11:55 +02:00
|
|
|
|
2001-07-10 14:53:08 +02:00
|
|
|
|
2016-01-27 10:57:25 +01:00
|
|
|
void show_binlogs_get_fields(THD *thd, List<Item> *field_list)
|
|
|
|
{
|
|
|
|
MEM_ROOT *mem_root= thd->mem_root;
|
|
|
|
field_list->push_back(new (mem_root)
|
|
|
|
Item_empty_string(thd, "Log_name", 255),
|
|
|
|
mem_root);
|
|
|
|
field_list->push_back(new (mem_root)
|
|
|
|
Item_return_int(thd, "File_size", 20,
|
|
|
|
MYSQL_TYPE_LONGLONG),
|
|
|
|
mem_root);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
/**
|
|
|
|
Execute a SHOW BINARY LOGS statement.
|
2002-08-08 02:12:02 +02:00
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
@param thd Pointer to THD object for the client thread executing the
|
|
|
|
statement.
|
2002-08-08 02:12:02 +02:00
|
|
|
|
2009-01-09 13:49:24 +01:00
|
|
|
@retval FALSE success
|
|
|
|
@retval TRUE failure
|
2002-08-08 02:12:02 +02:00
|
|
|
*/
|
2004-10-20 03:04:37 +02:00
|
|
|
bool show_binlogs(THD* thd)
|
2000-10-27 06:11:55 +02:00
|
|
|
{
|
2002-08-08 02:12:02 +02:00
|
|
|
IO_CACHE *index_file;
|
2005-05-19 12:34:15 +02:00
|
|
|
LOG_INFO cur;
|
|
|
|
File file;
|
2000-10-27 06:11:55 +02:00
|
|
|
char fname[FN_REFLEN];
|
|
|
|
List<Item> field_list;
|
2000-11-16 02:58:58 +01:00
|
|
|
uint length;
|
2005-05-25 11:56:47 +02:00
|
|
|
int cur_dir_len;
|
2002-12-11 08:17:51 +01:00
|
|
|
Protocol *protocol= thd->protocol;
|
|
|
|
DBUG_ENTER("show_binlogs");
|
2001-07-10 14:53:08 +02:00
|
|
|
|
|
|
|
if (!mysql_bin_log.is_open())
|
2000-11-16 02:58:58 +01:00
|
|
|
{
|
2010-12-07 17:55:25 +01:00
|
|
|
my_error(ER_NO_BINARY_LOGGING, MYF(0));
|
2009-10-19 15:04:27 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
2000-11-16 02:58:58 +01:00
|
|
|
}
|
2000-10-27 06:11:55 +02:00
|
|
|
|
2016-01-27 10:57:25 +01:00
|
|
|
show_binlogs_get_fields(thd, &field_list);
|
|
|
|
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
if (protocol->send_result_set_metadata(&field_list,
|
Port of cursors to be pushed into 5.0 tree:
- client side part is simple and may be considered stable
- server side part now just joggles with THD state to save execution
state and has no additional locking wisdom.
Lot's of it are to be rewritten.
include/mysql.h:
Cursor patch to push into the main tree, client library part (considered
stable):
- new statement attribute STMT_ATTR_CURSOR_TYPE
- MYSQL_STMT::flags to store statement cursor type
- MYSQL_STMT::server_status to store server status (i. e. if the server
was able to open a cursor for this query).
include/mysql_com.h:
Cursor patch to push into the main tree, client library part (considered
stable):
- new COMmand, COM_FETCH, to fetch K rows from read-only cursor.
By design should support scrollable cursors as well.
- a few new server statuses:
SERVER_STATUS_CURSOR_EXISTS is sent by server in reply to COM_EXECUTE,
when cursor was successfully opened for this query
SERVER_STATUS_LAST_ROW_SENT is sent along with the last row to prevent one
more round trip just for finding out that all rows were fetched from
this cursor (this is server mem savier also).
- and finally, all possible values of STMT_ATTR_CURSOR_TYPE,
while now we support only CURSORT_TYPE_NO_CURSOR and
CURSOR_TYPE_READ_ONLY
libmysql/libmysql.c:
Cursor patch to push into the main tree, client library part (considered
stable):
- simple additions to mysql_stmt_fetch implementation to read data
from an opened cursor: we can read up to iteration count rows per
one request; read rows are buffered in the same way as rows of
mysql_stmt_store_result.
- now send stmt->flags to server to let him now if we wish to have
a cursor for this statement.
- support for setting/getting statement cursor type.
libmysqld/examples/Makefile.am:
Testing cursors was originally implemented in C++. Now when these tests
go into client_test, it's time to convert it to C++ as well.
libmysqld/lib_sql.cc:
- cleanup: send_fields flags are now named.
sql/ha_innodb.cc:
- cleanup: send_fields flags are now named.
sql/mysql_priv.h:
- cursors support: declaration for server-side handler of COM_FETCH
sql/protocol.cc:
- cleanup: send_fields flags are now named.
- we can't anymore assert that field_types[field_pos] is sensible:
if we have COM_EXCUTE(stmt1), COM_EXECUTE(stmt2), COM_FETCH(stmt1)
field_types[field_pos] will point to fields of stmt2.
sql/protocol.h:
- cleanup: send_fields flag_s_ are now named.
sql/protocol_cursor.cc:
- cleanup: send_fields flags are now named.
sql/repl_failsafe.cc:
- cleanup: send_fields flags are now named.
sql/slave.cc:
- cleanup: send_fields flags are now named.
sql/sp.cc:
- cleanup: send_fields flags are now named.
sql/sp_head.cc:
- cleanup: send_fields flags are now named.
sql/sql_acl.cc:
- cleanup: send_fields flags are now named.
sql/sql_class.cc:
- cleanup: send_fields flags are now named.
sql/sql_class.h:
- cleanup: send_fields flags are now named.
sql/sql_error.cc:
- cleanup: send_fields flags are now named.
sql/sql_handler.cc:
- cleanup: send_fields flags are now named.
sql/sql_help.cc:
- cleanup: send_fields flags are now named.
sql/sql_parse.cc:
Server side support for cursors:
- handle COM_FETCH
- enforce assumption that whenever we free thd->free_list,
we reset it to zero. This way it's much easier to handle free_list
in prepared statements implementation.
sql/sql_prepare.cc:
Server side support for cursors:
- implementation of mysql_stmt_fetch (fetch some rows from open cursor).
- management of cursors memory is quite tricky now.
- execute_stmt can't be reused anymore in mysql_stmt_execute and
mysql_sql_stmt_execute
sql/sql_repl.cc:
- cleanup: send_fields flags are now named.
sql/sql_select.cc:
Server side support for cursors:
- implementation of Cursor::open, Cursor::fetch (buggy when it comes to
non-equi joins), cursor cleanups.
- -4 -3 -0 constants indicating return value of sub_select and end_send are
to be renamed to something more readable:
it turned out to be not so simple, so it should come with the other patch.
sql/sql_select.h:
Server side support for cursors:
- declaration of Cursor class.
- JOIN::fetch_limit contains runtime value of rows fetched via cursor.
sql/sql_show.cc:
- cleanup: send_fields flags are now named.
sql/sql_table.cc:
- cleanup: send_fields flags are now named.
sql/sql_union.cc:
- if there was a cursor, don't cleanup unit: we'll need it to fetch
the rest of the rows.
tests/Makefile.am:
Now client_test is in C++.
tests/client_test.cc:
A few elementary tests for cursors.
BitKeeper/etc/ignore:
Added libmysqld/examples/client_test.cc to the ignore list
2004-08-03 12:32:21 +02:00
|
|
|
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
|
2004-10-20 03:04:37 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
2006-09-04 13:43:34 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(mysql_bin_log.get_log_lock());
|
2000-10-27 06:11:55 +02:00
|
|
|
mysql_bin_log.lock_index();
|
2002-08-08 02:12:02 +02:00
|
|
|
index_file=mysql_bin_log.get_index_file();
|
2006-09-04 13:43:34 +02:00
|
|
|
|
|
|
|
mysql_bin_log.raw_get_current_log(&cur); // dont take mutex
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(mysql_bin_log.get_log_lock()); // lockdep, OK
|
2006-09-04 13:43:34 +02:00
|
|
|
|
2005-05-25 11:56:47 +02:00
|
|
|
cur_dir_len= dirname_length(cur.log_file_name);
|
2005-05-19 12:34:15 +02:00
|
|
|
|
2002-08-08 02:12:02 +02:00
|
|
|
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)
|
2000-11-16 02:58:58 +01:00
|
|
|
{
|
2005-05-25 11:56:47 +02:00
|
|
|
int dir_len;
|
|
|
|
ulonglong file_length= 0; // Length if open fails
|
|
|
|
fname[--length] = '\0'; // remove the newline
|
2005-05-19 12:34:15 +02:00
|
|
|
|
2002-12-14 16:43:01 +01:00
|
|
|
protocol->prepare_for_resend();
|
2005-05-25 11:56:47 +02:00
|
|
|
dir_len= dirname_length(fname);
|
|
|
|
length-= dir_len;
|
|
|
|
protocol->store(fname + dir_len, length, &my_charset_bin);
|
|
|
|
|
|
|
|
if (!(strncmp(fname+dir_len, cur.log_file_name+cur_dir_len, length)))
|
|
|
|
file_length= cur.pos; /* The active log, use the active position */
|
|
|
|
else
|
2005-05-19 12:34:15 +02:00
|
|
|
{
|
|
|
|
/* this is an old log, open it and find the size */
|
2010-01-07 06:42:07 +01:00
|
|
|
if ((file= mysql_file_open(key_file_binlog,
|
|
|
|
fname, O_RDONLY | O_SHARE | O_BINARY,
|
|
|
|
MYF(0))) >= 0)
|
2005-05-19 12:34:15 +02:00
|
|
|
{
|
2010-01-07 06:42:07 +01:00
|
|
|
file_length= (ulonglong) mysql_file_seek(file, 0L, MY_SEEK_END, MYF(0));
|
|
|
|
mysql_file_close(file, MYF(0));
|
2005-05-19 12:34:15 +02:00
|
|
|
}
|
|
|
|
}
|
2005-05-25 11:56:47 +02:00
|
|
|
protocol->store(file_length);
|
2002-12-11 08:17:51 +01:00
|
|
|
if (protocol->write())
|
2002-08-08 02:12:02 +02:00
|
|
|
goto err;
|
2000-11-16 02:58:58 +01:00
|
|
|
}
|
2013-03-28 09:44:39 +01:00
|
|
|
if(index_file->error == -1)
|
|
|
|
goto err;
|
2000-10-27 06:11:55 +02:00
|
|
|
mysql_bin_log.unlock_index();
|
2008-02-19 13:58:08 +01:00
|
|
|
my_eof(thd);
|
2004-10-20 03:04:37 +02:00
|
|
|
DBUG_RETURN(FALSE);
|
2000-11-16 02:58:58 +01:00
|
|
|
|
2002-08-08 02:12:02 +02:00
|
|
|
err:
|
|
|
|
mysql_bin_log.unlock_index();
|
2004-10-20 03:04:37 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
2000-10-27 06:11:55 +02:00
|
|
|
}
|
|
|
|
|
2007-12-21 21:34:43 +01:00
|
|
|
/**
|
|
|
|
Load data's io cache specific hook to be executed
|
|
|
|
before a chunk of data is being read into the cache's buffer
|
|
|
|
The fuction instantianates and writes into the binlog
|
|
|
|
replication events along LOAD DATA processing.
|
|
|
|
|
|
|
|
@param file pointer to io-cache
|
2010-01-24 08:03:23 +01:00
|
|
|
@retval 0 success
|
|
|
|
@retval 1 failure
|
2007-12-21 21:34:43 +01:00
|
|
|
*/
|
2015-05-16 08:48:52 +02:00
|
|
|
int log_loaded_block(IO_CACHE* file, uchar *Buffer, size_t Count)
|
2001-08-03 23:57:53 +02:00
|
|
|
{
|
2007-12-21 21:34:43 +01:00
|
|
|
DBUG_ENTER("log_loaded_block");
|
2015-05-16 08:48:52 +02:00
|
|
|
LOAD_FILE_IO_CACHE *lf_info= static_cast<LOAD_FILE_IO_CACHE*>(file);
|
2007-12-21 21:34:43 +01:00
|
|
|
uint block_len;
|
|
|
|
/* buffer contains position where we started last read */
|
2008-01-31 12:32:48 +01:00
|
|
|
uchar* buffer= (uchar*) my_b_get_buffer_start(file);
|
2015-05-16 08:48:52 +02:00
|
|
|
uint max_event_size= lf_info->thd->variables.max_allowed_packet;
|
|
|
|
|
BUG#39934: Slave stops for engine that only support row-based logging
General overview:
The logic for switching to row format when binlog_format=MIXED had
numerous flaws. The underlying problem was the lack of a consistent
architecture.
General purpose of this changeset:
This changeset introduces an architecture for switching to row format
when binlog_format=MIXED. It enforces the architecture where it has
to. It leaves some bugs to be fixed later. It adds extensive tests to
verify that unsafe statements work as expected and that appropriate
errors are produced by problems with the selection of binlog format.
It was not practical to split this into smaller pieces of work.
Problem 1:
To determine the logging mode, the code has to take several parameters
into account (namely: (1) the value of binlog_format; (2) the
capabilities of the engines; (3) the type of the current statement:
normal, unsafe, or row injection). These parameters may conflict in
several ways, namely:
- binlog_format=STATEMENT for a row injection
- binlog_format=STATEMENT for an unsafe statement
- binlog_format=STATEMENT for an engine only supporting row logging
- binlog_format=ROW for an engine only supporting statement logging
- statement is unsafe and engine does not support row logging
- row injection in a table that does not support statement logging
- statement modifies one table that does not support row logging and
one that does not support statement logging
Several of these conflicts were not detected, or were detected with
an inappropriate error message. The problem of BUG#39934 was that no
appropriate error message was written for the case when an engine
only supporting row logging executed a row injection with
binlog_format=ROW. However, all above cases must be handled.
Fix 1:
Introduce new error codes (sql/share/errmsg.txt). Ensure that all
conditions are detected and handled in decide_logging_format()
Problem 2:
The binlog format shall be determined once per statement, in
decide_logging_format(). It shall not be changed before or after that.
Before decide_logging_format() is called, all information necessary to
determine the logging format must be available. This principle ensures
that all unsafe statements are handled in a consistent way.
However, this principle is not followed:
thd->set_current_stmt_binlog_row_based_if_mixed() is called in several
places, including from code executing UPDATE..LIMIT,
INSERT..SELECT..LIMIT, DELETE..LIMIT, INSERT DELAYED, and
SET @@binlog_format. After Problem 1 was fixed, that caused
inconsistencies where these unsafe statements would not print the
appropriate warnings or errors for some of the conflicts.
Fix 2:
Remove calls to THD::set_current_stmt_binlog_row_based_if_mixed() from
code executed after decide_logging_format(). Compensate by calling the
set_current_stmt_unsafe() at parse time. This way, all unsafe statements
are detected by decide_logging_format().
Problem 3:
INSERT DELAYED is not unsafe: it is logged in statement format even if
binlog_format=MIXED, and no warning is printed even if
binlog_format=STATEMENT. This is BUG#45825.
Fix 3:
Made INSERT DELAYED set itself to unsafe at parse time. This allows
decide_logging_format() to detect that a warning should be printed or
the binlog_format changed.
Problem 4:
LIMIT clause were not marked as unsafe when executed inside stored
functions/triggers/views/prepared statements. This is
BUG#45785.
Fix 4:
Make statements containing the LIMIT clause marked as unsafe at
parse time, instead of at execution time. This allows propagating
unsafe-ness to the view.
mysql-test/extra/rpl_tests/create_recursive_construct.inc:
Added auxiliary file used by binlog_unsafe.test to create and
execute recursive constructs
(functions/procedures/triggers/views/prepared statements).
mysql-test/extra/rpl_tests/rpl_foreign_key.test:
removed unnecessary set @@session.binlog_format
mysql-test/extra/rpl_tests/rpl_insert_delayed.test:
Filter out table id from table map events in binlog listing.
Got rid of $binlog_format_statement.
mysql-test/extra/rpl_tests/rpl_ndb_apply_status.test:
disable warnings around call to unsafe procedure
mysql-test/include/rpl_udf.inc:
Disabled warnings for code that generates warnings
for some binlog formats. That would otherwise cause
inconsistencies in the result file.
mysql-test/r/mysqldump.result:
Views are now unsafe if they contain a LIMIT clause.
That fixed BUG#45831. Due to BUG#45832, a warning is
printed for the CREATE VIEW statement.
mysql-test/r/sp_trans.result:
Unsafe statements in stored procedures did not give a warning if
binlog_format=statement. This is BUG#45824. Now they do, so this
result file gets a new warning.
mysql-test/suite/binlog/r/binlog_multi_engine.result:
Error message changed.
mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result:
INSERT DELAYED didn't generate a warning when binlog_format=STATEMENT.
That was BUG#45825. Now there is a warning, so result file needs to be
updated.
mysql-test/suite/binlog/r/binlog_stm_ps.result:
Changed error message.
mysql-test/suite/binlog/r/binlog_unsafe.result:
updated result file:
- error message changed
- added test for most combinations of unsafe constructs invoked
from recursive constructs
- INSERT DELAYED now gives a warning (because BUG#45826 is fixed)
- INSERT..SELECT..LIMIT now gives a warning from inside recursive
constructs (because BUG#45785 was fixed)
- When a recursive construct (e.g., stored proc or function)
contains more than one statement, at least one of which is
unsafe, then all statements in the recursive construct give
warnings. This is a new bug introduced by this changeset.
It will be addressed in a post-push fix.
mysql-test/suite/binlog/t/binlog_innodb.test:
Changed error code for innodb updates with READ COMMITTED or
READ UNCOMMITTED transaction isolation level and
binlog_format=statement.
mysql-test/suite/binlog/t/binlog_multi_engine.test:
The error code has changed for statements where more than one
engine is involved and one of them is self-logging.
mysql-test/suite/binlog/t/binlog_unsafe-master.opt:
Since binlog_unsafe now tests unsafe-ness of UDF's, we need an extra
flag in the .opt file.
mysql-test/suite/binlog/t/binlog_unsafe.test:
- Clarified comment.
- Rewrote first part of test. Now it tests not only unsafe variables
and functions, but also unsafe-ness due to INSERT..SELECT..LIMIT,
INSERT DELAYED, insert into two autoinc columns, use of UDF's, and
access to log tables in the mysql database.
Also, in addition to functions, procedures, triggers, and prepared
statements, it now also tests views; and it constructs recursive
calls in two levels by combining these recursive constructs.
Part of the logic is in extra/rpl_tests/create_recursive_construct.inc.
- added tests for all special system variables that should not be unsafe.
- added specific tests for BUG#45785 and BUG#45825
mysql-test/suite/rpl/r/rpl_events.result:
updated result file
mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result:
updated result file
mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result:
updated result file
mysql-test/suite/rpl/r/rpl_foreign_key_innodb.result:
updated result file
mysql-test/suite/rpl/r/rpl_idempotency.result:
updated result file
mysql-test/suite/rpl/r/rpl_mix_found_rows.result:
Split rpl_found_rows.test into rpl_mix_found_rows.test (a new file) and
rpl_stm_found_rows.test (renamed rpl_found_rows.test). This file equals
the second half of the old rpl_found_rows.result, with the following
modifications:
- minor formatting changes
- additional initialization
mysql-test/suite/rpl/r/rpl_mix_insert_delayed.result:
Moved out code operating in mixed mode from rpl_stm_insert_delayed
(into rpl_mix_insert_delayed) and got rid of explicit setting of
binlog format.
mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result:
updated result file
mysql-test/suite/rpl/r/rpl_row_idempotency.result:
Moved the second half of rpl_idempotency.test, which only
executed in row mode, to rpl_row_idempotency.test. This is
the new result file.
mysql-test/suite/rpl/r/rpl_row_insert_delayed.result:
Got rid of unnecessary explicit setting of binlog format.
mysql-test/suite/rpl/r/rpl_stm_found_rows.result:
Split rpl_found_rows.test into rpl_mix_found_rows.test (a new file) and
rpl_stm_found_rows.test (renamed rpl_found_rows.test). Changes in
this file:
- minor formatting changes
- warning is now issued for unsafe statements inside procedures
(since BUG#45824 is fixed)
- second half of file is moved to rpl_mix_found_rows.result
mysql-test/suite/rpl/r/rpl_stm_insert_delayed.result:
Moved out code operating in mixed mode from rpl_stm_insert_delayed
(into rpl_mix_insert_delayed) and got rid of explicit setting of
binlog format.
mysql-test/suite/rpl/r/rpl_stm_loadfile.result:
error message changed
mysql-test/suite/rpl/r/rpl_temporary_errors.result:
updated result file
mysql-test/suite/rpl/r/rpl_udf.result:
Remove explicit set of binlog format (and triplicate test execution)
and rely on test system executing the test in all binlog formats.
mysql-test/suite/rpl/t/rpl_bug31076.test:
Test is only valid in mixed or row mode since it generates row events.
mysql-test/suite/rpl/t/rpl_events.test:
Removed explicit set of binlog_format and removed duplicate testing.
Instead, we rely on the test system to try all binlog formats.
mysql-test/suite/rpl/t/rpl_extraColmaster_innodb.test:
Removed triplicate testing and instead relying on test system.
Test is only relevant for row format since statement-based replication
cannot handle extra columns on master.
mysql-test/suite/rpl/t/rpl_extraColmaster_myisam.test:
Removed triplicate testing and instead relying on test system.
Test is only relevant for row format since statement-based replication
cannot handle extra columns on master.
mysql-test/suite/rpl/t/rpl_idempotency-slave.opt:
Removed .opt file to avoid server restarts.
mysql-test/suite/rpl/t/rpl_idempotency.test:
- Moved out row-only tests to a new test file, rpl_row_idempotency.test.
rpl_idempotency now only contains tests that execute in all
binlog_formats.
- While I was here, also removed .opt file to avoid server restarts.
The slave_exec_mode is now set inside the test instead.
mysql-test/suite/rpl/t/rpl_mix_found_rows.test:
Split rpl_found_rows.test into rpl_mix_found_rows.test (a new file) and
rpl_stm_found_rows.test (renamed rpl_found_rows.test). This file
contains the second half of the original rpl_found_rows.test with the
follwing changes:
- initialization
- removed SET_BINLOG_FORMAT and added have_binlog_format_mixed.inc
- minor formatting changes
mysql-test/suite/rpl/t/rpl_mix_insert_delayed.test:
Moved out code operating in mixed mode from rpl_stm_insert_delayed
(into rpl_mix_insert_delayed) and got rid of explicit setting of
binlog format.
mysql-test/suite/rpl/t/rpl_rbr_to_sbr.test:
Test cannot execute in statement mode, since we no longer
switch to row format when binlog_format=statement.
Enforced mixed mode throughout the test.
mysql-test/suite/rpl/t/rpl_row_idempotency.test:
Moved the second half of rpl_idempotency.test, which only
executed in row mode, to this new file. We now rely on the
test system to set binlog format.
mysql-test/suite/rpl/t/rpl_row_insert_delayed.test:
- Got rid of unnecessary explicit setting of binlog format.
- extra/rpl_tests/rpl_insert_delayed.test does not need the
$binlog_format_statement variable any more, so that was
removed.
mysql-test/suite/rpl/t/rpl_slave_skip.test:
The test switches binlog_format internally and master generates both
row and statement events. Hence, the slave must be able to log in both
statement and row format. Hence test was changed to only execute in
mixed mode.
mysql-test/suite/rpl/t/rpl_stm_found_rows.test:
Split rpl_found_rows.test into rpl_mix_found_rows.test (a new file) and
rpl_stm_found_rows.test (renamed rpl_found_rows.test). Changes in
this file:
- minor formatting changes
- added have_binlog_format_statement and removed SET BINLOG_FORMAT.
- second half of file is moved to rpl_mix_found_rows.test
- added cleanup code
mysql-test/suite/rpl/t/rpl_stm_insert_delayed.test:
Moved out code operating in mixed mode from rpl_stm_insert_delayed
(into rpl_mix_insert_delayed) and got rid of explicit setting of
binlog format.
mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test:
The test switches binlog_format internally and master generates both
row and statement events. Hence, the slave must be able to log in both
statement and row format. Hence test was changed to only execute in
mixed mode on slave.
mysql-test/suite/rpl/t/rpl_temporary_errors.test:
Removed explicit set of binlog format. Instead, the test now only
executes in row mode.
mysql-test/suite/rpl/t/rpl_udf.test:
Remove explicit set of binlog format (and triplicate test execution)
and rely on test system executing the test in all binlog formats.
mysql-test/suite/rpl_ndb/combinations:
Added combinations file for rpl_ndb.
mysql-test/suite/rpl_ndb/r/rpl_ndb_binlog_format_errors.result:
new result file
mysql-test/suite/rpl_ndb/r/rpl_ndb_circular_simplex.result:
updated result file
mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_binlog_format_errors-master.opt:
new option file
mysql-test/suite/rpl_ndb/t/rpl_ndb_binlog_format_errors-slave.opt:
new option file
mysql-test/suite/rpl_ndb/t/rpl_ndb_binlog_format_errors.test:
New test case to verify all errors and warnings generated by
decide_logging_format.
mysql-test/suite/rpl_ndb/t/rpl_ndb_blob.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_blob2.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_circular.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_circular_simplex.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
While I was here, also made the test clean up after itself.
mysql-test/suite/rpl_ndb/t/rpl_ndb_commit_afterflush.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_ctype_ucs2_def.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_delete_nowhere.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_do_db.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_do_table.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_func003.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_innodb_trans.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_insert_ignore.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_mixed_engines_transactions.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_multi_update3.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_rep_ignore.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_row_001.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_sp003.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_sp006.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/suite/rpl_ndb/t/rpl_ndb_trig004.test:
The test needs slave to be able to switch to row mode, so the
test was changed to only execute in mixed and row mode.
mysql-test/t/partition_innodb_stmt.test:
Changed error code for innodb updates with READ COMMITTED or
READ UNCOMMITTED transaction isolation level and
binlog_format=statement.
sql/event_db_repository.cc:
Use member function to read current_stmt_binlog_row_based.
sql/events.cc:
Use member function to read current_stmt_binlog_row_based.
sql/ha_ndbcluster_binlog.cc:
reset_current_stmt_binlog_row_based() is not a no-op for the ndb_binlog
thread any more. Instead, the ndb_binlog thread now forces row mode both
initially and just after calling mysql_parse. (mysql_parse() is the only
place where reset_current_stmt_binlog_row_based() may be called from
the ndb_binlog thread, so these are the only two places that need to
change.)
sql/ha_partition.cc:
Use member function to read current_stmt_binlog_row_based.
sql/handler.cc:
Use member function to read current_stmt_binlog_row_based.
sql/item_create.cc:
Added DBUG_ENTER to some functions, to be able to trace when
set_stmt_unsafe is called.
sql/log.cc:
Use member function to read current_stmt_binlog_row_based.
sql/log_event.cc:
- Moved logic for changing to row format out of do_apply_event (and into
decide_logging_format).
- Added @todo comment for post-push cleanup.
sql/log_event_old.cc:
Move logic for changing to row format out of do_apply_event (and into
decide_logging_format).
sql/mysql_priv.h:
Make decide_logging_format() a member of the THD class, for two reasons:
- It is natural from an object-oriented perspective.
- decide_logging_format() needs to access private members of THD
(specifically, the new binlog_warning_flags field).
sql/rpl_injector.cc:
Removed call to set_current_stmt_binlog_row_based().
From now on, only decide_logging_fromat is allowed to modify
current_stmt_binlog_row_based. This call is from the ndb_binlog
thread, mostly executing code in ha_ndbcluster_binlog.cc.
This call can be safely removed, because:
- current_stmt_binlog_row_based is initialized for the ndb_binlog
thread's THD object when the THD object is created. So we're
not going to read uninitialized memory.
- The behavior of ndb_binlog thread does not use the state of the
current_stmt_binlog_row_based. It is conceivable that the
ndb_binlog thread would rely on the current_stmt_binlog_format
in two situations:
(1) when it calls mysql_parse;
(2) when it calls THD::binlog_query.
In case (1), it always clears THD::options&OPTION_BIN_LOG (because
run_query() in ha_ndbcluster_binlog.cc is only called with
disable_binlogging = TRUE).
In case (2), it always uses qtype=STMT_QUERY_TYPE.
sql/set_var.cc:
Added @todo comment for post-push cleanup.
sql/share/errmsg.txt:
Added new error messages and clarified ER_BINLOG_UNSAFE_STATEMENT.
sql/sp.cc:
Added DBUG_ENTER, to be able to trace when set_stmt_unsafe is called.
Got rid of MYSQL_QUERY_TYPE: it was equivalent to STMT_QUERY_TYPE.
sql/sp_head.cc:
Use member function to read current_stmt_binlog_row_based.
sql/sp_head.h:
Added DBUG_ENTER, to be able to trace when set_stmt_unsafe is called.
sql/sql_acl.cc:
Got rid of MYSQL_QUERY_TYPE: it was equivalent to STMT_QUERY_TYPE.
sql/sql_base.cc:
- Made decide_logging_format take care of all logic for deciding the
logging format, and for determining the related warnings and errors.
See comment above decide_logging_format for details.
- Made decide_logging_format a member function of THD, since it needs
to access private members of THD and since its purpose is to update
the state of a THD object.
- Added DBUG_ENTER, to be able to trace when set_stmt_unsafe is called.
sql/sql_class.cc:
- Moved logic for determining unsafe warnings away from THD::binlog_query
(and into decide_logging_format()). Now, it works like this:
1. decide_logging_format detects that the current statement shall
produce a warning, if it ever makes it to the binlog
2. decide_logging_format sets a flag of THD::binlog_warning_flags.
3. THD::binlog_query reads the flag. If the flag is set, it generates
a warning.
- Use member function to read current_stmt_binlog_row_based.
sql/sql_class.h:
- Added THD::binlog_warning_flags (see sql_class.cc for explanation).
- Made decide_logging_format() and reset_for_next_command() member
functions of THD (instead of standalone functions). This was needed
for two reasons: (1) the functions need to access the private member
THD::binlog_warning_flags; (2) the purpose of these functions is to
update the staet of a THD object, so from an object-oriented point
of view they should be member functions.
- Encapsulated current_stmt_binlog_row_based, so it is now private and
can only be accessed from a member function. Also changed the
data type to an enumeration instead of a bool.
- Removed MYSQL_QUERY_TYPE, because it was equivalent to
STMT_QUERY_TYPE anyways.
- When reset_current_stmt_binlog_row_based was called from the
ndb_binlog thread, it would behave as a no-op. This special
case has been removed, and the behavior of
reset_current_stmt_binlog_row_based does not depend on which thread
calls it any more. The special case did not serve any purpose,
since the ndb binlog thread did not take the
current_stmt_binlog_row_based flag into account anyways.
sql/sql_delete.cc:
- Moved logic for setting row format for DELETE..LIMIT away from
mysql_prepare_delete.
(Instead, we mark the statement as unsafe at parse time (sql_yacc.yy)
and rely on decide_logging_format() (sql_class.cc) to set row format.)
This is part of the fix for BUG#45831.
- Use member function to read current_stmt_binlog_row_based.
sql/sql_insert.cc:
- Removed unnecessary calls to thd->lex->set_stmt_unsafe() and
thd->set_current_stmt_binlog_row_based_if_mixed() from
handle_delayed_insert(). The calls are unnecessary because they
have already been made; they were made in the constructor of
the `di' object.
- Since decide_logging_format() is now a member function of THD, code
that calls decide_logging_format() had to be updated.
- Added DBUG_ENTER call, to be able to trace when set_stmt_unsafe is
called.
- Moved call to set_stmt_unsafe() for INSERT..SELECT..LIMIT away from
mysql_insert_select_prepare() (and into decide_logging_format).
This is part of the fix for BUG#45831.
- Use member function to read current_stmt_binlog_row_based.
sql/sql_lex.h:
- Added the flag BINLOG_STMT_FLAG_ROW_INJECTION to enum_binlog_stmt_flag.
This was necessary so that a statement can identify itself as a row
injection.
- Added appropriate setter and getter functions for the new flag.
- Added or clarified some comments.
- Added DBUG_ENTER()
sql/sql_load.cc:
Use member function to read current_stmt_binlog_row_based.
sql/sql_parse.cc:
- Made mysql_reset_thd_for_next_command() clear thd->binlog_warning_flags.
- Since thd->binlog_warning_flags is private, it must be set in a
member function of THD. Hence, moved the body of
mysql_reset_thd_for_next_command() to the new member function
THD::reset_thd_for_next_command(), and made
mysql_reset_thd_for_next_command() call
THD::reset_thd_for_next_command().
- Removed confusing comment.
- Use member function to read current_stmt_binlog_row_based.
sql/sql_repl.cc:
Use member function to read current_stmt_binlog_row_based.
sql/sql_table.cc:
Use member function to read current_stmt_binlog_row_based.
sql/sql_udf.cc:
Use member function to read current_stmt_binlog_row_based.
sql/sql_update.cc:
Moved logic for setting row format for UPDATE..LIMIT away from
mysql_prepare_update.
(Instead, we mark the statement as unsafe at parse time (sql_yacc.yy)
and rely on decide_logging_format() (sql_class.cc) to set row format.)
This is part of the fix for BUG#45831.
sql/sql_yacc.yy:
Made INSERT DELAYED, INSERT..SELECT..LIMIT, UPDATE..LIMIT, and
DELETE..LIMIT mark themselves as unsafe at parse time (instead
of at execution time).
This is part of the fixes BUG#45831 and BUG#45825.
storage/example/ha_example.cc:
Made exampledb accept inserts. This was needed by the new test case
rpl_ndb_binlog_format_errors, because it needs an engine that
is statement-only (and accepts inserts).
storage/example/ha_example.h:
Made exampledb a statement-only engine instead of a row-only engine.
No existing test relied exampledb's row-only capabilities. The new
test case rpl_ndb_binlog_format_errors needs an engine that is
statement-only.
storage/innobase/handler/ha_innodb.cc:
- Changed error error code and message given by innodb when
binlog_format=STATEMENT and transaction isolation level is
READ COMMITTED or READ UNCOMMITTED.
- While I was here, also simplified the condition for
checking when to give the error.
2009-07-14 21:31:19 +02:00
|
|
|
if (lf_info->thd->is_current_stmt_binlog_format_row())
|
2015-05-16 08:48:52 +02:00
|
|
|
goto ret;
|
2001-08-03 23:57:53 +02:00
|
|
|
if (lf_info->last_pos_in_file != HA_POS_ERROR &&
|
2007-12-21 21:34:43 +01:00
|
|
|
lf_info->last_pos_in_file >= my_b_get_pos_in_file(file))
|
2015-05-16 08:48:52 +02:00
|
|
|
goto ret;
|
2007-12-21 21:34:43 +01:00
|
|
|
|
2009-02-10 23:47:54 +01:00
|
|
|
for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
|
2013-03-25 23:03:13 +01:00
|
|
|
buffer += MY_MIN(block_len, max_event_size),
|
|
|
|
block_len -= MY_MIN(block_len, max_event_size))
|
2001-08-03 23:57:53 +02:00
|
|
|
{
|
2007-12-21 21:34:43 +01:00
|
|
|
lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
|
|
|
|
if (lf_info->wrote_create_file)
|
|
|
|
{
|
|
|
|
Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
|
2013-03-25 23:03:13 +01:00
|
|
|
MY_MIN(block_len, max_event_size),
|
2007-12-21 21:34:43 +01:00
|
|
|
lf_info->log_delayed);
|
2010-01-24 08:03:23 +01:00
|
|
|
if (mysql_bin_log.write(&a))
|
|
|
|
DBUG_RETURN(1);
|
2007-12-21 21:34:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
|
|
|
|
buffer,
|
2013-03-25 23:03:13 +01:00
|
|
|
MY_MIN(block_len, max_event_size),
|
2007-12-21 21:34:43 +01:00
|
|
|
lf_info->log_delayed);
|
2010-01-24 08:03:23 +01:00
|
|
|
if (mysql_bin_log.write(&b))
|
|
|
|
DBUG_RETURN(1);
|
2007-12-21 21:34:43 +01:00
|
|
|
lf_info->wrote_create_file= 1;
|
|
|
|
}
|
2001-08-03 23:57:53 +02:00
|
|
|
}
|
2015-05-16 08:48:52 +02:00
|
|
|
ret:
|
|
|
|
int res= Buffer ? lf_info->real_read_function(file, Buffer, Count) : 0;
|
|
|
|
DBUG_RETURN(res);
|
2001-08-03 23:57:53 +02:00
|
|
|
}
|
2002-12-16 14:33:29 +01:00
|
|
|
|
2012-11-05 15:01:49 +01:00
|
|
|
|
|
|
|
/**
|
2013-05-22 17:36:48 +02:00
|
|
|
Initialise the slave replication state from the mysql.gtid_slave_pos table.
|
2012-11-05 15:01:49 +01:00
|
|
|
|
|
|
|
This is called each time an SQL thread starts, but the data is only actually
|
|
|
|
loaded on the first call.
|
|
|
|
|
|
|
|
The slave state is the last GTID applied on the slave within each
|
|
|
|
replication domain.
|
|
|
|
|
|
|
|
To avoid row lock contention, there are multiple rows for each domain_id.
|
|
|
|
The one containing the current slave state is the one with the maximal
|
|
|
|
sub_id value, within each domain_id.
|
|
|
|
|
2013-05-22 17:36:48 +02:00
|
|
|
CREATE TABLE mysql.gtid_slave_pos (
|
2012-11-05 15:01:49 +01:00
|
|
|
domain_id INT UNSIGNED NOT NULL,
|
|
|
|
sub_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
server_id INT UNSIGNED NOT NULL,
|
|
|
|
seq_no BIGINT UNSIGNED NOT NULL,
|
|
|
|
PRIMARY KEY (domain_id, sub_id))
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
rpl_init_gtid_slave_state()
|
|
|
|
{
|
2015-11-29 16:51:23 +01:00
|
|
|
rpl_global_gtid_slave_state= new rpl_slave_state;
|
2012-11-05 15:01:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
rpl_deinit_gtid_slave_state()
|
|
|
|
{
|
2015-11-29 16:51:23 +01:00
|
|
|
delete rpl_global_gtid_slave_state;
|
2012-11-05 15:01:49 +01:00
|
|
|
}
|
|
|
|
|
2013-04-04 17:38:10 +02:00
|
|
|
|
2014-02-07 19:15:28 +01:00
|
|
|
void
|
|
|
|
rpl_init_gtid_waiting()
|
|
|
|
{
|
|
|
|
rpl_global_gtid_waiting.init();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
rpl_deinit_gtid_waiting()
|
|
|
|
{
|
|
|
|
rpl_global_gtid_waiting.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-04 17:38:10 +02:00
|
|
|
/*
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
Format the current GTID state as a string, for returning the value of
|
|
|
|
@@global.gtid_slave_pos.
|
2013-04-04 17:38:10 +02:00
|
|
|
|
|
|
|
If the flag use_binlog is true, then the contents of the binary log (if
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
enabled) is merged into the current GTID state (@@global.gtid_current_pos).
|
2013-04-04 17:38:10 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
rpl_append_gtid_state(String *dest, bool use_binlog)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
rpl_gtid *gtid_list= NULL;
|
|
|
|
uint32 num_gtids= 0;
|
|
|
|
|
2013-05-22 17:36:48 +02:00
|
|
|
if (use_binlog && opt_bin_log &&
|
2013-04-04 17:38:10 +02:00
|
|
|
(err= mysql_bin_log.get_most_recent_gtid_list(>id_list, &num_gtids)))
|
|
|
|
return err;
|
|
|
|
|
2015-11-29 16:51:23 +01:00
|
|
|
err= rpl_global_gtid_slave_state->tostring(dest, gtid_list, num_gtids);
|
2013-04-04 17:38:10 +02:00
|
|
|
my_free(gtid_list);
|
|
|
|
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2013-08-16 15:10:25 +02:00
|
|
|
Load the current GTID position into a slave_connection_state, for use when
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
connecting to a master server with GTID.
|
|
|
|
|
|
|
|
If the flag use_binlog is true, then the contents of the binary log (if
|
|
|
|
enabled) is merged into the current GTID state (master_use_gtid=current_pos).
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
rpl_load_gtid_state(slave_connection_state *state, bool use_binlog)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
rpl_gtid *gtid_list= NULL;
|
|
|
|
uint32 num_gtids= 0;
|
|
|
|
|
|
|
|
if (use_binlog && opt_bin_log &&
|
|
|
|
(err= mysql_bin_log.get_most_recent_gtid_list(>id_list, &num_gtids)))
|
|
|
|
return err;
|
|
|
|
|
2015-11-29 16:51:23 +01:00
|
|
|
err= state->load(rpl_global_gtid_slave_state, gtid_list, num_gtids);
|
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00
|
|
|
my_free(gtid_list);
|
|
|
|
|
|
|
|
return err;
|
2013-04-04 17:38:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-05 16:20:58 +02:00
|
|
|
bool
|
2013-05-22 17:36:48 +02:00
|
|
|
rpl_gtid_pos_check(THD *thd, char *str, size_t len)
|
2013-04-05 16:20:58 +02:00
|
|
|
{
|
|
|
|
slave_connection_state tmp_slave_state;
|
2013-05-22 17:36:48 +02:00
|
|
|
bool gave_conflict_warning= false, gave_missing_warning= false;
|
2013-04-05 16:20:58 +02:00
|
|
|
|
|
|
|
/* Check that we can parse the supplied string. */
|
|
|
|
if (tmp_slave_state.load(str, len))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Check our own binlog for any of our own transactions that are newer
|
|
|
|
than the GTID state the user is requesting. Any such transactions would
|
|
|
|
result in an out-of-order binlog, which could break anyone replicating
|
|
|
|
with us as master.
|
|
|
|
|
|
|
|
So give an error if this is found, requesting the user to do a
|
|
|
|
RESET MASTER (to clean up the binlog) if they really want this.
|
|
|
|
*/
|
|
|
|
if (mysql_bin_log.is_open())
|
|
|
|
{
|
|
|
|
rpl_gtid *binlog_gtid_list= NULL;
|
|
|
|
uint32 num_binlog_gtids= 0;
|
|
|
|
uint32 i;
|
|
|
|
|
|
|
|
if (mysql_bin_log.get_most_recent_gtid_list(&binlog_gtid_list,
|
|
|
|
&num_binlog_gtids))
|
|
|
|
{
|
|
|
|
my_error(ER_OUT_OF_RESOURCES, MYF(MY_WME));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
for (i= 0; i < num_binlog_gtids; ++i)
|
|
|
|
{
|
|
|
|
rpl_gtid *binlog_gtid= &binlog_gtid_list[i];
|
|
|
|
rpl_gtid *slave_gtid;
|
|
|
|
if (binlog_gtid->server_id != global_system_variables.server_id)
|
|
|
|
continue;
|
|
|
|
if (!(slave_gtid= tmp_slave_state.find(binlog_gtid->domain_id)))
|
|
|
|
{
|
2013-05-28 13:28:31 +02:00
|
|
|
if (opt_gtid_strict_mode)
|
2013-05-22 17:36:48 +02:00
|
|
|
{
|
|
|
|
my_error(ER_MASTER_GTID_POS_MISSING_DOMAIN, MYF(0),
|
|
|
|
binlog_gtid->domain_id, binlog_gtid->domain_id,
|
|
|
|
binlog_gtid->server_id, binlog_gtid->seq_no);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!gave_missing_warning)
|
|
|
|
{
|
2013-07-21 16:39:19 +02:00
|
|
|
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
2013-05-22 17:36:48 +02:00
|
|
|
ER_MASTER_GTID_POS_MISSING_DOMAIN,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_THD(thd, ER_MASTER_GTID_POS_MISSING_DOMAIN),
|
2013-05-22 17:36:48 +02:00
|
|
|
binlog_gtid->domain_id, binlog_gtid->domain_id,
|
|
|
|
binlog_gtid->server_id, binlog_gtid->seq_no);
|
|
|
|
gave_missing_warning= true;
|
|
|
|
}
|
2013-04-05 16:20:58 +02:00
|
|
|
}
|
2013-05-22 17:36:48 +02:00
|
|
|
else if (slave_gtid->seq_no < binlog_gtid->seq_no)
|
2013-04-05 16:20:58 +02:00
|
|
|
{
|
2013-05-28 13:28:31 +02:00
|
|
|
if (opt_gtid_strict_mode)
|
2013-05-22 17:36:48 +02:00
|
|
|
{
|
|
|
|
my_error(ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG, MYF(0),
|
|
|
|
slave_gtid->domain_id, slave_gtid->server_id,
|
|
|
|
slave_gtid->seq_no, binlog_gtid->domain_id,
|
|
|
|
binlog_gtid->server_id, binlog_gtid->seq_no);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!gave_conflict_warning)
|
|
|
|
{
|
2013-07-21 16:39:19 +02:00
|
|
|
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
2013-05-22 17:36:48 +02:00
|
|
|
ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_THD(thd, ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG),
|
2013-05-22 17:36:48 +02:00
|
|
|
slave_gtid->domain_id, slave_gtid->server_id,
|
|
|
|
slave_gtid->seq_no, binlog_gtid->domain_id,
|
|
|
|
binlog_gtid->server_id, binlog_gtid->seq_no);
|
|
|
|
gave_conflict_warning= true;
|
|
|
|
}
|
2013-04-05 16:20:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
my_free(binlog_gtid_list);
|
|
|
|
if (i != num_binlog_gtids)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
rpl_gtid_pos_update(THD *thd, char *str, size_t len)
|
|
|
|
{
|
2015-11-29 16:51:23 +01:00
|
|
|
if (rpl_global_gtid_slave_state->load(thd, str, len, true, true))
|
2013-04-05 16:20:58 +02:00
|
|
|
{
|
|
|
|
my_error(ER_FAILED_GTID_STATE_INIT, MYF(0));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-15 09:11:44 +01:00
|
|
|
#endif /* HAVE_REPLICATION */
|