mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
Allow setting of default connection flags through the environment variable MYSQL_TEST_CONNECT_FLAGS
This commit is contained in:
parent
5edef9d2dd
commit
fbfd13310b
2 changed files with 7 additions and 3 deletions
|
@ -20,14 +20,17 @@ if (!function_exists('sys_get_temp_dir')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wrapper to simplify test porting */
|
/* wrapper to simplify test porting */
|
||||||
function my_mysql_connect($host, $user, $passwd, $db, $port, $socket) {
|
function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL) {
|
||||||
|
global $connect_flags;
|
||||||
|
|
||||||
|
$flags = ($flags === NULL) ? $connect_flags : $flags;
|
||||||
|
|
||||||
if ($socket)
|
if ($socket)
|
||||||
$host = sprintf("%s:%s", $host, $socket);
|
$host = sprintf("%s:%s", $host, $socket);
|
||||||
else if ($port)
|
else if ($port)
|
||||||
$host = sprintf("%s:%s", $host, $port);
|
$host = sprintf("%s:%s", $host, $port);
|
||||||
|
|
||||||
if (!$link = mysql_connect($host, $user, $passwd, true)) {
|
if (!$link = mysql_connect($host, $user, $passwd, true, $flags)) {
|
||||||
printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n",
|
printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n",
|
||||||
$host, $user, $passwd,
|
$host, $user, $passwd,
|
||||||
mysql_errno(), mysql_error());
|
mysql_errno(), mysql_error());
|
||||||
|
@ -55,6 +58,7 @@ $db = getenv("MYSQL_TEST_DB") ? getenv("MYSQL_TEST_DB") : "test";
|
||||||
$engine = getenv("MYSQL_TEST_ENGINE") ? getenv("MYSQL_TEST_ENGINE") : "MyISAM";
|
$engine = getenv("MYSQL_TEST_ENGINE") ? getenv("MYSQL_TEST_ENGINE") : "MyISAM";
|
||||||
$socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null;
|
$socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null;
|
||||||
$skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true;
|
$skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true;
|
||||||
|
$connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0;
|
||||||
|
|
||||||
/* Development setting: test experimal features and/or feature requests that never worked before? */
|
/* Development setting: test experimal features and/or feature requests that never worked before? */
|
||||||
$TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
|
$TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
|
||||||
|
|
|
@ -6,7 +6,7 @@ if ($skip_on_connect_failure) {
|
||||||
else if ($port)
|
else if ($port)
|
||||||
$myhost = sprintf("%s:%s", $host, $port);
|
$myhost = sprintf("%s:%s", $host, $port);
|
||||||
|
|
||||||
if (!$link = @mysql_connect($myhost, $user, $passwd, true))
|
if (!$link = @mysql_connect($myhost, $user, $passwd, true, $connect_flags))
|
||||||
die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysql_errno(), mysql_error()));
|
die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysql_errno(), mysql_error()));
|
||||||
|
|
||||||
if (!@mysql_select_db($db, $link))
|
if (!@mysql_select_db($db, $link))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue