| 1 |
# ********************************************************* |
| 2 |
# The aim of this testcase is to test the functionality |
| 3 |
# of the multiple get functionality |
| 4 |
# case 1: be able to get correct value from mutliple get |
| 5 |
# case 2: If there is no corresponding value for a key |
| 6 |
# should not affect the other values in fetching |
| 7 |
# case 3: No support for switch between the tables |
| 8 |
# ********************************************************* |
| 9 |
source include/not_valgrind.inc; |
| 10 |
source include/have_memcached_plugin.inc; |
| 11 |
source include/not_windows.inc; |
| 12 |
# This testcase fails sporadiaclly with these options --big,--parallel=8,--repeat=30 --retry=0 |
| 13 |
# Due to some bug in the get_multi, variable unbale to clean up,following is the failure snippet |
| 14 |
# @@desc_t2.DD => DELHIDELHIDELHIDELHIDELHIDELHIDELHIDELHIDELHIDELHI0DAHARDAHARDAHARDAHARDAHARDAHARDAHARDAHARDAHARDAHAR |
| 15 |
# Tried with un-initialize variables , but still fails ,hence skipping |
| 16 |
#--source include/not_parallel.inc |
| 17 |
|
| 18 |
# Create the memcached tables |
| 19 |
--disable_query_log |
| 20 |
source include/memcache_config.inc; |
| 21 |
--enable_query_log |
| 22 |
|
| 23 |
INSERT INTO cache_policies VALUES("cache_policy", "innodb_only", |
| 24 |
"innodb_only", "innodb_only", "innodb_only"); |
| 25 |
|
| 26 |
INSERT INTO config_options VALUES("separator", "0"); |
| 27 |
|
| 28 |
# describe table for memcache |
| 29 |
INSERT INTO containers VALUES ("desc_t1", "test", "t1", "c1", "c2, |
| 30 |
c21,c22,c23,c24,c25", "c3", "c4", "c5", "PRIMARY"); |
| 31 |
|
| 32 |
INSERT INTO containers VALUES ("desc_t2", "test", "t2", "c1", |
| 33 |
"c2,c3", "c4", "c5", "c6", "PRIMARY"); |
| 34 |
|
| 35 |
USE test; |
| 36 |
|
| 37 |
--disable_warnings |
| 38 |
DROP TABLE IF EXISTS t1; |
| 39 |
DROP TABLE IF EXISTS t2; |
| 40 |
|
| 41 |
--enable_warnings |
| 42 |
CREATE TABLE t1 (c1 VARCHAR(32),c2 VARCHAR(40),c21 VARCHAR(40),c22 VARCHAR(40), |
| 43 |
c23 VARCHAR(40),c24 VARCHAR(40),c25 VARCHAR(40),c3 INT, c4 BIGINT UNSIGNED, c5 INT, primary key(c1)) |
| 44 |
ENGINE = INNODB; |
| 45 |
|
| 46 |
INSERT INTO t1 VALUES ('D', 'Darmstadt', 'City','1', 'dddddddddddddd', '1234', '2012', 0, 0, 0); |
| 47 |
INSERT INTO t1 VALUES ('B', 'Berlin', 'Mitte', '2', 'bbbbbbbbbbbbbb', '2345', '2012', 0, 0, 0); |
| 48 |
INSERT INTO t1 VALUES ('C', 'Cottbus', 'West', '3', 'cccccccccccccc', '3456', '2012', 0, 0 ,0); |
| 49 |
INSERT INTO t1 VALUES ('H', 'Hamburg', 'Norderstedt', '4', 'hhhhhhhhhh', '4567', '2012', 0, 0, 0); |
| 50 |
INSERT INTO t1 VALUES ('N', NULL, NULL, NULL, NULL, NULL, '2012', 0, 0, 0); |
| 51 |
|
| 52 |
CREATE TABLE t2(c1 VARCHAR(32),c2 VARCHAR(1024),c3 VARCHAR(1024), |
| 53 |
c4 INT, c5 BIGINT UNSIGNED, c6 INT, primary key(c1)) ENGINE=InnoDB; |
| 54 |
|
| 55 |
INSERT INTO t2 VALUES ('DD','DELHI','DAHAR', 0, 0, 0); |
| 56 |
INSERT INTO t2 VALUES ('BB','BOMBAY', 'BANGALORE', 0, 0, 0); |
| 57 |
INSERT INTO t2 VALUES ('CC','CALICUTT','CHENNAI', 0, 0 ,0); |
| 58 |
INSERT INTO t2 VALUES ('HH','HYDERABAD','HOSPET', 0, 0, 0); |
| 59 |
|
| 60 |
# Tables must exist before plugin can be started! |
| 61 |
--let $memcached_address=127.0.0.1:11294 |
| 62 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 63 |
|
| 64 |
--sorted_result |
| 65 |
SELECT c1,c2,c21,c22,c23,c24,c25 FROM t1; |
| 66 |
|
| 67 |
--echo # case 1: Fetch results for all Keys |
| 68 |
perl; |
| 69 |
use DBI; |
| 70 |
use Cache::Memcached; |
| 71 |
use Data::Dumper; |
| 72 |
my $memd = new Cache::Memcached { |
| 73 |
'servers' => [ "127.0.0.1:11294" ], |
| 74 |
'connect_timeout' => 20, |
| 75 |
'select_timeout' => 20 |
| 76 |
}; |
| 77 |
@keys = qw( D B C H D B C H N ); |
| 78 |
print "Here are the memcached results with @keys:\n"; |
| 79 |
my $val = $memd->get_multi(@keys); |
| 80 |
foreach my $item (sort keys %$val) { |
| 81 |
if (defined $item && exists $val->{$item} ) { |
| 82 |
print "$item => $val->{$item}\n"; |
| 83 |
} |
| 84 |
delete $val->{$item}; |
| 85 |
undef $val->{$item}; |
| 86 |
} |
| 87 |
$memd->disconnect_all; |
| 88 |
EOF |
| 89 |
|
| 90 |
SELECT SLEEP(2); |
| 91 |
|
| 92 |
--sorted_result |
| 93 |
SELECT c1,c2,c21,c22,c23,c24,c25 FROM t1; |
| 94 |
|
| 95 |
--echo # case 2: Fetch results, when no values are exist for some keys |
| 96 |
perl; |
| 97 |
use DBI; |
| 98 |
use Cache::Memcached; |
| 99 |
my $memd = new Cache::Memcached { |
| 100 |
'servers' => [ "127.0.0.1:11294" ], |
| 101 |
'connect_timeout' => 20, |
| 102 |
'select_timeout' => 20 |
| 103 |
}; |
| 104 |
@keys = qw( D B C H I J K L M N O P NULL Q R S T U V X Y Z A D B C H ); |
| 105 |
print "Here are the memcached results with @keys:\n"; |
| 106 |
my $val = $memd->get_multi(@keys); |
| 107 |
foreach my $item (sort keys %$val) { |
| 108 |
if (defined $item && exists $val->{$item} ) { |
| 109 |
print "$item => $val->{$item}\n"; |
| 110 |
} |
| 111 |
delete $val->{$item}; |
| 112 |
undef $val->{$item}; |
| 113 |
} |
| 114 |
$memd->disconnect_all; |
| 115 |
EOF |
| 116 |
|
| 117 |
SELECT SLEEP(2); |
| 118 |
|
| 119 |
--sorted_result |
| 120 |
SELECT c1,c2,c3 FROM t2; |
| 121 |
|
| 122 |
--echo # case 3: No support switch between the tables t2 and t1 |
| 123 |
--echo # Here it shows the results of table t2 and not for t1 |
| 124 |
|
| 125 |
perl; |
| 126 |
use DBI; |
| 127 |
use Cache::Memcached; |
| 128 |
my $memd = new Cache::Memcached { |
| 129 |
'servers' => [ "127.0.0.1:11294" ], |
| 130 |
'connect_timeout' => 20, |
| 131 |
'select_timeout' => 20 |
| 132 |
}; |
| 133 |
@keys = qw( @@desc_t2.DD @@desc_t2.BB @@desc_t2.CC @@desc_t1.c @@desc_t2.HH @@desc_t1.H ); |
| 134 |
print "Here are the memcached results with @keys:\n"; |
| 135 |
my $val = $memd->get_multi(@keys); |
| 136 |
foreach my $item (sort keys %$val) { |
| 137 |
if (defined $item && exists $val->{$item} ) { |
| 138 |
print "$item => $val->{$item}\n"; |
| 139 |
} |
| 140 |
delete $val->{$item}; |
| 141 |
undef $val->{$item}; |
| 142 |
} |
| 143 |
$memd->disconnect_all; |
| 144 |
EOF |
| 145 |
|
| 146 |
SELECT SLEEP(2); |
| 147 |
|
| 148 |
--sorted_result |
| 149 |
SELECT c1,c2,c21,c22,c23,c24,c25 FROM t1; |
| 150 |
|
| 151 |
# Temporary quote out due to instability |
| 152 |
#perl; |
| 153 |
#use DBI; |
| 154 |
#use Cache::Memcached; |
| 155 |
#my $memd = new Cache::Memcached { |
| 156 |
# 'servers' => [ "127.0.0.1:11294" ], |
| 157 |
# 'connect_timeout' => 20, |
| 158 |
# 'select_timeout' => 20 |
| 159 |
#}; |
| 160 |
|
| 161 |
#print "Test No support for Multiple range get :\n"; |
| 162 |
#$val = $memd->get('@@desc_t1'); |
| 163 |
#if ($val) { print "$val\n"; } |
| 164 |
#$val = $memd->get('@1 @@ @^ @? / @=D @=C'); |
| 165 |
#if ($val) { print "$val\n"; } |
| 166 |
#$val = $memd->get('@<D @>D @>=D@<=N @>D @<N'); |
| 167 |
#if ($val) { print "$val\n"; } |
| 168 |
#$memd->disconnect_all; |
| 169 |
#EOF |
| 170 |
|
| 171 |
#SELECT SLEEP(2); |
| 172 |
|
| 173 |
DROP TABLE t1; |
| 174 |
DROP TABLE t2; |
| 175 |
|
| 176 |
UNINSTALL PLUGIN daemon_memcached; |
| 177 |
DROP DATABASE innodb_memcache; |