|
| 1 | +# |
| 2 | +# Test of update hints |
| 3 | +# |
| 4 | +--source include/have_debug_sync.inc |
| 5 | +source include/have_innodb.inc; |
| 6 | + |
| 7 | +--disable_warnings |
| 8 | +drop table if exists t1; |
| 9 | +--enable_warnings |
| 10 | + |
| 11 | +create table t1 (id int primary key, c int) engine=innodb; |
| 12 | +connect (user1,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); |
| 13 | + |
| 14 | +#test target_affect_rows |
| 15 | +--error ER_UNMATCH_AFFECTED_ROWS |
| 16 | +update TARGET_AFFECT_ROW 1 t1 set c=c+1 where id=1; |
| 17 | +#-------------------------------------------------------------# |
| 18 | + |
| 19 | +#test commit_on_success |
| 20 | + |
| 21 | +begin; |
| 22 | +insert into t1 values(1,1); |
| 23 | +update COMMIT_ON_SUCCESS ROLLBACK_ON_FAIL TARGET_AFFECT_ROW 1 t1 set c=c+1 where id=1; |
| 24 | + |
| 25 | +connection user1; |
| 26 | +select * from t1; |
| 27 | +#-------------------------------------------------------------# |
| 28 | + |
| 29 | +#test rollback_on_fail |
| 30 | +connection default; |
| 31 | +begin; |
| 32 | +insert into t1 values(2,1); |
| 33 | +--error ER_UNMATCH_AFFECTED_ROWS |
| 34 | +update COMMIT_ON_SUCCESS ROLLBACK_ON_FAIL TARGET_AFFECT_ROW 2 t1 set c=c+1 where id=2; |
| 35 | + |
| 36 | +connection user1; |
| 37 | +select * from t1; |
| 38 | +#-------------------------------------------------------------# |
| 39 | + |
| 40 | +#test prepare-execute useage |
| 41 | +connection default; |
| 42 | +set @a=3; |
| 43 | +start transaction; |
| 44 | +insert into t1 values(3,1); |
| 45 | +prepare stmt from "update COMMIT_ON_SUCCESS ROLLBACK_ON_FAIL TARGET_AFFECT_ROW 1 t1 set c=c+1 where id=?"; |
| 46 | +execute stmt using @a; |
| 47 | + |
| 48 | +prepare stmt from "insert COMMIT_ON_SUCCESS ROLLBACK_ON_FAIL into t1 values(?,1)"; |
| 49 | +--error ER_DUP_ENTRY |
| 50 | +execute stmt using @a; |
| 51 | + |
| 52 | +connection user1; |
| 53 | +select * from t1; |
| 54 | +#-------------------------------------------------------------# |
| 55 | + |
| 56 | +#total hints |
| 57 | +connection default; |
| 58 | +update COMMIT_ON_SUCCESS ROLLBACK_ON_FAIL QUEUE_ON_PK 1 TARGET_AFFECT_ROW 1 t1 set c=c+1 where id=1; |
| 59 | +select * from t1; |
| 60 | +#-------------------------------------------------------------# |
| 61 | + |
| 62 | + |
| 63 | +# |
| 64 | +# Test for queue_on_pk |
| 65 | +# |
| 66 | + |
| 67 | +#wait for pk |
| 68 | +#rds_ic_reduce_hint_enable=OFF |
| 69 | +set global rds_ic_reduce_hint_enable=OFF; |
| 70 | +connection default; |
| 71 | +--send insert QUEUE_ON_PK 2 into t1 values(4,sleep(2)); |
| 72 | + |
| 73 | +connection user1; |
| 74 | +set @tbegin=unix_timestamp(now()); |
| 75 | +insert QUEUE_ON_PK 2 into t1 values(5,sleep(2)); |
| 76 | +set @tend=unix_timestamp(now()); |
| 77 | +select @tend - @tbegin cost; |
| 78 | + |
| 79 | +connection default; |
| 80 | +--reap |
| 81 | +delete from t1 where id in (4,5); |
| 82 | + |
| 83 | +#rds_ic_reduce_hint_enable=ON |
| 84 | +set global rds_ic_reduce_hint_enable=ON; |
| 85 | +connection default; |
| 86 | +--send insert QUEUE_ON_PK 2 into t1 values(4,sleep(2)); |
| 87 | + |
| 88 | +connection user1; |
| 89 | +set @tbegin=unix_timestamp(now()); |
| 90 | +insert QUEUE_ON_PK 2 into t1 values(5,sleep(2)); |
| 91 | +set @tend=unix_timestamp(now()); |
| 92 | +select @tend - @tbegin cost; |
| 93 | + |
| 94 | +connection default; |
| 95 | +--reap |
| 96 | + |
| 97 | +#for cover |
| 98 | +connection default; |
| 99 | +begin; |
| 100 | +insert QUEUE_ON_PK 2 into t1 values(6,1); |
| 101 | +insert QUEUE_ON_PK 2 into t1 values(7,1); |
| 102 | +commit; |
| 103 | + |
| 104 | +--error ER_DUP_ENTRY |
| 105 | +insert COMMIT_ON_SUCCESS ROLLBACK_ON_FAIL into t1 values(7,1); |
| 106 | + |
| 107 | +insert COMMIT_ON_SUCCESS ROLLBACK_ON_FAIL into t1 values(8,1); |
| 108 | + |
| 109 | +create table t2 like t1; |
| 110 | +insert into t2 value (1,1),(2,2); |
| 111 | +update COMMIT_ON_SUCCESS ROLLBACK_ON_FAIL t1,t2 set t2.c=3 where t2.id=t1.id and t1.id=1; |
| 112 | +--error ER_DUP_ENTRY |
| 113 | +update COMMIT_ON_SUCCESS ROLLBACK_ON_FAIL t1,t2 set t2.id=2 where t2.id=t1.id and t1.id=1; |
| 114 | + |
| 115 | +#sync for left_thread_num |
| 116 | +connection default; |
| 117 | +SET DEBUG_SYNC='after_unlock_queue_lock_in_unregist WAIT_FOR unlock_in_check'; |
| 118 | +--send insert QUEUE_ON_PK 2 into t1 values(9,1); |
| 119 | + |
| 120 | +connection user1; |
| 121 | +SET DEBUG_SYNC='after_unlock_queue_lock_in_check SIGNAL unlock_in_check WAIT_FOR go'; |
| 122 | +--sleep 1 |
| 123 | +--send insert QUEUE_ON_PK 2 into t1 values(10,1); |
| 124 | + |
| 125 | +connection default; |
| 126 | +--reap |
| 127 | +--sleep 1 |
| 128 | +SET DEBUG_SYNC='now SIGNAL go'; |
| 129 | + |
| 130 | +connection user1; |
| 131 | +--reap |
| 132 | + |
| 133 | +# |
| 134 | +#clean up |
| 135 | +# |
| 136 | +set global rds_ic_reduce_hint_enable=OFF; |
| 137 | + |
| 138 | +drop table t1,t2; |
| 139 | + |
| 140 | +disconnect user1; |
| 141 | +disconnect default; |
0 commit comments