| 1 |
source include/not_valgrind.inc; |
| 2 |
source include/have_memcached_plugin.inc; |
| 3 |
source include/not_windows.inc; |
| 4 |
|
| 5 |
--disable_query_log |
| 6 |
CALL mtr.add_suppression("daemon-memcached-w-batch-size': unsigned"); |
| 7 |
CALL mtr.add_suppression("Could not obtain server's UPN to be used as target service name"); |
| 8 |
CALL mtr.add_suppression("Warning: MySQL is trying to drop"); |
| 9 |
--enable_query_log |
| 10 |
|
| 11 |
SET @transaction_isolation= @@global.transaction_isolation; |
| 12 |
SET GLOBAL TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; |
| 13 |
|
| 14 |
# Create the memcached tables |
| 15 |
--disable_query_log |
| 16 |
source include/memcache_config.inc; |
| 17 |
--enable_query_log |
| 18 |
|
| 19 |
INSERT INTO cache_policies VALUES("cache_policy", "cache_only", |
| 20 |
"innodb_only", "innodb_only", "innodb_only"); |
| 21 |
|
| 22 |
INSERT INTO config_options VALUES("separator", "|"); |
| 23 |
|
| 24 |
# describe table for memcache |
| 25 |
INSERT INTO containers VALUES ("desc_t1", "test", "t1", |
| 26 |
"c1", "c2", "c3", "c4", "c5", "PRIMARY"); |
| 27 |
|
| 28 |
USE test; |
| 29 |
|
| 30 |
CREATE TABLE t1 (c1 VARCHAR(32), |
| 31 |
c2 VARCHAR(1024), |
| 32 |
c3 INT, c4 BIGINT UNSIGNED, c5 INT, primary key(c1)) |
| 33 |
ENGINE = INNODB; |
| 34 |
|
| 35 |
INSERT INTO t1 VALUES ('D', 'Darmstadt', 0, 0, 0); |
| 36 |
INSERT INTO t1 VALUES ('B', 'Berlin', 0, 0, 0); |
| 37 |
INSERT INTO t1 VALUES ('C', 'Cottbus', 0, 0 ,0); |
| 38 |
INSERT INTO t1 VALUES ('H', 'Hamburg', 0, 0, 0); |
| 39 |
|
| 40 |
# Tables must exist before plugin can be started! |
| 41 |
--let $memcached_address=127.0.0.1:11247 |
| 42 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 43 |
|
| 44 |
# ---------------------------------------------------------------- |
| 45 |
# Test the "cache_only" get |
| 46 |
# |
| 47 |
# get - cache_only |
| 48 |
# set - innodb_only |
| 49 |
# delete - innodb_only |
| 50 |
# ---------------------------------------------------------------- |
| 51 |
|
| 52 |
--sorted_result |
| 53 |
SELECT c1,c2 FROM t1; |
| 54 |
|
| 55 |
# Since "get" are cache_only, it is not going to fetch any rows |
| 56 |
perl; |
| 57 |
use DBI; |
| 58 |
use Cache::Memcached; |
| 59 |
print "----- Test get (cache_only) -----\n"; |
| 60 |
my $memd = new Cache::Memcached { |
| 61 |
'servers' => [ "127.0.0.1:11247" ], |
| 62 |
'connect_timeout' => 20, |
| 63 |
'select_timeout' => 20 |
| 64 |
}; |
| 65 |
print "Here are the memcached results with D,B,H,C:\n"; |
| 66 |
$val = $memd->get("D"); |
| 67 |
if ($val) { print "$val\n"; } |
| 68 |
$val = $memd->get("B"); |
| 69 |
if ($val) { print "$val\n"; } |
| 70 |
$val = $memd->get("H"); |
| 71 |
if ($val) { print "$val\n"; } |
| 72 |
$val = $memd->get("C"); |
| 73 |
if ($val) { print "$val\n"; } |
| 74 |
$memd->disconnect_all; |
| 75 |
EOF |
| 76 |
|
| 77 |
--sorted_result |
| 78 |
SELECT c1,c2 FROM t1; |
| 79 |
|
| 80 |
perl; |
| 81 |
use DBI; |
| 82 |
use Cache::Memcached; |
| 83 |
my $memd = new Cache::Memcached { |
| 84 |
'servers' => [ "127.0.0.1:11247" ], |
| 85 |
'connect_timeout' => 20, |
| 86 |
'select_timeout' => 20 |
| 87 |
}; |
| 88 |
print "Here are the memcached results with B:\n"; |
| 89 |
$val = $memd->get("B"); |
| 90 |
if ($val) { print "$val\n"; } |
| 91 |
$memd->disconnect_all; |
| 92 |
EOF |
| 93 |
|
| 94 |
--sorted_result |
| 95 |
SELECT c1,c2 FROM t1; |
| 96 |
|
| 97 |
perl; |
| 98 |
use DBI; |
| 99 |
use Cache::Memcached; |
| 100 |
my $memd = new Cache::Memcached { |
| 101 |
'servers' => [ "127.0.0.1:11247" ], |
| 102 |
'connect_timeout' => 20, |
| 103 |
'select_timeout' => 20 |
| 104 |
}; |
| 105 |
print "Here are the memcached results with D,H:\n"; |
| 106 |
$val = $memd->get("D"); |
| 107 |
if ($val) { print "$val\n"; } |
| 108 |
$val = $memd->get("H"); |
| 109 |
if ($val) { print "$val\n"; } |
| 110 |
$memd->disconnect_all; |
| 111 |
EOF |
| 112 |
|
| 113 |
# ---------------------------------------------------------------- |
| 114 |
# Test the "caching" get, which fetch data from disk if they are |
| 115 |
# not in cache |
| 116 |
# |
| 117 |
# get - caching |
| 118 |
# set - innodb_only |
| 119 |
# delete - innodb_only |
| 120 |
# ---------------------------------------------------------------- |
| 121 |
|
| 122 |
# Stop plugin before innodb_memcached configuration |
| 123 |
UNINSTALL PLUGIN daemon_memcached; |
| 124 |
|
| 125 |
use innodb_memcache; |
| 126 |
|
| 127 |
DELETE FROM cache_policies; |
| 128 |
|
| 129 |
INSERT INTO cache_policies VALUES("cache_policy", "caching", |
| 130 |
"innodb_only", "innodb_only", "innodb_only"); |
| 131 |
|
| 132 |
--let $memcached_address=127.0.0.1:11247 |
| 133 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 134 |
|
| 135 |
# Since "get" is now "caching", it will fetch data from disk if not in cache |
| 136 |
perl; |
| 137 |
use DBI; |
| 138 |
use Cache::Memcached; |
| 139 |
print "----- Test get (caching) -----\n"; |
| 140 |
|
| 141 |
my $memd = new Cache::Memcached { |
| 142 |
'servers' => [ "127.0.0.1:11247" ], |
| 143 |
'connect_timeout' => 20, |
| 144 |
'select_timeout' => 20 |
| 145 |
}; |
| 146 |
print "Here are the memcached results with D,B,H,C:\n"; |
| 147 |
$val = $memd->get("D"); |
| 148 |
if ($val) { print "$val\n"; } |
| 149 |
$val = $memd->get("B"); |
| 150 |
if ($val) { print "$val\n"; } |
| 151 |
$val = $memd->get("H"); |
| 152 |
if ($val) { print "$val\n"; } |
| 153 |
$val = $memd->get("C"); |
| 154 |
if ($val) { print "$val\n"; } |
| 155 |
$memd->disconnect_all; |
| 156 |
EOF |
| 157 |
|
| 158 |
# ---------------------------------------------------------------- |
| 159 |
# Now let's make the "insert" operation also cache_only, so the |
| 160 |
# configuration is |
| 161 |
# |
| 162 |
# get - cache_only |
| 163 |
# set - cache_only |
| 164 |
# delete - innodb_only |
| 165 |
# ---------------------------------------------------------------- |
| 166 |
# Stop plugin before innodb_memcached configuration |
| 167 |
|
| 168 |
UNINSTALL PLUGIN daemon_memcached; |
| 169 |
|
| 170 |
use innodb_memcache; |
| 171 |
|
| 172 |
DELETE FROM cache_policies; |
| 173 |
|
| 174 |
INSERT INTO cache_policies VALUES("cache_policy", "cache_only", |
| 175 |
"cache_only", "innodb_only", "innodb_only"); |
| 176 |
|
| 177 |
--let $memcached_address=127.0.0.1:11247 |
| 178 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 179 |
|
| 180 |
perl; |
| 181 |
use DBI; |
| 182 |
use Cache::Memcached; |
| 183 |
print "----- Test insert (cache_only) -----\n"; |
| 184 |
|
| 185 |
my $memd = new Cache::Memcached { |
| 186 |
'servers' => [ "127.0.0.1:11247" ], |
| 187 |
'connect_timeout' => 20, |
| 188 |
'select_timeout' => 20 |
| 189 |
}; |
| 190 |
print "Add E|Essen:\n"; |
| 191 |
if ($memd->add("E","Essen")) { |
| 192 |
print "Ok.\n"; |
| 193 |
} |
| 194 |
else { |
| 195 |
print "Error: fail to add.\n"; |
| 196 |
} |
| 197 |
$memd->disconnect_all; |
| 198 |
EOF |
| 199 |
|
| 200 |
--sorted_result |
| 201 |
use test; |
| 202 |
SELECT c1,c2 FROM t1; |
| 203 |
|
| 204 |
perl; |
| 205 |
use DBI; |
| 206 |
use Cache::Memcached; |
| 207 |
my $memd = new Cache::Memcached { |
| 208 |
'servers' => [ "127.0.0.1:11247" ], |
| 209 |
'connect_timeout' => 20, |
| 210 |
'select_timeout' => 20 |
| 211 |
}; |
| 212 |
print "Here are the memcached results with E:\n"; |
| 213 |
$val = $memd->get("E"); |
| 214 |
if ($val) { print "$val\n"; } |
| 215 |
$memd->disconnect_all; |
| 216 |
EOF |
| 217 |
|
| 218 |
perl; |
| 219 |
use DBI; |
| 220 |
use Cache::Memcached; |
| 221 |
my $memd = new Cache::Memcached { |
| 222 |
'servers' => [ "127.0.0.1:11247" ], |
| 223 |
'connect_timeout' => 20, |
| 224 |
'select_timeout' => 20 |
| 225 |
}; |
| 226 |
print "Set P|Paris:\n"; |
| 227 |
if ($memd->set("P","Paris", 60)) { |
| 228 |
print "Ok.\n"; |
| 229 |
} |
| 230 |
else { |
| 231 |
print "Error: fail to set.\n"; |
| 232 |
} |
| 233 |
print "Here are the memcached results with P:\n"; |
| 234 |
$val = $memd->get("P"); |
| 235 |
if ($val) { print "$val\n"; } |
| 236 |
$memd->disconnect_all; |
| 237 |
EOF |
| 238 |
|
| 239 |
# ---------------------------------------------------------------- |
| 240 |
# Now let's make the "insert" operation also "caching", so |
| 241 |
# get - caching |
| 242 |
# set - caching |
| 243 |
# delete - innodb_only |
| 244 |
# ---------------------------------------------------------------- |
| 245 |
# Stop plugin before innodb_memcached configuration |
| 246 |
|
| 247 |
UNINSTALL PLUGIN daemon_memcached; |
| 248 |
|
| 249 |
use innodb_memcache; |
| 250 |
|
| 251 |
DELETE FROM cache_policies; |
| 252 |
|
| 253 |
INSERT INTO cache_policies VALUES("cache_policy", "caching", |
| 254 |
"caching", "innodb_only", "innodb_only"); |
| 255 |
|
| 256 |
--let $memcached_address=127.0.0.1:11247 |
| 257 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 258 |
|
| 259 |
perl; |
| 260 |
use DBI; |
| 261 |
use Cache::Memcached; |
| 262 |
print "----- Test insert (caching) -----\n"; |
| 263 |
|
| 264 |
my $memd = new Cache::Memcached { |
| 265 |
'servers' => [ "127.0.0.1:11247" ], |
| 266 |
'connect_timeout' => 20, |
| 267 |
'select_timeout' => 20 |
| 268 |
}; |
| 269 |
print "Add G|Gossen:\n"; |
| 270 |
if ($memd->add("G","Gossen")) { |
| 271 |
print "Ok.\n"; |
| 272 |
} |
| 273 |
else { |
| 274 |
print "Error: fail to add.\n"; |
| 275 |
} |
| 276 |
$memd->disconnect_all; |
| 277 |
EOF |
| 278 |
|
| 279 |
--sorted_result |
| 280 |
use test; |
| 281 |
SELECT c1,c2 FROM t1; |
| 282 |
|
| 283 |
perl; |
| 284 |
use DBI; |
| 285 |
use Cache::Memcached; |
| 286 |
my $memd = new Cache::Memcached { |
| 287 |
'servers' => [ "127.0.0.1:11247" ], |
| 288 |
'connect_timeout' => 20, |
| 289 |
'select_timeout' => 20 |
| 290 |
}; |
| 291 |
print "Here are the memcached results with G:\n"; |
| 292 |
$val = $memd->get("G"); |
| 293 |
if ($val) { print "$val\n"; } |
| 294 |
$memd->disconnect_all; |
| 295 |
EOF |
| 296 |
|
| 297 |
# delete will only delete the InnoDB record, cache record still exists |
| 298 |
perl; |
| 299 |
use DBI; |
| 300 |
use Cache::Memcached; |
| 301 |
my $memd = new Cache::Memcached { |
| 302 |
'servers' => [ "127.0.0.1:11247" ], |
| 303 |
'connect_timeout' => 20, |
| 304 |
'select_timeout' => 20 |
| 305 |
}; |
| 306 |
print "Delete G|Gossen:\n"; |
| 307 |
if ($memd->delete("G")) { |
| 308 |
print "Ok.\n"; |
| 309 |
} |
| 310 |
else { |
| 311 |
print "Error: G|Gossen doesn't exist.\n"; |
| 312 |
} |
| 313 |
$memd->disconnect_all; |
| 314 |
EOF |
| 315 |
|
| 316 |
--sorted_result |
| 317 |
SELECT c1,c2 FROM test.t1; |
| 318 |
|
| 319 |
perl; |
| 320 |
use DBI; |
| 321 |
use Cache::Memcached; |
| 322 |
my $memd = new Cache::Memcached { |
| 323 |
'servers' => [ "127.0.0.1:11247" ], |
| 324 |
'connect_timeout' => 20, |
| 325 |
'select_timeout' => 20 |
| 326 |
}; |
| 327 |
print "Here are the memcached results with G:\n"; |
| 328 |
$val = $memd->get("G"); |
| 329 |
if ($val) { print "$val\n"; } |
| 330 |
$memd->disconnect_all; |
| 331 |
EOF |
| 332 |
|
| 333 |
# ---------------------------------------------------------------- |
| 334 |
# Configure the "delete" operation to "cache_only", so overall |
| 335 |
# configuration would be: |
| 336 |
# get - caching |
| 337 |
# set - caching |
| 338 |
# delete - cache_only |
| 339 |
# ---------------------------------------------------------------- |
| 340 |
# Stop plugin before innodb_memcached configuration |
| 341 |
|
| 342 |
UNINSTALL PLUGIN daemon_memcached; |
| 343 |
|
| 344 |
use innodb_memcache; |
| 345 |
|
| 346 |
DELETE FROM cache_policies; |
| 347 |
|
| 348 |
INSERT INTO cache_policies VALUES("cache_policy", "caching", |
| 349 |
"caching", "cache_only", "innodb_only"); |
| 350 |
|
| 351 |
--let $memcached_address=127.0.0.1:11247 |
| 352 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 353 |
|
| 354 |
perl; |
| 355 |
use DBI; |
| 356 |
use Cache::Memcached; |
| 357 |
print "----- Test delete (cache_only) -----\n"; |
| 358 |
|
| 359 |
my $memd = new Cache::Memcached { |
| 360 |
'servers' => [ "127.0.0.1:11247" ], |
| 361 |
'connect_timeout' => 20, |
| 362 |
'select_timeout' => 20 |
| 363 |
}; |
| 364 |
print "Delete G|Gossen:\n"; |
| 365 |
if ($memd->delete("G","Gossen")) { |
| 366 |
print "Ok.\n"; |
| 367 |
} |
| 368 |
else { |
| 369 |
print "Error: fail to delete.\n"; |
| 370 |
} |
| 371 |
$memd->disconnect_all; |
| 372 |
EOF |
| 373 |
|
| 374 |
--sorted_result |
| 375 |
use test; |
| 376 |
SELECT c1,c2 FROM t1; |
| 377 |
|
| 378 |
perl; |
| 379 |
use DBI; |
| 380 |
use Cache::Memcached; |
| 381 |
my $memd = new Cache::Memcached { |
| 382 |
'servers' => [ "127.0.0.1:11247" ], |
| 383 |
'connect_timeout' => 20, |
| 384 |
'select_timeout' => 20 |
| 385 |
}; |
| 386 |
print "Here are the memcached results with G:\n"; |
| 387 |
$val = $memd->get("G"); |
| 388 |
if ($val) { print "$val\n"; } |
| 389 |
$memd->disconnect_all; |
| 390 |
EOF |
| 391 |
|
| 392 |
# delete will only delete the cache record, InnoDB record still exists |
| 393 |
perl; |
| 394 |
use DBI; |
| 395 |
use Cache::Memcached; |
| 396 |
my $memd = new Cache::Memcached { |
| 397 |
'servers' => [ "127.0.0.1:11247" ], |
| 398 |
'connect_timeout' => 20, |
| 399 |
'select_timeout' => 20 |
| 400 |
}; |
| 401 |
print "Delete E|Essen:\n"; |
| 402 |
if ($memd->delete("E")) { |
| 403 |
print "Ok.\n"; |
| 404 |
} |
| 405 |
else { |
| 406 |
print "Error: E|Essen doesn't exist.\n"; |
| 407 |
} |
| 408 |
$memd->disconnect_all; |
| 409 |
EOF |
| 410 |
|
| 411 |
--sorted_result |
| 412 |
SELECT c1,c2 FROM test.t1; |
| 413 |
|
| 414 |
perl; |
| 415 |
use DBI; |
| 416 |
use Cache::Memcached; |
| 417 |
my $memd = new Cache::Memcached { |
| 418 |
'servers' => [ "127.0.0.1:11247" ], |
| 419 |
'connect_timeout' => 20, |
| 420 |
'select_timeout' => 20 |
| 421 |
}; |
| 422 |
print "Here are the memcached results with E:\n"; |
| 423 |
$val = $memd->get("E"); |
| 424 |
if ($val) { print "$val\n"; } |
| 425 |
$memd->disconnect_all; |
| 426 |
EOF |
| 427 |
|
| 428 |
# ---------------------------------------------------------------- |
| 429 |
# Configure the "delete" operation to "caching", so the overall |
| 430 |
# configuration is: |
| 431 |
# |
| 432 |
# get - caching |
| 433 |
# set - caching |
| 434 |
# delete - caching |
| 435 |
# ---------------------------------------------------------------- |
| 436 |
# Stop plugin before innodb_memcached configuration |
| 437 |
|
| 438 |
UNINSTALL PLUGIN daemon_memcached; |
| 439 |
|
| 440 |
use innodb_memcache; |
| 441 |
|
| 442 |
DELETE FROM cache_policies; |
| 443 |
|
| 444 |
INSERT INTO cache_policies VALUES("cache_policy", "caching", |
| 445 |
"caching", "caching", "innodb_only"); |
| 446 |
|
| 447 |
--let $memcached_address=127.0.0.1:11247 |
| 448 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 449 |
|
| 450 |
perl; |
| 451 |
use DBI; |
| 452 |
use Cache::Memcached; |
| 453 |
print "----- Test delete (caching) -----\n"; |
| 454 |
|
| 455 |
my $memd = new Cache::Memcached { |
| 456 |
'servers' => [ "127.0.0.1:11247" ], |
| 457 |
'connect_timeout' => 20, |
| 458 |
'select_timeout' => 20 |
| 459 |
}; |
| 460 |
print "add G|Gossen:\n"; |
| 461 |
if ($memd->add("G","Gossen")) { |
| 462 |
print "Ok.\n"; |
| 463 |
} |
| 464 |
else { |
| 465 |
print "Error: fail to add.\n"; |
| 466 |
} |
| 467 |
$memd->disconnect_all; |
| 468 |
EOF |
| 469 |
|
| 470 |
--sorted_result |
| 471 |
use test; |
| 472 |
SELECT c1,c2 FROM t1; |
| 473 |
|
| 474 |
perl; |
| 475 |
use DBI; |
| 476 |
use Cache::Memcached; |
| 477 |
my $memd = new Cache::Memcached { |
| 478 |
'servers' => [ "127.0.0.1:11247" ], |
| 479 |
'connect_timeout' => 20, |
| 480 |
'select_timeout' => 20 |
| 481 |
}; |
| 482 |
print "Here are the memcached results with G:\n"; |
| 483 |
$val = $memd->get("G"); |
| 484 |
if ($val) { print "$val\n"; } |
| 485 |
$memd->disconnect_all; |
| 486 |
EOF |
| 487 |
|
| 488 |
# delete will only delete the InnoDB record, cache record still exists |
| 489 |
perl; |
| 490 |
use DBI; |
| 491 |
use Cache::Memcached; |
| 492 |
my $memd = new Cache::Memcached { |
| 493 |
'servers' => [ "127.0.0.1:11247" ], |
| 494 |
'connect_timeout' => 20, |
| 495 |
'select_timeout' => 20 |
| 496 |
}; |
| 497 |
print "Delete G|Gossen:\n"; |
| 498 |
if ($memd->delete("G")) { |
| 499 |
print "Ok.\n"; |
| 500 |
} |
| 501 |
else { |
| 502 |
print "Error: G|Gossen doesn't exist.\n"; |
| 503 |
} |
| 504 |
$memd->disconnect_all; |
| 505 |
EOF |
| 506 |
|
| 507 |
--sorted_result |
| 508 |
SELECT c1,c2 FROM test.t1; |
| 509 |
|
| 510 |
perl; |
| 511 |
use DBI; |
| 512 |
use Cache::Memcached; |
| 513 |
my $memd = new Cache::Memcached { |
| 514 |
'servers' => [ "127.0.0.1:11247" ], |
| 515 |
'connect_timeout' => 20, |
| 516 |
'select_timeout' => 20 |
| 517 |
}; |
| 518 |
print "Here are the memcached results with G:\n"; |
| 519 |
$val = $memd->get("G"); |
| 520 |
if ($val) { print "$val\n"; } |
| 521 |
$memd->disconnect_all; |
| 522 |
EOF |
| 523 |
|
| 524 |
# ---------------------------------------------------------------- |
| 525 |
# Configure the "flush" operation to "cache_only", so the overall |
| 526 |
# configuration is: |
| 527 |
# |
| 528 |
# get - cache_only (for testing flush's cache_only) |
| 529 |
# set - caching |
| 530 |
# delete - caching |
| 531 |
# flush - cache_only |
| 532 |
# ---------------------------------------------------------------- |
| 533 |
# Stop plugin before innodb_memcached configuration |
| 534 |
|
| 535 |
UNINSTALL PLUGIN daemon_memcached; |
| 536 |
|
| 537 |
use innodb_memcache; |
| 538 |
|
| 539 |
DELETE FROM cache_policies; |
| 540 |
|
| 541 |
INSERT INTO cache_policies VALUES("cache_policy", "cache_only", |
| 542 |
"caching", "cache_only", "cache_only"); |
| 543 |
|
| 544 |
--let $memcached_address=127.0.0.1:11247 |
| 545 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 546 |
|
| 547 |
perl; |
| 548 |
use DBI; |
| 549 |
use Cache::Memcached; |
| 550 |
print "----- Test flush (cache_only) -----\n"; |
| 551 |
|
| 552 |
my $memd = new Cache::Memcached { |
| 553 |
'servers' => [ "127.0.0.1:11247" ], |
| 554 |
'connect_timeout' => 20, |
| 555 |
'select_timeout' => 20 |
| 556 |
}; |
| 557 |
print "add G|Gossen:\n"; |
| 558 |
if ($memd->add("G","Gossen")) { |
| 559 |
print "Ok.\n"; |
| 560 |
} |
| 561 |
else { |
| 562 |
print "Error: fail to add.\n"; |
| 563 |
} |
| 564 |
$memd->disconnect_all; |
| 565 |
EOF |
| 566 |
|
| 567 |
--sorted_result |
| 568 |
use test; |
| 569 |
SELECT c1,c2 FROM t1; |
| 570 |
|
| 571 |
perl; |
| 572 |
use DBI; |
| 573 |
use Cache::Memcached; |
| 574 |
my $memd = new Cache::Memcached { |
| 575 |
'servers' => [ "127.0.0.1:11247" ], |
| 576 |
'connect_timeout' => 20, |
| 577 |
'select_timeout' => 20 |
| 578 |
}; |
| 579 |
print "Here are the memcached results with G:\n"; |
| 580 |
$val = $memd->get("G"); |
| 581 |
if ($val) { print "$val\n"; } |
| 582 |
$memd->disconnect_all; |
| 583 |
EOF |
| 584 |
|
| 585 |
--sorted_result |
| 586 |
SELECT c1,c2 FROM test.t1; |
| 587 |
|
| 588 |
perl; |
| 589 |
use DBI; |
| 590 |
use Cache::Memcached; |
| 591 |
my $memd = new Cache::Memcached { |
| 592 |
'servers' => [ "127.0.0.1:11247" ], |
| 593 |
'connect_timeout' => 20, |
| 594 |
'select_timeout' => 20 |
| 595 |
}; |
| 596 |
print "Here are the memcached results after flush_all:\n"; |
| 597 |
$memd->flush_all; |
| 598 |
$val = $memd->get("G"); |
| 599 |
if ($val) { print "$val\n"; } |
| 600 |
$memd->disconnect_all; |
| 601 |
EOF |
| 602 |
|
| 603 |
# Row should still in the database (only cache is flushed) |
| 604 |
--sorted_result |
| 605 |
SELECT c1,c2 FROM test.t1; |
| 606 |
|
| 607 |
perl; |
| 608 |
use DBI; |
| 609 |
use Cache::Memcached; |
| 610 |
my $memd = new Cache::Memcached { |
| 611 |
'servers' => [ "127.0.0.1:11247" ], |
| 612 |
'connect_timeout' => 20, |
| 613 |
'select_timeout' => 20 |
| 614 |
}; |
| 615 |
print "Here are the memcached results with G:\n"; |
| 616 |
$val = $memd->get("G"); |
| 617 |
if ($val) { print "$val\n"; } |
| 618 |
$memd->disconnect_all; |
| 619 |
EOF |
| 620 |
|
| 621 |
# ---------------------------------------------------------------- |
| 622 |
# Configure the "flush" operation to "caching", so the overall |
| 623 |
# configuration is: |
| 624 |
# |
| 625 |
# get - caching (for testing flush's cache_only) |
| 626 |
# set - caching |
| 627 |
# delete - caching |
| 628 |
# flush - caching |
| 629 |
# ---------------------------------------------------------------- |
| 630 |
# Stop plugin before innodb_memcached configuration |
| 631 |
|
| 632 |
UNINSTALL PLUGIN daemon_memcached; |
| 633 |
|
| 634 |
use innodb_memcache; |
| 635 |
|
| 636 |
DELETE FROM cache_policies; |
| 637 |
|
| 638 |
INSERT INTO cache_policies VALUES("cache_policy", "caching", |
| 639 |
"caching", "caching", "caching"); |
| 640 |
|
| 641 |
--let $memcached_address=127.0.0.1:11247 |
| 642 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 643 |
|
| 644 |
perl; |
| 645 |
use DBI; |
| 646 |
use Cache::Memcached; |
| 647 |
print "----- Test flush (cache_only) -----\n"; |
| 648 |
|
| 649 |
my $memd = new Cache::Memcached { |
| 650 |
'servers' => [ "127.0.0.1:11247" ], |
| 651 |
'connect_timeout' => 20, |
| 652 |
'select_timeout' => 20 |
| 653 |
}; |
| 654 |
print "add G|Gossen:\n"; |
| 655 |
if ($memd->add("G","Gossen")) { |
| 656 |
print "Ok.\n"; |
| 657 |
} |
| 658 |
else { |
| 659 |
print "Error: fail to add.\n"; |
| 660 |
} |
| 661 |
$memd->disconnect_all; |
| 662 |
EOF |
| 663 |
|
| 664 |
--sorted_result |
| 665 |
use test; |
| 666 |
SELECT c1,c2 FROM t1; |
| 667 |
|
| 668 |
perl; |
| 669 |
use DBI; |
| 670 |
use Cache::Memcached; |
| 671 |
my $memd = new Cache::Memcached { |
| 672 |
'servers' => [ "127.0.0.1:11247" ], |
| 673 |
'connect_timeout' => 20, |
| 674 |
'select_timeout' => 20 |
| 675 |
}; |
| 676 |
print "Here are the memcached results with G:\n"; |
| 677 |
$val = $memd->get("G"); |
| 678 |
if ($val) { print "$val\n"; } |
| 679 |
$memd->disconnect_all; |
| 680 |
EOF |
| 681 |
|
| 682 |
--sorted_result |
| 683 |
SELECT c1,c2 FROM test.t1; |
| 684 |
|
| 685 |
perl; |
| 686 |
use DBI; |
| 687 |
use Cache::Memcached; |
| 688 |
my $memd = new Cache::Memcached { |
| 689 |
'servers' => [ "127.0.0.1:11247" ], |
| 690 |
'connect_timeout' => 20, |
| 691 |
'select_timeout' => 20 |
| 692 |
}; |
| 693 |
print "Here are the memcached results after flush_all:\n"; |
| 694 |
$memd->flush_all; |
| 695 |
$val = $memd->get("G"); |
| 696 |
if ($val) { print "$val\n"; } |
| 697 |
$memd->disconnect_all; |
| 698 |
EOF |
| 699 |
|
| 700 |
# Rows should be deleted from the InnoDB table |
| 701 |
--sorted_result |
| 702 |
SELECT c1,c2 FROM test.t1; |
| 703 |
|
| 704 |
perl; |
| 705 |
use DBI; |
| 706 |
use Cache::Memcached; |
| 707 |
my $memd = new Cache::Memcached { |
| 708 |
'servers' => [ "127.0.0.1:11247" ], |
| 709 |
'connect_timeout' => 20, |
| 710 |
'select_timeout' => 20 |
| 711 |
}; |
| 712 |
print "Here are the memcached results with G:\n"; |
| 713 |
$val = $memd->get("G"); |
| 714 |
if ($val) { print "$val\n"; } |
| 715 |
$memd->disconnect_all; |
| 716 |
EOF |
| 717 |
|
| 718 |
# ---------------------------------------------------------------- |
| 719 |
# Configure the operation to "disabled", so the overall |
| 720 |
# configuration is: |
| 721 |
# |
| 722 |
# get - disabled |
| 723 |
# set - disabled |
| 724 |
# delete - disabled |
| 725 |
# flush - disabled |
| 726 |
# ---------------------------------------------------------------- |
| 727 |
# Stop plugin before innodb_memcached configuration |
| 728 |
|
| 729 |
UNINSTALL PLUGIN daemon_memcached; |
| 730 |
|
| 731 |
use innodb_memcache; |
| 732 |
|
| 733 |
DELETE FROM cache_policies; |
| 734 |
|
| 735 |
INSERT INTO cache_policies VALUES("cache_policy", "caching", |
| 736 |
"disabled", "disabled", "disabled"); |
| 737 |
|
| 738 |
--let $memcached_address=127.0.0.1:11247 |
| 739 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 740 |
|
| 741 |
# Add some rows |
| 742 |
--sorted_result |
| 743 |
use test; |
| 744 |
|
| 745 |
delete from t1; |
| 746 |
|
| 747 |
INSERT INTO t1 VALUES ('D', 'Darmstadt', 0, 0, 0); |
| 748 |
INSERT INTO t1 VALUES ('B', 'Berlin', 0, 0, 0); |
| 749 |
INSERT INTO t1 VALUES ('C', 'Cottbus', 0, 0 ,0); |
| 750 |
INSERT INTO t1 VALUES ('H', 'Hamburg', 0, 0, 0); |
| 751 |
|
| 752 |
perl; |
| 753 |
use DBI; |
| 754 |
use Cache::Memcached; |
| 755 |
print "----- Test all operations disabled -----\n"; |
| 756 |
|
| 757 |
my $memd = new Cache::Memcached { |
| 758 |
'servers' => [ "127.0.0.1:11247" ], |
| 759 |
'connect_timeout' => 20, |
| 760 |
'select_timeout' => 20 |
| 761 |
}; |
| 762 |
print "add G|Gossen:\n"; |
| 763 |
if ($memd->add("G","Gossen")) { |
| 764 |
print "Ok.\n"; |
| 765 |
} |
| 766 |
else { |
| 767 |
print "Error: fail to add.\n"; |
| 768 |
} |
| 769 |
$memd->disconnect_all; |
| 770 |
EOF |
| 771 |
|
| 772 |
--sorted_result |
| 773 |
use test; |
| 774 |
SELECT c1,c2 FROM t1; |
| 775 |
|
| 776 |
perl; |
| 777 |
use DBI; |
| 778 |
use Cache::Memcached; |
| 779 |
my $memd = new Cache::Memcached { |
| 780 |
'servers' => [ "127.0.0.1:11247" ], |
| 781 |
'connect_timeout' => 20, |
| 782 |
'select_timeout' => 20 |
| 783 |
}; |
| 784 |
print "Here are the memcached results with G:\n"; |
| 785 |
$val = $memd->get("G"); |
| 786 |
if ($val) { print "$val\n"; } |
| 787 |
$memd->disconnect_all; |
| 788 |
EOF |
| 789 |
|
| 790 |
--sorted_result |
| 791 |
SELECT c1,c2 FROM test.t1; |
| 792 |
|
| 793 |
perl; |
| 794 |
use DBI; |
| 795 |
use Cache::Memcached; |
| 796 |
my $memd = new Cache::Memcached { |
| 797 |
'servers' => [ "127.0.0.1:11247" ], |
| 798 |
'connect_timeout' => 20, |
| 799 |
'select_timeout' => 20 |
| 800 |
}; |
| 801 |
print "Here are the memcached results after flush_all:\n"; |
| 802 |
$memd->flush_all; |
| 803 |
$val = $memd->get("G"); |
| 804 |
if ($val) { print "$val\n"; } |
| 805 |
$memd->disconnect_all; |
| 806 |
EOF |
| 807 |
|
| 808 |
# Rows should be deleted from the InnoDB table |
| 809 |
--sorted_result |
| 810 |
SELECT c1,c2 FROM test.t1; |
| 811 |
|
| 812 |
perl; |
| 813 |
use DBI; |
| 814 |
use Cache::Memcached; |
| 815 |
my $memd = new Cache::Memcached { |
| 816 |
'servers' => [ "127.0.0.1:11247" ], |
| 817 |
'connect_timeout' => 20, |
| 818 |
'select_timeout' => 20 |
| 819 |
}; |
| 820 |
print "Here are the memcached results with G:\n"; |
| 821 |
$val = $memd->get("G"); |
| 822 |
if ($val) { print "$val\n"; } |
| 823 |
$memd->disconnect_all; |
| 824 |
EOF |
| 825 |
|
| 826 |
# ---------------------------------------------------------------- |
| 827 |
# Negative test, insert "junk" value to cache_policies |
| 828 |
# |
| 829 |
# ---------------------------------------------------------------- |
| 830 |
# Stop plugin before innodb_memcached configuration |
| 831 |
|
| 832 |
UNINSTALL PLUGIN daemon_memcached; |
| 833 |
|
| 834 |
use innodb_memcache; |
| 835 |
|
| 836 |
DELETE FROM cache_policies; |
| 837 |
|
| 838 |
INSERT IGNORE INTO cache_policies VALUES("junk", "junk", |
| 839 |
"caching", "cache_only", "disabled"); |
| 840 |
|
| 841 |
--let $memcached_address=127.0.0.1:11247 |
| 842 |
--source ../include/load_daemon_memcached_expecting_success.inc |
| 843 |
|
| 844 |
perl; |
| 845 |
use DBI; |
| 846 |
use Cache::Memcached; |
| 847 |
print "----- Test with wrong policy name -----\n"; |
| 848 |
|
| 849 |
my $memd = new Cache::Memcached { |
| 850 |
'servers' => [ "127.0.0.1:11247" ], |
| 851 |
'connect_timeout' => 20, |
| 852 |
'select_timeout' => 20 |
| 853 |
}; |
| 854 |
print "add G|Gossen:\n"; |
| 855 |
if ($memd->add("G","Gossen")) { |
| 856 |
print "Ok.\n"; |
| 857 |
} |
| 858 |
else { |
| 859 |
print "Error: fail to add.\n"; |
| 860 |
} |
| 861 |
$memd->disconnect_all; |
| 862 |
EOF |
| 863 |
|
| 864 |
--sorted_result |
| 865 |
use test; |
| 866 |
SELECT c1,c2 FROM t1; |
| 867 |
|
| 868 |
perl; |
| 869 |
use DBI; |
| 870 |
use Cache::Memcached; |
| 871 |
my $memd = new Cache::Memcached { |
| 872 |
'servers' => [ "127.0.0.1:11247" ], |
| 873 |
'connect_timeout' => 20, |
| 874 |
'select_timeout' => 20 |
| 875 |
}; |
| 876 |
print "Here are the memcached results with G:\n"; |
| 877 |
$val = $memd->get("G"); |
| 878 |
if ($val) { print "$val\n"; } |
| 879 |
$memd->disconnect_all; |
| 880 |
EOF |
| 881 |
|
| 882 |
--sorted_result |
| 883 |
SELECT c1,c2 FROM test.t1; |
| 884 |
|
| 885 |
perl; |
| 886 |
use DBI; |
| 887 |
use Cache::Memcached; |
| 888 |
my $memd = new Cache::Memcached { |
| 889 |
'servers' => [ "127.0.0.1:11247" ], |
| 890 |
'connect_timeout' => 20, |
| 891 |
'select_timeout' => 20 |
| 892 |
}; |
| 893 |
print "Here are the memcached results after flush_all (flush disabled):\n"; |
| 894 |
$memd->flush_all; |
| 895 |
$val = $memd->get("G"); |
| 896 |
if ($val) { print "$val\n"; } |
| 897 |
$memd->disconnect_all; |
| 898 |
EOF |
| 899 |
|
| 900 |
# Rows should be deleted from the InnoDB table |
| 901 |
--sorted_result |
| 902 |
SELECT c1,c2 FROM test.t1; |
| 903 |
|
| 904 |
perl; |
| 905 |
use DBI; |
| 906 |
use Cache::Memcached; |
| 907 |
my $memd = new Cache::Memcached { |
| 908 |
'servers' => [ "127.0.0.1:11247" ], |
| 909 |
'connect_timeout' => 20, |
| 910 |
'select_timeout' => 20 |
| 911 |
}; |
| 912 |
print "Here are the memcached results with G:\n"; |
| 913 |
$val = $memd->get("G"); |
| 914 |
if ($val) { print "$val\n"; } |
| 915 |
$memd->disconnect_all; |
| 916 |
EOF |
| 917 |
|
| 918 |
USE test; |
| 919 |
DROP TABLE t1; |
| 920 |
|
| 921 |
UNINSTALL PLUGIN daemon_memcached; |
| 922 |
DROP DATABASE innodb_memcache; |
| 923 |
|
| 924 |
SET @@global.transaction_isolation= @transaction_isolation; |