2003-01-18 16:39:21 +02:00
stop slave;
2003-01-14 11:27:26 +02:00
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
2003-01-18 16:39:21 +02:00
start slave;
2003-08-20 23:24:45 +02:00
reset master;
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
select last_insert_id();
last_insert_id()
0
2003-01-14 11:27:26 +02:00
create table t1(a int not null auto_increment, b int, primary key(a) );
2007-12-12 18:19:24 +01:00
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
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
select last_insert_id();
last_insert_id()
1
2003-04-03 12:54:08 -04:00
create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60));
2007-12-12 18:19:24 +01:00
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines;
2003-04-03 12:54:08 -04:00
create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60));
insert into t3 select * from t2;
2003-01-14 11:27:26 +02:00
select * from t1;
a b
1 10
2 15
2003-04-03 12:54:08 -04:00
select * from t3;
day id category name
2003-02-22 2461 b a a a @ % ' " a
2003-03-22 2161 c asdf
2003-09-25 00:14:46 +02:00
2003-03-22 2416 a bbbbb
2003-01-14 11:27:26 +02:00
drop table t1;
2003-04-03 12:54:08 -04:00
drop table t2;
drop table t3;
2003-06-03 15:47:29 +02:00
create table t1(a int, b int, unique(b));
insert into t1 values(1,10);
2007-12-12 18:19:24 +01:00
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
2003-08-04 10:59:44 +02:00
set global sql_slave_skip_counter=1;
start slave;
2009-09-29 14:16:23 +03:00
show slave status;;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File master-bin.000001
2009-11-03 19:02:56 +00:00
Read_Master_Log_Pos #
2009-09-29 14:16:23 +03:00
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running Yes
Slave_SQL_Running Yes
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table #
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
2009-11-03 19:02:56 +00:00
Exec_Master_Log_Pos #
2009-09-29 14:16:23 +03:00
Relay_Log_Space #
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
2009-10-01 19:44:53 +03:00
Replicate_Ignore_Server_Ids
Master_Server_Id 1
2003-08-04 10:59:44 +02:00
set sql_log_bin=0;
delete from t1;
set sql_log_bin=1;
2007-12-12 18:19:24 +01:00
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
2003-08-04 10:59:44 +02:00
stop slave;
change master to master_user='test';
change master to master_user='root';
2009-09-29 14:16:23 +03:00
show slave status;;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File master-bin.000001
2009-11-03 19:02:56 +00:00
Read_Master_Log_Pos #
2009-09-29 14:16:23 +03:00
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running No
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table #
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
2009-11-03 19:02:56 +00:00
Exec_Master_Log_Pos #
2009-09-29 14:16:23 +03:00
Relay_Log_Space #
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
2009-10-01 19:44:53 +03:00
Replicate_Ignore_Server_Ids
Master_Server_Id 1
2003-08-04 10:59:44 +02:00
set global sql_slave_skip_counter=1;
start slave;
set sql_log_bin=0;
delete from t1;
set sql_log_bin=1;
2007-12-12 18:19:24 +01:00
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
2003-08-04 10:59:44 +02:00
stop slave;
reset slave;
2009-09-29 14:16:23 +03:00
show slave status;;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File
Read_Master_Log_Pos 4
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File
Slave_IO_Running No
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table #
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
2009-11-03 19:02:56 +00:00
Exec_Master_Log_Pos #
2009-09-29 14:16:23 +03:00
Relay_Log_Space #
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
2009-10-01 19:44:53 +03:00
Replicate_Ignore_Server_Ids
Master_Server_Id 1
2003-09-25 00:14:46 +02:00
reset master;
create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
2005-03-25 14:51:17 +01:00
unique(day)) engine=MyISAM;
2007-12-12 18:19:24 +01:00
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
2003-09-25 00:14:46 +02:00
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
'\n##\n' starting by '>' ignore 1 lines;
2006-01-23 12:17:05 +01:00
ERROR 23000: Duplicate entry '2003-03-22' for key 'day'
2005-03-25 14:51:17 +01:00
select * from t2;
day id category name
2003-02-22 2461 b a a a @ % ' " a
2003-03-22 2161 c asdf
start slave;
select * from t2;
day id category name
2003-02-22 2461 b a a a @ % ' " a
2003-03-22 2161 c asdf
alter table t2 drop key day;
delete from t2;
2007-12-12 18:19:24 +01:00
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
2005-03-25 14:51:17 +01:00
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
'\n##\n' starting by '>' ignore 1 lines;
2006-01-23 12:17:05 +01:00
ERROR 23000: Duplicate entry '2003-03-22' for key 'day'
2008-11-13 20:19:00 +01:00
drop table t1, t2;
drop table t1, t2;
2007-05-08 10:17:00 -04:00
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB;
2007-12-12 18:19:24 +01:00
LOAD DATA INFILE "../../std_data/words.dat" INTO TABLE t1;
2007-05-08 10:17:00 -04:00
ERROR 23000: Duplicate entry 'Aarhus' for key 'PRIMARY'
DROP TABLE IF EXISTS t1;