1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
--TEST--
PDO_MYSQL: check the session_connect_attrs table for connection attributes
--EXTENSIONS--
pdo_mysql
--SKIPIF--
<?php
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
MySQLPDOTest::skip();
if (!MySQLPDOTest::isPDOMySQLnd()) die('skip only for mysqlnd');
$pdo = MySQLPDOTest::factory();
$stmt = $pdo->query("select count(*) from information_schema.tables where table_schema='performance_schema' and table_name='session_connect_attrs'");
if (!$stmt || !$stmt->fetchColumn()) {
die("skip mysql does not support session_connect_attrs table yet");
}
$stmt = $pdo->query("show variables like 'performance_schema'");
if (!$stmt || $stmt->fetchColumn(1) !== 'ON') {
die("skip performance_schema is OFF");
}
?>
--FILE--
<?php
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
$pdo = MySQLPDOTest::factory();
if (preg_match('/host=([^;]+)/', PDO_MYSQL_TEST_DSN, $m)) {
$host = $m[1];
}
//in case $host is empty, do not test for _server_host field
if (isset($host) && $host !== '') {
$stmt = $pdo->query("select * from performance_schema.session_connect_attrs where ATTR_NAME='_server_host' and processlist_id = connection_id()");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$row || !isset($row['attr_name'])) {
echo "_server_host missing\n";
} elseif ($row['attr_value'] !== $host) {
printf("_server_host mismatch (expected '%s', got '%s')\n", $host, $row['attr_value']);
}
}
$stmt = $pdo->query("select * from performance_schema.session_connect_attrs where ATTR_NAME='_client_name' and processlist_id = connection_id()");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$row || !isset($row['attr_name'])) {
echo "_client_name missing\n";
} elseif ($row['attr_value'] !== 'mysqlnd') {
printf("_client_name mismatch (expected 'mysqlnd', got '%s')\n", $row['attr_value']);
}
printf("done!");
?>
--EXPECT--
done!
|