mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
f169114042
Now one can use user variables as target for data loaded from file (besides table's columns). Also LOAD DATA got new SET-clause in which one can specify values for table columns as expressions. For example the following is possible: LOAD DATA INFILE 'words.dat' INTO TABLE t1 (a, @b) SET c = @b + 1; This patch also implements new way of replicating LOAD DATA. Now we do it similarly to other queries. We store LOAD DATA query in new Execute_load_query event (which is last in the sequence of events representing LOAD DATA). When we are executing this event we simply rewrite part of query which holds name of file (we use name of temporary file) and then execute it as usual query. In the beggining of this sequence we use Begin_load_query event which is almost identical to Append_file event
207 lines
6.6 KiB
Text
207 lines
6.6 KiB
Text
drop table if exists t1, t2;
|
|
create table t1 (a int) engine=innodb;
|
|
create table t2 (a int) engine=myisam;
|
|
reset master;
|
|
begin;
|
|
insert into t1 values(1);
|
|
insert into t2 select * from t1;
|
|
commit;
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 98 Query 1 # use `test`; BEGIN
|
|
master-bin.000001 167 Query 1 # use `test`; insert into t1 values(1)
|
|
master-bin.000001 255 Query 1 # use `test`; insert into t2 select * from t1
|
|
master-bin.000001 350 Xid 1 # COMMIT /* xid=7 */
|
|
delete from t1;
|
|
delete from t2;
|
|
reset master;
|
|
begin;
|
|
insert into t1 values(2);
|
|
insert into t2 select * from t1;
|
|
rollback;
|
|
Warnings:
|
|
Warning 1196 Some non-transactional changed tables couldn't be rolled back
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 98 Query 1 # use `test`; BEGIN
|
|
master-bin.000001 167 Query 1 # use `test`; insert into t1 values(2)
|
|
master-bin.000001 255 Query 1 # use `test`; insert into t2 select * from t1
|
|
master-bin.000001 350 Query 1 # use `test`; ROLLBACK
|
|
delete from t1;
|
|
delete from t2;
|
|
reset master;
|
|
begin;
|
|
insert into t1 values(3);
|
|
savepoint my_savepoint;
|
|
insert into t1 values(4);
|
|
insert into t2 select * from t1;
|
|
rollback to savepoint my_savepoint;
|
|
Warnings:
|
|
Warning 1196 Some non-transactional changed tables couldn't be rolled back
|
|
commit;
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 98 Query 1 # use `test`; BEGIN
|
|
master-bin.000001 167 Query 1 # use `test`; insert into t1 values(3)
|
|
master-bin.000001 255 Query 1 # use `test`; savepoint my_savepoint
|
|
master-bin.000001 341 Query 1 # use `test`; insert into t1 values(4)
|
|
master-bin.000001 429 Query 1 # use `test`; insert into t2 select * from t1
|
|
master-bin.000001 524 Query 1 # use `test`; rollback to savepoint my_savepoint
|
|
master-bin.000001 622 Xid 1 # COMMIT /* xid=24 */
|
|
delete from t1;
|
|
delete from t2;
|
|
reset master;
|
|
begin;
|
|
insert into t1 values(5);
|
|
savepoint my_savepoint;
|
|
insert into t1 values(6);
|
|
insert into t2 select * from t1;
|
|
rollback to savepoint my_savepoint;
|
|
Warnings:
|
|
Warning 1196 Some non-transactional changed tables couldn't be rolled back
|
|
insert into t1 values(7);
|
|
commit;
|
|
select a from t1 order by a;
|
|
a
|
|
5
|
|
7
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 98 Query 1 # use `test`; BEGIN
|
|
master-bin.000001 167 Query 1 # use `test`; insert into t1 values(5)
|
|
master-bin.000001 255 Query 1 # use `test`; savepoint my_savepoint
|
|
master-bin.000001 341 Query 1 # use `test`; insert into t1 values(6)
|
|
master-bin.000001 429 Query 1 # use `test`; insert into t2 select * from t1
|
|
master-bin.000001 524 Query 1 # use `test`; rollback to savepoint my_savepoint
|
|
master-bin.000001 622 Query 1 # use `test`; insert into t1 values(7)
|
|
master-bin.000001 710 Xid 1 # COMMIT /* xid=36 */
|
|
delete from t1;
|
|
delete from t2;
|
|
reset master;
|
|
select get_lock("a",10);
|
|
get_lock("a",10)
|
|
1
|
|
begin;
|
|
insert into t1 values(8);
|
|
insert into t2 select * from t1;
|
|
select get_lock("a",10);
|
|
get_lock("a",10)
|
|
1
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 98 Query 1 # use `test`; BEGIN
|
|
master-bin.000001 167 Query 1 # use `test`; insert into t1 values(8)
|
|
master-bin.000001 255 Query 1 # use `test`; insert into t2 select * from t1
|
|
master-bin.000001 350 Query 1 # use `test`; ROLLBACK
|
|
delete from t1;
|
|
delete from t2;
|
|
reset master;
|
|
insert into t1 values(9);
|
|
insert into t2 select * from t1;
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 98 Query 1 # use `test`; insert into t1 values(9)
|
|
master-bin.000001 186 Xid 1 # COMMIT /* xid=59 */
|
|
master-bin.000001 213 Query 1 # use `test`; insert into t2 select * from t1
|
|
delete from t1;
|
|
delete from t2;
|
|
reset master;
|
|
insert into t1 values(10);
|
|
begin;
|
|
insert into t2 select * from t1;
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 98 Query 1 # use `test`; insert into t1 values(10)
|
|
master-bin.000001 187 Xid 1 # COMMIT /* xid=65 */
|
|
master-bin.000001 214 Query 1 # use `test`; insert into t2 select * from t1
|
|
insert into t1 values(11);
|
|
commit;
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 98 Query 1 # use `test`; insert into t1 values(10)
|
|
master-bin.000001 187 Xid 1 # COMMIT /* xid=65 */
|
|
master-bin.000001 214 Query 1 # use `test`; insert into t2 select * from t1
|
|
master-bin.000001 309 Query 1 # use `test`; BEGIN
|
|
master-bin.000001 378 Query 1 # use `test`; insert into t1 values(11)
|
|
master-bin.000001 467 Xid 1 # COMMIT /* xid=67 */
|
|
alter table t2 engine=INNODB;
|
|
delete from t1;
|
|
delete from t2;
|
|
reset master;
|
|
begin;
|
|
insert into t1 values(12);
|
|
insert into t2 select * from t1;
|
|
commit;
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 98 Query 1 # use `test`; BEGIN
|
|
master-bin.000001 167 Query 1 # use `test`; insert into t1 values(12)
|
|
master-bin.000001 256 Query 1 # use `test`; insert into t2 select * from t1
|
|
master-bin.000001 351 Xid 1 # COMMIT /* xid=77 */
|
|
delete from t1;
|
|
delete from t2;
|
|
reset master;
|
|
begin;
|
|
insert into t1 values(13);
|
|
insert into t2 select * from t1;
|
|
rollback;
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
delete from t1;
|
|
delete from t2;
|
|
reset master;
|
|
begin;
|
|
insert into t1 values(14);
|
|
savepoint my_savepoint;
|
|
insert into t1 values(15);
|
|
insert into t2 select * from t1;
|
|
rollback to savepoint my_savepoint;
|
|
commit;
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 98 Query 1 # use `test`; BEGIN
|
|
master-bin.000001 167 Query 1 # use `test`; insert into t1 values(14)
|
|
master-bin.000001 256 Xid 1 # COMMIT /* xid=93 */
|
|
delete from t1;
|
|
delete from t2;
|
|
reset master;
|
|
begin;
|
|
insert into t1 values(16);
|
|
savepoint my_savepoint;
|
|
insert into t1 values(17);
|
|
insert into t2 select * from t1;
|
|
rollback to savepoint my_savepoint;
|
|
insert into t1 values(18);
|
|
commit;
|
|
select a from t1 order by a;
|
|
a
|
|
16
|
|
18
|
|
show binlog events from 98;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 98 Query 1 # use `test`; BEGIN
|
|
master-bin.000001 167 Query 1 # use `test`; insert into t1 values(16)
|
|
master-bin.000001 256 Query 1 # use `test`; insert into t1 values(18)
|
|
master-bin.000001 345 Xid 1 # COMMIT /* xid=104 */
|
|
delete from t1;
|
|
delete from t2;
|
|
alter table t2 type=MyISAM;
|
|
insert into t1 values (1);
|
|
begin;
|
|
select * from t1 for update;
|
|
a
|
|
1
|
|
select (@before:=unix_timestamp())*0;
|
|
(@before:=unix_timestamp())*0
|
|
0
|
|
begin;
|
|
select * from t1 for update;
|
|
insert into t2 values (20);
|
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
select (@after:=unix_timestamp())*0;
|
|
(@after:=unix_timestamp())*0
|
|
0
|
|
select (@after-@before) >= 2;
|
|
(@after-@before) >= 2
|
|
1
|
|
drop table t1,t2;
|