Commit 760d1490 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-30128 remove support for 5.1- replication events

including patches from Andrei Elkin
parent 42f53c76
This diff is collapsed.
......@@ -971,17 +971,17 @@ explain extended select length('\n\t\r\b\0\_\%\\');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select octet_length('\n \r\0008\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`
Note 1003 select octet_length('\n\t\r\b\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`
explain extended select bit_length('\n\t\r\b\0\_\%\\');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select bit_length('\n \r\0008\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`
Note 1003 select bit_length('\n\t\r\b\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`
explain extended select bit_length('\n\t\r\b\0\_\%\\');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select bit_length('\n \r\0008\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`
Note 1003 select bit_length('\n\t\r\b\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`
explain extended select concat('monty',' was here ','again');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
......
......@@ -407,16 +407,26 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
SET TIMESTAMP=1108844556/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1140641973/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
CREATE TABLE t1(c INT)
/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1108844555/*!*/;
insert t1 values (1)
SET TIMESTAMP=1140641985/*!*/;
CREATE TABLE t2(s CHAR(200))
/*!*/;
SET TIMESTAMP=1140642018/*!*/;
CREATE TRIGGER trg1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES(CURRENT_USER())
/*!*/;
SET TIMESTAMP=1140642025/*!*/;
INSERT INTO t1 VALUES(1)
/*!*/;
DELIMITER ;
# End of log file
......@@ -427,16 +437,21 @@ ROLLBACK /* added by mysqlbinlog */;
/*!40019 SET @@session.max_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
SET TIMESTAMP=1108844556/*!*/;
ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1140642018/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
CREATE TRIGGER trg1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES(CURRENT_USER())
/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1108844555/*!*/;
insert t1 values (1)
SET TIMESTAMP=1140642025/*!*/;
INSERT INTO t1 VALUES(1)
/*!*/;
DELIMITER ;
# End of log file
......
......@@ -123,13 +123,13 @@ select "--- reading stdin --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
--exec $MYSQL_BINLOG --short-form - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
--exec $MYSQL_BINLOG --short-form - < $MYSQL_TEST_DIR/std_data/bug16266.000001
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
# postion is constant to correspond to an event in pre-recorded binlog
--let $binlog_start_pos=79
--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start_pos - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
--let $binlog_start_pos=274
--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start_pos - < $MYSQL_TEST_DIR/std_data/bug16266.000001
drop table t1,t2;
......
call mtr.add_suppression("BINLOG_BASE64_EVENT: According to the master's version");
call mtr.add_suppression("BINLOG_BASE64_EVENT: Column 1 of table 'test.char128_utf8' cannot be converted");
DROP TABLE IF EXISTS t1;
==== Test BUG#32407 ====
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1), (1);
select * from t1;
a
1
......@@ -49,35 +49,6 @@ a
SELECT @binlog_fragment_0, @binlog_fragment_1 as 'NULL','NULL';
@binlog_fragment_0 NULL NULL
NULL NULL NULL
==== Test --base64-output=never on a binlog with row events ====
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
<#>
ROLLBACK/*!*/;
<#>
use `test`/*!*/;
SET TIMESTAMP=1196959712/*!*/;
<#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
create table t1 (a int) engine= myisam
/*!*/;
<#>
<#>
<#>
<#>
<#>
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
==== Test non-matching FD event and Row event ====
BINLOG '
4CdYRw8BAAAAYgAAAGYAAAAAAAQANS4xLjE1LW5kYi02LjEuMjQtZGVidWctbG9nAAAAAAAAAAAA
......
==== Read binlog with v2 row events ====
SELECT * FROM t1 ORDER BY a;
a b
0 last_insert_id
1 one
3 last stm in trx: next event should be xid
4 four
62046 random
SELECT * FROM t2 ORDER BY a;
a b
3 first stm in trx
SELECT COUNT(*) FROM t3;
COUNT(*)
17920
DROP TABLE t1, t2, t3;
==== Read modern binlog (version 5.1.23) ====
SELECT * FROM t1 ORDER BY a;
a b
0 last_insert_id
1 one
3 last stm in trx: next event should be xid
4 four
674568 random
SELECT * FROM t2 ORDER BY a;
a b
3 first stm in trx
SELECT COUNT(*) FROM t3;
COUNT(*)
17920
DROP TABLE t1, t2, t3;
==== Read binlog from version 5.1.17 ====
SELECT * FROM t1 ORDER BY a;
a b
0 last_insert_id
1 one
3 last stm in trx: next event should be xid
4 four
764247 random
SELECT * FROM t2 ORDER BY a;
a b
3 first stm in trx
SELECT COUNT(*) FROM t3;
COUNT(*)
17920
DROP TABLE t1, t2, t3;
==== Read binlog from version 4.1 ====
SELECT * FROM t1 ORDER BY a;
a b
0 last_insert_id
4 four
190243 random
SELECT COUNT(*) FROM t3;
COUNT(*)
17920
DROP TABLE t1, t3;
==== Read binlog from telco tree (mysql-5.1-telco-6.1) ====
SELECT * FROM t1 ORDER BY a;
a b
0 last_insert_id
1 one
3 last stm in trx: next event should be xid
4 four
703356 random
SELECT * FROM t2 ORDER BY a;
a b
3 first stm in trx
SELECT COUNT(*) FROM t3;
COUNT(*)
17920
DROP TABLE t1, t2, t3;
......@@ -2,9 +2,6 @@
# work as expected, and that BINLOG statements with row events fail if
# they are not preceded by BINLOG statements with Format description
# events.
#
# See also BUG#32407.
# BINLOG statement does not work in embedded mode.
source include/not_embedded.inc;
......@@ -12,23 +9,10 @@ source include/not_embedded.inc;
call mtr.add_suppression("BINLOG_BASE64_EVENT: According to the master's version");
call mtr.add_suppression("BINLOG_BASE64_EVENT: Column 1 of table 'test.char128_utf8' cannot be converted");
disable_warnings;
DROP TABLE IF EXISTS t1;
enable_warnings;
# Test to show BUG#32407. This reads a binlog created with the
# mysql-5.1-telco-6.1 tree, specifically at the tag
# mysql-5.1.15-ndb-6.1.23, and applies it to the database. The test
# should fail before BUG#32407 was fixed and succeed afterwards.
--echo ==== Test BUG#32407 ====
# The binlog contains row events equivalent to:
# CREATE TABLE t1 (a int) engine = myisam
# INSERT INTO t1 VALUES (1), (1)
exec $MYSQL_BINLOG suite/binlog/std_data/bug32407.001 | $MYSQL;
# The above line should succeed and t1 should contain two ones
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1), (1);
select * from t1;
# Test that a BINLOG statement encoding a row event fails unless a
# Format_description_event as been supplied with an earlier BINLOG
# statement.
......@@ -92,14 +76,6 @@ select * from t1;
# show "one-shot" feature of binlog_fragment variables
SELECT @binlog_fragment_0, @binlog_fragment_1 as 'NULL','NULL';
# New mysqlbinlog supports --base64-output=never
--echo ==== Test --base64-output=never on a binlog with row events ====
# mysqlbinlog should fail
--replace_regex /#[0-9][0-9][0-9][0-9][0-9][0-9] \N*/<#>/ /SET \@\@session.pseudo_thread_id.*/<#>/
exec $MYSQL_BINLOG --base64-output=never --print-row-count=0 --print-row-event-positions=0 suite/binlog/std_data/bug32407.001;
# Test that the following fails cleanly: "First, read a
# Format_description event which has N event types. Then, read an
# event of type M>N"
......
# Test that old binlog formats can be read.
# Some previous versions of MySQL use their own binlog format,
# especially in row-based replication. This test uses saved binlogs
# from those old versions to test that we can replicate from old
# versions to the present version.
# Replicating from old versions to new versions is necessary in an
# online upgrade scenario, where the .
# The previous versions we currently test are:
# - version 5.1.17 and earlier trees
# - mysql-5.1-wl2325-xxx trees (AKA alcatel trees)
# - mysql-5.1-telco-6.1 trees
# For completeness, we also test mysql-5.1-new_rpl, which is supposed
# to be the "correct" version.
# All binlogs were generated with the same commands (listed at the end
# of this test for reference). The binlogs contain the following
# events: Table_map, Write_rows, Update_rows, Delete_rows Query, Xid,
# User_var, Int_var, Rand, Begin_load, Append_file, Execute_load.
# Related bugs: BUG#27779, BUG#31581, BUG#31582, BUG#31583, BUG#32407
source include/not_embedded.inc;
--echo ==== Read binlog with v2 row events ====
# Read binlog.
--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_trunk_row_v2.001 | $MYSQL --local-infile=1
# Show result.
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
SELECT COUNT(*) FROM t3;
# Reset.
DROP TABLE t1, t2, t3;
--echo ==== Read modern binlog (version 5.1.23) ====
# Read binlog.
--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1_23.001 | $MYSQL --local-infile=1
# Show result.
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
SELECT COUNT(*) FROM t3;
# Reset.
DROP TABLE t1, t2, t3;
--echo ==== Read binlog from version 5.1.17 ====
# Read binlog.
--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1_17.001 | $MYSQL --local-infile=1
# Show result.
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
SELECT COUNT(*) FROM t3;
# Reset.
DROP TABLE t1, t2, t3;
--echo ==== Read binlog from version 4.1 ====
# In this version, neither row-based binlogging nor Xid events
# existed, so the binlog was generated without the "row-based tests"
# part and the "get xid event" part, and it does not create table t2.
# Read binlog.
--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/binlog_old_version_4_1.000001 | $MYSQL --local-infile=1
# Show result.
SELECT * FROM t1 ORDER BY a;
SELECT COUNT(*) FROM t3;
# Reset.
DROP TABLE t1, t3;
--echo ==== Read binlog from telco tree (mysql-5.1-telco-6.1) ====
# Read binlog.
--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1-telco.001 | $MYSQL --local-infile=1
# Show resulting tablea.
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
SELECT COUNT(*) FROM t3;
# Reset.
DROP TABLE t1, t2, t3;
#### The following commands were used to generate the binlogs ####
#
#source include/master-slave.inc;
#
## ==== initialize ====
#USE test;
#CREATE TABLE t1 (a int, b char(50)) ENGINE = MyISAM;
#CREATE TABLE t2 (a int, b char(50)) ENGINE = InnoDB;
#CREATE TABLE t3 (a char(20));
#
#
## ==== row based tests ====
#SET BINLOG_FORMAT='row';
#
## ---- get write, update, and delete rows events ----
#INSERT INTO t1 VALUES (0, 'one'), (1, 'two');
#UPDATE t1 SET a=a+1;
#DELETE FROM t1 WHERE a=2;
#
#
## ==== statement based tests ====
#SET BINLOG_FORMAT = 'statement';
#
## ---- get xid events ----
#BEGIN;
#INSERT INTO t2 VALUES (3, 'first stm in trx');
#INSERT INTO t1 VALUES (3, 'last stm in trx: next event should be xid');
#COMMIT;
#
## ---- get user var events ----
#SET @x = 4;
#INSERT INTO t1 VALUES (@x, 'four');
#
## ---- get rand event ----
#INSERT INTO t1 VALUES (RAND() * 1000000, 'random');
#
## ---- get intvar event ----
#INSERT INTO t1 VALUES (LAST_INSERT_ID(), 'last_insert_id');
#
## ---- get begin, append and execute load events ----
## double the file until we have more than 2^17 bytes, so that the
## event has to be split and we can use Append_file_log_event.
#
#SET SQL_LOG_BIN=0;
#CREATE TABLE temp (a char(20));
#LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE temp;
#INSERT INTO temp SELECT * FROM temp;
#INSERT INTO temp SELECT * FROM temp;
#INSERT INTO temp SELECT * FROM temp;
#INSERT INTO temp SELECT * FROM temp;
#INSERT INTO temp SELECT * FROM temp;
#INSERT INTO temp SELECT * FROM temp;
#INSERT INTO temp SELECT * FROM temp;
#INSERT INTO temp SELECT * FROM temp;
#SELECT a FROM temp INTO OUTFILE 'big_file.dat';
#DROP TABLE temp;
#SET SQL_LOG_BIN=1;
#
#LOAD DATA INFILE 'big_file.dat' INTO TABLE t3;
#
#SELECT * FROM t1 ORDER BY a;
#SELECT * FROM t2 ORDER BY a;
#SELECT COUNT(*) FROM t3;
#--source include/rpl_end.inc
include/master-slave.inc
[connection master]
==== Initialize ====
connection slave;
include/stop_slave.inc
RESET SLAVE;
include/setup_fake_relay_log.inc
Setting up fake replication from MYSQL_TEST_DIR/suite/binlog/std_data/binlog_old_version_4_1.000001
==== Test ====
start slave sql_thread;
include/wait_for_slave_param.inc [Exec_Master_Log_Pos]
==== a prove that the fake has been processed successfully ====
SELECT COUNT(*) - 17920 as zero FROM t3;
zero
0
==== Clean up ====
include/stop_slave_sql.inc
include/cleanup_fake_relay_log.inc
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
drop table t1, t3;
include/rpl_end.inc
--replicate-same-server-id --relay-log=slave-relay-bin
# ==== Purpose ====
#
# Verify cross-version replication from an old master to the up-to-date slave
#
# ==== Implementation ====
#
# Feed to the slave server a binlog recorded on an old version master
# via setting up slave-to-slave replication. The latter is done by means of
# the opt file and include/setup_fake_relay_log.inc.
# The master's binlog is treated as a relay log that the SQL thread executes.
#
--source include/master-slave.inc
#
# Bug#31240 load data infile replication between (4.0 or 4.1) and 5.1 fails
#
--echo ==== Initialize ====
--connection slave
--disable_query_log
# The binlog contains the function RAND which is unsafe.
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
--enable_query_log
--source include/stop_slave.inc
RESET SLAVE;
# the relay log contains create t1, t3 tables and load data infile
--let $fake_relay_log = $MYSQL_TEST_DIR/suite/binlog/std_data/binlog_old_version_4_1.000001
--source include/setup_fake_relay_log.inc
--echo ==== Test ====
start slave sql_thread;
--let $slave_param = Exec_Master_Log_Pos
# end_log_pos of the last event of the relay log
--let $slave_param_value = 149436
--source include/wait_for_slave_param.inc
--echo ==== a prove that the fake has been processed successfully ====
SELECT COUNT(*) - 17920 as zero FROM t3;
--echo ==== Clean up ====
--source include/stop_slave_sql.inc
--source include/cleanup_fake_relay_log.inc
drop table t1, t3;
--let $rpl_only_running_threads= 1
--source include/rpl_end.inc
......@@ -106,7 +106,6 @@ SET (SQL_SOURCE
key.cc log.cc lock.cc
log_event.cc log_event_server.cc
rpl_record.cc rpl_reporting.cc
log_event_old.cc rpl_record_old.cc
mf_iocache.cc my_decimal.cc
mysqld.cc net_serv.cc keycaches.cc
../sql-common/client_plugin.c
......
This diff is collapsed.
This diff is collapsed.
......@@ -2104,9 +2104,9 @@ bool Query_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
}
bool Start_log_event_v3::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
bool Format_description_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
{
DBUG_ENTER("Start_log_event_v3::print");
DBUG_ENTER("Format_description_log_event::print");
Write_on_release_cache cache(&print_event_info->head_cache, file,
Write_on_release_cache::FLUSH_F);
......@@ -2188,122 +2188,6 @@ bool Start_encryption_log_event::print(FILE* file,
}
bool Load_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
{
return print(file, print_event_info, 0);
}
bool Load_log_event::print(FILE* file_arg, PRINT_EVENT_INFO* print_event_info,
bool commented)
{
Write_on_release_cache cache(&print_event_info->head_cache, file_arg);
bool different_db= 1;
DBUG_ENTER("Load_log_event::print");
if (!print_event_info->short_form)
{
if (print_header(&cache, print_event_info, FALSE) ||
my_b_printf(&cache, "\tQuery\tthread_id=%ld\texec_time=%ld\n",
thread_id, exec_time))
goto err;
}
if (db)
{
/*
If the database is different from the one of the previous statement, we
need to print the "use" command, and we update the last_db.
But if commented, the "use" is going to be commented so we should not
update the last_db.
*/
if ((different_db= memcmp(print_event_info->db, db, db_len + 1)) &&
!commented)
memcpy(print_event_info->db, db, db_len + 1);
}
if (db && db[0] && different_db)
if (my_b_printf(&cache, "%suse %`s%s\n",
commented ? "# " : "",
db, print_event_info->delimiter))
goto err;
if (flags & LOG_EVENT_THREAD_SPECIFIC_F)
if (my_b_printf(&cache,"%sSET @@session.pseudo_thread_id=%lu%s\n",
commented ? "# " : "", (ulong)thread_id,
print_event_info->delimiter))
goto err;
if (my_b_printf(&cache, "%sLOAD DATA ",
commented ? "# " : ""))
goto err;
if (check_fname_outside_temp_buf())
if (my_b_write_string(&cache, "LOCAL "))
goto err;
if (my_b_printf(&cache, "INFILE '%-*s' ", fname_len, fname))
goto err;
if (sql_ex.opt_flags & REPLACE_FLAG)
{
if (my_b_write_string(&cache, "REPLACE "))
goto err;
}
else if (sql_ex.opt_flags & IGNORE_FLAG)
if (my_b_write_string(&cache, "IGNORE "))
goto err;
if (my_b_printf(&cache, "INTO TABLE `%s`", table_name) ||
my_b_write_string(&cache, " FIELDS TERMINATED BY ") ||
pretty_print_str(&cache, sql_ex.field_term, sql_ex.field_term_len))
goto err;
if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG)
if (my_b_write_string(&cache, " OPTIONALLY "))
goto err;
if (my_b_write_string(&cache, " ENCLOSED BY ") ||
pretty_print_str(&cache, sql_ex.enclosed, sql_ex.enclosed_len) ||
my_b_write_string(&cache, " ESCAPED BY ") ||
pretty_print_str(&cache, sql_ex.escaped, sql_ex.escaped_len) ||
my_b_write_string(&cache, " LINES TERMINATED BY ") ||
pretty_print_str(&cache, sql_ex.line_term, sql_ex.line_term_len))
goto err;
if (sql_ex.line_start)
{
if (my_b_write_string(&cache," STARTING BY ") ||
pretty_print_str(&cache, sql_ex.line_start, sql_ex.line_start_len))
goto err;
}
if ((long) skip_lines > 0)
if (my_b_printf(&cache, " IGNORE %ld LINES", (long) skip_lines))
goto err;
if (num_fields)
{
uint i;
const char* field = fields;
if (my_b_write_string(&cache, " ("))
goto err;
for (i = 0; i < num_fields; i++)
{
if (i)
if (my_b_write_byte(&cache, ','))
goto err;
if (my_b_printf(&cache, "%`s", field))
goto err;
field += field_lens[i] + 1;
}
if (my_b_write_byte(&cache, ')'))
goto err;
}
if (my_b_printf(&cache, "%s\n", print_event_info->delimiter))
goto err;
DBUG_RETURN(cache.flush_data());
err:
DBUG_RETURN(1);
}
bool Rotate_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
{
if (print_event_info->short_form)
......@@ -2626,61 +2510,6 @@ bool Stop_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
#endif
bool Create_file_log_event::print(FILE* file,
PRINT_EVENT_INFO* print_event_info,
bool enable_local)
{
if (print_event_info->short_form)
{
if (enable_local && check_fname_outside_temp_buf())
return Load_log_event::print(file, print_event_info);
return 0;
}
Write_on_release_cache cache(&print_event_info->head_cache, file);
if (enable_local)
{
if (Load_log_event::print(file, print_event_info,
!check_fname_outside_temp_buf()))
goto err;
/**
reduce the size of io cache so that the write function is called
for every call to my_b_printf().
*/
DBUG_EXECUTE_IF ("simulate_create_event_write_error",
{(&cache)->write_pos= (&cache)->write_end;
DBUG_SET("+d,simulate_file_write_error");});
/*
That one is for "file_id: etc" below: in mysqlbinlog we want the #, in
SHOW BINLOG EVENTS we don't.
*/
if (my_b_write_byte(&cache, '#'))
goto err;
}
if (my_b_printf(&cache, " file_id: %d block_len: %d\n", file_id, block_len))
goto err;
return cache.flush_data();
err:
return 1;
}
bool Create_file_log_event::print(FILE* file,
PRINT_EVENT_INFO* print_event_info)
{
return print(file, print_event_info, 0);
}
/*
Append_block_log_event::print()
*/
bool Append_block_log_event::print(FILE* file,
PRINT_EVENT_INFO* print_event_info)
{
......@@ -2700,10 +2529,6 @@ bool Append_block_log_event::print(FILE* file,
}
/*
Delete_file_log_event::print()
*/
bool Delete_file_log_event::print(FILE* file,
PRINT_EVENT_INFO* print_event_info)
{
......@@ -2719,25 +2544,6 @@ bool Delete_file_log_event::print(FILE* file,
return cache.flush_data();
}
/*
Execute_load_log_event::print()
*/
bool Execute_load_log_event::print(FILE* file,
PRINT_EVENT_INFO* print_event_info)
{
if (print_event_info->short_form)
return 0;
Write_on_release_cache cache(&print_event_info->head_cache, file);
if (print_header(&cache, print_event_info, FALSE) ||
my_b_printf(&cache, "\n#Exec_load: file_id=%d\n",
file_id))
return 1;
return cache.flush_data();
}
bool Execute_load_query_log_event::print(FILE* file,
PRINT_EVENT_INFO* print_event_info)
......@@ -2995,10 +2801,6 @@ bool copy_cache_to_string_wrapped(IO_CACHE *cache,
where fragments are represented by a pair of indexed user
"one shot" variables.
@note
If any changes made don't forget to duplicate them to
Old_rows_log_event as long as it's supported.
@param file pointer to IO_CACHE
@param print_event_info pointer to print_event_info specializing
what out of and how to print the event
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
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
the Free Software Foundation; version 2 of the License.
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
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#include "mariadb.h"
#include "sql_priv.h"
#include "rpl_rli.h"
#include "rpl_record_old.h"
#include "log_event.h" // Log_event_type
size_t
pack_row_old(TABLE *table, MY_BITMAP const* cols,
uchar *row_data, const uchar *record)
{
Field **p_field= table->field, *field;
int n_null_bytes= table->s->null_bytes;
uchar *ptr;
uint i;
my_ptrdiff_t const rec_offset= record - table->record[0];
my_ptrdiff_t const def_offset= table->s->default_values - table->record[0];
memcpy(row_data, record, n_null_bytes);
ptr= row_data+n_null_bytes;
for (i= 0 ; (field= *p_field) ; i++, p_field++)
{
if (bitmap_is_set(cols,i))
{
my_ptrdiff_t const offset=
field->is_null(rec_offset) ? def_offset : rec_offset;
field->move_field_offset(offset);
ptr= field->pack(ptr, field->ptr);
field->move_field_offset(-offset);
}
}
return (static_cast<size_t>(ptr - row_data));
}
/*
Unpack a row into a record.
SYNOPSIS
unpack_row()
rli Relay log info
table Table to unpack into
colcnt Number of columns to read from record
record Record where the data should be unpacked
row Packed row data
cols Pointer to columns data to fill in
row_end Pointer to variable that will hold the value of the
one-after-end position for the row
master_reclength
Pointer to variable that will be set to the length of the
record on the master side
rw_set Pointer to bitmap that holds either the read_set or the
write_set of the table
DESCRIPTION
The row is assumed to only consist of the fields for which the
bitset represented by 'arr' and 'bits'; the other parts of the
record are left alone.
At most 'colcnt' columns are read: if the table is larger than
that, the remaining fields are not filled in.
RETURN VALUE
Error code, or zero if no error. The following error codes can
be returned:
ER_NO_DEFAULT_FOR_FIELD
Returned if one of the fields existing on the slave but not on
the master does not have a default value (and isn't nullable)
ER_SLAVE_CORRUPT_EVENT
Wrong data for field found.
*/
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
int
unpack_row_old(rpl_group_info *rgi,
TABLE *table, uint const colcnt, uchar *record,
uchar const *row, const uchar *row_buffer_end,
MY_BITMAP const *cols,
uchar const **row_end, ulong *master_reclength,
MY_BITMAP* const rw_set, Log_event_type const event_type)
{
DBUG_ASSERT(record && row);
my_ptrdiff_t const offset= record - (uchar*) table->record[0];
size_t master_null_bytes= table->s->null_bytes;
if (colcnt != table->s->fields)
{
Field **fptr= &table->field[colcnt-1];
do
master_null_bytes= (*fptr)->last_null_byte();
while (master_null_bytes == Field::LAST_NULL_BYTE_UNDEF &&
fptr-- > table->field);
/*
If master_null_bytes is LAST_NULL_BYTE_UNDEF (0) at this time,
there were no nullable fields nor BIT fields at all in the
columns that are common to the master and the slave. In that
case, there is only one null byte holding the X bit.
OBSERVE! There might still be nullable columns following the
common columns, so table->s->null_bytes might be greater than 1.
*/
if (master_null_bytes == Field::LAST_NULL_BYTE_UNDEF)
master_null_bytes= 1;
}
DBUG_ASSERT(master_null_bytes <= table->s->null_bytes);
memcpy(record, row, master_null_bytes); // [1]
int error= 0;
bitmap_set_all(rw_set);
Field **const begin_ptr = table->field;
Field **field_ptr;
uchar const *ptr= row + master_null_bytes;
Field **const end_ptr= begin_ptr + colcnt;
for (field_ptr= begin_ptr ; field_ptr < end_ptr ; ++field_ptr)
{
Field *const f= *field_ptr;
if (bitmap_is_set(cols, (uint)(field_ptr - begin_ptr)))
{
f->move_field_offset(offset);
ptr= f->unpack(f->ptr, ptr, row_buffer_end, 0);
f->move_field_offset(-offset);
if (!ptr)
{
rgi->rli->report(ERROR_LEVEL, ER_SLAVE_CORRUPT_EVENT, NULL,
"Could not read field `%s` of table `%s`.`%s`",
f->field_name.str, table->s->db.str,
table->s->table_name.str);
return(ER_SLAVE_CORRUPT_EVENT);
}
}
else
bitmap_clear_bit(rw_set, (uint)(field_ptr - begin_ptr));
}
*row_end = ptr;
if (master_reclength)
{
if (*field_ptr)
*master_reclength = (ulong)((*field_ptr)->ptr - table->record[0]);
else
*master_reclength = table->s->reclength;
}
/*
Set properties for remaining columns, if there are any. We let the
corresponding bit in the write_set be set, to write the value if
it was not there already. We iterate over all remaining columns,
even if there were an error, to get as many error messages as
possible. We are still able to return a pointer to the next row,
so redo that.
This generation of error messages is only relevant when inserting
new rows.
*/
for ( ; *field_ptr ; ++field_ptr)
{
uint32 const mask= NOT_NULL_FLAG | NO_DEFAULT_VALUE_FLAG;
DBUG_PRINT("debug", ("flags = 0x%x, mask = 0x%x, flags & mask = 0x%x",
(*field_ptr)->flags, mask,
(*field_ptr)->flags & mask));
if (event_type == WRITE_ROWS_EVENT &&
((*field_ptr)->flags & mask) == mask)
{
rgi->rli->report(ERROR_LEVEL, ER_NO_DEFAULT_FOR_FIELD, NULL,
"Field `%s` of table `%s`.`%s` "
"has no default value and cannot be NULL",
(*field_ptr)->field_name.str, table->s->db.str,
table->s->table_name.str);
error = ER_NO_DEFAULT_FOR_FIELD;
}
else
(*field_ptr)->set_default();
}
return error;
}
#endif
/* Copyright (c) 2007, 2010, Oracle and/or its affiliates.
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
the Free Software Foundation; version 2 of the License.
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
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#ifndef RPL_RECORD_OLD_H
#define RPL_RECORD_OLD_H
#include "log_event.h" /* Log_event_type */
#ifndef MYSQL_CLIENT
size_t pack_row_old(TABLE *table, MY_BITMAP const* cols,
uchar *row_data, const uchar *record);
#ifdef HAVE_REPLICATION
int unpack_row_old(rpl_group_info *rgi,
TABLE *table, uint const colcnt, uchar *record,
uchar const *row, uchar const *row_buffer_end,
MY_BITMAP const *cols,
uchar const **row_end, ulong *master_reclength,
MY_BITMAP* const rw_set,
Log_event_type const event_type);
#endif
#endif
#endif
......@@ -525,13 +525,7 @@ read_relay_log_description_event(IO_CACHE *cur_log, ulonglong start_pos,
Format_description_log_event *fdev;
bool found= false;
/*
By default the relay log is in binlog format 3 (4.0).
Even if format is 4, this will work enough to read the first event
(Format_desc) (remember that format 4 is just lenghtened compared to format
3; format 3 is a prefix of format 4).
*/
fdev= new Format_description_log_event(3);
fdev= new Format_description_log_event(4);
while (!found)
{
......@@ -666,14 +660,7 @@ int init_relay_log_pos(Relay_log_info* rli,const char* log,
running, say, CHANGE MASTER.
*/
delete rli->relay_log.description_event_for_exec;
/*
By default the relay log is in binlog format 3 (4.0).
Even if format is 4, this will work enough to read the first event
(Format_desc) (remember that format 4 is just lenghtened compared to format
3; format 3 is a prefix of format 4).
*/
rli->relay_log.description_event_for_exec= new
Format_description_log_event(3);
rli->relay_log.description_event_for_exec= new Format_description_log_event(4);
mysql_mutex_lock(log_lock);
......
This diff is collapsed.
......@@ -90,7 +90,6 @@ struct rpl_group_info;
struct rpl_parallel_thread;
class Rpl_filter;
class Query_log_event;
class Load_log_event;
class Log_event_writer;
class sp_rcontext;
class sp_cache;
......
This diff is collapsed.
......@@ -1467,7 +1467,7 @@ gtid_state_from_pos(const char *name, uint32 offset,
if (unlikely((file= open_binlog(&cache, name, &errormsg)) == (File)-1))
return errormsg;
if (!(fdev= new Format_description_log_event(3)))
if (!(fdev= new Format_description_log_event(4)))
{
errormsg= "Out of memory initializing format_description event "
"while scanning binlog to find start position";
......@@ -2273,7 +2273,7 @@ static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
if (info->fdev != NULL)
delete info->fdev;
if (!(info->fdev= new Format_description_log_event(3)))
if (!(info->fdev= new Format_description_log_event(4)))
{
info->errmsg= "Out of memory initializing format_description event";
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
......@@ -4163,7 +4163,7 @@ bool mysql_show_binlog_events(THD* thd)
}
Format_description_log_event *description_event= new
Format_description_log_event(3); /* MySQL 4.0 by default */
Format_description_log_event(4);
if (binary_log->is_open())
{
......
......@@ -1146,7 +1146,6 @@ String_copier::well_formed_copy(CHARSET_INFO *to_cs,
}
/*
Append characters to a single-quoted string '...', escaping special
characters with backslashes as necessary.
......@@ -1164,6 +1163,8 @@ bool String::append_for_single_quote(const char *st, size_t len)
case '\\': APPEND(STRING_WITH_LEN("\\\\"));
case '\0': APPEND(STRING_WITH_LEN("\\0"));
case '\'': APPEND(STRING_WITH_LEN("\\'"));
case '\b': APPEND(STRING_WITH_LEN("\\b"));
case '\t': APPEND(STRING_WITH_LEN("\\t"));
case '\n': APPEND(STRING_WITH_LEN("\\n"));
case '\r': APPEND(STRING_WITH_LEN("\\r"));
case '\032': APPEND(STRING_WITH_LEN("\\Z"));
......
......@@ -3413,7 +3413,7 @@ int wsrep_must_ignore_error(THD* thd)
WSREP_WARN("Ignoring error '%s' on query. "
"Default database: '%s'. Query: '%s', Error_code: %d",
thd->get_stmt_da()->message(),
print_slave_db_safe(thd->db.str),
safe_str(thd->db.str),
thd->query(),
error);
return 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment