| 1 |
# Test for InnoDB memcached support for utf8 charset |
| 2 |
# To make sure it handles utf8 as same as MYSQL. |
| 3 |
|
| 4 |
source include/not_valgrind.inc; |
| 5 |
source include/have_memcached_plugin.inc; |
| 6 |
source include/not_windows.inc; |
| 7 |
|
| 8 |
--disable_query_log |
| 9 |
CALL mtr.add_suppression("daemon-memcached-w-batch-size': unsigned"); |
| 10 |
CALL mtr.add_suppression("Could not obtain server's UPN to be used as target service name"); |
| 11 |
CALL mtr.add_suppression("Warning: MySQL is trying to drop"); |
| 12 |
--enable_query_log |
| 13 |
|
| 14 |
--enable_connect_log |
| 15 |
SET @transaction_isolation= @@global.transaction_isolation; |
| 16 |
SET GLOBAL TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; |
| 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", "|"); |
| 27 |
|
| 28 |
# describe table for memcache |
| 29 |
INSERT INTO containers VALUES ("desc_t1", "test", "t1", |
| 30 |
"c1", "c2,c21,c22,c23,c24,c25", "c3", "c4", "c5", "PRIMARY"); |
| 31 |
|
| 32 |
USE test; |
| 33 |
|
| 34 |
--disable_warnings |
| 35 |
DROP TABLE IF EXISTS t1; |
| 36 |
--enable_warnings |
| 37 |
CREATE TABLE t1 (c1 VARCHAR(32), |
| 38 |
c2 VARCHAR(40), |
| 39 |
c21 VARCHAR(40), |
| 40 |
c22 VARCHAR(40), |
| 41 |
c23 VARCHAR(40), |
| 42 |
c24 VARCHAR(40), |
| 43 |
c25 VARCHAR(40), |
| 44 |
c3 INT, c4 BIGINT UNSIGNED, c5 INT, primary key(c1)) |
| 45 |
ENGINE = INNODB DEFAULT CHARSET UTF8; |
| 46 |
|
| 47 |
INSERT INTO t1 VALUES ('D', 'Darmstadt', 'City','1', 'dddddddddddddd', '1234', '2012', 0, 0, 0); |
| 48 |
INSERT INTO t1 VALUES ('B', 'Berlin', 'Mitte', '2', 'bbbbbbbbbbbbbb', '2345', '2012', 0, 0, 0); |
| 49 |
INSERT INTO t1 VALUES ('C', 'Cottbus', 'West', '3', 'cccccccccccccc', '3456', '2012', 0, 0 ,0); |
| 50 |
INSERT INTO t1 VALUES ('M', 'München', 'Süd', '4', 'ÜÖÄßüöä', '4567', '2012', 0, 0, 0); |
| 51 |
|
| 52 |
# Tables must exist before plugin can be started! |
| 53 |
--let $memcached_address=127.0.0.1:11216 |
| 54 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 55 |
|
| 56 |
SHOW CREATE TABLE t1; |
| 57 |
|
| 58 |
--sorted_result |
| 59 |
SELECT c1,c2,c21,c22,c23,c24,c25 FROM t1; |
| 60 |
|
| 61 |
# Test get by key. |
| 62 |
perl; |
| 63 |
use DBI; |
| 64 |
use Cache::Memcached; |
| 65 |
my $memd = new Cache::Memcached { |
| 66 |
'servers' => [ "127.0.0.1:11216" ], |
| 67 |
'connect_timeout' => 20, |
| 68 |
'select_timeout' =>20 |
| 69 |
}; |
| 70 |
print "Here are the memcached results with D,B,M,C:\n"; |
| 71 |
$val = $memd->get("D"); |
| 72 |
if ($val) { print "$val\n"; } |
| 73 |
$val = $memd->get("B"); |
| 74 |
if ($val) { print "$val\n"; } |
| 75 |
$val = $memd->get("M"); |
| 76 |
if ($val) { print "$val\n"; } |
| 77 |
$val = $memd->get("C"); |
| 78 |
if ($val) { print "$val\n"; } |
| 79 |
$memd->disconnect_all; |
| 80 |
EOF |
| 81 |
|
| 82 |
--sorted_result |
| 83 |
SELECT c1,c2,c21,c22,c23,c24,c25 FROM t1; |
| 84 |
|
| 85 |
# Test set/get by key. |
| 86 |
# Here we test if the key is an invalid utf8 string, |
| 87 |
# and if the key exceed the column length. |
| 88 |
perl; |
| 89 |
use DBI; |
| 90 |
use Cache::Memcached; |
| 91 |
my $memd = new Cache::Memcached { |
| 92 |
'servers' => [ "127.0.0.1:11216" ], |
| 93 |
'connect_timeout' => 20, |
| 94 |
'select_timeout' =>20 |
| 95 |
}; |
| 96 |
|
| 97 |
# Test for normal utf8 key. |
| 98 |
print "Here are the memcached results after set:\n"; |
| 99 |
$val = $memd->set("Ü","Ülzen|City|5|üöäßÜÖÄ|5678|2012"); |
| 100 |
$val = $memd->get("Ü"); |
| 101 |
if ($val) { print "$val\n"; } |
| 102 |
|
| 103 |
# Test for invalid utf8 key. |
| 104 |
# The key will be truncated from the invalid byte. |
| 105 |
$key = "\x5f\xee\x39\x67\x6d"; |
| 106 |
$val = $memd->set($key,"Beijing|City|6|fffffffff|6789|2012"); |
| 107 |
$key2 = "\x5f"; |
| 108 |
$val = $memd->get($key2); |
| 109 |
if ($val) { print "$val\n"; } |
| 110 |
|
| 111 |
# Test key with all invalid bytes, which result the truncated length is 0 |
| 112 |
# It will be truncated to a empty string, and inserted into the table. |
| 113 |
$key = "\xee\x5f\x39\x67\x6d"; |
| 114 |
$val = $memd->set($key,"Shanghai|City|7|fffffffff|7890|2012"); |
| 115 |
$key2 = "\xee\x5f\x39\x67\x6d"; |
| 116 |
$val = $memd->get($key2); |
| 117 |
if ($val) { print "$val\n"; } |
| 118 |
|
| 119 |
# Test key exceed the column length. |
| 120 |
# It will be truncated to column length, and inserted into the table. |
| 121 |
$val = $memd->set("0123456789012345678901234567890123456789","Wuhan|City|8|eeeeeeeee|8901|2012"); |
| 122 |
$val = $memd->get("01234567890123456789012345678901"); |
| 123 |
if ($val) { print "$val\n"; } |
| 124 |
|
| 125 |
$memd->disconnect_all; |
| 126 |
EOF |
| 127 |
|
| 128 |
--sorted_result |
| 129 |
SELECT c1,c2,c21,c22,c23,c24,c25 FROM t1; |
| 130 |
|
| 131 |
DROP TABLE t1; |
| 132 |
|
| 133 |
UNINSTALL PLUGIN daemon_memcached; |
| 134 |
|
| 135 |
############################################################################## |
| 136 |
# Dup test for CHAR(32) key. |
| 137 |
############################################################################## |
| 138 |
--disable_warnings |
| 139 |
DROP TABLE IF EXISTS t1; |
| 140 |
--enable_warnings |
| 141 |
CREATE TABLE t1 (c1 CHAR(32), |
| 142 |
c2 CHAR(40), |
| 143 |
c21 CHAR(40), |
| 144 |
c22 CHAR(40), |
| 145 |
c23 CHAR(40), |
| 146 |
c24 CHAR(40), |
| 147 |
c25 CHAR(40), |
| 148 |
c3 INT, c4 BIGINT UNSIGNED, c5 INT, primary key(c1)) |
| 149 |
ENGINE = INNODB DEFAULT CHARSET UTF8; |
| 150 |
|
| 151 |
INSERT INTO t1 VALUES ('D', 'Darmstadt', 'City','1', 'dddddddddddddd', '1234', '2012', 0, 0, 0); |
| 152 |
INSERT INTO t1 VALUES ('B', 'Berlin', 'Mitte', '2', 'bbbbbbbbbbbbbb', '2345', '2012', 0, 0, 0); |
| 153 |
INSERT INTO t1 VALUES ('C', 'Cottbus', 'West', '3', 'cccccccccccccc', '3456', '2012', 0, 0 ,0); |
| 154 |
INSERT INTO t1 VALUES ('M', 'München', 'Süd', '4', 'ÜÖÄßüöä', '4567', '2012', 0, 0, 0); |
| 155 |
|
| 156 |
# Tables must exist before plugin can be started! |
| 157 |
--let $memcached_address=127.0.0.1:11216 |
| 158 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 159 |
|
| 160 |
SHOW CREATE TABLE t1; |
| 161 |
|
| 162 |
--sorted_result |
| 163 |
SELECT c1,c2,c21,c22,c23,c24,c25 FROM t1; |
| 164 |
|
| 165 |
# Test get by key. |
| 166 |
perl; |
| 167 |
use DBI; |
| 168 |
use Cache::Memcached; |
| 169 |
my $memd = new Cache::Memcached { |
| 170 |
'servers' => [ "127.0.0.1:11216" ], |
| 171 |
'connect_timeout' => 20, |
| 172 |
'select_timeout' =>20 |
| 173 |
}; |
| 174 |
print "Here are the memcached results with D,B,M,C:\n"; |
| 175 |
$val = $memd->get("D"); |
| 176 |
if ($val) { print "$val\n"; } |
| 177 |
$val = $memd->get("B"); |
| 178 |
if ($val) { print "$val\n"; } |
| 179 |
$val = $memd->get("M"); |
| 180 |
if ($val) { print "$val\n"; } |
| 181 |
$val = $memd->get("C"); |
| 182 |
if ($val) { print "$val\n"; } |
| 183 |
$memd->disconnect_all; |
| 184 |
EOF |
| 185 |
|
| 186 |
--sorted_result |
| 187 |
SELECT c1,c2,c21,c22,c23,c24,c25 FROM t1; |
| 188 |
|
| 189 |
# Test set/get by key. |
| 190 |
# Here we test if the key is an invalid utf8 string, |
| 191 |
# and if the key exceed the column length. |
| 192 |
perl; |
| 193 |
use DBI; |
| 194 |
use Cache::Memcached; |
| 195 |
my $memd = new Cache::Memcached { |
| 196 |
'servers' => [ "127.0.0.1:11216" ], |
| 197 |
'connect_timeout' => 20, |
| 198 |
'select_timeout' =>20 |
| 199 |
}; |
| 200 |
|
| 201 |
# Test for normal utf8 key. |
| 202 |
print "Here are the memcached results after set:\n"; |
| 203 |
$val = $memd->set("Ü","Ülzen|City|5|üöäßÜÖÄ|5678|2012"); |
| 204 |
$val = $memd->get("Ü"); |
| 205 |
if ($val) { print "$val\n"; } |
| 206 |
|
| 207 |
# Test for invalid utf8 key. |
| 208 |
# The key will be truncated from the invalid byte. |
| 209 |
$key = "\x5f\xee\x39\x67\x6d"; |
| 210 |
$val = $memd->set($key,"Beijing|City|6|fffffffff|6789|2012"); |
| 211 |
$key2 = "\x5f"; |
| 212 |
$val = $memd->get($key2); |
| 213 |
if ($val) { print "$val\n"; } |
| 214 |
|
| 215 |
# Test key with all invalid bytes, which result the truncated length is 0 |
| 216 |
# It will be truncated to a empty string, and inserted into the table. |
| 217 |
$key = "\xee\x5f\x39\x67\x6d"; |
| 218 |
$val = $memd->set($key,"Shanghai|City|7|fffffffff|7890|2012"); |
| 219 |
$key2 = "\xee\x5f\x39\x67\x6d"; |
| 220 |
$val = $memd->get($key2); |
| 221 |
if ($val) { print "$val\n"; } |
| 222 |
|
| 223 |
# Test key exceed the column length. |
| 224 |
# It will be truncated to column length, and inserted into the table. |
| 225 |
$val = $memd->set("0123456789012345678901234567890123456789","Wuhan|City|8|eeeeeeeee|8901|2012"); |
| 226 |
$val = $memd->get("01234567890123456789012345678901"); |
| 227 |
if ($val) { print "$val\n"; } |
| 228 |
|
| 229 |
$memd->disconnect_all; |
| 230 |
EOF |
| 231 |
|
| 232 |
--sorted_result |
| 233 |
SELECT c1,c2,c21,c22,c23,c24,c25 FROM t1; |
| 234 |
|
| 235 |
DROP TABLE t1; |
| 236 |
|
| 237 |
UNINSTALL PLUGIN daemon_memcached; |
| 238 |
DROP DATABASE innodb_memcache; |
| 239 |
|
| 240 |
SET @@global.transaction_isolation= @transaction_isolation; |