1source include/not_valgrind.inc; 2source include/have_memcached_plugin.inc; 3source include/not_windows.inc; 4source include/have_innodb.inc; 5 6--disable_query_log 7CALL mtr.add_suppression("daemon-memcached-r-batch-size': unsigned value"); 8CALL mtr.add_suppression("Could not obtain server's UPN to be used as target service name"); 9CALL mtr.add_suppression("InnoDB: Warning: MySQL is trying to drop"); 10--enable_query_log 11 12--enable_connect_log 13SET @auto_commit= @@global.autocommit; 14SET @@global.autocommit=0; 15SET @tx_isolation= @@global.tx_isolation; 16SET GLOBAL TRANSACTION ISOLATION LEVEL SERIALIZABLE; 17SET @lock_wait=@@global.lock_wait_timeout; 18SET @@global.lock_wait_timeout=1; 19SET @innodb_lock_wait=@@global.innodb_lock_wait_timeout; 20SET @@global.innodb_lock_wait_timeout=1; 21 22# Create the memcached tables 23--disable_query_log 24source include/memcache_config.inc; 25--enable_query_log 26 27INSERT INTO cache_policies VALUES("cache_policy", "innodb_only", 28 "innodb_only", "innodb_only", "innodb_only"); 29 30INSERT INTO config_options VALUES("separator", "|"); 31 32# describe table for memcache 33INSERT INTO containers VALUES ("desc_t1", "test", "t1", 34 "c1", "c2,c21", "c3", "c4", "c5", "PRIMARY"); 35 36CREATE USER mysqltest1@localhost; 37COMMIT; 38connect (mysqltest1,localhost,mysqltest1,,); 39connection mysqltest1; 40 41USE test; 42 43--disable_warnings 44DROP TABLE IF EXISTS t1; 45--enable_warnings 46CREATE TABLE t1 (c1 VARCHAR(32), 47 c2 VARCHAR(1024), 48 c21 VARCHAR(1024), 49 c3 INT, c4 BIGINT UNSIGNED, c5 INT, primary key(c1)) 50ENGINE = INNODB; 51 52COMMIT; 53 54connection default; 55# Tables must exist before plugin can be started! 56INSTALL PLUGIN daemon_memcached SONAME 'libmemcached.so'; 57SELECT @@global.daemon_memcached_w_batch_size; 58--error ER_INCORRECT_GLOBAL_LOCAL_VAR 59SET @@global.daemon_memcached_w_batch_size=100; 60 61connection mysqltest1; 62 63# The following select is writing all to memcache otherwisw memcache is empty. 64--sorted_result 65SELECT c1,c2,c21 FROM t1; 66COMMIT; 67 68SELECT SLEEP(2); 69 70connection default; 71perl; 72use DBI; 73use Cache::Memcached; 74my $memd = new Cache::Memcached { 75 'servers' => [ "127.0.0.1:11266" ], 76 'connect_timeout' => 20, 77 'select_timeout' => 20 78}; 79#print "Here the memcached :\n"; 80$val = $memd->set("B","Berlin|Mitte"); 81if ($val) { print "$val\n"; } 82$val = $memd->set("D","Darmstadt|City"); 83if ($val) { print "$val\n"; } 84$val = $memd->set("C","Cottbus|Süd"); 85if ($val) { print "$val\n"; } 86$val = $memd->set("H","Hamburg|Altona"); 87if ($val) { print "$val\n"; } 88$memd->disconnect_all; 89EOF 90--sorted_result 91SELECT c1,c2,c21 FROM test.t1; 92 93connection mysqltest1; 94--sorted_result 95SELECT c1,c2,c21 FROM t1 FOR UPDATE; 96ROLLBACK; 97 98connection default; 99perl; 100use DBI; 101use Cache::Memcached; 102my $memd = new Cache::Memcached { 103 'servers' => [ "127.0.0.1:11266" ], 104 'connect_timeout' => 20, 105 'select_timeout' => 20 106}; 107print "Here the memcached results:\n"; 108$val = $memd->add("M","München|Perlach"); 109if ($val) { print "$val\n"; } 110$val = $memd->add("N","Nürnberg|Nord"); 111if ($val) { print "$val\n"; } 112$val = $memd->add("O","Oldenburg|Friesland"); 113if ($val) { print "$val\n"; } 114$val = $memd->add("S","Stuttgart|Schwaben"); 115if ($val) { print "$val\n"; } 116$val = $memd->add("G","Gossen|City"); 117if ($val) { print "$val\n"; } 118$val = $memd->add("F","Frankfurt|Sachsenhausen"); 119if ($val) { print "$val\n"; } 120$val = $memd->add("E","Essen|West"); 121if ($val) { print "$val\n"; } 122$val = $memd->add("P","Paderborn|City"); 123if ($val) { print "$val\n"; } 124$memd->disconnect_all; 125EOF 126--sorted_result 127SELECT c1,c2,c21 FROM test.t1; 128 129connection mysqltest1; 130SELECT c1,c2,c21 FROM test.t1 FOR UPDATE; 131COMMIT; 132 133connection default; 134perl; 135use DBI; 136use Cache::Memcached; 137my $memd = new Cache::Memcached { 138 'servers' => [ "127.0.0.1:11266" ], 139 'connect_timeout' => 20, 140 'select_timeout' => 20 141}; 142print "Here the memcached results:\n"; 143$val = $memd->replace("G","Gossen|C"); 144if ($val) { print "$val\n"; } 145$val = $memd->replace("F","Frankfurt|S"); 146if ($val) { print "$val\n"; } 147$val = $memd->replace("E","Essen|W"); 148if ($val) { print "$val\n"; } 149$memd->disconnect_all; 150EOF 151--sorted_result 152SELECT SLEEP(2); 153SELECT c1,c2,c21 FROM test.t1; 154 155connection mysqltest1; 156# With latest checkin, the memcached plugin will automatically commit 157# transactions when you close the connection. So we cannot test the 158# timeout with the memcached connection closed. If there are new ways 159# to test such, we can re-enable this 160# --error ER_LOCK_WAIT_TIMEOUT 161SELECT c1,c2,c21 FROM test.t1 FOR UPDATE; 162DROP TABLE test.t1; 163COMMIT; 164 165connection default; 166disconnect mysqltest1; 167 168UNINSTALL PLUGIN daemon_memcached; 169DROP DATABASE innodb_memcache; 170DROP USER mysqltest1@localhost; 171 172SET @@global.tx_isolation= @tx_isolation; 173SET @@global.autocommit=@auto_commit; 174SET @@global.lock_wait_timeout=@lock_wait; 175SET @@global.innodb_lock_wait_timeout=@innodb_lock_wait; 176