mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-30 04:26:45 +03:00 
			
		
		
		
	 f169114042
			
		
	
	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
		
			
				
	
	
		
			57 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| #
 | |
| # Test of replicating user variables
 | |
| #
 | |
| source include/master-slave.inc;
 | |
| # Disable PS as the log positions differs
 | |
| --disable_ps_protocol
 | |
| 
 | |
| 
 | |
| # Clean up old slave's binlogs.
 | |
| # The slave is started with --log-slave-updates
 | |
| # and this test does SHOW BINLOG EVENTS on the slave's
 | |
| # binlog. But previous tests can influence the current test's
 | |
| # binlog (e.g. a temporary table in the previous test has not
 | |
| # been explicitly deleted, or it has but the slave hasn't had
 | |
| # enough time to catch it before STOP SLAVE, 
 | |
| # and at the beginning of the current
 | |
| # test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
 | |
| # We wait for the slave to have written all he wants to the binlog
 | |
| # (otherwise RESET MASTER may come too early).
 | |
| save_master_pos;
 | |
| connection slave;
 | |
| sync_with_master;
 | |
| reset master;
 | |
| connection master;
 | |
| 
 | |
| create table t1(n char(30));
 | |
| set @i1:=12345678901234, @i2:=-12345678901234, @i3:=0, @i4:=-1;
 | |
| set @s1:='This is a test', @r1:=12.5, @r2:=-12.5;
 | |
| set @n1:=null;
 | |
| set @s2:='', @s3:='abc\'def', @s4:= 'abc\\def', @s5:= 'abc''def';
 | |
| insert into t1 values (@i1), (@i2), (@i3), (@i4);
 | |
| insert into t1 values (@r1), (@r2);
 | |
| insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5);
 | |
| insert into t1 values (@n1);
 | |
| insert into t1 values (@n2); # not explicitely set before
 | |
| insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1);
 | |
| insert into t1 values (@a+(@b:=@a+1));
 | |
| set @q:='abc';
 | |
| insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2'));
 | |
| set @a:=5;
 | |
| insert into t1 values (@a),(@a);
 | |
| connection master1; # see if variable is reset in binlog when thread changes
 | |
| insert into t1 values (@a),(@a),(@a*5);
 | |
| select * from t1;
 | |
| save_master_pos;
 | |
| connection slave;
 | |
| sync_with_master;
 | |
| select * from t1;
 | |
| --replace_column 2 # 5 #
 | |
| show binlog events from 98;
 | |
| connection master;
 | |
| drop table t1;
 | |
| save_master_pos;
 | |
| connection slave;
 | |
| sync_with_master;
 | |
| stop slave;
 |