2005-02-23 14:55:16 +01:00
|
|
|
#
|
|
|
|
# misc binlogging tests that do not require a slave running
|
|
|
|
#
|
2005-12-22 06:39:02 +01:00
|
|
|
|
2006-02-24 17:34:15 +01:00
|
|
|
-- source include/not_embedded.inc
|
2005-02-23 14:55:16 +01:00
|
|
|
-- source include/have_innodb.inc
|
2005-12-22 06:39:02 +01:00
|
|
|
-- source include/have_debug.inc
|
2005-02-23 14:55:16 +01:00
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t1, t2;
|
|
|
|
--enable_warnings
|
2005-02-23 18:26:49 +01:00
|
|
|
reset master;
|
2005-02-23 14:55:16 +01:00
|
|
|
|
2006-08-11 03:29:25 +02:00
|
|
|
create table t1 (a int) engine=innodb;
|
2005-02-23 14:55:16 +01:00
|
|
|
create table t2 (a int) engine=innodb;
|
|
|
|
begin;
|
|
|
|
insert t1 values (5);
|
|
|
|
commit;
|
|
|
|
begin;
|
|
|
|
insert t2 values (5);
|
|
|
|
commit;
|
|
|
|
# first COMMIT must be Query_log_event, second - Xid_log_event
|
2005-03-16 21:12:27 +01:00
|
|
|
--replace_column 2 # 5 #
|
2006-05-17 22:16:51 +02:00
|
|
|
--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
|
2005-12-22 06:39:02 +01:00
|
|
|
show binlog events from 102;
|
2005-02-23 14:55:16 +01:00
|
|
|
drop table t1,t2;
|
|
|
|
|
2005-02-23 20:35:59 +01:00
|
|
|
#
|
|
|
|
# binlog rotation after one big transaction
|
|
|
|
#
|
|
|
|
reset master;
|
|
|
|
let $1=100;
|
|
|
|
|
|
|
|
create table t1 (n int) engine=innodb;
|
|
|
|
begin;
|
|
|
|
--disable_query_log
|
|
|
|
while ($1)
|
|
|
|
{
|
|
|
|
eval insert into t1 values($1 + 4);
|
|
|
|
dec $1;
|
|
|
|
}
|
|
|
|
--enable_query_log
|
|
|
|
commit;
|
|
|
|
drop table t1;
|
2005-03-16 21:12:27 +01:00
|
|
|
--replace_column 2 # 5 #
|
2006-05-17 22:16:51 +02:00
|
|
|
--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
|
2005-12-22 06:39:02 +01:00
|
|
|
show binlog events in 'master-bin.000001' from 102;
|
2005-03-16 21:12:27 +01:00
|
|
|
--replace_column 2 # 5 #
|
2006-05-17 22:16:51 +02:00
|
|
|
--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
|
2005-12-22 06:39:02 +01:00
|
|
|
show binlog events in 'master-bin.000002' from 102;
|
WL#3146 "less locking in auto_increment":
this is a cleanup patch for our current auto_increment handling:
new names for auto_increment variables in THD, new methods to manipulate them
(see sql_class.h), some move into handler::, causing less backup/restore
work when executing substatements.
This makes the logic hopefully clearer, less work is is needed in
mysql_insert().
By cleaning up, using different variables for different purposes (instead
of one for 3 things...), we fix those bugs, which someone may want to fix
in 5.0 too:
BUG#20339 "stored procedure using LAST_INSERT_ID() does not replicate
statement-based"
BUG#20341 "stored function inserting into one auto_increment puts bad
data in slave"
BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY UPDATE"
(now if a row is updated, LAST_INSERT_ID() will return its id)
and re-fixes:
BUG#6880 "LAST_INSERT_ID() value changes during multi-row INSERT"
(already fixed differently by Ramil in 4.1)
Test of documented behaviour of mysql_insert_id() (there was no test).
The behaviour changes introduced are:
- LAST_INSERT_ID() now returns "the first autogenerated auto_increment value
successfully inserted", instead of "the first autogenerated auto_increment
value if any row was successfully inserted", see auto_increment.test.
Same for mysql_insert_id(), see mysql_client_test.c.
- LAST_INSERT_ID() returns the id of the updated row if ON DUPLICATE KEY
UPDATE, see auto_increment.test. Same for mysql_insert_id(), see
mysql_client_test.c.
- LAST_INSERT_ID() does not change if no autogenerated value was successfully
inserted (it used to then be 0), see auto_increment.test.
- if in INSERT SELECT no autogenerated value was successfully inserted,
mysql_insert_id() now returns the id of the last inserted row (it already
did this for INSERT VALUES), see mysql_client_test.c.
- if INSERT SELECT uses LAST_INSERT_ID(X), mysql_insert_id() now returns X
(it already did this for INSERT VALUES), see mysql_client_test.c.
- NDB now behaves like other engines wrt SET INSERT_ID: with INSERT IGNORE,
the id passed in SET INSERT_ID is re-used until a row succeeds; SET INSERT_ID
influences not only the first row now.
Additionally, when unlocking a table we check that the thread is not keeping
a next_insert_id (as the table is unlocked that id is potentially out-of-date);
forgetting about this next_insert_id is done in a new
handler::ha_release_auto_increment().
Finally we prepare for engines capable of reserving finite-length intervals
of auto_increment values: we store such intervals in THD. The next step
(to be done by the replication team in 5.1) is to read those intervals from
THD and actually store them in the statement-based binary log. NDB
will be a good engine to test that.
2006-07-09 17:52:19 +02:00
|
|
|
|
|
|
|
# Test of a too big SET INSERT_ID: see if the truncated value goes
|
|
|
|
# into binlog (right), or the too big value (wrong); we look at the
|
|
|
|
# binlog further down with SHOW BINLOG EVENTS.
|
|
|
|
reset master;
|
|
|
|
create table t1 (id tinyint auto_increment primary key);
|
|
|
|
set insert_id=128;
|
|
|
|
insert into t1 values(null);
|
|
|
|
select * from t1;
|
|
|
|
drop table t1;
|
|
|
|
|
|
|
|
# Test of binlogging of INSERT_ID with INSERT DELAYED
|
|
|
|
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
|
|
|
|
# First, avoid BUG#20627:
|
|
|
|
set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1;
|
|
|
|
# Verify that only one INSERT_ID event is binlogged.
|
|
|
|
insert delayed into t1 values (207);
|
|
|
|
|
|
|
|
# We use sleeps between statements, that's the only way to get a
|
|
|
|
# repeatable binlog in a normal test run and under Valgrind.
|
|
|
|
# It may be that the "binlog missing rows" of BUG#20821 shows up
|
|
|
|
# here.
|
|
|
|
sleep 2;
|
|
|
|
insert delayed into t1 values (null);
|
|
|
|
sleep 2;
|
|
|
|
insert delayed into t1 values (300);
|
|
|
|
sleep 2; # time for the delayed queries to reach disk
|
|
|
|
select * from t1;
|
|
|
|
--replace_column 2 # 5 #
|
|
|
|
--replace_regex /table_id: [0-9]+/table_id: #/
|
|
|
|
show binlog events from 102;
|
|
|
|
drop table t1;
|